@gcunharodrigues/wrxn 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -0
  3. package/bin/wrxn.cjs +342 -0
  4. package/lib/connect.cjs +216 -0
  5. package/lib/executor.cjs +238 -0
  6. package/lib/install.cjs +105 -0
  7. package/lib/manifest.cjs +67 -0
  8. package/lib/migrate.cjs +93 -0
  9. package/lib/onboard.cjs +84 -0
  10. package/lib/semver.cjs +14 -0
  11. package/lib/update.cjs +91 -0
  12. package/lib/worktree.cjs +217 -0
  13. package/manifest.json +451 -0
  14. package/migrations/README.md +21 -0
  15. package/package.json +23 -0
  16. package/payload/.claude/constitution.local.md +13 -0
  17. package/payload/.claude/constitution.md +28 -0
  18. package/payload/.claude/hooks/code-intel-push.cjs +108 -0
  19. package/payload/.claude/hooks/enforce-managed-guard.cjs +68 -0
  20. package/payload/.claude/hooks/enforce-managed-precommit.cjs +74 -0
  21. package/payload/.claude/hooks/enforce-push-authority.cjs +51 -0
  22. package/payload/.claude/hooks/enforce-review-marker.cjs +62 -0
  23. package/payload/.claude/hooks/enforce-tests-on-push.cjs +40 -0
  24. package/payload/.claude/hooks/recall-surface.cjs +127 -0
  25. package/payload/.claude/hooks/reference-detect.cjs +83 -0
  26. package/payload/.claude/hooks/session-end.cjs +132 -0
  27. package/payload/.claude/hooks/session-history.cjs +76 -0
  28. package/payload/.claude/hooks/session-start.cjs +117 -0
  29. package/payload/.claude/hooks/synapse-engine.cjs +351 -0
  30. package/payload/.claude/hooks/wiki-lint.cjs +104 -0
  31. package/payload/.claude/settings.json +60 -0
  32. package/payload/.claude/skills/audit/SKILL.md +23 -0
  33. package/payload/.claude/skills/diagnose/SKILL.md +117 -0
  34. package/payload/.claude/skills/diagnose/scripts/hitl-loop.template.sh +41 -0
  35. package/payload/.claude/skills/grill-me/SKILL.md +10 -0
  36. package/payload/.claude/skills/grill-with-docs/ADR-FORMAT.md +47 -0
  37. package/payload/.claude/skills/grill-with-docs/CONTEXT-FORMAT.md +60 -0
  38. package/payload/.claude/skills/grill-with-docs/SKILL.md +88 -0
  39. package/payload/.claude/skills/handoff/SKILL.md +19 -0
  40. package/payload/.claude/skills/improve-codebase-architecture/DEEPENING.md +37 -0
  41. package/payload/.claude/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
  42. package/payload/.claude/skills/improve-codebase-architecture/INTERFACE-DESIGN.md +44 -0
  43. package/payload/.claude/skills/improve-codebase-architecture/LANGUAGE.md +53 -0
  44. package/payload/.claude/skills/improve-codebase-architecture/SKILL.md +81 -0
  45. package/payload/.claude/skills/level-up/SKILL.md +28 -0
  46. package/payload/.claude/skills/memory/SKILL.md +79 -0
  47. package/payload/.claude/skills/onboard/SKILL.md +43 -0
  48. package/payload/.claude/skills/prototype/LOGIC.md +79 -0
  49. package/payload/.claude/skills/prototype/SKILL.md +30 -0
  50. package/payload/.claude/skills/prototype/UI.md +112 -0
  51. package/payload/.claude/skills/qa-walk/SKILL.md +227 -0
  52. package/payload/.claude/skills/qa-walk/references/cli-mode.md +28 -0
  53. package/payload/.claude/skills/qa-walk/references/finding-issue-template.md +48 -0
  54. package/payload/.claude/skills/qa-walk/references/walk-report-template.md +56 -0
  55. package/payload/.claude/skills/qa-walk/references/web-mode.md +112 -0
  56. package/payload/.claude/skills/setup-matt-pocock-skills/SKILL.md +121 -0
  57. package/payload/.claude/skills/setup-matt-pocock-skills/domain.md +51 -0
  58. package/payload/.claude/skills/setup-matt-pocock-skills/issue-tracker-github.md +22 -0
  59. package/payload/.claude/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +23 -0
  60. package/payload/.claude/skills/setup-matt-pocock-skills/issue-tracker-local.md +19 -0
  61. package/payload/.claude/skills/setup-matt-pocock-skills/triage-labels.md +15 -0
  62. package/payload/.claude/skills/skill-creator/LICENSE.txt +202 -0
  63. package/payload/.claude/skills/skill-creator/SKILL.md +209 -0
  64. package/payload/.claude/skills/skill-creator/scripts/init_skill.py +303 -0
  65. package/payload/.claude/skills/skill-creator/scripts/package_skill.py +110 -0
  66. package/payload/.claude/skills/skill-creator/scripts/quick_validate.py +65 -0
  67. package/payload/.claude/skills/synapse/SKILL.md +132 -0
  68. package/payload/.claude/skills/synapse/assets/README.md +50 -0
  69. package/payload/.claude/skills/synapse/references/brackets.md +100 -0
  70. package/payload/.claude/skills/synapse/references/commands.md +118 -0
  71. package/payload/.claude/skills/synapse/references/domains.md +126 -0
  72. package/payload/.claude/skills/synapse/references/layers.md +186 -0
  73. package/payload/.claude/skills/synapse/references/manifest.md +142 -0
  74. package/payload/.claude/skills/tdd/SKILL.md +22 -0
  75. package/payload/.claude/skills/tech-search/SKILL.md +431 -0
  76. package/payload/.claude/skills/tech-search/prompts/page-extract.md +133 -0
  77. package/payload/.claude/skills/to-issues/SKILL.md +83 -0
  78. package/payload/.claude/skills/to-prd/SKILL.md +74 -0
  79. package/payload/.claude/skills/triage/AGENT-BRIEF.md +168 -0
  80. package/payload/.claude/skills/triage/OUT-OF-SCOPE.md +101 -0
  81. package/payload/.claude/skills/triage/SKILL.md +103 -0
  82. package/payload/.claude/skills/write-a-skill/SKILL.md +117 -0
  83. package/payload/.recon.json +3 -0
  84. package/payload/.synapse/global +6 -0
  85. package/payload/.synapse/manifest +38 -0
  86. package/payload/.synapse/pipeline +6 -0
  87. package/payload/.synapse/routing +8 -0
  88. package/payload/.wrxn/continuity/.gitkeep +0 -0
  89. package/payload/.wrxn/history/.gitkeep +0 -0
  90. package/payload/.wrxn/wiki/.gitkeep +0 -0
  91. package/payload/.wrxn/wiki/concepts/.gitkeep +0 -0
  92. package/payload/.wrxn/wiki/decisions/.gitkeep +0 -0
  93. package/payload/.wrxn/wiki/gotchas/.gitkeep +0 -0
  94. package/payload/.wrxn/wiki/sessions/.gitkeep +0 -0
  95. package/payload/.wrxn/wiki.cjs +164 -0
  96. package/payload/aios-intake.md +32 -0
  97. package/payload/connections.md +15 -0
  98. package/payload/decisions/log.md +18 -0
  99. package/payload/docs/agents/domain.md +38 -0
  100. package/payload/docs/agents/issue-tracker.md +25 -0
  101. package/payload/docs/agents/triage-labels.md +15 -0
  102. package/payload/docs/workspace/operator-layer.md +14 -0
