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.
- package/.claude/commands/specrails/batch-implement.md +287 -0
- package/.claude/commands/specrails/compat-check.md +271 -0
- package/.claude/commands/specrails/doctor.md +62 -0
- package/.claude/commands/specrails/enrich.md +1635 -0
- package/.claude/commands/specrails/explore-spec.md +173 -0
- package/.claude/commands/specrails/health-check.md +527 -0
- package/.claude/commands/specrails/implement.md +1457 -0
- package/.claude/commands/specrails/memory-inspect.md +259 -0
- package/.claude/commands/specrails/opsx-diff.md +419 -0
- package/.claude/commands/specrails/propose-spec.md +102 -0
- package/.claude/commands/specrails/reconfig.md +89 -0
- package/.claude/commands/specrails/refactor-recommender.md +212 -0
- package/.claude/commands/specrails/retry.md +363 -0
- package/.claude/commands/specrails/telemetry.md +552 -0
- package/.claude/commands/specrails/why.md +96 -0
- package/LICENSE +21 -0
- package/README.md +290 -0
- package/cli/dist/specrails-desktop.js +1098 -0
- package/client/dist/assets/ActivityFeedPage-Gy4x8dBt.js +1 -0
- package/client/dist/assets/AgentsPage-CPgu--Fb.js +86 -0
- package/client/dist/assets/AnalyticsPage-B5sJEee2.js +1 -0
- package/client/dist/assets/BarChart-7IMQ8HY1.js +33 -0
- package/client/dist/assets/CodePage-CBdFvbwe.js +2 -0
- package/client/dist/assets/DesktopAnalyticsPage-w0rdTq4w.js +1 -0
- package/client/dist/assets/DocsDialog-BZUYM7wm.js +11 -0
- package/client/dist/assets/DocsPage-9QglWl46.js +11 -0
- package/client/dist/assets/ExportDropdown-BLZFXtNi.js +1 -0
- package/client/dist/assets/IntegrationsPage-BxBE4y99.js +3 -0
- package/client/dist/assets/JobDetailPage-DydWx_5S.js +16 -0
- package/client/dist/assets/JobsPage-20ibw0IO.js +1 -0
- package/client/dist/assets/abap-Bw6f2wDG.js +1 -0
- package/client/dist/assets/activity-BEIp_Y1A.js +1 -0
- package/client/dist/assets/activity-BdrPln96.js +1 -0
- package/client/dist/assets/activity-CpkRS8Sx.js +1 -0
- package/client/dist/assets/activity-DKCpESPt.js +1 -0
- package/client/dist/assets/activity-DOUVEjJi.js +1 -0
- package/client/dist/assets/activity-DRwkql_y.js +1 -0
- package/client/dist/assets/activity-DcDQ7tjw.js +1 -0
- package/client/dist/assets/activity-Dv6H7wEr.js +1 -0
- package/client/dist/assets/addon-image-3WCl5Vhd.js +1 -0
- package/client/dist/assets/addon-ligatures-C5OdliKs.js +2 -0
- package/client/dist/assets/addon-webgl-BbX6pSjl.js +44 -0
- package/client/dist/assets/addspec-B5yl4Loj.js +1 -0
- package/client/dist/assets/addspec-BEeF5-zc.js +1 -0
- package/client/dist/assets/addspec-D33ocMxf.js +1 -0
- package/client/dist/assets/addspec-DFswZ0jK.js +1 -0
- package/client/dist/assets/addspec-DRE-jZv7.js +1 -0
- package/client/dist/assets/addspec-DVZ15Jp8.js +1 -0
- package/client/dist/assets/addspec-Fkv91Opc.js +1 -0
- package/client/dist/assets/addspec-GWm4ffKl.js +1 -0
- package/client/dist/assets/agents-1nCDWRmP.js +1 -0
- package/client/dist/assets/agents-Bm9rPqnt.js +1 -0
- package/client/dist/assets/agents-CMxtJMLD.js +1 -0
- package/client/dist/assets/agents-DK-Dlc0i.js +1 -0
- package/client/dist/assets/agents-Q6Ldfpxx.js +1 -0
- package/client/dist/assets/agents-TeOSy-ax.js +1 -0
- package/client/dist/assets/agents-iTqjRajS.js +1 -0
- package/client/dist/assets/agents-s87sMGzL.js +1 -0
- package/client/dist/assets/agentstudio-B6Wb59E7.js +1 -0
- package/client/dist/assets/agentstudio-BADhZ41e.js +1 -0
- package/client/dist/assets/agentstudio-BSnWLR63.js +1 -0
- package/client/dist/assets/agentstudio-BdidyBzZ.js +1 -0
- package/client/dist/assets/agentstudio-CxlUllqI.js +1 -0
- package/client/dist/assets/agentstudio-D3I62TLJ.js +1 -0
- package/client/dist/assets/agentstudio-DuH9TogZ.js +1 -0
- package/client/dist/assets/agentstudio-Kw88_dUF.js +1 -0
- package/client/dist/assets/aiedit-BWxHGsYA.js +1 -0
- package/client/dist/assets/aiedit-D2ji6Qy0.js +1 -0
- package/client/dist/assets/aiedit-DAhZTvtk.js +1 -0
- package/client/dist/assets/aiedit-DJMny-D5.js +1 -0
- package/client/dist/assets/aiedit-DOcxERkU.js +1 -0
- package/client/dist/assets/aiedit-DvrcbwGv.js +1 -0
- package/client/dist/assets/aiedit-TTwzL1TS.js +1 -0
- package/client/dist/assets/aiedit-WBSjT_C1.js +1 -0
- package/client/dist/assets/analytics-BIdr0YfL.js +1 -0
- package/client/dist/assets/analytics-C6EzgtdE.js +1 -0
- package/client/dist/assets/analytics-C9Zc-rkM.js +1 -0
- package/client/dist/assets/analytics-CVx3YOc0.js +1 -0
- package/client/dist/assets/analytics-CYj0tfj7.js +1 -0
- package/client/dist/assets/analytics-CnY4kNG3.js +1 -0
- package/client/dist/assets/analytics-CrPCZRJ-.js +1 -0
- package/client/dist/assets/analytics-DMCto-TF.js +1 -0
- package/client/dist/assets/apex-Cw8_REBo.js +1 -0
- package/client/dist/assets/atom-one-dark-B-oHczHB.css +1 -0
- package/client/dist/assets/attachments-BIsSSnHJ.js +1 -0
- package/client/dist/assets/attachments-BW4L3l2L.js +1 -0
- package/client/dist/assets/attachments-Bcf6BG6V.js +1 -0
- package/client/dist/assets/attachments-Bke8sCU4.js +1 -0
- package/client/dist/assets/attachments-COcrGRFz.js +1 -0
- package/client/dist/assets/attachments-DYHGA2Dj.js +1 -0
- package/client/dist/assets/attachments-Dd92KpUH.js +1 -0
- package/client/dist/assets/attachments-DzdU6DV6.js +1 -0
- package/client/dist/assets/azcli-Cz6HAoOw.js +1 -0
- package/client/dist/assets/bat-CcJ-xyqL.js +1 -0
- package/client/dist/assets/bicep-z1WDCKYz.js +2 -0
- package/client/dist/assets/browser-5ErDlJoR.js +1 -0
- package/client/dist/assets/browser-Bc-YdlVg.js +1 -0
- package/client/dist/assets/browser-BlYF4OOq.js +1 -0
- package/client/dist/assets/browser-CT-ReZGt.js +1 -0
- package/client/dist/assets/browser-DGITz3fC.js +1 -0
- package/client/dist/assets/browser-JsAIGCEW.js +1 -0
- package/client/dist/assets/browser-M5-rbPlw.js +1 -0
- package/client/dist/assets/browser-Qya9cARy.js +1 -0
- package/client/dist/assets/cameligo-BRewOpfa.js +1 -0
- package/client/dist/assets/chat-BEGuC03z.js +1 -0
- package/client/dist/assets/chat-BEW60P_u.js +1 -0
- package/client/dist/assets/chat-BQNMD0PL.js +1 -0
- package/client/dist/assets/chat-BsbNGPW9.js +1 -0
- package/client/dist/assets/chat-CboQguCi.js +1 -0
- package/client/dist/assets/chat-DRCa9pOt.js +1 -0
- package/client/dist/assets/chat-DwUm6W9z.js +1 -0
- package/client/dist/assets/chat-yoXwguQu.js +1 -0
- package/client/dist/assets/chunk-CilyBKbf.js +1 -0
- package/client/dist/assets/clojure-DBjRWN6g.js +1 -0
- package/client/dist/assets/clsx-DnqN-uhr.js +1 -0
- package/client/dist/assets/code-AL1rVIMb.js +1 -0
- package/client/dist/assets/code-C0BKpkht.js +1 -0
- package/client/dist/assets/code-C0FTS3ew.js +1 -0
- package/client/dist/assets/code-CPcHxzxw.js +1 -0
- package/client/dist/assets/code-D3ryDniw.js +1 -0
- package/client/dist/assets/code-D3zVVQTj.js +1 -0
- package/client/dist/assets/code-PCmfS3dn.js +1 -0
- package/client/dist/assets/code-exI0G5Wd.js +1 -0
- package/client/dist/assets/codicon-ngg6Pgfi.ttf +0 -0
- package/client/dist/assets/coffee-Cfk_XHGR.js +1 -0
- package/client/dist/assets/commands-B772IyDa.js +1 -0
- package/client/dist/assets/commands-BDDp6xFG.js +1 -0
- package/client/dist/assets/commands-CJxCry-o.js +1 -0
- package/client/dist/assets/commands-CfgY-_of.js +1 -0
- package/client/dist/assets/commands-DLrvnPNg.js +1 -0
- package/client/dist/assets/commands-IXMOKBYt.js +1 -0
- package/client/dist/assets/commands-UD1NzmwX.js +1 -0
- package/client/dist/assets/commands-sqrqsxyE.js +1 -0
- package/client/dist/assets/common-DCr6VzJ7.js +1 -0
- package/client/dist/assets/common-Dard9UNH.js +1 -0
- package/client/dist/assets/common-DeDELLZJ.js +1 -0
- package/client/dist/assets/common-DltqHaAe.js +1 -0
- package/client/dist/assets/common-Dmm1GhdD.js +1 -0
- package/client/dist/assets/common-DnjcgkPH.js +1 -0
- package/client/dist/assets/common-GbpxfPG8.js +1 -0
- package/client/dist/assets/common-wA36jmj1.js +1 -0
- package/client/dist/assets/cpp-BVob6BaP.js +1 -0
- package/client/dist/assets/csharp-C4fbRuOu.js +1 -0
- package/client/dist/assets/csp-DthFP_vT.js +1 -0
- package/client/dist/assets/css-CGMH0hcW.js +3 -0
- package/client/dist/assets/css.worker-Wv5dxAWO.js +89 -0
- package/client/dist/assets/cssMode-Cc6ozl-J.js +1 -0
- package/client/dist/assets/cypher-Pnf68BRV.js +1 -0
- package/client/dist/assets/dart-PMMOtxZX.js +1 -0
- package/client/dist/assets/dashboard-B4ixDVk8.js +1 -0
- package/client/dist/assets/dashboard-BZBADHSj.js +1 -0
- package/client/dist/assets/dashboard-C1MfeUHs.js +1 -0
- package/client/dist/assets/dashboard-C7SK6xu5.js +1 -0
- package/client/dist/assets/dashboard-CB6Le1yN.js +1 -0
- package/client/dist/assets/dashboard-CoTpMOBM.js +1 -0
- package/client/dist/assets/dashboard-Duo4DDCW.js +1 -0
- package/client/dist/assets/dashboard-I19DXBxw.js +1 -0
- package/client/dist/assets/dist-js-BY-Fv_fg.js +1 -0
- package/client/dist/assets/dist-js-Bakc4uxT.js +1 -0
- package/client/dist/assets/dockerfile-di1nsJCc.js +1 -0
- package/client/dist/assets/ecl-D_WVcB5M.js +1 -0
- package/client/dist/assets/editor-Br_kD0ds.css +1 -0
- package/client/dist/assets/editor.api2-XLGzZfbc.js +872 -0
- package/client/dist/assets/editor.main-CfXxHimg.js +6 -0
- package/client/dist/assets/editor.worker-Bd9IXS8d.js +26 -0
- package/client/dist/assets/elixir-OAdJEMOn.js +1 -0
- package/client/dist/assets/explore-4mFpnrKU.js +1 -0
- package/client/dist/assets/explore-A8Ltoblq.js +1 -0
- package/client/dist/assets/explore-B9A3iN2W.js +1 -0
- package/client/dist/assets/explore-BV5Xxlsn.js +1 -0
- package/client/dist/assets/explore-BrBJvfjP.js +1 -0
- package/client/dist/assets/explore-C3FSE42C.js +1 -0
- package/client/dist/assets/explore-D2EFgt8J.js +1 -0
- package/client/dist/assets/explore-hFc3HFcp.js +1 -0
- package/client/dist/assets/flow9-D3QEZjgn.js +1 -0
- package/client/dist/assets/format-command-CwGuwzGA.js +1 -0
- package/client/dist/assets/freemarker2-DP7J1gG3.js +3 -0
- package/client/dist/assets/fsharp-BF0k_8N8.js +1 -0
- package/client/dist/assets/go-BAQO5Jsz.js +1 -0
- package/client/dist/assets/graphql-hdFVFkiV.js +1 -0
- package/client/dist/assets/handlebars-BjRlucw6.js +1 -0
- package/client/dist/assets/hcl-DWnl1o-X.js +1 -0
- package/client/dist/assets/html-OumBQJ-U.js +1 -0
- package/client/dist/assets/html.worker-CQP8QQsS.js +502 -0
- package/client/dist/assets/htmlMode-CStc3zXM.js +1 -0
- package/client/dist/assets/index-CimDRRi7.css +2 -0
- package/client/dist/assets/index-XGZaKl_u.js +142 -0
- package/client/dist/assets/ini-CB-6OVu3.js +1 -0
- package/client/dist/assets/integrations-C3p12Ms6.js +1 -0
- package/client/dist/assets/integrations-Cr6hH7XR.js +1 -0
- package/client/dist/assets/integrations-Cublz3m6.js +1 -0
- package/client/dist/assets/integrations-D28q1kF6.js +1 -0
- package/client/dist/assets/integrations-DRdbki5W.js +1 -0
- package/client/dist/assets/integrations-DaC4SzzL.js +1 -0
- package/client/dist/assets/integrations-DmQYCUvN.js +1 -0
- package/client/dist/assets/integrations-HIlUxXVs.js +1 -0
- package/client/dist/assets/java-d1CmfiHX.js +1 -0
- package/client/dist/assets/javascript-CMk--e7g.js +1 -0
- package/client/dist/assets/jobs-BE1siB0M.js +1 -0
- package/client/dist/assets/jobs-BHcQ_Faf.js +1 -0
- package/client/dist/assets/jobs-CFfc2dNX.js +1 -0
- package/client/dist/assets/jobs-CSi5n8X_.js +1 -0
- package/client/dist/assets/jobs-Dc3X86PY.js +1 -0
- package/client/dist/assets/jobs-De5tASex.js +1 -0
- package/client/dist/assets/jobs-DsoXEdo7.js +1 -0
- package/client/dist/assets/jobs-Wl-ApPMb.js +1 -0
- package/client/dist/assets/json.worker-DzV-CpCQ.js +58 -0
- package/client/dist/assets/jsonMode-C2h3ZcjZ.js +7 -0
- package/client/dist/assets/julia-Bgv08lKa.js +1 -0
- package/client/dist/assets/kotlin-u98kaVTf.js +1 -0
- package/client/dist/assets/less-CjYwpgg5.js +2 -0
- package/client/dist/assets/lexon-YTjaAFBB.js +1 -0
- package/client/dist/assets/lib-CPxTMOAq.js +7 -0
- package/client/dist/assets/liquid-mI3KJrBE.js +1 -0
- package/client/dist/assets/lspLanguageFeatures-DU09ggWi.js +4 -0
- package/client/dist/assets/lua-BzmkWv27.js +1 -0
- package/client/dist/assets/m3-CFwk9fw0.js +1 -0
- package/client/dist/assets/markdown-CR5iMpSZ.js +1 -0
- package/client/dist/assets/mdx-C41VDTR_.js +1 -0
- package/client/dist/assets/mips-CcEalc17.js +1 -0
- package/client/dist/assets/monaco.contribution-CPObAXMC.js +2 -0
- package/client/dist/assets/msdax-BQbkawnr.js +1 -0
- package/client/dist/assets/mysql-GTlaaW_P.js +1 -0
- package/client/dist/assets/nav-0fwkrgHt.js +1 -0
- package/client/dist/assets/nav-BEL3MTwK.js +1 -0
- package/client/dist/assets/nav-B_G-TJDW.js +1 -0
- package/client/dist/assets/nav-C2YXcbZS.js +1 -0
- package/client/dist/assets/nav-ClzOE4mA.js +1 -0
- package/client/dist/assets/nav-CtYwmMgu.js +1 -0
- package/client/dist/assets/nav-D2bOGSEg.js +1 -0
- package/client/dist/assets/nav-iH1V5j6o.js +1 -0
- package/client/dist/assets/objective-c-Byu1T5if.js +1 -0
- package/client/dist/assets/pascal-BrfzBfRm.js +1 -0
- package/client/dist/assets/pascaligo-BXXKFUeo.js +1 -0
- package/client/dist/assets/perl-B3OikKq-.js +1 -0
- package/client/dist/assets/pgsql-CTsa0Acc.js +1 -0
- package/client/dist/assets/php-DiQh3FUW.js +1 -0
- package/client/dist/assets/pla-92uH8Fzm.js +1 -0
- package/client/dist/assets/postiats-BbeWkKUr.js +1 -0
- package/client/dist/assets/powerquery-DgDMzpsm.js +1 -0
- package/client/dist/assets/powershell-BfdUUzaG.js +1 -0
- package/client/dist/assets/preload-helper-DSXbuxSR.js +1 -0
- package/client/dist/assets/protobuf-BojW2ftW.js +2 -0
- package/client/dist/assets/pug-BxqTg3IU.js +1 -0
- package/client/dist/assets/python-Y27rKQtk.js +1 -0
- package/client/dist/assets/qsharp-BX_A-MW9.js +1 -0
- package/client/dist/assets/r-D9BMnxvJ.js +1 -0
- package/client/dist/assets/razor-Cd5-q9Bp.js +1 -0
- package/client/dist/assets/redis-5cJqEQJJ.js +1 -0
- package/client/dist/assets/redshift-d8BBqiwb.js +1 -0
- package/client/dist/assets/restructuredtext-C8a6yIcZ.js +1 -0
- package/client/dist/assets/ruby-egeh-6KX.js +1 -0
- package/client/dist/assets/rust-a3r9IInB.js +1 -0
- package/client/dist/assets/sb-y8iRIDei.js +1 -0
- package/client/dist/assets/scala-BPDK2AmK.js +1 -0
- package/client/dist/assets/scheme-BIWUEoOs.js +1 -0
- package/client/dist/assets/scss-CA-PSzwg.js +3 -0
- package/client/dist/assets/settings-55oDcbSh.js +1 -0
- package/client/dist/assets/settings-Bd4Tq1RB.js +1 -0
- package/client/dist/assets/settings-CCSM-Fhn.js +1 -0
- package/client/dist/assets/settings-D3e_bDoW.js +1 -0
- package/client/dist/assets/settings-DKbTkbn7.js +1 -0
- package/client/dist/assets/settings-Dxpo6_w7.js +1 -0
- package/client/dist/assets/settings-bt84e3Aa.js +1 -0
- package/client/dist/assets/settings-nu68QukM.js +1 -0
- package/client/dist/assets/setup-BMqwfbW9.js +1 -0
- package/client/dist/assets/setup-Bb5LcG28.js +1 -0
- package/client/dist/assets/setup-BeEx2_da.js +1 -0
- package/client/dist/assets/setup-CCCrB53Q.js +1 -0
- package/client/dist/assets/setup-CJA0ATmd.js +1 -0
- package/client/dist/assets/setup-CeiDbZcb.js +1 -0
- package/client/dist/assets/setup-Cus7TApA.js +1 -0
- package/client/dist/assets/setup-D9qOs2Xo.js +1 -0
- package/client/dist/assets/shell--LiT1Bja.js +1 -0
- package/client/dist/assets/solidity-DdqZccZg.js +1 -0
- package/client/dist/assets/sophia-S6-YxNG_.js +1 -0
- package/client/dist/assets/sparql-BSf5kMp2.js +1 -0
- package/client/dist/assets/specs-BFfu3u-a.js +1 -0
- package/client/dist/assets/specs-B__C8-8a.js +1 -0
- package/client/dist/assets/specs-CZ1PsXsC.js +1 -0
- package/client/dist/assets/specs-D2FzlLn9.js +1 -0
- package/client/dist/assets/specs-DaUTrNF9.js +1 -0
- package/client/dist/assets/specs-Dyc5hYeE.js +1 -0
- package/client/dist/assets/specs-cKEh2LXt.js +1 -0
- package/client/dist/assets/specs-k0PyLDVt.js +1 -0
- package/client/dist/assets/sql-D7KgjR8G.js +1 -0
- package/client/dist/assets/st-BnoDa-Ml.js +1 -0
- package/client/dist/assets/swift-DEUHTkUX.js +1 -0
- package/client/dist/assets/systemverilog-Tqb_KPnW.js +1 -0
- package/client/dist/assets/tcl-BmBFS2qq.js +1 -0
- package/client/dist/assets/terminal-80yDMgMF.js +1 -0
- package/client/dist/assets/terminal-Bje4ziIa.js +1 -0
- package/client/dist/assets/terminal-C2WYcFHF.js +1 -0
- package/client/dist/assets/terminal-CSONJOex.js +1 -0
- package/client/dist/assets/terminal-DEqzGtcr.js +1 -0
- package/client/dist/assets/terminal-DeWzh6ys.js +1 -0
- package/client/dist/assets/terminal-YOlsJCQj.js +1 -0
- package/client/dist/assets/terminal-lkZYR4wJ.js +1 -0
- package/client/dist/assets/tickets-CB7N30gm.js +1 -0
- package/client/dist/assets/tickets-CF2PYelu.js +1 -0
- package/client/dist/assets/tickets-DNOANUXr.js +1 -0
- package/client/dist/assets/tickets-DU1aqsbr.js +1 -0
- package/client/dist/assets/tickets-DYvafSaY.js +1 -0
- package/client/dist/assets/tickets-DlpC_iTg.js +1 -0
- package/client/dist/assets/tickets-DucYgtdl.js +1 -0
- package/client/dist/assets/tickets-clefmXLv.js +1 -0
- package/client/dist/assets/ts.worker-METxwbDZ.js +67719 -0
- package/client/dist/assets/tsMode-B0y_xEci.js +11 -0
- package/client/dist/assets/twig-BQV8igWC.js +1 -0
- package/client/dist/assets/typescript-BzK0OgwW.js +1 -0
- package/client/dist/assets/typespec-DlFroUGY.js +1 -0
- package/client/dist/assets/useProjectCache-DSaiGFjV.js +1 -0
- package/client/dist/assets/vb-BlrJpIMX.js +1 -0
- package/client/dist/assets/wgsl-BWgIc6FZ.js +298 -0
- package/client/dist/assets/workers-rt--R2Qy.js +1 -0
- package/client/dist/assets/xml-eX9QXAmI.js +1 -0
- package/client/dist/assets/yaml-fcsNkpOt.js +1 -0
- package/client/dist/index.html +246 -0
- package/docs/README.md +54 -0
- package/docs/cli.md +198 -0
- package/docs/codex.md +210 -0
- package/docs/creating-specs.md +197 -0
- package/docs/customizing.md +197 -0
- package/docs/getting-started.md +140 -0
- package/docs/internals/README.md +25 -0
- package/docs/internals/adding-a-provider.md +238 -0
- package/docs/internals/api-reference.md +634 -0
- package/docs/internals/architecture.md +332 -0
- package/docs/internals/configuration.md +172 -0
- package/docs/internals/openspec-workflow.md +282 -0
- package/docs/internals/operations-runbook.md +198 -0
- package/docs/internals/profiles.md +152 -0
- package/docs/platforms/macos.md +130 -0
- package/docs/platforms/windows.md +81 -0
- package/docs/running-pipelines.md +240 -0
- package/docs/terminal.md +138 -0
- package/docs/tracking-cost.md +155 -0
- package/package.json +82 -0
- package/server/dist/agent-generator.js +232 -0
- package/server/dist/agent-refine-db.js +124 -0
- package/server/dist/agent-refine-manager.js +526 -0
- package/server/dist/ai-invocations.js +111 -0
- package/server/dist/attachment-manager.js +299 -0
- package/server/dist/auth.js +207 -0
- package/server/dist/binary-probe.js +35 -0
- package/server/dist/browser-capture-manager.js +576 -0
- package/server/dist/browser-capture-types.js +28 -0
- package/server/dist/browser-network.js +149 -0
- package/server/dist/browser-playwright.js +888 -0
- package/server/dist/build-dirs.js +44 -0
- package/server/dist/changes-reader.js +120 -0
- package/server/dist/chat-manager.js +1060 -0
- package/server/dist/chromium-resolver.js +311 -0
- package/server/dist/code-explorer-router.js +788 -0
- package/server/dist/codex-otel-bridge.js +235 -0
- package/server/dist/command-resolver.js +102 -0
- package/server/dist/config.js +306 -0
- package/server/dist/context-budget.js +113 -0
- package/server/dist/context-scope.js +279 -0
- package/server/dist/contract-refine-runner.js +521 -0
- package/server/dist/core-compat.js +207 -0
- package/server/dist/core-package.js +14 -0
- package/server/dist/db.js +1034 -0
- package/server/dist/desktop-analytics.js +156 -0
- package/server/dist/desktop-db.js +456 -0
- package/server/dist/desktop-router.js +735 -0
- package/server/dist/docs-router.js +207 -0
- package/server/dist/explore-contract-refine.js +421 -0
- package/server/dist/explore-cwd-manager.js +242 -0
- package/server/dist/explore-draft-title.js +47 -0
- package/server/dist/explore-smash.js +450 -0
- package/server/dist/feature-flags.js +17 -0
- package/server/dist/file-provenance.js +382 -0
- package/server/dist/file-summary-generator.js +221 -0
- package/server/dist/file-summary-manager.js +689 -0
- package/server/dist/hooks.js +102 -0
- package/server/dist/ids.js +7 -0
- package/server/dist/index.js +586 -0
- package/server/dist/metrics.js +136 -0
- package/server/dist/mobile/index.js +16 -0
- package/server/dist/mobile/mobile-admin-router.js +84 -0
- package/server/dist/mobile/mobile-auth.js +67 -0
- package/server/dist/mobile/mobile-devices.js +80 -0
- package/server/dist/mobile/mobile-event-bus.js +39 -0
- package/server/dist/mobile/mobile-gateway.js +285 -0
- package/server/dist/mobile/mobile-mdns.js +81 -0
- package/server/dist/mobile/mobile-pairing.js +179 -0
- package/server/dist/mobile/mobile-redact.js +53 -0
- package/server/dist/mobile/mobile-router.js +411 -0
- package/server/dist/mobile/mobile-tls.js +86 -0
- package/server/dist/mobile/mobile-types.js +9 -0
- package/server/dist/mobile/mobile-ws.js +275 -0
- package/server/dist/path-resolver.js +298 -0
- package/server/dist/plugin-manager.js +617 -0
- package/server/dist/plugins/claude-approval.js +179 -0
- package/server/dist/plugins/claude-md-mutation.js +146 -0
- package/server/dist/plugins/codex-mcp.js +108 -0
- package/server/dist/plugins/contributors.js +72 -0
- package/server/dist/plugins/drift.js +58 -0
- package/server/dist/plugins/index.js +14 -0
- package/server/dist/plugins/json-mutation.js +120 -0
- package/server/dist/plugins/manager.js +32 -0
- package/server/dist/plugins/ownership.js +86 -0
- package/server/dist/plugins/paths.js +37 -0
- package/server/dist/plugins/prereq-installer.js +104 -0
- package/server/dist/plugins/rail-integration.js +79 -0
- package/server/dist/plugins/serena/index.js +13 -0
- package/server/dist/plugins/serena/install.js +91 -0
- package/server/dist/plugins/serena/instructions-content.js +21 -0
- package/server/dist/plugins/serena/manifest.js +111 -0
- package/server/dist/plugins/serena/verify.js +78 -0
- package/server/dist/plugins-router.js +215 -0
- package/server/dist/pricing.js +89 -0
- package/server/dist/profile-manager.js +310 -0
- package/server/dist/profiles-router.js +759 -0
- package/server/dist/project-registry.js +443 -0
- package/server/dist/project-router.js +4016 -0
- package/server/dist/proposal-manager.js +291 -0
- package/server/dist/provider-selection.js +69 -0
- package/server/dist/providers/claude-adapter.js +281 -0
- package/server/dist/providers/codex-adapter.js +264 -0
- package/server/dist/providers/index.js +23 -0
- package/server/dist/providers/registry.js +37 -0
- package/server/dist/providers/types.js +22 -0
- package/server/dist/queue-manager.js +1511 -0
- package/server/dist/rails-router.js +362 -0
- package/server/dist/rails-store.js +116 -0
- package/server/dist/result-event.js +106 -0
- package/server/dist/schemas/profile.v1.json +151 -0
- package/server/dist/setup-manager.js +1165 -0
- package/server/dist/setup-prerequisites.js +372 -0
- package/server/dist/smash-runner.js +663 -0
- package/server/dist/spec-draft-parser.js +133 -0
- package/server/dist/spec-launcher-manager.js +174 -0
- package/server/dist/spec-models.js +32 -0
- package/server/dist/specrails-tech-client.js +82 -0
- package/server/dist/spending.js +448 -0
- package/server/dist/telemetry-compactor.js +180 -0
- package/server/dist/telemetry-export.js +317 -0
- package/server/dist/telemetry-receiver.js +224 -0
- package/server/dist/terminal-manager.js +633 -0
- package/server/dist/terminal-marks-store.js +117 -0
- package/server/dist/terminal-osc-parser.js +159 -0
- package/server/dist/terminal-settings.js +282 -0
- package/server/dist/terminal-shell-integration.js +196 -0
- package/server/dist/ticket-broadcast.js +47 -0
- package/server/dist/ticket-store.js +397 -0
- package/server/dist/ticket-watcher.js +117 -0
- package/server/dist/types.js +10 -0
- package/server/dist/user-mcp-config.js +117 -0
- package/server/dist/util/cli-prompt.js +181 -0
- package/server/dist/util/secure-fs.js +50 -0
- package/server/dist/util/win-spawn.js +43 -0
- package/server/dist/webhook-manager.js +89 -0
- package/server/dist/ws-routing.js +47 -0
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Contract Refine Runner
|
|
4
|
+
*
|
|
5
|
+
* Standalone runner that spawns a single Claude turn to produce the
|
|
6
|
+
* Contract Layer for a just-committed Explore Spec ticket. Lives outside the
|
|
7
|
+
* ChatManager lifecycle for now (design.md D3 — "thin sibling helper" option):
|
|
8
|
+
* the refine is fire-and-forget, single-attempt, 60 s budget, no idle-kill /
|
|
9
|
+
* crash-respawn semantics.
|
|
10
|
+
*
|
|
11
|
+
* See openspec/changes/explore-spec-contract-refine.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.prepareContractRefineSpawn = prepareContractRefineSpawn;
|
|
15
|
+
exports.readRefineChildOutput = readRefineChildOutput;
|
|
16
|
+
exports.applyContractLayerToTicket = applyContractLayerToTicket;
|
|
17
|
+
exports.runContractRefine = runContractRefine;
|
|
18
|
+
exports.runContractRefineForQuick = runContractRefineForQuick;
|
|
19
|
+
const node_crypto_1 = require("node:crypto");
|
|
20
|
+
const node_readline_1 = require("node:readline");
|
|
21
|
+
const cli_prompt_1 = require("./util/cli-prompt");
|
|
22
|
+
const explore_contract_refine_1 = require("./explore-contract-refine");
|
|
23
|
+
const db_1 = require("./db");
|
|
24
|
+
const explore_cwd_manager_1 = require("./explore-cwd-manager");
|
|
25
|
+
const ai_invocations_1 = require("./ai-invocations");
|
|
26
|
+
const result_event_1 = require("./result-event");
|
|
27
|
+
const ticket_store_1 = require("./ticket-store");
|
|
28
|
+
const REFINE_TIMEOUT_MS = 60_000;
|
|
29
|
+
function normalizeClaudeCodeModel(model) {
|
|
30
|
+
if (!model || typeof model !== 'string')
|
|
31
|
+
return 'sonnet';
|
|
32
|
+
return model;
|
|
33
|
+
}
|
|
34
|
+
function buildRefineArgs(model, systemPrompt, sessionId) {
|
|
35
|
+
return [
|
|
36
|
+
'--model', normalizeClaudeCodeModel(model),
|
|
37
|
+
'--dangerously-skip-permissions',
|
|
38
|
+
'--output-format', 'stream-json',
|
|
39
|
+
'--verbose',
|
|
40
|
+
'--system-prompt', systemPrompt,
|
|
41
|
+
'--disallowedTools', 'Read,Grep,Glob,Bash',
|
|
42
|
+
'--resume', sessionId,
|
|
43
|
+
'--max-turns', '1',
|
|
44
|
+
'-p', explore_contract_refine_1.CONTRACT_MARKER_USER_MESSAGE,
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Build the spawn argv + cwd for the refine turn. Exported for tests.
|
|
49
|
+
*/
|
|
50
|
+
function prepareContractRefineSpawn(deps, conversation) {
|
|
51
|
+
const systemPrompt = (0, explore_contract_refine_1.buildContractRefineSystemPrompt)();
|
|
52
|
+
let mcpEnabled = false;
|
|
53
|
+
if (conversation.context_scope) {
|
|
54
|
+
try {
|
|
55
|
+
const scope = JSON.parse(conversation.context_scope);
|
|
56
|
+
mcpEnabled = !!scope?.mcp;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
/* default false */
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
let cwd = deps.projectPath;
|
|
63
|
+
if (!mcpEnabled) {
|
|
64
|
+
try {
|
|
65
|
+
cwd = (0, explore_cwd_manager_1.ensureExploreCwd)({
|
|
66
|
+
slug: deps.projectSlug,
|
|
67
|
+
projectPath: deps.projectPath,
|
|
68
|
+
projectName: deps.projectName,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
cwd = deps.projectPath;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const args = buildRefineArgs(conversation.model ?? 'sonnet', systemPrompt, conversation.session_id ?? '');
|
|
76
|
+
return { args, cwd, systemPrompt };
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Test-friendly inner runner: takes a child-like object and returns the parsed
|
|
80
|
+
* outcome (text + result event + close code). Does NOT touch the DB or the
|
|
81
|
+
* file system — the caller wires those.
|
|
82
|
+
*/
|
|
83
|
+
function readRefineChildOutput(child, timeoutMs) {
|
|
84
|
+
return new Promise((resolve) => {
|
|
85
|
+
let fullText = '';
|
|
86
|
+
let resultEvent = null;
|
|
87
|
+
let timedOut = false;
|
|
88
|
+
let settled = false;
|
|
89
|
+
if (!child.stdout) {
|
|
90
|
+
resolve({ fullText, resultEvent, code: -1, timedOut: false });
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
let stderrBuf = '';
|
|
94
|
+
if (child.stderr) {
|
|
95
|
+
child.stderr.on('data', (chunk) => {
|
|
96
|
+
const s = typeof chunk === 'string' ? chunk : chunk.toString('utf-8');
|
|
97
|
+
stderrBuf += s;
|
|
98
|
+
if (stderrBuf.length > 8192)
|
|
99
|
+
stderrBuf = stderrBuf.slice(-8192);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
const reader = (0, node_readline_1.createInterface)({ input: child.stdout, crlfDelay: Infinity });
|
|
103
|
+
reader.on('line', (line) => {
|
|
104
|
+
let parsed = null;
|
|
105
|
+
try {
|
|
106
|
+
parsed = JSON.parse(line);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (!parsed)
|
|
112
|
+
return;
|
|
113
|
+
const type = parsed.type;
|
|
114
|
+
if (type === 'result') {
|
|
115
|
+
resultEvent = parsed;
|
|
116
|
+
}
|
|
117
|
+
else if (type === 'assistant') {
|
|
118
|
+
const message = parsed.message;
|
|
119
|
+
const blocks = message?.content ?? [];
|
|
120
|
+
for (const b of blocks) {
|
|
121
|
+
if (b.type === 'text' && typeof b.text === 'string')
|
|
122
|
+
fullText += b.text;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
const timer = setTimeout(() => {
|
|
127
|
+
timedOut = true;
|
|
128
|
+
try {
|
|
129
|
+
child.kill('SIGTERM');
|
|
130
|
+
}
|
|
131
|
+
catch { /* best effort */ }
|
|
132
|
+
if (!settled) {
|
|
133
|
+
settled = true;
|
|
134
|
+
resolve({ fullText, resultEvent, code: null, timedOut: true });
|
|
135
|
+
}
|
|
136
|
+
}, timeoutMs);
|
|
137
|
+
child.on('close', (code) => {
|
|
138
|
+
clearTimeout(timer);
|
|
139
|
+
if (settled)
|
|
140
|
+
return;
|
|
141
|
+
settled = true;
|
|
142
|
+
if (code !== 0 && stderrBuf) {
|
|
143
|
+
console.log(`[contract-refine-runner] child stderr: ${JSON.stringify(stderrBuf.slice(-2000))}`);
|
|
144
|
+
}
|
|
145
|
+
resolve({ fullText, resultEvent, code, timedOut });
|
|
146
|
+
});
|
|
147
|
+
child.on('error', (err) => {
|
|
148
|
+
clearTimeout(timer);
|
|
149
|
+
console.log(`[contract-refine-runner] child error: ${err.message}; stderr=${JSON.stringify(stderrBuf.slice(-2000))}`);
|
|
150
|
+
if (settled)
|
|
151
|
+
return;
|
|
152
|
+
settled = true;
|
|
153
|
+
resolve({ fullText, resultEvent, code: -1, timedOut });
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Patch a ticket's description in place: append the rendered Contract Layer
|
|
159
|
+
* markdown to the user-authored body. Returns the updated Ticket, or null
|
|
160
|
+
* when the ticket id is unknown.
|
|
161
|
+
*/
|
|
162
|
+
function applyContractLayerToTicket(filePath, ticketId, layer, nowIso) {
|
|
163
|
+
let updated = null;
|
|
164
|
+
(0, ticket_store_1.mutateStore)(filePath, (s) => {
|
|
165
|
+
const t = s.tickets[String(ticketId)];
|
|
166
|
+
if (!t)
|
|
167
|
+
return;
|
|
168
|
+
t.description = (0, explore_contract_refine_1.appendContractLayerToDescription)(t.description, layer);
|
|
169
|
+
t.updated_at = nowIso;
|
|
170
|
+
updated = t;
|
|
171
|
+
});
|
|
172
|
+
return updated;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Fire a single Contract Refine attempt for the given conversation + ticket.
|
|
176
|
+
*
|
|
177
|
+
* Returns a Promise that resolves with the outcome. Side effects:
|
|
178
|
+
* - On success: patches the ticket's description, broadcasts `ticket_updated`
|
|
179
|
+
* (in the caller-supplied shape via broadcast), records `ai_invocations`.
|
|
180
|
+
* - On failure: broadcasts `explore.contract_refine_failed`, records
|
|
181
|
+
* `ai_invocations` with status=failed/aborted.
|
|
182
|
+
*
|
|
183
|
+
* Early-returns with `reason='disabled'` when the per-project toggle is off,
|
|
184
|
+
* the kill switch is active, the conversation is not Explore, or no
|
|
185
|
+
* `session_id` exists yet (no parent turn to --resume).
|
|
186
|
+
*/
|
|
187
|
+
async function runContractRefine(deps, conversationId, ticketId) {
|
|
188
|
+
const now = deps.now ?? (() => new Date());
|
|
189
|
+
const timeoutMs = deps.timeoutMs ?? REFINE_TIMEOUT_MS;
|
|
190
|
+
const spawn = deps.spawn ?? cli_prompt_1.spawnAiCli;
|
|
191
|
+
console.log(`[contract-refine-runner] entry conv=${conversationId} ticket=${ticketId}`);
|
|
192
|
+
if ((0, explore_contract_refine_1.isExploreContractRefineKillSwitchActive)()) {
|
|
193
|
+
console.log(`[contract-refine-runner] skip: kill switch active`);
|
|
194
|
+
return { ok: false, reason: 'disabled', ticketId, conversationId };
|
|
195
|
+
}
|
|
196
|
+
const conversation = (0, db_1.getConversation)(deps.db, conversationId);
|
|
197
|
+
if (!conversation || conversation.kind !== 'explore') {
|
|
198
|
+
console.log(`[contract-refine-runner] skip: conversation missing or not explore (kind=${conversation?.kind})`);
|
|
199
|
+
return { ok: false, reason: 'not-explore', ticketId, conversationId };
|
|
200
|
+
}
|
|
201
|
+
// Contract Layer refinement is a Claude-only capability (it `--resume`s the
|
|
202
|
+
// Explore session and invokes the `/specrails:contract-refine` slash command,
|
|
203
|
+
// neither of which Codex supports). Skip defensively when the conversation
|
|
204
|
+
// ran on a non-claude engine; the Add Spec UI already hides the toggle for
|
|
205
|
+
// those, but a manually-crafted scope must never spawn the wrong CLI.
|
|
206
|
+
if (conversation.provider && conversation.provider !== 'claude') {
|
|
207
|
+
console.log(`[contract-refine-runner] skip: provider '${conversation.provider}' does not support contract refine`);
|
|
208
|
+
return { ok: false, reason: 'provider-unsupported', ticketId, conversationId };
|
|
209
|
+
}
|
|
210
|
+
// Per-conversation gating: contractRefine on the conversation's stored
|
|
211
|
+
// context_scope is the only source of truth. Legacy null/missing scope or
|
|
212
|
+
// a malformed JSON blob is treated as opted out.
|
|
213
|
+
if (!deps.ignoreConversationScope) {
|
|
214
|
+
let convoOptIn = false;
|
|
215
|
+
if (conversation.context_scope) {
|
|
216
|
+
try {
|
|
217
|
+
const scope = JSON.parse(conversation.context_scope);
|
|
218
|
+
if (typeof scope?.contractRefine === 'boolean')
|
|
219
|
+
convoOptIn = scope.contractRefine;
|
|
220
|
+
}
|
|
221
|
+
catch { /* malformed scope; treat as opted out */ }
|
|
222
|
+
}
|
|
223
|
+
if (!convoOptIn) {
|
|
224
|
+
console.log(`[contract-refine-runner] skip: conversation scope opted out (contractRefine!=true)`);
|
|
225
|
+
return { ok: false, reason: 'scope-disabled', ticketId, conversationId };
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (!conversation.session_id) {
|
|
229
|
+
console.log(`[contract-refine-runner] skip: no session_id on conversation ${conversationId}`);
|
|
230
|
+
return { ok: false, reason: 'no-session', ticketId, conversationId };
|
|
231
|
+
}
|
|
232
|
+
console.log(`[contract-refine-runner] spawning refine model=${conversation.model} session=${conversation.session_id}`);
|
|
233
|
+
deps.broadcast({
|
|
234
|
+
type: 'explore.contract_refine_started',
|
|
235
|
+
projectId: deps.projectId,
|
|
236
|
+
ticketId,
|
|
237
|
+
timestamp: now().toISOString(),
|
|
238
|
+
});
|
|
239
|
+
const { args, cwd } = prepareContractRefineSpawn({
|
|
240
|
+
projectSlug: deps.projectSlug,
|
|
241
|
+
projectPath: deps.projectPath,
|
|
242
|
+
projectName: deps.projectName,
|
|
243
|
+
}, conversation);
|
|
244
|
+
const startedAt = now().toISOString();
|
|
245
|
+
let child;
|
|
246
|
+
try {
|
|
247
|
+
child = spawn('claude', args, {
|
|
248
|
+
env: process.env,
|
|
249
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
250
|
+
cwd,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
catch (err) {
|
|
254
|
+
recordSafely(deps, conversationId, ticketId, conversation.model, startedAt, now().toISOString(), 'failed', null);
|
|
255
|
+
deps.broadcast({
|
|
256
|
+
type: 'explore.contract_refine_failed',
|
|
257
|
+
projectId: deps.projectId,
|
|
258
|
+
ticketId,
|
|
259
|
+
reason: 'crashed',
|
|
260
|
+
timestamp: now().toISOString(),
|
|
261
|
+
});
|
|
262
|
+
return { ok: false, reason: 'crashed', ticketId, conversationId };
|
|
263
|
+
}
|
|
264
|
+
const result = await readRefineChildOutput(child, timeoutMs);
|
|
265
|
+
const finishedAt = now().toISOString();
|
|
266
|
+
console.log(`[contract-refine-runner] spawn done code=${result.code} timedOut=${result.timedOut} hasResult=${!!result.resultEvent} textBytes=${result.fullText.length}`);
|
|
267
|
+
if (result.timedOut) {
|
|
268
|
+
recordSafely(deps, conversationId, ticketId, conversation.model, startedAt, finishedAt, 'aborted', result.resultEvent);
|
|
269
|
+
deps.broadcast({
|
|
270
|
+
type: 'explore.contract_refine_failed',
|
|
271
|
+
projectId: deps.projectId,
|
|
272
|
+
ticketId,
|
|
273
|
+
reason: 'timeout',
|
|
274
|
+
timestamp: finishedAt,
|
|
275
|
+
});
|
|
276
|
+
return { ok: false, reason: 'timeout', ticketId, conversationId };
|
|
277
|
+
}
|
|
278
|
+
if (result.code !== 0 || !result.resultEvent) {
|
|
279
|
+
const r = result.resultEvent;
|
|
280
|
+
console.log(`[contract-refine-runner] non-zero exit code=${result.code} ` +
|
|
281
|
+
`subtype=${r?.subtype ?? '-'} is_error=${r?.is_error ?? '-'} ` +
|
|
282
|
+
`num_turns=${r?.num_turns ?? '-'} ` +
|
|
283
|
+
`textTail=${JSON.stringify(result.fullText.slice(-400))}`);
|
|
284
|
+
if (r)
|
|
285
|
+
console.log(`[contract-refine-runner] result event: ${JSON.stringify(r).slice(0, 2000)}`);
|
|
286
|
+
recordSafely(deps, conversationId, ticketId, conversation.model, startedAt, finishedAt, 'failed', result.resultEvent);
|
|
287
|
+
deps.broadcast({
|
|
288
|
+
type: 'explore.contract_refine_failed',
|
|
289
|
+
projectId: deps.projectId,
|
|
290
|
+
ticketId,
|
|
291
|
+
reason: result.resultEvent ? 'model_error' : 'crashed',
|
|
292
|
+
timestamp: finishedAt,
|
|
293
|
+
});
|
|
294
|
+
return { ok: false, reason: result.resultEvent ? 'model_error' : 'crashed', ticketId, conversationId };
|
|
295
|
+
}
|
|
296
|
+
const parse = (0, explore_contract_refine_1.parseContractLayerBlock)(result.fullText);
|
|
297
|
+
console.log(`[contract-refine-runner] parse ok=${parse.ok} reason=${!parse.ok ? parse.reason : '-'} firstChars=${JSON.stringify(result.fullText.slice(0, 200))}`);
|
|
298
|
+
if (!parse.ok) {
|
|
299
|
+
const reason = parse.reason === 'parser-error'
|
|
300
|
+
? 'parser_error'
|
|
301
|
+
: 'malformed';
|
|
302
|
+
recordSafely(deps, conversationId, ticketId, conversation.model, startedAt, finishedAt, 'failed', result.resultEvent);
|
|
303
|
+
deps.broadcast({
|
|
304
|
+
type: 'explore.contract_refine_failed',
|
|
305
|
+
projectId: deps.projectId,
|
|
306
|
+
ticketId,
|
|
307
|
+
reason,
|
|
308
|
+
timestamp: finishedAt,
|
|
309
|
+
});
|
|
310
|
+
return { ok: false, reason, ticketId, conversationId };
|
|
311
|
+
}
|
|
312
|
+
// Patch the ticket description.
|
|
313
|
+
let updated = null;
|
|
314
|
+
try {
|
|
315
|
+
const filePath = (0, ticket_store_1.resolveTicketStoragePath)(deps.projectPath);
|
|
316
|
+
updated = applyContractLayerToTicket(filePath, ticketId, parse.value, finishedAt);
|
|
317
|
+
}
|
|
318
|
+
catch (err) {
|
|
319
|
+
console.error('[contract-refine-runner] PATCH failed:', err);
|
|
320
|
+
recordSafely(deps, conversationId, ticketId, conversation.model, startedAt, finishedAt, 'failed', result.resultEvent);
|
|
321
|
+
deps.broadcast({
|
|
322
|
+
type: 'explore.contract_refine_failed',
|
|
323
|
+
projectId: deps.projectId,
|
|
324
|
+
ticketId,
|
|
325
|
+
reason: 'parser_error',
|
|
326
|
+
timestamp: finishedAt,
|
|
327
|
+
});
|
|
328
|
+
return { ok: false, reason: 'parser_error', ticketId, conversationId };
|
|
329
|
+
}
|
|
330
|
+
recordSafely(deps, conversationId, ticketId, conversation.model, startedAt, finishedAt, 'success', result.resultEvent);
|
|
331
|
+
if (updated) {
|
|
332
|
+
deps.broadcast({
|
|
333
|
+
type: 'ticket_updated',
|
|
334
|
+
ticket: updated,
|
|
335
|
+
projectId: deps.projectId,
|
|
336
|
+
timestamp: finishedAt,
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
deps.broadcast({ type: 'spending.invalidated', projectId: deps.projectId });
|
|
340
|
+
return { ok: true, ticketId, conversationId };
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Quick-mode variant: fire a single Contract Refine attempt with no parent
|
|
344
|
+
* Explore conversation (no `--resume`). The runner seeds the model with the
|
|
345
|
+
* just-generated spec body inside the system prompt as one-shot context.
|
|
346
|
+
*
|
|
347
|
+
* Used by `POST /tickets/generate-spec` when `contractRefine: true` is on the
|
|
348
|
+
* request body and the project setting + kill switch permit it.
|
|
349
|
+
*/
|
|
350
|
+
async function runContractRefineForQuick(deps, ticketId, generatedTitle, generatedDescription, model = null) {
|
|
351
|
+
const now = deps.now ?? (() => new Date());
|
|
352
|
+
const timeoutMs = deps.timeoutMs ?? REFINE_TIMEOUT_MS;
|
|
353
|
+
const spawn = deps.spawn ?? cli_prompt_1.spawnAiCli;
|
|
354
|
+
console.log(`[contract-refine-runner] quick-entry ticket=${ticketId}`);
|
|
355
|
+
if ((0, explore_contract_refine_1.isExploreContractRefineKillSwitchActive)()) {
|
|
356
|
+
console.log(`[contract-refine-runner] quick skip: kill switch active`);
|
|
357
|
+
return { ok: false, reason: 'disabled', ticketId, conversationId: '' };
|
|
358
|
+
}
|
|
359
|
+
const systemPrompt = [
|
|
360
|
+
(0, explore_contract_refine_1.buildContractRefineSystemPrompt)(),
|
|
361
|
+
'',
|
|
362
|
+
'## Spec under refinement',
|
|
363
|
+
'',
|
|
364
|
+
`### Title`,
|
|
365
|
+
generatedTitle,
|
|
366
|
+
'',
|
|
367
|
+
`### Description`,
|
|
368
|
+
generatedDescription,
|
|
369
|
+
].join('\n');
|
|
370
|
+
const args = [
|
|
371
|
+
'--model', model ?? 'sonnet',
|
|
372
|
+
'--dangerously-skip-permissions',
|
|
373
|
+
'--output-format', 'stream-json',
|
|
374
|
+
'--verbose',
|
|
375
|
+
'--system-prompt', systemPrompt,
|
|
376
|
+
'--disallowedTools', 'Read,Grep,Glob,Bash',
|
|
377
|
+
'--max-turns', '1',
|
|
378
|
+
'-p', explore_contract_refine_1.CONTRACT_MARKER_USER_MESSAGE,
|
|
379
|
+
];
|
|
380
|
+
const startedAt = now().toISOString();
|
|
381
|
+
deps.broadcast({
|
|
382
|
+
type: 'explore.contract_refine_started',
|
|
383
|
+
projectId: deps.projectId,
|
|
384
|
+
ticketId,
|
|
385
|
+
timestamp: startedAt,
|
|
386
|
+
});
|
|
387
|
+
let child;
|
|
388
|
+
try {
|
|
389
|
+
child = spawn('claude', args, {
|
|
390
|
+
env: process.env,
|
|
391
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
392
|
+
cwd: deps.projectPath,
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
catch (err) {
|
|
396
|
+
recordSafelyQuick(deps, ticketId, model, startedAt, now().toISOString(), 'failed', null);
|
|
397
|
+
deps.broadcast({
|
|
398
|
+
type: 'explore.contract_refine_failed',
|
|
399
|
+
projectId: deps.projectId,
|
|
400
|
+
ticketId,
|
|
401
|
+
reason: 'crashed',
|
|
402
|
+
timestamp: now().toISOString(),
|
|
403
|
+
});
|
|
404
|
+
return { ok: false, reason: 'crashed', ticketId, conversationId: '' };
|
|
405
|
+
}
|
|
406
|
+
const result = await readRefineChildOutput(child, timeoutMs);
|
|
407
|
+
const finishedAt = now().toISOString();
|
|
408
|
+
console.log(`[contract-refine-runner] quick spawn done code=${result.code} timedOut=${result.timedOut} textBytes=${result.fullText.length}`);
|
|
409
|
+
if (result.timedOut) {
|
|
410
|
+
recordSafelyQuick(deps, ticketId, model, startedAt, finishedAt, 'aborted', result.resultEvent);
|
|
411
|
+
deps.broadcast({
|
|
412
|
+
type: 'explore.contract_refine_failed',
|
|
413
|
+
projectId: deps.projectId,
|
|
414
|
+
ticketId,
|
|
415
|
+
reason: 'timeout',
|
|
416
|
+
timestamp: finishedAt,
|
|
417
|
+
});
|
|
418
|
+
return { ok: false, reason: 'timeout', ticketId, conversationId: '' };
|
|
419
|
+
}
|
|
420
|
+
if (result.code !== 0 || !result.resultEvent) {
|
|
421
|
+
const r = result.resultEvent;
|
|
422
|
+
console.log(`[contract-refine-runner] quick non-zero exit code=${result.code} ` +
|
|
423
|
+
`subtype=${r?.subtype ?? '-'} is_error=${r?.is_error ?? '-'} ` +
|
|
424
|
+
`num_turns=${r?.num_turns ?? '-'} ` +
|
|
425
|
+
`textTail=${JSON.stringify(result.fullText.slice(-400))}`);
|
|
426
|
+
recordSafelyQuick(deps, ticketId, model, startedAt, finishedAt, 'failed', result.resultEvent);
|
|
427
|
+
deps.broadcast({
|
|
428
|
+
type: 'explore.contract_refine_failed',
|
|
429
|
+
projectId: deps.projectId,
|
|
430
|
+
ticketId,
|
|
431
|
+
reason: result.resultEvent ? 'model_error' : 'crashed',
|
|
432
|
+
timestamp: finishedAt,
|
|
433
|
+
});
|
|
434
|
+
return { ok: false, reason: result.resultEvent ? 'model_error' : 'crashed', ticketId, conversationId: '' };
|
|
435
|
+
}
|
|
436
|
+
const parse = (0, explore_contract_refine_1.parseContractLayerBlock)(result.fullText);
|
|
437
|
+
if (!parse.ok) {
|
|
438
|
+
const reason = parse.reason === 'parser-error' ? 'parser_error' : 'malformed';
|
|
439
|
+
recordSafelyQuick(deps, ticketId, model, startedAt, finishedAt, 'failed', result.resultEvent);
|
|
440
|
+
deps.broadcast({
|
|
441
|
+
type: 'explore.contract_refine_failed',
|
|
442
|
+
projectId: deps.projectId,
|
|
443
|
+
ticketId,
|
|
444
|
+
reason,
|
|
445
|
+
timestamp: finishedAt,
|
|
446
|
+
});
|
|
447
|
+
return { ok: false, reason, ticketId, conversationId: '' };
|
|
448
|
+
}
|
|
449
|
+
let updated = null;
|
|
450
|
+
try {
|
|
451
|
+
const filePath = (0, ticket_store_1.resolveTicketStoragePath)(deps.projectPath);
|
|
452
|
+
updated = applyContractLayerToTicket(filePath, ticketId, parse.value, finishedAt);
|
|
453
|
+
}
|
|
454
|
+
catch (err) {
|
|
455
|
+
console.error('[contract-refine-runner] quick PATCH failed:', err);
|
|
456
|
+
recordSafelyQuick(deps, ticketId, model, startedAt, finishedAt, 'failed', result.resultEvent);
|
|
457
|
+
deps.broadcast({
|
|
458
|
+
type: 'explore.contract_refine_failed',
|
|
459
|
+
projectId: deps.projectId,
|
|
460
|
+
ticketId,
|
|
461
|
+
reason: 'parser_error',
|
|
462
|
+
timestamp: finishedAt,
|
|
463
|
+
});
|
|
464
|
+
return { ok: false, reason: 'parser_error', ticketId, conversationId: '' };
|
|
465
|
+
}
|
|
466
|
+
recordSafelyQuick(deps, ticketId, model, startedAt, finishedAt, 'success', result.resultEvent);
|
|
467
|
+
if (updated) {
|
|
468
|
+
deps.broadcast({
|
|
469
|
+
type: 'ticket_updated',
|
|
470
|
+
ticket: updated,
|
|
471
|
+
projectId: deps.projectId,
|
|
472
|
+
timestamp: finishedAt,
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
deps.broadcast({ type: 'spending.invalidated', projectId: deps.projectId });
|
|
476
|
+
return { ok: true, ticketId, conversationId: '' };
|
|
477
|
+
}
|
|
478
|
+
function recordSafelyQuick(deps, ticketId, model, startedAt, finishedAt, status, resultEvent) {
|
|
479
|
+
try {
|
|
480
|
+
const normalised = resultEvent ? (0, result_event_1.normaliseResultEvent)(resultEvent, 'claude') : {};
|
|
481
|
+
(0, ai_invocations_1.recordInvocation)(deps.db, {
|
|
482
|
+
id: (0, node_crypto_1.randomUUID)(),
|
|
483
|
+
project_id: deps.projectId,
|
|
484
|
+
provider: 'claude',
|
|
485
|
+
surface: 'quick-spec',
|
|
486
|
+
surface_ref_id: `contract-refine:${ticketId}`,
|
|
487
|
+
conversation_id: null,
|
|
488
|
+
ticket_id: ticketId,
|
|
489
|
+
status,
|
|
490
|
+
started_at: startedAt,
|
|
491
|
+
finished_at: finishedAt,
|
|
492
|
+
...normalised,
|
|
493
|
+
model: resultEvent?.model ?? model ?? undefined,
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
catch (err) {
|
|
497
|
+
console.error('[contract-refine-runner] quick recordInvocation failed:', err);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
function recordSafely(deps, conversationId, ticketId, model, startedAt, finishedAt, status, resultEvent) {
|
|
501
|
+
try {
|
|
502
|
+
const normalised = resultEvent ? (0, result_event_1.normaliseResultEvent)(resultEvent, 'claude') : {};
|
|
503
|
+
(0, ai_invocations_1.recordInvocation)(deps.db, {
|
|
504
|
+
id: (0, node_crypto_1.randomUUID)(),
|
|
505
|
+
project_id: deps.projectId,
|
|
506
|
+
provider: 'claude',
|
|
507
|
+
surface: 'explore-spec',
|
|
508
|
+
surface_ref_id: `contract-refine:${conversationId}`,
|
|
509
|
+
conversation_id: conversationId,
|
|
510
|
+
ticket_id: ticketId,
|
|
511
|
+
status,
|
|
512
|
+
started_at: startedAt,
|
|
513
|
+
finished_at: finishedAt,
|
|
514
|
+
...normalised,
|
|
515
|
+
model: resultEvent?.model ?? model ?? undefined,
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
catch (err) {
|
|
519
|
+
console.error('[contract-refine-runner] recordInvocation failed:', err);
|
|
520
|
+
}
|
|
521
|
+
}
|