cairn-ai 0.1.4 → 0.1.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 +2 -2
- package/.agents/workflows/cairn-plan.md +15 -14
- package/.agents/workflows/cairn-review.md +2 -2
- package/.agents/workflows/cairn-work.md +14 -13
- package/.claude/agents/explorer.md +2 -0
- package/.claude/agents/worker.md +2 -0
- package/.claude/commands/cairn-plan.md +1 -1
- package/.claude/commands/cairn-work.md +1 -1
- package/.codex-plugin/plugin.json +5 -3
- package/agents/explorer.md +2 -0
- package/agents/worker.md +2 -0
- package/commands/cairn-memory.md +2 -2
- package/commands/cairn-plan.md +15 -14
- package/commands/cairn-review.md +2 -2
- package/commands/cairn-work.md +14 -13
- package/package.json +1 -1
- package/scripts/cairn-state.mjs +13 -4
- package/scripts/cairn-state.sh +3 -2
- package/scripts/cairn-toolcheck.mjs +8 -2
- package/scripts/cairn.mjs +11 -5
- package/skills/cairn-memory/SKILL.md +3 -1
- package/skills/cairn-plan/SKILL.md +22 -15
- package/skills/cairn-review/SKILL.md +3 -1
- package/skills/cairn-work/SKILL.md +21 -18
- package/templates/work-plan.md +9 -0
|
@@ -7,9 +7,9 @@ Goal: create or update repository memory without asking the user for discoverabl
|
|
|
7
7
|
Procedure:
|
|
8
8
|
|
|
9
9
|
1. Ensure `MEMORY.md`, `PLAN.md`, `docs/memory`, and `docs/plan`.
|
|
10
|
-
2.
|
|
10
|
+
2. Every agent must read the project-root `MEMORY.md` for domain knowledge and repository policy before assigned discovery or update work.
|
|
11
11
|
3. Explore repository facts with focused tools.
|
|
12
|
-
4. Use `explorer` for read-only domain discovery and contradiction checks when available; use `worker` for exact references, command checks, and bounded evidence capture.
|
|
12
|
+
4. Use `explorer` for read-only domain discovery and contradiction checks when available; use `worker` for exact references, command checks, and bounded evidence capture. Tell every delegated agent to read the project-root `MEMORY.md` before work.
|
|
13
13
|
5. Write details to `docs/memory/<domain>.md`.
|
|
14
14
|
6. Keep `MEMORY.md` as a short index.
|
|
15
15
|
7. Use the OS locale for user-visible output unless the user asks for another language.
|
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
Use the `cairn-plan` skill.
|
|
4
4
|
|
|
5
|
-
Goal: leave a decision-complete plan for the current task in files.
|
|
5
|
+
Goal: leave a decision-complete plan for the current task in files before non-trivial implementation.
|
|
6
6
|
|
|
7
7
|
Procedure:
|
|
8
8
|
|
|
9
|
-
1.
|
|
10
|
-
2.
|
|
11
|
-
3.
|
|
12
|
-
4.
|
|
13
|
-
5.
|
|
14
|
-
6.
|
|
15
|
-
7.
|
|
16
|
-
8. Use
|
|
17
|
-
9. Use `
|
|
18
|
-
10.
|
|
19
|
-
11.
|
|
20
|
-
12.
|
|
21
|
-
13.
|
|
9
|
+
1. Every agent must read the project-root `MEMORY.md` for domain knowledge and repository policy before repository exploration, tool selection, work, or delegation.
|
|
10
|
+
2. Read relevant `docs/memory/*.md`.
|
|
11
|
+
3. If the active or assigned model is Claude-family, read `docs/model-guidance/claude.md`; if Codex-family, read `docs/model-guidance/codex.md`.
|
|
12
|
+
4. Run `node scripts/cairn.mjs toolcheck` when available.
|
|
13
|
+
5. If required LSP/check tools are missing, run `node scripts/cairn.mjs toolcheck --install` or a repository-native install command before accepting a fallback.
|
|
14
|
+
6. Explore before asking the user.
|
|
15
|
+
7. Run complexity triage before applying agent, plugin, or delegated workflow guidance, and record it before mutating files.
|
|
16
|
+
8. Use Light Path by default unless a Heavy Path condition clearly applies.
|
|
17
|
+
9. Use `explorer` for independent read-only discovery, impact analysis, pattern search, and read-only verification when available.
|
|
18
|
+
10. Use `worker` for bounded implementation or verification tasks with clear file ownership. Tell every delegated agent to read the project-root `MEMORY.md` before work. Keep urgent blocking work local.
|
|
19
|
+
11. Write `docs/plan/<topic>.md`.
|
|
20
|
+
12. Add the topic link and status to `PLAN.md`.
|
|
21
|
+
13. Put the selected Light/Heavy Path, checked Heavy Path signals, tool readiness, module acceptance verification, and surface integration verification on every module slice.
|
|
22
|
+
14. Use the OS locale for user-visible output unless the user asks for another language.
|
|
@@ -6,9 +6,9 @@ Goal: review completed work against plan, memory, policy, and evidence.
|
|
|
6
6
|
|
|
7
7
|
Procedure:
|
|
8
8
|
|
|
9
|
-
1.
|
|
9
|
+
1. Every agent must read the project-root `MEMORY.md` for domain knowledge and repository policy before review work, then read the plan slice and memory inputs.
|
|
10
10
|
2. Check changed files, tool readiness evidence, and verification evidence.
|
|
11
|
-
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.
|
|
11
|
+
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. Tell every delegated agent to read the project-root `MEMORY.md` before work.
|
|
12
12
|
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.
|
|
13
13
|
5. Record review evidence in `docs/plan/<topic>.md`.
|
|
14
14
|
6. Use the OS locale for user-visible output unless the user asks for another language.
|
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
Use the `cairn-work` skill.
|
|
4
4
|
|
|
5
|
-
Goal: execute the next incomplete module slice in `PLAN.md
|
|
5
|
+
Goal: execute the next incomplete module slice in `PLAN.md` without bypassing the recorded complexity triage.
|
|
6
6
|
|
|
7
7
|
Procedure:
|
|
8
8
|
|
|
9
|
-
1.
|
|
10
|
-
2. Read the
|
|
11
|
-
3.
|
|
12
|
-
4.
|
|
13
|
-
5. Confirm
|
|
14
|
-
6.
|
|
15
|
-
7. For
|
|
16
|
-
8.
|
|
17
|
-
9.
|
|
18
|
-
10. Re-run
|
|
19
|
-
11.
|
|
20
|
-
12.
|
|
9
|
+
1. Every agent must read the project-root `MEMORY.md` for domain knowledge and repository policy before selecting or executing a slice.
|
|
10
|
+
2. Read `PLAN.md`, the detailed plan, and relevant memory notes.
|
|
11
|
+
3. Read the Codex or Claude model guidance recorded in the plan.
|
|
12
|
+
4. Select one small module slice.
|
|
13
|
+
5. Confirm required tool readiness. If a required LSP/check tool is missing, run `node scripts/cairn.mjs toolcheck --install` or a repository-native install command before accepting a fallback.
|
|
14
|
+
6. Confirm the complexity triage and selected Light/Heavy Path recorded in the plan. If missing, update the plan before mutating files.
|
|
15
|
+
7. For Light Path, implement directly or use one bounded `worker`, then run focused verification.
|
|
16
|
+
8. For Heavy Path, follow the plan's staged implementation and review gates without role-mapping shortcuts.
|
|
17
|
+
9. When delegating implementation to `worker`, state the file ownership clearly, tell every delegated agent to read the project-root `MEMORY.md` before work, and tell the worker not to revert others' edits.
|
|
18
|
+
10. Re-run module acceptance verification.
|
|
19
|
+
11. Re-run surface integration verification.
|
|
20
|
+
12. Record tool readiness and verification evidence in `docs/plan/<topic>.md` and update `PLAN.md`.
|
|
21
|
+
13. Use the OS locale for user-visible output unless the user asks for another language.
|
package/.claude/agents/worker.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# cairn-plan
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Start by reading the project-root `MEMORY.md`, then create or update `PLAN.md` and `docs/plan/<topic>.md` before non-trivial implementation, including Light/Heavy Path complexity triage and tool readiness.
|
|
4
4
|
|
|
5
5
|
Follow plugin command `commands/cairn-plan.md`.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# cairn-work
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Start by reading the project-root `MEMORY.md`, then execute the next incomplete module slice only after the plan records Light/Heavy Path complexity triage, tool readiness, module acceptance verification, and surface integration verification.
|
|
4
4
|
|
|
5
5
|
Follow plugin command `commands/cairn-work.md`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cairn",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Token-efficient agent harness with tool readiness for Codex, Claude Code, and Antigravity.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "WkNam"
|
|
@@ -22,9 +22,11 @@
|
|
|
22
22
|
],
|
|
23
23
|
"defaultPrompt": [
|
|
24
24
|
"Use Cairn to create MEMORY.md and PLAN.md for this repository.",
|
|
25
|
+
"At the start of each task, every agent must read the project-root MEMORY.md for domain knowledge and repository policy before planning, implementation, review, or delegation.",
|
|
25
26
|
"Run cairn-toolcheck before planning implementation work.",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
27
|
+
"Before non-trivial implementation, run cairn-plan for this task without asking me for discoverable facts.",
|
|
28
|
+
"Record Light Path or Heavy Path complexity triage in docs/plan/<topic>.md before mutating files.",
|
|
29
|
+
"Run cairn-work from the current PLAN.md and pass dry-run/check, module acceptance, and surface integration gates."
|
|
28
30
|
]
|
|
29
31
|
}
|
|
30
32
|
}
|
package/agents/explorer.md
CHANGED
|
@@ -9,6 +9,8 @@ tools: Read, Grep, Glob, Bash
|
|
|
9
9
|
|
|
10
10
|
Handle read-only discovery and verification tasks.
|
|
11
11
|
|
|
12
|
+
Before doing any assigned task, read the project-root `MEMORY.md`. Treat it as the domain knowledge and repository policy index, then read only the relevant `docs/memory/*.md` notes needed for the task.
|
|
13
|
+
|
|
12
14
|
Use for:
|
|
13
15
|
|
|
14
16
|
- Codebase questions.
|
package/agents/worker.md
CHANGED
|
@@ -9,6 +9,8 @@ tools: Read, Grep, Glob, Bash, Write, Edit, MultiEdit
|
|
|
9
9
|
|
|
10
10
|
Handle narrow, focused tasks.
|
|
11
11
|
|
|
12
|
+
Before doing any assigned task, read the project-root `MEMORY.md`. Treat it as the domain knowledge and repository policy index, then read only the relevant `docs/memory/*.md` notes needed for the task.
|
|
13
|
+
|
|
12
14
|
Use for:
|
|
13
15
|
|
|
14
16
|
- Finding exact files and symbols.
|
package/commands/cairn-memory.md
CHANGED
|
@@ -9,9 +9,9 @@ Goal: create or update repository memory without asking the user for discoverabl
|
|
|
9
9
|
Procedure:
|
|
10
10
|
|
|
11
11
|
1. Run the plugin state initialization script.
|
|
12
|
-
2.
|
|
12
|
+
2. Every agent must read the project-root `MEMORY.md` for domain knowledge and repository policy before assigned discovery or update work.
|
|
13
13
|
3. Explore repository facts with focused tools.
|
|
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.
|
|
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. Tell every delegated agent to read the project-root `MEMORY.md` before work.
|
|
15
15
|
5. Write details to `docs/memory/<domain>.md`.
|
|
16
16
|
6. Keep `MEMORY.md` as a short index.
|
|
17
17
|
7. Use the OS locale for user-visible output unless the user asks for another language.
|
package/commands/cairn-plan.md
CHANGED
|
@@ -4,20 +4,21 @@ Use the `cairn-plan` skill.
|
|
|
4
4
|
|
|
5
5
|
Prerequisite: if `node scripts/cairn.mjs doctor` fails, restore installation with `node scripts/cairn.mjs install` or `node scripts/cairn.mjs upgrade`.
|
|
6
6
|
|
|
7
|
-
Goal: leave a decision-complete plan for the current task in files.
|
|
7
|
+
Goal: leave a decision-complete plan for the current task in files before non-trivial implementation.
|
|
8
8
|
|
|
9
9
|
Procedure:
|
|
10
10
|
|
|
11
|
-
1.
|
|
12
|
-
2.
|
|
13
|
-
3.
|
|
14
|
-
4.
|
|
15
|
-
5.
|
|
16
|
-
6.
|
|
17
|
-
7.
|
|
18
|
-
8. Use
|
|
19
|
-
9. Use `
|
|
20
|
-
10.
|
|
21
|
-
11.
|
|
22
|
-
12.
|
|
23
|
-
13.
|
|
11
|
+
1. Every agent must read the project-root `MEMORY.md` for domain knowledge and repository policy before repository exploration, tool selection, work, or delegation.
|
|
12
|
+
2. Read relevant `docs/memory/*.md`.
|
|
13
|
+
3. If the active or assigned model is Claude-family, read `docs/model-guidance/claude.md`; if Codex-family, read `docs/model-guidance/codex.md`.
|
|
14
|
+
4. Run `node scripts/cairn.mjs toolcheck` when available.
|
|
15
|
+
5. If required LSP/check tools are missing, run `node scripts/cairn.mjs toolcheck --install` or a repository-native install command before accepting a fallback.
|
|
16
|
+
6. Explore before asking the user.
|
|
17
|
+
7. Run complexity triage before applying agent, plugin, or delegated workflow guidance, and record it before mutating files.
|
|
18
|
+
8. Use Light Path by default unless a Heavy Path condition clearly applies.
|
|
19
|
+
9. Use `explorer` for independent read-only discovery, impact analysis, pattern search, and read-only verification when available.
|
|
20
|
+
10. Use `worker` for bounded implementation or verification tasks with clear file ownership. Tell every delegated agent to read the project-root `MEMORY.md` before work. Keep urgent blocking work local.
|
|
21
|
+
11. Write `docs/plan/<topic>.md`.
|
|
22
|
+
12. Add the topic link and status to `PLAN.md`.
|
|
23
|
+
13. Put the selected Light/Heavy Path, checked Heavy Path signals, tool readiness, module acceptance verification, and surface integration verification on every module slice.
|
|
24
|
+
14. Use the OS locale for user-visible output unless the user asks for another language.
|
package/commands/cairn-review.md
CHANGED
|
@@ -8,9 +8,9 @@ Goal: review completed work against plan, memory, policy, and evidence.
|
|
|
8
8
|
|
|
9
9
|
Procedure:
|
|
10
10
|
|
|
11
|
-
1.
|
|
11
|
+
1. Every agent must read the project-root `MEMORY.md` for domain knowledge and repository policy before review work, then read the plan slice and memory inputs.
|
|
12
12
|
2. Check changed files, tool readiness evidence, and verification evidence.
|
|
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.
|
|
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. Tell every delegated agent to read the project-root `MEMORY.md` before work.
|
|
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.
|
|
15
15
|
5. Record review evidence in `docs/plan/<topic>.md`.
|
|
16
16
|
6. Use the OS locale for user-visible output unless the user asks for another language.
|
package/commands/cairn-work.md
CHANGED
|
@@ -4,19 +4,20 @@ Use the `cairn-work` skill.
|
|
|
4
4
|
|
|
5
5
|
Prerequisite: if `node scripts/cairn.mjs doctor` fails, restore installation with `node scripts/cairn.mjs install` or `node scripts/cairn.mjs upgrade`.
|
|
6
6
|
|
|
7
|
-
Goal: execute the next incomplete module slice in `PLAN.md
|
|
7
|
+
Goal: execute the next incomplete module slice in `PLAN.md` without bypassing the recorded complexity triage.
|
|
8
8
|
|
|
9
9
|
Procedure:
|
|
10
10
|
|
|
11
|
-
1.
|
|
12
|
-
2. Read the
|
|
13
|
-
3.
|
|
14
|
-
4.
|
|
15
|
-
5. Confirm
|
|
16
|
-
6.
|
|
17
|
-
7. For
|
|
18
|
-
8.
|
|
19
|
-
9.
|
|
20
|
-
10. Re-run
|
|
21
|
-
11.
|
|
22
|
-
12.
|
|
11
|
+
1. Every agent must read the project-root `MEMORY.md` for domain knowledge and repository policy before selecting or executing a slice.
|
|
12
|
+
2. Read `PLAN.md`, the detailed plan, and relevant memory notes.
|
|
13
|
+
3. Read the Codex or Claude model guidance recorded in the plan.
|
|
14
|
+
4. Select one small module slice.
|
|
15
|
+
5. Confirm required tool readiness. If a required LSP/check tool is missing, run `node scripts/cairn.mjs toolcheck --install` or a repository-native install command before accepting a fallback.
|
|
16
|
+
6. Confirm the complexity triage and selected Light/Heavy Path recorded in the plan. If missing, update the plan before mutating files.
|
|
17
|
+
7. For Light Path, implement directly or use one bounded `worker`, then run focused verification.
|
|
18
|
+
8. For Heavy Path, follow the plan's staged implementation and review gates without role-mapping shortcuts.
|
|
19
|
+
9. When delegating implementation to `worker`, state the file ownership clearly, tell every delegated agent to read the project-root `MEMORY.md` before work, and tell the worker not to revert others' edits.
|
|
20
|
+
10. Re-run module acceptance verification.
|
|
21
|
+
11. Re-run surface integration verification.
|
|
22
|
+
12. Record tool readiness and verification evidence in `docs/plan/<topic>.md` and update `PLAN.md`.
|
|
23
|
+
13. Use the OS locale for user-visible output unless the user asks for another language.
|
package/package.json
CHANGED
package/scripts/cairn-state.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
2
3
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
4
|
import { join, resolve } from "node:path";
|
|
4
|
-
import { pathToFileURL } from "node:url";
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
6
|
|
|
6
7
|
const memoryTemplate = `# MEMORY
|
|
7
8
|
|
|
@@ -39,7 +40,10 @@ This file is a short index of active and completed work plans.
|
|
|
39
40
|
|
|
40
41
|
## Planning Rules
|
|
41
42
|
|
|
43
|
+
- Every agent must start assigned work by reading the project-root \`MEMORY.md\` for domain knowledge and repository policy.
|
|
42
44
|
- Plans must be decision-complete before implementation.
|
|
45
|
+
- Run complexity triage before applying agent, plugin, or delegated workflow guidance.
|
|
46
|
+
- Record the selected Light Path or Heavy Path and the checked Heavy Path signals in \`docs/plan/<topic>.md\`.
|
|
43
47
|
- Split implementation into small module slices.
|
|
44
48
|
- Detect repository stack and required LSP/check tools before implementation.
|
|
45
49
|
- Install or bootstrap missing required tools before declaring them unavailable.
|
|
@@ -67,8 +71,8 @@ export async function runState(event = "manual", { root = process.env.HARNESS_RE
|
|
|
67
71
|
const ko = locale.toLowerCase().startsWith("ko");
|
|
68
72
|
if (event === "session-start" || event === "user-prompt-submit") {
|
|
69
73
|
return ko
|
|
70
|
-
? "Cairn 컨텍스트:
|
|
71
|
-
: "Cairn context:
|
|
74
|
+
? "Cairn 컨텍스트: 모든 에이전트는 작업 시작 시 도메인 지식과 정책 색인인 프로젝트 루트 MEMORY.md를 먼저 읽어야 합니다."
|
|
75
|
+
: "Cairn context: every agent must start by reading the project-root MEMORY.md for domain knowledge and repository policy.";
|
|
72
76
|
}
|
|
73
77
|
if (event === "post-tool-use") {
|
|
74
78
|
return ko
|
|
@@ -99,5 +103,10 @@ function localeValue() {
|
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
function isCliEntry() {
|
|
102
|
-
|
|
106
|
+
if (!process.argv[1]) return false;
|
|
107
|
+
try {
|
|
108
|
+
return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1]);
|
|
109
|
+
} catch {
|
|
110
|
+
return import.meta.url === pathToFileURL(process.argv[1]).href;
|
|
111
|
+
}
|
|
103
112
|
}
|
package/scripts/cairn-state.sh
CHANGED
|
@@ -51,6 +51,7 @@ This file is a short index of active and completed work plans.
|
|
|
51
51
|
|
|
52
52
|
## Planning Rules
|
|
53
53
|
|
|
54
|
+
- Every agent must start assigned work by reading the project-root `MEMORY.md` for domain knowledge and repository policy.
|
|
54
55
|
- Plans must be decision-complete before implementation.
|
|
55
56
|
- Split implementation into small module slices.
|
|
56
57
|
- Detect repository stack and required LSP/check tools before implementation.
|
|
@@ -75,9 +76,9 @@ is_ko() {
|
|
|
75
76
|
case "$event" in
|
|
76
77
|
session-start|user-prompt-submit)
|
|
77
78
|
if is_ko; then
|
|
78
|
-
printf '%s\n' "Cairn 컨텍스트:
|
|
79
|
+
printf '%s\n' "Cairn 컨텍스트: 모든 에이전트는 작업 시작 시 도메인 지식과 정책 색인인 프로젝트 루트 MEMORY.md를 먼저 읽어야 합니다."
|
|
79
80
|
else
|
|
80
|
-
printf '%s\n' "Cairn context:
|
|
81
|
+
printf '%s\n' "Cairn context: every agent must start by reading the project-root MEMORY.md for domain knowledge and repository policy."
|
|
81
82
|
fi
|
|
82
83
|
;;
|
|
83
84
|
post-tool-use)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
2
3
|
import { readdir, stat } from "node:fs/promises";
|
|
3
4
|
import { join, relative, sep } from "node:path";
|
|
4
5
|
import { spawnSync } from "node:child_process";
|
|
5
|
-
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
7
|
|
|
7
8
|
if (isCliEntry()) {
|
|
8
9
|
const root = process.cwd();
|
|
@@ -233,7 +234,12 @@ export function shouldUseShell(command, platform = process.platform) {
|
|
|
233
234
|
}
|
|
234
235
|
|
|
235
236
|
function isCliEntry() {
|
|
236
|
-
|
|
237
|
+
if (!process.argv[1]) return false;
|
|
238
|
+
try {
|
|
239
|
+
return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1]);
|
|
240
|
+
} catch {
|
|
241
|
+
return import.meta.url === pathToFileURL(process.argv[1]).href;
|
|
242
|
+
}
|
|
237
243
|
}
|
|
238
244
|
|
|
239
245
|
function normalizePath(path) {
|
package/scripts/cairn.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
2
3
|
import { dirname, join } from "node:path";
|
|
3
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
5
|
import { spawnSync } from "node:child_process";
|
|
@@ -47,21 +48,26 @@ function localeValue() {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
function isCliEntry() {
|
|
50
|
-
|
|
51
|
+
if (!process.argv[1]) return false;
|
|
52
|
+
try {
|
|
53
|
+
return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1]);
|
|
54
|
+
} catch {
|
|
55
|
+
return import.meta.url === pathToFileURL(process.argv[1]).href;
|
|
56
|
+
}
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
const messages = {
|
|
54
60
|
en: {
|
|
55
61
|
memory: "Use the cairn-memory skill. Keep MEMORY.md as a short index and write details to docs/memory/<domain>.md.",
|
|
56
|
-
plan: "Use the cairn-plan skill. Keep PLAN.md as an index
|
|
57
|
-
work: "Use the cairn-work skill. Execute one module slice and capture module and surface evidence.",
|
|
62
|
+
plan: "Use the cairn-plan skill before non-trivial implementation. Every agent must first read the project-root MEMORY.md for domain knowledge and repository policy. Keep PLAN.md as an index, write detailed plans to docs/plan/<topic>.md, and record Light/Heavy Path triage before any mutation.",
|
|
63
|
+
work: "Use the cairn-work skill only after a plan exists. Every agent must first read the project-root MEMORY.md for domain knowledge and repository policy. Execute one module slice using the recorded Light/Heavy Path route, and capture dry-run/check, module, and surface evidence.",
|
|
58
64
|
review: "Use the cairn-review skill. Compare evidence against PLAN.md and MEMORY.md.",
|
|
59
65
|
usage: "Usage: cairn install|upgrade|doctor|uninstall|init|memory|plan|work|review|toolcheck",
|
|
60
66
|
},
|
|
61
67
|
ko: {
|
|
62
68
|
memory: "cairn-memory 스킬을 사용하세요. MEMORY.md는 짧은 색인으로, 상세 내용은 docs/memory/<domain>.md에 기록합니다.",
|
|
63
|
-
plan: "cairn-plan 스킬을 사용하세요. PLAN.md는 색인으로, 상세 계획은 docs/plan/<topic>.md에
|
|
64
|
-
work: "cairn-work 스킬을 사용하세요. 하나의 모듈 조각을
|
|
69
|
+
plan: "중요 구현 전에는 cairn-plan 스킬을 사용하세요. 모든 에이전트는 도메인 지식과 저장소 정책을 위해 프로젝트 루트 MEMORY.md를 먼저 읽어야 합니다. PLAN.md는 색인으로, 상세 계획은 docs/plan/<topic>.md에 기록하며 파일 변경 전 Light/Heavy Path 트리아지를 남깁니다.",
|
|
70
|
+
work: "계획이 있을 때만 cairn-work 스킬을 사용하세요. 모든 에이전트는 도메인 지식과 저장소 정책을 위해 프로젝트 루트 MEMORY.md를 먼저 읽어야 합니다. 기록된 Light/Heavy Path 경로로 하나의 모듈 조각을 실행하며 dry-run/check, 모듈, 표면 증거를 확보합니다.",
|
|
65
71
|
review: "cairn-review 스킬을 사용하세요. PLAN.md와 MEMORY.md 기준으로 증거를 비교합니다.",
|
|
66
72
|
usage: "사용법: cairn install|upgrade|doctor|uninstall|init|memory|plan|work|review|toolcheck",
|
|
67
73
|
},
|
|
@@ -11,6 +11,8 @@ Use this when domain knowledge, repository policy, or pre-plan context compressi
|
|
|
11
11
|
|
|
12
12
|
The root `MEMORY.md` is an index, not detailed knowledge. Record details in `docs/memory/<domain>.md`.
|
|
13
13
|
|
|
14
|
+
Every delegated agent must read the project-root `MEMORY.md` before doing its assigned discovery, evidence, or update task.
|
|
15
|
+
|
|
14
16
|
## Procedure
|
|
15
17
|
|
|
16
18
|
1. Run `node scripts/cairn-state.mjs manual` if it exists. Otherwise ensure `MEMORY.md`, `PLAN.md`, `docs/memory`, and `docs/plan` directly.
|
|
@@ -28,7 +30,7 @@ The root `MEMORY.md` is an index, not detailed knowledge. Record details in `doc
|
|
|
28
30
|
TASK: Explore persistent domain knowledge for <domain>.
|
|
29
31
|
EXPECTED OUTCOME: Return facts, source paths, and proof commands concisely.
|
|
30
32
|
REQUIRED TOOLS: Read-only file search, LSP/symbol tools, command checks.
|
|
31
|
-
MUST DO: Preserve proper nouns exactly. Cite local paths. Separate facts from inference. Use the OS locale for user-visible text.
|
|
33
|
+
MUST DO: Read the project-root `MEMORY.md` before doing assigned work. Preserve proper nouns exactly. Cite local paths. Separate facts from inference. Use the OS locale for user-visible text.
|
|
32
34
|
MUST NOT DO: Edit files. Ask the user. Guess missing names.
|
|
33
35
|
CONTEXT: Current task, repository root, existing MEMORY.md entries.
|
|
34
36
|
```
|
|
@@ -1,34 +1,39 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cairn-plan
|
|
3
|
-
description:
|
|
3
|
+
description: Use before non-trivial implementation, refactoring, migrations, debugging, repository automation, or any request that asks to plan, design, implement carefully, triage complexity, or coordinate agents. Creates decision-complete PLAN.md and docs/plan plans through repository evidence and bounded delegation instead of user questions.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Cairn Plan
|
|
7
7
|
|
|
8
|
-
Use this
|
|
8
|
+
Use this before non-trivial implementation, refactoring, migrations, debugging, or repository automation. Also use it when the user asks for planning, design, "설계부터", "신중하게", "꼼꼼히", complexity triage, or coordinated agent work.
|
|
9
9
|
|
|
10
10
|
## Purpose
|
|
11
11
|
|
|
12
12
|
Plans must reduce execution tokens. Do not leave long plans only in chat. Store the topic in `PLAN.md` and details in `docs/plan/<topic>.md`.
|
|
13
13
|
|
|
14
|
+
Every planning run starts by reading the project-root `MEMORY.md`. Treat it as the repository policy and domain-knowledge index before exploring or delegating work. Every delegated agent must also read the project-root `MEMORY.md` before doing its assigned task.
|
|
15
|
+
|
|
16
|
+
Do not treat planning as optional for implementation work that is more than a narrow single-file fix. If the current request can change behavior, architecture, data, external state, or multiple files, produce or update a plan artifact before mutation.
|
|
17
|
+
|
|
14
18
|
## Procedure
|
|
15
19
|
|
|
16
20
|
1. Run `node scripts/cairn-state.mjs manual` if it exists. Otherwise ensure `MEMORY.md`, `PLAN.md`, `docs/memory`, and `docs/plan` directly.
|
|
17
|
-
2. Read
|
|
18
|
-
3.
|
|
19
|
-
4.
|
|
20
|
-
5.
|
|
21
|
-
6.
|
|
22
|
-
7.
|
|
23
|
-
8.
|
|
24
|
-
9.
|
|
21
|
+
2. Read the project-root `MEMORY.md` before repository exploration, tool selection, or delegation.
|
|
22
|
+
3. Read only the relevant `docs/memory/*.md` files referenced by `MEMORY.md` or required by the current task.
|
|
23
|
+
4. Based on the active or assigned model, read `docs/model-guidance/README.md` and only the relevant model guidance.
|
|
24
|
+
5. Run `node scripts/cairn.mjs toolcheck` when available, or `scripts/cairn-toolcheck.mjs` directly, to identify repository stacks and required tools.
|
|
25
|
+
6. If LSP, typecheck, lint, dry-run, or verification tools are missing, run `node scripts/cairn.mjs toolcheck --install` or the closest repository-native install command before treating the tool as unavailable.
|
|
26
|
+
7. Explore the repository with focused search and LSP/symbol tools after tool readiness is confirmed.
|
|
27
|
+
8. Identify the closest available dry-run or check mode for every slice that can mutate external state.
|
|
28
|
+
9. Run complexity triage before applying workflow guidance from agents, plugins, or delegated roles. Record the route before any implementation slice.
|
|
29
|
+
10. Delegate according to the selected path and model guidance instead of asking the user.
|
|
25
30
|
- Use `explorer` for independent read-only codebase discovery, impact analysis, pattern searches, and read-only verification that can run in parallel when the current tool list supports it.
|
|
26
31
|
- Use `worker` for bounded implementation slices with clear file ownership, disjoint write scope, or verification tasks that can run while the main session continues.
|
|
27
32
|
- Keep urgent blocking work local when the next step depends immediately on the result.
|
|
28
|
-
- Tell workers they are not alone in the codebase and must not revert others' edits.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
- Tell every delegated agent to read the project-root `MEMORY.md` before work, and tell workers they are not alone in the codebase and must not revert others' edits.
|
|
34
|
+
11. Create `docs/plan/<topic>.md` from `templates/work-plan.md`.
|
|
35
|
+
12. Add a short index entry to `PLAN.md`.
|
|
36
|
+
13. Write user-visible output in the OS locale unless the user asks for another language.
|
|
32
37
|
|
|
33
38
|
## Complexity Triage
|
|
34
39
|
|
|
@@ -81,6 +86,7 @@ Heavy Path flow: plan -> pre-implementation review -> bounded `worker` implement
|
|
|
81
86
|
- Selected path.
|
|
82
87
|
- Selection rationale.
|
|
83
88
|
- Heavy Path conditions found, if any.
|
|
89
|
+
- Heavy Path conditions checked and not found.
|
|
84
90
|
- Roles or delegation omitted in Light Path and why.
|
|
85
91
|
- Pre-implementation decisions that review must resolve in Heavy Path.
|
|
86
92
|
|
|
@@ -88,6 +94,7 @@ Heavy Path flow: plan -> pre-implementation review -> bounded `worker` implement
|
|
|
88
94
|
|
|
89
95
|
- Every plan must be decision-complete.
|
|
90
96
|
- Every plan must include complexity triage and the selected path.
|
|
97
|
+
- Every plan must explicitly list Heavy Path signals checked, even when Light Path is selected.
|
|
91
98
|
- Every plan must include applied model guidance and rationale.
|
|
92
99
|
- Every plan must include tool readiness results: detected stack, required LSP/check tools, installed tools, and blockers.
|
|
93
100
|
- Every implementation slice must be small enough to verify with two checks.
|
|
@@ -125,7 +132,7 @@ Prefer repository-native dry-run and check modes before mutating external state.
|
|
|
125
132
|
TASK: Produce <role> input needed for the <topic> plan.
|
|
126
133
|
EXPECTED OUTCOME: Return concrete decisions, file paths, dependencies, risks, and evidence requirements.
|
|
127
134
|
REQUIRED TOOLS: Read-only repository exploration, tool readiness checks, LSP/symbol tools, local command checks.
|
|
128
|
-
MUST DO: Preserve proper nouns exactly. Prefer repository evidence. Install or bootstrap missing required tools before declaring them unavailable. Identify assumptions. Use `explorer` for read-only discovery and `worker` for bounded implementation or verification when available and useful. Tell workers they are not alone in the codebase and must not revert others' edits. Use the OS locale for user-visible text.
|
|
135
|
+
MUST DO: Read the project-root `MEMORY.md` before doing assigned work. Preserve proper nouns exactly. Prefer repository evidence. Install or bootstrap missing required tools before declaring them unavailable. Identify assumptions. Use `explorer` for read-only discovery and `worker` for bounded implementation or verification when available and useful. Tell every delegated agent to read the project-root `MEMORY.md` before work. Tell workers they are not alone in the codebase and must not revert others' edits. Use the OS locale for user-visible text.
|
|
129
136
|
MUST NOT DO: Edit production code. Ask the user. Expand scope.
|
|
130
137
|
CONTEXT: User request, MEMORY.md, relevant docs/memory notes, applied model guidance, repository root.
|
|
131
138
|
```
|
|
@@ -11,6 +11,8 @@ Use this after meaningful implementation with Cairn.
|
|
|
11
11
|
|
|
12
12
|
Review is not another implementation loop. Confirm that the completed slice satisfies the plan and that memory and plan artifacts are useful to the next agent.
|
|
13
13
|
|
|
14
|
+
Every review run and every delegated review agent must read the project-root `MEMORY.md` before doing assigned work.
|
|
15
|
+
|
|
14
16
|
## Procedure
|
|
15
17
|
|
|
16
18
|
1. Read the completed slice in `docs/plan/<topic>.md`.
|
|
@@ -29,7 +31,7 @@ Review is not another implementation loop. Confirm that the completed slice sati
|
|
|
29
31
|
TASK: Review correctness, scope, and evidence for slice <slice-id>.
|
|
30
32
|
EXPECTED OUTCOME: Findings ordered by severity with file and line references, or an explicit no-issue result with residual risk.
|
|
31
33
|
REQUIRED TOOLS: Read-only diff inspection, tool readiness checks, verification command execution, plan/memory reading.
|
|
32
|
-
MUST DO: 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 text.
|
|
34
|
+
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 text.
|
|
33
35
|
MUST NOT DO: Edit files. Ask the user. Approve skipped LSP/typecheck/lint without install evidence. Approve missing evidence or open-ended verification loops.
|
|
34
36
|
CONTEXT: docs/plan/<topic>.md, MEMORY.md, relevant docs/memory notes, changed files.
|
|
35
37
|
```
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cairn-work
|
|
3
|
-
description:
|
|
3
|
+
description: Use after cairn-plan to execute the next incomplete docs/plan module slice with the recorded Light/Heavy Path route, bounded worker delegation, dry-run/check evidence, and two verification gates.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Cairn Work
|
|
7
7
|
|
|
8
|
-
Use this to implement a plan created by `cairn-plan`.
|
|
8
|
+
Use this to implement a plan created by `cairn-plan`. Do not use this as a shortcut around planning; if no plan exists for non-trivial implementation, run `cairn-plan` first.
|
|
9
9
|
|
|
10
10
|
## Purpose
|
|
11
11
|
|
|
12
12
|
Execute only one module slice at a time. Instead of a repeated red-green loop, prove a small slice with two strong verification gates.
|
|
13
13
|
|
|
14
|
+
Every work run starts by reading the project-root `MEMORY.md` before choosing or executing a slice. Every delegated agent must also read the project-root `MEMORY.md` before doing its assigned task.
|
|
15
|
+
|
|
14
16
|
## Procedure
|
|
15
17
|
|
|
16
|
-
1. Read
|
|
17
|
-
2. Read the `docs/
|
|
18
|
-
3.
|
|
19
|
-
4.
|
|
20
|
-
5.
|
|
21
|
-
6.
|
|
22
|
-
7.
|
|
23
|
-
8. For
|
|
24
|
-
9.
|
|
25
|
-
10.
|
|
26
|
-
11.
|
|
27
|
-
12.
|
|
28
|
-
13.
|
|
29
|
-
14.
|
|
30
|
-
15.
|
|
18
|
+
1. Read the project-root `MEMORY.md` first.
|
|
19
|
+
2. Read `PLAN.md`, the selected `docs/plan/<topic>.md`, and relevant memory notes.
|
|
20
|
+
3. Read the `docs/model-guidance/*.md` inputs recorded in the plan.
|
|
21
|
+
4. Select the first incomplete module slice.
|
|
22
|
+
5. Confirm that required LSP, typecheck, lint, dry-run, and verification tools are available from the plan's tool readiness section.
|
|
23
|
+
6. If a required tool is missing, run `node scripts/cairn.mjs toolcheck --install` or the closest repository-native install command, then rerun the tool before continuing.
|
|
24
|
+
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.
|
|
25
|
+
8. For Light Path, implement directly or delegate to one bounded `worker`; keep the verification gate.
|
|
26
|
+
9. For Heavy Path, follow the full planning and review pipeline recorded in the plan. Run pre-implementation review before mutation and read-only review after evidence exists.
|
|
27
|
+
10. Delegate implementation to `worker` with exact files, ownership, constraints, and model-specific adjustment rules. Tell every delegated agent to read the project-root `MEMORY.md` before work. Use `explorer` for parallel read-only discovery or verification when available and useful.
|
|
28
|
+
11. Before mutating external state, run the slice dry-run or check command when one is recorded. If none exists, record the absence and continue with the smallest reversible command available.
|
|
29
|
+
12. `worker` must return changed files, tool readiness result, dry-run or check result when applicable, module acceptance command and result, surface integration command or QA artifact, and cleanup notes.
|
|
30
|
+
13. Re-run both verification gates directly.
|
|
31
|
+
14. Apply the bounded loop policy when a gate fails.
|
|
32
|
+
15. Record evidence in the plan file before marking the slice complete.
|
|
33
|
+
16. Write user-visible output in the OS locale unless the user asks for another language.
|
|
31
34
|
|
|
32
35
|
## Builder Prompt Format
|
|
33
36
|
|
|
@@ -35,7 +38,7 @@ Execute only one module slice at a time. Instead of a repeated red-green loop, p
|
|
|
35
38
|
TASK: Implement slice <slice-id> for <topic>.
|
|
36
39
|
EXPECTED OUTCOME: Minimal code or documentation change satisfying the slice contract.
|
|
37
40
|
REQUIRED TOOLS: Scoped file editing, tool readiness checks, existing test/build commands, surface QA commands.
|
|
38
|
-
MUST DO:
|
|
41
|
+
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. Install or bootstrap missing required tools before declaring them unavailable. Run dry-run or check mode before external-state mutation when available. Provide module evidence and surface evidence. Use the OS locale for user-visible text.
|
|
39
42
|
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. Claim completion without evidence. Modify files outside the assigned ownership.
|
|
40
43
|
CONTEXT: docs/plan/<topic>.md slice, relevant docs/memory notes, applied model guidance, exact files, verification commands.
|
|
41
44
|
```
|
package/templates/work-plan.md
CHANGED
|
@@ -23,6 +23,15 @@ Describe the observable result.
|
|
|
23
23
|
|
|
24
24
|
- Selected path: Light Path or Heavy Path.
|
|
25
25
|
- Selection rationale:
|
|
26
|
+
- Heavy Path signals checked:
|
|
27
|
+
- New directory/module/layer:
|
|
28
|
+
- New domain model/service/abstraction:
|
|
29
|
+
- Security/auth/session:
|
|
30
|
+
- External API/message queue/payment:
|
|
31
|
+
- DB schema/migration:
|
|
32
|
+
- Concurrency/transaction/cache invalidation:
|
|
33
|
+
- Cross-domain refactor:
|
|
34
|
+
- Explicit extra-care signal:
|
|
26
35
|
- Heavy Path trigger, if selected:
|
|
27
36
|
- Omitted delegation in Light Path, if applicable:
|
|
28
37
|
- Pre-implementation decisions:
|