@cairnkeep/cli 1.0.2
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.md +45 -0
- package/CONTRIBUTING.md +49 -0
- package/LICENSE +201 -0
- package/README.md +149 -0
- package/SECURITY.md +37 -0
- package/bin/cairn +73 -0
- package/claude/agents/code-reviewer.md +174 -0
- package/claude/agents/security-investigator.md +112 -0
- package/claude/agents/security-target-selector.md +90 -0
- package/claude/agents/security-validator.md +97 -0
- package/claude/agents/wiki-ingester.md +108 -0
- package/claude/agents/wiki-lint-auditor.md +94 -0
- package/claude/agents/wiki-query-analyst.md +84 -0
- package/claude/commands/context-explore.md +40 -0
- package/claude/commands/graphify.md +150 -0
- package/claude/commands/memory-review.md +85 -0
- package/claude/commands/memory-sync.md +71 -0
- package/claude/commands/recall.md +32 -0
- package/claude/commands/remember.md +43 -0
- package/claude/commands/repo-review.md +191 -0
- package/claude/commands/security-audit.md +174 -0
- package/claude/commands/wiki-ingest.md +112 -0
- package/claude/commands/wiki-lint.md +86 -0
- package/claude/commands/wiki-query.md +92 -0
- package/claude/hooks/context-explore-pretask.sh +93 -0
- package/claude/hooks/memory-capture.sh +59 -0
- package/claude/hooks/memory-recall.sh +84 -0
- package/claude/hooks/memory-wakeup.sh +45 -0
- package/docs/building-an-overlay.md +117 -0
- package/docs/domain-knowledge.md +86 -0
- package/docs/git-providers.md +36 -0
- package/docs/operating.md +366 -0
- package/mcp-memory-server/dist/embeddings.js +122 -0
- package/mcp-memory-server/dist/explore-cache.js +97 -0
- package/mcp-memory-server/dist/index.js +1256 -0
- package/mcp-memory-server/package.json +36 -0
- package/opencode/agents/code-reviewer.md +173 -0
- package/opencode/agents/security-investigator.md +111 -0
- package/opencode/agents/security-target-selector.md +89 -0
- package/opencode/agents/security-validator.md +96 -0
- package/opencode/agents/wiki-ingester.md +107 -0
- package/opencode/agents/wiki-lint-auditor.md +93 -0
- package/opencode/agents/wiki-query-analyst.md +83 -0
- package/opencode/command/code-review.md +199 -0
- package/opencode/command/context-explore.md +42 -0
- package/opencode/command/graphify.md +153 -0
- package/opencode/command/memory-review.md +44 -0
- package/opencode/command/memory-sync.md +94 -0
- package/opencode/command/recall.md +38 -0
- package/opencode/command/remember.md +46 -0
- package/opencode/command/security-audit.md +80 -0
- package/opencode/command/wiki-ingest.md +55 -0
- package/opencode/command/wiki-lint.md +51 -0
- package/opencode/command/wiki-query.md +50 -0
- package/opencode/plugins/memory-capture.ts +188 -0
- package/opencode/plugins/memory-recall.ts +132 -0
- package/opencode/plugins/memory-wakeup.ts +102 -0
- package/opencode/templates/security-finding-register.yaml.template +51 -0
- package/opencode/templates/security-issue.md.template +43 -0
- package/opencode/templates/security-policy.md.template +29 -0
- package/opencode/templates/security-report.md.template +43 -0
- package/opencode/templates/wiki-contradictions.md.template +31 -0
- package/opencode/templates/wiki-index.md.template +40 -0
- package/opencode/templates/wiki-lint-report.md.template +38 -0
- package/opencode/templates/wiki-log.md.template +11 -0
- package/opencode/templates/wiki-policy.md.template +47 -0
- package/opencode/templates/wiki-query-answer.md.template +26 -0
- package/opencode/templates/wiki-source-summary.md.template +33 -0
- package/opencode/workflows/memory-review-workflow.md +66 -0
- package/opencode/workflows/security-audit-workflow.md +197 -0
- package/opencode/workflows/wiki-ingest-workflow.md +149 -0
- package/opencode/workflows/wiki-lint-workflow.md +128 -0
- package/opencode/workflows/wiki-query-workflow.md +122 -0
- package/package.json +56 -0
- package/scripts/bootstrap.sh +99 -0
- package/scripts/doctor.sh +91 -0
- package/scripts/install-audit-timer.sh +68 -0
- package/scripts/lib/assert-tool-event.mjs +50 -0
- package/scripts/memory-store.sh +71 -0
- package/scripts/memory-wiki-audit.sh +156 -0
- package/scripts/sync-claude-assets.sh +182 -0
- package/scripts/sync-opencode-explore-assets.sh +187 -0
- package/scripts/sync-opencode-graphify-assets.sh +152 -0
- package/scripts/sync-opencode-memory-assets.sh +160 -0
- package/scripts/sync-opencode-plugin-assets.sh +163 -0
- package/scripts/sync-opencode-security-assets.sh +195 -0
- package/scripts/sync-opencode-wiki-assets.sh +250 -0
- package/scripts/test-audit-timer.sh +29 -0
- package/scripts/test-bootstrap-untracked.sh +41 -0
- package/scripts/test-cli-dispatch.sh +21 -0
- package/scripts/test-doctor.sh +32 -0
- package/scripts/test-launcher-hooks.sh +66 -0
- package/scripts/test-memory-store.sh +44 -0
- package/scripts/test-remember-recall-assertions.sh +70 -0
- package/scripts/transcript-to-text.mjs +53 -0
- package/scripts/verify-docs-parity.sh +112 -0
- package/scripts/verify-explore-maturation.sh +288 -0
- package/scripts/verify-fastcontext-reliability.sh +624 -0
- package/scripts/verify-no-private-references.sh +145 -0
- package/scripts/verify-opencode-live-parity.sh +864 -0
- package/scripts/verify-routing-seam.sh +169 -0
- package/scripts/verify-token-savings-ab.sh +557 -0
- package/templates/PROJECT-INSTRUCTIONS.md.template +42 -0
- package/templates/alignment-gap-register.yaml.template +56 -0
- package/templates/alignment-policy.md.template +28 -0
- package/templates/alignment-pr-template.md.template +18 -0
- package/templates/alignment-report.md.template +56 -0
- package/templates/env.example.template +25 -0
- package/templates/graph-policy.md.template +37 -0
- package/templates/graphs-gitignore.template +3 -0
- package/templates/memory-wiki-audit.service.template +6 -0
- package/templates/memory-wiki-audit.timer.template +9 -0
- package/templates/memory.json.template +4 -0
- package/templates/planning-config.json.template +6 -0
- package/templates/project-brief.md.template +40 -0
- package/templates/security-finding-register.yaml.template +51 -0
- package/templates/security-issue.md.template +43 -0
- package/templates/security-policy.md.template +29 -0
- package/templates/security-report.md.template +43 -0
- package/templates/start-claude.sh.template +46 -0
- package/templates/start-opencode.sh.template +41 -0
- package/templates/structured-change-canvas.md.template +63 -0
- package/templates/wiki-contradictions.md.template +31 -0
- package/templates/wiki-index.md.template +40 -0
- package/templates/wiki-lint-report.md.template +38 -0
- package/templates/wiki-log.md.template +11 -0
- package/templates/wiki-policy.md.template +47 -0
- package/templates/wiki-query-answer.md.template +26 -0
- package/templates/wiki-source-summary.md.template +33 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wiki-query-analyst
|
|
3
|
+
description: Answers repository questions from the compiled wiki first, then canonical raw sources, and optionally writes back a reusable derived answer. Spawned by /wiki-query.
|
|
4
|
+
tools: Read, Write, Edit, Grep, Glob, Bash
|
|
5
|
+
model: inherit
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<role>
|
|
9
|
+
You are the query analyst for the governed project wiki.
|
|
10
|
+
|
|
11
|
+
Your job is to answer one repository question by using the wiki as a navigation aid first and canonical raw sources second. If writeback is requested, store a reusable derived answer without presenting it as canonical truth.
|
|
12
|
+
|
|
13
|
+
If the prompt contains a `<required_reading>` block, read every listed file before doing anything else.
|
|
14
|
+
</role>
|
|
15
|
+
|
|
16
|
+
<project_context>
|
|
17
|
+
Before answering:
|
|
18
|
+
|
|
19
|
+
1. Read `./AGENTS.md` if it exists.
|
|
20
|
+
2. Read the supplied policy and index.
|
|
21
|
+
3. Use the index to shortlist relevant wiki pages before reading them.
|
|
22
|
+
4. Read canonical raw docs, tests, interfaces, config, or code whenever the wiki is missing, stale, contradictory, or insufficient.
|
|
23
|
+
</project_context>
|
|
24
|
+
|
|
25
|
+
<input_contract>
|
|
26
|
+
You will receive a `<wiki_assignment>` block containing:
|
|
27
|
+
- `project_root`
|
|
28
|
+
- `question`
|
|
29
|
+
- `writeback`
|
|
30
|
+
- `index_path`
|
|
31
|
+
- `log_path`
|
|
32
|
+
- `policy_path`
|
|
33
|
+
- `output_path`
|
|
34
|
+
- `timestamp`
|
|
35
|
+
- `branch`
|
|
36
|
+
- `project_name`
|
|
37
|
+
|
|
38
|
+
Treat `project_root` as the working directory. If the runtime spawned you elsewhere, change into `project_root` before reading or writing any relative paths.
|
|
39
|
+
</input_contract>
|
|
40
|
+
|
|
41
|
+
<retrieval_order>
|
|
42
|
+
Use this order:
|
|
43
|
+
|
|
44
|
+
1. `.planning/wiki/index.md`
|
|
45
|
+
2. relevant wiki pages under `sources/`, `topics/`, `entities/`, `queries/`, and recent lint reports when they clarify trust issues
|
|
46
|
+
3. cited canonical raw sources and any directly relevant repo files
|
|
47
|
+
|
|
48
|
+
Truth rules:
|
|
49
|
+
- raw repository docs, tests, interfaces, config, and code outrank derived wiki pages
|
|
50
|
+
- prior query writebacks are reusable hints, not proof by themselves
|
|
51
|
+
- when the wiki and raw sources disagree, preserve the contradiction and trust the raw sources
|
|
52
|
+
</retrieval_order>
|
|
53
|
+
|
|
54
|
+
<answer_rules>
|
|
55
|
+
In the final answer:
|
|
56
|
+
- lead with the best grounded conclusion
|
|
57
|
+
- preserve source references for the claims you rely on
|
|
58
|
+
- call out contradiction, ambiguity, or freshness risk explicitly
|
|
59
|
+
- avoid pretending the wiki settled something the raw sources do not support
|
|
60
|
+
</answer_rules>
|
|
61
|
+
|
|
62
|
+
<writeback_rules>
|
|
63
|
+
If `writeback` is true:
|
|
64
|
+
- write markdown to `output_path`
|
|
65
|
+
- start with `# Query: {short title}`
|
|
66
|
+
- include bullets for `Asked at`, `Question`, `Answer status`, and `Last reviewed`
|
|
67
|
+
- include sections named `Answer`, `Wiki Pages Consulted`, `Canonical Sources`, `Contradictions And Freshness Notes`, and `Suggested Follow-up`
|
|
68
|
+
- keep the artifact concise and citation-heavy
|
|
69
|
+
- update `.planning/wiki/index.md` once inside the `<!-- wiki:queries:start -->` and `<!-- wiki:queries:end -->` block when those markers exist
|
|
70
|
+
- if `- None yet.` is present inside the queries block and you are adding a real entry, replace it
|
|
71
|
+
- append one `wiki-query --writeback` entry to `.planning/wiki/log.md`, inside the `<!-- wiki:entries:start -->` and `<!-- wiki:entries:end -->` block when those markers exist
|
|
72
|
+
|
|
73
|
+
If `writeback` is false:
|
|
74
|
+
- do not modify files
|
|
75
|
+
</writeback_rules>
|
|
76
|
+
|
|
77
|
+
<critical_rules>
|
|
78
|
+
1. The wiki is derived, not canonical.
|
|
79
|
+
2. Index first, wiki pages second, raw sources third.
|
|
80
|
+
3. Preserve provenance in both the chat answer and any written artifact.
|
|
81
|
+
4. Do not smooth over contradictions.
|
|
82
|
+
5. Resolve all relative paths from `project_root`, not from the process cwd.
|
|
83
|
+
6. Return a concise grounded answer after finishing any requested writeback.
|
|
84
|
+
</critical_rules>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: On-demand token-efficient repo exploration via context_explore, returning compact citations
|
|
3
|
+
argument-hint: "<query> [repo path]"
|
|
4
|
+
allowed-tools: Bash, mcp__cairn-memory__context_explore
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<objective>
|
|
8
|
+
Answer a repo-exploration question with compact `path:line-range` citations from `context_explore`, without reading or summarizing the cited ranges yourself — that expansion is the caller's decision, not this command's.
|
|
9
|
+
</objective>
|
|
10
|
+
|
|
11
|
+
<context>
|
|
12
|
+
Arguments: $ARGUMENTS
|
|
13
|
+
|
|
14
|
+
The first token (or the full string if no path is given) is the query. An optional trailing path argument overrides the resolved repo root.
|
|
15
|
+
</context>
|
|
16
|
+
|
|
17
|
+
<process>
|
|
18
|
+
## 0. Resolve repo root
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
ROOT=$(git rev-parse --show-toplevel 2>/dev/null || true)
|
|
22
|
+
if [ -z "$ROOT" ]; then
|
|
23
|
+
echo "Not inside a git repository. /context-explore must run from a project repo."
|
|
24
|
+
exit 1
|
|
25
|
+
fi
|
|
26
|
+
cd "$ROOT"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
If `$ARGUMENTS` carries an optional trailing path token that is a valid path, use it to override `$ROOT`. The winning value becomes the explicit `repo_root` argument in step 1.
|
|
30
|
+
|
|
31
|
+
## 1. Call the tool
|
|
32
|
+
|
|
33
|
+
Call `context_explore` with `query` set to the question text from `$ARGUMENTS` (path override stripped) and `repo_root` set to the resolved path from step 0. `repo_root` MUST be passed explicitly — the MCP server's own working directory is not the target repo, so cwd and any environment default cannot be relied on.
|
|
34
|
+
|
|
35
|
+
## 2. Report
|
|
36
|
+
|
|
37
|
+
On success, relay the tool's `content[0].text` citation list verbatim, including its zero-citation note if that is what was returned. Do not read or summarize the cited ranges.
|
|
38
|
+
|
|
39
|
+
On failure, relay a one-line pass-through of the tool's error message (the thrown message, or `structuredContent.error`) — never a raw JSON dump, never a re-diagnosis of the cause.
|
|
40
|
+
</process>
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Build, rebuild, query, and inspect the project knowledge graph in .planning/graphs/"
|
|
3
|
+
argument-hint: "[build [--force]|query <term>|status|diff]"
|
|
4
|
+
allowed-tools: Read, Bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**STOP -- DO NOT READ THIS FILE. You are already reading it. This prompt was injected into your context by Claude Code's command system. Using the Read tool on this file wastes tokens. Begin executing Step 0 immediately.**
|
|
8
|
+
|
|
9
|
+
**graphify CLI:** the `graphify` subcommand is exposed by `gsd-tools` (on PATH). Invoke as `gsd-tools graphify …` as documented in this command and in `docs/CLI-TOOLS.md`. Other GSD queries use `gsd-tools <subcmd>` where a handler exists.
|
|
10
|
+
|
|
11
|
+
## Step 0 -- Banner
|
|
12
|
+
|
|
13
|
+
**Before ANY tool calls**, display this banner:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
GRAPHIFY
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Then proceed to Step 1.
|
|
20
|
+
|
|
21
|
+
## Step 1 -- Config Gate
|
|
22
|
+
|
|
23
|
+
Check if graphify is enabled by reading `.planning/config.json` directly using the Read tool.
|
|
24
|
+
|
|
25
|
+
**DO NOT use the gsd-tools config get-value command** -- it hard-exits on missing keys.
|
|
26
|
+
|
|
27
|
+
1. Read `.planning/config.json` using the Read tool
|
|
28
|
+
2. If the file does not exist: display the disabled message below and **STOP**
|
|
29
|
+
3. Parse the JSON content. Check if `config.graphify && config.graphify.enabled === true`
|
|
30
|
+
4. If `graphify.enabled` is NOT explicitly `true`: display the disabled message below and **STOP**
|
|
31
|
+
5. If `graphify.enabled` is `true`: proceed to Step 2
|
|
32
|
+
|
|
33
|
+
**Disabled message:**
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
GRAPHIFY
|
|
37
|
+
|
|
38
|
+
Knowledge graph is disabled. To activate:
|
|
39
|
+
|
|
40
|
+
gsd-tools config-set graphify.enabled true
|
|
41
|
+
|
|
42
|
+
Then run /graphify build to create the initial graph.
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Step 2 -- Parse Argument
|
|
48
|
+
|
|
49
|
+
Parse `$ARGUMENTS` to determine the operation mode:
|
|
50
|
+
|
|
51
|
+
| Argument | Action |
|
|
52
|
+
|----------|--------|
|
|
53
|
+
| `build` or `build --force` | Run inline build (Step 3) |
|
|
54
|
+
| `query <term>` | Run inline query (Step 2a) |
|
|
55
|
+
| `status` | Run inline status check (Step 2b) |
|
|
56
|
+
| `diff` | Run inline diff check (Step 2c) |
|
|
57
|
+
| No argument or unknown | Show usage message |
|
|
58
|
+
|
|
59
|
+
**Usage message** (shown when no argument or unrecognized argument):
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
GRAPHIFY
|
|
63
|
+
|
|
64
|
+
Usage: /graphify <mode>
|
|
65
|
+
|
|
66
|
+
Modes:
|
|
67
|
+
build [--force] Build or rebuild the knowledge graph
|
|
68
|
+
query <term> Search the graph for a term
|
|
69
|
+
status Show graph freshness and statistics
|
|
70
|
+
diff Show changes since last build
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Step 2a -- Query
|
|
74
|
+
|
|
75
|
+
Run:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
gsd-tools graphify query <term>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Parse the JSON output and display results:
|
|
82
|
+
- If the output contains `"disabled": true`, display the disabled message from Step 1 and **STOP**
|
|
83
|
+
- If the output contains `"error"` field, display the error message and **STOP**
|
|
84
|
+
- If no nodes found, display: `No graph matches for '<term>'. Try /graphify build to create or rebuild the graph.`
|
|
85
|
+
- Otherwise, display matched nodes grouped by type, with edge relationships and confidence tiers (EXTRACTED/INFERRED/AMBIGUOUS)
|
|
86
|
+
|
|
87
|
+
**STOP** after displaying results. Do not spawn an agent.
|
|
88
|
+
|
|
89
|
+
### Step 2b -- Status
|
|
90
|
+
|
|
91
|
+
Run:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
gsd-tools graphify status
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Parse the JSON output and display:
|
|
98
|
+
- If `exists: false`, display the message field
|
|
99
|
+
- Otherwise show last build time, node/edge/hyperedge counts, and STALE or FRESH indicator
|
|
100
|
+
|
|
101
|
+
**STOP** after displaying status. Do not spawn an agent.
|
|
102
|
+
|
|
103
|
+
### Step 2c -- Diff
|
|
104
|
+
|
|
105
|
+
Run:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
gsd-tools graphify diff
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Parse the JSON output and display:
|
|
112
|
+
- If `no_baseline: true`, display the message field
|
|
113
|
+
- Otherwise show node and edge change counts (added/removed/changed)
|
|
114
|
+
|
|
115
|
+
If no snapshot exists, suggest running `build` twice (first to create, second to generate a diff baseline).
|
|
116
|
+
|
|
117
|
+
**STOP** after displaying diff. Do not spawn an agent.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Step 3 -- Build (Inline)
|
|
122
|
+
|
|
123
|
+
Run:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
gsd-tools graphify build [--force]
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Parse the JSON output and display:
|
|
130
|
+
- If the output contains `"disabled": true`, display the disabled message from Step 1 and **STOP**
|
|
131
|
+
- If the output contains an `"error"` field, display the error and the `stage` field when present, then **STOP**
|
|
132
|
+
- Otherwise display the build summary using `status.last_build`, `status.node_count`, `status.edge_count`, `status.hyperedge_count`, whether the snapshot was saved, and whether a forced clean rebuild was used
|
|
133
|
+
|
|
134
|
+
This command now performs the full pipeline directly:
|
|
135
|
+
- runs `graphify update .` with legacy fallback to `graphify . --update`
|
|
136
|
+
- when `--force` is present, clears `graphify-out/`, published graph artifacts, and `.planning/graphs/.last-build-snapshot.json` first
|
|
137
|
+
- validates `graphify-out/graph.json`
|
|
138
|
+
- copies `graph.json`, `graph.html`, and `GRAPH_REPORT.md` into `.planning/graphs/`
|
|
139
|
+
- writes `.planning/graphs/.last-build-snapshot.json`
|
|
140
|
+
|
|
141
|
+
**STOP** after displaying the build result. Do not spawn an agent.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Anti-Patterns
|
|
146
|
+
|
|
147
|
+
1. DO NOT spawn an agent for graphify operations -- build/query/status/diff are handled directly
|
|
148
|
+
2. DO NOT modify graph files directly outside the graphify CLI path
|
|
149
|
+
3. DO NOT skip the config gate check
|
|
150
|
+
4. DO NOT use gsd-tools config get-value for the config gate -- it exits on missing keys
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Review staged memory candidates extracted from prior sessions and accept (write to AgentFS) or discard them
|
|
3
|
+
argument-hint: "[--all]"
|
|
4
|
+
allowed-tools: Read, Write, Edit, Bash, Grep, Glob, mcp__cairn-memory__memory_read, mcp__cairn-memory__memory_search, mcp__cairn-memory__memory_write, mcp__cairn-memory__memory_supersede
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<objective>
|
|
8
|
+
Review memory candidates that the SessionEnd hook (memory-capture.sh) extracted
|
|
9
|
+
automatically from prior sessions and staged under `.planning/memory-staging/`.
|
|
10
|
+
This is the accept gate between autonomous extraction and durable AgentFS writes:
|
|
11
|
+
no candidate becomes a memory fact until you accept it here.
|
|
12
|
+
|
|
13
|
+
Accepted candidates are written via the cairn-memory MCP (`memory_write`).
|
|
14
|
+
Discarded ones are deleted from staging. This keeps writes agent-gated (no
|
|
15
|
+
premature or auto writes) while making extraction fully automatic.
|
|
16
|
+
|
|
17
|
+
Argument handling:
|
|
18
|
+
- no args: review candidates from the most recent staged session
|
|
19
|
+
- `--all`: review candidates across all staged sessions
|
|
20
|
+
</objective>
|
|
21
|
+
|
|
22
|
+
<context>
|
|
23
|
+
Arguments: $ARGUMENTS
|
|
24
|
+
</context>
|
|
25
|
+
|
|
26
|
+
<process>
|
|
27
|
+
|
|
28
|
+
## 0. Initialize repo context
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
|
|
32
|
+
cd "$ROOT"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Resolve the staging dir: `$ROOT/.planning/memory-staging/`. If it does not exist or contains no `*.json`, report "No staged memory candidates to review" and stop.
|
|
36
|
+
|
|
37
|
+
## 1. Load staged candidates
|
|
38
|
+
|
|
39
|
+
- default: read the newest `*.json` file only
|
|
40
|
+
- `--all`: read every `*.json` file, oldest first
|
|
41
|
+
|
|
42
|
+
Each staged file is the JSON emitted by `mcp-memory-server extract`:
|
|
43
|
+
```json
|
|
44
|
+
{ "model": "...", "count": N, "candidates": [ { "key": "...", "value": "...", "category": "...", "importance": N, "rationale": "..." }, ... ] }
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Parse every candidate's `key`, `value`, `category`, `importance`, and `rationale`.
|
|
48
|
+
|
|
49
|
+
## 2. Review each candidate (judgment gate)
|
|
50
|
+
|
|
51
|
+
For each candidate, apply these acceptance rules:
|
|
52
|
+
- **Accept** when the claim is a durable, branch-safe, short fact/decision/pitfall/convention that future sessions would benefit from and that is not already in AgentFS. Check for duplicates by reading the existing project memory (use `memory_search` with the candidate's key/terms).
|
|
53
|
+
- **Skip/discard** when it is: branch-local or speculative, a restatement of code/config already canonical in the repo, trivial/transient, or already present in AgentFS.
|
|
54
|
+
|
|
55
|
+
For accepted candidates, classify the AgentFS scope:
|
|
56
|
+
- `project` for repo-specific facts (the default)
|
|
57
|
+
- `domain-engineering` for reusable engineering patterns/conventions
|
|
58
|
+
- `identity` only for user/identity facts
|
|
59
|
+
|
|
60
|
+
## 3. Write accepted candidates
|
|
61
|
+
|
|
62
|
+
For each accepted candidate, call the cairn-memory MCP:
|
|
63
|
+
```
|
|
64
|
+
memory_write(scope="<scope>", key="<candidate.key>", value="<candidate.value>", promote_to="<category if applicable>")
|
|
65
|
+
```
|
|
66
|
+
If a candidate supersedes an existing entry (same key, updated value), use `memory_supersede` instead of `memory_write`, with a `reason`.
|
|
67
|
+
|
|
68
|
+
## 4. Clear staging
|
|
69
|
+
|
|
70
|
+
- delete the staged files whose candidates have been fully reviewed (accepted or discarded)
|
|
71
|
+
- if `--all` was passed, clear the entire staging dir once review is complete
|
|
72
|
+
|
|
73
|
+
## 5. Report
|
|
74
|
+
|
|
75
|
+
Display a summary: N reviewed, N accepted (→ AgentFS), N discarded, N superseded. Note that accepted facts are now durable across both harnesses.
|
|
76
|
+
|
|
77
|
+
</process>
|
|
78
|
+
|
|
79
|
+
<success_criteria>
|
|
80
|
+
- [ ] Staging dir read; candidates parsed
|
|
81
|
+
- [ ] Each candidate judged against the acceptance rules (durable, branch-safe, non-duplicate)
|
|
82
|
+
- [ ] Accepted candidates written via memory_write / memory_supersede
|
|
83
|
+
- [ ] Reviewed staging files cleared
|
|
84
|
+
- [ ] No speculative, branch-local, or trivial claims written to AgentFS
|
|
85
|
+
</success_criteria>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Sync project memory (AgentFS via cairn-memory MCP, AnythingLLM) with current MR/PR state from your git provider
|
|
3
|
+
argument-hint: "[--dry-run] [--force]"
|
|
4
|
+
allowed-tools: Read, Grep, Glob, Bash, mcp__cairn-memory__memory_read, mcp__cairn-memory__memory_write, mcp__cairn-memory__memory_list, mcp__cairn-memory__domain_knowledge_sync
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Git provider: these steps use the git host set by `CAIRN_GIT_PROVIDER` (`github`/`gitlab`/`codeberg`/`forgejo`/`none`); resolve the operation-to-tool mapping from `docs/git-providers.md`. If it is `none` or unset, or no provider MCP is registered, skip the provider steps and continue locally.
|
|
8
|
+
|
|
9
|
+
<objective>
|
|
10
|
+
Sync durable memory with the current state of tracked MRs and PRs.
|
|
11
|
+
|
|
12
|
+
Output artifacts:
|
|
13
|
+
- Updated AgentFS keys (project scope): `internal-mrs-status`, `upstream-prs-status`
|
|
14
|
+
- Optional AnythingLLM sync if new docs were created
|
|
15
|
+
|
|
16
|
+
Flag handling:
|
|
17
|
+
- `--dry-run` — show what would change without writing
|
|
18
|
+
- `--force` — sync even if nothing appears changed (useful after manual edits)
|
|
19
|
+
|
|
20
|
+
This is an operational command. It reads live API state and writes to the memory store.
|
|
21
|
+
</objective>
|
|
22
|
+
|
|
23
|
+
<context>
|
|
24
|
+
Arguments: $ARGUMENTS
|
|
25
|
+
|
|
26
|
+
Default behavior:
|
|
27
|
+
1. Read the project memory config (`.agent/memory.json`, `.opencode/memory.json`, or `.claude/memory.json`) to determine scope and workspaces
|
|
28
|
+
2. Read AgentFS key `internal-mrs-status` (project scope) via the cairn-memory `memory_read` tool to get the tracked MR list
|
|
29
|
+
3. For each tracked MR, query the git-provider MCP for current state
|
|
30
|
+
4. Read AgentFS key `upstream-prs-status` via `memory_read` to get the tracked PR list
|
|
31
|
+
5. For each tracked PR, query the git-provider MCP for current state
|
|
32
|
+
6. Compare live state against stored state
|
|
33
|
+
7. If changed (or --force):
|
|
34
|
+
- Update AgentFS keys with current state via `memory_write`
|
|
35
|
+
- If `anythingllm_workspaces` is configured and new docs exist, offer `domain_knowledge_sync`
|
|
36
|
+
8. Print a summary of changes
|
|
37
|
+
|
|
38
|
+
Important rules:
|
|
39
|
+
- Never delete memory entries — only update them
|
|
40
|
+
- Preserve historical context (merged dates, close reasons) in updated entries
|
|
41
|
+
- If an API call fails, skip that item and continue with others
|
|
42
|
+
- Log the sync timestamp in updated entries
|
|
43
|
+
</context>
|
|
44
|
+
|
|
45
|
+
<process>
|
|
46
|
+
## 1. Read memory configuration
|
|
47
|
+
Read the project memory config to get scopes and `anythingllm_workspaces`. If no config file exists, default to scope `project` with no workspaces.
|
|
48
|
+
|
|
49
|
+
## 2. Extract tracked MRs and PRs from AgentFS
|
|
50
|
+
Use `memory_read` with scope `project` for keys `internal-mrs-status` and `upstream-prs-status`.
|
|
51
|
+
Parse the markdown to extract tracked items:
|
|
52
|
+
- MRs: `project_id` and `iid` (format: `!IID` in project `ID` or `PATH`)
|
|
53
|
+
- PRs: `owner/repo#NUMBER`
|
|
54
|
+
|
|
55
|
+
## 3. Query live state
|
|
56
|
+
For each tracked MR, use the git-provider MCP tools to capture: state, draft, assignees, merge_status, updated_at, latest discussion notes (last 3).
|
|
57
|
+
For each tracked PR, call the provider's "get change state" tool from the operation map (e.g. `get_pull_request`) and capture: state, merged, updated_at, comments count.
|
|
58
|
+
|
|
59
|
+
## 4. Compare and diff
|
|
60
|
+
Compare each item's live state against the stored AgentFS state: state changes (open→merged, open→closed), assignee changes, new discussion notes/comments, draft status changes, merge status changes.
|
|
61
|
+
|
|
62
|
+
## 5. Write updates
|
|
63
|
+
If `--dry-run`, print the diff and stop.
|
|
64
|
+
|
|
65
|
+
Otherwise:
|
|
66
|
+
- Update AgentFS `internal-mrs-status` and `upstream-prs-status` via `memory_write` (preserve historical notes)
|
|
67
|
+
- If `anythingllm_workspaces` is configured and new `.md` files exist in the repo that are not yet synced, offer `domain_knowledge_sync` (do not auto-sync)
|
|
68
|
+
|
|
69
|
+
## 6. Print summary
|
|
70
|
+
Output a compact table: each tracked item, current state, changed (yes/no), notable change.
|
|
71
|
+
</process>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Recall known info across memory layers (AgentFS project scope, wiki index, optional AnythingLLM)
|
|
3
|
+
argument-hint: "<question or topic>"
|
|
4
|
+
allowed-tools: Read, Grep, Glob, mcp__cairn-memory__memory_read, mcp__cairn-memory__memory_search, mcp__cairn-memory__domain_knowledge_query
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<objective>
|
|
8
|
+
Cross-layer read companion to the automatic SessionStart wakeup. Use mid-session when the task shifts and you need stored context the wakeup did not surface.
|
|
9
|
+
</objective>
|
|
10
|
+
|
|
11
|
+
<context>
|
|
12
|
+
Question or topic: $ARGUMENTS
|
|
13
|
+
|
|
14
|
+
Read order (canonical sources still win over derived layers):
|
|
15
|
+
1. AgentFS project scope (short accepted facts)
|
|
16
|
+
2. Wiki index and derived pages (.planning/wiki/)
|
|
17
|
+
3. AnythingLLM workspaces (only if repo docs and memory are insufficient)
|
|
18
|
+
</context>
|
|
19
|
+
|
|
20
|
+
<process>
|
|
21
|
+
## 1. AgentFS
|
|
22
|
+
`memory_search` scope `project` with $ARGUMENTS. If nothing relevant, retry scope `all`.
|
|
23
|
+
|
|
24
|
+
## 2. Wiki
|
|
25
|
+
Read `.planning/wiki/index.md` if present and follow links relevant to $ARGUMENTS.
|
|
26
|
+
|
|
27
|
+
## 3. AnythingLLM (optional)
|
|
28
|
+
Only if 1 and 2 are insufficient and the answer likely lives in long-form docs: `domain_knowledge_query` against the project workspace from the memory config.
|
|
29
|
+
|
|
30
|
+
## 4. Report
|
|
31
|
+
Summarize what each layer returned in a few lines. If layers disagree, prefer the canonical raw source and note the staleness.
|
|
32
|
+
</process>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Persist a durable finding across memory layers (AgentFS + file memory), flagging wiki/AnythingLLM candidates
|
|
3
|
+
argument-hint: "<the fact to remember>"
|
|
4
|
+
allowed-tools: Read, Write, Edit, Grep, Glob, mcp__cairn-memory__memory_read, mcp__cairn-memory__memory_search, mcp__cairn-memory__memory_write, mcp__cairn-memory__memory_supersede
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<objective>
|
|
8
|
+
Persist one durable, accepted finding so future sessions recall it without being asked.
|
|
9
|
+
|
|
10
|
+
This is the write half of the memory loop. It writes the fact to the layers that hold short structured facts (AgentFS project scope + the Claude file-memory), and it only flags the document layers (wiki, AnythingLLM) as candidates rather than writing to them blindly, because those are compiled or embedded from canonical sources.
|
|
11
|
+
</objective>
|
|
12
|
+
|
|
13
|
+
<context>
|
|
14
|
+
Fact to remember: $ARGUMENTS
|
|
15
|
+
|
|
16
|
+
Layer shapes (do not treat as four copies of the same thing):
|
|
17
|
+
- AgentFS project scope: short key/value facts, accepted and branch-safe. Direct write.
|
|
18
|
+
- File-memory (`~/.claude/projects/<encoded-cwd>/memory/`): markdown, auto-loaded each session. Direct write.
|
|
19
|
+
- Wiki (`.planning/wiki/`): derived synthesis, compiled via /wiki-ingest. Not a raw-fact store.
|
|
20
|
+
- AnythingLLM: document embeddings, refreshed via domain_knowledge_sync. Not a raw-fact store.
|
|
21
|
+
</context>
|
|
22
|
+
|
|
23
|
+
<process>
|
|
24
|
+
## 1. Guard
|
|
25
|
+
If $ARGUMENTS is empty, ask what to remember and stop. Do not invent a fact.
|
|
26
|
+
|
|
27
|
+
## 2. Dedupe before writing
|
|
28
|
+
Run `memory_search` (scope `project`) on the key terms of the fact. If a near-duplicate key exists, update that entry instead of creating a new one.
|
|
29
|
+
|
|
30
|
+
## 3. Write AgentFS (project scope)
|
|
31
|
+
If step 2 found a near-duplicate key that should keep its prior value for audit/debugging, use `memory_supersede` on that key. Otherwise use `memory_write` scope `project` with a short kebab-case key and the fact as value. Convert relative dates to absolute. No em dashes or double-hyphen dashes (use commas or full stops).
|
|
32
|
+
|
|
33
|
+
## 4. Write file-memory
|
|
34
|
+
Append or update a one-file-one-fact note under the project memory directory and add a one-line pointer to its `MEMORY.md` index. Skip if the fact is already covered there.
|
|
35
|
+
|
|
36
|
+
## 5. Flag document layers (do not auto-run)
|
|
37
|
+
- If the fact is stable, doc-worthy synthesis of a canonical source, suggest `/wiki-ingest <path>`.
|
|
38
|
+
- If a repo document changed and retrieval should reflect it, suggest `domain_knowledge_sync`.
|
|
39
|
+
State the suggestion in one line each; do not execute them here.
|
|
40
|
+
|
|
41
|
+
## 6. Confirm
|
|
42
|
+
Print: the AgentFS key written, the file-memory file touched, and any flagged candidates.
|
|
43
|
+
</process>
|