Documentation
¶
Overview ¶
Package claudecode captures Claude Code activity through its command hooks.
Claude Code runs each configured hook command with a JSON description of the event on stdin (session_id, cwd, hook_event_name, plus event fields). `memspace hook claude` normalizes that into MemSpace events, spools them, and returns immediately; uploading happens in a detached sync process.
Index ¶
- Constants
- func ProjectDir(cwd string) string
- type Adapter
- func (a *Adapter) Capabilities() []string
- func (a *Adapter) Detect(ctx context.Context) adapter.Detection
- func (a *Adapter) Doctor(ctx context.Context, opts adapter.InstallOptions) []adapter.Check
- func (a *Adapter) Install(ctx context.Context, opts adapter.InstallOptions) error
- func (a *Adapter) MCPCheck(ctx context.Context) adapter.Check
- func (a *Adapter) Name() string
- func (a *Adapter) Normalize(raw []byte, now time.Time) ([]spool.Record, error)
- func (a *Adapter) RegisterMCP(ctx context.Context, opts adapter.MCPOptions) error
- func (a *Adapter) SettingsPath() string
- func (a *Adapter) Uninstall(ctx context.Context, out io.Writer) error
- func (a *Adapter) UnregisterMCP(ctx context.Context) error
Constants ¶
const AgentType = "claude-code"
AgentType is the agent_type stored on sessions.
const ProjectDirEnv = "CLAUDE_PROJECT_DIR"
ProjectDirEnv is set by Claude Code for hook commands: the directory the session was started in. DSH's hook bridge sets it too.
Variables ¶
This section is empty.
Functions ¶
func ProjectDir ¶
ProjectDir is the directory that identifies the session's project: the one the session was started in, not the hook's cwd, which follows the agent's cd and can be a subagent's temporary directory.
Types ¶
type Adapter ¶
type Adapter struct {
// ConfigDir overrides the Claude config dir (default $CLAUDE_CONFIG_DIR or ~/.claude).
ConfigDir string
}
Adapter implements adapter.Adapter for Claude Code.
func (*Adapter) Capabilities ¶
func (*Adapter) Normalize ¶
Normalize maps one hook invocation to MemSpace events. Unknown or uninteresting hook events yield no events.
func (*Adapter) RegisterMCP ¶
RegisterMCP adds MemSpace as a user-scoped stdio MCP server running the bridge (`memspace mcp stdio`), which reads this device's credentials itself, so Claude Code's configuration never contains the token.
func (*Adapter) SettingsPath ¶
SettingsPath is the user-level settings file hooks are installed into.