@rkarim08/sia 1.0.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 (355) hide show
  1. package/.claude-plugin/marketplace.json +35 -0
  2. package/.claude-plugin/plugin.json +27 -0
  3. package/.mcp.json +13 -0
  4. package/CLAUDE.md +226 -0
  5. package/LICENSE +202 -0
  6. package/PLUGIN_README.md +253 -0
  7. package/README.md +1013 -0
  8. package/agents/sia-changelog-writer.md +89 -0
  9. package/agents/sia-code-reviewer.md +86 -0
  10. package/agents/sia-conflict-resolver.md +100 -0
  11. package/agents/sia-convention-enforcer.md +69 -0
  12. package/agents/sia-debug.md +106 -0
  13. package/agents/sia-decision-reviewer.md +101 -0
  14. package/agents/sia-dependency-tracker.md +80 -0
  15. package/agents/sia-explain.md +126 -0
  16. package/agents/sia-feature.md +116 -0
  17. package/agents/sia-knowledge-capture.md +117 -0
  18. package/agents/sia-lead-architecture-advisor.md +93 -0
  19. package/agents/sia-lead-team-health.md +107 -0
  20. package/agents/sia-migration.md +100 -0
  21. package/agents/sia-onboarding.md +115 -0
  22. package/agents/sia-orientation.md +99 -0
  23. package/agents/sia-pm-briefing.md +106 -0
  24. package/agents/sia-pm-risk-advisor.md +82 -0
  25. package/agents/sia-qa-analyst.md +116 -0
  26. package/agents/sia-qa-regression-map.md +94 -0
  27. package/agents/sia-refactor.md +115 -0
  28. package/agents/sia-regression.md +112 -0
  29. package/agents/sia-security-audit.md +125 -0
  30. package/agents/sia-test-advisor.md +91 -0
  31. package/hooks/hooks.json +98 -0
  32. package/migrations/bridge/001_initial.sql +34 -0
  33. package/migrations/episodic/001_initial.sql +35 -0
  34. package/migrations/meta/001_initial.sql +68 -0
  35. package/migrations/semantic/001_initial.sql +292 -0
  36. package/migrations/semantic/002_ontology.sql +89 -0
  37. package/migrations/semantic/003_freshness.sql +63 -0
  38. package/migrations/semantic/004_v5_unified_schema.sql +194 -0
  39. package/migrations/semantic/005_backfill_event_kinds.sql +8 -0
  40. package/migrations/semantic/006_tree_sitter.sql +6 -0
  41. package/migrations/semantic/007_branch_snapshots.sql +22 -0
  42. package/package.json +110 -0
  43. package/scripts/branch-switch.sh +13 -0
  44. package/scripts/build-wasm-grammars.sh +81 -0
  45. package/scripts/post-compact.sh +8 -0
  46. package/scripts/post-tool-use.sh +10 -0
  47. package/scripts/pre-compact.sh +8 -0
  48. package/scripts/session-end.sh +8 -0
  49. package/scripts/session-start.sh +8 -0
  50. package/scripts/start-mcp.ts +45 -0
  51. package/scripts/stop-hook.sh +8 -0
  52. package/scripts/user-prompt-submit.sh +8 -0
  53. package/scripts/viz-server.ts +152 -0
  54. package/skills/sia-brainstorm/SKILL.md +156 -0
  55. package/skills/sia-brainstorm/scripts/frame-template.html +214 -0
  56. package/skills/sia-brainstorm/scripts/helper.js +95 -0
  57. package/skills/sia-brainstorm/scripts/server.cjs +338 -0
  58. package/skills/sia-brainstorm/scripts/start-server.sh +153 -0
  59. package/skills/sia-brainstorm/scripts/stop-server.sh +55 -0
  60. package/skills/sia-brainstorm/spec-document-reviewer-prompt.md +49 -0
  61. package/skills/sia-brainstorm/visual-companion.md +286 -0
  62. package/skills/sia-capture/SKILL.md +64 -0
  63. package/skills/sia-compare/SKILL.md +33 -0
  64. package/skills/sia-conflicts/SKILL.md +38 -0
  65. package/skills/sia-debug-workflow/SKILL.md +120 -0
  66. package/skills/sia-debug-workflow/root-cause-tracing.md +70 -0
  67. package/skills/sia-debug-workflow/scripts/find-polluter.sh +64 -0
  68. package/skills/sia-debug-workflow/temporal-investigation.md +72 -0
  69. package/skills/sia-digest/SKILL.md +23 -0
  70. package/skills/sia-dispatch/SKILL.md +69 -0
  71. package/skills/sia-dispatch/agent-task-template.md +99 -0
  72. package/skills/sia-doctor/SKILL.md +39 -0
  73. package/skills/sia-execute/SKILL.md +70 -0
  74. package/skills/sia-execute-plan/SKILL.md +85 -0
  75. package/skills/sia-export-import/SKILL.md +49 -0
  76. package/skills/sia-export-knowledge/SKILL.md +46 -0
  77. package/skills/sia-finish/SKILL.md +100 -0
  78. package/skills/sia-finish/pr-summary-template.md +54 -0
  79. package/skills/sia-freshness/SKILL.md +38 -0
  80. package/skills/sia-history/SKILL.md +42 -0
  81. package/skills/sia-impact/SKILL.md +70 -0
  82. package/skills/sia-index/SKILL.md +54 -0
  83. package/skills/sia-install/SKILL.md +39 -0
  84. package/skills/sia-lead-compliance/SKILL.md +16 -0
  85. package/skills/sia-lead-drift-report/SKILL.md +16 -0
  86. package/skills/sia-lead-knowledge-map/SKILL.md +16 -0
  87. package/skills/sia-learn/SKILL.md +58 -0
  88. package/skills/sia-plan/SKILL.md +68 -0
  89. package/skills/sia-plan/plan-reviewer-prompt.md +63 -0
  90. package/skills/sia-playbooks/SKILL.md +29 -0
  91. package/skills/sia-playbooks/reference-feature.md +100 -0
  92. package/skills/sia-playbooks/reference-flagging.md +50 -0
  93. package/skills/sia-playbooks/reference-orientation.md +92 -0
  94. package/skills/sia-playbooks/reference-regression.md +115 -0
  95. package/skills/sia-playbooks/reference-review.md +64 -0
  96. package/skills/sia-playbooks/reference-tools.md +239 -0
  97. package/skills/sia-pm-decision-log/SKILL.md +28 -0
  98. package/skills/sia-pm-risk-dashboard/SKILL.md +24 -0
  99. package/skills/sia-pm-sprint-summary/SKILL.md +27 -0
  100. package/skills/sia-prune/SKILL.md +45 -0
  101. package/skills/sia-qa-coverage/SKILL.md +28 -0
  102. package/skills/sia-qa-flaky/SKILL.md +20 -0
  103. package/skills/sia-qa-report/SKILL.md +26 -0
  104. package/skills/sia-reindex/SKILL.md +30 -0
  105. package/skills/sia-review-respond/SKILL.md +88 -0
  106. package/skills/sia-review-respond/pushback-patterns.md +90 -0
  107. package/skills/sia-search/SKILL.md +47 -0
  108. package/skills/sia-setup/SKILL.md +82 -0
  109. package/skills/sia-setup/setup-checklist.md +97 -0
  110. package/skills/sia-stats/SKILL.md +36 -0
  111. package/skills/sia-status/SKILL.md +44 -0
  112. package/skills/sia-sync/SKILL.md +46 -0
  113. package/skills/sia-team/SKILL.md +64 -0
  114. package/skills/sia-test/SKILL.md +92 -0
  115. package/skills/sia-test/testing-anti-patterns.md +104 -0
  116. package/skills/sia-tour/SKILL.md +29 -0
  117. package/skills/sia-upgrade/SKILL.md +43 -0
  118. package/skills/sia-verify/SKILL.md +81 -0
  119. package/skills/sia-visualize/SKILL.md +28 -0
  120. package/skills/sia-visualize-live/SKILL.md +55 -0
  121. package/skills/sia-visualize-live/scripts/graph-template.html +389 -0
  122. package/skills/sia-visualize-live/scripts/start-visualizer.sh +161 -0
  123. package/skills/sia-visualize-live/scripts/stop-visualizer.sh +55 -0
  124. package/skills/sia-visualize-live/scripts/visualizer-server.cjs +264 -0
  125. package/skills/sia-workspace/SKILL.md +57 -0
  126. package/src/agent/claude-md-template-flagging.md +219 -0
  127. package/src/agent/claude-md-template.md +213 -0
  128. package/src/agent/modules/sia-feature.md +100 -0
  129. package/src/agent/modules/sia-flagging.md +50 -0
  130. package/src/agent/modules/sia-orientation.md +92 -0
  131. package/src/agent/modules/sia-regression.md +115 -0
  132. package/src/agent/modules/sia-review.md +64 -0
  133. package/src/agent/modules/sia-tools.md +239 -0
  134. package/src/ast/extractors/c-include.ts +189 -0
  135. package/src/ast/extractors/csharp-project.ts +260 -0
  136. package/src/ast/extractors/prisma-schema.ts +44 -0
  137. package/src/ast/extractors/project-manifest.ts +111 -0
  138. package/src/ast/extractors/sql-schema.ts +67 -0
  139. package/src/ast/extractors/tier-a.ts +423 -0
  140. package/src/ast/extractors/tier-b.ts +289 -0
  141. package/src/ast/extractors/tier-dispatch.ts +247 -0
  142. package/src/ast/index-worker.ts +108 -0
  143. package/src/ast/indexer.ts +484 -0
  144. package/src/ast/languages.ts +408 -0
  145. package/src/ast/pagerank-builder.ts +125 -0
  146. package/src/ast/path-utils.ts +137 -0
  147. package/src/ast/tree-sitter/backends/native.ts +57 -0
  148. package/src/ast/tree-sitter/backends/wasm.ts +39 -0
  149. package/src/ast/tree-sitter/call-walker.ts +44 -0
  150. package/src/ast/tree-sitter/edit-computer.ts +55 -0
  151. package/src/ast/tree-sitter/query-runner.ts +46 -0
  152. package/src/ast/tree-sitter/service.ts +174 -0
  153. package/src/ast/tree-sitter/tree-cache.ts +39 -0
  154. package/src/ast/tree-sitter/types.ts +79 -0
  155. package/src/ast/watcher.ts +322 -0
  156. package/src/capture/chunker.ts +169 -0
  157. package/src/capture/consolidate.ts +127 -0
  158. package/src/capture/edge-inferrer.ts +161 -0
  159. package/src/capture/embedder.ts +166 -0
  160. package/src/capture/embedding-cache.ts +73 -0
  161. package/src/capture/flag-processor.ts +64 -0
  162. package/src/capture/hook.ts +67 -0
  163. package/src/capture/pipeline.ts +450 -0
  164. package/src/capture/prompts/consolidate.ts +25 -0
  165. package/src/capture/prompts/edge-infer.ts +29 -0
  166. package/src/capture/prompts/extract-flagged.ts +36 -0
  167. package/src/capture/prompts/extract.ts +42 -0
  168. package/src/capture/tokenizer.ts +147 -0
  169. package/src/capture/track-a-ast.ts +93 -0
  170. package/src/capture/track-b-llm.ts +149 -0
  171. package/src/capture/types.ts +64 -0
  172. package/src/cli/commands/community.ts +137 -0
  173. package/src/cli/commands/compare.ts +123 -0
  174. package/src/cli/commands/conflicts.ts +41 -0
  175. package/src/cli/commands/digest.ts +197 -0
  176. package/src/cli/commands/disable-flagging.ts +34 -0
  177. package/src/cli/commands/doctor.ts +240 -0
  178. package/src/cli/commands/download-model.ts +161 -0
  179. package/src/cli/commands/enable-flagging.ts +34 -0
  180. package/src/cli/commands/export-knowledge.ts +208 -0
  181. package/src/cli/commands/export.ts +85 -0
  182. package/src/cli/commands/freshness.ts +164 -0
  183. package/src/cli/commands/graph.ts +51 -0
  184. package/src/cli/commands/history.ts +139 -0
  185. package/src/cli/commands/import.ts +335 -0
  186. package/src/cli/commands/install.ts +156 -0
  187. package/src/cli/commands/lead-report.ts +241 -0
  188. package/src/cli/commands/learn.ts +321 -0
  189. package/src/cli/commands/pm-report.ts +413 -0
  190. package/src/cli/commands/prune.ts +75 -0
  191. package/src/cli/commands/qa-report.ts +278 -0
  192. package/src/cli/commands/reindex.ts +104 -0
  193. package/src/cli/commands/rollback.ts +70 -0
  194. package/src/cli/commands/search.ts +103 -0
  195. package/src/cli/commands/server.ts +91 -0
  196. package/src/cli/commands/share.ts +33 -0
  197. package/src/cli/commands/stats.ts +79 -0
  198. package/src/cli/commands/status.ts +176 -0
  199. package/src/cli/commands/sync.ts +96 -0
  200. package/src/cli/commands/team.ts +118 -0
  201. package/src/cli/commands/tour.ts +157 -0
  202. package/src/cli/commands/visualize-live.ts +162 -0
  203. package/src/cli/commands/workspace.ts +117 -0
  204. package/src/cli/index.ts +424 -0
  205. package/src/cli/learn-progress.ts +87 -0
  206. package/src/community/detection-bridge.ts +344 -0
  207. package/src/community/leiden.ts +462 -0
  208. package/src/community/raptor.ts +210 -0
  209. package/src/community/scheduler.ts +74 -0
  210. package/src/community/summarize.ts +115 -0
  211. package/src/decay/archiver.ts +73 -0
  212. package/src/decay/bridge-orphan-cleanup.ts +212 -0
  213. package/src/decay/consolidation-sweep.ts +112 -0
  214. package/src/decay/decay.ts +116 -0
  215. package/src/decay/deep-validator.ts +62 -0
  216. package/src/decay/episodic-promoter.ts +132 -0
  217. package/src/decay/maintenance-scheduler.ts +326 -0
  218. package/src/decay/scheduler.ts +6 -0
  219. package/src/decay/session-sweeper.ts +79 -0
  220. package/src/decay/types.ts +17 -0
  221. package/src/freshness/confidence-decay.ts +122 -0
  222. package/src/freshness/cuckoo-filter.ts +176 -0
  223. package/src/freshness/deep-validation.ts +345 -0
  224. package/src/freshness/dirty-tracker.ts +237 -0
  225. package/src/freshness/file-watcher-layer.ts +119 -0
  226. package/src/freshness/firewall.ts +64 -0
  227. package/src/freshness/git-reconcile-layer.ts +161 -0
  228. package/src/freshness/inverted-index.ts +158 -0
  229. package/src/freshness/stale-read-layer.ts +222 -0
  230. package/src/graph/audit.ts +69 -0
  231. package/src/graph/bridge-db.ts +141 -0
  232. package/src/graph/communities.ts +195 -0
  233. package/src/graph/db-interface.ts +259 -0
  234. package/src/graph/edges.ts +163 -0
  235. package/src/graph/entities.ts +327 -0
  236. package/src/graph/episodic-db.ts +113 -0
  237. package/src/graph/flags.ts +31 -0
  238. package/src/graph/meta-db.ts +200 -0
  239. package/src/graph/semantic-db.ts +101 -0
  240. package/src/graph/session-resume.ts +56 -0
  241. package/src/graph/snapshots.ts +342 -0
  242. package/src/graph/staging.ts +151 -0
  243. package/src/graph/types.ts +128 -0
  244. package/src/hooks/adapters/claude-code.ts +21 -0
  245. package/src/hooks/adapters/cline.ts +43 -0
  246. package/src/hooks/adapters/cursor.ts +65 -0
  247. package/src/hooks/adapters/generic.ts +12 -0
  248. package/src/hooks/agent-detect.ts +34 -0
  249. package/src/hooks/claude-md-directives.ts +32 -0
  250. package/src/hooks/event-router.ts +182 -0
  251. package/src/hooks/extractors/pattern-detector.ts +111 -0
  252. package/src/hooks/handlers/post-compact.ts +30 -0
  253. package/src/hooks/handlers/post-tool-use.ts +403 -0
  254. package/src/hooks/handlers/pre-compact.ts +100 -0
  255. package/src/hooks/handlers/session-end.ts +47 -0
  256. package/src/hooks/handlers/session-start.ts +154 -0
  257. package/src/hooks/handlers/stop.ts +128 -0
  258. package/src/hooks/handlers/user-prompt-submit.ts +68 -0
  259. package/src/hooks/plugin-branch-switch.ts +68 -0
  260. package/src/hooks/plugin-common.ts +47 -0
  261. package/src/hooks/plugin-post-compact.ts +28 -0
  262. package/src/hooks/plugin-post-tool-use.ts +38 -0
  263. package/src/hooks/plugin-pre-compact.ts +37 -0
  264. package/src/hooks/plugin-session-end.ts +37 -0
  265. package/src/hooks/plugin-session-start.ts +75 -0
  266. package/src/hooks/plugin-stop.ts +61 -0
  267. package/src/hooks/plugin-user-prompt-submit.ts +47 -0
  268. package/src/hooks/types.ts +43 -0
  269. package/src/knowledge/discovery.ts +238 -0
  270. package/src/knowledge/external-refs.ts +98 -0
  271. package/src/knowledge/freshness.ts +221 -0
  272. package/src/knowledge/ingest.ts +330 -0
  273. package/src/knowledge/markdown-export.ts +229 -0
  274. package/src/knowledge/markdown-import.ts +359 -0
  275. package/src/knowledge/patterns.ts +74 -0
  276. package/src/knowledge/templates.ts +307 -0
  277. package/src/llm/ai-sdk-adapter.ts +46 -0
  278. package/src/llm/config.ts +88 -0
  279. package/src/llm/cost-tracker.ts +110 -0
  280. package/src/llm/prompts/extraction.ts +55 -0
  281. package/src/llm/prompts/summarization.ts +36 -0
  282. package/src/llm/prompts/validation.ts +37 -0
  283. package/src/llm/provider-registry.ts +68 -0
  284. package/src/llm/reliability.ts +179 -0
  285. package/src/llm/schemas.ts +52 -0
  286. package/src/mcp/freshness-annotator.ts +69 -0
  287. package/src/mcp/server.ts +949 -0
  288. package/src/mcp/tools/sia-ast-query.ts +225 -0
  289. package/src/mcp/tools/sia-at-time.ts +151 -0
  290. package/src/mcp/tools/sia-backlinks.ts +87 -0
  291. package/src/mcp/tools/sia-batch-execute.ts +169 -0
  292. package/src/mcp/tools/sia-by-file.ts +89 -0
  293. package/src/mcp/tools/sia-community.ts +113 -0
  294. package/src/mcp/tools/sia-doctor.ts +73 -0
  295. package/src/mcp/tools/sia-execute-file.ts +122 -0
  296. package/src/mcp/tools/sia-execute.ts +104 -0
  297. package/src/mcp/tools/sia-expand.ts +158 -0
  298. package/src/mcp/tools/sia-fetch-and-index.ts +241 -0
  299. package/src/mcp/tools/sia-flag.ts +65 -0
  300. package/src/mcp/tools/sia-index.ts +111 -0
  301. package/src/mcp/tools/sia-note.ts +134 -0
  302. package/src/mcp/tools/sia-search.ts +105 -0
  303. package/src/mcp/tools/sia-stats.ts +63 -0
  304. package/src/mcp/tools/sia-sync-status.ts +44 -0
  305. package/src/mcp/tools/sia-upgrade.ts +247 -0
  306. package/src/mcp/truncate.ts +231 -0
  307. package/src/native/bridge.ts +167 -0
  308. package/src/native/fallback-ast-diff.ts +144 -0
  309. package/src/native/fallback-graph.ts +325 -0
  310. package/src/ontology/constraints.ts +56 -0
  311. package/src/ontology/errors.ts +8 -0
  312. package/src/ontology/middleware.ts +266 -0
  313. package/src/retrieval/bm25-search.ts +151 -0
  314. package/src/retrieval/context-assembly.ts +76 -0
  315. package/src/retrieval/graph-traversal.ts +168 -0
  316. package/src/retrieval/pagerank.ts +40 -0
  317. package/src/retrieval/query-classifier.ts +106 -0
  318. package/src/retrieval/reranker.ts +156 -0
  319. package/src/retrieval/search.ts +236 -0
  320. package/src/retrieval/throttle.ts +102 -0
  321. package/src/retrieval/vector-search.ts +203 -0
  322. package/src/retrieval/workspace-search.ts +130 -0
  323. package/src/sandbox/context-mode.ts +285 -0
  324. package/src/sandbox/credential-pass.ts +55 -0
  325. package/src/sandbox/executor.ts +235 -0
  326. package/src/security/pattern-detector.ts +127 -0
  327. package/src/security/rule-of-two.ts +50 -0
  328. package/src/security/sanitize.ts +46 -0
  329. package/src/security/semantic-consistency.ts +93 -0
  330. package/src/security/staging-promoter.ts +154 -0
  331. package/src/shared/config.ts +302 -0
  332. package/src/shared/diagnostics.ts +210 -0
  333. package/src/shared/errors.ts +48 -0
  334. package/src/shared/git-utils.ts +143 -0
  335. package/src/shared/llm-client.ts +120 -0
  336. package/src/shared/logger.ts +99 -0
  337. package/src/shared/types.ts +79 -0
  338. package/src/sync/client.ts +43 -0
  339. package/src/sync/conflict.ts +106 -0
  340. package/src/sync/dedup.ts +183 -0
  341. package/src/sync/hlc.ts +117 -0
  342. package/src/sync/keychain.ts +144 -0
  343. package/src/sync/pull.ts +232 -0
  344. package/src/sync/push.ts +131 -0
  345. package/src/types/chokidar.d.ts +23 -0
  346. package/src/visualization/graph-renderer.ts +312 -0
  347. package/src/visualization/subgraph-extract.ts +208 -0
  348. package/src/visualization/views/community-clusters.ts +246 -0
  349. package/src/visualization/views/dependency-map.ts +189 -0
  350. package/src/visualization/views/graph-explorer.ts +364 -0
  351. package/src/visualization/views/timeline.ts +247 -0
  352. package/src/workspace/api-contracts.ts +226 -0
  353. package/src/workspace/cross-repo.ts +61 -0
  354. package/src/workspace/detector.ts +190 -0
  355. package/src/workspace/manifest.ts +141 -0
package/package.json ADDED
@@ -0,0 +1,110 @@
1
+ {
2
+ "name": "@rkarim08/sia",
3
+ "version": "1.0.0",
4
+ "description": "Persistent graph memory for AI coding agents",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "author": {
8
+ "name": "Ramez Karim"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/rkarim08/sia.git"
13
+ },
14
+ "homepage": "https://github.com/rkarim08/sia#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/rkarim08/sia/issues"
17
+ },
18
+ "keywords": [
19
+ "claude-code",
20
+ "plugin",
21
+ "memory",
22
+ "knowledge-graph",
23
+ "mcp",
24
+ "ai-coding",
25
+ "persistent-memory",
26
+ "bi-temporal",
27
+ "tree-sitter"
28
+ ],
29
+ "bin": {
30
+ "sia": "./src/cli/index.ts"
31
+ },
32
+ "scripts": {
33
+ "test": "vitest run --config vitest.config.ts",
34
+ "test:unit": "vitest run --config vitest.config.ts",
35
+ "test:integration": "vitest run --config vitest.integration.config.ts",
36
+ "test:watch": "vitest --config vitest.config.ts",
37
+ "lint": "biome check .",
38
+ "lint:fix": "biome check --write .",
39
+ "format": "biome format --write .",
40
+ "typecheck": "tsc --noEmit",
41
+ "test:tree-sitter-bun": "bun test tests/bun/tree-sitter-smoke.test.ts",
42
+ "prepublishOnly": "bun run typecheck && bun run test"
43
+ },
44
+ "dependencies": {
45
+ "@ai-sdk/anthropic": "^3.0.58",
46
+ "@ai-sdk/openai": "^3.0.41",
47
+ "@anthropic-ai/sdk": "^0.79.0",
48
+ "@libsql/client": "^0.10.0",
49
+ "@modelcontextprotocol/sdk": "^1.27.1",
50
+ "@napi-rs/keyring": "^1.1.8",
51
+ "ai": "^6.0.116",
52
+ "chokidar": "^3.6.0",
53
+ "onnxruntime-node": "^1.24.3",
54
+ "tree-sitter": "^0.25.0",
55
+ "tree-sitter-bash": "^0.25.1",
56
+ "tree-sitter-c": "^0.24.1",
57
+ "tree-sitter-c-sharp": "^0.23.1",
58
+ "tree-sitter-cpp": "^0.23.4",
59
+ "tree-sitter-dart": "^1.0.0",
60
+ "tree-sitter-elixir": "^0.3.5",
61
+ "tree-sitter-go": "^0.25.0",
62
+ "tree-sitter-haskell": "^0.23.1",
63
+ "tree-sitter-java": "^0.23.5",
64
+ "tree-sitter-javascript": "^0.25.0",
65
+ "tree-sitter-kotlin": "^0.3.8",
66
+ "tree-sitter-lua": "^2.1.3",
67
+ "tree-sitter-ocaml": "^0.24.2",
68
+ "tree-sitter-php": "^0.24.2",
69
+ "tree-sitter-python": "^0.25.0",
70
+ "tree-sitter-r": "^0.0.1-security",
71
+ "tree-sitter-ruby": "^0.23.1",
72
+ "tree-sitter-rust": "^0.24.0",
73
+ "tree-sitter-scala": "^0.24.0",
74
+ "tree-sitter-sql": "^0.1.0",
75
+ "tree-sitter-swift": "^0.7.1",
76
+ "tree-sitter-toml": "^0.5.1",
77
+ "tree-sitter-typescript": "^0.23.2",
78
+ "tree-sitter-zig": "^0.2.0",
79
+ "turndown": "^7.2.2",
80
+ "uuid": "^13.0.0",
81
+ "web-tree-sitter": "^0.26.7",
82
+ "yaml": "^2.8.3",
83
+ "zod": "^4.3.6"
84
+ },
85
+ "devDependencies": {
86
+ "@biomejs/biome": "^2.4.7",
87
+ "@types/better-sqlite3": "^7.6.13",
88
+ "@types/bun": "^1.3.10",
89
+ "@types/turndown": "^5.0.6",
90
+ "@types/uuid": "^11.0.0",
91
+ "better-sqlite3": "^12.8.0",
92
+ "typescript": "^5.9.3",
93
+ "vitest": "^4.1.0"
94
+ },
95
+ "engines": {
96
+ "bun": ">=1.0.0"
97
+ },
98
+ "files": [
99
+ "src/",
100
+ "scripts/",
101
+ "skills/",
102
+ "agents/",
103
+ "hooks/",
104
+ "migrations/",
105
+ ".claude-plugin/",
106
+ ".mcp.json",
107
+ "CLAUDE.md",
108
+ "PLUGIN_README.md"
109
+ ]
110
+ }
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env bash
2
+ # Branch switch detection hook
3
+ # stderr is redirected to a log file so diagnostics from the TypeScript
4
+ # handler are preserved for debugging (not discarded via /dev/null).
5
+ set -euo pipefail
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8
+ PLUGIN_ROOT="$(dirname "$SCRIPT_DIR")"
9
+
10
+ SIA_LOG_DIR="${CLAUDE_PLUGIN_DATA:-${HOME}/.sia}/logs"
11
+ mkdir -p "$SIA_LOG_DIR"
12
+
13
+ exec bun run "$PLUGIN_ROOT/src/hooks/plugin-branch-switch.ts" 2>>"${SIA_LOG_DIR}/hooks.log"
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env bash
2
+ # build-wasm-grammars.sh
3
+ # Builds tree-sitter WASM grammars from npm packages.
4
+ # Requires: tree-sitter CLI, emscripten (emcc on PATH)
5
+ #
6
+ # Usage:
7
+ # ./scripts/build-wasm-grammars.sh [grammar-name ...]
8
+ # If no arguments given, builds all grammars from grammars/versions.json.
9
+ #
10
+ # Output: grammars/wasm/*.wasm
11
+
12
+ set -euo pipefail
13
+
14
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15
+ REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
16
+ VERSIONS_FILE="${REPO_ROOT}/grammars/versions.json"
17
+ OUT_DIR="${REPO_ROOT}/grammars/wasm"
18
+ NODE_MODULES="${REPO_ROOT}/node_modules"
19
+
20
+ mkdir -p "${OUT_DIR}"
21
+
22
+ # Check dependencies
23
+ if ! command -v tree-sitter &>/dev/null; then
24
+ echo "ERROR: tree-sitter CLI not found. Install with: npm install -g tree-sitter-cli" >&2
25
+ exit 1
26
+ fi
27
+
28
+ if ! command -v emcc &>/dev/null; then
29
+ echo "ERROR: emcc (Emscripten) not found. See https://emscripten.org/docs/getting_started/downloads.html" >&2
30
+ exit 1
31
+ fi
32
+
33
+ # Parse versions.json to get grammar list
34
+ # Requires: jq
35
+ if ! command -v jq &>/dev/null; then
36
+ echo "ERROR: jq not found. Install with: brew install jq / apt install jq" >&2
37
+ exit 1
38
+ fi
39
+
40
+ # Build a specific grammar given its language key
41
+ build_grammar() {
42
+ local lang="$1"
43
+ local pkg wasm_file src_dir
44
+
45
+ pkg=$(jq -r ".grammars[\"${lang}\"].package" "${VERSIONS_FILE}")
46
+ wasm_file=$(jq -r ".grammars[\"${lang}\"].wasmFile" "${VERSIONS_FILE}")
47
+
48
+ if [[ "${pkg}" == "null" ]]; then
49
+ echo "WARNING: Unknown grammar '${lang}', skipping." >&2
50
+ return 0
51
+ fi
52
+
53
+ src_dir="${NODE_MODULES}/${pkg}"
54
+
55
+ if [[ ! -d "${src_dir}" ]]; then
56
+ echo "WARNING: Package directory not found: ${src_dir}. Run 'bun install' first." >&2
57
+ return 0
58
+ fi
59
+
60
+ echo "Building ${lang} -> ${wasm_file} ..."
61
+ (
62
+ cd "${src_dir}"
63
+ tree-sitter build --wasm --output "${OUT_DIR}/${wasm_file}"
64
+ )
65
+ echo " Done: ${OUT_DIR}/${wasm_file}"
66
+ }
67
+
68
+ # Determine which grammars to build
69
+ if [[ $# -gt 0 ]]; then
70
+ TARGETS=("$@")
71
+ else
72
+ mapfile -t TARGETS < <(jq -r '.grammars | keys[]' "${VERSIONS_FILE}")
73
+ fi
74
+
75
+ echo "Building ${#TARGETS[@]} WASM grammar(s) into ${OUT_DIR}/"
76
+ for lang in "${TARGETS[@]}"; do
77
+ build_grammar "${lang}"
78
+ done
79
+
80
+ echo ""
81
+ echo "All done. WASM files written to: ${OUT_DIR}/"
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ # PostCompact hook — logs compaction coverage info for observability
3
+ set -euo pipefail
4
+
5
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
+ PLUGIN_ROOT="$(dirname "$SCRIPT_DIR")"
7
+
8
+ exec bun run "$PLUGIN_ROOT/src/hooks/plugin-post-compact.ts" 2>/dev/null
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+ # PostToolUse hook — captures knowledge from Write/Edit events
3
+ # Receives hook event data on stdin as JSON
4
+ set -euo pipefail
5
+
6
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7
+ PLUGIN_ROOT="$(dirname "$SCRIPT_DIR")"
8
+
9
+ # Pass stdin through to the handler
10
+ exec bun run "$PLUGIN_ROOT/src/hooks/plugin-post-tool-use.ts" 2>/dev/null
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ # PreCompact hook — scans transcript tail for unextracted knowledge before context compaction
3
+ set -euo pipefail
4
+
5
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
+ PLUGIN_ROOT="$(dirname "$SCRIPT_DIR")"
7
+
8
+ exec bun run "$PLUGIN_ROOT/src/hooks/plugin-pre-compact.ts" 2>/dev/null
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ # SessionEnd hook — records session statistics and entity counts
3
+ set -euo pipefail
4
+
5
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
+ PLUGIN_ROOT="$(dirname "$SCRIPT_DIR")"
7
+
8
+ exec bun run "$PLUGIN_ROOT/src/hooks/plugin-session-end.ts" 2>/dev/null
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ # SessionStart hook — injects recent decisions/conventions/bugs as context
3
+ set -euo pipefail
4
+
5
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
+ PLUGIN_ROOT="$(dirname "$SCRIPT_DIR")"
7
+
8
+ exec bun run "$PLUGIN_ROOT/src/hooks/plugin-session-start.ts" 2>/dev/null
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env bun
2
+ import { randomUUID } from "node:crypto";
3
+ import { resolveRepoHash } from "../src/capture/hook";
4
+ import { openBridgeDb } from "../src/graph/bridge-db";
5
+ import { openMetaDb } from "../src/graph/meta-db";
6
+ import { openGraphDb } from "../src/graph/semantic-db";
7
+ import { startServer } from "../src/mcp/server";
8
+ import { getConfig, resolveSiaHome } from "../src/shared/config";
9
+
10
+ const cwd = process.cwd();
11
+ const repoHash = resolveRepoHash(cwd);
12
+ const siaHome = resolveSiaHome();
13
+ const config = getConfig(siaHome);
14
+
15
+ const graphDb = openGraphDb(repoHash, siaHome);
16
+ const metaDb = openMetaDb(siaHome);
17
+ const bridgeDb = openBridgeDb(siaHome);
18
+ const sessionId = randomUUID();
19
+
20
+ await startServer({ graphDb, bridgeDb, metaDb, embedder: null, config, sessionId });
21
+
22
+ // Start maintenance scheduler (background — non-blocking)
23
+ try {
24
+ const { openEpisodicDb } = await import("../src/graph/semantic-db");
25
+ const { createMaintenanceScheduler } = await import("../src/decay/maintenance-scheduler");
26
+
27
+ const episodicDb = openEpisodicDb(repoHash, siaHome);
28
+
29
+ const scheduler = createMaintenanceScheduler({
30
+ graphDb,
31
+ episodicDb,
32
+ bridgeDb,
33
+ config,
34
+ repoHash,
35
+ siaHome,
36
+ });
37
+
38
+ scheduler.onStartup(repoHash).catch((err) => {
39
+ process.stderr.write(`sia: maintenance startup failed (non-fatal): ${err}\n`);
40
+ });
41
+
42
+ process.stderr.write("sia: maintenance scheduler started\n");
43
+ } catch (err) {
44
+ process.stderr.write(`sia: maintenance scheduler init failed: ${err}\n`);
45
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ # Stop hook — detects uncaptured knowledge patterns before session ends
3
+ set -euo pipefail
4
+
5
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
+ PLUGIN_ROOT="$(dirname "$SCRIPT_DIR")"
7
+
8
+ exec bun run "$PLUGIN_ROOT/src/hooks/plugin-stop.ts" 2>/dev/null
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ # UserPromptSubmit hook — captures user prompts and detects correction/preference patterns
3
+ set -euo pipefail
4
+
5
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
+ PLUGIN_ROOT="$(dirname "$SCRIPT_DIR")"
7
+
8
+ exec bun run "$PLUGIN_ROOT/src/hooks/plugin-user-prompt-submit.ts" 2>/dev/null
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env bun
2
+
3
+ // SIA Graph Visualizer — Live browser companion server
4
+ //
5
+ // Watches a directory for HTML files and serves the newest one.
6
+ // Based on superpowers' visual companion pattern.
7
+ //
8
+ // Usage: bun run scripts/viz-server.ts --screen-dir <dir> [--port <port>]
9
+
10
+ import {
11
+ appendFileSync,
12
+ existsSync,
13
+ mkdirSync,
14
+ readdirSync,
15
+ readFileSync,
16
+ statSync,
17
+ writeFileSync,
18
+ } from "node:fs";
19
+ import { createServer } from "node:http";
20
+ import { extname, join } from "node:path";
21
+
22
+ // Frame template with SIA branding
23
+ export const FRAME_TEMPLATE = `<!DOCTYPE html>
24
+ <html lang="en">
25
+ <head>
26
+ <meta charset="UTF-8">
27
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
28
+ <title>SIA Knowledge Graph</title>
29
+ <style>
30
+ * { margin: 0; padding: 0; box-sizing: border-box; }
31
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #1a1a2e; color: #e0e0e0; }
32
+ .header { padding: 12px 24px; background: #16213e; border-bottom: 1px solid #0f3460; display: flex; align-items: center; gap: 12px; }
33
+ .header h1 { font-size: 16px; font-weight: 600; color: #e94560; }
34
+ .header .subtitle { font-size: 13px; color: #888; }
35
+ .content { padding: 24px; }
36
+ h2 { color: #e94560; margin-bottom: 16px; }
37
+ h3 { color: #ccc; margin-bottom: 8px; }
38
+ .subtitle { color: #888; font-size: 14px; }
39
+ .options { display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 0; }
40
+ .option { background: #16213e; border: 2px solid #0f3460; border-radius: 8px; padding: 16px; cursor: pointer; flex: 1; min-width: 200px; transition: all 0.2s; }
41
+ .option:hover { border-color: #e94560; }
42
+ .option.selected { border-color: #e94560; background: #1a1a3e; }
43
+ </style>
44
+ </head>
45
+ <body>
46
+ <div class="header">
47
+ <h1>SIA</h1>
48
+ <span class="subtitle">Knowledge Graph Visualizer</span>
49
+ </div>
50
+ <div class="content">
51
+ {{CONTENT}}
52
+ </div>
53
+ <script>
54
+ function toggleSelect(el) {
55
+ document.querySelectorAll('.option, .card').forEach(o => o.classList.remove('selected'));
56
+ el.classList.add('selected');
57
+ const choice = el.dataset.choice;
58
+ const text = el.textContent.trim().slice(0, 100);
59
+ fetch('/event', { method: 'POST', body: JSON.stringify({ type: 'click', choice, text, timestamp: Date.now() }) });
60
+ }
61
+ </script>
62
+ </body>
63
+ </html>`;
64
+
65
+ /** Replace the {{CONTENT}} placeholder in the frame template. */
66
+ export function buildFrameHtml(content: string): string {
67
+ return FRAME_TEMPLATE.replace("{{CONTENT}}", content);
68
+ }
69
+
70
+ /** Find the newest .html file in the given directory. Returns filename or null. */
71
+ export function getNewestHtml(dir: string): string | null {
72
+ if (!existsSync(dir)) return null;
73
+ const files = readdirSync(dir)
74
+ .filter((f) => extname(f) === ".html")
75
+ .map((f) => ({ name: f, mtime: statSync(join(dir, f)).mtimeMs }))
76
+ .sort((a, b) => b.mtime - a.mtime);
77
+ return files.length > 0 ? files[0].name : null;
78
+ }
79
+
80
+ /** Start the viz server. Only runs when executed directly (not imported for tests). */
81
+ export function startServer(screenDir: string, port: number): void {
82
+ mkdirSync(screenDir, { recursive: true });
83
+
84
+ const server = createServer((req, res) => {
85
+ if (req.method === "POST" && req.url === "/event") {
86
+ const chunks: Buffer[] = [];
87
+ req.on("data", (c) => chunks.push(c));
88
+ req.on("end", () => {
89
+ appendFileSync(join(screenDir, ".events"), `${Buffer.concat(chunks).toString()}\n`);
90
+ res.writeHead(200);
91
+ res.end("ok");
92
+ });
93
+ return;
94
+ }
95
+
96
+ if (req.url === "/health") {
97
+ res.writeHead(200, { "Content-Type": "application/json" });
98
+ res.end(JSON.stringify({ status: "ok" }));
99
+ return;
100
+ }
101
+
102
+ const newest = getNewestHtml(screenDir);
103
+ if (!newest) {
104
+ res.writeHead(200, { "Content-Type": "text/html" });
105
+ res.end(buildFrameHtml("<p class='subtitle'>Waiting for visualization...</p>"));
106
+ return;
107
+ }
108
+
109
+ const content = readFileSync(join(screenDir, newest), "utf-8");
110
+ res.writeHead(200, { "Content-Type": "text/html" });
111
+
112
+ if (content.startsWith("<!DOCTYPE") || content.startsWith("<html")) {
113
+ res.end(content);
114
+ } else {
115
+ res.end(buildFrameHtml(content));
116
+ }
117
+ });
118
+
119
+ server.listen(port, () => {
120
+ const info = {
121
+ type: "server-started",
122
+ port,
123
+ url: `http://localhost:${port}`,
124
+ screen_dir: screenDir,
125
+ };
126
+ writeFileSync(join(screenDir, ".server-info"), JSON.stringify(info));
127
+ console.log(JSON.stringify(info));
128
+ });
129
+ }
130
+
131
+ // --- CLI entry point ---
132
+ // Only start server when run directly, not when imported for testing
133
+ const isDirectRun =
134
+ process.argv[1]?.endsWith("viz-server.ts") || process.argv[1]?.endsWith("viz-server.js");
135
+
136
+ if (isDirectRun) {
137
+ const args = process.argv.slice(2);
138
+ let screenDir = "";
139
+ let port = 52742;
140
+
141
+ for (let i = 0; i < args.length; i++) {
142
+ if (args[i] === "--screen-dir" && args[i + 1]) screenDir = args[++i];
143
+ if (args[i] === "--port" && args[i + 1]) port = parseInt(args[++i], 10);
144
+ }
145
+
146
+ if (!screenDir) {
147
+ console.error("Usage: bun run viz-server.ts --screen-dir <dir>");
148
+ process.exit(1);
149
+ }
150
+
151
+ startServer(screenDir, port);
152
+ }
@@ -0,0 +1,156 @@
1
+ ---
2
+ name: sia-brainstorm
3
+ description: Brainstorms features using SIA's knowledge graph — surfaces past decisions, rejected alternatives, and architectural constraints before proposing approaches. Use when starting any creative work, designing features, or modifying behavior.
4
+ ---
5
+
6
+ # SIA-Enhanced Brainstorming
7
+
8
+ Help turn ideas into fully formed designs and specs through natural collaborative dialogue, powered by SIA's knowledge graph. This improves upon standard brainstorming by starting with accumulated project knowledge instead of from scratch.
9
+
10
+ <HARD-GATE>
11
+ Do NOT invoke any implementation skill, write any code, scaffold any project, or take any implementation action until you have presented a design and the user has approved it. This applies to EVERY project regardless of perceived simplicity.
12
+ </HARD-GATE>
13
+
14
+ ## Anti-Pattern: "This Is Too Simple To Need A Design"
15
+
16
+ Every project goes through this process. A todo list, a single-function utility, a config change — all of them. "Simple" projects are where unexamined assumptions cause the most wasted work. The design can be short (a few sentences for truly simple projects), but you MUST present it and get approval.
17
+
18
+ ## What SIA Adds
19
+
20
+ Standard brainstorming explores the codebase by reading files and recent commits. SIA-enhanced brainstorming also queries:
21
+ - **Past decisions** in the same area — what was chosen and why
22
+ - **Rejected alternatives** — what was tried and abandoned (bi-temporal `t_valid_until` data)
23
+ - **Architectural constraints** — conventions and patterns that must be respected
24
+ - **Community structure** — module boundaries and relationships
25
+ - **Prior sessions** — what was discussed before about similar topics
26
+
27
+ ## Checklist
28
+
29
+ You MUST create a task for each of these items and complete them in order:
30
+
31
+ 1. **SIA Context Retrieval** — query the knowledge graph for prior decisions, conventions, and rejected approaches
32
+ 2. **Explore project context** — check files, docs, recent commits
33
+ 3. **Offer visual companion** (if topic will involve visual questions) — this is its own message, not combined with a clarifying question. See the Visual Companion section below.
34
+ 4. **Ask clarifying questions** — one at a time, understand purpose/constraints/success criteria
35
+ 5. **Propose 2-3 approaches** — with trade-offs and your recommendation (informed by SIA graph context)
36
+ 6. **Present design** — in sections scaled to their complexity, get user approval after each section
37
+ 7. **Write design doc + capture knowledge** — save to `docs/specs/YYYY-MM-DD-<topic>-design.md`, capture decisions to SIA, commit
38
+ 8. **Spec review loop** — dispatch spec-document-reviewer subagent (see spec-document-reviewer-prompt.md); fix issues and re-dispatch until approved (max 3 iterations, then surface to human)
39
+ 9. **User reviews written spec** — ask user to review the spec file before proceeding
40
+ 10. **Transition to implementation** — invoke sia-plan to create implementation plan
41
+
42
+ ## Enhanced Workflow
43
+
44
+ ### Step 0 — SIA Context Retrieval (before any exploration)
45
+
46
+ Before exploring files or asking questions, query the knowledge graph:
47
+
48
+ ```
49
+ sia_search({ query: "<feature area description>", task_type: "feature", limit: 15 })
50
+ sia_search({ query: "decisions conventions <feature area>", node_types: ["Decision", "Convention"], limit: 10 })
51
+ sia_community({ query: "<feature area>", level: 1 })
52
+ ```
53
+
54
+ Review the results. Key things to note:
55
+ - **Active decisions** that constrain the design space
56
+ - **Conventions** that must be followed
57
+ - **Past proposals** in this area (check for invalidated entities — `t_valid_until` set — these are rejected approaches)
58
+ - **Community structure** showing module boundaries
59
+
60
+ Present a brief "Graph Context" summary to the user before asking questions:
61
+
62
+ > **SIA Context:**
63
+ > - 3 prior decisions in this area: [list]
64
+ > - 2 conventions that apply: [list]
65
+ > - 1 previously rejected approach: [description + why rejected]
66
+
67
+ ### Step 1 — Explore Project Context
68
+
69
+ Check out the current project state (files, docs, recent commits). Before asking detailed questions, assess scope: if the request describes multiple independent subsystems, flag this immediately.
70
+
71
+ If the project is too large for a single spec, help the user decompose into sub-projects. Each sub-project gets its own spec → plan → implementation cycle.
72
+
73
+ ### Step 2 — Offer Visual Companion
74
+
75
+ When you anticipate that upcoming questions will involve visual content (mockups, layouts, diagrams), offer the visual companion once for consent:
76
+
77
+ > "Some of what we're working on might be easier to explain if I can show it to you in a web browser. I can put together mockups, diagrams, comparisons, and other visuals as we go. This feature is still new and can be token-intensive. Want to try it? (Requires opening a local URL)"
78
+
79
+ **This offer MUST be its own message.** Do not combine it with clarifying questions, context summaries, or any other content. Wait for the user's response before continuing. If they decline, proceed with text-only brainstorming.
80
+
81
+ **Per-question decision:** Even after the user accepts, decide FOR EACH QUESTION whether to use the browser or the terminal. The test: **would the user understand this better by seeing it than reading it?**
82
+
83
+ - **Use the browser** for content that IS visual — mockups, wireframes, layout comparisons, architecture diagrams, side-by-side visual designs
84
+ - **Use the terminal** for content that is text — requirements questions, conceptual choices, tradeoff lists, A/B/C/D text options, scope decisions
85
+
86
+ If they agree to the companion, read the detailed guide before proceeding:
87
+ `skills/sia-brainstorm/visual-companion.md`
88
+
89
+ ### Step 3 — Ask Clarifying Questions
90
+
91
+ - One question at a time — don't overwhelm with multiple questions
92
+ - Prefer multiple choice when possible, but open-ended is fine too
93
+ - Focus on understanding: purpose, constraints, success criteria
94
+
95
+ ### Step 4 — Propose 2-3 Approaches (ENHANCED)
96
+
97
+ - Present options conversationally with your recommendation and reasoning
98
+ - Lead with your recommended option and explain why
99
+
100
+ **SIA Enhancement:** When proposing approaches, explicitly note which prior decisions each approach aligns with or contradicts. If an approach was tried before and rejected, say so and explain what's different now.
101
+
102
+ ### Step 5 — Present Design
103
+
104
+ - Scale each section to its complexity: a few sentences if straightforward, up to 200-300 words if nuanced
105
+ - Ask after each section whether it looks right so far
106
+ - Cover: architecture, components, data flow, error handling, testing
107
+
108
+ **Design for isolation and clarity:**
109
+ - Break the system into smaller units with one clear purpose each
110
+ - For each unit: what does it do, how do you use it, what does it depend on?
111
+
112
+ ### Step 6 — Write Design Doc + Capture Knowledge (ENHANCED)
113
+
114
+ Write the validated design (spec) to `docs/specs/YYYY-MM-DD-<topic>-design.md` and commit.
115
+
116
+ **SIA Enhancement — capture decisions to the graph:**
117
+
118
+ ```
119
+ sia_note({ kind: "Decision", name: "<main design decision>", content: "<rationale, alternatives considered, what was rejected>", tags: ["design", "<feature-area>"] })
120
+ ```
121
+
122
+ For each rejected alternative:
123
+
124
+ ```
125
+ sia_note({ kind: "Decision", name: "Rejected: <alternative>", content: "<why rejected>", supersedes: "<old_decision_id if replacing>" })
126
+ ```
127
+
128
+ ### Step 7 — Spec Review Loop
129
+
130
+ After writing the spec document:
131
+
132
+ 1. Dispatch spec-document-reviewer subagent (see `skills/sia-brainstorm/spec-document-reviewer-prompt.md`)
133
+ 2. If Issues Found: fix, re-dispatch, repeat until Approved
134
+ 3. If loop exceeds 3 iterations, surface to human for guidance
135
+
136
+ ### Step 8 — User Review Gate
137
+
138
+ After the spec review loop passes, ask the user to review the written spec before proceeding:
139
+
140
+ > "Spec written and committed to `<path>`. Please review it and let me know if you want to make any changes before we start writing out the implementation plan."
141
+
142
+ Wait for the user's response. If they request changes, make them and re-run the spec review loop. Only proceed once the user approves.
143
+
144
+ ### Step 9 — Transition to Implementation
145
+
146
+ Invoke sia-plan to create a detailed implementation plan. Do NOT invoke any other skill.
147
+
148
+ ## Key Principles
149
+
150
+ - **Never brainstorm from zero** — always check what SIA knows first
151
+ - **One question at a time** — don't overwhelm with multiple questions
152
+ - **Multiple choice preferred** — easier to answer than open-ended when possible
153
+ - **YAGNI ruthlessly** — remove unnecessary features from all designs
154
+ - **Surface rejected approaches explicitly** — prevent repeating failed ideas
155
+ - **Capture the design** — future brainstorming sessions will benefit from this one's output
156
+ - **Cite graph entities** — when a prior decision constrains the design, name it