@@ -0,0 +1,100 @@
1
+ # SYNAPSE Context Brackets Reference
2
+
3
+ ## Overview
4
+
5
+ Context brackets control how much content SYNAPSE injects per prompt based on how much context window remains. As the conversation progresses and context fills up, SYNAPSE adapts by changing which layers are active and how many tokens it injects.
6
+
7
+ The bracket system is implemented in `.aiox-core/core/synapse/context/context-tracker.js`.
8
+
9
+ ## The 4 Brackets
10
+
11
+ | Bracket | Context Remaining | Token Budget | Behavior |
12
+ |---------|-------------------|-------------|----------|
13
+ | **FRESH** | 60-100% | ~800 tokens | Lean injection — essentials only |
14
+ | **MODERATE** | 40-60% | ~1500 tokens | Standard injection — all layers active |
15
+ | **DEPLETED** | 25-40% | ~2000 tokens | Reinforcement — reinforce critical rules, memory hints enabled |
16
+ | **CRITICAL** | <25% | ~2500 tokens | Handoff warning — recommend session handoff, document state |
17
+
18
+ ## How Brackets Are Calculated
19
+
20
+ The context tracker estimates remaining context using:
21
+
22
+ ```
23
+ contextPercent = 100 - ((promptCount * avgTokensPerPrompt) / maxContext * 100)
24
+ ```
25
+
26
+ **Default values:**
27
+ - `avgTokensPerPrompt`: 1500
28
+ - `maxContext`: 200000 (Claude's context window)
29
+
30
+ **Bracket assignment:**
31
+ - `contextPercent >= 60` → FRESH
32
+ - `contextPercent >= 40` → MODERATE
33
+ - `contextPercent >= 25` → DEPLETED
34
+ - `contextPercent < 25` → CRITICAL
35
+
36
+ Invalid or NaN input defaults to CRITICAL (fail-safe).
37
+
38
+ ## Layer Activation per Bracket
39
+
40
+ | Bracket | Active Layers | Memory Hints | Handoff Warning |
41
+ |---------|---------------|-------------|-----------------|
42
+ | **FRESH** | L0, L1, L2, L7 | No | No |
43
+ | **MODERATE** | L0-L7 (all) | No | No |
44
+ | **DEPLETED** | L0-L7 (all) | Yes | No |
45
+ | **CRITICAL** | L0-L7 (all) | Yes | Yes |
46
+
47
+ **Key behavior:**
48
+ - **FRESH**: Only core layers (Constitution, Global, Agent, Star-Commands) — saves tokens early
49
+ - **MODERATE**: Full layer stack activated — normal operation
50
+ - **DEPLETED**: Memory hints from MIS enabled (when pro available) to reinforce context
51
+ - **CRITICAL**: Handoff warning injected, recommending session continuation in new window
52
+
53
+ ## Bracket-Specific Rules
54
+
55
+ The `.synapse/context` domain file contains rules that vary by bracket:
56
+
57
+ ### FRESH Rules
58
+ - Minimize injected rules to essentials only
59
+ - Avoid redundant context — agent has full conversation history
60
+ - Full layer stack available but lean injection
61
+
62
+ ### MODERATE Rules
63
+ - All layers active at normal priority
64
+ - Monitor token usage — consider summarizing long outputs
65
+ - Prefer concise code examples over verbose explanations
66
+
67
+ ### DEPLETED Rules
68
+ - Reinforce critical rules and constraints
69
+ - Prefer concise responses to save tokens
70
+ - Skip optional layers (L6 keyword domains) to conserve
71
+ - Summarize progress before each action
72
+
73
+ ### CRITICAL Rules
74
+ - Recommend session handoff
75
+ - Summarize current state for new session continuation
76
+ - Only inject L0 Constitution and L1 Global rules — skip other layers
77
+ - Document incomplete work in story file
78
+
79
+ ## Token Budget Enforcement
80
+
81
+ The output formatter (`.aiox-core/core/synapse/output/formatter.js`) enforces token budgets:
82
+
83
+ 1. Each bracket has a max token budget (800 / 1500 / 2000 / 2500)
84
+ 2. Sections are rendered in priority order (CONSTITUTION first, SUMMARY last)
85
+ 3. When budget is exceeded, sections are truncated from the end (lowest priority first)
86
+
87
+ **Truncation order** (last removed first):
88
+ ```
89
+ SUMMARY → KEYWORD → SQUAD → TASK → WORKFLOW → AGENT → CONSTITUTION
90
+ ```
91
+
92
+ Constitution (L0) is never truncated.
93
+
94
+ ## Source Files
95
+
96
+ | File | Purpose |
97
+ |------|---------|
98
+ | `.aiox-core/core/synapse/context/context-tracker.js` | Bracket calculation, token budgets, layer configs |
99
+ | `.synapse/context` | Bracket-specific context rules (L1) |
100
+ | `.aiox-core/core/synapse/output/formatter.js` | Token budget enforcement + truncation |
@@ -0,0 +1,118 @@
1
+ # SYNAPSE Commands Reference
2
+
3
+ ## Overview
4
+
5
+ SYNAPSE provides three categories of commands:
6
+ 1. **Mode star-commands** — Switch response behavior (`*brief`, `*dev`, etc.)
7
+ 2. **`*synapse` sub-commands** — Query and manage engine state
8
+ 3. **CRUD operations** — Create, modify, and manage domains and rules
9
+
10
+ ## Mode Star-Commands (L7)
11
+
12
+ These commands switch the response mode for the current session. They are detected by L7 (Star-Command processor) and inject mode-specific rules.
13
+
14
+ | Command | Behavior |
15
+ |---------|----------|
16
+ | `*brief` | Bullet points only, max 5 items, no code blocks unless requested, skip preamble |
17
+ | `*dev` | Code over explanation, minimal changes, follow existing patterns, skip docs unless needed |
18
+ | `*review` | Check code quality and patterns, identify bugs/security issues, suggest improvements with rationale |
19
+ | `*plan` | Outline approach before implementation, list files to modify, identify risks, estimate complexity |
20
+ | `*discuss` | Explore trade-offs and alternatives, ask clarifying questions, present pros/cons, recommend with reasoning |
21
+ | `*debug` | Analyze error messages and stack traces, check common failure patterns, suggest targeted fixes |
22
+ | `*explain` | Explain in teaching detail, use analogies, show examples with code, build from basics to advanced |
23
+
24
+ **Usage:** Type the command anywhere in your prompt. The mode persists for that response.
25
+
26
+ **Source:** `.synapse/commands` (KEY=VALUE format, `COMMANDS_RULE_{MODE}_{INDEX}`)
27
+
28
+ ## `*synapse` Sub-Commands
29
+
30
+ These commands query or control the SYNAPSE engine state.
31
+
32
+ | Command | What it does |
33
+ |---------|-------------|
34
+ | `*synapse help` | Show available synapse commands and their descriptions |
35
+ | `*synapse status` | Display current state: active domains, layers, session info |
36
+ | `*synapse debug` | Show detailed debug info: manifest parse results, domain load times, rule counts |
37
+ | `*synapse domains` | List all registered domains with their state and trigger conditions |
38
+ | `*synapse session` | Show current session context: active agent, workflow, bracket level |
39
+ | `*synapse reload` | Force reload of manifest and all domain files from disk |
40
+
41
+ **Note:** These are read-only operations handled by the L7 star-command processor in the hook. They do not modify any files.
42
+
43
+ ## CRUD Operations
44
+
45
+ These commands modify domain files and the manifest. They are implemented as Claude Code slash commands in `.claude/commands/synapse/`.
46
+
47
+ ### Router
48
+
49
+ All CRUD operations go through the manager: `.claude/commands/synapse/manager.md`
50
+
51
+ The manager parses the sub-command and dispatches to the appropriate task file.
52
+
53
+ ### Available Operations
54
+
55
+ | Command | Task File | Purpose |
56
+ |---------|-----------|---------|
57
+ | `*synapse create` | `tasks/create-domain.md` | Create new domain file + manifest entry |
58
+ | `*synapse add` | `tasks/add-rule.md` | Add a new rule to an existing domain |
59
+ | `*synapse edit` | `tasks/edit-rule.md` | Edit or remove a rule by index |
60
+ | `*synapse toggle` | `tasks/toggle-domain.md` | Toggle domain STATE between active/inactive |
61
+ | `*synapse command` | `tasks/create-command.md` | Create a new star-command definition |
62
+ | `*synapse suggest` | `tasks/suggest-domain.md` | Suggest the best domain for a given rule |
63
+
64
+ ### Usage Examples
65
+
66
+ **Create a new domain:**
67
+ ```
68
+ *synapse create
69
+ ```
70
+ Prompts for: domain name, layer, description, initial rules.
71
+
72
+ **Add a rule to an existing domain:**
73
+ ```
74
+ *synapse add global "Always prefer functional patterns over imperative"
75
+ ```
76
+
77
+ **Toggle a domain off:**
78
+ ```
79
+ *synapse toggle agent-dev
80
+ ```
81
+
82
+ **Edit a specific rule:**
83
+ ```
84
+ *synapse edit global 3
85
+ ```
86
+ Opens rule at index 3 in `global` domain for editing.
87
+
88
+ **Create a new star-command:**
89
+ ```
90
+ *synapse command
91
+ ```
92
+ Prompts for: command name, behavior rules.
93
+
94
+ **Get domain suggestion for a rule:**
95
+ ```
96
+ *synapse suggest "Use TypeScript strict mode"
97
+ ```
98
+ Analyzes the rule content and suggests the best-fit domain.
99
+
100
+ ## Command Categories Summary
101
+
102
+ ```
103
+ Automatic per-event -> HOOK (synapse-engine.js, UserPromptSubmit)
104
+ User guidance/learning -> SKILL (synapse/SKILL.md + references)
105
+ User-invoked CRUD -> COMMAND (synapse/manager.md + 6 tasks)
106
+ Read-state star-cmds -> HOOK L7 (*synapse status, *synapse debug, *brief, *dev)
107
+ Write-file star-cmds -> COMMAND (*synapse create, *synapse add, *synapse toggle)
108
+ ```
109
+
110
+ ## Source Files
111
+
112
+ | File | Purpose |
113
+ |------|---------|
114
+ | `.synapse/commands` | Star-command rule definitions (L7) |
115
+ | `.claude/commands/synapse/manager.md` | CRUD command router |
116
+ | `.claude/commands/synapse/tasks/*.md` | Individual CRUD task workflows |
117
+ | `.claude/commands/synapse/templates/` | Domain and manifest templates |
118
+ | `.claude/commands/synapse/utils/manifest-parser-reference.md` | Parser format reference |
@@ -0,0 +1,126 @@
1
+ # SYNAPSE Domains Reference
2
+
3
+ ## What is a Domain?
4
+
5
+ A domain is a text file containing KEY=VALUE rules that SYNAPSE injects into prompts. Each domain maps to a specific layer (L0-L7) and is registered in the manifest file (`.synapse/manifest`).
6
+
7
+ Domains live in `.synapse/` and use a simple KEY=VALUE format with comments.
8
+
9
+ ## Domain Types by Layer
10
+
11
+ | Layer | Type | Trigger | Example Files |
12
+ |-------|------|---------|---------------|
13
+ | L0 | Constitution | Always active (`ALWAYS_ON=true`, `NON_NEGOTIABLE=true`) | `constitution` |
14
+ | L1 | Global | Always active (`ALWAYS_ON=true`) | `global`, `context` |
15
+ | L2 | Agent-scoped | Active agent matches `AGENT_TRIGGER` | `agent-dev`, `agent-qa`, `agent-architect` |
16
+ | L3 | Workflow-scoped | Active workflow matches `WORKFLOW_TRIGGER` | `workflow-sdc`, `workflow-qa-loop` |
17
+ | L4 | Task context | Active task detected in session | (injected dynamically) |
18
+ | L5 | Squad discovery | Squad is active in session | (squad domains) |
19
+ | L6 | Keyword (RECALL) | User prompt contains keyword from `RECALL` field | (keyword-triggered domains) |
20
+ | L7 | Star-commands | User types `*command` in prompt | `commands` |
21
+
22
+ ## KEY=VALUE Format
23
+
24
+ ### Syntax Rules
25
+
26
+ ```
27
+ # Comments start with #
28
+ # Empty lines are ignored
29
+
30
+ # Keys use SCREAMING_SNAKE_CASE with domain prefix
31
+ DOMAINPREFIX_RULE_0=First rule text
32
+ DOMAINPREFIX_RULE_1=Second rule text
33
+
34
+ # Grouped comments describe rule sections
35
+ # [section-name] COMMAND:
36
+ # 0. First behavior
37
+ # 1. Second behavior
38
+ ```
39
+
40
+ ### Key Naming Convention
41
+
42
+ ```
43
+ {DOMAIN_KEY}_RULE_{INDEX}={RULE_TEXT}
44
+ ```
45
+
46
+ - `DOMAIN_KEY`: Unique prefix matching manifest registration (e.g., `CONSTITUTION`, `GLOBAL`, `AGENT_DEV`)
47
+ - `RULE`: Literal word `RULE` (or `STATE`, `ALWAYS_ON`, etc. for manifest keys)
48
+ - `INDEX`: Zero-based integer or descriptive suffix
49
+ - `RULE_TEXT`: Plain text rule content
50
+
51
+ ### Example: Agent Domain
52
+
53
+ ```
54
+ # SYNAPSE Agent Domain: @dev (L2)
55
+ # Agent-scoped rules for developer agent
56
+ # Source: .aiox-core/development/agents/dev.md
57
+
58
+ AGENT_DEV_RULE_0=Follow story tasks sequentially — read task, implement, test, mark [x]
59
+ AGENT_DEV_RULE_1=ONLY update Dev Agent Record sections in story files
60
+ AGENT_DEV_RULE_2=Run CodeRabbit pre-commit review before marking story complete
61
+ ```
62
+
63
+ ### Example: Workflow Domain
64
+
65
+ ```
66
+ # SYNAPSE Workflow Domain: Story Development (L3)
67
+
68
+ WORKFLOW_SDC_RULE_0=Follow SDC phases: Create → Validate → Implement → QA Gate
69
+ WORKFLOW_SDC_RULE_1=Update story checkboxes as tasks complete
70
+ ```
71
+
72
+ ## Manifest Registration
73
+
74
+ Every domain must be registered in `.synapse/manifest`. The manifest uses the same KEY=VALUE format:
75
+
76
+ ### Required Manifest Keys
77
+
78
+ | Key | Purpose | Example |
79
+ |-----|---------|---------|
80
+ | `{PREFIX}_STATE` | Domain active state (`active` or `inactive`) | `AGENT_DEV_STATE=active` |
81
+
82
+ ### Optional Manifest Keys
83
+
84
+ | Key | Purpose | Example |
85
+ |-----|---------|---------|
86
+ | `{PREFIX}_ALWAYS_ON` | Domain always loaded (L0, L1) | `CONSTITUTION_ALWAYS_ON=true` |
87
+ | `{PREFIX}_NON_NEGOTIABLE` | Cannot be overridden (L0 only) | `CONSTITUTION_NON_NEGOTIABLE=true` |
88
+ | `{PREFIX}_AGENT_TRIGGER` | Activate when agent matches (L2) | `AGENT_DEV_AGENT_TRIGGER=dev` |
89
+ | `{PREFIX}_WORKFLOW_TRIGGER` | Activate when workflow matches (L3) | `WORKFLOW_SDC_WORKFLOW_TRIGGER=sdc` |
90
+ | `{PREFIX}_RECALL` | Keywords that trigger domain (L6) | `MYLIB_RECALL=react,hooks` |
91
+ | `{PREFIX}_EXCLUDE` | Agents/contexts to exclude from | `MYLIB_EXCLUDE=qa` |
92
+
93
+ ### Current Manifest Domains
94
+
95
+ The manifest at `.synapse/manifest` registers:
96
+ - 1 Constitution domain (L0, NON_NEGOTIABLE, ALWAYS_ON)
97
+ - 2 Global domains (L1, ALWAYS_ON): `global`, `context`
98
+ - 1 Commands domain (L7): `commands`
99
+ - 12 Agent domains (L2): one per core agent (`agent-dev`, `agent-qa`, etc.)
100
+ - 4 Workflow domains (L3): `sdc`, `qa-loop`, `spec`, `brownfield` (triggers; keys `WORKFLOW_SDC`, `WORKFLOW_QA_LOOP`, `WORKFLOW_SPEC`, `WORKFLOW_BROWNFIELD`)
101
+
102
+ ## Creating Custom Domains
103
+
104
+ Use the CRUD command to create a new domain:
105
+
106
+ ```
107
+ *synapse create
108
+ ```
109
+
110
+ This will:
111
+ 1. Ask for domain name, layer, and description
112
+ 2. Create the domain file in `.synapse/`
113
+ 3. Add the manifest entry to `.synapse/manifest`
114
+ 4. Validate the format is parseable by domain-loader
115
+
116
+ For the domain file template, see: `.claude/commands/synapse/templates/domain-template`
117
+
118
+ For the manifest entry template, see: `.claude/commands/synapse/templates/manifest-entry-template`
119
+
120
+ ## Source Files
121
+
122
+ | File | Purpose |
123
+ |------|---------|
124
+ | `.synapse/manifest` | Central domain registry |
125
+ | `.synapse/*` | Domain content files |
126
+ | `.aiox-core/core/synapse/domain/domain-loader.js` | Domain parser (SYN-1) |
@@ -0,0 +1,186 @@
1
+ # SYNAPSE 8-Layer Architecture Reference
2
+
3
+ ## Overview
4
+
5
+ SYNAPSE processes rules through an 8-layer pipeline executed sequentially on every prompt. Each layer has a specific purpose, trigger condition, and priority level. The engine orchestrator (`.aiox-core/core/synapse/engine.js`) chains all layers and the output formatter produces the final `<synapse-rules>` XML block.
6
+
7
+ ## Layer Pipeline
8
+
9
+ ```
10
+ L0 Constitution → L1 Global → L2 Agent → L3 Workflow → L4 Task → L5 Squad → L6 Keyword → L7 Star-Command
11
+ ```
12
+
13
+ Layers execute in order. Each layer's output is collected and passed to the formatter.
14
+
15
+ ## Layer Details
16
+
17
+ ### L0: Constitution (NON-NEGOTIABLE)
18
+
19
+ | Property | Value |
20
+ |----------|-------|
21
+ | **Purpose** | Enforce inviolable framework principles (6 articles) |
22
+ | **Trigger** | Always active (`ALWAYS_ON=true`, `NON_NEGOTIABLE=true`) |
23
+ | **Priority** | Highest — cannot be overridden by any other layer |
24
+ | **Domain file** | `.synapse/constitution` |
25
+ | **Source** | Auto-generated from `.aiox-core/constitution.md` via `generate-constitution.js` |
26
+ | **Implementation** | `.aiox-core/core/synapse/layers/l0-constitution.js` |
27
+
28
+ **Articles:** CLI First, Agent Authority, Story-Driven Development, No Invention, Quality First, Absolute Imports.
29
+
30
+ ### L1: Global + Context
31
+
32
+ | Property | Value |
33
+ |----------|-------|
34
+ | **Purpose** | Universal rules applied to all prompts + bracket-specific behavior |
35
+ | **Trigger** | Always active (`ALWAYS_ON=true`) |
36
+ | **Priority** | High — applies to every prompt regardless of context |
37
+ | **Domain files** | `.synapse/global`, `.synapse/context` |
38
+ | **Implementation** | `.aiox-core/core/synapse/layers/l1-global.js` |
39
+
40
+ **Content:** Coding standards, import rules, TypeScript rules, error handling patterns, bracket-specific context rules.
41
+
42
+ ### L2: Agent-Scoped
43
+
44
+ | Property | Value |
45
+ |----------|-------|
46
+ | **Purpose** | Inject agent-specific rules when an agent is active |
47
+ | **Trigger** | `AGENT_TRIGGER` matches active agent ID from session |
48
+ | **Priority** | Medium-high — only active when agent is activated |
49
+ | **Domain files** | `.synapse/agent-dev`, `.synapse/agent-qa`, `.synapse/agent-architect`, etc. (12 total) |
50
+ | **Implementation** | `.aiox-core/core/synapse/layers/l2-agent.js` |
51
+
52
+ **Agents covered:** dev, qa, architect, pm, po, sm, devops, analyst, data-engineer, ux (ux-design-expert), aiox-master, squad-creator.
53
+
54
+ ### L3: Workflow-Scoped
55
+
56
+ | Property | Value |
57
+ |----------|-------|
58
+ | **Purpose** | Inject workflow-specific rules when a workflow is active |
59
+ | **Trigger** | `WORKFLOW_TRIGGER` matches active workflow from session |
60
+ | **Priority** | Medium — active during specific development workflows |
61
+ | **Domain files** | `.synapse/workflow-sdc`, `.synapse/workflow-qa-loop`, `.synapse/workflow-spec`, `.synapse/workflow-brownfield` |
62
+ | **Implementation** | `.aiox-core/core/synapse/layers/l3-workflow.js` |
63
+
64
+ ### L4: Task Context
65
+
66
+ | Property | Value |
67
+ |----------|-------|
68
+ | **Purpose** | Inject context about the currently active task |
69
+ | **Trigger** | Active task detected in session state |
70
+ | **Priority** | Medium — active during task execution |
71
+ | **Domain files** | Dynamic (injected from session context) |
72
+ | **Implementation** | `.aiox-core/core/synapse/layers/l4-task.js` |
73
+
74
+ ### L5: Squad Discovery
75
+
76
+ | Property | Value |
77
+ |----------|-------|
78
+ | **Purpose** | Discover and inject rules from active squad domains |
79
+ | **Trigger** | Squad is active in session |
80
+ | **Priority** | Medium-low — only when working with squads |
81
+ | **Domain files** | Squad-specific domains (discovered at runtime) |
82
+ | **Implementation** | `.aiox-core/core/synapse/layers/l5-squad.js` |
83
+
84
+ ### L6: Keyword (RECALL)
85
+
86
+ | Property | Value |
87
+ |----------|-------|
88
+ | **Purpose** | Activate domains when user prompt contains matching keywords |
89
+ | **Trigger** | User prompt contains keyword listed in domain's `RECALL` field |
90
+ | **Priority** | Low — optional, skipped in DEPLETED bracket to conserve tokens |
91
+ | **Domain files** | Any domain with `RECALL` key in manifest |
92
+ | **Implementation** | `.aiox-core/core/synapse/layers/l6-keyword.js` |
93
+
94
+ ### L7: Star-Command
95
+
96
+ | Property | Value |
97
+ |----------|-------|
98
+ | **Purpose** | Detect and inject mode-switching commands (`*brief`, `*dev`, `*synapse status`, etc.) |
99
+ | **Trigger** | User types `*command` in prompt |
100
+ | **Priority** | Highest for explicit commands — user intent is paramount |
101
+ | **Domain file** | `.synapse/commands` |
102
+ | **Implementation** | `.aiox-core/core/synapse/layers/l7-star-command.js` |
103
+
104
+ ## Pipeline Execution Flow
105
+
106
+ ```
107
+ 1. Hook receives UserPromptSubmit event (stdin JSON)
108
+ 2. Engine calculates context bracket (prompt count → percent → bracket)
109
+ 3. Engine determines active layers for current bracket
110
+ 4. For each active layer (L0 → L7):
111
+ a. Layer processor loads relevant domain(s)
112
+ b. Rules are filtered/resolved
113
+ c. Layer output is collected
114
+ 5. Memory bridge consulted (if pro available, DEPLETED/CRITICAL brackets)
115
+ 6. Formatter assembles <synapse-rules> XML within token budget
116
+ 7. Output written to stdout (appended to user prompt)
117
+ ```
118
+
119
+ ## Conflict Resolution
120
+
121
+ When rules from different layers conflict:
122
+
123
+ 1. **NON_NEGOTIABLE wins** — L0 Constitution rules cannot be overridden
124
+ 2. **Higher layer number = more specific** — L7 Star-Command overrides L1 Global for the current prompt
125
+ 3. **Agent > Global** — L2 agent-scoped rules take precedence over L1 global rules
126
+ 4. **Workflow > Agent** — L3 workflow rules can augment L2 agent rules
127
+ 5. **Explicit > Implicit** — Star-commands (explicit user intent) override automatic rules
128
+
129
+ ## Output Format
130
+
131
+ The formatter produces XML output:
132
+
133
+ ```xml
134
+ <synapse-rules>
135
+ [CONTEXT BRACKET: MODERATE] 40-60% context remaining — all layers active
136
+ [CONSTITUTION] (NON-NEGOTIABLE) CLI First | Agent Authority | Story-Driven | No Invention | Quality First | Absolute Imports
137
+ [ACTIVE AGENT: @dev] Follow story tasks, update Dev Agent Record only, CodeRabbit pre-commit
138
+ [ACTIVE WORKFLOW: sdc] Follow SDC phases, update checkboxes
139
+ [TASK CONTEXT] Current task details
140
+ [SQUAD: mmos] Squad-specific rules
141
+ [STAR-COMMANDS] *dev: Code over explanation, minimal changes
142
+ [DEVMODE STATUS] Pipeline metrics (if DEVMODE=true)
143
+ [LOADED DOMAINS SUMMARY] constitution, global, context, agent-dev, workflow-sdc, commands
144
+ </synapse-rules>
145
+ ```
146
+
147
+ **Section ordering** (highest priority first):
148
+ 1. CONTEXT_BRACKET
149
+ 2. CONSTITUTION
150
+ 3. AGENT
151
+ 4. WORKFLOW
152
+ 5. TASK
153
+ 6. SQUAD
154
+ 7. KEYWORD
155
+ 8. MEMORY_HINTS
156
+ 9. STAR_COMMANDS
157
+ 10. DEVMODE
158
+ 11. SUMMARY
159
+
160
+ ## Performance Targets
161
+
162
+ | Metric | Target | Hard Limit |
163
+ |--------|--------|------------|
164
+ | Total pipeline | <70ms | <100ms |
165
+ | Individual layer | <15ms | <20ms (L0/L7: <5ms) |
166
+ | Startup (.synapse/ discovery) | <5ms | <10ms |
167
+ | Session I/O | <10ms | <15ms |
168
+
169
+ **Timeout behavior:** If any layer exceeds its time limit, it is skipped with a warning. The pipeline never blocks the prompt.
170
+
171
+ ## Source Files
172
+
173
+ | File | Purpose |
174
+ |------|---------|
175
+ | `.aiox-core/core/synapse/engine.js` | SynapseEngine orchestrator |
176
+ | `.aiox-core/core/synapse/layers/l0-constitution.js` | L0 processor |
177
+ | `.aiox-core/core/synapse/layers/l1-global.js` | L1 processor |
178
+ | `.aiox-core/core/synapse/layers/l2-agent.js` | L2 processor |
179
+ | `.aiox-core/core/synapse/layers/l3-workflow.js` | L3 processor |
180
+ | `.aiox-core/core/synapse/layers/l4-task.js` | L4 processor |
181
+ | `.aiox-core/core/synapse/layers/l5-squad.js` | L5 processor |
182
+ | `.aiox-core/core/synapse/layers/l6-keyword.js` | L6 processor |
183
+ | `.aiox-core/core/synapse/layers/l7-star-command.js` | L7 processor |
184
+ | `.aiox-core/core/synapse/layers/layer-processor.js` | Abstract base class |
185
+ | `.aiox-core/core/synapse/output/formatter.js` | XML formatter + token budget |
186
+ | `.claude/hooks/synapse-engine.js` | Hook entry point |
@@ -0,0 +1,142 @@
1
+ # SYNAPSE Manifest Reference
2
+
3
+ ## Overview
4
+
5
+ The manifest (`.synapse/manifest`) is the central registry for all SYNAPSE domains. It uses a KEY=VALUE format and determines which domains are loaded, when they activate, and how they behave.
6
+
7
+ The manifest is parsed by `domain-loader.js` (`.aiox-core/core/synapse/domain/domain-loader.js`) on every prompt.
8
+
9
+ ## File Format
10
+
11
+ ```
12
+ # Comments start with #
13
+ # Empty lines are ignored
14
+
15
+ # Debug mode toggle
16
+ DEVMODE=false
17
+
18
+ # Domain registration: {PREFIX}_{KEY}={VALUE}
19
+ CONSTITUTION_STATE=active
20
+ CONSTITUTION_ALWAYS_ON=true
21
+ CONSTITUTION_NON_NEGOTIABLE=true
22
+ ```
23
+
24
+ ## Valid Keys
25
+
26
+ Every domain is identified by a unique prefix (e.g., `CONSTITUTION`, `GLOBAL`, `AGENT_DEV`). The following keys are valid for each prefix:
27
+
28
+ ### Required Keys
29
+
30
+ | Key | Type | Description |
31
+ |-----|------|-------------|
32
+ | `{PREFIX}_STATE` | `active` \| `inactive` | Whether the domain is loaded. Required for every domain. |
33
+
34
+ ### Optional Keys
35
+
36
+ | Key | Type | Description | Used By |
37
+ |-----|------|-------------|---------|
38
+ | `{PREFIX}_ALWAYS_ON` | `true` \| `false` | Domain always loaded regardless of context | L0, L1 |
39
+ | `{PREFIX}_NON_NEGOTIABLE` | `true` \| `false` | Rules cannot be overridden by other layers | L0 only |
40
+ | `{PREFIX}_AGENT_TRIGGER` | agent ID string | Activate when this agent is active | L2 |
41
+ | `{PREFIX}_WORKFLOW_TRIGGER` | workflow ID string | Activate when this workflow is active | L3 |
42
+ | `{PREFIX}_RECALL` | comma-separated keywords | Activate when user prompt contains keyword | L6 |
43
+ | `{PREFIX}_EXCLUDE` | comma-separated values | Contexts/agents to exclude domain from | Any |
44
+
45
+ ### Global Key
46
+
47
+ | Key | Type | Description |
48
+ |-----|------|-------------|
49
+ | `DEVMODE` | `true` \| `false` | Enable debug metrics in output |
50
+
51
+ ## Complete Manifest Example
52
+
53
+ Below is the current manifest structure (from `.synapse/manifest`):
54
+
55
+ ```
56
+ # Debug mode
57
+ DEVMODE=false
58
+
59
+ # Layer 0: Constitution (NON-NEGOTIABLE)
60
+ CONSTITUTION_STATE=active
61
+ CONSTITUTION_ALWAYS_ON=true
62
+ CONSTITUTION_NON_NEGOTIABLE=true
63
+
64
+ # Layer 1: Global (ALWAYS_ON)
65
+ GLOBAL_STATE=active
66
+ GLOBAL_ALWAYS_ON=true
67
+
68
+ # Layer 1: Context brackets (ALWAYS_ON)
69
+ CONTEXT_STATE=active
70
+ CONTEXT_ALWAYS_ON=true
71
+
72
+ # Layer 7: Star-commands
73
+ COMMANDS_STATE=active
74
+
75
+ # Layer 2: Agent-scoped domains
76
+ AGENT_DEV_STATE=active
77
+ AGENT_DEV_AGENT_TRIGGER=dev
78
+ AGENT_QA_STATE=active
79
+ AGENT_QA_AGENT_TRIGGER=qa
80
+ AGENT_ARCHITECT_STATE=active
81
+ AGENT_ARCHITECT_AGENT_TRIGGER=architect
82
+ # ... (12 agent domains total)
83
+
84
+ # Layer 3: Workflow domains
85
+ WORKFLOW_SDC_STATE=active
86
+ WORKFLOW_SDC_WORKFLOW_TRIGGER=sdc
87
+ WORKFLOW_EPIC_CREATE_STATE=active
88
+ WORKFLOW_EPIC_CREATE_WORKFLOW_TRIGGER=epic_creation
89
+ WORKFLOW_ARCH_REVIEW_STATE=active
90
+ WORKFLOW_ARCH_REVIEW_WORKFLOW_TRIGGER=architecture_review
91
+ ```
92
+
93
+ ## Domain-to-File Mapping
94
+
95
+ The domain-loader resolves domain prefixes to files in `.synapse/`:
96
+
97
+ | Prefix | File | Layer |
98
+ |--------|------|-------|
99
+ | `CONSTITUTION` | `.synapse/constitution` | L0 |
100
+ | `GLOBAL` | `.synapse/global` | L1 |
101
+ | `CONTEXT` | `.synapse/context` | L1 |
102
+ | `COMMANDS` | `.synapse/commands` | L7 |
103
+ | `AGENT_DEV` | `.synapse/agent-dev` | L2 |
104
+ | `AGENT_QA` | `.synapse/agent-qa` | L2 |
105
+ | `WORKFLOW_SDC` | `.synapse/workflow-sdc` | L3 |
106
+
107
+ **Naming convention:** The prefix is derived from the filename by:
108
+ 1. Converting to SCREAMING_SNAKE_CASE
109
+ 2. Removing hyphens and replacing with underscores
110
+
111
+ ## Troubleshooting
112
+
113
+ ### Domain Not Loading
114
+
115
+ 1. Check `{PREFIX}_STATE=active` in manifest
116
+ 2. Verify the domain file exists in `.synapse/`
117
+ 3. For L2 domains: verify `AGENT_TRIGGER` matches the active agent ID
118
+ 4. For L3 domains: verify `WORKFLOW_TRIGGER` matches the active workflow
119
+ 5. Run `*synapse debug` to see manifest parse results
120
+
121
+ ### Invalid Format Errors
122
+
123
+ - Keys must use SCREAMING_SNAKE_CASE
124
+ - Values cannot contain newlines
125
+ - No spaces around `=` sign
126
+ - Comments must start with `#` at the beginning of the line
127
+
128
+ ### Adding a New Domain
129
+
130
+ Use `*synapse create` or manually:
131
+ 1. Create the domain file in `.synapse/` with KEY=VALUE rules
132
+ 2. Add the registration keys to `.synapse/manifest`
133
+ 3. Run `*synapse reload` to reload from disk
134
+
135
+ ## Source Files
136
+
137
+ | File | Purpose |
138
+ |------|---------|
139
+ | `.synapse/manifest` | The manifest file itself |
140
+ | `.aiox-core/core/synapse/domain/domain-loader.js` | Manifest parser + domain file loader |
141
+ | `.claude/commands/synapse/utils/manifest-parser-reference.md` | Detailed parser format spec |
142
+ | `.claude/commands/synapse/templates/manifest-entry-template` | Template for new manifest entries |
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: tdd
3
+ description: Test-driven build loop — red, green, refactor. Use when building a feature or fixing a bug; write a failing test first, make it pass, then refactor with the suite green.
4
+ ---
5
+
6
+ # TDD — the kernel build loop
7
+
8
+ The canonical build stage of the WRXN pipeline (grill → research → prototype → PRD → issues →
9
+ verticality review → **tdd** → code review → security review → QA-walk → operator accepts).
10
+
11
+ ## The loop
12
+
13
+ 1. **Red** — write one failing test that pins the next slice of behavior at the highest seam
14
+ (public interface, not internals). Run it; watch it fail for the right reason.
15
+ 2. **Green** — write the minimum code to pass. Nothing speculative.
16
+ 3. **Refactor** — clean up with the suite green. Behavior unchanged.
17
+
18
+ ## Rules
19
+
20
+ - Tests and typecheck pass on **every commit** (Constitution Art. III). A red commit is not done.
21
+ - Test external behavior, not implementation — internals stay refactorable.
22
+ - One slice = one tracer bullet: independently buildable and walkable (Constitution Art. II).