specrails-core 3.5.3 → 3.6.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.
@@ -54,20 +54,50 @@ Example — adding a constraint to the developer:
54
54
 
55
55
  ### Agent model selection
56
56
 
57
- Each agent specifies its model in YAML frontmatter:
57
+ Agent models are controlled by `.specrails/agents.yaml`, generated automatically when you first run `/specrails:setup`.
58
58
 
59
59
  ```yaml
60
- ---
61
- model: sonnet
62
- ---
60
+ # specrails agent configuration
61
+ # Valid models: opus, sonnet, haiku
62
+
63
+ defaults:
64
+ model: sonnet
65
+
66
+ agents:
67
+ sr-architect:
68
+ model: sonnet
69
+ sr-product-manager:
70
+ model: opus
71
+ sr-product-analyst:
72
+ model: haiku
73
+ # ... all 14 agents listed
63
74
  ```
64
75
 
65
- Available models:
76
+ **Valid models:**
66
77
  - `opus` — best for creative/strategic tasks (Product Manager)
67
78
  - `sonnet` — balanced for implementation tasks (most agents)
68
79
  - `haiku` — fast and cheap for analysis tasks (Product Analyst)
69
80
 
70
- Change the model by editing the frontmatter.
81
+ **Precedence rules:**
82
+ 1. Per-agent entry in `agents:` section overrides everything
83
+ 2. `defaults.model` applies to any agent not explicitly listed
84
+ 3. Template hard-coded value is the fallback when no config exists
85
+
86
+ **Applying config changes:** After editing `.specrails/agents.yaml`, run `/specrails:reconfig` to update the generated agent files without re-running the full setup wizard:
87
+
88
+ ```
89
+ /specrails:reconfig
90
+ ```
91
+
92
+ Output example:
93
+ ```
94
+ Updated 1 agent(s):
95
+ sr-developer: sonnet → opus
96
+
97
+ Unchanged (13): sr-architect, sr-reviewer, ...
98
+ ```
99
+
100
+ **Important:** `/specrails:reconfig` wins over direct edits to `.claude/agents/sr-*.md`. If you edit an agent file directly, that change will be overwritten the next time you run reconfig or setup. For permanent per-agent overrides, edit `.specrails/agents.yaml` instead.
71
101
 
72
102
  ### Adding a new agent
73
103
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specrails-core",
3
- "version": "3.5.3",
3
+ "version": "3.6.0",
4
4
  "description": "AI agent workflow system for Claude Code — installs 12 specialized agents, orchestration commands, and persona-driven product discovery into any repository",
