* feat(help): Add CLI help command Fixes #136 * chore: remove binary * feat(mcp): Add TCP transport Fixes #126 * feat(io): Migrate pkg/mcp to use Medium abstraction Fixes #103 * chore(io): Migrate internal/cmd/docs/* to Medium abstraction Fixes #113 * chore(io): Migrate internal/cmd/dev/* to Medium abstraction Fixes #114 * chore(io): Migrate internal/cmd/setup/* to Medium abstraction * chore(io): Complete migration of internal/cmd/dev/* to Medium abstraction * chore(io): Migrate internal/cmd/sdk, pkgcmd, and workspace to Medium abstraction * style: fix formatting in internal/variants Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor(io): simplify local Medium implementation Rewrote to match the simpler TypeScript pattern: - path() sanitizes and returns string directly - Each method calls path() once - No complex symlink validation - Less code, less attack surface Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test(mcp): update sandboxing tests for simplified Medium The simplified io/local.Medium implementation: - Sanitizes .. to . (no error, path is cleaned) - Allows absolute paths through (caller validates if needed) - Follows symlinks (no traversal blocking) Update tests to match this simplified behavior. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(updater): resolve PkgVersion duplicate declaration Remove var PkgVersion from updater.go since go generate creates const PkgVersion in version.go. Track version.go in git to ensure builds work without running go generate first. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
87 lines
1.6 KiB
Go
87 lines
1.6 KiB
Go
package help
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// Catalog manages help topics.
|
|
type Catalog struct {
|
|
topics map[string]*Topic
|
|
index *searchIndex
|
|
}
|
|
|
|
// DefaultCatalog returns a catalog with built-in topics.
|
|
func DefaultCatalog() *Catalog {
|
|
c := &Catalog{
|
|
topics: make(map[string]*Topic),
|
|
index: newSearchIndex(),
|
|
}
|
|
|
|
// Add default topics
|
|
c.Add(&Topic{
|
|
ID: "getting-started",
|
|
Title: "Getting Started",
|
|
Content: `# Getting Started
|
|
|
|
Welcome to Core! This CLI tool helps you manage development workflows.
|
|
|
|
## Common Commands
|
|
|
|
- core dev: Development workflows
|
|
- core setup: Setup repository
|
|
- core doctor: Check environment health
|
|
- core test: Run tests
|
|
|
|
## Next Steps
|
|
|
|
Run 'core help <topic>' to learn more about a specific topic.
|
|
`,
|
|
})
|
|
c.Add(&Topic{
|
|
ID: "config",
|
|
Title: "Configuration",
|
|
Content: `# Configuration
|
|
|
|
Core is configured via environment variables and config files.
|
|
|
|
## Environment Variables
|
|
|
|
- CORE_DEBUG: Enable debug logging
|
|
- GITHUB_TOKEN: GitHub API token
|
|
|
|
## Config Files
|
|
|
|
Config is stored in ~/.core/config.yaml
|
|
`,
|
|
})
|
|
return c
|
|
}
|
|
|
|
// Add adds a topic to the catalog.
|
|
func (c *Catalog) Add(t *Topic) {
|
|
c.topics[t.ID] = t
|
|
c.index.Add(t)
|
|
}
|
|
|
|
// List returns all topics.
|
|
func (c *Catalog) List() []*Topic {
|
|
var list []*Topic
|
|
for _, t := range c.topics {
|
|
list = append(list, t)
|
|
}
|
|
return list
|
|
}
|
|
|
|
// Search searches for topics.
|
|
func (c *Catalog) Search(query string) []*SearchResult {
|
|
return c.index.Search(query)
|
|
}
|
|
|
|
// Get returns a topic by ID.
|
|
func (c *Catalog) Get(id string) (*Topic, error) {
|
|
t, ok := c.topics[id]
|
|
if !ok {
|
|
return nil, fmt.Errorf("topic not found: %s", id)
|
|
}
|
|
return t, nil
|
|
}
|