cairn-ai 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/workflows/cairn-memory.md +1 -1
- package/.agents/workflows/cairn-plan.md +6 -2
- package/.agents/workflows/cairn-review.md +1 -1
- package/.agents/workflows/cairn-work.md +5 -1
- package/.claude/agents/explorer.md +1 -1
- package/.claude/agents/worker.md +1 -1
- package/.codex-plugin/plugin.json +4 -4
- package/README.ko.md +2 -0
- package/README.md +8 -4
- package/agents/explorer.md +2 -2
- package/agents/worker.md +6 -2
- package/commands/cairn-memory.md +1 -1
- package/commands/cairn-plan.md +7 -3
- package/commands/cairn-review.md +1 -1
- package/commands/cairn-uninstall.md +1 -1
- package/commands/cairn-work.md +5 -1
- package/docs/model-guidance/README.md +14 -2
- package/docs/model-guidance/claude.md +2 -0
- package/docs/model-guidance/codex.md +3 -1
- package/package.json +2 -2
- package/scripts/cairn-cleanup.mjs +61 -0
- package/scripts/cairn-goal.mjs +143 -24
- package/scripts/cairn-lifecycle.mjs +118 -28
- package/scripts/cairn-paths.mjs +47 -1
- package/scripts/cairn-state.mjs +41 -15
- package/scripts/cairn-state.sh +6 -6
- package/scripts/cairn.mjs +32 -24
- package/skills/cairn-memory/SKILL.md +3 -3
- package/skills/cairn-plan/SKILL.md +28 -9
- package/skills/cairn-review/SKILL.md +4 -4
- package/skills/cairn-work/SKILL.md +33 -20
- package/templates/PLAN.md +3 -1
- package/templates/work-plan.md +21 -0
|
@@ -9,7 +9,7 @@ Goal: create or update repository memory without asking the user for discoverabl
|
|
|
9
9
|
Procedure:
|
|
10
10
|
|
|
11
11
|
1. Ensure `MEMORY.md`, `PLAN.md`, `docs/memory`, and `docs/plan`.
|
|
12
|
-
2. Every agent
|
|
12
|
+
2. Every agent reads project-root `MEMORY.md` when present and continues without repository memory when absent before assigned discovery or update work.
|
|
13
13
|
3. Explore repository facts with focused tools.
|
|
14
14
|
4. Use `explorer` for read-only domain discovery and contradiction checks when available; use `worker` for exact references, command checks, and bounded evidence capture. When subagent tools are available, each agent may recursively delegate bounded sub-tasks to subagents. Tell every delegated agent and child subagent to read the project-root `MEMORY.md` before work, keep scope, and preserve others' edits.
|
|
15
15
|
5. Write details to `docs/memory/<domain>.md`.
|
|
@@ -6,10 +6,14 @@ Read the installed Cairn runtime locator at `{{CAIRN_RUNTIME_LOCATOR_JSON}}`. Re
|
|
|
6
6
|
|
|
7
7
|
Goal: write an initial plan with triage as its active task before exploration, persist the goal/roadmap, then update the same plan to a decision-complete implementation revision after triage.
|
|
8
8
|
|
|
9
|
+
Complexity triage has a provisional request checkpoint, post-exploration planning checkpoint, and code checkpoint after exact file/caller/test inspection immediately before the first edit. Before editing, evidence may change either route. Every change must synchronize the plan artifact, repository goal task roadmap through `goal replan`, and native UI plan, including reviews and required evidence. After editing begins, a new Heavy Path signal promotes Light Path to Heavy Path: stop further edits, mark affected evidence stale, synchronize all three roadmaps, and repeat the code checkpoint.
|
|
10
|
+
|
|
11
|
+
Models always inherit. Route reasoning effort per task: Light planning/implementation/verification=`medium`; Heavy planning/review/implementation=`high`; final verification/review=`xhigh`. Record requested/effective effort for every task. Only a new task/worker may receive requested effort through a supported host-native option; unsupported host/value means effective=`inherited` with no model/global config change. Route changes synchronize the plan artifact, repository goal task roadmap, native UI plan, and reasoning effort profile; preserve completed profiles and recalculate incomplete profiles.
|
|
12
|
+
|
|
9
13
|
Procedure:
|
|
10
14
|
|
|
11
|
-
1. Every agent
|
|
12
|
-
2. For implementation or
|
|
15
|
+
1. Every agent reads project-root `MEMORY.md` when present and continues without repository memory when absent before repository exploration, tool selection, work, or delegation.
|
|
16
|
+
2. Keep routine known-target Git/GitHub operations plan/goal-free unless they require code edits, conflict resolution, destructive recovery, release/deploy, or design. For non-trivial implementation or continuation of planned work, write the initial repository plan and `PLAN.md` entry from the request and `MEMORY.md`. Include a planned `triage-plan` task and anticipated execution/verification stages, then start or attach the repository Cairn goal before exploration.
|
|
13
17
|
3. When the surface exposes native plan/goal UI tools, synchronize the same roadmap there before exploration; otherwise record that those tools are unavailable.
|
|
14
18
|
4. Read relevant `docs/memory/*.md` and perform toolcheck, exploration, and Light/Heavy Path triage according to the initial task.
|
|
15
19
|
5. Update the same plan to a decision-complete implementation revision before implementation.
|
|
@@ -8,7 +8,7 @@ Goal: review completed work against plan, memory, policy, and evidence.
|
|
|
8
8
|
|
|
9
9
|
Procedure:
|
|
10
10
|
|
|
11
|
-
1. Every agent
|
|
11
|
+
1. Every agent reads project-root `MEMORY.md` when present and continues without repository memory when absent before review work, then reads the plan task and available memory inputs.
|
|
12
12
|
2. Check changed files, tool readiness evidence, and verification evidence.
|
|
13
13
|
3. Delegate independent read-only review to `explorer` when it materially improves speed or quality; use `worker` only for scoped verification reruns or QA artifacts. When subagent tools are available, each agent may recursively delegate bounded sub-tasks to subagents. Tell every delegated agent and child subagent to read the project-root `MEMORY.md` before work, keep scope, and preserve others' edits.
|
|
14
14
|
4. Report findings first, ordered by severity, with file and line references. If no issues are found, say so clearly and mention remaining test gaps or residual risk.
|
|
@@ -6,9 +6,13 @@ Read the installed Cairn runtime locator at `{{CAIRN_RUNTIME_LOCATOR_JSON}}`. Re
|
|
|
6
6
|
|
|
7
7
|
Goal: execute the next incomplete module task in `PLAN.md` without bypassing the recorded complexity triage.
|
|
8
8
|
|
|
9
|
+
Confirm the provisional request checkpoint and post-exploration planning checkpoint, then record the code checkpoint after exact file/caller/test inspection immediately before the first edit. Before editing, evidence may change either route. Every change must synchronize the plan artifact, repository goal task roadmap through `goal replan`, and native UI plan, including reviews and required evidence. After editing begins, a new Heavy Path signal promotes Light Path to Heavy Path: stop further edits, mark affected evidence stale, synchronize all three roadmaps, and repeat the code checkpoint.
|
|
10
|
+
|
|
11
|
+
Models always inherit. Route reasoning effort per task: Light planning/implementation/verification=`medium`; Heavy planning/review/implementation=`high`; final verification/review=`xhigh`. Record requested/effective effort for every task. Only a new task/worker may receive requested effort through a supported host-native option; unsupported host/value means effective=`inherited` with no model/global config change. Route changes synchronize the plan artifact, repository goal task roadmap, native UI plan, and reasoning effort profile; preserve completed profiles and recalculate incomplete profiles.
|
|
12
|
+
|
|
9
13
|
Procedure:
|
|
10
14
|
|
|
11
|
-
1. Every agent
|
|
15
|
+
1. Every agent reads project-root `MEMORY.md` when present and continues without repository memory when absent before selecting or executing a task.
|
|
12
16
|
2. Read `PLAN.md`, the detailed plan, and relevant memory notes.
|
|
13
17
|
3. Read the Codex or Claude model guidance recorded in the plan.
|
|
14
18
|
4. Select one small module task.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Read-only discovery agent for codebase questions, impact analysis, pattern search, and verification.
|
|
4
4
|
|
|
5
|
-
Before any task, read
|
|
5
|
+
Before any task, read project-root `MEMORY.md` when present; continue without repository memory when absent.
|
|
6
6
|
|
|
7
7
|
Read the installed Cairn runtime locator at `{{CAIRN_RUNTIME_LOCATOR_JSON}}`. Resolve `resources.agents` from that JSON object and follow `explorer.md` in that directory. Do not resolve Cairn agent files from the target project.
|
package/.claude/agents/worker.md
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Focused execution agent for search, small edits, command checks, and QA artifacts.
|
|
4
4
|
|
|
5
|
-
Before any task, read
|
|
5
|
+
Before any task, read project-root `MEMORY.md` when present; continue without repository memory when absent.
|
|
6
6
|
|
|
7
7
|
Read the installed Cairn runtime locator at `{{CAIRN_RUNTIME_LOCATOR_JSON}}`. Resolve `resources.agents` from that JSON object and follow `worker.md` in that directory. Do not resolve Cairn agent files from the target project.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cairn",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Token-efficient agent harness with tool readiness for Codex, Claude Code, and Antigravity.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "WkNam"
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"Tool Readiness"
|
|
22
22
|
],
|
|
23
23
|
"defaultPrompt": [
|
|
24
|
-
"Use Cairn's repository-local
|
|
24
|
+
"Use Cairn's repository-local PLAN.md and persisted goal state as the recovery spine; read root MEMORY.md first when it exists, and continue without repository memory when it does not.",
|
|
25
25
|
"For non-trivial work, load the phase skill (cairn-plan, cairn-work, or cairn-review), then restore the active plan and current-task references before acting.",
|
|
26
|
-
"After compaction, restart, handoff, or delegation, restore MEMORY.md → phase skill → active plan → current task references; do not rely on conversation recall.",
|
|
27
|
-
"
|
|
26
|
+
"After compaction, restart, handoff, or delegation, restore optional MEMORY.md → phase skill → active plan → current task references; do not rely on conversation recall.",
|
|
27
|
+
"A missing MEMORY.md never blocks work; fail closed only when active state, its skill, plan, or a required task reference is missing, unreadable, or inconsistent.",
|
|
28
28
|
"Missing, failed, skipped, stale, or placeholder evidence never completes work; advance UI state only after bound repository evidence passes.",
|
|
29
29
|
"Before external-state changes, run dry-run/check and bind the resulting evidence to the current task.",
|
|
30
30
|
"Answer side questions briefly, then resume the current task unless asked to pause, stop, or switch."
|
package/README.ko.md
CHANGED
|
@@ -28,6 +28,8 @@ Cairn은 실행 정책에서는 LazyCodex와 다릅니다. LazyCodex의 role-cha
|
|
|
28
28
|
|
|
29
29
|
선택된 path와 근거는 계획 산출물이 있을 때 `docs/plan/<topic>.md`에 기록합니다. Light Path에서도 두 검증 게이트는 유지됩니다. subagent 도구가 없으면 main agent가 implementation을 직접 인계하고, 그 takeover를 evidence에 기록합니다.
|
|
30
30
|
|
|
31
|
+
Cairn은 host/user model을 상속하고 reasoning effort만 라우팅합니다. Light 계획·구현·검증은 `medium`, Heavy 계획·검토·구현은 `high`, 최종 검증·검토는 `xhigh`를 요청합니다. 각 task는 requested/effective effort를 기록하며, 새로 dispatch하는 task/worker에만 host가 지원하는 effort option을 전달합니다. 미지원 host/value는 model/global config를 바꾸지 않고 `effective: inherited`로 남깁니다. path가 바뀌면 plan artifact, 저장소 goal task roadmap, native UI plan, effort profile을 함께 동기화하고 완료 profile은 보존하며 미완료 profile은 재계산합니다.
|
|
32
|
+
|
|
31
33
|
subagent 도구가 progress-reporting channel을 제공하면 subagent는 작업 시작, 방향 결정/확인, 주기적 진행, 완료 시점에 orchestrator에게 상태를 보고합니다. orchestrator는 받은 status event를 즉시 사용자에게 전달합니다. mid-run reporting channel이 없으면 orchestrator는 할당, 대기, 최종 완료처럼 관측 가능한 event를 사용자에게 전달합니다.
|
|
32
34
|
|
|
33
35
|
위임받은 subagent는 작업을 마치면 퇴근 전에 final report를 남깁니다. orchestrator가 final report와 evidence를 회수한 뒤 완료된 subagent를 close/release합니다. 그 다음 orchestrator가 final report와 evidence를 검토한 뒤 작업 완료 여부를 판단합니다.
|
package/README.md
CHANGED
|
@@ -36,6 +36,8 @@ Every implementation task passes complexity triage first, before agent, plugin,
|
|
|
36
36
|
|
|
37
37
|
The selected path and rationale are recorded in `docs/plan/<topic>.md` when a plan artifact exists. Even on Light Path, the two verification gates remain. If subagent tools are unavailable, the main agent takes over implementation directly and records that takeover in evidence.
|
|
38
38
|
|
|
39
|
+
Cairn inherits the host/user model and routes only reasoning effort. Light planning, implementation, and verification request `medium`; Heavy planning, review, and implementation request `high`; final verification/review requests `xhigh`. Each task records requested and effective effort. Only a newly dispatched task/worker may receive a host-supported effort option. Unsupported hosts or values remain `effective: inherited` without changing model/global config. When the path changes, the plan artifact, repository goal task roadmap, native UI plan, and effort profile are synchronized together; completed profiles are preserved and incomplete profiles are recalculated.
|
|
40
|
+
|
|
39
41
|
When the subagent tool provides a progress-reporting channel, subagents report status to the orchestrator when starting work, when deciding or confirming direction, during periodic progress, and when finishing. The orchestrator immediately relays received status events to the user. If no mid-run reporting channel exists, the orchestrator relays observable events such as assignment, waiting, and final completion.
|
|
40
42
|
|
|
41
43
|
When a delegated subagent finishes, it provides a final report before leaving. After the orchestrator captures that final report and evidence, the completed subagent is closed or released. The orchestrator then reviews the final report and evidence before marking the work complete.
|
|
@@ -81,7 +83,7 @@ The harness creates and maintains these files at the target repository root.
|
|
|
81
83
|
- `docs/memory/*.md`: detailed knowledge by domain.
|
|
82
84
|
- `PLAN.md`: short index of active and completed work topics.
|
|
83
85
|
- `docs/plan/*.md`: detailed execution plans.
|
|
84
|
-
-
|
|
86
|
+
- `~/.cairn/projects/<project-id>/worktrees/<worktree-id>/state.json`: user-home, project/worktree-scoped active goal/task/evidence state used for interruption recovery and scoped stop gates. The project working tree does not own runtime state.
|
|
85
87
|
|
|
86
88
|
Runtime scripts, templates, commands, agents, and model guidance stay in the installed plugin root. Runtime locator files let Codex, Claude Code, and Antigravity share that installed copy without copying Cairn internals into the target repository.
|
|
87
89
|
|
|
@@ -113,19 +115,21 @@ cairn toolcheck
|
|
|
113
115
|
- `cairn doctor`: validates the ownership manifest, managed digests, effective Codex features, actual installed/enabled/version plugin state, and mirror/runtime locators without repairing them.
|
|
114
116
|
- `cairn uninstall`: removes or restores only ownership-manifest entries that remain unmodified, then prunes empty managed cache scaffolds; modified or unmanaged targets and their parent directories are preserved, and pre-commit failures roll back.
|
|
115
117
|
- `cairn toolcheck`: detects repository stacks and checks required LSP and verification tools; installation runs only for an approved supported installer.
|
|
116
|
-
- `cairn
|
|
118
|
+
- `cairn cleanup --root <repo>`: reports legacy project-local `.cairn` residue by default; `--yes` migrates/reconciles state into the user-home store, removes only known Cairn state/lock/tool residue, preserves unknown files, and prunes the directory only when empty.
|
|
119
|
+
- `cairn goal ...`: starts, inspects, pauses, resumes, blocks, cancels, and completes a persisted repository goal. State lives under user-home `.cairn`, separated by repository and Git worktree; state without `worktreeId` and state copied from another worktree are stale and removed on the next hook/goal start. Successful completion or cancellation removes active state because completed evidence already lives in the plan document, while paused/blocked state remains resumable. The default tool-bound policy records successful evidence by executing `goal verify -- <argv>`. The legacy `goal receipt` command imports declared evidence only.
|
|
120
|
+
- `cairn cleanup --root <repo>`: inspects legacy project-local `.cairn` residue without changing it. Add `--yes` to remove known Cairn residue; unknown entries are preserved and reported.
|
|
117
121
|
- `cairn-memory`: explores domain knowledge and updates `MEMORY.md`.
|
|
118
122
|
- `cairn-plan`: creates a decision-complete plan under `docs/plan/`.
|
|
119
123
|
- `cairn-work`: executes the next module task in the current `PLAN.md` with two verification gates.
|
|
120
124
|
- `cairn-review`: reviews completed tasks against plan, memory, and evidence.
|
|
121
125
|
|
|
122
|
-
On every `UserPromptSubmit`, Cairn injects model-visible guidance that
|
|
126
|
+
On every `UserPromptSubmit`, Cairn injects model-visible guidance that non-trivial implementation or continuation of planned work authorizes goal creation even if the user never says “goal.” Routine known-target Git/GitHub operations—status, fetch, checkout, branch, merge, push, and PR management—stay plan/goal-free unless they require code edits, conflict resolution, destructive recovery, release/deploy, or design. For planned work, the agent first writes an initial repository plan with triage as the active task, synchronizes the roadmap before exploration, and updates it to a decision-complete revision before implementation. An active goal keeps the ordered roadmap and current task in hook context so a side question returns to the original work. Consultation, explanation, and plan-only requests also remain goal-free.
|
|
123
127
|
|
|
124
128
|
For token-efficient execution, Cairn puts reasoning into a focused executable test contract—requirements, invariants, boundaries, and failure modes—before implementation. Implementation receives the failing contract and bounded file scope, then makes the minimum passing change. Tool exit codes and machine summaries decide success; successful output stays concise and only failures expand context. Verification climbs from focused tests to one final full check. Before package verification, inspect lifecycle scripts and run normal `npm pack --dry-run` by default: content-producing or unknown scripts must never use `--ignore-scripts`; only absent or proven content-neutral scripts may use it while the full-check evidence remains fresh. Successful state mutations support `--quiet` so growing goal JSON does not consume the conversation budget.
|
|
125
129
|
|
|
126
130
|
Install and upgrade keep the custom marketplace lifecycle; they do not invoke `codex plugin add`. Candidates are staged and validated before commit, every managed destination and digest is recorded in an ownership manifest, and committed phases roll back in reverse order on failure. An exact unmodified supported legacy installation can be adopted after release-integrity validation; modified or unknown artifacts are preserved and rejected. Cairn edits only its own TOML sections and never forces public feature or agent settings. The source plugin manifest stays validator-friendly; only the installed cache copy gets a `hooks` field. Lifecycle commands must run from the published/global package, not from the cached copy that they replace.
|
|
127
131
|
|
|
128
|
-
Clean uninstall removes the Cairn marketplace cache root only when every managed scaffold is empty, using empty-directory removal rather than recursive deletion. It does not delete the source repository
|
|
132
|
+
Clean uninstall removes the Cairn marketplace cache root only when every managed scaffold is empty, using empty-directory removal rather than recursive deletion. It does not delete the source repository, repository `MEMORY.md`/`PLAN.md`, user-home Cairn goal state, the global `cairn-ai` package, package-manager download caches, legacy backups, or legacy shared settings outside the current ownership manifest; those require a separate explicit cleanup decision.
|
|
129
133
|
|
|
130
134
|
Codex uses `skills/` and `commands/`. Claude Code uses mirrored commands and agent definitions under `.claude/`. Antigravity uses `.agents/workflows` and global skills mirrors.
|
|
131
135
|
|
package/agents/explorer.md
CHANGED
|
@@ -8,11 +8,11 @@ tools: Read, Grep, Glob, Bash
|
|
|
8
8
|
|
|
9
9
|
Handle read-only discovery and verification tasks.
|
|
10
10
|
|
|
11
|
-
Before
|
|
11
|
+
Before an assigned task, read project-root `MEMORY.md` when present. If absent, continue without repository memory and do not invoke another memory service; then read only relevant `docs/memory/*.md` notes that exist.
|
|
12
12
|
|
|
13
13
|
At the start and after compaction, restart, or handoff, restore context in this order: root `MEMORY.md` → the phase skill named by the assignment → the active plan → current-task references → model guidance recorded by that plan. The assignment must identify the plan and current task whenever persisted work is active. If a required reference is missing, unreadable, or inconsistent with the assignment or goal state, report a blocker and do not perform the assigned discovery or delegate it.
|
|
14
14
|
|
|
15
|
-
When subagent tools are available, you may recursively delegate bounded read-only sub-tasks to subagents. Every child subagent
|
|
15
|
+
When subagent tools are available, you may recursively delegate bounded read-only sub-tasks to subagents. Every child subagent reads project-root `MEMORY.md` when present and continues when absent, keeps the assigned scope, and preserves others' edits.
|
|
16
16
|
|
|
17
17
|
Use for:
|
|
18
18
|
|
package/agents/worker.md
CHANGED
|
@@ -8,11 +8,11 @@ tools: Read, Grep, Glob, Bash, Write, Edit, MultiEdit
|
|
|
8
8
|
|
|
9
9
|
Handle narrow, focused tasks.
|
|
10
10
|
|
|
11
|
-
Before
|
|
11
|
+
Before an assigned task, read project-root `MEMORY.md` when present. If absent, continue without repository memory and do not invoke another memory service; then read only relevant `docs/memory/*.md` notes that exist.
|
|
12
12
|
|
|
13
13
|
At the start and after compaction, restart, or handoff, restore context in this order: root `MEMORY.md` → the phase skill named by the assignment → the active plan → current-task references → model guidance recorded by that plan. The assignment must identify the plan and current task whenever persisted work is active. If a required reference is missing, unreadable, or inconsistent with the assignment or goal state, report a blocker and do not edit, delegate, or claim completion.
|
|
14
14
|
|
|
15
|
-
When subagent tools are available, you may recursively delegate bounded sub-tasks to subagents. Every child subagent
|
|
15
|
+
When subagent tools are available, you may recursively delegate bounded sub-tasks to subagents. Every child subagent reads project-root `MEMORY.md` when present and continues when absent, keeps the assigned scope, and preserves others' edits.
|
|
16
16
|
|
|
17
17
|
Use for:
|
|
18
18
|
|
|
@@ -25,6 +25,10 @@ Use for:
|
|
|
25
25
|
|
|
26
26
|
Do not make architecture decisions. Do not ask the user. Do not delegate vague or unbounded work. Do not treat a missing tool as unavailable until install or bootstrap has been attempted. Report only important paths, commands, and outputs accurately.
|
|
27
27
|
|
|
28
|
+
Before the first edit, inspect the assigned exact files, callers, and tests and report evidence for the plan's code checkpoint. If you discover a new Heavy Path signal before or during implementation, stop further edits and report it to the orchestrator so the plan artifact, repository goal task roadmap, native UI plan, review requirements, and stale evidence can be updated. Resume only after a new code checkpoint is recorded.
|
|
29
|
+
|
|
30
|
+
Keep the model inherited. Read the task's `Requested reasoning effort` and `Effective reasoning effort`. A newly delegated task or new worker may receive requested effort only through a host-exposed task/subagent reasoning-effort option or host-native equivalent; omit model overrides. If the host or value is unsupported, report effective reasoning effort `inherited` and do not alter model/global config.
|
|
31
|
+
|
|
28
32
|
Use this prompt format:
|
|
29
33
|
|
|
30
34
|
```text
|
package/commands/cairn-memory.md
CHANGED
|
@@ -9,7 +9,7 @@ Goal: create or update repository memory without asking the user for discoverabl
|
|
|
9
9
|
Procedure:
|
|
10
10
|
|
|
11
11
|
1. Run the installed plugin state initialization script with an explicit target `--root`.
|
|
12
|
-
2. Every agent
|
|
12
|
+
2. Every agent reads project-root `MEMORY.md` when present and continues without repository memory when absent before assigned discovery or update work.
|
|
13
13
|
3. Explore repository facts with focused tools.
|
|
14
14
|
4. Use `explorer` for read-only domain discovery and contradiction checks when available; use `worker` for exact references, command checks, and bounded evidence capture. When subagent tools are available, each agent may recursively delegate bounded sub-tasks to subagents. Tell every delegated agent and child subagent to read the project-root `MEMORY.md` before work, keep scope, and preserve others' edits.
|
|
15
15
|
5. Write details to `docs/memory/<domain>.md`.
|
package/commands/cairn-plan.md
CHANGED
|
@@ -6,11 +6,15 @@ Prerequisite: resolve the installed Cairn runtime from the plugin or skill locat
|
|
|
6
6
|
|
|
7
7
|
Goal: show an initial plan and goal before triage can be interrupted, then leave a decision-complete implementation plan before non-trivial implementation.
|
|
8
8
|
|
|
9
|
+
Complexity is staged, not decided once. Record a provisional request checkpoint, re-evaluate it at the planning checkpoint after exploration, and require a code checkpoint after exact file/caller/test inspection immediately before the first edit. Before editing, either route may change when evidence supports it. Every change must synchronize the plan artifact, repository goal task roadmap through `goal replan`, and native UI plan, including reviews and required evidence. After editing begins, a new Heavy Path signal only promotes Light Path to Heavy Path: stop further edits, mark affected evidence stale, synchronize all three roadmaps, and repeat the code checkpoint.
|
|
10
|
+
|
|
11
|
+
Models always inherit. Route reasoning effort per task: Light planning/implementation/verification=`medium`; Heavy planning/review/implementation=`high`; final verification/review=`xhigh`. Record requested/effective effort for every task. Only a new task/worker may receive requested effort through a supported host-native option; unsupported host/value means effective=`inherited` with no model/global config change. Route changes synchronize the plan artifact, repository goal task roadmap, native UI plan, and reasoning effort profile; preserve completed profiles and recalculate incomplete profiles.
|
|
12
|
+
|
|
9
13
|
Procedure:
|
|
10
14
|
|
|
11
|
-
1. Every agent
|
|
12
|
-
2. For implementation or
|
|
13
|
-
3. Before repository exploration, toolcheck, complexity triage, delegation, or a non-blocking user question, call Codex `update_plan` and then `create_goal` when those UI tools are available. Mirror the same roadmap into the repository Cairn goal. Record unavailable UI tools instead of silently implying UI synchronization. Skip goal activation for consultation, explanation, and plan-only requests.
|
|
15
|
+
1. Every agent reads project-root `MEMORY.md` when present and continues without repository memory when absent before repository exploration, tool selection, work, or delegation.
|
|
16
|
+
2. Classify routine known-target Git/GitHub operations separately: status, fetch, checkout, branch, merge, push, and PR management stay plan/goal-free unless they require code edits, conflict resolution, destructive recovery, release/deploy, or design. For non-trivial implementation or continuation of planned work, write an initial `docs/plan/<topic>.md` and `PLAN.md` entry from the request and `MEMORY.md`. Make `triage-plan` the first active task and specify its investigation scope, path-decision criteria, plan-update condition, and anticipated implementation/verification stages. This initial plan must be decision-complete for triage and explicitly not implementation-ready.
|
|
17
|
+
3. Before repository exploration, toolcheck, complexity triage, delegation, or a non-blocking user question for planned work, call Codex `update_plan` and then `create_goal` when those UI tools are available. Mirror the same roadmap into the repository Cairn goal. Record unavailable UI tools instead of silently implying UI synchronization. Skip goal activation for routine known-target Git/GitHub operations, consultation, explanation, and plan-only requests.
|
|
14
18
|
4. Read relevant `docs/memory/*.md` as directed by the initial triage task.
|
|
15
19
|
5. Read the applicable installed model guidance.
|
|
16
20
|
6. Run the installed runtime's `toolcheck --root <repoRoot>` and handle missing tools through the explicit approval policy.
|
package/commands/cairn-review.md
CHANGED
|
@@ -8,7 +8,7 @@ Goal: review completed work against plan, memory, policy, and evidence.
|
|
|
8
8
|
|
|
9
9
|
Procedure:
|
|
10
10
|
|
|
11
|
-
1. Every agent
|
|
11
|
+
1. Every agent reads project-root `MEMORY.md` when present and continues without repository memory when absent before review work, then reads the plan task and available memory inputs.
|
|
12
12
|
2. Check changed files, tool readiness evidence, and verification evidence.
|
|
13
13
|
3. Delegate independent read-only review to `explorer` when it materially improves speed or quality; use `worker` only for scoped verification reruns or QA artifacts. When subagent tools are available, each agent may recursively delegate bounded sub-tasks to subagents. Tell every delegated agent and child subagent to read the project-root `MEMORY.md` before work, keep scope, and preserve others' edits.
|
|
14
14
|
4. Report findings first, ordered by severity, with file and line references. If no issues are found, say so clearly and mention remaining test gaps or residual risk.
|
|
@@ -19,4 +19,4 @@ Managed items:
|
|
|
19
19
|
|
|
20
20
|
After the transaction commits, Cairn removes empty managed scaffold directories bottom-up and removes the custom marketplace root only after releasing its own lifecycle lock. A directory containing any unmanaged child is preserved; pruning never uses recursive deletion.
|
|
21
21
|
|
|
22
|
-
The source work folder
|
|
22
|
+
The source work folder, repository `MEMORY.md`, `PLAN.md`, `docs/`, and user-home Cairn goal state are not deleted. The globally installed `cairn-ai` package, package-manager download caches, legacy backup files, and legacy shared settings not recorded by the current ownership manifest are also outside this command's scope and require a separate, explicit cleanup decision.
|
package/commands/cairn-work.md
CHANGED
|
@@ -6,9 +6,13 @@ Prerequisite: resolve the installed Cairn runtime from the plugin or skill locat
|
|
|
6
6
|
|
|
7
7
|
Goal: execute the active goal's current task without bypassing complexity triage, then keep advancing tasks until goal-level final review completes or the goal is explicitly paused, blocked, or cancelled.
|
|
8
8
|
|
|
9
|
+
Require three complexity records: the provisional request checkpoint, post-exploration planning checkpoint, and code checkpoint after exact file/caller/test inspection immediately before the first edit. Before editing, evidence may change either route. Every change must synchronize the plan artifact, repository goal task roadmap through `goal replan`, and native UI plan, including reviews and required evidence. After editing begins, a new Heavy Path signal promotes Light Path to Heavy Path: stop further edits, mark affected evidence stale, synchronize all three roadmaps, and repeat the code checkpoint.
|
|
10
|
+
|
|
11
|
+
Models always inherit. Route reasoning effort per task: Light planning/implementation/verification=`medium`; Heavy planning/review/implementation=`high`; final verification/review=`xhigh`. Record requested/effective effort for every task. Only a new task/worker may receive requested effort through a supported host-native option; unsupported host/value means effective=`inherited` with no model/global config change. Route changes synchronize the plan artifact, repository goal task roadmap, native UI plan, and reasoning effort profile; preserve completed profiles and recalculate incomplete profiles.
|
|
12
|
+
|
|
9
13
|
Procedure:
|
|
10
14
|
|
|
11
|
-
1. Every agent
|
|
15
|
+
1. Every agent reads project-root `MEMORY.md` when present and continues without repository memory when absent before selecting or executing a task.
|
|
12
16
|
2. Read `PLAN.md`, the detailed plan, and relevant memory notes.
|
|
13
17
|
3. Resolve and read the `cairn://` Codex or Claude model guidance recorded in the plan through the installed runtime.
|
|
14
18
|
4. Read Cairn goal status and select only its current task. If implementation was requested but no goal exists, create it from the decision-complete plan.
|
|
@@ -14,11 +14,13 @@ The goal is not to make prompts long by model. The goal is to stabilize the same
|
|
|
14
14
|
|
|
15
15
|
## Common Rules
|
|
16
16
|
|
|
17
|
-
- On every fresh entry, compaction recovery, restart, delegation, or handoff, restore context in this order: root `MEMORY.md` → current phase skill → active plan → current-task references → model guidance recorded by the plan. If persisted state or an assignment requires
|
|
17
|
+
- On every fresh entry, compaction recovery, restart, delegation, or handoff, restore context in this order: optional root `MEMORY.md` → current phase skill → active plan → current-task references → model guidance recorded by the plan. If `MEMORY.md` is absent, continue without repository memory and do not invoke another memory service. If persisted state or an assignment requires another reference that is missing, unreadable, or inconsistent, fail closed: do not edit, delegate, approve, or complete; report or record a blocker.
|
|
18
18
|
- Keep root `MEMORY.md` and `PLAN.md` as indexes only.
|
|
19
19
|
- Keep repository-specific judgment in `docs/memory/` and `docs/plan/`. Keep Cairn's model guidance in the installed plugin and reference it with `cairn://docs/model-guidance/...`.
|
|
20
|
+
- Treat the user-home `.cairn/projects/<project-id>/worktrees/<worktree-id>/state.json` as a worktree-bound active-work slot. State without `worktreeId` and state copied into another worktree are stale and are removed on the next hook/goal start. Successful completion or cancellation removes the owning copy after plan evidence is recorded; only paused or blocked work remains for resumption.
|
|
20
21
|
- Preserve proper nouns, file names, variable names, service names, alert names, MCP tool names, and agent names exactly as written.
|
|
21
22
|
- Select Light Path or Heavy Path before implementation.
|
|
23
|
+
- Treat complexity as three checkpoints: a provisional request checkpoint, a post-exploration planning checkpoint, and a code checkpoint after exact file/caller/test inspection immediately before the first edit. Before editing, evidence may change either route. Every change must synchronize the plan artifact, repository goal task roadmap through `goal replan`, and native UI plan, including reviews and required evidence. After editing begins, a new Heavy signal promotes Light Path to Heavy Path: stop further edits, mark affected evidence stale, synchronize all three roadmaps, and repeat the code checkpoint.
|
|
22
24
|
- Treat the user-called/main agent as the orchestrator: it plans, assigns, verifies, and records evidence.
|
|
23
25
|
- Delegate actual implementation edits to `worker` subagents whenever subagent tools are available, regardless of Light Path or Heavy Path.
|
|
24
26
|
- When the subagent tool provides a progress-reporting channel, require subagents to report status to the orchestrator when starting work, when deciding or confirming direction, during periodic progress, and when finishing; the orchestrator must immediately relay received status events to the user. If no mid-run reporting channel exists, the orchestrator relays observable events such as assignment, waiting, and final completion.
|
|
@@ -26,7 +28,7 @@ The goal is not to make prompts long by model. The goal is to stabilize the same
|
|
|
26
28
|
- If subagent tools are unavailable, the main agent takes over implementation directly and records that takeover in evidence.
|
|
27
29
|
- Detect required LSP, typecheck, lint, dry-run, and verification tools before implementation.
|
|
28
30
|
- Missing required tools must be reported with a proposed install. Installation requires explicit user approval and a pinned/supported installer.
|
|
29
|
-
- Treat
|
|
31
|
+
- Treat non-trivial implementation or continuation of planned work as authorization to bind active work to a persisted Cairn goal and stable task IDs, even when the user does not mention a goal. Routine known-target Git/GitHub operations (status, fetch, checkout, branch, merge, push, PR management) stay plan/goal-free unless they require code edits, conflict resolution, destructive recovery, release/deploy, or design. For planned work, after MEMORY.md, first write an initial plan that makes triage the active task, synchronize it before exploration, and implement only from the decision-complete revision. Exclude consultation, explanation, and plan-only requests.
|
|
30
32
|
- Treat missing, failed, skipped, stale, or placeholder evidence as failure. Task evidence records must be bound to the current goal, task, and plan.
|
|
31
33
|
- Treat the repository Cairn state as the fail-closed transition authority. Advance the matching Codex UI plan step only after the evidence-gated repository task transition succeeds.
|
|
32
34
|
- Spend reasoning on a focused executable test contract before implementation: requirements, invariants, boundaries, and failure modes. Give implementation only that contract, failing evidence, file scope, and constraints; require the minimum passing change.
|
|
@@ -46,6 +48,16 @@ The goal is not to make prompts long by model. The goal is to stabilize the same
|
|
|
46
48
|
- Character budgets are regression proxies for cache-friendly prompt shape, not measurements of provider cache hits or cost. Cairn does not require provider cache keys, breakpoints, or live API telemetry.
|
|
47
49
|
- Do not add read receipts that claim model attention. Restore references on every re-entry and use readable state plus fresh bound evidence as the enforceable contract.
|
|
48
50
|
|
|
51
|
+
## Reasoning Effort Routing
|
|
52
|
+
|
|
53
|
+
- Models always inherit the host or user default; Cairn never selects or overrides a model.
|
|
54
|
+
- Light Path planning, implementation, and verification request `medium`.
|
|
55
|
+
- Heavy Path planning, review, and implementation request `high`; final verification and review request `xhigh`.
|
|
56
|
+
- Every plan task records `Requested reasoning effort` and `Effective reasoning effort`.
|
|
57
|
+
- Only a newly dispatched task or worker may receive the requested value, and only through a host-exposed reasoning-effort option or host-native equivalent. Omit every model override.
|
|
58
|
+
- For an unsupported host or value, record `Effective reasoning effort: inherited` with the reason. Do not change the model or global config and do not silently choose a nearby value.
|
|
59
|
+
- A route change synchronizes the plan artifact, repository goal task roadmap through `goal replan`, native UI plan, and reasoning effort profile before edits resume. Preserve completed task profiles as audit history and recalculate incomplete task profiles for the new path.
|
|
60
|
+
|
|
49
61
|
## Delegation Defaults
|
|
50
62
|
|
|
51
63
|
- `explorer`: use for read-only codebase discovery, impact analysis, pattern searches, and read-only verification when available.
|
|
@@ -18,7 +18,9 @@ Claude-family models are strong at long-context retention, policy interpretation
|
|
|
18
18
|
- Do not skip the two verification gates even on Light Path.
|
|
19
19
|
- Do not approve a plan that lacks dry-run or check evidence for external-state-changing work.
|
|
20
20
|
- Do not allow open-ended verification loops. Require a blocker or sub-task split after two failed passes.
|
|
21
|
+
- Keep the model inherited. Review each task's `Requested reasoning effort` and `Effective reasoning effort`; apply the requested value only to a newly dispatched task or worker through a host-native task/subagent option, never a model override. For an unsupported host or value, require effective reasoning effort `inherited` and no model/global configuration change.
|
|
21
22
|
- On Heavy Path, check plan gaps before implementation.
|
|
23
|
+
- Review all three complexity records: the provisional request checkpoint, post-exploration planning checkpoint, and code checkpoint after exact file/caller/test inspection immediately before the first edit. Before editing, evidence may change either route. Every change must synchronize the plan artifact, repository goal task roadmap through `goal replan`, and native UI plan, including reviews and required evidence. After editing begins, a new Heavy signal promotes Light Path to Heavy Path: stop further edits, mark affected evidence stale, synchronize all three roadmaps, and repeat the code checkpoint.
|
|
22
24
|
- Before asking the user, use repository evidence and available `explorer`/`worker` delegation when it materially improves speed or quality.
|
|
23
25
|
- Write user-visible responses and generated or updated documentation, plans, and memory artifacts in the OS locale unless the user asks for another language.
|
|
24
26
|
|
|
@@ -17,8 +17,10 @@ Codex-family models are strong at small implementation tasks, explicit tool use,
|
|
|
17
17
|
|
|
18
18
|
## Adjustment Rules
|
|
19
19
|
|
|
20
|
-
- On every fresh entry, compaction recovery, restart, delegation, or handoff, restore root `MEMORY.md` → current phase skill → active plan → current-task references → recorded model guidance. If persisted state or the assignment requires
|
|
20
|
+
- On every fresh entry, compaction recovery, restart, delegation, or handoff, restore optional root `MEMORY.md` → current phase skill → active plan → current-task references → recorded model guidance. Missing `MEMORY.md` never blocks and must not trigger another memory service. If persisted state or the assignment requires another missing, unreadable, or inconsistent reference, fail closed and report a blocker before editing, delegating, approving, or completing.
|
|
21
21
|
- Do not start implementation without a plan.
|
|
22
|
+
- Keep the model inherited. Read each plan task's `Requested reasoning effort` and `Effective reasoning effort`; only a newly dispatched task or worker may receive the requested effort through the host's task/subagent option, with no model override. For an unsupported host or value, record the effective reasoning effort as `inherited` and leave model/global configuration unchanged.
|
|
23
|
+
- Do not treat complexity as a one-time choice. Require the provisional request checkpoint, post-exploration planning checkpoint, and code checkpoint after exact file/caller/test inspection immediately before the first edit. Before editing, evidence may change either route. Every change must synchronize the plan artifact, repository goal task roadmap through `goal replan`, and native UI plan, including reviews and required evidence. After editing begins, a new Heavy signal promotes Light Path to Heavy Path: stop further edits, mark affected evidence stale, synchronize all three roadmaps, and repeat the code checkpoint.
|
|
22
24
|
- Do not stop before local implementation solely because subagent tools are unavailable; the main agent takes over implementation directly and records that takeover in evidence.
|
|
23
25
|
- Keep work units small. Split large changes into smaller plan tasks.
|
|
24
26
|
- If `apply_patch` is unstable in the environment, use an editing tool or a clear file update path.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cairn-ai",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Token-efficient agent harness with tool readiness for Codex, Claude Code, and Antigravity",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"README.*.md"
|
|
40
40
|
],
|
|
41
41
|
"scripts": {
|
|
42
|
-
"check": "node --check scripts/cairn.mjs && node --check scripts/cairn-paths.mjs && node --check scripts/cairn-safe-fs.mjs && node --check scripts/cairn-goal.mjs && node --check scripts/cairn-state.mjs && node --check scripts/cairn-lifecycle.mjs && node --check scripts/cairn-toolcheck.mjs && node -e \"JSON.parse(require('node:fs').readFileSync('package.json','utf8')); JSON.parse(require('node:fs').readFileSync('.codex-plugin/plugin.json','utf8')); JSON.parse(require('node:fs').readFileSync('hooks/hooks.json','utf8')); JSON.parse(require('node:fs').readFileSync('scripts/release-integrity-0.2.2.json','utf8'))\" && npm test",
|
|
42
|
+
"check": "node --check scripts/cairn.mjs && node --check scripts/cairn-paths.mjs && node --check scripts/cairn-safe-fs.mjs && node --check scripts/cairn-goal.mjs && node --check scripts/cairn-state.mjs && node --check scripts/cairn-cleanup.mjs && node --check scripts/cairn-lifecycle.mjs && node --check scripts/cairn-toolcheck.mjs && node -e \"JSON.parse(require('node:fs').readFileSync('package.json','utf8')); JSON.parse(require('node:fs').readFileSync('.codex-plugin/plugin.json','utf8')); JSON.parse(require('node:fs').readFileSync('hooks/hooks.json','utf8')); JSON.parse(require('node:fs').readFileSync('scripts/release-integrity-0.2.2.json','utf8'))\" && npm test",
|
|
43
43
|
"test": "node --test",
|
|
44
44
|
"prepack": "npm run check"
|
|
45
45
|
},
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { lstat, readdir, rm, rmdir } from "node:fs/promises";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
import { reconcileWorktreeState } from "./cairn-goal.mjs";
|
|
6
|
+
import { parseRootArgs } from "./cairn-paths.mjs";
|
|
7
|
+
|
|
8
|
+
const knownNames = new Set(["state.json", "state.lock", "tools"]);
|
|
9
|
+
|
|
10
|
+
export async function cleanupProjectCairn({ root = process.cwd(), apply = false } = {}) {
|
|
11
|
+
const repoRoot = resolve(root);
|
|
12
|
+
const legacyRoot = join(repoRoot, ".cairn");
|
|
13
|
+
let entries;
|
|
14
|
+
try {
|
|
15
|
+
entries = await readdir(legacyRoot, { withFileTypes: true });
|
|
16
|
+
} catch (error) {
|
|
17
|
+
if (error?.code === "ENOENT") return { root: repoRoot, apply, known: [], unknown: [], removed: [], projectDirectoryRemoved: false };
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const known = [];
|
|
22
|
+
const unknown = [];
|
|
23
|
+
for (const entry of entries) {
|
|
24
|
+
const isKnownStaleLock = entry.name.startsWith("state.lock.stale.");
|
|
25
|
+
(knownNames.has(entry.name) || isKnownStaleLock ? known : unknown).push(entry.name);
|
|
26
|
+
}
|
|
27
|
+
if (!apply) return { root: repoRoot, apply, known: known.sort(), unknown: unknown.sort(), removed: [], projectDirectoryRemoved: false };
|
|
28
|
+
|
|
29
|
+
if (known.includes("state.json")) await reconcileWorktreeState({ root: repoRoot });
|
|
30
|
+
const removed = [];
|
|
31
|
+
for (const name of known) {
|
|
32
|
+
const path = join(legacyRoot, name);
|
|
33
|
+
try {
|
|
34
|
+
const stat = await lstat(path);
|
|
35
|
+
await rm(path, { recursive: stat.isDirectory(), force: true });
|
|
36
|
+
removed.push(name);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (error?.code !== "ENOENT") throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
let projectDirectoryRemoved = false;
|
|
42
|
+
try {
|
|
43
|
+
await rmdir(legacyRoot);
|
|
44
|
+
projectDirectoryRemoved = true;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(error?.code)) throw error;
|
|
47
|
+
}
|
|
48
|
+
return { root: repoRoot, apply, known: known.sort(), unknown: unknown.sort(), removed: removed.sort(), projectDirectoryRemoved };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function main() {
|
|
52
|
+
const { args, repoRoot } = parseRootArgs(process.argv.slice(2));
|
|
53
|
+
const apply = args.includes("--yes");
|
|
54
|
+
const unsupported = args.filter((value) => value !== "--yes" && value !== "--check");
|
|
55
|
+
if (unsupported.length > 0) throw new Error(`Unknown cleanup option: ${unsupported[0]}`);
|
|
56
|
+
console.log(JSON.stringify(await cleanupProjectCairn({ root: repoRoot, apply }), null, 2));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
60
|
+
await main();
|
|
61
|
+
}
|