@weavecode/weave 0.1.5 → 0.1.7
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/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/encodeurl/README.md +14 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/encodeurl/index.js +5 -10
- package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/encodeurl/package.json +10 -6
- package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/CHANGELOG.md +42 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/README.md +38 -10
- package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/dist/qs.js +18 -18
- package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/lib/parse.js +16 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/lib/utils.js +13 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/package.json +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/express-rate-limit/dist/index.cjs +6 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/express-rate-limit/dist/index.mjs +6 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/express-rate-limit/package.json +10 -10
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/decrypt.d.ts +3 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/unsecured.d.ts +2 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/verify.d.ts +3 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/types.d.ts +8 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/util/decode_jwt.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/package.json +1 -1
- package/node_modules/@weavecode/cli/dist/cli.js +4 -4
- package/node_modules/@weavecode/cli/dist/commands/chpass.js +1 -1
- package/node_modules/@weavecode/cli/dist/commands/daemon-auth.js +1 -1
- package/node_modules/@weavecode/cli/dist/commands/daemon.d.ts +2 -0
- package/node_modules/@weavecode/cli/dist/commands/daemon.js +2 -2
- package/node_modules/@weavecode/cli/dist/commands/dashboard.js +2 -2
- package/node_modules/@weavecode/cli/dist/commands/doctor.js +1 -1
- package/node_modules/@weavecode/cli/dist/commands/init.js +1 -1
- package/node_modules/@weavecode/cli/dist/commands/msg.js +2 -2
- package/node_modules/@weavecode/cli/dist/commands/scan.js +1 -1
- package/node_modules/@weavecode/cli/dist/commands/status.js +2 -2
- package/node_modules/@weavecode/cli/dist/commands/uninstall.js +1 -1
- package/node_modules/@weavecode/cli/dist/i18n/dict/en.js +5 -5
- package/node_modules/@weavecode/cli/dist/i18n/dict/zh.d.ts +6 -1
- package/node_modules/@weavecode/cli/dist/i18n/dict/zh.js +5 -5
- package/node_modules/@weavecode/cli/dist/i18n/index.js +1 -1
- package/node_modules/@weavecode/cli/dist/i18n/t.js +1 -1
- package/node_modules/@weavecode/cli/dist/init/claudemd-gen.js +3 -3
- package/node_modules/@weavecode/cli/dist/init/executor.js +3 -3
- package/node_modules/@weavecode/cli/dist/init/git-commit.js +2 -2
- package/node_modules/@weavecode/cli/dist/init/harnesses/claude.js +7 -7
- package/node_modules/@weavecode/cli/dist/init/harnesses/codex.js +1 -1
- package/node_modules/@weavecode/cli/dist/init/instruction-link.js +1 -1
- package/node_modules/@weavecode/cli/dist/init/plugin-templates.js +1 -1
- package/node_modules/@weavecode/cli/dist/init/prompt.js +4 -4
- package/node_modules/@weavecode/cli/dist/init/provision.js +1 -1
- package/node_modules/@weavecode/cli/dist/init/uninstall.js +6 -6
- package/node_modules/@weavecode/cli/dist/init/wiring.js +1 -1
- package/node_modules/@weavecode/cli/dist/parser.js +1 -1
- package/node_modules/@weavecode/cli/dist/statusline/ansi.js +1 -1
- package/node_modules/@weavecode/cli/dist/statusline/mock-input.js +1 -1
- package/node_modules/@weavecode/cli/dist/statusline/preview.js +2 -2
- package/node_modules/@weavecode/cli/package.json +5 -5
- package/node_modules/@weavecode/core/dist/harness-checks.js +1 -1
- package/node_modules/@weavecode/core/dist/harness.d.ts +25 -0
- package/node_modules/@weavecode/core/dist/harness.js +1 -1
- package/node_modules/@weavecode/core/dist/index.d.ts +1 -1
- package/node_modules/@weavecode/core/dist/index.js +1 -1
- package/node_modules/@weavecode/core/dist/platform.js +1 -1
- package/node_modules/@weavecode/core/dist/types.js +1 -1
- package/node_modules/@weavecode/core/dist/utils/fs.js +1 -1
- package/node_modules/@weavecode/core/dist/utils/logger.js +1 -1
- package/node_modules/@weavecode/core/package.json +1 -1
- package/node_modules/@weavecode/harness/dist/claude/assets.js +4 -4
- package/node_modules/@weavecode/harness/dist/claude/capture.js +9 -9
- package/node_modules/@weavecode/harness/dist/claude/commands.d.ts +3 -0
- package/node_modules/@weavecode/harness/dist/claude/commands.js +2 -3
- package/node_modules/@weavecode/harness/dist/claude/config.js +2 -2
- package/node_modules/@weavecode/harness/dist/claude/detect.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/edits.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/event-source.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/images.js +2 -2
- package/node_modules/@weavecode/harness/dist/claude/index.d.ts +1 -0
- package/node_modules/@weavecode/harness/dist/claude/index.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/liveness.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/mcp-gen.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/messaging.js +2 -2
- package/node_modules/@weavecode/harness/dist/claude/model-aliases.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/narration.d.ts +0 -11
- package/node_modules/@weavecode/harness/dist/claude/narration.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/peers.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/plan.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/plugins.js +4 -4
- package/node_modules/@weavecode/harness/dist/claude/prompt-inbox.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/prompt.js +3 -3
- package/node_modules/@weavecode/harness/dist/claude/questions.js +2 -2
- package/node_modules/@weavecode/harness/dist/claude/resume.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/rewind.d.ts +8 -0
- package/node_modules/@weavecode/harness/dist/claude/rewind.js +1 -0
- package/node_modules/@weavecode/harness/dist/claude/settings-gen.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/side-question.js +2 -2
- package/node_modules/@weavecode/harness/dist/claude/statusline/generator.js +36 -15
- package/node_modules/@weavecode/harness/dist/claude/statusline/git-cache.js +1 -1
- package/node_modules/@weavecode/harness/dist/claude/statusline/surface.js +2 -2
- package/node_modules/@weavecode/harness/dist/claude/transcript-cursor.d.ts +26 -0
- package/node_modules/@weavecode/harness/dist/claude/transcript-cursor.js +2 -0
- package/node_modules/@weavecode/harness/dist/claude/transcript.js +7 -7
- package/node_modules/@weavecode/harness/dist/codex/assets.js +1 -1
- package/node_modules/@weavecode/harness/dist/codex/capture.js +2 -2
- package/node_modules/@weavecode/harness/dist/codex/commands.js +4 -4
- package/node_modules/@weavecode/harness/dist/codex/config.js +2 -2
- package/node_modules/@weavecode/harness/dist/codex/detect.js +1 -1
- package/node_modules/@weavecode/harness/dist/codex/event-source.js +2 -2
- package/node_modules/@weavecode/harness/dist/codex/images.js +1 -1
- package/node_modules/@weavecode/harness/dist/codex/index.js +1 -1
- package/node_modules/@weavecode/harness/dist/codex/liveness.js +1 -1
- package/node_modules/@weavecode/harness/dist/codex/mcp.js +1 -1
- package/node_modules/@weavecode/harness/dist/codex/messaging.js +2 -2
- package/node_modules/@weavecode/harness/dist/codex/narration.js +1 -1
- package/node_modules/@weavecode/harness/dist/codex/plugin-state.js +1 -1
- package/node_modules/@weavecode/harness/dist/codex/plugins.js +3 -3
- package/node_modules/@weavecode/harness/dist/codex/provision.js +1 -1
- package/node_modules/@weavecode/harness/dist/codex/questions.js +2 -2
- package/node_modules/@weavecode/harness/dist/codex/rollout.js +5 -5
- package/node_modules/@weavecode/harness/dist/codex/side-question.js +4 -4
- package/node_modules/@weavecode/harness/dist/codex/titles.js +4 -4
- package/node_modules/@weavecode/harness/dist/codex/toml.js +13 -13
- package/node_modules/@weavecode/harness/dist/codex/transcript.js +2 -2
- package/node_modules/@weavecode/harness/dist/driver.d.ts +56 -1
- package/node_modules/@weavecode/harness/dist/driver.js +1 -1
- package/node_modules/@weavecode/harness/dist/init/generated.js +2 -2
- package/node_modules/@weavecode/harness/dist/init/pipeline.js +1 -1
- package/node_modules/@weavecode/harness/dist/registry-wiring.js +1 -1
- package/node_modules/@weavecode/harness/dist/shared/install-link.js +1 -1
- package/node_modules/@weavecode/harness/dist/shared/json-cap.js +1 -1
- package/node_modules/@weavecode/harness/package.json +2 -2
- package/node_modules/@weavecode/server/dist/config/profiles.d.ts +19 -13
- package/node_modules/@weavecode/server/dist/config/profiles.js +2 -2
- package/node_modules/@weavecode/server/dist/daemon/config-routes.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/dev-entry.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/entry.js +7 -1
- package/node_modules/@weavecode/server/dist/daemon/hooks-routes.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/opener/launch.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/opener.d.ts +2 -0
- package/node_modules/@weavecode/server/dist/daemon/opener.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/routes/session-control.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/routes/session-insights.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/routes/uploads.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/routes/visualizations.d.ts +3 -0
- package/node_modules/@weavecode/server/dist/daemon/routes/visualizations.js +1 -0
- package/node_modules/@weavecode/server/dist/daemon/server.js +2 -2
- package/node_modules/@weavecode/server/dist/daemon/session-open.d.ts +17 -0
- package/node_modules/@weavecode/server/dist/daemon/session-open.js +1 -1
- package/node_modules/@weavecode/server/dist/daemon/session-probe.d.ts +5 -4
- package/node_modules/@weavecode/server/dist/daemon/start.js +1 -1
- package/node_modules/@weavecode/server/dist/db/db.js +6 -2
- package/node_modules/@weavecode/server/dist/hooks/bus.d.ts +3 -1
- package/node_modules/@weavecode/server/dist/hooks/delivery/ack-gate.d.ts +12 -6
- package/node_modules/@weavecode/server/dist/hooks/delivery/ack-gate.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/delivery/channels.d.ts +3 -3
- package/node_modules/@weavecode/server/dist/hooks/delivery/channels.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/delivery/keys.d.ts +19 -9
- package/node_modules/@weavecode/server/dist/hooks/delivery/keys.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/delivery/relay.d.ts +2 -2
- package/node_modules/@weavecode/server/dist/hooks/delivery/relay.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/delivery/views.d.ts +5 -1
- package/node_modules/@weavecode/server/dist/hooks/delivery/views.js +1 -1
- package/node_modules/@weavecode/server/dist/hooks/message-deliverer.d.ts +45 -38
- package/node_modules/@weavecode/server/dist/hooks/message-deliverer.js +5 -3
- package/node_modules/@weavecode/server/dist/repositories/hook-events.d.ts +1 -1
- package/node_modules/@weavecode/server/dist/repositories/hook-events.js +4 -4
- package/node_modules/@weavecode/server/dist/repositories/sessions.d.ts +11 -1
- package/node_modules/@weavecode/server/dist/repositories/sessions.js +4 -2
- package/node_modules/@weavecode/server/dist/repositories/uploads.d.ts +14 -4
- package/node_modules/@weavecode/server/dist/repositories/uploads.js +11 -11
- package/node_modules/@weavecode/server/dist/surfaces.d.ts +3 -1
- package/node_modules/@weavecode/server/dist/surfaces.js +1 -1
- package/node_modules/@weavecode/server/package.json +4 -4
- package/node_modules/@weavecode/server/web/dist/assets/{abnfDiagram-WEYOIA3C-C-f9WfD3.js → abnfDiagram-WEYOIA3C-DDeQkTf5.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{arc-D62qulAD.js → arc-CRZTRyjb.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{architectureDiagram-ZHVYKT53-B6ZJRpcL.js → architectureDiagram-ZHVYKT53-Dj54DE3O.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{blockDiagram-RJAE7QA3-DOtDFeiT.js → blockDiagram-RJAE7QA3-BIH8mSIZ.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{c4Diagram-XDPPPE54-DWn3ng8X.js → c4Diagram-XDPPPE54-5YoKWFOD.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/channel-5VM93AJ8.js +1 -0
- package/node_modules/@weavecode/server/web/dist/assets/{chunk-2E7WHVMD-B5IIc9cn.js → chunk-2E7WHVMD-B653kMXt.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{chunk-2Q5K7J3B-BUU9Zvt8.js → chunk-2Q5K7J3B-f_A4_eDz.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{chunk-4EMNKR2T-CqEGIghP.js → chunk-4EMNKR2T-v5j5qNGj.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{chunk-55XCU76K-D36o_E2b.js → chunk-55XCU76K-CgEqeP7j.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{chunk-5VM5RSS4-sxws8ERh.js → chunk-5VM5RSS4-BeROhLXN.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{chunk-JWPE2WC7-CJo_rEEb.js → chunk-JWPE2WC7-D6dXb_jr.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{chunk-VQ5W62QI-9UlLCpsb.js → chunk-VQ5W62QI-CnHdSEMi.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{chunk-XXDRQBXY-CX9CPbWb.js → chunk-XXDRQBXY-BkG_e6PE.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{chunk-ZCHMQSOR-DwEfdZcF.js → chunk-ZCHMQSOR-DxR-fxzs.js} +2 -2
- package/node_modules/@weavecode/server/web/dist/assets/{classDiagram-v2-4MYWR3UA-CFCmIyt8.js → classDiagram-v2-4MYWR3UA-DQe1b_k8.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{cose-bilkent-JH36ORCC-qWXeXJTn.js → cose-bilkent-JH36ORCC-DThrA8S5.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{cynefin-EF2NZ3EQ-CXabWQxz.js → cynefin-EF2NZ3EQ-OZotFKUu.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{cynefinDiagram-WF24UDRP-Bzpj8Qbj.js → cynefinDiagram-WF24UDRP-DJjq2hfT.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{dagre-NK4GIZVX-CXsL8t30.js → dagre-NK4GIZVX-C2vH93HT.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{diagram-CBK3MWTC-xfR-zlAD.js → diagram-CBK3MWTC-DrF_ScM-.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{diagram-I5XIIV2D-BjMqEsXr.js → diagram-I5XIIV2D-D1qoUJ4t.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{diagram-ODIL2UCW-QZpf8KhT.js → diagram-ODIL2UCW-D9A6W8oB.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{diagram-PFBEJUXE-Cw1ESWft.js → diagram-PFBEJUXE-PeI-eyu2.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{diagram-RJA3I4VV-CAy2RYYZ.js → diagram-RJA3I4VV-DITY0Rd8.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{diagram-TYUNFSNR-B09WciWt.js → diagram-TYUNFSNR-D5KieEw5.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{ebnfDiagram-V4P3TTPT-DuLmHG0U.js → ebnfDiagram-V4P3TTPT-DDylK-gz.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{elk-QONTBCTQ--zzx0EVP.js → elk-QONTBCTQ-D3xrVg0U.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{erDiagram-KYQIGQAA-BPDjG5vB.js → erDiagram-KYQIGQAA-y_V1cor7.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{flowDiagram-IUGLLWBU-DtE2M9a_.js → flowDiagram-IUGLLWBU-BJ8Z0MkF.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{ganttDiagram-R7GPNTJY-B-4AaWVa.js → ganttDiagram-R7GPNTJY-C0q-CS1T.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{gitGraphDiagram-PDYL7XHY-CYj5FGYx.js → gitGraphDiagram-PDYL7XHY-BYTComiB.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/index-BKxAxaVG.js +1091 -0
- package/node_modules/@weavecode/server/web/dist/assets/index-C0Sd4MH7.css +11 -0
- package/node_modules/@weavecode/server/web/dist/assets/{infoDiagram-MVDRKAX5-DHYSDj-3.js → infoDiagram-MVDRKAX5-DtixgjLP.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{ishikawaDiagram-HPEHV2GE-CumAEBoU.js → ishikawaDiagram-HPEHV2GE-ChEnND76.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{journeyDiagram-BOSHW7O7-ES3O3X05.js → journeyDiagram-BOSHW7O7-DHcNtpYF.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{kanban-definition-FNSA4HC5-BMIrf0d9.js → kanban-definition-FNSA4HC5-Dft7qpW5.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{linear-DEZ5FO1r.js → linear-DEo11t-X.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{mermaid.core-D7gm2szA.js → mermaid.core-D_Dp_Kl2.js} +4 -4
- package/node_modules/@weavecode/server/web/dist/assets/{mindmap-definition-6OY57UG3-BBQP8lyN.js → mindmap-definition-6OY57UG3-CM6OAd_-.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{pegDiagram-ECIUJNBX-DzkKsqmg.js → pegDiagram-ECIUJNBX-_QkY0h8Q.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{pieDiagram-GNMPY74T-zR3q7Qs1.js → pieDiagram-GNMPY74T-ZGr5vtDj.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{quadrantDiagram-D57K4MC3-B4xuIsMW.js → quadrantDiagram-D57K4MC3-D8pQ_PU2.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{railroadDiagram-Y72NRBL7-D2I52m9D.js → railroadDiagram-Y72NRBL7-DUIo-WmA.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{requirementDiagram-EQYSW5RA-aJ1KfKj2.js → requirementDiagram-EQYSW5RA-C90DU5Ny.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{sankeyDiagram-SY24JHO5-CEq16Ecf.js → sankeyDiagram-SY24JHO5-B_poYGgJ.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{sequenceDiagram-BLEHNHQU-Bc66KG9f.js → sequenceDiagram-BLEHNHQU-DDW7b2Dn.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{sizeCapture-INFHLROL-Ddizw_UG.js → sizeCapture-INFHLROL-CmKoqX6K.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{stateDiagram-v2-A6IESKWZ-C1eVtEX9.js → stateDiagram-v2-A6IESKWZ-CkVMAyxG.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{swimlanes-B3ENRKFQ-CCd_KlpZ.js → swimlanes-B3ENRKFQ-Dm_Omzky.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/swimlanesDiagram-AYQRV4AK-Bjj8ZA4d.js +8 -0
- package/node_modules/@weavecode/server/web/dist/assets/{timeline-definition-JXYKGLGB-DqpBhIII.js → timeline-definition-JXYKGLGB-DnhkRGLb.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{usecaseDiagram-WPOLBNNX-bX_jNjSt.js → usecaseDiagram-WPOLBNNX-_TdIjC6Z.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{vennDiagram-Q3Y3IDCW-D07CUHl3.js → vennDiagram-Q3Y3IDCW-FzgsymXB.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{wardleyDiagram-IVAIDKWA-CZ5ovcWa.js → wardleyDiagram-IVAIDKWA-BwqimStC.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/assets/{xychartDiagram-4URNHDU4-CBTh52hU.js → xychartDiagram-4URNHDU4-CFjjVPIV.js} +1 -1
- package/node_modules/@weavecode/server/web/dist/icons/apple-touch-icon.png +0 -0
- package/node_modules/@weavecode/server/web/dist/icons/icon-192.png +0 -0
- package/node_modules/@weavecode/server/web/dist/icons/icon-512.png +0 -0
- package/node_modules/@weavecode/server/web/dist/icons/icon-maskable-512.png +0 -0
- package/node_modules/@weavecode/server/web/dist/index.html +11 -2
- package/node_modules/@weavecode/server/web/dist/manifest.webmanifest +16 -0
- package/node_modules/@weavecode/server/web/dist/sw.js +14 -12
- package/node_modules/@weavecode/templates/package.json +2 -2
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/tslib/README.md +3 -8
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/tslib/package.json +1 -1
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/tslib/tslib.d.ts +4 -2
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/tslib/tslib.es6.js +10 -1
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/tslib/tslib.es6.mjs +10 -1
- package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/tslib/tslib.js +10 -1
- package/node_modules/selfsigned/node_modules/pkijs/node_modules/tslib/README.md +3 -8
- package/node_modules/selfsigned/node_modules/pkijs/node_modules/tslib/package.json +1 -1
- package/node_modules/selfsigned/node_modules/pkijs/node_modules/tslib/tslib.d.ts +4 -2
- package/node_modules/selfsigned/node_modules/pkijs/node_modules/tslib/tslib.es6.js +10 -1
- package/node_modules/selfsigned/node_modules/pkijs/node_modules/tslib/tslib.es6.mjs +10 -1
- package/node_modules/selfsigned/node_modules/pkijs/node_modules/tslib/tslib.js +10 -1
- package/package.json +6 -6
- package/node_modules/@weavecode/server/web/dist/assets/channel-CjSr3Zfg.js +0 -1
- package/node_modules/@weavecode/server/web/dist/assets/index-BGdTLG4q.js +0 -1031
- package/node_modules/@weavecode/server/web/dist/assets/index-CEpJpR7P.css +0 -11
- package/node_modules/@weavecode/server/web/dist/assets/swimlanesDiagram-AYQRV4AK-yIifcHaR.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile as
|
|
1
|
+
import{readFile as d,writeFile as g,access as T,mkdir as k}from"node:fs/promises";import $ from"node:path";import{parse as m}from"smol-toml";import{CodexTomlCorruptError as v,parseSectionEntries as w,removeTomlSection as M,renderTomlHeader as S,renderTomlKey as x,renderTomlString as f,sameKey as y,splitTomlSections as l,upsertTomlSection as _}from"./toml.js";export function readCodexMcpFromText(r){let e;try{e=m(r)}catch{return{}}const n=e.mcp_servers;if(!n||typeof n!="object"||Array.isArray(n))return{};const t={};for(const[o,s]of Object.entries(n)){const c=E(s);c&&(t[o]=c)}return t}function j(r){if(!r||typeof r!="object"||Array.isArray(r))return;const e={};for(const[n,t]of Object.entries(r))typeof t=="string"&&(e[n]=t);return Object.keys(e).length>0?e:void 0}function E(r){if(!r||typeof r!="object"||Array.isArray(r))return null;const e=r;if(typeof e.url=="string"){const t={url:e.url},o=j(e.http_headers);return o&&(t.headers=o),typeof e.bearer_token_env_var=="string"&&(t.bearerTokenEnvVar=e.bearer_token_env_var),t}if(typeof e.command!="string")return null;const n={command:e.command};if(Array.isArray(e.args)){const t=e.args.filter(o=>typeof o=="string");t.length>0&&(n.args=t)}if(e.env&&typeof e.env=="object"&&!Array.isArray(e.env)){const t={};for(const[o,s]of Object.entries(e.env))typeof s=="string"&&(t[o]=s);Object.keys(t).length>0&&(n.env=t)}return n}function b(r,e,n,t,o){const s=[];if("command"in e)s.push(`command = ${f(e.command)}`),e.args&&e.args.length>0&&s.push(`args = [${e.args.map(f).join(", ")}]`);else{s.push(`url = ${f(e.url)}`),e.bearerTokenEnvVar&&s.push(`bearer_token_env_var = ${f(e.bearerTokenEnvVar)}`);const a=Object.entries(e.headers??{});a.length>0&&s.push(`http_headers = { ${a.map(([i,u])=>`${x(i)} = ${f(u)}`).join(", ")} }`)}if(o&&n){const a=new Set(["command","args","env","url","http_headers","bearer_token_env_var"]);for(const[i,u]of w(n.lines.slice(1)))a.has(i)||s.push(u)}const c=Object.entries("env"in e?e.env??{}:{}),p=o&&t?w(t.lines.slice(1)).filter(([a])=>!(a in("env"in e?e.env??{}:{}))):[];if(c.length>0||p.length>0){s.push(""),s.push(S([...r,"env"]));for(const[a,i]of c)s.push(`${x(a)} = ${f(i)}`);for(const[,a]of p)s.push(a)}return s}export function upsertCodexMcpInText(r,e,n){const t=["mcp_servers",e],o=A(r);if(o)throw o;const s=l(r),c=s.find(i=>y(i.key,t)),p=s.find(i=>y(i.key,[...t,"env"])),a=_(r,t,b(t,n,c,p,!0));try{return m(a),a}catch{const i=_(r,t,b(t,n,c,p,!1));try{return m(i),i}catch(u){throw new v(`unable to produce valid TOML for [mcp_servers.${e}]: ${u instanceof Error?u.message:String(u)}`)}}}export function removeCodexMcpFromText(r,e){return M(r,["mcp_servers",e])}function A(r){return l(r)[0].lines.find(t=>/^\s*mcp_servers\s*=/.test(t))?new v('~/.codex/config.toml defines "mcp_servers" as an inline value \u2014 weave only manages the [mcp_servers.<name>] section form'):null}async function O(r){try{return await d(r,"utf-8")}catch{return""}}async function h(r){try{return await T(r),!0}catch{return!1}}export async function readCodexMcpServers(r){return await h(r)?readCodexMcpFromText(await d(r,"utf-8")):{}}export async function codexMcpExists(r,e){return await h(e)?C(await d(e,"utf-8"),["mcp_servers",r]):!1}function C(r,e){return l(r).some(n=>y(n.key,e))}export async function writeCodexMcpServer(r,e,n){const t=await O(n);if(t.trim()!=="")try{m(t)}catch(o){throw new v(`${n} is not valid TOML \u2014 refusing to write: ${o instanceof Error?o.message:String(o)}`)}await k($.dirname(n),{recursive:!0}),await g(n,upsertCodexMcpInText(t,r,e),"utf-8")}export async function removeCodexMcpServer(r,e){if(!await h(e))return!1;const n=await d(e,"utf-8");try{m(n)}catch(s){throw new v(`${e} is not valid TOML \u2014 refusing to write: ${s instanceof Error?s.message:String(s)}`)}const{text:t,removed:o}=removeCodexMcpFromText(n,r);return o&&await g(e,t,"utf-8"),o}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as d,readFileSync as l}from"node:fs";import a from"node:path";import{HARNESS_LIFECYCLE as u}from"@weavecode/core";import{CODEX_SIDE_QUESTION as f}from"./side-question.js";function m(){const n=process.env.WEAVE_CODEX_BIN;if(n&&n.trim())return{bin:n.trim(),prefix:[]};if(process.platform!=="win32")return{bin:"codex",prefix:[]};for(const t of(process.env.PATH??"").split(a.delimiter)){if(!t)continue;const s=a.join(t,"codex.exe");if(d(s))return{bin:s,prefix:[]};const e=a.join(t,"codex.cmd");if(d(e))try{const o=l(e,"utf8").split(/\r?\n/).map(c=>c.trim()).find(c=>/^".+?\.exe"/.test(c)),r=/^"(.+?\.exe)"/.exec(o??"");if(r&&d(r[1]))return{bin:r[1],prefix:[]}}catch{}const i=a.join(t,"node_modules","@openai","codex","bin","codex.js");if(d(i))return{bin:process.execPath,prefix:[i]}}return{bin:"codex",prefix:[]}}export const CODEX_QUEUED_PROMPT={command(n,t){const{bin:s,prefix:e}=m();return{bin:s,args:[...e,"queue","--thread",n,"--message",t]}},timeoutMs:3e4},CODEX_ATTACH={kinds:["file","image"],composePrompt(n,t){const s=t.filter(i=>!n.includes(i.path));if(s.length===0)return n;const e=s.map(i=>i.path).join(`
|
|
2
2
|
`);return n?`${n}
|
|
3
3
|
|
|
4
|
-
${e}`:e}};const
|
|
4
|
+
${e}`:e}};const h={kinds:["file","dir"],lines:!1,expression:({path:n,kind:t})=>t==="dir"?`${n}/`:n,recognize:n=>{const t=[];for(const s of n.matchAll(/(?:^|\s)"([^"]*\s[^"]*)"(?=\s|$)/g)){const e=s[1],i=s.index+(s[0].startsWith(" ")?1:0),o=i+e.length+2;e.startsWith("/")||e.includes(":")||t.push({start:i,end:o,ref:n.slice(i,o),path:e,kind:"file"})}for(const s of n.matchAll(/(?:^|\s)([^\s"]+)(?=\s|$)/g)){const e=s[1];if(!/[./]/.test(e))continue;const i=s.index+(s[0].startsWith(" ")?1:0),o=i+e.length;if(e.startsWith("/")||e.includes(":")||e.includes("\\")||t.some(p=>i>=p.start&&o<=p.end))continue;const r=e.endsWith("/"),c=r?e.slice(0,-1):e;c&&t.push({start:i,end:o,ref:n.slice(i,o),path:c,kind:r?"dir":"file"})}return t.sort((s,e)=>s.start-e.start)}};export const CODEX_MESSAGING={harness:"codex",discovery:!1,prompt:null,promptInbox:null,queuedPrompt:CODEX_QUEUED_PROMPT,inject:null,headless:null,idleSignals:[...u.codex.close,"SessionEnd"],paneEnvSource:"launch",attach:CODEX_ATTACH,pathRefs:h,sideQuestion:f,unsupportedReasons:{discovery:"Codex event ingestion is pending research (BACKLOG \xA710-6); sessions are not discoverable",prompt:"Codex has no native peer-messaging channel; prompts reach it via its own queue or terminal text injection",inject:"Codex has no synchronous injection channel yet (pending research)",headless:"Codex resume is pending research",watch:"Codex error-ended turns emit no Stop; those rounds never fire idle/turnEnd"}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createReadStream as
|
|
1
|
+
import{createReadStream as a}from"node:fs";import{createInterface as i}from"node:readline";export const CODEX_NARRATION={async sessionNarration({transcriptPath:n}){if(!n)return null;const e=[],t=i({input:a(n,{encoding:"utf8"}),crlfDelay:1/0});try{for await(const r of t){const s=l(r);s&&e.push(s)}}catch{return null}finally{t.close()}return e},lineParser:l};function l(n){if(!n.includes('"AgentMessage"'))return null;let e;try{e=JSON.parse(n)}catch{return null}if(e.type!=="event_msg")return null;const t=e.payload;if(t?.type!=="AgentMessage")return null;const r=typeof t.message=="string"?t.message:"";return r.trim()?{at:typeof e.timestamp=="string"?e.timestamp:null,text:r}:null}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{access as
|
|
1
|
+
import{access as u,mkdir as p,readFile as n,writeFile as d}from"node:fs/promises";import{homedir as s}from"node:os";import m from"node:path";import{parse as f}from"smol-toml";import{CODEX_ASSETS as l}from"./assets.js";import{CodexTomlCorruptError as b,upsertCodexPluginEnabledInText as w}from"./toml.js";const c=r=>u(r).then(()=>!0,()=>!1);async function E(r){if(!await c(r))return{};try{const t=f(await n(r,"utf-8")).plugins;if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[o,a]of Object.entries(t))a&&typeof a=="object"&&typeof a.enabled=="boolean"&&(e[o]=a.enabled);return e}catch{return{}}}export const CODEX_PLUGIN_STATE={readGlobalEnabled:()=>E(l.userConfigFile(s())),async writeGlobalEnabled(r,i){const t=l.userConfigFile(s());let e="";if(await c(t)){e=await n(t,"utf-8");try{f(e)}catch(o){throw new b(`${t} is not valid TOML \u2014 refusing to write: ${o instanceof Error?o.message:String(o)}`)}}await p(m.dirname(t),{recursive:!0}),await d(t,w(e,r,i),"utf-8")}};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{spawn as
|
|
2
|
-
`).trim()||`exit ${e}`;u(new Error(
|
|
3
|
-
`,"utf8")};return{projectPluginDir:t=>
|
|
1
|
+
import{spawn as C}from"node:child_process";import{homedir as I}from"node:os";import{lstat as A,mkdir as v,readFile as $,readdir as P,writeFile as E}from"node:fs/promises";import c from"node:path";import{CODEX_ASSETS as U}from"./assets.js";import{parseSectionEntries as L,removeTomlSection as G,splitTomlSections as O,upsertCodexPluginEnabledInText as S}from"./toml.js";export const CODEX_MARKETPLACE="weave";const K=6e4,_=2e3,M=64*1024;export function codexCommandLine(a){return["codex",...a.map(g=>`"${g.replace(/"/g,'\\"')}"`)].join(" ")}function N(a){if(!(a.exitCode!==null||a.signalCode!==null)){if(process.platform==="win32"&&a.pid!==void 0){C("taskkill",["/pid",String(a.pid),"/t","/f"],{windowsHide:!0,stdio:"ignore"}).unref();return}a.kill("SIGKILL")}}function D(a){return a.length>_?`${a.slice(0,_)}\u2026`:a}const q=(a,g)=>new Promise((y,u)=>{const x=process.platform==="win32",l=C(x?process.env.ComSpec||"cmd.exe":"codex",x?["/d","/s","/c",codexCommandLine(a)]:a,{windowsHide:!0,windowsVerbatimArguments:x,stdio:["ignore","pipe","pipe"]}),d=`codex ${a.join(" ")}`;let p="",f="",m=!1;const b=e=>{m||(m=!0,clearTimeout(t),u(new Error(D(e))))},t=setTimeout(()=>{N(l),b(`${d}: timed out after ${g.timeoutMs}ms`)},g.timeoutMs);l.stdout?.setEncoding("utf8"),l.stdout?.on("data",e=>{p.length<M&&(p+=e)}),l.stderr?.setEncoding("utf8"),l.stderr?.on("data",e=>{f.length<M&&(f+=e)}),l.on("error",e=>b(`${d}: ${e.message}`)),l.on("close",e=>{if(m)return;if(m=!0,clearTimeout(t),e===0){y({stdout:p,stderr:f});return}const i=[f,p].filter(Boolean).join(`
|
|
2
|
+
`).trim()||`exit ${e}`;u(new Error(D(`${d}: ${i}`)))})});export function createCodexPluginSurface(a={}){const g=a.exec??q,y=t=>g(t,{timeoutMs:K}),u=()=>U.userConfigFile(I()),x=()=>c.join(I(),".codex","plugins","cache"),l=(t,e)=>`${t}@${e??CODEX_MARKETPLACE}`,d=async()=>{try{return await $(u(),"utf8")}catch{return null}},p=t=>{if(!t)return{};const e=O(t),i={};for(const n of e)if(!(!n.key||n.key.length!==2||n.key[0]!=="plugins"))for(const[r,o]of L(n.lines.slice(1))){if(r!=="enabled")continue;const s=o.split("=")[1]?.trim();(s==="true"||s==="false")&&(i[n.key[1]]=s==="true")}return i},f=async()=>{const t=x(),e={};let i;try{i=await P(t,{withFileTypes:!0})}catch{return e}for(const n of i){if(!n.isDirectory()&&!n.isSymbolicLink())continue;const r=c.join(t,n.name);let o;try{o=await P(r,{withFileTypes:!0})}catch{continue}for(const s of o){if(!s.isDirectory()&&!s.isSymbolicLink())continue;const w=c.join(r,s.name);let h;try{h=await P(w,{withFileTypes:!0})}catch{continue}const k=h.filter(j=>j.isDirectory()||j.isSymbolicLink());if(k.length===0)continue;const T=k.map(j=>j.name).sort().pop(),F=`${s.name}@${n.name}`;e[F]=[{scope:"user",installPath:c.join(w,T),version:T}]}}return e},m=(t,e,i)=>{const n=e?.[e.length-1];return{key:t,alreadyInstalled:i,...n?.scope?{scope:n.scope}:{},...n?.installPath?{installPath:n.installPath}:{},...n?.version?{version:n.version}:{}}},b=async(t,e,i)=>{if(!t.dir)throw new Error(`marketplace dir required for ${e}@${t.name}`);if((await A(t.dir)).isSymbolicLink())return;const n=c.join(t.dir,".claude-plugin","marketplace.json");let r={};try{r=JSON.parse(await $(n,"utf8"))}catch{r={}}const o=Array.isArray(r.plugins)?[...r.plugins]:[],s=`./${c.relative(t.dir,i).split(c.sep).join("/")}`,w={name:e,source:s},h=o.findIndex(k=>k?.name===e);h>=0?o[h]=w:o.push(w),r.name=t.name,r.owner||(r.owner={name:"weave"}),r.plugins=o,await v(c.dirname(n),{recursive:!0}),await E(n,`${JSON.stringify(r,null,2)}
|
|
3
|
+
`,"utf8")};return{projectPluginDir:t=>c.join(t,".codex","plugins"),pluginKey:l,parsePluginKey(t){const e=t.lastIndexOf("@");return e>0?{name:t.slice(0,e),market:t.slice(e+1)}:{name:t,market:CODEX_MARKETPLACE}},async globalInstall(t,e={}){let i=e.name;if(!i)try{const s=JSON.parse(await $(c.join(t,".claude-plugin","plugin.json"),"utf8"));i=typeof s.name=="string"?s.name:void 0}catch{i=void 0}if(!i)throw new Error(`plugin manifest missing name: ${t}`);const n=e.marketplace,r=l(i,n?.name),o=(await f())[r];if(o&&o.length>0)return m(r,o,!0);if(n)await b(n,i,t),await y(["plugin","marketplace","add",n.dir??""]);else throw new Error(`codex plugin install requires a marketplace (got none for ${r}); weave-managed packs must come from a market directory`);return await y(["plugin","add",r,"--json"]),m(r,(await f())[r],!1)},readInstalled:f,async isInstalled(t,e){const i=(await f())[l(t,e)];return!!i&&i.length>0},async uninstall(t,e){const i=l(t,e),n=(await f())[i];!n||n.length===0||await y(["plugin","remove",i,"--json"])},async removeMarketplace(t){const e=await d();if(!e)return;const i=c.resolve(t),n=O(e);let r;for(const o of n)if(!(!o.key||o.key.length!==2||o.key[0]!=="marketplaces")){for(const[s,w]of L(o.lines.slice(1))){if(s!=="source")continue;const k=w.split("=").slice(1).join("=").trim().replace(/^"(.*)"$/,"$1");if(c.resolve(k)===i){r=o.key[1];break}}if(r)break}r&&await y(["plugin","marketplace","remove",r])},async readProjectEnabled(t,e,i){return p(await d())[l(e,i)]??!1},async setProjectEnabled(t,e,i,n){const r=l(e,n),o=await d()??"";await v(c.dirname(u()),{recursive:!0}),await E(u(),S(o,r,i),"utf8")},async readGlobalEnabled(){return p(await d())},async writeGlobalEnabled(t,e){const i=await d()??"";await v(c.dirname(u()),{recursive:!0}),await E(u(),S(i,t,e),"utf8")},pluginScopes:()=>["user"],async readEnabledOverrides(t){return{user:await this.readGlobalEnabled(),project:{},local:{}}},async setEnabledOverride(t,e,i,n){if(e!=="user")throw new Error(`codex plugins only support user-scope overrides (got ${e})`);const r=await d()??"";if(n==="inherit"){const{text:o,removed:s}=G(r,["plugins",i]);if(!s)return;await v(c.dirname(u()),{recursive:!0}),await E(u(),o,"utf8");return}await v(c.dirname(u()),{recursive:!0}),await E(u(),S(r,i,n==="on"),"utf8")}}}export const CODEX_PLUGINS=createCodexPluginSurface();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as d}from"node:fs";import{homedir as c}from"node:os";import p from"node:path";import{codexHome as m}from"./home.js";function l(o){return p.join(process.env.LOCALAPPDATA||p.join(o,"AppData","Local"),"OpenAI","Codex")}function u(o){return p.join(m(o),"packages","app-server-daemon")}async function f(o){const{spawn:a}=await import("node:child_process");return new Promise(
|
|
1
|
+
import{existsSync as d}from"node:fs";import{homedir as c}from"node:os";import p from"node:path";import{codexHome as m}from"./home.js";function l(o){return p.join(process.env.LOCALAPPDATA||p.join(o,"AppData","Local"),"OpenAI","Codex")}function u(o){return p.join(m(o),"packages","app-server-daemon")}async function f(o){const{spawn:a}=await import("node:child_process");return new Promise(n=>{let r="";const s=process.platform==="win32"?a(`${o} app-server daemon version`,{windowsHide:!0,shell:!0,stdio:["ignore","pipe","pipe"]}):a(o,["app-server","daemon","version"],{windowsHide:!0,stdio:["ignore","pipe","pipe"]}),i=setTimeout(()=>{s.kill("SIGKILL"),n(null)},8e3);s.stdout?.on("data",e=>r+=e.toString()),s.on("error",()=>{clearTimeout(i),n(null)}),s.on("close",()=>{clearTimeout(i);try{const e=JSON.parse(r);typeof e.managedCodexVersion=="string"&&typeof e.cliVersion=="string"?n({managedCodexVersion:e.managedCodexVersion,cliVersion:e.cliVersion}):n(null)}catch{n(null)}})})}export async function codexProvisionCheck(o,a=()=>f(o),n=c()){const r=[],s=[],i=d(l(n)),e=d(u(n));if(i&&!e&&(r.push("codex desktop app detected without the shared app-server daemon package \u2014 the two faces share ~/.codex, and version skew makes the older side rewrite config.toml from its stale snapshot (wiping manual provider / hooks-trust edits)"),s.push("codex app-server daemon update --from-cli --yes")),e){const t=await a();t&&t.managedCodexVersion!==t.cliVersion&&(r.push(`codex shared daemon (${t.managedCodexVersion}) differs from CLI (${t.cliVersion}) \u2014 the older side rewrites ~/.codex/config.toml from its stale snapshot on startup, wiping manual edits`),s.push("codex app-server daemon update --from-cli --yes"))}return{desktopApp:i,daemonPackage:e,warnings:r,hints:s}}export const CODEX_PROVISION={harness:"codex",check:codexProvisionCheck};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const
|
|
2
|
-
`)[0]??"patch";return t.length>200?`${t.slice(0,200)}\u2026`:t}function u(
|
|
1
|
+
const m="y",p="n",d="d",f="1",c={key:"codex:opaque",header:null,question:"The session is waiting for input (options unavailable \u2014 answer in its terminal)",multiSelect:!1,options:[]};function r(n){const e=n&&typeof n=="object"?n:{},o=Array.isArray(e.command)?e.command.filter(i=>typeof i=="string").join(" "):typeof e.command=="string"?e.command:"",s=typeof e.description=="string"?e.description:null,t=o||s||"Codex wants to run a command";return t.length>200?`${t.slice(0,200)}\u2026`:t}function a(n){const e=n&&typeof n=="object"?n:{},o=typeof e.command=="string"?e.command:"";if(!o)return"Codex wants to apply a patch";const s=[...o.matchAll(/^\*\*\* (?:Add|Update|Delete) File: (.+)$/gm)].map(i=>i[1]),t=s.length>0?s.join(", "):o.split(`
|
|
2
|
+
`)[0]??"patch";return t.length>200?`${t.slice(0,200)}\u2026`:t}function u(n,e){const o=e&&typeof e=="object"&&Object.keys(e).length>0?JSON.stringify(e):"",s=`Codex wants to call ${n}`,t=o?`${s} ${o}`:s;return t.length>200?`${t.slice(0,200)}\u2026`:t}function l(n,e){return[{keys:["y"],label:n},{keys:["n"],label:e}]}export const CODEX_QUESTIONS={plan:null,blockingTools:[],permissionNotificationType:null,silentPermissionModes:["bypassPermissions"],permissionQuestion(){return{...c,key:"codex:permission"}},parseQuestions(){return[{...c}]},eventQuestion(n,e){if(n!=="PermissionRequest")return null;const o=e.raw&&typeof e.raw=="object"?e.raw:{},s=e.toolName,t=e.toolInput;return(typeof o.permission_mode=="string"?o.permission_mode:null)==="bypassPermissions"||s==null?null:s.startsWith("mcp__")?{key:"PermissionRequest:mcp",header:"MCP tool approval",question:u(s,t),multiSelect:!1,options:[{keys:["1"],label:"Yes, run the tool and continue"}]}:s==="apply_patch"?{key:"PermissionRequest:patch",header:"Apply patch",question:a(t),multiSelect:!1,options:l("Yes, proceed","No, and tell Codex what to do differently")}:s==="request_permissions"?{key:"PermissionRequest:permissions",header:"Permissions",question:r(t),multiSelect:!1,options:[{keys:["y"],label:"Yes, grant these permissions for this turn"},{keys:["d"],label:"No, continue without permissions"}]}:s==="write_stdin"?{key:"PermissionRequest:write_stdin",header:"Command approval",question:r(t),multiSelect:!1,options:l("Yes, proceed","No, cancel")}:{key:"PermissionRequest:exec",header:"Command approval",question:r(t),multiSelect:!1,options:l("Yes, proceed","No, and tell Codex what to do differently")}}};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{mkdir as
|
|
2
|
-
`);if(
|
|
3
|
-
`);if(
|
|
4
|
-
`);if(
|
|
5
|
-
`)){if(
|
|
1
|
+
import{mkdir as x,open as C,readdir as N,readFile as I,stat as L,utimes as T,writeFile as _}from"node:fs/promises";import l from"node:path";import{CodexTurnBuffer as B,metaOfLine as H}from"./event-source.js";import{readUserCapture as U}from"./capture.js";import{codexHome as O}from"./home.js";const A=512*1024,X=256*1024,W=2*6e4,J=1024*1024,K=10080*6e4,Y=400,P=4*1024*1024,E=128*1024,R="cursors.json",$=".lock",G=6e4;function q(){const n=O();return[l.join(n,"sessions"),l.join(n,"archived_sessions")]}function j(n){const t=l.resolve(n);return process.platform==="win32"?t.toLowerCase():t}function k(n){try{const t=JSON.parse(n);return!t||typeof t!="object"||Array.isArray(t)?null:t}catch{return null}}async function Q(){const n=[],t=async(e,r)=>{if(r>4)return;let i;try{i=await N(e,{withFileTypes:!0})}catch{return}for(const a of i){const f=l.join(e,a.name);if(a.isDirectory()){await t(f,r+1);continue}if(!a.isFile()||!a.name.startsWith("rollout-")||!a.name.endsWith(".jsonl"))continue;const h=await L(f).catch(()=>null);h&&n.push({path:f,size:h.size,mtimeMs:h.mtimeMs})}};for(const e of q())await t(e,0);return n}async function V(n){const t=await C(n,"r").catch(()=>null);if(!t)return null;try{const e=Buffer.alloc(E),{bytesRead:r}=await t.read(e,0,E,0),i=e.subarray(0,r).toString("utf8"),a=i.indexOf(`
|
|
2
|
+
`);if(a<0)return r<E?"pending":null;const f=k(i.slice(0,a));return f?H(f):null}finally{await t.close()}}async function Z(n,t,e){const r=await C(n,"r").catch(()=>null);if(!r)return null;try{const i=Buffer.alloc(e),{bytesRead:a}=await r.read(i,0,e,t);return{text:i.subarray(0,a).toString("utf8"),bytes:a}}finally{await r.close()}}async function z(n){try{const t=await I(l.join(n,R),"utf8"),e=JSON.parse(t);if(e&&typeof e=="object"&&e.files&&typeof e.files=="object")return e}catch{}return{at:null,files:{}}}async function tt(n,t){t.at=new Date().toISOString(),await x(n,{recursive:!0}),await _(l.join(n,R),JSON.stringify(t))}function et(n){const t=Number(n);if(!Number.isInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function st(n){await x(n,{recursive:!0});const t=l.join(n,$),e=`${process.pid}`;try{return await _(t,e,{flag:"wx"}),!0}catch{}const r=(await I(t,"utf8").catch(()=>"")).trim();if(r===e){const i=await L(t).catch(()=>null);if(!i||Date.now()-i.mtimeMs>G){const a=new Date;await T(t,a,a).catch(()=>{})}return!0}return r&&et(r)?!1:_(t,e).then(()=>!0,()=>!1)}const nt=1e4;export class CodexLogSource{harness="codex";buffers=new Map;lastError=null;capture=null;async captureInstalled(){const t=Date.now(),e=O();if(this.capture&&this.capture.root===e&&t-this.capture.at<nt)return this.capture.on;const r=(await U()).installed;return this.capture={root:e,at:t,on:r},r}async poll(t){const e=await this.captureInstalled();if(!await st(t.stateDir))return[];const r=(await Q()).sort((s,o)=>s.mtimeMs-o.mtimeMs),i=await z(t.stateDir);if(r.length===0&&Object.keys(i.files).length===0)return[];const a=new Map(t.cwdWhitelist.map(s=>[j(s),s])),f=t.maxRecords??Y;let h=t.maxBytes??P;const d=[];let u=!1;for(const s of r){if(d.length>=f||h<=0)break;let o=i.files[s.path],S=!1;if(!o){const c=await V(s.path);if(c==="pending")continue;if(!c){i.files[s.path]={offset:s.size,sessionId:null,cwd:null},u=!0;continue}o={offset:0,sessionId:c.sessionId,cwd:c.cwd},i.files[s.path]=o,u=!0,Date.now()-s.mtimeMs>K?o.offset=s.size:Date.now()-s.mtimeMs<W&&s.size<J?o.offset=0:(o.offset=Math.max(0,s.size-X),S=!0)}const M=o.cwd?a.get(j(o.cwd)):void 0;if(!M){o.offset!==s.size&&(o.offset=s.size,u=!0);continue}if(s.size<o.offset&&(o.offset=0,S=!1,this.buffers.delete(s.path),u=!0),s.size===o.offset)continue;const p=await Z(s.path,o.offset,Math.min(s.size-o.offset,h));if(!p){this.lastError=`read failed: ${s.path}`;continue}h-=p.bytes;let w=p.text,m=o.offset;if(S){const c=w.indexOf(`
|
|
3
|
+
`);if(c<0){o.offset=m+p.bytes,u=!0;continue}m+=Buffer.byteLength(w.slice(0,c+1),"utf8"),w=w.slice(c+1)}const g=w.lastIndexOf(`
|
|
4
|
+
`);if(g<0){w.length>A&&(o.offset=m+p.bytes,this.lastError=`oversized line skipped: ${l.basename(s.path)}`,u=!0);continue}let D=m;const F=this.bufferOf(s.path);for(const c of w.slice(0,g).split(`
|
|
5
|
+
`)){if(d.length>=f)break;if(D+=Buffer.byteLength(c,"utf8")+1,!c||c.length>A)continue;const y=k(c);if(!y||e&&y.type!=="session_meta")continue;const b=F.report(y);b&&(b.sessionId=o.sessionId??void 0,b.cwd=M,d.push({report:b,at:rt(y,s.mtimeMs)}))}o.offset=D,u=!0}const v=new Set(r.map(s=>s.path));for(const s of Object.keys(i.files))v.has(s)||(delete i.files[s],this.buffers.delete(s),u=!0);return u&&await tt(t.stateDir,i).catch(()=>{}),d}async health(t){const e=await z(t.stateDir),r=O();let i=0;for(const a of Object.values(e.files))a.cwd&&i++;return{root:r,files:i,lastPollAt:e.at,lastError:this.lastError}}bufferOf(t){let e=this.buffers.get(t);return e||(e=new B,this.buffers.set(t,e)),e}}function rt(n,t){if(typeof n.timestamp=="string"&&n.timestamp){const e=Date.parse(n.timestamp);if(!Number.isNaN(e))return new Date(e).toISOString()}return new Date(t).toISOString()}export const CODEX_LOG_SOURCE=new CodexLogSource;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
`);let
|
|
3
|
-
`):null}function
|
|
4
|
-
`).some(
|
|
1
|
+
const I=2e3,a=/^[^\x00-\x1f\x7f]+$/,_="Side from main thread",f=/•\s+Working\s*\(/,E=/^\s*Worked for\s+/,O=/^\s*└\s+Tip:/,P="\u203A ";function R(e,t,s){const l="\u203A "+e,c=s.split(`
|
|
2
|
+
`);let u=-1;for(let n=c.length-1;n>=0;n--){const i=c[n].trim();if(i===l&&!k(t,l)){u=n;break}if(i===l){u=n;break}}if(u<0)return null;const o=[];for(let n=u+1;n<c.length;n++){const i=c[n],r=i.trim();if(r){if(E.test(r))break;if(f.test(r))return null;if(!O.test(i)){if(r.startsWith("\u203A ".trim()))break;if(r.startsWith("\u2022")){o.push(r.replace(/^•\s*/,""));continue}o.length>0&&o.push(r)}}}return o.length>0?o.join(`
|
|
3
|
+
`):null}function k(e,t){return e.split(`
|
|
4
|
+
`).some(s=>s.trim()===t)}export const CODEX_SIDE_QUESTION={command(e){return e},validate(e){const t=e.trim();return t?t.length>2e3?{ok:!1,error:"\u95EE\u9898\u8FC7\u957F\uFF08\u4E0A\u9650 2000 \u5B57\u7B26\uFF09"}:a.test(t)?{ok:!0,text:t}:{ok:!1,error:"\u95EE\u9898\u4E0D\u80FD\u542B\u6362\u884C\u6216\u63A7\u5236\u5B57\u7B26\uFF08\u4F1A\u63D0\u524D\u63D0\u4EA4\uFF09"}:{ok:!1,error:"\u95EE\u9898\u4E0D\u80FD\u4E3A\u7A7A"}},answerOf(){return null},prerequisite:"\u4E3B\u7EBF\u7A0B\u81F3\u5C11\u53D1\u8FC7\u4E00\u6761\u6D88\u606F\u540E\u624D\u80FD\u5F00\u4FA7\u8FB9\u4F1A\u8BDD\uFF08\u5BBF\u4E3B\u9650\u5236\uFF09",screen:{openKeys:"/side",submitKey:"\r",closeKey:"",panelOpen(e){return e.includes(_)},extractAnswer(e,t,s){return f.test(s)?{answer:null,done:!1}:{answer:R(e,t,s),done:!0}}}};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{spawn as
|
|
2
|
-
`)){const
|
|
3
|
-
`)};e.on("error",()=>t(new Error("failed to spawn codex app-server"))),e.on("exit",()=>t(new Error("codex app-server exited before thread/name/set"))),e.stdin?.on("error",()=>t(new Error("codex app-server stdin closed"))),
|
|
4
|
-
`))>=0;){const
|
|
1
|
+
import{spawn as h}from"node:child_process";import{readFileSync as S,statSync as g}from"node:fs";import v from"node:path";import{codexHome as y}from"./home.js";import{codexCommandLine as T}from"./plugins.js";const E=1e4,u=new Map;export function codexSessionTitleOf(c,s){const n=v.join(y(s),"session_index.jsonl");let r;try{r=g(n)}catch{return null}const d=u.get(n);if(!d||d.mtimeMs!==r.mtimeMs||d.size!==r.size){const e=new Map;try{for(const l of S(n,"utf8").split(`
|
|
2
|
+
`)){const o=l.trim();if(o)try{const t=JSON.parse(o);typeof t.id=="string"&&typeof t.thread_name=="string"&&e.set(t.id,t.thread_name)}catch{}}}catch{return null}u.set(n,{mtimeMs:r.mtimeMs,size:r.size,names:e})}const i=u.get(n).names.get(c)??null;return i!=null&&i.trim()?i:null}export function codexSetSessionTitle(c,s){return new Promise((n,r)=>{const d=s.trim();if(!d){r(new Error("thread name must not be empty"));return}const i=process.platform==="win32",e=h(i?process.env.ComSpec||"cmd.exe":"codex",i?["/d","/s","/c",T(["app-server"])]:["app-server"],{windowsHide:!0,windowsVerbatimArguments:i,stdio:["pipe","pipe","pipe"]});let l=!1,o="";const t=a=>{l||(l=!0,clearTimeout(w),i&&e.pid!==void 0?h("taskkill",["/pid",String(e.pid),"/t","/f"],{windowsHide:!0,stdio:"ignore"}).unref():e.kill("SIGKILL"),a?r(a):n())},w=setTimeout(()=>t(new Error("codex app-server thread/name/set timed out")),E),p=a=>{e.stdin?.write(`${JSON.stringify(a)}
|
|
3
|
+
`)};e.on("error",()=>t(new Error("failed to spawn codex app-server"))),e.on("exit",()=>t(new Error("codex app-server exited before thread/name/set"))),e.stdin?.on("error",()=>t(new Error("codex app-server stdin closed"))),p({jsonrpc:"2.0",id:1,method:"initialize",params:{clientInfo:{name:"weave",title:"weave",version:"1.0.0"}}}),e.stdout?.setEncoding("utf8"),e.stdout?.on("data",a=>{o+=a;let f;for(;(f=o.indexOf(`
|
|
4
|
+
`))>=0;){const x=o.slice(0,f);o=o.slice(f+1);let m=null;try{m=JSON.parse(x)}catch{continue}if(m?.id===1){p({jsonrpc:"2.0",method:"initialized",params:{}}),p({jsonrpc:"2.0",id:2,method:"thread/name/set",params:{threadId:c,name:d}});continue}m?.id===2&&t(m.error?new Error(String(m.error.message??"thread/name/set failed")):null)}})})}export function createCodexTitleSurface(c={}){return{harness:"codex",sessionTitleOf:s=>Promise.resolve(codexSessionTitleOf(s,c.home)),setSessionTitle:(s,n)=>codexSetSessionTitle(s,n)}}export const CODEX_TITLES=createCodexTitleSurface();
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import{parse as W}from"smol-toml";export class CodexTomlCorruptError extends Error{constructor(
|
|
2
|
-
`,f:"\f",r:"\r",'"':'"',"\\":"\\"};export function parseDottedKey(
|
|
3
|
-
`?
|
|
4
|
-
`),e=[];let r={key:null,lines:[]};for(const
|
|
5
|
-
`}function
|
|
1
|
+
import{parse as W}from"smol-toml";export class CodexTomlCorruptError extends Error{constructor(t){super(t),this.name="CodexTomlCorruptError"}}function A(n){return/[A-Za-z0-9_-]/.test(n)}function y(n){return n===" "||n===" "}const $={b:"\b",t:" ",n:`
|
|
2
|
+
`,f:"\f",r:"\r",'"':'"',"\\":"\\"};export function parseDottedKey(n){const t=[];let e=0;for(;;){for(;e<n.length&&y(n[e]);)e++;if(e>=n.length)return null;const r=n[e];if(r==='"'||r==="'"){e++;let o="";for(;e<n.length;){const i=n[e];if(r==='"'&&i==="\\"){const s=n[e+1];if(s===void 0||!(s in $))return null;o+=$[s],e+=2;continue}if(i===r)break;o+=i,e++}if(e>=n.length)return null;e++,t.push(o)}else{const o=e;for(;e<n.length&&A(n[e]);)e++;if(e===o)return null;t.push(n.slice(o,e))}for(;e<n.length&&y(n[e]);)e++;if(e>=n.length)return t;if(n[e]!==".")return null;e++}}export function sectionHeaderKey(n){const t=n.trim();if(!t.startsWith("["))return null;const e=t.startsWith("[[");let r=e?2:1,o="",i=!1;for(;r<t.length;){const l=t[r];if(l==='"'||l==="'"){const c=l;for(o+=c,r++;r<t.length;){if(c==='"'&&t[r]==="\\"){if(r+1>=t.length)return null;o+=t[r]+t[r+1],r+=2;continue}if(t[r]===c)break;o+=t[r],r++}if(r>=t.length)return null;o+=c,r++;continue}if(l==="]"){if(e){if(t[r+1]!=="]")return null;r+=2}else r++;i=!0;break}o+=l,r++}if(!i)return null;const s=t.slice(r).trim();return s!==""&&!s.startsWith("#")?null:parseDottedKey(o)}export function renderTomlKey(n){return/^[A-Za-z0-9_-]+$/.test(n)?n:`"${x(n)}"`}export function renderTomlHeader(n){return`[${n.map(renderTomlKey).join(".")}]`}function x(n){let t="";for(const e of n)e==="\\"?t+="\\\\":e==='"'?t+='\\"':e===`
|
|
3
|
+
`?t+="\\n":e==="\r"?t+="\\r":e===" "?t+="\\t":e<" "||e==="\x7F"?t+=`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`:t+=e;return t}export function renderTomlString(n){const t=n.includes("\\"),e=!n.includes("'")&&!/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f\n]/.test(n);return t&&e?`'${n}'`:`"${x(n)}"`}export function splitTomlSections(n){const t=n.split(`
|
|
4
|
+
`),e=[];let r={key:null,lines:[]};for(const o of t){const i=sectionHeaderKey(o);i!==null?(e.push(r),r={key:i,lines:[o]}):r.lines.push(o)}return e.push(r),e}export function sameKey(n,t){return n!==null&&n.length===t.length&&n.every((e,r)=>e===t[r])}function m(n,t){return n!==null&&n.length>t.length&&t.every((e,r)=>n[r]===e)}function C(n){let t=0;for(let e=n.length-1;e>=0&&n[e].trim()==="";e--)t++;return t}function h(n){const t=n.replace(/(?:\r?\n)+[ \t]*$/,"");return t===""?"":`${t}
|
|
5
|
+
`}function w(n,t){const e=n.replace(/(?:\r?\n)+[ \t]*$/,"");return e.trim()===""?`${t.join(`
|
|
6
6
|
`)}
|
|
7
7
|
`:`${e}
|
|
8
8
|
|
|
9
|
-
${
|
|
9
|
+
${t.join(`
|
|
10
10
|
`)}
|
|
11
|
-
`}export function upsertTomlSection(t,
|
|
12
|
-
`))}export function removeTomlSection(t
|
|
13
|
-
`)),removed:!0}}export function parseSectionEntries(
|
|
14
|
-
`))}let
|
|
15
|
-
`))}export function removeTomlValueInText(t
|
|
16
|
-
`)),removed:!0}}}return{text:
|
|
17
|
-
`));continue}}e=upsertTomlSection(e,[...
|
|
11
|
+
`}export function upsertTomlSection(n,t,e){const r=splitTomlSections(n);let o=-1,i=-1;const s=new Set;for(let u=0;u<r.length;u++){const d=r[u].key;sameKey(d,t)?(o<0&&(o=u),s.add(u),i=u):m(d,t)&&(s.add(u),i=u)}if(o<0)return w(n,[renderTomlHeader(t),...e]);const l=r[i].lines,c=l.slice(l.length-C(l)),f=[renderTomlHeader(t),...e,...c],a=[];for(let u=0;u<r.length;u++)u===o&&a.push(...f),!s.has(u)&&a.push(...r[u].lines);return h(a.join(`
|
|
12
|
+
`))}export function removeTomlSection(n,t){const e=splitTomlSections(n),r=new Set;for(let i=0;i<e.length;i++){const s=e[i].key;(sameKey(s,t)||m(s,t))&&r.add(i)}if(r.size===0)return{text:n,removed:!1};const o=[];for(let i=0;i<e.length;i++)r.has(i)||o.push(...e[i].lines);return{text:h(o.join(`
|
|
13
|
+
`)),removed:!0}}export function parseSectionEntries(n){const t=[];for(const e of n){const r=e.trim();if(r===""||r.startsWith("#")||r.startsWith("["))continue;const o=/^("[^"]*"|'[^']*'|[A-Za-z0-9_-]+)\s*=/.exec(r);if(!o)continue;const i=parseDottedKey(o[1]);i===null||i.length!==1||t.push([i[0],e])}return t}export function upsertCodexPluginEnabledInText(n,t,e){const r=["plugins",t],i=splitTomlSections(n).find(l=>sameKey(l.key,r)),s=[`enabled = ${e?"true":"false"}`];if(i)for(const[l,c]of parseSectionEntries(i.lines.slice(1)))l!=="enabled"&&s.push(c);return upsertTomlSection(n,r,s)}export function renderTomlValue(n){return n==null?'""':typeof n=="boolean"?n?"true":"false":typeof n=="number"?Number.isFinite(n)?String(n):'""':typeof n=="string"?renderTomlString(n):Array.isArray(n)?`[${n.map(renderTomlValue).join(", ")}]`:`{ ${Object.entries(n).filter(([,e])=>e!==void 0).map(([e,r])=>`${renderTomlKey(e)} = ${renderTomlValue(r)}`).join(", ")} }`}export function setTomlValueInText(n,t,e){if(t.length===0)return n;const r=`${renderTomlKey(t[t.length-1])} = ${renderTomlValue(e)}`,o=t.slice(0,-1);if(o.length===0){const d=splitTomlSections(n),p=d[0],k=t[0],g=b(p.lines,k,r);if(g===p.lines)return n;const S=d.flatMap((T,j)=>j===0?g:T.lines);return h(S.join(`
|
|
14
|
+
`))}let i=I(n,o);const s=splitTomlSections(i),l=s.findIndex(d=>sameKey(d.key,o));if(l<0)return i;const c=s[l],f=t[t.length-1],a=b(c.lines,f,r);if(a===c.lines)return i;const u=s.flatMap((d,p)=>p===l?a:d.lines);return h(u.join(`
|
|
15
|
+
`))}export function removeTomlValueInText(n,t){if(t.length===0)return{text:n,removed:!1};const e=splitTomlSections(n),r=t.slice(0,-1),o=t[t.length-1];for(let i=0;i<e.length;i++){const s=e[i];if(!(r.length===0?s.key===null:sameKey(s.key,r)))continue;const c=E(s.lines,o);if(c!==s.lines){const f=e.flatMap((a,u)=>u===i?c:a.lines);return{text:h(f.join(`
|
|
16
|
+
`)),removed:!0}}}return{text:n,removed:!1}}function b(n,t,e){const r=[];let o=!1;for(let s=0;s<n.length;s++){const l=n[s],c=l.trim();if(!o&&(c.startsWith(`${t} =`)||c.startsWith(`${t}=`))){r.push(e),o=!0;continue}r.push(l)}if(o)return r;let i=-1;for(let s=n.length-1;s>=0;s--){const l=n[s].trim();if(l!==""&&!l.startsWith("#")){i=s;break}}return r.splice(i+1,0,e),r}function E(n,t){const e=[];let r=!1;for(const o of n){const i=o.trim();if(!r&&(i.startsWith(`${t} =`)||i.startsWith(`${t}=`))){r=!0;continue}e.push(o)}return r?e:n}function I(n,t){let e=n;for(let r=1;r<=t.length;r++){const o=t.slice(0,r),i=splitTomlSections(e);if(i.some(f=>sameKey(f.key,o)||f.key!==null&&m(f.key,o)))continue;const s=o.slice(0,-1),l=s.length===0?i[0]:i.find(f=>sameKey(f.key,s)),c=o[r-1];if(l){const f=K(l.lines,c);if(f){const a=i.indexOf(l);e=h([...i.flatMap((u,d)=>d===a?f.lines:u.lines),...f.sectionLines].join(`
|
|
17
|
+
`));continue}}e=upsertTomlSection(e,[...o],[])}return e}function K(n,t){const e=n.findIndex(f=>{const a=f.trim();return a.startsWith(`${t} =`)&&a.includes("{")});if(e<0)return null;const r=n[e].trim(),o=r.slice(r.indexOf("=")+1).trim();let i;try{i=W(`v = ${o}`)}catch{return null}const s=i.v;if(!s||typeof s!="object"||Array.isArray(s))return null;const l=Object.entries(s).map(([f,a])=>`${renderTomlKey(f)} = ${renderTomlValue(a)}`),c=[...n];return c.splice(e,1),{lines:c,sectionLines:[`[${t}]`,...l]}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export function codexInterruptMarkerAt(o){let t=null;for(const
|
|
2
|
-
`)){if(!
|
|
1
|
+
export function codexInterruptMarkerAt(o){let t=null;for(const e of o.split(`
|
|
2
|
+
`)){if(!e.includes('"turn_aborted"'))continue;let r;try{r=JSON.parse(e)}catch{continue}const i=r;if(i?.payload?.type!=="turn_aborted")continue;const n=Date.parse(String(i.timestamp??""));Number.isFinite(n)&&(t===null||n>t)&&(t=n)}return t}
|
|
@@ -7,7 +7,7 @@ import type { FileAssetCategory } from './shared/file-specs.js';
|
|
|
7
7
|
* 依赖硬约束:本包仅依赖 @weavecode/core(永不依赖 server/cli,防 statusline/i18n 成环)。
|
|
8
8
|
*/
|
|
9
9
|
/** 可插拔能力槽——driver 声明持有哪些,注册表按能力检索。 */
|
|
10
|
-
export type HarnessCapability = 'init' | 'events' | 'assets' | 'resume' | 'detect' | 'plugins' | 'pluginState' | 'messaging' | 'questions' | 'capture' | 'statusline' | 'logs' | 'config' | 'edits' | 'images' | 'narration' | 'commands' | 'provision' | 'liveness';
|
|
10
|
+
export type HarnessCapability = 'init' | 'events' | 'assets' | 'resume' | 'detect' | 'plugins' | 'pluginState' | 'messaging' | 'questions' | 'capture' | 'statusline' | 'logs' | 'config' | 'edits' | 'images' | 'narration' | 'commands' | 'provision' | 'liveness' | 'rewind';
|
|
11
11
|
/**
|
|
12
12
|
* 采集集成的 user 档状态(tool-object-model §2.6 基石)。
|
|
13
13
|
*/
|
|
@@ -999,7 +999,30 @@ export interface HarnessCommand {
|
|
|
999
999
|
source: 'builtin' | 'command' | 'skill' | 'plugin';
|
|
1000
1000
|
/** 触发符:缺省 `/`;codex 的 skill 是 `$name`。前端按它展示与插胶囊。 */
|
|
1001
1001
|
sigil?: '/' | '$';
|
|
1002
|
+
/**
|
|
1003
|
+
* 宿主能不能在**句子中间**(前后空白)认出这条命令:claude 的 skill / 插件 /
|
|
1004
|
+
* 自定义命令走 mention 扫描可以,内建只在整条输入开头分派;codex 只有
|
|
1005
|
+
* `$skill` 是 mention(且无前置边界),`/` 命令一律只在开头。缺省 = 只在
|
|
1006
|
+
* 开头可用——前端据此决定句中敲触发符时菜单还弹不弹、气泡还认不认。
|
|
1007
|
+
*/
|
|
1008
|
+
inline?: boolean;
|
|
1002
1009
|
}
|
|
1010
|
+
/**
|
|
1011
|
+
* 输入框里的一种「命令形态」:宿主自己执行、**不当作一条 prompt 提交**的敲法。
|
|
1012
|
+
* 触发符归 harness(claude = `/` 斜杠命令与 `!` bash 模式,codex = `/` 命令),
|
|
1013
|
+
* 投递闸据此走命令的短回执窗口(这类输入多半不发 prompt 提交事件),前端据此
|
|
1014
|
+
* 给输入框上色(颜色是渲染层的事,这里只答形态)。
|
|
1015
|
+
*/
|
|
1016
|
+
export interface CommandInputMode {
|
|
1017
|
+
/** 形态。`bash` = 宿主本地 shell 模式(claude 输入框在此时变品红)。 */
|
|
1018
|
+
readonly kind: 'slash' | 'bash';
|
|
1019
|
+
/** 触发符:trim 后以此开头即该形态。 */
|
|
1020
|
+
readonly sigil: string;
|
|
1021
|
+
/** 触发符后必须紧跟命令名(`/name`)才算;bash 模式是整行命令行,不要求。 */
|
|
1022
|
+
readonly named: boolean;
|
|
1023
|
+
}
|
|
1024
|
+
/** 这段输入命中哪种命令形态(触发符表归 harness);null = 普通 prompt。 */
|
|
1025
|
+
export declare function commandModeAt(text: string, modes: readonly CommandInputMode[]): CommandInputMode | null;
|
|
1003
1026
|
/** 转录里的一条命令执行记录(内建命令不发 hook 事件,只有转录记着)。 */
|
|
1004
1027
|
export interface CommandExecution {
|
|
1005
1028
|
name: string;
|
|
@@ -1015,6 +1038,8 @@ export interface CommandExecution {
|
|
|
1015
1038
|
*/
|
|
1016
1039
|
export interface CommandsSurface {
|
|
1017
1040
|
readonly harness: Harness;
|
|
1041
|
+
/** 输入框的命令形态表(触发符 + 形态);空表 = 该 harness 没有命令形态。 */
|
|
1042
|
+
readonly inputModes: readonly CommandInputMode[];
|
|
1018
1043
|
/** 该会话此刻可用的命令(项目级命令按项目路径现扫;`homedir` 缺省 = 本机家目录)。 */
|
|
1019
1044
|
list(req: {
|
|
1020
1045
|
projectPath: string;
|
|
@@ -1056,6 +1081,35 @@ export interface LivenessSurface {
|
|
|
1056
1081
|
*/
|
|
1057
1082
|
alive(ids?: readonly string[]): Promise<Map<string, boolean>>;
|
|
1058
1083
|
}
|
|
1084
|
+
/** 一次对话回退(宿主 rewind):何时发生的、退回到了哪里之前。 */
|
|
1085
|
+
export interface RewindMark {
|
|
1086
|
+
/**
|
|
1087
|
+
* 回退发生的时刻(ISO)。claude 的锚点行自身不带 timestamp,取锚点行之前
|
|
1088
|
+
* 最近一条带 timestamp 转录行的时刻——rewind 只能发生在最后活动之后。
|
|
1089
|
+
*/
|
|
1090
|
+
at: string;
|
|
1091
|
+
/**
|
|
1092
|
+
* 回退边界(退回到哪条消息之前)的时刻;宿主锚点只给 uuid 不给时刻,
|
|
1093
|
+
* server 按事件时刻近似——这里恒 null(不猜)。
|
|
1094
|
+
*/
|
|
1095
|
+
boundaryAt: string | null;
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* 对话回退面:宿主的 rewind(claude = Esc Esc / `/rewind`,退回代码与/或对话)
|
|
1099
|
+
* 在转录里留下的痕迹归 harness 解析,server 只把「哪些气泡被回退了」交给前端
|
|
1100
|
+
* 置灰展示。缺这个槽 = 该 harness 的回退不可观测(前端不摆「已回退」标记)。
|
|
1101
|
+
*/
|
|
1102
|
+
export interface RewindSurface {
|
|
1103
|
+
/**
|
|
1104
|
+
* 该会话的全部回退(时间序);读不到(无转录 / 路径未知 / 半路出错)→
|
|
1105
|
+
* null(不猜)。没有回退 = 空数组。
|
|
1106
|
+
*/
|
|
1107
|
+
sessionRewinds(req: {
|
|
1108
|
+
sessionId: string;
|
|
1109
|
+
/** 转录路径(server 的探针答,宿主不自己拼目录);null = 不知道在哪。 */
|
|
1110
|
+
transcriptPath: string | null;
|
|
1111
|
+
}): Promise<RewindMark[] | null>;
|
|
1112
|
+
}
|
|
1059
1113
|
/**
|
|
1060
1114
|
* 会话标题读写面:宿主侧**用户自定义名**(codex = thread name,落 session_index
|
|
1061
1115
|
* 与 sqlite threads.name)的读/写通道。读 = 宿主持久层 diff 采纳(TUI 改名反显
|
|
@@ -1093,6 +1147,7 @@ export interface HarnessDriver {
|
|
|
1093
1147
|
commands?: CommandsSurface;
|
|
1094
1148
|
provision?: ProvisionSurface;
|
|
1095
1149
|
liveness?: LivenessSurface;
|
|
1150
|
+
rewind?: RewindSurface;
|
|
1096
1151
|
/** 不入 capabilities 清单——无 web 面,消费点仅 server 两处(dispatcher diff 采纳 / PATCH rename RPC)。 */
|
|
1097
1152
|
titles?: SessionTitleSurface;
|
|
1098
1153
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export class HarnessRegistry{drivers=new Map;register(
|
|
1
|
+
export function commandModeAt(i,e){const t=i.trim();for(const r of e)if(t.startsWith(r.sigil)&&!(r.named&&!/^[A-Za-z][A-Za-z0-9:_-]*(\s|$)/.test(t.slice(r.sigil.length))))return r;return null}export class HarnessRegistry{drivers=new Map;register(e){if(this.drivers.has(e.id))throw new Error(`harness driver already registered: ${e.id}`);this.drivers.set(e.id,e);let t=!1;return()=>{t||(t=!0,this.drivers.get(e.id)===e&&this.drivers.delete(e.id))}}get(e){return this.drivers.get(e)}all(){return[...this.drivers.values()]}byCapability(e){return this.all().filter(t=>t.capabilities.includes(e))}initFor(e){return this.drivers.get(e)?.init}unregister(e){return this.drivers.delete(e)}}export function supports(i,e){return i.capabilities.includes(e)}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
`}function
|
|
1
|
+
import i from"node:path";import{generateHookHandler as p,readUserCapture as u}from"../claude/capture.js";import{generateAutoMemoryHook as m}from"../claude/helpers-gen.js";import{generateMcpJson as c,mergeMcpJson as f}from"../claude/mcp-gen.js";import{generateSettingsJson as h,mergeSettingsJson as g}from"../claude/settings-gen.js";export const WEAVE_CONTENT_MARKER="@version weave@";const d={preToolUse:!1,postToolUse:!1,userPromptSubmit:!1,sessionStart:!1,stop:!1,stopFailure:!1,subagentStop:!1,subagentStart:!1,notification:!1,postToolUseFailure:!1,permissionRequest:!1,permissionDenied:!1,preCompact:!1,sessionEnd:!1,preModelSwitch:!1,timeout:5e3,continueOnError:!0};function a(e){try{const o=JSON.parse(e);return typeof o=="object"&&o!==null&&!Array.isArray(o)?o:null}catch{return null}}function t(e){return JSON.stringify(e,null,2)+`
|
|
2
|
+
`}function l(e){return(o,s)=>{const n=a(o),r=a(s);return n===null||r===null?null:t(e(n,r))}}async function S(e){const o=i.join(e.projectPath,".claude","helpers"),n=(await u({home:e.platform.homeDir})).installed?d:e.hooks,r=[];return e.components.helpers&&r.push({relPath:".claude/helpers/hook-handler.cjs",weaveMarker:WEAVE_CONTENT_MARKER,content:p(e.version)},{relPath:".claude/helpers/auto-memory-hook.mjs",weaveMarker:WEAVE_CONTENT_MARKER,content:m(e.version)}),e.components.settings&&r.push({relPath:".claude/settings.json",content:t(h({components:e.components,hooks:n,platform:e.platform,helpersDir:o})),merge:l(g)}),e.components.mcp&&e.mcp.weave&&r.push({relPath:".mcp.json",content:t(c({platform:e.platform,includeWeaveServer:!0})),merge:l(f)}),r}const E={claude:S,codex:async()=>[]};export function generateInitFiles(e,o){return E[e](o)}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readdir as
|
|
1
|
+
import{readdir as d,readFile as p,unlink as g,writeFile as S}from"node:fs/promises";import r from"node:path";import{ensureDir as h,fileExists as b,writeFileIfAbsent as A}from"@weavecode/core";export class InitPipeline{ctx;skipped=[];skipReasons=new Map;constructor(t){this.ctx=t}async runSurface(){await this.ensureDirs(),await this.writeSettings(),await this.writeMcp(),await this.copySkills(),await this.copyCommands(),await this.copyAgents(),await this.injectPluginTemplates(),await this.writeHelpers()}injectPluginTemplates(){}skip(t,e){this.skipped.push(t),this.skipReasons.set(t,e)}async writeOrMergeJson(t,e,s){if(!s&&await b(t)){const n=await x(t);return n===void 0?!1:(await k(t,m(n,e)),!0)}return await k(t,e),!0}async copyDirIfAbsent(t,e,s=!1){let n;try{n=await d(t,{withFileTypes:!0})}catch{return}await h(e);for(const a of n){const o=r.join(t,a.name),c=r.join(e,a.name);if(a.isDirectory())await this.copyDirIfAbsent(o,c,s);else{const w=await p(o,"utf-8");await A(c,w,s)}}}async sweepMarked(t,e,s){const n=new Set(e),a=[],o=async c=>{let w;try{w=await d(c,{withFileTypes:!0})}catch{return}for(const l of w){const u=r.join(c,l.name);if(l.isDirectory()){await o(u);continue}const j=r.relative(t,u).split(r.sep).join("/");if(n.has(j))continue;const y=await p(u,"utf-8").catch(()=>null);y!==null&&y.includes(s)&&(await g(u),a.push(u))}};return await o(t),a}}function m(i,t){const e={...i};for(const[s,n]of Object.entries(t)){const a=e[s];e[s]=f(a)&&f(n)?m(a,n):n}return e}function f(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}async function x(i){try{const t=await p(i,"utf-8"),e=JSON.parse(t);return f(e)?e:void 0}catch{return}}async function k(i,t){await h(r.dirname(i)),await S(i,JSON.stringify(t,null,2)+`
|
|
2
2
|
`,"utf-8")}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CLAUDE_DRIVER as t}from"./claude/index.js";import{CODEX_DRIVER as o}from"./codex/index.js";import{HarnessRegistry as
|
|
1
|
+
import{CLAUDE_DRIVER as t}from"./claude/index.js";import{CODEX_DRIVER as o}from"./codex/index.js";import{HarnessRegistry as i}from"./driver.js";export const HARNESS_DRIVERS={claude:t,codex:o};export function registerRuntimeDrivers(r){for(const e of Object.values(HARNESS_DRIVERS))r.register(e)}export function createRuntimeRegistry(){const r=new i;return registerRuntimeDrivers(r),r}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cp as
|
|
1
|
+
import{cp as a,lstat as c,mkdir as s,rm as u,symlink as l,unlink as m}from"node:fs/promises";import o from"node:path";export async function linkOrCopy(r,t){const i=o.resolve(r);await s(o.dirname(t),{recursive:!0});try{return await l(i,t,process.platform==="win32"?"junction":"dir"),"link"}catch(e){const n=e.code;if(n!=="EPERM"&&n!=="EEXIST"&&n!=="ENOTSUP")throw e}return await a(i,t,{recursive:!0}),"copy"}export async function removeInstalled(r){let t;try{t=await c(r)}catch{return"absent"}return t.isSymbolicLink()?(await m(r),"link"):(await u(r,{recursive:!0,force:!0}),"removed")}export async function installForm(r){try{return(await c(r)).isSymbolicLink()?"link":"copy"}catch{return"absent"}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const MAX_FIELD_CHARS=4e3,MAX_ARRAY_ITEMS=200;export function capFields(
|
|
1
|
+
export const MAX_FIELD_CHARS=4e3,MAX_ARRAY_ITEMS=200;export function capFields(t){if(typeof t=="string")return t.length>4e3?`${t.slice(0,4e3)}\u2026`:t;if(Array.isArray(t))return t.slice(0,200).map(capFields);if(t&&typeof t=="object"){const r={};for(const[o,A]of Object.entries(t))r[o]=capFields(A);return r}return t}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weavecode/harness",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Pluggable harness drivers — registry, init pipeline template method, and harness integration modules",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"node": ">=22.5.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@weavecode/core": "^0.1.
|
|
23
|
+
"@weavecode/core": "^0.1.7",
|
|
24
24
|
"smol-toml": "^1.3.0"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -2,7 +2,13 @@ import type { ConfigFileId } from '@weavecode/harness';
|
|
|
2
2
|
/**
|
|
3
3
|
* 配置快照的落盘面。`root` = `local/harness-config`(由调用方给,测试用临时目录):
|
|
4
4
|
* 快照里可能带 API key ⇒ 本机专属、不进 settings 表、不随迁移带走。
|
|
5
|
+
*
|
|
6
|
+
* `file` 实参是存储键(profileKeyOf 的输出):user/global 全机共享原样;
|
|
7
|
+
* project/projectLocal 带 `@p<projectId>` 后缀按项目隔离——活文件路径仍由
|
|
8
|
+
* 调用方按真实档位解析,这里的键只管快照/备份/基线落在谁的名下。
|
|
5
9
|
*/
|
|
10
|
+
/** project/projectLocal 档的快照按项目隔离;user/global 全机共享,不带后缀。 */
|
|
11
|
+
export declare function profileKeyOf(file: ConfigFileId, projectId: number | null): string;
|
|
6
12
|
export interface ConfigProfileMeta {
|
|
7
13
|
id: string;
|
|
8
14
|
name: string;
|
|
@@ -13,27 +19,27 @@ export interface ConfigProfileState {
|
|
|
13
19
|
activeId: string | null;
|
|
14
20
|
profiles: ConfigProfileMeta[];
|
|
15
21
|
}
|
|
16
|
-
export declare function listProfiles(root: string, harness: string, file:
|
|
22
|
+
export declare function listProfiles(root: string, harness: string, file: string): Promise<ConfigProfileState>;
|
|
17
23
|
/** 落一份快照(整份 JSON)。 */
|
|
18
|
-
export declare function writeSnapshot(root: string, harness: string, file:
|
|
19
|
-
export declare function readSnapshot(root: string, harness: string, file:
|
|
20
|
-
export declare function createProfile(root: string, harness: string, file:
|
|
24
|
+
export declare function writeSnapshot(root: string, harness: string, file: string, id: string, values: Record<string, unknown>): Promise<void>;
|
|
25
|
+
export declare function readSnapshot(root: string, harness: string, file: string, id: string): Promise<Record<string, unknown> | null>;
|
|
26
|
+
export declare function createProfile(root: string, harness: string, file: string, name: string, values: Record<string, unknown>): Promise<ConfigProfileMeta>;
|
|
21
27
|
/** 覆盖某份快照的内容并刷新 updatedAt。 */
|
|
22
|
-
export declare function saveProfile(root: string, harness: string, file:
|
|
23
|
-
export declare function renameProfile(root: string, harness: string, file:
|
|
24
|
-
export declare function removeProfile(root: string, harness: string, file:
|
|
25
|
-
export declare function setActive(root: string, harness: string, file:
|
|
28
|
+
export declare function saveProfile(root: string, harness: string, file: string, id: string, values: Record<string, unknown>): Promise<void>;
|
|
29
|
+
export declare function renameProfile(root: string, harness: string, file: string, id: string, name: string): Promise<void>;
|
|
30
|
+
export declare function removeProfile(root: string, harness: string, file: string, id: string): Promise<void>;
|
|
31
|
+
export declare function setActive(root: string, harness: string, file: string, id: string | null): Promise<void>;
|
|
26
32
|
/**
|
|
27
33
|
* 无活跃快照档位的自动基线(project/projectLocal 不支持快照、user/global 可能还没建):
|
|
28
34
|
* 首次查看立基线、写入口同步——没有它这些档位的外部改动永远判不出漂移。
|
|
29
35
|
*/
|
|
30
36
|
export declare const LASTSEEN_ID = "_lastseen";
|
|
31
37
|
/** 漂移基线:活跃快照优先,缺省落自动基线。 */
|
|
32
|
-
export declare function baselineSnapshot(root: string, harness: string, file:
|
|
38
|
+
export declare function baselineSnapshot(root: string, harness: string, file: string, state: ConfigProfileState): Promise<Record<string, unknown> | null>;
|
|
33
39
|
/** 写入口同步基线:有活跃快照同步它;`_lastseen` 恒跟着写(删掉活跃快照后基线不复活旧值)。 */
|
|
34
|
-
export declare function syncBaseline(root: string, harness: string, file:
|
|
40
|
+
export declare function syncBaseline(root: string, harness: string, file: string, state: ConfigProfileState, values: Record<string, unknown>): Promise<void>;
|
|
35
41
|
/** 写盘前把当前活配置存一份(每档留最新 20 份,超出按时间删旧)。 */
|
|
36
|
-
export declare function pushBackup(root: string, harness: string, file:
|
|
42
|
+
export declare function pushBackup(root: string, harness: string, file: string, values: Record<string, unknown>): Promise<void>;
|
|
37
43
|
/** 备份列表(新 → 旧)。同秒序号(`-2`)比无后缀的更新——按「时刻 + 序号」排,不按裸字典序。 */
|
|
38
|
-
export declare function listBackups(root: string, harness: string, file:
|
|
39
|
-
export declare function readBackup(root: string, harness: string, file:
|
|
44
|
+
export declare function listBackups(root: string, harness: string, file: string): Promise<string[]>;
|
|
45
|
+
export declare function readBackup(root: string, harness: string, file: string, id: string): Promise<Record<string, unknown> | null>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import s from"node:fs/promises";import
|
|
2
|
-
`,"utf8"),await s.rename(e,t)}async function j(t,n){return await y(S(t,n))??{}}function g(){return{activeId:null,profiles:[]}}function v(t,n){return t[n]??g()}export async function listProfiles(t,n,e){return v(await j(t,n),e)}async function
|
|
1
|
+
import s from"node:fs/promises";import p from"node:path";import{randomUUID as h}from"node:crypto";export function profileKeyOf(t,n){return(t==="project"||t==="projectLocal")&&n!==null?`${t}@p${n}`:t}const I=20;function l(t,n){return p.join(t,n)}function S(t,n){return p.join(l(t,n),"profiles.json")}function w(t,n,e,r){return p.join(l(t,n),`${e}-${r}.json`)}function m(t,n){return p.join(l(t,n),"backups")}function $(t,n,e,r){return p.join(m(t,n),`${e}-${r}.json`)}async function y(t){try{const n=JSON.parse(await s.readFile(t,"utf8"));return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:null}catch{return null}}async function x(t,n){await s.mkdir(p.dirname(t),{recursive:!0});const e=`${t}.${process.pid}.${Date.now()}.tmp`;await s.writeFile(e,`${JSON.stringify(n,null,2)}
|
|
2
|
+
`,"utf8"),await s.rename(e,t)}async function j(t,n){return await y(S(t,n))??{}}function g(){return{activeId:null,profiles:[]}}function v(t,n){return t[n]??g()}export async function listProfiles(t,n,e){return v(await j(t,n),e)}async function f(t,n,e,r){const a=await j(t,n),c=v(a,e);return r(c),a[e]=c,await x(S(t,n),a),c}function d(){return new Date().toISOString()}export async function writeSnapshot(t,n,e,r,a){await x(w(t,n,e,r),a)}export async function readSnapshot(t,n,e,r){return y(w(t,n,e,r))}export async function createProfile(t,n,e,r,a){const c={id:h().slice(0,8),name:r,createdAt:d(),updatedAt:d()};return await writeSnapshot(t,n,e,c.id,a),await f(t,n,e,i=>{i.profiles.push(c)}),c}export async function saveProfile(t,n,e,r,a){await writeSnapshot(t,n,e,r,a),await f(t,n,e,c=>{const i=c.profiles.find(o=>o.id===r);i&&(i.updatedAt=d())})}export async function renameProfile(t,n,e,r,a){await f(t,n,e,c=>{const i=c.profiles.find(o=>o.id===r);i&&(i.name=a,i.updatedAt=d())})}export async function removeProfile(t,n,e,r){await f(t,n,e,a=>{a.profiles=a.profiles.filter(c=>c.id!==r),a.activeId===r&&(a.activeId=null)}),await s.rm(w(t,n,e,r),{force:!0})}export async function setActive(t,n,e,r){await f(t,n,e,a=>{a.activeId=r})}export const LASTSEEN_ID="_lastseen";export async function baselineSnapshot(t,n,e,r){if(r.activeId){const a=await readSnapshot(t,n,e,r.activeId);if(a)return a}return readSnapshot(t,n,e,LASTSEEN_ID)}export async function syncBaseline(t,n,e,r,a){r.activeId&&await saveProfile(t,n,e,r.activeId,a),await writeSnapshot(t,n,e,LASTSEEN_ID,a)}function A(t){const n=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}-${n(t.getHours())}${n(t.getMinutes())}${n(t.getSeconds())}`}export async function pushBackup(t,n,e,r){const a=A(new Date),c=new Set((await s.readdir(m(t,n)).catch(()=>[])).filter(u=>u.startsWith(`${e}-${a}`)));let i=a;for(let u=2;c.has(`${e}-${i}.json`);u++)i=`${a}-${u}`;await x($(t,n,e,i),r);const o=(await listBackups(t,n,e)).slice(I);for(const u of o)await s.rm($(t,n,e,u),{force:!0})}export async function listBackups(t,n,e){const r=`${e}-`,a=i=>{const o=/^(\d{4}-\d{2}-\d{2}-\d{6})(?:-(\d+))?$/.exec(i);return o?+`${o[1].replace(/-/g,"")}${o[2]??"1"}`:0};return(await s.readdir(m(t,n)).catch(()=>[])).filter(i=>i.startsWith(r)&&i.endsWith(".json")).map(i=>i.slice(r.length,-5)).sort((i,o)=>a(i)-a(o)).reverse()}export async function readBackup(t,n,e,r){return/^[A-Za-z0-9-]+$/.test(r)?y($(t,n,e,r)):null}
|