specrails-core 4.6.4 → 4.6.5

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 (27) hide show
  1. package/commands/enrich.md +109 -214
  2. package/dist/installer/phases/scaffold.js +152 -153
  3. package/dist/installer/phases/scaffold.js.map +1 -1
  4. package/docs/deployment.md +1 -1
  5. package/package.json +1 -2
  6. package/schemas/profile.v1.json +1 -9
  7. package/templates/agents/sr-architect.md +9 -6
  8. package/templates/codex-skills/enrich/SKILL.md +3 -3
  9. package/templates/codex-skills/implement/SKILL.md +75 -8
  10. package/templates/codex-skills/rails/sr-architect/SKILL.md +33 -7
  11. package/templates/codex-skills/rails/sr-developer/SKILL.md +6 -3
  12. package/templates/codex-skills/rails/sr-reviewer/SKILL.md +57 -5
  13. package/templates/commands/specrails/enrich.md +36 -213
  14. package/templates/commands/specrails/implement.md +22 -10
  15. package/templates/commands/specrails/reconfig.md +1 -10
  16. package/templates/commands/specrails/retry.md +2 -1
  17. package/templates/skills/rails/sr-architect/SKILL.md +0 -234
  18. package/templates/skills/rails/sr-developer/SKILL.md +0 -210
  19. package/templates/skills/rails/sr-merge-resolver/SKILL.md +0 -197
  20. package/templates/skills/rails/sr-reviewer/SKILL.md +0 -320
  21. package/templates/skills/sr-auto-propose-backlog-specs/SKILL.md +0 -275
  22. package/templates/skills/sr-batch-implement/SKILL.md +0 -292
  23. package/templates/skills/sr-compat-check/SKILL.md +0 -275
  24. package/templates/skills/sr-get-backlog-specs/SKILL.md +0 -199
  25. package/templates/skills/sr-implement/SKILL.md +0 -1205
  26. package/templates/skills/sr-refactor-recommender/SKILL.md +0 -216
  27. package/templates/skills/sr-why/SKILL.md +0 -106
