/** * claude-code adapter — appends the OpenLore instruction block to CLAUDE.md * (creating it if absent), registers the OpenLore MCP server in `.mcp.json` * (the project-scope file Claude Code actually reads for MCP), and adds a * SessionStart hook to `.claude/settings.json`. * * NB: Claude Code loads MCP servers only from `.mcp.json` (project), * `~/.claude.json`, or `claude mcp add` — never from `.claude/settings.json`. * Earlier versions wrote `mcpServers.openlore` to `settings.json`, so the * server never loaded; `apply` now migrates that stale entry away. */ import type { Adapter, ApplyContext } from './types.js'; /** * Each OpenLore hook group is marked with `_openlore: true` so we can identify * (and replace, or remove on uninstall) just our group without touching any * other hooks the user may have configured. Claude Code ignores unknown fields * on matcher groups. * * Two groups are wired: * - SessionStart → whole-repo orientation primer (`orient --json`). * - UserPromptSubmit → task-scoped injection (`orient --inject`), which runs * orient against the submitted prompt and injects a bounded, ignorable * block so the first turn begins already oriented * (change: add-task-scoped-context-injection). * * The keys and argv live here, SEPARATE from the formatted command, because uninstall needs * only the keys: it identifies our groups by the `_openlore` marker. Formatting a command on * that path would let an unformattable path (see `windowsCommandHazard`) throw during * REMOVAL, stranding the very hooks uninstall exists to take out * (change: harden-windows-hook-quoting). */ interface ManagedHook { key: string; args: readonly string[]; /** * An agent-loop moment (change: add-agent-loop-hook-surfaces). Its group carries * `_openloreHook: ` and is identified by that alone, so it never touches another * `_openlore` group on the same event (the opt-in `check-edit` PostToolUse hook). */ moment?: string; /** Tool-name matcher for tool events (the edit tools). */ matcher?: string; /** Hook timeout, in seconds. */ timeout?: number; } /** Exported so the Claude Code plugin's hooks are checked against the same moments (plugin-manifest.test.ts). */ export declare const MANAGED_HOOKS: ReadonlyArray; /** * The user-scope guard of a loop moment: outside a project with `.openlore/`, the hook exits before * Node starts. The session-start and prompt hooks do not get it: they are what sets OpenLore up in * a new repository or worktree (change: user-scope-loop-hooks). */ export declare const USER_SCOPE_PROJECT_GUARD = "[ -d \"${CLAUDE_PROJECT_DIR:-.}/.openlore\" ] || exit 0; "; /** * Test seam for the compare-and-swap contract. * * The race it guards — a running Claude Code rewriting `~/.claude.json` between our * read and our write — cannot be scheduled deterministically from outside, and a * test that races the real scheduler asserts nothing. This exposes the exact * question instead: given the bytes we observed, does a publication whose target * has since changed refuse, and leave the change intact? */ export declare function _publishManagedFileForTesting(ctx: ApplyContext, path: string, data: string, observedRaw: string | null): Promise<{ ok: true; } | { ok: false; reason: string; }>; export declare const claudeCodeAdapter: Adapter; export {}; //# sourceMappingURL=claude-code.d.ts.map