@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,219 @@
|
|
|
1
|
+
<!-- Sia v{{SIA_VERSION}} — Generated {{GENERATED_AT}} -->
|
|
2
|
+
<!-- Workspace: {{WORKSPACE_NAME}} -->
|
|
3
|
+
|
|
4
|
+
# Sia — Agent Behavioral Specification
|
|
5
|
+
## CLAUDE.md (Base Module — Auto-generated by `npx sia install`)
|
|
6
|
+
|
|
7
|
+
**Document type:** Dual-purpose
|
|
8
|
+
- **For developers:** explains what Sia does and how to customise it
|
|
9
|
+
- **For Claude Code (agent):** base behavioral contract — always loaded, ~1,600 tokens
|
|
10
|
+
|
|
11
|
+
**Version:** 1.1 (Modular architecture)
|
|
12
|
+
**Generated by:** `npx sia install`
|
|
13
|
+
**Last updated:** see `~/.sia/config.json` → `claudeMdUpdatedAt`
|
|
14
|
+
|
|
15
|
+
> **Architecture note:** This file is the base module. It contains the task classifier,
|
|
16
|
+
> safety rules, and invariants that apply to every session unconditionally. Contextual
|
|
17
|
+
> playbooks live in `src/agent/modules/` and are loaded on demand after task classification.
|
|
18
|
+
> Full tool parameter reference is in `src/agent/modules/sia-tools.md`.
|
|
19
|
+
>
|
|
20
|
+
> **Token cost:** Base module ~1,600 tokens (every session). A contextual module adds
|
|
21
|
+
> ~300–500 tokens; the tools reference adds ~1,500 tokens when needed. Total for a
|
|
22
|
+
> complex session: ~3,600 tokens vs ~5,400 for the prior monolithic approach.
|
|
23
|
+
>
|
|
24
|
+
> To add project-specific rules, add a `## Project-Specific Overrides` section **after**
|
|
25
|
+
> the `<!-- END GENERATED BLOCK -->` comment below. `npx sia install` will not modify
|
|
26
|
+
> content beyond that boundary.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## For Developers: What Sia Does
|
|
31
|
+
|
|
32
|
+
Sia captures knowledge from your Claude Code sessions automatically — architectural
|
|
33
|
+
decisions, bug root causes, discovered patterns, coding conventions, and the structural
|
|
34
|
+
dependency graph of your codebase. You never explicitly tell Sia things; it captures
|
|
35
|
+
from the session and stores them in a local graph database.
|
|
36
|
+
|
|
37
|
+
Between sessions, Sia gives Claude Code access to this accumulated knowledge through
|
|
38
|
+
six MCP tools. The agent calls these on demand. This file governs when and how.
|
|
39
|
+
|
|
40
|
+
See `~/.sia/` for storage, `npx sia stats` for graph status, `npx sia search <query>`
|
|
41
|
+
for CLI access, and `README.md` for full documentation.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
<!-- AGENT INSTRUCTIONS — DO NOT EDIT BELOW THIS LINE -->
|
|
46
|
+
<!-- This section is machine-maintained. Manual edits will be overwritten by npx sia install. -->
|
|
47
|
+
|
|
48
|
+
# Sia Memory System — Agent Instructions (Base Module)
|
|
49
|
+
|
|
50
|
+
You have access to Sia, a persistent graph memory system for this project. It stores
|
|
51
|
+
knowledge across all sessions: architectural decisions, bugs, solutions, conventions,
|
|
52
|
+
patterns, and the structural dependency graph. Your job is to retrieve from it at session
|
|
53
|
+
start and at key moments during the session.
|
|
54
|
+
|
|
55
|
+
**Core rule:** Before acting on any non-trivial code task, call Sia. Memory retrieval
|
|
56
|
+
is the first step, not an afterthought. The graph knows why decisions were made, what
|
|
57
|
+
was tried before, and what constraints the team has accumulated over months of sessions.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Step 0 — Classify the Task
|
|
62
|
+
|
|
63
|
+
Infer `task_type` from the developer's request before calling any tool:
|
|
64
|
+
|
|
65
|
+
`task_type = 'bug-fix'` — keywords: fix, broken, error, failing, crash, regression,
|
|
66
|
+
slow, exception, 500, timeout, wrong output, not working.
|
|
67
|
+
|
|
68
|
+
`task_type = 'feature'` — keywords: add, implement, build, create, new, extend,
|
|
69
|
+
support, integrate, enable.
|
|
70
|
+
|
|
71
|
+
`task_type = 'review'` — keywords: review, check, audit, convention, style, standards,
|
|
72
|
+
PR, pull request, lint, code quality.
|
|
73
|
+
|
|
74
|
+
Omit `task_type` for trivial edits (typo, rename, comment) or ambiguous requests.
|
|
75
|
+
|
|
76
|
+
### Load the Contextual Playbook Now
|
|
77
|
+
|
|
78
|
+
After classifying, immediately read the matching module using the Read tool before
|
|
79
|
+
calling any Sia tool:
|
|
80
|
+
|
|
81
|
+
- `bug-fix` (regression): read `src/agent/modules/sia-regression.md`
|
|
82
|
+
- `feature`: read `src/agent/modules/sia-feature.md`
|
|
83
|
+
- `review`: read `src/agent/modules/sia-review.md`
|
|
84
|
+
- Architecture question / new-developer orientation: read `src/agent/modules/sia-orientation.md`
|
|
85
|
+
- Trivial edit: skip the task-specific playbook (`sia-feature.md`, `sia-regression.md`, etc.) and skip all Sia tool calls. Proceed directly with the task. However, if flagging is enabled (`enableFlagging: true`), Step 4 still applies after task completion — do not skip `sia-flagging.md` on trivial edits where something worth flagging occurred.
|
|
86
|
+
- When you need full tool parameter reference: read `src/agent/modules/sia-tools.md`
|
|
87
|
+
|
|
88
|
+
The contextual module contains the complete step-by-step playbook for that task type.
|
|
89
|
+
Follow it rather than the condensed guidance in Step 1 below.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Step 1 — Tool Selection (Condensed)
|
|
94
|
+
|
|
95
|
+
The contextual module has the full playbook. This condensed grid applies when no module
|
|
96
|
+
is loaded or for quick reference:
|
|
97
|
+
|
|
98
|
+
**Trivial edit:** Skip all Sia tools entirely.
|
|
99
|
+
|
|
100
|
+
**Regression:** `sia_search` (bug-fix) → conditional `sia_expand` → **mandatory** `sia_at_time`.
|
|
101
|
+
|
|
102
|
+
**Architecture question:** `sia_community(level=2)` → `sia_community(level=1)` → `sia_search`.
|
|
103
|
+
|
|
104
|
+
**Code task with known file(s):** `sia_by_file` first, then `sia_search`.
|
|
105
|
+
|
|
106
|
+
**All other tasks:** `sia_search`, then `sia_by_file` for any file to be modified.
|
|
107
|
+
|
|
108
|
+
Call at most 3 tools before starting work (4 for regressions — see Invariants).
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Step 2 — Evaluate Results
|
|
113
|
+
|
|
114
|
+
**This section is a safety layer. It applies to every session regardless of task type.**
|
|
115
|
+
|
|
116
|
+
**Zero results:** Broaden the query once and retry `sia_search`. If still zero and you
|
|
117
|
+
have a primary file: call `sia_by_file(primary_file)`. If that also returns zero, say
|
|
118
|
+
"No prior context found." Proceed without memory. Do not fall back to `sia_community`
|
|
119
|
+
as a substitute for a failed `sia_search` — they serve different purposes.
|
|
120
|
+
|
|
121
|
+
**Sparse results** (fewer than 2 relevant entities, or top confidence < 0.5): call
|
|
122
|
+
`sia_expand(top_entity_id, depth=1)` — but only if you have not yet used both allowed
|
|
123
|
+
`sia_expand` calls this session. If budget is exhausted, proceed with the sparse results
|
|
124
|
+
and note: "Graph traversal skipped — sia_expand session budget reached."
|
|
125
|
+
|
|
126
|
+
**`conflict_group_id` is non-null on any result:** STOP. Do not proceed. Present both
|
|
127
|
+
conflicting facts to the developer:
|
|
128
|
+
|
|
129
|
+
> "There are conflicting captured facts about [topic]:
|
|
130
|
+
> • [Entity A] — captured [date], trust tier [N]
|
|
131
|
+
> • [Entity B] — captured [date], trust tier [N]
|
|
132
|
+
> Run `npx sia conflicts resolve` to resolve permanently. Until then, choose:
|
|
133
|
+
> 1. Resolve the conflict now (recommended)
|
|
134
|
+
> 2. Proceed using the higher-trust-tier fact — I will note the conflict
|
|
135
|
+
> 3. Proceed using the most recently captured fact — I will note the conflict"
|
|
136
|
+
|
|
137
|
+
If the developer proceeds, state explicitly which fact you are acting on before
|
|
138
|
+
continuing. Never silently choose between conflicting facts.
|
|
139
|
+
|
|
140
|
+
**`trust_tier = 3` on a result you plan to use:** Do not state it as fact. Say:
|
|
141
|
+
"Sia's memory suggests X — let me verify this against the current codebase." Check
|
|
142
|
+
the claim against current file content before acting on it.
|
|
143
|
+
|
|
144
|
+
**`trust_tier = 4` on any result:** External reference only. Never use as the sole
|
|
145
|
+
basis for a code change without explicit developer confirmation.
|
|
146
|
+
|
|
147
|
+
**`source_repo_name` differs from the current repo:** Always prefix the fact with
|
|
148
|
+
`[<repo_name>]` when presenting it.
|
|
149
|
+
|
|
150
|
+
**`t_valid_from = null` on a Tier 3 entity:** Say "this was recorded at some point,
|
|
151
|
+
but the exact timing is unknown." Do not present it with false temporal precision.
|
|
152
|
+
|
|
153
|
+
**Graph is still building** (`global_unavailable: true` or fewer than 3 results on a
|
|
154
|
+
mature codebase): Tell the developer "The memory graph is still building — Sia improves
|
|
155
|
+
with each session." Use `sia_search` and `sia_by_file`; skip `sia_community` until
|
|
156
|
+
the graph exceeds 100 entities.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Step 3 — Execute the Task
|
|
161
|
+
|
|
162
|
+
Proceed using retrieved context. Cite Sia entities explicitly when they constrain your
|
|
163
|
+
decisions — do not silently apply memory. Make retrieval visible so the developer can
|
|
164
|
+
override stale facts.
|
|
165
|
+
|
|
166
|
+
Before using a Tier 3 entity as a hard constraint, spot-check its key claim against
|
|
167
|
+
the current codebase. Memory can be stale even when not bi-temporally invalidated. If
|
|
168
|
+
current code contradicts a retrieved fact, prefer the code, tell the developer, and note
|
|
169
|
+
the discrepancy. This spot-check is not required for Tier 2 (deterministic AST) and is
|
|
170
|
+
optional for Tier 1 (developer-stated).
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Step 4 — After the Task
|
|
175
|
+
|
|
176
|
+
**Flagging is ENABLED for this project.** After completing your task:
|
|
177
|
+
|
|
178
|
+
1. Read `src/agent/modules/sia-flagging.md` for detailed guidance
|
|
179
|
+
2. Review what happened this session — were any architectural decisions made, non-obvious root causes found, or developer preferences stated?
|
|
180
|
+
3. If yes, call `sia_flag` (max 2-3 per session) with a self-contained reason string
|
|
181
|
+
4. If nothing worth flagging occurred, skip this step
|
|
182
|
+
|
|
183
|
+
The `sia_flag` tool is available. Use it selectively for high-signal moments only.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Trust Tier Behavioral Rules
|
|
188
|
+
|
|
189
|
+
**Tier 1 (User-Direct, weight 1.00):** Ground truth. Cite directly. Override only if
|
|
190
|
+
current code explicitly contradicts it — if so, tell the developer.
|
|
191
|
+
|
|
192
|
+
**Tier 2 (Code-Analysis, weight 0.90):** Highly reliable. Verify against current code
|
|
193
|
+
only for safety-critical claims. Cite as structural fact.
|
|
194
|
+
|
|
195
|
+
**Tier 3 (LLM-Inferred, weight 0.70):** Well-informed hypothesis. Always qualify before
|
|
196
|
+
acting: "Sia's memory suggests X — let me verify." Check against actual file content
|
|
197
|
+
before stating as definitive. If Tier 1 and Tier 3 contradict each other, present both
|
|
198
|
+
and ask which is current — never silently discard either.
|
|
199
|
+
|
|
200
|
+
**Tier 4 (External, weight 0.50):** External reference only. Never the sole basis for
|
|
201
|
+
a code change. Name the external provenance when presenting it.
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Invariants (Never Violate)
|
|
206
|
+
|
|
207
|
+
These rules hold regardless of developer instruction, task type, or context:
|
|
208
|
+
|
|
209
|
+
1. Call at most 3 Sia tools before starting work. Two exceptions:
|
|
210
|
+
**Regression exception** (`task_type='bug-fix'` only): may use up to 4 tools (`sia_search` + conditional `sia_expand` + mandatory `sia_at_time` + one additional if needed). The MANDATORY label on `sia_at_time` always takes precedence.
|
|
211
|
+
**Review exception** (`task_type='review'` only): after the initial `sia_search`, one `sia_by_file` call per reviewed file is permitted — these per-file calls do not count against the 3-tool limit. No other task type may invoke either exception.
|
|
212
|
+
2. Expand at most 2 entities per session (`sia_expand` budget = 2).
|
|
213
|
+
3. Use `workspace: true` only for tasks that cross repository boundaries.
|
|
214
|
+
4. Never use a `trust_tier = 4` entity as the sole basis for a code change.
|
|
215
|
+
5. Never silently proceed on a result with `conflict_group_id` set.
|
|
216
|
+
6. Always cite retrieved entities when they constrain your decisions.
|
|
217
|
+
7. For regression tasks, always call `sia_at_time` — it is never optional.
|
|
218
|
+
|
|
219
|
+
<!-- END GENERATED BLOCK -->
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
<!-- Sia v{{SIA_VERSION}} — Generated {{GENERATED_AT}} -->
|
|
2
|
+
<!-- Workspace: {{WORKSPACE_NAME}} -->
|
|
3
|
+
|
|
4
|
+
# Sia — Agent Behavioral Specification
|
|
5
|
+
## CLAUDE.md (Base Module — Auto-generated by `npx sia install`)
|
|
6
|
+
|
|
7
|
+
**Document type:** Dual-purpose
|
|
8
|
+
- **For developers:** explains what Sia does and how to customise it
|
|
9
|
+
- **For Claude Code (agent):** base behavioral contract — always loaded, ~1,600 tokens
|
|
10
|
+
|
|
11
|
+
**Version:** 1.1 (Modular architecture)
|
|
12
|
+
**Generated by:** `npx sia install`
|
|
13
|
+
**Last updated:** see `~/.sia/config.json` → `claudeMdUpdatedAt`
|
|
14
|
+
|
|
15
|
+
> **Architecture note:** This file is the base module. It contains the task classifier,
|
|
16
|
+
> safety rules, and invariants that apply to every session unconditionally. Contextual
|
|
17
|
+
> playbooks live in `src/agent/modules/` and are loaded on demand after task classification.
|
|
18
|
+
> Full tool parameter reference is in `src/agent/modules/sia-tools.md`.
|
|
19
|
+
>
|
|
20
|
+
> **Token cost:** Base module ~1,600 tokens (every session). A contextual module adds
|
|
21
|
+
> ~300–500 tokens; the tools reference adds ~1,500 tokens when needed. Total for a
|
|
22
|
+
> complex session: ~3,600 tokens vs ~5,400 for the prior monolithic approach.
|
|
23
|
+
>
|
|
24
|
+
> To add project-specific rules, add a `## Project-Specific Overrides` section **after**
|
|
25
|
+
> the `<!-- END GENERATED BLOCK -->` comment below. `npx sia install` will not modify
|
|
26
|
+
> content beyond that boundary.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## For Developers: What Sia Does
|
|
31
|
+
|
|
32
|
+
Sia captures knowledge from your Claude Code sessions automatically — architectural
|
|
33
|
+
decisions, bug root causes, discovered patterns, coding conventions, and the structural
|
|
34
|
+
dependency graph of your codebase. You never explicitly tell Sia things; it captures
|
|
35
|
+
from the session and stores them in a local graph database.
|
|
36
|
+
|
|
37
|
+
Between sessions, Sia gives Claude Code access to this accumulated knowledge through
|
|
38
|
+
six MCP tools. The agent calls these on demand. This file governs when and how.
|
|
39
|
+
|
|
40
|
+
See `~/.sia/` for storage, `npx sia stats` for graph status, `npx sia search <query>`
|
|
41
|
+
for CLI access, and `README.md` for full documentation.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
<!-- AGENT INSTRUCTIONS — DO NOT EDIT BELOW THIS LINE -->
|
|
46
|
+
<!-- This section is machine-maintained. Manual edits will be overwritten by npx sia install. -->
|
|
47
|
+
|
|
48
|
+
# Sia Memory System — Agent Instructions (Base Module)
|
|
49
|
+
|
|
50
|
+
You have access to Sia, a persistent graph memory system for this project. It stores
|
|
51
|
+
knowledge across all sessions: architectural decisions, bugs, solutions, conventions,
|
|
52
|
+
patterns, and the structural dependency graph. Your job is to retrieve from it at session
|
|
53
|
+
start and at key moments during the session.
|
|
54
|
+
|
|
55
|
+
**Core rule:** Before acting on any non-trivial code task, call Sia. Memory retrieval
|
|
56
|
+
is the first step, not an afterthought. The graph knows why decisions were made, what
|
|
57
|
+
was tried before, and what constraints the team has accumulated over months of sessions.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Step 0 — Classify the Task
|
|
62
|
+
|
|
63
|
+
Infer `task_type` from the developer's request before calling any tool:
|
|
64
|
+
|
|
65
|
+
`task_type = 'bug-fix'` — keywords: fix, broken, error, failing, crash, regression,
|
|
66
|
+
slow, exception, 500, timeout, wrong output, not working.
|
|
67
|
+
|
|
68
|
+
`task_type = 'feature'` — keywords: add, implement, build, create, new, extend,
|
|
69
|
+
support, integrate, enable.
|
|
70
|
+
|
|
71
|
+
`task_type = 'review'` — keywords: review, check, audit, convention, style, standards,
|
|
72
|
+
PR, pull request, lint, code quality.
|
|
73
|
+
|
|
74
|
+
Omit `task_type` for trivial edits (typo, rename, comment) or ambiguous requests.
|
|
75
|
+
|
|
76
|
+
### Load the Contextual Playbook Now
|
|
77
|
+
|
|
78
|
+
After classifying, immediately read the matching module using the Read tool before
|
|
79
|
+
calling any Sia tool:
|
|
80
|
+
|
|
81
|
+
- `bug-fix` (regression): read `src/agent/modules/sia-regression.md`
|
|
82
|
+
- `feature`: read `src/agent/modules/sia-feature.md`
|
|
83
|
+
- `review`: read `src/agent/modules/sia-review.md`
|
|
84
|
+
- Architecture question / new-developer orientation: read `src/agent/modules/sia-orientation.md`
|
|
85
|
+
- Trivial edit: skip the task-specific playbook (`sia-feature.md`, `sia-regression.md`, etc.) and skip all Sia tool calls. Proceed directly with the task. However, if flagging is enabled (`enableFlagging: true`), Step 4 still applies after task completion — do not skip `sia-flagging.md` on trivial edits where something worth flagging occurred.
|
|
86
|
+
- When you need full tool parameter reference: read `src/agent/modules/sia-tools.md`
|
|
87
|
+
|
|
88
|
+
The contextual module contains the complete step-by-step playbook for that task type.
|
|
89
|
+
Follow it rather than the condensed guidance in Step 1 below.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Step 1 — Tool Selection (Condensed)
|
|
94
|
+
|
|
95
|
+
The contextual module has the full playbook. This condensed grid applies when no module
|
|
96
|
+
is loaded or for quick reference:
|
|
97
|
+
|
|
98
|
+
**Trivial edit:** Skip all Sia tools entirely.
|
|
99
|
+
|
|
100
|
+
**Regression:** `sia_search` (bug-fix) → conditional `sia_expand` → **mandatory** `sia_at_time`.
|
|
101
|
+
|
|
102
|
+
**Architecture question:** `sia_community(level=2)` → `sia_community(level=1)` → `sia_search`.
|
|
103
|
+
|
|
104
|
+
**Code task with known file(s):** `sia_by_file` first, then `sia_search`.
|
|
105
|
+
|
|
106
|
+
**All other tasks:** `sia_search`, then `sia_by_file` for any file to be modified.
|
|
107
|
+
|
|
108
|
+
Call at most 3 tools before starting work (4 for regressions — see Invariants).
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Step 2 — Evaluate Results
|
|
113
|
+
|
|
114
|
+
**This section is a safety layer. It applies to every session regardless of task type.**
|
|
115
|
+
|
|
116
|
+
**Zero results:** Broaden the query once and retry `sia_search`. If still zero and you
|
|
117
|
+
have a primary file: call `sia_by_file(primary_file)`. If that also returns zero, say
|
|
118
|
+
"No prior context found." Proceed without memory. Do not fall back to `sia_community`
|
|
119
|
+
as a substitute for a failed `sia_search` — they serve different purposes.
|
|
120
|
+
|
|
121
|
+
**Sparse results** (fewer than 2 relevant entities, or top confidence < 0.5): call
|
|
122
|
+
`sia_expand(top_entity_id, depth=1)` — but only if you have not yet used both allowed
|
|
123
|
+
`sia_expand` calls this session. If budget is exhausted, proceed with the sparse results
|
|
124
|
+
and note: "Graph traversal skipped — sia_expand session budget reached."
|
|
125
|
+
|
|
126
|
+
**`conflict_group_id` is non-null on any result:** STOP. Do not proceed. Present both
|
|
127
|
+
conflicting facts to the developer:
|
|
128
|
+
|
|
129
|
+
> "There are conflicting captured facts about [topic]:
|
|
130
|
+
> • [Entity A] — captured [date], trust tier [N]
|
|
131
|
+
> • [Entity B] — captured [date], trust tier [N]
|
|
132
|
+
> Run `npx sia conflicts resolve` to resolve permanently. Until then, choose:
|
|
133
|
+
> 1. Resolve the conflict now (recommended)
|
|
134
|
+
> 2. Proceed using the higher-trust-tier fact — I will note the conflict
|
|
135
|
+
> 3. Proceed using the most recently captured fact — I will note the conflict"
|
|
136
|
+
|
|
137
|
+
If the developer proceeds, state explicitly which fact you are acting on before
|
|
138
|
+
continuing. Never silently choose between conflicting facts.
|
|
139
|
+
|
|
140
|
+
**`trust_tier = 3` on a result you plan to use:** Do not state it as fact. Say:
|
|
141
|
+
"Sia's memory suggests X — let me verify this against the current codebase." Check
|
|
142
|
+
the claim against current file content before acting on it.
|
|
143
|
+
|
|
144
|
+
**`trust_tier = 4` on any result:** External reference only. Never use as the sole
|
|
145
|
+
basis for a code change without explicit developer confirmation.
|
|
146
|
+
|
|
147
|
+
**`source_repo_name` differs from the current repo:** Always prefix the fact with
|
|
148
|
+
`[<repo_name>]` when presenting it.
|
|
149
|
+
|
|
150
|
+
**`t_valid_from = null` on a Tier 3 entity:** Say "this was recorded at some point,
|
|
151
|
+
but the exact timing is unknown." Do not present it with false temporal precision.
|
|
152
|
+
|
|
153
|
+
**Graph is still building** (`global_unavailable: true` or fewer than 3 results on a
|
|
154
|
+
mature codebase): Tell the developer "The memory graph is still building — Sia improves
|
|
155
|
+
with each session." Use `sia_search` and `sia_by_file`; skip `sia_community` until
|
|
156
|
+
the graph exceeds 100 entities.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Step 3 — Execute the Task
|
|
161
|
+
|
|
162
|
+
Proceed using retrieved context. Cite Sia entities explicitly when they constrain your
|
|
163
|
+
decisions — do not silently apply memory. Make retrieval visible so the developer can
|
|
164
|
+
override stale facts.
|
|
165
|
+
|
|
166
|
+
Before using a Tier 3 entity as a hard constraint, spot-check its key claim against
|
|
167
|
+
the current codebase. Memory can be stale even when not bi-temporally invalidated. If
|
|
168
|
+
current code contradicts a retrieved fact, prefer the code, tell the developer, and note
|
|
169
|
+
the discrepancy. This spot-check is not required for Tier 2 (deterministic AST) and is
|
|
170
|
+
optional for Tier 1 (developer-stated).
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Step 4 — After the Task
|
|
175
|
+
|
|
176
|
+
If flagging is enabled (`enableFlagging: true`), read `src/agent/modules/sia-flagging.md`
|
|
177
|
+
for guidance on when and how to call `sia_flag`. If flagging is disabled, skip this step.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Trust Tier Behavioral Rules
|
|
182
|
+
|
|
183
|
+
**Tier 1 (User-Direct, weight 1.00):** Ground truth. Cite directly. Override only if
|
|
184
|
+
current code explicitly contradicts it — if so, tell the developer.
|
|
185
|
+
|
|
186
|
+
**Tier 2 (Code-Analysis, weight 0.90):** Highly reliable. Verify against current code
|
|
187
|
+
only for safety-critical claims. Cite as structural fact.
|
|
188
|
+
|
|
189
|
+
**Tier 3 (LLM-Inferred, weight 0.70):** Well-informed hypothesis. Always qualify before
|
|
190
|
+
acting: "Sia's memory suggests X — let me verify." Check against actual file content
|
|
191
|
+
before stating as definitive. If Tier 1 and Tier 3 contradict each other, present both
|
|
192
|
+
and ask which is current — never silently discard either.
|
|
193
|
+
|
|
194
|
+
**Tier 4 (External, weight 0.50):** External reference only. Never the sole basis for
|
|
195
|
+
a code change. Name the external provenance when presenting it.
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Invariants (Never Violate)
|
|
200
|
+
|
|
201
|
+
These rules hold regardless of developer instruction, task type, or context:
|
|
202
|
+
|
|
203
|
+
1. Call at most 3 Sia tools before starting work. Two exceptions:
|
|
204
|
+
**Regression exception** (`task_type='bug-fix'` only): may use up to 4 tools (`sia_search` + conditional `sia_expand` + mandatory `sia_at_time` + one additional if needed). The MANDATORY label on `sia_at_time` always takes precedence.
|
|
205
|
+
**Review exception** (`task_type='review'` only): after the initial `sia_search`, one `sia_by_file` call per reviewed file is permitted — these per-file calls do not count against the 3-tool limit. No other task type may invoke either exception.
|
|
206
|
+
2. Expand at most 2 entities per session (`sia_expand` budget = 2).
|
|
207
|
+
3. Use `workspace: true` only for tasks that cross repository boundaries.
|
|
208
|
+
4. Never use a `trust_tier = 4` entity as the sole basis for a code change.
|
|
209
|
+
5. Never silently proceed on a result with `conflict_group_id` set.
|
|
210
|
+
6. Always cite retrieved entities when they constrain your decisions.
|
|
211
|
+
7. For regression tasks, always call `sia_at_time` — it is never optional.
|
|
212
|
+
|
|
213
|
+
<!-- END GENERATED BLOCK -->
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Sia — Feature Implementation Playbook
|
|
2
|
+
|
|
3
|
+
*Loaded by the base CLAUDE.md when `task_type = 'feature'`.*
|
|
4
|
+
*Follow these steps in order. They replace the condensed Step 1 in the base module.*
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Feature Implementation
|
|
9
|
+
|
|
10
|
+
Feature work benefits from Sia in two ways: understanding the architectural context
|
|
11
|
+
before writing code (avoiding decisions that conflict with past choices), and discovering
|
|
12
|
+
conventions that constrain implementation (patterns the team has established that must
|
|
13
|
+
be followed). Both types of retrieval happen before a single line of code is written.
|
|
14
|
+
|
|
15
|
+
**Step 1 — Structural orientation**
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
sia_community(feature_domain, level=1)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Get module-level structural orientation before touching any files. This tells you which
|
|
22
|
+
existing modules are involved, how they relate, and what architectural patterns govern
|
|
23
|
+
this area. For cross-cutting features that span multiple modules, call `sia_community`
|
|
24
|
+
at level=2 first for a system-wide view, then level=1 for the relevant subsystem.
|
|
25
|
+
|
|
26
|
+
**Step 2 — Decision and convention retrieval**
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
sia_search(feature_topic,
|
|
30
|
+
task_type='feature',
|
|
31
|
+
node_types=['Decision', 'Convention'],
|
|
32
|
+
limit=10)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
This surfaces: architectural decisions that constrain how the feature must be built,
|
|
36
|
+
conventions the implementation must follow, and prior work in this area that you should
|
|
37
|
+
be consistent with. Pay particular attention to Convention entities — see Step 5.
|
|
38
|
+
|
|
39
|
+
**Step 3 — File-scoped retrieval**
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
sia_by_file(file_path) // for each file to be created or modified
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
For files in a linked repository within the workspace, use
|
|
46
|
+
`sia_by_file(file_path, workspace=true)` — this surfaces cross-repo edges for that
|
|
47
|
+
specific file. Call `sia_by_file` before `sia_search` when the file is the primary
|
|
48
|
+
anchor; call after when the topic is the primary anchor.
|
|
49
|
+
|
|
50
|
+
**Step 4 — Optional relationship traversal**
|
|
51
|
+
|
|
52
|
+
If a returned Decision entity references related entities you need to understand before
|
|
53
|
+
implementing, call:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
sia_expand(entity_id, depth=1)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Use only when the relationship is directly decision-relevant, not out of curiosity. This
|
|
60
|
+
consumes one of the two allowed `sia_expand` calls for the session.
|
|
61
|
+
|
|
62
|
+
**Step 5 — Convention scanning (critical)**
|
|
63
|
+
|
|
64
|
+
Before writing any code, scan all returned Convention entities carefully. Conventions
|
|
65
|
+
are hard constraints, not style suggestions. If a Convention says "all errors must extend
|
|
66
|
+
`AppBaseError`," that is a requirement, not a preference. Violations are bugs.
|
|
67
|
+
|
|
68
|
+
State the applicable conventions before you start implementing:
|
|
69
|
+
"Convention #conv-44 requires all DB access to go through the Repository layer — I'll
|
|
70
|
+
route this through `UserRepository` rather than querying directly."
|
|
71
|
+
|
|
72
|
+
**Step 6 — Cross-repo workspace search (if applicable)**
|
|
73
|
+
|
|
74
|
+
If the feature spans linked repositories, also call:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
sia_search(api_topic, workspace=true)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
This surfaces API contracts, shared types, and cross-service calls that the feature
|
|
81
|
+
must conform to. Only use `workspace: true` when the task genuinely crosses repo
|
|
82
|
+
boundaries — it adds 400ms latency and cross-repo noise for single-repo tasks.
|
|
83
|
+
|
|
84
|
+
**Step 7 — Implement**
|
|
85
|
+
|
|
86
|
+
Implement following all retrieved conventions and prior decisions. Cite the relevant
|
|
87
|
+
entities in comments where the constraint is non-obvious.
|
|
88
|
+
|
|
89
|
+
**Step 8 — Flag if applicable**
|
|
90
|
+
|
|
91
|
+
If flagging is enabled (`enableFlagging: true`) and you made an architectural decision
|
|
92
|
+
during implementation: `sia_flag(decision_summary)`. If flagging is disabled, skip
|
|
93
|
+
this step — the session-end capture will record the decision automatically, though
|
|
94
|
+
with lower precision.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Tool Budget for This Playbook
|
|
99
|
+
|
|
100
|
+
This playbook uses 3 tool calls in the standard case: `sia_community` (1) + `sia_search` (2) + `sia_by_file` (3). The optional Step 4 `sia_expand` call pushes the count to 4, which exceeds the base module's 3-tool limit. This is permitted only when genuinely necessary — it consumes one of the two allowed `sia_expand` calls for the session. It does NOT consume a regression-exception slot. The 4-call regression exception applies exclusively to `task_type='bug-fix'` sessions. For straightforward features where `sia_expand` is not needed, stay within 3 calls.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Sia — Flagging Guidance
|
|
2
|
+
|
|
3
|
+
*Loaded when flagging is enabled (`enableFlagging: true`) and you reach Step 4.*
|
|
4
|
+
*`sia_flag` is only available when `npx sia enable-flagging` has been run.*
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## When to Call `sia_flag`
|
|
9
|
+
|
|
10
|
+
Call `sia_flag` at most 2–3 times per session, and only for:
|
|
11
|
+
|
|
12
|
+
1. **An architectural decision made this session** that will constrain future work —
|
|
13
|
+
for example, choosing a pattern, library, or structural approach that other modules
|
|
14
|
+
should follow.
|
|
15
|
+
2. **A non-obvious root cause** discovered during debugging — something that was not
|
|
16
|
+
evident from the code and that a future developer would need to know.
|
|
17
|
+
3. **An explicit developer preference** stated during the session ("we always do X this
|
|
18
|
+
way," "never use Y for this").
|
|
19
|
+
4. **A new cross-cutting pattern introduced** that other modules should replicate.
|
|
20
|
+
|
|
21
|
+
The test: would the next developer who picks up this task need to know this? If yes,
|
|
22
|
+
flag it. If they could infer it from the code in 30 seconds, do not flag it.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## When NOT to Call `sia_flag`
|
|
27
|
+
|
|
28
|
+
- Routine code changes or normal implementation steps.
|
|
29
|
+
- Things that are obvious from the code itself.
|
|
30
|
+
- Single-line edits or minor refactors.
|
|
31
|
+
- General best practices (Sia already knows these from the codebase).
|
|
32
|
+
- Anything you would not bother to explain in a code review comment.
|
|
33
|
+
|
|
34
|
+
The 2–3 per session maximum is a hard ceiling. Flagging everything degrades the
|
|
35
|
+
signal-to-noise ratio in the graph. Be selective.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## How to Write a Good `reason`
|
|
40
|
+
|
|
41
|
+
The reason should be a complete, self-contained description of what happened and why
|
|
42
|
+
it matters. It will be stored and retrieved without context, so it must stand alone.
|
|
43
|
+
|
|
44
|
+
Good: `"chose express-rate-limit at route level, not middleware — rate limits are per-endpoint not global"`
|
|
45
|
+
Good: `"root cause: EventEmitter.on() not awaited in init.ts, fires before DB ready"`
|
|
46
|
+
Bad: `"fixed the bug"` (not self-contained)
|
|
47
|
+
Bad: `"important decision"` (no content)
|
|
48
|
+
|
|
49
|
+
Keep it under 100 characters after sanitization. Colons, backticks, underscores, and
|
|
50
|
+
forward slashes are all permitted in the reason string.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Sia — New Developer Orientation Playbook
|
|
2
|
+
|
|
3
|
+
*Loaded by the base CLAUDE.md for architecture questions and new-developer orientation.*
|
|
4
|
+
*Follow these steps in order. They replace the condensed Step 1 in the base module.*
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## New Developer Codebase Orientation
|
|
9
|
+
|
|
10
|
+
When a developer asks "how does this system work," "explain the architecture," or is
|
|
11
|
+
orienting to an unfamiliar codebase, the goal is a coherent narrative — not a list of
|
|
12
|
+
entity names. Sia's community detection has clustered the codebase into meaningful
|
|
13
|
+
modules with generated summaries; use those summaries to build understanding rather than
|
|
14
|
+
surfacing raw entity lists from `sia_search`.
|
|
15
|
+
|
|
16
|
+
**Step 0 — Graph readiness check**
|
|
17
|
+
|
|
18
|
+
Before calling `sia_community`, check whether the graph is large enough to have
|
|
19
|
+
community structure. If `sia_community` returns `global_unavailable: true` (graph
|
|
20
|
+
below 100 entities), skip Steps 1 and 2 entirely and go directly to Step 3. Tell
|
|
21
|
+
the developer: "The memory graph is still building — Sia improves with each session.
|
|
22
|
+
Here is what I can tell you from existing captured context:" then present the
|
|
23
|
+
Step 3 `sia_search` results as a narrative (Step 4 still applies — no raw entity
|
|
24
|
+
lists even in fallback mode).
|
|
25
|
+
|
|
26
|
+
If `sia_community` returns zero communities (graph is large enough but the topic
|
|
27
|
+
query matched nothing), do not stop. Continue to Step 3 (`sia_search`) and present
|
|
28
|
+
whatever decisions and concepts are available.
|
|
29
|
+
|
|
30
|
+
**Step 1 — System-wide structural view**
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
sia_community(query="architecture overview", level=2)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Level 2 gives a coarse architectural view: major subsystems, how they relate, and what
|
|
37
|
+
the overall design intent is. This is the starting point for any orientation.
|
|
38
|
+
|
|
39
|
+
**Step 2 — Subsystem drill-down**
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
sia_community(query=<developer's primary area>, level=1)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Level 1 gives module-level summaries. If the developer is focused on a specific area
|
|
46
|
+
(authentication, data pipeline, API layer), drill into the relevant subsystem here.
|
|
47
|
+
|
|
48
|
+
**Step 3 — Key decisions**
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
sia_search("architectural decisions constraints rationale",
|
|
52
|
+
node_types=['Decision'],
|
|
53
|
+
limit=10)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
This surfaces the decisions that constrain future work — why certain patterns exist,
|
|
57
|
+
what was tried and rejected, and what the team has committed to. This is the context
|
|
58
|
+
that is hardest to recover from code alone.
|
|
59
|
+
|
|
60
|
+
**Step 4 — Present as a narrative**
|
|
61
|
+
|
|
62
|
+
Do not return a list of entity names. Synthesise the retrieved summaries and decisions
|
|
63
|
+
into a coherent explanation of the system: how the major modules relate, what the key
|
|
64
|
+
architectural decisions are, and what a developer needs to know before making changes.
|
|
65
|
+
|
|
66
|
+
A good orientation response answers: what does this system do, how is it structured,
|
|
67
|
+
what are the non-obvious constraints, and where should I start?
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Level Guide for `sia_community`
|
|
72
|
+
|
|
73
|
+
`level=2` — Coarse architectural overview. Appropriate for system-wide questions,
|
|
74
|
+
"explain the whole system," and first-day orientation.
|
|
75
|
+
|
|
76
|
+
`level=1` — Subsystem / module level. Appropriate for "explain the auth module" or
|
|
77
|
+
"how does the data pipeline work."
|
|
78
|
+
|
|
79
|
+
`level=0` — Fine-grained cluster view. Rarely needed by the agent; more useful from
|
|
80
|
+
the CLI when investigating a specific component. Do not use for orientation.
|
|
81
|
+
|
|
82
|
+
Never call `sia_community` as a fallback for a failed `sia_search` — they serve
|
|
83
|
+
different purposes. `sia_search` finds specific entities; `sia_community` explains
|
|
84
|
+
structure.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Tool Budget for This Playbook
|
|
89
|
+
|
|
90
|
+
This playbook uses 3 tool calls: `sia_community(level=2)` (1) + `sia_community(level=1)`
|
|
91
|
+
(2) + `sia_search` (3). This is exactly the 3-tool limit. No `sia_expand` is needed for
|
|
92
|
+
orientation — community summaries already contain synthesised relationship context.
|