Documentation
¶
Overview ¶
Package claude is the brainjar Platform adapter for Claude Code. Imported for side effects from cmd/brainjar to register itself in the parent platform registry.
Index ¶
- type Platform
- func (c *Platform) Capabilities() platform.Capabilities
- func (c *Platform) HooksStatus(_ context.Context, scope platform.HookScope, projectRoot string) (platform.HookStatus, error)
- func (c *Platform) InstallHooks(_ context.Context, scope platform.HookScope, projectRoot string) error
- func (c *Platform) InstallMCP(_ context.Context, scope platform.HookScope, projectRoot, home string) error
- func (c *Platform) MCPStatus(_ context.Context, scope platform.HookScope, projectRoot, home string) (platform.MCPStatus, error)
- func (c *Platform) MapModelPrefs(prefs *models.ModelPrefs) map[string]any
- func (c *Platform) Name() string
- func (c *Platform) RemoveHooks(_ context.Context, scope platform.HookScope, projectRoot string) error
- func (c *Platform) RemoveMCP(_ context.Context, scope platform.HookScope, projectRoot string) error
- func (c *Platform) Spawn(ctx context.Context, prompt string, extraArgs []string) (*exec.Cmd, error)
- func (c *Platform) Sync(_ context.Context, prompt string, projectRoot string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Platform ¶
type Platform struct{}
Platform adapts brainjar to Claude Code. Writes composed prompts to `<projectRoot>/.claude/CLAUDE.md` inside a managed section, and keeps `.claude/settings.json` hooks in sync.
func (*Platform) Capabilities ¶
func (c *Platform) Capabilities() platform.Capabilities
Capabilities implements Platform. Claude supports every scope because the settings/config files have committed, gitignored-local, and user-global variants.
func (*Platform) HooksStatus ¶
func (c *Platform) HooksStatus(_ context.Context, scope platform.HookScope, projectRoot string) (platform.HookStatus, error)
HooksStatus reports whether the brainjar hook is installed at the requested scope and whether the installed command matches what Install would write now.
func (*Platform) InstallHooks ¶
func (c *Platform) InstallHooks(_ context.Context, scope platform.HookScope, projectRoot string) error
InstallHooks registers the brainjar UserPromptSubmit hook in `.claude/settings.json` at the requested scope. Existing user- authored hooks at any event are preserved. Re-invoking upserts — no duplicate entries.
func (*Platform) InstallMCP ¶
func (c *Platform) InstallMCP(_ context.Context, scope platform.HookScope, projectRoot, home string) error
InstallMCP registers brainjar as an MCP server in Claude's config at the requested scope. User and local scopes target ~/.claude.json; project scope targets <projectRoot>/.mcp.json. Everything else in the target file — including other MCP servers — is preserved.
func (*Platform) MCPStatus ¶
func (c *Platform) MCPStatus(_ context.Context, scope platform.HookScope, projectRoot, home string) (platform.MCPStatus, error)
MCPStatus reports whether brainjar is registered at the given scope and whether the stored command + args match what InstallMCP would write right now for the given home. Drift in --home is a real case (the user re-pointed their CLI at a different workspace), so home participates in the UpToDate check.
func (*Platform) MapModelPrefs ¶
func (c *Platform) MapModelPrefs(prefs *models.ModelPrefs) map[string]any
MapModelPrefs translates a generic ModelPrefs into a params map using current Claude model IDs. Unknown generic names pass through unchanged — a user who wrote a specific ID meant exactly that.
func (*Platform) RemoveHooks ¶
func (c *Platform) RemoveHooks(_ context.Context, scope platform.HookScope, projectRoot string) error
RemoveHooks strips brainjar-owned hook entries from the settings file at the requested scope while preserving everything else. If removing brainjar's hook leaves the file semantically empty, the file is deleted.
func (*Platform) RemoveMCP ¶
RemoveMCP strips brainjar's MCP entry from the target file at the requested scope. Empty parent objects are cleaned up. If removing brainjar leaves the entire settings file empty, the file is deleted.
func (*Platform) Spawn ¶
Spawn implements Platform. Builds an *exec.Cmd that runs `claude --append-system-prompt <prompt> [extraArgs...]`. Stdio is left nil so the caller can wire process streams; PATH lookup happens at Start() time, so a missing `claude` binary surfaces as exec.ErrNotFound to the caller (the CLI translates it to a friendly install hint).