nolzu 0.0.1 → 0.1.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/LICENSE +105 -0
- package/README.md +24 -7
- package/build/client/_app/immutable/assets/0.SPD4wYkc.css +1 -0
- package/build/client/_app/immutable/assets/1.BRilEoOO.css +1 -0
- package/build/client/_app/immutable/assets/10.DwLiBGDj.css +1 -0
- package/build/client/_app/immutable/assets/11.D_TtWT3D.css +1 -0
- package/build/client/_app/immutable/assets/12.CSVGmtUY.css +1 -0
- package/build/client/_app/immutable/assets/13.qTa7IHbg.css +1 -0
- package/build/client/_app/immutable/assets/19.CbCFXKb8.css +1 -0
- package/build/client/_app/immutable/assets/2.CfHhgI77.css +1 -0
- package/build/client/_app/immutable/assets/20.C5CSZhyT.css +1 -0
- package/build/client/_app/immutable/assets/21.BBpYkZcc.css +1 -0
- package/build/client/_app/immutable/assets/22.C9RgY9kl.css +1 -0
- package/build/client/_app/immutable/assets/23.B6Dp9RJO.css +1 -0
- package/build/client/_app/immutable/assets/24.C7g2abUW.css +1 -0
- package/build/client/_app/immutable/assets/26.DTMI6ROV.css +1 -0
- package/build/client/_app/immutable/assets/27.AxXMpDkB.css +1 -0
- package/build/client/_app/immutable/assets/28.939ac-98.css +1 -0
- package/build/client/_app/immutable/assets/3.3lqex1t-.css +1 -0
- package/build/client/_app/immutable/assets/4.C52MzO_d.css +1 -0
- package/build/client/_app/immutable/assets/5.CsfJAwvS.css +1 -0
- package/build/client/_app/immutable/assets/8.ByspUp-s.css +1 -0
- package/build/client/_app/immutable/assets/9.BCSFZmce.css +1 -0
- package/build/client/_app/immutable/assets/Banner.DDqfpWLD.css +1 -0
- package/build/client/_app/immutable/assets/BoardOff.mpX08-Be.css +1 -0
- package/build/client/_app/immutable/assets/Button.BlwsEgUc.css +1 -0
- package/build/client/_app/immutable/assets/Chip.qAAa6_e5.css +1 -0
- package/build/client/_app/immutable/assets/Dialog.D5Ln60a8.css +1 -0
- package/build/client/_app/immutable/assets/FeaturePanels.DZ_Mth5M.css +1 -0
- package/build/client/_app/immutable/assets/FolderBrowser.DBmRWDCH.css +1 -0
- package/build/client/_app/immutable/assets/Geist-Variable.Bj2R_7yk.woff2 +0 -0
- package/build/client/_app/immutable/assets/GeistMono-Variable.Dispecij.woff2 +0 -0
- package/build/client/_app/immutable/assets/HelpTip.DF6T9nns.css +1 -0
- package/build/client/_app/immutable/assets/InfoBox.CpavOykF.css +1 -0
- package/build/client/_app/immutable/assets/KeyCaps.D2t-lY-8.css +1 -0
- package/build/client/_app/immutable/assets/LogLine.Bu4feLn5.css +1 -0
- package/build/client/_app/immutable/assets/Markdown.DI6AtWAc.css +1 -0
- package/build/client/_app/immutable/assets/ModelPicker.DQzj7Nj8.css +1 -0
- package/build/client/_app/immutable/assets/OptionButtons.BYiyOXOE.css +1 -0
- package/build/client/_app/immutable/assets/PeekPanel.DzMdHoqg.css +1 -0
- package/build/client/_app/immutable/assets/ScoutPage.CVIiLy5c.css +1 -0
- package/build/client/_app/immutable/assets/SetupSteps.B6pZP1Bk.css +1 -0
- package/build/client/_app/immutable/assets/Skeleton.BC-1_U5d.css +1 -0
- package/build/client/_app/immutable/assets/SlotsMeter.Dq7GGYlD.css +1 -0
- package/build/client/_app/immutable/assets/StartConfirm.DxNN2AOb.css +1 -0
- package/build/client/_app/immutable/assets/StatePill.CGWFVUUg.css +1 -0
- package/build/client/_app/immutable/assets/Streamed.DpZ6wgO2.css +1 -0
- package/build/client/_app/immutable/assets/card-pulls.C5uGMuAh.css +1 -0
- package/build/client/_app/immutable/assets/next-step.CKg1w06J.css +1 -0
- package/build/client/_app/immutable/chunks/-B5EclhK.js +1 -0
- package/build/client/_app/immutable/chunks/-Q3zApAy.js +1 -0
- package/build/client/_app/immutable/chunks/6-hwN_Ik.js +3 -0
- package/build/client/_app/immutable/chunks/B16UF4PA.js +11 -0
- package/build/client/_app/immutable/chunks/B1V3h1VF.js +1 -0
- package/build/client/_app/immutable/chunks/B2d2Mkuz.js +68 -0
- package/build/client/_app/immutable/chunks/B2yzhiEa.js +1 -0
- package/build/client/_app/immutable/chunks/B5zDDQUU.js +2 -0
- package/build/client/_app/immutable/chunks/B8DHSiWf.js +1 -0
- package/build/client/_app/immutable/chunks/B8z33EzI.js +1 -0
- package/build/client/_app/immutable/chunks/BCRkrH6c.js +1 -0
- package/build/client/_app/immutable/chunks/BCScjOxu.js +1 -0
- package/build/client/_app/immutable/chunks/BMUQtCEC.js +1 -0
- package/build/client/_app/immutable/chunks/BNnfkvZM.js +1 -0
- package/build/client/_app/immutable/chunks/BelWyZaW.js +1 -0
- package/build/client/_app/immutable/chunks/BhZpqODT.js +1 -0
- package/build/client/_app/immutable/chunks/Bjy-W4x2.js +81 -0
- package/build/client/_app/immutable/chunks/BmafI-Bs.js +1 -0
- package/build/client/_app/immutable/chunks/BvRk9kiK.js +0 -0
- package/build/client/_app/immutable/chunks/C4i6bdQg.js +1 -0
- package/build/client/_app/immutable/chunks/C8u5TyIB.js +1 -0
- package/build/client/_app/immutable/chunks/CFs2xhoy.js +1 -0
- package/build/client/_app/immutable/chunks/CIm2DioU.js +1 -0
- package/build/client/_app/immutable/chunks/CONqGBXC.js +1 -0
- package/build/client/_app/immutable/chunks/CSOz40qO.js +1 -0
- package/build/client/_app/immutable/chunks/CXxuD1ef.js +3 -0
- package/build/client/_app/immutable/chunks/CarrGsZA.js +2 -0
- package/build/client/_app/immutable/chunks/CdrmTD44.js +1 -0
- package/build/client/_app/immutable/chunks/CfJRH9gh.js +2 -0
- package/build/client/_app/immutable/chunks/Ci7C9Cki.js +1 -0
- package/build/client/_app/immutable/chunks/CkOTL1vK.js +1 -0
- package/build/client/_app/immutable/chunks/CngTtGc_.js +1 -0
- package/build/client/_app/immutable/chunks/Cp3A1zR8.js +1 -0
- package/build/client/_app/immutable/chunks/CwtMnwNL.js +3 -0
- package/build/client/_app/immutable/chunks/Cy7f_oXg.js +1 -0
- package/build/client/_app/immutable/chunks/D-wwLm5t.js +1 -0
- package/build/client/_app/immutable/chunks/D2imbgaf.js +1 -0
- package/build/client/_app/immutable/chunks/D32mip60.js +1 -0
- package/build/client/_app/immutable/chunks/D46Vk19W.js +1 -0
- package/build/client/_app/immutable/chunks/DCUUgo-6.js +1 -0
- package/build/client/_app/immutable/chunks/DFjnjJjy.js +1 -0
- package/build/client/_app/immutable/chunks/DHMbSbMg.js +1 -0
- package/build/client/_app/immutable/chunks/DJOFx2wx.js +1 -0
- package/build/client/_app/immutable/chunks/DV4tvxHp.js +3 -0
- package/build/client/_app/immutable/chunks/DXk_5YEw.js +1 -0
- package/build/client/_app/immutable/chunks/DjgnRLJt.js +1 -0
- package/build/client/_app/immutable/chunks/DlWlQ_vP.js +1 -0
- package/build/client/_app/immutable/chunks/DpIAei2y.js +2 -0
- package/build/client/_app/immutable/chunks/Dt-HX3Vu.js +1 -0
- package/build/client/_app/immutable/chunks/DuSthUWX.js +1 -0
- package/build/client/_app/immutable/chunks/Ecfl8TOn.js +2 -0
- package/build/client/_app/immutable/chunks/ITHE99Aa.js +1 -0
- package/build/client/_app/immutable/chunks/Khdge0KS.js +1 -0
- package/build/client/_app/immutable/chunks/LMEKNlm0.js +1 -0
- package/build/client/_app/immutable/chunks/OnIeaiuO.js +1 -0
- package/build/client/_app/immutable/chunks/VFQLu55q.js +1 -0
- package/build/client/_app/immutable/chunks/ZsUxKnQw.js +1 -0
- package/build/client/_app/immutable/chunks/aWP8DVhV.js +1 -0
- package/build/client/_app/immutable/chunks/bB04Xp1f.js +1 -0
- package/build/client/_app/immutable/chunks/eylBqhv8.js +3 -0
- package/build/client/_app/immutable/chunks/hx0ssLL_.js +2 -0
- package/build/client/_app/immutable/chunks/mumDj17t.js +1 -0
- package/build/client/_app/immutable/chunks/pZYp3_TE.js +1 -0
- package/build/client/_app/immutable/chunks/tImwjqWn.js +1 -0
- package/build/client/_app/immutable/chunks/uBIymjUX.js +1 -0
- package/build/client/_app/immutable/chunks/xihTtKlq.js +1 -0
- package/build/client/_app/immutable/entry/app.DVZ1wE36.js +2 -0
- package/build/client/_app/immutable/entry/start.DluCc61B.js +1 -0
- package/build/client/_app/immutable/nodes/0.CwNFevXf.js +1 -0
- package/build/client/_app/immutable/nodes/1.BR6FYiC-.js +1 -0
- package/build/client/_app/immutable/nodes/10.wNwBFtom.js +2 -0
- package/build/client/_app/immutable/nodes/11.DpoIbMNF.js +2 -0
- package/build/client/_app/immutable/nodes/12.CWdUJ8l3.js +2 -0
- package/build/client/_app/immutable/nodes/13.CZ2uTvNS.js +1 -0
- package/build/client/_app/immutable/nodes/14.CzgyXuvL.js +1 -0
- package/build/client/_app/immutable/nodes/15.CzgyXuvL.js +1 -0
- package/build/client/_app/immutable/nodes/16.odL9eB2N.js +1 -0
- package/build/client/_app/immutable/nodes/17.B-RnUeVU.js +1 -0
- package/build/client/_app/immutable/nodes/18.BLYKxyq2.js +1 -0
- package/build/client/_app/immutable/nodes/19.CgyFfPqF.js +3 -0
- package/build/client/_app/immutable/nodes/2.CCWT41Qr.js +1 -0
- package/build/client/_app/immutable/nodes/20.BBk5-krg.js +1 -0
- package/build/client/_app/immutable/nodes/21.CJoU3s1A.js +2 -0
- package/build/client/_app/immutable/nodes/22.CoRvPh8m.js +1 -0
- package/build/client/_app/immutable/nodes/23.zXO3NjnM.js +3 -0
- package/build/client/_app/immutable/nodes/24.CmO27TED.js +1 -0
- package/build/client/_app/immutable/nodes/26.TVKNr_xX.js +18 -0
- package/build/client/_app/immutable/nodes/27.RojtGU_o.js +1 -0
- package/build/client/_app/immutable/nodes/28.CVTdeeSI.js +2 -0
- package/build/client/_app/immutable/nodes/3.Cgib7Vi6.js +1 -0
- package/build/client/_app/immutable/nodes/4.CnMwOCec.js +1 -0
- package/build/client/_app/immutable/nodes/5.-NqYtQj_.js +1 -0
- package/build/client/_app/immutable/nodes/6.D5xk-UBM.js +1 -0
- package/build/client/_app/immutable/nodes/7.IL4b-DII.js +1 -0
- package/build/client/_app/immutable/nodes/8.DJrguHjO.js +11 -0
- package/build/client/_app/immutable/nodes/9.DTUSzWiK.js +1 -0
- package/build/client/_app/version.json +1 -0
- package/build/client/favicon.svg +7 -0
- package/build/env.js +70 -0
- package/build/handler.js +26 -0
- package/build/index.js +149 -0
- package/build/server/chunks/chunks/Banner.js-D4mtxUfF.js +17 -0
- package/build/server/chunks/chunks/BoardOff.js-Dg5-LoR3.js +1627 -0
- package/build/server/chunks/chunks/Button.js-Buh9rnpu.js +43 -0
- package/build/server/chunks/chunks/Chip.js-xZ7vFkHx.js +12 -0
- package/build/server/chunks/chunks/Dialog.js-CGpwdpM-.js +60 -0
- package/build/server/chunks/chunks/FeaturePanels.js-B2sKozgF.js +84 -0
- package/build/server/chunks/chunks/FolderBrowser.js-DUHFhDaX.js +28 -0
- package/build/server/chunks/chunks/HelpTip.js-CzemvmjC.js +19 -0
- package/build/server/chunks/chunks/InfoBox.js-BJiVzZgw.js +10 -0
- package/build/server/chunks/chunks/KeyCaps.js-BMI2Hrh2.js +37 -0
- package/build/server/chunks/chunks/LogLine.js-2b7uX__H.js +35 -0
- package/build/server/chunks/chunks/Markdown.js-Clud88KU.js +4233 -0
- package/build/server/chunks/chunks/ModelPicker.js-FuBgyKIA.js +141 -0
- package/build/server/chunks/chunks/OptionButtons.js-LQKrAwUX.js +28 -0
- package/build/server/chunks/chunks/PeekPanel.js-aZ-r_v3N.js +375 -0
- package/build/server/chunks/chunks/ScoutPage.js-2DcNia96.js +733 -0
- package/build/server/chunks/chunks/SetupSteps.js-D7TAF7xa.js +66 -0
- package/build/server/chunks/chunks/Skeleton.js-diCP2sd5.js +30 -0
- package/build/server/chunks/chunks/SlotsMeter.js-BV_sAGf5.js +18 -0
- package/build/server/chunks/chunks/StartConfirm.js-CzEdFtbO.js +124 -0
- package/build/server/chunks/chunks/StatePill.js-CM7-HXNM.js +27 -0
- package/build/server/chunks/chunks/Streamed.js-_NgwNMMs.js +43 -0
- package/build/server/chunks/chunks/_page.server.js-BaGoctEY.js +1419 -0
- package/build/server/chunks/chunks/activity.js-CSoPUQLq.js +84 -0
- package/build/server/chunks/chunks/add-repo.js-DtHEobfm.js +305 -0
- package/build/server/chunks/chunks/app-header.js-CCflgeEQ.js +13 -0
- package/build/server/chunks/chunks/app.js-CuPn8jtk.js +12 -0
- package/build/server/chunks/chunks/bin.js-Cyb2cYLc.js +58 -0
- package/build/server/chunks/chunks/board-keys.js-CW3qw-MC.js +32 -0
- package/build/server/chunks/chunks/board-page.js-D0tdsE9J.js +860 -0
- package/build/server/chunks/chunks/board.js-BxL3CjB1.js +203 -0
- package/build/server/chunks/chunks/browser-test.js-DJEpOoVz.js +170 -0
- package/build/server/chunks/chunks/card-pulls.js-d_uGmBB3.js +229 -0
- package/build/server/chunks/chunks/card-repos.js-QaMCxiyV.js +59 -0
- package/build/server/chunks/chunks/chain-store.js-D42m8DUo.js +91 -0
- package/build/server/chunks/chunks/chain.js-CJFRywIC.js +52 -0
- package/build/server/chunks/chunks/changes.js-D8ITRMgU.js +513 -0
- package/build/server/chunks/chunks/checkout.js-Ys5L_gA4.js +319 -0
- package/build/server/chunks/chunks/client.js-B7jIMDuS.js +68 -0
- package/build/server/chunks/chunks/clipboard.js-qXskOBim.js +12 -0
- package/build/server/chunks/chunks/cloud-status.js-hy-9zUVX.js +95 -0
- package/build/server/chunks/chunks/coach.js-BhNB14rV.js +296 -0
- package/build/server/chunks/chunks/comments.js-1nWJQptB.js +311 -0
- package/build/server/chunks/chunks/commit-message.js-CMcNZUZw.js +8 -0
- package/build/server/chunks/chunks/create-card.js-DKtprMG6.js +498 -0
- package/build/server/chunks/chunks/db.js-pqoVpAzG.js +80 -0
- package/build/server/chunks/chunks/diff-comments.js-BSCuay_U.js +95 -0
- package/build/server/chunks/chunks/discussion.js-rJ5OMfvX.js +355 -0
- package/build/server/chunks/chunks/display.js-Bf-vGQ7Q.js +61 -0
- package/build/server/chunks/chunks/elapsed.js-DikkNhaD.js +27 -0
- package/build/server/chunks/chunks/engine.js-DS5zUwsE.js +115 -0
- package/build/server/chunks/chunks/env.js-l0sNRNKZ.js +2 -0
- package/build/server/chunks/chunks/estimate.js-BHTYVTaQ.js +2484 -0
- package/build/server/chunks/chunks/evidence-timeline.js-Dk0dTZIy.js +253 -0
- package/build/server/chunks/chunks/evidence.js-CT3tWdbB.js +257 -0
- package/build/server/chunks/chunks/exports.js-Hn-WQRMB.js +150 -0
- package/build/server/chunks/chunks/features.svelte.js-DNsFmFZb.js +10 -0
- package/build/server/chunks/chunks/files.js-V46lE0-6.js +46 -0
- package/build/server/chunks/chunks/filter.js-CsmCtJMd.js +11 -0
- package/build/server/chunks/chunks/forms.js-03E8qnFz.js +35 -0
- package/build/server/chunks/chunks/gate.js-Cbqo8Yy0.js +82 -0
- package/build/server/chunks/chunks/getting-started.js-DKbHofN5.js +55 -0
- package/build/server/chunks/chunks/git.js-l43vBHqs.js +16 -0
- package/build/server/chunks/chunks/home-path.js-BXgrl3TP.js +11 -0
- package/build/server/chunks/chunks/hub-link.js-B5kjLyyd.js +1532 -0
- package/build/server/chunks/chunks/internal.js-DaSBO6jY.js +1239 -0
- package/build/server/chunks/chunks/internal2.js-D6AKyUgY.js +27 -0
- package/build/server/chunks/chunks/knowledge-page.js-D2ALB3v9.js +292 -0
- package/build/server/chunks/chunks/knowledge-revert.js-2eyN9Lcb.js +109 -0
- package/build/server/chunks/chunks/knowledge.js--eAgdzNx.js +394 -0
- package/build/server/chunks/chunks/last-board.js-BemeiK3t.js +23 -0
- package/build/server/chunks/chunks/log.js-R2zUph6T.js +228 -0
- package/build/server/chunks/chunks/loop.js-D3guWKLp.js +4038 -0
- package/build/server/chunks/chunks/loop2.js-B_Qd2m4y.js +67 -0
- package/build/server/chunks/chunks/navigation.js-DQJMz-SM.js +2 -0
- package/build/server/chunks/chunks/new-project.js-DNcr9JpB.js +305 -0
- package/build/server/chunks/chunks/next-step.js-B8Kl0Iv9.js +522 -0
- package/build/server/chunks/chunks/node.js-Bz2jT5wt.js +3381 -0
- package/build/server/chunks/chunks/now-live.svelte.js-hIaDgjJ3.js +13 -0
- package/build/server/chunks/chunks/now-snapshot.js-zGKLIzox.js +207 -0
- package/build/server/chunks/chunks/now.js-Dfm-o0Ha.js +765 -0
- package/build/server/chunks/chunks/onboard.js-LBqPOxyU.js +1525 -0
- package/build/server/chunks/chunks/ordinal.js-Bm_9QEBD.js +12 -0
- package/build/server/chunks/chunks/overview.js-C32iHkXD.js +1108 -0
- package/build/server/chunks/chunks/page-keys.svelte.js-D8vXA_8Z.js +14 -0
- package/build/server/chunks/chunks/patch.js-Bl7vwsUj.js +62 -0
- package/build/server/chunks/chunks/paths.js-DVRjNYFW.js +19 -0
- package/build/server/chunks/chunks/peek.js-D9sSjT9t.js +95 -0
- package/build/server/chunks/chunks/plan.js-DFq5ntMM.js +143 -0
- package/build/server/chunks/chunks/project-files-notice.js-CcqcBgUP.js +19 -0
- package/build/server/chunks/chunks/project-files.js-DTC4jUxy.js +52 -0
- package/build/server/chunks/chunks/project-folder.js-CoKgPiM0.js +22 -0
- package/build/server/chunks/chunks/projects.js-bw2V11od.js +989 -0
- package/build/server/chunks/chunks/prs.js-CLfImauu.js +118 -0
- package/build/server/chunks/chunks/publish.js-D2vWpIJU.js +195 -0
- package/build/server/chunks/chunks/pull-list.js-BCIBJdyz.js +691 -0
- package/build/server/chunks/chunks/qa-ask.svelte.js-8Hf1JWW2.js +47 -0
- package/build/server/chunks/chunks/qa-setup.js-DFOEcNxH.js +1241 -0
- package/build/server/chunks/chunks/quiet.js-1GKY40Ay.js +104 -0
- package/build/server/chunks/chunks/rail.js-BePBwOqZ.js +135 -0
- package/build/server/chunks/chunks/review.js-MPqnq9Gy.js +98 -0
- package/build/server/chunks/chunks/routing.js-B8s1QwSP.js +265 -0
- package/build/server/chunks/chunks/run-log.js-CnN2jOcg.js +94 -0
- package/build/server/chunks/chunks/run.js-COSejjLl.js +34 -0
- package/build/server/chunks/chunks/scout-findings.js-CqJti10a.js +940 -0
- package/build/server/chunks/chunks/scout.js-Bm7wQLX2.js +62 -0
- package/build/server/chunks/chunks/sentinels.js-BXvpnzr3.js +13 -0
- package/build/server/chunks/chunks/server.js-BR0D07DR.js +3803 -0
- package/build/server/chunks/chunks/settings-sections.js-V70W7BkZ.js +103 -0
- package/build/server/chunks/chunks/shared.js-BgfCUZUJ.js +776 -0
- package/build/server/chunks/chunks/sign-in.js-O-pBhi19.js +14 -0
- package/build/server/chunks/chunks/snapshot.js-BekzL_He.js +38 -0
- package/build/server/chunks/chunks/spend.js-BabnR69T.js +63 -0
- package/build/server/chunks/chunks/src.js-Cm8RAH_q.js +609 -0
- package/build/server/chunks/chunks/src2.js-CV8tsClO.js +1186 -0
- package/build/server/chunks/chunks/src3.js-h9tTEbVb.js +11222 -0
- package/build/server/chunks/chunks/stack.js-CMWXhMZS.js +13 -0
- package/build/server/chunks/chunks/standup.js-D-qBnMx4.js +103 -0
- package/build/server/chunks/chunks/state.js-BTDrgu7s.js +71 -0
- package/build/server/chunks/chunks/stream.js-D6r6iqjD.js +66 -0
- package/build/server/chunks/chunks/terms.js-DPZztSEn.js +88 -0
- package/build/server/chunks/chunks/ticket-system.js-Dj9R3XJw.js +147 -0
- package/build/server/chunks/chunks/ticket.js-6sj-2ZEM.js +110 -0
- package/build/server/chunks/chunks/timesheet.js-DfhIokoE.js +212 -0
- package/build/server/chunks/chunks/timesheet2.js-Cu95ddl3.js +84 -0
- package/build/server/chunks/chunks/to-workspace.js-DiOJP59J.js +308 -0
- package/build/server/chunks/chunks/toast-stack.svelte.js-CXIg3_KT.js +10 -0
- package/build/server/chunks/chunks/uneval.js-VnZcgzZr.js +488 -0
- package/build/server/chunks/chunks/utils.js-DQTBh7_6.js +1006 -0
- package/build/server/chunks/chunks/when-said.js-0F9asAma.js +35 -0
- package/build/server/chunks/chunks/workspace.js-BBdJRon9.js +212 -0
- package/build/server/chunks/entries/endpoints/api/board/_server.ts.js-BlYC_lpV.js +69 -0
- package/build/server/chunks/entries/endpoints/api/board/minimize/_server.ts.js-Wddt9YPR.js +68 -0
- package/build/server/chunks/entries/endpoints/api/board/move/_server.ts.js-BwZpCKx0.js +68 -0
- package/build/server/chunks/entries/endpoints/api/board/promote/_server.ts.js-Cw6kvkMq.js +68 -0
- package/build/server/chunks/entries/endpoints/api/board/pulls/_server.ts.js-DFhpbiMo.js +71 -0
- package/build/server/chunks/entries/endpoints/api/board/stop/_server.ts.js-D5eylDMw.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/answer/_server.ts.js-CG8xh52y.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/branch/_server.ts.js-a5_P9voA.js +40 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/chain/_server.ts.js-tJvQy6RK.js +70 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/checkouts/_server.ts.js-B2_gx6vF.js +41 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/choice/_server.ts.js-pmAdIQkK.js +34 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/comments/_id_/_server.ts.js-C5NxGWw3.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/comments/_server.ts.js-0rw7UNv8.js +64 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/commit/_server.ts.js-_yXWCOlQ.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/commit-diff/_server.ts.js-CRPV3z-g.js +61 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/commit-message/_server.ts.js-CO9mD3u6.js +82 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/context/_server.ts.js-7kzrigFz.js +42 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/delete/_server.ts.js-DH0nO9wG.js +516 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/file/_server.ts.js-D80SvJDi.js +35 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/files/_...path_/_server.ts.js-GxFjb2H0.js +34 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/fix/_server.ts.js-B-HAB050.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/knowledge/_server.ts.js-D4fN-j7X.js +81 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/link/_other_/_server.ts.js-C00pQDCu.js +42 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/log/_server.ts.js-BXW_tG-I.js +32 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/log/raw/_server.ts.js-pT8StZGR.js +32 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/message/_server.ts.js-ZMno2Hu6.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/models/_server.ts.js-DEZVpqO3.js +73 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/patch/_server.ts.js-BxfLi-Zs.js +61 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/peek/_server.ts.js-CsTKWIP_.js +169 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/_server.ts.js-CsOeAXkf.js +53 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/comments/_server.ts.js-DZ2XHOhF.js +71 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/discuss/_server.ts.js-CO8eM0e8.js +72 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/discussions/_server.ts.js-Lp7l0Yqv.js +71 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/fix/_server.ts.js-CeIhjpQ4.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/fix-all/_server.ts.js-D-DKoCpQ.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/links/_server.ts.js-B_q3jUP3.js +72 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/qa/_server.ts.js-BulVcJY9.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/seen/_server.ts.js-Z06A6MS1.js +71 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pr/triage/_server.ts.js-qADU4URF.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/pull/_server.ts.js-CHnTH9WK.js +58 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/push/_server.ts.js-BPdPwPo2.js +83 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/repos/_server.ts.js-Bjqa3Uoo.js +73 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/research/_server.ts.js-DzQjoHOZ.js +138 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/retry/_server.ts.js-CAodrXqd.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/send-back/_server.ts.js-CmJSnvTx.js +68 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/stack/_server.ts.js-DjI8S94J.js +82 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/tasks/_server.ts.js-BzX_nNJk.js +71 -0
- package/build/server/chunks/entries/endpoints/api/card/_key_/thread/_server.ts.js-Dn36Guxk.js +33 -0
- package/build/server/chunks/entries/endpoints/api/cards/_server.ts.js-DPMOBsvp.js +77 -0
- package/build/server/chunks/entries/endpoints/api/cards/context/_server.ts.js-D6y-g2O-.js +52 -0
- package/build/server/chunks/entries/endpoints/api/cards/next/_server.ts.js-C2se67rf.js +55 -0
- package/build/server/chunks/entries/endpoints/api/chain/_server.ts.js-DKO5Q8GV.js +70 -0
- package/build/server/chunks/entries/endpoints/api/clones/_server.ts.js-Bgcc_Beg.js +56 -0
- package/build/server/chunks/entries/endpoints/api/current-project/_server.ts.js-DZCtSlXs.js +81 -0
- package/build/server/chunks/entries/endpoints/api/evidence/timesheet/_server.ts.js-xJwzSrcl.js +32 -0
- package/build/server/chunks/entries/endpoints/api/folders/_server.ts.js-BdcE7k8S.js +83 -0
- package/build/server/chunks/entries/endpoints/api/gh/_server.ts.js-CGvM8fn7.js +66 -0
- package/build/server/chunks/entries/endpoints/api/gh/name/_server.ts.js-CHh3tAu7.js +36 -0
- package/build/server/chunks/entries/endpoints/api/health/_server.ts.js-DLUfrHo6.js +22 -0
- package/build/server/chunks/entries/endpoints/api/login-item/_server.ts.js-Cya7S7W6.js +77 -0
- package/build/server/chunks/entries/endpoints/api/notes/_server.ts.js-DaUFVqSM.js +26 -0
- package/build/server/chunks/entries/endpoints/api/notifications/_server.ts.js-DK6NFnII.js +76 -0
- package/build/server/chunks/entries/endpoints/api/now/_server.ts.js-xW0jeJdy.js +83 -0
- package/build/server/chunks/entries/endpoints/api/package/entry/_server.ts.js-DQyZanpo.js +35 -0
- package/build/server/chunks/entries/endpoints/api/projects/_server.ts.js-CzXJTj_l.js +58 -0
- package/build/server/chunks/entries/endpoints/api/qa-setup/_server.ts.js-DujrYbEP.js +76 -0
- package/build/server/chunks/entries/endpoints/api/remove-check/_server.ts.js-1KAi9LDi.js +58 -0
- package/build/server/chunks/entries/endpoints/api/setup/_server.ts.js-D0MKtjR7.js +69 -0
- package/build/server/chunks/entries/endpoints/api/tickets/jira/_server.ts.js-Z2LdOr5l.js +39 -0
- package/build/server/chunks/entries/endpoints/api/tickets/read/_server.ts.js-BziHtc8Y.js +68 -0
- package/build/server/chunks/entries/endpoints/api/tools/_server.ts.js-oyvq8i1y.js +30 -0
- package/build/server/chunks/entries/endpoints/api/workspace/_server.ts.js-CMGBL5cX.js +58 -0
- package/build/server/chunks/entries/endpoints/api/workspace/commit/_server.ts.js-BZQQJ1YG.js +66 -0
- package/build/server/chunks/entries/endpoints/api/workspace/patch/_server.ts.js-xrjgHECx.js +64 -0
- package/build/server/chunks/entries/endpoints/api/workspace/push/_server.ts.js-CTdia7Uz.js +66 -0
- package/build/server/chunks/entries/hooks.server.js-B0jE-ELC.js +211 -0
- package/build/server/chunks/entries/pages/_error.svelte.js-DPcKI5sX.js +25 -0
- package/build/server/chunks/entries/pages/_layout.server.ts.js-Jj3i2Th9.js +134 -0
- package/build/server/chunks/entries/pages/_layout.svelte.js-Cu3ghN80.js +1251 -0
- package/build/server/chunks/entries/pages/_page.svelte.js-DEYydBCm.js +662 -0
- package/build/server/chunks/entries/pages/accept/_page.server.ts.js-BF7MrA5s.js +29 -0
- package/build/server/chunks/entries/pages/accept/_page.svelte.js-8yPsedd-.js +54 -0
- package/build/server/chunks/entries/pages/b/_board_/_page.svelte.js-S9acLF3f.js +68 -0
- package/build/server/chunks/entries/pages/b/_board_/_page.ts.js-BcKdG_Tp.js +21 -0
- package/build/server/chunks/entries/pages/b/research/_page.svelte.js-FW6Hw9g5.js +68 -0
- package/build/server/chunks/entries/pages/b/research/_page.ts.js-Ds2AjFFK.js +13 -0
- package/build/server/chunks/entries/pages/evidence/_page.server.ts.js-uwu2X7bA.js +1382 -0
- package/build/server/chunks/entries/pages/evidence/_page.svelte.js-DBCjiT59.js +594 -0
- package/build/server/chunks/entries/pages/f/_...path_/_page.svelte.js-DxwJaJzh.js +58 -0
- package/build/server/chunks/entries/pages/knowledge/_page.server.ts.js-BAUvFEcM.js +80 -0
- package/build/server/chunks/entries/pages/knowledge/_page.svelte.js-D9117gHM.js +732 -0
- package/build/server/chunks/entries/pages/new/_page.server.ts.js-BNCQQpyw.js +110 -0
- package/build/server/chunks/entries/pages/new/_page.svelte.js-Ben8-N_h.js +503 -0
- package/build/server/chunks/entries/pages/new/idea/_page.server.ts.js-jssA29y3.js +46 -0
- package/build/server/chunks/entries/pages/new/idea/_page.svelte.js-XoKspqAc.js +210 -0
- package/build/server/chunks/entries/pages/new/task/_page.server.ts.js-CmZgfvyt.js +66 -0
- package/build/server/chunks/entries/pages/new/task/_page.svelte.js-BKpERKvm.js +169 -0
- package/build/server/chunks/entries/pages/onboard/_page.server.ts.js-pmc_pXvs.js +12 -0
- package/build/server/chunks/entries/pages/onboard/_page.svelte.js-C7LNK-ba.js +5 -0
- package/build/server/chunks/entries/pages/projects/_page.server.ts.js-BEhLRfJ_.js +12 -0
- package/build/server/chunks/entries/pages/projects/_page.svelte.js-OraOjsyb.js +5 -0
- package/build/server/chunks/entries/pages/scout/_page.server.ts.js-hQYnMHwY.js +10 -0
- package/build/server/chunks/entries/pages/scout/_page.svelte.js-7q4d044Z.js +40 -0
- package/build/server/chunks/entries/pages/scout/f/_id_/_page.server.ts.js-BN4TnSpB.js +22 -0
- package/build/server/chunks/entries/pages/scout/f/_id_/_page.svelte.js-GzpLhARi.js +40 -0
- package/build/server/chunks/entries/pages/settings/_layout.server.ts.js-B5LgqMMT.js +12 -0
- package/build/server/chunks/entries/pages/settings/_layout.svelte.js-CSCpV6qA.js +81 -0
- package/build/server/chunks/entries/pages/settings/_page.svelte.js-DNpsNFo0.js +25 -0
- package/build/server/chunks/entries/pages/settings/_section_/_page.server.ts.js-nRDEV3i_.js +348 -0
- package/build/server/chunks/entries/pages/settings/_section_/_page.svelte.js-BihUf-nY.js +1052 -0
- package/build/server/chunks/entries/pages/settings/integrations/_page.server.ts.js-BTuRpg8m.js +58 -0
- package/build/server/chunks/entries/pages/settings/integrations/_page.svelte.js-C8i8ZmZR.js +161 -0
- package/build/server/chunks/entries/pages/settings/mcp/_page.server.ts.js-TFISfO1a.js +925 -0
- package/build/server/chunks/entries/pages/settings/mcp/_page.svelte.js-D1X0TNOm.js +433 -0
- package/build/server/chunks/entries/pages/settings/phases/_page.server.ts.js-CgK7MTZf.js +48 -0
- package/build/server/chunks/entries/pages/settings/phases/_page.svelte.js-u-sTQ-ue.js +80 -0
- package/build/server/chunks/entries/pages/settings/project/_page.server.ts.js-CCnk9WbO.js +363 -0
- package/build/server/chunks/entries/pages/settings/project/_page.svelte.js-MxvNqYlQ.js +1269 -0
- package/build/server/chunks/entries/pages/settings/wall/_page.server.ts.js-Bt5siY_N.js +12 -0
- package/build/server/chunks/entries/pages/settings/wall/_page.svelte.js-CMR4zSAt.js +43 -0
- package/build/server/chunks/entries/pages/t/_key_/_layout.server.ts.js-W6YPvOCA.js +124 -0
- package/build/server/chunks/entries/pages/t/_key_/_layout.svelte.js-CK0PiWsz.js +543 -0
- package/build/server/chunks/entries/pages/t/_key_/_page.server.ts.js-CdB7v0WX.js +15 -0
- package/build/server/chunks/entries/pages/t/_key_/_tab_/_page.server.ts.js-Bksaje8R.js +75 -0
- package/build/server/chunks/entries/pages/t/_key_/_tab_/_page.svelte.js-9OQ2eQxu.js +4607 -0
- package/build/server/chunks/entries/pages/team/_page.svelte.js-BdUSXC04.js +18 -0
- package/build/server/chunks/entries/pages/team/_page.ts.js-DfhJmoZI.js +20 -0
- package/build/server/chunks/entries/pages/workspace/_page.svelte.js-DLaWe23r.js +579 -0
- package/build/server/chunks/handler-Dlwmumt5.js +1735 -0
- package/build/server/chunks/index.js-BX0fZD5G.js +3701 -0
- package/build/server/chunks/manifest.js-B2Of6Dj7.js +761 -0
- package/build/server/chunks/nodes/0.js-DSzhdY0D.js +87 -0
- package/build/server/chunks/nodes/1.js-j4osL1br.js +9 -0
- package/build/server/chunks/nodes/10.js-jkvevEFY.js +75 -0
- package/build/server/chunks/nodes/11.js-plyiDP2n.js +72 -0
- package/build/server/chunks/nodes/12.js-DwtvDAyM.js +78 -0
- package/build/server/chunks/nodes/13.js-BpxwqFh4.js +72 -0
- package/build/server/chunks/nodes/14.js-B5iNIKGy.js +15 -0
- package/build/server/chunks/nodes/15.js-CXCAqUsG.js +15 -0
- package/build/server/chunks/nodes/16.js-oxkLEH0n.js +76 -0
- package/build/server/chunks/nodes/17.js-B-ZJEo9K.js +76 -0
- package/build/server/chunks/nodes/18.js-C0OUCEux.js +9 -0
- package/build/server/chunks/nodes/19.js-M8EAQJdW.js +76 -0
- package/build/server/chunks/nodes/2.js-ZedduK-3.js +33 -0
- package/build/server/chunks/nodes/20.js-BHvsLNjD.js +72 -0
- package/build/server/chunks/nodes/21.js-eOaW4si1.js +76 -0
- package/build/server/chunks/nodes/22.js-CbJ6tQSs.js +38 -0
- package/build/server/chunks/nodes/23.js-DXk8ejlx.js +81 -0
- package/build/server/chunks/nodes/24.js-C4qGJc4X.js +33 -0
- package/build/server/chunks/nodes/25.js-Cal8uT5V.js +21 -0
- package/build/server/chunks/nodes/26.js-Cp5jBcrN.js +80 -0
- package/build/server/chunks/nodes/27.js-Do55o_cb.js +17 -0
- package/build/server/chunks/nodes/28.js-SNz3QVix.js +9 -0
- package/build/server/chunks/nodes/3.js-DyivQ5dN.js +75 -0
- package/build/server/chunks/nodes/4.js-BGgTTQFR.js +9 -0
- package/build/server/chunks/nodes/5.js-DQYA2BBI.js +31 -0
- package/build/server/chunks/nodes/6.js-BVTi2KFL.js +24 -0
- package/build/server/chunks/nodes/7.js-CnprIn3p.js +12 -0
- package/build/server/chunks/nodes/8.js-Bdicn369.js +50 -0
- package/build/server/chunks/nodes/9.js-DVclPGXf.js +9 -0
- package/build/shims.js +33 -0
- package/dist/THIRD-PARTY-NOTICES.md +659 -0
- package/dist/detect-BmI_gskA.js +585 -0
- package/dist/fonts/OFL.txt +92 -0
- package/dist/nolzu.js +48 -0
- package/dist/package-vezZOzhD.js +181 -0
- package/dist/shared/finish.md +110 -0
- package/dist/shared/knowledge.md +72 -0
- package/dist/shared/verdict.md +42 -0
- package/dist/skills/.gitkeep +0 -0
- package/dist/skills/nolzu-architecture/SKILL.md +140 -0
- package/dist/skills/nolzu-architecture/finish.md +110 -0
- package/dist/skills/nolzu-assess/SKILL.md +99 -0
- package/dist/skills/nolzu-assess/finish.md +110 -0
- package/dist/skills/nolzu-design/SKILL.md +115 -0
- package/dist/skills/nolzu-design/finish.md +110 -0
- package/dist/skills/nolzu-feedback/SKILL.md +107 -0
- package/dist/skills/nolzu-feedback/finish.md +110 -0
- package/dist/skills/nolzu-implement/SKILL.md +138 -0
- package/dist/skills/nolzu-implement/finish.md +110 -0
- package/dist/skills/nolzu-investigate/SKILL.md +139 -0
- package/dist/skills/nolzu-investigate/finish.md +110 -0
- package/dist/skills/nolzu-learn-repo/SKILL.md +115 -0
- package/dist/skills/nolzu-learn-repo/finish.md +110 -0
- package/dist/skills/nolzu-learn-repo/knowledge.md +72 -0
- package/dist/skills/nolzu-optimize/SKILL.md +82 -0
- package/dist/skills/nolzu-optimize/finish.md +110 -0
- package/dist/skills/nolzu-optimize/knowledge.md +72 -0
- package/dist/skills/nolzu-orient/SKILL.md +115 -0
- package/dist/skills/nolzu-orient/finish.md +110 -0
- package/dist/skills/nolzu-orient/knowledge.md +72 -0
- package/dist/skills/nolzu-plan/SKILL.md +165 -0
- package/dist/skills/nolzu-plan/finish.md +110 -0
- package/dist/skills/nolzu-pr-review/SKILL.md +150 -0
- package/dist/skills/nolzu-pr-review/finish.md +110 -0
- package/dist/skills/nolzu-qa/SKILL.md +177 -0
- package/dist/skills/nolzu-qa/finish.md +110 -0
- package/dist/skills/nolzu-qa/verdict.md +42 -0
- package/dist/skills/nolzu-refine/SKILL.md +145 -0
- package/dist/skills/nolzu-refine/finish.md +110 -0
- package/dist/skills/nolzu-research/SKILL.md +140 -0
- package/dist/skills/nolzu-research/finish.md +110 -0
- package/dist/skills/nolzu-wrapup/SKILL.md +126 -0
- package/dist/skills/nolzu-wrapup/finish.md +110 -0
- package/dist/skills/nolzu-wrapup/knowledge.md +72 -0
- package/dist/src-BG8LaXLS.js +723 -0
- package/dist/src-DPfcvRqs.js +4 -0
- package/dist/start-ItZOcBtM.js +362 -0
- package/package.json +49 -9
- package/bin/nolzu.js +0 -8
|
@@ -0,0 +1,4038 @@
|
|
|
1
|
+
import { m as missingProfileText, D as DEFAULT_PROFILE, p as profileName, L as LIMIT_SIGNAL } from './engine.js-DS5zUwsE.js';
|
|
2
|
+
import { p as phaseLabel, i as isBoardKind, b as isPass, a as isResearchKind } from './board.js-BxL3CjB1.js';
|
|
3
|
+
import { H as NO_REPOSITORY, y as policyFor, c as resolveModels, e as projectRepos, j as isAction, z as vendorRefusal, T as modelsForPick, s as startsInCardFolder, a6 as READ_GIT_COMMANDS, a7 as chainTo, a8 as smallChain, a9 as startsLabel, h as boardFor, aa as EXTRACT_SUMMARY_POLICY, ab as presetModels, V as goneText } from './estimate.js-BHTYVTaQ.js';
|
|
4
|
+
import { r as resolveDataDir, w as writeSetting, a4 as openDatabase, a1 as openProject, O as registeredProjects, a3 as FIRST_PROJECT, ag as projectFiles, i as isFakeMode, g as getSetting, U as bumpVersion, ah as markRunning, d as boardOfCard, b as reposOfCard, ai as seenHead, aj as saveStackStatus, ak as saveRun, al as recordKnowledgeChanges, am as savePullRound, an as saveQuestionOptions, ao as parseQuestionOptions, ap as saveVerdict, aq as saveCommitWarning, ar as endFix, as as reopenFixed, at as startWriting, au as recoverRuns, e as projectProfiles, f as cardPreset, h as cardBase, j as cardModels, y as projectOutsideGit, m as sessionFolder, l as sessionInCardFolder, av as epicOfTask, aw as returnedKnowledgeNote, ax as setCardTitle, ay as scoutFinding, p as pendingKnowledgeChanges, az as cardHolds, ae as recordMove, aA as setCardStack, N as NOT_A_PASS, aB as startRun, aC as otherRunOfCard, aD as clearReadOnlyBreaks, aE as saveReadOnlyBreak, ad as cardDiscussions, aF as beginFix, K as cardPullRows, aG as beginFixAll, aH as fixedSinceQa, aI as lastJudgedQa, aJ as assessScoutFinding, aK as boardSnapshot, S as addNotification, aL as applyTriage, aM as saveOutputCheck, aN as savePlainSummary, a7 as setCardRepos, aO as promote, aP as remove, aQ as enqueue, aR as createQueue, aS as pick, aT as cardStack, aU as notifications, aV as unreadNotifications } from './node.js-Bz2jT5wt.js';
|
|
5
|
+
import { z as refinedTitle, w as parseTicketRef } from './src.js-Cm8RAH_q.js';
|
|
6
|
+
import { s as shortReason, a as atLimit } from './run.js-COSejjLl.js';
|
|
7
|
+
import { Q as QUESTION_FILE } from './sentinels.js-BXvpnzr3.js';
|
|
8
|
+
import { c as cardStarts } from './snapshot.js-BekzL_He.js';
|
|
9
|
+
import { b as repoOfLearnKey, i as isMaintenanceKey, k as resolveKnowledgeDir, r as repoKnowledgePath, o as isAskThread, t as isFeedbackRef, n as isDeliveryPhase, K as KB_MAINTENANCE_KEY, B as learnRepoKey, E as checkedPaths, F as outputCheck } from './src2.js-CV8tsClO.js';
|
|
10
|
+
import { i as isStackState } from './stack.js-CMWXhMZS.js';
|
|
11
|
+
import { f as findingOfKey, a as assessKey } from './scout.js-Bm7wQLX2.js';
|
|
12
|
+
import { au as selectEngine, Y as mcpRunsFolder, D as checkoutRoot, t as checkoutPath, a as gitEnv, av as ensureWorktree, ak as ghRunner, aw as noteInRunLog, r as repoFolder, ax as removeCardFile, an as writeCardFile, ay as makeCardFolder, az as stackCommand, aA as startApp, aB as STACK_TIMEOUT_MS, aC as stackNotes, aD as appWall, aE as installCommand, aF as installApp, U as worktreesFolder, g as git, aG as swapPromptLine, aH as browserLine, aI as serversLine, aJ as sweptAfter, aK as runWithRetries, k as knowledgeState, aL as knowledgeChanges, aM as holdKnowledge, aN as commitKnowledge, Z as restoreCursorMcp, aO as runStackHook, aP as stackStatusAfter, aQ as extractVerdict, u as readCardText, aR as stripSharedAttribution, aS as runJob, F as wallHere, j as isPlainName, G as GUARD_PATH, aT as ownSandbox, aU as epicDocPaths, aV as readPhaseInstructions, aW as readFirstPaths, aX as phaseInstructionsFile, aY as pickKnowledge, aZ as commitAt, a_ as askPrompt, a$ as buildPrompt, ao as FROM_EPIC_FILE, A as renameFreshBranch, b0 as guardSettings, b1 as recordedRepos, b2 as gitBefore, b3 as gitAfter, o as cardFileKind, b4 as knowledgeGit, f as checkKnowledgeDir, b5 as sweepRemovals, b6 as findExecutable, am as getPull, b7 as stackEnv, ap as githubIssues, b8 as STACK_UNLOAD_TIMEOUT_MS, b9 as resolvedPath, ba as ENGINES, bb as resumeJob, bc as wallKind, bd as stepsDone, be as PROGRESS_FILE, bf as resumeMessage, m as readCardFile } from './src3.js-h9tTEbVb.js';
|
|
13
|
+
import { a as activityLine } from './activity.js-CSoPUQLq.js';
|
|
14
|
+
import { i as inTurn, f as fillAllowedCommands, a as personsSkillEdit } from './onboard.js-LBqPOxyU.js';
|
|
15
|
+
import { r as remoteEnv } from './publish.js-D2vWpIJU.js';
|
|
16
|
+
import { c as appKeychain, d as qaReposOf, e as answerFor, o as ownStarts, f as ownFolder, g as scriptsChanged, m as makeQaCopy, h as cursorMergesHere, p as promptMcp, r as runMcp, i as mcpNames, j as removeQaCopy, k as sweepMcpRuns, l as sweepQaCopies, n as migrateQaBrowser, P as PLAYWRIGHT_FILE, t as commitMcpList, u as qaCopyPath, v as flushMcpCommit, w as qaCopyRoot, q as qaHasBrowser } from './qa-setup.js-DFOEcNxH.js';
|
|
17
|
+
import { s as skillsFolder } from './project-files.js-DTC4jUxy.js';
|
|
18
|
+
import { t as threadTitlePrompt, e as extractSummaryPrompt } from './changes.js-D8ITRMgU.js';
|
|
19
|
+
import { f as filesFor, c as cardFolder } from './files.js-V46lE0-6.js';
|
|
20
|
+
import { r as recordPhaseSummary, a as addMessage, b as answerOf, w as wantsSubject, m as messagesIn, T as THREAD_TITLE, c as cleanSubject, s as saveSubject } from './discussion.js-rJ5OMfvX.js';
|
|
21
|
+
import { d as cardBranch, c as cardCheckouts, t as templateBranch } from './checkout.js-Ys5L_gA4.js';
|
|
22
|
+
import { r as roundsIn, a as measured, p as planSteps } from './overview.js-C32iHkXD.js';
|
|
23
|
+
import { k as keepHeld, m as moveTo, l as learnAsking, w as withAfterLearn, f as followLearn } from './hub-link.js-B5kjLyyd.js';
|
|
24
|
+
import { c as chosenProject, s as standInOf, d as damagedDatabase, o as openFirstThatOpens } from './db.js-pqoVpAzG.js';
|
|
25
|
+
import { k as knowledgeFiles, b as knowledgeIndexFiles } from './knowledge-page.js-D2ALB3v9.js';
|
|
26
|
+
import { c as commentsOf } from './diff-comments.js-BSCuay_U.js';
|
|
27
|
+
import { p as parseQaChecklist, a as placeComments } from './comments.js-1nWJQptB.js';
|
|
28
|
+
import { o as originRepo } from './create-card.js-DKtprMG6.js';
|
|
29
|
+
import { u as unlinkedCards, l as linkOpenPulls } from './pull-list.js-BCIBJdyz.js';
|
|
30
|
+
import { v as error } from './utils.js-DQTBh7_6.js';
|
|
31
|
+
import { mkdirSync, existsSync, rmSync, writeFileSync, readdirSync, lstatSync, statSync, realpathSync, readFileSync } from 'node:fs';
|
|
32
|
+
import { join, dirname, relative, sep } from 'node:path';
|
|
33
|
+
import { execFileSync, spawn } from 'node:child_process';
|
|
34
|
+
|
|
35
|
+
//#region ../../packages/protocol/src/triage.ts
|
|
36
|
+
/**
|
|
37
|
+
* The verdicts a triage run wrote, read from `<card folder>/feedback/triage.md`.
|
|
38
|
+
*
|
|
39
|
+
* The `nolzu-feedback` skill owns the shape: one block per discussion, blocks split by a blank line,
|
|
40
|
+
* and four lines in each, `T3: fix`, `Summary:`, `Reason:` and `Reply:`. All the blocks or none, the
|
|
41
|
+
* same rule as a review round: a file with one block that does not parse is refused whole, with the
|
|
42
|
+
* line named, because rows half updated from a broken file read as a finished triage. Here and not in
|
|
43
|
+
* the ui package, because the loop applies the file when the run ends and the PRs tab shows the
|
|
44
|
+
* refusal.
|
|
45
|
+
*/
|
|
46
|
+
var TRIAGE_VERDICTS = [
|
|
47
|
+
"fix",
|
|
48
|
+
"reject",
|
|
49
|
+
"clarify",
|
|
50
|
+
"defer",
|
|
51
|
+
"none"
|
|
52
|
+
];
|
|
53
|
+
var FILE = "triage.md";
|
|
54
|
+
var FIELDS = [
|
|
55
|
+
"Summary",
|
|
56
|
+
"Reason",
|
|
57
|
+
"Reply"
|
|
58
|
+
];
|
|
59
|
+
var HEAD = /^(T\d+):[ \t]*(\S*)$/;
|
|
60
|
+
var VERDICTS = "fix, reject, clarify, defer and none";
|
|
61
|
+
var quote = (line) => JSON.stringify(line.length > 60 ? `${line.slice(0, 60)}...` : line);
|
|
62
|
+
function parseTriage(text) {
|
|
63
|
+
const lines = text.replace(/\r\n/g, "\n").split("\n").map((line) => line.replace(/[ \t]+$/, ""));
|
|
64
|
+
const refuse = (problem) => ({
|
|
65
|
+
ok: false,
|
|
66
|
+
problem
|
|
67
|
+
});
|
|
68
|
+
const blocks = [];
|
|
69
|
+
let at = 0;
|
|
70
|
+
while (at < lines.length) {
|
|
71
|
+
if (lines[at] === "") {
|
|
72
|
+
at += 1;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const start = at;
|
|
76
|
+
const chunk = [];
|
|
77
|
+
while (at < lines.length && lines[at] !== "") chunk.push(lines[at++] ?? "");
|
|
78
|
+
for (const [index, line] of chunk.entries()) if (line !== line.trimStart()) return refuse(`Line ${start + index + 1} of ${FILE} is indented. Every line of a block starts at the left margin.`);
|
|
79
|
+
const first = chunk[0] ?? "";
|
|
80
|
+
const head = HEAD.exec(first);
|
|
81
|
+
if (head === null) return refuse(`Line ${start + 1} of ${FILE} is ${quote(first)}, where a block starts with a ref and a verdict, such as "T3: fix".`);
|
|
82
|
+
const ref = head[1] ?? "";
|
|
83
|
+
const verdict = head[2] ?? "";
|
|
84
|
+
if (!TRIAGE_VERDICTS.includes(verdict)) return refuse(`Line ${start + 1} of ${FILE} gives ${ref} the verdict ${quote(verdict)}. The verdicts are ${VERDICTS}.`);
|
|
85
|
+
if (blocks.some((one) => one.ref === ref)) return refuse(`Line ${start + 1} of ${FILE} starts a second block for ${ref}. Each ref has one block.`);
|
|
86
|
+
const values = [];
|
|
87
|
+
for (const [index, field] of FIELDS.entries()) {
|
|
88
|
+
const line = chunk[index + 1];
|
|
89
|
+
const number = start + index + 2;
|
|
90
|
+
if (line === void 0) return refuse(`The block of ${ref} at line ${start + 1} of ${FILE} ends before its ${field}: line. A block holds four lines.`);
|
|
91
|
+
if (!line.startsWith(`${field}:`)) return refuse(`Line ${number} of ${FILE} should start with "${field}:", the ${[
|
|
92
|
+
"second",
|
|
93
|
+
"third",
|
|
94
|
+
"fourth"
|
|
95
|
+
][index]} line of the block of ${ref}.`);
|
|
96
|
+
const value = line.slice(field.length + 1).trim();
|
|
97
|
+
if (value === "" && field !== "Reply") return refuse(`Line ${number} of ${FILE} gives ${ref} no ${field.toLowerCase()}. Summary and Reason each hold one line.`);
|
|
98
|
+
values.push(value);
|
|
99
|
+
}
|
|
100
|
+
if (chunk.length > 4) return refuse(`Line ${start + 5} of ${FILE} is a fifth line in the block of ${ref}. A block holds four lines, and the reply is one paragraph on one line.`);
|
|
101
|
+
blocks.push({
|
|
102
|
+
ref,
|
|
103
|
+
verdict,
|
|
104
|
+
summary: values[0] ?? "",
|
|
105
|
+
reason: values[1] ?? "",
|
|
106
|
+
reply: values[2] || null
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
if (blocks.length === 0) return refuse(`${FILE} is empty, so no verdict was taken from it.`);
|
|
110
|
+
return {
|
|
111
|
+
ok: true,
|
|
112
|
+
blocks
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region ../../packages/core/src/run.ts
|
|
117
|
+
function usageTotal(events) {
|
|
118
|
+
const calls = /* @__PURE__ */ new Map();
|
|
119
|
+
events.forEach((event, at) => {
|
|
120
|
+
if (event.type === "usage") calls.set(event.id ?? at, event.tokens);
|
|
121
|
+
});
|
|
122
|
+
if (calls.size === 0) return null;
|
|
123
|
+
const total = {
|
|
124
|
+
input: 0,
|
|
125
|
+
output: 0,
|
|
126
|
+
cacheRead: 0,
|
|
127
|
+
cacheCreation: 0
|
|
128
|
+
};
|
|
129
|
+
for (const one of calls.values()) {
|
|
130
|
+
total.input += one.input;
|
|
131
|
+
total.output += one.output;
|
|
132
|
+
total.cacheRead += one.cacheRead;
|
|
133
|
+
total.cacheCreation += one.cacheCreation;
|
|
134
|
+
}
|
|
135
|
+
return total;
|
|
136
|
+
}
|
|
137
|
+
function stateAfterRun(events) {
|
|
138
|
+
const has = (type) => events.some((event) => event.type === type);
|
|
139
|
+
if (has("failed")) return "failed";
|
|
140
|
+
if (has("needs_input")) return "blocked";
|
|
141
|
+
return has("complete") ? "ready" : "failed";
|
|
142
|
+
}
|
|
143
|
+
function foldRun(events, stopped = false) {
|
|
144
|
+
let sessionId = null;
|
|
145
|
+
let model = null;
|
|
146
|
+
let costUsd = null;
|
|
147
|
+
let durationMs = null;
|
|
148
|
+
let tokens = null;
|
|
149
|
+
let question = null;
|
|
150
|
+
let failureReason = null;
|
|
151
|
+
let failureStatus = null;
|
|
152
|
+
let retry = null;
|
|
153
|
+
let sessionTotal = false;
|
|
154
|
+
let state = "running";
|
|
155
|
+
let ended = false;
|
|
156
|
+
for (const event of events) switch (event.type) {
|
|
157
|
+
case "session":
|
|
158
|
+
sessionId = event.sessionId;
|
|
159
|
+
model = event.model;
|
|
160
|
+
break;
|
|
161
|
+
case "needs_input":
|
|
162
|
+
question = event.question;
|
|
163
|
+
break;
|
|
164
|
+
case "api_retry":
|
|
165
|
+
retry = {
|
|
166
|
+
attempt: event.attempt,
|
|
167
|
+
delayMs: event.delayMs,
|
|
168
|
+
reason: event.reason,
|
|
169
|
+
...event.until === void 0 ? {} : {
|
|
170
|
+
until: event.until,
|
|
171
|
+
maxRetries: event.maxRetries
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
state = "retrying";
|
|
175
|
+
break;
|
|
176
|
+
case "complete":
|
|
177
|
+
costUsd = event.costUsd;
|
|
178
|
+
sessionTotal = event.sessionTotal === true;
|
|
179
|
+
durationMs = event.durationMs;
|
|
180
|
+
tokens = event.tokens;
|
|
181
|
+
retry = null;
|
|
182
|
+
state = "complete";
|
|
183
|
+
ended = true;
|
|
184
|
+
break;
|
|
185
|
+
case "failed":
|
|
186
|
+
failureReason = event.reason;
|
|
187
|
+
failureStatus = event.status;
|
|
188
|
+
if (event.costUsd !== void 0) {
|
|
189
|
+
costUsd = event.costUsd;
|
|
190
|
+
sessionTotal = event.sessionTotal === true;
|
|
191
|
+
}
|
|
192
|
+
if (event.durationMs !== void 0) durationMs = event.durationMs;
|
|
193
|
+
if (event.tokens !== void 0) tokens = event.tokens;
|
|
194
|
+
retry = null;
|
|
195
|
+
state = "failed";
|
|
196
|
+
ended = true;
|
|
197
|
+
}
|
|
198
|
+
tokens ??= usageTotal(events);
|
|
199
|
+
if (!ended && state !== "retrying") state = "failed";
|
|
200
|
+
const cardState = state === "retrying" ? "running" : stateAfterRun(events);
|
|
201
|
+
if (stopped && !events.some((event) => event.type === "failed" && event.halted === true)) return {
|
|
202
|
+
sessionId,
|
|
203
|
+
model,
|
|
204
|
+
costUsd: null,
|
|
205
|
+
durationMs: null,
|
|
206
|
+
tokens: null,
|
|
207
|
+
question,
|
|
208
|
+
failureReason,
|
|
209
|
+
failureStatus,
|
|
210
|
+
state: "stopped",
|
|
211
|
+
cardState: "idle",
|
|
212
|
+
retry: null
|
|
213
|
+
};
|
|
214
|
+
return {
|
|
215
|
+
sessionId,
|
|
216
|
+
model,
|
|
217
|
+
costUsd,
|
|
218
|
+
durationMs,
|
|
219
|
+
tokens,
|
|
220
|
+
question,
|
|
221
|
+
failureReason,
|
|
222
|
+
failureStatus,
|
|
223
|
+
state,
|
|
224
|
+
cardState,
|
|
225
|
+
retry,
|
|
226
|
+
...sessionTotal ? { costIsSessionTotal: true } : {}
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region ../../packages/core/src/scheduler.ts
|
|
231
|
+
var idOf = (runId, project) => `${project ?? ""}:${runId}`;
|
|
232
|
+
function createScheduler(slots, ports) {
|
|
233
|
+
let state = createQueue(slots);
|
|
234
|
+
const jobs = /* @__PURE__ */ new Map();
|
|
235
|
+
const running = /* @__PURE__ */ new Map();
|
|
236
|
+
const startReady = () => {
|
|
237
|
+
const picked = pick(state);
|
|
238
|
+
state = picked.state;
|
|
239
|
+
for (const entry of picked.started) {
|
|
240
|
+
const id = idOf(entry.runId, entry.project);
|
|
241
|
+
const job = jobs.get(id);
|
|
242
|
+
if (job === void 0) continue;
|
|
243
|
+
const controller = new AbortController();
|
|
244
|
+
running.set(id, controller);
|
|
245
|
+
ports.onChange();
|
|
246
|
+
ports.startJob(job, controller.signal, (event) => ports.onEvent?.(entry.runId, event)).catch(() => void 0).finally(() => {
|
|
247
|
+
running.delete(id);
|
|
248
|
+
jobs.delete(id);
|
|
249
|
+
state = remove(state, entry.runId, entry.project);
|
|
250
|
+
ports.onChange();
|
|
251
|
+
startReady();
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
return {
|
|
256
|
+
queue: () => state,
|
|
257
|
+
add(job) {
|
|
258
|
+
state = enqueue(state, {
|
|
259
|
+
runId: job.runId,
|
|
260
|
+
cardKey: job.cardKey,
|
|
261
|
+
lane: job.lane,
|
|
262
|
+
project: job.project
|
|
263
|
+
});
|
|
264
|
+
jobs.set(idOf(job.runId, job.project), job);
|
|
265
|
+
ports.onChange();
|
|
266
|
+
startReady();
|
|
267
|
+
},
|
|
268
|
+
stop(runId, project) {
|
|
269
|
+
const controller = running.get(idOf(runId, project));
|
|
270
|
+
if (controller !== void 0) {
|
|
271
|
+
if (controller.signal.aborted) return;
|
|
272
|
+
controller.abort();
|
|
273
|
+
ports.onChange();
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (!jobs.delete(idOf(runId, project))) return;
|
|
277
|
+
state = remove(state, runId, project);
|
|
278
|
+
ports.onChange();
|
|
279
|
+
startReady();
|
|
280
|
+
},
|
|
281
|
+
promote(runId, project) {
|
|
282
|
+
state = promote(state, runId, project);
|
|
283
|
+
ports.onChange();
|
|
284
|
+
},
|
|
285
|
+
resize(slots) {
|
|
286
|
+
state = {
|
|
287
|
+
...state,
|
|
288
|
+
slots
|
|
289
|
+
};
|
|
290
|
+
ports.onChange();
|
|
291
|
+
startReady();
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
//#endregion
|
|
296
|
+
//#region ../../packages/core/src/summary.ts
|
|
297
|
+
var HEADING = /^\s*#*\s*what changed, in plain words\s*$/i;
|
|
298
|
+
function cleanSummary(text) {
|
|
299
|
+
const lines = text.split("\n");
|
|
300
|
+
const first = lines.findIndex((line) => line.trim() !== "");
|
|
301
|
+
if (first !== -1 && HEADING.test(lines[first])) lines.splice(first, 1);
|
|
302
|
+
return lines.join("\n").trim();
|
|
303
|
+
}
|
|
304
|
+
function needsExtraction(text) {
|
|
305
|
+
return text === null || text.trim() === "";
|
|
306
|
+
}
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region ../../packages/core/src/repositories-line.ts
|
|
309
|
+
var LINE = /^(?:[-+>]\s*|\*\s+)*[*_]*repositories[*_]*:[*_]*(.*)$/i;
|
|
310
|
+
/**
|
|
311
|
+
* The repositories a refine or plan run named for its card, from the line that ends its file.
|
|
312
|
+
*
|
|
313
|
+
* The last `Repositories: a, b` line counts, because plan can quote refine's line and then give its
|
|
314
|
+
* own. A name matches the project's path whatever its case, and comes back in the project's
|
|
315
|
+
* spelling. Names the project does not list come back apart, so the caller can drop them and say
|
|
316
|
+
* which. Null when there is no such line, which means the run named nothing.
|
|
317
|
+
*/
|
|
318
|
+
function repositoriesLine(text, known) {
|
|
319
|
+
const last = text.split("\n").map((line) => LINE.exec(line.trim())?.[1]).filter((rest) => rest !== void 0).at(-1);
|
|
320
|
+
if (last === void 0) return null;
|
|
321
|
+
const names = last.split(",").map((name) => name.trim().replace(/^`(.*)`$/, "$1").trim()).map((name) => name.length > 1 ? name.replace(/\/+$/, "") : name).filter((name) => name !== "").map((name) => known.find((path) => path.toLowerCase() === name.toLowerCase()) ?? name);
|
|
322
|
+
const unique = [...new Set(names)];
|
|
323
|
+
return {
|
|
324
|
+
known: unique.filter((name) => known.includes(name)),
|
|
325
|
+
unknown: unique.filter((name) => !known.includes(name))
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region ../../packages/runner/src/awake.ts
|
|
330
|
+
function keepAwakeCommand(platform, has, pid) {
|
|
331
|
+
if (platform === "darwin") return ["caffeinate", [
|
|
332
|
+
"-i",
|
|
333
|
+
"-w",
|
|
334
|
+
String(pid)
|
|
335
|
+
]];
|
|
336
|
+
if (platform === "linux" && has("systemd-inhibit")) return ["systemd-inhibit", [
|
|
337
|
+
"--what=idle",
|
|
338
|
+
"--who=Nolzu",
|
|
339
|
+
"--why=An agent run is going",
|
|
340
|
+
"sh",
|
|
341
|
+
"-c",
|
|
342
|
+
"while kill -0 \"$1\" 2>/dev/null; do sleep 15; done",
|
|
343
|
+
"nolzu",
|
|
344
|
+
String(pid)
|
|
345
|
+
]];
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
function holdAwake(deps) {
|
|
349
|
+
const command = keepAwakeCommand(deps.platform, deps.has, deps.pid);
|
|
350
|
+
if (command === null) return () => void 0;
|
|
351
|
+
let helper = null;
|
|
352
|
+
try {
|
|
353
|
+
helper = deps.spawn(command[0], command[1]);
|
|
354
|
+
} catch {
|
|
355
|
+
return () => void 0;
|
|
356
|
+
}
|
|
357
|
+
return () => {
|
|
358
|
+
helper?.kill();
|
|
359
|
+
helper = null;
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
var systemAwake = (env) => ({
|
|
363
|
+
platform: process.platform,
|
|
364
|
+
has: (name) => findExecutable(name, env.PATH ?? "") !== null,
|
|
365
|
+
pid: process.pid,
|
|
366
|
+
spawn: (command, args) => {
|
|
367
|
+
const child = spawn(command, args, { stdio: "ignore" });
|
|
368
|
+
child.on("error", () => void 0);
|
|
369
|
+
return { kill: () => child.kill() };
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
//#endregion
|
|
373
|
+
//#region ../../packages/runner/src/process-start.ts
|
|
374
|
+
function processStart(pid) {
|
|
375
|
+
try {
|
|
376
|
+
const said = execFileSync("ps", [
|
|
377
|
+
"-o",
|
|
378
|
+
"lstart=",
|
|
379
|
+
"-p",
|
|
380
|
+
String(pid)
|
|
381
|
+
], {
|
|
382
|
+
encoding: "utf8",
|
|
383
|
+
env: {
|
|
384
|
+
...process.env,
|
|
385
|
+
LC_ALL: "C"
|
|
386
|
+
},
|
|
387
|
+
stdio: [
|
|
388
|
+
"ignore",
|
|
389
|
+
"pipe",
|
|
390
|
+
"ignore"
|
|
391
|
+
]
|
|
392
|
+
}).trim();
|
|
393
|
+
const at = Date.parse(said);
|
|
394
|
+
return Number.isNaN(at) ? null : at;
|
|
395
|
+
} catch {
|
|
396
|
+
return null;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region ../../packages/skills/src/instructions.ts
|
|
401
|
+
var FRONTMATTER = /^---\r?\n[\s\S]*?\r?\n---\r?\n/;
|
|
402
|
+
var LINK = /\]\(([\w.-]+\.md)\)/g;
|
|
403
|
+
var PLAIN = /^[a-z][a-z0-9-]*$/;
|
|
404
|
+
/**
|
|
405
|
+
* The phase instructions a run is handed as a file, on every engine.
|
|
406
|
+
*
|
|
407
|
+
* Built from the skill that owns the phase, every time a run starts, so there is no second copy
|
|
408
|
+
* to keep in step: a change to the skill is in the next run's text. The files the skill links to
|
|
409
|
+
* are read from the same folder and copied in, because a relative link means nothing to an engine
|
|
410
|
+
* that was handed one file.
|
|
411
|
+
*
|
|
412
|
+
* `own` answers with the person's text of a file in the skill folder and the project folder it came
|
|
413
|
+
* from, such as `.agents/skills`, or null when the project has no edit of it. It is handed the text
|
|
414
|
+
* Nolzu ships, so it can tell an edit from a copy. A file it answers for wins over the shipped one,
|
|
415
|
+
* and every other file comes from the package.
|
|
416
|
+
*
|
|
417
|
+
* Null when no skill owns the phase. The summary pass is the one such pass, and its prompt
|
|
418
|
+
* already carries the rules it follows.
|
|
419
|
+
*/
|
|
420
|
+
function phaseInstructions(phase, own) {
|
|
421
|
+
if (!PLAIN.test(phase)) return null;
|
|
422
|
+
const folder = join(skillsFolder(), `nolzu-${phase}`);
|
|
423
|
+
if (!existsSync(join(folder, "SKILL.md"))) return null;
|
|
424
|
+
const from = /* @__PURE__ */ new Set();
|
|
425
|
+
const read = (name) => {
|
|
426
|
+
const shipped = existsSync(join(folder, name)) ? readFileSync(join(folder, name), "utf8") : null;
|
|
427
|
+
const theirs = own?.(name, shipped) ?? null;
|
|
428
|
+
if (theirs !== null) from.add(`${theirs.folder}/nolzu-${phase}`);
|
|
429
|
+
return theirs?.text ?? shipped;
|
|
430
|
+
};
|
|
431
|
+
const body = (read("SKILL.md") ?? "").replace(FRONTMATTER, "").trim();
|
|
432
|
+
const linked = [...new Set([...body.matchAll(LINK)].flatMap(([, name]) => name ?? []))].flatMap((name) => {
|
|
433
|
+
const text = read(name);
|
|
434
|
+
return text === null ? [] : [{
|
|
435
|
+
name,
|
|
436
|
+
text
|
|
437
|
+
}];
|
|
438
|
+
});
|
|
439
|
+
return `${[
|
|
440
|
+
`These are the instructions for the ${phase} phase of this run. Follow them.`,
|
|
441
|
+
...from.size > 0 ? [`They come from this project's own copy in ${[...from].join(" and ")}, which someone changed, and not from the one Nolzu ships.`] : [],
|
|
442
|
+
"The files they link to are copied in at the end, each under its own name.",
|
|
443
|
+
body,
|
|
444
|
+
...linked.flatMap(({ name, text }) => [
|
|
445
|
+
"---",
|
|
446
|
+
`Linked file: ${name}`,
|
|
447
|
+
text.trim()
|
|
448
|
+
])
|
|
449
|
+
].join("\n\n")}\n`;
|
|
450
|
+
}
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region src/lib/engine-limits.ts
|
|
453
|
+
var WINDOW = {
|
|
454
|
+
five_hour: "5-hour window",
|
|
455
|
+
seven_day: "weekly window"
|
|
456
|
+
};
|
|
457
|
+
var LAST_SEEN = "The number is the last one seen and not a live one. It covers the whole account, so a run on another device moves it too.";
|
|
458
|
+
function when(ms, timeZone) {
|
|
459
|
+
return new Intl.DateTimeFormat("en-GB", {
|
|
460
|
+
timeZone,
|
|
461
|
+
day: "2-digit",
|
|
462
|
+
month: "short",
|
|
463
|
+
year: "numeric",
|
|
464
|
+
hour: "2-digit",
|
|
465
|
+
minute: "2-digit",
|
|
466
|
+
hour12: false
|
|
467
|
+
}).format(new Date(ms));
|
|
468
|
+
}
|
|
469
|
+
function line(window, timeZone) {
|
|
470
|
+
const used = window.used === null ? "share not reported" : `${Math.round(window.used * 100)}% used`;
|
|
471
|
+
const resets = window.resetsAt === null ? "no reset time reported" : `resets ${when(window.resetsAt * 1e3, timeZone)}`;
|
|
472
|
+
return `${WINDOW[window.name] ?? window.name}: ${used}, ${resets}`;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* The limit block for one profile, from what its engine last reported.
|
|
476
|
+
*
|
|
477
|
+
* The time the numbers were seen comes from the stored reading and never from the clock, so the
|
|
478
|
+
* block says the same thing tomorrow as it says today. Nothing here asks a vendor anything: the
|
|
479
|
+
* numbers come from what the CLI printed in its own run, which is the rule in `PROJECT.md`.
|
|
480
|
+
*/
|
|
481
|
+
function limitBlock(vendor, seen, timeZone) {
|
|
482
|
+
const signal = LIMIT_SIGNAL[vendor];
|
|
483
|
+
if (signal.knownSilent) return {
|
|
484
|
+
state: "unavailable",
|
|
485
|
+
headline: "Not available for this engine.",
|
|
486
|
+
windows: [],
|
|
487
|
+
shares: [],
|
|
488
|
+
note: signal.note
|
|
489
|
+
};
|
|
490
|
+
if (seen === void 0 || seen.windows.length === 0) return {
|
|
491
|
+
state: "unknown",
|
|
492
|
+
headline: "Unknown. No usage window has been seen for this profile.",
|
|
493
|
+
windows: [],
|
|
494
|
+
shares: [],
|
|
495
|
+
note: signal.note
|
|
496
|
+
};
|
|
497
|
+
const windows = seen.windows.map((window) => line(window, timeZone));
|
|
498
|
+
const shares = seen.windows.map((window) => window.used === null ? null : Math.round(window.used * 100));
|
|
499
|
+
const full = seen.windows.filter(atLimit);
|
|
500
|
+
const at = when(seen.seenAt, timeZone);
|
|
501
|
+
if (full.length === 0) return {
|
|
502
|
+
state: "share",
|
|
503
|
+
headline: `Seen ${at}.`,
|
|
504
|
+
windows,
|
|
505
|
+
shares,
|
|
506
|
+
note: LAST_SEEN
|
|
507
|
+
};
|
|
508
|
+
const resets = full.map((window) => window.resetsAt);
|
|
509
|
+
if (resets.some((reset) => reset === null)) return {
|
|
510
|
+
state: "open",
|
|
511
|
+
headline: `At its limit. The engine reported no reset time. Seen ${at}.`,
|
|
512
|
+
windows,
|
|
513
|
+
shares,
|
|
514
|
+
note: LAST_SEEN
|
|
515
|
+
};
|
|
516
|
+
return {
|
|
517
|
+
state: "until",
|
|
518
|
+
headline: `At its limit until ${when(Math.max(...resets) * 1e3, timeZone)}. Seen ${at}.`,
|
|
519
|
+
windows,
|
|
520
|
+
shares,
|
|
521
|
+
note: LAST_SEEN
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Keeps what a run's engine reported about one profile's usage windows.
|
|
526
|
+
*
|
|
527
|
+
* The time is passed in rather than read here, so the reading carries the moment the run read the
|
|
528
|
+
* line and not the moment the row was written. The last reading wins: the block says the last one
|
|
529
|
+
* seen, and an older reading is of no use next to a newer one.
|
|
530
|
+
*/
|
|
531
|
+
function saveLimit(db, profile, windows, seenAt, card) {
|
|
532
|
+
const stored = getSetting(db, "engineLimits");
|
|
533
|
+
if (JSON.stringify(stored[profile]?.windows) === JSON.stringify(windows)) return;
|
|
534
|
+
writeSetting(db, "engineLimits", {
|
|
535
|
+
...stored,
|
|
536
|
+
[profile]: {
|
|
537
|
+
seenAt,
|
|
538
|
+
windows,
|
|
539
|
+
...card === void 0 ? {} : { card }
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
for (const window of windows) {
|
|
543
|
+
if (WINDOW[window.name] === void 0 || window.used === null || window.used < .9 || window.resetsAt !== null && window.resetsAt * 1e3 <= seenAt) continue;
|
|
544
|
+
const before = stored[profile]?.windows.find((one) => one.name === window.name);
|
|
545
|
+
if (window.resetsAt === null && before?.resetsAt === null && before.used !== null && before.used >= .9) continue;
|
|
546
|
+
addNotification(db, {
|
|
547
|
+
id: `near:${profile}:${window.name}:${window.resetsAt ?? seenAt}`,
|
|
548
|
+
kind: "warning",
|
|
549
|
+
text: `${profileName(profile)}, ${line(window)}`,
|
|
550
|
+
card: card ?? null,
|
|
551
|
+
href: "/settings/engines"
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function keepLimitsOf(db, ids) {
|
|
556
|
+
const stored = getSetting(db, "engineLimits");
|
|
557
|
+
const left = Object.entries(stored).filter(([id]) => ids.includes(id));
|
|
558
|
+
if (left.length !== Object.keys(stored).length) writeSetting(db, "engineLimits", Object.fromEntries(left));
|
|
559
|
+
}
|
|
560
|
+
//#endregion
|
|
561
|
+
//#region src/lib/feedback.ts
|
|
562
|
+
/**
|
|
563
|
+
* The files of a triage run (`feedback`). Nolzu reads GitHub itself, so the run needs no GitHub
|
|
564
|
+
* access: the comments go into the card folder before the run starts, the way the review diff
|
|
565
|
+
* does, and the verdicts come back as a file the loop applies when the run ends. Comment text
|
|
566
|
+
* stays on this machine: these files sit in the card folder, and nothing here reaches the snapshot
|
|
567
|
+
* or the hub.
|
|
568
|
+
*/
|
|
569
|
+
var DISCUSSIONS_FILE = join("feedback", "discussions.md");
|
|
570
|
+
var TRIAGE_FILE = join("feedback", "triage.md");
|
|
571
|
+
var FIXES_FILE = join("feedback", "fixes.md");
|
|
572
|
+
var THREAD_BUDGET = 8e3;
|
|
573
|
+
var CONTEXT_BUDGET = 6e3;
|
|
574
|
+
var CONTEXT_FILES = [
|
|
575
|
+
join("plan", "plan.md"),
|
|
576
|
+
join("refine", "refined.md"),
|
|
577
|
+
join("implement", "pr.md")
|
|
578
|
+
];
|
|
579
|
+
var isOpen = (row) => row.status !== "done";
|
|
580
|
+
function keptMessages(messages, budget = THREAD_BUDGET) {
|
|
581
|
+
let used = 0;
|
|
582
|
+
let from = messages.length;
|
|
583
|
+
while (from > 0) {
|
|
584
|
+
const size = messages[from - 1]?.body.length ?? 0;
|
|
585
|
+
if (from < messages.length && used + size > budget) break;
|
|
586
|
+
used += size;
|
|
587
|
+
from -= 1;
|
|
588
|
+
}
|
|
589
|
+
return {
|
|
590
|
+
kept: messages.slice(from),
|
|
591
|
+
cut: from
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
var quoted = (body) => body.trim().split("\n").map((line) => `> ${line}`.trimEnd()).join("\n");
|
|
595
|
+
/** The comments file itself, from the card's open discussions, its pull requests and its context. */
|
|
596
|
+
function discussionsFile(input) {
|
|
597
|
+
const parts = [`# Open discussions on ${input.key}: ${input.title}`];
|
|
598
|
+
if (input.context === null) parts.push("The card has no plan or brief in its folder, so judge each comment against the code alone.");
|
|
599
|
+
else {
|
|
600
|
+
const text = input.context.text.trim();
|
|
601
|
+
const cut = text.length > CONTEXT_BUDGET;
|
|
602
|
+
parts.push(`## What the change is for\n\nFrom ${input.context.file}${cut ? `, its first ${CONTEXT_BUDGET} characters` : ""}:\n\n${quoted(cut ? text.slice(0, CONTEXT_BUDGET) : text)}`);
|
|
603
|
+
}
|
|
604
|
+
for (const row of input.discussions.filter(isOpen)) {
|
|
605
|
+
const pull = input.pulls.find((one) => one.id === row.pull);
|
|
606
|
+
const where = row.path === null ? "" : ` on ${row.path}${row.line === null ? "" : `:${row.line}`}`;
|
|
607
|
+
const facts = [
|
|
608
|
+
`Kind: ${row.kind === "thread" ? "review thread" : row.kind === "review" ? "review's own text" : "comment"}${where}`,
|
|
609
|
+
...pull === void 0 ? [] : [`Pull request: ${pull.repo}#${pull.number}`],
|
|
610
|
+
`Status: ${row.status}`,
|
|
611
|
+
...row.outdated ? ["Outdated: the line has changed since the comment."] : [],
|
|
612
|
+
...row.verdict === null ? [] : [`Earlier verdict: ${row.verdict}`],
|
|
613
|
+
...row.summary === null ? [] : [`Earlier summary: ${row.summary}`],
|
|
614
|
+
...row.reason === null ? [] : [`Earlier reason: ${row.reason}`],
|
|
615
|
+
...row.fixNote === null ? [] : [`Fix note: ${row.fixNote}`]
|
|
616
|
+
];
|
|
617
|
+
const { kept, cut } = keptMessages(row.messages);
|
|
618
|
+
const messages = kept.map((one) => `${one.author ?? "Deleted account"}${one.mine ? " (the person's own)" : ""}, ${one.createdAt}:\n${quoted(one.body)}`);
|
|
619
|
+
const said = cut === 0 ? [] : [`${cut} older ${cut === 1 ? "message was" : "messages were"} cut to keep this file short. The newest ${kept.length} follow.`];
|
|
620
|
+
parts.push([
|
|
621
|
+
`## ${row.ref}`,
|
|
622
|
+
facts.join("\n"),
|
|
623
|
+
...said,
|
|
624
|
+
...messages
|
|
625
|
+
].join("\n\n"));
|
|
626
|
+
}
|
|
627
|
+
return `${parts.join("\n\n")}\n`;
|
|
628
|
+
}
|
|
629
|
+
function discussionBlock(row, pull) {
|
|
630
|
+
const where = row.path === null ? "" : `, on ${row.path}${row.line === null ? "" : `:${row.line}`}`;
|
|
631
|
+
const kind = row.kind === "thread" ? "A review thread" : row.kind === "review" ? "A review's own text" : "A comment";
|
|
632
|
+
const facts = [
|
|
633
|
+
`${row.ref}: ${kind}${pull === void 0 ? "" : ` on ${pull.repo}#${pull.number}`}${where}.`,
|
|
634
|
+
...row.outdated ? ["The line has changed since the comment, so look for the code it was about."] : [],
|
|
635
|
+
...row.verdict === null ? [] : [`Triage verdict: ${row.verdict}`],
|
|
636
|
+
...row.summary === null ? [] : [`Triage summary: ${row.summary}`],
|
|
637
|
+
...row.reason === null ? [] : [`Triage reason: ${row.reason}`],
|
|
638
|
+
...row.fixNote === null ? [] : [`An earlier fix said: ${row.fixNote}`],
|
|
639
|
+
...row.fixFailed === null ? [] : [`Why the last fix did not hold: ${row.fixFailed}`]
|
|
640
|
+
];
|
|
641
|
+
const messages = row.messages.map((one) => `${one.author ?? "Deleted account"}${one.mine ? " (the person's own)" : ""}, ${one.createdAt}:\n${quoted(one.body)}`);
|
|
642
|
+
return [facts.join("\n"), ...messages].join("\n\n");
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* What a Fix tells the card's Implement session: the discussion with every message and its triage, to
|
|
646
|
+
* change the code for it, and the three things a fix never does. The comment text stays on this
|
|
647
|
+
* machine: it goes to the local engine as the run's message and nowhere else.
|
|
648
|
+
*/
|
|
649
|
+
function fixFeedbackMessage(row, pull) {
|
|
650
|
+
return [
|
|
651
|
+
`A reviewer left this on the pull request of your change. Change the code so it answers it. If you find the reviewer is wrong, change nothing and say why in your summary.`,
|
|
652
|
+
discussionBlock(row, pull),
|
|
653
|
+
"Do not commit, do not push and do not reply on GitHub. The person reads your change on the Changes tab, commits and pushes it, and answers the reviewer. Then finish the way the implement skill says."
|
|
654
|
+
].join("\n\n");
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* What Fix all tells the card's Implement session: every discussion triage wants fixed, to change the
|
|
658
|
+
* code for each, and the file that says what happened to each one, because one plain summary cannot
|
|
659
|
+
* be split across several rows.
|
|
660
|
+
*/
|
|
661
|
+
function fixAllMessage(rows, pulls) {
|
|
662
|
+
const example = rows[0]?.ref ?? "T1";
|
|
663
|
+
return [
|
|
664
|
+
`Reviewers left these ${rows.length === 1 ? "comment" : `${rows.length} comments`} on the pull request of your change. Change the code so it answers each of them. If you find a reviewer is wrong, change nothing for that comment and say why on its line in the file below.`,
|
|
665
|
+
...rows.map((row) => discussionBlock(row, pulls.find((one) => one.id === row.pull))),
|
|
666
|
+
`When you are done, write \`<card folder>/feedback/fixes.md\` with one line per comment and nothing else: its ref, a colon, and what you changed or why you changed nothing, such as \`${example}: The search lower-cases both sides now.\``,
|
|
667
|
+
"Do not commit, do not push and do not reply on GitHub. The person reads your change on the Changes tab, commits and pushes it, and answers the reviewers. Then finish the way the implement skill says."
|
|
668
|
+
].join("\n\n");
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* The notes of a Fix all run by ref, from the file it wrote, or null when it wrote none. A line that
|
|
672
|
+
* is no `T<n>: note` is skipped, and the first line of a ref wins.
|
|
673
|
+
*/
|
|
674
|
+
function readFixNotes(taskDir) {
|
|
675
|
+
const text = readCardText(taskDir, FIXES_FILE);
|
|
676
|
+
if (text === null) return null;
|
|
677
|
+
const notes = /* @__PURE__ */ new Map();
|
|
678
|
+
for (const line of text.split(/\r?\n/)) {
|
|
679
|
+
const found = /^\s*(?:[-*]\s+)?`?(T\d+)`?\s*:\s*(.*\S)\s*$/.exec(line);
|
|
680
|
+
if (found !== null && !notes.has(found[1] ?? "")) notes.set(found[1] ?? "", found[2] ?? "");
|
|
681
|
+
}
|
|
682
|
+
return notes;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* The first message of a Discuss thread: the discussion and its triage, so the read-only session the
|
|
686
|
+
* person's first question starts knows what it is about. Nothing it answers changes the row.
|
|
687
|
+
*/
|
|
688
|
+
function discussMessage(row, pull) {
|
|
689
|
+
return [`I want to talk about this comment on the pull request. Read the code it is about. Change nothing.`, discussionBlock(row, pull)].join("\n\n");
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Discuss on a row of the PRs tab: the thread under its ref, opened with `discussMessage` the first
|
|
693
|
+
* time and left as it is after that. No run starts here; the person's first message starts the
|
|
694
|
+
* read-only session, as in an Ask discussion. Answers the thread, or the sentence it was refused with.
|
|
695
|
+
*/
|
|
696
|
+
function openDiscussion(db, key, ref) {
|
|
697
|
+
const row = isFeedbackRef(ref) ? cardDiscussions(db, key).find((one) => one.ref === ref) : void 0;
|
|
698
|
+
if (row === void 0) return {
|
|
699
|
+
ok: false,
|
|
700
|
+
reason: `${key} has no comment ${ref}. Read the comments again.`
|
|
701
|
+
};
|
|
702
|
+
if (messagesIn(db, key, ref).length === 0) addMessage(db, key, ref, "person", discussMessage(row, cardPullRows(db, key).find((one) => one.id === row.pull)), null);
|
|
703
|
+
return {
|
|
704
|
+
ok: true,
|
|
705
|
+
thread: ref
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Writes the comments file into the card folder before a triage run and takes away the triage file
|
|
710
|
+
* an earlier run left, so a run that writes none applies nothing old. Answers how many discussions
|
|
711
|
+
* went in, and throws when there are none, so no engine starts on an empty file.
|
|
712
|
+
*/
|
|
713
|
+
function writeFeedbackFile(db, key, title, taskDir) {
|
|
714
|
+
const discussions = cardDiscussions(db, key);
|
|
715
|
+
const open = discussions.filter(isOpen).length;
|
|
716
|
+
if (open === 0) throw new Error(`${key} has no open discussion to triage. Read comments on its PRs tab first, or reopen one.`);
|
|
717
|
+
const found = CONTEXT_FILES.map((file) => ({
|
|
718
|
+
file,
|
|
719
|
+
text: readCardText(taskDir, file)
|
|
720
|
+
})).find((one) => one.text !== null);
|
|
721
|
+
const context = found === void 0 ? null : {
|
|
722
|
+
file: found.file,
|
|
723
|
+
text: found.text ?? ""
|
|
724
|
+
};
|
|
725
|
+
removeCardFile(taskDir, TRIAGE_FILE);
|
|
726
|
+
writeCardFile(taskDir, DISCUSSIONS_FILE, discussionsFile({
|
|
727
|
+
key,
|
|
728
|
+
title,
|
|
729
|
+
context,
|
|
730
|
+
pulls: cardPullRows(db, key),
|
|
731
|
+
discussions
|
|
732
|
+
}));
|
|
733
|
+
return open;
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Applies the triage file in the card folder to the card's rows, or answers why it did not. The file
|
|
737
|
+
* is taken whole or not at all, so a refusal changes no row.
|
|
738
|
+
*/
|
|
739
|
+
function applyTriageFile(db, key, taskDir) {
|
|
740
|
+
const text = readCardText(taskDir, TRIAGE_FILE);
|
|
741
|
+
if (text === null) return {
|
|
742
|
+
ok: false,
|
|
743
|
+
problem: "The triage run wrote no triage.md, so no row has a verdict from it."
|
|
744
|
+
};
|
|
745
|
+
const read = parseTriage(text);
|
|
746
|
+
if (!read.ok) return read;
|
|
747
|
+
return {
|
|
748
|
+
ok: true,
|
|
749
|
+
...applyTriage(db, key, read.blocks)
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
/** The sentence the PRs tab shows when the triage file in the card folder does not parse, or null. */
|
|
753
|
+
function triageProblem(taskDir) {
|
|
754
|
+
const text = readCardText(taskDir, TRIAGE_FILE);
|
|
755
|
+
if (text === null) return null;
|
|
756
|
+
const read = parseTriage(text);
|
|
757
|
+
return read.ok ? null : `${read.problem} Each row keeps the verdict it had before.`;
|
|
758
|
+
}
|
|
759
|
+
/** What the Run triage button on the PRs tab says before the press: the model, the cost and any refusal. */
|
|
760
|
+
function triageOfferFor(db, key, models) {
|
|
761
|
+
const profiles = projectProfiles(db);
|
|
762
|
+
const row = resolveModels(cardModels(db, key), cardBase(db, key), cardPreset(db, key), models, profiles).feedback;
|
|
763
|
+
const refusal = row.missingProfile ? missingProfileText(row.engine) : row.refusal ?? (row.gone ? goneText(row.model) : null);
|
|
764
|
+
const folder = cardFolder(db, key);
|
|
765
|
+
const state = db.prepare("SELECT state FROM cards WHERE key = ?").get(key)?.state;
|
|
766
|
+
const ended = state !== "queued" && state !== "running" && state !== "blocked";
|
|
767
|
+
return {
|
|
768
|
+
starts: {
|
|
769
|
+
engine: row.engine,
|
|
770
|
+
model: row.model,
|
|
771
|
+
effort: row.effort,
|
|
772
|
+
...profiles.length > 1 ? { severalProfiles: true } : {}
|
|
773
|
+
},
|
|
774
|
+
estimate: measured(db, "feedback", row, profiles),
|
|
775
|
+
refusal,
|
|
776
|
+
problem: folder === null || !ended ? null : triageProblem(folder)
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
//#endregion
|
|
780
|
+
//#region src/lib/fix-check.ts
|
|
781
|
+
var out = async (args, cwd, env) => {
|
|
782
|
+
const result = await git(args, {
|
|
783
|
+
cwd,
|
|
784
|
+
env
|
|
785
|
+
});
|
|
786
|
+
return result.code === 0 ? result.stdout.trim() : null;
|
|
787
|
+
};
|
|
788
|
+
async function readOne(checkout, env) {
|
|
789
|
+
const { repo, path } = checkout;
|
|
790
|
+
if (!existsSync(path)) return {
|
|
791
|
+
repo,
|
|
792
|
+
problem: `there is no checkout at ${path}`
|
|
793
|
+
};
|
|
794
|
+
const top = await out(["rev-parse", "--show-toplevel"], path, env);
|
|
795
|
+
if (top === null || realpathSync(top) !== realpathSync(path)) return {
|
|
796
|
+
repo,
|
|
797
|
+
problem: `${path} is not a git checkout`
|
|
798
|
+
};
|
|
799
|
+
const head = await out([
|
|
800
|
+
"rev-parse",
|
|
801
|
+
"-q",
|
|
802
|
+
"--verify",
|
|
803
|
+
"HEAD^{commit}"
|
|
804
|
+
], path, env);
|
|
805
|
+
if (head === null || head === "") return {
|
|
806
|
+
repo,
|
|
807
|
+
problem: `git could not read HEAD in ${path}`
|
|
808
|
+
};
|
|
809
|
+
const ref = await out([
|
|
810
|
+
"rev-parse",
|
|
811
|
+
"--symbolic-full-name",
|
|
812
|
+
"@{upstream}"
|
|
813
|
+
], path, env);
|
|
814
|
+
if (ref === null || ref === "") return {
|
|
815
|
+
repo,
|
|
816
|
+
head,
|
|
817
|
+
upstream: null
|
|
818
|
+
};
|
|
819
|
+
return {
|
|
820
|
+
repo,
|
|
821
|
+
head,
|
|
822
|
+
upstream: {
|
|
823
|
+
ref,
|
|
824
|
+
commit: await out([
|
|
825
|
+
"rev-parse",
|
|
826
|
+
"-q",
|
|
827
|
+
"--verify",
|
|
828
|
+
`${ref}^{commit}`
|
|
829
|
+
], path, env) || null
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
var readHeads = (checkouts, env) => Promise.all(checkouts.map((one) => readOne(one, env)));
|
|
834
|
+
var named = (repo) => repo === "." ? "the card checkout" : repo;
|
|
835
|
+
var short = (sha) => sha === null ? "nothing" : sha.slice(0, 7);
|
|
836
|
+
/** The sentences for every checkout a run committed or pushed in, or could not be read, or null. */
|
|
837
|
+
function runMoved(before, after, run) {
|
|
838
|
+
const said = [];
|
|
839
|
+
for (const start of before) {
|
|
840
|
+
const end = after.find((one) => one.repo === start.repo) ?? {
|
|
841
|
+
repo: start.repo,
|
|
842
|
+
problem: "it was not read"
|
|
843
|
+
};
|
|
844
|
+
const where = named(start.repo);
|
|
845
|
+
if ("problem" in start || "problem" in end) {
|
|
846
|
+
const when = "problem" in start ? "started" : "ended";
|
|
847
|
+
const why = "problem" in start ? start.problem : end.problem;
|
|
848
|
+
said.push(`Nolzu could not read ${where} when the ${run} run ${when} (${why}), so it cannot tell whether the run made a commit or pushed. Look at git log in the checkout before you commit from Changes.`);
|
|
849
|
+
continue;
|
|
850
|
+
}
|
|
851
|
+
if (start.head !== end.head) said.push(`The ${run} run made a commit in ${where} (${short(start.head)} to ${short(end.head)}). Nolzu does not commit for you. Look at git log in the checkout, keep or undo it, then commit from Changes.`);
|
|
852
|
+
const from = start.upstream?.commit ?? null;
|
|
853
|
+
const to = end.upstream?.commit ?? null;
|
|
854
|
+
if (from !== to) {
|
|
855
|
+
const ref = (end.upstream ?? start.upstream)?.ref.replace(/^refs\/remotes\//, "") ?? "its upstream";
|
|
856
|
+
said.push(`The ${run} run pushed from ${where} (${ref} ${short(from)} to ${short(to)}). Nolzu does not push for you. Look at ${run === "fix" ? "the pull request" : "the branch on GitHub"} and decide whether that push stays.`);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
return said.length === 0 ? null : said.join(" ");
|
|
860
|
+
}
|
|
861
|
+
//#endregion
|
|
862
|
+
//#region src/lib/fix-it.ts
|
|
863
|
+
/**
|
|
864
|
+
* What Fix it tells the Implement run, as the message of its resumed session or after the card in a
|
|
865
|
+
* fresh prompt. Paths are named from the card folder, which both already know, so no path on this
|
|
866
|
+
* machine reaches the engine.
|
|
867
|
+
*
|
|
868
|
+
* The qa skill starts a screenshot's name with its check's number, so the screenshot of a failed
|
|
869
|
+
* check is the one Fix it names. A run since the evidence rules saves them in `qa/evidence/`, an older
|
|
870
|
+
* one in `qa/`. A name with no number, such as one from a skill copy that predates the rule, cannot be
|
|
871
|
+
* matched, so then every screenshot is named.
|
|
872
|
+
*/
|
|
873
|
+
function fixMessage(input) {
|
|
874
|
+
const failed = ((input.report === null ? null : parseQaChecklist(input.report))?.rows ?? []).flatMap((row, at) => row.result === "fail" ? [{
|
|
875
|
+
number: at + 1,
|
|
876
|
+
...row
|
|
877
|
+
}] : []);
|
|
878
|
+
const own = input.shots.filter((path) => failed.some((row) => (path.split("/").pop() ?? "").startsWith(`${row.number}-`)));
|
|
879
|
+
const shots = own.length > 0 ? own : input.shots;
|
|
880
|
+
const named = shots.map((path) => `\`${path}\``).join(", ");
|
|
881
|
+
const under = (row) => Object.entries({
|
|
882
|
+
Reason: row.reason,
|
|
883
|
+
Expected: row.expected,
|
|
884
|
+
Actual: row.actual,
|
|
885
|
+
Evidence: row.evidence
|
|
886
|
+
}).map(([label, value]) => value == null ? "" : `\n ${label}: ${value}`).join("");
|
|
887
|
+
return [
|
|
888
|
+
"QA failed this card, and the person asked you to fix it. Fix what QA found, then finish the way the implement skill says. QA runs again after this run ends.",
|
|
889
|
+
input.reason === null ? "QA gave no reason." : `QA said: ${input.reason}`,
|
|
890
|
+
failed.length === 0 ? "" : ["The checks that failed:", ...failed.map((row) => `${row.number}. ${row.ac === void 0 ? "" : `${row.ac}: `}${row.step}${under(row)}`)].join("\n"),
|
|
891
|
+
shots.length === 0 ? "" : own.length > 0 ? `The screenshot of the failed check is in the card folder: ${named}. Open it to see what QA saw.` : `QA took these screenshots, in the card folder: ${named}. Open the one of the failed check to see what QA saw.`,
|
|
892
|
+
input.report === null ? "" : "QA's whole report is `qa/report.md` in the card folder."
|
|
893
|
+
].filter((block) => block !== "").join("\n\n");
|
|
894
|
+
}
|
|
895
|
+
//#endregion
|
|
896
|
+
//#region src/lib/qa-fixes.ts
|
|
897
|
+
/**
|
|
898
|
+
* QA the fixes on a Delivery card's PRs tab: a QA run over what the fixes for review comments changed,
|
|
899
|
+
* while the card stays on Pull request. The scope goes in the run's message, the way Fix it tells
|
|
900
|
+
* Implement what QA found, so the QA skill stays as it is. The run writes one report with everything
|
|
901
|
+
* in it: the rows it did not run again are carried over, and one row per fixed comment is added.
|
|
902
|
+
*/
|
|
903
|
+
/** What QA the fixes tells the QA run, after the card. `since` is when the last QA with a verdict started. */
|
|
904
|
+
function qaFixesMessage(rows, pulls, since) {
|
|
905
|
+
const last = since === null ? "the last QA" : `the QA of ${since.slice(0, 10)}`;
|
|
906
|
+
const example = rows[0]?.ref ?? "T1";
|
|
907
|
+
return [
|
|
908
|
+
`This QA run checks the fixes made for review comments on this card's pull request, not the whole card again. ${rows.length === 1 ? "One comment was" : `${rows.length} comments were`} fixed since ${last}:`,
|
|
909
|
+
...rows.map((row) => discussionBlock(row, pulls.find((one) => one.id === row.pull))),
|
|
910
|
+
"To see what the fixes changed, run `git diff @{upstream}` in each repository of the card: that is the change since the reviewers read the pull request. Where a branch has no upstream, run `git diff HEAD`.",
|
|
911
|
+
`Start from \`<card folder>/qa/report.md\`, the report of ${last}, and write the new report over it with everything together. Nolzu kept a copy of the old one in \`<card folder>/qa/history/\`.`,
|
|
912
|
+
[
|
|
913
|
+
"- Run the project's own checks again, as always.",
|
|
914
|
+
"- Keep every row of section 2 in its place and with its number. Run a row again only when the fixes touch what it checks, and write its new result.",
|
|
915
|
+
`- A row you do not run again keeps its result and its Evidence line, and its How line becomes \`How: from ${last}, the fixes do not touch it\`.`,
|
|
916
|
+
`- After those rows, add one row per fixed comment, its step starting with the ref, such as \`${example}: The search ignores case now\`. It passes when what the reviewer asked for holds.`,
|
|
917
|
+
"- A new screenshot for a row starts with that row's number, under a name not used before.",
|
|
918
|
+
"- Section 1 and the verdict are about the whole report."
|
|
919
|
+
].join("\n"),
|
|
920
|
+
"When there is no report there, check the fixed comments and the project's own checks, and write the report with those rows."
|
|
921
|
+
].join("\n\n");
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* The rows a failed QA of the fixes sends back to new, each with QA's reason. A comment whose own row
|
|
925
|
+
* failed goes back alone. When only other rows failed, such as the project's tests, every checked
|
|
926
|
+
* comment goes back with the first failed check named, because the fixes are what changed.
|
|
927
|
+
*/
|
|
928
|
+
function failedFixes(report, refs, reason) {
|
|
929
|
+
const failed = (report === null ? null : parseQaChecklist(report)?.rows)?.filter((row) => row.result === "fail") ?? [];
|
|
930
|
+
const own = failed.flatMap((row) => {
|
|
931
|
+
const ref = /^(T\d+)\b/.exec(row.step)?.[1];
|
|
932
|
+
if (ref === void 0 || !refs.includes(ref)) return [];
|
|
933
|
+
return [{
|
|
934
|
+
ref,
|
|
935
|
+
reason: `QA says: ${[
|
|
936
|
+
row.reason ?? row.step,
|
|
937
|
+
...row.expected === void 0 ? [] : [`Expected: ${row.expected}`],
|
|
938
|
+
...row.actual === void 0 ? [] : [`Actual: ${row.actual}`]
|
|
939
|
+
].join(". ")}`
|
|
940
|
+
}];
|
|
941
|
+
});
|
|
942
|
+
if (own.length > 0) return own;
|
|
943
|
+
const named = failed[0] === void 0 ? reason ?? "no check was named" : `${failed[0].step}${failed[0].reason === null ? "" : `, ${failed[0].reason}`}`;
|
|
944
|
+
return refs.map((ref) => ({
|
|
945
|
+
ref,
|
|
946
|
+
reason: `QA failed a check no comment names: ${named}`
|
|
947
|
+
}));
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* Keeps the QA report a run is about to write over, as `qa/history/report-<n>.md`, numbered from the
|
|
951
|
+
* oldest. Skipped when there is none, and when it is the same as the newest copy, which is a run that
|
|
952
|
+
* ended before it wrote a report. Answers the name it was kept under, or null.
|
|
953
|
+
*/
|
|
954
|
+
function keepReport(qaDir) {
|
|
955
|
+
const card = dirname(qaDir);
|
|
956
|
+
const report = readCardText(card, join("qa", "report.md"));
|
|
957
|
+
if (report === null) return null;
|
|
958
|
+
const history = join(qaDir, "history");
|
|
959
|
+
const numbers = (lstatSync(history, { throwIfNoEntry: false })?.isDirectory() === true ? readdirSync(history) : []).flatMap((name) => {
|
|
960
|
+
const found = /^report-(\d+)\.md$/.exec(name);
|
|
961
|
+
return found === null ? [] : [Number(found[1])];
|
|
962
|
+
});
|
|
963
|
+
const last = numbers.length === 0 ? 0 : Math.max(...numbers);
|
|
964
|
+
if (last > 0 && readCardText(card, join("qa", "history", `report-${last}.md`)) === report) return null;
|
|
965
|
+
const name = `report-${last + 1}.md`;
|
|
966
|
+
writeCardFile(card, join("qa", "history", name), report);
|
|
967
|
+
return join("qa", "history", name);
|
|
968
|
+
}
|
|
969
|
+
//#endregion
|
|
970
|
+
//#region src/lib/notifications.ts
|
|
971
|
+
var NEWEST_SENT = 5;
|
|
972
|
+
function notificationsView(db) {
|
|
973
|
+
return {
|
|
974
|
+
unread: unreadNotifications(db),
|
|
975
|
+
newest: notifications(db, NEWEST_SENT)
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* Keeps the end of one card run, in the words its toast uses, plus a question it asked. A stop is the
|
|
980
|
+
* person's own act and keeps nothing. The run id is the key, so the end is kept once.
|
|
981
|
+
*/
|
|
982
|
+
function noteRunEnd(db, run, end, qa) {
|
|
983
|
+
const phase = phaseLabel(run.phase);
|
|
984
|
+
const note = (kind, text) => addNotification(db, {
|
|
985
|
+
id: `run:${run.id}`,
|
|
986
|
+
kind,
|
|
987
|
+
text,
|
|
988
|
+
card: run.key
|
|
989
|
+
});
|
|
990
|
+
if (end.cardState === "failed") note("error", end.failureReason === null ? `${phase} failed. It gave no reason.` : `${phase} failed: ${shortReason(end.failureReason)}`);
|
|
991
|
+
else if (end.cardState === "blocked") note("warning", `${phase} asks you: ${shortReason(end.question ?? "Read the question on the card.")}`);
|
|
992
|
+
else if (end.cardState !== "ready") return;
|
|
993
|
+
else if (qa?.verdict === "FAIL") note("error", qa.reason === null ? `${phase} failed` : `${phase} failed: ${shortReason(qa.reason)}`);
|
|
994
|
+
else if (qa !== null && qa.verdict === null && qa.reason !== null) note("warning", `${phase} gave no verdict: ${shortReason(qa.reason)}`);
|
|
995
|
+
else note("success", qa?.verdict === "PASS" ? `${phase} passed` : `${phase} finished`);
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Keeps a failed knowledge run of no card, Learn or Optimize, which raises no toast and shows only on
|
|
999
|
+
* Knowledge otherwise, so a Learn that failed before the card it held started is not missed. The run
|
|
1000
|
+
* id is the key, so the end is kept once.
|
|
1001
|
+
*/
|
|
1002
|
+
function noteMaintenanceFailure(db, run, end) {
|
|
1003
|
+
if (!isMaintenanceKey(run.key) || end.cardState !== "failed") return;
|
|
1004
|
+
const repo = repoOfLearnKey(run.key);
|
|
1005
|
+
const what = repo === null ? phaseLabel(run.phase) : `Learning ${repo}`;
|
|
1006
|
+
const text = end.failureReason === null ? `${what} failed. It gave no reason.` : `${what} failed: ${shortReason(end.failureReason)}`;
|
|
1007
|
+
addNotification(db, {
|
|
1008
|
+
id: `run:${run.id}`,
|
|
1009
|
+
kind: "error",
|
|
1010
|
+
text,
|
|
1011
|
+
href: "/knowledge"
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
//#endregion
|
|
1015
|
+
//#region src/lib/pr-diff.ts
|
|
1016
|
+
/**
|
|
1017
|
+
* The diff a pr-review run reads, on disk before the engine starts.
|
|
1018
|
+
*
|
|
1019
|
+
* The skill reads `<card folder>/pr-review/diff.patch` and refuses the run when it is not there, so
|
|
1020
|
+
* this is the writer of that file. It is fetched once per run and not once per card: a re-review has
|
|
1021
|
+
* to read the head as it is now, and a patch written when the card was made would be the first
|
|
1022
|
+
* round's.
|
|
1023
|
+
*
|
|
1024
|
+
* `gh pr diff` has not been recorded against the real GitHub CLI here, so the stub in
|
|
1025
|
+
* `pr-diff.test.ts` is a documented shape and not a measured one. That test names what the first
|
|
1026
|
+
* real call has to confirm.
|
|
1027
|
+
*/
|
|
1028
|
+
var FAKE_PATCH = `diff --git a/services/api/src/recipes/list.ts b/services/api/src/recipes/list.ts
|
|
1029
|
+
index 4f2a1c3..9b8e2d1 100644
|
|
1030
|
+
--- a/services/api/src/recipes/list.ts
|
|
1031
|
+
+++ b/services/api/src/recipes/list.ts
|
|
1032
|
+
@@ -1,3 +1,7 @@
|
|
1033
|
+
+export function filterRecipes(recipes, query) {
|
|
1034
|
+
+ return recipes.filter((recipe) => recipe.title.includes(query));
|
|
1035
|
+
+}
|
|
1036
|
+
+
|
|
1037
|
+
export function listRecipes(recipes) {
|
|
1038
|
+
return recipes.map((recipe) => recipe.title);
|
|
1039
|
+
}
|
|
1040
|
+
`;
|
|
1041
|
+
var FETCH_MS = 6e5;
|
|
1042
|
+
var TOO_BIG = /HTTP 406/;
|
|
1043
|
+
var OVER_CAP = /sent more than \d+ characters/;
|
|
1044
|
+
/**
|
|
1045
|
+
* Write the pull request's diff into the card folder, and answer with the path.
|
|
1046
|
+
*
|
|
1047
|
+
* Throws, and writes no file, when the card names no GitHub pull request, when `gh` exits non-zero
|
|
1048
|
+
* or when it prints nothing. In fake mode nothing is called and the built-in patch is written,
|
|
1049
|
+
* whatever the card names. The run then fails with that sentence and no engine is spawned, which
|
|
1050
|
+
* is the point of doing this before the spawn.
|
|
1051
|
+
*/
|
|
1052
|
+
var DIFF_FILE = join("pr-review", "diff.patch");
|
|
1053
|
+
async function writePrDiff(request) {
|
|
1054
|
+
const { sourceRef, gh } = request;
|
|
1055
|
+
const file = join(request.taskDir, DIFF_FILE);
|
|
1056
|
+
if (gh === null) {
|
|
1057
|
+
write(request.taskDir, FAKE_PATCH);
|
|
1058
|
+
return file;
|
|
1059
|
+
}
|
|
1060
|
+
const ref = sourceRef === null ? null : parseTicketRef(sourceRef);
|
|
1061
|
+
if (ref === null || ref.kind !== "github" || ref.owner === null) {
|
|
1062
|
+
const named = sourceRef === null ? "no pull request" : JSON.stringify(sourceRef);
|
|
1063
|
+
throw new Error(`This card names ${named}, so Nolzu does not know which diff to read. A pull request card carries its pull request as owner/repo#number.`);
|
|
1064
|
+
}
|
|
1065
|
+
const repo = `${ref.owner}/${ref.repo}`;
|
|
1066
|
+
const named = `${repo}#${ref.number}`;
|
|
1067
|
+
const pull = {
|
|
1068
|
+
owner: ref.owner,
|
|
1069
|
+
repo: ref.repo,
|
|
1070
|
+
number: ref.number
|
|
1071
|
+
};
|
|
1072
|
+
const args = [
|
|
1073
|
+
"pr",
|
|
1074
|
+
"diff",
|
|
1075
|
+
String(ref.number),
|
|
1076
|
+
"--repo",
|
|
1077
|
+
repo,
|
|
1078
|
+
"--color",
|
|
1079
|
+
"never"
|
|
1080
|
+
];
|
|
1081
|
+
let answer;
|
|
1082
|
+
try {
|
|
1083
|
+
answer = await gh(args, request.signal);
|
|
1084
|
+
} catch (error) {
|
|
1085
|
+
if (!OVER_CAP.test(String(error))) throw error;
|
|
1086
|
+
return fromGit(request, pull, file, "the diff is bigger than gh reads at once");
|
|
1087
|
+
}
|
|
1088
|
+
const say = `Run gh ${args.join(" ")} in a terminal to see what it says.`;
|
|
1089
|
+
if (answer.code !== 0) {
|
|
1090
|
+
const said = answer.stderr.trim().split("\n")[0]?.trim() ?? "";
|
|
1091
|
+
if (TOO_BIG.test(said)) return fromGit(request, pull, file, `GitHub said: ${said}`);
|
|
1092
|
+
throw new Error(`gh could not read the diff of ${named}, so there is nothing to review. It exited ${answer.code}${said === "" ? "" : ` and said: ${said}`}. ${say}`);
|
|
1093
|
+
}
|
|
1094
|
+
if (answer.stdout.trim() === "") throw new Error(`gh read an empty diff for ${named}, so there is nothing to review. The pull request may hold no change, or gh may not be able to open that repository. ${say}`);
|
|
1095
|
+
write(request.taskDir, answer.stdout);
|
|
1096
|
+
return file;
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* The head of the card's pull request as GitHub has it now, read right before the diff, so the round
|
|
1100
|
+
* saves the head it reviewed and not the one the last Read pull requests saw. Null in fake mode, for a
|
|
1101
|
+
* card that names no GitHub pull request, and for an answer that cannot be read: the caller then keeps
|
|
1102
|
+
* the head that read saw, and a missing head never claims a push.
|
|
1103
|
+
*/
|
|
1104
|
+
async function readPrHead(sourceRef, gh, signal) {
|
|
1105
|
+
const ref = gh === null || sourceRef === null ? null : parseTicketRef(sourceRef);
|
|
1106
|
+
if (gh === null || ref === null || ref.kind !== "github" || ref.owner === null) return null;
|
|
1107
|
+
try {
|
|
1108
|
+
const found = (await getPull(gh, {
|
|
1109
|
+
owner: ref.owner,
|
|
1110
|
+
repo: ref.repo,
|
|
1111
|
+
number: ref.number
|
|
1112
|
+
}, signal)).pull;
|
|
1113
|
+
return found?.headSha === void 0 ? null : {
|
|
1114
|
+
sha: found.headSha,
|
|
1115
|
+
commits: found.commits ?? null
|
|
1116
|
+
};
|
|
1117
|
+
} catch {
|
|
1118
|
+
return null;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* The diff GitHub would not send, from git: the pull request's head and its base branch fetched from
|
|
1123
|
+
* the local repository's origin into refs of Nolzu's own, compared the way GitHub compares them (from
|
|
1124
|
+
* where the head left the base), and the refs removed again. The person's branches stay as they are.
|
|
1125
|
+
*/
|
|
1126
|
+
async function fromGit(request, ref, file, why) {
|
|
1127
|
+
const named = `${ref.owner}/${ref.repo}#${ref.number}`;
|
|
1128
|
+
const refuse = (rest) => /* @__PURE__ */ new Error(`GitHub sends no diff for ${named} (${why}), and Nolzu could not read it from git either: ${rest}`);
|
|
1129
|
+
const folder = await request.localRepo?.(ref.owner, ref.repo) ?? null;
|
|
1130
|
+
if (folder === null) throw refuse(`no repository of this project has ${ref.owner}/${ref.repo} as its origin. Add it to the project, or review this pull request on GitHub.`);
|
|
1131
|
+
const base = await request.gh?.([
|
|
1132
|
+
"pr",
|
|
1133
|
+
"view",
|
|
1134
|
+
String(ref.number),
|
|
1135
|
+
"--repo",
|
|
1136
|
+
`${ref.owner}/${ref.repo}`,
|
|
1137
|
+
"--json",
|
|
1138
|
+
"baseRefName",
|
|
1139
|
+
"--jq",
|
|
1140
|
+
".baseRefName"
|
|
1141
|
+
], request.signal);
|
|
1142
|
+
const branch = base?.code === 0 ? base.stdout.trim() : "";
|
|
1143
|
+
if (branch === "") throw refuse(`gh could not read its base branch. ${base?.stderr.trim().split("\n")[0] ?? ""}`.trim());
|
|
1144
|
+
const head = `refs/nolzu/pull/${ref.number}/head`;
|
|
1145
|
+
const onto = `refs/nolzu/pull/${ref.number}/base`;
|
|
1146
|
+
const run = (args) => git(args, {
|
|
1147
|
+
cwd: folder,
|
|
1148
|
+
env: request.gitEnv,
|
|
1149
|
+
signal: request.signal
|
|
1150
|
+
});
|
|
1151
|
+
const first = (text) => text.trim().split("\n")[0] ?? "";
|
|
1152
|
+
try {
|
|
1153
|
+
const env = await remoteEnv(request.gitEnv ?? process.env, run);
|
|
1154
|
+
const fetched = await git([
|
|
1155
|
+
"fetch",
|
|
1156
|
+
"--no-tags",
|
|
1157
|
+
"--quiet",
|
|
1158
|
+
"origin",
|
|
1159
|
+
`+refs/pull/${ref.number}/head:${head}`,
|
|
1160
|
+
`+refs/heads/${branch}:${onto}`
|
|
1161
|
+
], {
|
|
1162
|
+
cwd: folder,
|
|
1163
|
+
env,
|
|
1164
|
+
signal: AbortSignal.any([request.signal, AbortSignal.timeout(FETCH_MS)])
|
|
1165
|
+
}).catch((error) => {
|
|
1166
|
+
throw request.signal.aborted ? error : refuse(`git fetch in ${folder} took longer than ${FETCH_MS / 6e4} minutes, so Nolzu stopped it.`);
|
|
1167
|
+
});
|
|
1168
|
+
if (fetched.code !== 0) throw refuse(`git fetch in ${folder} exited ${fetched.code} and said: ${first(fetched.stderr)}`);
|
|
1169
|
+
const diff = await run([
|
|
1170
|
+
"diff",
|
|
1171
|
+
"--no-color",
|
|
1172
|
+
"--no-ext-diff",
|
|
1173
|
+
"--no-textconv",
|
|
1174
|
+
"-M",
|
|
1175
|
+
`${onto}...${head}`
|
|
1176
|
+
]);
|
|
1177
|
+
if (diff.code !== 0) throw refuse(`git diff in ${folder} exited ${diff.code} and said: ${first(diff.stderr)}`);
|
|
1178
|
+
if (diff.stdout.trim() === "") throw refuse(`git found no change between ${branch} and the pull request's head.`);
|
|
1179
|
+
write(request.taskDir, diff.stdout);
|
|
1180
|
+
const files = diff.stdout.split("\n").filter((line) => line.startsWith("diff --git ")).length;
|
|
1181
|
+
request.note?.(`GitHub sends no diff for ${named} (${why}), so Nolzu read it from git in ${folder}: ${files} ${files === 1 ? "file" : "files"}.`);
|
|
1182
|
+
return file;
|
|
1183
|
+
} finally {
|
|
1184
|
+
await run([
|
|
1185
|
+
"update-ref",
|
|
1186
|
+
"-d",
|
|
1187
|
+
head
|
|
1188
|
+
]).catch(() => void 0);
|
|
1189
|
+
await run([
|
|
1190
|
+
"update-ref",
|
|
1191
|
+
"-d",
|
|
1192
|
+
onto
|
|
1193
|
+
]).catch(() => void 0);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
function write(taskDir, patch) {
|
|
1197
|
+
writeCardFile(taskDir, DIFF_FILE, numberDiff(patch));
|
|
1198
|
+
}
|
|
1199
|
+
var HUNK = /^@@ -\d+(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;
|
|
1200
|
+
/**
|
|
1201
|
+
* The diff with each hunk line's number in the file after the change in front of it, which is the
|
|
1202
|
+
* number a finding's place names and the one GitHub shows on that line. A reviewer left to count from
|
|
1203
|
+
* the `@@` header miscounts, and the number its file reader prints is the line of the diff file:
|
|
1204
|
+
* a real round put a finding ten lines off that way. A removed line has no such number and gets a
|
|
1205
|
+
* blank. Headers stay as they are, and every line keeps its bytes after the number.
|
|
1206
|
+
*/
|
|
1207
|
+
function numberDiff(patch) {
|
|
1208
|
+
let old = 0;
|
|
1209
|
+
let next = 0;
|
|
1210
|
+
let at = 0;
|
|
1211
|
+
const lines = patch.split("\n").map((line) => {
|
|
1212
|
+
const hunk = HUNK.exec(line);
|
|
1213
|
+
if (hunk) {
|
|
1214
|
+
old = Number(hunk[1] ?? 1);
|
|
1215
|
+
at = Number(hunk[2]);
|
|
1216
|
+
next = Number(hunk[3] ?? 1);
|
|
1217
|
+
return {
|
|
1218
|
+
line,
|
|
1219
|
+
n: null,
|
|
1220
|
+
body: false
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
if (line.startsWith("\\")) return {
|
|
1224
|
+
line,
|
|
1225
|
+
n: null,
|
|
1226
|
+
body: true
|
|
1227
|
+
};
|
|
1228
|
+
if (old <= 0 && next <= 0) return {
|
|
1229
|
+
line,
|
|
1230
|
+
n: null,
|
|
1231
|
+
body: false
|
|
1232
|
+
};
|
|
1233
|
+
if (line.startsWith("-")) {
|
|
1234
|
+
old--;
|
|
1235
|
+
return {
|
|
1236
|
+
line,
|
|
1237
|
+
n: null,
|
|
1238
|
+
body: true
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
if (line.startsWith("+")) {
|
|
1242
|
+
next--;
|
|
1243
|
+
return {
|
|
1244
|
+
line,
|
|
1245
|
+
n: at++,
|
|
1246
|
+
body: true
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1249
|
+
if (line.startsWith(" ")) {
|
|
1250
|
+
old--;
|
|
1251
|
+
next--;
|
|
1252
|
+
return {
|
|
1253
|
+
line,
|
|
1254
|
+
n: at++,
|
|
1255
|
+
body: true
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
return {
|
|
1259
|
+
line,
|
|
1260
|
+
n: null,
|
|
1261
|
+
body: false
|
|
1262
|
+
};
|
|
1263
|
+
});
|
|
1264
|
+
const width = String(Math.max(0, ...lines.map((l) => l.n ?? 0))).length;
|
|
1265
|
+
return lines.map((l) => l.body ? `${(l.n === null ? "" : String(l.n)).padStart(width)} ${l.line}` : l.line).join("\n");
|
|
1266
|
+
}
|
|
1267
|
+
//#endregion
|
|
1268
|
+
//#region src/lib/qa-panel.ts
|
|
1269
|
+
/**
|
|
1270
|
+
* What the two QA panels of the ticket page read, from the database, the project and the card folder.
|
|
1271
|
+
*
|
|
1272
|
+
* The rules are in `@nolzu/ui/qa`; this file only gathers. The Status commands run here, on the page
|
|
1273
|
+
* load, because a panel that says what the app reports has to ask it. Their output is carried through
|
|
1274
|
+
* untouched: Nolzu never knows what the app is.
|
|
1275
|
+
*/
|
|
1276
|
+
var stackLane = (snapshot) => snapshot.lanes.find((lane) => lane.name === "stack")?.heldBy ?? null;
|
|
1277
|
+
var cardStackEnv = (db, key, env) => ({
|
|
1278
|
+
...env,
|
|
1279
|
+
...stackEnv(key, getSetting(db, "projectPath") ?? "", reposOfCard(db, key) ?? [])
|
|
1280
|
+
});
|
|
1281
|
+
/** The card's own commands under Start the app, in the order QA and Start run them. */
|
|
1282
|
+
function cardOwn(db, key) {
|
|
1283
|
+
const project = getSetting(db, "projectPath");
|
|
1284
|
+
const several = projectRepos({
|
|
1285
|
+
repos: getSetting(db, "repos"),
|
|
1286
|
+
baseBranch: getSetting(db, "baseBranch")
|
|
1287
|
+
}).length > 1;
|
|
1288
|
+
return ownStarts(getSetting(db, "qaApp"), reposOfCard(db, key) ?? []).map(({ repo, answer }) => ({
|
|
1289
|
+
repo,
|
|
1290
|
+
name: repo === null ? several ? "every repository" : "app" : several ? repo : "app",
|
|
1291
|
+
at: project === null || !isPlainName(key) ? null : ownFolder(project, key, repo),
|
|
1292
|
+
answer
|
|
1293
|
+
}));
|
|
1294
|
+
}
|
|
1295
|
+
/** Why the card's own commands have nowhere to run, or null when every folder is there. */
|
|
1296
|
+
function ownProblem(owns, what) {
|
|
1297
|
+
if (owns.some((own) => own.at === null)) return `There is no project folder set, so ${what} has nowhere to run.`;
|
|
1298
|
+
if (owns.some((own) => own.at !== null && !existsSync(own.at))) return `This card has no checkout, so ${what} has nowhere to run. A run makes one. A closed card has none once its checkouts are removed.`;
|
|
1299
|
+
return null;
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* What the card's Status commands say, or why they did not run. The one slow part of the panels,
|
|
1303
|
+
* because each runs a command the person wrote, so the card page streams it. With several, they run
|
|
1304
|
+
* at once and their output reads as one block, each part under its name.
|
|
1305
|
+
*/
|
|
1306
|
+
async function stackStatusFor(db, key, options = {}) {
|
|
1307
|
+
const env = options.env ?? process.env;
|
|
1308
|
+
const owns = cardOwn(db, key).filter((own) => own.answer.status !== null);
|
|
1309
|
+
if (owns.length === 0) return {
|
|
1310
|
+
status: null,
|
|
1311
|
+
statusProblem: null
|
|
1312
|
+
};
|
|
1313
|
+
const problem = ownProblem(owns, "the Status command");
|
|
1314
|
+
if (problem !== null) return {
|
|
1315
|
+
status: null,
|
|
1316
|
+
statusProblem: problem
|
|
1317
|
+
};
|
|
1318
|
+
try {
|
|
1319
|
+
const ran = (await Promise.all(owns.map((own) => runStackHook({
|
|
1320
|
+
load: null,
|
|
1321
|
+
unload: null,
|
|
1322
|
+
status: own.answer.status
|
|
1323
|
+
}, "status", key, {
|
|
1324
|
+
cwd: own.at ?? "",
|
|
1325
|
+
env: cardStackEnv(db, key, env),
|
|
1326
|
+
signal: options.signal,
|
|
1327
|
+
timeoutMs: options.timeoutMs ?? 5e3
|
|
1328
|
+
})))).flatMap((result, index) => result === null ? [] : [{
|
|
1329
|
+
...result,
|
|
1330
|
+
name: owns[index]?.name ?? ""
|
|
1331
|
+
}]);
|
|
1332
|
+
const one = ran.length === 1 ? ran[0] : void 0;
|
|
1333
|
+
return {
|
|
1334
|
+
status: ran.length === 0 ? null : {
|
|
1335
|
+
command: ran.map((result) => result.command).join("\n"),
|
|
1336
|
+
code: ran.find((result) => result.code !== 0)?.code ?? 0,
|
|
1337
|
+
output: one !== void 0 ? `${one.stdout}${one.stderr}` : ran.map((result) => `${result.name}\n${result.stdout}${result.stderr}`.trim()).join("\n\n"),
|
|
1338
|
+
timedOut: ran.some((result) => result.timedOut)
|
|
1339
|
+
},
|
|
1340
|
+
statusProblem: null
|
|
1341
|
+
};
|
|
1342
|
+
} catch (error) {
|
|
1343
|
+
return {
|
|
1344
|
+
status: null,
|
|
1345
|
+
statusProblem: `The Status command could not run: ${error.message}`
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
/**
|
|
1350
|
+
* Everything the panels read but the Status commands: the database and the card folder, so the page
|
|
1351
|
+
* draws it at once. With no status, the app line says the command has not run yet.
|
|
1352
|
+
*/
|
|
1353
|
+
function qaInputFor(db, key, options = {}) {
|
|
1354
|
+
const env = options.env ?? process.env;
|
|
1355
|
+
const owns = cardOwn(db, key);
|
|
1356
|
+
const run = db.prepare("SELECT id, state, verdict, verdict_reason FROM runs WHERE card_key = ? AND phase = 'qa' ORDER BY id DESC LIMIT 1").get(key);
|
|
1357
|
+
const qaFiles = filesFor(db, key, env).find((group) => group.folder === "qa")?.files ?? [];
|
|
1358
|
+
const stored = cardStack(db, key);
|
|
1359
|
+
const stack = stored !== null && isStackState(stored.state) ? {
|
|
1360
|
+
state: stored.state,
|
|
1361
|
+
reason: stored.reason
|
|
1362
|
+
} : null;
|
|
1363
|
+
const report = qaFiles.find((file) => file.path === "qa/report.md")?.path ?? null;
|
|
1364
|
+
const folder = cardFolder(db, key, env);
|
|
1365
|
+
const read = folder === null || report === null ? null : readCardFile(folder, report);
|
|
1366
|
+
return {
|
|
1367
|
+
cardKey: key,
|
|
1368
|
+
run: run === void 0 ? null : {
|
|
1369
|
+
id: run.id,
|
|
1370
|
+
state: run.state,
|
|
1371
|
+
verdict: run.verdict,
|
|
1372
|
+
verdictReason: run.verdict_reason
|
|
1373
|
+
},
|
|
1374
|
+
stack,
|
|
1375
|
+
hasLoad: owns.length > 0,
|
|
1376
|
+
hasUnload: owns.length > 0,
|
|
1377
|
+
hasStatus: owns.some((own) => own.answer.status !== null),
|
|
1378
|
+
status: null,
|
|
1379
|
+
statusProblem: null,
|
|
1380
|
+
stackLane: options.busy ?? null,
|
|
1381
|
+
report,
|
|
1382
|
+
reportText: read?.ok ? read.bytes.toString("utf8") : null,
|
|
1383
|
+
screenshots: qaFiles.filter((file) => file.kind === "image").map((file) => ({
|
|
1384
|
+
path: file.path,
|
|
1385
|
+
name: file.name
|
|
1386
|
+
})),
|
|
1387
|
+
hasBrowser: qaHasBrowser(db),
|
|
1388
|
+
loadCommand: owns.length === 1 ? owns[0]?.answer.start ?? null : null,
|
|
1389
|
+
apps: owns.map((own) => ({
|
|
1390
|
+
name: own.name,
|
|
1391
|
+
start: own.answer.start
|
|
1392
|
+
}))
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
//#endregion
|
|
1396
|
+
//#region src/lib/stack-action.ts
|
|
1397
|
+
/**
|
|
1398
|
+
* The Start, Stop and Force buttons of the app line, `PRODUCT-BRIEF.md` 7.3. They act on the card's own
|
|
1399
|
+
* commands under Start the app, each repository in order.
|
|
1400
|
+
*
|
|
1401
|
+
* These are not runs in the phase sense. They start no agent, take no slot and finish while the
|
|
1402
|
+
* request is open, so they answer with the command's own words rather than leaving the person to
|
|
1403
|
+
* follow a board snapshot. The one thing they do read from the snapshot is the stack lane: a QA run
|
|
1404
|
+
* owns the app while it checks a card, and stopping that app under it would make its verdict
|
|
1405
|
+
* meaningless.
|
|
1406
|
+
*
|
|
1407
|
+
* Force is Stop with the state check dropped. It is what a person presses for an app an earlier run
|
|
1408
|
+
* left behind, one running another card's code, or one whose command never came back.
|
|
1409
|
+
*
|
|
1410
|
+
* The three words are the panel's own type, so the button a person presses and the button this
|
|
1411
|
+
* refuses can never drift apart. They keep the names load, unload and force on the wire.
|
|
1412
|
+
*/
|
|
1413
|
+
var isStackAction = (value) => value === "load" || value === "unload" || value === "force";
|
|
1414
|
+
var held = /* @__PURE__ */ new Map();
|
|
1415
|
+
var pressing = /* @__PURE__ */ new Set();
|
|
1416
|
+
var heldId = (key, repo) => `${key}\n${repo ?? ""}`;
|
|
1417
|
+
var started = /* @__PURE__ */ new Set();
|
|
1418
|
+
var appHeld = (key) => pressing.has(key) || started.has(key) || [...held.keys()].some((id) => id.startsWith(`${key}\n`));
|
|
1419
|
+
async function stopHeld(key, repo) {
|
|
1420
|
+
const app = held.get(heldId(key, repo));
|
|
1421
|
+
held.delete(heldId(key, repo));
|
|
1422
|
+
await app?.stop();
|
|
1423
|
+
}
|
|
1424
|
+
async function releaseHeld(key) {
|
|
1425
|
+
for (const id of [...held.keys()].filter((one) => one.startsWith(`${key}\n`))) {
|
|
1426
|
+
const app = held.get(id);
|
|
1427
|
+
held.delete(id);
|
|
1428
|
+
await app?.stop();
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
async function startAll(db, key, owns, env) {
|
|
1432
|
+
for (const own of owns) {
|
|
1433
|
+
const command = stackCommand(own.answer.start, key);
|
|
1434
|
+
await stopHeld(key, own.repo);
|
|
1435
|
+
try {
|
|
1436
|
+
const app = await startApp(command, {
|
|
1437
|
+
cwd: own.at ?? "",
|
|
1438
|
+
env: cardStackEnv(db, key, env),
|
|
1439
|
+
mayExit: true,
|
|
1440
|
+
timeoutMs: STACK_TIMEOUT_MS
|
|
1441
|
+
});
|
|
1442
|
+
if (!app.exited) held.set(heldId(key, own.repo), app);
|
|
1443
|
+
else started.add(key);
|
|
1444
|
+
} catch (error) {
|
|
1445
|
+
return `${command} did not start the app. ${error.message}`;
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
return null;
|
|
1449
|
+
}
|
|
1450
|
+
async function releaseAll() {
|
|
1451
|
+
const apps = [...held.values()];
|
|
1452
|
+
held.clear();
|
|
1453
|
+
await Promise.all(apps.map((app) => app.stop()));
|
|
1454
|
+
}
|
|
1455
|
+
async function stopAll(db, key, owns, env) {
|
|
1456
|
+
const left = [];
|
|
1457
|
+
for (const own of owns) {
|
|
1458
|
+
const running = held.has(heldId(key, own.repo));
|
|
1459
|
+
await stopHeld(key, own.repo);
|
|
1460
|
+
if (own.answer.stop === null) {
|
|
1461
|
+
if (!running) left.push(`No Stop command is set, so what ${stackCommand(own.answer.start, key)} started is still up.`);
|
|
1462
|
+
continue;
|
|
1463
|
+
}
|
|
1464
|
+
const status = await runStackHook({
|
|
1465
|
+
load: null,
|
|
1466
|
+
unload: own.answer.stop,
|
|
1467
|
+
status: null
|
|
1468
|
+
}, "unload", key, {
|
|
1469
|
+
cwd: own.at ?? "",
|
|
1470
|
+
env: cardStackEnv(db, key, env),
|
|
1471
|
+
timeoutMs: STACK_UNLOAD_TIMEOUT_MS
|
|
1472
|
+
}).then((result) => stackStatusAfter("unload", result)).catch((error) => ({
|
|
1473
|
+
state: "up",
|
|
1474
|
+
reason: `The Stop command could not run: ${error.message}. The app is still up.`
|
|
1475
|
+
}));
|
|
1476
|
+
if (status.state === "up") left.push(status.reason ?? "");
|
|
1477
|
+
}
|
|
1478
|
+
return left;
|
|
1479
|
+
}
|
|
1480
|
+
async function pressStack(db, snapshot, key, button, env = process.env) {
|
|
1481
|
+
const card = db.prepare("SELECT key, stack_state FROM cards WHERE key = ?").get(key);
|
|
1482
|
+
if (card === void 0) return {
|
|
1483
|
+
ok: false,
|
|
1484
|
+
said: `There is no card ${key} here, so there is no app to work on.`
|
|
1485
|
+
};
|
|
1486
|
+
const lane = stackLane(snapshot);
|
|
1487
|
+
if (lane !== null) return {
|
|
1488
|
+
ok: false,
|
|
1489
|
+
said: `${lane === key ? "This card is" : `${lane} is`} running QA, which owns the app until it ends. Stop that run first.`
|
|
1490
|
+
};
|
|
1491
|
+
if (button !== "force" && (card.stack_state === "loading" || card.stack_state === "unloading")) return {
|
|
1492
|
+
ok: false,
|
|
1493
|
+
said: "A start or stop of this card's app is already running. Wait for it, or press Force."
|
|
1494
|
+
};
|
|
1495
|
+
const owns = cardOwn(db, key);
|
|
1496
|
+
if (owns.length === 0) return {
|
|
1497
|
+
ok: false,
|
|
1498
|
+
said: "No repository of this card has its own start commands. Add them in the QA question, or under Start the app in Settings, Project."
|
|
1499
|
+
};
|
|
1500
|
+
if (button === "unload" && card.stack_state !== "up" && card.stack_state !== "failed") return {
|
|
1501
|
+
ok: false,
|
|
1502
|
+
said: "Nolzu has started no app for this card. Press Force to run the Stop commands anyway."
|
|
1503
|
+
};
|
|
1504
|
+
const problem = ownProblem(owns, "the command");
|
|
1505
|
+
if (problem !== null) return {
|
|
1506
|
+
ok: false,
|
|
1507
|
+
said: problem
|
|
1508
|
+
};
|
|
1509
|
+
if (pressing.has(key)) return {
|
|
1510
|
+
ok: false,
|
|
1511
|
+
said: "A start or stop of this card's app is already running. Wait for it."
|
|
1512
|
+
};
|
|
1513
|
+
pressing.add(key);
|
|
1514
|
+
try {
|
|
1515
|
+
return await press(db, key, button, owns, env);
|
|
1516
|
+
} finally {
|
|
1517
|
+
pressing.delete(key);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
async function press(db, key, button, owns, env) {
|
|
1521
|
+
if (button === "load") {
|
|
1522
|
+
setCardStack(db, key, {
|
|
1523
|
+
state: "loading",
|
|
1524
|
+
reason: null
|
|
1525
|
+
});
|
|
1526
|
+
const failed = await startAll(db, key, owns, env).catch((error) => error.message);
|
|
1527
|
+
setCardStack(db, key, failed === null ? {
|
|
1528
|
+
state: "up",
|
|
1529
|
+
reason: null
|
|
1530
|
+
} : {
|
|
1531
|
+
state: "failed",
|
|
1532
|
+
reason: failed
|
|
1533
|
+
});
|
|
1534
|
+
return {
|
|
1535
|
+
ok: failed === null,
|
|
1536
|
+
said: failed ?? "The app is up."
|
|
1537
|
+
};
|
|
1538
|
+
}
|
|
1539
|
+
setCardStack(db, key, {
|
|
1540
|
+
state: "unloading",
|
|
1541
|
+
reason: null
|
|
1542
|
+
});
|
|
1543
|
+
const left = await stopAll(db, key, owns, env).catch((error) => [error.message]);
|
|
1544
|
+
if (left.length === 0) started.delete(key);
|
|
1545
|
+
setCardStack(db, key, left.length === 0 ? {
|
|
1546
|
+
state: "off",
|
|
1547
|
+
reason: null
|
|
1548
|
+
} : {
|
|
1549
|
+
state: "up",
|
|
1550
|
+
reason: left.join(" ")
|
|
1551
|
+
});
|
|
1552
|
+
return {
|
|
1553
|
+
ok: left.length === 0,
|
|
1554
|
+
said: left.length === 0 ? "The app was stopped." : left.join(" ")
|
|
1555
|
+
};
|
|
1556
|
+
}
|
|
1557
|
+
//#endregion
|
|
1558
|
+
//#region src/lib/persons-words.ts
|
|
1559
|
+
/**
|
|
1560
|
+
* What the person said on a card, for the prompt of a fresh run: each question a run asked with the
|
|
1561
|
+
* answer, the line typed on a move (Accept anyway, a Send back note) and their own Discussion messages.
|
|
1562
|
+
*
|
|
1563
|
+
* An answer is stored as two messages on the run that asked, the question and then the person's reply
|
|
1564
|
+
* (`answer` in `loop.ts`), so a person's message right after its run's question is that answer and
|
|
1565
|
+
* not a Discussion message. A question with no such pair, asked before answers were stored or never
|
|
1566
|
+
* answered, has a null answer.
|
|
1567
|
+
*/
|
|
1568
|
+
function personsWords(db, key, stages) {
|
|
1569
|
+
const asked = db.prepare("SELECT id, phase, question FROM runs WHERE card_key = ? AND trim(coalesce(question, '')) != '' ORDER BY id").all(key);
|
|
1570
|
+
const all = db.prepare("SELECT thread, author, body, run_id AS runId FROM messages WHERE card_key = ? ORDER BY id").all(key);
|
|
1571
|
+
const answers = /* @__PURE__ */ new Map();
|
|
1572
|
+
const messages = [];
|
|
1573
|
+
all.forEach((message, at) => {
|
|
1574
|
+
if (message.author !== "person") return;
|
|
1575
|
+
const before = all.slice(0, at).findLast((one) => one.thread === message.thread);
|
|
1576
|
+
const id = message.runId ?? -1;
|
|
1577
|
+
const question = asked.find((run) => run.id === id)?.question.trim();
|
|
1578
|
+
if (before?.author === "agent" && before.runId === id && question !== void 0 && before.body === question && !answers.has(id)) answers.set(id, message.body);
|
|
1579
|
+
else if (!isFeedbackRef(message.thread)) messages.push({
|
|
1580
|
+
thread: isAskThread(message.thread) ? "ask" : message.thread,
|
|
1581
|
+
text: message.body
|
|
1582
|
+
});
|
|
1583
|
+
});
|
|
1584
|
+
const label = (id) => stages.find((stage) => stage.id === id)?.label ?? id ?? "the start";
|
|
1585
|
+
const index = (id) => stages.findIndex((stage) => stage.id === id);
|
|
1586
|
+
const moves = db.prepare("SELECT from_stage AS fromStage, to_stage AS toStage, reason FROM card_events WHERE card_key = ? AND trim(coalesce(reason, '')) != '' ORDER BY id").all(key).map((move) => ({
|
|
1587
|
+
from: label(move.fromStage),
|
|
1588
|
+
to: label(move.toStage),
|
|
1589
|
+
back: index(move.toStage) < index(move.fromStage),
|
|
1590
|
+
reason: move.reason
|
|
1591
|
+
}));
|
|
1592
|
+
return {
|
|
1593
|
+
questions: asked.map((run) => ({
|
|
1594
|
+
phase: run.phase,
|
|
1595
|
+
question: run.question,
|
|
1596
|
+
answer: answers.get(run.id) ?? null
|
|
1597
|
+
})),
|
|
1598
|
+
moves,
|
|
1599
|
+
messages
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* The card's runs before `before`, for the wrap-up, which looks for what cost time: how often each
|
|
1604
|
+
* phase ran, in the order the phases first ran, and each QA verdict that was not PASS, oldest first.
|
|
1605
|
+
* An Ask run and a pass such as the plain summary move no work, so they are left out.
|
|
1606
|
+
*/
|
|
1607
|
+
function cardHistory(db, key, before) {
|
|
1608
|
+
const runs = db.prepare(`SELECT phase, count(*) AS count FROM runs WHERE card_key = ? AND id < ? AND ${NOT_A_PASS} GROUP BY phase ORDER BY min(id)`).all(key, before);
|
|
1609
|
+
const verdicts = db.prepare("SELECT verdict, verdict_reason AS reason FROM runs WHERE card_key = ? AND id < ? AND verdict IS NOT NULL AND verdict != 'PASS' ORDER BY id").all(key, before);
|
|
1610
|
+
return {
|
|
1611
|
+
runs: runs.map(({ phase, count }) => ({
|
|
1612
|
+
phase,
|
|
1613
|
+
count
|
|
1614
|
+
})),
|
|
1615
|
+
verdicts: verdicts.map(({ verdict, reason }) => ({
|
|
1616
|
+
verdict,
|
|
1617
|
+
reason
|
|
1618
|
+
}))
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
1621
|
+
//#endregion
|
|
1622
|
+
//#region src/lib/send-back.ts
|
|
1623
|
+
/**
|
|
1624
|
+
* Where a comment's line is in the card's folder now, matched by its text as the Changes tab matches
|
|
1625
|
+
* it, so the message points at the line the agent will find. Null when the line or the file is gone.
|
|
1626
|
+
* A file link that leads out of the checkout is never read.
|
|
1627
|
+
*/
|
|
1628
|
+
function lineNow(checkout, comment) {
|
|
1629
|
+
try {
|
|
1630
|
+
const real = realpathSync(join(checkout, comment.file));
|
|
1631
|
+
if (!real.startsWith(`${realpathSync(checkout)}${sep}`)) return null;
|
|
1632
|
+
const lines = readFileSync(real, "utf8").split("\n").map((code, at) => ({
|
|
1633
|
+
kind: "same",
|
|
1634
|
+
text: code,
|
|
1635
|
+
old: null,
|
|
1636
|
+
new: at + 1,
|
|
1637
|
+
sign: " ",
|
|
1638
|
+
code
|
|
1639
|
+
}));
|
|
1640
|
+
const [index] = placeComments(lines, [comment]).at.keys();
|
|
1641
|
+
return index === void 0 ? null : index + 1;
|
|
1642
|
+
} catch {
|
|
1643
|
+
return null;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
var plural = (count) => `${count} ${count === 1 ? "comment" : "comments"}`;
|
|
1647
|
+
var shown = (text) => text.trim() === "" ? "(an empty line)" : text.trim();
|
|
1648
|
+
/**
|
|
1649
|
+
* What Send back with comments tells the Implement run, as the message of its resumed session or after
|
|
1650
|
+
* the card in a fresh prompt: every comment once, in file and line order, each with its repository,
|
|
1651
|
+
* file, line and that line's text. Paths are from the repository, which both already know.
|
|
1652
|
+
*/
|
|
1653
|
+
function sendBackMessage(comments) {
|
|
1654
|
+
const items = [...comments].sort((a, b) => a.repo.localeCompare(b.repo) || a.file.localeCompare(b.file) || a.line - b.line).map((one, at) => {
|
|
1655
|
+
const where = one.repo === "." ? "In the project folder" : `In the ${one.repo} repository`;
|
|
1656
|
+
const head = one.now === null ? `${where}, ${one.file}, made on line ${one.line}. That line has changed since, so the comment is outdated.` : `${where}, ${one.file}, line ${one.now}${one.now === one.line ? "" : ` (made on line ${one.line})`}.`;
|
|
1657
|
+
return [
|
|
1658
|
+
`${at + 1}. ${head}`,
|
|
1659
|
+
` ${one.now === null ? "The line it was made on" : "The line"}: ${shown(one.lineText)}`,
|
|
1660
|
+
` Comment: ${one.text.replaceAll("\n", "\n ")}`
|
|
1661
|
+
].join("\n");
|
|
1662
|
+
});
|
|
1663
|
+
return [`The person read your change and left ${plural(comments.length)} on its lines. Do what each comment asks, then finish the way the implement skill says.`, ...items].join("\n\n");
|
|
1664
|
+
}
|
|
1665
|
+
//#endregion
|
|
1666
|
+
//#region src/lib/shared-scheduler.ts
|
|
1667
|
+
function sharedScheduler(shared, dataDir, slots) {
|
|
1668
|
+
const already = shared.get(dataDir);
|
|
1669
|
+
if (already !== void 0) return already;
|
|
1670
|
+
const projects = /* @__PURE__ */ new Map();
|
|
1671
|
+
const portsOf = (project) => project === void 0 ? void 0 : projects.get(project);
|
|
1672
|
+
const waiters = /* @__PURE__ */ new Set();
|
|
1673
|
+
const scheduler = createScheduler(slots, {
|
|
1674
|
+
startJob(job, signal) {
|
|
1675
|
+
const ports = portsOf(job.project);
|
|
1676
|
+
if (ports === void 0) return Promise.reject(/* @__PURE__ */ new Error(`Project ${job.project} has no loop open, so its run cannot start.`));
|
|
1677
|
+
return ports.startJob(job, signal, (event) => ports.onEvent?.(job.runId, event));
|
|
1678
|
+
},
|
|
1679
|
+
onChange() {
|
|
1680
|
+
for (const ports of [...projects.values()]) ports.onChange();
|
|
1681
|
+
for (const wait of [...waiters]) wait();
|
|
1682
|
+
}
|
|
1683
|
+
});
|
|
1684
|
+
const made = {
|
|
1685
|
+
join(project, ports) {
|
|
1686
|
+
if (projects.has(project)) throw new Error(`Project ${project} already has a loop open on ${dataDir}.`);
|
|
1687
|
+
projects.set(project, ports);
|
|
1688
|
+
const mine = (job) => job.project === project;
|
|
1689
|
+
return {
|
|
1690
|
+
queue: () => {
|
|
1691
|
+
const state = scheduler.queue();
|
|
1692
|
+
return {
|
|
1693
|
+
...state,
|
|
1694
|
+
waiting: state.waiting.filter(mine),
|
|
1695
|
+
running: state.running.filter(mine)
|
|
1696
|
+
};
|
|
1697
|
+
},
|
|
1698
|
+
add: (job) => scheduler.add({
|
|
1699
|
+
...job,
|
|
1700
|
+
project
|
|
1701
|
+
}),
|
|
1702
|
+
stop: (runId) => scheduler.stop(runId, project),
|
|
1703
|
+
promote: (runId) => scheduler.promote(runId, project),
|
|
1704
|
+
resize: (count) => scheduler.resize(count)
|
|
1705
|
+
};
|
|
1706
|
+
},
|
|
1707
|
+
leave(project) {
|
|
1708
|
+
projects.delete(project);
|
|
1709
|
+
if (projects.size === 0 && shared.get(dataDir) === made) shared.delete(dataDir);
|
|
1710
|
+
},
|
|
1711
|
+
queue: () => scheduler.queue(),
|
|
1712
|
+
async shutdown() {
|
|
1713
|
+
scheduler.resize(0);
|
|
1714
|
+
for (const ports of [...projects.values()]) ports.leave();
|
|
1715
|
+
const { waiting, running } = scheduler.queue();
|
|
1716
|
+
for (const job of [...waiting, ...running]) portsOf(job.project)?.stop(job.runId);
|
|
1717
|
+
await new Promise((resolve) => {
|
|
1718
|
+
const ended = () => {
|
|
1719
|
+
if (scheduler.queue().running.length > 0) return;
|
|
1720
|
+
waiters.delete(ended);
|
|
1721
|
+
resolve();
|
|
1722
|
+
};
|
|
1723
|
+
waiters.add(ended);
|
|
1724
|
+
ended();
|
|
1725
|
+
});
|
|
1726
|
+
await Promise.all([...projects.values()].map((ports) => ports.left()));
|
|
1727
|
+
}
|
|
1728
|
+
};
|
|
1729
|
+
shared.set(dataDir, made);
|
|
1730
|
+
return made;
|
|
1731
|
+
}
|
|
1732
|
+
//#endregion
|
|
1733
|
+
//#region src/lib/summary.ts
|
|
1734
|
+
var said = (events) => events.filter((event) => event.type === "text").map((event) => event.text).join("\n");
|
|
1735
|
+
async function recordSummary(deps, job, events) {
|
|
1736
|
+
const { db } = deps;
|
|
1737
|
+
const written = deps.read(join(job.taskDir, job.phase, "summary.md"));
|
|
1738
|
+
const cleaned = written === null ? null : cleanSummary(written);
|
|
1739
|
+
if (cleaned !== null && !needsExtraction(cleaned)) {
|
|
1740
|
+
savePlainSummary(db, job.runId, cleaned);
|
|
1741
|
+
return;
|
|
1742
|
+
}
|
|
1743
|
+
const logPath = job.logPath.replace(/\.ndjson$/, "-summary.ndjson");
|
|
1744
|
+
const { model, effort } = deps.summaryModel;
|
|
1745
|
+
const prompt = extractSummaryPrompt(said(events));
|
|
1746
|
+
const runId = startRun(db, {
|
|
1747
|
+
cardKey: job.cardKey,
|
|
1748
|
+
phase: "extract-summary",
|
|
1749
|
+
engine: deps.engine,
|
|
1750
|
+
model,
|
|
1751
|
+
effort,
|
|
1752
|
+
sessionId: null,
|
|
1753
|
+
logPath,
|
|
1754
|
+
lane: null
|
|
1755
|
+
});
|
|
1756
|
+
const extraction = {
|
|
1757
|
+
...job,
|
|
1758
|
+
runId,
|
|
1759
|
+
phase: "extract-summary",
|
|
1760
|
+
engine: deps.engine,
|
|
1761
|
+
model,
|
|
1762
|
+
effort,
|
|
1763
|
+
prompt,
|
|
1764
|
+
sessionId: null,
|
|
1765
|
+
resumeFrom: null,
|
|
1766
|
+
logPath,
|
|
1767
|
+
tools: EXTRACT_SUMMARY_POLICY.tools,
|
|
1768
|
+
mcpConfigPath: null,
|
|
1769
|
+
mcp: void 0,
|
|
1770
|
+
qaCopy: null
|
|
1771
|
+
};
|
|
1772
|
+
const answer = [];
|
|
1773
|
+
try {
|
|
1774
|
+
for await (const event of deps.extract(extraction)) answer.push(event);
|
|
1775
|
+
} catch (error) {
|
|
1776
|
+
answer.push({
|
|
1777
|
+
type: "failed",
|
|
1778
|
+
reason: error.message,
|
|
1779
|
+
status: null
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
saveRun(db, runId, foldRun(answer, deps.signal?.aborted ?? false));
|
|
1783
|
+
const summary = cleanSummary(said(answer));
|
|
1784
|
+
if (!needsExtraction(summary)) savePlainSummary(db, job.runId, summary);
|
|
1785
|
+
}
|
|
1786
|
+
//#endregion
|
|
1787
|
+
//#region src/lib/named-issues.ts
|
|
1788
|
+
var MOST = 20;
|
|
1789
|
+
var READ_MS = 1e4;
|
|
1790
|
+
function namedNumbers(text, own) {
|
|
1791
|
+
const found = [...text.matchAll(/(?<![\w&/#-])#([1-9]\d{0,6})\b/g)].map((match) => Number(match[1])).filter((number) => number !== own);
|
|
1792
|
+
return [...new Set(found)].slice(0, MOST);
|
|
1793
|
+
}
|
|
1794
|
+
/**
|
|
1795
|
+
* One line per issue a GitHub card's text names by number: "- #2: Holds expire (closed)".
|
|
1796
|
+
*
|
|
1797
|
+
* An epic lists its tasks as `- [ ] #1`, and GitHub shows their titles there, but the text holds the
|
|
1798
|
+
* numbers alone. A run cannot reach GitHub, so without this it spent its turns looking for them. Read
|
|
1799
|
+
* with the person's `gh`, as Add card reads an issue. Empty for any other card, and when GitHub did
|
|
1800
|
+
* not answer: the run then has the ticket as before.
|
|
1801
|
+
*/
|
|
1802
|
+
async function namedIssues(db, key, run, signal) {
|
|
1803
|
+
if (run === null) return [];
|
|
1804
|
+
const card = db.prepare("SELECT summary, source, source_ref FROM cards WHERE key = ?").get(key);
|
|
1805
|
+
if (card === void 0 || card.source !== "github" || card.summary === null || card.source_ref === null) return [];
|
|
1806
|
+
const own = parseTicketRef(card.source_ref);
|
|
1807
|
+
if (own.kind !== "github" || own.owner === null) return [];
|
|
1808
|
+
const { owner, repo } = own;
|
|
1809
|
+
const numbers = namedNumbers(card.summary, own.number);
|
|
1810
|
+
if (numbers.length === 0) return [];
|
|
1811
|
+
try {
|
|
1812
|
+
return (await githubIssues({
|
|
1813
|
+
run,
|
|
1814
|
+
defaultOwner: owner
|
|
1815
|
+
}).get(numbers.map((number) => ({
|
|
1816
|
+
kind: "github",
|
|
1817
|
+
owner,
|
|
1818
|
+
repo,
|
|
1819
|
+
number
|
|
1820
|
+
})), AbortSignal.any([signal, AbortSignal.timeout(READ_MS)]))).flatMap((one, at) => one.ticket === null ? [] : [`- #${numbers[at]}: ${one.ticket.title.replace(/\s+/g, " ").trim()}${one.ticket.state === "closed" ? " (closed)" : ""}`]);
|
|
1821
|
+
} catch {
|
|
1822
|
+
return [];
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
function withNamedIssues(prompt, lines) {
|
|
1826
|
+
if (lines.length === 0) return prompt;
|
|
1827
|
+
const block = `## Issues the ticket names\n\nGitHub's titles for the issues the ticket names by number. This run cannot reach GitHub, so\nthese lines are all it has of them.\n\n${lines.join("\n")}\n\n`;
|
|
1828
|
+
const at = prompt.lastIndexOf("\n## How this run works\n");
|
|
1829
|
+
return at === -1 ? `${prompt}\n${block.trimEnd()}\n` : `${prompt.slice(0, at + 1)}${block}${prompt.slice(at + 1)}`;
|
|
1830
|
+
}
|
|
1831
|
+
//#endregion
|
|
1832
|
+
//#region src/lib/loop.ts
|
|
1833
|
+
var MAINTENANCE_TITLE = "Optimize a knowledge file";
|
|
1834
|
+
var MAINTENANCE_ASK = "This run belongs to no card. Rewrite the one knowledge file named below, and change nothing else.";
|
|
1835
|
+
var LEARN_TITLE = "Learn this project";
|
|
1836
|
+
var learnAsk = (repo) => `This run belongs to no card. A person asked it to learn this project from what people wrote and from their answers.${repo === null ? "" : ` Start with the repository \`${repo}\`, which was added a moment ago.`}`;
|
|
1837
|
+
var learnRepoTitle = (repo) => `Learn the ${repo === "." ? "project folder" : `${repo} repository`}`;
|
|
1838
|
+
var LEARN_REPO_ASK = "This run belongs to no card. A person asked it to learn one repository from its README, CI files and stack files.";
|
|
1839
|
+
var belongsToNoCard = (key) => isMaintenanceKey(key) || findingOfKey(key) !== null;
|
|
1840
|
+
var writtenSince = (taskDir, path, since) => {
|
|
1841
|
+
const file = join(taskDir, path);
|
|
1842
|
+
return existsSync(file) && statSync(file).mtimeMs >= Math.floor(since / 1e3) * 1e3 ? readCardText(taskDir, path) : null;
|
|
1843
|
+
};
|
|
1844
|
+
var picksRepos = (phase) => phase === "refine" || phase === "plan";
|
|
1845
|
+
var readsInPlace = (phase) => picksRepos(phase) || phase === "ask";
|
|
1846
|
+
var readsUnlisted = (phase, board) => phase === "research" || phase === "investigate" || phase === "wrapup" && isResearchKind(board);
|
|
1847
|
+
var noAnswer = (reason) => `No answer came. ${reason ?? "The run ended early."} Its log is on the Log tab.`;
|
|
1848
|
+
function fixOutcome(record, summary) {
|
|
1849
|
+
if (record.cardState === "ready") {
|
|
1850
|
+
const line = summary?.split("\n").map((one) => one.trim()).find((one) => one !== "") ?? "";
|
|
1851
|
+
return {
|
|
1852
|
+
ok: true,
|
|
1853
|
+
note: line === "" ? "The fix ended without a summary. Read its edits on the Changes tab." : line
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1856
|
+
if (record.state === "stopped") return {
|
|
1857
|
+
ok: false,
|
|
1858
|
+
reason: "The fix was stopped."
|
|
1859
|
+
};
|
|
1860
|
+
if (record.cardState === "blocked") return {
|
|
1861
|
+
ok: false,
|
|
1862
|
+
reason: `The fix asked: ${record.question ?? "nothing it wrote down"}`
|
|
1863
|
+
};
|
|
1864
|
+
return {
|
|
1865
|
+
ok: false,
|
|
1866
|
+
reason: record.failureReason ?? "The fix run ended without finishing. Its log is on the Log tab."
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1869
|
+
function sayCutOff(db) {
|
|
1870
|
+
const cut = db.prepare(`SELECT id, card_key, thread, error FROM runs WHERE phase = ? AND thread IS NOT NULL AND state = 'interrupted' AND card_key IN (SELECT key FROM cards)
|
|
1871
|
+
AND NOT EXISTS (SELECT 1 FROM messages WHERE messages.run_id = runs.id AND messages.author = 'agent')`).all("ask");
|
|
1872
|
+
for (const run of cut) addMessage(db, run.card_key, run.thread, "agent", noAnswer(run.error), run.id);
|
|
1873
|
+
}
|
|
1874
|
+
var progressOf = (taskDir, phase) => readCardText(taskDir, join(phase, "progress.md")) ?? void 0;
|
|
1875
|
+
var noRepoList = (key, board) => board.stages.some((stage) => stage.phase !== void 0 && picksRepos(stage.phase)) ? `Nothing says which repositories ${key} changes yet. Run refine or plan on it, or pick them on its Settings tab.` : `Nothing says which repositories ${key} changes yet. Pick them on its Settings tab.`;
|
|
1876
|
+
var open = /* @__PURE__ */ new Map();
|
|
1877
|
+
var schedulers = /* @__PURE__ */ new Map();
|
|
1878
|
+
var PULL_WATCH_MS = 18e4;
|
|
1879
|
+
var PULL_ASK_MS = 3e4;
|
|
1880
|
+
var firstIds = /* @__PURE__ */ new Map();
|
|
1881
|
+
function loop(env = process.env, project) {
|
|
1882
|
+
const dataFolder = resolveDataDir(env);
|
|
1883
|
+
const first = firstLoop(dataFolder, env);
|
|
1884
|
+
const chosen = chosenProject(first.db, project).id;
|
|
1885
|
+
if (project === void 0 && chosen !== first.project && chosen === firstIds.get(dataFolder) && standInOf(dataFolder) === first.project) {
|
|
1886
|
+
writeSetting(first.db, "currentProject", first.project);
|
|
1887
|
+
return first;
|
|
1888
|
+
}
|
|
1889
|
+
try {
|
|
1890
|
+
return createLoop(dataFolder, env, { project: chosen });
|
|
1891
|
+
} catch (error) {
|
|
1892
|
+
if (project !== void 0 || !damagedDatabase(error)) throw error;
|
|
1893
|
+
console.error(`Project ${chosen} could not open (${error.message}), so Nolzu opened project ${first.project} instead. Restart Nolzu and pick it again once it is fixed.`);
|
|
1894
|
+
writeSetting(first.db, "currentProject", first.project);
|
|
1895
|
+
return first;
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
var firstLoop = (dataFolder, env) => openFirstThatOpens(dataFolder, (id) => createLoop(dataFolder, env, id === void 0 ? {} : { project: id }));
|
|
1899
|
+
function loopOf(url, env = process.env) {
|
|
1900
|
+
const named = url.searchParams.get("project");
|
|
1901
|
+
if (named === null) return loop(env);
|
|
1902
|
+
if (!/^\d+$/.test(named)) error(400, "The address names no project by its number.");
|
|
1903
|
+
const dataFolder = resolveDataDir(env);
|
|
1904
|
+
let project;
|
|
1905
|
+
try {
|
|
1906
|
+
project = chosenProject(firstLoop(dataFolder, env).db, Number(named)).id;
|
|
1907
|
+
} catch (refused) {
|
|
1908
|
+
error(409, refused instanceof Error ? refused.message : String(refused));
|
|
1909
|
+
}
|
|
1910
|
+
return createLoop(dataFolder, env, { project });
|
|
1911
|
+
}
|
|
1912
|
+
function checkRunOutputs(db, job, written = {
|
|
1913
|
+
notes: {},
|
|
1914
|
+
created: []
|
|
1915
|
+
}) {
|
|
1916
|
+
const notes = written.notes;
|
|
1917
|
+
try {
|
|
1918
|
+
const folder = join(job.taskDir, job.phase);
|
|
1919
|
+
const own = existsSync(folder) ? readdirSync(folder).filter((name) => name.endsWith(".md")).map((name) => `${job.phase}/${name}`) : [];
|
|
1920
|
+
const files = { ...notes };
|
|
1921
|
+
const board = boardOfCard(db, job.cardKey) ?? void 0;
|
|
1922
|
+
for (const path of /* @__PURE__ */ new Set([...own, ...checkedPaths(job.phase, board)])) {
|
|
1923
|
+
const text = readCardText(job.taskDir, path);
|
|
1924
|
+
if (text !== null) files[path] = text;
|
|
1925
|
+
}
|
|
1926
|
+
const project = job.projectDir ?? null;
|
|
1927
|
+
const instructions = project !== null && readPhaseInstructions(project, job.phase) !== void 0 ? relative(project, phaseInstructionsFile(project, job.phase)) : null;
|
|
1928
|
+
const repos = projectRepos({
|
|
1929
|
+
repos: getSetting(db, "repos"),
|
|
1930
|
+
baseBranch: getSetting(db, "baseBranch")
|
|
1931
|
+
}).map((repo) => repo.path);
|
|
1932
|
+
const check = outputCheck(job.phase, files, instructions, board, repos, written.created);
|
|
1933
|
+
if (check !== null) saveOutputCheck(db, job.runId, check);
|
|
1934
|
+
} catch (error) {
|
|
1935
|
+
noteInRunLog(job.logPath, `The output check could not read what the run wrote: ${error.message}`);
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
/**
|
|
1939
|
+
* Nolzu's own writes, which other cards make while a read-only run goes, left out of its compare: every
|
|
1940
|
+
* card folder, every checkout, the knowledge folders a wrap-up commits to, the `.nolzu/` folder whose
|
|
1941
|
+
* files, such as the MCP list, Nolzu commits when a setting changes, and the `.cursor/mcp.json` it
|
|
1942
|
+
* merges at the project folder for a Cursor run of a Research card, with the `.gitignore` it may make
|
|
1943
|
+
* beside it.
|
|
1944
|
+
*/
|
|
1945
|
+
async function nolzuWrites(project, taskDir, knowledge, env) {
|
|
1946
|
+
const tracked = (await git([
|
|
1947
|
+
"ls-files",
|
|
1948
|
+
"--",
|
|
1949
|
+
".cursor/mcp.json",
|
|
1950
|
+
".cursor/.gitignore"
|
|
1951
|
+
], {
|
|
1952
|
+
cwd: project,
|
|
1953
|
+
env
|
|
1954
|
+
})).stdout.split("\n");
|
|
1955
|
+
const merged = [".cursor/mcp.json", ".cursor/.gitignore"].filter((path) => !tracked.includes(path)).map((path) => join(project, path));
|
|
1956
|
+
return [
|
|
1957
|
+
dirname(taskDir),
|
|
1958
|
+
worktreesFolder(project),
|
|
1959
|
+
join(project, ".nolzu"),
|
|
1960
|
+
...merged,
|
|
1961
|
+
...knowledge.filter((dir) => dir != null)
|
|
1962
|
+
];
|
|
1963
|
+
}
|
|
1964
|
+
async function writtenNotes(run, folder, changes) {
|
|
1965
|
+
const prefix = (await run(["rev-parse", "--show-prefix"])).stdout.trim();
|
|
1966
|
+
const written = {
|
|
1967
|
+
notes: {},
|
|
1968
|
+
created: []
|
|
1969
|
+
};
|
|
1970
|
+
for (const change of changes) {
|
|
1971
|
+
if (change.kind === "removed" || !change.path.startsWith(prefix) || !change.path.endsWith(".md")) continue;
|
|
1972
|
+
const inside = change.path.slice(prefix.length);
|
|
1973
|
+
const text = readCardText(folder, inside);
|
|
1974
|
+
if (text === null) continue;
|
|
1975
|
+
written.notes[`knowledge/${inside}`] = text;
|
|
1976
|
+
if (change.kind === "added") written.created.push(`knowledge/${inside}`);
|
|
1977
|
+
}
|
|
1978
|
+
return written;
|
|
1979
|
+
}
|
|
1980
|
+
function createLoop(dataFolder, env = process.env, options = {}) {
|
|
1981
|
+
const keyOf = (project) => project === void 0 || project === firstIds.get(dataFolder) ? dataFolder : `${dataFolder}#${project}`;
|
|
1982
|
+
let cacheKey = keyOf(options.project);
|
|
1983
|
+
const already = open.get(cacheKey);
|
|
1984
|
+
if (already !== void 0) return already;
|
|
1985
|
+
const db = options.project === void 0 ? openDatabase(dataFolder) : openProject(dataFolder, options.project);
|
|
1986
|
+
let giveBack = () => void 0;
|
|
1987
|
+
try {
|
|
1988
|
+
return build();
|
|
1989
|
+
} catch (error) {
|
|
1990
|
+
giveBack();
|
|
1991
|
+
db.close();
|
|
1992
|
+
throw error;
|
|
1993
|
+
}
|
|
1994
|
+
function build() {
|
|
1995
|
+
const registered = registeredProjects(db).find((one) => options.project === void 0 ? one.file === FIRST_PROJECT : one.id === options.project);
|
|
1996
|
+
if (registered === void 0) throw new Error(`There is no project ${options.project ?? "nolzu.db"} in ${dataFolder}.`);
|
|
1997
|
+
const firstId = registeredProjects(db).find((one) => one.file === FIRST_PROJECT)?.id;
|
|
1998
|
+
if (firstId !== void 0) firstIds.set(dataFolder, firstId);
|
|
1999
|
+
cacheKey = keyOf(registered.id);
|
|
2000
|
+
const dataDir = projectFiles(dataFolder, registered);
|
|
2001
|
+
mkdirSync(dataDir, { recursive: true });
|
|
2002
|
+
const keychain = options.keychain ?? appKeychain(env);
|
|
2003
|
+
const boardNow = (kind = "delivery") => boardFor(kind, getSetting(db, "deliveryFlow"));
|
|
2004
|
+
const boardOf = (key) => boardNow(boardOfCard(db, key) ?? "delivery");
|
|
2005
|
+
const profilesNow = () => getSetting(db, "engineProfiles");
|
|
2006
|
+
const wallNow = () => options.wall ?? wallHere();
|
|
2007
|
+
const fake = isFakeMode(env) ? selectEngine(env) : null;
|
|
2008
|
+
const adapter = (vendor) => {
|
|
2009
|
+
if (fake !== null) return {
|
|
2010
|
+
...fake,
|
|
2011
|
+
vendor,
|
|
2012
|
+
listModels: vendor === fake.vendor ? fake.listModels : () => presetModels(vendor)
|
|
2013
|
+
};
|
|
2014
|
+
const engine = selectEngine(env, {
|
|
2015
|
+
engine: vendor,
|
|
2016
|
+
profiles: profilesNow()
|
|
2017
|
+
});
|
|
2018
|
+
return {
|
|
2019
|
+
...engine,
|
|
2020
|
+
spawn: (job, signal) => engine.spawn({
|
|
2021
|
+
...job,
|
|
2022
|
+
walls: job.walls ?? getSetting(db, "wallLists")
|
|
2023
|
+
}, signal)
|
|
2024
|
+
};
|
|
2025
|
+
};
|
|
2026
|
+
const engineFor = (profile) => {
|
|
2027
|
+
const vendor = profilesNow().find((one) => one.id === profile)?.vendor;
|
|
2028
|
+
if (vendor === void 0) throw new Error(missingProfileText(profile));
|
|
2029
|
+
return adapter(vendor);
|
|
2030
|
+
};
|
|
2031
|
+
const wallOf = (profile) => fake !== null ? "none" : wallKind(profilesNow().find((one) => one.id === profile)?.vendor ?? profile, wallNow(), process.platform);
|
|
2032
|
+
const runnable = (vendor) => ENGINES.includes(vendor);
|
|
2033
|
+
const defaultEngine = () => adapter(profilesNow().find((one) => runnable(one.vendor))?.vendor ?? DEFAULT_PROFILE.vendor);
|
|
2034
|
+
const offered = () => {
|
|
2035
|
+
const table = {};
|
|
2036
|
+
for (const vendor of new Set(profilesNow().map((one) => one.vendor))) {
|
|
2037
|
+
if (!runnable(vendor)) continue;
|
|
2038
|
+
const list = adapter(vendor).listModels();
|
|
2039
|
+
if (list.length > 0) table[vendor] = list;
|
|
2040
|
+
}
|
|
2041
|
+
return table;
|
|
2042
|
+
};
|
|
2043
|
+
defaultEngine();
|
|
2044
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
2045
|
+
let closed = false;
|
|
2046
|
+
const leaving = new AbortController();
|
|
2047
|
+
const asking = /* @__PURE__ */ new Set();
|
|
2048
|
+
const fixes = /* @__PURE__ */ new Map();
|
|
2049
|
+
const dropUnanswered = () => {
|
|
2050
|
+
for (const [key, fix] of fixes) {
|
|
2051
|
+
if (fix.asked === void 0) continue;
|
|
2052
|
+
if (db.prepare("SELECT state FROM cards WHERE key = ?").get(key)?.state === "blocked") continue;
|
|
2053
|
+
fixes.delete(key);
|
|
2054
|
+
for (const row of fix.rows) endFix(db, row.id, {
|
|
2055
|
+
ok: false,
|
|
2056
|
+
reason: `The card moved before the fix's question was answered. The fix asked: ${fix.asked}`
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
};
|
|
2060
|
+
const pullAsked = /* @__PURE__ */ new Map();
|
|
2061
|
+
const watchPulls = (key) => {
|
|
2062
|
+
const gh = options.gh ?? (isFakeMode(env) ? null : ghRunner());
|
|
2063
|
+
if (closed || gh === null) return;
|
|
2064
|
+
const now = Date.now();
|
|
2065
|
+
const keys = key !== void 0 ? [key] : unlinkedCards(db).filter((one) => now - (pullAsked.get(one) ?? 0) >= PULL_WATCH_MS);
|
|
2066
|
+
if (keys.length === 0) return;
|
|
2067
|
+
for (const one of keys) pullAsked.set(one, now);
|
|
2068
|
+
linkOpenPulls(db, keys, gh, AbortSignal.timeout(PULL_ASK_MS)).then((linked) => {
|
|
2069
|
+
if (linked.length > 0 && !closed) changed();
|
|
2070
|
+
}, () => void 0);
|
|
2071
|
+
};
|
|
2072
|
+
const pullTimer = setInterval(() => watchPulls(), PULL_WATCH_MS);
|
|
2073
|
+
pullTimer.unref();
|
|
2074
|
+
let afterLearn = () => {};
|
|
2075
|
+
const changed = () => {
|
|
2076
|
+
if (!closed) dropUnanswered();
|
|
2077
|
+
for (const listen of [...listeners]) listen();
|
|
2078
|
+
if (!closed) afterLearn();
|
|
2079
|
+
};
|
|
2080
|
+
const live = /* @__PURE__ */ new Map();
|
|
2081
|
+
const watchers = /* @__PURE__ */ new Set();
|
|
2082
|
+
const heard = (runId, event) => {
|
|
2083
|
+
const entry = live.get(runId);
|
|
2084
|
+
if (closed || entry === void 0) return;
|
|
2085
|
+
const line = event === void 0 ? null : activityLine(event, entry.cwd);
|
|
2086
|
+
entry.activity = {
|
|
2087
|
+
...entry.activity,
|
|
2088
|
+
line: line ?? entry.activity.line,
|
|
2089
|
+
outputAt: Date.now()
|
|
2090
|
+
};
|
|
2091
|
+
for (const watch of [...watchers]) try {
|
|
2092
|
+
watch(entry.activity);
|
|
2093
|
+
} catch {
|
|
2094
|
+
watchers.delete(watch);
|
|
2095
|
+
}
|
|
2096
|
+
};
|
|
2097
|
+
const modelsFor = (key, onProfile = null) => resolveModels(cardModels(db, key), cardBase(db, key), cardPreset(db, key), offered(), projectProfiles(db), onProfile);
|
|
2098
|
+
const reposNow = () => projectRepos({
|
|
2099
|
+
repos: getSetting(db, "repos"),
|
|
2100
|
+
baseBranch: getSetting(db, "baseBranch")
|
|
2101
|
+
});
|
|
2102
|
+
const buildJob = (key, phase, runId, file = null, onProfile = null, onModel = null, resumed = null) => {
|
|
2103
|
+
if (!isAction(phase)) throw new Error(`The ${phase} phase starts no run yet, so there is no model for it and no job to build.`);
|
|
2104
|
+
const resolved = modelsFor(key, onProfile)[phase];
|
|
2105
|
+
if (resolved.missingProfile) throw new Error(`${key} runs ${phase} on the engine profile ${resolved.engine}, which this machine has no login for. Add it on the Engines screen, or set the row back to inherit on the card's Settings tab.`);
|
|
2106
|
+
const vendorHere = profilesNow().find((one) => one.id === resolved.engine)?.vendor;
|
|
2107
|
+
const project = getSetting(db, "projectPath");
|
|
2108
|
+
const outsideGit = projectOutsideGit(db);
|
|
2109
|
+
const refusedHere = vendorHere === void 0 ? null : vendorRefusal(vendorHere, phase, {
|
|
2110
|
+
outsideGit,
|
|
2111
|
+
wall: wallNow()
|
|
2112
|
+
});
|
|
2113
|
+
if (refusedHere !== null) throw new Error(`${key} cannot run ${phase} on ${resolved.engine}. ${refusedHere}`);
|
|
2114
|
+
const model = onModel ?? resolved.model;
|
|
2115
|
+
const known = modelsForPick(resolved, profilesNow(), offered());
|
|
2116
|
+
if (known.length > 0 && !known.includes(model)) throw new Error(`${key} runs ${phase} on ${model}, which the engine no longer offers. Pick another model on the card's Settings tab.`);
|
|
2117
|
+
const assessing = findingOfKey(key);
|
|
2118
|
+
const learning = repoOfLearnKey(key);
|
|
2119
|
+
if (learning !== null !== (phase === "learn-repo")) throw new Error(`${phaseLabel(phase)} cannot run under the key ${key}.`);
|
|
2120
|
+
if (learning !== null && !reposNow().some((repo) => repo.path === learning)) throw new Error(`There is no repository ${JSON.stringify(learning)} in this project, so there is nothing to learn.`);
|
|
2121
|
+
const card = key === "kb-maintenance" ? phase === "orient" ? {
|
|
2122
|
+
key,
|
|
2123
|
+
title: LEARN_TITLE,
|
|
2124
|
+
summary: learnAsk(file),
|
|
2125
|
+
extra_context: null
|
|
2126
|
+
} : {
|
|
2127
|
+
key,
|
|
2128
|
+
title: MAINTENANCE_TITLE,
|
|
2129
|
+
summary: MAINTENANCE_ASK,
|
|
2130
|
+
extra_context: null
|
|
2131
|
+
} : learning !== null ? {
|
|
2132
|
+
key,
|
|
2133
|
+
title: learnRepoTitle(learning),
|
|
2134
|
+
summary: LEARN_REPO_ASK,
|
|
2135
|
+
extra_context: null
|
|
2136
|
+
} : assessing !== null ? findingCard(assessing, key) : db.prepare("SELECT key, title, summary, extra_context FROM cards WHERE key = ?").get(key);
|
|
2137
|
+
if (card === void 0) throw new Error(`There is no card ${key}, so no job can be built for it.`);
|
|
2138
|
+
if (!isPlainName(key)) throw new Error(`The card key ${JSON.stringify(key)} is not one plain name, so it cannot name the card's folders.`);
|
|
2139
|
+
if (project === null && !isFakeMode(env)) throw new Error(`There is no project set, so ${key} has no checkout to run in. Make a project on New project at /new.`);
|
|
2140
|
+
const policy = policyFor(phase);
|
|
2141
|
+
const knowledgeDir = policy.knowledge === true ? knowledgeFolder(key, phase, resumed !== null) : null;
|
|
2142
|
+
const knowledgeFile = file === null || phase === "orient" ? null : file.trim();
|
|
2143
|
+
if (phase === "orient" && file !== null && !reposNow().some((repo) => repo.path === file)) throw new Error(`There is no repository ${JSON.stringify(file)} in this project, so Learn this project has nothing to start with.`);
|
|
2144
|
+
if (phase === "optimize" && (knowledgeFile === null || knowledgeFile === "")) throw new Error("No knowledge file was named, so there is nothing to rewrite.");
|
|
2145
|
+
if (knowledgeFile !== null && (knowledgeDir === null || !knowledgeFiles(knowledgeDir).includes(knowledgeFile))) throw new Error(`There is no knowledge file ${JSON.stringify(knowledgeFile)} in ${knowledgeDir ?? "the knowledge folder"}, so there is nothing to rewrite.`);
|
|
2146
|
+
const listed = project === null || belongsToNoCard(key) ? 1 : reposNow().length;
|
|
2147
|
+
const several = listed > 1;
|
|
2148
|
+
const unlisted = listed === 0 || several && reposOfCard(db, key) === null;
|
|
2149
|
+
const readsIfUnlisted = readsUnlisted(phase, boardOfCard(db, key) ?? "delivery");
|
|
2150
|
+
const inPlace = readsInPlace(phase) || unlisted && readsIfUnlisted;
|
|
2151
|
+
if (listed === 0 && !inPlace) throw new Error(NO_REPOSITORY);
|
|
2152
|
+
if (several && !inPlace && reposOfCard(db, key) === null) throw new Error(noRepoList(key, boardOf(key)));
|
|
2153
|
+
const looks = listed !== 1 && picksRepos(phase) || phase === "ask" || unlisted && readsIfUnlisted || resumed !== null && listed !== 1 && readsIfUnlisted;
|
|
2154
|
+
const madeIn = project !== null && looks && resumed !== null ? sessionFolder(db, key, resumed) : null;
|
|
2155
|
+
const at = project === null ? dataDir : madeIn === project || madeIn === checkoutRoot(project, key) ? madeIn : belongsToNoCard(key) || looks && !existsSync(checkoutRoot(project, key)) ? project : checkoutRoot(project, key);
|
|
2156
|
+
const shell = policy.tools.includes("Bash");
|
|
2157
|
+
const picked = project === null || !shell || at !== checkoutRoot(project, key) || looks ? null : several ? reposOfCard(db, key) : reposNow().map((repo) => repo.path);
|
|
2158
|
+
const inRepo = project !== null && picked?.length === 1 ? checkoutPath(project, key, picked[0]) : null;
|
|
2159
|
+
const cwd = inRepo !== null && (resumed === null || sessionFolder(db, key, resumed) === inRepo) ? inRepo : at;
|
|
2160
|
+
const settingsPath = engineSettings(project);
|
|
2161
|
+
if (project !== null && !existsSync(join(project, ".claude/hooks/nolzu-phase-guard.mjs")) && (belongsToNoCard(key) || cwd === project)) {
|
|
2162
|
+
const held = isMaintenanceKey(key) ? "a maintenance run to the knowledge folder" : belongsToNoCard(key) ? "an assessment run to reading" : phase === "ask" ? "an Ask run to reading" : `a ${phase} run to its card folder`;
|
|
2163
|
+
throw new Error(`This project has no run guard at ${GUARD_PATH}, so nothing would hold ${held}. Press Write the project files in Project settings.`);
|
|
2164
|
+
}
|
|
2165
|
+
const taskDir = join(project ?? dataDir, ".tasks", key);
|
|
2166
|
+
const vendor = engineFor(resolved.engine).vendor;
|
|
2167
|
+
const inCardFolder = resumed !== null ? sessionInCardFolder(db, key, resumed, vendor, phase) : startsInCardFolder(vendor, phase, ownSandbox(vendor, wallNow()));
|
|
2168
|
+
const qaCopy = project !== null && !inCardFolder && policy.readOnly && policy.commands === true ? qaCopyPath(dataFolder, cwd, key) : null;
|
|
2169
|
+
const startIn = inCardFolder ? taskDir : qaCopy ?? cwd;
|
|
2170
|
+
const named = (path) => qaCopy === null ? relative(startIn, path) || "." : resolvedPath(path);
|
|
2171
|
+
const instructions = phase === "ask" ? null : phaseInstructions(phase, project === null ? void 0 : (name, shipped) => personsSkillEdit(project, `nolzu-${phase}/${name}`, shipped));
|
|
2172
|
+
const repositories = project !== null && several && picksRepos(phase) ? reposNow().map((repo) => repo.path) : void 0;
|
|
2173
|
+
const knowledgeHome = resolveKnowledgeDir({
|
|
2174
|
+
knowledgeDir: getSetting(db, "knowledgeDir"),
|
|
2175
|
+
projectPath: project
|
|
2176
|
+
});
|
|
2177
|
+
const reposInPrompt = project === null ? void 0 : repositories?.map((name) => {
|
|
2178
|
+
const checkout = checkoutPath(project, key, name);
|
|
2179
|
+
const at = existsSync(join(checkout, ".git")) ? checkout : repoFolder(project, name);
|
|
2180
|
+
const knowledge = knowledgeHome === null ? null : join(knowledgeHome, repoKnowledgePath(name));
|
|
2181
|
+
return {
|
|
2182
|
+
name,
|
|
2183
|
+
path: relative(startIn, at) || ".",
|
|
2184
|
+
knowledge: knowledge !== null && existsSync(knowledge) ? relative(startIn, knowledge) : null
|
|
2185
|
+
};
|
|
2186
|
+
});
|
|
2187
|
+
const progress = progressOf(taskDir, phase);
|
|
2188
|
+
const epic = phase === "ask" ? null : epicOfTask(db, key);
|
|
2189
|
+
const epicFiles = epic === null ? [] : epicDocPaths(join(project ?? dataDir, ".tasks", epic.key));
|
|
2190
|
+
if (instructions === null && phase !== "ask") throw new Error(`Nolzu cannot read the ${phase} skill it ships, so the run would have the card and no method. Install Nolzu again.`);
|
|
2191
|
+
const projectInstructions = project === null ? void 0 : readPhaseInstructions(project, phase);
|
|
2192
|
+
const readFirst = phase === "ask" ? [] : phase === "pr-review" ? roundsIn(taskDir).map((round) => join(taskDir, round.file)) : readFirstPaths(taskDir, phase);
|
|
2193
|
+
const laterInstructions = project === null || phase !== "plan" ? [] : ["implement", "qa"].filter((later) => readPhaseInstructions(project, later) !== void 0).map((later) => ({
|
|
2194
|
+
phase: later,
|
|
2195
|
+
file: phaseInstructionsFile(project, later)
|
|
2196
|
+
}));
|
|
2197
|
+
const allRepos = reposNow().map((repo) => repo.path);
|
|
2198
|
+
const scope = project === null || belongsToNoCard(key) ? void 0 : {
|
|
2199
|
+
card: reposOfCard(db, key) ?? allRepos,
|
|
2200
|
+
repos: allRepos
|
|
2201
|
+
};
|
|
2202
|
+
const knowledgeIndex = knowledgeDir !== null || phase === "ask" || knowledgeHome === null ? null : pickKnowledge(knowledgeIndexFiles(knowledgeHome), void 0, scope);
|
|
2203
|
+
const knowledgeReadDir = knowledgeHome !== null && knowledgeIndex !== null && knowledgeIndex.kept.length > 0 ? knowledgeHome : null;
|
|
2204
|
+
const readFiles = laterInstructions.map((later) => later.file);
|
|
2205
|
+
const allowedCommands = policy.tools.includes("Bash") ? [.../* @__PURE__ */ new Set([...fillAllowedCommands(db), ...policy.readGit === true ? READ_GIT_COMMANDS : []])] : [];
|
|
2206
|
+
const apps = allowedCommands.length === 0 ? null : getSetting(db, "qaApp");
|
|
2207
|
+
const answers = apps === null ? [] : qaReposOf(db, key).flatMap((repo) => answerFor(apps, repo) ?? []);
|
|
2208
|
+
const firstQa = answers.filter((app, index) => answers.indexOf(app) === index);
|
|
2209
|
+
const personsSaid = {
|
|
2210
|
+
...personsWords(db, key, boardOf(key).stages),
|
|
2211
|
+
allowedCommands,
|
|
2212
|
+
...firstQa.length === 0 ? {} : { firstQa }
|
|
2213
|
+
};
|
|
2214
|
+
const oneRepo = project === null || belongsToNoCard(key) ? void 0 : several ? inRepo === null ? void 0 : picked?.[0] : reposNow()[0]?.path;
|
|
2215
|
+
const commit = project === null || oneRepo === void 0 ? null : existsSync(join(checkoutPath(project, key, oneRepo), ".git")) ? commitAt(checkoutPath(project, key, oneRepo), gitEnv(env)) : commitAt(repoFolder(project, oneRepo), gitEnv(env), reposNow().find((repo) => repo.path === oneRepo)?.base ?? getSetting(db, "baseBranch"));
|
|
2216
|
+
const onServers = promptMcp(project, phase, vendor, getSetting(db, "qaMcpConfigPath"));
|
|
2217
|
+
return {
|
|
2218
|
+
runId,
|
|
2219
|
+
cardKey: key,
|
|
2220
|
+
engine: resolved.engine,
|
|
2221
|
+
phase,
|
|
2222
|
+
cwd,
|
|
2223
|
+
...qaCopy === null ? {} : { qaCopy },
|
|
2224
|
+
taskDir,
|
|
2225
|
+
projectDir: project,
|
|
2226
|
+
knowledgeDir,
|
|
2227
|
+
knowledgeFile,
|
|
2228
|
+
instructions,
|
|
2229
|
+
prompt: phase === "ask" ? askPrompt({
|
|
2230
|
+
key: card.key,
|
|
2231
|
+
title: card.title,
|
|
2232
|
+
ticket: card.summary ?? "",
|
|
2233
|
+
extra: card.extra_context ?? "",
|
|
2234
|
+
folder: relative(startIn, taskDir) || ".",
|
|
2235
|
+
projectInstructions
|
|
2236
|
+
}) : buildPrompt({
|
|
2237
|
+
phase,
|
|
2238
|
+
key: card.key,
|
|
2239
|
+
title: card.title,
|
|
2240
|
+
ticket: card.summary ?? "",
|
|
2241
|
+
extra: card.extra_context ?? "",
|
|
2242
|
+
readOnly: policy.readOnly,
|
|
2243
|
+
folder: named(taskDir),
|
|
2244
|
+
fullPaths: qaCopy !== null,
|
|
2245
|
+
checkout: inCardFolder ? relative(startIn, cwd) : void 0,
|
|
2246
|
+
knowledgeFolder: knowledgeDir === null ? void 0 : relative(startIn, knowledgeDir),
|
|
2247
|
+
knowledgeNote: knowledgeDir === null ? void 0 : returnedKnowledgeNote(db, card.key, key === "kb-maintenance" ? phase : void 0) ?? void 0,
|
|
2248
|
+
knowledgeFile: knowledgeFile ?? void 0,
|
|
2249
|
+
learnRepo: learning === null || project === null ? void 0 : {
|
|
2250
|
+
name: learning,
|
|
2251
|
+
path: named(repoFolder(project, learning))
|
|
2252
|
+
},
|
|
2253
|
+
progress,
|
|
2254
|
+
repositories: reposInPrompt,
|
|
2255
|
+
folderRepos: project !== null && picked !== null && picked.length > 1 ? picked.map((name) => ({
|
|
2256
|
+
name,
|
|
2257
|
+
path: relative(cwd, checkoutPath(project, key, name)) || "."
|
|
2258
|
+
})) : void 0,
|
|
2259
|
+
epic: epic === null || epicFiles.length === 0 ? void 0 : {
|
|
2260
|
+
key: epic.key,
|
|
2261
|
+
title: epic.title,
|
|
2262
|
+
files: epicFiles.map(named)
|
|
2263
|
+
},
|
|
2264
|
+
...boardOfCard(db, key) === "epics" ? { epicCard: true } : {},
|
|
2265
|
+
...existsSync(join(taskDir, "from-epic.md")) ? { epicNotes: named(join(taskDir, FROM_EPIC_FILE)) } : {},
|
|
2266
|
+
projectInstructions,
|
|
2267
|
+
readFirst: readFirst.map(named),
|
|
2268
|
+
laterInstructions: laterInstructions.map((later) => ({
|
|
2269
|
+
phase: later.phase,
|
|
2270
|
+
path: named(later.file)
|
|
2271
|
+
})),
|
|
2272
|
+
personsWords: personsSaid,
|
|
2273
|
+
...phase === "wrapup" ? { history: cardHistory(db, key, runId) } : {},
|
|
2274
|
+
knowledgeIndex: knowledgeReadDir === null || knowledgeIndex === null ? void 0 : {
|
|
2275
|
+
folder: named(knowledgeReadDir),
|
|
2276
|
+
files: knowledgeIndex.kept,
|
|
2277
|
+
left: knowledgeIndex.left,
|
|
2278
|
+
other: knowledgeIndex.other
|
|
2279
|
+
},
|
|
2280
|
+
commit: commit ?? void 0,
|
|
2281
|
+
browser: onServers.browser,
|
|
2282
|
+
servers: onServers.servers
|
|
2283
|
+
}),
|
|
2284
|
+
model,
|
|
2285
|
+
effort: resolved.effort,
|
|
2286
|
+
sessionId: null,
|
|
2287
|
+
resumeFrom: null,
|
|
2288
|
+
timeoutMs: getSetting(db, "runTimeoutMs"),
|
|
2289
|
+
logPath: join(dataDir, "logs", `${key}-${phase}-${runId}.ndjson`),
|
|
2290
|
+
lane: policy.knowledge === true ? "knowledge" : phase === "qa" ? "stack" : phase === "assess" ? "scout" : null,
|
|
2291
|
+
mcpConfigPath: null,
|
|
2292
|
+
settingsPath,
|
|
2293
|
+
tools: policy.tools,
|
|
2294
|
+
allowedCommands,
|
|
2295
|
+
...repositories === void 0 ? {} : { repositories },
|
|
2296
|
+
...epicFiles.length === 0 ? {} : { epicFiles },
|
|
2297
|
+
...readFiles.length === 0 ? {} : { readFiles },
|
|
2298
|
+
...knowledgeReadDir === null ? {} : { knowledgeReadDir },
|
|
2299
|
+
...outsideGit ? { outsideGit: true } : {},
|
|
2300
|
+
...vendor === "codex" ? { startsInCardFolder: inCardFolder } : {}
|
|
2301
|
+
};
|
|
2302
|
+
};
|
|
2303
|
+
/**
|
|
2304
|
+
* The repositories a refine or plan run named for its card, kept as the card's list.
|
|
2305
|
+
*
|
|
2306
|
+
* Only for a run that completed, on a project with several repositories. The line at the end of
|
|
2307
|
+
* the phase's file says which. A file this run did not write, or one with no such line, changes
|
|
2308
|
+
* nothing. A name the project does not list is dropped, and the run's log says so. A repository
|
|
2309
|
+
* the card has a checkout of stays, because its work there would drop out of the card's changes.
|
|
2310
|
+
* A person's own list is never replaced; `setCardRepos` holds to that.
|
|
2311
|
+
*/
|
|
2312
|
+
const keepNamedRepos = (job, since) => {
|
|
2313
|
+
const project = getSetting(db, "projectPath");
|
|
2314
|
+
if (project === null || belongsToNoCard(job.cardKey) || job.phase !== "refine" && job.phase !== "plan") return;
|
|
2315
|
+
const paths = reposNow().map((repo) => repo.path);
|
|
2316
|
+
if (paths.length < 2) return;
|
|
2317
|
+
const text = writtenSince(job.taskDir, join(job.phase, job.phase === "refine" ? "refined.md" : "plan.md"), since);
|
|
2318
|
+
const named = text === null ? null : repositoriesLine(text, paths);
|
|
2319
|
+
if (named === null) return;
|
|
2320
|
+
if (named.known.length > 0) {
|
|
2321
|
+
const list = paths.filter((path) => named.known.includes(path) || existsSync(join(checkoutPath(project, job.cardKey, path), ".git")));
|
|
2322
|
+
if (setCardRepos(db, job.cardKey, list, job.phase)) changed();
|
|
2323
|
+
}
|
|
2324
|
+
if (named.unknown.length > 0) {
|
|
2325
|
+
const one = named.unknown.length === 1;
|
|
2326
|
+
noteInRunLog(job.logPath, `The ${job.phase} named ${named.unknown.join(", ")}, which ${one ? "is not a repository" : "are not repositories"} of this project, so ${job.cardKey}'s list leaves ${one ? "it" : "them"} out.`);
|
|
2327
|
+
}
|
|
2328
|
+
};
|
|
2329
|
+
const keepNamedReposSafely = (job, since) => {
|
|
2330
|
+
try {
|
|
2331
|
+
keepNamedRepos(job, since);
|
|
2332
|
+
} catch (error) {
|
|
2333
|
+
console.error(`Keeping the repositories ${job.cardKey}'s ${job.phase} named failed: ${error.message}`);
|
|
2334
|
+
}
|
|
2335
|
+
};
|
|
2336
|
+
const takeRefinedTitle = (job, since) => {
|
|
2337
|
+
if (job.phase !== "refine" || belongsToNoCard(job.cardKey)) return;
|
|
2338
|
+
try {
|
|
2339
|
+
const text = writtenSince(job.taskDir, join("refine", "refined.md"), since);
|
|
2340
|
+
const title = text === null ? null : refinedTitle(text, job.cardKey);
|
|
2341
|
+
if (title !== null && setCardTitle(db, job.cardKey, title, "refine")) changed();
|
|
2342
|
+
} catch (error) {
|
|
2343
|
+
console.error(`Taking the title ${job.cardKey}'s refine wrote failed: ${error.message}`);
|
|
2344
|
+
}
|
|
2345
|
+
};
|
|
2346
|
+
const renameAfterRefine = async (job) => {
|
|
2347
|
+
const project = getSetting(db, "projectPath");
|
|
2348
|
+
if (job.phase !== "refine" || project === null || belongsToNoCard(job.cardKey) || !isPlainName(job.cardKey)) return;
|
|
2349
|
+
try {
|
|
2350
|
+
const checkouts = cardCheckouts(db, job.cardKey);
|
|
2351
|
+
if (checkouts.length === 0) return;
|
|
2352
|
+
const forGit = gitEnv(env);
|
|
2353
|
+
const from = await cardBranch(db, job.cardKey, checkouts.map((one) => one.path), forGit);
|
|
2354
|
+
const done = await renameFreshBranch({
|
|
2355
|
+
checkouts,
|
|
2356
|
+
from,
|
|
2357
|
+
to: templateBranch(db, job.cardKey),
|
|
2358
|
+
env: forGit
|
|
2359
|
+
});
|
|
2360
|
+
if (done.renamed) changed();
|
|
2361
|
+
else if (done.reason !== null) noteInRunLog(job.logPath, done.reason);
|
|
2362
|
+
} catch (error) {
|
|
2363
|
+
console.error(`Renaming ${job.cardKey}'s branch after refine failed: ${error.message}`);
|
|
2364
|
+
}
|
|
2365
|
+
};
|
|
2366
|
+
/**
|
|
2367
|
+
* What an assessment run carries where a card's title and ticket text would be.
|
|
2368
|
+
*
|
|
2369
|
+
* The finding is the whole ticket. The two collected lines are the evidence, so they travel into
|
|
2370
|
+
* the prompt as they were pasted. They stay out of the key, the log path and every screen label,
|
|
2371
|
+
* because pasted text can hold a real token.
|
|
2372
|
+
*/
|
|
2373
|
+
const findingCard = (findingId, key) => {
|
|
2374
|
+
const finding = scoutFinding(db, findingId);
|
|
2375
|
+
if (finding === null) throw new Error(`There is no finding ${findingId} on this machine, so there is nothing to assess. It may have gone with the source that found it.`);
|
|
2376
|
+
const first = finding.lastMessage.split("\n")[0]?.trim() ?? "";
|
|
2377
|
+
const seen = finding.occurrences === 1 ? "once" : `${finding.occurrences} times`;
|
|
2378
|
+
const lines = finding.firstMessage === finding.lastMessage ? `The line as it was collected:\n\n${finding.lastMessage}` : `The first line seen:\n\n${finding.firstMessage}\n\nThe newest line seen:\n\n${finding.lastMessage}`;
|
|
2379
|
+
return {
|
|
2380
|
+
key,
|
|
2381
|
+
title: first === "" ? `Scout finding ${findingId}` : first,
|
|
2382
|
+
summary: [
|
|
2383
|
+
"This run belongs to no card. Scout found the event below, and this run says what is behind it.",
|
|
2384
|
+
`Seen ${seen}, first on ${finding.firstSeen} and last on ${finding.lastSeen}.${finding.location === "" ? "" : `\nWhere it happens: ${finding.location}`}`,
|
|
2385
|
+
lines
|
|
2386
|
+
].join("\n\n"),
|
|
2387
|
+
extra_context: null
|
|
2388
|
+
};
|
|
2389
|
+
};
|
|
2390
|
+
/**
|
|
2391
|
+
* The knowledge folder this project writes into, for a run that is about to be built.
|
|
2392
|
+
*
|
|
2393
|
+
* Nothing is made here. The folder is made when the run gets its slot, because a job that waits
|
|
2394
|
+
* in the queue may never run at all.
|
|
2395
|
+
*/
|
|
2396
|
+
const knowledgeFolder = (key, phase, answering) => {
|
|
2397
|
+
const again = phase === "learn-repo" ? "start Learn your repositories again" : key !== "kb-maintenance" ? `run ${key} again` : phase === "orient" ? answering ? "send your answer again" : "press Learn this project again" : "start the Optimize run again";
|
|
2398
|
+
const who = isMaintenanceKey(key) ? "a maintenance run" : key;
|
|
2399
|
+
const pending = pendingKnowledgeChanges(db);
|
|
2400
|
+
if (pending.length > 0 && !aheadOfReview) {
|
|
2401
|
+
const files = [...new Set(pending.map((change) => change.filePath))].join(", ");
|
|
2402
|
+
throw new Error(`Knowledge from an earlier run is still waiting for a person: ${files}. Approve or return it on the Knowledge screen at /knowledge, then ${again}.`);
|
|
2403
|
+
}
|
|
2404
|
+
const folder = resolveKnowledgeDir({
|
|
2405
|
+
knowledgeDir: getSetting(db, "knowledgeDir"),
|
|
2406
|
+
projectPath: getSetting(db, "projectPath")
|
|
2407
|
+
});
|
|
2408
|
+
if (folder === null) throw new Error(`There is no project set, so ${who} has no knowledge folder to write into. Make a project on New project at /new.`);
|
|
2409
|
+
return folder;
|
|
2410
|
+
};
|
|
2411
|
+
const engineSettings = (project) => {
|
|
2412
|
+
const path = join(dataDir, "engine-settings.json");
|
|
2413
|
+
mkdirSync(dataDir, { recursive: true });
|
|
2414
|
+
writeFileSync(path, guardSettings(project !== null && existsSync(join(project, ".claude/hooks/nolzu-phase-guard.mjs")) ? project : null));
|
|
2415
|
+
return path;
|
|
2416
|
+
};
|
|
2417
|
+
const failStart = (key, phase, error) => {
|
|
2418
|
+
const runId = startRun(db, {
|
|
2419
|
+
cardKey: key,
|
|
2420
|
+
phase,
|
|
2421
|
+
engine: projectProfiles(db)[0]?.id ?? DEFAULT_PROFILE.id,
|
|
2422
|
+
model: null,
|
|
2423
|
+
effort: null,
|
|
2424
|
+
sessionId: null,
|
|
2425
|
+
logPath: "",
|
|
2426
|
+
lane: null
|
|
2427
|
+
});
|
|
2428
|
+
const record = foldRun([{
|
|
2429
|
+
type: "failed",
|
|
2430
|
+
reason: error.message,
|
|
2431
|
+
status: null
|
|
2432
|
+
}]);
|
|
2433
|
+
saveRun(db, runId, record);
|
|
2434
|
+
db.prepare("UPDATE cards SET state = ? WHERE key = ?").run(record.cardState, key);
|
|
2435
|
+
if (phase !== "ask" && !belongsToNoCard(key)) noteRunEnd(db, {
|
|
2436
|
+
id: runId,
|
|
2437
|
+
key,
|
|
2438
|
+
phase
|
|
2439
|
+
}, record, null);
|
|
2440
|
+
noteMaintenanceFailure(db, {
|
|
2441
|
+
id: runId,
|
|
2442
|
+
key,
|
|
2443
|
+
phase
|
|
2444
|
+
}, record);
|
|
2445
|
+
changed();
|
|
2446
|
+
};
|
|
2447
|
+
/**
|
|
2448
|
+
* Where a finished run leaves the card: its state always, and its stage when `chainTo` takes it one
|
|
2449
|
+
* column on, onto a person's column or the archive. Null `run` is a run that never chains: a Fix
|
|
2450
|
+
* or a triage, which hand the card back as it was.
|
|
2451
|
+
*
|
|
2452
|
+
* The stage is read here and not when the run started, because a run takes minutes and the card
|
|
2453
|
+
* may have been moved in the meantime. A card on the archive reads idle, as a drag there leaves it,
|
|
2454
|
+
* so it counts as done and not as waiting.
|
|
2455
|
+
*
|
|
2456
|
+
* A chain writes its timeline row the way a move by hand does, in one transaction with the stage,
|
|
2457
|
+
* so the timeline never shows a move the board did not make. It starts no run, so the row names
|
|
2458
|
+
* no phase.
|
|
2459
|
+
*/
|
|
2460
|
+
const landCard = (key, state, run) => {
|
|
2461
|
+
db.exec("BEGIN IMMEDIATE");
|
|
2462
|
+
try {
|
|
2463
|
+
const card = run === null ? void 0 : db.prepare("SELECT stage, board FROM cards WHERE key = ?").get(key);
|
|
2464
|
+
const board = card === void 0 ? void 0 : boardNow(card.board);
|
|
2465
|
+
const to = card === void 0 || board === void 0 || run === null ? void 0 : chainTo(board, card.stage, {
|
|
2466
|
+
phase: run.phase,
|
|
2467
|
+
state,
|
|
2468
|
+
verdict: run.verdict,
|
|
2469
|
+
waits: cardHolds(db, key) !== null
|
|
2470
|
+
});
|
|
2471
|
+
if (card === void 0 || board === void 0 || to === void 0) db.prepare("UPDATE cards SET state = ? WHERE key = ?").run(state, key);
|
|
2472
|
+
else {
|
|
2473
|
+
recordMove(db, key, card.stage, to, "auto", null);
|
|
2474
|
+
db.prepare("UPDATE cards SET state = ?, stage = ? WHERE key = ?").run(board.stages.find((stage) => stage.id === to)?.role === "archive" ? "idle" : state, to, key);
|
|
2475
|
+
}
|
|
2476
|
+
db.exec("COMMIT");
|
|
2477
|
+
} catch (error) {
|
|
2478
|
+
if (db.isTransaction) db.exec("ROLLBACK");
|
|
2479
|
+
throw error;
|
|
2480
|
+
}
|
|
2481
|
+
};
|
|
2482
|
+
/**
|
|
2483
|
+
* The chain a person allowed in advance (`PRODUCT-BRIEF.md` 3.1): a small Delivery card whose plan
|
|
2484
|
+
* ended ready goes on to Implement, once, through `moveTo`, the writer a drop posts to.
|
|
2485
|
+
*
|
|
2486
|
+
* What a drop refuses before it sends anything is read off the snapshot the board draws, so a
|
|
2487
|
+
* refused chain leaves the card ready where it ran, as a refused drop does, and the run that ended
|
|
2488
|
+
* keeps the reason for Now to say. What the server refuses after the move fails the card in the
|
|
2489
|
+
* next stage with its reason, as it does for a drop.
|
|
2490
|
+
*/
|
|
2491
|
+
const chainOn = async (key, phase, runId, then) => {
|
|
2492
|
+
if (closed) return;
|
|
2493
|
+
const card = db.prepare("SELECT board, stage, state, size FROM cards WHERE key = ?").get(key);
|
|
2494
|
+
if (card === void 0 || card.state !== "ready" || !isBoardKind(card.board)) return;
|
|
2495
|
+
const board = boardNow(card.board);
|
|
2496
|
+
const to = then ?? smallChain(board, card, phase, getSetting(db, "chainBoards"));
|
|
2497
|
+
if (to === void 0) return;
|
|
2498
|
+
const label = board.stages.find((stage) => stage.id === to)?.label ?? to;
|
|
2499
|
+
const refused = (reason) => {
|
|
2500
|
+
db.prepare("UPDATE runs SET chain_refused = ? WHERE id = ?").run(`${label} did not start on its own. ${reason}`, runId);
|
|
2501
|
+
bumpVersion(db);
|
|
2502
|
+
};
|
|
2503
|
+
try {
|
|
2504
|
+
const snapshot = made.snapshot(card.board);
|
|
2505
|
+
const view = snapshot.cards.find((one) => one.key === key) ?? null;
|
|
2506
|
+
const stages = snapshot.stages.map((stage) => ({
|
|
2507
|
+
...stage,
|
|
2508
|
+
starts: cardStarts(stage, view)
|
|
2509
|
+
}));
|
|
2510
|
+
const starts = stages.find((stage) => stage.id === to)?.starts ?? null;
|
|
2511
|
+
if (starts !== null && (starts.modelState !== "ok" || starts.refusal !== null)) {
|
|
2512
|
+
refused(startsLabel(board, card.stage, to, stages) ?? "");
|
|
2513
|
+
return;
|
|
2514
|
+
}
|
|
2515
|
+
const moved = await moveTo(made, key, to, "auto");
|
|
2516
|
+
if (moved?.status === 409) refused(moved.message);
|
|
2517
|
+
} catch (error) {
|
|
2518
|
+
if (!closed) refused(error.message);
|
|
2519
|
+
}
|
|
2520
|
+
};
|
|
2521
|
+
const chaining = /* @__PURE__ */ new Map();
|
|
2522
|
+
const triageFrom = /* @__PURE__ */ new Map();
|
|
2523
|
+
const triageBack = (key) => {
|
|
2524
|
+
const state = triageFrom.get(key) ?? "idle";
|
|
2525
|
+
triageFrom.delete(key);
|
|
2526
|
+
return state;
|
|
2527
|
+
};
|
|
2528
|
+
const fixOf = (key, runId) => {
|
|
2529
|
+
const fix = fixes.get(key);
|
|
2530
|
+
return fix?.runId === runId ? fix : void 0;
|
|
2531
|
+
};
|
|
2532
|
+
const fixEnded = (key, fix, reason) => {
|
|
2533
|
+
fixes.delete(key);
|
|
2534
|
+
for (const row of fix.rows) endFix(db, row.id, {
|
|
2535
|
+
ok: false,
|
|
2536
|
+
reason
|
|
2537
|
+
});
|
|
2538
|
+
db.prepare("UPDATE cards SET state = ? WHERE key = ?").run(fix.from, key);
|
|
2539
|
+
};
|
|
2540
|
+
const checking = /* @__PURE__ */ new Map();
|
|
2541
|
+
const checkOf = (key, runId) => {
|
|
2542
|
+
const check = checking.get(key);
|
|
2543
|
+
return check?.runId === runId ? check : void 0;
|
|
2544
|
+
};
|
|
2545
|
+
const fixing = /* @__PURE__ */ new Map();
|
|
2546
|
+
const markStack = (key, stack) => {
|
|
2547
|
+
setCardStack(db, key, stack);
|
|
2548
|
+
changed();
|
|
2549
|
+
};
|
|
2550
|
+
const NO_VERDICT = "This QA run printed no verdict, so nobody can say what it found. Read its log, then move the card yourself.";
|
|
2551
|
+
const NO_REASON = "QA is blocked and gave no reason. Read its log, then answer with what it needs.";
|
|
2552
|
+
const waitingReview = /* @__PURE__ */ new Map();
|
|
2553
|
+
let aheadOfReview = false;
|
|
2554
|
+
let stoppingWaits = false;
|
|
2555
|
+
const start = (key, phase, resume, file = null, onProfile = null, retried = false, released = false) => {
|
|
2556
|
+
const waits = !released && !belongsToNoCard(key) && isAction(phase) && policyFor(phase).knowledge === true && (pendingKnowledgeChanges(db).length > 0 || waitingReview.size > 0 || knowledgeBusy());
|
|
2557
|
+
const make = (runId) => {
|
|
2558
|
+
const job = buildJob(key, phase, runId, file, resume?.engine ?? onProfile, resume?.model ?? null, resume?.sessionId ?? null);
|
|
2559
|
+
if (resume === void 0) return job;
|
|
2560
|
+
if (resume.sessionId === null) return {
|
|
2561
|
+
...job,
|
|
2562
|
+
prompt: `${job.prompt}\n\n${resume.message}`
|
|
2563
|
+
};
|
|
2564
|
+
return resumeJob(job, resume.sessionId, resumeMessage(phase, resume.message), {
|
|
2565
|
+
engine: resume.engine,
|
|
2566
|
+
model: resume.model
|
|
2567
|
+
});
|
|
2568
|
+
};
|
|
2569
|
+
let draft;
|
|
2570
|
+
aheadOfReview = waits;
|
|
2571
|
+
try {
|
|
2572
|
+
draft = make(0);
|
|
2573
|
+
} catch (error) {
|
|
2574
|
+
failStart(key, phase, error);
|
|
2575
|
+
return false;
|
|
2576
|
+
} finally {
|
|
2577
|
+
aheadOfReview = false;
|
|
2578
|
+
}
|
|
2579
|
+
if (waits && stoppingWaits) {
|
|
2580
|
+
failStart(key, phase, /* @__PURE__ */ new Error(`Nolzu is stopping, so ${phaseLabel(phase)} of ${key} did not start. Start it again after the next start of Nolzu.`));
|
|
2581
|
+
return false;
|
|
2582
|
+
}
|
|
2583
|
+
if (waits) {
|
|
2584
|
+
const runId = startRun(db, {
|
|
2585
|
+
cardKey: key,
|
|
2586
|
+
phase,
|
|
2587
|
+
engine: draft.engine,
|
|
2588
|
+
model: draft.model,
|
|
2589
|
+
effort: draft.effort,
|
|
2590
|
+
sessionId: resume?.sessionId ?? null,
|
|
2591
|
+
logPath: "",
|
|
2592
|
+
lane: "knowledge"
|
|
2593
|
+
});
|
|
2594
|
+
db.prepare("UPDATE runs SET state = 'waiting_review' WHERE id = ?").run(runId);
|
|
2595
|
+
db.prepare("UPDATE cards SET state = 'queued' WHERE key = ?").run(key);
|
|
2596
|
+
waitingReview.set(runId, {
|
|
2597
|
+
key,
|
|
2598
|
+
phase,
|
|
2599
|
+
go: () => start(key, phase, resume, file, onProfile, retried, true)
|
|
2600
|
+
});
|
|
2601
|
+
changed();
|
|
2602
|
+
return true;
|
|
2603
|
+
}
|
|
2604
|
+
const progress = resume === void 0 ? progressOf(draft.taskDir, phase) : void 0;
|
|
2605
|
+
const continued = progress !== void 0 && stepsDone(progress).length > 0;
|
|
2606
|
+
const runId = startRun(db, {
|
|
2607
|
+
cardKey: key,
|
|
2608
|
+
phase,
|
|
2609
|
+
engine: draft.engine,
|
|
2610
|
+
model: draft.model,
|
|
2611
|
+
effort: draft.effort,
|
|
2612
|
+
sessionId: resume?.sessionId ?? null,
|
|
2613
|
+
logPath: draft.logPath,
|
|
2614
|
+
lane: draft.lane,
|
|
2615
|
+
resumed: resume !== void 0 || retried || continued
|
|
2616
|
+
});
|
|
2617
|
+
const job = make(runId);
|
|
2618
|
+
if (phase === "plan") removeCardFile(job.taskDir, join("implement", PROGRESS_FILE));
|
|
2619
|
+
db.prepare("UPDATE runs SET log_path = ?, cwd = ?, in_card_folder = ?, wall = ? WHERE id = ?").run(job.logPath, job.cwd, job.startsInCardFolder === true ? 1 : 0, wallOf(job.engine), runId);
|
|
2620
|
+
scheduler.add(job);
|
|
2621
|
+
return true;
|
|
2622
|
+
};
|
|
2623
|
+
const restart = (key, phase, resume, onProfile = null, retried = false) => {
|
|
2624
|
+
db.prepare("UPDATE cards SET state = 'queued' WHERE key = ?").run(key);
|
|
2625
|
+
try {
|
|
2626
|
+
return start(key, phase, resume, null, onProfile, retried);
|
|
2627
|
+
} catch (error) {
|
|
2628
|
+
failStart(key, phase, error);
|
|
2629
|
+
return false;
|
|
2630
|
+
}
|
|
2631
|
+
};
|
|
2632
|
+
const answer = (key, text) => {
|
|
2633
|
+
if (key === "kb-maintenance") return answerLearn(text);
|
|
2634
|
+
const card = db.prepare("SELECT state FROM cards WHERE key = ?").get(key);
|
|
2635
|
+
if (card === void 0) throw new Error(`There is no card ${key}, so there is no question to answer.`);
|
|
2636
|
+
if (card.state !== "blocked") throw new Error(`${key} is ${card.state} and not blocked, so no question is waiting for an answer.`);
|
|
2637
|
+
if (text.trim() === "") throw new Error(`The answer to ${key} is empty. Write what the agent asked for, then send it.`);
|
|
2638
|
+
const asked = db.prepare(`SELECT id, phase, session_id, engine, question, thread FROM runs WHERE card_key = ? AND ${NOT_A_PASS} ORDER BY id DESC LIMIT 1`).get(key);
|
|
2639
|
+
const ref = asked?.thread ?? null;
|
|
2640
|
+
const waiting = fixes.get(key);
|
|
2641
|
+
const fix = waiting?.asked !== void 0 && ref !== null ? waiting : void 0;
|
|
2642
|
+
if (fix !== void 0) fixes.delete(key);
|
|
2643
|
+
if (asked !== void 0) {
|
|
2644
|
+
const question = asked.question?.trim() ?? "";
|
|
2645
|
+
if (question !== "") addMessage(db, key, asked.phase, "agent", question, asked.id);
|
|
2646
|
+
addMessage(db, key, asked.phase, "person", text.trim(), asked.id);
|
|
2647
|
+
}
|
|
2648
|
+
const before = db.prepare("SELECT max(id) AS id FROM runs").get().id ?? 0;
|
|
2649
|
+
const started = restart(key, asked?.phase ?? "refine", {
|
|
2650
|
+
sessionId: asked?.session_id ?? "",
|
|
2651
|
+
message: text,
|
|
2652
|
+
engine: asked?.engine
|
|
2653
|
+
});
|
|
2654
|
+
if (ref === null) return started;
|
|
2655
|
+
const run = db.prepare("SELECT id, error FROM runs WHERE card_key = ? AND id > ? ORDER BY id DESC LIMIT 1").get(key, before);
|
|
2656
|
+
if (!started || run === void 0) {
|
|
2657
|
+
if (fix === void 0) return false;
|
|
2658
|
+
fixEnded(key, fix, run?.error ?? "The answer could not go on with the fix.");
|
|
2659
|
+
changed();
|
|
2660
|
+
return false;
|
|
2661
|
+
}
|
|
2662
|
+
db.prepare("UPDATE runs SET thread = ? WHERE id = ?").run(ref, run.id);
|
|
2663
|
+
if (fix !== void 0) fixes.set(key, {
|
|
2664
|
+
runId: run.id,
|
|
2665
|
+
rows: fix.rows,
|
|
2666
|
+
from: fix.from,
|
|
2667
|
+
...fix.all === true ? { all: true } : {}
|
|
2668
|
+
});
|
|
2669
|
+
changed();
|
|
2670
|
+
return true;
|
|
2671
|
+
};
|
|
2672
|
+
/**
|
|
2673
|
+
* A message in a discussion thread, which continues that phase's own session.
|
|
2674
|
+
*
|
|
2675
|
+
* The profile comes off the thread, which read it off the run row. A card whose action table
|
|
2676
|
+
* changed since the phase ran still continues on the login that holds the session, because a
|
|
2677
|
+
* session lives inside one profile and a resume on another finds nothing.
|
|
2678
|
+
*/
|
|
2679
|
+
const discuss = (key, thread, text, model) => {
|
|
2680
|
+
const card = db.prepare("SELECT state FROM cards WHERE key = ?").get(key);
|
|
2681
|
+
if (card === void 0) throw new Error(`There is no card ${key}, so there is no thread to write in.`);
|
|
2682
|
+
if (isAskThread(thread.id) || isFeedbackRef(thread.id)) return ask(key, thread, text, model);
|
|
2683
|
+
if (card.state !== "ready" && card.state !== "idle") throw new Error(`${key} is ${card.state}. ${{
|
|
2684
|
+
queued: "Wait for the run to start and end, then send the message.",
|
|
2685
|
+
running: "Wait for the run to end, then send the message.",
|
|
2686
|
+
blocked: "Answer the question on the overview first, which continues the same session.",
|
|
2687
|
+
failed: "Retry the card first, or move it back."
|
|
2688
|
+
}[card.state] ?? "Wait until the card is ready."}`);
|
|
2689
|
+
if (!isDeliveryPhase(thread.id)) throw new Error(`The ${thread.id} thread starts no run, so a message in it continues nothing.`);
|
|
2690
|
+
return restart(key, thread.id, {
|
|
2691
|
+
sessionId: thread.sessionId ?? "",
|
|
2692
|
+
message: text,
|
|
2693
|
+
engine: thread.engine ?? void 0,
|
|
2694
|
+
model: model === "" ? void 0 : model
|
|
2695
|
+
});
|
|
2696
|
+
};
|
|
2697
|
+
/**
|
|
2698
|
+
* A message in an Ask discussion (owner question 23): a read-only session that reads the card's code
|
|
2699
|
+
* and the card folder and answers in the discussion. It goes on in the discussion's session, or
|
|
2700
|
+
* starts one on the ask row. Every refusal of a run is thrown before anything is written.
|
|
2701
|
+
*
|
|
2702
|
+
* It is kept out of the card's state: it never moves the card or writes its state, and it takes no
|
|
2703
|
+
* place in the queue, so a phase run of the card never waits behind it. Its row carries the card,
|
|
2704
|
+
* so its cost counts where the card's other runs count, and the Log tab lists it.
|
|
2705
|
+
* ponytail: outside the scheduler, as `writeMessage` is, so it takes no slot either. Put it on a lane
|
|
2706
|
+
* if asks ever pile up.
|
|
2707
|
+
*/
|
|
2708
|
+
const ask = (key, thread, text, model) => {
|
|
2709
|
+
if (text.trim() === "") throw new Error("The message is empty. Write it above, then send it.");
|
|
2710
|
+
if (db.prepare("SELECT id FROM runs WHERE card_key = ? AND phase = ? AND thread = ? AND state IN ('queued', 'running') LIMIT 1").get(key, "ask", thread.id) !== void 0) throw new Error("The agent is still answering in this discussion. Wait for its answer, then send the next message.");
|
|
2711
|
+
const picked = model === void 0 || model === "" ? null : model;
|
|
2712
|
+
const make = (runId) => {
|
|
2713
|
+
const job = buildJob(key, "ask", runId, null, thread.engine, picked, thread.sessionId);
|
|
2714
|
+
const opening = isFeedbackRef(thread.id) ? messagesIn(db, key, thread.id)[0]?.body ?? "" : "";
|
|
2715
|
+
const about = opening === "" || opening === text.trim() ? "" : `${opening}\n\n`;
|
|
2716
|
+
if (thread.sessionId === null) return {
|
|
2717
|
+
...job,
|
|
2718
|
+
prompt: `${job.prompt}\n${about}${text.trim()}\n`
|
|
2719
|
+
};
|
|
2720
|
+
return resumeJob(job, thread.sessionId, text.trim(), {
|
|
2721
|
+
engine: thread.engine ?? void 0,
|
|
2722
|
+
model: picked ?? void 0
|
|
2723
|
+
});
|
|
2724
|
+
};
|
|
2725
|
+
const draft = make(0);
|
|
2726
|
+
const runId = startRun(db, {
|
|
2727
|
+
cardKey: key,
|
|
2728
|
+
phase: "ask",
|
|
2729
|
+
engine: draft.engine,
|
|
2730
|
+
model: draft.model,
|
|
2731
|
+
effort: draft.effort,
|
|
2732
|
+
sessionId: thread.sessionId,
|
|
2733
|
+
logPath: draft.logPath,
|
|
2734
|
+
lane: null,
|
|
2735
|
+
resumed: thread.sessionId !== null,
|
|
2736
|
+
thread: thread.id
|
|
2737
|
+
});
|
|
2738
|
+
const job = make(runId);
|
|
2739
|
+
db.prepare("UPDATE runs SET log_path = ?, cwd = ?, in_card_folder = ?, wall = ?, state = 'running', started_at = strftime('%Y-%m-%dT%H:%M:%fZ') WHERE id = ?").run(job.logPath, job.cwd, job.startsInCardFolder === true ? 1 : 0, wallOf(job.engine), runId);
|
|
2740
|
+
const answering = answerIn(job, thread.id).catch((error) => console.error(`The Ask run ${runId} of ${key} ended without its answer being kept: ${error.message}`));
|
|
2741
|
+
asking.add(answering);
|
|
2742
|
+
answering.finally(() => asking.delete(answering));
|
|
2743
|
+
return true;
|
|
2744
|
+
};
|
|
2745
|
+
const sinceNow = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
2746
|
+
const readBefore = async (job, quiet = true) => {
|
|
2747
|
+
const project = getSetting(db, "projectPath");
|
|
2748
|
+
if (project === null || !policyFor(job.phase).readOnly) return null;
|
|
2749
|
+
const own = worktreesFolder(project);
|
|
2750
|
+
const ignored = job.cwd.startsWith(`${own}/`) && quiet;
|
|
2751
|
+
const knowledge = resolveKnowledgeDir({
|
|
2752
|
+
knowledgeDir: getSetting(db, "knowledgeDir"),
|
|
2753
|
+
projectPath: project
|
|
2754
|
+
});
|
|
2755
|
+
try {
|
|
2756
|
+
const exclude = await nolzuWrites(project, job.taskDir, [job.knowledgeDir, knowledge], gitEnv(env));
|
|
2757
|
+
const repos = recordedRepos({
|
|
2758
|
+
project,
|
|
2759
|
+
repos: reposNow().map((repo) => repo.path),
|
|
2760
|
+
key: belongsToNoCard(job.cardKey) ? null : job.cardKey,
|
|
2761
|
+
cardRepos: reposOfCard(db, job.cardKey) ?? [],
|
|
2762
|
+
cwd: job.cwd
|
|
2763
|
+
});
|
|
2764
|
+
return {
|
|
2765
|
+
before: await gitBefore(repos, {
|
|
2766
|
+
exclude,
|
|
2767
|
+
ignored,
|
|
2768
|
+
env: gitEnv(env)
|
|
2769
|
+
}),
|
|
2770
|
+
own,
|
|
2771
|
+
project
|
|
2772
|
+
};
|
|
2773
|
+
} catch (error) {
|
|
2774
|
+
noteInRunLog(job.logPath, `Nolzu could not read the git state before this read-only run, so it cannot check the run changed nothing. ${error.message}`);
|
|
2775
|
+
return null;
|
|
2776
|
+
}
|
|
2777
|
+
};
|
|
2778
|
+
async function* comparedAround(job, run, read) {
|
|
2779
|
+
const since = read?.since ?? sinceNow();
|
|
2780
|
+
const watch = read === void 0 ? await readBefore(job) : read.watch;
|
|
2781
|
+
if (watch === null) {
|
|
2782
|
+
yield* run;
|
|
2783
|
+
return;
|
|
2784
|
+
}
|
|
2785
|
+
const beside = otherRunOfCard(db, job.cardKey, job.runId);
|
|
2786
|
+
const held = [];
|
|
2787
|
+
try {
|
|
2788
|
+
for await (const event of run) {
|
|
2789
|
+
if (event.type === "complete" || event.type === "failed" || event.type === "needs_input") {
|
|
2790
|
+
held.push(event);
|
|
2791
|
+
continue;
|
|
2792
|
+
}
|
|
2793
|
+
yield* held.splice(0);
|
|
2794
|
+
yield event;
|
|
2795
|
+
}
|
|
2796
|
+
} finally {
|
|
2797
|
+
if (beside || !closed && otherRunOfCard(db, job.cardKey, job.runId, since)) noteInRunLog(job.logPath, "Another run of this card went at the same time, so Nolzu did not compare the git state after this read-only run. A change could be that run's, so nothing was put back or marked.");
|
|
2798
|
+
else {
|
|
2799
|
+
const ownFolder = wallOf(job.engine) === "macos" || wallOf(job.engine) === "bubblewrap" ? null : watch.own;
|
|
2800
|
+
const found = await gitAfter(watch.before, {
|
|
2801
|
+
ownFolder,
|
|
2802
|
+
project: watch.project,
|
|
2803
|
+
env: gitEnv(env)
|
|
2804
|
+
}).catch((error) => {
|
|
2805
|
+
noteInRunLog(job.logPath, `Nolzu could not compare the git state after this read-only run. ${error.message}`);
|
|
2806
|
+
});
|
|
2807
|
+
if (found !== void 0) await markBreak(job, found);
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
yield* held;
|
|
2811
|
+
}
|
|
2812
|
+
const markBreak = async (job, found) => {
|
|
2813
|
+
if (closed) return;
|
|
2814
|
+
try {
|
|
2815
|
+
if (found === null) {
|
|
2816
|
+
if (!isPass(job.phase) && clearReadOnlyBreaks(db, job.cardKey, job.runId)) changed();
|
|
2817
|
+
return;
|
|
2818
|
+
}
|
|
2819
|
+
saveReadOnlyBreak(db, job.runId, found);
|
|
2820
|
+
const walled = wallOf(job.engine) === "macos" || wallOf(job.engine) === "bubblewrap";
|
|
2821
|
+
noteInRunLog(job.logPath, found.restored ? `This read-only run changed the card's checkout, so Nolzu put it back. ${[...found.undone, ...found.left].join(" ")}` : walled ? "Files changed in the project folder while this read-only run went. The wall kept the run from writing there, so the change came from another program or from the person. Nolzu left them as they are and marked the card." : `Files changed in the project folder while this read-only run went. Nolzu left them as they are and marked the card.`);
|
|
2822
|
+
changed();
|
|
2823
|
+
} catch (error) {
|
|
2824
|
+
console.error(`Keeping the read-only mark of ${job.cardKey} run ${job.runId} failed: ${error.message}`);
|
|
2825
|
+
}
|
|
2826
|
+
};
|
|
2827
|
+
const answerIn = async (job, thread) => {
|
|
2828
|
+
const events = [];
|
|
2829
|
+
try {
|
|
2830
|
+
for await (const event of comparedAround(job, runJob(engineFor(job.engine), job, leaving.signal))) events.push(event);
|
|
2831
|
+
} catch (error) {
|
|
2832
|
+
events.push({
|
|
2833
|
+
type: "failed",
|
|
2834
|
+
reason: error.message,
|
|
2835
|
+
status: null
|
|
2836
|
+
});
|
|
2837
|
+
}
|
|
2838
|
+
if (closed) return;
|
|
2839
|
+
const ended = foldRun(events, leaving.signal.aborted);
|
|
2840
|
+
saveRun(db, job.runId, ended);
|
|
2841
|
+
const said = answerOf(events);
|
|
2842
|
+
const body = ended.state !== "complete" ? noAnswer(ended.failureReason ?? null) : said === "" ? "The agent ended without an answer. Its log is on the Log tab." : said;
|
|
2843
|
+
addMessage(db, job.cardKey, thread, "agent", body, job.runId);
|
|
2844
|
+
if (ended.state === "complete" && said !== "" && wantsSubject(db, job.cardKey, thread)) {
|
|
2845
|
+
const question = messagesIn(db, job.cardKey, thread).findLast((one) => one.author === "person")?.body ?? "";
|
|
2846
|
+
const titling = titleThread(job.cardKey, thread, question, said).catch((error) => console.error(`The subject of ${job.cardKey} ${thread} was not written: ${error.message}`));
|
|
2847
|
+
asking.add(titling);
|
|
2848
|
+
titling.finally(() => asking.delete(titling));
|
|
2849
|
+
}
|
|
2850
|
+
bumpVersion(db);
|
|
2851
|
+
changed();
|
|
2852
|
+
};
|
|
2853
|
+
const retry = (key, onProfile = null) => {
|
|
2854
|
+
const card = db.prepare("SELECT stage, state FROM cards WHERE key = ?").get(key);
|
|
2855
|
+
if (card === void 0) throw new Error(`There is no card ${key}, so there is nothing to retry.`);
|
|
2856
|
+
const last = db.prepare(`SELECT phase, state FROM runs WHERE card_key = ? AND ${NOT_A_PASS} ORDER BY id DESC LIMIT 1`).get(key);
|
|
2857
|
+
const phase = boardOf(key).stages.find((stage) => stage.id === card.stage)?.phase;
|
|
2858
|
+
const halted = card.state === "idle" && last?.state === "stopped" && last.phase === phase;
|
|
2859
|
+
if (card.state !== "failed" && !halted) throw new Error(`${key} is ${card.state} and not failed, so there is nothing to retry.`);
|
|
2860
|
+
if (last?.phase === "feedback") throw new Error(`The triage of ${key} failed. Run triage again on its PRs tab, or move the card.`);
|
|
2861
|
+
if (onProfile !== null && !profilesNow().some((one) => one.id === onProfile)) throw new Error(missingProfileText(onProfile));
|
|
2862
|
+
if (phase === void 0) throw new Error(`${key} sits in ${card.stage}, which starts no run, so there is nothing to retry. Move the card instead.`);
|
|
2863
|
+
return restart(key, phase, void 0, onProfile, true);
|
|
2864
|
+
};
|
|
2865
|
+
const fix = async (key) => {
|
|
2866
|
+
const card = db.prepare("SELECT stage, state FROM cards WHERE key = ?").get(key);
|
|
2867
|
+
if (card === void 0) throw new Error(`There is no card ${key}, so there is nothing to fix.`);
|
|
2868
|
+
const qa = boardOf(key).stages.find((stage) => stage.id === card.stage);
|
|
2869
|
+
const last = db.prepare(`SELECT phase, verdict, verdict_reason FROM runs WHERE card_key = ? AND ${NOT_A_PASS} ORDER BY id DESC LIMIT 1`).get(key);
|
|
2870
|
+
if (card.state !== "ready" || qa?.phase !== "qa" || last?.phase !== "qa" || last.verdict !== "FAIL") throw new Error(`${key} has no failed QA run to fix. Fix it follows a QA FAIL.`);
|
|
2871
|
+
const implement = implementOf(key, "Fix it");
|
|
2872
|
+
const qaDir = join(getSetting(db, "projectPath") ?? dataDir, ".tasks", key, "qa");
|
|
2873
|
+
const shots = ["qa", "qa/evidence"].flatMap((folder) => {
|
|
2874
|
+
const at = join(qaDir, "..", folder);
|
|
2875
|
+
return existsSync(at) ? readdirSync(at).filter((name) => cardFileKind(name) === "image").sort().map((name) => `${folder}/${name}`) : [];
|
|
2876
|
+
});
|
|
2877
|
+
const message = fixMessage({
|
|
2878
|
+
reason: last.verdict_reason,
|
|
2879
|
+
report: readCardText(dirname(qaDir), join("qa", "report.md")),
|
|
2880
|
+
shots
|
|
2881
|
+
});
|
|
2882
|
+
const runId = await backToImplement(key, card.stage, implement, message);
|
|
2883
|
+
if (runId !== null) fixing.set(key, {
|
|
2884
|
+
runId,
|
|
2885
|
+
then: qa.id
|
|
2886
|
+
});
|
|
2887
|
+
return runId !== null;
|
|
2888
|
+
};
|
|
2889
|
+
const implementOf = (key, what) => {
|
|
2890
|
+
const implement = boardOf(key).stages.find((stage) => stage.phase === "implement");
|
|
2891
|
+
if (implement === void 0) throw new Error(`${key} sits on a board with no Implement column, so ${what} has nowhere to go back to.`);
|
|
2892
|
+
return implement;
|
|
2893
|
+
};
|
|
2894
|
+
const backToImplement = async (key, stage, implement, message) => {
|
|
2895
|
+
if (stage !== implement.id) {
|
|
2896
|
+
const moved = await moveTo(made, key, implement.id);
|
|
2897
|
+
if (moved !== null) throw new Error(moved.message);
|
|
2898
|
+
}
|
|
2899
|
+
const session = db.prepare("SELECT session_id, engine FROM runs WHERE card_key = ? AND phase = 'implement' AND session_id IS NOT NULL ORDER BY id DESC LIMIT 1").get(key);
|
|
2900
|
+
if (!restart(key, "implement", {
|
|
2901
|
+
sessionId: session?.session_id ?? null,
|
|
2902
|
+
message,
|
|
2903
|
+
engine: session?.engine
|
|
2904
|
+
})) return null;
|
|
2905
|
+
return db.prepare("SELECT max(id) AS id FROM runs WHERE card_key = ?").get(key).id;
|
|
2906
|
+
};
|
|
2907
|
+
const triage = (key) => {
|
|
2908
|
+
const card = db.prepare("SELECT board, state FROM cards WHERE key = ?").get(key);
|
|
2909
|
+
if (card === void 0) throw new Error(`There is no card ${key}, so there are no comments to triage.`);
|
|
2910
|
+
if (card.board !== "delivery") throw new Error(`${key} is not on Delivery. Only a Delivery card has its own pull request comments to triage.`);
|
|
2911
|
+
const newest = db.prepare(`SELECT phase FROM runs WHERE card_key = ? AND ${NOT_A_PASS} ORDER BY id DESC LIMIT 1`).get(key);
|
|
2912
|
+
const again = card.state === "failed" && newest?.phase === "feedback";
|
|
2913
|
+
if (card.state !== "ready" && card.state !== "idle" && !again) throw new Error(`${key} is ${card.state}. Run triage once nothing else holds the card.`);
|
|
2914
|
+
if (!cardDiscussions(db, key).some(isOpen)) throw new Error(`${key} has no open discussion to triage. Read comments on its PRs tab first, or reopen one.`);
|
|
2915
|
+
triageFrom.set(key, again ? "idle" : card.state);
|
|
2916
|
+
return restart(key, "feedback");
|
|
2917
|
+
};
|
|
2918
|
+
const fixableCard = (key, what) => {
|
|
2919
|
+
const card = db.prepare("SELECT board, stage, state FROM cards WHERE key = ?").get(key);
|
|
2920
|
+
if (card === void 0) throw new Error(`There is no card ${key}, so there is no comment to fix.`);
|
|
2921
|
+
if (card.board !== "delivery") throw new Error(`${key} is not on Delivery. Only a Delivery card has its own pull request comments to fix.`);
|
|
2922
|
+
if (card.state !== "ready" && card.state !== "idle" && !cardDiscussions(db, key).some((one) => one.status === "fixing")) throw new Error(`${key} is ${card.state}. ${{
|
|
2923
|
+
queued: "Wait for the run to start and end, then fix the comment.",
|
|
2924
|
+
running: "Wait for the run to end, then fix the comment.",
|
|
2925
|
+
blocked: "Answer the question on the overview first.",
|
|
2926
|
+
failed: "Retry the card first, or move it."
|
|
2927
|
+
}[card.state] ?? "Wait until the card is ready."}`);
|
|
2928
|
+
implementOf(key, what);
|
|
2929
|
+
if (boardOf(key).stages.at(-1)?.id === card.stage) throw new Error(`${key} is done, so its checkout is not there to fix. Move it back first.`);
|
|
2930
|
+
return card;
|
|
2931
|
+
};
|
|
2932
|
+
const startFix = (key, from, rows, message, all) => {
|
|
2933
|
+
const session = db.prepare("SELECT session_id, engine FROM runs WHERE card_key = ? AND phase = 'implement' AND session_id IS NOT NULL ORDER BY id DESC LIMIT 1").get(key);
|
|
2934
|
+
const before = db.prepare("SELECT max(id) AS id FROM runs").get().id ?? 0;
|
|
2935
|
+
const started = restart(key, "implement", {
|
|
2936
|
+
sessionId: session?.session_id ?? null,
|
|
2937
|
+
message,
|
|
2938
|
+
engine: session?.engine
|
|
2939
|
+
});
|
|
2940
|
+
const run = db.prepare("SELECT id, error FROM runs WHERE card_key = ? AND id > ? ORDER BY id DESC LIMIT 1").get(key, before);
|
|
2941
|
+
if (!started || run === void 0) {
|
|
2942
|
+
fixEnded(key, {
|
|
2943
|
+
rows,
|
|
2944
|
+
from
|
|
2945
|
+
}, run?.error ?? "The fix could not start.");
|
|
2946
|
+
changed();
|
|
2947
|
+
return false;
|
|
2948
|
+
}
|
|
2949
|
+
db.prepare("UPDATE runs SET thread = ? WHERE id = ?").run(rows.map((row) => row.ref).join(","), run.id);
|
|
2950
|
+
fixes.set(key, {
|
|
2951
|
+
runId: run.id,
|
|
2952
|
+
rows,
|
|
2953
|
+
from,
|
|
2954
|
+
...all ? { all: true } : {}
|
|
2955
|
+
});
|
|
2956
|
+
changed();
|
|
2957
|
+
return true;
|
|
2958
|
+
};
|
|
2959
|
+
const fixFeedback = (key, ref) => {
|
|
2960
|
+
const card = fixableCard(key, "Fix");
|
|
2961
|
+
const begun = beginFix(db, key, ref);
|
|
2962
|
+
if (!begun.ok) throw new Error(begun.reason);
|
|
2963
|
+
const pull = cardPullRows(db, key).find((one) => one.id === begun.row.pull);
|
|
2964
|
+
return startFix(key, card.state, [{
|
|
2965
|
+
id: begun.row.id,
|
|
2966
|
+
ref: begun.row.ref
|
|
2967
|
+
}], fixFeedbackMessage(begun.row, pull), false);
|
|
2968
|
+
};
|
|
2969
|
+
const fixAll = (key) => {
|
|
2970
|
+
const card = fixableCard(key, "Fix all");
|
|
2971
|
+
const begun = beginFixAll(db, key);
|
|
2972
|
+
if (!begun.ok) throw new Error(begun.reason);
|
|
2973
|
+
removeCardFile(join(getSetting(db, "projectPath") ?? dataDir, ".tasks", key), FIXES_FILE);
|
|
2974
|
+
const rows = begun.rows.map((row) => ({
|
|
2975
|
+
id: row.id,
|
|
2976
|
+
ref: row.ref
|
|
2977
|
+
}));
|
|
2978
|
+
return startFix(key, card.state, rows, fixAllMessage(begun.rows, cardPullRows(db, key)), true);
|
|
2979
|
+
};
|
|
2980
|
+
const qaFixes = (key) => {
|
|
2981
|
+
const card = db.prepare("SELECT board, stage, state FROM cards WHERE key = ?").get(key);
|
|
2982
|
+
if (card === void 0) throw new Error(`There is no card ${key}, so there are no fixes to check.`);
|
|
2983
|
+
if (card.board !== "delivery") throw new Error(`${key} is not on Delivery. Only a Delivery card has fixes for its own pull request comments to check.`);
|
|
2984
|
+
if (card.state !== "ready" && card.state !== "idle") throw new Error(`${key} is ${card.state}. ${{
|
|
2985
|
+
queued: "Wait for the run to start and end, then run QA of the fixes.",
|
|
2986
|
+
running: "Wait for the run to end, then run QA of the fixes.",
|
|
2987
|
+
blocked: "Answer the question on the overview first.",
|
|
2988
|
+
failed: "Retry the card first, or move it."
|
|
2989
|
+
}[card.state] ?? "Wait until the card is ready."}`);
|
|
2990
|
+
if (boardOf(key).stages.at(-1)?.id === card.stage) throw new Error(`${key} is done, so its checkout is not there to check. Move it back first.`);
|
|
2991
|
+
const rows = fixedSinceQa(db, key);
|
|
2992
|
+
if (rows.length === 0) throw new Error(`Nothing was fixed on ${key} since its last QA, so QA has nothing new to check. Fix a comment first.`);
|
|
2993
|
+
const before = db.prepare("SELECT max(id) AS id FROM runs").get().id ?? 0;
|
|
2994
|
+
const started = restart(key, "qa", {
|
|
2995
|
+
sessionId: null,
|
|
2996
|
+
message: qaFixesMessage(rows, cardPullRows(db, key), lastJudgedQa(db, key))
|
|
2997
|
+
});
|
|
2998
|
+
const run = db.prepare("SELECT id FROM runs WHERE card_key = ? AND id > ? ORDER BY id DESC LIMIT 1").get(key, before);
|
|
2999
|
+
if (!started || run === void 0) {
|
|
3000
|
+
db.prepare("UPDATE cards SET state = ? WHERE key = ?").run(card.state, key);
|
|
3001
|
+
changed();
|
|
3002
|
+
return false;
|
|
3003
|
+
}
|
|
3004
|
+
const refs = rows.map((row) => row.ref);
|
|
3005
|
+
db.prepare("UPDATE runs SET thread = ? WHERE id = ?").run(refs.join(","), run.id);
|
|
3006
|
+
checking.set(key, {
|
|
3007
|
+
runId: run.id,
|
|
3008
|
+
refs,
|
|
3009
|
+
from: card.state
|
|
3010
|
+
});
|
|
3011
|
+
changed();
|
|
3012
|
+
return true;
|
|
3013
|
+
};
|
|
3014
|
+
const sendBack = async (key) => {
|
|
3015
|
+
const card = db.prepare("SELECT stage, state FROM cards WHERE key = ?").get(key);
|
|
3016
|
+
if (card === void 0) throw new Error(`There is no card ${key}, so there is nothing to send back.`);
|
|
3017
|
+
const open = commentsOf(db, key).filter((one) => one.sentAt === null);
|
|
3018
|
+
if (open.length === 0) throw new Error(`${key} has no open comments to send back. Comment on a line on the Changes tab first.`);
|
|
3019
|
+
if (card.state !== "ready" && card.state !== "idle") throw new Error(`${key} is ${card.state}. ${{
|
|
3020
|
+
queued: "Wait for the run to start and end, then send the comments back.",
|
|
3021
|
+
running: "Wait for the run to end, then send the comments back.",
|
|
3022
|
+
blocked: "Answer the question on the overview first.",
|
|
3023
|
+
failed: "Retry the card first, or move it back."
|
|
3024
|
+
}[card.state] ?? "Wait until the card is ready."}`);
|
|
3025
|
+
const implement = implementOf(key, "Send back");
|
|
3026
|
+
const stages = boardOf(key).stages;
|
|
3027
|
+
const at = stages.findIndex((stage) => stage.id === card.stage);
|
|
3028
|
+
if (at < stages.findIndex((stage) => stage.id === implement.id) || at === stages.length - 1) throw new Error(`${key} sits in ${card.stage}, so there is no Implement run to send comments back to.`);
|
|
3029
|
+
const project = getSetting(db, "projectPath");
|
|
3030
|
+
const checkout = (repo) => {
|
|
3031
|
+
try {
|
|
3032
|
+
return project === null || !isPlainName(key) ? null : checkoutPath(project, key, repo);
|
|
3033
|
+
} catch {
|
|
3034
|
+
return null;
|
|
3035
|
+
}
|
|
3036
|
+
};
|
|
3037
|
+
const message = sendBackMessage(open.map((one) => {
|
|
3038
|
+
const at = checkout(one.repo);
|
|
3039
|
+
return {
|
|
3040
|
+
repo: one.repo,
|
|
3041
|
+
file: one.file,
|
|
3042
|
+
line: one.line,
|
|
3043
|
+
lineText: one.lineText,
|
|
3044
|
+
text: one.text,
|
|
3045
|
+
now: at === null ? null : lineNow(at, one)
|
|
3046
|
+
};
|
|
3047
|
+
}));
|
|
3048
|
+
if (await backToImplement(key, card.stage, implement, message) === null) return false;
|
|
3049
|
+
const sent = db.prepare("UPDATE diff_comments SET sent_at = ? WHERE id = ? AND sent_at IS NULL");
|
|
3050
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3051
|
+
for (const one of open) sent.run(now, one.id);
|
|
3052
|
+
return true;
|
|
3053
|
+
};
|
|
3054
|
+
/**
|
|
3055
|
+
* A knowledge maintenance run that rewrites one file.
|
|
3056
|
+
*
|
|
3057
|
+
* The job is built here first, so a refusal is a sentence the person reads on the Knowledge
|
|
3058
|
+
* screen. A card's start writes its reason on a run row and the board shows it there, and a
|
|
3059
|
+
* maintenance run has no card and no board to show anything on.
|
|
3060
|
+
*
|
|
3061
|
+
* It takes the knowledge lane like every other run that writes knowledge, so a wrap-up started
|
|
3062
|
+
* at the same time waits for it, and work that has nothing to do with knowledge goes past.
|
|
3063
|
+
*/
|
|
3064
|
+
const optimize = (file) => {
|
|
3065
|
+
buildJob(KB_MAINTENANCE_KEY, "optimize", 0, file);
|
|
3066
|
+
return start(KB_MAINTENANCE_KEY, "optimize", void 0, file);
|
|
3067
|
+
};
|
|
3068
|
+
/**
|
|
3069
|
+
* Learn this project (owner, Phase outputs question 9). A person starts it, never Nolzu. It runs
|
|
3070
|
+
* like Optimize, under the reserved key and on the knowledge lane, and its writing always waits for
|
|
3071
|
+
* review. Built first, so a refusal is a sentence on the screen that offered it.
|
|
3072
|
+
*/
|
|
3073
|
+
const learn = (repo) => {
|
|
3074
|
+
buildJob(KB_MAINTENANCE_KEY, "orient", 0, repo ?? null);
|
|
3075
|
+
return start(KB_MAINTENANCE_KEY, "orient", void 0, repo ?? null);
|
|
3076
|
+
};
|
|
3077
|
+
/**
|
|
3078
|
+
* Learn your repositories (T37): a read-only run per repository on the action's own row, each under
|
|
3079
|
+
* a key of its own. Distinct keys let the queue take every run at once, and the knowledge lane is
|
|
3080
|
+
* what runs them one after another, under the same slot limit as every other run. Every job is built
|
|
3081
|
+
* first, so one refusal, such as knowledge still waiting for review, starts none of them.
|
|
3082
|
+
*/
|
|
3083
|
+
const learnRepos = (repos) => {
|
|
3084
|
+
const picked = [...new Set(repos)];
|
|
3085
|
+
if (picked.length === 0) throw new Error("No repository was picked, so there is nothing to learn. Tick one or more, then start again.");
|
|
3086
|
+
const queue = scheduler.queue();
|
|
3087
|
+
const queued = picked.filter((repo) => [...queue.waiting, ...queue.running].some((job) => job.cardKey === learnRepoKey(repo)));
|
|
3088
|
+
if (queued.length > 0) throw new Error(`${queued.join(", ")} ${queued.length === 1 ? "is" : "are"} being learned already. Wait for that run to end, then start again.`);
|
|
3089
|
+
for (const repo of picked) buildJob(learnRepoKey(repo), "learn-repo", 0);
|
|
3090
|
+
return picked.filter((repo) => start(learnRepoKey(repo), "learn-repo")).length;
|
|
3091
|
+
};
|
|
3092
|
+
const answerLearn = (text) => {
|
|
3093
|
+
const asked = learnAsking(db);
|
|
3094
|
+
if (asked === null) throw new Error("Learn this project is not waiting for an answer, so there is nothing to send it to.");
|
|
3095
|
+
if (text.trim() === "") throw new Error("The answer is empty. Pick one of the answers or write your own, then send it.");
|
|
3096
|
+
buildJob(KB_MAINTENANCE_KEY, "orient", 0, null, asked.engine, null, asked.sessionId);
|
|
3097
|
+
return start(KB_MAINTENANCE_KEY, "orient", {
|
|
3098
|
+
sessionId: asked.sessionId,
|
|
3099
|
+
message: text,
|
|
3100
|
+
engine: asked.engine
|
|
3101
|
+
});
|
|
3102
|
+
};
|
|
3103
|
+
/**
|
|
3104
|
+
* A read-only assessment of one Scout finding.
|
|
3105
|
+
*
|
|
3106
|
+
* It takes the Scout lane, so a second finding's assessment waits and work that has nothing to do
|
|
3107
|
+
* with Scout goes past. The lane is what holds one at a time, which is why every assessment
|
|
3108
|
+
* carries the key of its own finding: the queue refuses a second run under one key with an
|
|
3109
|
+
* exception, and an exception is not a wait.
|
|
3110
|
+
*
|
|
3111
|
+
* A second assessment of the same finding is refused while the first one is in the queue. Once
|
|
3112
|
+
* that one has ended, another run writes over the file in the same folder, the way a second run of
|
|
3113
|
+
* any phase does.
|
|
3114
|
+
*/
|
|
3115
|
+
const assess = (findingId) => {
|
|
3116
|
+
const key = assessKey(findingId);
|
|
3117
|
+
const queue = scheduler.queue();
|
|
3118
|
+
if ([...queue.waiting, ...queue.running].some((job) => job.cardKey === key)) throw new Error(`Finding ${findingId} has an assessment in the queue already. Wait for it to end, then read what it wrote.`);
|
|
3119
|
+
buildJob(key, "assess", 0);
|
|
3120
|
+
const started = start(key, "assess");
|
|
3121
|
+
if (started) assessScoutFinding(db, findingId);
|
|
3122
|
+
return started;
|
|
3123
|
+
};
|
|
3124
|
+
const reviewAnswered = () => {
|
|
3125
|
+
for (;;) {
|
|
3126
|
+
if (closed) return;
|
|
3127
|
+
const oldest = [...waitingReview][0];
|
|
3128
|
+
if (oldest === void 0 || pendingKnowledgeChanges(db).length > 0 || knowledgeBusy()) return;
|
|
3129
|
+
const [runId, held] = oldest;
|
|
3130
|
+
waitingReview.delete(runId);
|
|
3131
|
+
db.prepare("DELETE FROM runs WHERE id = ?").run(runId);
|
|
3132
|
+
let started = false;
|
|
3133
|
+
try {
|
|
3134
|
+
started = held.go();
|
|
3135
|
+
} catch (error) {
|
|
3136
|
+
failStart(held.key, held.phase, error);
|
|
3137
|
+
}
|
|
3138
|
+
changed();
|
|
3139
|
+
if (started) return;
|
|
3140
|
+
}
|
|
3141
|
+
};
|
|
3142
|
+
const knowledgeBusy = () => {
|
|
3143
|
+
const queue = scheduler.queue();
|
|
3144
|
+
return [...queue.running, ...queue.waiting].some((job) => job.lane === "knowledge");
|
|
3145
|
+
};
|
|
3146
|
+
const stopRun = (runId) => {
|
|
3147
|
+
const held = waitingReview.get(runId);
|
|
3148
|
+
if (held !== void 0) {
|
|
3149
|
+
waitingReview.delete(runId);
|
|
3150
|
+
saveRun(db, runId, foldRun([], true));
|
|
3151
|
+
db.prepare("UPDATE cards SET state = 'idle' WHERE key = ?").run(held.key);
|
|
3152
|
+
changed();
|
|
3153
|
+
return;
|
|
3154
|
+
}
|
|
3155
|
+
const waiting = scheduler.queue().waiting.find((job) => job.runId === runId);
|
|
3156
|
+
scheduler.stop(runId);
|
|
3157
|
+
if (waiting === void 0) return;
|
|
3158
|
+
const record = foldRun([], true);
|
|
3159
|
+
saveRun(db, runId, record);
|
|
3160
|
+
const phase = db.prepare("SELECT phase FROM runs WHERE id = ?").get(runId)?.phase;
|
|
3161
|
+
const fixRun = fixOf(waiting.cardKey, runId);
|
|
3162
|
+
const check = checkOf(waiting.cardKey, runId);
|
|
3163
|
+
if (check !== void 0) checking.delete(waiting.cardKey);
|
|
3164
|
+
if (fixRun !== void 0) fixEnded(waiting.cardKey, fixRun, "The fix was stopped before it started.");
|
|
3165
|
+
else db.prepare("UPDATE cards SET state = ? WHERE key = ?").run(phase === "feedback" ? triageBack(waiting.cardKey) : check?.from ?? record.cardState, waiting.cardKey);
|
|
3166
|
+
changed();
|
|
3167
|
+
};
|
|
3168
|
+
const stopAllWaits = () => {
|
|
3169
|
+
for (const [key, one] of open) if (key === dataFolder || key.startsWith(`${dataFolder}#`)) one.stopWaiting();
|
|
3170
|
+
};
|
|
3171
|
+
const shutdown = () => {
|
|
3172
|
+
stopAllWaits();
|
|
3173
|
+
return Promise.all([shared.shutdown(), releaseAll()]).then(() => stopAllWaits());
|
|
3174
|
+
};
|
|
3175
|
+
const beforeFile = (job) => join(dataDir, "knowledge-before", `${job.cardKey}${job.cardKey === "kb-maintenance" && job.phase === "orient" ? "-orient" : ""}.json`);
|
|
3176
|
+
/**
|
|
3177
|
+
* The state the knowledge folder had before this card's wrap-up started, when an earlier attempt
|
|
3178
|
+
* left one.
|
|
3179
|
+
*
|
|
3180
|
+
* A run that ended blocked or failed left its files in the folder. A fresh reading would take
|
|
3181
|
+
* them for the person's own work and never commit them, so the answer to a question, or a retry
|
|
3182
|
+
* after a refused commit, would report success and lose what the run wrote.
|
|
3183
|
+
*/
|
|
3184
|
+
const rememberedBefore = (job) => {
|
|
3185
|
+
if (!existsSync(beforeFile(job))) return null;
|
|
3186
|
+
return JSON.parse(readFileSync(beforeFile(job), "utf8"));
|
|
3187
|
+
};
|
|
3188
|
+
const rememberBefore = (job, before) => {
|
|
3189
|
+
if (before === null) {
|
|
3190
|
+
rmSync(beforeFile(job), { force: true });
|
|
3191
|
+
return;
|
|
3192
|
+
}
|
|
3193
|
+
mkdirSync(join(dataDir, "knowledge-before"), { recursive: true });
|
|
3194
|
+
writeFileSync(beforeFile(job), JSON.stringify(before));
|
|
3195
|
+
};
|
|
3196
|
+
/**
|
|
3197
|
+
* Gets the knowledge folder ready for a run that writes knowledge, and reads its state.
|
|
3198
|
+
*
|
|
3199
|
+
* Null for every other phase. The default folder inside the project is made here, because
|
|
3200
|
+
* `checkKnowledgeDir` refuses a folder that is not there and nothing has made it before the first
|
|
3201
|
+
* wrap-up. A folder a person typed is never made: they chose a path, and a typo would leave a new
|
|
3202
|
+
* empty folder somewhere on their machine instead of a sentence.
|
|
3203
|
+
*/
|
|
3204
|
+
const openKnowledge = async (job, project, signal) => {
|
|
3205
|
+
const folder = job.knowledgeDir ?? null;
|
|
3206
|
+
if (folder === null) return null;
|
|
3207
|
+
if (getSetting(db, "knowledgeDir") === null) mkdirSync(folder, { recursive: true });
|
|
3208
|
+
const { run, forPatch, sweep } = await knowledgeGit(folder, gitEnv(env), signal);
|
|
3209
|
+
const check = await checkKnowledgeDir(folder, {
|
|
3210
|
+
projectPath: project,
|
|
3211
|
+
run,
|
|
3212
|
+
repos: reposNow().map((repo) => repo.path)
|
|
3213
|
+
});
|
|
3214
|
+
if (!check.ok) throw new Error(check.reason ?? `The knowledge folder ${folder} cannot be used.`);
|
|
3215
|
+
return {
|
|
3216
|
+
run,
|
|
3217
|
+
forPatch,
|
|
3218
|
+
sweep,
|
|
3219
|
+
before: rememberedBefore(job) ?? await knowledgeState(run)
|
|
3220
|
+
};
|
|
3221
|
+
};
|
|
3222
|
+
options.sendTeam;
|
|
3223
|
+
const booting = !schedulers.has(dataFolder);
|
|
3224
|
+
const shared = sharedScheduler(schedulers, dataFolder, getSetting(db, "agentSlots"));
|
|
3225
|
+
const scheduler = shared.join(registered.id, {
|
|
3226
|
+
async startJob(queued, signal, onEvent) {
|
|
3227
|
+
let job = queued;
|
|
3228
|
+
const started = Date.now();
|
|
3229
|
+
const events = [];
|
|
3230
|
+
const helpers = options.awake ?? (isFakeMode(env) ? null : systemAwake(env));
|
|
3231
|
+
const release = helpers !== null && getSetting(db, "keepAwake") ? holdAwake(helpers) : () => void 0;
|
|
3232
|
+
markRunning(db, job.runId);
|
|
3233
|
+
live.set(job.runId, {
|
|
3234
|
+
cwd: job.cwd,
|
|
3235
|
+
activity: {
|
|
3236
|
+
runId: job.runId,
|
|
3237
|
+
cardKey: job.cardKey,
|
|
3238
|
+
line: null,
|
|
3239
|
+
outputAt: started
|
|
3240
|
+
}
|
|
3241
|
+
});
|
|
3242
|
+
heard(job.runId);
|
|
3243
|
+
changed();
|
|
3244
|
+
let knowledge = null;
|
|
3245
|
+
let notes = {
|
|
3246
|
+
notes: {},
|
|
3247
|
+
created: []
|
|
3248
|
+
};
|
|
3249
|
+
const apps = [];
|
|
3250
|
+
let startFailed = null;
|
|
3251
|
+
let review = null;
|
|
3252
|
+
let copied = null;
|
|
3253
|
+
const mcpDir = join(mcpRunsFolder(dataFolder), `${registered.id}-${job.runId}`);
|
|
3254
|
+
let headsAtStart = null;
|
|
3255
|
+
try {
|
|
3256
|
+
const project = getSetting(db, "projectPath");
|
|
3257
|
+
if (project !== null && !belongsToNoCard(job.cardKey)) {
|
|
3258
|
+
const target = checkoutRoot(project, job.cardKey);
|
|
3259
|
+
const repos = reposNow();
|
|
3260
|
+
const readsIfUnlisted = readsUnlisted(job.phase, boardOfCard(db, job.cardKey) ?? "delivery");
|
|
3261
|
+
const unlistedNow = repos.length === 0 || reposOfCard(db, job.cardKey) === null;
|
|
3262
|
+
const looking = repos.length !== 1 && (picksRepos(job.phase) || readsIfUnlisted && (unlistedNow || job.cwd === project));
|
|
3263
|
+
if (looking && readsIfUnlisted && job.cwd === target && !existsSync(target)) throw new Error(noRepoList(job.cardKey, boardOf(job.cardKey)));
|
|
3264
|
+
if (job.cwd !== target && dirname(job.cwd) !== target && !(looking && job.cwd === project)) throw new Error(`The project changed while ${job.cardKey} waited for its turn, so this run would start in a checkout of the old one. Start the card again.`);
|
|
3265
|
+
if (!looking) {
|
|
3266
|
+
if (repos.length === 0) throw new Error(NO_REPOSITORY);
|
|
3267
|
+
const picked = repos.length > 1 ? reposOfCard(db, job.cardKey) : repos.map((repo) => repo.path);
|
|
3268
|
+
if (picked === null) throw new Error(noRepoList(job.cardKey, boardOf(job.cardKey)));
|
|
3269
|
+
if (job.cwd !== target && (picked.length !== 1 || job.cwd !== checkoutPath(project, job.cardKey, picked[0]))) throw new Error(`The repositories of ${job.cardKey} changed while it waited for its turn, so this run would start in the wrong one. Start the card again.`);
|
|
3270
|
+
const forGit = gitEnv(env);
|
|
3271
|
+
const branch = await cardBranch(db, job.cardKey, picked.map((repo) => checkoutPath(project, job.cardKey, repo)), forGit);
|
|
3272
|
+
if (!picked.includes(".")) mkdirSync(target, { recursive: true });
|
|
3273
|
+
for (const repo of picked) await ensureWorktree({
|
|
3274
|
+
projectPath: project,
|
|
3275
|
+
key: job.cardKey,
|
|
3276
|
+
repo,
|
|
3277
|
+
branch,
|
|
3278
|
+
baseBranch: repos.find((one) => one.path === repo)?.base ?? getSetting(db, "baseBranch"),
|
|
3279
|
+
env: forGit,
|
|
3280
|
+
signal
|
|
3281
|
+
});
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
if (job.phase === "pr-review") {
|
|
3285
|
+
const card = db.prepare("SELECT source_ref FROM cards WHERE key = ?").get(job.cardKey);
|
|
3286
|
+
const gh = options.gh ?? (isFakeMode(env) ? null : ghRunner());
|
|
3287
|
+
review = {
|
|
3288
|
+
head: await readPrHead(card?.source_ref ?? null, gh, signal) ?? seenHead(db, job.cardKey),
|
|
3289
|
+
before: roundsIn(job.taskDir).at(-1)?.number ?? 0
|
|
3290
|
+
};
|
|
3291
|
+
await writePrDiff({
|
|
3292
|
+
taskDir: job.taskDir,
|
|
3293
|
+
sourceRef: card?.source_ref ?? null,
|
|
3294
|
+
gh,
|
|
3295
|
+
signal,
|
|
3296
|
+
localRepo: async (owner, name) => {
|
|
3297
|
+
const repo = await originRepo(db, owner, name);
|
|
3298
|
+
return project === null || repo === null ? null : repoFolder(project, repo);
|
|
3299
|
+
},
|
|
3300
|
+
gitEnv: gitEnv(env),
|
|
3301
|
+
note: (line) => noteInRunLog(job.logPath, line)
|
|
3302
|
+
});
|
|
3303
|
+
}
|
|
3304
|
+
if (job.phase === "feedback") {
|
|
3305
|
+
const card = db.prepare("SELECT title FROM cards WHERE key = ?").get(job.cardKey);
|
|
3306
|
+
writeFeedbackFile(db, job.cardKey, card?.title ?? job.cardKey, job.taskDir);
|
|
3307
|
+
}
|
|
3308
|
+
if (project !== null && job.phase === "implement") {
|
|
3309
|
+
const checkouts = (reposOfCard(db, job.cardKey) ?? []).map((repo) => ({
|
|
3310
|
+
repo,
|
|
3311
|
+
path: checkoutPath(project, job.cardKey, repo)
|
|
3312
|
+
}));
|
|
3313
|
+
headsAtStart = {
|
|
3314
|
+
checkouts,
|
|
3315
|
+
heads: await readHeads(checkouts, gitEnv(env))
|
|
3316
|
+
};
|
|
3317
|
+
}
|
|
3318
|
+
removeCardFile(job.taskDir, join(job.phase, "summary.md"));
|
|
3319
|
+
removeCardFile(job.taskDir, join(job.phase, QUESTION_FILE));
|
|
3320
|
+
knowledge = await openKnowledge(job, project, signal);
|
|
3321
|
+
const qaApps = job.phase === "qa" ? getSetting(db, "qaApp") : null;
|
|
3322
|
+
const addresses = join("qa", "addresses.md");
|
|
3323
|
+
const writeAddresses = (lines) => {
|
|
3324
|
+
if (lines.length === 0) return;
|
|
3325
|
+
writeCardFile(job.taskDir, addresses, `${lines.join("\n")}\n`);
|
|
3326
|
+
};
|
|
3327
|
+
const startNotes = join("qa", "app-start.md");
|
|
3328
|
+
if (job.phase === "qa") {
|
|
3329
|
+
removeCardFile(job.taskDir, addresses);
|
|
3330
|
+
removeCardFile(job.taskDir, startNotes);
|
|
3331
|
+
}
|
|
3332
|
+
if (job.phase === "qa") makeCardFolder(job.taskDir, join("qa", "evidence"));
|
|
3333
|
+
if (job.phase === "qa") {
|
|
3334
|
+
const kept = keepReport(join(job.taskDir, "qa"));
|
|
3335
|
+
if (kept !== null) noteInRunLog(job.logPath, `Kept the report of the QA before as ${kept}.`);
|
|
3336
|
+
}
|
|
3337
|
+
if (qaApps !== null) {
|
|
3338
|
+
const several = reposNow().length > 1;
|
|
3339
|
+
const picked = (project === null ? [] : qaReposOf(db, job.cardKey)).map((repo) => ({
|
|
3340
|
+
repo,
|
|
3341
|
+
answer: answerFor(qaApps, repo)
|
|
3342
|
+
}));
|
|
3343
|
+
const failed = (reason) => {
|
|
3344
|
+
const status = {
|
|
3345
|
+
state: "failed",
|
|
3346
|
+
reason
|
|
3347
|
+
};
|
|
3348
|
+
saveStackStatus(db, job.runId, status);
|
|
3349
|
+
markStack(job.cardKey, status);
|
|
3350
|
+
throw new Error(reason);
|
|
3351
|
+
};
|
|
3352
|
+
const keepPrinted = (command, output) => {
|
|
3353
|
+
const printed = output?.trim() ?? "";
|
|
3354
|
+
if (printed !== "") noteInRunLog(job.logPath, `${command} printed before it failed:\n\n\`\`\`\n${printed}\n\`\`\``);
|
|
3355
|
+
};
|
|
3356
|
+
const open = picked.find((one) => one.answer === null);
|
|
3357
|
+
if (open !== void 0) failed(`QA asks how to run ${open.repo} before it runs. Retry ${job.cardKey} on the board to answer.`);
|
|
3358
|
+
const running = picked.flatMap(({ repo, answer }) => answer?.mode === "running" ? [{
|
|
3359
|
+
repo,
|
|
3360
|
+
address: answer.address
|
|
3361
|
+
}] : []);
|
|
3362
|
+
const lines = running.map((one) => `${several ? one.repo : "app"} ${one.address}`);
|
|
3363
|
+
const said = [];
|
|
3364
|
+
const notes = [];
|
|
3365
|
+
const owns = ownStarts(qaApps, picked.map(({ repo }) => repo));
|
|
3366
|
+
const starts = [...owns.filter((own) => own.repo === null), ...picked.flatMap(({ repo, answer }) => answer?.mode === "dev" ? [{
|
|
3367
|
+
repo,
|
|
3368
|
+
answer
|
|
3369
|
+
}] : owns.filter((own) => own.repo === repo))];
|
|
3370
|
+
await releaseHeld(job.cardKey);
|
|
3371
|
+
if (starts.length > 0) markStack(job.cardKey, {
|
|
3372
|
+
state: "loading",
|
|
3373
|
+
reason: null
|
|
3374
|
+
});
|
|
3375
|
+
for (const { repo, answer } of starts) {
|
|
3376
|
+
const name = repo === null || !several ? "app" : repo;
|
|
3377
|
+
if (answer.mode === "own") {
|
|
3378
|
+
const at = ownFolder(project ?? "", job.cardKey, repo);
|
|
3379
|
+
const command = stackCommand(answer.start, job.cardKey);
|
|
3380
|
+
if (!existsSync(at)) failed(`${job.cardKey} has no checkout${repo === null ? "" : ` of ${repo}`}, so Nolzu did not run ${command}. Start the card again.`);
|
|
3381
|
+
const started = await startApp(command, {
|
|
3382
|
+
cwd: at,
|
|
3383
|
+
env: cardStackEnv(db, job.cardKey, env),
|
|
3384
|
+
signal,
|
|
3385
|
+
mayExit: true,
|
|
3386
|
+
timeoutMs: STACK_TIMEOUT_MS
|
|
3387
|
+
}).catch((error) => {
|
|
3388
|
+
keepPrinted(command, error.output);
|
|
3389
|
+
const reason = `${command} did not start the app. ${error.message}`;
|
|
3390
|
+
if (answer.stop !== null) {
|
|
3391
|
+
apps.push({
|
|
3392
|
+
server: null,
|
|
3393
|
+
stop: {
|
|
3394
|
+
hook: {
|
|
3395
|
+
load: null,
|
|
3396
|
+
unload: answer.stop,
|
|
3397
|
+
status: null
|
|
3398
|
+
},
|
|
3399
|
+
at,
|
|
3400
|
+
command
|
|
3401
|
+
}
|
|
3402
|
+
});
|
|
3403
|
+
startFailed = reason;
|
|
3404
|
+
}
|
|
3405
|
+
return failed(reason);
|
|
3406
|
+
});
|
|
3407
|
+
apps.push({
|
|
3408
|
+
server: started,
|
|
3409
|
+
stop: {
|
|
3410
|
+
hook: {
|
|
3411
|
+
load: null,
|
|
3412
|
+
unload: answer.stop,
|
|
3413
|
+
status: null
|
|
3414
|
+
},
|
|
3415
|
+
at,
|
|
3416
|
+
command
|
|
3417
|
+
}
|
|
3418
|
+
});
|
|
3419
|
+
said.push(`Nolzu started ${command}${repo !== null && several ? ` in ${repo}` : ""}${started.address === null ? "" : ` at ${started.address}`}, with no wall.`);
|
|
3420
|
+
const printed = stackNotes(started.output);
|
|
3421
|
+
if (printed !== "") {
|
|
3422
|
+
const note = `${command} printed:\n\n\`\`\`\n${printed}\n\`\`\``;
|
|
3423
|
+
noteInRunLog(job.logPath, note);
|
|
3424
|
+
notes.push(note);
|
|
3425
|
+
}
|
|
3426
|
+
lines.push(...started.exited && started.named.length > 0 ? started.named : started.address === null ? [] : [`${name} ${started.address}`]);
|
|
3427
|
+
continue;
|
|
3428
|
+
}
|
|
3429
|
+
const dev = answer;
|
|
3430
|
+
const checkout = checkoutPath(project ?? "", job.cardKey, dev.repo);
|
|
3431
|
+
const at = join(checkout, dev.folder ?? "");
|
|
3432
|
+
if (!existsSync(at)) failed(`${job.cardKey} has no checkout of ${join(dev.repo, dev.folder ?? "")}, so Nolzu did not run ${dev.command}. Start the card again.`);
|
|
3433
|
+
const changed = scriptsChanged(db, dev, at, job.cardKey);
|
|
3434
|
+
if (changed !== null) failed(changed);
|
|
3435
|
+
const ready = wallNow();
|
|
3436
|
+
const wall = ready.ready && project !== null ? appWall({
|
|
3437
|
+
checkout,
|
|
3438
|
+
repoFolder: join(project, dev.repo),
|
|
3439
|
+
project,
|
|
3440
|
+
walls: getSetting(db, "wallLists"),
|
|
3441
|
+
env
|
|
3442
|
+
}) : void 0;
|
|
3443
|
+
const how = {
|
|
3444
|
+
cwd: at,
|
|
3445
|
+
env,
|
|
3446
|
+
signal,
|
|
3447
|
+
...wall === void 0 ? {} : { wall }
|
|
3448
|
+
};
|
|
3449
|
+
const install = installCommand(at);
|
|
3450
|
+
if (install !== null) await installApp(install, how).catch((error) => failed(`${install} failed in ${at}: ${error.message}. Install it by hand in that folder, then move the card into QA again.`));
|
|
3451
|
+
const started = await startApp(dev.command, how).catch((error) => {
|
|
3452
|
+
keepPrinted(dev.command, error.output);
|
|
3453
|
+
return failed(`${dev.command} did not start the app. ${error.message}`);
|
|
3454
|
+
});
|
|
3455
|
+
apps.push({
|
|
3456
|
+
server: started,
|
|
3457
|
+
stop: null
|
|
3458
|
+
});
|
|
3459
|
+
const where = join(several ? dev.repo : "", dev.folder ?? "");
|
|
3460
|
+
said.push(`Nolzu started ${dev.command}${where === "" || where === "." ? "" : ` in ${where}`} at ${started.address}.${wall !== void 0 ? "" : ready.ready ? " Not walled: the project folder is not set." : ` Not walled: ${ready.reason}`}`);
|
|
3461
|
+
lines.push(`${name} ${started.address}`);
|
|
3462
|
+
}
|
|
3463
|
+
const leftAlone = running.map((one) => `QA checks the app already running at ${one.address} and leaves it alone.`);
|
|
3464
|
+
const status = apps.length > 0 ? {
|
|
3465
|
+
state: "up",
|
|
3466
|
+
reason: [...said, ...leftAlone].join(" ")
|
|
3467
|
+
} : {
|
|
3468
|
+
state: "off",
|
|
3469
|
+
reason: running.length > 0 ? ["Nolzu started no app.", ...leftAlone].join(" ") : "Nolzu started no app. QA checks the code only."
|
|
3470
|
+
};
|
|
3471
|
+
saveStackStatus(db, job.runId, status);
|
|
3472
|
+
markStack(job.cardKey, status);
|
|
3473
|
+
writeAddresses(lines);
|
|
3474
|
+
if (notes.length > 0) writeCardFile(job.taskDir, startNotes, `${notes.join("\n\n")}\n`);
|
|
3475
|
+
} else if (job.phase === "qa") {
|
|
3476
|
+
saveStackStatus(db, job.runId, {
|
|
3477
|
+
state: "off",
|
|
3478
|
+
reason: null
|
|
3479
|
+
});
|
|
3480
|
+
markStack(job.cardKey, {
|
|
3481
|
+
state: "off",
|
|
3482
|
+
reason: null
|
|
3483
|
+
});
|
|
3484
|
+
}
|
|
3485
|
+
const retries = {
|
|
3486
|
+
waits: getSetting(db, "retryWaitsMs"),
|
|
3487
|
+
onWait: (wait) => {
|
|
3488
|
+
const waiting = foldRun([...events, wait]);
|
|
3489
|
+
saveRun(db, job.runId, waiting);
|
|
3490
|
+
db.prepare("UPDATE cards SET state = ? WHERE key = ?").run(waiting.cardState, job.cardKey);
|
|
3491
|
+
changed();
|
|
3492
|
+
},
|
|
3493
|
+
onResume: () => {
|
|
3494
|
+
markRunning(db, job.runId);
|
|
3495
|
+
heard(job.runId);
|
|
3496
|
+
changed();
|
|
3497
|
+
}
|
|
3498
|
+
};
|
|
3499
|
+
const since = sinceNow();
|
|
3500
|
+
const watch = await readBefore(job, apps.length === 0);
|
|
3501
|
+
if (project !== null && job.qaCopy != null) {
|
|
3502
|
+
copied = job.qaCopy;
|
|
3503
|
+
const made = await makeQaCopy(job.cwd, job.qaCopy, {
|
|
3504
|
+
skip: [dirname(job.taskDir), worktreesFolder(project)],
|
|
3505
|
+
signal
|
|
3506
|
+
});
|
|
3507
|
+
noteInRunLog(job.logPath, `QA works on a throwaway copy of ${job.cwd} at ${job.qaCopy}, made by ${made.method} in ${(made.ms / 1e3).toFixed(1)} s. It is deleted after the run.`);
|
|
3508
|
+
}
|
|
3509
|
+
const vendor = engineFor(job.engine).vendor;
|
|
3510
|
+
const tracked = async (root) => (await git([
|
|
3511
|
+
"ls-files",
|
|
3512
|
+
"--error-unmatch",
|
|
3513
|
+
"--",
|
|
3514
|
+
".cursor/mcp.json"
|
|
3515
|
+
], {
|
|
3516
|
+
cwd: root,
|
|
3517
|
+
env: gitEnv(env)
|
|
3518
|
+
})).code === 0;
|
|
3519
|
+
const cursorHere = vendor === "cursor" && project !== null && await cursorMergesHere({
|
|
3520
|
+
project,
|
|
3521
|
+
cwd: job.cwd,
|
|
3522
|
+
qaCopy: job.qaCopy,
|
|
3523
|
+
tracked
|
|
3524
|
+
});
|
|
3525
|
+
const planned = promptMcp(project, job.phase, vendor, getSetting(db, "qaMcpConfigPath"));
|
|
3526
|
+
const mcp = await runMcp({
|
|
3527
|
+
project,
|
|
3528
|
+
projectId: registered.id,
|
|
3529
|
+
phase: job.phase,
|
|
3530
|
+
vendor,
|
|
3531
|
+
keychain,
|
|
3532
|
+
dir: mcpDir,
|
|
3533
|
+
cursorHere,
|
|
3534
|
+
legacy: getSetting(db, "qaMcpConfigPath")
|
|
3535
|
+
});
|
|
3536
|
+
for (const note of mcp.notes) noteInRunLog(job.logPath, note);
|
|
3537
|
+
const got = new Set(mcpNames(mcp.mcp));
|
|
3538
|
+
const prompt = swapPromptLine(swapPromptLine(job.prompt, browserLine(planned.browser), browserLine(planned.browser.filter((name) => got.has(name)))), serversLine(planned.servers), serversLine(planned.servers.filter((server) => got.has(server.name))));
|
|
3539
|
+
const named = job.resumeFrom === null ? await namedIssues(db, job.cardKey, options.gh ?? (isFakeMode(env) ? null : ghRunner()), signal) : [];
|
|
3540
|
+
job = {
|
|
3541
|
+
...job,
|
|
3542
|
+
prompt: withNamedIssues(prompt, named),
|
|
3543
|
+
mcp: mcp.mcp ?? {
|
|
3544
|
+
stdio: {},
|
|
3545
|
+
remote: {},
|
|
3546
|
+
rules: {},
|
|
3547
|
+
dir: mcpDir
|
|
3548
|
+
}
|
|
3549
|
+
};
|
|
3550
|
+
const sweep = () => {
|
|
3551
|
+
if (knowledge?.sweep() === true) noteInRunLog(job.logPath, "The run made a git repository in the knowledge folder, so Nolzu removed its .git. Nolzu reads and commits the folder through the project repository only.");
|
|
3552
|
+
};
|
|
3553
|
+
for await (const event of sweptAfter(comparedAround(job, runWithRetries(engineFor(job.engine), job, signal, retries), {
|
|
3554
|
+
watch,
|
|
3555
|
+
since
|
|
3556
|
+
}), sweep)) {
|
|
3557
|
+
events.push(event);
|
|
3558
|
+
if (event.type === "rate_limit") saveLimit(db, job.engine, event.windows, Date.now(), belongsToNoCard(job.cardKey) ? void 0 : job.cardKey);
|
|
3559
|
+
onEvent(event);
|
|
3560
|
+
}
|
|
3561
|
+
if (knowledge !== null && foldRun(events, signal.aborted).cardState === "ready") {
|
|
3562
|
+
const state = {
|
|
3563
|
+
run: knowledge.run,
|
|
3564
|
+
cardKey: job.cardKey,
|
|
3565
|
+
runId: job.runId,
|
|
3566
|
+
before: knowledge.before,
|
|
3567
|
+
after: await knowledgeState(knowledge.run)
|
|
3568
|
+
};
|
|
3569
|
+
notes = await writtenNotes(knowledge.run, job.knowledgeDir ?? "", knowledgeChanges(state.before, state.after)).catch(() => ({
|
|
3570
|
+
notes: {},
|
|
3571
|
+
created: []
|
|
3572
|
+
}));
|
|
3573
|
+
const rows = (changes) => changes.map((change) => ({
|
|
3574
|
+
path: change.path,
|
|
3575
|
+
summary: change.kind
|
|
3576
|
+
}));
|
|
3577
|
+
const keep = (held) => {
|
|
3578
|
+
keepHeld(dataDir, held);
|
|
3579
|
+
recordKnowledgeChanges(db, {
|
|
3580
|
+
cardKey: job.cardKey,
|
|
3581
|
+
runId: job.runId,
|
|
3582
|
+
commitSha: null,
|
|
3583
|
+
status: "pending",
|
|
3584
|
+
files: rows(held.files)
|
|
3585
|
+
});
|
|
3586
|
+
};
|
|
3587
|
+
if (getSetting(db, "reviewKnowledge") || policyFor(job.phase).alwaysHeld === true) await holdKnowledge({
|
|
3588
|
+
...state,
|
|
3589
|
+
keep
|
|
3590
|
+
});
|
|
3591
|
+
else {
|
|
3592
|
+
const commit = () => commitKnowledge({
|
|
3593
|
+
...state,
|
|
3594
|
+
record: (made) => {
|
|
3595
|
+
recordKnowledgeChanges(db, {
|
|
3596
|
+
cardKey: job.cardKey,
|
|
3597
|
+
runId: job.runId,
|
|
3598
|
+
commitSha: made.commit,
|
|
3599
|
+
status: "applied",
|
|
3600
|
+
files: rows(made.changes)
|
|
3601
|
+
});
|
|
3602
|
+
}
|
|
3603
|
+
});
|
|
3604
|
+
await (project === null ? commit() : inTurn(project, commit));
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
} catch (error) {
|
|
3608
|
+
events.push({
|
|
3609
|
+
type: "failed",
|
|
3610
|
+
reason: error.message,
|
|
3611
|
+
status: null
|
|
3612
|
+
});
|
|
3613
|
+
}
|
|
3614
|
+
release();
|
|
3615
|
+
restoreCursorMcp(mcpDir);
|
|
3616
|
+
try {
|
|
3617
|
+
rmSync(mcpDir, {
|
|
3618
|
+
recursive: true,
|
|
3619
|
+
force: true
|
|
3620
|
+
});
|
|
3621
|
+
} catch (error) {
|
|
3622
|
+
noteInRunLog(job.logPath, `The run's MCP folder ${mcpDir} could not be removed (${error.message}). The next start of Nolzu removes it.`);
|
|
3623
|
+
}
|
|
3624
|
+
if (copied !== null) {
|
|
3625
|
+
const gone = copied;
|
|
3626
|
+
await removeQaCopy(gone).catch((error) => noteInRunLog(job.logPath, `The QA copy at ${gone} could not be deleted (${error.message}). The next start of Nolzu deletes it.`));
|
|
3627
|
+
}
|
|
3628
|
+
if (job.phase === "qa") await releaseHeld(job.cardKey);
|
|
3629
|
+
if (apps.length > 0) {
|
|
3630
|
+
markStack(job.cardKey, {
|
|
3631
|
+
state: "unloading",
|
|
3632
|
+
reason: null
|
|
3633
|
+
});
|
|
3634
|
+
const left = [];
|
|
3635
|
+
for (const { server, stop } of apps) {
|
|
3636
|
+
await server?.stop();
|
|
3637
|
+
if (stop === null) continue;
|
|
3638
|
+
if (stop.hook.unload === null) {
|
|
3639
|
+
if (server?.exited === true) left.push(`No Stop command is set, so what ${stop.command} started is still up.`);
|
|
3640
|
+
continue;
|
|
3641
|
+
}
|
|
3642
|
+
const down = await runStackHook(stop.hook, "unload", job.cardKey, {
|
|
3643
|
+
cwd: stop.at,
|
|
3644
|
+
env: cardStackEnv(db, job.cardKey, env),
|
|
3645
|
+
timeoutMs: STACK_UNLOAD_TIMEOUT_MS
|
|
3646
|
+
}).then((result) => stackStatusAfter("unload", result)).catch((error) => ({
|
|
3647
|
+
state: "up",
|
|
3648
|
+
reason: `The Stop command could not run: ${error.message}. The app is still up.`
|
|
3649
|
+
}));
|
|
3650
|
+
if (down.state === "up") left.push(down.reason ?? "");
|
|
3651
|
+
}
|
|
3652
|
+
const status = left.length > 0 ? {
|
|
3653
|
+
state: "up",
|
|
3654
|
+
reason: left.join(" ")
|
|
3655
|
+
} : startFailed !== null ? {
|
|
3656
|
+
state: "off",
|
|
3657
|
+
reason: `${startFailed} Nolzu ran the Stop command after it.`
|
|
3658
|
+
} : {
|
|
3659
|
+
state: "off",
|
|
3660
|
+
reason: apps.length === 1 ? "The app Nolzu started for this run was stopped after it." : "The apps Nolzu started for this run were stopped after it."
|
|
3661
|
+
};
|
|
3662
|
+
if (startFailed === null) saveStackStatus(db, job.runId, status);
|
|
3663
|
+
markStack(job.cardKey, status);
|
|
3664
|
+
}
|
|
3665
|
+
const ended = foldRun(events, signal.aborted);
|
|
3666
|
+
const judged = job.phase === "qa" && ended.cardState === "ready";
|
|
3667
|
+
const verdict = judged ? extractVerdict(said(events)) : null;
|
|
3668
|
+
if (verdict?.verdict === "BLOCKED") events.push({
|
|
3669
|
+
type: "needs_input",
|
|
3670
|
+
question: verdict.reason ?? NO_REASON
|
|
3671
|
+
});
|
|
3672
|
+
const record = verdict?.verdict === "BLOCKED" ? foldRun(events, signal.aborted) : ended;
|
|
3673
|
+
if (knowledge !== null) rememberBefore(job, record.cardState === "ready" ? null : knowledge.before);
|
|
3674
|
+
if (record.cardState === "ready") {
|
|
3675
|
+
keepNamedReposSafely(job, started);
|
|
3676
|
+
takeRefinedTitle(job, started);
|
|
3677
|
+
await renameAfterRefine(job);
|
|
3678
|
+
}
|
|
3679
|
+
const round = review === null || record.cardState !== "ready" ? 0 : roundsIn(job.taskDir).at(-1)?.number ?? 0;
|
|
3680
|
+
if (review !== null && round > review.before) savePullRound(db, job.cardKey, round, review.head);
|
|
3681
|
+
if (job.phase === "feedback" && record.cardState === "ready") try {
|
|
3682
|
+
const applied = applyTriageFile(db, job.cardKey, job.taskDir);
|
|
3683
|
+
if (!applied.ok) noteInRunLog(job.logPath, `${applied.problem} No row took a verdict from it.`);
|
|
3684
|
+
} catch (error) {
|
|
3685
|
+
noteInRunLog(job.logPath, `The triage could not be applied: ${error.message}`);
|
|
3686
|
+
}
|
|
3687
|
+
if (job.phase === "feedback" && record.cardState === "blocked") noteInRunLog(job.logPath, "The triage asked a question, and a triage takes no answer. No row took a verdict. Run triage again.");
|
|
3688
|
+
const start = headsAtStart;
|
|
3689
|
+
const end = start === null ? [] : await readHeads(start.checkouts, gitEnv(env)).catch((error) => start.checkouts.map((one) => ({
|
|
3690
|
+
repo: one.repo,
|
|
3691
|
+
problem: error.message
|
|
3692
|
+
})));
|
|
3693
|
+
const moved = start === null ? null : runMoved(start.heads, end, fixOf(job.cardKey, job.runId) === void 0 ? "implement" : "fix");
|
|
3694
|
+
if (moved !== null) noteInRunLog(job.logPath, moved);
|
|
3695
|
+
if (record.cardState === "blocked") saveQuestionOptions(db, job.runId, parseQuestionOptions(readCardText(job.taskDir, join(job.phase, QUESTION_FILE))));
|
|
3696
|
+
try {
|
|
3697
|
+
const stripped = stripSharedAttribution(job.taskDir);
|
|
3698
|
+
if (stripped.length > 0) noteInRunLog(job.logPath, `Took the line that named a tool as the writer out of ${stripped.join(", ")}.`);
|
|
3699
|
+
} catch (error) {
|
|
3700
|
+
noteInRunLog(job.logPath, `The shared files could not be checked for a tool line: ${error.message}`);
|
|
3701
|
+
}
|
|
3702
|
+
saveRun(db, job.runId, record);
|
|
3703
|
+
if (record.cardState === "ready") checkRunOutputs(db, job, notes);
|
|
3704
|
+
if (judged) saveVerdict(db, job.runId, verdict ?? {
|
|
3705
|
+
verdict: null,
|
|
3706
|
+
reason: NO_VERDICT
|
|
3707
|
+
});
|
|
3708
|
+
try {
|
|
3709
|
+
if (record.cardState === "ready" && job.phase !== "feedback") {
|
|
3710
|
+
const summary = modelsFor(job.cardKey)["extract-summary"];
|
|
3711
|
+
await recordSummary({
|
|
3712
|
+
db,
|
|
3713
|
+
engine: summary.engine,
|
|
3714
|
+
summaryModel: {
|
|
3715
|
+
model: summary.model,
|
|
3716
|
+
effort: summary.effort
|
|
3717
|
+
},
|
|
3718
|
+
read: (path) => readCardText(job.taskDir, relative(job.taskDir, path)),
|
|
3719
|
+
extract: (extraction) => comparedAround(extraction, runJob(engineFor(extraction.engine), extraction, signal)),
|
|
3720
|
+
signal
|
|
3721
|
+
}, job, events);
|
|
3722
|
+
}
|
|
3723
|
+
recordPhaseSummary(db, job);
|
|
3724
|
+
} finally {
|
|
3725
|
+
live.delete(job.runId);
|
|
3726
|
+
const fixRun = fixOf(job.cardKey, job.runId);
|
|
3727
|
+
if (moved !== null && fixRun === void 0 && !closed) saveCommitWarning(db, job.runId, moved);
|
|
3728
|
+
let asks = false;
|
|
3729
|
+
if (fixRun !== void 0) {
|
|
3730
|
+
fixes.delete(job.cardKey);
|
|
3731
|
+
const outcome = fixOutcome(record, db.prepare("SELECT plain_summary FROM runs WHERE id = ?").get(job.runId)?.plain_summary ?? null);
|
|
3732
|
+
asks = moved === null && record.cardState === "blocked";
|
|
3733
|
+
if (asks) fixes.set(job.cardKey, {
|
|
3734
|
+
...fixRun,
|
|
3735
|
+
asked: record.question ?? "nothing it wrote down"
|
|
3736
|
+
});
|
|
3737
|
+
else {
|
|
3738
|
+
const failed = moved !== null ? {
|
|
3739
|
+
ok: false,
|
|
3740
|
+
reason: outcome.ok ? moved : `${moved} ${outcome.reason}`
|
|
3741
|
+
} : outcome.ok ? null : outcome;
|
|
3742
|
+
const notes = failed === null && fixRun.all === true ? readFixNotes(job.taskDir) : null;
|
|
3743
|
+
for (const row of fixRun.rows) {
|
|
3744
|
+
const note = notes?.get(row.ref);
|
|
3745
|
+
const missing = notes === null ? "The run wrote no feedback/fixes.md, so it does not say what it did for this comment. Read its edits on the Changes tab." : `The run wrote no line for ${row.ref} in feedback/fixes.md. Read its edits on the Changes tab.`;
|
|
3746
|
+
endFix(db, row.id, failed ?? (fixRun.all !== true ? outcome : note !== void 0 ? {
|
|
3747
|
+
ok: true,
|
|
3748
|
+
note
|
|
3749
|
+
} : {
|
|
3750
|
+
ok: false,
|
|
3751
|
+
reason: missing
|
|
3752
|
+
}));
|
|
3753
|
+
}
|
|
3754
|
+
}
|
|
3755
|
+
}
|
|
3756
|
+
const check = checkOf(job.cardKey, job.runId);
|
|
3757
|
+
if (check !== void 0) {
|
|
3758
|
+
checking.delete(job.cardKey);
|
|
3759
|
+
if (verdict?.verdict === "FAIL") reopenFixed(db, job.cardKey, failedFixes(readCardText(job.taskDir, join("qa", "report.md")), check.refs, verdict.reason));
|
|
3760
|
+
if (record.cardState === "blocked") noteInRunLog(job.logPath, `QA of the fixes stopped on a question, and it takes no answer: ${record.question ?? "nothing it wrote down"} Give it what it needs, then press QA the fixes again.`);
|
|
3761
|
+
}
|
|
3762
|
+
landCard(job.cardKey, fixRun !== void 0 ? asks ? "blocked" : fixRun.from : check !== void 0 ? check.from : job.phase === "feedback" ? triageBack(job.cardKey) : record.cardState, fixRun !== void 0 || check !== void 0 || job.phase === "feedback" ? null : {
|
|
3763
|
+
id: job.runId,
|
|
3764
|
+
phase: job.phase,
|
|
3765
|
+
verdict: verdict?.verdict ?? null
|
|
3766
|
+
});
|
|
3767
|
+
if (job.phase !== "ask" && !belongsToNoCard(job.cardKey)) noteRunEnd(db, {
|
|
3768
|
+
id: job.runId,
|
|
3769
|
+
key: job.cardKey,
|
|
3770
|
+
phase: job.phase
|
|
3771
|
+
}, record, judged ? verdict ?? {
|
|
3772
|
+
verdict: null,
|
|
3773
|
+
reason: NO_VERDICT
|
|
3774
|
+
} : null);
|
|
3775
|
+
noteMaintenanceFailure(db, {
|
|
3776
|
+
id: job.runId,
|
|
3777
|
+
key: job.cardKey,
|
|
3778
|
+
phase: job.phase
|
|
3779
|
+
}, record);
|
|
3780
|
+
const fixed = fixing.get(job.cardKey);
|
|
3781
|
+
const then = fixed?.runId === job.runId ? fixed.then : void 0;
|
|
3782
|
+
if (then !== void 0) fixing.delete(job.cardKey);
|
|
3783
|
+
if (record.cardState === "ready" && job.phase !== "feedback" && check === void 0) chaining.set(job.cardKey, {
|
|
3784
|
+
phase: job.phase,
|
|
3785
|
+
runId: job.runId,
|
|
3786
|
+
...then === void 0 ? {} : { then }
|
|
3787
|
+
});
|
|
3788
|
+
}
|
|
3789
|
+
},
|
|
3790
|
+
onEvent(runId, event) {
|
|
3791
|
+
heard(runId, event);
|
|
3792
|
+
},
|
|
3793
|
+
onChange() {
|
|
3794
|
+
if (closed) return;
|
|
3795
|
+
bumpVersion(db);
|
|
3796
|
+
changed();
|
|
3797
|
+
const queue = scheduler.queue();
|
|
3798
|
+
for (const [key, ended] of chaining) {
|
|
3799
|
+
if ([...queue.running, ...queue.waiting].some((one) => one.cardKey === key)) continue;
|
|
3800
|
+
chaining.delete(key);
|
|
3801
|
+
queueMicrotask(() => void chainOn(key, ended.phase, ended.runId, ended.then).catch(() => void 0));
|
|
3802
|
+
}
|
|
3803
|
+
if (waitingReview.size > 0) queueMicrotask(reviewAnswered);
|
|
3804
|
+
},
|
|
3805
|
+
stop: (runId) => stopRun(runId),
|
|
3806
|
+
leave: () => leaving.abort(),
|
|
3807
|
+
left: async () => {
|
|
3808
|
+
await Promise.all(asking);
|
|
3809
|
+
}
|
|
3810
|
+
});
|
|
3811
|
+
giveBack = () => shared.leave(registered.id);
|
|
3812
|
+
const runPass = async (key, phase, prompt, signal, folder, extra = {}) => {
|
|
3813
|
+
const project = getSetting(db, "projectPath");
|
|
3814
|
+
if (project === null && !isFakeMode(env)) return {
|
|
3815
|
+
ok: false,
|
|
3816
|
+
reason: "There is no project set, so this card has no checkout to write a message for."
|
|
3817
|
+
};
|
|
3818
|
+
const resolved = modelsFor(key)["extract-summary"];
|
|
3819
|
+
if (resolved.missingProfile) return {
|
|
3820
|
+
ok: false,
|
|
3821
|
+
reason: `The plain summary row runs on the engine profile ${resolved.engine}, which this machine has no login for. Add it on the Engines settings page, or pick another profile for that row.`
|
|
3822
|
+
};
|
|
3823
|
+
const cwd = extra.scratch === true ? join(dataDir, "passes") : project === null ? dataDir : folder(project);
|
|
3824
|
+
if (extra.scratch === true) mkdirSync(cwd, { recursive: true });
|
|
3825
|
+
const runId = startRun(db, {
|
|
3826
|
+
cardKey: key,
|
|
3827
|
+
phase,
|
|
3828
|
+
engine: resolved.engine,
|
|
3829
|
+
model: resolved.model,
|
|
3830
|
+
effort: resolved.effort,
|
|
3831
|
+
sessionId: null,
|
|
3832
|
+
logPath: "",
|
|
3833
|
+
lane: null,
|
|
3834
|
+
thread: extra.thread
|
|
3835
|
+
});
|
|
3836
|
+
const logPath = join(dataDir, "logs", `${key}-${phase}-${runId}.ndjson`);
|
|
3837
|
+
db.prepare("UPDATE runs SET log_path = ? WHERE id = ?").run(logPath, runId);
|
|
3838
|
+
const job = {
|
|
3839
|
+
runId,
|
|
3840
|
+
cardKey: key,
|
|
3841
|
+
engine: resolved.engine,
|
|
3842
|
+
phase,
|
|
3843
|
+
cwd,
|
|
3844
|
+
taskDir: join(project ?? dataDir, ".tasks", key),
|
|
3845
|
+
projectDir: project,
|
|
3846
|
+
prompt,
|
|
3847
|
+
model: resolved.model,
|
|
3848
|
+
effort: resolved.effort,
|
|
3849
|
+
sessionId: null,
|
|
3850
|
+
resumeFrom: null,
|
|
3851
|
+
timeoutMs: getSetting(db, "runTimeoutMs"),
|
|
3852
|
+
logPath,
|
|
3853
|
+
lane: null,
|
|
3854
|
+
mcpConfigPath: null,
|
|
3855
|
+
settingsPath: engineSettings(project),
|
|
3856
|
+
tools: EXTRACT_SUMMARY_POLICY.tools
|
|
3857
|
+
};
|
|
3858
|
+
const events = [];
|
|
3859
|
+
const stopping = signal === void 0 ? leaving.signal : AbortSignal.any([signal, leaving.signal]);
|
|
3860
|
+
try {
|
|
3861
|
+
const run = runJob(engineFor(job.engine), job, stopping);
|
|
3862
|
+
for await (const event of extra.scratch === true ? run : comparedAround(job, run)) events.push(event);
|
|
3863
|
+
} catch (error) {
|
|
3864
|
+
events.push({
|
|
3865
|
+
type: "failed",
|
|
3866
|
+
reason: error.message,
|
|
3867
|
+
status: null
|
|
3868
|
+
});
|
|
3869
|
+
}
|
|
3870
|
+
const ended = foldRun(events, stopping.aborted);
|
|
3871
|
+
saveRun(db, runId, ended);
|
|
3872
|
+
if (ended.state === "complete") extra.keep?.(said(events));
|
|
3873
|
+
changed();
|
|
3874
|
+
if (ended.state !== "complete") return {
|
|
3875
|
+
ok: false,
|
|
3876
|
+
reason: ended.failureReason ?? `The ${resolved.engine} engine wrote no message. Its log is on the Log tab.`
|
|
3877
|
+
};
|
|
3878
|
+
return {
|
|
3879
|
+
ok: true,
|
|
3880
|
+
answer: said(events),
|
|
3881
|
+
model: resolved.model,
|
|
3882
|
+
cost: ended.costUsd
|
|
3883
|
+
};
|
|
3884
|
+
};
|
|
3885
|
+
const writeMessage = async (key, prompt, signal, repo = ".") => {
|
|
3886
|
+
if (!isPlainName(key)) return {
|
|
3887
|
+
ok: false,
|
|
3888
|
+
reason: `The card key ${JSON.stringify(key)} is not one plain name, so it names no checkout.`
|
|
3889
|
+
};
|
|
3890
|
+
const passing = runPass(key, "commit-message", prompt, signal, (project) => checkoutPath(project, key, repo));
|
|
3891
|
+
const ends = passing.then(() => void 0, () => void 0);
|
|
3892
|
+
asking.add(ends);
|
|
3893
|
+
ends.finally(() => asking.delete(ends));
|
|
3894
|
+
return passing;
|
|
3895
|
+
};
|
|
3896
|
+
const titleThread = (key, thread, question, reply) => runPass(key, THREAD_TITLE, threadTitlePrompt(question, reply), void 0, (project) => project, {
|
|
3897
|
+
thread,
|
|
3898
|
+
scratch: true,
|
|
3899
|
+
keep: (answer) => {
|
|
3900
|
+
const subject = cleanSubject(answer);
|
|
3901
|
+
if (subject === null) return;
|
|
3902
|
+
saveSubject(db, key, thread, subject, false);
|
|
3903
|
+
bumpVersion(db);
|
|
3904
|
+
}
|
|
3905
|
+
}).then(() => void 0);
|
|
3906
|
+
const made = {
|
|
3907
|
+
db,
|
|
3908
|
+
project: registered.id,
|
|
3909
|
+
dataDir,
|
|
3910
|
+
boardOf,
|
|
3911
|
+
get engine() {
|
|
3912
|
+
return fake ?? defaultEngine();
|
|
3913
|
+
},
|
|
3914
|
+
models: offered,
|
|
3915
|
+
scheduler,
|
|
3916
|
+
snapshot: (kind = "delivery") => withAfterLearn(boardSnapshot(db, {
|
|
3917
|
+
board: boardFor(kind, getSetting(db, "deliveryFlow")),
|
|
3918
|
+
queue: shared.queue(),
|
|
3919
|
+
project: registered.id,
|
|
3920
|
+
models: offered(),
|
|
3921
|
+
planned: (key) => planSteps(db, key, env),
|
|
3922
|
+
wall: wallNow()
|
|
3923
|
+
}), {
|
|
3924
|
+
db,
|
|
3925
|
+
scheduler
|
|
3926
|
+
}),
|
|
3927
|
+
buildJob,
|
|
3928
|
+
start: (key, phase) => start(key, phase),
|
|
3929
|
+
optimize,
|
|
3930
|
+
learn,
|
|
3931
|
+
learnRepos,
|
|
3932
|
+
assess,
|
|
3933
|
+
answer,
|
|
3934
|
+
discuss,
|
|
3935
|
+
retry,
|
|
3936
|
+
fix,
|
|
3937
|
+
sendBack,
|
|
3938
|
+
triage,
|
|
3939
|
+
fixFeedback,
|
|
3940
|
+
fixAll,
|
|
3941
|
+
qaFixes,
|
|
3942
|
+
writeMessage,
|
|
3943
|
+
stop: stopRun,
|
|
3944
|
+
reviewAnswered,
|
|
3945
|
+
stopWaiting: () => {
|
|
3946
|
+
stoppingWaits = true;
|
|
3947
|
+
for (const runId of [...waitingReview.keys()]) stopRun(runId);
|
|
3948
|
+
},
|
|
3949
|
+
shutdown,
|
|
3950
|
+
onChange(listen) {
|
|
3951
|
+
listeners.add(listen);
|
|
3952
|
+
return () => {
|
|
3953
|
+
listeners.delete(listen);
|
|
3954
|
+
};
|
|
3955
|
+
},
|
|
3956
|
+
listeners: () => listeners.size + watchers.size,
|
|
3957
|
+
changed,
|
|
3958
|
+
activity: () => [...live.values()].map((entry) => entry.activity),
|
|
3959
|
+
onActivity(listen) {
|
|
3960
|
+
watchers.add(listen);
|
|
3961
|
+
return () => {
|
|
3962
|
+
watchers.delete(listen);
|
|
3963
|
+
};
|
|
3964
|
+
},
|
|
3965
|
+
watchPulls,
|
|
3966
|
+
close() {
|
|
3967
|
+
flushMcpCommit(getSetting(db, "projectPath"));
|
|
3968
|
+
closed = true;
|
|
3969
|
+
clearInterval(pullTimer);
|
|
3970
|
+
listeners.clear();
|
|
3971
|
+
watchers.clear();
|
|
3972
|
+
db.close();
|
|
3973
|
+
open.delete(cacheKey);
|
|
3974
|
+
shared.leave(registered.id);
|
|
3975
|
+
}
|
|
3976
|
+
};
|
|
3977
|
+
startWriting(db, {
|
|
3978
|
+
dataDir: dataFolder,
|
|
3979
|
+
startedAt: processStart
|
|
3980
|
+
});
|
|
3981
|
+
sayCutOff(db);
|
|
3982
|
+
const sweepCopies = (project) => {
|
|
3983
|
+
if (project !== null) sweepQaCopies(qaCopyRoot(dataFolder, project));
|
|
3984
|
+
};
|
|
3985
|
+
const sweepRemoved = (from) => {
|
|
3986
|
+
const project = getSetting(from, "projectPath");
|
|
3987
|
+
if (project === null) return;
|
|
3988
|
+
for (const repo of projectRepos({
|
|
3989
|
+
repos: getSetting(from, "repos"),
|
|
3990
|
+
baseBranch: getSetting(from, "baseBranch")
|
|
3991
|
+
})) {
|
|
3992
|
+
let folder;
|
|
3993
|
+
try {
|
|
3994
|
+
folder = repoFolder(project, repo.path);
|
|
3995
|
+
} catch {
|
|
3996
|
+
continue;
|
|
3997
|
+
}
|
|
3998
|
+
sweepRemovals(folder, env).catch((error) => console.error(`The checkouts moved aside in ${folder} were not deleted: ${error.message}`));
|
|
3999
|
+
}
|
|
4000
|
+
};
|
|
4001
|
+
if (booting) {
|
|
4002
|
+
sweepMcpRuns(dataFolder);
|
|
4003
|
+
sweepQaCopies(join(dataFolder, "qa-copies"));
|
|
4004
|
+
sweepCopies(getSetting(db, "projectPath"));
|
|
4005
|
+
sweepRemoved(db);
|
|
4006
|
+
}
|
|
4007
|
+
const projectAtBoot = getSetting(db, "projectPath");
|
|
4008
|
+
migrateQaBrowser(db, registered.id, keychain, join(dataDir, PLAYWRIGHT_FILE)).then(async (problem) => {
|
|
4009
|
+
if (problem !== null) console.error(problem);
|
|
4010
|
+
const unsaved = await commitMcpList(projectAtBoot, env);
|
|
4011
|
+
if (unsaved !== null) console.error(unsaved);
|
|
4012
|
+
}).catch((error) => console.error(`The QA browser was not moved to Settings, MCP servers: ${error.message}`));
|
|
4013
|
+
if (booting) for (const other of registeredProjects(db)) {
|
|
4014
|
+
if (other.id === registered.id) continue;
|
|
4015
|
+
let swept;
|
|
4016
|
+
try {
|
|
4017
|
+
swept = openProject(dataFolder, other.id);
|
|
4018
|
+
} catch {
|
|
4019
|
+
continue;
|
|
4020
|
+
}
|
|
4021
|
+
try {
|
|
4022
|
+
recoverRuns(swept);
|
|
4023
|
+
sayCutOff(swept);
|
|
4024
|
+
sweepCopies(getSetting(swept, "projectPath"));
|
|
4025
|
+
sweepRemoved(swept);
|
|
4026
|
+
} finally {
|
|
4027
|
+
swept.close();
|
|
4028
|
+
}
|
|
4029
|
+
}
|
|
4030
|
+
afterLearn = followLearn(made, (key, to) => closed ? null : moveTo(made, key, to));
|
|
4031
|
+
afterLearn();
|
|
4032
|
+
open.set(cacheKey, made);
|
|
4033
|
+
return made;
|
|
4034
|
+
}
|
|
4035
|
+
}
|
|
4036
|
+
|
|
4037
|
+
export { limitBlock as a, keepLimitsOf as b, stackStatusFor as c, loopOf as d, appHeld as e, cleanSummary as f, pressStack as g, isStackAction as i, keepAwakeCommand as k, loop as l, notificationsView as n, openDiscussion as o, processStart as p, qaInputFor as q, stackLane as s, triageOfferFor as t };
|
|
4038
|
+
//# sourceMappingURL=loop.js-D3guWKLp.js.map
|