specrails-core 5.6.0 → 6.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.
Files changed (275) hide show
  1. package/README.md +27 -145
  2. package/bin/specrails-core.mjs +12 -554
  3. package/dist/agent-runtime/capabilities.js +0 -1
  4. package/dist/agent-runtime/cli-executor.d.ts +1 -1
  5. package/dist/agent-runtime/cli-executor.js +1 -2
  6. package/dist/agent-runtime/cli-process.js +0 -1
  7. package/dist/agent-runtime/cli.js +3 -4
  8. package/dist/agent-runtime/codex-schema.js +0 -1
  9. package/dist/agent-runtime/compact/architect.d.ts +3 -272
  10. package/dist/agent-runtime/compact/architect.js +8 -9
  11. package/dist/agent-runtime/compact/chat-client.d.ts +3 -3
  12. package/dist/agent-runtime/compact/chat-client.js +1 -2
  13. package/dist/agent-runtime/compact/developer.d.ts +3 -70
  14. package/dist/agent-runtime/compact/developer.js +13 -14
  15. package/dist/agent-runtime/compact/environment.d.ts +4 -5
  16. package/dist/agent-runtime/compact/environment.js +1 -2
  17. package/dist/agent-runtime/compact/exit-code-honesty.d.ts +2 -1
  18. package/dist/agent-runtime/compact/exit-code-honesty.js +0 -1
  19. package/dist/agent-runtime/compact/guarded-loop.d.ts +2 -18
  20. package/dist/agent-runtime/compact/guarded-loop.js +7 -8
  21. package/dist/agent-runtime/compact/prompt-inputs.d.ts +0 -2
  22. package/dist/agent-runtime/compact/prompt-inputs.js +1 -2
  23. package/dist/agent-runtime/compact/reviewer.d.ts +0 -13
  24. package/dist/agent-runtime/compact/reviewer.js +5 -6
  25. package/dist/agent-runtime/compact/step.d.ts +0 -1
  26. package/dist/agent-runtime/compact/step.js +1 -2
  27. package/dist/agent-runtime/compact/test-reachability.js +0 -1
  28. package/dist/agent-runtime/config.js +0 -1
  29. package/dist/agent-runtime/core-host.d.ts +1 -1
  30. package/dist/agent-runtime/core-host.js +1 -2
  31. package/dist/agent-runtime/durable-store.d.ts +0 -1
  32. package/dist/agent-runtime/durable-store.js +1 -2
  33. package/dist/agent-runtime/efficiency-summary.d.ts +2 -2
  34. package/dist/agent-runtime/efficiency-summary.js +1 -2
  35. package/dist/agent-runtime/efficiency-types.js +0 -1
  36. package/dist/agent-runtime/efficiency.js +0 -1
  37. package/dist/agent-runtime/evaluation-corpus.js +0 -1
  38. package/dist/agent-runtime/evaluation.d.ts +2 -1
  39. package/dist/agent-runtime/evaluation.js +1 -2
  40. package/dist/agent-runtime/executor-types.d.ts +1 -1
  41. package/dist/agent-runtime/executor-types.js +0 -1
  42. package/dist/agent-runtime/executors.js +0 -1
  43. package/dist/agent-runtime/gemini-policy.js +0 -1
  44. package/dist/agent-runtime/graph/artifacts.d.ts +1 -1
  45. package/dist/agent-runtime/graph/artifacts.js +1 -2
  46. package/dist/agent-runtime/graph/nodes.d.ts +1 -1
  47. package/dist/agent-runtime/graph/nodes.js +1 -2
  48. package/dist/agent-runtime/graph/review-policy.js +0 -1
  49. package/dist/agent-runtime/graph/roles.d.ts +2 -5
  50. package/dist/agent-runtime/graph/roles.js +2 -8
  51. package/dist/agent-runtime/graph/state.d.ts +1 -1
  52. package/dist/agent-runtime/graph/state.js +0 -1
  53. package/dist/agent-runtime/graph-checkpointer.d.ts +2 -1
  54. package/dist/agent-runtime/graph-checkpointer.js +0 -1
  55. package/dist/agent-runtime/guardrails.d.ts +3 -3
  56. package/dist/agent-runtime/guardrails.js +1 -2
  57. package/dist/agent-runtime/index.d.ts +1 -1
  58. package/dist/agent-runtime/index.js +1 -2
  59. package/dist/agent-runtime/kimi-acp.js +1 -2
  60. package/dist/agent-runtime/kimi-model.d.ts +6 -0
  61. package/dist/agent-runtime/kimi-model.js +12 -0
  62. package/dist/agent-runtime/openai-executor.d.ts +0 -9
  63. package/dist/agent-runtime/openai-executor.js +6 -7
  64. package/dist/agent-runtime/openspec-tool-server.js +1 -2
  65. package/dist/agent-runtime/openspec.d.ts +0 -2
  66. package/dist/agent-runtime/openspec.js +1 -6
  67. package/dist/agent-runtime/prompts.d.ts +4 -3
  68. package/dist/agent-runtime/prompts.js +0 -1
  69. package/dist/agent-runtime/provider-diagnostic.js +1 -2
  70. package/dist/agent-runtime/recovery.js +1 -2
  71. package/dist/agent-runtime/repository-context.d.ts +1 -1
  72. package/dist/agent-runtime/repository-context.js +0 -1
  73. package/dist/agent-runtime/review-context.d.ts +1 -1
  74. package/dist/agent-runtime/review-context.js +0 -1
  75. package/dist/agent-runtime/role-routing.js +0 -1
  76. package/dist/agent-runtime/role-state.js +0 -1
  77. package/dist/agent-runtime/runtime-identity.js +1 -2
  78. package/dist/agent-runtime/tool-event.js +0 -1
  79. package/dist/agent-runtime/verification-plan.d.ts +5 -4
  80. package/dist/agent-runtime/verification-plan.js +1 -2
  81. package/dist/agent-runtime/workflow-types.js +0 -1
  82. package/dist/agent-runtime/workflow.js +0 -1
  83. package/dist/agent-runtime/workspace-tools.d.ts +2 -2
  84. package/dist/agent-runtime/workspace-tools.js +1 -2
  85. package/dist/installer/cli.d.ts +3 -32
  86. package/dist/installer/cli.js +26 -101
  87. package/dist/installer/commands/framework.d.ts +4 -3
  88. package/dist/installer/commands/framework.js +0 -1
  89. package/dist/installer/commands/init.d.ts +4 -25
  90. package/dist/installer/commands/init.js +5 -8
  91. package/dist/installer/phases/framework-lifecycle.d.ts +3 -17
  92. package/dist/installer/phases/framework-lifecycle.js +2 -3
  93. package/dist/installer/phases/install-config.d.ts +7 -8
  94. package/dist/installer/phases/install-config.js +2 -7
  95. package/dist/installer/phases/manifest.d.ts +6 -7
  96. package/dist/installer/phases/manifest.js +2 -7
  97. package/dist/installer/phases/prereqs.d.ts +6 -7
  98. package/dist/installer/phases/prereqs.js +4 -6
  99. package/dist/installer/phases/provider-detect.d.ts +6 -7
  100. package/dist/installer/phases/provider-detect.js +2 -4
  101. package/dist/installer/phases/scaffold.d.ts +9 -10
  102. package/dist/installer/phases/scaffold.js +82 -805
  103. package/dist/installer/util/errors.js +0 -1
  104. package/dist/installer/util/exec.d.ts +3 -2
  105. package/dist/installer/util/exec.js +0 -1
  106. package/dist/installer/util/fs.d.ts +0 -10
  107. package/dist/installer/util/fs.js +1 -2
  108. package/dist/installer/util/git.js +0 -1
  109. package/dist/installer/util/install-transaction.d.ts +2 -2
  110. package/dist/installer/util/install-transaction.js +1 -2
  111. package/dist/installer/util/logger.d.ts +1 -3
  112. package/dist/installer/util/logger.js +0 -1
  113. package/dist/installer/util/paths.js +0 -1
  114. package/dist/installer/util/registry.d.ts +4 -8
  115. package/dist/installer/util/registry.js +2 -3
  116. package/dist/{installer/runtime → pipeline}/pipeline-state.js +0 -3
  117. package/dist/shared/args.d.ts +18 -0
  118. package/dist/shared/args.js +53 -0
  119. package/integration-contract.json +10 -46
  120. package/package.json +3 -10
  121. package/templates/agents/sr-architect.md +15 -310
  122. package/templates/agents/sr-developer.md +15 -269
  123. package/templates/agents/sr-reviewer.md +13 -367
  124. package/templates/codex-skills/rails/sr-architect/SKILL.md +14 -308
  125. package/templates/codex-skills/rails/sr-developer/SKILL.md +14 -201
  126. package/templates/codex-skills/rails/sr-reviewer/SKILL.md +15 -289
  127. package/templates/kimi/specrails/run-skill.mjs +91 -2173
  128. package/bin/tui-installer.mjs +0 -430
  129. package/commands/doctor.md +0 -62
  130. package/dist/agent-runtime/capabilities.js.map +0 -1
  131. package/dist/agent-runtime/cli-executor.js.map +0 -1
  132. package/dist/agent-runtime/cli-process.js.map +0 -1
  133. package/dist/agent-runtime/cli.js.map +0 -1
  134. package/dist/agent-runtime/codex-schema.js.map +0 -1
  135. package/dist/agent-runtime/compact/architect.js.map +0 -1
  136. package/dist/agent-runtime/compact/chat-client.js.map +0 -1
  137. package/dist/agent-runtime/compact/developer.js.map +0 -1
  138. package/dist/agent-runtime/compact/environment.js.map +0 -1
  139. package/dist/agent-runtime/compact/exit-code-honesty.js.map +0 -1
  140. package/dist/agent-runtime/compact/guarded-loop.js.map +0 -1
  141. package/dist/agent-runtime/compact/prompt-inputs.js.map +0 -1
  142. package/dist/agent-runtime/compact/reviewer.js.map +0 -1
  143. package/dist/agent-runtime/compact/step.js.map +0 -1
  144. package/dist/agent-runtime/compact/test-reachability.js.map +0 -1
  145. package/dist/agent-runtime/config.js.map +0 -1
  146. package/dist/agent-runtime/core-host.js.map +0 -1
  147. package/dist/agent-runtime/durable-store.js.map +0 -1
  148. package/dist/agent-runtime/efficiency-summary.js.map +0 -1
  149. package/dist/agent-runtime/efficiency-types.js.map +0 -1
  150. package/dist/agent-runtime/efficiency.js.map +0 -1
  151. package/dist/agent-runtime/evaluation-corpus.js.map +0 -1
  152. package/dist/agent-runtime/evaluation.js.map +0 -1
  153. package/dist/agent-runtime/executor-types.js.map +0 -1
  154. package/dist/agent-runtime/executors.js.map +0 -1
  155. package/dist/agent-runtime/gemini-policy.js.map +0 -1
  156. package/dist/agent-runtime/graph/artifacts.js.map +0 -1
  157. package/dist/agent-runtime/graph/nodes.js.map +0 -1
  158. package/dist/agent-runtime/graph/review-policy.js.map +0 -1
  159. package/dist/agent-runtime/graph/roles.js.map +0 -1
  160. package/dist/agent-runtime/graph/state.js.map +0 -1
  161. package/dist/agent-runtime/graph-checkpointer.js.map +0 -1
  162. package/dist/agent-runtime/guardrails.js.map +0 -1
  163. package/dist/agent-runtime/index.js.map +0 -1
  164. package/dist/agent-runtime/kimi-acp.js.map +0 -1
  165. package/dist/agent-runtime/openai-executor.js.map +0 -1
  166. package/dist/agent-runtime/openspec-tool-server.js.map +0 -1
  167. package/dist/agent-runtime/openspec.js.map +0 -1
  168. package/dist/agent-runtime/prompts.js.map +0 -1
  169. package/dist/agent-runtime/provider-diagnostic.js.map +0 -1
  170. package/dist/agent-runtime/recovery.js.map +0 -1
  171. package/dist/agent-runtime/repository-context.js.map +0 -1
  172. package/dist/agent-runtime/review-context.js.map +0 -1
  173. package/dist/agent-runtime/role-routing.js.map +0 -1
  174. package/dist/agent-runtime/role-state.js.map +0 -1
  175. package/dist/agent-runtime/runtime-identity.js.map +0 -1
  176. package/dist/agent-runtime/tool-event.js.map +0 -1
  177. package/dist/agent-runtime/verification-plan.js.map +0 -1
  178. package/dist/agent-runtime/workflow-types.js.map +0 -1
  179. package/dist/agent-runtime/workflow.js.map +0 -1
  180. package/dist/agent-runtime/workspace-tools.js.map +0 -1
  181. package/dist/installer/cli.js.map +0 -1
  182. package/dist/installer/commands/doctor.d.ts +0 -27
  183. package/dist/installer/commands/doctor.js +0 -615
  184. package/dist/installer/commands/doctor.js.map +0 -1
  185. package/dist/installer/commands/framework.js.map +0 -1
  186. package/dist/installer/commands/init.js.map +0 -1
  187. package/dist/installer/commands/update.d.ts +0 -56
  188. package/dist/installer/commands/update.js +0 -257
  189. package/dist/installer/commands/update.js.map +0 -1
  190. package/dist/installer/commands/v5-migration.d.ts +0 -32
  191. package/dist/installer/commands/v5-migration.js +0 -133
  192. package/dist/installer/commands/v5-migration.js.map +0 -1
  193. package/dist/installer/phases/framework-lifecycle.js.map +0 -1
  194. package/dist/installer/phases/install-config.js.map +0 -1
  195. package/dist/installer/phases/manifest.js.map +0 -1
  196. package/dist/installer/phases/prereqs.js.map +0 -1
  197. package/dist/installer/phases/provider-detect.js.map +0 -1
  198. package/dist/installer/phases/scaffold.js.map +0 -1
  199. package/dist/installer/runtime/kimi.d.ts +0 -84
  200. package/dist/installer/runtime/kimi.js +0 -255
  201. package/dist/installer/runtime/kimi.js.map +0 -1
  202. package/dist/installer/runtime/pipeline-state.js.map +0 -1
  203. package/dist/installer/util/errors.js.map +0 -1
  204. package/dist/installer/util/exec.js.map +0 -1
  205. package/dist/installer/util/fs.js.map +0 -1
  206. package/dist/installer/util/git.js.map +0 -1
  207. package/dist/installer/util/install-transaction.js.map +0 -1
  208. package/dist/installer/util/logger.js.map +0 -1
  209. package/dist/installer/util/paths.js.map +0 -1
  210. package/dist/installer/util/prompts.d.ts +0 -23
  211. package/dist/installer/util/prompts.js +0 -49
  212. package/dist/installer/util/prompts.js.map +0 -1
  213. package/dist/installer/util/registry.js.map +0 -1
  214. package/dist/installer/util/template.d.ts +0 -23
  215. package/dist/installer/util/template.js +0 -60
  216. package/dist/installer/util/template.js.map +0 -1
  217. package/docs/README.md +0 -40
  218. package/docs/agent-runtime-efficiency.md +0 -65
  219. package/docs/agent-runtime.md +0 -393
  220. package/docs/agents.md +0 -315
  221. package/docs/changelog.md +0 -168
  222. package/docs/ci-cd.md +0 -60
  223. package/docs/concepts.md +0 -183
  224. package/docs/customization.md +0 -363
  225. package/docs/deployment.md +0 -234
  226. package/docs/getting-started.md +0 -122
  227. package/docs/installation.md +0 -395
  228. package/docs/local-tickets.md +0 -191
  229. package/docs/migration-guide.md +0 -140
  230. package/docs/playbook-oss-maintainer.md +0 -112
  231. package/docs/playbook-parallel-dev.md +0 -124
  232. package/docs/playbook-product-discovery.md +0 -115
  233. package/docs/plugin-architecture.md +0 -144
  234. package/docs/research/codex-compatibility-analysis.md +0 -365
  235. package/docs/research/mcp-feasibility-analysis.md +0 -382
  236. package/docs/testing/test-matrix-codex.md +0 -130
  237. package/docs/updating.md +0 -89
  238. package/docs/user-docs/cli-reference.md +0 -428
  239. package/docs/user-docs/codex-vs-claude-code.md +0 -23
  240. package/docs/user-docs/core-updates.md +0 -70
  241. package/docs/user-docs/faq.md +0 -146
  242. package/docs/user-docs/getting-started-codex.md +0 -194
  243. package/docs/user-docs/getting-started-kimi.md +0 -423
  244. package/docs/user-docs/installation.md +0 -237
  245. package/docs/user-docs/provider-pipelines.md +0 -96
  246. package/docs/user-docs/quick-start.md +0 -161
  247. package/docs/windows.md +0 -78
  248. package/docs/workflows.md +0 -463
  249. package/schemas/profile.v1.json +0 -207
  250. package/templates/claude-md/CLAUDE-quickstart.md +0 -54
  251. package/templates/claude-md/root.md +0 -50
  252. package/templates/codex-skills/batch-implement/SKILL.md +0 -38
  253. package/templates/codex-skills/implement/SKILL.md +0 -38
  254. package/templates/codex-skills/retry/SKILL.md +0 -16
  255. package/templates/commands/specrails/compat-check.md +0 -271
  256. package/templates/commands/specrails/doctor.md +0 -62
  257. package/templates/commands/specrails/explore-spec.md +0 -173
  258. package/templates/commands/specrails/health-check.md +0 -527
  259. package/templates/commands/specrails/memory-inspect.md +0 -261
  260. package/templates/commands/specrails/opsx-diff.md +0 -419
  261. package/templates/commands/specrails/propose-spec.md +0 -102
  262. package/templates/commands/specrails/refactor-recommender.md +0 -169
  263. package/templates/commands/specrails/telemetry.md +0 -553
  264. package/templates/commands/specrails/why.md +0 -96
  265. package/templates/gemini-commands/batch-implement.toml +0 -37
  266. package/templates/gemini-commands/implement.toml +0 -37
  267. package/templates/gemini-commands/retry.toml +0 -15
  268. package/templates/profiles/default.json +0 -14
  269. package/templates/profiles/kimi-default.json +0 -15
  270. package/templates/rules/layer.md +0 -8
  271. package/templates/runtime/provider-pipeline.md +0 -113
  272. package/templates/security/security-exemptions.yaml +0 -20
  273. package/templates/settings/confidence-config.json +0 -17
  274. package/templates/settings/settings.json +0 -15
  275. /package/dist/{installer/runtime → pipeline}/pipeline-state.d.ts +0 -0
@@ -1,102 +0,0 @@
1
- ---
2
- description: Explore a spec idea and produce a structured proposal
3
- ---
4
-
5
- You are a senior product engineer helping evaluate and structure a spec proposal for this codebase.
6
-
7
- The user's raw idea is:
8
-
9
- $ARGUMENTS
10
-
11
- ## Your Task
12
-
13
- Before proposing anything, explore the codebase to understand:
14
- 1. What already exists that relates to this idea
15
- 2. What the current architecture looks like in the relevant area
16
- 3. What constraints or patterns you must respect
17
-
18
- Use Read, Glob, and Grep to explore. Take at least 3 codebase reads before writing the proposal.
19
-
20
- ## Required Output
21
-
22
- Output ONLY the following structured markdown. Do not add any preamble or explanation outside these sections.
23
-
24
- ## Spec Title
25
- [A concise, action-oriented title, e.g., "Add Real-Time Cost Alerts"]
26
-
27
- ## Problem Statement
28
- [2-3 sentences: what problem does this solve? Who experiences it? What is the current workaround?]
29
-
30
- ## Proposed Solution
31
- [3-5 sentences: what exactly will be built? Be specific about the UI, API, and data changes.]
32
-
33
- ## Out of Scope
34
- [Bullet list of things this proposal deliberately does NOT cover]
35
-
36
- ## Acceptance Criteria
37
- [Numbered list of testable outcomes. Each criterion must be independently verifiable.]
38
-
39
- ## Technical Considerations
40
- [Bullet list of implementation notes, constraints from the existing architecture, risks, and dependencies]
41
-
42
- ## Estimated Complexity
43
- [One of: Low (< 1 day) / Medium (1-3 days) / High (3-7 days) / Very High (> 1 week)]
44
- [One sentence justifying the estimate]
45
-
46
- ---
47
-
48
- ## Backlog Sync
49
-
50
- After generating the proposal, read `.specrails/backlog-config.json` to determine `BACKLOG_PROVIDER` and `BACKLOG_WRITE`.
51
-
52
- If `.specrails/backlog-config.json` does not exist, default to `provider=local` and `write_access=true`. Initialize `.specrails/local-tickets.json` if it does not exist (empty store with `schema_version: "1.0"`, `revision: 0`, `next_id: 1`, `tickets: {}`).
53
-
54
- ### If provider=local — Create Local Ticket
55
-
56
- Create a local ticket from the proposal output:
57
-
58
- ```
59
- {{BACKLOG_CREATE_CMD}}
60
- ```
61
-
62
- Set the following fields:
63
- - `title`: The Spec Title from the proposal
64
- - `description`: The full structured proposal markdown (all sections from Problem Statement through Estimated Complexity)
65
- - `status`: `"todo"`
66
- - `priority`: Map Estimated Complexity — Low → `"low"`, Medium → `"medium"`, High/Very High → `"high"`
67
- - `labels`: `["spec-proposal"]`
68
- - `source`: `"propose-spec"`
69
- - `created_by`: `"sr-architect"`
70
-
71
- Print: `Created local ticket #{id}: {title}`
72
-
73
- ### If provider=github and BACKLOG_WRITE=true — Create GitHub Issue
74
-
75
- ```bash
76
- {{BACKLOG_CREATE_CMD}}
77
- ```
78
-
79
- Create a GitHub Issue with:
80
- - Title: The Spec Title
81
- - Body: Full structured proposal markdown
82
- - Labels: `spec-proposal`
83
-
84
- Print: `Created GitHub Issue #{number}: {title}`
85
-
86
- ### If provider=jira and BACKLOG_WRITE=true — Create JIRA Story
87
-
88
- Create a JIRA Story using the same authentication and API pattern as `/specrails:auto-propose-backlog-specs`:
89
- - Summary: The Spec Title
90
- - Description: Full structured proposal in Atlassian Document Format
91
- - Labels: `spec-proposal`
92
-
93
- Print: `Created JIRA ticket {key}: {title}`
94
-
95
- ### If BACKLOG_WRITE=false or provider=none
96
-
97
- Do NOT create any tickets. Print:
98
- ```
99
- Spec proposal ready. Create a ticket manually if desired:
100
- Title: {Spec Title}
101
- Complexity: {Estimated Complexity}
102
- ```
@@ -1,169 +0,0 @@
1
- ---
2
- name: "Refactor Recommender"
3
- description: "Scan the codebase for refactoring opportunities ranked by impact/effort ratio. Analyzes code for duplicates, long functions, large files, dead code, outdated patterns, and complex logic. Optionally creates GitHub Issues for tracking."
4
- category: Workflow
5
- tags: [workflow, refactoring, code-quality, tech-debt]
6
- ---
7
-
8
- Scan the codebase for refactoring opportunities, score each by impact/effort ratio, and optionally create GitHub Issues for the top findings in {{BACKLOG_PROVIDER_NAME}}.
9
-
10
- **Input:** `$ARGUMENTS` — optional: comma-separated paths to scope the analysis. Flags: `--dry-run` (print findings without creating issues).
11
-
12
- ---
13
-
14
- ## Phase 0: Pre-flight
15
-
16
- Check whether the GitHub CLI is available:
17
-
18
- ```bash
19
- {{BACKLOG_PREFLIGHT}}
20
- ```
21
-
22
- 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.
23
-
24
- ---
25
-
26
- ## Phase 1: Scope
27
-
28
- Parse paths from `$ARGUMENTS` after stripping any flags. If no paths are provided, scan the entire repository.
29
-
30
- Always exclude the following from all analysis:
31
-
32
- - `node_modules/`
33
- - `.git/`
34
- - `.claude/`
35
- - `vendor/`
36
- - `dist/`
37
- - `build/`
38
-
39
- ---
40
-
41
- ## Phase 2: Analysis
42
-
43
- Analyze the scoped files across six categories. For each finding record:
44
-
45
- - **file** — relative path
46
- - **line_range** — start and end line numbers
47
- - **current_snippet** — the problematic code as-is
48
- - **proposed_snippet** — concrete refactored version
49
- - **rationale** — one sentence explaining the improvement
50
-
51
- ### Duplicate Code
52
-
53
- 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.
54
-
55
- ### Long Functions
56
-
57
- Find functions or methods exceeding 50 lines. Extraction into smaller, single-purpose functions is the expected refactoring.
58
-
59
- ### Large Files
60
-
61
- Find files exceeding 300 lines. Splitting into cohesive modules is the expected refactoring.
62
-
63
- ### Dead Code
64
-
65
- 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.
66
-
67
- ### Outdated Patterns
68
-
69
- 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.
70
-
71
- ### Complex Logic
72
-
73
- 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.
74
-
75
- ---
76
-
77
- ## Phase 3: Score and Rank
78
-
79
- Score every finding on two dimensions (1–5 each):
80
-
81
- - **Impact** — how much the refactoring improves code quality, readability, or maintainability
82
- - **Effort** — how hard the refactoring is to implement (1 = trivial, 5 = major)
83
-
84
- **Composite score**: `impact * 2 + (6 - effort)`. Higher is better.
85
-
86
- 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.
87
-
88
- ---
89
-
90
- ## Phase 4: Create GitHub Issues
91
-
92
- Skip this phase if `GH_AVAILABLE=false` or `DRY_RUN=true`.
93
-
94
- First ensure the tracking labels exist:
95
-
96
- ```bash
97
- gh label create "refactor-opportunity" --color "B60205" --force
98
- ```
99
-
100
- Fetch existing open issues that already carry the label to avoid duplicates:
101
-
102
- ```bash
103
- gh issue list --label "refactor-opportunity" --state open --limit 100 --json number,title
104
- ```
105
-
106
- 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:
107
-
108
- ```
109
- ## Refactoring Opportunity: {description}
110
-
111
- **Category**: {category}
112
- **File**: {file}:{line_range}
113
- **Impact**: {impact}/5 | **Effort**: {effort}/5 | **Score**: {composite}
114
-
115
- ### Current Code
116
- ```{lang}
117
- {current_snippet}
118
- ```
119
-
120
- ### Proposed Refactoring
121
- ```{lang}
122
- {proposed_snippet}
123
- ```
124
-
125
- ### Rationale
126
- {rationale}
127
-
128
- ---
129
- _Generated by `/specrails:refactor-recommender` in {{PROJECT_NAME}}_
130
- ```
131
-
132
- ---
133
-
134
- ## Phase 5: Output Summary
135
-
136
- Print the following report:
137
-
138
- ```
139
- ## Refactoring Opportunities — {{PROJECT_NAME}}
140
-
141
- {N} opportunities found | Sorted by composite score
142
-
143
- | # | Category | File | Impact | Effort | Score | Description |
144
- |---|----------|------|--------|--------|-------|-------------|
145
- | 1 | {category} | {file}:{line_range} | {impact}/5 | {effort}/5 | {composite} | {description} |
146
- ...
147
-
148
- ### Top 3 Detailed Recommendations
149
-
150
- #### 1. {description}
151
- **File**: {file}:{line_range}
152
- **Category**: {category} | **Score**: {composite}
153
-
154
- **Current:**
155
- ```{lang}
156
- {current_snippet}
157
- ```
158
-
159
- **Proposed:**
160
- ```{lang}
161
- {proposed_snippet}
162
- ```
163
-
164
- **Rationale:** {rationale}
165
-
166
- (repeat for #2 and #3)
167
-
168
- Issues created: {N} (or "dry-run: no issues created")
169
- ```