@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/README.md ADDED
@@ -0,0 +1,1013 @@
1
+ # Sia
2
+
3
+ **Persistent graph memory for AI coding agents.**
4
+
5
+ > *Sia was the Egyptian personification of perception, insight, and divine knowledge. She rode on the prow of Ra's solar barque and was said to write knowledge on the heart — the precise act of embedding structured understanding into a store that shapes all future reasoning.*
6
+
7
+ Every time you close a Claude Code session, the agent forgets everything. Decisions made Monday are invisible Friday. Bugs analyzed last week get rediscovered from scratch. Conventions established over days must be re-explained. Across a month of daily development, this compounds into hours of lost effort — and across a team, the problem multiplies because each developer's agent independently rebuilds the same understanding.
8
+
9
+ Sia captures knowledge from your sessions automatically and stores it in a local, bi-temporal knowledge graph. Between sessions, your agent retrieves only what is relevant. No explicit input. No server required. Everything runs locally.
10
+
11
+ ---
12
+
13
+ ## Why Sia?
14
+
15
+ ### The Problem: Agent Amnesia
16
+
17
+ AI coding agents have no persistent memory. Each session starts from zero. The agent cannot recall why a decision was made, what was tried before, or what constraints the team has accumulated over months. Context windows are finite, and when they compact, even intra-session knowledge is lost.
18
+
19
+ ### The Solution: Persistent Knowledge Graph
20
+
21
+ Sia gives your agent a typed, temporal, ontology-enforced knowledge graph that captures decisions, bugs, conventions, patterns, and the structural dependency graph of your codebase. Knowledge flows in automatically via hooks and out automatically via MCP tools. The developer never needs to manage the graph explicitly.
22
+
23
+ ### How Sia Differs from Existing Solutions
24
+
25
+ | Capability | CLAUDE.md (manual) | claude-mem | Obsidian + plugins | **Sia** |
26
+ |---|---|---|---|---|
27
+ | **Storage model** | Flat text file | Key-value store | Markdown vault with wikilinks | Unified knowledge graph with typed nodes and edges |
28
+ | **Relationships** | None — facts are isolated lines | None | Wikilinks (untyped, manual) | Typed, weighted edges (calls, supersedes, caused_by, solves, pertains_to, ...) |
29
+ | **Ontology enforcement** | None | None | None — any link to any note | Declarative edge constraints — invalid relationships rejected at write time |
30
+ | **Temporal awareness** | None — stale facts persist forever | Manual deletion | Git history (manual) | Bi-temporal: every fact has valid-from/valid-until; nothing is deleted, only invalidated |
31
+ | **Time-travel queries** | Not possible | Not possible | Manual git checkout | `sia_at_time` queries the graph at any historical point |
32
+ | **Retrieval** | Entire file injected every session | Keyword search | Full-text search + backlinks | Hybrid: vector similarity + BM25 + graph traversal with trust-weighted RRF reranking |
33
+ | **Context cost** | Grows unbounded with project maturity | Grows with entries | Manual copy-paste to agent | ~1,200 tokens average per session (only relevant facts retrieved) |
34
+ | **Code structure** | Not captured | Not captured | Not captured | AST-powered structural backbone via Tree-sitter (30+ languages) |
35
+ | **Documentation ingestion** | Not captured | Not captured | Manual note creation | Auto-discovers and indexes AGENTS.md, CLAUDE.md, ADRs, README.md, and 15+ doc formats |
36
+ | **Agent integration** | Injected at session start | MCP tool calls | None native; requires manual bridging | Native MCP server with 16 tools, automatic hook-based capture |
37
+ | **Sandbox execution** | N/A | N/A | N/A | Isolated subprocess execution with context-aware output indexing |
38
+ | **Session continuity** | Lost on compaction | Lost on compaction | N/A | Priority-weighted subgraph serialization survives context compaction |
39
+ | **Knowledge authoring** | Developer writes manually | Developer writes manually | Developer writes manually (rich editor) | `sia_note` for deliberate entry + automatic dual-track capture |
40
+ | **Multi-repo** | One file per repo, no cross-repo awareness | Single store, no repo concept | One vault, manual organization | Workspace model with cross-repo edges and API contract detection |
41
+ | **Team sharing** | Copy-paste or shared file | Not supported | Git sync or Obsidian Sync ($) | Optional sync via self-hosted server with visibility controls |
42
+ | **Security** | No write validation | No write validation | No trust model | 4-tier trust model, ontology enforcement, isolated staging area, paranoid mode, audit log with rollback |
43
+ | **Scalability** | Collapses past ~50 entries | Linear degradation | Degrades past ~10K notes | SQLite-backed, tested to 50K nodes with sub-800ms retrieval |
44
+ | **Capture method** | Developer writes manually | Developer writes manually | Developer writes manually | Automatic dual-track: deterministic AST + probabilistic LLM |
45
+ | **Knowledge decay** | Manual cleanup | Manual cleanup | Manual cleanup | Automatic importance decay with configurable half-lives per node kind |
46
+ | **Graph freshness** | Stale facts persist forever | No freshness model | No freshness model | Five-layer freshness engine: file-watcher, git-reconcile, stale-while-revalidate, confidence decay, deep validation |
47
+ | **Visualization** | Not available | Not available | Graph view (built-in) | Interactive D3.js graph explorer |
48
+ | **Export** | N/A | N/A | Native markdown | Obsidian-compatible markdown vault export/import (round-trip) |
49
+ | **Native performance** | N/A | N/A | N/A | Optional Rust module via NAPI-RS (AST diffing, PageRank, Leiden) with Wasm and TypeScript fallbacks |
50
+ | **Knowledge capture** | N/A | N/A | N/A | Three-layer: hooks (real-time, $0) + CLAUDE.md directives (proactive, $0) + pluggable LLM fallback |
51
+ | **Cross-agent support** | Claude Code only | Claude Code only | N/A | Claude Code (native), Cursor, Cline (hook adapters), Windsurf/Aider (MCP-only fallback) |
52
+
53
+ **The core difference:** CLAUDE.md and claude-mem treat memory as flat text or key-value stores. Obsidian provides rich manual knowledge management but has no AI agent integration. Sia treats memory as a **typed, temporal, ontology-enforced knowledge graph** with native agent integration — the same data structure that makes knowledge useful to humans also makes it useful to AI agents, and knowledge flows automatically between sessions without manual curation.
54
+
55
+ ---
56
+
57
+ ## Quick Start
58
+
59
+ ### Plugin Installation (Recommended)
60
+
61
+ ```bash
62
+ # 1. Add the Sia marketplace (one-time)
63
+ /plugin marketplace add rkarim08/sia
64
+
65
+ # 2. Install the plugin
66
+ /plugin install sia@sia-plugins
67
+ ```
68
+
69
+ This registers all 21 MCP tools, 46 skills, 23 agents, 8 hooks, and CLAUDE.md behavioral directives in one step.
70
+
71
+ > **Coming soon:** Once Sia is accepted into the official Anthropic marketplace, installation will simplify to `/plugin install sia@claude-plugins-official`.
72
+
73
+ ### Standalone Installation
74
+
75
+ If you prefer CLI-only usage without the plugin system:
76
+
77
+ ```bash
78
+ npx sia install
79
+ ```
80
+
81
+ This takes under three minutes and creates the `~/.sia/` directory, downloads the embedding model (~90MB ONNX), indexes your repository, generates CLAUDE.md directives, and registers the MCP server.
82
+
83
+ ### Build the Knowledge Graph
84
+
85
+ ```bash
86
+ /sia-learn # Full build: install + index code + ingest docs + detect communities
87
+ /sia-learn --incremental # Update changed files only
88
+ /sia-learn --force # Full rebuild ignoring all caches
89
+ ```
90
+
91
+ ### First-Run Wizard
92
+
93
+ ```bash
94
+ /sia-setup # Guided setup: detect project, configure, learn, tour
95
+ ```
96
+
97
+ ### Verify It Works
98
+
99
+ ```bash
100
+ sia stats # Graph statistics
101
+ sia search "authentication" # Search the knowledge graph
102
+ sia doctor # Health check
103
+ /sia-visualize-live # Graph explorer in your browser
104
+ ```
105
+
106
+ ---
107
+
108
+ ## How It Works
109
+
110
+ ### Write Path (Capture)
111
+
112
+ ```
113
+ Claude Code session
114
+ |
115
+ hooks fire on every action
116
+ |
117
+ v
118
+ PostToolUse ──┐
119
+ Stop ─────────┤
120
+ UserPrompt ───┤
121
+ PreCompact ───┤
122
+ SessionStart ─┘
123
+ |
124
+ v
125
+ Hook capture ($0) ──> Event nodes (EditEvent, ExecutionEvent, GitEvent, ...)
126
+ Dual-track extraction ──> Track A: AST (deterministic) + Track B: LLM (probabilistic)
127
+ Ontology validation ──> Edge constraints enforced at SQLite trigger level
128
+ Two-phase consolidation ──> ADD / UPDATE / INVALIDATE / NOOP against existing graph
129
+ Atomic write ──> Single transaction with full audit log
130
+ ```
131
+
132
+ ### Read Path (Retrieval)
133
+
134
+ ```
135
+ MCP tool call (sia_search, sia_by_file, ...)
136
+ |
137
+ v
138
+ Vector similarity (ONNX embeddings + sqlite-vss)
139
+ BM25 keyword search (SQLite FTS5)
140
+ Graph traversal (1-hop expansion from mentioned nodes)
141
+ |
142
+ v
143
+ Reciprocal Rank Fusion
144
+ weighted by: trust tier, task type, importance decay, graph proximity
145
+ |
146
+ v
147
+ Progressive throttling: normal (calls 1-3), reduced (4-8), blocked (9+)
148
+ |
149
+ v
150
+ Response to Claude Code
151
+ ```
152
+
153
+ ### Three-Layer Capture Architecture
154
+
155
+ ```
156
+ Layer 1: Claude Code Hooks (real-time, deterministic, $0)
157
+ PostToolUse --> extracts knowledge from every Write, Edit, Bash, Read operation
158
+ Stop --> processes transcript for decisions expressed in natural language
159
+ PreCompact --> snapshots graph state before context compaction
160
+ SessionStart --> injects relevant graph context into new sessions
161
+
162
+ Layer 2: CLAUDE.md Behavioral Directives (proactive, $0)
163
+ Claude calls sia_note when it makes architectural decisions
164
+ Claude calls sia_search before starting new tasks
165
+ Captures the "why" -- reasoning, alternatives, context
166
+
167
+ Layer 3: Pluggable LLM Provider (offline + fallback)
168
+ Community summarization (requires full-graph reasoning)
169
+ Deep validation (maintenance sweep)
170
+ Non-Claude-Code agents (Cursor, Windsurf, Cline)
171
+ Built on Vercel AI SDK -- supports Anthropic, OpenAI, Google, Ollama
172
+ ```
173
+
174
+ **Cost in practice:** ~$0.04/day vs ~$0.36/day for a pure-API approach. Hooks observe at the moment of maximum context, capturing richer knowledge at zero LLM cost.
175
+
176
+ **Three capture modes** (configured in `sia.config.yaml`):
177
+ - **`hooks`** (default for Claude Code): Real-time hook capture + LLM for offline operations only
178
+ - **`api`** (fallback for non-Claude-Code agents): All extraction via pluggable LLM provider
179
+ - **`hybrid`**: Hooks for real-time + LLM for batch operations
180
+
181
+ ### Auto-Integration via CLAUDE.md
182
+
183
+ SIA injects behavioral directives into your project's CLAUDE.md that make Claude use the knowledge graph automatically:
184
+
185
+ - **Task classification** -- Claude classifies each task (bug-fix, feature, review, orientation) and loads the corresponding playbook via `/sia-playbooks`
186
+ - **Tool selection** -- `sia_search` before any non-trivial task, `sia_by_file` before modifying files, `sia_note` after decisions, `sia_at_time` for regressions
187
+ - **Trust tier rules** -- Tier 1-2 facts cited as ground truth, Tier 3 qualified before acting, Tier 4 referenced only
188
+
189
+ Knowledge flows into and out of the graph automatically during normal coding sessions.
190
+
191
+ ---
192
+
193
+ ## What Gets Captured
194
+
195
+ Sia uses a unified graph with a `kind` discriminator. Nodes fall into three categories:
196
+
197
+ ### Structural Nodes (Code Backbone)
198
+
199
+ | Kind | What It Represents | Example |
200
+ |------|-------------------|---------|
201
+ | **CodeSymbol** | Functions, classes, modules | `UserService.authenticate()` -- handles JWT validation |
202
+ | **FileNode** | Source files and documentation files | `src/auth/service.ts` |
203
+ | **PackageNode** | Packages in monorepos | `packages/auth` |
204
+
205
+ ### Semantic Nodes (Developer Knowledge)
206
+
207
+ | Kind | What It Captures | Example |
208
+ |------|-----------------|---------|
209
+ | **Concept** | Architectural ideas, patterns | "We use the repository pattern for all DB access" |
210
+ | **Decision** | Choices with rationale and alternatives | "Chose Express over Fastify because of middleware ecosystem" |
211
+ | **Bug** | Defects with symptoms and root cause | "Race condition in EventEmitter.on() -- fires before DB ready" |
212
+ | **Solution** | Fixes linked to the bugs they resolve | "Added await to init() -- ensures DB connection before event binding" |
213
+ | **Convention** | Project-specific rules | "All errors must extend AppBaseError" |
214
+ | **Community** | Auto-discovered module clusters | "Authentication subsystem: UserService, JWTProvider, AuthMiddleware" |
215
+ | **ContentChunk** | Indexed documentation sections, execution output | Heading-scoped chunks from ARCHITECTURE.md |
216
+
217
+ ### Event Nodes (Session Timeline)
218
+
219
+ | Kind | What It Captures | Example |
220
+ |------|-----------------|---------|
221
+ | **SessionNode** | A Claude Code session | Session started at 10:30 AM, 45 events |
222
+ | **EditEvent** | File modifications | Modified `src/auth/jwt.ts` lines 42-58 |
223
+ | **ExecutionEvent** | Command/script runs | `bun run test` -- 3 failures |
224
+ | **ErrorEvent** | Errors encountered | TypeError: Cannot read property 'token' of undefined |
225
+ | **GitEvent** | Git operations | Committed `fix: token refresh` on branch `auth-fix` |
226
+ | **UserDecision** | Developer corrections | "Use Redis instead of Memcached" |
227
+ | **UserPrompt** | Developer messages | Prompt with references to entities |
228
+ | **TaskNode** | Logical task groupings | "Implement JWT refresh token flow" |
229
+
230
+ ---
231
+
232
+ ## MCP Tools (16)
233
+
234
+ Sia exposes 16 tools via the Model Context Protocol, organized into four categories.
235
+
236
+ ### Memory Tools
237
+
238
+ #### `sia_search` -- General Memory Retrieval
239
+
240
+ The primary tool. Called at the start of every non-trivial task.
241
+
242
+ ```
243
+ sia_search({
244
+ query: "session timeout expiry behavior",
245
+ task_type: "bug-fix", // boosts Bug, Solution nodes
246
+ node_types: ["Decision"], // narrow by node kind
247
+ limit: 10, // default 5
248
+ paranoid: true, // exclude all Tier 4 content
249
+ workspace: true, // include cross-repo results
250
+ })
251
+ ```
252
+
253
+ #### `sia_by_file` -- File-Scoped Retrieval
254
+
255
+ Called before modifying any file. Returns everything Sia knows about that file.
256
+
257
+ ```
258
+ sia_by_file({
259
+ file_path: "src/services/UserService.ts",
260
+ workspace: true,
261
+ })
262
+ ```
263
+
264
+ #### `sia_expand` -- Graph Relationship Traversal
265
+
266
+ Follows edges from a known node. Session budget: 2 calls.
267
+
268
+ ```
269
+ sia_expand({
270
+ node_id: "...",
271
+ depth: 2,
272
+ edge_types: ["supersedes", "caused_by", "solves"],
273
+ })
274
+ ```
275
+
276
+ #### `sia_community` -- Architectural Summaries
277
+
278
+ Returns module-level descriptions from Leiden community detection.
279
+
280
+ ```
281
+ sia_community({
282
+ query: "how does the auth module work",
283
+ level: 1, // 0=fine, 1=module, 2=architectural overview
284
+ })
285
+ ```
286
+
287
+ #### `sia_at_time` -- Temporal Query
288
+
289
+ Queries the graph at a historical point. Essential for regression investigation.
290
+
291
+ ```
292
+ sia_at_time({
293
+ as_of: "30 days ago",
294
+ node_types: ["Decision", "Solution"],
295
+ tags: ["caching"],
296
+ })
297
+ ```
298
+
299
+ Returns `nodes[]` (facts valid at that time) and `invalidated_nodes[]` (facts that had ended by then).
300
+
301
+ #### `sia_note` -- Developer-Authored Knowledge
302
+
303
+ Create a Tier 1 knowledge node with explicit tags and edges.
304
+
305
+ ```
306
+ sia_note({
307
+ kind: "Decision",
308
+ name: "Use Redis for session cache",
309
+ content: "Chose Redis over Memcached because...",
310
+ relates_to: ["src/cache/redis.ts"],
311
+ template: "adr",
312
+ })
313
+ ```
314
+
315
+ #### `sia_flag` -- Mid-Session Capture Signal (opt-in)
316
+
317
+ Marks an important moment for higher-priority capture. Disabled by default.
318
+
319
+ ```
320
+ sia_flag({ reason: "chose express-rate-limit at route level, not middleware" })
321
+ ```
322
+
323
+ #### `sia_backlinks` -- Incoming Edge Traversal
324
+
325
+ Returns all nodes that reference a given node, grouped by edge type.
326
+
327
+ ```
328
+ sia_backlinks({
329
+ node_id: "...",
330
+ edge_types: ["pertains_to", "caused_by"],
331
+ })
332
+ ```
333
+
334
+ ### Sandbox Tools
335
+
336
+ #### `sia_execute` -- Isolated Subprocess Execution
337
+
338
+ Run code in an isolated subprocess with stdout capture. Supports 11 runtimes. When output exceeds the context threshold and an intent is provided, Context Mode activates: output is chunked, embedded, indexed, and only relevant chunks returned.
339
+
340
+ ```
341
+ sia_execute({
342
+ language: "python",
343
+ code: "import json; print(json.dumps(analyze_logs()))",
344
+ intent: "find OOM errors",
345
+ })
346
+ ```
347
+
348
+ #### `sia_execute_file` -- File Processing in Sandbox
349
+
350
+ Like `sia_execute` but mounts a file into the sandbox. Raw content never enters the agent's context.
351
+
352
+ ```
353
+ sia_execute_file({
354
+ file_path: "logs/production.log",
355
+ language: "python",
356
+ code: "parse_and_summarize()",
357
+ })
358
+ ```
359
+
360
+ #### `sia_batch_execute` -- Multi-Command Batch
361
+
362
+ Execute multiple commands and searches in one call. Creates event nodes with `precedes` edges.
363
+
364
+ ```
365
+ sia_batch_execute({
366
+ operations: [
367
+ { type: "execute", language: "bash", code: "git log --oneline -20" },
368
+ { type: "search", query: "recent authentication changes" },
369
+ { type: "execute", language: "python", code: "analyze_diff()" },
370
+ ]
371
+ })
372
+ ```
373
+
374
+ ### Graph Management Tools
375
+
376
+ #### `sia_index` -- Content Indexing
377
+
378
+ Chunk markdown by headings, create ContentChunk nodes with embeddings.
379
+
380
+ ```
381
+ sia_index({ content: "# API Documentation\n...", source: "api-docs" })
382
+ ```
383
+
384
+ #### `sia_fetch_and_index` -- URL Fetch and Index
385
+
386
+ Fetch a URL, convert to markdown, chunk and index as Tier 4 ContentChunk nodes.
387
+
388
+ ```
389
+ sia_fetch_and_index({ url: "https://docs.example.com/api" })
390
+ ```
391
+
392
+ #### `sia_ast_query` -- Structural Code Analysis
393
+
394
+ Run tree-sitter queries against source files.
395
+
396
+ ### Diagnostic Tools
397
+
398
+ #### `sia_stats` -- Graph Metrics
399
+
400
+ Returns node counts by kind, edge counts by type, freshness metrics, context savings, native module status.
401
+
402
+ #### `sia_doctor` -- Health Check
403
+
404
+ Checks runtimes, hooks, capture mode, LLM provider health, FTS5, sqlite-vss, ONNX model, native module status, graph integrity, and inverted dependency index coverage.
405
+
406
+ #### `sia_upgrade` -- Self-Update
407
+
408
+ Fetches latest version, rebuilds, runs migrations, and rebuilds VSS if the schema changed.
409
+
410
+ #### `sia_sync_status` -- Sync Status
411
+
412
+ Check team sync configuration and connection status.
413
+
414
+ ### Branch Snapshot Tools
415
+
416
+ #### `sia_snapshot_list` / `sia_snapshot_restore` / `sia_snapshot_prune`
417
+
418
+ List, restore, and prune branch snapshots for worktree-aware graph state management.
419
+
420
+ ---
421
+
422
+ ## Skills (46)
423
+
424
+ Skills are slash commands providing structured workflows. Invoke them in Claude Code with `/sia-<name>`.
425
+
426
+ ### Core
427
+
428
+ | Skill | Description |
429
+ |---|---|
430
+ | `/sia-learn` | Build complete knowledge graph (install + index + docs + communities) |
431
+ | `/sia-setup` | First-time setup wizard (detect project, configure, learn, tour) |
432
+ | `/sia-install` | Initialize SIA databases and register the repo |
433
+ | `/sia-search` | Guided search with examples |
434
+ | `/sia-stats` | Graph statistics |
435
+ | `/sia-status` | Knowledge graph health dashboard |
436
+ | `/sia-doctor` | System health diagnostics |
437
+ | `/sia-reindex` | Re-parse repository with Tree-sitter |
438
+ | `/sia-playbooks` | Load task-specific playbooks (regression, feature, review, orientation) |
439
+
440
+ ### Knowledge Management
441
+
442
+ | Skill | Description |
443
+ |---|---|
444
+ | `/sia-capture` | Guided knowledge capture -- decisions, conventions, bugs, solutions |
445
+ | `/sia-execute` | Run code in sandbox with knowledge capture |
446
+ | `/sia-index` | Index external content (text, URLs) |
447
+ | `/sia-workspace` | Manage cross-repo workspaces |
448
+ | `/sia-export-import` | Export/import graphs as portable JSON |
449
+ | `/sia-export-knowledge` | Export graph as human-readable KNOWLEDGE.md |
450
+ | `/sia-history` | Explore temporal knowledge evolution |
451
+ | `/sia-impact` | Analyze impact of planned code changes |
452
+ | `/sia-compare` | Compare graph state between two time points |
453
+ | `/sia-digest` | Daily knowledge summary |
454
+ | `/sia-freshness` | Graph freshness report |
455
+ | `/sia-conflicts` | List and resolve knowledge conflicts |
456
+ | `/sia-prune` | Remove archived entities |
457
+ | `/sia-upgrade` | Self-update SIA |
458
+
459
+ ### Development Workflow
460
+
461
+ These nine skills augment standard development workflows with graph intelligence:
462
+
463
+ | Skill | Enhancement Over Standard Workflow |
464
+ |---|---|
465
+ | `/sia-debug-workflow` | Temporal root-cause tracing, known bug lookup, causal chain analysis |
466
+ | `/sia-plan` | Community-aware task decomposition, convention injection per task |
467
+ | `/sia-execute-plan` | Staleness detection, per-task convention checks, session resumption |
468
+ | `/sia-brainstorm` | Surfaces past decisions, rejected alternatives, architectural constraints |
469
+ | `/sia-test` | Known edge cases from Bug history, project test conventions |
470
+ | `/sia-finish` | Semantic PR summaries from graph entities, post-merge knowledge capture |
471
+ | `/sia-dispatch` | Community-based independence verification for parallel agents |
472
+ | `/sia-review-respond` | Past decision context, YAGNI checks via usage patterns |
473
+ | `/sia-verify` | Area-specific requirements, past verification failures, known gotchas |
474
+
475
+ ### Visualization & Onboarding
476
+
477
+ | Skill | Description |
478
+ |---|---|
479
+ | `/sia-visualize` | Generate static HTML graph visualization |
480
+ | `/sia-visualize-live` | Launch interactive browser-based graph explorer |
481
+ | `/sia-tour` | Interactive guided tour of the knowledge graph |
482
+
483
+ ### Team Sync
484
+
485
+ | Skill | Description |
486
+ |---|---|
487
+ | `/sia-team` | Join, leave, or check team sync status |
488
+ | `/sia-sync` | Manual push/pull to/from team server |
489
+
490
+ ### Multi-Audience Reporting
491
+
492
+ | Skill | Audience | What It Produces |
493
+ |---|---|---|
494
+ | `/sia-qa-report` | QA | Changes since last test cycle, risky areas, test priorities |
495
+ | `/sia-qa-coverage` | QA | Test coverage gaps, buggy areas without tests |
496
+ | `/sia-qa-flaky` | QA | Flaky test patterns, recurring failures |
497
+ | `/sia-pm-sprint-summary` | PM | Plain-language progress, decisions, features delivered |
498
+ | `/sia-pm-decision-log` | PM | Chronological decisions with rationale and alternatives |
499
+ | `/sia-pm-risk-dashboard` | PM | Recurring bugs, conflicting decisions, fragile modules |
500
+ | `/sia-lead-drift-report` | Tech Lead | Architecture drift vs captured decisions |
501
+ | `/sia-lead-knowledge-map` | Tech Lead | Knowledge distribution, coverage gaps, bus-factor risks |
502
+ | `/sia-lead-compliance` | Tech Lead | Convention compliance audit across the codebase |
503
+
504
+ ---
505
+
506
+ ## Agents (23)
507
+
508
+ Agents are specialized subagents dispatched for focused tasks. Invoke via `@sia-<name>` (e.g., `@sia-code-reviewer`). All agents retrieve from the knowledge graph and can run simultaneously.
509
+
510
+ ### Before Coding
511
+
512
+ | Agent | What It Does |
513
+ |---|---|
514
+ | `sia-orientation` | Answers specific architecture questions from the graph |
515
+ | `sia-onboarding` | Comprehensive multi-topic onboarding session |
516
+ | `sia-decision-reviewer` | Surfaces past decisions and rejected alternatives |
517
+ | `sia-explain` | Explains SIA's graph structure, tools, and capabilities |
518
+
519
+ ### During Coding
520
+
521
+ | Agent | What It Does |
522
+ |---|---|
523
+ | `sia-feature` | Feature development with convention awareness and dependency context |
524
+ | `sia-refactor` | Impact analysis via dependency graph before structural changes |
525
+ | `sia-migration` | Plans knowledge graph updates during major refactoring |
526
+ | `sia-convention-enforcer` | Checks code against all known conventions |
527
+ | `sia-dependency-tracker` | Cross-repo dependency monitoring and API contract tracking |
528
+ | `sia-security-audit` | Security review with paranoid mode and Tier 4 exposure tracking |
529
+ | `sia-test-advisor` | Test strategy from past failures, coverage gaps, and edge cases |
530
+
531
+ ### Debugging
532
+
533
+ | Agent | What It Does |
534
+ |---|---|
535
+ | `sia-debug` | Temporal root-cause investigation using `sia_at_time` and causal history |
536
+ | `sia-regression` | Regression risk analysis from known bugs and failure patterns |
537
+
538
+ ### Code Review
539
+
540
+ | Agent | What It Does |
541
+ |---|---|
542
+ | `sia-code-reviewer` | Reviews with historical context, convention enforcement, regression detection |
543
+ | `sia-conflict-resolver` | Resolves contradicting knowledge entities with evidence |
544
+
545
+ ### After Coding
546
+
547
+ | Agent | What It Does |
548
+ |---|---|
549
+ | `sia-knowledge-capture` | Systematic review and capture of uncaptured session knowledge |
550
+ | `sia-changelog-writer` | Generates changelogs from decisions, bugs fixed, and features added |
551
+
552
+ ### QA, PM & Tech Lead
553
+
554
+ | Agent | What It Does |
555
+ |---|---|
556
+ | `sia-qa-analyst` | Regression risks, coverage gaps, test recommendations |
557
+ | `sia-qa-regression-map` | Scored regression risk map (0-100) per module |
558
+ | `sia-pm-briefing` | Plain-language project briefings for PMs |
559
+ | `sia-pm-risk-advisor` | Technical risk in business-impact language |
560
+ | `sia-lead-architecture-advisor` | Architecture drift detection against captured decisions |
561
+ | `sia-lead-team-health` | Knowledge distribution, coverage gaps, capture rate trends |
562
+
563
+ ---
564
+
565
+ ## Knowledge Graph Features
566
+
567
+ ### Bi-Temporal Model
568
+
569
+ Every fact (nodes and edges) carries four timestamps:
570
+
571
+ - **`t_created`** -- when Sia recorded the fact
572
+ - **`t_expired`** -- when Sia marked it superseded
573
+ - **`t_valid_from`** -- when the fact became true in the world
574
+ - **`t_valid_until`** -- when it stopped being true (null = still true)
575
+
576
+ Facts are never deleted -- only invalidated. This enables temporal queries like "what was the authentication strategy in January?" via `sia_at_time`.
577
+
578
+ ### Branch-Aware Snapshots
579
+
580
+ When you switch branches, the PostToolUse hook saves a snapshot of the current graph state tagged with the departing branch, then restores the arriving branch's snapshot. Each git worktree gets its own graph database instance. The `/sia-finish` skill handles snapshot pruning after merge.
581
+
582
+ ### Community Detection
583
+
584
+ Leiden clustering at three resolution levels groups related code into communities. Communities are summarized (LLM-based when available, plain-text fallback) and queryable via `sia_community`.
585
+
586
+ ### Ontology Enforcement
587
+
588
+ Every edge is validated against a declarative `edge_constraints` table. Invalid relationships are rejected at the SQLite trigger level. Additional constraints: Bug nodes must have `caused_by` edges, Convention nodes must have `pertains_to` edges, `supersedes` edges can only connect same-kind nodes.
589
+
590
+ ### Five-Layer Freshness Engine
591
+
592
+ ```
593
+ Layer 1 -- File-Watcher Invalidation [milliseconds] [>90% of cases]
594
+ File save --> Tree-sitter incremental re-parse --> surgical node invalidation
595
+ Layer 2 -- Git-Commit Reconciliation [seconds] [merges, rebases, checkouts]
596
+ Git operation --> diff parse --> bounded BFS with firewall nodes
597
+ Layer 3 -- Stale-While-Revalidate Reads [per-query] [~0.1ms overhead]
598
+ Fresh --> serve instantly | Stale --> serve + async re-validate | Rotten --> block + repair
599
+ Layer 4 -- Confidence Decay [hours to days] [LLM-inferred facts only]
600
+ Exponential decay x trust tier, with Bayesian re-observation reinforcement
601
+ Layer 5 -- Periodic Deep Validation [daily/weekly] [batch cleanup]
602
+ Doc-vs-code cross-check --> LLM re-verify --> PageRank recompute --> compaction
603
+ ```
604
+
605
+ Each search result carries a `freshness` field (`fresh`, `stale`, or `rotten`) so the agent knows whether to cite with confidence or verify first.
606
+
607
+ ---
608
+
609
+ ## Performance
610
+
611
+ ### Worker-Threaded Indexer
612
+
613
+ - **Worker thread pool** -- configurable (default: CPU count - 1), each worker parses independently via Tree-sitter
614
+ - **Batch SQL** -- 100 insertions per transaction
615
+ - **Periodic cache saves** -- every 500 files; crashes lose at most one interval's work
616
+ - **Per-file retry** -- individual parse failures logged without stopping the overall index
617
+ - **Incremental mode** -- skips files with unchanged mtime
618
+
619
+ ### Expected Performance
620
+
621
+ | Operation | Target |
622
+ |-----------|--------|
623
+ | Hybrid search (50K nodes) | <800ms |
624
+ | Incremental AST re-parse | <200ms per file |
625
+ | Full capture pipeline | <8s after hook fires |
626
+ | Workspace search (2 x 25K nodes) | <1.2s |
627
+ | Community detection (10K nodes) | <30s |
628
+ | File-save invalidation (end-to-end) | <200ms |
629
+ | Sandbox execution (simple script) | <5s |
630
+ | Graph visualization (100 nodes) | <3s render |
631
+
632
+ ### Crash Recovery
633
+
634
+ If `/sia-learn` crashes mid-run (OOM, Ctrl+C, power loss), re-running automatically resumes from the last checkpoint. A `.sia-learn-progress.json` file tracks progress per phase and is deleted on successful completion.
635
+
636
+ ---
637
+
638
+ ## Multi-Audience Intelligence
639
+
640
+ SIA generates role-specific reports from the same knowledge graph.
641
+
642
+ **QA teams** get regression risk maps with numeric scores (0-100) per module combining bug density, change velocity, and dependency fan-out. Coverage gap analysis surfaces buggy areas without tests. Flaky test tracking identifies intermittent failures.
643
+
644
+ **Project managers** get plain-language sprint summaries (decisions made, bugs fixed, features delivered), chronological decision logs with rationale and alternatives, and risk dashboards scoring technical risk in business-impact language.
645
+
646
+ **Tech leads** get architecture drift reports comparing current code against captured decisions, knowledge distribution maps showing bus-factor risks, and convention compliance audits checking every known convention against current code.
647
+
648
+ ---
649
+
650
+ ## Visualization
651
+
652
+ Browser-based interactive graph explorer with four views:
653
+
654
+ | View | What It Shows |
655
+ |---|---|
656
+ | **Graph Explorer** | Force-directed graph -- click to expand, filter by type/tier, zoom and pan |
657
+ | **Timeline** | Temporal history -- when decisions were made, bugs found, entities invalidated |
658
+ | **Dependency Map** | File dependency map -- imports, calls, depends_on edges |
659
+ | **Community Clusters** | Leiden-detected module groups with summaries and inter-cluster edges |
660
+
661
+ ```bash
662
+ /sia-visualize-live # Graph explorer (default)
663
+ /sia-visualize-live --view timeline # Temporal timeline
664
+ /sia-visualize-live --view deps # Dependency map
665
+ /sia-visualize-live --view communities # Community clusters
666
+ ```
667
+
668
+ ---
669
+
670
+ ## Team Sync
671
+
672
+ SIA supports team knowledge sharing via a self-hosted sqld (libSQL) server. Data sovereignty is guaranteed -- knowledge stays on infrastructure your team controls.
673
+
674
+ ### Setup
675
+
676
+ 1. DevOps deploys a sqld server (Docker, direct binary, or Kubernetes)
677
+ 2. DevOps provides a server URL and auth token
678
+ 3. Developer runs `/sia-team` and follows the setup instructions
679
+
680
+ ### Automatic Sync
681
+
682
+ | Event | Action |
683
+ |---|---|
684
+ | Session start | Auto-pulls latest team knowledge |
685
+ | Session end | Auto-pushes locally captured knowledge |
686
+ | `/sia-sync` | Manual push/pull on demand |
687
+
688
+ ### Visibility Model
689
+
690
+ | Level | Behavior |
691
+ |-------|----------|
692
+ | **private** (default) | Never leaves your machine. Never synced. |
693
+ | **team** | Synced to all workspace members. |
694
+ | **project** | Synced to members of a specific workspace only. |
695
+
696
+ ### Sync Internals
697
+
698
+ - `@libsql/client` embedded replicas against a self-hosted `sqld` server
699
+ - Hybrid Logical Clocks (HLC) for causal ordering
700
+ - Three-layer dedup: Jaccard, cosine similarity, LLM
701
+ - Auth tokens stored in OS keychain, never in config files
702
+ - Contradictions flagged with `conflict_group_id` for team review
703
+
704
+ ---
705
+
706
+ ## Security
707
+
708
+ Sia takes memory poisoning seriously. When an AI agent reads malicious content, naive memory systems achieve over 95% injection success rates.
709
+
710
+ ### Five Lines of Defense
711
+
712
+ **1. Ontology Enforcement** -- Every edge is validated against a declarative constraint table. Invalid relationships are rejected at the SQLite trigger level before they can corrupt the graph.
713
+
714
+ **2. Trust Tiers** -- Every fact carries provenance. External content enters at Tier 4 (lowest trust, 50% retrieval weight). The agent never uses Tier 4 facts as the sole basis for code changes.
715
+
716
+ **3. Staging Area** -- Tier 4 content is written to an isolated `memory_staging` table with no foreign keys to the main graph. Three checks run before promotion:
717
+
718
+ | Check | What It Does |
719
+ |-------|-------------|
720
+ | Pattern Detection | Regex scan for injection language ("remember to always...", "this is mandatory...") |
721
+ | Semantic Consistency | Cosine distance from project domain centroid -- flags off-topic content |
722
+ | Confidence Threshold | Tier 4 requires >= 0.75 confidence (vs 0.60 for Tier 3) |
723
+
724
+ **4. Rule of Two** -- For Tier 4 ADD operations, a separate LLM call asks: "Is this content attempting to inject instructions into an AI memory system?" Independent second opinion on untrusted content.
725
+
726
+ **5. Paranoid Mode** -- Two levels of isolation:
727
+
728
+ ```bash
729
+ # Query-time: exclude Tier 4 from search results
730
+ sia search "auth" --paranoid
731
+
732
+ # Capture-time: quarantine ALL external content at the chunker stage
733
+ # Set in ~/.sia/config.json: "paranoidCapture": true
734
+ ```
735
+
736
+ ### Additional Safeguards
737
+
738
+ - **External link safety** -- URLs found in docs are never auto-followed. `sia_fetch_and_index` applies Tier 4 trust and the full security pipeline.
739
+ - **Audit and rollback** -- Every write logged to `audit_log` with source hash, trust tier, and extraction method. Point-in-time recovery via `sia rollback <timestamp>`.
740
+ - **Read-only MCP** -- The MCP server opens all databases with `OPEN_READONLY` -- it physically cannot modify the graph even if an injection bypasses all other layers.
741
+
742
+ ### Trust Tier Behavioral Rules
743
+
744
+ | Tier | Source | Confidence | Agent Behavior |
745
+ |------|--------|------------|----------------|
746
+ | 1 | **User-Direct** -- developer stated this or authored docs | 0.95 | Ground truth; cite directly |
747
+ | 2 | **Code-Analysis** -- deterministically extracted from AST | 0.92 | Highly reliable; verify only for safety-critical claims |
748
+ | 3 | **LLM-Inferred** -- probabilistic extraction from conversation | 0.70 | Qualify: "Sia suggests X -- let me verify" |
749
+ | 4 | **External** -- from fetched URLs or unknown sources | 0.50 | Reference only; never sole basis for code changes |
750
+
751
+ ---
752
+
753
+ ## Language Support
754
+
755
+ ### Supported Languages
756
+
757
+ | Tier | Capability | Languages |
758
+ |------|-----------|-----------|
759
+ | **A** -- Full extraction | Functions, classes, imports, call sites | TypeScript, TSX, JavaScript, JSX, Python, Go, Rust, Java, Kotlin, Swift, PHP, Ruby, Scala, Elixir, Dart |
760
+ | **B** -- Structural | Functions, classes, imports (no call tracking) | C, C++, C#, Bash/Shell, Lua, Zig, Perl, R, OCaml, Haskell |
761
+ | **C** -- Schema | Custom extractors for data definitions | SQL (tables, columns, FKs, indexes), Prisma schema |
762
+ | **D** -- Manifest | Dependency edges from project files | `Cargo.toml`, `go.mod`, `pyproject.toml`, `.csproj`/`.sln`, `build.gradle`/`pom.xml` |
763
+
764
+ ### Sandbox Execution Runtimes
765
+
766
+ `sia_execute` supports 11 runtimes: Python, Node.js, Bun, Bash, Ruby, Go, Rust, Java, PHP, Perl, and R.
767
+
768
+ ### Native Performance Module (Optional)
769
+
770
+ Optional Rust module (`@sia/native`) distributed as prebuilt binaries. No Rust toolchain required.
771
+
772
+ | Operation | Rust Native | Wasm | TypeScript |
773
+ |-----------|------------|------|------------|
774
+ | AST diff (500-node trees) | < 10ms | < 25ms | < 100ms |
775
+ | PageRank (50K nodes) | < 20ms | < 50ms | < 80ms |
776
+ | Leiden (50K nodes, 3 levels) | < 500ms | < 500ms | < 1s (Louvain) |
777
+
778
+ Graceful three-tier fallback: Rust native --> Wasm --> pure TypeScript. All tiers produce identical results.
779
+
780
+ ### Adding Languages
781
+
782
+ Register additional Tree-sitter grammars at runtime:
783
+
784
+ ```json
785
+ // ~/.sia/config.json
786
+ {
787
+ "additionalLanguages": [
788
+ { "name": "gleam", "extensions": [".gleam"], "grammar": "tree-sitter-gleam", "tier": "B" }
789
+ ]
790
+ }
791
+ ```
792
+
793
+ ---
794
+
795
+ ## CLI Reference
796
+
797
+ ### Core Commands
798
+
799
+ ```bash
800
+ sia install # Install and index the repository
801
+ sia stats # Graph statistics
802
+ sia search <query> # Search the knowledge graph
803
+ sia search --paranoid <query> # Exclude all Tier 4 content
804
+ sia reindex # Re-parse AST backbone and re-discover docs
805
+ sia doctor # Health check (runtimes, hooks, model, graph integrity)
806
+ sia doctor --providers # LLM provider connectivity and cost estimate
807
+ sia upgrade # Self-update with migration
808
+ sia freshness # Graph freshness report
809
+ sia prune # Clean up decayed entities
810
+ sia rollback <timestamp> # Restore graph to a previous state
811
+ ```
812
+
813
+ ### Knowledge Commands
814
+
815
+ ```bash
816
+ sia learn # Build complete knowledge graph
817
+ sia learn --incremental # Update changed files only
818
+ sia learn --force # Full rebuild ignoring caches
819
+ sia community # View community summaries
820
+ sia digest --period 7d # Weekly knowledge digest
821
+ sia download-model # Download/update the ONNX embedding model
822
+ sia enable-flagging # Enable sia_flag mid-session capture
823
+ sia disable-flagging
824
+ ```
825
+
826
+ ### Visualization
827
+
828
+ ```bash
829
+ sia graph --open # Interactive graph in browser
830
+ sia graph --scope src/auth/ # Visualize a subgraph
831
+ ```
832
+
833
+ ### Export/Import
834
+
835
+ ```bash
836
+ sia export # Export graph for backup or migration
837
+ sia export --format markdown # Obsidian-compatible markdown vault
838
+ sia import # Import a previously exported graph
839
+ sia import --format markdown <dir>
840
+ sia export-knowledge # Generate KNOWLEDGE.md
841
+ ```
842
+
843
+ ### Workspace Commands
844
+
845
+ ```bash
846
+ sia workspace create "My App" --repos ./frontend ./backend
847
+ sia workspace list
848
+ sia workspace show "My App"
849
+ sia workspace add "My App" ./shared-lib
850
+ sia workspace remove "My App" ./old-service
851
+ ```
852
+
853
+ ### Team Commands
854
+
855
+ ```bash
856
+ sia team join <url> <token> # Join a team
857
+ sia team leave
858
+ sia team status
859
+ sia sync push # Push knowledge to team
860
+ sia sync pull # Pull from team
861
+ sia share <node-id> # Promote node to team visibility
862
+ sia conflicts list # View unresolved contradictions
863
+ sia conflicts resolve # Resolve a contradiction
864
+ ```
865
+
866
+ ### Multi-Audience Reports
867
+
868
+ ```bash
869
+ sia qa-report # QA-focused report
870
+ sia pm-report # PM sprint summary / decision log / risk dashboard
871
+ sia lead-report # Architecture drift / knowledge map / compliance
872
+ ```
873
+
874
+ ### Standalone Alternative
875
+
876
+ All `sia` commands can also be run as `npx sia <command>` when not using plugin mode.
877
+
878
+ ---
879
+
880
+ ## Configuration
881
+
882
+ All configuration lives in `~/.sia/config.json` (created by `sia install`).
883
+
884
+ ### Key Settings
885
+
886
+ | Setting | Default | Description |
887
+ |---------|---------|-------------|
888
+ | `captureModel` | `claude-haiku-4-5-20251001` | LLM for extraction, consolidation, security checks |
889
+ | `minExtractConfidence` | `0.6` | Minimum confidence for LLM-extracted candidates |
890
+ | `paranoidCapture` | `false` | Quarantine all Tier 4 content at chunker stage |
891
+ | `enableFlagging` | `false` | Enable `sia_flag` for mid-session capture |
892
+ | `airGapped` | `false` | Disable all outbound network calls (LLM) |
893
+ | `maxResponseTokens` | `1500` | Max tokens per MCP tool response |
894
+ | `workingMemoryTokenBudget` | `8000` | Token budget before working memory compaction |
895
+ | `communityTriggerNodeCount` | `20` | New nodes before community re-detection |
896
+ | `communityMinGraphSize` | `100` | Minimum graph size for Leiden |
897
+ | `archiveThreshold` | `0.05` | Importance below which decayed nodes are archived |
898
+ | `sandboxTimeout` | `30000` | Subprocess execution timeout (ms) |
899
+ | `contextModeThreshold` | `5000` | Output bytes before Context Mode activates |
900
+
901
+ ### LLM Provider Configuration
902
+
903
+ Capture mode and LLM providers are configured in `sia.config.yaml`:
904
+
905
+ ```yaml
906
+ capture:
907
+ mode: hooks # hooks | api | hybrid
908
+
909
+ providers:
910
+ summarize:
911
+ provider: anthropic
912
+ model: claude-sonnet-4
913
+ validate:
914
+ provider: ollama
915
+ model: qwen2.5-coder:7b
916
+ extract: # active in api/hybrid only
917
+ provider: anthropic
918
+ model: claude-haiku-4-5
919
+ consolidate: # active in api/hybrid only
920
+ provider: anthropic
921
+ model: claude-haiku-4-5
922
+
923
+ fallback:
924
+ chain: [anthropic, openai, ollama]
925
+ maxRetries: 3
926
+
927
+ costTracking:
928
+ budgetPerDay: 1.00
929
+ ```
930
+
931
+ ### Air-Gapped Mode
932
+
933
+ Set `"airGapped": true` for zero outbound network calls. This disables LLM extraction, consolidation, community summaries, and the Rule of Two security check. ONNX embeddings, vector search, BM25, graph traversal, hooks, sandbox execution, and doc ingestion remain fully functional.
934
+
935
+ ---
936
+
937
+ ## Multi-Repo Workspaces
938
+
939
+ ### Single Repository (default)
940
+
941
+ Each repo gets an isolated SQLite database at `~/.sia/repos/<hash>/graph.db`.
942
+
943
+ ### Workspace (linked repos)
944
+
945
+ ```bash
946
+ sia workspace create "Acme Fullstack" --repos ./frontend ./backend
947
+ ```
948
+
949
+ Cross-repo relationships are auto-detected from: OpenAPI/Swagger specs, GraphQL schemas, TypeScript project references, `.csproj` references, `Cargo.toml` workspace members, `go.mod` replace directives, `pyproject.toml` path dependencies, and `workspace:*` npm dependencies.
950
+
951
+ ### Monorepo
952
+
953
+ Auto-detected from `pnpm-workspace.yaml`, `package.json` workspaces, `nx.json`, or Gradle multi-project builds. All packages share one `graph.db` scoped by `package_path`.
954
+
955
+ ---
956
+
957
+ ## Onboarding & Export
958
+
959
+ **`/sia-setup`** -- First-time wizard: detects project type and languages, creates databases, runs `/sia-learn`, launches `/sia-tour`.
960
+
961
+ **`/sia-tour`** -- Interactive guided tour covering architecture, decisions, conventions, and known issues.
962
+
963
+ **`/sia-export-knowledge`** -- Exports the graph as a human-readable `KNOWLEDGE.md` for team onboarding, sharing outside SIA, or generating project documentation.
964
+
965
+ ---
966
+
967
+ ## v2 Roadmap
968
+
969
+ - Natural language graph queries ("what changed in auth last week?")
970
+ - PR review integration with graph-backed suggestions
971
+ - External source ingestion (Slack, Notion, Jira, Confluence)
972
+ - PM tool sync (bidirectional Jira/Linear integration)
973
+ - Graph analytics dashboard (trend lines, health scores)
974
+ - Embedding model upgrade (domain-tuned code embeddings)
975
+ - Lifecycle notifications (Slack/Teams alerts for drift, risk, compliance)
976
+
977
+ ---
978
+
979
+ ## Compatibility
980
+
981
+ - **OS**: macOS, Linux, Windows (WSL2)
982
+ - **Runtime**: Node.js 18+, Bun 1.0+
983
+ - **Transport**: Standard MCP stdio
984
+ - **AI Agent**: Claude Code (native hooks), Cursor (hook adapter), Cline (hook adapter), Windsurf/Aider (MCP-only), any MCP-compatible agent
985
+ - **LLM Providers**: Anthropic, OpenAI, Google, Ollama via Vercel AI SDK
986
+ - **Native module**: Prebuilt for macOS (ARM/Intel), Linux (x64/ARM64, glibc/musl), Windows (x64)
987
+
988
+ ---
989
+
990
+ ## Storage
991
+
992
+ ```
993
+ ~/.sia/
994
+ meta.db # workspace/repo registry, sharing rules
995
+ bridge.db # cross-repo edges
996
+ config.json # user configuration
997
+ repos/<sha256-of-repo-path>/
998
+ graph.db # unified graph (nodes, edges, communities, ontology)
999
+ episodic.db # append-only interaction archive
1000
+ models/
1001
+ all-MiniLM-L6-v2.onnx # local embedding model (~90MB)
1002
+ ast-cache/<hash>/ # Tree-sitter parse cache
1003
+ snapshots/<hash>/YYYY-MM-DD.snapshot # daily graph snapshots
1004
+ logs/sia.log # structured JSON log
1005
+ ```
1006
+
1007
+ ---
1008
+
1009
+ ## License
1010
+
1011
+ Apache License 2.0 — see [LICENSE](LICENSE) and [NOTICE](NOTICE) for details.
1012
+
1013
+ Attribution is required for all distributions, including commercial use.