@stackmemoryai/stackmemory 1.10.4 → 1.12.0

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 (95) hide show
  1. package/README.md +104 -23
  2. package/dist/src/cli/claude-sm.js +266 -84
  3. package/dist/src/cli/codex-sm.js +185 -33
  4. package/dist/src/cli/commands/bench.js +209 -2
  5. package/dist/src/cli/commands/cache.js +126 -0
  6. package/dist/src/cli/commands/daemon.js +41 -0
  7. package/dist/src/cli/commands/handoff.js +40 -9
  8. package/dist/src/cli/commands/onboard.js +70 -3
  9. package/dist/src/cli/commands/optimize.js +117 -0
  10. package/dist/src/cli/commands/orchestrate.js +230 -5
  11. package/dist/src/cli/commands/orchestrator.js +312 -24
  12. package/dist/src/cli/commands/pack.js +322 -0
  13. package/dist/src/cli/commands/search.js +40 -1
  14. package/dist/src/cli/commands/setup.js +177 -7
  15. package/dist/src/cli/commands/skills.js +10 -1
  16. package/dist/src/cli/commands/state.js +265 -0
  17. package/dist/src/cli/commands/wiki.js +33 -0
  18. package/dist/src/cli/gemini-sm.js +19 -29
  19. package/dist/src/cli/index.js +90 -29
  20. package/dist/src/cli/opencode-sm.js +38 -21
  21. package/dist/src/cli/utils/determinism-watcher.js +66 -0
  22. package/dist/src/cli/utils/real-cli-bin.js +44 -0
  23. package/dist/src/core/cache/content-cache.js +238 -0
  24. package/dist/src/core/cache/index.js +11 -0
  25. package/dist/src/core/cache/token-estimator.js +16 -0
  26. package/dist/src/core/context/frame-database.js +38 -30
  27. package/dist/src/core/cross-search/cross-project-search.js +269 -0
  28. package/dist/src/core/{merge → cross-search}/index.js +6 -4
  29. package/dist/src/core/database/sqlite-adapter.js +0 -83
  30. package/dist/src/core/extensions/provider-adapter.js +5 -0
  31. package/dist/src/core/models/model-router.js +22 -2
  32. package/dist/src/core/monitoring/logger.js +2 -1
  33. package/dist/src/core/optimization/trace-optimizer.js +413 -0
  34. package/dist/src/core/provenance/confidence-scorer.js +128 -0
  35. package/dist/src/core/provenance/index.js +40 -0
  36. package/dist/src/core/provenance/provenance-store.js +194 -0
  37. package/dist/src/core/provenance/types.js +82 -0
  38. package/dist/src/core/session/project-handoff.js +64 -0
  39. package/dist/src/core/session/session-manager.js +28 -0
  40. package/dist/src/core/shared-state/canonical-store.js +564 -0
  41. package/dist/src/core/skill-packs/index.js +18 -0
  42. package/dist/src/core/skill-packs/parser.js +42 -0
  43. package/dist/src/core/skill-packs/registry.js +224 -0
  44. package/dist/src/core/skill-packs/types.js +66 -0
  45. package/dist/src/core/trace/trace-event-store.js +282 -0
  46. package/dist/src/core/trace/trace-event.js +4 -0
  47. package/dist/src/core/wiki/wiki-compiler.js +219 -0
  48. package/dist/src/daemon/daemon-config.js +7 -0
  49. package/dist/src/daemon/services/github-service.js +126 -0
  50. package/dist/src/daemon/unified-daemon.js +30 -0
  51. package/dist/src/features/sweep/pty-wrapper.js +13 -5
  52. package/dist/src/hooks/schemas.js +2 -0
  53. package/dist/src/integrations/claude-code/subagent-client.js +89 -0
  54. package/dist/src/integrations/github/pr-state.js +158 -0
  55. package/dist/src/integrations/linear/client.js +4 -1
  56. package/dist/src/integrations/mcp/handlers/cross-search-handlers.js +188 -0
  57. package/dist/src/integrations/mcp/handlers/index.js +40 -59
  58. package/dist/src/integrations/mcp/server.js +425 -311
  59. package/dist/src/integrations/mcp/tool-alias-registry.js +370 -0
  60. package/dist/src/integrations/mcp/tool-definitions.js +98 -229
  61. package/dist/src/integrations/ralph/context/stackmemory-context-loader.js +3 -40
  62. package/dist/src/integrations/ralph/learning/pattern-learner.js +1 -20
  63. package/dist/src/integrations/ralph/swarm/swarm-coordinator.js +0 -2
  64. package/dist/src/mcp/stackmemory-mcp-server.js +315 -0
  65. package/dist/src/orchestrators/multimodal/determinism.js +243 -0
  66. package/dist/src/orchestrators/multimodal/harness.js +147 -77
  67. package/dist/src/orchestrators/multimodal/providers.js +44 -3
  68. package/dist/src/utils/hook-installer.js +8 -8
  69. package/package.json +10 -1
  70. package/packs/coding/python-fastapi/instructions.md +60 -0
  71. package/packs/coding/python-fastapi/pack.yaml +28 -0
  72. package/packs/coding/typescript-react/instructions.md +47 -0
  73. package/packs/coding/typescript-react/pack.yaml +28 -0
  74. package/packs/core/commands/capture.md +32 -0
  75. package/packs/core/commands/learn.md +73 -0
  76. package/packs/core/commands/next.md +36 -0
  77. package/packs/core/commands/restart.md +58 -0
  78. package/packs/core/commands/restore.md +29 -0
  79. package/packs/core/commands/start.md +57 -0
  80. package/packs/core/commands/stop.md +65 -0
  81. package/packs/core/commands/summary.md +40 -0
  82. package/packs/core/manifest.json +24 -0
  83. package/packs/ops/decision-recovery/instructions.md +65 -0
  84. package/packs/ops/decision-recovery/pack.yaml +89 -0
  85. package/templates/claude-hooks/doc-ingest.js +76 -0
  86. package/dist/src/cli/commands/team.js +0 -168
  87. package/dist/src/core/context/shared-context-layer.js +0 -620
  88. package/dist/src/core/context/stack-merge-resolver.js +0 -748
  89. package/dist/src/core/merge/conflict-detector.js +0 -430
  90. package/dist/src/core/merge/resolution-engine.js +0 -557
  91. package/dist/src/core/merge/stack-diff.js +0 -531
  92. package/dist/src/core/merge/unified-merge-resolver.js +0 -302
  93. package/dist/src/integrations/mcp/handlers/cord-handlers.js +0 -397
  94. package/dist/src/integrations/mcp/handlers/team-handlers.js +0 -211
  95. /package/dist/src/core/{merge → cache}/types.js +0 -0