@@ -1,216 +0,0 @@
1
- ---
2
- name: sr-refactor-recommender
3
- description: "sr:refactor-recommender — Scan the codebase for refactoring opportunities ranked by impact/effort ratio. Optionally creates GitHub Issues for tracking."
4
- license: MIT
5
- compatibility: "Requires git."
6
- metadata:
7
- author: specrails
8
- version: "1.0"
9
- ---
10
-
11
-
12
- Scan the codebase for refactoring opportunities, score each by impact/effort ratio and VPC persona value, and optionally create GitHub Issues for the top findings in {{BACKLOG_PROVIDER_NAME}}.
13
-
14
- **Input:** `$ARGUMENTS` — optional: comma-separated paths to scope the analysis. Flags: `--dry-run` (print findings without creating issues).
15
-
16
- ---
17
-
18
- ## Phase 0: Pre-flight
19
-
20
- Check whether the GitHub CLI is available:
21
-
22
- ```bash
23
- {{BACKLOG_PREFLIGHT}}
24
- ```
25
-
26
- Set `GH_AVAILABLE=true` if the command succeeds, `GH_AVAILABLE=false` otherwise. Do not stop — analysis proceeds regardless. Parse `--dry-run` from `$ARGUMENTS` and set `DRY_RUN=true` if present.
27
-
28
- ---
29
-
30
- ## Phase 1: Scope
31
-
32
- Parse paths from `$ARGUMENTS` after stripping any flags. If no paths are provided, scan the entire repository.
33
-
34
- Always exclude the following from all analysis:
35
-
36
- - `node_modules/`
37
- - `.git/`
38
- - `.claude/`
39
- - `vendor/`
40
- - `dist/`
41
- - `build/`
42
-
43
- ---
44
-
45
- ## Phase 1.5: VPC Context
46
-
47
- Check whether persona files exist at `.claude/agents/personas/`. This path is present in any repo that has run `/specrails:enrich`.
48
-
49
- ```bash
50
- ls .claude/agents/personas/ 2>/dev/null
51
- ```
52
-
53
- If the directory exists and contains persona files, set `VPC_AVAILABLE=true`. Otherwise set `VPC_AVAILABLE=false` and skip all VPC steps (they are optional enrichment, not blockers).
54
-
55
- When `VPC_AVAILABLE=true`, read each persona file and extract a compact VPC summary. For each persona record:
56
-
57
- - **name** — persona display name (e.g. "Alex — The Lead Dev")
58
- - **top_jobs** — up to 3 functional jobs relevant to code quality and maintainability
59
- - **critical_pains** — up to 3 pains marked Critical or High related to code reliability, complexity, or developer experience
60
- - **high_gains** — up to 3 gains marked High related to code clarity, speed, or confidence
61
-
62
- Store these as an in-memory `VPC_PROFILES` list. You will use it in Phase 3 to score persona fit.
63
-
64
- ---
65
-
66
- ## Phase 2: Analysis
67
-
68
- Analyze the scoped files across six categories. For each finding record:
69
-
70
- - **file** — relative path
71
- - **line_range** — start and end line numbers
72
- - **current_snippet** — the problematic code as-is
73
- - **proposed_snippet** — concrete refactored version
74
- - **rationale** — one sentence explaining the improvement
75
-
76
- ### Duplicate Code
77
-
78
- Find code blocks larger than 10 lines that are substantially similar across two or more files. Consolidation into a shared function or module is the expected refactoring.
79
-
80
- ### Long Functions
81
-
82
- Find functions or methods exceeding 50 lines. Extraction into smaller, single-purpose functions is the expected refactoring.
83
-
84
- ### Large Files
85
-
86
- Find files exceeding 300 lines. Splitting into cohesive modules is the expected refactoring.
87
-
88
- ### Dead Code
89
-
90
- Find unused exports, unreferenced functions, and commented-out blocks that have not been active for the lifetime of the file. Deletion or archival is the expected refactoring.
91
-
92
- ### Outdated Patterns
93
-
94
- Find deprecated APIs and old language syntax: `var` instead of `let`/`const`, callbacks instead of `async`/`await`, legacy framework APIs with documented replacements, etc. Modernisation to current idioms is the expected refactoring.
95
-
96
- ### Complex Logic
97
-
98
- Find deeply nested conditionals (more than 3 levels) and functions with high cyclomatic complexity. Extraction, early-return guards, or strategy patterns are the expected refactoring.
99
-
100
- ---
101
-
102
- ## Phase 3: Score and Rank
103
-
104
- Score every finding on three dimensions (1–5 each):
105
-
106
- - **Impact** — how much the refactoring improves code quality, readability, or maintainability
107
- - **Effort** — how hard the refactoring is to implement (1 = trivial, 5 = major)
108
- - **VPC Value** — how directly this refactoring addresses persona jobs, pains, or gains (1 = no relevance, 5 = resolves a critical persona pain or delivers a high-value gain). Set to 3 when `VPC_AVAILABLE=false`.
109
-
110
- **Scoring VPC Value** (only when `VPC_AVAILABLE=true`):
111
-
112
- For each finding, reason over `VPC_PROFILES`:
113
-
114
- - Does fixing this reduce a **Critical/High pain** for any persona? (e.g. complex logic → harder to trust AI output → Alex's "agents go off the rails" pain) → score 4–5
115
- - Does fixing this deliver a **High gain** for any persona? (e.g. extracting a function → cleaner API surface → easier onboarding → Sara's gain) → score 3–4
116
- - Is there indirect persona value? (e.g. dead code removal → smaller codebase → easier contributor review → Kai) → score 2–3
117
- - No clear persona relevance → score 1–2
118
-
119
- Assign one `vpc_value` integer per finding, and note the **primary persona** and **rationale** (one sentence).
120
-
121
- **Composite score**: `impact * 2 + (6 - effort) + vpc_value`. Higher is better.
122
-
123
- Sort all findings by composite score descending. If the same code block was flagged by multiple categories, keep only the highest-scored entry and discard the duplicates.
124
-
125
- ---
126
-
127
- ## Phase 4: Create GitHub Issues
128
-
129
- Skip this phase if `GH_AVAILABLE=false` or `DRY_RUN=true`.
130
-
131
- First ensure the tracking labels exist:
132
-
133
- ```bash
134
- gh label create "refactor-opportunity" --color "B60205" --force
135
- ```
136
-
137
- Fetch existing open issues that already carry the label to avoid duplicates:
138
-
139
- ```bash
140
- gh issue list --label "refactor-opportunity" --state open --limit 100 --json number,title
141
- ```
142
-
143
- For each of the **top 5** findings (by composite score) that does not already have a matching open issue, create a GitHub Issue with the following body:
144
-
145
- ```
146
- ## Refactoring Opportunity: {description}
147
-
148
- **Category**: {category}
149
- **File**: {file}:{line_range}
150
- **Impact**: {impact}/5 | **Effort**: {effort}/5 | **Score**: {composite}
151
- {vpc_line}
152
-
153
- ### Current Code
154
- ```{lang}
155
- {current_snippet}
156
- ```
157
-
158
- ### Proposed Refactoring
159
- ```{lang}
160
- {proposed_snippet}
161
- ```
162
-
163
- ### Rationale
164
- {rationale}
165
-
166
- ---
167
- _Generated by `/specrails:refactor-recommender` in {{PROJECT_NAME}}_
168
- ```
169
-
170
- Where `{vpc_line}` is included only when `VPC_AVAILABLE=true`:
171
- `**VPC Value**: {vpc_value}/5 — {vpc_persona}: {vpc_rationale}`
172
-
173
- ---
174
-
175
- ## Phase 5: Output Summary
176
-
177
- Print the following report:
178
-
179
- ```
180
- ## Refactoring Opportunities — {{PROJECT_NAME}}
181
-
182
- {N} opportunities found | Sorted by composite score
183
- {vpc_header}
184
-
185
- | # | Category | File | Impact | Effort | VPC | Score | Description |
186
- |---|----------|------|--------|--------|-----|-------|-------------|
187
- | 1 | {category} | {file}:{line_range} | {impact}/5 | {effort}/5 | {vpc_value}/5 | {composite} | {description} |
188
- ...
189
-
190
- ### Top 3 Detailed Recommendations
191
-
192
- #### 1. {description}
193
- **File**: {file}:{line_range}
194
- **Category**: {category} | **Score**: {composite}
195
- {vpc_detail}
196
-
197
- **Current:**
198
- ```{lang}
199
- {current_snippet}
200
- ```
201
-
202
- **Proposed:**
203
- ```{lang}
204
- {proposed_snippet}
205
- ```
206
-
207
- **Rationale:** {rationale}
208
-
209
- (repeat for #2 and #3)
210
-
211
- Issues created: {N} (or "dry-run: no issues created")
212
- ```
213
-
214
- Where:
215
- - `{vpc_header}` is `VPC personas loaded: {persona names}` when `VPC_AVAILABLE=true`, or `VPC personas: not found (run /specrails:enrich to enable)` otherwise.
216
- - `{vpc_detail}` is `**VPC Value**: {vpc_value}/5 — {vpc_persona}: {vpc_rationale}` when `VPC_AVAILABLE=true`, omitted otherwise.
@@ -1,106 +0,0 @@
1
- ---
2
- name: sr-why
3
- description: "sr:why — Search explanation records written by specrails agents during the OpenSpec implementation pipeline."
4
- license: MIT
5
- compatibility: "Requires git."
6
- metadata:
7
- author: specrails
8
- version: "1.0"
9
- ---
10
-
11
- # /specrails:why — In-Context Help
12
-
13
- Searches explanation records written by sr-architect, sr-developer, and sr-reviewer agents
14
- during the OpenSpec implementation pipeline.
15
-
16
- Records are stored in `.claude/agent-memory/explanations/` as Markdown files with
17
- YAML frontmatter (agent, feature, tags, date).
18
-
19
- **Usage:**
20
- - `/specrails:why` — list the 20 most recent explanation records
21
- - `/specrails:why <query>` — search records by keyword or tag
22
-
23
- ---
24
-
25
- ## Step 1: Find explanation records
26
-
27
- Glob all files matching `.claude/agent-memory/explanations/*.md`.
28
-
29
- If the directory does not exist or contains no files:
30
- Print:
31
- ```
32
- No explanation records found yet.
33
-
34
- Explanation records are written by the sr-architect, sr-developer, and sr-reviewer agents
35
- when they make significant decisions during feature implementation.
36
-
37
- Run `/specrails:implement` on a feature to generate your first explanation records.
38
- ```
39
- Then stop.
40
-
41
- ## Step 2: Handle no-argument mode (listing)
42
-
43
- If `$ARGUMENTS` is empty:
44
-
45
- Read each explanation record file. Extract from frontmatter: `date`, `agent`, `feature`, `tags`.
46
- Extract the first sentence of the `## Decision` section as the decision summary.
47
-
48
- Sort records by `date` descending. Print the 20 most recent as a Markdown table:
49
-
50
- ```
51
- ## Recent Explanation Records
52
-
53
- | Date | Agent | Feature | Tags | Decision |
54
- |------|-------|---------|------|----------|
55
- | 2026-03-14 | sr-architect | in-context-help | [templates, commands] | Chose flat directory over per-agent subdirectories. |
56
- | ... | ... | ... | ... | ... |
57
- ```
58
-
59
- Then stop.
60
-
61
- ## Step 3: Handle query mode (search)
62
-
63
- If `$ARGUMENTS` is non-empty, treat the full string as the search query.
64
-
65
- For each explanation record file:
66
- 1. Read the full file content
67
- 2. Score the record against the query:
68
- - Filename contains a query word: +3 points per matching word
69
- - Frontmatter `tags` array contains an exact query word: +3 points per matching tag
70
- - Frontmatter `feature` contains a query word: +2 points
71
- - Body text contains a query word: +1 point per occurrence (case-insensitive)
72
- 3. Sum the score
73
-
74
- Sort records by score descending. Take the top 5 records with score > 0.
75
-
76
- If no records score > 0:
77
- Print:
78
- ```
79
- No explanation records match "<query>".
80
- ```
81
- Then list all unique tags from existing records:
82
- ```
83
- ## Available Tags
84
-
85
- [sorted list of all unique tags from all explanation records]
86
-
87
- Try `/specrails:why <tag>` with one of the tags above, or `/specrails:why` to browse all records.
88
- ```
89
-
90
- If records match, print each matching record in full, separated by `---`:
91
-
92
- ```
93
- ## Results for "<query>" (N matches)
94
-
95
- ---
96
-
97
- **[date] [agent] — [feature]**
98
- Tags: [tag1, tag2]
99
-
100
- [full record body]
101
-
102
- ---
103
-
104
- **[date] [agent] — [feature]**
105
- ...
106
- ```