specrails-desktop 2.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 (455) hide show
  1. package/.claude/commands/specrails/batch-implement.md +287 -0
  2. package/.claude/commands/specrails/compat-check.md +271 -0
  3. package/.claude/commands/specrails/doctor.md +62 -0
  4. package/.claude/commands/specrails/enrich.md +1635 -0
  5. package/.claude/commands/specrails/explore-spec.md +173 -0
  6. package/.claude/commands/specrails/health-check.md +527 -0
  7. package/.claude/commands/specrails/implement.md +1457 -0
  8. package/.claude/commands/specrails/memory-inspect.md +259 -0
  9. package/.claude/commands/specrails/opsx-diff.md +419 -0
  10. package/.claude/commands/specrails/propose-spec.md +102 -0
  11. package/.claude/commands/specrails/reconfig.md +89 -0
  12. package/.claude/commands/specrails/refactor-recommender.md +212 -0
  13. package/.claude/commands/specrails/retry.md +363 -0
  14. package/.claude/commands/specrails/telemetry.md +552 -0
  15. package/.claude/commands/specrails/why.md +96 -0
  16. package/LICENSE +21 -0
  17. package/README.md +290 -0
  18. package/cli/dist/specrails-desktop.js +1098 -0
  19. package/client/dist/assets/ActivityFeedPage-Gy4x8dBt.js +1 -0
  20. package/client/dist/assets/AgentsPage-CPgu--Fb.js +86 -0
  21. package/client/dist/assets/AnalyticsPage-B5sJEee2.js +1 -0
  22. package/client/dist/assets/BarChart-7IMQ8HY1.js +33 -0
  23. package/client/dist/assets/CodePage-CBdFvbwe.js +2 -0
  24. package/client/dist/assets/DesktopAnalyticsPage-w0rdTq4w.js +1 -0
  25. package/client/dist/assets/DocsDialog-BZUYM7wm.js +11 -0
  26. package/client/dist/assets/DocsPage-9QglWl46.js +11 -0
  27. package/client/dist/assets/ExportDropdown-BLZFXtNi.js +1 -0
  28. package/client/dist/assets/IntegrationsPage-BxBE4y99.js +3 -0
  29. package/client/dist/assets/JobDetailPage-DydWx_5S.js +16 -0
  30. package/client/dist/assets/JobsPage-20ibw0IO.js +1 -0
  31. package/client/dist/assets/abap-Bw6f2wDG.js +1 -0
  32. package/client/dist/assets/activity-BEIp_Y1A.js +1 -0
  33. package/client/dist/assets/activity-BdrPln96.js +1 -0
  34. package/client/dist/assets/activity-CpkRS8Sx.js +1 -0
  35. package/client/dist/assets/activity-DKCpESPt.js +1 -0
  36. package/client/dist/assets/activity-DOUVEjJi.js +1 -0
  37. package/client/dist/assets/activity-DRwkql_y.js +1 -0
  38. package/client/dist/assets/activity-DcDQ7tjw.js +1 -0
  39. package/client/dist/assets/activity-Dv6H7wEr.js +1 -0
  40. package/client/dist/assets/addon-image-3WCl5Vhd.js +1 -0
  41. package/client/dist/assets/addon-ligatures-C5OdliKs.js +2 -0
  42. package/client/dist/assets/addon-webgl-BbX6pSjl.js +44 -0
  43. package/client/dist/assets/addspec-B5yl4Loj.js +1 -0
  44. package/client/dist/assets/addspec-BEeF5-zc.js +1 -0
  45. package/client/dist/assets/addspec-D33ocMxf.js +1 -0
  46. package/client/dist/assets/addspec-DFswZ0jK.js +1 -0
  47. package/client/dist/assets/addspec-DRE-jZv7.js +1 -0
  48. package/client/dist/assets/addspec-DVZ15Jp8.js +1 -0
  49. package/client/dist/assets/addspec-Fkv91Opc.js +1 -0
  50. package/client/dist/assets/addspec-GWm4ffKl.js +1 -0
  51. package/client/dist/assets/agents-1nCDWRmP.js +1 -0
  52. package/client/dist/assets/agents-Bm9rPqnt.js +1 -0
  53. package/client/dist/assets/agents-CMxtJMLD.js +1 -0
  54. package/client/dist/assets/agents-DK-Dlc0i.js +1 -0
  55. package/client/dist/assets/agents-Q6Ldfpxx.js +1 -0
  56. package/client/dist/assets/agents-TeOSy-ax.js +1 -0
  57. package/client/dist/assets/agents-iTqjRajS.js +1 -0
  58. package/client/dist/assets/agents-s87sMGzL.js +1 -0
  59. package/client/dist/assets/agentstudio-B6Wb59E7.js +1 -0
  60. package/client/dist/assets/agentstudio-BADhZ41e.js +1 -0
  61. package/client/dist/assets/agentstudio-BSnWLR63.js +1 -0
  62. package/client/dist/assets/agentstudio-BdidyBzZ.js +1 -0
  63. package/client/dist/assets/agentstudio-CxlUllqI.js +1 -0
  64. package/client/dist/assets/agentstudio-D3I62TLJ.js +1 -0
  65. package/client/dist/assets/agentstudio-DuH9TogZ.js +1 -0
  66. package/client/dist/assets/agentstudio-Kw88_dUF.js +1 -0
  67. package/client/dist/assets/aiedit-BWxHGsYA.js +1 -0
  68. package/client/dist/assets/aiedit-D2ji6Qy0.js +1 -0
  69. package/client/dist/assets/aiedit-DAhZTvtk.js +1 -0
  70. package/client/dist/assets/aiedit-DJMny-D5.js +1 -0
  71. package/client/dist/assets/aiedit-DOcxERkU.js +1 -0
  72. package/client/dist/assets/aiedit-DvrcbwGv.js +1 -0
  73. package/client/dist/assets/aiedit-TTwzL1TS.js +1 -0
  74. package/client/dist/assets/aiedit-WBSjT_C1.js +1 -0
  75. package/client/dist/assets/analytics-BIdr0YfL.js +1 -0
  76. package/client/dist/assets/analytics-C6EzgtdE.js +1 -0
  77. package/client/dist/assets/analytics-C9Zc-rkM.js +1 -0
  78. package/client/dist/assets/analytics-CVx3YOc0.js +1 -0
  79. package/client/dist/assets/analytics-CYj0tfj7.js +1 -0
  80. package/client/dist/assets/analytics-CnY4kNG3.js +1 -0
  81. package/client/dist/assets/analytics-CrPCZRJ-.js +1 -0
  82. package/client/dist/assets/analytics-DMCto-TF.js +1 -0
  83. package/client/dist/assets/apex-Cw8_REBo.js +1 -0
  84. package/client/dist/assets/atom-one-dark-B-oHczHB.css +1 -0
  85. package/client/dist/assets/attachments-BIsSSnHJ.js +1 -0
  86. package/client/dist/assets/attachments-BW4L3l2L.js +1 -0
  87. package/client/dist/assets/attachments-Bcf6BG6V.js +1 -0
  88. package/client/dist/assets/attachments-Bke8sCU4.js +1 -0
  89. package/client/dist/assets/attachments-COcrGRFz.js +1 -0
  90. package/client/dist/assets/attachments-DYHGA2Dj.js +1 -0
  91. package/client/dist/assets/attachments-Dd92KpUH.js +1 -0
  92. package/client/dist/assets/attachments-DzdU6DV6.js +1 -0
  93. package/client/dist/assets/azcli-Cz6HAoOw.js +1 -0
  94. package/client/dist/assets/bat-CcJ-xyqL.js +1 -0
  95. package/client/dist/assets/bicep-z1WDCKYz.js +2 -0
  96. package/client/dist/assets/browser-5ErDlJoR.js +1 -0
  97. package/client/dist/assets/browser-Bc-YdlVg.js +1 -0
  98. package/client/dist/assets/browser-BlYF4OOq.js +1 -0
  99. package/client/dist/assets/browser-CT-ReZGt.js +1 -0
  100. package/client/dist/assets/browser-DGITz3fC.js +1 -0
  101. package/client/dist/assets/browser-JsAIGCEW.js +1 -0
  102. package/client/dist/assets/browser-M5-rbPlw.js +1 -0
  103. package/client/dist/assets/browser-Qya9cARy.js +1 -0
  104. package/client/dist/assets/cameligo-BRewOpfa.js +1 -0
  105. package/client/dist/assets/chat-BEGuC03z.js +1 -0
  106. package/client/dist/assets/chat-BEW60P_u.js +1 -0
  107. package/client/dist/assets/chat-BQNMD0PL.js +1 -0
  108. package/client/dist/assets/chat-BsbNGPW9.js +1 -0
  109. package/client/dist/assets/chat-CboQguCi.js +1 -0
  110. package/client/dist/assets/chat-DRCa9pOt.js +1 -0
  111. package/client/dist/assets/chat-DwUm6W9z.js +1 -0
  112. package/client/dist/assets/chat-yoXwguQu.js +1 -0
  113. package/client/dist/assets/chunk-CilyBKbf.js +1 -0
  114. package/client/dist/assets/clojure-DBjRWN6g.js +1 -0
  115. package/client/dist/assets/clsx-DnqN-uhr.js +1 -0
  116. package/client/dist/assets/code-AL1rVIMb.js +1 -0
  117. package/client/dist/assets/code-C0BKpkht.js +1 -0
  118. package/client/dist/assets/code-C0FTS3ew.js +1 -0
  119. package/client/dist/assets/code-CPcHxzxw.js +1 -0
  120. package/client/dist/assets/code-D3ryDniw.js +1 -0
  121. package/client/dist/assets/code-D3zVVQTj.js +1 -0
  122. package/client/dist/assets/code-PCmfS3dn.js +1 -0
  123. package/client/dist/assets/code-exI0G5Wd.js +1 -0
  124. package/client/dist/assets/codicon-ngg6Pgfi.ttf +0 -0
  125. package/client/dist/assets/coffee-Cfk_XHGR.js +1 -0
  126. package/client/dist/assets/commands-B772IyDa.js +1 -0
  127. package/client/dist/assets/commands-BDDp6xFG.js +1 -0
  128. package/client/dist/assets/commands-CJxCry-o.js +1 -0
  129. package/client/dist/assets/commands-CfgY-_of.js +1 -0
  130. package/client/dist/assets/commands-DLrvnPNg.js +1 -0
  131. package/client/dist/assets/commands-IXMOKBYt.js +1 -0
  132. package/client/dist/assets/commands-UD1NzmwX.js +1 -0
  133. package/client/dist/assets/commands-sqrqsxyE.js +1 -0
  134. package/client/dist/assets/common-DCr6VzJ7.js +1 -0
  135. package/client/dist/assets/common-Dard9UNH.js +1 -0
  136. package/client/dist/assets/common-DeDELLZJ.js +1 -0
  137. package/client/dist/assets/common-DltqHaAe.js +1 -0
  138. package/client/dist/assets/common-Dmm1GhdD.js +1 -0
  139. package/client/dist/assets/common-DnjcgkPH.js +1 -0
  140. package/client/dist/assets/common-GbpxfPG8.js +1 -0
  141. package/client/dist/assets/common-wA36jmj1.js +1 -0
  142. package/client/dist/assets/cpp-BVob6BaP.js +1 -0
  143. package/client/dist/assets/csharp-C4fbRuOu.js +1 -0
  144. package/client/dist/assets/csp-DthFP_vT.js +1 -0
  145. package/client/dist/assets/css-CGMH0hcW.js +3 -0
  146. package/client/dist/assets/css.worker-Wv5dxAWO.js +89 -0
  147. package/client/dist/assets/cssMode-Cc6ozl-J.js +1 -0
  148. package/client/dist/assets/cypher-Pnf68BRV.js +1 -0
  149. package/client/dist/assets/dart-PMMOtxZX.js +1 -0
  150. package/client/dist/assets/dashboard-B4ixDVk8.js +1 -0
  151. package/client/dist/assets/dashboard-BZBADHSj.js +1 -0
  152. package/client/dist/assets/dashboard-C1MfeUHs.js +1 -0
  153. package/client/dist/assets/dashboard-C7SK6xu5.js +1 -0
  154. package/client/dist/assets/dashboard-CB6Le1yN.js +1 -0
  155. package/client/dist/assets/dashboard-CoTpMOBM.js +1 -0
  156. package/client/dist/assets/dashboard-Duo4DDCW.js +1 -0
  157. package/client/dist/assets/dashboard-I19DXBxw.js +1 -0
  158. package/client/dist/assets/dist-js-BY-Fv_fg.js +1 -0
  159. package/client/dist/assets/dist-js-Bakc4uxT.js +1 -0
  160. package/client/dist/assets/dockerfile-di1nsJCc.js +1 -0
  161. package/client/dist/assets/ecl-D_WVcB5M.js +1 -0
  162. package/client/dist/assets/editor-Br_kD0ds.css +1 -0
  163. package/client/dist/assets/editor.api2-XLGzZfbc.js +872 -0
  164. package/client/dist/assets/editor.main-CfXxHimg.js +6 -0
  165. package/client/dist/assets/editor.worker-Bd9IXS8d.js +26 -0
  166. package/client/dist/assets/elixir-OAdJEMOn.js +1 -0
  167. package/client/dist/assets/explore-4mFpnrKU.js +1 -0
  168. package/client/dist/assets/explore-A8Ltoblq.js +1 -0
  169. package/client/dist/assets/explore-B9A3iN2W.js +1 -0
  170. package/client/dist/assets/explore-BV5Xxlsn.js +1 -0
  171. package/client/dist/assets/explore-BrBJvfjP.js +1 -0
  172. package/client/dist/assets/explore-C3FSE42C.js +1 -0
  173. package/client/dist/assets/explore-D2EFgt8J.js +1 -0
  174. package/client/dist/assets/explore-hFc3HFcp.js +1 -0
  175. package/client/dist/assets/flow9-D3QEZjgn.js +1 -0
  176. package/client/dist/assets/format-command-CwGuwzGA.js +1 -0
  177. package/client/dist/assets/freemarker2-DP7J1gG3.js +3 -0
  178. package/client/dist/assets/fsharp-BF0k_8N8.js +1 -0
  179. package/client/dist/assets/go-BAQO5Jsz.js +1 -0
  180. package/client/dist/assets/graphql-hdFVFkiV.js +1 -0
  181. package/client/dist/assets/handlebars-BjRlucw6.js +1 -0
  182. package/client/dist/assets/hcl-DWnl1o-X.js +1 -0
  183. package/client/dist/assets/html-OumBQJ-U.js +1 -0
  184. package/client/dist/assets/html.worker-CQP8QQsS.js +502 -0
  185. package/client/dist/assets/htmlMode-CStc3zXM.js +1 -0
  186. package/client/dist/assets/index-CimDRRi7.css +2 -0
  187. package/client/dist/assets/index-XGZaKl_u.js +142 -0
  188. package/client/dist/assets/ini-CB-6OVu3.js +1 -0
  189. package/client/dist/assets/integrations-C3p12Ms6.js +1 -0
  190. package/client/dist/assets/integrations-Cr6hH7XR.js +1 -0
  191. package/client/dist/assets/integrations-Cublz3m6.js +1 -0
  192. package/client/dist/assets/integrations-D28q1kF6.js +1 -0
  193. package/client/dist/assets/integrations-DRdbki5W.js +1 -0
  194. package/client/dist/assets/integrations-DaC4SzzL.js +1 -0
  195. package/client/dist/assets/integrations-DmQYCUvN.js +1 -0
  196. package/client/dist/assets/integrations-HIlUxXVs.js +1 -0
  197. package/client/dist/assets/java-d1CmfiHX.js +1 -0
  198. package/client/dist/assets/javascript-CMk--e7g.js +1 -0
  199. package/client/dist/assets/jobs-BE1siB0M.js +1 -0
  200. package/client/dist/assets/jobs-BHcQ_Faf.js +1 -0
  201. package/client/dist/assets/jobs-CFfc2dNX.js +1 -0
  202. package/client/dist/assets/jobs-CSi5n8X_.js +1 -0
  203. package/client/dist/assets/jobs-Dc3X86PY.js +1 -0
  204. package/client/dist/assets/jobs-De5tASex.js +1 -0
  205. package/client/dist/assets/jobs-DsoXEdo7.js +1 -0
  206. package/client/dist/assets/jobs-Wl-ApPMb.js +1 -0
  207. package/client/dist/assets/json.worker-DzV-CpCQ.js +58 -0
  208. package/client/dist/assets/jsonMode-C2h3ZcjZ.js +7 -0
  209. package/client/dist/assets/julia-Bgv08lKa.js +1 -0
  210. package/client/dist/assets/kotlin-u98kaVTf.js +1 -0
  211. package/client/dist/assets/less-CjYwpgg5.js +2 -0
  212. package/client/dist/assets/lexon-YTjaAFBB.js +1 -0
  213. package/client/dist/assets/lib-CPxTMOAq.js +7 -0
  214. package/client/dist/assets/liquid-mI3KJrBE.js +1 -0
  215. package/client/dist/assets/lspLanguageFeatures-DU09ggWi.js +4 -0
  216. package/client/dist/assets/lua-BzmkWv27.js +1 -0
  217. package/client/dist/assets/m3-CFwk9fw0.js +1 -0
  218. package/client/dist/assets/markdown-CR5iMpSZ.js +1 -0
  219. package/client/dist/assets/mdx-C41VDTR_.js +1 -0
  220. package/client/dist/assets/mips-CcEalc17.js +1 -0
  221. package/client/dist/assets/monaco.contribution-CPObAXMC.js +2 -0
  222. package/client/dist/assets/msdax-BQbkawnr.js +1 -0
  223. package/client/dist/assets/mysql-GTlaaW_P.js +1 -0
  224. package/client/dist/assets/nav-0fwkrgHt.js +1 -0
  225. package/client/dist/assets/nav-BEL3MTwK.js +1 -0
  226. package/client/dist/assets/nav-B_G-TJDW.js +1 -0
  227. package/client/dist/assets/nav-C2YXcbZS.js +1 -0
  228. package/client/dist/assets/nav-ClzOE4mA.js +1 -0
  229. package/client/dist/assets/nav-CtYwmMgu.js +1 -0
  230. package/client/dist/assets/nav-D2bOGSEg.js +1 -0
  231. package/client/dist/assets/nav-iH1V5j6o.js +1 -0
  232. package/client/dist/assets/objective-c-Byu1T5if.js +1 -0
  233. package/client/dist/assets/pascal-BrfzBfRm.js +1 -0
  234. package/client/dist/assets/pascaligo-BXXKFUeo.js +1 -0
  235. package/client/dist/assets/perl-B3OikKq-.js +1 -0
  236. package/client/dist/assets/pgsql-CTsa0Acc.js +1 -0
  237. package/client/dist/assets/php-DiQh3FUW.js +1 -0
  238. package/client/dist/assets/pla-92uH8Fzm.js +1 -0
  239. package/client/dist/assets/postiats-BbeWkKUr.js +1 -0
  240. package/client/dist/assets/powerquery-DgDMzpsm.js +1 -0
  241. package/client/dist/assets/powershell-BfdUUzaG.js +1 -0
  242. package/client/dist/assets/preload-helper-DSXbuxSR.js +1 -0
  243. package/client/dist/assets/protobuf-BojW2ftW.js +2 -0
  244. package/client/dist/assets/pug-BxqTg3IU.js +1 -0
  245. package/client/dist/assets/python-Y27rKQtk.js +1 -0
  246. package/client/dist/assets/qsharp-BX_A-MW9.js +1 -0
  247. package/client/dist/assets/r-D9BMnxvJ.js +1 -0
  248. package/client/dist/assets/razor-Cd5-q9Bp.js +1 -0
  249. package/client/dist/assets/redis-5cJqEQJJ.js +1 -0
  250. package/client/dist/assets/redshift-d8BBqiwb.js +1 -0
  251. package/client/dist/assets/restructuredtext-C8a6yIcZ.js +1 -0
  252. package/client/dist/assets/ruby-egeh-6KX.js +1 -0
  253. package/client/dist/assets/rust-a3r9IInB.js +1 -0
  254. package/client/dist/assets/sb-y8iRIDei.js +1 -0
  255. package/client/dist/assets/scala-BPDK2AmK.js +1 -0
  256. package/client/dist/assets/scheme-BIWUEoOs.js +1 -0
  257. package/client/dist/assets/scss-CA-PSzwg.js +3 -0
  258. package/client/dist/assets/settings-55oDcbSh.js +1 -0
  259. package/client/dist/assets/settings-Bd4Tq1RB.js +1 -0
  260. package/client/dist/assets/settings-CCSM-Fhn.js +1 -0
  261. package/client/dist/assets/settings-D3e_bDoW.js +1 -0
  262. package/client/dist/assets/settings-DKbTkbn7.js +1 -0
  263. package/client/dist/assets/settings-Dxpo6_w7.js +1 -0
  264. package/client/dist/assets/settings-bt84e3Aa.js +1 -0
  265. package/client/dist/assets/settings-nu68QukM.js +1 -0
  266. package/client/dist/assets/setup-BMqwfbW9.js +1 -0
  267. package/client/dist/assets/setup-Bb5LcG28.js +1 -0
  268. package/client/dist/assets/setup-BeEx2_da.js +1 -0
  269. package/client/dist/assets/setup-CCCrB53Q.js +1 -0
  270. package/client/dist/assets/setup-CJA0ATmd.js +1 -0
  271. package/client/dist/assets/setup-CeiDbZcb.js +1 -0
  272. package/client/dist/assets/setup-Cus7TApA.js +1 -0
  273. package/client/dist/assets/setup-D9qOs2Xo.js +1 -0
  274. package/client/dist/assets/shell--LiT1Bja.js +1 -0
  275. package/client/dist/assets/solidity-DdqZccZg.js +1 -0
  276. package/client/dist/assets/sophia-S6-YxNG_.js +1 -0
  277. package/client/dist/assets/sparql-BSf5kMp2.js +1 -0
  278. package/client/dist/assets/specs-BFfu3u-a.js +1 -0
  279. package/client/dist/assets/specs-B__C8-8a.js +1 -0
  280. package/client/dist/assets/specs-CZ1PsXsC.js +1 -0
  281. package/client/dist/assets/specs-D2FzlLn9.js +1 -0
  282. package/client/dist/assets/specs-DaUTrNF9.js +1 -0
  283. package/client/dist/assets/specs-Dyc5hYeE.js +1 -0
  284. package/client/dist/assets/specs-cKEh2LXt.js +1 -0
  285. package/client/dist/assets/specs-k0PyLDVt.js +1 -0
  286. package/client/dist/assets/sql-D7KgjR8G.js +1 -0
  287. package/client/dist/assets/st-BnoDa-Ml.js +1 -0
  288. package/client/dist/assets/swift-DEUHTkUX.js +1 -0
  289. package/client/dist/assets/systemverilog-Tqb_KPnW.js +1 -0
  290. package/client/dist/assets/tcl-BmBFS2qq.js +1 -0
  291. package/client/dist/assets/terminal-80yDMgMF.js +1 -0
  292. package/client/dist/assets/terminal-Bje4ziIa.js +1 -0
  293. package/client/dist/assets/terminal-C2WYcFHF.js +1 -0
  294. package/client/dist/assets/terminal-CSONJOex.js +1 -0
  295. package/client/dist/assets/terminal-DEqzGtcr.js +1 -0
  296. package/client/dist/assets/terminal-DeWzh6ys.js +1 -0
  297. package/client/dist/assets/terminal-YOlsJCQj.js +1 -0
  298. package/client/dist/assets/terminal-lkZYR4wJ.js +1 -0
  299. package/client/dist/assets/tickets-CB7N30gm.js +1 -0
  300. package/client/dist/assets/tickets-CF2PYelu.js +1 -0
  301. package/client/dist/assets/tickets-DNOANUXr.js +1 -0
  302. package/client/dist/assets/tickets-DU1aqsbr.js +1 -0
  303. package/client/dist/assets/tickets-DYvafSaY.js +1 -0
  304. package/client/dist/assets/tickets-DlpC_iTg.js +1 -0
  305. package/client/dist/assets/tickets-DucYgtdl.js +1 -0
  306. package/client/dist/assets/tickets-clefmXLv.js +1 -0
  307. package/client/dist/assets/ts.worker-METxwbDZ.js +67719 -0
  308. package/client/dist/assets/tsMode-B0y_xEci.js +11 -0
  309. package/client/dist/assets/twig-BQV8igWC.js +1 -0
  310. package/client/dist/assets/typescript-BzK0OgwW.js +1 -0
  311. package/client/dist/assets/typespec-DlFroUGY.js +1 -0
  312. package/client/dist/assets/useProjectCache-DSaiGFjV.js +1 -0
  313. package/client/dist/assets/vb-BlrJpIMX.js +1 -0
  314. package/client/dist/assets/wgsl-BWgIc6FZ.js +298 -0
  315. package/client/dist/assets/workers-rt--R2Qy.js +1 -0
  316. package/client/dist/assets/xml-eX9QXAmI.js +1 -0
  317. package/client/dist/assets/yaml-fcsNkpOt.js +1 -0
  318. package/client/dist/index.html +246 -0
  319. package/docs/README.md +54 -0
  320. package/docs/cli.md +198 -0
  321. package/docs/codex.md +210 -0
  322. package/docs/creating-specs.md +197 -0
  323. package/docs/customizing.md +197 -0
  324. package/docs/getting-started.md +140 -0
  325. package/docs/internals/README.md +25 -0
  326. package/docs/internals/adding-a-provider.md +238 -0
  327. package/docs/internals/api-reference.md +634 -0
  328. package/docs/internals/architecture.md +332 -0
  329. package/docs/internals/configuration.md +172 -0
  330. package/docs/internals/openspec-workflow.md +282 -0
  331. package/docs/internals/operations-runbook.md +198 -0
  332. package/docs/internals/profiles.md +152 -0
  333. package/docs/platforms/macos.md +130 -0
  334. package/docs/platforms/windows.md +81 -0
  335. package/docs/running-pipelines.md +240 -0
  336. package/docs/terminal.md +138 -0
  337. package/docs/tracking-cost.md +155 -0
  338. package/package.json +82 -0
  339. package/server/dist/agent-generator.js +232 -0
  340. package/server/dist/agent-refine-db.js +124 -0
  341. package/server/dist/agent-refine-manager.js +526 -0
  342. package/server/dist/ai-invocations.js +111 -0
  343. package/server/dist/attachment-manager.js +299 -0
  344. package/server/dist/auth.js +207 -0
  345. package/server/dist/binary-probe.js +35 -0
  346. package/server/dist/browser-capture-manager.js +576 -0
  347. package/server/dist/browser-capture-types.js +28 -0
  348. package/server/dist/browser-network.js +149 -0
  349. package/server/dist/browser-playwright.js +888 -0
  350. package/server/dist/build-dirs.js +44 -0
  351. package/server/dist/changes-reader.js +120 -0
  352. package/server/dist/chat-manager.js +1060 -0
  353. package/server/dist/chromium-resolver.js +311 -0
  354. package/server/dist/code-explorer-router.js +788 -0
  355. package/server/dist/codex-otel-bridge.js +235 -0
  356. package/server/dist/command-resolver.js +102 -0
  357. package/server/dist/config.js +306 -0
  358. package/server/dist/context-budget.js +113 -0
  359. package/server/dist/context-scope.js +279 -0
  360. package/server/dist/contract-refine-runner.js +521 -0
  361. package/server/dist/core-compat.js +207 -0
  362. package/server/dist/core-package.js +14 -0
  363. package/server/dist/db.js +1034 -0
  364. package/server/dist/desktop-analytics.js +156 -0
  365. package/server/dist/desktop-db.js +456 -0
  366. package/server/dist/desktop-router.js +735 -0
  367. package/server/dist/docs-router.js +207 -0
  368. package/server/dist/explore-contract-refine.js +421 -0
  369. package/server/dist/explore-cwd-manager.js +242 -0
  370. package/server/dist/explore-draft-title.js +47 -0
  371. package/server/dist/explore-smash.js +450 -0
  372. package/server/dist/feature-flags.js +17 -0
  373. package/server/dist/file-provenance.js +382 -0
  374. package/server/dist/file-summary-generator.js +221 -0
  375. package/server/dist/file-summary-manager.js +689 -0
  376. package/server/dist/hooks.js +102 -0
  377. package/server/dist/ids.js +7 -0
  378. package/server/dist/index.js +586 -0
  379. package/server/dist/metrics.js +136 -0
  380. package/server/dist/mobile/index.js +16 -0
  381. package/server/dist/mobile/mobile-admin-router.js +84 -0
  382. package/server/dist/mobile/mobile-auth.js +67 -0
  383. package/server/dist/mobile/mobile-devices.js +80 -0
  384. package/server/dist/mobile/mobile-event-bus.js +39 -0
  385. package/server/dist/mobile/mobile-gateway.js +285 -0
  386. package/server/dist/mobile/mobile-mdns.js +81 -0
  387. package/server/dist/mobile/mobile-pairing.js +179 -0
  388. package/server/dist/mobile/mobile-redact.js +53 -0
  389. package/server/dist/mobile/mobile-router.js +411 -0
  390. package/server/dist/mobile/mobile-tls.js +86 -0
  391. package/server/dist/mobile/mobile-types.js +9 -0
  392. package/server/dist/mobile/mobile-ws.js +275 -0
  393. package/server/dist/path-resolver.js +298 -0
  394. package/server/dist/plugin-manager.js +617 -0
  395. package/server/dist/plugins/claude-approval.js +179 -0
  396. package/server/dist/plugins/claude-md-mutation.js +146 -0
  397. package/server/dist/plugins/codex-mcp.js +108 -0
  398. package/server/dist/plugins/contributors.js +72 -0
  399. package/server/dist/plugins/drift.js +58 -0
  400. package/server/dist/plugins/index.js +14 -0
  401. package/server/dist/plugins/json-mutation.js +120 -0
  402. package/server/dist/plugins/manager.js +32 -0
  403. package/server/dist/plugins/ownership.js +86 -0
  404. package/server/dist/plugins/paths.js +37 -0
  405. package/server/dist/plugins/prereq-installer.js +104 -0
  406. package/server/dist/plugins/rail-integration.js +79 -0
  407. package/server/dist/plugins/serena/index.js +13 -0
  408. package/server/dist/plugins/serena/install.js +91 -0
  409. package/server/dist/plugins/serena/instructions-content.js +21 -0
  410. package/server/dist/plugins/serena/manifest.js +111 -0
  411. package/server/dist/plugins/serena/verify.js +78 -0
  412. package/server/dist/plugins-router.js +215 -0
  413. package/server/dist/pricing.js +89 -0
  414. package/server/dist/profile-manager.js +310 -0
  415. package/server/dist/profiles-router.js +759 -0
  416. package/server/dist/project-registry.js +443 -0
  417. package/server/dist/project-router.js +4016 -0
  418. package/server/dist/proposal-manager.js +291 -0
  419. package/server/dist/provider-selection.js +69 -0
  420. package/server/dist/providers/claude-adapter.js +281 -0
  421. package/server/dist/providers/codex-adapter.js +264 -0
  422. package/server/dist/providers/index.js +23 -0
  423. package/server/dist/providers/registry.js +37 -0
  424. package/server/dist/providers/types.js +22 -0
  425. package/server/dist/queue-manager.js +1511 -0
  426. package/server/dist/rails-router.js +362 -0
  427. package/server/dist/rails-store.js +116 -0
  428. package/server/dist/result-event.js +106 -0
  429. package/server/dist/schemas/profile.v1.json +151 -0
  430. package/server/dist/setup-manager.js +1165 -0
  431. package/server/dist/setup-prerequisites.js +372 -0
  432. package/server/dist/smash-runner.js +663 -0
  433. package/server/dist/spec-draft-parser.js +133 -0
  434. package/server/dist/spec-launcher-manager.js +174 -0
  435. package/server/dist/spec-models.js +32 -0
  436. package/server/dist/specrails-tech-client.js +82 -0
  437. package/server/dist/spending.js +448 -0
  438. package/server/dist/telemetry-compactor.js +180 -0
  439. package/server/dist/telemetry-export.js +317 -0
  440. package/server/dist/telemetry-receiver.js +224 -0
  441. package/server/dist/terminal-manager.js +633 -0
  442. package/server/dist/terminal-marks-store.js +117 -0
  443. package/server/dist/terminal-osc-parser.js +159 -0
  444. package/server/dist/terminal-settings.js +282 -0
  445. package/server/dist/terminal-shell-integration.js +196 -0
  446. package/server/dist/ticket-broadcast.js +47 -0
  447. package/server/dist/ticket-store.js +397 -0
  448. package/server/dist/ticket-watcher.js +117 -0
  449. package/server/dist/types.js +10 -0
  450. package/server/dist/user-mcp-config.js +117 -0
  451. package/server/dist/util/cli-prompt.js +181 -0
  452. package/server/dist/util/secure-fs.js +50 -0
  453. package/server/dist/util/win-spawn.js +43 -0
  454. package/server/dist/webhook-manager.js +89 -0
  455. package/server/dist/ws-routing.js +47 -0