@@ -0,0 +1,73 @@
1
+ # /learn — Review session and identify what to update
2
+
3
+ Run /summary internally, then audit what scripts, skills, commands, or memories need updating based on this session's work.
4
+
5
+ ## Execution
6
+
7
+ ### Phase 1: Session Review (silent)
8
+
9
+ Internally run the /summary logic — review conversation history for all actions, decisions, patterns, and corrections. Do NOT output the summary separately.
10
+
11
+ ### Phase 2: Audit (parallel)
12
+
13
+ Compare session activity against persistent artifacts:
14
+
15
+ 1. **Memory** — Read `MEMORY.md` from project memory dir
16
+ - Any new patterns, gotchas, or decisions that should be saved?
17
+ - Any existing memories now stale or contradicted by this session?
18
+ - Any user corrections/feedback worth persisting?
19
+
20
+ 2. **CLAUDE.md** — Read project and global CLAUDE.md
21
+ - Any new commands, paths, or conventions discovered?
22
+ - Any documented patterns that are now wrong?
23
+
24
+ 3. **Skills/Commands** — Glob `~/.claude/commands/*.md` and project `.claude/commands/*.md`
25
+ - Any skills that broke or need updating?
26
+ - Any new workflow worth turning into a skill?
27
+
28
+ 4. **Scripts** — Check `scripts/`, `.husky/`, hook files
29
+ - Any scripts created or modified this session?
30
+ - Any hooks that failed and need fixing?
31
+
32
+ 5. **Wiki** — If wiki exists, check for stale articles
33
+ - Any new entities or concepts from this session?
34
+
35
+ ### Phase 3: Report
36
+
37
+ Output in this format:
38
+
39
+ ```
40
+ ## Session Learnings
41
+
42
+ **What happened:**
43
+ - [1-line per action/outcome]
44
+
45
+ **Updates needed:**
46
+
47
+ | Target | Action | Detail |
48
+ |--------|--------|--------|
49
+ | memory/X.md | create/update/delete | [what and why] |
50
+ | CLAUDE.md | update | [section + change] |
51
+ | commands/X.md | create/update | [what] |
52
+ | scripts/X | update | [what] |
53
+ | wiki/X.md | create/update | [what] |
54
+
55
+ **No action needed:**
56
+ - [artifacts reviewed but current]
57
+ ```
58
+
59
+ ### Phase 4: Execute (with confirmation)
60
+
61
+ Ask: "Apply these updates? (all / pick / skip)"
62
+
63
+ - **all**: Apply every update in the table
64
+ - **pick**: Let user select which ones
65
+ - **skip**: Report only, no changes
66
+
67
+ ## Rules
68
+
69
+ - Don't create memories for ephemeral task details — only durable learnings
70
+ - Don't update CLAUDE.md for one-off patterns — only if it'll recur
71
+ - Bias toward updating existing memories over creating new ones
72
+ - Keep the report under 30 lines — dense, not verbose
73
+ - If nothing needs updating, say so in one line and stop
@@ -0,0 +1,36 @@
1
+ # /next — What should I do next?
2
+
3
+ Read context and suggest the highest-impact next action.
4
+
5
+ ## Context to gather (parallel)
6
+
7
+ 1. **Git state**: `git status`, `git branch --show-current`, `git log --oneline -3`
8
+ 2. **Open PR for branch**: `/opt/homebrew/bin/gh pr view --json title,state,reviews,checks 2>/dev/null`
9
+ 3. **GHA status**: `/opt/homebrew/bin/gh run list --branch $(git branch --show-current) --limit 1 --json status,conclusion,name 2>/dev/null`
10
+ 4. **Memory**: Read `MEMORY.md` and `project_todos_queue.md` from the project memory directory
11
+ 5. **Uncommitted work**: `git diff --stat HEAD`
12
+
13
+ ## Decision logic
14
+
15
+ Evaluate in priority order. Pick the FIRST that applies:
16
+
17
+ 1. **Uncommitted changes exist** → suggest commit or continue current work
18
+ 2. **PR open + CI failing** → suggest fix CI failures
19
+ 3. **PR open + Greptile comments** → suggest `/greptile-fix`
20
+ 4. **PR open + CI passing + no reviews** → suggest waiting or starting next task
21
+ 5. **On feature branch, no PR** → suggest `/pr`
22
+ 6. **On master, clean** → suggest next task from queue (pick highest priority unchecked item)
23
+
24
+ ## Output format
25
+
26
+ ```
27
+ ## Next up
28
+
29
+ [One sentence: what to do and why]
30
+
31
+ A) [Primary action — the recommendation]
32
+ B) [Alternative action]
33
+ C) [Skip — pick something else from queue]
34
+ ```
35
+
36
+ Always present A/B/C options. Keep it to 5 lines max. No preamble.
@@ -0,0 +1,58 @@
1
+ # /restart — Close session, clear context, and reboot
2
+
3
+ Chain `/stop done` → `/clear` → `/start` in one command. Use when switching contexts or resetting after a long session.
4
+
5
+ ## Usage
6
+
7
+ `$ARGUMENTS` — optional: `quick` (skip /learn, just capture + clear + start)
8
+
9
+ ## Execution
10
+
11
+ ### Phase 1: Stop (condensed)
12
+
13
+ Run /stop logic with `done` mode:
14
+
15
+ 1. **Summary** — Review all actions, decisions, files changed (hold output)
16
+ 2. **Capture** — Run `stackmemory capture --no-commit`
17
+ - If uncommitted changes exist, ask: "Commit before restart? (y/n)"
18
+ - If yes: commit, re-capture
19
+ 3. **Learn** — Unless `quick` argument was passed:
20
+ - Audit memory, CLAUDE.md, skills for needed updates
21
+ - Apply non-controversial updates automatically
22
+ - Ask for confirmation on new memories or CLAUDE.md changes
23
+ 4. Output the stop summary (keep under 15 lines):
24
+
25
+ ```
26
+ ## Closing session
27
+
28
+ **Done:** [1-3 bullet summary]
29
+ **Captured:** [yes/no]
30
+ **Updates:** [applied/none]
31
+ ```
32
+
33
+ ### Phase 2: Clear
34
+
35
+ Tell the user: "Clearing context. Starting fresh session..."
36
+
37
+ Then run `/clear` to reset the conversation context.
38
+
39
+ ### Phase 3: Start
40
+
41
+ Run full /start logic:
42
+
43
+ 1. **Context Load** (parallel):
44
+ - Git state: branch, log, status, stash list
45
+ - Restore: `stackmemory restore --no-copy`
46
+ - Open PRs: `gh pr list --author @me --state open --limit 5`
47
+ - Memory: review MEMORY.md
48
+ 2. **Situational Awareness** — branch state, handoff, PRs, stashes
49
+ 3. **Output** — standard /start format with branch, commits, next steps
50
+
51
+ ## Rules
52
+
53
+ - If /stop capture fails, warn but continue — don't block the restart
54
+ - Never force-clear with uncommitted work — always ask first
55
+ - If `quick` mode, skip /learn entirely (saves ~30s)
56
+ - The /clear step resets conversation context — everything after is a fresh start
57
+ - Total output: stop summary (15 lines) + start output (25 lines)
58
+ - If any phase fails, continue to the next — report errors inline
@@ -0,0 +1,29 @@
1
+ # /restore — Restore session context via StackMemory
2
+
3
+ Run `stackmemory restore` to load context from the last handoff and resume where you left off.
4
+
5
+ ## Usage
6
+
7
+ `$ARGUMENTS` — optional flags passed directly to `stackmemory restore`.
8
+
9
+ ## Behavior
10
+
11
+ 1. Run `stackmemory restore $ARGUMENTS`
12
+ 2. Read the restored handoff prompt
13
+ 3. Use the restored context to understand current state: branch, in-progress work, blockers, next steps
14
+ 4. Run `stackmemory status` to confirm project state
15
+ 5. Summarize what was restored and suggest next actions
16
+
17
+ ## Common flags
18
+
19
+ | Flag | Effect |
20
+ |------|--------|
21
+ | `--no-copy` | Don't copy prompt to clipboard |
22
+ | `--force` | Restore even if branch doesn't match |
23
+
24
+ ## Examples
25
+
26
+ ```
27
+ /restore # Restore last handoff
28
+ /restore --force # Restore even on different branch
29
+ ```
@@ -0,0 +1,57 @@
1
+ # /start — Boot a session with full context
2
+
3
+ Load memory, restore last handoff, review recent history, and suggest what to work on.
4
+
5
+ ## Execution
6
+
7
+ Run all phases. Keep output tight — the user wants to start working, not read a report.
8
+
9
+ ### Phase 1: Context Load (parallel)
10
+
11
+ 1. **Memory** — Read `MEMORY.md` from project memory dir (already in context, just review)
12
+ 2. **Git state** — Run in parallel:
13
+ - `git branch --show-current`
14
+ - `git log --oneline -10`
15
+ - `git status`
16
+ - `git stash list`
17
+ 3. **Restore** — Run `stackmemory restore --no-copy` to load last handoff
18
+ 4. **Open PRs** — `/opt/homebrew/bin/gh pr list --author @me --state open --limit 5 --json number,title,headRefName,reviews,statusCheckRollup 2>/dev/null`
19
+
20
+ ### Phase 2: Situational Awareness
21
+
22
+ From the gathered context, determine:
23
+
24
+ - **Current branch** and whether it has uncommitted work
25
+ - **Last session's state** from the handoff (in-progress work, blockers, next steps)
26
+ - **Open PRs** and their CI/review status
27
+ - **Any stashes** that might be forgotten work
28
+
29
+ ### Phase 3: Output
30
+
31
+ ```
32
+ ## Session Start
33
+
34
+ **Branch:** [branch] [clean|dirty]
35
+ **Last session:** [1-line summary from handoff]
36
+ **Open PRs:** [count] — [brief status of each]
37
+
38
+ **Recent commits:**
39
+ - [last 3-5 relevant commits, 1 line each]
40
+
41
+ **Restored context:**
42
+ - [key items from handoff: active work, blockers, decisions]
43
+
44
+ ## What's next
45
+
46
+ A) [Primary — continue from handoff / fix CI / address review]
47
+ B) [Alternative]
48
+ C) [Something else]
49
+ ```
50
+
51
+ ## Rules
52
+
53
+ - Total output under 25 lines
54
+ - Don't re-read files already in context (CLAUDE.md, MEMORY.md)
55
+ - If restore fails (no handoff), skip gracefully — still show git state + suggest /next
56
+ - If on main with clean state and no handoff, just run /next logic directly
57
+ - Never block on a failed command — report and continue
@@ -0,0 +1,65 @@
1
+ # /stop — End a session cleanly
2
+
3
+ Run /summary → /capture → /learn, then either /compact or clear based on whether work remains.
4
+
5
+ ## Usage
6
+
7
+ `$ARGUMENTS` — optional: `done` (session complete, clear context) or omit (default: compact for continuation)
8
+
9
+ ## Execution
10
+
11
+ ### Phase 1: Summary (silent)
12
+
13
+ Run /summary logic internally — review all actions, decisions, files changed. Hold the output for Phase 3.
14
+
15
+ ### Phase 2: Capture
16
+
17
+ 1. Run `stackmemory capture --no-commit` to generate handoff
18
+ 2. If there are uncommitted changes, ask: "Commit before closing? (y/n)"
19
+ - If yes: commit with auto-generated message, then re-run capture
20
+
21
+ ### Phase 3: Learn
22
+
23
+ Run /learn logic — audit memory, CLAUDE.md, skills, scripts for needed updates.
24
+
25
+ Output the combined summary + learnings report:
26
+
27
+ ```
28
+ ## Session Close
29
+
30
+ **What was done:**
31
+ - [actions from summary]
32
+
33
+ **Captured:** [handoff saved / failed]
34
+
35
+ **Updates needed:**
36
+ | Target | Action | Detail |
37
+ |--------|--------|--------|
38
+ | ... | ... | ... |
39
+
40
+ **Updates applied:** [list] or "none needed"
41
+ ```
42
+
43
+ Apply any non-controversial updates automatically (stale memory cleanup, factual corrections). Ask for confirmation on new memories or CLAUDE.md changes.
44
+
45
+ ### Phase 4: Close
46
+
47
+ Determine session state:
48
+
49
+ **If `done` argument OR no open work remaining:**
50
+ - All tasks complete, no blockers, clean branch
51
+ - Output: "Session complete. Clearing context."
52
+ - Clear conversation (suggest user run /clear)
53
+
54
+ **If work remains (default):**
55
+ - Open tasks, uncommitted changes, or active blockers
56
+ - Run /compact to preserve context for continuation
57
+ - Output: "Compacted. Resume with /start"
58
+
59
+ ## Rules
60
+
61
+ - Total output under 30 lines (excluding the updates table)
62
+ - If /learn finds nothing to update, skip the table — just say "Nothing to update"
63
+ - If capture fails, warn but continue — don't block the close
64
+ - Commit confirmation only if there are actual uncommitted changes
65
+ - Never force-clear if there's uncommitted work — always warn first
@@ -0,0 +1,40 @@
1
+ # /summary — Summarize what was accomplished this session
2
+
3
+ Generate a concise summary of work done in the current conversation.
4
+
5
+ ## Execution
6
+
7
+ 1. Review the conversation history for all actions taken
8
+ 2. Group by topic/theme if multiple things were done
9
+ 3. Output in this format:
10
+
11
+ ## Format
12
+
13
+ ```
14
+ ## Session Summary
15
+
16
+ **What was done:**
17
+ - [action 1]
18
+ - [action 2]
19
+ - ...
20
+
21
+ **Files changed:**
22
+ - [file path] — [what changed]
23
+
24
+ **Decisions made:**
25
+ - [decision and rationale]
26
+
27
+ **Status:** [complete | in-progress | blocked]
28
+
29
+ **Next steps:**
30
+ - [follow-up if any]
31
+ ```
32
+
33
+ ## Rules
34
+
35
+ - Keep it short — one line per item
36
+ - Focus on outcomes, not process
37
+ - Include file paths for any created/modified files
38
+ - Note any new commands, tools, or integrations set up
39
+ - If commits were made, list them
40
+ - Skip filler — no "I helped the user..." framing
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "core",
3
+ "version": "1.0.0",
4
+ "description": "Session lifecycle commands for Claude Code — start, stop, restart, and next",
5
+ "requires": "stackmemory >= 1.10.0",
6
+ "commands": {
7
+ "public": [
8
+ { "file": "commands/start.md", "name": "start", "description": "Boot a session with full context" },
9
+ { "file": "commands/stop.md", "name": "stop", "description": "End a session cleanly" },
10
+ { "file": "commands/restart.md", "name": "restart", "description": "Close session, clear context, and reboot" },
11
+ { "file": "commands/next.md", "name": "next", "description": "What should I do next?" }
12
+ ],
13
+ "internal": [
14
+ { "file": "commands/summary.md", "name": "summary", "description": "Summarize session work (used by /stop)" },
15
+ { "file": "commands/capture.md", "name": "capture", "description": "Save context via StackMemory (used by /stop)" },
16
+ { "file": "commands/learn.md", "name": "learn", "description": "Review session and update memory (used by /stop)" },
17
+ { "file": "commands/restore.md", "name": "restore", "description": "Restore from last handoff (used by /start)" }
18
+ ]
19
+ },
20
+ "install": {
21
+ "target": "~/.claude/commands",
22
+ "method": "symlink"
23
+ }
24
+ }
@@ -0,0 +1,65 @@
1
+ # ops/decision-recovery
2
+
3
+ ## Purpose
4
+
5
+ Track decisions, recover context, and hand off work between sessions. This pack ensures nothing is lost when an agent session ends, a human picks up work, or context needs to be recovered after a failure.
6
+
7
+ ## Decision Tracking
8
+
9
+ Every significant decision should be logged with:
10
+
11
+ 1. **The decision itself** — what was chosen
12
+ 2. **Rationale** — why (the most important part)
13
+ 3. **Alternatives considered** — what else was evaluated
14
+ 4. **Confidence level** — how certain (0-1 scale)
15
+
16
+ ### When to log decisions
17
+
18
+ - Architecture choices (database, framework, protocol)
19
+ - Trade-off resolutions (speed vs. correctness, scope vs. timeline)
20
+ - Integration selections (which tool, which API)
21
+ - Rejection decisions (what was explicitly *not* done, and why)
22
+ - Policy choices (error handling strategy, naming conventions)
23
+
24
+ ### Decision supersession
25
+
26
+ When a decision is reversed or updated, log the new decision with a reference to the old one. Don't delete old decisions — they provide valuable context about what was tried and why it didn't work.
27
+
28
+ ## Context Recovery
29
+
30
+ When starting a new session or recovering from a failure:
31
+
32
+ 1. **Check the last handoff** — what was the previous session working on?
33
+ 2. **Review recent decisions** — what constraints are in place?
34
+ 3. **Check for blockers** — what's preventing progress?
35
+ 4. **Review git state** — uncommitted work, open PRs, branch state
36
+
37
+ ### Recovery priority order
38
+
39
+ 1. Uncommitted changes → commit or stash
40
+ 2. Open blockers → address or escalate
41
+ 3. Failed CI → fix before continuing
42
+ 4. In-progress work → resume from handoff
43
+ 5. Next task → pick from queue
44
+
45
+ ## Session Handoff
46
+
47
+ At the end of every session, create a structured handoff:
48
+
49
+ - **Summary** — 1-3 sentences on what was accomplished
50
+ - **Key decisions** — decisions made during the session
51
+ - **Blockers** — anything that's preventing progress
52
+ - **Next steps** — concrete, actionable items for the next session
53
+ - **Open questions** — things that need human input
54
+
55
+ ### Handoff format
56
+
57
+ Keep handoffs concise. The next agent or human should be able to resume in < 2 minutes by reading the handoff.
58
+
59
+ ## Anti-Patterns
60
+
61
+ - Starting work without checking the last handoff → duplicate work
62
+ - Making decisions without logging rationale → lost context
63
+ - Ending a session without a handoff → cold start next time
64
+ - Logging implementation details as decisions → noise
65
+ - Deleting or overwriting old decisions → lost history
@@ -0,0 +1,89 @@
1
+ name: ops/decision-recovery
2
+ version: 1.0.0
3
+ description: Decision tracking, context recovery, and session handoff patterns for agent workflows
4
+ author: stackmemory
5
+ license: MIT
6
+ runtime:
7
+ type: local
8
+ ingestion:
9
+ sources:
10
+ - linear
11
+ - github
12
+ scope: decisions-and-anchors
13
+ ontology:
14
+ entities:
15
+ - decision
16
+ - anchor
17
+ - blocker
18
+ - handoff
19
+ - session
20
+ relations:
21
+ - supersedes
22
+ - blocks
23
+ - resolves
24
+ - continues
25
+ mcp:
26
+ tools:
27
+ - name: log_decision
28
+ description: Record a decision with rationale, alternatives considered, and confidence level
29
+ inputSchema:
30
+ type: object
31
+ properties:
32
+ decision:
33
+ type: string
34
+ description: The decision made
35
+ rationale:
36
+ type: string
37
+ description: Why this was chosen
38
+ alternatives:
39
+ type: array
40
+ items:
41
+ type: string
42
+ description: Alternatives that were considered
43
+ confidence:
44
+ type: number
45
+ description: Confidence level (0-1)
46
+ required:
47
+ - decision
48
+ - rationale
49
+ - name: recover_context
50
+ description: Retrieve decisions, anchors, and blockers from the current or recent sessions
51
+ inputSchema:
52
+ type: object
53
+ properties:
54
+ scope:
55
+ type: string
56
+ enum:
57
+ - current
58
+ - recent
59
+ - all
60
+ description: How far back to look
61
+ filter:
62
+ type: string
63
+ description: Optional keyword filter
64
+ - name: create_handoff
65
+ description: Create a structured session handoff for the next agent or human
66
+ inputSchema:
67
+ type: object
68
+ properties:
69
+ summary:
70
+ type: string
71
+ description: What was accomplished
72
+ blockers:
73
+ type: array
74
+ items:
75
+ type: string
76
+ description: Open blockers
77
+ next_steps:
78
+ type: array
79
+ items:
80
+ type: string
81
+ description: Suggested next actions
82
+ required:
83
+ - summary
84
+ examples:
85
+ - input: "We decided to use SQLite instead of Postgres for the local store"
86
+ output: "log_decision({ decision: 'Use SQLite for local store', rationale: 'Zero-config, file-based, FTS5 built-in, no server process', alternatives: ['Postgres', 'Dolt'], confidence: 0.9 })"
87
+ - input: "What decisions were made in the last session?"
88
+ output: "recover_context({ scope: 'recent', filter: 'decision' })"
89
+ instructions: instructions.md
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Doc Ingest Hook
5
+ *
6
+ * Fires on PostToolUse when WebFetch is used. If the fetched URL looks like
7
+ * documentation (docs.*, /api/, /reference/, /guide/), auto-ingests it into
8
+ * the project wiki via stackmemory wiki ingest.
9
+ *
10
+ * Lightweight: only runs if .stackmemory/config.yaml has obsidian.vaultPath.
11
+ */
12
+
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+ const { execSync } = require('child_process');
16
+
17
+ // Doc URL patterns
18
+ const DOC_PATTERNS = [
19
+ /^https?:\/\/docs\./i,
20
+ /^https?:\/\/[^/]+\/docs\//i,
21
+ /^https?:\/\/[^/]+\/api\//i,
22
+ /^https?:\/\/[^/]+\/reference\//i,
23
+ /^https?:\/\/[^/]+\/guide/i,
24
+ /^https?:\/\/[^/]+\/tutorial/i,
25
+ /^https?:\/\/developer\./i,
26
+ ];
27
+
28
+ // Rate limit: max 1 ingest per URL per session
29
+ const seen = new Set();
30
+
31
+ function main() {
32
+ try {
33
+ // Only fire on WebFetch tool
34
+ const toolName = process.env.TOOL_NAME || '';
35
+ if (toolName !== 'WebFetch') return;
36
+
37
+ // Check wiki is configured
38
+ const configPath = path.join(process.cwd(), '.stackmemory', 'config.yaml');
39
+ if (!fs.existsSync(configPath)) return;
40
+ const config = fs.readFileSync(configPath, 'utf-8');
41
+ if (!config.includes('vaultPath:')) return;
42
+
43
+ // Extract URL from tool input
44
+ const input = process.env.TOOL_INPUT || '';
45
+ let url;
46
+ try {
47
+ const parsed = JSON.parse(input);
48
+ url = parsed.url;
49
+ } catch {
50
+ // Try regex fallback
51
+ const match = input.match(/https?:\/\/[^\s"']+/);
52
+ url = match ? match[0] : null;
53
+ }
54
+
55
+ if (!url) return;
56
+
57
+ // Check if URL matches doc patterns
58
+ const isDoc = DOC_PATTERNS.some((p) => p.test(url));
59
+ if (!isDoc) return;
60
+
61
+ // Dedupe per session
62
+ const host = new URL(url).hostname;
63
+ if (seen.has(host)) return;
64
+ seen.add(host);
65
+
66
+ // Run ingest (fire-and-forget, max 1 page for auto-ingest)
67
+ execSync(`stackmemory wiki ingest "${url}" -n 5`, {
68
+ timeout: 15000,
69
+ stdio: 'ignore',
70
+ });
71
+ } catch {
72
+ // Silent fail
73
+ }
74
+ }
75
+
76
+ main();