5
5
  "bin": {
6
6
  "specrails-core": "bin/specrails-core.js"
@@ -0,0 +1,89 @@
1
+ # Reconfig: Apply Agent Config to Generated Files
2
+
3
+ Reads `.specrails/agents.yaml` and updates the `model:` frontmatter field in all generated `.claude/agents/sr-*.md` files to match. No full re-setup needed — only model frontmatter is changed.
4
+
5
+ ---
6
+
7
+ ## Step 1: Locate generated agents directory
8
+
9
+ Determine `$SPECRAILS_DIR`:
10
+
11
+ 1. Read `.specrails/setup-templates/.provider-detection.json` to get `cli_provider` and `specrails_dir`.
12
+ 2. If the file does not exist, default to `cli_provider = "claude"` and `specrails_dir = ".claude"`.
13
+ 3. Set `$AGENTS_DIR = $SPECRAILS_DIR/agents`
14
+
15
+ ## Step 2: Read agent config
16
+
17
+ Read `.specrails/agents.yaml`.
18
+
19
+ If the file does not exist, stop and display:
20
+
21
+ ```
22
+ No .specrails/agents.yaml found.
23
+
24
+ Run /specrails:setup to generate the config file, then edit it before running /specrails:reconfig.
25
+ ```
26
+
27
+ If the file exists, parse it. Validate all `model:` values — only `opus`, `sonnet`, and `haiku` are accepted. If an invalid value is found, display a warning and skip that agent:
28
+
29
+ ```
30
+ Warning: unknown model "gpt-4" for sr-developer — skipping (valid values: opus, sonnet, haiku)
31
+ ```
32
+
33
+ ## Step 3: Resolve model for each agent
34
+
35
+ For each agent file found in `$AGENTS_DIR/sr-*.md`:
36
+
37
+ 1. Extract the agent name from the filename (e.g., `sr-developer.md` → `sr-developer`)
38
+ 2. Resolve the target model:
39
+ - Check `agents.<agent-name>.model` in config (per-agent override)
40
+ - If not present, check `defaults.model` in config (global default)
41
+ - If neither is present, skip this agent
42
+ 3. Read the current `model:` value from the file's YAML frontmatter
43
+ 4. If the current model matches the target model, mark as **unchanged**
44
+ 5. If they differ, record the change: `sr-<name>: <current> → <target>`
45
+
46
+ ## Step 4: Apply changes
47
+
48
+ For each agent with a recorded change:
49
+
50
+ 1. Read the file
51
+ 2. Replace the `model:` line in the YAML frontmatter with the resolved value
52
+ 3. Write the file back
53
+
54
+ The `model:` line is always in the frontmatter block (between the first `---` and second `---`). Replace only that specific line — do not modify any other content.
55
+
56
+ **Codex format:** If `cli_provider == "codex"`, apply the same logic to `.codex/agents/sr-*.toml` files. Replace the `model = "..."` line with the mapped Codex model:
57
+ - `sonnet` → `codex-mini-latest`
58
+ - `opus` → `o3`
59
+ - `haiku` → `codex-mini-latest`
60
+
61
+ ## Step 5: Report results
62
+
63
+ Display a summary of what changed:
64
+
65
+ ```
66
+ ## Reconfig complete
67
+
68
+ Updated 2 agent(s):
69
+ sr-developer: sonnet → opus
70
+ sr-product-analyst: haiku → sonnet
71
+
72
+ Unchanged (3):
73
+ sr-architect, sr-reviewer, sr-product-manager
74
+
75
+ Skipped (1):
76
+ sr-custom-agent (not in config)
77
+ ```
78
+
79
+ If nothing changed:
80
+
81
+ ```
82
+ All agents already match .specrails/agents.yaml — nothing to update.
83
+ ```
84
+
85
+ If all agents were skipped due to validation errors, display:
86
+
87
+ ```
88
+ No agents updated. Fix the validation errors in .specrails/agents.yaml and retry.
89
+ ```
@@ -61,6 +61,8 @@ Read the following files to understand the current installation state:
61
61
 
62
62
  6. Read `.specrails/backlog-config.json` if it exists — contains stored provider configuration needed for command placeholder substitution.
63
63
 
64
+ 7. Read `.specrails/agents.yaml` if it exists — contains agent model configuration. Validate all `model:` values (only `opus`, `sonnet`, `haiku` are valid). Store as `AGENTS_CONFIG` for use in Phase U4. If the file does not exist, set `AGENTS_CONFIG = null`.
65
+
64
66
  ### Phase U2: Quick Codebase Re-Analysis
65
67
 
66
68
  Perform the same analysis as Phase 1 of the full setup wizard, but silently — do not prompt the user and do not show the findings table. Just execute and store results internally.
@@ -158,10 +160,15 @@ For each agent in the "changed" list:
158
160
  - `{{KEY_FILE_PATHS}}` → important file paths detected in Phase U2
159
161
  - `{{WARNINGS}}` → read from existing `CLAUDE.md` if present
160
162
  - `{{MEMORY_PATH}}` → `$SPECRAILS_DIR/agent-memory/sr-<agent-name>/`
161
- 3. Write the adapted agent using the format for the active provider (same dual-format rules as Phase 4.1):
163
+ 3. Resolve the agent's model using `AGENTS_CONFIG` (loaded in Phase U1, step 7):
164
+ - Check `AGENTS_CONFIG.agents.<agent-name>.model` (per-agent override)
165
+ - If not present, check `AGENTS_CONFIG.defaults.model` (global default)
166
+ - If `AGENTS_CONFIG` is null, use the model from the template frontmatter
167
+ - Replace the `model:` field in the YAML frontmatter with the resolved value before writing
168
+ 4. Write the adapted agent using the format for the active provider (same dual-format rules as Phase 4.1):
162
169
  - `cli_provider == "claude"`: write to `$SPECRAILS_DIR/agents/sr-<name>.md` (Markdown with YAML frontmatter)
163
170
  - `cli_provider == "codex"`: write to `$SPECRAILS_DIR/agents/sr-<name>.toml` (TOML format with `name`, `description`, `model`, `prompt` fields)
164
- 4. Show: `✓ Regenerated sr-<name>`
171
+ 5. Show: `✓ Regenerated sr-<name>`
165
172
 
166
173
  After regenerating all changed agents, verify no unresolved placeholders remain:
167
174
  ```bash
@@ -400,6 +407,8 @@ For each default agent (sr-architect, sr-developer, sr-reviewer, sr-product-mana
400
407
  - `cli_provider == "claude"`: write to `.claude/agents/<name>.md` (Markdown with frontmatter)
401
408
  - `cli_provider == "codex"`: write to `.codex/agents/<name>.toml` (TOML format)
402
409
 
410
+ If `.specrails/agents.yaml` exists, read it and apply model resolution (per-agent override → defaults → template value) before writing each agent file.
411
+
403
412
  Fill placeholders with best-effort values from the limited context available:
404
413
  - `{{PROJECT_NAME}}` → directory name or README first heading
405
414
  - `{{PROJECT_DESCRIPTION}}` → `QS_PROJECT_DESCRIPTION`
@@ -661,6 +670,62 @@ Display each generated persona to the user:
661
670
 
662
671
  Wait for confirmation. If the user wants edits, apply them.
663
672
 
673
+ ### 2.5 Initialize agent config
674
+
675
+ Check for `.specrails/agents.yaml`:
676
+
677
+ 1. If the file **exists**:
678
+ - Read it
679
+ - Validate all `model:` values — only `opus`, `sonnet`, and `haiku` are valid
680
+ - If any value is invalid, warn the user and fall back to the template default for that agent
681
+ - Store as `AGENTS_CONFIG` for use in Phase 4
682
+
683
+ 2. If the file **does not exist**:
684
+ - Generate it with the default model assignments matching the template hard-coded values:
685
+
686
+ ```yaml
687
+ # specrails agent configuration
688
+ # Modify model assignments and other agent settings
689
+ # Valid models: opus, sonnet, haiku
690
+
691
+ defaults:
692
+ model: sonnet
693
+
694
+ agents:
695
+ sr-architect:
696
+ model: sonnet
697
+ sr-developer:
698
+ model: sonnet
699
+ sr-reviewer:
700
+ model: sonnet
701
+ sr-product-manager:
702
+ model: opus
703
+ sr-product-analyst:
704
+ model: haiku
705
+ sr-test-writer:
706
+ model: sonnet
707
+ sr-security-reviewer:
708
+ model: sonnet
709
+ sr-backend-developer:
710
+ model: sonnet
711
+ sr-frontend-developer:
712
+ model: sonnet
713
+ sr-backend-reviewer:
714
+ model: sonnet
715
+ sr-frontend-reviewer:
716
+ model: sonnet
717
+ sr-doc-sync:
718
+ model: sonnet
719
+ sr-merge-resolver:
720
+ model: sonnet
721
+ sr-performance-reviewer:
722
+ model: sonnet
723
+ ```
724
+
725
+ - Write this file to `.specrails/agents.yaml`
726
+ - Store as `AGENTS_CONFIG` for use in Phase 4
727
+ - Log: "Generated `.specrails/agents.yaml` with default model assignments"
728
+
664
729
  ---
665
730
 
666
731
  ## Phase 3: Configuration
@@ -1037,7 +1102,12 @@ When generating each agent:
1037
1102
  - `{{TECH_EXPERTISE}}` → detected languages, frameworks, and test frameworks from Phase 1
1038
1103
  - `{{LAYER_CLAUDE_MD_PATHS}}` → comma-separated paths to per-layer rules files (e.g., `$SPECRAILS_DIR/rules/backend.md`, `$SPECRAILS_DIR/rules/frontend.md`)
1039
1104
  - `{{SECURITY_EXEMPTIONS_PATH}}` → `$SPECRAILS_DIR/security-exemptions.yaml`
1040
- 3. Write the final file in the format for the active provider:
1105
+ 3. Resolve the agent's model using `AGENTS_CONFIG` (loaded in Phase 2.5):
1106
+ - Check `AGENTS_CONFIG.agents.<agent-name>.model` (per-agent override)
1107
+ - If not present, check `AGENTS_CONFIG.defaults.model` (global default)
1108
+ - If `AGENTS_CONFIG` was not loaded (e.g., re-run without config), use the model from the template frontmatter (current behavior)
1109
+ - Replace the `model:` field in the YAML frontmatter with the resolved value before writing
1110
+ 4. Write the final file in the format for the active provider:
1041
1111
 
1042
1112
  **If `cli_provider == "claude"`:** Write as Markdown with YAML frontmatter — the template file as-is (frontmatter preserved).
1043
1113
 
@@ -1086,6 +1156,7 @@ For each selected command, read the template and adapt.
1086
1156
  - `.specrails/setup-templates/commands/specrails/compat-check.md` → `.claude/commands/specrails/compat-check.md`
1087
1157
  - `.specrails/setup-templates/commands/specrails/refactor-recommender.md` → `.claude/commands/specrails/refactor-recommender.md`
1088
1158
  - `.specrails/setup-templates/commands/specrails/why.md` → `.claude/commands/specrails/why.md`
1159
+ - `.specrails/setup-templates/commands/specrails/reconfig.md` → `.claude/commands/specrails/reconfig.md`
1089
1160
 
1090
1161
  **If `cli_provider == "codex"`:**
1091
1162
  - `.specrails/setup-templates/skills/sr-implement/SKILL.md` → `.agents/skills/sr-implement/SKILL.md`
@@ -1096,6 +1167,7 @@ For each selected command, read the template and adapt.
1096
1167
  - `.specrails/setup-templates/skills/sr-compat-check/SKILL.md` → `.agents/skills/sr-compat-check/SKILL.md`
1097
1168
  - `.specrails/setup-templates/skills/sr-refactor-recommender/SKILL.md` → `.agents/skills/sr-refactor-recommender/SKILL.md`
1098
1169
  - `.specrails/setup-templates/skills/sr-why/SKILL.md` → `.agents/skills/sr-why/SKILL.md`
1170
+ - `.specrails/setup-templates/commands/specrails/reconfig.md` → `.agents/skills/sr-reconfig/SKILL.md` (wrap with YAML frontmatter)
1099
1171
 
1100
1172
  **Codex skill frontmatter wrapping:** When a dedicated skill template does not exist in `.specrails/setup-templates/skills/` for a command, generate the `SKILL.md` by prepending YAML frontmatter to the command content:
1101
1173
  ```yaml