Documentation
¶
Overview ¶
internal/migrate/catalog.go
internal/migrate/detect_agentfiles.go
internal/migrate/detect_docs.go
internal/migrate/detector.go
Index ¶
- Constants
- func ClearManifest(contexoDir string) error
- func DefaultCloner(url, dest string) error
- func IsGitURL(s string) bool
- func LabelFor(dir string) string
- func ManifestPath(contexoDir string) string
- func ResolveExternal(from, contexoDir string, clone Cloner) (scanDir, cacheDir string, err error)
- func SaveManifest(contexoDir string, m *Manifest) error
- func Slugify(s string) string
- type Candidate
- type Catalog
- type Cloner
- type Detector
- type Manifest
- type ManifestItem
- type RenderOpts
Constants ¶
const CatalogRenderCap = 100
CatalogRenderCap bounds how many rows a rendered catalog / directive shows before summarizing the remainder, so a huge KB never floods the terminal or the MCP tool output.
Variables ¶
This section is empty.
Functions ¶
func ClearManifest ¶
ClearManifest removes the manifest file and best-effort removes any external clone cache it referenced.
func DefaultCloner ¶
DefaultCloner shells out to git with an argument slice (never a shell string).
func ManifestPath ¶
func ResolveExternal ¶
ResolveExternal turns a --from value into a local directory to scan. For a URL it clones into .contexo/.migrate-cache/<hash> and returns that as both scanDir and cacheDir (so the caller records it for later cleanup).
func SaveManifest ¶
Types ¶
type Candidate ¶
type Candidate struct {
ID int
Detector string
SourceRoot string
AbsPath string
RelPath string
Title string
Preview string
EstTokens int
SuggestedType schema.PageType
SuggestedSlug string
AlreadyImported bool
}
Candidate is one discovered knowledge item. Detectors fill everything except ID (assigned by Catalog.Build after ordering) and AlreadyImported (set by Build against the local .contexo/ store).
type Catalog ¶
type Catalog struct{ Items []Candidate }
Catalog is an ordered, numbered set of discovered candidates.
func Build ¶
Build runs each detector over scanDir, dedups by AbsPath (earlier detector wins), orders deterministically, assigns 1-based IDs, and flags candidates whose SuggestedSlug already exists under contexoDir.
func NewCatalog ¶
NewCatalog finalizes a pre-ordered candidate slice into a Catalog: it assigns 1-based IDs in the given order (no reordering) and flags AlreadyImported. Build uses it after its own dedup+sort; generate uses it directly on adapter-produced candidates.
func (Catalog) Filter ¶
Filter keeps items matching typ (SuggestedType) and/or detector name; empty strings match everything. IDs are renumbered 1..n so selection stays contiguous.
func (Catalog) Render ¶
func (c Catalog) Render(w io.Writer, opts RenderOpts)
Render writes the catalog to w.
The signature stays (io.Writer, RenderOpts) on purpose: cli/migrate.go and cli/generate.go call it, and catalog_test.go hands it a bare *bytes.Buffer, so widening it would break a test in another package. Styling is therefore resolved INSIDE, from w, via ui.Plain — which yields the plain text again for any non-terminal sink, so the golden test output is unchanged.
Note this is CLI-only. The MCP tool path does NOT come through here; it builds its own catalog text in mcp/migrate.go and mcp/generate.go. The two renderers are duplicated and drift independently.
type Detector ¶
Detector recognizes a knowledge format under root and enumerates its items. A Detector that does not recognize root returns (nil, nil), not an error.
func DefaultDetectors ¶
func DefaultDetectors() []Detector
DefaultDetectors returns the v1 detector set in registration order. Order is load-bearing: it decides dedup precedence and render grouping.
type Manifest ¶
type Manifest struct {
Version int `json:"version"`
Created string `json:"created"`
SourceRoot string `json:"source_root"`
ExternalCache string `json:"external_cache,omitempty"`
Label string `json:"label"`
Kind string `json:"kind,omitempty"` // "migrate" (default) | "generate"
Items []ManifestItem `json:"items"`
}
Manifest is the pending-migration handoff written by the CLI picker and consumed by the ctx_migrate MCP tool.
func LoadManifest ¶
LoadManifest returns the pending manifest, or (nil, nil) if none exists.
type ManifestItem ¶
type ManifestItem struct {
AbsPath string `json:"abs_path"`
RelPath string `json:"rel_path"`
Detector string `json:"detector"`
SuggestedType schema.PageType `json:"suggested_type"`
SuggestedSlug string `json:"suggested_slug"`
}
ManifestItem is one staged source awaiting agent distillation.
type RenderOpts ¶
type RenderOpts struct{ Max int }
RenderOpts controls Render. Max caps how many rows print (0 = all).