@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.
- package/.claude-plugin/marketplace.json +35 -0
- package/.claude-plugin/plugin.json +27 -0
- package/.mcp.json +13 -0
- package/CLAUDE.md +226 -0
- package/LICENSE +202 -0
- package/PLUGIN_README.md +253 -0
- package/README.md +1013 -0
- package/agents/sia-changelog-writer.md +89 -0
- package/agents/sia-code-reviewer.md +86 -0
- package/agents/sia-conflict-resolver.md +100 -0
- package/agents/sia-convention-enforcer.md +69 -0
- package/agents/sia-debug.md +106 -0
- package/agents/sia-decision-reviewer.md +101 -0
- package/agents/sia-dependency-tracker.md +80 -0
- package/agents/sia-explain.md +126 -0
- package/agents/sia-feature.md +116 -0
- package/agents/sia-knowledge-capture.md +117 -0
- package/agents/sia-lead-architecture-advisor.md +93 -0
- package/agents/sia-lead-team-health.md +107 -0
- package/agents/sia-migration.md +100 -0
- package/agents/sia-onboarding.md +115 -0
- package/agents/sia-orientation.md +99 -0
- package/agents/sia-pm-briefing.md +106 -0
- package/agents/sia-pm-risk-advisor.md +82 -0
- package/agents/sia-qa-analyst.md +116 -0
- package/agents/sia-qa-regression-map.md +94 -0
- package/agents/sia-refactor.md +115 -0
- package/agents/sia-regression.md +112 -0
- package/agents/sia-security-audit.md +125 -0
- package/agents/sia-test-advisor.md +91 -0
- package/hooks/hooks.json +98 -0
- package/migrations/bridge/001_initial.sql +34 -0
- package/migrations/episodic/001_initial.sql +35 -0
- package/migrations/meta/001_initial.sql +68 -0
- package/migrations/semantic/001_initial.sql +292 -0
- package/migrations/semantic/002_ontology.sql +89 -0
- package/migrations/semantic/003_freshness.sql +63 -0
- package/migrations/semantic/004_v5_unified_schema.sql +194 -0
- package/migrations/semantic/005_backfill_event_kinds.sql +8 -0
- package/migrations/semantic/006_tree_sitter.sql +6 -0
- package/migrations/semantic/007_branch_snapshots.sql +22 -0
- package/package.json +110 -0
- package/scripts/branch-switch.sh +13 -0
- package/scripts/build-wasm-grammars.sh +81 -0
- package/scripts/post-compact.sh +8 -0
- package/scripts/post-tool-use.sh +10 -0
- package/scripts/pre-compact.sh +8 -0
- package/scripts/session-end.sh +8 -0
- package/scripts/session-start.sh +8 -0
- package/scripts/start-mcp.ts +45 -0
- package/scripts/stop-hook.sh +8 -0
- package/scripts/user-prompt-submit.sh +8 -0
- package/scripts/viz-server.ts +152 -0
- package/skills/sia-brainstorm/SKILL.md +156 -0
- package/skills/sia-brainstorm/scripts/frame-template.html +214 -0
- package/skills/sia-brainstorm/scripts/helper.js +95 -0
- package/skills/sia-brainstorm/scripts/server.cjs +338 -0
- package/skills/sia-brainstorm/scripts/start-server.sh +153 -0
- package/skills/sia-brainstorm/scripts/stop-server.sh +55 -0
- package/skills/sia-brainstorm/spec-document-reviewer-prompt.md +49 -0
- package/skills/sia-brainstorm/visual-companion.md +286 -0
- package/skills/sia-capture/SKILL.md +64 -0
- package/skills/sia-compare/SKILL.md +33 -0
- package/skills/sia-conflicts/SKILL.md +38 -0
- package/skills/sia-debug-workflow/SKILL.md +120 -0
- package/skills/sia-debug-workflow/root-cause-tracing.md +70 -0
- package/skills/sia-debug-workflow/scripts/find-polluter.sh +64 -0
- package/skills/sia-debug-workflow/temporal-investigation.md +72 -0
- package/skills/sia-digest/SKILL.md +23 -0
- package/skills/sia-dispatch/SKILL.md +69 -0
- package/skills/sia-dispatch/agent-task-template.md +99 -0
- package/skills/sia-doctor/SKILL.md +39 -0
- package/skills/sia-execute/SKILL.md +70 -0
- package/skills/sia-execute-plan/SKILL.md +85 -0
- package/skills/sia-export-import/SKILL.md +49 -0
- package/skills/sia-export-knowledge/SKILL.md +46 -0
- package/skills/sia-finish/SKILL.md +100 -0
- package/skills/sia-finish/pr-summary-template.md +54 -0
- package/skills/sia-freshness/SKILL.md +38 -0
- package/skills/sia-history/SKILL.md +42 -0
- package/skills/sia-impact/SKILL.md +70 -0
- package/skills/sia-index/SKILL.md +54 -0
- package/skills/sia-install/SKILL.md +39 -0
- package/skills/sia-lead-compliance/SKILL.md +16 -0
- package/skills/sia-lead-drift-report/SKILL.md +16 -0
- package/skills/sia-lead-knowledge-map/SKILL.md +16 -0
- package/skills/sia-learn/SKILL.md +58 -0
- package/skills/sia-plan/SKILL.md +68 -0
- package/skills/sia-plan/plan-reviewer-prompt.md +63 -0
- package/skills/sia-playbooks/SKILL.md +29 -0
- package/skills/sia-playbooks/reference-feature.md +100 -0
- package/skills/sia-playbooks/reference-flagging.md +50 -0
- package/skills/sia-playbooks/reference-orientation.md +92 -0
- package/skills/sia-playbooks/reference-regression.md +115 -0
- package/skills/sia-playbooks/reference-review.md +64 -0
- package/skills/sia-playbooks/reference-tools.md +239 -0
- package/skills/sia-pm-decision-log/SKILL.md +28 -0
- package/skills/sia-pm-risk-dashboard/SKILL.md +24 -0
- package/skills/sia-pm-sprint-summary/SKILL.md +27 -0
- package/skills/sia-prune/SKILL.md +45 -0
- package/skills/sia-qa-coverage/SKILL.md +28 -0
- package/skills/sia-qa-flaky/SKILL.md +20 -0
- package/skills/sia-qa-report/SKILL.md +26 -0
- package/skills/sia-reindex/SKILL.md +30 -0
- package/skills/sia-review-respond/SKILL.md +88 -0
- package/skills/sia-review-respond/pushback-patterns.md +90 -0
- package/skills/sia-search/SKILL.md +47 -0
- package/skills/sia-setup/SKILL.md +82 -0
- package/skills/sia-setup/setup-checklist.md +97 -0
- package/skills/sia-stats/SKILL.md +36 -0
- package/skills/sia-status/SKILL.md +44 -0
- package/skills/sia-sync/SKILL.md +46 -0
- package/skills/sia-team/SKILL.md +64 -0
- package/skills/sia-test/SKILL.md +92 -0
- package/skills/sia-test/testing-anti-patterns.md +104 -0
- package/skills/sia-tour/SKILL.md +29 -0
- package/skills/sia-upgrade/SKILL.md +43 -0
- package/skills/sia-verify/SKILL.md +81 -0
- package/skills/sia-visualize/SKILL.md +28 -0
- package/skills/sia-visualize-live/SKILL.md +55 -0
- package/skills/sia-visualize-live/scripts/graph-template.html +389 -0
- package/skills/sia-visualize-live/scripts/start-visualizer.sh +161 -0
- package/skills/sia-visualize-live/scripts/stop-visualizer.sh +55 -0
- package/skills/sia-visualize-live/scripts/visualizer-server.cjs +264 -0
- package/skills/sia-workspace/SKILL.md +57 -0
- package/src/agent/claude-md-template-flagging.md +219 -0
- package/src/agent/claude-md-template.md +213 -0
- package/src/agent/modules/sia-feature.md +100 -0
- package/src/agent/modules/sia-flagging.md +50 -0
- package/src/agent/modules/sia-orientation.md +92 -0
- package/src/agent/modules/sia-regression.md +115 -0
- package/src/agent/modules/sia-review.md +64 -0
- package/src/agent/modules/sia-tools.md +239 -0
- package/src/ast/extractors/c-include.ts +189 -0
- package/src/ast/extractors/csharp-project.ts +260 -0
- package/src/ast/extractors/prisma-schema.ts +44 -0
- package/src/ast/extractors/project-manifest.ts +111 -0
- package/src/ast/extractors/sql-schema.ts +67 -0
- package/src/ast/extractors/tier-a.ts +423 -0
- package/src/ast/extractors/tier-b.ts +289 -0
- package/src/ast/extractors/tier-dispatch.ts +247 -0
- package/src/ast/index-worker.ts +108 -0
- package/src/ast/indexer.ts +484 -0
- package/src/ast/languages.ts +408 -0
- package/src/ast/pagerank-builder.ts +125 -0
- package/src/ast/path-utils.ts +137 -0
- package/src/ast/tree-sitter/backends/native.ts +57 -0
- package/src/ast/tree-sitter/backends/wasm.ts +39 -0
- package/src/ast/tree-sitter/call-walker.ts +44 -0
- package/src/ast/tree-sitter/edit-computer.ts +55 -0
- package/src/ast/tree-sitter/query-runner.ts +46 -0
- package/src/ast/tree-sitter/service.ts +174 -0
- package/src/ast/tree-sitter/tree-cache.ts +39 -0
- package/src/ast/tree-sitter/types.ts +79 -0
- package/src/ast/watcher.ts +322 -0
- package/src/capture/chunker.ts +169 -0
- package/src/capture/consolidate.ts +127 -0
- package/src/capture/edge-inferrer.ts +161 -0
- package/src/capture/embedder.ts +166 -0
- package/src/capture/embedding-cache.ts +73 -0
- package/src/capture/flag-processor.ts +64 -0
- package/src/capture/hook.ts +67 -0
- package/src/capture/pipeline.ts +450 -0
- package/src/capture/prompts/consolidate.ts +25 -0
- package/src/capture/prompts/edge-infer.ts +29 -0
- package/src/capture/prompts/extract-flagged.ts +36 -0
- package/src/capture/prompts/extract.ts +42 -0
- package/src/capture/tokenizer.ts +147 -0
- package/src/capture/track-a-ast.ts +93 -0
- package/src/capture/track-b-llm.ts +149 -0
- package/src/capture/types.ts +64 -0
- package/src/cli/commands/community.ts +137 -0
- package/src/cli/commands/compare.ts +123 -0
- package/src/cli/commands/conflicts.ts +41 -0
- package/src/cli/commands/digest.ts +197 -0
- package/src/cli/commands/disable-flagging.ts +34 -0
- package/src/cli/commands/doctor.ts +240 -0
- package/src/cli/commands/download-model.ts +161 -0
- package/src/cli/commands/enable-flagging.ts +34 -0
- package/src/cli/commands/export-knowledge.ts +208 -0
- package/src/cli/commands/export.ts +85 -0
- package/src/cli/commands/freshness.ts +164 -0
- package/src/cli/commands/graph.ts +51 -0
- package/src/cli/commands/history.ts +139 -0
- package/src/cli/commands/import.ts +335 -0
- package/src/cli/commands/install.ts +156 -0
- package/src/cli/commands/lead-report.ts +241 -0
- package/src/cli/commands/learn.ts +321 -0
- package/src/cli/commands/pm-report.ts +413 -0
- package/src/cli/commands/prune.ts +75 -0
- package/src/cli/commands/qa-report.ts +278 -0
- package/src/cli/commands/reindex.ts +104 -0
- package/src/cli/commands/rollback.ts +70 -0
- package/src/cli/commands/search.ts +103 -0
- package/src/cli/commands/server.ts +91 -0
- package/src/cli/commands/share.ts +33 -0
- package/src/cli/commands/stats.ts +79 -0
- package/src/cli/commands/status.ts +176 -0
- package/src/cli/commands/sync.ts +96 -0
- package/src/cli/commands/team.ts +118 -0
- package/src/cli/commands/tour.ts +157 -0
- package/src/cli/commands/visualize-live.ts +162 -0
- package/src/cli/commands/workspace.ts +117 -0
- package/src/cli/index.ts +424 -0
- package/src/cli/learn-progress.ts +87 -0
- package/src/community/detection-bridge.ts +344 -0
- package/src/community/leiden.ts +462 -0
- package/src/community/raptor.ts +210 -0
- package/src/community/scheduler.ts +74 -0
- package/src/community/summarize.ts +115 -0
- package/src/decay/archiver.ts +73 -0
- package/src/decay/bridge-orphan-cleanup.ts +212 -0
- package/src/decay/consolidation-sweep.ts +112 -0
- package/src/decay/decay.ts +116 -0
- package/src/decay/deep-validator.ts +62 -0
- package/src/decay/episodic-promoter.ts +132 -0
- package/src/decay/maintenance-scheduler.ts +326 -0
- package/src/decay/scheduler.ts +6 -0
- package/src/decay/session-sweeper.ts +79 -0
- package/src/decay/types.ts +17 -0
- package/src/freshness/confidence-decay.ts +122 -0
- package/src/freshness/cuckoo-filter.ts +176 -0
- package/src/freshness/deep-validation.ts +345 -0
- package/src/freshness/dirty-tracker.ts +237 -0
- package/src/freshness/file-watcher-layer.ts +119 -0
- package/src/freshness/firewall.ts +64 -0
- package/src/freshness/git-reconcile-layer.ts +161 -0
- package/src/freshness/inverted-index.ts +158 -0
- package/src/freshness/stale-read-layer.ts +222 -0
- package/src/graph/audit.ts +69 -0
- package/src/graph/bridge-db.ts +141 -0
- package/src/graph/communities.ts +195 -0
- package/src/graph/db-interface.ts +259 -0
- package/src/graph/edges.ts +163 -0
- package/src/graph/entities.ts +327 -0
- package/src/graph/episodic-db.ts +113 -0
- package/src/graph/flags.ts +31 -0
- package/src/graph/meta-db.ts +200 -0
- package/src/graph/semantic-db.ts +101 -0
- package/src/graph/session-resume.ts +56 -0
- package/src/graph/snapshots.ts +342 -0
- package/src/graph/staging.ts +151 -0
- package/src/graph/types.ts +128 -0
- package/src/hooks/adapters/claude-code.ts +21 -0
- package/src/hooks/adapters/cline.ts +43 -0
- package/src/hooks/adapters/cursor.ts +65 -0
- package/src/hooks/adapters/generic.ts +12 -0
- package/src/hooks/agent-detect.ts +34 -0
- package/src/hooks/claude-md-directives.ts +32 -0
- package/src/hooks/event-router.ts +182 -0
- package/src/hooks/extractors/pattern-detector.ts +111 -0
- package/src/hooks/handlers/post-compact.ts +30 -0
- package/src/hooks/handlers/post-tool-use.ts +403 -0
- package/src/hooks/handlers/pre-compact.ts +100 -0
- package/src/hooks/handlers/session-end.ts +47 -0
- package/src/hooks/handlers/session-start.ts +154 -0
- package/src/hooks/handlers/stop.ts +128 -0
- package/src/hooks/handlers/user-prompt-submit.ts +68 -0
- package/src/hooks/plugin-branch-switch.ts +68 -0
- package/src/hooks/plugin-common.ts +47 -0
- package/src/hooks/plugin-post-compact.ts +28 -0
- package/src/hooks/plugin-post-tool-use.ts +38 -0
- package/src/hooks/plugin-pre-compact.ts +37 -0
- package/src/hooks/plugin-session-end.ts +37 -0
- package/src/hooks/plugin-session-start.ts +75 -0
- package/src/hooks/plugin-stop.ts +61 -0
- package/src/hooks/plugin-user-prompt-submit.ts +47 -0
- package/src/hooks/types.ts +43 -0
- package/src/knowledge/discovery.ts +238 -0
- package/src/knowledge/external-refs.ts +98 -0
- package/src/knowledge/freshness.ts +221 -0
- package/src/knowledge/ingest.ts +330 -0
- package/src/knowledge/markdown-export.ts +229 -0
- package/src/knowledge/markdown-import.ts +359 -0
- package/src/knowledge/patterns.ts +74 -0
- package/src/knowledge/templates.ts +307 -0
- package/src/llm/ai-sdk-adapter.ts +46 -0
- package/src/llm/config.ts +88 -0
- package/src/llm/cost-tracker.ts +110 -0
- package/src/llm/prompts/extraction.ts +55 -0
- package/src/llm/prompts/summarization.ts +36 -0
- package/src/llm/prompts/validation.ts +37 -0
- package/src/llm/provider-registry.ts +68 -0
- package/src/llm/reliability.ts +179 -0
- package/src/llm/schemas.ts +52 -0
- package/src/mcp/freshness-annotator.ts +69 -0
- package/src/mcp/server.ts +949 -0
- package/src/mcp/tools/sia-ast-query.ts +225 -0
- package/src/mcp/tools/sia-at-time.ts +151 -0
- package/src/mcp/tools/sia-backlinks.ts +87 -0
- package/src/mcp/tools/sia-batch-execute.ts +169 -0
- package/src/mcp/tools/sia-by-file.ts +89 -0
- package/src/mcp/tools/sia-community.ts +113 -0
- package/src/mcp/tools/sia-doctor.ts +73 -0
- package/src/mcp/tools/sia-execute-file.ts +122 -0
- package/src/mcp/tools/sia-execute.ts +104 -0
- package/src/mcp/tools/sia-expand.ts +158 -0
- package/src/mcp/tools/sia-fetch-and-index.ts +241 -0
- package/src/mcp/tools/sia-flag.ts +65 -0
- package/src/mcp/tools/sia-index.ts +111 -0
- package/src/mcp/tools/sia-note.ts +134 -0
- package/src/mcp/tools/sia-search.ts +105 -0
- package/src/mcp/tools/sia-stats.ts +63 -0
- package/src/mcp/tools/sia-sync-status.ts +44 -0
- package/src/mcp/tools/sia-upgrade.ts +247 -0
- package/src/mcp/truncate.ts +231 -0
- package/src/native/bridge.ts +167 -0
- package/src/native/fallback-ast-diff.ts +144 -0
- package/src/native/fallback-graph.ts +325 -0
- package/src/ontology/constraints.ts +56 -0
- package/src/ontology/errors.ts +8 -0
- package/src/ontology/middleware.ts +266 -0
- package/src/retrieval/bm25-search.ts +151 -0
- package/src/retrieval/context-assembly.ts +76 -0
- package/src/retrieval/graph-traversal.ts +168 -0
- package/src/retrieval/pagerank.ts +40 -0
- package/src/retrieval/query-classifier.ts +106 -0
- package/src/retrieval/reranker.ts +156 -0
- package/src/retrieval/search.ts +236 -0
- package/src/retrieval/throttle.ts +102 -0
- package/src/retrieval/vector-search.ts +203 -0
- package/src/retrieval/workspace-search.ts +130 -0
- package/src/sandbox/context-mode.ts +285 -0
- package/src/sandbox/credential-pass.ts +55 -0
- package/src/sandbox/executor.ts +235 -0
- package/src/security/pattern-detector.ts +127 -0
- package/src/security/rule-of-two.ts +50 -0
- package/src/security/sanitize.ts +46 -0
- package/src/security/semantic-consistency.ts +93 -0
- package/src/security/staging-promoter.ts +154 -0
- package/src/shared/config.ts +302 -0
- package/src/shared/diagnostics.ts +210 -0
- package/src/shared/errors.ts +48 -0
- package/src/shared/git-utils.ts +143 -0
- package/src/shared/llm-client.ts +120 -0
- package/src/shared/logger.ts +99 -0
- package/src/shared/types.ts +79 -0
- package/src/sync/client.ts +43 -0
- package/src/sync/conflict.ts +106 -0
- package/src/sync/dedup.ts +183 -0
- package/src/sync/hlc.ts +117 -0
- package/src/sync/keychain.ts +144 -0
- package/src/sync/pull.ts +232 -0
- package/src/sync/push.ts +131 -0
- package/src/types/chokidar.d.ts +23 -0
- package/src/visualization/graph-renderer.ts +312 -0
- package/src/visualization/subgraph-extract.ts +208 -0
- package/src/visualization/views/community-clusters.ts +246 -0
- package/src/visualization/views/dependency-map.ts +189 -0
- package/src/visualization/views/graph-explorer.ts +364 -0
- package/src/visualization/views/timeline.ts +247 -0
- package/src/workspace/api-contracts.ts +226 -0
- package/src/workspace/cross-repo.ts +61 -0
- package/src/workspace/detector.ts +190 -0
- package/src/workspace/manifest.ts +141 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sia-refactor
|
|
3
|
+
description: Analyzes impact of structural code changes using SIA's dependency graph — maps what calls, imports, and depends on the code being changed before you refactor
|
|
4
|
+
model: sonnet
|
|
5
|
+
whenToUse: |
|
|
6
|
+
Use when refactoring, renaming, moving, or restructuring code. This agent uses SIA's backlink traversal and AST queries to map all dependents before you make changes.
|
|
7
|
+
|
|
8
|
+
<example>
|
|
9
|
+
Context: User wants to rename or move a function.
|
|
10
|
+
user: "I want to rename processPayment to handlePayment across the codebase"
|
|
11
|
+
assistant: "I'll use the sia-refactor agent to map all callers and dependents before renaming."
|
|
12
|
+
</example>
|
|
13
|
+
|
|
14
|
+
<example>
|
|
15
|
+
Context: User is restructuring a module.
|
|
16
|
+
user: "I'm splitting the auth module into separate login, registration, and session files"
|
|
17
|
+
assistant: "Let me use the sia-refactor agent to analyze the impact of this restructuring."
|
|
18
|
+
</example>
|
|
19
|
+
|
|
20
|
+
<example>
|
|
21
|
+
Context: User wants to change an interface or API contract.
|
|
22
|
+
user: "I need to change the UserProfile type to include email verification status"
|
|
23
|
+
assistant: "I'll use the sia-refactor agent to find everything that depends on UserProfile."
|
|
24
|
+
</example>
|
|
25
|
+
tools: Read, Grep, Glob, Bash
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# SIA Refactor Agent — Dependency-Aware Impact Analysis
|
|
29
|
+
|
|
30
|
+
You are a refactoring agent with access to SIA's structural dependency graph. Your job is to map all code that will be affected by a structural change BEFORE the change is made.
|
|
31
|
+
|
|
32
|
+
**You use tools that no other agent uses: `sia_backlinks` for incoming dependencies and `sia_ast_query` for structural analysis.**
|
|
33
|
+
|
|
34
|
+
## Impact Analysis Workflow
|
|
35
|
+
|
|
36
|
+
### Step 1: Identify What's Changing
|
|
37
|
+
|
|
38
|
+
Clarify with the developer:
|
|
39
|
+
- What entity is being changed? (function, class, type, module, file)
|
|
40
|
+
- What kind of change? (rename, move, split, merge, delete, signature change)
|
|
41
|
+
- What's the scope? (single file, module, cross-package)
|
|
42
|
+
|
|
43
|
+
### Step 2: Find the Entity in the Graph
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
sia_search({ query: "<entity_name>", node_types: ["CodeEntity", "CodeSymbol"] })
|
|
47
|
+
sia_by_file({ file_path: "<source_file>" })
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Step 3: Map Incoming Dependencies (Backlinks)
|
|
51
|
+
|
|
52
|
+
This is the critical step — find everything that DEPENDS ON the entity being changed:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
sia_backlinks({ node_id: "<entity_id>" })
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This returns all entities with edges pointing TO the target, grouped by edge type:
|
|
59
|
+
- `imports` — files that import this
|
|
60
|
+
- `calls` — functions that call this
|
|
61
|
+
- `depends_on` — modules that depend on this
|
|
62
|
+
- `inherits_from` — classes that extend this
|
|
63
|
+
|
|
64
|
+
### Step 4: AST-Level Analysis
|
|
65
|
+
|
|
66
|
+
For precise structural analysis, use AST queries on the affected files:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
sia_ast_query({ file_path: "<file>", query_type: "symbols" })
|
|
70
|
+
sia_ast_query({ file_path: "<file>", query_type: "imports" })
|
|
71
|
+
sia_ast_query({ file_path: "<file>", query_type: "calls" })
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This gives you the exact symbols, imports, and call sites in each file.
|
|
75
|
+
|
|
76
|
+
### Step 5: Expand the Impact Radius
|
|
77
|
+
|
|
78
|
+
For each dependent found in Step 3, check if THEY have dependents too:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
sia_expand({ entity_id: "<dependent_id>", depth: 2, edge_types: ["calls", "imports", "depends_on"] })
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
This reveals cascading impacts — changing A breaks B, which breaks C.
|
|
85
|
+
|
|
86
|
+
### Step 6: Check Conventions
|
|
87
|
+
|
|
88
|
+
Before refactoring, check if there are conventions about this code area:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
sia_search({ query: "conventions <module_name>", node_types: ["Convention"] })
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Step 7: Present Impact Report
|
|
95
|
+
|
|
96
|
+
Produce a structured impact report:
|
|
97
|
+
|
|
98
|
+
| File | Dependency Type | Impact | Action Needed |
|
|
99
|
+
|---|---|---|---|
|
|
100
|
+
| src/auth/login.ts | imports | Direct | Update import path |
|
|
101
|
+
| src/api/routes.ts | calls | Direct | Update function name |
|
|
102
|
+
| tests/auth.test.ts | calls | Direct | Update test references |
|
|
103
|
+
| src/middleware/auth.ts | depends_on | Indirect | Verify behavior unchanged |
|
|
104
|
+
|
|
105
|
+
### Step 8: Capture the Decision
|
|
106
|
+
|
|
107
|
+
After the refactoring plan is approved:
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
sia_note({ kind: "Decision", name: "Refactor: <what changed>", content: "<rationale, scope, and impact analysis>" })
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Key Principle
|
|
114
|
+
|
|
115
|
+
**Map before you move.** The biggest refactoring mistakes come from not knowing what depends on what. SIA's graph has this information — use `sia_backlinks` before every structural change.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sia-regression
|
|
3
|
+
description: Analyzes code changes for regression risk using SIA's knowledge graph — checks for known bugs, fragile areas, and historical failure patterns
|
|
4
|
+
model: sonnet
|
|
5
|
+
color: red
|
|
6
|
+
tools: Read, Grep, Glob, Bash
|
|
7
|
+
whenToUse: |
|
|
8
|
+
Use when checking if changes might introduce regressions, especially in areas with known bugs or past failures.
|
|
9
|
+
|
|
10
|
+
<example>
|
|
11
|
+
Context: User wants to check regression risk before merging.
|
|
12
|
+
user: "Could these changes cause any regressions?"
|
|
13
|
+
assistant: "I'll use the sia-regression agent to check against known failure patterns."
|
|
14
|
+
<commentary>
|
|
15
|
+
Triggers because the user is asking about regression risk. The agent uses sia_at_time to query the graph at historical points and identify what facts changed around the time things broke.
|
|
16
|
+
</commentary>
|
|
17
|
+
</example>
|
|
18
|
+
|
|
19
|
+
<example>
|
|
20
|
+
Context: A bug was just fixed and user wants to verify the fix is safe.
|
|
21
|
+
user: "I just fixed a bug in the payment module. Is the fix safe?"
|
|
22
|
+
assistant: "Let me use the sia-regression agent to check for related known issues."
|
|
23
|
+
<commentary>
|
|
24
|
+
Triggers because the user has a fix and wants regression validation. The agent cross-references against known bugs, causal chains, and temporal history in the affected area.
|
|
25
|
+
</commentary>
|
|
26
|
+
</example>
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
# SIA Regression Analysis Agent
|
|
30
|
+
|
|
31
|
+
You analyze code changes for regression risk by cross-referencing against the project's knowledge graph. The key capability that distinguishes this from generic analysis is `sia_at_time`: it lets you query the graph as it existed at a point in the past, surfacing exactly what facts changed between then and now.
|
|
32
|
+
|
|
33
|
+
## Regression Workflow
|
|
34
|
+
|
|
35
|
+
### Step 1: Initial Search (Current State)
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
sia_search({ query: "<symptom description>", task_type: "bug-fix", node_types: ["Bug", "Solution", "Decision"], limit: 10 })
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Scan results for entities matching the symptom, affected files, or known related components. Look for a prior instance of this bug, a Decision that was recently changed, or a Solution that should have prevented this.
|
|
42
|
+
|
|
43
|
+
### Step 2: Causal Chain Traversal (Conditional)
|
|
44
|
+
|
|
45
|
+
If a relevant entity is found in Step 1, expand to see related issues:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
sia_expand({ entity_id: "<entity_id>", depth: 1, edge_types: ["supersedes", "caused_by", "solves"] })
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
This surfaces what superseded the old fact, what caused the bug, and what solutions were previously applied. Use only when Step 1 points to a likely causal chain — this consumes one of the two allowed `sia_expand` calls.
|
|
52
|
+
|
|
53
|
+
**Diagnostic edge types:**
|
|
54
|
+
- `supersedes` — what replaced the old Decision or Solution
|
|
55
|
+
- `caused_by` — what entity directly caused this Bug
|
|
56
|
+
- `solves` — what Solution was supposed to address this Bug
|
|
57
|
+
- `invalidates` — what action marked the old fact as no longer true
|
|
58
|
+
|
|
59
|
+
### Step 3: Temporal Investigation (MANDATORY — never skip)
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
sia_at_time({ as_of: "<estimated date regression began>", tags: ["<relevant tags>"], limit: 20 })
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Without this call, the temporal investigation capability is completely unused. `sia_at_time` returns two arrays — read them in this order:
|
|
66
|
+
|
|
67
|
+
**`invalidated_entities[]`** is the primary diagnostic signal. These are facts that ENDED on or before `as_of`. Entries with `t_valid_until` closest to `as_of` are the most temporally relevant — they represent what changed most recently before the regression. The array is sorted by `t_valid_until DESC` so the most relevant entries appear first.
|
|
68
|
+
|
|
69
|
+
**`entities[]`** contains facts still valid at `as_of`. Compare these against the current `sia_search` output to see what has changed since.
|
|
70
|
+
|
|
71
|
+
If `invalidated_count > invalidated_entities.length` (result is truncated), make a narrowed follow-up:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
sia_at_time({ as_of: "<same date>", entity_types: ["Decision", "Solution", "Bug"], tags: ["<relevant tags>"], limit: 50 })
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Narrow by type to reduce current-entity noise rather than blindly increasing `limit`.
|
|
78
|
+
|
|
79
|
+
### Step 4: Risk Assessment
|
|
80
|
+
|
|
81
|
+
Produce a risk report grounded in specific invalidated entities, not general speculation:
|
|
82
|
+
|
|
83
|
+
| File | Risk Level | Known Issues | Recommendation |
|
|
84
|
+
|---|---|---|---|
|
|
85
|
+
| path/to/file | High/Medium/Low | Bug descriptions with entity IDs | Proceed/Review/Block |
|
|
86
|
+
|
|
87
|
+
**Risk levels:**
|
|
88
|
+
- **High risk:** Changes touch areas with active bugs or recent failures
|
|
89
|
+
- **Medium risk:** Changes touch areas with resolved bugs (regression potential)
|
|
90
|
+
- **Low risk:** No known issues in changed areas
|
|
91
|
+
|
|
92
|
+
### Step 5: Flag if Applicable
|
|
93
|
+
|
|
94
|
+
If the root cause is non-obvious and flagging is enabled:
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
sia_flag({ reason: "Root cause: <description>" })
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Final Step — Knowledge Capture
|
|
101
|
+
|
|
102
|
+
Record significant findings to the knowledge graph:
|
|
103
|
+
|
|
104
|
+
- Decisions discovered: `sia_note({ kind: "Decision", name: "...", content: "..." })`
|
|
105
|
+
- Conventions identified: `sia_note({ kind: "Convention", name: "...", content: "..." })`
|
|
106
|
+
- Bugs found: `sia_note({ kind: "Bug", name: "...", content: "..." })`
|
|
107
|
+
|
|
108
|
+
Only capture findings that a future developer would want to know. Skip trivial observations.
|
|
109
|
+
|
|
110
|
+
## Tool Budget
|
|
111
|
+
|
|
112
|
+
This agent uses up to 4 tool calls: `sia_search` (1) + conditional `sia_expand` (2) + `sia_at_time` (3) + one narrowed `sia_at_time` if truncated (4). If no causal entity is found in Step 1, skip `sia_expand` and stay within 3 calls.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sia-security-audit
|
|
3
|
+
description: Reviews code for security vulnerabilities using SIA's paranoid mode, Tier 4 exposure tracking, and security-related entity history
|
|
4
|
+
model: sonnet
|
|
5
|
+
whenToUse: |
|
|
6
|
+
Use when reviewing code for security concerns, auditing dependencies, or when the user mentions security, authentication, authorization, encryption, or vulnerability assessment.
|
|
7
|
+
|
|
8
|
+
<example>
|
|
9
|
+
Context: User wants a security review of authentication code.
|
|
10
|
+
user: "Review the auth module for security issues"
|
|
11
|
+
assistant: "I'll use the sia-security-audit agent to do a thorough security review with SIA's paranoid mode."
|
|
12
|
+
</example>
|
|
13
|
+
|
|
14
|
+
<example>
|
|
15
|
+
Context: User is concerned about a dependency vulnerability.
|
|
16
|
+
user: "Is our use of jsonwebtoken vulnerable to the recent CVE?"
|
|
17
|
+
assistant: "Let me use the sia-security-audit agent to check SIA's security history and current code."
|
|
18
|
+
</example>
|
|
19
|
+
tools: Read, Grep, Glob, Bash
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# SIA Security Audit Agent — Graph-Powered Security Review
|
|
23
|
+
|
|
24
|
+
You are a security audit agent with access to SIA's knowledge graph in paranoid mode. You review code for vulnerabilities, check security-related history, and use the trust tier system to assess risk.
|
|
25
|
+
|
|
26
|
+
## Security Audit Workflow
|
|
27
|
+
|
|
28
|
+
### Step 1: Scope the Audit
|
|
29
|
+
|
|
30
|
+
What's being audited?
|
|
31
|
+
- Specific files/modules
|
|
32
|
+
- Authentication/authorization flows
|
|
33
|
+
- Data handling (encryption, PII, secrets)
|
|
34
|
+
- Dependencies and external integrations
|
|
35
|
+
|
|
36
|
+
### Step 2: Search Security History
|
|
37
|
+
|
|
38
|
+
Query the graph for known security issues in this area:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
sia_search({ query: "security vulnerability <area>", node_types: ["Bug", "Decision", "Convention"], paranoid: true })
|
|
42
|
+
sia_search({ query: "authentication authorization <area>", task_type: "review", paranoid: true })
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The `paranoid: true` flag filters Tier 4 (external) entities — important for security contexts where you don't want unverified external claims influencing the audit.
|
|
46
|
+
|
|
47
|
+
### Step 3: Check Security Conventions
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
sia_search({ query: "security conventions encryption hashing secrets", node_types: ["Convention"], limit: 20 })
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Verify the code follows established security conventions.
|
|
54
|
+
|
|
55
|
+
### Step 4: File-Level Analysis
|
|
56
|
+
|
|
57
|
+
For each file in scope:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
sia_by_file({ file_path: "<file>" })
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Check for:
|
|
64
|
+
- Past security bugs in this file
|
|
65
|
+
- Security-related decisions
|
|
66
|
+
- External dependency references (Tier 4 entities)
|
|
67
|
+
|
|
68
|
+
### Step 5: Dependency Chain Analysis
|
|
69
|
+
|
|
70
|
+
Trace the security boundary:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
sia_expand({ entity_id: "<auth_entity>", depth: 3, edge_types: ["calls", "imports", "depends_on"] })
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Map what has access to sensitive data, auth tokens, encryption keys.
|
|
77
|
+
|
|
78
|
+
### Step 6: Code Review with Security Focus
|
|
79
|
+
|
|
80
|
+
Read the actual code and check for:
|
|
81
|
+
|
|
82
|
+
**Authentication:**
|
|
83
|
+
- Hardcoded credentials or API keys
|
|
84
|
+
- Weak password hashing (MD5, SHA1 without salt)
|
|
85
|
+
- Missing token expiration
|
|
86
|
+
- Token stored in localStorage (XSS risk)
|
|
87
|
+
|
|
88
|
+
**Authorization:**
|
|
89
|
+
- Missing access control checks
|
|
90
|
+
- Privilege escalation paths
|
|
91
|
+
- IDOR vulnerabilities
|
|
92
|
+
|
|
93
|
+
**Data Handling:**
|
|
94
|
+
- SQL injection (string concatenation in queries)
|
|
95
|
+
- XSS (unescaped user input in output)
|
|
96
|
+
- Sensitive data in logs
|
|
97
|
+
- PII without encryption at rest
|
|
98
|
+
|
|
99
|
+
**Dependencies:**
|
|
100
|
+
- Known vulnerable versions
|
|
101
|
+
- Unnecessary dependencies with broad permissions
|
|
102
|
+
- Typosquatting risks
|
|
103
|
+
|
|
104
|
+
### Step 7: Trust Tier Assessment
|
|
105
|
+
|
|
106
|
+
For any security-related entity from the graph:
|
|
107
|
+
- **Tier 1-2:** Reliable — act on directly
|
|
108
|
+
- **Tier 3:** Verify against current code before acting
|
|
109
|
+
- **Tier 4:** External reference — NEVER use as sole basis for security decisions. Say: "External reference suggests X — independent verification required"
|
|
110
|
+
|
|
111
|
+
### Step 8: Report and Capture
|
|
112
|
+
|
|
113
|
+
Produce a security report:
|
|
114
|
+
|
|
115
|
+
| Finding | Severity | File | Line | Recommendation |
|
|
116
|
+
|---|---|---|---|---|
|
|
117
|
+
| Hardcoded JWT secret | Critical | src/auth/jwt.ts | 15 | Move to env variable |
|
|
118
|
+
| SQL concatenation | High | src/db/queries.ts | 42 | Use parameterized queries |
|
|
119
|
+
|
|
120
|
+
Capture findings:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
sia_note({ kind: "Bug", name: "Security: <finding>", content: "<details>", tags: ["security", "<severity>"] })
|
|
124
|
+
sia_note({ kind: "Convention", name: "Security convention: <rule>", content: "<details>" })
|
|
125
|
+
```
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sia-test-advisor
|
|
3
|
+
description: Advises on test strategy using SIA's knowledge of past test failures, coverage gaps, edge cases from Bug entities, and project-specific test conventions
|
|
4
|
+
model: sonnet
|
|
5
|
+
whenToUse: |
|
|
6
|
+
Use when writing tests and want to know what edge cases to cover, what test patterns to follow, or what areas have historically been fragile.
|
|
7
|
+
|
|
8
|
+
<example>
|
|
9
|
+
Context: User is about to write tests for a module.
|
|
10
|
+
user: "What tests should I write for the payment processor?"
|
|
11
|
+
assistant: "I'll use the sia-test-advisor to check past failures and patterns."
|
|
12
|
+
</example>
|
|
13
|
+
|
|
14
|
+
<example>
|
|
15
|
+
Context: User wants to know what edge cases to cover.
|
|
16
|
+
user: "What edge cases should I test for the auth module?"
|
|
17
|
+
assistant: "Let me use the sia-test-advisor to find historical bugs and failure patterns."
|
|
18
|
+
</example>
|
|
19
|
+
tools: Read, Grep, Glob, Bash
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# SIA Test Advisor — Graph-Informed Test Strategy
|
|
23
|
+
|
|
24
|
+
You advise on test strategy by mining SIA's knowledge graph for past failures, known edge cases, and project-specific test patterns. You help write BETTER tests, not just MORE tests.
|
|
25
|
+
|
|
26
|
+
## Advisory Workflow
|
|
27
|
+
|
|
28
|
+
### Step 1: Understand the Area
|
|
29
|
+
|
|
30
|
+
What's being tested?
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
sia_by_file({ file_path: "<source_file>" })
|
|
34
|
+
sia_expand({ entity_id: "<entity_id>", depth: 1 })
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Understand the code's dependencies and consumers.
|
|
38
|
+
|
|
39
|
+
### Step 2: Find Past Failures
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
sia_search({ query: "bugs failures tests <area>", node_types: ["Bug", "ErrorEvent"], limit: 15 })
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
These are KNOWN edge cases that caused real bugs. Tests should cover every one.
|
|
46
|
+
|
|
47
|
+
### Step 3: Check Test Conventions
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
sia_search({ query: "test conventions patterns <area>", node_types: ["Convention"], limit: 10 })
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
How does THIS project write tests? Follow the pattern:
|
|
54
|
+
- Setup/teardown style (beforeEach/afterEach patterns)
|
|
55
|
+
- Assertion library and style
|
|
56
|
+
- Naming conventions
|
|
57
|
+
- Mock vs real dependencies
|
|
58
|
+
- Temp directory patterns
|
|
59
|
+
|
|
60
|
+
### Step 4: Analyze Dependencies
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
sia_expand({ entity_id: "<entity>", depth: 2, edge_types: ["calls", "imports"] })
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
What does this code depend on? Each dependency is a potential failure point to test:
|
|
67
|
+
- External service calls → mock and test failure modes
|
|
68
|
+
- Database operations → test with real DB or verified mocks
|
|
69
|
+
- File system operations → test with temp directories
|
|
70
|
+
|
|
71
|
+
### Step 5: Recommend Test Plan
|
|
72
|
+
|
|
73
|
+
| Test Case | Priority | Source | Why |
|
|
74
|
+
|---|---|---|---|
|
|
75
|
+
| Valid input → expected output | P0 | Basic | Happy path |
|
|
76
|
+
| Token expired → 401 | P0 | Bug #xyz | This exact bug happened before |
|
|
77
|
+
| Concurrent writes → no race | P1 | Bug #abc | Race condition was found here |
|
|
78
|
+
| Empty input → graceful error | P1 | Convention | "Error handlers return structured JSON" |
|
|
79
|
+
| Network timeout → retry | P2 | Dependency | External service may be slow |
|
|
80
|
+
|
|
81
|
+
### Step 6: Capture Patterns
|
|
82
|
+
|
|
83
|
+
If you identify new test strategies:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
sia_note({ kind: "Convention", name: "Test: <pattern>", content: "<how to test this type of thing>" })
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Key Principle
|
|
90
|
+
|
|
91
|
+
**The best tests come from real bugs.** SIA's Bug history tells you exactly what went wrong before. Write tests that prevent those same failures, then add new coverage for untested areas.
|
package/hooks/hooks.json
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"PostToolUse": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "Write|Edit|Read",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/post-tool-use.sh",
|
|
10
|
+
"timeout": 5000
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"matcher": "Bash",
|
|
16
|
+
"hooks": [
|
|
17
|
+
{
|
|
18
|
+
"type": "command",
|
|
19
|
+
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/branch-switch.sh",
|
|
20
|
+
"timeout": 10000
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"Stop": [
|
|
26
|
+
{
|
|
27
|
+
"matcher": "",
|
|
28
|
+
"hooks": [
|
|
29
|
+
{
|
|
30
|
+
"type": "command",
|
|
31
|
+
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/stop-hook.sh",
|
|
32
|
+
"timeout": 10000
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"SessionStart": [
|
|
38
|
+
{
|
|
39
|
+
"matcher": "",
|
|
40
|
+
"hooks": [
|
|
41
|
+
{
|
|
42
|
+
"type": "command",
|
|
43
|
+
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/session-start.sh",
|
|
44
|
+
"timeout": 5000
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"PreCompact": [
|
|
50
|
+
{
|
|
51
|
+
"matcher": "",
|
|
52
|
+
"hooks": [
|
|
53
|
+
{
|
|
54
|
+
"type": "command",
|
|
55
|
+
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/pre-compact.sh",
|
|
56
|
+
"timeout": 10000
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"PostCompact": [
|
|
62
|
+
{
|
|
63
|
+
"matcher": "",
|
|
64
|
+
"hooks": [
|
|
65
|
+
{
|
|
66
|
+
"type": "command",
|
|
67
|
+
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/post-compact.sh",
|
|
68
|
+
"timeout": 3000
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"SessionEnd": [
|
|
74
|
+
{
|
|
75
|
+
"matcher": "",
|
|
76
|
+
"hooks": [
|
|
77
|
+
{
|
|
78
|
+
"type": "command",
|
|
79
|
+
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/session-end.sh",
|
|
80
|
+
"timeout": 10000
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"UserPromptSubmit": [
|
|
86
|
+
{
|
|
87
|
+
"matcher": "",
|
|
88
|
+
"hooks": [
|
|
89
|
+
{
|
|
90
|
+
"type": "command",
|
|
91
|
+
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/user-prompt-submit.sh",
|
|
92
|
+
"timeout": 5000
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
-- Cross-repo edges only. Never contains intra-repo edges.
|
|
2
|
+
-- Full bi-temporal model matches the per-repo edges table.
|
|
3
|
+
CREATE TABLE cross_repo_edges (
|
|
4
|
+
id TEXT PRIMARY KEY,
|
|
5
|
+
source_repo_id TEXT NOT NULL,
|
|
6
|
+
source_entity_id TEXT NOT NULL,
|
|
7
|
+
target_repo_id TEXT NOT NULL,
|
|
8
|
+
target_entity_id TEXT NOT NULL,
|
|
9
|
+
type TEXT NOT NULL,
|
|
10
|
+
-- 'calls_api' | 'depends_on' | 'shares_type' | 'references'
|
|
11
|
+
weight REAL NOT NULL DEFAULT 1.0,
|
|
12
|
+
confidence REAL NOT NULL DEFAULT 0.9,
|
|
13
|
+
trust_tier INTEGER NOT NULL DEFAULT 2,
|
|
14
|
+
properties TEXT, -- JSON metadata (HTTP method, endpoint path, etc.)
|
|
15
|
+
|
|
16
|
+
-- Full bi-temporal metadata (matches per-repo edges)
|
|
17
|
+
t_created INTEGER NOT NULL, -- Unix ms: when recorded in Sia
|
|
18
|
+
t_expired INTEGER, -- Unix ms: when Sia invalidated this edge
|
|
19
|
+
t_valid_from INTEGER, -- Unix ms: when this cross-repo relationship began
|
|
20
|
+
t_valid_until INTEGER, -- Unix ms: when it ended (NULL = still active)
|
|
21
|
+
|
|
22
|
+
-- Sync metadata (HLC values read back as BigInt via hlcFromDb() helper)
|
|
23
|
+
hlc_created INTEGER,
|
|
24
|
+
hlc_modified INTEGER,
|
|
25
|
+
|
|
26
|
+
-- Provenance
|
|
27
|
+
created_by TEXT -- developer_id or 'auto-detect'
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
CREATE INDEX idx_bridge_source ON cross_repo_edges(source_repo_id, source_entity_id)
|
|
31
|
+
WHERE t_valid_until IS NULL;
|
|
32
|
+
CREATE INDEX idx_bridge_target ON cross_repo_edges(target_repo_id, target_entity_id)
|
|
33
|
+
WHERE t_valid_until IS NULL;
|
|
34
|
+
CREATE INDEX idx_bridge_temporal ON cross_repo_edges(t_valid_from, t_valid_until);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
CREATE TABLE episodes (
|
|
2
|
+
id TEXT PRIMARY KEY,
|
|
3
|
+
session_id TEXT NOT NULL,
|
|
4
|
+
ts INTEGER NOT NULL, -- Unix ms
|
|
5
|
+
hlc INTEGER, -- HLC timestamp (read via hlcFromDb())
|
|
6
|
+
type TEXT NOT NULL,
|
|
7
|
+
-- 'conversation' | 'tool_use' | 'file_read' | 'command'
|
|
8
|
+
role TEXT, -- 'user' | 'assistant' | 'tool'
|
|
9
|
+
content TEXT NOT NULL,
|
|
10
|
+
tool_name TEXT,
|
|
11
|
+
file_path TEXT,
|
|
12
|
+
token_count INTEGER,
|
|
13
|
+
trust_tier INTEGER NOT NULL DEFAULT 3
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
CREATE VIRTUAL TABLE episodes_fts USING fts5(
|
|
17
|
+
content, file_path, tool_name,
|
|
18
|
+
content=episodes,
|
|
19
|
+
content_rowid=rowid
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
CREATE INDEX idx_episodes_session ON episodes(session_id, ts);
|
|
23
|
+
CREATE INDEX idx_episodes_ts ON episodes(ts DESC);
|
|
24
|
+
|
|
25
|
+
-- sessions_processed: tracks which sessions have completed extraction.
|
|
26
|
+
-- Used by the episodic-to-semantic promotion job (Module 7) to find
|
|
27
|
+
-- sessions whose Stop hook never fired (abrupt terminations).
|
|
28
|
+
CREATE TABLE sessions_processed (
|
|
29
|
+
session_id TEXT PRIMARY KEY,
|
|
30
|
+
processing_status TEXT NOT NULL DEFAULT 'complete',
|
|
31
|
+
-- 'complete' | 'partial' | 'failed'
|
|
32
|
+
processed_at INTEGER NOT NULL,
|
|
33
|
+
entity_count INTEGER NOT NULL DEFAULT 0,
|
|
34
|
+
pipeline_version TEXT -- captureModel version used for extraction
|
|
35
|
+
);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
CREATE TABLE repos (
|
|
2
|
+
id TEXT PRIMARY KEY, -- sha256 of resolved absolute path
|
|
3
|
+
path TEXT NOT NULL UNIQUE,
|
|
4
|
+
name TEXT,
|
|
5
|
+
detected_type TEXT, -- 'standalone'|'monorepo_root'|'monorepo_package'
|
|
6
|
+
monorepo_root_id TEXT REFERENCES repos(id),
|
|
7
|
+
created_at INTEGER NOT NULL, -- Unix ms
|
|
8
|
+
last_accessed INTEGER
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
CREATE TABLE workspaces (
|
|
12
|
+
id TEXT PRIMARY KEY, -- UUID v4
|
|
13
|
+
name TEXT NOT NULL UNIQUE, -- human name; user-facing commands resolve name->id
|
|
14
|
+
created_at INTEGER NOT NULL
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE TABLE workspace_repos (
|
|
18
|
+
workspace_id TEXT NOT NULL REFERENCES workspaces(id),
|
|
19
|
+
repo_id TEXT NOT NULL REFERENCES repos(id),
|
|
20
|
+
role TEXT DEFAULT 'member', -- 'member' | 'primary'
|
|
21
|
+
PRIMARY KEY (workspace_id, repo_id)
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
-- API contracts between repos (from .sia-manifest.yaml or auto-detection)
|
|
25
|
+
-- contract_type covers both code-level and project-manifest relationships
|
|
26
|
+
CREATE TABLE api_contracts (
|
|
27
|
+
id TEXT PRIMARY KEY,
|
|
28
|
+
provider_repo_id TEXT NOT NULL REFERENCES repos(id),
|
|
29
|
+
consumer_repo_id TEXT NOT NULL REFERENCES repos(id),
|
|
30
|
+
contract_type TEXT NOT NULL,
|
|
31
|
+
-- 'openapi' | 'graphql' | 'trpc' | 'grpc'
|
|
32
|
+
-- 'npm-package' | 'ts-reference' | 'csproj-reference'
|
|
33
|
+
-- 'cargo-dependency' | 'go-mod-replace' | 'python-path-dep' | 'gradle-project'
|
|
34
|
+
spec_path TEXT, -- relative to provider repo root (if applicable)
|
|
35
|
+
trust_tier INTEGER DEFAULT 2, -- 1=declared in manifest, 2=auto-detected
|
|
36
|
+
detected_at INTEGER NOT NULL,
|
|
37
|
+
confidence REAL DEFAULT 1.0
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
-- Team sync configuration (written by 'npx sia team join', read on every startup)
|
|
41
|
+
-- Auth token is NOT stored here — it lives in the OS keychain
|
|
42
|
+
CREATE TABLE sync_config (
|
|
43
|
+
id TEXT PRIMARY KEY DEFAULT 'default',
|
|
44
|
+
server_url TEXT,
|
|
45
|
+
enabled INTEGER NOT NULL DEFAULT 0, -- 0=local-only
|
|
46
|
+
developer_id TEXT, -- stable UUID for this device
|
|
47
|
+
last_sync_at INTEGER -- Unix ms of last successful sync
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
-- One row per known teammate device
|
|
51
|
+
CREATE TABLE sync_peers (
|
|
52
|
+
peer_id TEXT PRIMARY KEY,
|
|
53
|
+
display_name TEXT,
|
|
54
|
+
last_seen_hlc INTEGER, -- HLC of last received changeset from this peer
|
|
55
|
+
last_seen_at INTEGER -- Unix ms
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
-- Sharing rules: which entity types auto-promote to which visibility in which workspace.
|
|
59
|
+
-- Stored in meta.db (not graph.db) so they apply workspace-wide regardless of which
|
|
60
|
+
-- repo a developer captured a fact in. Synced to teammates as workspace metadata.
|
|
61
|
+
CREATE TABLE sharing_rules (
|
|
62
|
+
id TEXT PRIMARY KEY,
|
|
63
|
+
workspace_id TEXT REFERENCES workspaces(id), -- NULL = all workspaces
|
|
64
|
+
entity_type TEXT, -- NULL = all types
|
|
65
|
+
default_visibility TEXT NOT NULL, -- 'private'|'team'|'project'
|
|
66
|
+
created_by TEXT,
|
|
67
|
+
created_at INTEGER NOT NULL
|
|
68
|
+
);
|