@@ -0,0 +1,1635 @@
1
+ # Enrich: Agent Workflow System
2
+
3
+ Interactive wizard to configure the full agent workflow system for this repository. Analyzes the codebase, discovers target users, generates VPC personas, and creates all agents, commands, rules, and configuration adapted to this project. Supports config-driven mode for direct installation from a pre-built config file.
4
+
5
+ **Prerequisites:** Ensure this repo was initialized with `npx specrails-core@latest init` (or via specrails-desktop) so `.specrails/setup-templates/` exists.
6
+
7
+ ### Desktop Checkpoint Protocol
8
+
9
+ When running inside specrails-desktop, emit checkpoint markers at key transitions so the app's `CheckpointTracker` can display progress. Each checkpoint is a single line printed to stdout:
10
+
11
+ ```
12
+ [checkpoint:phase_1_analysis] Codebase analysis complete
13
+ [checkpoint:phase_2_personas] VPC personas generated
14
+ [checkpoint:phase_3_commands] Commands and rules generated
15
+ [checkpoint:phase_4_agents] Agent files generated
16
+ [checkpoint:phase_5_cleanup] Cleanup and summary complete
17
+ ```
18
+
19
+ The app parses these via `detectCheckpointFromText()` regex patterns. Always emit checkpoints at the end of each phase, even in `--from-config` and `--quick` modes.
20
+
21
+ ---
22
+
23
+ ## Mode Detection
24
+
25
+ Check `$ARGUMENTS` in this order:
26
+
27
+ 1. If `--update` is present → execute **Update Mode** (below), then stop.
28
+ 2. If `--from-config` is present → execute **From-Config Mode** (below), then stop.
29
+ 3. If `--quick` or `--lite` is present → execute **Quick Mode** (below), then stop.
30
+ 4. Otherwise (no flags) → skip directly to **Phase 1** and execute the full 5-phase wizard.
31
+
32
+ **Default is the full wizard.** Quick Mode only runs when `--quick` or `--lite` is explicitly passed.
33
+
34
+ ---
35
+
36
+ ## From-Config Mode
37
+
38
+ When `--from-config` is passed, execute a fully automated installation using `.specrails/install-config.yaml`. No interactive prompts — all decisions come from the config file.
39
+
40
+ ### FC1: Read and Validate Config
41
+
42
+ Read `.specrails/install-config.yaml`. If it does not exist, display:
43
+ > "`.specrails/install-config.yaml` not found. Run the TUI installer first (`npx specrails-core@latest init`) or use `/specrails:enrich` without `--from-config` for the interactive wizard."
44
+ Then stop.
45
+
46
+ Parse the YAML and extract:
47
+ - `config.version` — must be `1`; if not, warn and proceed
48
+ - `config.provider` — `claude` or `codex`; default `claude`
49
+ - `config.tier` — `full` or `quick`; default `full`
50
+ - `config.agents.selected` — list of agent names to install
51
+ - `config.agents.excluded` — list of agent names to skip (for reference only)
52
+ - `config.models.preset` — `balanced`, `budget`, or `max` (see Model Presets below)
53
+ - `config.models.defaults.model` — default model override (overrides preset)
54
+ - `config.models.overrides` — per-agent model overrides (highest priority)
55
+ - `config.agent_teams` — boolean; whether to install team-review/team-debug commands
56
+
57
+ Store all values in variables prefixed `FC_`.
58
+
59
+ **Model Presets** (applied when `config.models.defaults` is not set):
60
+ - `balanced` (default): sr-architect=opus, sr-product-manager=opus, all others=sonnet
61
+ - `budget`: all agents=haiku
62
+ - `max`: all agents=opus
63
+
64
+ To resolve the model for any given agent:
65
+ 1. Check `config.models.overrides.<agent-name>` — if present, use it
66
+ 2. Check `config.models.defaults.model` — if present, use it
67
+ 3. Apply preset defaults based on `config.models.preset`
68
+ 4. Fallback to model in template frontmatter
69
+
70
+ ### FC2: Provider Setup
71
+
72
+ Use `FC_provider` from the config as the source of truth. Set `CLI_PROVIDER = FC_provider`, and set `SPECRAILS_DIR` to `.codex` when `CLI_PROVIDER == "codex"`, otherwise `.claude`.
73
+
74
+ Set `SPECRAILS_DIR` and `CLI_PROVIDER` from resolved provider.
75
+
76
+ ### FC3: If tier is `quick` — run Quick Mode with config context
77
+
78
+ If `FC_tier == "quick"`:
79
+ - Set `FC_AGENTS_SELECTED` as the list of agents to generate (instead of defaults)
80
+ - Execute Quick Mode (QS1–QS4), generating all `FC_AGENTS_SELECTED` agents (not just defaults)
81
+ - Then stop.
82
+
83
+ ### FC4: If tier is `full` — run automated full wizard
84
+
85
+ **Phase 1 (Silent):** Run the full Phase 1 analysis (1.1–1.4) without any user prompts. Store all detected values internally.
86
+
87
+ **Phase 2 (AI-Inferred VPC Discovery):** Run VPC persona generation from codebase analysis:
88
+ - Analyze the codebase (README, package.json, source code, configs) to infer what the product does and who it serves
89
+ - Generate `PROJECT_DESCRIPTION` (2–3 sentence summary) and `TARGET_USERS` from analysis
90
+ - Use these inferred values to generate full VPC personas (3 primary, 3 secondary)
91
+ - Do not ask the user any questions — infer everything from codebase analysis
92
+
93
+ **Phase 3 (Silent):** Run Phase 3 normally without user prompts.
94
+
95
+ **Phase 4 (Config-Driven Agent Generation):**
96
+ - Generate only agents in `FC_AGENTS_SELECTED` (skip any not in the list)
97
+ - Apply model resolution (FC1 preset/override logic) to each agent's frontmatter
98
+ - Run all Phase 4 sub-phases (4.1, 4.2, 4.3, 4.4) normally but without interactive prompts
99
+ - If `FC_agent_teams == true`, also install team-review and team-debug commands
100
+
101
+ **Phase 5 (Normal):** Run Phase 5 cleanup normally.
102
+
103
+ ### FC5: Completion
104
+
105
+ Display:
106
+ ```
107
+ ✅ Enrich complete (from-config).
108
+
109
+ Agents generated: <count> of <total selected>
110
+ Models applied:
111
+ sr-architect: <resolved-model>
112
+ sr-developer: <resolved-model>
113
+ [... one line per generated agent ...]
114
+
115
+ Next steps:
116
+ > /specrails:implement <feature>
117
+ ```
118
+
119
+ ---
120
+
121
+ ## Update Mode
122
+
123
+ When `--update` is passed, execute this streamlined flow instead of the full wizard. Do not run any phases from the full wizard. When Phase U7 is complete, stop.
124
+
125
+ ### Phase U1: Read Update Context
126
+
127
+ Read the following files to understand the current installation state:
128
+
129
+ 1. Read `.specrails/specrails-manifest.json` — contains agent template checksums from the last install/update. Structure:
130
+ ```json
131
+ {
132
+ "version": "0.2.0",
133
+ "installed_at": "2025-01-15T10:00:00Z",
134
+ "artifacts": {
135
+ "templates/agents/architect.md": "sha256:<checksum>",
136
+ "templates/agents/developer.md": "sha256:<checksum>",
137
+ "templates/agents/reviewer.md": "sha256:<checksum>"
138
+ }
139
+ }
140
+ ```
141
+ If this file does not exist, inform the user:
142
+ > "No `.specrails/specrails-manifest.json` found. This repo predates the Node-native installer. Re-run `npx specrails-core@latest init` to refresh the install, then re-run `/specrails:enrich --update`."
143
+ Then stop.
144
+
145
+ 2. Read `.specrails/specrails-version` — contains the current version string (e.g., `0.2.0`). If it does not exist, treat version as `0.1.0 (legacy)`.
146
+
147
+ 3. Determine `$SPECRAILS_DIR` from the existing install layout. If `.codex/` exists, use `cli_provider = "codex"` and `specrails_dir = ".codex"`. Otherwise use `cli_provider = "claude"` and `specrails_dir = ".claude"`.
148
+
149
+ 4. List all template files in `.specrails/setup-templates/agents/` — these are the NEW agent templates from the update:
150
+ ```bash
151
+ ls .specrails/setup-templates/agents/
152
+ ```
153
+ Template files are named with `sr-` prefix (e.g., `sr-architect.md`, `sr-developer.md`).
154
+
155
+ 5. List all template files in `.specrails/setup-templates/commands/specrails/` — these are the NEW command templates from the update:
156
+ ```bash
157
+ ls .specrails/setup-templates/commands/specrails/
158
+ ```
159
+ Command template files include `implement.md`, `batch-implement.md`, `compat-check.md`, `refactor-recommender.md`, `why.md`, `get-backlog-specs.md`, `auto-propose-backlog-specs.md`.
160
+ If this directory does not exist, skip command template checking for this update.
161
+
162
+ 6. Read `.specrails/backlog-config.json` if it exists — contains stored provider configuration needed for command placeholder substitution.
163
+
164
+ 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`.
165
+
166
+ ### Phase U2: Quick Codebase Re-Analysis
167
+
168
+ 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.
169
+
170
+ Detect:
171
+ - **Languages**: Check for `*.py`, `*.ts`, `*.tsx`, `*.go`, `*.rs`, `*.java`, `*.kt`, `*.rb`, `*.cs`
172
+ - **Frameworks**: Search for imports (`fastapi`, `express`, `react`, `vue`, `angular`, `django`, `spring`, `gin`, `actix`, `rails`)
173
+ - **Directory structure**: Identify backend/frontend/core/test directories
174
+ - **Database**: Check for SQL files, ORM configs, migration directories
175
+ - **CI/CD**: Parse `.github/workflows/*.yml` for lint/test/build commands
176
+ - **Naming conventions**: Read 2-3 source files per detected layer
177
+
178
+ Read:
179
+ - `README.md` (if exists)
180
+ - `package.json` / `pyproject.toml` / `Cargo.toml` / `go.mod` / `pom.xml` (detect stack)
181
+ - `.github/workflows/*.yml` (detect CI commands)
182
+
183
+ Store all results for use in Phases U4 and U5.
184
+
185
+ ### Phase U3: Identify What Needs Regeneration
186
+
187
+ **Agent templates:** For each agent template, find its entry in the manifest's `artifacts` map (keyed as `templates/agents/sr-<name>.md`). Compute the SHA-256 checksum of the corresponding file in `.specrails/setup-templates/agents/`:
188
+
189
+ ```bash
190
+ sha256sum .specrails/setup-templates/agents/sr-<name>.md
191
+ ```
192
+
193
+ Build three lists for agents:
194
+
195
+ 1. **Changed agents**: agent name exists in manifest AND the current template checksum differs from the manifest checksum → mark for regeneration
196
+ 2. **New agents**: template file exists in `.specrails/setup-templates/agents/` but the agent name is NOT in the manifest → mark for evaluation
197
+ 3. **Unchanged agents**: agent name exists in manifest AND checksum matches → skip
198
+
199
+ **Command templates:** If `.specrails/setup-templates/commands/specrails/` exists, for each command template file, find its entry in the manifest's `artifacts` map (keyed as `templates/commands/specrails/<name>.md`). Compute the SHA-256 checksum of the corresponding file in `.specrails/setup-templates/commands/specrails/`:
200
+
201
+ ```bash
202
+ sha256sum .specrails/setup-templates/commands/specrails/<name>.md
203
+ ```
204
+
205
+ Build three lists for commands:
206
+
207
+ 1. **Changed commands**: command name exists in manifest AND the current template checksum differs from the manifest checksum → mark for update
208
+ 2. **New commands**: template file exists in `.specrails/setup-templates/commands/specrails/` but the command name is NOT in the manifest → mark for evaluation
209
+ 3. **Unchanged commands**: command name exists in manifest AND checksum matches → skip
210
+
211
+ Display the combined analysis to the user:
212
+
213
+ ```
214
+ ## Update Analysis
215
+
216
+ ### Agents — Changed Templates (will be regenerated)
217
+ - sr-architect.md (template modified)
218
+ - sr-developer.md (template modified)
219
+
220
+ ### Agents — New Templates Available
221
+ - sr-frontend-developer.md
222
+ - sr-backend-developer.md
223
+
224
+ ### Agents — Unchanged (keeping current)
225
+ - sr-reviewer.md
226
+ - sr-product-manager.md
227
+
228
+ ### Commands — Changed Templates (will be updated)
229
+ - implement.md (template modified)
230
+
231
+ ### Commands — New Templates Available
232
+ - refactor-recommender.md
233
+
234
+ ### Commands — Unchanged (keeping current)
235
+ - compat-check.md
236
+ - why.md
237
+ ```
238
+
239
+ If there are no changed agents, no new agents, no changed commands, and no new commands, display:
240
+ ```
241
+ All agents and commands are already up to date. Nothing to regenerate.
242
+ ```
243
+ Then jump to Phase U7.
244
+
245
+ ### Phase U4: Regenerate Changed Agents
246
+
247
+ For each agent in the "changed" list:
248
+
249
+ 1. Read the NEW template from `.specrails/setup-templates/agents/sr-<name>.md`
250
+ 2. Use the codebase analysis from Phase U2 to fill in all `` values, using the same substitution rules as Phase 4.1 of the full setup:
251
+ - `specrails-desktop` → project name (from README.md or directory name)
252
+ - `` → detected architecture layers
253
+ - `` → detected layer tags (e.g., `[backend]`, `[frontend]`, `[api]`)
254
+ - `` → backend CI commands
255
+ - `` → frontend CI commands
256
+ - `` → detected conventions per layer
257
+ - `` → read existing persona names from `$SPECRAILS_DIR/agents/personas/` filenames
258
+ - `` → paths to existing persona files in `$SPECRAILS_DIR/agents/personas/`
259
+ - `` → infer from detected stack and README
260
+ - `` → important file paths detected in Phase U2
261
+ - `` → read from existing `CLAUDE.md` if present
262
+ - `.claude/agent-memory/` → `$SPECRAILS_DIR/agent-memory/sr-<agent-name>/`
263
+ 3. Resolve the agent's model using `AGENTS_CONFIG` (loaded in Phase U1, step 7):
264
+ - Check `AGENTS_CONFIG.agents.<agent-name>.model` (per-agent override)
265
+ - If not present, check `AGENTS_CONFIG.defaults.model` (global default)
266
+ - If `AGENTS_CONFIG` is null, use the model from the template frontmatter
267
+ - Replace the `model:` field in the YAML frontmatter with the resolved value before writing
268
+ 4. Write the adapted agent using the format for the active provider (same dual-format rules as Phase 4.1):
269
+ - `cli_provider == "claude"`: write to `$SPECRAILS_DIR/agents/sr-<name>.md` (Markdown with YAML frontmatter)
270
+ - `cli_provider == "codex"`: write to `$SPECRAILS_DIR/agents/sr-<name>.toml` (TOML format with `name`, `description`, `model`, `prompt` fields)
271
+ 5. Show: `✓ Regenerated sr-<name>`
272
+
273
+ After regenerating all changed agents, verify no unresolved placeholders remain:
274
+ ```bash
275
+ # Claude Code
276
+ grep -r '{{[A-Z_]*}}' .claude/agents/sr-*.md 2>/dev/null || echo "OK: no broken placeholders"
277
+ # Codex
278
+ grep -r '{{[A-Z_]*}}' .codex/agents/sr-*.toml 2>/dev/null || echo "OK: no broken placeholders"
279
+ ```
280
+
281
+ ### Phase U4b: Update Changed Commands
282
+
283
+ For each command in the "changed commands" list from Phase U3:
284
+
285
+ 1. Read the NEW template:
286
+ - If `cli_provider == "claude"`: from `.specrails/setup-templates/commands/specrails/<name>.md`
287
+ - If `cli_provider == "codex"`: from `.specrails/setup-templates/skills/sr-<name>/SKILL.md`
288
+ 2. Read stored backlog configuration from `.specrails/backlog-config.json` (if it exists) to resolve provider-specific placeholders:
289
+ - `BACKLOG_PROVIDER` → `provider` field (`github`, `jira`, or `none`)
290
+ - `BACKLOG_WRITE` → `write_access` field
291
+ - `JIRA_BASE_URL` → `jira_base_url` field
292
+ - `JIRA_PROJECT_KEY` → `jira_project_key` field
293
+ 3. Substitute all `` values using the same rules as Phase 4.3 of the full setup:
294
+ - `` → backend CI commands detected in Phase U2
295
+ - `` → frontend CI commands detected in Phase U2
296
+ - `` → stack-specific dependency check commands from Phase U2
297
+ - `` → test runner commands from Phase U2
298
+ - `` → provider-specific fetch command from backlog config
299
+ - `` → provider-specific create command from backlog config
300
+ - `` → provider-specific view command from backlog config
301
+ - `` → provider-specific preflight check from backlog config
302
+ - Any other `` values → use Phase U2 analysis data
303
+ 4. Write the updated file:
304
+ - If `cli_provider == "claude"`: to `.claude/commands/specrails/<name>.md`
305
+ - If `cli_provider == "codex"`: to `.agents/skills/sr-<name>/SKILL.md`
306
+ 5. Show:
307
+ - If `cli_provider == "claude"`: `✓ Updated /specrails:<name>`
308
+ - If `cli_provider == "codex"`: `✓ Updated $sr-<name>`
309
+
310
+ After updating all changed commands/skills, verify no unresolved placeholders remain:
311
+ ```bash
312
+ # If cli_provider == "claude":
313
+ grep -l '{{[A-Z_]*}}' .claude/commands/specrails/*.md 2>/dev/null || echo "OK: no broken placeholders"
314
+ # If cli_provider == "codex":
315
+ grep -rl '{{[A-Z_]*}}' .agents/skills/sr-*/SKILL.md 2>/dev/null || echo "OK: no broken placeholders"
316
+ ```
317
+ If any placeholders remain unresolved, warn the user:
318
+ > "⚠ Some placeholders in `<filename>` could not be resolved automatically. Please review the file and fill them in manually."
319
+
320
+ ### Phase U5: Evaluate New Agents
321
+
322
+ For each agent in the "new" list:
323
+
324
+ 1. Read the template from `.specrails/setup-templates/agents/sr-<name>.md` to understand what stack or layer it targets (read its description and any layer-specific comments)
325
+ 2. Match against the codebase detected in Phase U2:
326
+ - If the template targets a layer/stack that IS present (e.g., `sr-frontend-developer` and React was detected), prompt:
327
+ > "New agent available: `sr-<name>` — your project uses [detected tech]. Add it? [Y/n]"
328
+ - If the template targets a layer/stack that is NOT present (e.g., `sr-backend-developer` and no backend was detected), prompt:
329
+ > "New agent available: `sr-<name>` — no [layer] detected in your project. Skip? [Y/n]"
330
+ 3. If the user accepts (or presses Enter on a pre-selected default):
331
+ - Generate the agent using the same template adaptation as Phase U4
332
+ - Create memory directory if it does not exist: `$SPECRAILS_DIR/agent-memory/sr-<name>/`
333
+ - Show: `✓ Added sr-<name>`
334
+ 4. If the user declines:
335
+ - Show: `→ Skipped sr-<name>`
336
+
337
+ For each command in the "new commands" list from Phase U3:
338
+
339
+ 1. Read the template:
340
+ - If `cli_provider == "claude"`: from `.specrails/setup-templates/commands/specrails/<name>.md`
341
+ - If `cli_provider == "codex"`: from `.specrails/setup-templates/skills/sr-<name>/SKILL.md`
342
+ 2. Prompt the user:
343
+ - If `cli_provider == "claude"`: `"New command available: /specrails:<name> — [one-line description]. Install it? [Y/n]"`
344
+ - If `cli_provider == "codex"`: `"New skill available: $sr-<name> — [one-line description]. Install it? [Y/n]"`
345
+ 3. If the user accepts (or presses Enter):
346
+ - Apply placeholder substitution using the same rules as Phase U4b (backlog config + codebase analysis)
347
+ - If `cli_provider == "claude"`: write to `.claude/commands/specrails/<name>.md` — show `✓ Added /specrails:<name>`
348
+ - If `cli_provider == "codex"`: write to `.agents/skills/sr-<name>/SKILL.md` — show `✓ Added $sr-<name>`
349
+ 4. If the user declines:
350
+ - If `cli_provider == "claude"`: show `→ Skipped /specrails:<name>`
351
+ - If `cli_provider == "codex"`: show `→ Skipped $sr-<name>`
352
+
353
+ ### Phase U6: Update Workflow Commands
354
+
355
+ If any new agents were added in Phase U5:
356
+
357
+ 1. Read the implement command/skill:
358
+ - If `cli_provider == "claude"`: `.claude/commands/specrails/implement.md`
359
+ - If `cli_provider == "codex"`: `.agents/skills/sr-implement/SKILL.md`
360
+ 2. Check if the file references agent names in its orchestration steps (look for `sr-architect`, `sr-developer`, `sr-reviewer` etc.)
361
+ 3. If newly added agents belong in the implementation pipeline (i.e., they are layer-specific developers such as `sr-frontend-developer` or `sr-backend-developer`), add them to the appropriate step in the implement command — specifically where parallel developer agents are launched
362
+ 4. Write the updated file if any changes were made:
363
+ - If `cli_provider == "claude"`: `.claude/commands/specrails/implement.md`
364
+ - If `cli_provider == "codex"`: `.agents/skills/sr-implement/SKILL.md`
365
+ 5. Show which commands were updated, or "No command updates needed" if nothing changed
366
+
367
+ This is a lightweight check — only update commands where the sr- agent clearly belongs. Do not restructure the entire command.
368
+
369
+ ### Phase U7: Summary
370
+
371
+ Display the final summary and stop. Do not continue to Phase 1 of the full setup wizard.
372
+
373
+ ```
374
+ ## Update Complete
375
+
376
+ specrails updated from v<previous> to v<new>.
377
+
378
+ | Action | Count |
379
+ |---------------------|-------|
380
+ | Agents regenerated | N |
381
+ | Agents added | N |
382
+ | Agents skipped | N |
383
+ | Commands updated | N |
384
+ | Commands added | N |
385
+ | Commands skipped | N |
386
+
387
+ All agents and commands are now up to date.
388
+
389
+ ### Agents Regenerated
390
+ [list agent names, or "(none)"]
391
+
392
+ ### Agents Added
393
+ [list agent names, or "(none)"]
394
+
395
+ ### Agents Skipped
396
+ [list agent names, or "(none)"]
397
+
398
+ ### Commands Updated
399
+ [list command names, or "(none)"]
400
+
401
+ ### Commands Added
402
+ [list command names, or "(none)"]
403
+
404
+ ### Commands Skipped
405
+ [list command names, or "(none)"]
406
+ ```
407
+
408
+ Update `.specrails/specrails-manifest.json` to reflect the new checksums for all regenerated/updated and added agents and commands:
409
+ - For each regenerated agent: update its checksum entry to the new template's checksum (keyed as `templates/agents/sr-<name>.md`)
410
+ - For each added agent: add a new entry with its checksum
411
+ - For each updated command: update its checksum entry to the new template's checksum (keyed as `templates/commands/specrails/<name>.md`)
412
+ - For each added command: add a new entry with its checksum
413
+ - Update the `version` field to the version read from `.specrails/specrails-version`
414
+
415
+ ---
416
+
417
+ ## Quick Mode
418
+
419
+ When `--quick` or `--lite` is passed, run this streamlined 3-question setup. Do NOT run Phase 1–5. When QS4 is complete, stop.
420
+
421
+ ### QS1: Infer context and ask git access
422
+
423
+ **Step 1 — AI inference (silent):** Analyze the codebase to infer:
424
+ - `QS_PROJECT_DESCRIPTION` — a 2–3 sentence summary of what this project does (from README, package.json, source code, configs)
425
+ - `QS_TARGET_USERS` — who the target users are (from docs, UI copy, API design, domain language)
426
+
427
+ **Step 2 — Ask one question:**
428
+
429
+ Display the following prompt EXACTLY ONCE:
430
+
431
+ Welcome to specrails! Let's get your AI agent team set up.
432
+
433
+ I've analyzed your codebase:
434
+ - **Project:** {QS_PROJECT_DESCRIPTION}
435
+ - **Target users:** {QS_TARGET_USERS}
436
+
437
+ 1. Git access for agents — read-only or read-write?
438
+ (read-only = agents can read and suggest; read-write = agents can commit)
439
+
440
+ Store the answer as:
441
+ - `QS_GIT_ACCESS` — "read-only" or "read-write" (normalize if user types "ro", "rw", "readonly", etc.)
442
+
443
+ ### QS2: Apply opinionated defaults
444
+
445
+ Use these defaults for all configuration not asked in QS1:
446
+
447
+ | Setting | Quick Mode Default |
448
+ |---------|------------------|
449
+ | Agents enabled | sr-architect, sr-developer, sr-reviewer, sr-product-manager |
450
+ | Git mode | Derived from QS_GIT_ACCESS |
451
+ | CLAUDE.md template | `templates/CLAUDE-quickstart.md` |
452
+ | OpenSpec enabled | Yes if `openspec` CLI is detected in PATH, No otherwise |
453
+ | Telemetry | Not configured (deferred to PRD-002) |
454
+ | Backlog provider | local (lightweight JSON-based, no external tools needed) |
455
+
456
+ Detect whether this is an existing codebase or new project:
457
+ - **Existing codebase**: `package.json`, `Gemfile`, `pyproject.toml`, `go.mod`, or `pom.xml` found in the repo root
458
+ - **New project**: none of the above found
459
+
460
+ Store as `QS_IS_EXISTING_CODEBASE=true/false`.
461
+
462
+ ### QS2.5: Re-run Detection
463
+
464
+ Before generating files, check if this is a re-run:
465
+
466
+ 1. Check if commands/skills already exist:
467
+ - If `cli_provider == "claude"`: check if `.claude/commands/specrails/` directory exists with any `.md` files:
468
+ ```bash
469
+ ls .claude/commands/specrails/*.md 2>/dev/null
470
+ ```
471
+ - If `cli_provider == "codex"`: check if `.agents/skills/sr-*/SKILL.md` files exist:
472
+ ```bash
473
+ ls .agents/skills/sr-*/SKILL.md 2>/dev/null
474
+ ```
475
+ 2. If files are found → this is a **re-run**. Store `QS_IS_RERUN=true`.
476
+ 3. If the directory does not exist or is empty → this is a **fresh install**. Store `QS_IS_RERUN=false`.
477
+
478
+ In re-run mode, QS3 executes in **gap-fill mode** for command/skill files:
479
+ - For each command in the list, check if it already exists:
480
+ - If `cli_provider == "claude"`: at `.claude/commands/specrails/<name>.md`
481
+ - If `cli_provider == "codex"`: at `.agents/skills/sr-<name>/SKILL.md`
482
+ - If it exists: skip it and show:
483
+ - Claude: `✓ Already installed: /specrails:<name>`
484
+ - Codex: `✓ Already installed: $sr-<name>`
485
+ - If it does NOT exist: install it and show:
486
+ - Claude: `✓ Added /specrails:<name> (was missing)`
487
+ - Codex: `✓ Added $sr-<name> (was missing)`
488
+ - Do NOT prompt the user for confirmation on missing files — install them automatically
489
+
490
+ For CLAUDE.md/AGENTS.md and agent files, the existing per-file prompts already handle re-runs (user is asked before overwriting). No change needed there.
491
+
492
+ ### QS3: Generate files
493
+
494
+ Generate files using the Quick Mode defaults.
495
+
496
+ **1. CLAUDE.md**
497
+
498
+ Read `.specrails/setup-templates/claude-md/CLAUDE-quickstart.md` (or fall back to `.specrails/setup-templates/claude-md/default.md` if quickstart template is not found).
499
+
500
+ Replace placeholders:
501
+ - `specrails-desktop` → derive from directory name or README.md first heading
502
+ - `` → `QS_GIT_ACCESS`
503
+
504
+ Write to `CLAUDE.md` in the repo root. If `CLAUDE.md` already exists, ask:
505
+ > "CLAUDE.md already exists. Overwrite? [Y/n]"
506
+ Skip if user says no.
507
+
508
+ **2. Agent files**
509
+
510
+ For each default agent (sr-architect, sr-developer, sr-reviewer, sr-product-manager), read the template from `.specrails/setup-templates/agents/<name>.md` and generate the adapted agent file using the dual-format rules from Phase 4.1:
511
+ - `cli_provider == "claude"`: write to `.claude/agents/<name>.md` (Markdown with frontmatter)
512
+ - `cli_provider == "codex"`: write to `.codex/agents/<name>.toml` (TOML format)
513
+
514
+ If `.specrails/agents.yaml` exists, read it and apply model resolution (per-agent override → defaults → template value) before writing each agent file.
515
+
516
+ Fill placeholders with best-effort values from the limited context available:
517
+ - `specrails-desktop` → directory name or README first heading
518
+ - `` → `QS_GIT_ACCESS`
519
+ - `` → "(Quick Mode — run `/specrails:enrich` for full architecture analysis)"
520
+ - `` → "(Quick Mode — run `/specrails:enrich` for codebase-specific expertise)"
521
+ - `` → detect from package.json / Gemfile / go.mod if present; otherwise leave empty
522
+ - All other placeholders → "(not configured — run `/specrails:enrich`)"
523
+
524
+ Create memory directories: `$SPECRAILS_DIR/agent-memory/sr-<name>/`
525
+
526
+ **3. Command files**
527
+
528
+ Core commands (always install if missing):
529
+ - `implement.md`
530
+ - `batch-implement.md`
531
+ - `propose-spec.md`
532
+ - `compat-check.md`
533
+ - `why.md`
534
+ - `get-backlog-specs.md`
535
+ - `auto-propose-backlog-specs.md`
536
+
537
+ **Initialize local ticket storage** (backlog provider defaults to `local`):
538
+ 1. Copy `templates/local-tickets-schema.json` to `.specrails/local-tickets.json` and set `last_updated` to the current ISO-8601 timestamp. Skip if the file already exists.
539
+ 2. Write `.specrails/backlog-config.json` (skip if already exists):
540
+ ```json
541
+ {
542
+ "provider": "local",
543
+ "write_access": true,
544
+ "git_auto": true
545
+ }
546
+ ```
547
+
548
+ **If `cli_provider == "claude"`:**
549
+
550
+ If `QS_IS_RERUN=false` (fresh install): for each core command, read the template from `.specrails/setup-templates/commands/specrails/<name>.md`, substitute the backlog placeholders with local values (using the same table as Phase 4.3 "Local Tickets"), stub all persona placeholders with `(Quick Mode — run /specrails:enrich to configure personas)`, then write to `.claude/commands/specrails/<name>.md`.
551
+
552
+ If `QS_IS_RERUN=true` (gap-fill mode): for each command in the list above, check if `.claude/commands/specrails/<name>.md` already exists:
553
+ - If it exists: skip it — show `✓ Already installed: /specrails:<name>`
554
+ - If it does NOT exist: read template, substitute placeholders as above, write to `.claude/commands/specrails/<name>.md` — show `✓ Added /specrails:<name> (was missing)`
555
+
556
+ **If `cli_provider == "codex"`:**
557
+
558
+ If `QS_IS_RERUN=false` (fresh install): for each core command, read the corresponding skill template from `.specrails/setup-templates/skills/sr-<name>/SKILL.md`, substitute the backlog placeholders with local values and stub persona placeholders with `(Quick Mode — run /specrails:enrich to configure personas)`, then write to `.agents/skills/sr-<name>/SKILL.md` (create the directory first).
559
+
560
+ If `QS_IS_RERUN=true` (gap-fill mode): for each command in the list above, check if `.agents/skills/sr-<name>/SKILL.md` already exists:
561
+ - If it exists: skip it — show `✓ Already installed: $sr-<name>`
562
+ - If it does NOT exist: read template, substitute placeholders as above, write to `.agents/skills/sr-<name>/SKILL.md` — show `✓ Added $sr-<name> (was missing)`
563
+
564
+ **4. Cleanup**
565
+
566
+ Remove `.specrails/setup-templates/` (same as full wizard cleanup in Phase 5).
567
+
568
+ Remove `commands/enrich.md` from `.claude/commands/` if it was copied there by the installer.
569
+
570
+ ### QS4: First Task Prompt
571
+
572
+ After generating all files, display the setup complete message.
573
+
574
+ Then, based on `QS_IS_EXISTING_CODEBASE`:
575
+ - **Existing codebase** (`true`): recommend `/specrails:refactor-recommender`
576
+ - **New project** (`false`): recommend `/specrails:get-backlog-specs`
577
+
578
+ If `QS_IS_RERUN=false`, display:
579
+ ```
580
+ ✅ Setup complete.
581
+
582
+ Try your first command:
583
+ > /specrails:get-backlog-specs
584
+ ```
585
+ (Replace `/specrails:get-backlog-specs` with `/specrails:refactor-recommender` for existing codebases.)
586
+
587
+ If `QS_IS_RERUN=true`, display the gap-fill summary and stop:
588
+ ```
589
+ ✅ Re-run complete.
590
+
591
+ Commands status:
592
+ ✓ Already installed: /specrails:<name>
593
+ ✓ Added /specrails:<name> (was missing)
594
+ [... one line per command ...]
595
+
596
+ All commands are up to date.
597
+ ```
598
+ If all commands were already present, display:
599
+ ```
600
+ ✅ Re-run complete. All commands already installed — nothing to add.
601
+ ```
602
+
603
+ Then stop. Do not execute Phase 1.
604
+
605
+ ---
606
+
607
+ ## Phase 1: Codebase Analysis
608
+
609
+ Analyze the repository to understand its architecture, stack, and conventions.
610
+
611
+ ### 1.1 Read project structure
612
+
613
+ ```bash
614
+ # Get the repo root and basic info
615
+ git rev-parse --show-toplevel
616
+ ls -la
617
+ ```
618
+
619
+ Read the following to understand the project:
620
+ - `README.md` (if exists)
621
+ - `CLAUDE.md` (if exists — don't overwrite, merge later)
622
+ - `package.json` or `pyproject.toml` or `Cargo.toml` or `go.mod` or `pom.xml` (detect stack)
623
+ - `.github/workflows/*.yml` (detect CI commands)
624
+ - `docker-compose.yml` or `Dockerfile` (detect infra)
625
+
626
+ ### 1.2 Detect architecture layers
627
+
628
+ Use Glob and Grep to identify:
629
+
630
+ 1. **Languages**: Check for `*.py`, `*.ts`, `*.tsx`, `*.go`, `*.rs`, `*.java`, `*.kt`, `*.rb`, `*.cs`
631
+ 2. **Frameworks**: Search for imports (`fastapi`, `express`, `react`, `vue`, `angular`, `django`, `spring`, `gin`, `actix`, `rails`)
632
+ 3. **Directory structure**: Identify backend/frontend/core/test directories
633
+ 4. **Database**: Check for SQL files, ORM configs, migration directories
634
+ 5. **CI/CD**: Parse workflow files for lint/test/build commands
635
+
636
+ ### 1.3 Infer conventions
637
+
638
+ Read 3-5 representative source files from each detected layer to understand:
639
+ - Naming conventions (camelCase, snake_case, PascalCase)
640
+ - Import patterns
641
+ - Error handling patterns
642
+ - Testing patterns (framework, structure, mocking approach)
643
+ - API patterns (REST, GraphQL, tRPC)
644
+
645
+ ### 1.4 Present findings
646
+
647
+ Display the detected architecture to the user:
648
+
649
+ ```
650
+ ## Codebase Analysis
651
+
652
+ | Layer | Tech | Path |
653
+ |-------------|---------------------|---------------|
654
+ | Backend | FastAPI (Python) | backend/ |
655
+ | Frontend | React + TypeScript | frontend/ |
656
+ | Core | Python package | src/ |
657
+ | Tests | pytest | tests/ |
658
+ | Database | PostgreSQL | migrations/ |
659
+
660
+ ### CI Commands Detected
661
+ - Lint: `ruff check .`
662
+ - Format: `ruff format --check .`
663
+ - Test: `pytest tests/ -q`
664
+ - Frontend lint: `npm run lint`
665
+ - Frontend build: `npx tsc --noEmit`
666
+
667
+ ### Conventions Detected
668
+ - Python: snake_case, type hints, Pydantic models
669
+ - TypeScript: strict mode, functional components
670
+ - Testing: pytest fixtures with scope="function"
671
+
672
+ ### OSS Project Detection
673
+
674
+ Read `.specrails/setup-templates/.oss-detection.json` if it exists.
675
+
676
+ | Signal | Status |
677
+ |--------|--------|
678
+ | Public repository | [Yes / No / Unknown] |
679
+ | CI workflows (.github/workflows/) | [Yes / No] |
680
+ | CONTRIBUTING.md | [Yes / No] |
681
+ | **Result** | **OSS detected / Not detected / Could not check** |
682
+
683
+ If `is_oss: false` but at least one signal is `true`:
684
+ > "Some OSS signals were found but not all three. Is this an open-source project? (yes/no)"
685
+
686
+ If `.oss-detection.json` does not exist:
687
+ > "Is this an open-source project? (yes/no)"
688
+
689
+ When `IS_OSS=false` and no signals are present, skip OSS output entirely to avoid cluttering the display for non-OSS projects.
690
+
691
+ Store the final OSS determination as `IS_OSS` for use throughout the rest of setup.
692
+
693
+ [Confirm] [Modify] [Rescan]
694
+ ```
695
+
696
+ Wait for user confirmation. If they want to modify, ask what to change.
697
+
698
+ ---
699
+
700
+ ## Phase 2: User Personas & Product Discovery
701
+
702
+ ### 2.1 Ask about target users
703
+
704
+ Ask the user:
705
+
706
+ > If IS_OSS=true, prepend:
707
+ > "This is an OSS project. The **Maintainer** persona (Kai) is automatically included —
708
+ > you do not need to add 'open-source maintainers' to your list.
709
+ > Describe your other target user types below."
710
+
711
+ > **Who are the target users of your software?**
712
+ >
713
+ > Describe them in natural language. Examples:
714
+ > - "Developers who manage Kubernetes clusters"
715
+ > - "Small business owners tracking inventory and sales"
716
+ > - "Gamers who collect and trade digital items"
717
+ >
718
+ > I'll research the competitive landscape and create detailed personas
719
+ > with Value Proposition Canvas profiles for each user type.
720
+ >
721
+ > **How many distinct user types do you have?** (typically 2-3)
722
+
723
+ Wait for the user's response.
724
+
725
+ ### 2.2 Research competitive landscape
726
+
727
+ For each user type described, use WebSearch to research:
728
+
729
+ 1. **Existing tools** they use today (competitors)
730
+ 2. **Common pain points** reported in forums, Reddit, product reviews
731
+ 3. **Feature gaps** in current tools
732
+ 4. **Unmet needs** and workflow frustrations
733
+
734
+ Search queries to use (adapt to the domain):
735
+ - `"[domain] [user type] best tools 2025"`
736
+ - `"[domain] [user type] pain points frustrations"`
737
+ - `"[competitor name] missing features complaints"`
738
+ - `"[domain] management app feature comparison"`
739
+ - `site:reddit.com "[domain] [user type] what tool do you use"`
740
+
741
+ ### 2.3 Generate VPC personas
742
+
743
+ For each user type, generate a full Value Proposition Canvas persona file following the template at `.specrails/setup-templates/personas/persona.md`.
744
+
745
+ Each persona must include:
746
+ - **Profile**: Demographics, behaviors, tools used, spending patterns
747
+ - **Customer Jobs**: Functional, social, emotional (6-8 jobs)
748
+ - **Pains**: Graded by severity (Critical > High > Medium > Low) with 6-8 entries
749
+ - **Gains**: Graded by impact (High > Medium > Low) with 6-8 entries
750
+ - **Key Insight**: The #1 unmet need that this project can address
751
+ - **Sources**: Links to competitive analysis, forums, reviews used in research
752
+
753
+ ### 2.4 Present personas
754
+
755
+ Display each generated persona to the user:
756
+
757
+ ```
758
+ ## Generated Personas
759
+
760
+ ### Persona 1: "[Nickname]" — The [Role]
761
+ - Age: X-Y
762
+ - Key pain: [Critical pain]
763
+ - Key insight: [Main unmet need]
764
+
765
+ ### Persona 2: "[Nickname]" — The [Role]
766
+ - Age: X-Y
767
+ - Key pain: [Critical pain]
768
+ - Key insight: [Main unmet need]
769
+
770
+ [Accept] [Edit] [Regenerate]
771
+ ```
772
+
773
+ Wait for confirmation. If the user wants edits, apply them.
774
+
775
+ ### 2.5 Initialize agent config
776
+
777
+ Check for `.specrails/agents.yaml`:
778
+
779
+ 1. If the file **exists**:
780
+ - Read it
781
+ - Validate all `model:` values — only `opus`, `sonnet`, and `haiku` are valid
782
+ - If any value is invalid, warn the user and fall back to the template default for that agent
783
+ - Store as `AGENTS_CONFIG` for use in Phase 4
784
+
785
+ 2. If the file **does not exist**:
786
+ - Generate it with the default model assignments matching the template hard-coded values:
787
+
788
+ ```yaml
789
+ # specrails agent configuration
790
+ # Modify model assignments and other agent settings
791
+ # Valid models: opus, sonnet, haiku
792
+
793
+ defaults:
794
+ model: sonnet
795
+
796
+ agents:
797
+ sr-architect:
798
+ model: sonnet
799
+ sr-developer:
800
+ model: sonnet
801
+ sr-reviewer:
802
+ model: sonnet
803
+ sr-product-manager:
804
+ model: opus
805
+ sr-product-analyst:
806
+ model: haiku
807
+ sr-test-writer:
808
+ model: sonnet
809
+ sr-security-reviewer:
810
+ model: sonnet
811
+ sr-backend-developer:
812
+ model: sonnet
813
+ sr-frontend-developer:
814
+ model: sonnet
815
+ sr-backend-reviewer:
816
+ model: sonnet
817
+ sr-frontend-reviewer:
818
+ model: sonnet
819
+ sr-doc-sync:
820
+ model: sonnet
821
+ sr-merge-resolver:
822
+ model: sonnet
823
+ sr-performance-reviewer:
824
+ model: sonnet
825
+ ```
826
+
827
+ - Write this file to `.specrails/agents.yaml`
828
+ - Store as `AGENTS_CONFIG` for use in Phase 4
829
+ - Log: "Generated `.specrails/agents.yaml` with default model assignments"
830
+
831
+ ---
832
+
833
+ ## Phase 3: Configuration
834
+
835
+ ### 3.1 Agents to install
836
+
837
+ Present the available agents and let the user choose:
838
+
839
+ ```
840
+ ## Agent Selection
841
+
842
+ Which agents do you want to install?
843
+
844
+ | Agent | Purpose | Model | Required |
845
+ |-------|---------|-------|----------|
846
+ | sr-architect | Design features, create implementation plans | Sonnet | Yes |
847
+ | sr-developer (full-stack) | Implement features across all layers | Sonnet | Yes |
848
+ | sr-reviewer | CI/CD quality gate, fix issues | Sonnet | Yes |
849
+ | sr-test-writer | Generate unit, integration, and edge-case tests after implementation | Sonnet | Yes |
850
+ | sr-security-reviewer | Scan for secrets, OWASP vulnerabilities, hardcoded credentials | Sonnet | Yes |
851
+ | sr-product-manager | Product discovery, ideation, VPC evaluation | Opus | Recommended |
852
+ | sr-product-analyst | Read-only backlog analysis | Haiku | Recommended |
853
+ | sr-backend-developer | Specialized backend implementation | Sonnet | If backend layer exists |
854
+ | sr-frontend-developer | Specialized frontend implementation | Sonnet | If frontend layer exists |
855
+
856
+ [All] [Required only] [Custom selection]
857
+ ```
858
+
859
+ ### 3.2 Backlog provider
860
+
861
+ Ask the user how they want to manage their product backlog. Default is local — no external tools or accounts required:
862
+
863
+ ```
864
+ ## Backlog Provider
865
+
866
+ Use local ticket management or connect an external provider?
867
+
868
+ 1. **Local tickets** (default, recommended) — lightweight JSON-based ticket management built into the project.
869
+ No external tools or accounts required. Tickets stored in `.specrails/local-tickets.json`, version-controlled and diffable.
870
+ 2. **External provider** — connect GitHub Issues, JIRA, or disable backlog commands
871
+ ```
872
+
873
+ If the user selects **1** or presses Enter without typing anything: set `BACKLOG_PROVIDER=local` and proceed directly to **If Local Tickets** below. Do NOT ask about GitHub CLI, JIRA credentials, or any external provider configuration.
874
+
875
+ If the user selects **2**: display the secondary menu:
876
+
877
+ ```
878
+ ## External Backlog Provider
879
+
880
+ Which external provider?
881
+
882
+ 1. **Local tickets** (recommended) — lightweight JSON-based ticket management built into the project.
883
+ No external tools required. Tickets stored in `.specrails/local-tickets.json`, version-controlled and diffable.
884
+ 2. **GitHub Issues** — uses `gh` CLI to read/create issues with labels and VPC scores
885
+ 3. **JIRA** — uses JIRA CLI or REST API to read/create tickets in a JIRA project
886
+ 4. **None** — skip backlog commands (you can still use /implement with text descriptions)
887
+ ```
888
+
889
+ Wait for the user's choice. Set `BACKLOG_PROVIDER` to `local`, `github`, `jira`, or `none`.
890
+
891
+ #### If Local Tickets
892
+
893
+ No external tools or credentials required. Initialize the storage file:
894
+
895
+ 1. Copy `templates/local-tickets-schema.json` to `.specrails/local-tickets.json`
896
+ 2. Set `last_updated` to the current ISO-8601 timestamp
897
+
898
+ Store configuration in `.specrails/backlog-config.json`:
899
+ ```json
900
+ {
901
+ "provider": "local",
902
+ "write_access": true,
903
+ "git_auto": true
904
+ }
905
+ ```
906
+
907
+ Local tickets are always read-write — there is no "read only" mode since the file is local.
908
+
909
+ **Ticket schema** — each entry in the `tickets` map has these fields:
910
+
911
+ ```json
912
+ {
913
+ "id": 1,
914
+ "title": "Feature title",
915
+ "description": "Markdown description",
916
+ "status": "todo",
917
+ "priority": "medium",
918
+ "labels": ["area:frontend", "effort:medium"],
919
+ "assignee": null,
920
+ "prerequisites": [],
921
+ "metadata": {
922
+ "vpc_scores": {},
923
+ "effort_level": "Medium",
924
+ "user_story": "",
925
+ "area": ""
926
+ },
927
+ "comments": [],
928
+ "created_at": "<ISO-8601>",
929
+ "updated_at": "<ISO-8601>",
930
+ "created_by": "user",
931
+ "source": "manual"
932
+ }
933
+ ```
934
+
935
+ **Status values:** `todo`, `in_progress`, `done`, `cancelled`
936
+ **Priority values:** `critical`, `high`, `medium`, `low`
937
+ **Labels:** Freeform strings following the `area:*` and `effort:*` convention
938
+ **Source values:** `manual`, `get-backlog-specs`, `propose-spec`
939
+
940
+ **Advisory file locking protocol** (CLI agents and app server must both follow this):
941
+
942
+ The `revision` counter in the JSON root enables optimistic concurrency — increment it on **every** write. The lock file prevents concurrent corruption:
943
+
944
+ 1. **Acquire lock:** Check for `.specrails/local-tickets.json.lock`
945
+ - If the file exists and its `timestamp` is less than 30 seconds old: wait 500ms and retry (max 5 attempts before aborting with an error)
946
+ - If the file exists and its `timestamp` is 30+ seconds old (stale): delete it and proceed
947
+ - If no lock file exists: proceed immediately
948
+ 2. **Create lock file:** Write `{"agent": "<agent-name-or-process>", "timestamp": "<ISO-8601>"}` to `.specrails/local-tickets.json.lock`
949
+ 3. **Minimal lock window:** Read the JSON → modify in memory → write back → release
950
+ 4. **Release lock:** Delete `.specrails/local-tickets.json.lock`
951
+ 5. **Always increment `revision`** by 1 and update `last_updated` on every successful write
952
+
953
+ The app server uses `proper-lockfile` (or equivalent) to honor the same protocol via the `.lock` file path.
954
+
955
+ #### If GitHub Issues
956
+
957
+ - Verify `gh auth status` works. If not, warn and offer to skip.
958
+ - Ask about **access mode**:
959
+
960
+ ```
961
+ ## GitHub Issues — Access Mode
962
+
963
+ How should we interact with GitHub Issues?
964
+
965
+ 1. **Read & Write** (default) — read backlog, create new issues from product discovery,
966
+ close resolved issues, add comments on partial progress
967
+ 2. **Read only** — read backlog for prioritization, but don't create or modify issues.
968
+ Product discovery will propose ideas as output but won't sync them to GitHub.
969
+ ```
970
+
971
+ Set `BACKLOG_WRITE=true/false`.
972
+
973
+ - If write mode, ask if they want to create labels:
974
+ - `product-driven-backlog` (purple) — product feature ideas
975
+ - `area:*` labels for each detected layer/area
976
+ - `enhancement`, `bug`, `tech-debt`
977
+
978
+ #### If JIRA
979
+
980
+ First, check if JIRA CLI is installed:
981
+
982
+ ```bash
983
+ command -v jira &> /dev/null
984
+ ```
985
+
986
+ If not installed, offer to install it:
987
+
988
+ > JIRA CLI is not installed. There are several options:
989
+ >
990
+ > 1. **go-jira** (recommended) — lightweight CLI
991
+ > - macOS: `brew install go-jira`
992
+ > - Linux/other: `go install github.com/go-jira/jira/cmd/jira@latest`
993
+ > 2. **Atlassian CLI** — official but heavier
994
+ > - `npm install -g @atlassian/cli`
995
+ > 3. **Skip CLI, use REST API** — no CLI needed, uses `curl` with API token
996
+ >
997
+ > Which option? (1/2/3)
998
+
999
+ If the user chooses option 1 or 2, run the install command. If option 3, proceed with REST API mode.
1000
+
1001
+ Then ask for JIRA configuration:
1002
+
1003
+ > To connect to JIRA, I need:
1004
+ >
1005
+ > 1. **JIRA base URL** (e.g., `https://your-company.atlassian.net`)
1006
+ > 2. **Project key** (e.g., `PROJ`, `DECK`, `MYAPP`)
1007
+ > 3. **Authentication method**:
1008
+ > - **JIRA CLI** (`jira` command) — if already configured
1009
+ > - **API token** — stored in `.env` as `JIRA_API_TOKEN` and `JIRA_USER_EMAIL`
1010
+ >
1011
+ > Optional:
1012
+ > - **Custom issue type** for backlog items (default: "Story")
1013
+ > - **Custom fields** for VPC scores (or use labels/description)
1014
+
1015
+ Then ask about **access mode**:
1016
+
1017
+ ```
1018
+ ## JIRA — Access Mode
1019
+
1020
+ How should we interact with JIRA?
1021
+
1022
+ 1. **Read & Write** — read tickets for implementation context, create new tickets
1023
+ from product discovery, add a comment to tickets when implementation is complete
1024
+ 2. **Read only** — read tickets for implementation context, but never create or
1025
+ modify tickets. Product discovery will propose ideas as output only. After
1026
+ implementation, the pipeline will show what to update manually but won't
1027
+ touch JIRA.
1028
+ ```
1029
+
1030
+ Set `BACKLOG_WRITE=true/false`.
1031
+
1032
+ <!-- This command is mirrored from commands/enrich.md for staged installs. -->
1033
+
1034
+ #### Project Label
1035
+
1036
+ After the access mode selection, ask:
1037
+
1038
+ > **Project Label (optional but recommended)**
1039
+ >
1040
+ > JIRA teams often tag all tickets for a product with a project label
1041
+ > (e.g., `PROJECT-specrails`, `PLATFORM`, `MOBILE`). This label is applied
1042
+ > to every ticket the backlog pipeline creates — making it easy to filter all
1043
+ > AI-generated backlog items across JIRA.
1044
+ >
1045
+ > Enter a project label, or press Enter to skip:
1046
+
1047
+ If the user enters a label: set `PROJECT_LABEL=<value>`.
1048
+ If the user skips: set `PROJECT_LABEL=""`.
1049
+
1050
+ #### Epic Link Field
1051
+
1052
+ Ask:
1053
+
1054
+ > **Epic Link Field (optional — advanced)**
1055
+ >
1056
+ > JIRA Next-Gen (team-managed) projects link stories to epics using the `parent`
1057
+ > field. JIRA Classic (company-managed) projects use `Epic Link` (customfield_10014).
1058
+ >
1059
+ > Which does your project use?
1060
+ > 1. `parent` — Next-Gen / team-managed **(default)**
1061
+ > 2. `customfield_10014` — Classic / company-managed
1062
+
1063
+ Set `EPIC_LINK_FIELD` to `parent` or `customfield_10014`. Default: `parent`.
1064
+
1065
+ Store the full configuration in `.specrails/backlog-config.json`:
1066
+ ```json
1067
+ {
1068
+ "provider": "jira",
1069
+ "write_access": true,
1070
+ "jira_base_url": "https://your-company.atlassian.net",
1071
+ "jira_project_key": "PROJ",
1072
+ "issue_type": "Story",
1073
+ "auth_method": "api_token",
1074
+ "cli_installed": true,
1075
+ "project_label": "<PROJECT_LABEL or empty string>",
1076
+ "epic_link_field": "parent",
1077
+ "epic_mapping": {}
1078
+ }
1079
+ ```
1080
+
1081
+ #### If None
1082
+
1083
+ - Skip `/specrails:get-backlog-specs` and `/specrails:auto-propose-backlog-specs` commands.
1084
+ - The `/specrails:implement` command will still work with text descriptions.
1085
+
1086
+ ### 3.3 Git & shipping workflow
1087
+
1088
+ Ask how the user wants to handle git operations after implementation:
1089
+
1090
+ ```
1091
+ ## Git & Shipping
1092
+
1093
+ After implementation is complete, how should we handle shipping?
1094
+
1095
+ 1. **Automatic** (default) — create branch, commit changes, push, and open a PR
1096
+ (requires GitHub CLI for PRs, otherwise prints a compare URL)
1097
+ 2. **Manual** — stop after implementation and review. You handle branching,
1098
+ committing, and PR creation yourself. The pipeline will show a summary
1099
+ of all changes but won't touch git.
1100
+ ```
1101
+
1102
+ Set `GIT_AUTO=true/false`.
1103
+
1104
+ If automatic, also check if `gh` is authenticated (for PR creation). If not, warn that PRs will be skipped but commits and push will still work.
1105
+
1106
+ ### 3.4 Commands to install
1107
+
1108
+ ```
1109
+ ## Command Selection
1110
+
1111
+ | Command | Purpose | Requires |
1112
+ |---------|---------|----------|
1113
+ | /specrails:implement | Full pipeline: sr-architect → sr-developer → sr-reviewer → ship | sr-architect + sr-developer + sr-reviewer |
1114
+ | /specrails:batch-implement | Orchestrate multiple features in dependency-aware waves | sr-architect + sr-developer + sr-reviewer |
1115
+ | /specrails:propose-spec | Interactively propose and refine a feature spec, then create a GitHub issue | GitHub CLI |
1116
+ | /specrails:get-backlog-specs | View prioritized backlog with VPC scores | sr-product-analyst + Backlog provider |
1117
+ | /specrails:auto-propose-backlog-specs | Generate new feature ideas via product discovery | sr-product-manager + Backlog provider |
1118
+ | /specrails:compat-check | Snapshot API surface and detect breaking changes | None |
1119
+ | /specrails:refactor-recommender | Scan for refactoring opportunities ranked by impact/effort | None |
1120
+ | /specrails:why | Search past architectural decisions from agent memory | None |
1121
+
1122
+ [All] [Custom selection]
1123
+ ```
1124
+
1125
+ Note: If `BACKLOG_PROVIDER=none`, the backlog commands are not offered.
1126
+
1127
+ ### 3.5 Confirm configuration
1128
+
1129
+ Display the full configuration summary including access modes:
1130
+
1131
+ ```
1132
+ ## Configuration Summary
1133
+
1134
+ | Setting | Value |
1135
+ |---------|-------|
1136
+ | Backlog provider | GitHub Issues / JIRA / None |
1137
+ | Backlog access | Read & Write / Read only |
1138
+ | Project label (JIRA) | PROJECT-specrails / (none) |
1139
+ | Epic link field (JIRA) | parent / customfield_10014 |
1140
+ | Git workflow | Automatic / Manual |
1141
+ | Agents | [list] |
1142
+ | Commands | [list] |
1143
+ | Personas | [count] personas |
1144
+
1145
+ Note: The `Project label (JIRA)` and `Epic link field (JIRA)` rows are only shown when `BACKLOG_PROVIDER=jira`.
1146
+
1147
+ [Confirm] [Modify]
1148
+ ```
1149
+
1150
+ Wait for final confirmation.
1151
+
1152
+ ---
1153
+
1154
+ ## Phase 4: Generate Files
1155
+
1156
+ Read each template from `.specrails/setup-templates/` and generate the final files adapted to this project. Use the codebase analysis from Phase 1, personas from Phase 2, and configuration from Phase 3.
1157
+
1158
+ **Provider detection (required before any file generation):** Determine `cli_provider` from the existing install layout: use `"codex"` when `.codex/` exists, otherwise `"claude"`. Set `specrails_dir` to `.codex` or `.claude` accordingly. All output paths in Phase 4 use `$SPECRAILS_DIR` as the base directory.
1159
+
1160
+ ### 4.1 Generate agents
1161
+
1162
+ For each selected agent, read the template and generate the adapted version.
1163
+
1164
+ **Template → Output mapping:**
1165
+
1166
+ **If `cli_provider == "claude"` (default):**
1167
+ - `.specrails/setup-templates/agents/sr-architect.md` → `.claude/agents/sr-architect.md`
1168
+ - `.specrails/setup-templates/agents/sr-developer.md` → `.claude/agents/sr-developer.md`
1169
+ - `.specrails/setup-templates/agents/sr-reviewer.md` → `.claude/agents/sr-reviewer.md`
1170
+ - `.specrails/setup-templates/agents/sr-test-writer.md` → `.claude/agents/sr-test-writer.md`
1171
+ - `.specrails/setup-templates/agents/sr-security-reviewer.md` → `.claude/agents/sr-security-reviewer.md`
1172
+ - `.specrails/setup-templates/agents/sr-product-manager.md` → `.claude/agents/sr-product-manager.md`
1173
+ - `.specrails/setup-templates/agents/sr-product-analyst.md` → `.claude/agents/sr-product-analyst.md`
1174
+ - `.specrails/setup-templates/agents/sr-backend-developer.md` → `.claude/agents/sr-backend-developer.md` (if backend layer)
1175
+ - `.specrails/setup-templates/agents/sr-frontend-developer.md` → `.claude/agents/sr-frontend-developer.md` (if frontend layer)
1176
+
1177
+ **If `cli_provider == "codex"`:**
1178
+ - `.specrails/setup-templates/agents/sr-architect.md` → `.codex/agents/sr-architect.toml`
1179
+ - `.specrails/setup-templates/agents/sr-developer.md` → `.codex/agents/sr-developer.toml`
1180
+ - `.specrails/setup-templates/agents/sr-reviewer.md` → `.codex/agents/sr-reviewer.toml`
1181
+ - `.specrails/setup-templates/agents/sr-test-writer.md` → `.codex/agents/sr-test-writer.toml`
1182
+ - `.specrails/setup-templates/agents/sr-security-reviewer.md` → `.codex/agents/sr-security-reviewer.toml`
1183
+ - `.specrails/setup-templates/agents/sr-product-manager.md` → `.codex/agents/sr-product-manager.toml`
1184
+ - `.specrails/setup-templates/agents/sr-product-analyst.md` → `.codex/agents/sr-product-analyst.toml`
1185
+ - `.specrails/setup-templates/agents/sr-backend-developer.md` → `.codex/agents/sr-backend-developer.toml` (if backend layer)
1186
+ - `.specrails/setup-templates/agents/sr-frontend-developer.md` → `.codex/agents/sr-frontend-developer.toml` (if frontend layer)
1187
+
1188
+ When generating each agent:
1189
+ 1. Read the template
1190
+ 2. Replace all `` values with project-specific content:
1191
+ - `specrails-desktop` → project name
1192
+ - `` → detected architecture
1193
+ - `` → detected layer tags (e.g., `[backend]`, `[frontend]`, `[api]`, `[mobile]`)
1194
+ - `` → backend CI commands from Phase 1
1195
+ - `` → frontend CI commands from Phase 1
1196
+ - `` → detected conventions per layer
1197
+ - `` → names from generated personas
1198
+ - `` → paths to persona files
1199
+ - `` → domain knowledge from Phase 2 research
1200
+ - `` → competitors discovered in Phase 2
1201
+ - `` → important file paths detected in Phase 1
1202
+ - `` → project-specific warnings (from existing CLAUDE.md or detected)
1203
+ - `.claude/agent-memory/` → agent memory directory path (e.g., `$SPECRAILS_DIR/agent-memory/sr-<agent-name>/`)
1204
+ - `` → detected languages, frameworks, and test frameworks from Phase 1
1205
+ - `` → comma-separated paths to per-layer rules files (e.g., `$SPECRAILS_DIR/rules/backend.md`, `$SPECRAILS_DIR/rules/frontend.md`)
1206
+ - `.claude/security-exemptions.yaml` → `$SPECRAILS_DIR/security-exemptions.yaml`
1207
+ 3. Resolve the agent's model using `AGENTS_CONFIG` (loaded in Phase 2.5):
1208
+ - Check `AGENTS_CONFIG.agents.<agent-name>.model` (per-agent override)
1209
+ - If not present, check `AGENTS_CONFIG.defaults.model` (global default)
1210
+ - If `AGENTS_CONFIG` was not loaded (e.g., re-run without config), use the model from the template frontmatter (current behavior)
1211
+ - Replace the `model:` field in the YAML frontmatter with the resolved value before writing
1212
+ 4. Write the final file in the format for the active provider:
1213
+
1214
+ **If `cli_provider == "claude"`:** Write as Markdown with YAML frontmatter — the template file as-is (frontmatter preserved).
1215
+
1216
+ **If `cli_provider == "codex"`:** Convert to TOML format:
1217
+ - Extract YAML frontmatter fields: `name`, `description`, `model`
1218
+ - Extract the body content (everything after the closing `---` of the frontmatter)
1219
+ - Map the `model` field: `sonnet` → `codex-mini-latest`, `opus` → `o3`, `haiku` → `codex-mini-latest`
1220
+ - Write a `.toml` file with this structure:
1221
+ ```toml
1222
+ name = "<name from frontmatter>"
1223
+ description = "<description from frontmatter, escaped for TOML>"
1224
+ model = "codex-mini-latest"
1225
+ prompt = """
1226
+ <body content after placeholder substitution>
1227
+ """
1228
+ ```
1229
+
1230
+ ### 4.2 Generate personas
1231
+
1232
+ If IS_OSS=true:
1233
+ 1. Copy `.specrails/setup-templates/personas/the-maintainer.md` to `$SPECRAILS_DIR/agents/personas/the-maintainer.md`
1234
+ 2. Log: "Maintainer persona included"
1235
+ 3. Set MAINTAINER_INCLUDED=true for use in template substitution
1236
+ 4. Set `` = `- \`$SPECRAILS_DIR/agents/personas/the-maintainer.md\` — "Kai" the Maintainer (open-source maintainer)`
1237
+ 5. Increment `` by 1 to account for the Maintainer
1238
+
1239
+ If IS_OSS=false:
1240
+ - Set `` = *(empty string)*
1241
+
1242
+ Then for each user-defined VPC persona from Phase 2.3:
1243
+
1244
+ Write each persona to `$SPECRAILS_DIR/agents/personas/`:
1245
+ - Use the VPC personas generated in Phase 2
1246
+ - File naming: kebab-case of persona nickname (e.g., `the-developer.md`, `the-admin.md`)
1247
+
1248
+ ### 4.3 Generate commands / skills
1249
+
1250
+ For each selected command, read the template and adapt.
1251
+
1252
+ **If `cli_provider == "claude"` (default):**
1253
+ - `.specrails/setup-templates/commands/specrails/implement.md` → `.claude/commands/specrails/implement.md`
1254
+ - `.specrails/setup-templates/commands/specrails/batch-implement.md` → `.claude/commands/specrails/batch-implement.md`
1255
+ - `.specrails/setup-templates/commands/specrails/propose-spec.md` → `.claude/commands/specrails/propose-spec.md`
1256
+ - `.specrails/setup-templates/commands/specrails/get-backlog-specs.md` → `.claude/commands/specrails/get-backlog-specs.md` (if `BACKLOG_PROVIDER != none`)
1257
+ - `.specrails/setup-templates/commands/specrails/auto-propose-backlog-specs.md` → `.claude/commands/specrails/auto-propose-backlog-specs.md` (if `BACKLOG_PROVIDER != none`)
1258
+ - `.specrails/setup-templates/commands/specrails/compat-check.md` → `.claude/commands/specrails/compat-check.md`
1259
+ - `.specrails/setup-templates/commands/specrails/refactor-recommender.md` → `.claude/commands/specrails/refactor-recommender.md`
1260
+ - `.specrails/setup-templates/commands/specrails/why.md` → `.claude/commands/specrails/why.md`
1261
+ - `.specrails/setup-templates/commands/specrails/reconfig.md` → `.claude/commands/specrails/reconfig.md`
1262
+
1263
+ **If `cli_provider == "codex"`:**
1264
+ - `.specrails/setup-templates/skills/sr-implement/SKILL.md` → `.agents/skills/sr-implement/SKILL.md`
1265
+ - `.specrails/setup-templates/skills/sr-batch-implement/SKILL.md` → `.agents/skills/sr-batch-implement/SKILL.md`
1266
+ - `.specrails/setup-templates/commands/specrails/propose-spec.md` → `.agents/skills/sr-propose-spec/SKILL.md` (wrap with YAML frontmatter if no skill template exists)
1267
+ - `.specrails/setup-templates/commands/specrails/get-backlog-specs.md` → `.agents/skills/sr-get-backlog-specs/SKILL.md` (if `BACKLOG_PROVIDER != none`; wrap with frontmatter)
1268
+ - `.specrails/setup-templates/commands/specrails/auto-propose-backlog-specs.md` → `.agents/skills/sr-auto-propose-backlog-specs/SKILL.md` (if `BACKLOG_PROVIDER != none`; wrap with frontmatter)
1269
+ - `.specrails/setup-templates/skills/sr-compat-check/SKILL.md` → `.agents/skills/sr-compat-check/SKILL.md`
1270
+ - `.specrails/setup-templates/skills/sr-refactor-recommender/SKILL.md` → `.agents/skills/sr-refactor-recommender/SKILL.md`
1271
+ - `.specrails/setup-templates/skills/sr-why/SKILL.md` → `.agents/skills/sr-why/SKILL.md`
1272
+ - `.specrails/setup-templates/commands/specrails/reconfig.md` → `.agents/skills/sr-reconfig/SKILL.md` (wrap with YAML frontmatter)
1273
+
1274
+ **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:
1275
+ ```yaml
1276
+ ---
1277
+ name: sr-<name>
1278
+ description: "<one-line description from the command's first heading>"
1279
+ license: MIT
1280
+ compatibility: "Requires git."
1281
+ metadata:
1282
+ author: specrails
1283
+ version: "1.0"
1284
+ ---
1285
+ ```
1286
+
1287
+ For both providers, create the output directory before writing (`mkdir -p` for `.claude/commands/specrails/` or `.agents/skills/sr-<name>/`).
1288
+
1289
+ Adapt:
1290
+ - CI commands to match detected stack
1291
+ - **Persona references** to match generated personas (see substitution rules below)
1292
+ - File paths to match project structure
1293
+ - Layer tags to match detected layers
1294
+ - **Backlog provider commands** based on `BACKLOG_PROVIDER`:
1295
+
1296
+ #### Backlog command persona placeholder substitution
1297
+
1298
+ When adapting `auto-propose-backlog-specs.md` and `get-backlog-specs.md`, substitute the persona placeholders based on the full persona set (user-generated personas + Maintainer if `IS_OSS=true`):
1299
+
1300
+ | Placeholder | Substitution rule |
1301
+ |-------------|------------------|
1302
+ | `` | One bullet per persona file: `- Read \`$SPECRAILS_DIR/agents/personas/{name}.md\`` |
1303
+ | `` | Column headers for each persona nickname: e.g., `Alex \| Sara \| Kai` |
1304
+ | `` | One `------` separator per persona column |
1305
+ | `` | Inline score display: e.g., `Alex: X/5, Sara: X/5, Kai: X/5` |
1306
+ | `` | One VPC section block per persona (see format below) |
1307
+ | `` | Total max score = 5 × number of personas (e.g., `15` for 3 personas) |
1308
+ | `` | Comma-separated: e.g., `Alex (Lead Dev), Sara (Product Founder), Kai (OSS Maintainer)` |
1309
+
1310
+ **`` format** — repeat for each persona in order:
1311
+ ```
1312
+ ### "{Nickname}" — The {Role} (X/5)
1313
+ - **Jobs addressed**: {list}
1314
+ - **Pains relieved**: {list with severity}
1315
+ - **Gains created**: {list with impact}
1316
+ ```
1317
+
1318
+ **Kai inclusion rule**: When `IS_OSS=true`, Kai (`sr-the-maintainer.md`) is always the last entry in persona lists and the rightmost column in scoring tables. Kai uses the evaluation criteria defined in `.claude/agents/personas/sr-the-maintainer.md` — features score high (4-5/5) for Kai when they reduce async review burden, enforce project-specific conventions, or automate release/dependency coordination; features score low (0-1/5) when they add configuration complexity or require paid tiers.
1319
+
1320
+ **When `IS_OSS=false`**: All Kai-related persona references are omitted. `` reduces by 5. Tables and inline scores contain only user-generated personas.
1321
+
1322
+ #### Local Tickets (`BACKLOG_PROVIDER=local`)
1323
+
1324
+ For the local provider, backlog placeholders resolve to **inline file-operation instructions** embedded in the generated command markdown — not shell commands. Agents execute these by reading/writing `.specrails/local-tickets.json` directly using their file tools.
1325
+
1326
+ All write operations must follow the **advisory file locking protocol** defined in Phase 3.2. Always increment `revision` and update `last_updated` on every write.
1327
+
1328
+ | Placeholder | Substituted value |
1329
+ |-------------|-------------------|
1330
+ | `` | `Local Tickets` |
1331
+ | `` | `[[ -f ".specrails/local-tickets.json" ]] && echo "Local tickets storage: OK" \|\| echo "WARNING: .specrails/local-tickets.json not found — run /specrails:enrich to initialize"` |
1332
+ | `` | Read `.specrails/local-tickets.json`. Parse the `tickets` map and return all entries where `status` is `"todo"` or `"in_progress"`. |
1333
+ | `` | Read `.specrails/local-tickets.json`. Parse the `tickets` map and return all entries regardless of status. |
1334
+ | `` | Read `.specrails/local-tickets.json`. Parse the `tickets` map and return all entries where `status` is `"done"` or `"cancelled"`. |
1335
+ | `` | Read `.specrails/local-tickets.json`. Parse JSON and return the full ticket object at `tickets["{id}"]`, or an error if not found. |
1336
+ | `` | Write to `.specrails/local-tickets.json` using the advisory locking protocol: acquire lock → read file → set `id = next_id`, increment `next_id`, set all ticket fields, set `created_at` and `updated_at` to now, bump `revision`, update `last_updated` → write → release lock. |
1337
+ | `` | Write to `.specrails/local-tickets.json` using the advisory locking protocol: acquire lock → read file → update fields in `tickets["{id}"]`, set `updated_at` to now, bump `revision`, update `last_updated` → write → release lock. |
1338
+ | `` | Write to `.specrails/local-tickets.json` using the advisory locking protocol: acquire lock → read file → delete `tickets["{id}"]`, bump `revision`, update `last_updated` → write → release lock. |
1339
+ | `` | Write to `.specrails/local-tickets.json` using the advisory locking protocol: acquire lock → read file → append `{"author": "<agent-name>", "body": "<comment>", "created_at": "<ISO-8601>"}` to `tickets["{id}"].comments` (create the array if absent), set `updated_at` to now, bump `revision`, update `last_updated` → write → release lock. |
1340
+ | `` | Same as `` but append `{"author": "<agent-name>", "body": "<comment>", "type": "progress", "created_at": "<ISO-8601>"}`. |
1341
+ | `` | No label initialization required. Local tickets use freeform label strings. Standard label conventions: `area:frontend`, `area:backend`, `area:api`, `effort:low`, `effort:medium`, `effort:high`. |
1342
+
1343
+ #### GitHub Issues (`BACKLOG_PROVIDER=github`)
1344
+ - Issue fetch: `gh issue list --label "product-driven-backlog" --state open --limit 100 --json number,title,labels,body`
1345
+ - Issue create: `gh issue create --title "..." --label "..." --body "..."`
1346
+ - Issue view: `gh issue view {number} --json number,title,labels,body`
1347
+ - Issue label names to match project areas
1348
+ - Pre-flight check: `gh auth status`
1349
+
1350
+ #### JIRA (`BACKLOG_PROVIDER=jira`)
1351
+ - Issue fetch: `jira issue list --project --type Story --label get-backlog-specs --status "To Do" --plain` or equivalent JIRA REST API call via curl:
1352
+ ```bash
1353
+ curl -s -u "$JIRA_USER_EMAIL:$JIRA_API_TOKEN" \
1354
+ "/rest/api/3/search?jql=project= AND labels=get-backlog-specs AND status='To Do'&fields=summary,description,labels,priority"
1355
+ ```
1356
+ - Issue create: `jira issue create --project --type Story --summary "..." --label get-backlog-specs --description "..."` or equivalent REST API call
1357
+ - Issue view: `jira issue view {key}` or REST API
1358
+ - VPC scores stored in the issue description body (same markdown format, parsed from description)
1359
+ - Pre-flight check: `jira me` or test API connectivity
1360
+ - Store JIRA config in `.specrails/backlog-config.json`:
1361
+ ```json
1362
+ {
1363
+ "provider": "jira",
1364
+ "jira_base_url": "https://your-company.atlassian.net",
1365
+ "jira_project_key": "PROJ",
1366
+ "issue_type": "Story",
1367
+ "auth_method": "api_token"
1368
+ }
1369
+ ```
1370
+
1371
+ The command templates use ``, ``, ``, ``, and related placeholders that get filled with the provider-specific commands (for `local`) or instructions (for `github`, `jira`). The `` placeholder is substituted with a human-readable provider label in all three cases.
1372
+
1373
+ ### 4.4 Generate rules
1374
+
1375
+ For each detected layer, read the layer rule template and generate a layer-specific rules file:
1376
+ - `.specrails/setup-templates/rules/layer.md` → `$SPECRAILS_DIR/rules/{layer-name}.md`
1377
+
1378
+ Each rule file must:
1379
+ - Have the correct `paths:` frontmatter matching the layer's directory
1380
+ - Contain conventions specific to that layer (from Phase 1 analysis)
1381
+ - Reference actual file paths and patterns from the codebase
1382
+
1383
+ ### 4.5 Generate root instructions file
1384
+
1385
+ **If `cli_provider == "claude"`:** If no `CLAUDE.md` exists, generate one from the template. If one already exists, **merge** — add the agent workflow sections without removing existing content.
1386
+
1387
+ **If `cli_provider == "codex"`:** If no `AGENTS.md` exists, generate one from the template. If one already exists, **merge** — add the agent workflow sections without removing existing content.
1388
+
1389
+ ### 4.6 Generate settings
1390
+
1391
+ Resolve `cli_provider` from the existing install layout (`.codex/` => `codex`, otherwise `claude`).
1392
+
1393
+ **If `cli_provider == "claude"` (default):**
1394
+
1395
+ Create or merge `.claude/settings.json` with permissions for:
1396
+ - All detected CI commands
1397
+ - Git operations
1398
+ - OpenSpec CLI (if installed)
1399
+ - GitHub CLI (if available)
1400
+ - Language-specific tools (python, npm, cargo, go, etc.)
1401
+
1402
+ **If `cli_provider == "codex"`:**
1403
+
1404
+ 1. Read `.specrails/setup-templates/settings/codex-config.toml`. Write it to `.codex/config.toml` as-is (no substitutions needed — the TOML is static).
1405
+
1406
+ 2. Read `.specrails/setup-templates/settings/codex-rules.star`. Replace `` with Starlark `prefix_rule(...)` lines for each detected tool allowance:
1407
+
1408
+ | Detected tool/command | Starlark rule |
1409
+ |----------------------|---------------|
1410
+ | OpenSpec CLI (`openspec`) | `prefix_rule(pattern=["openspec"], decision="allow")` |
1411
+ | Python (`python`, `pip`) | `prefix_rule(pattern=["python"], decision="allow")`<br>`prefix_rule(pattern=["pip"], decision="allow")` |
1412
+ | npm (`npm`) | `prefix_rule(pattern=["npm"], decision="allow")` |
1413
+ | Cargo (`cargo`) | `prefix_rule(pattern=["cargo"], decision="allow")` |
1414
+ | Go (`go`) | `prefix_rule(pattern=["go"], decision="allow")` |
1415
+ | Any detected CI command | `prefix_rule(pattern=["<cmd>"], decision="allow")` |
1416
+
1417
+ Write the rendered file to `.codex/rules/default.rules`.
1418
+
1419
+ ```bash
1420
+ mkdir -p .codex/rules
1421
+ ```
1422
+
1423
+ If `cli_provider` cannot be determined (file missing), fall back to `"claude"` behavior.
1424
+
1425
+ ### 4.7 Initialize agent memory
1426
+
1427
+ Create memory directories for each installed agent using the provider-aware base directory:
1428
+
1429
+ ```bash
1430
+ mkdir -p $SPECRAILS_DIR/agent-memory/sr-{agent-name}/
1431
+ ```
1432
+
1433
+ Each gets an empty `MEMORY.md` that will be populated during usage.
1434
+
1435
+ ---
1436
+
1437
+ ## Phase 5: Cleanup & Summary
1438
+
1439
+ ### 5.1 Remove all scaffolding artifacts
1440
+
1441
+ The setup process installed temporary files that are only needed during installation. Remove them all now that the final files have been generated.
1442
+
1443
+ ```bash
1444
+ # 1. Remove setup templates (used as structural references during generation)
1445
+ rm -rf .specrails/setup-templates/
1446
+
1447
+ # 2. Remove the /specrails:enrich command itself — it's a one-time installer, not a permanent command
1448
+ rm -f .claude/commands/enrich.md
1449
+
1450
+ # 3. Remove the specrails/ directory from the repo if it exists at the root
1451
+ # (it was only needed for the retired shell installer and staging templates — everything is now in .claude/)
1452
+ # NOTE: Only remove if it's inside this repo. Ask the user if unsure.
1453
+ ```
1454
+
1455
+ **What gets removed:**
1456
+ | Artifact | Why |
1457
+ |----------|-----|
1458
+ | `.specrails/setup-templates/` | Temporary — templates already rendered into final files |
1459
+ | `.claude/commands/enrich.md` | One-time installer — running it again would overwrite customized agents |
1460
+
1461
+ **What to do with `specrails/`:**
1462
+
1463
+ The `specrails/` directory should NOT be committed to the target repo — it's an installer tool, not part of the project. Always add it to `.gitignore`:
1464
+
1465
+ ```bash
1466
+ # Add specrails/ to .gitignore if not already there
1467
+ if ! grep -q '^specrails/' .gitignore 2>/dev/null; then
1468
+ echo '' >> .gitignore
1469
+ echo '# specrails installer (one-time setup tool, not part of the project)' >> .gitignore
1470
+ echo 'specrails/' >> .gitignore
1471
+ fi
1472
+ ```
1473
+
1474
+ Then ask the user:
1475
+
1476
+ > `specrails/` has been added to `.gitignore`. Do you also want to delete it?
1477
+ >
1478
+ > 1. **Keep it** (default) — stays locally in case you want to re-run setup or install in other repos
1479
+ > 2. **Delete it** — everything is installed, you don't need it anymore
1480
+
1481
+ Apply the user's choice.
1482
+
1483
+ ### 5.2 Verify clean state
1484
+
1485
+ After cleanup, verify that only the intended files remain:
1486
+
1487
+ ```bash
1488
+ # These should exist (the actual system) — use the resolved $SPECRAILS_DIR:
1489
+ # If cli_provider == "claude":
1490
+ ls .claude/agents/sr-*.md
1491
+ ls .claude/agents/personas/*.md
1492
+ ls .claude/commands/specrails/*.md
1493
+ ls .claude/rules/*.md
1494
+ ls .claude/agent-memory/
1495
+
1496
+ # If cli_provider == "codex":
1497
+ ls .codex/agents/sr-*.toml
1498
+ ls .codex/agents/personas/*.md
1499
+ ls .agents/skills/sr-*/SKILL.md
1500
+ ls .codex/rules/*.md
1501
+ ls .codex/agent-memory/
1502
+
1503
+ # These should NOT exist (scaffolding):
1504
+ # .specrails/setup-templates/ — GONE
1505
+ # If cli_provider == "claude": $SPECRAILS_DIR/commands/enrich.md — GONE
1506
+ # If cli_provider == "codex": .agents/skills/setup/ — GONE (installer scaffold, not a generated sr-skill)
1507
+ ```
1508
+
1509
+ If any scaffolding artifact remains, remove it.
1510
+
1511
+ ### 5.3 Summary
1512
+
1513
+ Display the complete installation summary:
1514
+
1515
+ ```
1516
+ ## Setup Complete
1517
+
1518
+ ### Agents Installed
1519
+ | Agent | File | Model |
1520
+ |-------|------|-------|
1521
+ [If cli_provider == "claude":]
1522
+ | sr-architect | .claude/agents/sr-architect.md | Sonnet |
1523
+ | sr-developer | .claude/agents/sr-developer.md | Sonnet |
1524
+ | sr-reviewer | .claude/agents/sr-reviewer.md | Sonnet |
1525
+ | sr-test-writer | .claude/agents/sr-test-writer.md | Sonnet |
1526
+ | sr-security-reviewer | .claude/agents/sr-security-reviewer.md | Sonnet |
1527
+ | sr-product-manager | .claude/agents/sr-product-manager.md | Opus |
1528
+ [If cli_provider == "codex":]
1529
+ | sr-architect | .codex/agents/sr-architect.toml | codex-mini-latest |
1530
+ | sr-developer | .codex/agents/sr-developer.toml | codex-mini-latest |
1531
+ | sr-reviewer | .codex/agents/sr-reviewer.toml | codex-mini-latest |
1532
+ | sr-test-writer | .codex/agents/sr-test-writer.toml | codex-mini-latest |
1533
+ | sr-security-reviewer | .codex/agents/sr-security-reviewer.toml | codex-mini-latest |
1534
+ | sr-product-manager | .codex/agents/sr-product-manager.toml | o3 |
1535
+
1536
+ ### Personas Created
1537
+ | Persona | File | Source |
1538
+ |---------|------|--------|
1539
+ [If IS_OSS=true:]
1540
+ | "Kai" — The Maintainer | $SPECRAILS_DIR/agents/personas/sr-the-maintainer.md | Auto-included (OSS) |
1541
+ [For each user-generated persona:]
1542
+ | "[Name]" — The [Role] | $SPECRAILS_DIR/agents/personas/[name].md | Generated |
1543
+
1544
+ ### Commands / Skills Installed
1545
+ [If cli_provider == "claude":]
1546
+ | Command | File |
1547
+ |---------|------|
1548
+ | /specrails:implement | .claude/commands/specrails/implement.md |
1549
+ | /specrails:batch-implement | .claude/commands/specrails/batch-implement.md |
1550
+ | /specrails:propose-spec | .claude/commands/specrails/propose-spec.md |
1551
+ | /specrails:get-backlog-specs | .claude/commands/specrails/get-backlog-specs.md |
1552
+ | /specrails:auto-propose-backlog-specs | .claude/commands/specrails/auto-propose-backlog-specs.md |
1553
+ | /specrails:compat-check | .claude/commands/specrails/compat-check.md |
1554
+ | /specrails:refactor-recommender | .claude/commands/specrails/refactor-recommender.md |
1555
+ | /specrails:why | .claude/commands/specrails/why.md |
1556
+ [If cli_provider == "codex":]
1557
+ | Skill | File |
1558
+ |-------|------|
1559
+ | $sr-implement | .agents/skills/sr-implement/SKILL.md |
1560
+ | $sr-batch-implement | .agents/skills/sr-batch-implement/SKILL.md |
1561
+ | $sr-propose-spec | .agents/skills/sr-propose-spec/SKILL.md |
1562
+ | $sr-get-backlog-specs | .agents/skills/sr-get-backlog-specs/SKILL.md |
1563
+ | $sr-auto-propose-backlog-specs | .agents/skills/sr-auto-propose-backlog-specs/SKILL.md |
1564
+ | $sr-compat-check | .agents/skills/sr-compat-check/SKILL.md |
1565
+ | $sr-refactor-recommender | .agents/skills/sr-refactor-recommender/SKILL.md |
1566
+ | $sr-why | .agents/skills/sr-why/SKILL.md |
1567
+
1568
+ Note: Only commands/skills selected during setup are shown. Backlog commands are excluded if no backlog provider was configured.
1569
+
1570
+ ### Rules Created
1571
+ | Layer | File |
1572
+ |-------|------|
1573
+ | Backend | $SPECRAILS_DIR/rules/backend.md |
1574
+ | Frontend | $SPECRAILS_DIR/rules/frontend.md |
1575
+
1576
+ ### Scaffolding Removed
1577
+ | Artifact | Status |
1578
+ |----------|--------|
1579
+ | .specrails/setup-templates/ | Deleted |
1580
+ [If cli_provider == "claude":] | .claude/commands/enrich.md | Deleted |
1581
+ [If cli_provider == "codex":] | .agents/skills/setup/ | Deleted |
1582
+ | specrails/ | [User's choice] |
1583
+
1584
+ ### Next Steps
1585
+ [If cli_provider == "claude":]
1586
+ 1. Review the generated files in .claude/
1587
+ 2. Run `/specrails:get-backlog-specs` to see your backlog (if GitHub Issues exist)
1588
+ 3. Run `/specrails:auto-propose-backlog-specs` to generate feature ideas
1589
+ 4. Run `/specrails:implement #issue-number` to implement a feature
1590
+ 5. Commit the .claude/ directory to version control
1591
+ [If cli_provider == "codex":]
1592
+ 1. Review the generated files in .codex/ and .agents/skills/
1593
+ 2. Run `$sr-get-backlog-specs` to see your backlog (if GitHub Issues exist)
1594
+ 3. Run `$sr-auto-propose-backlog-specs` to generate feature ideas
1595
+ 4. Run `$sr-implement #issue-number` to implement a feature
1596
+ 5. Commit the .codex/ and .agents/ directories to version control
1597
+
1598
+ ### Quick Start
1599
+ [If cli_provider == "claude":]
1600
+ - `/specrails:implement "describe a feature"` — implement something right now
1601
+ - `/specrails:get-backlog-specs` — see prioritized feature ideas
1602
+ - `/specrails:auto-propose-backlog-specs` — discover new features using VPC
1603
+ [If cli_provider == "codex":]
1604
+ - `$sr-implement "describe a feature"` — implement something right now
1605
+ - `$sr-get-backlog-specs` — see prioritized feature ideas
1606
+ - `$sr-auto-propose-backlog-specs` — discover new features using VPC
1607
+ ```
1608
+
1609
+ ## First Task Prompt (Full Wizard)
1610
+
1611
+ After displaying the setup complete summary above, detect the project type and output:
1612
+
1613
+ **New project** (no `package.json`, `Gemfile`, `pyproject.toml`, `go.mod`, or `pom.xml` in root):
1614
+ ```
1615
+ ✅ Setup complete.
1616
+
1617
+ Try your first spec:
1618
+ [If cli_provider == "claude":]
1619
+ > /specrails:get-backlog-specs
1620
+ [If cli_provider == "codex":]
1621
+ > $sr-get-backlog-specs
1622
+ ```
1623
+
1624
+ **Existing codebase** (one or more of the above files found in root):
1625
+ ```
1626
+ ✅ Setup complete.
1627
+
1628
+ Try your first spec:
1629
+ [If cli_provider == "claude":]
1630
+ > /specrails:refactor-recommender
1631
+ [If cli_provider == "codex":]
1632
+ > $sr-refactor-recommender
1633
+ ```
1634
+
1635
+ Then stop.