@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
@@ -0,0 +1,120 @@
1
+ ---
2
+ name: sia-debug-workflow
3
+ description: Debugs systematically using SIA's temporal knowledge graph — traces root cause through time, surfaces known bugs, and finds past solutions. Use when encountering bugs, errors, test failures, or unexpected behavior.
4
+ ---
5
+
6
+ ## Invariants
7
+
8
+ > These rules have No exceptions. A debug session that violates them is incomplete.
9
+ >
10
+ > 1. YOU MUST query `sia_search` for known bugs BEFORE investigating. "I already
11
+ > know the cause" is the #1 reason developers re-debug solved problems.
12
+ > 2. YOU MUST capture both a Bug entity AND a Solution entity after fixing.
13
+ > A fix without graph capture is an incomplete session. STOP and capture
14
+ > before moving on.
15
+ > 3. If a Bug+Solution pair already exists in the graph, STOP investigating
16
+ > and apply the known fix. Do not re-derive what's already known.
17
+
18
+ ## Red Flags — If You Think Any of These, STOP
19
+
20
+ | Thought | Why It's Wrong |
21
+ |---------|---------------|
22
+ | "I already know the root cause" | You know A root cause. The graph may know THE root cause — and it may be different. Query first. |
23
+ | "This is a quick fix, I don't need the temporal query" | Quick fixes that skip temporal investigation are how regressions get re-introduced. |
24
+ | "The bug is obvious from the stack trace" | Stack traces show symptoms, not causes. The graph shows causal history. |
25
+ | "I'll capture the bug after I fix it" | If you forget (and you will), the next developer re-debugs from scratch. Capture NOW. |
26
+ | "This bug isn't important enough to record" | Every bug is important enough. Future-you will thank present-you. |
27
+
28
+ # SIA-Enhanced Systematic Debugging
29
+
30
+ Debug methodically with SIA's temporal knowledge graph — adds temporal investigation ("when did it break?"), known bug history, and cross-session memory to standard debugging.
31
+
32
+ ## Checklist
33
+
34
+ ```
35
+ - [ ] Phase 1: YOU MUST query SIA for known bugs/solutions BEFORE investigating. If a match exists, apply it — do not re-derive. Run sia_at_time. Check affected files.
36
+ - [ ] Phase 2: Expand dependency chain with sia_expand. Find working patterns in the same community. Do NOT skip this — the bug may originate upstream.
37
+ - [ ] Phase 3: Form ONE hypothesis, test minimally, verify. Do not shotgun multiple changes.
38
+ - [ ] Phase 4: Fix, then YOU MUST capture both Bug AND Solution to graph. A debug session without sia_note calls for both is INCOMPLETE.
39
+ ```
40
+
41
+ ## 4-Phase Workflow
42
+
43
+ ### Phase 1 — Root Cause Investigation (ENHANCED)
44
+
45
+ **Standard steps:** Read errors, reproduce consistently, check recent changes.
46
+
47
+ **SIA enhancement — add BEFORE standard investigation:**
48
+
49
+ ```
50
+ sia_search({ query: "<error message or symptom>", task_type: "bug-fix", node_types: ["Bug", "Solution"], limit: 10 })
51
+ ```
52
+
53
+ If a matching Bug+Solution pair exists → **stop investigating and apply the known fix.** Don't re-debug what's already been solved.
54
+
55
+ If no match, use temporal investigation:
56
+
57
+ ```
58
+ sia_at_time({ as_of: "<time_before_bug>", entity_types: ["Decision", "Bug", "Solution"] })
59
+ ```
60
+
61
+ Compare the graph state before vs after the bug appeared. What decisions or changes coincide with the bug's introduction?
62
+
63
+ For each affected file:
64
+
65
+ ```
66
+ sia_by_file({ file_path: "<broken_file>" })
67
+ ```
68
+
69
+ Check for known issues, recent changes, and related entities.
70
+
71
+ **For detailed temporal investigation guidance:** See [temporal-investigation.md](temporal-investigation.md)
72
+
73
+ ### Phase 2 — Pattern Analysis (ENHANCED)
74
+
75
+ **Standard steps:** Find working examples, compare, identify differences.
76
+
77
+ **SIA enhancement:**
78
+
79
+ ```
80
+ sia_expand({ entity_id: "<broken_entity>", depth: 2, edge_types: ["calls", "imports", "depends_on"] })
81
+ ```
82
+
83
+ Map the full dependency chain. The bug may originate upstream — SIA's edges show what calls/imports the broken code.
84
+
85
+ ```
86
+ sia_community({ entity_id: "<broken_entity>" })
87
+ ```
88
+
89
+ Find structurally similar code in the same community that IS working. Compare the broken version against the working pattern.
90
+
91
+ **For detailed causal chain analysis:** See [root-cause-tracing.md](root-cause-tracing.md)
92
+
93
+ ### Phase 3 — Hypothesis and Testing (same as standard)
94
+
95
+ Form a single hypothesis, test minimally, verify. No SIA changes needed here — this phase is about focused experimentation.
96
+
97
+ ### Phase 4 — Implementation + Capture (ENHANCED)
98
+
99
+ **Standard steps:** Create failing test, implement fix, verify.
100
+
101
+ **SIA enhancement — after fixing:**
102
+
103
+ ```
104
+ sia_note({ kind: "Bug", name: "<root_cause>", content: "<what was wrong, affected files, how it manifested>" })
105
+ sia_note({ kind: "Solution", name: "<fix_description>", content: "<what was done, why it works>", relates_to: ["<bug_entity_id>"] })
106
+ ```
107
+
108
+ **Always capture both the Bug and the Solution.** If 3+ fixes fail (standard threshold for questioning architecture), also query:
109
+
110
+ ```
111
+ sia_search({ query: "<module> recurring bugs failures", node_types: ["Bug"], limit: 20 })
112
+ ```
113
+
114
+ Check if this is a problem area with a history of bugs. If so, surface the pattern to the developer — this may need a design change, not another patch.
115
+
116
+ **For test pollution bisection:** Run `skills/sia-debug-workflow/scripts/find-polluter.sh`
117
+
118
+ ## Key Principle
119
+
120
+ **Time is your best debugging tool.** `sia_at_time` lets you ask "what was true before this broke?" — that's usually the fastest path to root cause.
@@ -0,0 +1,70 @@
1
+ # Root Cause Tracing with SIA
2
+
3
+ Trace bugs to their upstream origin by mapping dependency chains through the knowledge graph.
4
+
5
+ ## When to Use
6
+
7
+ Use root cause tracing when:
8
+ - The symptom is in file A but the cause is likely in a dependency
9
+ - Multiple files are affected and you need to find the common ancestor
10
+ - A fix in one place doesn't resolve the issue (upstream cause)
11
+
12
+ ## The Process
13
+
14
+ ### Step 1 — Map the broken entity's neighborhood
15
+
16
+ ```
17
+ sia_expand({ entity_id: "<broken_entity>", depth: 2, edge_types: ["calls", "imports", "depends_on"] })
18
+ ```
19
+
20
+ This returns a subgraph showing everything the broken code depends on and everything that depends on it.
21
+
22
+ ### Step 2 — Read the edges
23
+
24
+ | Edge Type | Direction | Meaning |
25
+ |---|---|---|
26
+ | `calls` | outgoing | This code calls that code — bug may be in the callee |
27
+ | `imports` | outgoing | This code imports that module — breaking change in dependency |
28
+ | `depends_on` | outgoing | Logical dependency — behavioral contract may have changed |
29
+ | `calls` | incoming | Something calls this code — caller may be passing bad input |
30
+
31
+ ### Step 3 — Follow the chain upstream
32
+
33
+ For each dependency in the expansion:
34
+
35
+ ```
36
+ sia_by_file({ file_path: "<dependency_file>" })
37
+ ```
38
+
39
+ Check if the dependency has:
40
+ - Recent Decision entities (was it intentionally changed?)
41
+ - Bug entities (is it already known to be broken?)
42
+ - Convention entities that were violated
43
+
44
+ ### Step 4 — Find the root
45
+
46
+ The root cause is the **deepest entity in the chain where the bug originates**. Signs you've found it:
47
+ - Changing this entity fixes all downstream symptoms
48
+ - A Decision entity here explains why the behavior changed
49
+ - A Convention entity here was violated
50
+
51
+ ### Step 5 — Verify with community context
52
+
53
+ ```
54
+ sia_community({ entity_id: "<suspected_root>" })
55
+ ```
56
+
57
+ Check if other entities in the same community are also affected. If yes, the root cause impacts the entire module — not just one file.
58
+
59
+ ## Worked Example
60
+
61
+ **Symptom:** API endpoint returns 500.
62
+
63
+ 1. `sia_expand` on the endpoint handler → depends on `AuthMiddleware`, `UserService`, `Database`
64
+ 2. `sia_by_file` on each → `UserService` has a recent Decision: "Changed user lookup to use email instead of ID"
65
+ 3. The Decision coincides with the bug's timeline → root cause found
66
+ 4. Fix: Update the endpoint to pass email, not ID
67
+
68
+ ## Anti-Pattern: Fixing Symptoms
69
+
70
+ **Never fix just the symptom.** If the API returns 500 because UserService changed its contract, adding a try-catch to the endpoint masks the real issue. Trace upstream, fix at the source.
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env bash
2
+ # Find which test pollutes another test by running bisection
3
+ # Usage: find-polluter.sh <test-command> <failing-test> [test-dir]
4
+ #
5
+ # Example:
6
+ # find-polluter.sh "bun test" "src/auth/login.test.ts" "src/"
7
+ #
8
+ # Runs the failing test after each other test file individually
9
+ # to find which one leaves behind state that causes the failure.
10
+
11
+ set -euo pipefail
12
+
13
+ TEST_CMD="${1:?Usage: find-polluter.sh <test-command> <failing-test> [test-dir]}"
14
+ FAILING_TEST="${2:?Usage: find-polluter.sh <test-command> <failing-test> [test-dir]}"
15
+ TEST_DIR="${3:-.}"
16
+
17
+ # Discover all test files except the failing one
18
+ mapfile -t TEST_FILES < <(find "$TEST_DIR" -name "*.test.*" -o -name "*.spec.*" | grep -v "$FAILING_TEST" | sort)
19
+
20
+ echo "Searching ${#TEST_FILES[@]} test files for polluter of $FAILING_TEST"
21
+ echo "---"
22
+
23
+ # Verify the failing test actually fails in isolation first
24
+ if $TEST_CMD "$FAILING_TEST" &>/dev/null; then
25
+ echo "The test passes when run alone — this IS a pollution issue."
26
+ else
27
+ echo "The test fails even in isolation — not a pollution issue."
28
+ echo "Debug the test itself, not other tests."
29
+ exit 1
30
+ fi
31
+
32
+ # Bisection
33
+ lo=0
34
+ hi=$((${#TEST_FILES[@]} - 1))
35
+
36
+ while [ $lo -le $hi ]; do
37
+ mid=$(( (lo + hi) / 2 ))
38
+ subset=("${TEST_FILES[@]:0:$((mid+1))}")
39
+
40
+ echo "Testing files 0..$mid (${#subset[@]} files)..."
41
+
42
+ # Run subset + failing test together
43
+ if $TEST_CMD "${subset[@]}" "$FAILING_TEST" &>/dev/null; then
44
+ echo " Pass — polluter is in files $((mid+1))..$hi"
45
+ lo=$((mid + 1))
46
+ else
47
+ echo " FAIL — polluter is in files $lo..$mid"
48
+ hi=$((mid - 1))
49
+ fi
50
+ done
51
+
52
+ if [ $lo -lt ${#TEST_FILES[@]} ]; then
53
+ echo "---"
54
+ echo "Found polluter: ${TEST_FILES[$lo]}"
55
+ echo ""
56
+ echo "Next steps:"
57
+ echo " 1. Run: $TEST_CMD ${TEST_FILES[$lo]} $FAILING_TEST"
58
+ echo " 2. Check what state ${TEST_FILES[$lo]} leaves behind"
59
+ echo " 3. Add proper cleanup/teardown to the polluting test"
60
+ else
61
+ echo "---"
62
+ echo "Could not isolate a single polluter."
63
+ echo "The pollution may require multiple tests interacting."
64
+ fi
@@ -0,0 +1,72 @@
1
+ # Temporal Investigation with sia_at_time
2
+
3
+ SIA's temporal queries let you ask "what was true before this broke?" — the fastest path to root cause for regressions.
4
+
5
+ ## When to Use
6
+
7
+ ```dot
8
+ digraph {
9
+ "Bug reported" -> "Known bug in graph?";
10
+ "Known bug in graph?" -> "Apply known fix" [label="yes"];
11
+ "Known bug in graph?" -> "When did it start?" [label="no"];
12
+ "When did it start?" -> "Known time" [label="user told you"];
13
+ "When did it start?" -> "Bisect with git" [label="unknown"];
14
+ "Known time" -> "sia_at_time query";
15
+ "Bisect with git" -> "sia_at_time query";
16
+ "sia_at_time query" -> "Compare before/after";
17
+ "Compare before/after" -> "Identify causal change";
18
+ }
19
+ ```
20
+
21
+ ## Choosing the Right Timestamp
22
+
23
+ | Scenario | Timestamp Strategy |
24
+ |---|---|
25
+ | "It broke last week" | Use `as_of` = last Monday midnight |
26
+ | "It broke after deploy X" | Use `as_of` = deploy timestamp from git tag |
27
+ | "It was working in v2.1" | Use `as_of` = v2.1 release date |
28
+ | "Not sure when" | Use git bisect first, then `sia_at_time` on the identified commit date |
29
+
30
+ ## The Query Pattern
31
+
32
+ **Step 1 — Snapshot before the bug:**
33
+
34
+ ```
35
+ sia_at_time({ as_of: "<before_bug>", entity_types: ["Decision", "Convention", "Bug", "Solution"] })
36
+ ```
37
+
38
+ **Step 2 — Compare with current state:**
39
+
40
+ ```
41
+ sia_search({ query: "<affected area>", task_type: "bug-fix", limit: 20 })
42
+ ```
43
+
44
+ **Step 3 — Identify the delta:**
45
+
46
+ Look for:
47
+ - **New Decision entities** that appeared after `as_of` — these are changes that coincide with the bug
48
+ - **Invalidated entities** (`t_valid_until` set) — something was intentionally changed
49
+ - **New Bug entities** in the same area — related issues that may share a root cause
50
+
51
+ ## Interpreting Results
52
+
53
+ **Strong signal:** A Decision entity was created near the bug's introduction date that modified the affected module. This is likely causal.
54
+
55
+ **Weak signal:** Only Convention changes in the timeframe. Conventions rarely cause bugs — look deeper.
56
+
57
+ **No signal:** The graph has no entities near the timestamp. Fall back to git log analysis and `sia_by_file` for structural investigation.
58
+
59
+ ## Common Pitfalls
60
+
61
+ | Pitfall | Fix |
62
+ |---|---|
63
+ | Querying too narrow a window | Widen by 2x — bugs often manifest days after the causal change |
64
+ | Ignoring `t_valid_until` entities | These are CHANGES — exactly what you're looking for |
65
+ | Trusting Tier 3 timestamps blindly | Tier 3 entities have `t_valid_from = null` sometimes — verify against git |
66
+ | Skipping `sia_by_file` after temporal | Always check the affected file's current graph state too |
67
+
68
+ ## Red Flags
69
+
70
+ - **3+ temporal queries with no signal** → The bug predates the graph. Switch to pure git investigation.
71
+ - **Conflicting temporal data** → Check for `conflict_group_id` on results. Resolve conflicts before debugging.
72
+ - **Bug reintroduced** → Same Bug entity appears, gets fixed (Solution), then reappears. This is a systemic issue — surface to developer.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: sia-digest
3
+ description: Generates a daily knowledge digest summarizing recent decisions, bugs, conventions, and changes captured by SIA. Use at the start of a session, for daily standups, or when the user asks what changed recently.
4
+ ---
5
+
6
+ # SIA Digest
7
+
8
+ Generate a summary of recent knowledge captured in the graph.
9
+
10
+ ## Steps
11
+
12
+ Run the digest command:
13
+
14
+ ```bash
15
+ bun run ${CLAUDE_PLUGIN_ROOT}/src/cli/commands/digest.ts
16
+ ```
17
+
18
+ This produces a markdown summary including:
19
+ - Decisions made in the last 24 hours
20
+ - New conventions established
21
+ - Bugs discovered and solutions applied
22
+ - Code areas with the most activity
23
+ - Community-level changes
@@ -0,0 +1,69 @@
1
+ ---
2
+ name: sia-dispatch
3
+ description: Dispatches parallel agents using SIA's community detection for independence verification and auto-extracted subgraph context per agent. Use when facing 2+ independent tasks, parallelizing work, or dispatching subagents.
4
+ ---
5
+
6
+ # SIA-Enhanced Parallel Agent Dispatch
7
+
8
+ Dispatch parallel agents with graph-powered independence verification and rich per-agent context extraction.
9
+
10
+ ## Checklist
11
+
12
+ ```
13
+ - [ ] Step 1: Query sia_community, verify domains are in different communities
14
+ - [ ] Step 2: For each agent — extract conventions, bugs, dependencies from graph
15
+ - [ ] Step 3: Dispatch agents with graph context in task descriptions
16
+ - [ ] Step 4: After integration — sia_expand to verify no cross-domain breakage
17
+ ```
18
+
19
+ ## Workflow
20
+
21
+ ### Step 1 — Identify Independent Domains (ENHANCED)
22
+
23
+ Instead of guessing independence, query the graph:
24
+
25
+ ```
26
+ sia_community({ level: 0 })
27
+ ```
28
+
29
+ Community clusters represent modules that are tightly connected internally but loosely connected externally. Tasks within the SAME community should be sequential. Tasks in DIFFERENT communities can be parallel.
30
+
31
+ For each proposed parallel task, verify independence:
32
+
33
+ ```
34
+ sia_expand({ entity_id: "<domain_a_entity>", depth: 2, edge_types: ["calls", "imports", "depends_on"] })
35
+ sia_expand({ entity_id: "<domain_b_entity>", depth: 2, edge_types: ["calls", "imports", "depends_on"] })
36
+ ```
37
+
38
+ If the expansion graphs overlap (shared entities), the tasks are NOT independent. Warn and suggest sequential execution.
39
+
40
+ ### Step 2 — Create Agent Tasks (ENHANCED)
41
+
42
+ **For task description format:** See [agent-task-template.md](agent-task-template.md)
43
+
44
+ For each agent, auto-extract the relevant subgraph:
45
+
46
+ ```
47
+ sia_by_file({ file_path: "<agent's primary file>" })
48
+ sia_search({ query: "conventions <agent's domain>", node_types: ["Convention"], limit: 5 })
49
+ sia_search({ query: "bugs <agent's domain>", node_types: ["Bug"], limit: 5 })
50
+ ```
51
+
52
+ Include the results in each agent's task description:
53
+ - Known conventions for this area
54
+ - Known bugs to watch for
55
+ - Dependency relationships to respect
56
+
57
+ ### Step 3-4 — Dispatch + Integrate (enhanced)
58
+
59
+ Standard dispatch and review, but after integration:
60
+
61
+ ```
62
+ sia_expand({ entity_id: "<modified_entity>", depth: 1 })
63
+ ```
64
+
65
+ Verify that no agent's changes broke another's domain by checking edge integrity.
66
+
67
+ ## Key Principle
68
+
69
+ **Community structure determines parallelizability.** Don't guess — let the graph's clustering tell you what's independent.
@@ -0,0 +1,99 @@
1
+ # Agent Task Template
2
+
3
+ Use this template when constructing task descriptions for parallel agents dispatched via sia-dispatch.
4
+
5
+ ## Template
6
+
7
+ For each agent, construct the task description using this structure:
8
+
9
+ ```
10
+ Agent tool:
11
+ description: "<3-5 word task summary>"
12
+ prompt: |
13
+ ## Task
14
+ <What this agent should accomplish>
15
+
16
+ ## Graph Context
17
+ ### Conventions for this area
18
+ <Paste sia_search Convention results here>
19
+
20
+ ### Known bugs to watch for
21
+ <Paste sia_search Bug results here>
22
+
23
+ ### Dependencies
24
+ <Paste sia_by_file results — what calls/imports/depends_on this code>
25
+
26
+ ## Constraints
27
+ - Do NOT modify files outside your domain: <list files>
28
+ - Follow these conventions: <list from graph>
29
+ - Test for these known edge cases: <list from Bug entities>
30
+
31
+ ## When You're Stuck
32
+ - If you need to modify a file outside your domain → STOP and report
33
+ - If a convention conflicts with the task → report the conflict
34
+ - If tests fail for reasons unrelated to your changes → report, don't fix
35
+ ```
36
+
37
+ ## How to Fill the Template
38
+
39
+ ### Step 1 — Extract conventions
40
+
41
+ ```
42
+ sia_search({ query: "conventions <agent's domain>", node_types: ["Convention"], limit: 5 })
43
+ ```
44
+
45
+ Include each Convention's `name` and `content` in the "Conventions" section.
46
+
47
+ ### Step 2 — Extract known bugs
48
+
49
+ ```
50
+ sia_search({ query: "bugs <agent's domain>", node_types: ["Bug"], limit: 5 })
51
+ ```
52
+
53
+ Include each Bug's `name` as an edge case to test for.
54
+
55
+ ### Step 3 — Extract dependencies
56
+
57
+ ```
58
+ sia_by_file({ file_path: "<agent's primary file>" })
59
+ ```
60
+
61
+ List incoming edges (callers) as things the agent must not break.
62
+
63
+ ## Worked Example
64
+
65
+ ```
66
+ Agent tool:
67
+ description: "Implement auth middleware"
68
+ prompt: |
69
+ ## Task
70
+ Implement JWT validation middleware for the Express API.
71
+
72
+ ## Graph Context
73
+ ### Conventions for this area
74
+ - [Convention: Middleware returns structured JSON errors] — all middleware
75
+ must return { error: string, code: number }, not plain text
76
+ - [Convention: Auth tokens in Authorization header] — Bearer scheme only
77
+
78
+ ### Known bugs to watch for
79
+ - [Bug: Token expiry off-by-one] — JWT expiry check was < instead of <=,
80
+ caused 401s at exact expiry second. Test boundary condition.
81
+
82
+ ### Dependencies
83
+ - `src/routes/users.ts` imports this middleware
84
+ - `src/routes/admin.ts` imports this middleware
85
+ - Changes must be backward-compatible with both consumers
86
+
87
+ ## Constraints
88
+ - Do NOT modify files outside src/middleware/
89
+ - Follow structured JSON error convention
90
+ - Test token expiry boundary condition
91
+
92
+ ## When You're Stuck
93
+ - If you need to modify route files → STOP and report
94
+ - If the JWT library API doesn't match expectations → report
95
+ ```
96
+
97
+ ## Why This Matters
98
+
99
+ Without structured context, parallel agents make incompatible assumptions. This template ensures each agent gets the same quality of graph context, preventing post-integration conflicts.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: sia-doctor
3
+ description: Runs SIA system health diagnostics — checks databases, providers, tree-sitter, embeddings, and connectivity. Use when SIA tools return errors, knowledge seems missing, or the user reports SIA issues.
4
+ ---
5
+
6
+ # SIA Doctor
7
+
8
+ Run comprehensive diagnostics on the SIA installation.
9
+
10
+ ## Steps
11
+
12
+ Run the doctor command:
13
+
14
+ ```bash
15
+ bun run ${CLAUDE_PLUGIN_ROOT}/src/cli/commands/doctor.ts
16
+ ```
17
+
18
+ This checks:
19
+ - Database integrity (graph.db, episodic.db, meta.db, bridge.db)
20
+ - Tree-sitter parser availability and grammar loading
21
+ - ONNX embedding model availability
22
+ - LLM provider connectivity (if configured)
23
+ - Hook registration status
24
+ - Disk usage
25
+
26
+ ## MCP Tool
27
+
28
+ You can also run diagnostics via the `sia_doctor` MCP tool with targeted checks:
29
+
30
+ ```
31
+ sia_doctor({ checks: ["all"] })
32
+ sia_doctor({ checks: ["graph_integrity", "onnx"] })
33
+ ```
34
+
35
+ Valid check names: `runtimes`, `hooks`, `fts5`, `vss`, `onnx`, `graph_integrity`, `all`
36
+
37
+ ## Interpreting Results
38
+
39
+ Each check reports: OK, Warning, or Error with remediation steps.
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: sia-execute
3
+ description: Executes code in SIA's isolated sandbox environment with automatic knowledge capture. Use when running code snippets, testing expressions, or executing scripts with SIA context.
4
+ ---
5
+
6
+ # SIA Execute
7
+
8
+ Run code in an isolated sandbox with automatic knowledge graph integration.
9
+
10
+ ## When To Use
11
+
12
+ Use this skill when you need to:
13
+ - Execute code snippets in a sandboxed environment
14
+ - Run an existing file in a sandbox subprocess
15
+ - Batch multiple operations (execute + search) in one call
16
+
17
+ ## MCP Tools
18
+
19
+ ### sia_execute — Run inline code
20
+
21
+ ```
22
+ sia_execute({
23
+ code: "console.log('hello')",
24
+ language: "javascript",
25
+ intent: "Test logging output",
26
+ timeout: 10000
27
+ })
28
+ ```
29
+
30
+ Parameters:
31
+ - **code** (required): The code to execute
32
+ - **language** (optional): Runtime language (supports 14+ runtimes)
33
+ - **intent** (optional): Description of what the code should do
34
+ - **timeout** (optional): Execution timeout in ms (default: 30s, configurable via `sandboxTimeoutMs`)
35
+ - **env** (optional): Environment variables to pass
36
+
37
+ ### sia_execute_file — Run an existing file
38
+
39
+ ```
40
+ sia_execute_file({
41
+ file_path: "scripts/migrate.ts",
42
+ language: "typescript",
43
+ intent: "Run database migration"
44
+ })
45
+ ```
46
+
47
+ Parameters:
48
+ - **file_path** (required): Path to the file to execute
49
+ - **language** (optional): Override language detection
50
+ - **command** (optional): Custom command to run the file
51
+ - **intent** (optional): Description of expected behavior
52
+ - **timeout** (optional): Execution timeout in ms
53
+
54
+ ### sia_batch_execute — Multiple operations in one call
55
+
56
+ ```
57
+ sia_batch_execute({
58
+ operations: [
59
+ { type: "execute", code: "1 + 1", language: "python" },
60
+ { type: "search", query: "related algorithms" }
61
+ ],
62
+ timeout_per_op: 5000
63
+ })
64
+ ```
65
+
66
+ ## Notes
67
+
68
+ - Sandbox execution uses credential passthrough with an environment allowlist
69
+ - Results are automatically indexed in the knowledge graph
70
+ - Context mode activates when output exceeds the threshold, chunking results for better retrieval