claude

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2026 License: MIT Imports: 14 Imported by: 0

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

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) Catalog added in v0.6.0

func (c *Platform) Catalog() platform.ModelCatalog

Catalog satisfies platform.Platform.

func (*Platform) EmitSkills added in v0.6.0

func (c *Platform) EmitSkills(_ context.Context, projectRoot string, skills []platform.SkillEmit) (platform.SkillEmitResult, error)

EmitSkills writes each Skill in skills to Claude's per-scope skill directory, splitting on Scope. Brainjar-owned skill dirs whose slug isn't in the incoming set are pruned at each scope; user-authored dirs (no .brainjar-managed marker) are left alone.

projectRoot is required when any incoming skill has SkillScopeProject — there's no sane default for "where the project lives" inside the adapter. User scope always resolves to os.UserHomeDir.

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 delegates to the catalog-backed canonical helper. Unknown generic names pass through unchanged — a user who wrote a specific ID meant exactly that.

func (*Platform) ModelArgs added in v0.6.0

func (c *Platform) ModelArgs(prefs *models.ModelPrefs) []string

ModelArgs renders prefs as argv for `claude` — only `--model <id>` today; temperature and max_tokens aren't exposed as Claude Code CLI flags (they live in API requests, not session config). The caller prepends the result so user-supplied `-- --model X` still wins.

func (*Platform) Name

func (c *Platform) Name() string

Name implements Platform.

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

func (c *Platform) RemoveMCP(_ context.Context, scope platform.HookScope, projectRoot string) error

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) SkillsStatus added in v0.6.0

func (c *Platform) SkillsStatus(_ context.Context, projectRoot string) (platform.SkillsStatus, error)

SkillsStatus walks Claude's per-scope skill dirs and reports every brainjar-managed skill currently on disk. Subdirs without the marker file are skipped (those are user-authored, not brainjar's business to enumerate). Version is read from the marker file's `version:` line so callers don't need to re-parse the SKILL.md frontmatter.

func (*Platform) Spawn

func (c *Platform) Spawn(ctx context.Context, prompt string, extraArgs []string) (*exec.Cmd, error)

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).

func (*Platform) Sync

func (c *Platform) Sync(_ context.Context, prompt string, projectRoot string) error

Sync writes prompt into the managed section of CLAUDE.md, creating the `.claude/` directory and file as needed. User content outside the managed section is preserved byte-for-byte. If the file already contains a managed section with matching content, Sync is a no-op.

func (*Platform) SyncRemove added in v0.7.0

func (c *Platform) SyncRemove(_ context.Context, projectRoot string) error

SyncRemove strips brainjar's managed section from the project's CLAUDE.md. If the file is empty (or only contained the managed section) after the strip, the file is removed. Missing file is a no-op.

func (*Platform) SyncUser added in v0.7.0

func (c *Platform) SyncUser(_ context.Context, prompt string) error

SyncUser writes prompt into ~/.claude/CLAUDE.md.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL