cairn-ai 0.2.6 → 0.2.8

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.
Files changed (65) hide show
  1. package/.agents/workflows/cairn-memory.md +2 -2
  2. package/.agents/workflows/cairn-plan.md +3 -3
  3. package/.agents/workflows/cairn-review.md +2 -2
  4. package/.agents/workflows/cairn-work.md +4 -4
  5. package/.claude/agents/explorer.md +1 -1
  6. package/.claude/agents/worker.md +1 -1
  7. package/.claude/commands/cairn-memory.md +1 -1
  8. package/.claude/commands/cairn-plan.md +1 -1
  9. package/.claude/commands/cairn-review.md +1 -1
  10. package/.claude/commands/cairn-work.md +1 -1
  11. package/.codex-plugin/plugin.json +1 -1
  12. package/README.de.md +3 -2
  13. package/README.es.md +3 -2
  14. package/README.fr.md +3 -2
  15. package/README.ja.md +3 -2
  16. package/README.ko.md +16 -8
  17. package/README.md +14 -8
  18. package/README.pt.md +3 -2
  19. package/README.zh.md +3 -2
  20. package/agents/worker.md +3 -1
  21. package/commands/cairn-install.md +2 -1
  22. package/commands/cairn-memory.md +2 -2
  23. package/commands/cairn-plan.md +3 -3
  24. package/commands/cairn-review.md +2 -2
  25. package/commands/cairn-work.md +4 -4
  26. package/docs/model-guidance/README.md +5 -5
  27. package/docs/model-guidance/claude.md +1 -1
  28. package/docs/model-guidance/codex.md +3 -3
  29. package/package.json +4 -2
  30. package/scripts/cairn-cleanup.mjs +12 -6
  31. package/scripts/cairn-goal-cli.mjs +239 -0
  32. package/scripts/cairn-goal-evidence.mjs +186 -0
  33. package/scripts/cairn-goal-operations-evidence.mjs +124 -0
  34. package/scripts/cairn-goal-operations-mutations.mjs +63 -0
  35. package/scripts/cairn-goal-operations.mjs +187 -0
  36. package/scripts/cairn-goal-policy.mjs +36 -0
  37. package/scripts/cairn-goal-state-validation.mjs +199 -0
  38. package/scripts/cairn-goal-state.mjs +124 -0
  39. package/scripts/cairn-goal.mjs +33 -1078
  40. package/scripts/cairn-lifecycle-commands.mjs +200 -0
  41. package/scripts/cairn-lifecycle-config.mjs +153 -0
  42. package/scripts/cairn-lifecycle-integrity.mjs +218 -0
  43. package/scripts/cairn-lifecycle-legacy.mjs +142 -0
  44. package/scripts/cairn-lifecycle-lock.mjs +205 -0
  45. package/scripts/cairn-lifecycle-mirror.mjs +91 -0
  46. package/scripts/cairn-lifecycle-staging.mjs +152 -0
  47. package/scripts/cairn-lifecycle-transaction-journal.mjs +210 -0
  48. package/scripts/cairn-lifecycle-transaction-targets.mjs +119 -0
  49. package/scripts/cairn-lifecycle-transaction.mjs +12 -0
  50. package/scripts/cairn-lifecycle.mjs +103 -1185
  51. package/scripts/cairn-paths.mjs +35 -5
  52. package/scripts/cairn-safe-fs.mjs +61 -35
  53. package/scripts/cairn-state-context.mjs +156 -0
  54. package/scripts/cairn-state-hook.mjs +26 -0
  55. package/scripts/cairn-state-init.mjs +137 -0
  56. package/scripts/cairn-state.mjs +32 -286
  57. package/scripts/cairn-toolcheck-detect.mjs +229 -0
  58. package/scripts/cairn-toolcheck-runtime.mjs +178 -0
  59. package/scripts/cairn-toolcheck.mjs +79 -424
  60. package/scripts/cairn.mjs +17 -3
  61. package/skills/cairn-memory/SKILL.md +3 -2
  62. package/skills/cairn-plan/SKILL.md +7 -4
  63. package/skills/cairn-review/SKILL.md +4 -4
  64. package/skills/cairn-work/SKILL.md +23 -7
  65. package/scripts/cairn-state.sh +0 -167
@@ -13,17 +13,17 @@ Review is not another implementation loop. Confirm that the completed task satis
13
13
 
14
14
  Every review run and delegated review agent reads project-root `MEMORY.md` when present. If it is absent, continue without repository memory and do not invoke another memory service.
15
15
 
16
- At the start and after compaction, restart, delegation, or handoff, restore context in this order: optional root `MEMORY.md` → `cairn-review` → the active plan → completed/current-task references → model guidance recorded by the plan. Missing `MEMORY.md` is not an inconsistency. Confirm the remaining references agree with persisted goal state before reviewing. If any required reference is missing, unreadable, or inconsistent, do not approve, delegate, record final review, or complete the goal; report a blocker. Do not use a read-receipt field as evidence that a model understood a reference.
16
+ At the start and after compaction, restart, delegation, or handoff, restore context in this order: optional root `MEMORY.md` → `cairn-review` → the active plan → completed/current-task references → model guidance recorded by the plan. Missing `MEMORY.md` is not an inconsistency. Confirm the remaining references agree with persisted goal state before reviewing. If any required reference is missing, unreadable, or inconsistent, do not approve, delegate, record final review, or complete the goal; report a blocker. Do not use a read-receipt field as evidence that a model understood a reference. Delegation means the delegated agent restores on its own entry; the orchestrator does not re-read this chain after dispatching or collecting a subagent, and within one unbroken context it rereads only references that changed, which keeps the cached prompt prefix stable.
17
17
 
18
18
  When subagent tools are available, each agent may recursively delegate bounded review 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.
19
19
 
20
- Resolve any `cairn://...` resource through `references/cairn-runtime.json` next to this `SKILL.md` (or this skill's `../..` source root during development). Never look for Cairn runtime resources in the target repository.
20
+ Resolve any `cairn://...` resource through `references/cairn-runtime.json` next to this `SKILL.md` (or this skill's `../..` source root during development). Never look for Cairn runtime resources in the target repository. If the shared runtime or locator is missing, unreadable, or inconsistent, stop every dependent mirror and recover from the published/global package with `cairn doctor` followed by `cairn upgrade`; do not use another mirror as a repair source.
21
21
 
22
22
  ## Procedure
23
23
 
24
24
  1. Read the completed task in `docs/plan/<topic>.md`.
25
25
  2. Read `MEMORY.md` when present and relevant `docs/memory/*.md`; continue when repository memory is absent.
26
- 3. Check changed files, tool readiness evidence, and evidence paths.
26
+ 3. Check changed files, tool readiness evidence, and evidence paths. Inspect test, fixture, and verification-command diffs and reject any weakening without a recorded plan reason. For defect fixes, confirm the same-rule sweep was performed and its result recorded.
27
27
  4. Delegate independent review when it materially improves speed or quality and the current tool policy allows it.
28
28
  - Use `explorer` for read-only impact analysis, pattern checks, and independent diff inspection.
29
29
  - Use `worker` for scoped verification command re-runs or QA artifact capture.
@@ -39,7 +39,7 @@ TASK: Review correctness, scope, and evidence for task <task-id>.
39
39
  EXPECTED OUTCOME: Findings ordered by severity with file and line references, or an explicit no-issue result with residual risk.
40
40
  REQUIRED TOOLS: Read-only diff inspection, tool readiness checks, verification command execution, plan/memory reading.
41
41
  MUST DO: Read the project-root `MEMORY.md` before doing assigned work. Check tool readiness and install-attempt evidence. Check dry-run or check evidence when external state could change. Check both module evidence and surface evidence. Preserve proper nouns exactly. Use the OS locale for user-visible responses and generated or updated documentation, plans, and memory artifacts.
42
- MUST NOT DO: Edit files. Ask the user. Approve skipped LSP/typecheck/lint without install evidence. Approve missing evidence or open-ended verification loops.
42
+ MUST NOT DO: Edit files. Ask the user. Approve skipped LSP/typecheck/lint without install evidence. Approve weakened, skipped, or deleted tests or verification commands without a recorded plan reason. Approve missing evidence or open-ended verification loops.
43
43
  CONTEXT: docs/plan/<topic>.md, MEMORY.md, relevant docs/memory notes, changed files.
44
44
  ```
45
45
 
@@ -23,18 +23,20 @@ If the user asks a side question, status question, or narrow clarification while
23
23
 
24
24
  ## Re-entry and Required References
25
25
 
26
- At the start and after compaction, restart, delegation, or handoff, restore context in this order: optional root `MEMORY.md` → `cairn-work` → the active plan → current-task references → model guidance recorded by the plan. Confirm that the plan task, persisted current task, and worker assignment agree before acting. Missing `MEMORY.md` is not an inconsistency. If state, skill, plan, assignment, or another required reference is missing, unreadable, or inconsistent, do not edit, delegate, record completion evidence, or complete work; report a blocker to the orchestrator. Do not introduce read receipts as proof of model attention: current state, readable references, and fresh tool-bound evidence are the authority.
26
+ At the start and after compaction, restart, delegation, or handoff, restore context in this order: optional root `MEMORY.md` → `cairn-work` → the active plan → current-task references → model guidance recorded by the plan. Confirm that the plan task, persisted current task, and worker assignment agree before acting. Missing `MEMORY.md` is not an inconsistency. If state, skill, plan, assignment, or another required reference is missing, unreadable, or inconsistent, do not edit, delegate, record completion evidence, or complete work; report a blocker to the orchestrator. Do not introduce read receipts as proof of model attention: current state, readable references, and fresh tool-bound evidence are the authority. Delegation means the delegated agent restores on its own entry; the orchestrator does not re-read this chain after dispatching or collecting a subagent, and within one unbroken context it rereads only references that changed, which keeps the cached prompt prefix stable.
27
27
 
28
28
  When subagent tools are available, each agent 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.
29
29
 
30
30
  ## Runtime Location
31
31
 
32
- Resolve Cairn's read-only runtime from `references/cairn-runtime.json` next to this `SKILL.md`. Its `pluginRoot` contains Cairn's scripts and model guidance. In a source checkout where the locator does not exist, resolve the plugin root from this `SKILL.md` location (`../..`). Never search the target repository for Cairn runtime files or derive the plugin root from the current working directory. Resolve `cairn://...` plan resources through this runtime and pass the target repository separately with `--root <repoRoot>`.
32
+ Resolve Cairn's read-only runtime from `references/cairn-runtime.json` next to this `SKILL.md`. Its `pluginRoot` contains Cairn's scripts and model guidance. In a source checkout where the locator does not exist, resolve the plugin root from this `SKILL.md` location (`../..`). Never search the target repository for Cairn runtime files or derive the plugin root from the current working directory. Resolve `cairn://...` plan resources through this runtime and pass the target repository separately with `--root <repoRoot>`. If the shared runtime or locator is missing, unreadable, or inconsistent, stop every dependent mirror and recover from the published/global package with `cairn doctor` followed by `cairn upgrade`; do not use another mirror as a repair source.
33
33
 
34
34
  Use the installed CLI for durable state. Important forms are:
35
35
 
36
36
  ```sh
37
+ node "<pluginRoot>/scripts/cairn.mjs" goal task status --root "<repoRoot>"
37
38
  node "<pluginRoot>/scripts/cairn.mjs" goal status --root "<repoRoot>"
39
+ node "<pluginRoot>/scripts/cairn.mjs" goal claim --quiet --root "<repoRoot>" --session "<session-id-shown-by-hook>"
38
40
  node "<pluginRoot>/scripts/cairn.mjs" goal replan --quiet --root "<repoRoot>" --tasks '[{"id":"<task-id>","title":"<task-title>","requiredEvidence":["moduleAcceptance","surfaceIntegration"]}]'
39
41
  node "<pluginRoot>/scripts/cairn.mjs" goal assign --quiet --root "<repoRoot>" --task "<task-id>" --agent "<agent-id>"
40
42
  node "<pluginRoot>/scripts/cairn.mjs" goal verify --quiet --root "<repoRoot>" --task "<task-id>" --kind moduleAcceptance --watch "<path|path>" -- <tool> <arg> ...
@@ -46,7 +48,7 @@ node "<pluginRoot>/scripts/cairn.mjs" goal complete --quiet --root "<repoRoot>"
46
48
 
47
49
  `goal verify` executes the argv after `--` without a shell and records its exit code, bounded tool output, output digest, and watched-workspace fingerprint. The legacy `goal receipt` command imports declared evidence for compatibility; declared evidence does not satisfy a default tool-bound goal.
48
50
 
49
- Verification defaults to 600,000 ms (10 minutes), accepts a shorter `--timeout-ms`, and is capped at 3,600,000 ms (1 hour). The external command never holds the state lock. A receipt is committed only when the starting goal/task identity and the pre/post watched fingerprint still match. Choose the watch set and verification command at the semantic boundary that proves the claimed behavior.
51
+ Verification defaults to 600,000 ms (10 minutes), accepts a shorter `--timeout-ms`, and is capped at 3,600,000 ms (1 hour). The external command never holds the state lock. A receipt is committed only when the starting goal/task identity and the pre/post watched fingerprint still match. Choose the watch set and verification command at the semantic boundary that proves the claimed behavior. With no explicit watch, Git-ignored files are excluded; pass each ignored artifact required by the claim with `--watch <path>` or explicitly watch its containing directory.
50
52
 
51
53
  Use `goal pause`, `goal block --reason "<concrete blocker>"`, or `goal cancel` when that is the truthful state. A task can be blocked with `goal task --task "<task-id>" --status blocked --reason "<concrete blocker>"`.
52
54
 
@@ -65,6 +67,18 @@ Use this verification ladder:
65
67
  5. Run normal `npm pack --dry-run` by default. Content-producing or unknown lifecycle scripts must never be skipped with `--ignore-scripts`; their generated contents are part of the package contract.
66
68
  6. Only when lifecycle scripts are absent or proven content-neutral, the full check is still fresh, and the dry-run is only checking the file list may package verification use `npm pack --dry-run --ignore-scripts`.
67
69
 
70
+ ## Verification Integrity
71
+
72
+ - The implementer must not be able to change the judge. Never edit, weaken, skip, or delete existing tests, fixtures, snapshots, or recorded verification commands to make a gate pass. When a contract genuinely changes, record the reason in `docs/plan/<topic>.md` before that edit; review rejects any judge change without a recorded reason.
73
+ - Prefer executable checks (test, lint, script, hook) for machine-checkable rules; keep prose only for rules that need judgment.
74
+
75
+ ## Defect Investigation
76
+
77
+ - Reproduce a reported defect with repository tools before fixing it; do not wait for more detail when a local reproduction is possible.
78
+ - For unclear or non-reproducible failures, test one hypothesis at a time and close it with a measurement before changing code. Never fix on speculation.
79
+ - Answer feasibility questions with a bounded experiment or measurement instead of an unverified "not possible". Stop and ask only when the experiment would bypass a security policy or mutate external state without approval.
80
+ - After fixing a defect, search the repository for other implementations of the same rule or pattern. Fix them within the assigned scope or record them as follow-up in the plan.
81
+
68
82
  Any relevant mutation after a gate makes that result stale evidence. Rerun the affected focused gate and, when integration could change, the full gate. Use `--quiet` for successful Cairn state mutations so full state JSON does not consume conversation tokens. `goal status` is read-only and always returns state, including when `--quiet` is supplied.
69
83
 
70
84
  ## Reasoning Effort Routing
@@ -72,8 +86,8 @@ Any relevant mutation after a gate makes that result stale evidence. Rerun the a
72
86
  - Models always inherit the host/user default; never configure or override them.
73
87
  - Light Path planning, implementation, and verification request `medium`.
74
88
  - Heavy Path planning, review, and implementation request `high`; final verification and review request `xhigh`.
75
- - Every module task records `Requested reasoning effort` and `Effective reasoning effort` in `docs/plan/<topic>.md`.
76
- - Pass requested effort only when dispatching a new task/worker and the host exposes a reasoning-effort option or host-native equivalent. Omit model overrides. For an unsupported host or value, record effective reasoning effort `inherited` with the reason and leave model/global config unchanged.
89
+ - Every module task records `Requested reasoning effort` and `Effective reasoning effort` in `docs/plan/<topic>.md`. Requested is Cairn's desired profile; Effective is what the dispatch result confirms.
90
+ - Pass requested effort only when dispatching a new task/worker and the host exposes a reasoning-effort option or host-native equivalent. Omit model overrides. Effective `inherited` means no task-level override was confirmed, not proof of missing host capability. Describe capability only from the exposed interface or dispatch response, distinguish Cairn non-integration from host non-support, and leave model/global config unchanged.
77
91
  - On every route change, synchronize the plan artifact, repository goal task roadmap through `goal replan`, native UI plan, and reasoning effort profile before edits resume. Completed task profiles are preserved as audit history; incomplete task profiles are recalculated for the new path.
78
92
 
79
93
  ## Procedure
@@ -81,7 +95,7 @@ Any relevant mutation after a gate makes that result stale evidence. Rerun the a
81
95
  1. Read project-root `MEMORY.md` when present; continue without repository memory when absent.
82
96
  2. Read `PLAN.md`, the selected `docs/plan/<topic>.md`, and relevant memory notes.
83
97
  3. Read the `cairn://docs/model-guidance/*.md` inputs recorded in the plan through the installed runtime.
84
- 4. Read user-home, project/worktree-scoped state through `cairn goal status --root "<repoRoot>"`. Select only the active goal's current task. If implementation was requested but no goal exists, create one from the decision-complete plan before editing.
98
+ 4. Read the current task through `cairn goal task status --root "<repoRoot>"`; the hook capsule already carries the roadmap. Read full `cairn goal status` only when receipts or the complete roadmap are needed, because its output grows with every receipt. Select only the active goal's current task. If a new implementation request or steer arrives while a goal is unfinished, add the work through `goal replan` instead of cancelling the goal, then keep advancing to goal final review. If implementation was requested but no goal exists, create one from the decision-complete plan before editing.
85
99
  5. Confirm that required LSP, typecheck, lint, dry-run, and verification tools are available from the plan's tool readiness section.
86
100
  6. If a required tool is missing, do not install it implicitly. Obtain explicit user approval, then run the installed runtime's `toolcheck --install --yes --root "<repoRoot>"` only for pinned/supported installers or run the approved repository-native command. Otherwise record a blocker.
87
101
  7. Confirm the selected Light Path or Heavy Path in the plan. If the plan lacks complexity triage, stop and update the plan before mutating files.
@@ -110,7 +124,7 @@ Any relevant mutation after a gate makes that result stale evidence. Rerun the a
110
124
  TASK: Implement task <task-id> for <topic>.
111
125
  EXPECTED OUTCOME: Minimal code or documentation change satisfying the task contract.
112
126
  REQUIRED TOOLS: Scoped file editing, tool readiness checks, existing test/build commands, surface QA commands.
113
- MUST DO: Read the project-root `MEMORY.md` before doing assigned work and follow its policy. Stay within the listed file scope and ownership. Assume you are not alone in the codebase; do not revert others' edits. Treat the user-called/main agent as the orchestrator; delegate actual implementation edits to `worker` whenever subagent tools are available, regardless of Light Path or Heavy Path. 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, relay observable events such as assignment, waiting, and final completion. Require delegated subagents to provide a final report before leaving; after capturing final report and evidence, close or release the completed subagent, then review the final report and evidence before marking the work complete. If subagent tools are unavailable, the main agent takes over implementation directly and records that takeover in evidence. When subagent tools are available, recursively delegate only bounded sub-tasks and pass these same constraints to every child subagent. Obtain explicit user approval before installing missing tools. Run dry-run or check mode before external-state mutation when available. Provide module evidence, surface evidence, and a structured handoff scoped to the assigned goal/task. Use the OS locale for user-visible responses and generated or updated documentation, plans, and memory artifacts.
127
+ MUST DO: Read the project-root `MEMORY.md` before doing assigned work and follow its policy. Stay within the listed file scope and ownership. Assume you are not alone in the codebase; do not revert others' edits. Treat the user-called/main agent as the orchestrator; delegate actual implementation edits to `worker` whenever subagent tools are available, regardless of Light Path or Heavy Path. 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, relay observable events such as assignment, waiting, and final completion. Require delegated subagents to provide a final report before leaving; after capturing final report and evidence, close or release the completed subagent, then review the final report and evidence before marking the work complete. If subagent tools are unavailable, the main agent takes over implementation directly and records that takeover in evidence. When subagent tools are available, recursively delegate only bounded sub-tasks and pass these same constraints to every child subagent. Obtain explicit user approval before installing missing tools. Run dry-run or check mode before external-state mutation when available. Provide module evidence, surface evidence, and a structured handoff scoped to the assigned goal/task. Never edit, weaken, skip, or delete existing tests, fixtures, or verification commands to pass a gate without a reason recorded in the plan. After a defect fix, search for other implementations of the same rule or pattern and report them. Use the OS locale for user-visible responses and generated or updated documentation, plans, and memory artifacts.
114
128
  MUST NOT DO: Ask the user. Skip LSP/typecheck/lint because a tool is missing without attempting installation. Refactor unrelated code. Continue an open-ended verification loop. Treat a side question as permission to abandon the active task. Delegate vague or unbounded work. Claim completion without evidence. Modify files outside the assigned ownership.
115
129
  CONTEXT: docs/plan/<topic>.md task, relevant docs/memory notes, applied model guidance, exact files, verification commands.
116
130
  ```
@@ -156,5 +170,7 @@ Run the closest available dry-run or check mode before commands that mutate exte
156
170
  - Dry-run or check evidence exists when the task could mutate external state, or the plan records why no dry-run exists.
157
171
  - The required Light Path or Heavy Path flow was followed.
158
172
  - The model guidance recorded in the plan was applied.
173
+ - No existing test, fixture, or verification command was weakened without a recorded plan reason.
174
+ - Defect fixes record the same-rule sweep result.
159
175
  - Evidence was recorded in `docs/plan/<topic>.md`.
160
176
  - `PLAN.md` status was updated only after evidence existed.
@@ -1,167 +0,0 @@
1
- #!/bin/sh
2
- set -eu
3
-
4
- event="${1:-manual}"
5
- root="${HARNESS_REPO_ROOT:-$(pwd)}"
6
- locale="${LC_ALL:-${LC_MESSAGES:-${LANG:-en}}}"
7
-
8
- mkdir -p "$root/docs/memory" "$root/docs/plan"
9
-
10
- memory="$root/MEMORY.md"
11
- plan="$root/PLAN.md"
12
-
13
- is_ko() {
14
- case "$locale" in
15
- ko*|KO*) return 0 ;;
16
- *) return 1 ;;
17
- esac
18
- }
19
-
20
- if [ ! -f "$memory" ]; then
21
- if is_ko; then
22
- cat > "$memory" <<'EOF'
23
- # MEMORY
24
-
25
- 이 파일은 지속적으로 필요한 저장소 지식의 짧은 색인입니다.
26
-
27
- ## Domain Knowledge
28
-
29
- - 자세한 기록은 `docs/memory/` 아래에 연결합니다.
30
-
31
- ## Policy
32
-
33
- - 구현 전에는 저장소를 정확히 탐색합니다.
34
- - 고유명사, 파일 이름, 변수 이름, 서비스 이름, 알림 이름, MCP 도구 이름, 에이전트 이름은 쓰인 그대로 보존합니다.
35
- - 현재 작업에 필요한 상세 메모리 파일만 읽습니다.
36
- - 사용자가 다른 언어를 요청하지 않는 한, 사용자에게 보이는 응답과 생성 또는 갱신하는 문서, 계획, 메모리 산출물은 OS locale 언어로 작성합니다.
37
-
38
- ## Update Rules
39
-
40
- - 루트 파일은 짧게 유지합니다.
41
- - 자세한 도메인 지식은 `docs/memory/<domain>.md`로 옮깁니다.
42
- - 사실은 출처 경로, 명령, 관찰된 동작과 함께 기록합니다.
43
- EOF
44
- else
45
- cat > "$memory" <<'EOF'
46
- # MEMORY
47
-
48
- This file is a short index of persistent repository knowledge.
49
-
50
- ## Domain Knowledge
51
-
52
- - Link detailed notes under `docs/memory/`.
53
-
54
- ## Policy
55
-
56
- - Prefer precise repository exploration before implementation.
57
- - Preserve proper nouns, file names, variable names, service names, alert names, MCP tool names, and agent names exactly as written.
58
- - Read only the detailed memory files needed for the current task.
59
- - Write user-visible responses and generated or updated documentation, plans, and memory artifacts in the OS locale unless the user asks for another language.
60
-
61
- ## Update Rules
62
-
63
- - Keep root files short.
64
- - Move detailed domain knowledge to `docs/memory/<domain>.md`.
65
- - Record facts with source paths, commands, and observed behavior.
66
- EOF
67
- fi
68
- fi
69
-
70
- if [ ! -f "$plan" ]; then
71
- if is_ko; then
72
- cat > "$plan" <<'EOF'
73
- # PLAN
74
-
75
- 이 파일은 진행 중이거나 완료된 작업 계획의 짧은 색인입니다.
76
-
77
- ## Active Plans
78
-
79
- - 상세 계획은 `docs/plan/` 아래에 연결합니다.
80
-
81
- ## Completed Plans
82
-
83
- - 완료된 주제는 증거 링크와 함께 이곳으로 옮깁니다.
84
-
85
- ## Planning Rules
86
-
87
- - 프로젝트 루트 `MEMORY.md`가 있으면 먼저 읽고, 없으면 저장소 메모리 없이 계속 진행합니다.
88
- - 비단순 구현 또는 계획된 작업 재개는 먼저 `triage-plan`이 active인 계획을 쓰거나 복원하고 탐색 전에 동기화합니다. 대상이 확정된 Git/GitHub 운영은 코드 수정·충돌 해결·파괴적 복구·릴리스/배포·설계가 필요하지 않으면 plan/goal 없이 실행합니다.
89
- - 계획은 구현 전에 의사결정이 완료된 상태여야 합니다.
90
- - 에이전트, 플러그인, 위임 워크플로 지침을 적용하기 전에 복잡도 트리아지를 실행합니다.
91
- - 선택한 Light Path 또는 Heavy Path와 확인한 Heavy Path 신호를 `docs/plan/<topic>.md`에 기록합니다.
92
- - 구현은 작은 모듈 작업으로 나눕니다.
93
- - 구현 전에 저장소 스택과 필요한 LSP/check 도구를 감지합니다.
94
- - 필요한 도구가 없으면 사용할 수 없다고 판단하기 전에 설치 또는 부트스트랩을 시도합니다.
95
- - 각 작업은 보통 정확히 두 게이트를 통과합니다.
96
- - 모듈 수용 검증.
97
- - 표면 통합 검증.
98
- - 외부 상태 변경 전에는 가능한 경우 dry-run 또는 check mode를 실행합니다.
99
- - 사용자가 다른 언어를 요청하지 않는 한, 사용자에게 보이는 응답과 생성 또는 갱신하는 문서, 계획, 메모리 산출물은 OS locale 언어로 작성합니다.
100
- - 기본적으로 작업당 검증은 최대 두 번만 수행합니다.
101
- - 게이트가 실패하면 한 번 진단하고, 작업을 줄이거나 sub-task로 나눈 뒤 두 게이트를 다시 실행합니다.
102
- - 두 번 실패한 뒤에는 blocker를 `docs/plan/<topic>.md`에 기록합니다.
103
- EOF
104
- else
105
- cat > "$plan" <<'EOF'
106
- # PLAN
107
-
108
- This file is a short index of active and completed work plans.
109
-
110
- ## Active Plans
111
-
112
- - Link detailed plans under `docs/plan/`.
113
-
114
- ## Completed Plans
115
-
116
- - Move completed topics here with evidence links.
117
-
118
- ## Planning Rules
119
-
120
- - Read project-root `MEMORY.md` first when it exists; if it is absent, continue without repository memory.
121
- - For non-trivial implementation or continuation of planned work, first write or restore a plan with `triage-plan` active and synchronize it before exploration. Known-target Git/GitHub operations stay plan/goal-free unless they require code edits, conflict resolution, destructive recovery, release/deploy, or design.
122
- - Plans must be decision-complete before implementation.
123
- - Split implementation into small module tasks.
124
- - Detect repository stack and required LSP/check tools before implementation.
125
- - Install or bootstrap missing required tools before declaring them unavailable.
126
- - Each task normally passes exactly two gates.
127
- - Module acceptance verification.
128
- - Surface integration verification.
129
- - Run dry-run or check mode before external-state mutation when available.
130
- - Write user-visible responses and generated or updated documentation, plans, and memory artifacts in the OS locale unless the user asks for another language.
131
- - Use at most two verification passes per task by default.
132
- - If a gate fails, diagnose once, shrink the task or split it into sub-tasks, and rerun both gates.
133
- - After two failed passes, record the blocker in `docs/plan/<topic>.md`.
134
- EOF
135
- fi
136
- fi
137
-
138
- case "$event" in
139
- session-start|user-prompt-submit)
140
- if is_ko; then
141
- printf '%s\n' "Cairn 컨텍스트: 프로젝트 루트 MEMORY.md가 있으면 읽고, 없으면 저장소 메모리 없이 계속 진행합니다."
142
- else
143
- printf '%s\n' "Cairn context: read project-root MEMORY.md first when present; if absent, continue without repository memory."
144
- fi
145
- ;;
146
- post-tool-use)
147
- if is_ko; then
148
- printf '%s\n' "Cairn 점검: 외부 상태 변경에는 dry-run/check 증거가 필요하고, 동작이 바뀌었다면 docs/plan 증거를 갱신하세요."
149
- else
150
- printf '%s\n' "Cairn check: external-state changes need dry-run/check evidence; if behavior changed, update docs/plan evidence."
151
- fi
152
- ;;
153
- stop|subagent-stop)
154
- if is_ko; then
155
- printf '%s\n' "Cairn 종료 게이트: 완료에는 docs/plan의 dry-run/check, 모듈 수용, 표면 통합 증거가 필요합니다."
156
- else
157
- printf '%s\n' "Cairn stop gate: completion requires dry-run/check, module acceptance, and surface integration evidence in docs/plan."
158
- fi
159
- ;;
160
- *)
161
- if is_ko; then
162
- printf '%s\n' "Cairn이 MEMORY.md, PLAN.md, docs/memory, docs/plan을 초기화했습니다."
163
- else
164
- printf '%s\n' "Cairn initialized MEMORY.md, PLAN.md, docs/memory, and docs/plan."
165
- fi
166
- ;;
167
- esac