@e4779/pi-fabric 0.117.2-fork.31 → 0.131.4-fork.33
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/README.md +13 -6
- package/THIRD_PARTY_NOTICES.md +6 -14
- package/dist/activity/store.d.ts +2 -1
- package/dist/activity/store.d.ts.map +1 -1
- package/dist/actors/binding-store.d.ts +13 -0
- package/dist/actors/binding-store.d.ts.map +1 -1
- package/dist/actors/directory.d.ts.map +1 -1
- package/dist/actors/feedback.d.ts +5 -0
- package/dist/actors/feedback.d.ts.map +1 -0
- package/dist/actors/global-registry.d.ts +8 -0
- package/dist/actors/global-registry.d.ts.map +1 -1
- package/dist/actors/host-event-payload.d.ts +14 -0
- package/dist/actors/host-event-payload.d.ts.map +1 -1
- package/dist/actors/manager.d.ts +4 -3
- package/dist/actors/manager.d.ts.map +1 -1
- package/dist/actors/mesh-monitor.d.ts +2 -0
- package/dist/actors/mesh-monitor.d.ts.map +1 -1
- package/dist/actors/name-policy.d.ts +3 -0
- package/dist/actors/name-policy.d.ts.map +1 -0
- package/dist/actors/registry-store.d.ts +14 -5
- package/dist/actors/registry-store.d.ts.map +1 -1
- package/dist/actors/store-read.d.ts +16 -0
- package/dist/actors/store-read.d.ts.map +1 -0
- package/dist/agents/agent-files.d.ts +80 -0
- package/dist/agents/agent-files.d.ts.map +1 -0
- package/dist/agents/agent-files.js +327 -0
- package/dist/agents/agent-files.js.map +7 -0
- package/dist/agents/child-skills.d.ts +60 -0
- package/dist/agents/child-skills.d.ts.map +1 -0
- package/dist/agents/child-skills.js +94 -0
- package/dist/agents/child-skills.js.map +7 -0
- package/dist/agents/clone-first-worktree.d.ts +6 -0
- package/dist/agents/clone-first-worktree.d.ts.map +1 -1
- package/dist/agents/completion-inbox.d.ts.map +1 -1
- package/dist/agents/cow-clone.d.ts.map +1 -1
- package/dist/agents/handoff.d.ts +12 -2
- package/dist/agents/handoff.d.ts.map +1 -1
- package/dist/agents/herdr-status.d.ts +26 -0
- package/dist/agents/herdr-status.d.ts.map +1 -0
- package/dist/agents/herdr-status.js +161 -0
- package/dist/agents/herdr-status.js.map +7 -0
- package/dist/agents/hosted-run.d.ts +20 -4
- package/dist/agents/hosted-run.d.ts.map +1 -1
- package/dist/agents/manager.d.ts +18 -2
- package/dist/agents/manager.d.ts.map +1 -1
- package/dist/agents/model-pin-guard.d.ts +27 -0
- package/dist/agents/model-pin-guard.d.ts.map +1 -0
- package/dist/agents/model-pin-guard.js +86 -0
- package/dist/agents/model-pin-guard.js.map +7 -0
- package/dist/agents/model-pin.d.ts +25 -0
- package/dist/agents/model-pin.d.ts.map +1 -0
- package/dist/agents/provider-bridge.d.ts +7 -6
- package/dist/agents/provider-bridge.d.ts.map +1 -1
- package/dist/agents/provider-bridge.js +33 -5
- package/dist/agents/provider-bridge.js.map +3 -3
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/result.d.ts.map +1 -1
- package/dist/agents/result.js +1 -1
- package/dist/agents/runner-notice.d.ts.map +1 -1
- package/dist/agents/runner-protocol.d.ts +8 -0
- package/dist/agents/runner-protocol.d.ts.map +1 -1
- package/dist/agents/service-schema.d.ts.map +1 -1
- package/dist/agents/transports/herdr-core-socket.d.ts +13 -0
- package/dist/agents/transports/herdr-core-socket.d.ts.map +1 -0
- package/dist/agents/transports/herdr-core-transport.d.ts +10 -0
- package/dist/agents/transports/herdr-core-transport.d.ts.map +1 -0
- package/dist/agents/transports/herdr-socket.d.ts +12 -0
- package/dist/agents/transports/herdr-socket.d.ts.map +1 -0
- package/dist/agents/transports/herdr-transport.d.ts.map +1 -1
- package/dist/agents/types.d.ts +51 -0
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/worker-recovery.d.ts +75 -0
- package/dist/agents/worker-recovery.d.ts.map +1 -0
- package/dist/agents/worktree-manager.d.ts.map +1 -1
- package/dist/agents.js +12 -11
- package/dist/agents.js.map +2 -2
- package/dist/audit/details.d.ts +38 -1
- package/dist/audit/details.d.ts.map +1 -1
- package/dist/audit/projection.d.ts.map +1 -1
- package/dist/audit/trace-schema.d.ts +50 -0
- package/dist/audit/trace-schema.d.ts.map +1 -0
- package/dist/audit/trace.d.ts +2 -48
- package/dist/audit/trace.d.ts.map +1 -1
- package/dist/chunks/chunk-2RWNVCFD.js +483 -0
- package/dist/chunks/chunk-2RWNVCFD.js.map +7 -0
- package/dist/chunks/chunk-2SCMGO2Z.js +16 -0
- package/dist/chunks/chunk-2SCMGO2Z.js.map +7 -0
- package/dist/chunks/chunk-35EEGOH3.js +324 -0
- package/dist/chunks/chunk-35EEGOH3.js.map +7 -0
- package/dist/chunks/{chunk-UTOBAZ5T.js → chunk-37NIOSVU.js} +1 -1
- package/dist/chunks/chunk-37NIOSVU.js.map +7 -0
- package/dist/chunks/chunk-3IJEQBFS.js +25 -0
- package/dist/chunks/chunk-3IJEQBFS.js.map +7 -0
- package/dist/chunks/{chunk-EHQQ4KCX.js → chunk-3MOY6WIB.js} +84 -19
- package/dist/chunks/chunk-3MOY6WIB.js.map +7 -0
- package/dist/chunks/chunk-3VK6UGAN.js +64 -0
- package/dist/chunks/chunk-3VK6UGAN.js.map +7 -0
- package/dist/chunks/{chunk-ROTCDDOV.js → chunk-3XT5WHSG.js} +59 -119
- package/dist/chunks/chunk-3XT5WHSG.js.map +7 -0
- package/dist/chunks/{chunk-FIDUHKMM.js → chunk-4BYS4ZLY.js} +16 -16
- package/dist/chunks/chunk-4BYS4ZLY.js.map +7 -0
- package/dist/chunks/{chunk-UOM37PE4.js → chunk-4PBW54I2.js} +162 -92
- package/dist/chunks/chunk-4PBW54I2.js.map +7 -0
- package/dist/chunks/{chunk-ZEXCKK4K.js → chunk-4WKD3YM3.js} +3 -3
- package/dist/chunks/{chunk-PK4NIJEV.js → chunk-4XMXFHAR.js} +62 -3
- package/dist/chunks/chunk-4XMXFHAR.js.map +7 -0
- package/dist/chunks/{chunk-4EW7GVUR.js → chunk-56NMRVTV.js} +589 -377
- package/dist/chunks/chunk-56NMRVTV.js.map +7 -0
- package/dist/chunks/chunk-5QJFDKPN.js +179 -0
- package/dist/chunks/chunk-5QJFDKPN.js.map +7 -0
- package/dist/chunks/{chunk-P7CBPPHY.js → chunk-6GWDGTHC.js} +5 -5
- package/dist/chunks/{chunk-P7CBPPHY.js.map → chunk-6GWDGTHC.js.map} +1 -1
- package/dist/chunks/chunk-6HO2IUQ5.js +104 -0
- package/dist/chunks/chunk-6HO2IUQ5.js.map +7 -0
- package/dist/chunks/chunk-6OGYPHNQ.js +62 -0
- package/dist/chunks/chunk-6OGYPHNQ.js.map +7 -0
- package/dist/chunks/{chunk-G4TLWHRS.js → chunk-7N7IC3Z2.js} +4 -3
- package/dist/chunks/{chunk-G4TLWHRS.js.map → chunk-7N7IC3Z2.js.map} +2 -2
- package/dist/chunks/{chunk-5XBYFSI5.js → chunk-7YNE4NB2.js} +2 -2
- package/dist/chunks/chunk-ASOJYFKU.js +1316 -0
- package/dist/chunks/chunk-ASOJYFKU.js.map +7 -0
- package/dist/chunks/{chunk-NTC2MCB6.js → chunk-B5L3X3ID.js} +1 -1
- package/dist/chunks/{chunk-NTC2MCB6.js.map → chunk-B5L3X3ID.js.map} +1 -1
- package/dist/chunks/chunk-BIBRWZWQ.js +325 -0
- package/dist/chunks/chunk-BIBRWZWQ.js.map +7 -0
- package/dist/chunks/{chunk-K6QXUGS5.js → chunk-BMAEZNZ5.js} +2 -1
- package/dist/chunks/{chunk-FSB2VIRZ.js → chunk-CBIV747V.js} +14 -3
- package/dist/chunks/chunk-CBIV747V.js.map +7 -0
- package/dist/chunks/{chunk-CCHZXF6K.js → chunk-CXYJJ3HZ.js} +3 -3
- package/dist/chunks/{chunk-R2XQ6AHT.js → chunk-DGERP4VL.js} +22 -10
- package/dist/chunks/chunk-DGERP4VL.js.map +7 -0
- package/dist/chunks/{chunk-C7Z6F3SO.js → chunk-DGUXJSYA.js} +64 -33
- package/dist/chunks/chunk-DGUXJSYA.js.map +7 -0
- package/dist/chunks/chunk-F2LGSRIN.js +38 -0
- package/dist/chunks/chunk-F2LGSRIN.js.map +7 -0
- package/dist/chunks/chunk-F6A6MQ6G.js +609 -0
- package/dist/chunks/chunk-F6A6MQ6G.js.map +7 -0
- package/dist/chunks/{chunk-IR3PIHJM.js → chunk-FK73YJKV.js} +67 -2
- package/dist/chunks/chunk-FK73YJKV.js.map +7 -0
- package/dist/chunks/{chunk-XCEEQ5AB.js → chunk-G2DZJ5LK.js} +1607 -1567
- package/dist/chunks/chunk-G2DZJ5LK.js.map +7 -0
- package/dist/chunks/{chunk-VYQV5JRT.js → chunk-GJVKEHDL.js} +2 -2
- package/dist/chunks/chunk-GJVKEHDL.js.map +7 -0
- package/dist/chunks/{chunk-TIIIHPHF.js → chunk-GS67KDMV.js} +2 -2
- package/dist/chunks/{chunk-D5NYNIST.js → chunk-H57KPL3V.js} +5 -5
- package/dist/chunks/{chunk-KVYNGDGC.js → chunk-HFDJWLMS.js} +6 -6
- package/dist/chunks/{chunk-KVYNGDGC.js.map → chunk-HFDJWLMS.js.map} +1 -1
- package/dist/chunks/{chunk-INRXG4J5.js → chunk-HGD75NZY.js} +2 -2
- package/dist/chunks/{chunk-CRRUW26I.js → chunk-HRDMBGMY.js} +12 -12
- package/dist/chunks/{chunk-CRRUW26I.js.map → chunk-HRDMBGMY.js.map} +2 -2
- package/dist/chunks/{chunk-GO32KSEZ.js → chunk-HRVYXRWZ.js} +85 -10
- package/dist/chunks/chunk-HRVYXRWZ.js.map +7 -0
- package/dist/chunks/{chunk-MLLYR3Y6.js → chunk-HSEZPCL5.js} +19 -78
- package/dist/chunks/chunk-HSEZPCL5.js.map +7 -0
- package/dist/chunks/chunk-JMUUNW2H.js +65 -0
- package/dist/chunks/chunk-JMUUNW2H.js.map +7 -0
- package/dist/chunks/{chunk-UXIBKMUM.js → chunk-KIFOEBYJ.js} +4 -4
- package/dist/chunks/{chunk-3FJUP3GV.js → chunk-L6H46CPY.js} +2 -2
- package/dist/chunks/{chunk-SPCJXN4K.js → chunk-LKYLD5SN.js} +298 -65
- package/dist/chunks/chunk-LKYLD5SN.js.map +7 -0
- package/dist/chunks/{chunk-K7J2ABAZ.js → chunk-LRSZFYUC.js} +92 -32
- package/dist/chunks/chunk-LRSZFYUC.js.map +7 -0
- package/dist/chunks/{chunk-GIK2WNAK.js → chunk-LZ2ZXOCU.js} +112 -23
- package/dist/chunks/chunk-LZ2ZXOCU.js.map +7 -0
- package/dist/chunks/{chunk-FUY6XVRX.js → chunk-MPMEK3IQ.js} +2 -2
- package/dist/chunks/{chunk-HP5P7NBO.js → chunk-MSDL7U6Q.js} +4 -4
- package/dist/chunks/{chunk-ASSLHWZS.js → chunk-MX53BRAC.js} +2 -2
- package/dist/chunks/chunk-N7ZAK2PB.js +132 -0
- package/dist/chunks/chunk-N7ZAK2PB.js.map +7 -0
- package/dist/chunks/{chunk-VSDUSNIA.js → chunk-NBIYYMKS.js} +8 -2
- package/dist/chunks/chunk-NBIYYMKS.js.map +7 -0
- package/dist/chunks/chunk-NENQZCGW.js +45 -0
- package/dist/chunks/chunk-NENQZCGW.js.map +7 -0
- package/dist/chunks/chunk-NJHJKINP.js +47 -0
- package/dist/chunks/chunk-NJHJKINP.js.map +7 -0
- package/dist/chunks/{chunk-U366I5K2.js → chunk-NQ7IWEIF.js} +18 -6
- package/dist/chunks/chunk-NQ7IWEIF.js.map +7 -0
- package/dist/chunks/{chunk-ZQMBS5SH.js → chunk-OJ4HAALD.js} +15 -12
- package/dist/chunks/chunk-OJ4HAALD.js.map +7 -0
- package/dist/chunks/chunk-OZCJU3PZ.js +33 -0
- package/dist/chunks/chunk-OZCJU3PZ.js.map +7 -0
- package/dist/chunks/chunk-P3DCXKL3.js +40 -0
- package/dist/chunks/chunk-P3DCXKL3.js.map +7 -0
- package/dist/chunks/chunk-P7YSPKTM.js +294 -0
- package/dist/chunks/chunk-P7YSPKTM.js.map +7 -0
- package/dist/chunks/chunk-PQVUMJ5J.js +223 -0
- package/dist/chunks/chunk-PQVUMJ5J.js.map +7 -0
- package/dist/chunks/chunk-PUBHBEYO.js +84 -0
- package/dist/chunks/chunk-PUBHBEYO.js.map +7 -0
- package/dist/chunks/{chunk-P4KH4S4S.js → chunk-QGTD3LAZ.js} +5 -20
- package/dist/chunks/chunk-QGTD3LAZ.js.map +7 -0
- package/dist/chunks/{chunk-TIJ3YQXX.js → chunk-QOEOKW2X.js} +2 -2
- package/dist/chunks/{chunk-TIJ3YQXX.js.map → chunk-QOEOKW2X.js.map} +1 -1
- package/dist/chunks/{chunk-QT4W5YVB.js → chunk-RAA3FAYZ.js} +2 -2
- package/dist/chunks/{chunk-3UGN25XS.js → chunk-RKJPBTBB.js} +98 -1664
- package/dist/chunks/chunk-RKJPBTBB.js.map +7 -0
- package/dist/chunks/{chunk-WJJXODAB.js → chunk-RLKRZXSX.js} +8 -1
- package/dist/chunks/{chunk-WJJXODAB.js.map → chunk-RLKRZXSX.js.map} +2 -2
- package/dist/chunks/chunk-RWKQ5SRW.js +129 -0
- package/dist/chunks/chunk-RWKQ5SRW.js.map +7 -0
- package/dist/chunks/chunk-SW25R47N.js +71 -0
- package/dist/chunks/chunk-SW25R47N.js.map +7 -0
- package/dist/chunks/{chunk-EKODKR6Y.js → chunk-TEMKDJJY.js} +148 -72
- package/dist/chunks/chunk-TEMKDJJY.js.map +7 -0
- package/dist/chunks/{chunk-EFETPXU2.js → chunk-TJZYM2SP.js} +118 -237
- package/dist/chunks/chunk-TJZYM2SP.js.map +7 -0
- package/dist/chunks/{chunk-53N2I4QA.js → chunk-TXCNZCZP.js} +2 -2
- package/dist/chunks/{chunk-LNASO4VT.js → chunk-U6Y6TKJL.js} +45 -20
- package/dist/chunks/chunk-U6Y6TKJL.js.map +7 -0
- package/dist/chunks/chunk-UD7LFV43.js +28 -0
- package/dist/chunks/chunk-UD7LFV43.js.map +7 -0
- package/dist/chunks/{chunk-7QKKLBHJ.js → chunk-UPMWLOKL.js} +10 -1
- package/dist/chunks/{chunk-7QKKLBHJ.js.map → chunk-UPMWLOKL.js.map} +2 -2
- package/dist/chunks/chunk-V4OW2ULC.js +422 -0
- package/dist/chunks/chunk-V4OW2ULC.js.map +7 -0
- package/dist/chunks/{chunk-FE6NOAO7.js → chunk-VGRUWTMG.js} +1993 -659
- package/dist/chunks/chunk-VGRUWTMG.js.map +7 -0
- package/dist/chunks/{chunk-PYFJW3HC.js → chunk-W5FEHVZA.js} +2 -16
- package/dist/chunks/{chunk-PYFJW3HC.js.map → chunk-W5FEHVZA.js.map} +3 -3
- package/dist/chunks/chunk-WKFRGICG.js +101 -0
- package/dist/chunks/chunk-WKFRGICG.js.map +7 -0
- package/dist/chunks/{chunk-LEU5CDSL.js → chunk-XFOSUGLU.js} +5 -5
- package/dist/chunks/{chunk-MZUC6LLH.js → chunk-XMYG2TKR.js} +4 -4
- package/dist/chunks/{chunk-MZUC6LLH.js.map → chunk-XMYG2TKR.js.map} +1 -1
- package/dist/chunks/chunk-YC65P7ZO.js +57 -0
- package/dist/chunks/chunk-YC65P7ZO.js.map +7 -0
- package/dist/chunks/{chunk-5UBRGTVN.js → chunk-ZHROHNEE.js} +31 -15
- package/dist/chunks/chunk-ZHROHNEE.js.map +7 -0
- package/dist/cli/decisions.d.ts.map +1 -1
- package/dist/cli/decisions.js +15 -3
- package/dist/cli/decisions.js.map +2 -2
- package/dist/cli/mesh.js +4 -3
- package/dist/cli/mesh.js.map +1 -1
- package/dist/commands/fabric-handler.d.ts +7 -0
- package/dist/commands/fabric-handler.d.ts.map +1 -0
- package/dist/commands/fabric-handler.js +916 -0
- package/dist/commands/fabric-handler.js.map +7 -0
- package/dist/commands/fabric.d.ts +11 -1
- package/dist/commands/fabric.d.ts.map +1 -1
- package/dist/compaction/claim-events.d.ts +61 -0
- package/dist/compaction/claim-events.d.ts.map +1 -0
- package/dist/compaction/claim-events.js +210 -0
- package/dist/compaction/claim-events.js.map +7 -0
- package/dist/compaction/claim.d.ts +51 -0
- package/dist/compaction/claim.d.ts.map +1 -0
- package/dist/compaction/hook.d.ts +28 -2
- package/dist/compaction/hook.d.ts.map +1 -1
- package/dist/compaction/hook.js +12 -7
- package/dist/compaction/owner.js +9 -8
- package/dist/compaction/trace-events.d.ts +1 -1
- package/dist/compaction/trace-events.d.ts.map +1 -1
- package/dist/components/configuration.js +6 -6
- package/dist/components/effect-scope.d.ts.map +1 -1
- package/dist/config.d.ts +40 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/core/action-arguments.d.ts.map +1 -1
- package/dist/core/action-policy-hooks.d.ts +69 -0
- package/dist/core/action-policy-hooks.d.ts.map +1 -0
- package/dist/core/action-registry.d.ts +31 -10
- package/dist/core/action-registry.d.ts.map +1 -1
- package/dist/core/action-registry.js +12 -9
- package/dist/core/approval-controller.d.ts +23 -3
- package/dist/core/approval-controller.d.ts.map +1 -1
- package/dist/core/atomic-write.d.ts +164 -0
- package/dist/core/atomic-write.d.ts.map +1 -1
- package/dist/core/call-presentation.d.ts +14 -0
- package/dist/core/call-presentation.d.ts.map +1 -0
- package/dist/core/child-tool-allowlist.d.ts +17 -1
- package/dist/core/child-tool-allowlist.d.ts.map +1 -1
- package/dist/core/compact-controller.d.ts +34 -0
- package/dist/core/compact-controller.d.ts.map +1 -1
- package/dist/core/core-override-guidance.d.ts +3 -1
- package/dist/core/core-override-guidance.d.ts.map +1 -1
- package/dist/core/file-lock.d.ts.map +1 -1
- package/dist/core/foreground-tools.d.ts +4 -1
- package/dist/core/foreground-tools.d.ts.map +1 -1
- package/dist/core/host-policy.d.ts +43 -0
- package/dist/core/host-policy.d.ts.map +1 -0
- package/dist/core/host-sdk-runtime.d.ts.map +1 -1
- package/dist/core/host-sdk.d.ts.map +1 -1
- package/dist/core/host-sdk.js +1 -1
- package/dist/core/managed-host-guidance.d.ts +5 -0
- package/dist/core/managed-host-guidance.d.ts.map +1 -0
- package/dist/core/model-aliases.d.ts +22 -0
- package/dist/core/model-aliases.d.ts.map +1 -0
- package/dist/core/model-resolution.d.ts +41 -20
- package/dist/core/model-resolution.d.ts.map +1 -1
- package/dist/core/native-tool-result.d.ts +1 -0
- package/dist/core/native-tool-result.d.ts.map +1 -1
- package/dist/core/program-tasks.d.ts +52 -0
- package/dist/core/program-tasks.d.ts.map +1 -0
- package/dist/core/prompt-guidance.d.ts +5 -0
- package/dist/core/prompt-guidance.d.ts.map +1 -0
- package/dist/core/prompt-guidance.js +159 -0
- package/dist/core/prompt-guidance.js.map +7 -0
- package/dist/core/provider-operations.d.ts.map +1 -1
- package/dist/core/provider-operations.js +60 -108
- package/dist/core/provider-operations.js.map +3 -3
- package/dist/core/shell-inbox.d.ts.map +1 -1
- package/dist/core/shell-jobs.d.ts +7 -5
- package/dist/core/shell-jobs.d.ts.map +1 -1
- package/dist/core/shell-timing.d.ts.map +1 -1
- package/dist/core/skill-prompt.d.ts +1 -1
- package/dist/core/skill-prompt.d.ts.map +1 -1
- package/dist/core/skill-references.d.ts +1 -1
- package/dist/core/skill-references.d.ts.map +1 -1
- package/dist/core/system-guidance.d.ts.map +1 -1
- package/dist/core/tool-result-proxy.d.ts.map +1 -1
- package/dist/decisions/command.d.ts +2 -1
- package/dist/decisions/command.d.ts.map +1 -1
- package/dist/decisions/command.js +40 -12
- package/dist/decisions/command.js.map +2 -2
- package/dist/decisions/events.d.ts +12 -0
- package/dist/decisions/events.d.ts.map +1 -0
- package/dist/decisions/events.js +130 -0
- package/dist/decisions/events.js.map +7 -0
- package/dist/decisions/host.d.ts +31 -3
- package/dist/decisions/host.d.ts.map +1 -1
- package/dist/decisions/render.d.ts +44 -0
- package/dist/decisions/render.d.ts.map +1 -0
- package/dist/decisions/store.d.ts +8 -0
- package/dist/decisions/store.d.ts.map +1 -1
- package/dist/durable/agent.d.ts +8 -0
- package/dist/durable/agent.d.ts.map +1 -1
- package/dist/durable/extension-load-error.d.ts +8 -0
- package/dist/durable/extension-load-error.d.ts.map +1 -0
- package/dist/durable/session.d.ts +1 -0
- package/dist/durable/session.d.ts.map +1 -1
- package/dist/durable/worker-host.d.ts +10 -1
- package/dist/durable/worker-host.d.ts.map +1 -1
- package/dist/durable/worker-host.js +10 -1181
- package/dist/durable/worker-host.js.map +4 -4
- package/dist/durable/worker-options.d.ts +3 -0
- package/dist/durable/worker-options.d.ts.map +1 -1
- package/dist/durable/worker-role-seed.d.ts +82 -0
- package/dist/durable/worker-role-seed.d.ts.map +1 -0
- package/dist/durable/worker.js +43 -4
- package/dist/durable/worker.js.map +2 -2
- package/dist/durable-controls.d.ts.map +1 -1
- package/dist/durable-extension-wasm.d.ts +8 -0
- package/dist/durable-extension-wasm.d.ts.map +1 -0
- package/dist/durable-extension-wasm.js +32 -0
- package/dist/durable-extension-wasm.js.map +7 -0
- package/dist/durable-extension.d.ts +94 -0
- package/dist/durable-extension.d.ts.map +1 -0
- package/dist/durable-extension.js +649 -0
- package/dist/durable-extension.js.map +7 -0
- package/dist/durable-host.d.ts +8 -0
- package/dist/durable-host.d.ts.map +1 -0
- package/dist/durable-host.js +20 -0
- package/dist/durable-host.js.map +7 -0
- package/dist/durable-journal.d.ts +94 -0
- package/dist/durable-journal.d.ts.map +1 -0
- package/dist/durable.d.ts.map +1 -1
- package/dist/durable.js +13 -10
- package/dist/durable.js.map +2 -2
- package/dist/entropy/index.js +12 -10
- package/dist/entropy/pool-store.d.ts.map +1 -1
- package/dist/execution-service.d.ts +14 -0
- package/dist/execution-service.d.ts.map +1 -1
- package/dist/extension-bootstrap.d.ts.map +1 -1
- package/dist/extension-bootstrap.js +28 -27
- package/dist/extension-bootstrap.js.map +2 -2
- package/dist/extension-copy.d.ts +21 -0
- package/dist/extension-copy.d.ts.map +1 -0
- package/dist/extension-copy.js +90 -0
- package/dist/extension-copy.js.map +7 -0
- package/dist/extension.d.ts +1 -1
- package/dist/extension.d.ts.map +1 -1
- package/dist/fabric-exec-arguments.d.ts.map +1 -1
- package/dist/fabric-exec-tool.d.ts +2 -1
- package/dist/fabric-exec-tool.d.ts.map +1 -1
- package/dist/fabric-runtime-state.d.ts +19 -0
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +2205 -839
- package/dist/fabric-runtime-state.js.map +4 -4
- package/dist/fabric-state.d.ts +44 -1
- package/dist/fabric-state.d.ts.map +1 -1
- package/dist/feedback.d.ts +5 -0
- package/dist/feedback.d.ts.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +88 -53
- package/dist/index.js.map +2 -2
- package/dist/jev/client.js +2 -2
- package/dist/jev/manager.d.ts +3 -0
- package/dist/jev/manager.d.ts.map +1 -1
- package/dist/jev/observation.d.ts +1 -1
- package/dist/jev/observation.js +6 -6
- package/dist/jev-fabric/bridge.d.ts.map +1 -1
- package/dist/jev.js +11 -12
- package/dist/main-agent.d.ts +2 -1
- package/dist/main-agent.d.ts.map +1 -1
- package/dist/managed-host.d.ts +13 -0
- package/dist/managed-host.d.ts.map +1 -1
- package/dist/memory/digest.js +2 -2
- package/dist/memory/discovery.js +6 -7
- package/dist/memory/file-worker.js +10 -11
- package/dist/memory/file-worker.js.map +1 -1
- package/dist/memory/normalize.js +5 -6
- package/dist/memory/search.js +7 -8
- package/dist/memory/worker-provider.js +11 -12
- package/dist/memory.js +11 -12
- package/dist/memory.js.map +1 -1
- package/dist/mesh/grants.d.ts +3 -3
- package/dist/mesh/grants.d.ts.map +1 -1
- package/dist/mesh/store.d.ts +8 -0
- package/dist/mesh/store.d.ts.map +1 -1
- package/dist/native-codemode.d.ts.map +1 -1
- package/dist/native-tool-catalog.d.ts.map +1 -1
- package/dist/native-tool-catalog.js +12 -3
- package/dist/native-tool-catalog.js.map +2 -2
- package/dist/programs/host.d.ts +18 -6
- package/dist/programs/host.d.ts.map +1 -1
- package/dist/programs/host.js +71 -47
- package/dist/programs/host.js.map +2 -2
- package/dist/programs/source.d.ts +11 -0
- package/dist/programs/source.d.ts.map +1 -1
- package/dist/programs/store.d.ts.map +1 -1
- package/dist/protocol.d.ts +504 -8
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +41 -11
- package/dist/provider-globals.d.ts +13 -0
- package/dist/provider-globals.d.ts.map +1 -0
- package/dist/providers/agents-actions.d.ts.map +1 -1
- package/dist/providers/agents-provider.d.ts +3 -0
- package/dist/providers/agents-provider.d.ts.map +1 -1
- package/dist/providers/captured-tools-provider.d.ts +5 -0
- package/dist/providers/captured-tools-provider.d.ts.map +1 -1
- package/dist/providers/compact-provider.d.ts +4 -1
- package/dist/providers/compact-provider.d.ts.map +1 -1
- package/dist/providers/components-provider.d.ts.map +1 -1
- package/dist/providers/decisions-provider.d.ts +9 -1
- package/dist/providers/decisions-provider.d.ts.map +1 -1
- package/dist/providers/jev-provider.d.ts +1 -1
- package/dist/providers/jev-provider.js +11 -12
- package/dist/providers/memory-provider.js +10 -11
- package/dist/providers/pi-tools-provider.d.ts +14 -0
- package/dist/providers/pi-tools-provider.d.ts.map +1 -1
- package/dist/providers/programs-provider.d.ts.map +1 -1
- package/dist/providers/sessions-provider.d.ts +7 -0
- package/dist/providers/sessions-provider.d.ts.map +1 -1
- package/dist/repeat-guard.d.ts +7 -6
- package/dist/repeat-guard.d.ts.map +1 -1
- package/dist/residency/actor-client.js +3 -3
- package/dist/residency/client.d.ts +15 -0
- package/dist/residency/client.d.ts.map +1 -1
- package/dist/residency/host.d.ts.map +1 -1
- package/dist/residency/host.js +34 -23
- package/dist/residency/launcher.js +1 -1
- package/dist/residency/pi-entry.js +34 -23
- package/dist/residency/pi-entry.js.map +1 -1
- package/dist/residency/protocol.d.ts +2 -0
- package/dist/residency/protocol.d.ts.map +1 -1
- package/dist/runners.js +11 -1
- package/dist/runners.js.map +2 -2
- package/dist/runtime/core-override-guest-types.js +2 -2
- package/dist/runtime/cpython-child-source.d.ts.map +1 -1
- package/dist/runtime/cpython-runtime.d.ts.map +1 -1
- package/dist/runtime/cpython-runtime.js +51 -21
- package/dist/runtime/cpython-runtime.js.map +2 -2
- package/dist/runtime/deadline-pause.d.ts +2 -0
- package/dist/runtime/deadline-pause.d.ts.map +1 -1
- package/dist/runtime/dynamic-guest-types.d.ts.map +1 -1
- package/dist/runtime/dynamic-guest-types.js +2 -1
- package/dist/runtime/exec-journal.d.ts +73 -0
- package/dist/runtime/exec-journal.d.ts.map +1 -0
- package/dist/runtime/exec-journal.js +335 -0
- package/dist/runtime/exec-journal.js.map +7 -0
- package/dist/runtime/guest-types.d.ts +3 -2
- package/dist/runtime/guest-types.d.ts.map +1 -1
- package/dist/runtime/guest-types.js +1 -1
- package/dist/runtime/journal-shim.d.ts +3 -0
- package/dist/runtime/journal-shim.d.ts.map +1 -0
- package/dist/runtime/kernel.d.ts +95 -1
- package/dist/runtime/kernel.d.ts.map +1 -1
- package/dist/runtime/monty-bridge.d.ts +6 -2
- package/dist/runtime/monty-bridge.d.ts.map +1 -1
- package/dist/runtime/monty-runtime.d.ts.map +1 -1
- package/dist/runtime/monty-runtime.js +27 -15
- package/dist/runtime/monty-runtime.js.map +2 -2
- package/dist/runtime/native-codemode-guest.d.ts.map +1 -1
- package/dist/runtime/node-process-runtime.d.ts.map +1 -1
- package/dist/runtime/node-process-runtime.js +7 -5
- package/dist/runtime/quickjs-runtime.d.ts +7 -1
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
- package/dist/runtime/quickjs-runtime.js +5 -4
- package/dist/runtime/sha256.d.ts +4 -0
- package/dist/runtime/sha256.d.ts.map +1 -0
- package/dist/runtime/transpile.d.ts +8 -0
- package/dist/runtime/transpile.d.ts.map +1 -0
- package/dist/runtime/type-checker.d.ts +1 -7
- package/dist/runtime/type-checker.d.ts.map +1 -1
- package/dist/runtime/type-checker.js +4 -2
- package/dist/runtime/typescript-kernel.js +13 -10
- package/dist/runtime/typescript-kernel.js.map +1 -1
- package/dist/runtime-state-builtins.d.ts.map +1 -1
- package/dist/speculation/scanner.js +1 -1
- package/dist/speculation/store.d.ts +7 -16
- package/dist/speculation/store.d.ts.map +1 -1
- package/dist/speculation/types.d.ts +1 -0
- package/dist/speculation/types.d.ts.map +1 -1
- package/dist/storage/retention.d.ts.map +1 -1
- package/dist/topology/participant-directory.d.ts +26 -1
- package/dist/topology/participant-directory.d.ts.map +1 -1
- package/dist/topology/peer-presence.d.ts.map +1 -1
- package/dist/topology/peer-settle.js +11 -0
- package/dist/topology/peer-settle.js.map +7 -0
- package/dist/topology/session-label-settings.d.ts +13 -0
- package/dist/topology/session-label-settings.d.ts.map +1 -0
- package/dist/topology/session-label.d.ts +60 -0
- package/dist/topology/session-label.d.ts.map +1 -0
- package/dist/topology/types.d.ts +27 -0
- package/dist/topology/types.d.ts.map +1 -1
- package/dist/type-error-guidance.js +1 -1
- package/dist/ui/controller.d.ts +1 -0
- package/dist/ui/controller.d.ts.map +1 -1
- package/dist/ui/conversation-chrome.d.ts.map +1 -1
- package/dist/ui/conversation-chrome.js +3 -2
- package/dist/ui/conversation-commands.d.ts +1 -1
- package/dist/ui/conversation-commands.d.ts.map +1 -1
- package/dist/ui/conversation-native-reader.js +2 -2
- package/dist/ui/conversation-selection.d.ts +4 -1
- package/dist/ui/conversation-selection.d.ts.map +1 -1
- package/dist/ui/conversation-targets.d.ts.map +1 -1
- package/dist/ui/conversation-targets.js +2 -2
- package/dist/ui/conversation.d.ts +25 -24
- package/dist/ui/conversation.d.ts.map +1 -1
- package/dist/ui/conversation.js +170 -339
- package/dist/ui/conversation.js.map +2 -2
- package/dist/ui/core-tool-render.d.ts +1 -0
- package/dist/ui/core-tool-render.d.ts.map +1 -1
- package/dist/ui/dashboard-model.d.ts.map +1 -1
- package/dist/ui/dashboard.d.ts.map +1 -1
- package/dist/ui/dashboard.js +23 -16
- package/dist/ui/dashboard.js.map +2 -2
- package/dist/ui/fabric-render.d.ts +7 -0
- package/dist/ui/fabric-render.d.ts.map +1 -1
- package/dist/ui/footer-dock.d.ts +48 -0
- package/dist/ui/footer-dock.d.ts.map +1 -0
- package/dist/ui/format.d.ts +7 -0
- package/dist/ui/format.d.ts.map +1 -1
- package/dist/ui/settings-sections-lifecycle.d.ts.map +1 -1
- package/dist/ui/settings-sections-presentation.d.ts.map +1 -1
- package/dist/ui/settings-values.d.ts +2 -1
- package/dist/ui/settings-values.d.ts.map +1 -1
- package/dist/ui/settings.js +60 -19
- package/dist/ui/settings.js.map +2 -2
- package/dist/ui/shell-hang-keys.d.ts +8 -1
- package/dist/ui/shell-hang-keys.d.ts.map +1 -1
- package/dist/ui/shell-tasks.d.ts +2 -2
- package/dist/ui/shell-tasks.d.ts.map +1 -1
- package/dist/ui/shell-tasks.js +27 -94
- package/dist/ui/shell-tasks.js.map +2 -2
- package/dist/ui/snapshot.d.ts.map +1 -1
- package/dist/ui/terminal-title.d.ts +41 -0
- package/dist/ui/terminal-title.d.ts.map +1 -0
- package/dist/ui/types.d.ts +4 -0
- package/dist/ui/types.d.ts.map +1 -1
- package/dist/ui/widget-keys.d.ts +5 -0
- package/dist/ui/widget-keys.d.ts.map +1 -0
- package/dist/ui/widget.d.ts +40 -18
- package/dist/ui/widget.d.ts.map +1 -1
- package/dist/ui/word-diff/line-emphasis.js +1603 -0
- package/dist/ui/word-diff/line-emphasis.js.map +7 -0
- package/dist/util.d.ts +2 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/verified/authority.d.ts +2 -2
- package/dist/verified/authority.d.ts.map +1 -1
- package/dist/verified/budget.d.ts +4 -0
- package/dist/verified/budget.d.ts.map +1 -0
- package/dist/verified/generated/actor-name.d.ts +4 -0
- package/dist/verified/generated/actor-name.js +17 -0
- package/dist/verified/generated/authority.d.ts +4 -0
- package/dist/verified/generated/authority.js +28 -0
- package/dist/verified/generated/budget.d.ts +4 -0
- package/dist/verified/generated/budget.js +17 -0
- package/dist/verified/generated/compaction.d.ts +4 -0
- package/dist/verified/generated/compaction.js +19 -0
- package/dist/verified/generated/grants.d.ts +4 -0
- package/dist/verified/generated/grants.js +17 -0
- package/dist/verified/generated/lifecycle.d.ts +4 -0
- package/dist/verified/generated/lifecycle.js +50 -0
- package/dist/verified/generated/manifest.json +137 -48
- package/dist/verified/generated/policy.d.ts +17 -0
- package/dist/verified/generated/policy.js +211 -0
- package/dist/verified/generated/provider.d.ts +4 -0
- package/dist/verified/generated/provider.js +18 -0
- package/dist/verified/generated/resources.d.ts +6 -0
- package/dist/verified/generated/resources.js +73 -0
- package/dist/verified/generated/speculation.d.ts +6 -0
- package/dist/verified/generated/speculation.js +48 -0
- package/dist/verified/generated/storage.d.ts +4 -0
- package/dist/verified/generated/storage.js +18 -0
- package/dist/verified/grants.d.ts +22 -0
- package/dist/verified/grants.d.ts.map +1 -0
- package/dist/verified/lifecycle.d.ts +31 -0
- package/dist/verified/lifecycle.d.ts.map +1 -0
- package/dist/verified/machine.d.ts +18 -0
- package/dist/verified/machine.d.ts.map +1 -0
- package/dist/verified/memory.d.ts +1 -1
- package/dist/verified/memory.d.ts.map +1 -1
- package/dist/verified/nat.d.ts +1 -1
- package/dist/verified/nat.d.ts.map +1 -1
- package/dist/verified/policy.d.ts +17 -5
- package/dist/verified/policy.d.ts.map +1 -1
- package/dist/verified/provider.d.ts +22 -0
- package/dist/verified/provider.d.ts.map +1 -0
- package/dist/verified/resources.d.ts +21 -7
- package/dist/verified/resources.d.ts.map +1 -1
- package/dist/verified/speculation.d.ts +36 -0
- package/dist/verified/speculation.d.ts.map +1 -0
- package/dist/verified/storage.d.ts.map +1 -1
- package/dist/worker/missing-install.d.ts +8 -0
- package/dist/worker/missing-install.d.ts.map +1 -0
- package/dist/worker/options.d.ts.map +1 -1
- package/dist/worker/options.js +25 -0
- package/dist/worker/options.js.map +2 -2
- package/dist/worker/prompt-lifecycle.d.ts +16 -0
- package/dist/worker/prompt-lifecycle.d.ts.map +1 -0
- package/dist/worker/prompt-lifecycle.js +90 -0
- package/dist/worker/prompt-lifecycle.js.map +7 -0
- package/dist/worker/questions.d.ts +15 -3
- package/dist/worker/questions.d.ts.map +1 -1
- package/dist/worker/questions.js +53 -8
- package/dist/worker/questions.js.map +2 -2
- package/dist/worker/recovery-watchdog.d.ts +22 -0
- package/dist/worker/recovery-watchdog.d.ts.map +1 -1
- package/dist/worker/recovery-watchdog.js +116 -1
- package/dist/worker/recovery-watchdog.js.map +2 -2
- package/dist/worker/result.js +1 -1
- package/dist/worker/result.js.map +2 -2
- package/dist/worker.js +131 -21
- package/dist/worker.js.map +2 -2
- package/docs/actor-name-policy-handoff.md +5 -0
- package/docs/agents.md +172 -22
- package/docs/architecture.md +5 -1
- package/docs/audit-trace.md +2 -1
- package/docs/background-tasks.md +126 -28
- package/docs/codemode-parity.md +2 -2
- package/docs/compaction.md +21 -5
- package/docs/components.md +1 -1
- package/docs/configuration.md +113 -66
- package/docs/decisions.md +92 -10
- package/docs/durable-extension.md +121 -0
- package/docs/durable-pi.md +306 -6
- package/docs/extractive-history.md +3 -1
- package/docs/interface.md +22 -17
- package/docs/jev.md +2 -2
- package/docs/kernels.md +1 -1
- package/{node_modules/pi-coralbricks-provider/LICENSE → docs/licenses/gdp-wired-mit.txt} +1 -1
- package/docs/managed-host-migration.md +50 -0
- package/docs/programmatic-compaction.md +216 -6
- package/docs/programs.md +23 -1
- package/docs/prompt-cache.md +4 -2
- package/docs/provider-capabilities.md +15 -14
- package/docs/providers.md +99 -3
- package/docs/shell-composition.md +15 -0
- package/docs/short-lock-protocol.md +90 -0
- package/docs/skills.md +5 -1
- package/docs/speculation.md +6 -0
- package/docs/verified-kernels.md +309 -220
- package/package.json +45 -24
- package/proofs/actor-name.ts +27 -0
- package/proofs/authority.ts +62 -0
- package/proofs/budget.ts +24 -0
- package/proofs/compaction.ts +51 -0
- package/proofs/grants.ts +39 -0
- package/proofs/index.ts +40 -0
- package/proofs/kernel.ts +44 -0
- package/proofs/lifecycle.ts +128 -0
- package/proofs/policy.ts +195 -0
- package/proofs/provider.ts +52 -0
- package/proofs/resources.ts +160 -0
- package/proofs/speculation.ts +69 -0
- package/proofs/storage.ts +66 -0
- package/scripts/verified-kernels.ts +141 -0
- package/skillsets/python/fabric-council/SKILL.md +94 -20
- package/skillsets/python/fabric-exec/SKILL.md +2 -2
- package/skillsets/python/fabric-exec/references/agents.md +10 -4
- package/skillsets/python/fabric-fusion/SKILL.md +1 -1
- package/skillsets/python/fabric-guide/SKILL.md +1 -1
- package/skillsets/typescript/fabric-council/SKILL.md +110 -22
- package/skillsets/typescript/fabric-exec/SKILL.md +7 -7
- package/skillsets/typescript/fabric-exec/references/agents.md +17 -8
- package/skillsets/typescript/fabric-fusion/SKILL.md +1 -1
- package/skillsets/typescript/fabric-guide/SKILL.md +1 -1
- package/LAWS.bend +0 -502
- package/PROOF.bend +0 -452
- package/dist/chunks/chunk-3UGN25XS.js.map +0 -7
- package/dist/chunks/chunk-4EW7GVUR.js.map +0 -7
- package/dist/chunks/chunk-5UBRGTVN.js.map +0 -7
- package/dist/chunks/chunk-BN7F52EG.js +0 -525
- package/dist/chunks/chunk-BN7F52EG.js.map +0 -7
- package/dist/chunks/chunk-C7Z6F3SO.js.map +0 -7
- package/dist/chunks/chunk-DK35W6U7.js +0 -259
- package/dist/chunks/chunk-DK35W6U7.js.map +0 -7
- package/dist/chunks/chunk-EFETPXU2.js.map +0 -7
- package/dist/chunks/chunk-EHQQ4KCX.js.map +0 -7
- package/dist/chunks/chunk-EKODKR6Y.js.map +0 -7
- package/dist/chunks/chunk-FE6NOAO7.js.map +0 -7
- package/dist/chunks/chunk-FIDUHKMM.js.map +0 -7
- package/dist/chunks/chunk-FSB2VIRZ.js.map +0 -7
- package/dist/chunks/chunk-GIK2WNAK.js.map +0 -7
- package/dist/chunks/chunk-GO32KSEZ.js.map +0 -7
- package/dist/chunks/chunk-IR3PIHJM.js.map +0 -7
- package/dist/chunks/chunk-ITVLKXCI.js +0 -266
- package/dist/chunks/chunk-ITVLKXCI.js.map +0 -7
- package/dist/chunks/chunk-K7J2ABAZ.js.map +0 -7
- package/dist/chunks/chunk-KJZAOENY.js +0 -212
- package/dist/chunks/chunk-KJZAOENY.js.map +0 -7
- package/dist/chunks/chunk-LNASO4VT.js.map +0 -7
- package/dist/chunks/chunk-MLLYR3Y6.js.map +0 -7
- package/dist/chunks/chunk-P4KH4S4S.js.map +0 -7
- package/dist/chunks/chunk-PK4NIJEV.js.map +0 -7
- package/dist/chunks/chunk-Q2JQ3RYZ.js +0 -99
- package/dist/chunks/chunk-Q2JQ3RYZ.js.map +0 -7
- package/dist/chunks/chunk-R2XQ6AHT.js.map +0 -7
- package/dist/chunks/chunk-ROTCDDOV.js.map +0 -7
- package/dist/chunks/chunk-SPCJXN4K.js.map +0 -7
- package/dist/chunks/chunk-U366I5K2.js.map +0 -7
- package/dist/chunks/chunk-UKMQK5VP.js +0 -231
- package/dist/chunks/chunk-UKMQK5VP.js.map +0 -7
- package/dist/chunks/chunk-UOM37PE4.js.map +0 -7
- package/dist/chunks/chunk-UTOBAZ5T.js.map +0 -7
- package/dist/chunks/chunk-VSDUSNIA.js.map +0 -7
- package/dist/chunks/chunk-VTK2FEH7.js +0 -229
- package/dist/chunks/chunk-VTK2FEH7.js.map +0 -7
- package/dist/chunks/chunk-VYQV5JRT.js.map +0 -7
- package/dist/chunks/chunk-XCEEQ5AB.js.map +0 -7
- package/dist/chunks/chunk-ZLNJDTCN.js +0 -226
- package/dist/chunks/chunk-ZLNJDTCN.js.map +0 -7
- package/dist/chunks/chunk-ZQMBS5SH.js.map +0 -7
- package/dist/ui/conversation-shortcut.d.ts +0 -3
- package/dist/ui/conversation-shortcut.d.ts.map +0 -1
- package/dist/ui/widget-activity.d.ts +0 -21
- package/dist/ui/widget-activity.d.ts.map +0 -1
- package/dist/verified/generated/authority-kernel.d.ts +0 -10
- package/dist/verified/generated/authority-kernel.js +0 -127
- package/dist/verified/generated/kernel.d.ts +0 -31
- package/dist/verified/generated/kernel.js +0 -389
- package/dist/verified/generated/lifecycle-kernel.d.ts +0 -7
- package/dist/verified/generated/lifecycle-kernel.js +0 -164
- package/dist/verified/generated/provider-kernel.d.ts +0 -9
- package/dist/verified/generated/provider-kernel.js +0 -87
- package/dist/verified/generated/storage-kernel.d.ts +0 -11
- package/dist/verified/generated/storage-kernel.js +0 -107
- package/docs/licenses/bend-apache-2.0.txt +0 -202
- package/node_modules/pi-coralbricks-provider/README.md +0 -306
- package/node_modules/pi-coralbricks-provider/auth.ts +0 -30
- package/node_modules/pi-coralbricks-provider/custom-models.json +0 -1
- package/node_modules/pi-coralbricks-provider/deprecated-models.json +0 -1
- package/node_modules/pi-coralbricks-provider/guard.ts +0 -155
- package/node_modules/pi-coralbricks-provider/index.ts +0 -662
- package/node_modules/pi-coralbricks-provider/models.json +0 -88
- package/node_modules/pi-coralbricks-provider/package.json +0 -74
- package/node_modules/pi-coralbricks-provider/park.ts +0 -122
- package/node_modules/pi-coralbricks-provider/patch.json +0 -34
- package/node_modules/pi-coralbricks-provider/scripts/update-models.js +0 -658
- package/node_modules/pi-coralbricks-provider/settings.ts +0 -143
- package/node_modules/pi-coralbricks-provider/sync-policy.ts +0 -309
- package/proofs/abi.json +0 -308
- package/proofs/authority-abi.json +0 -7
- package/proofs/authority-kernel.bend +0 -23
- package/proofs/authority-proof.bend +0 -74
- package/proofs/authority-spec.bend +0 -30
- package/proofs/authority-state.bend +0 -43
- package/proofs/authority-types.d.ts +0 -3
- package/proofs/kernel.bend +0 -139
- package/proofs/lifecycle-abi.json +0 -3
- package/proofs/lifecycle-kernel.bend +0 -11
- package/proofs/lifecycle-proof.bend +0 -249
- package/proofs/lifecycle-spec.bend +0 -261
- package/proofs/lifecycle-types.d.ts +0 -4
- package/proofs/lifecycle.bend +0 -119
- package/proofs/provider-abi.json +0 -4
- package/proofs/provider-kernel.bend +0 -14
- package/proofs/provider-plans.bend +0 -28
- package/proofs/provider-spec.bend +0 -14
- package/proofs/provider-types.d.ts +0 -5
- package/proofs/resource-proof.bend +0 -633
- package/proofs/resource-spec.bend +0 -133
- package/proofs/resources.bend +0 -160
- package/proofs/state-kernel.bend +0 -17
- package/proofs/state-plans.bend +0 -40
- package/proofs/state-proof.bend +0 -42
- package/proofs/state-spec.bend +0 -26
- package/proofs/storage-abi.json +0 -3
- package/proofs/storage-kernel.bend +0 -11
- package/proofs/storage-plans.bend +0 -100
- package/proofs/storage-proof.bend +0 -176
- package/proofs/storage-spec.bend +0 -70
- package/proofs/storage-types.d.ts +0 -8
- package/proofs/types.d.ts +0 -7
- package/scripts/test-verified-kernels.mjs +0 -107
- package/scripts/verified-kernels.mjs +0 -176
- /package/dist/chunks/{chunk-ZEXCKK4K.js.map → chunk-4WKD3YM3.js.map} +0 -0
- /package/dist/chunks/{chunk-5XBYFSI5.js.map → chunk-7YNE4NB2.js.map} +0 -0
- /package/dist/chunks/{chunk-K6QXUGS5.js.map → chunk-BMAEZNZ5.js.map} +0 -0
- /package/dist/chunks/{chunk-CCHZXF6K.js.map → chunk-CXYJJ3HZ.js.map} +0 -0
- /package/dist/chunks/{chunk-TIIIHPHF.js.map → chunk-GS67KDMV.js.map} +0 -0
- /package/dist/chunks/{chunk-D5NYNIST.js.map → chunk-H57KPL3V.js.map} +0 -0
- /package/dist/chunks/{chunk-INRXG4J5.js.map → chunk-HGD75NZY.js.map} +0 -0
- /package/dist/chunks/{chunk-UXIBKMUM.js.map → chunk-KIFOEBYJ.js.map} +0 -0
- /package/dist/chunks/{chunk-3FJUP3GV.js.map → chunk-L6H46CPY.js.map} +0 -0
- /package/dist/chunks/{chunk-FUY6XVRX.js.map → chunk-MPMEK3IQ.js.map} +0 -0
- /package/dist/chunks/{chunk-HP5P7NBO.js.map → chunk-MSDL7U6Q.js.map} +0 -0
- /package/dist/chunks/{chunk-ASSLHWZS.js.map → chunk-MX53BRAC.js.map} +0 -0
- /package/dist/chunks/{chunk-QT4W5YVB.js.map → chunk-RAA3FAYZ.js.map} +0 -0
- /package/dist/chunks/{chunk-53N2I4QA.js.map → chunk-TXCNZCZP.js.map} +0 -0
- /package/dist/chunks/{chunk-LEU5CDSL.js.map → chunk-XFOSUGLU.js.map} +0 -0
|
@@ -9,21 +9,31 @@ import {
|
|
|
9
9
|
observedThemeVariant,
|
|
10
10
|
shikiLanguages
|
|
11
11
|
} from "./chunk-QNMQJNXE.js";
|
|
12
|
+
import {
|
|
13
|
+
diffLineNumberWidth,
|
|
14
|
+
formatDiffLineNumber,
|
|
15
|
+
parseDiffLine
|
|
16
|
+
} from "./chunk-F2LGSRIN.js";
|
|
12
17
|
import {
|
|
13
18
|
countContentLines,
|
|
14
|
-
countNewlines,
|
|
15
19
|
headlineArg,
|
|
16
20
|
isFabricAgentToolPreview,
|
|
21
|
+
isRoutineInternalCall,
|
|
22
|
+
providerCallMetadata,
|
|
17
23
|
selectPreviewTextLines,
|
|
18
24
|
shouldSkipWriteDiffBytes,
|
|
19
25
|
shouldSkipWriteDiffComplexity
|
|
20
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-TEMKDJJY.js";
|
|
27
|
+
import {
|
|
28
|
+
countNewlines
|
|
29
|
+
} from "./chunk-P3DCXKL3.js";
|
|
21
30
|
import {
|
|
22
31
|
fabricStringLiterals
|
|
23
32
|
} from "./chunk-SZUXWOO7.js";
|
|
24
33
|
|
|
25
34
|
// src/ui/core-tool-render.ts
|
|
26
35
|
import { readFileSync, statSync } from "node:fs";
|
|
36
|
+
import { createRequire } from "node:module";
|
|
27
37
|
import { homedir } from "node:os";
|
|
28
38
|
import { basename, extname, isAbsolute, relative, resolve } from "node:path";
|
|
29
39
|
|
|
@@ -35,9 +45,6 @@ var formatToolCallDuration = (startedAt, endedAt) => {
|
|
|
35
45
|
return durationMs < 1e3 ? `${durationMs}ms` : `${(durationMs / 1e3).toFixed(1)}s`;
|
|
36
46
|
};
|
|
37
47
|
|
|
38
|
-
// src/ui/core-tool-render.ts
|
|
39
|
-
import { diffLines } from "diff";
|
|
40
|
-
|
|
41
48
|
// src/ui/arc-group.ts
|
|
42
49
|
var ANSI_ESCAPE = /\x1b\[[0-9;]*m/g;
|
|
43
50
|
var ARC_CLOSING = "\u2570\u2500 ";
|
|
@@ -232,1631 +239,6 @@ var parseAnsiRgb = (ansi) => {
|
|
|
232
239
|
return void 0;
|
|
233
240
|
};
|
|
234
241
|
|
|
235
|
-
// src/ui/word-diff/normalize.ts
|
|
236
|
-
var expandPreviewTabs = (text) => text.replace(/\t/g, " ");
|
|
237
|
-
var escapeControlChars = (text) => text.replace(/\x1b/g, "\u241B").replace(/\r/g, "\u240D").replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/g, "\uFFFD");
|
|
238
|
-
|
|
239
|
-
// src/ui/word-diff/tokens.ts
|
|
240
|
-
var WORD_TOKEN_PATTERN = new RegExp("[$_\\p{L}][$_\\p{L}\\p{N}\\p{Mark}]*|\\p{N}+(?:\\.\\p{N}+)?|===|!==|=>|==|!=|<=|>=|&&|\\|\\||[^\\s]", "gu");
|
|
241
|
-
var IDENTIFIER_TOKEN_PATTERN = /^[$_\p{L}][$_\p{L}\p{N}\p{Mark}]*$/u;
|
|
242
|
-
var NUMBER_TOKEN_PATTERN = new RegExp("^\\p{N}+(?:\\.\\p{N}+)?$", "u");
|
|
243
|
-
var SYMBOL_TOKEN_PATTERN = new RegExp("^\\p{S}+$", "u");
|
|
244
|
-
var MEANINGFUL_OPERATOR_TOKEN_PATTERN = /^(?:===|!==|=>|==|!=|<=|>=|&&|\|\||[+\-*\/%<>=!?:~&|^]+)$/;
|
|
245
|
-
var DOMAIN_SEPARATOR_TOKEN_PATTERN = /^[-/:@#]$/;
|
|
246
|
-
var STRUCTURAL_PUNCTUATION_TOKEN_PATTERN = /^[{}()[\].,;]$/;
|
|
247
|
-
function wordEmphasisTokens(text) {
|
|
248
|
-
const tokens = [];
|
|
249
|
-
for (const match of text.matchAll(WORD_TOKEN_PATTERN)) {
|
|
250
|
-
const value = match[0];
|
|
251
|
-
const start = match.index;
|
|
252
|
-
tokens.push({ value, start, end: start + value.length });
|
|
253
|
-
}
|
|
254
|
-
return tokens;
|
|
255
|
-
}
|
|
256
|
-
function wordTokenValues(text) {
|
|
257
|
-
return Array.from(text.matchAll(WORD_TOKEN_PATTERN), (match) => match[0]);
|
|
258
|
-
}
|
|
259
|
-
function isIdentifierToken(value) {
|
|
260
|
-
return IDENTIFIER_TOKEN_PATTERN.test(value);
|
|
261
|
-
}
|
|
262
|
-
function isNumberToken(value) {
|
|
263
|
-
return NUMBER_TOKEN_PATTERN.test(value);
|
|
264
|
-
}
|
|
265
|
-
function isSymbolToken(value) {
|
|
266
|
-
return SYMBOL_TOKEN_PATTERN.test(value);
|
|
267
|
-
}
|
|
268
|
-
function isMeaningfulOperatorToken(value) {
|
|
269
|
-
return MEANINGFUL_OPERATOR_TOKEN_PATTERN.test(value);
|
|
270
|
-
}
|
|
271
|
-
function wordEmphasisTokenWeight(value) {
|
|
272
|
-
if (isIdentifierToken(value)) return 2;
|
|
273
|
-
if (isNumberToken(value)) return 1.5;
|
|
274
|
-
if (DOMAIN_SEPARATOR_TOKEN_PATTERN.test(value)) return 0.25;
|
|
275
|
-
if (isMeaningfulOperatorToken(value)) return 1;
|
|
276
|
-
if (STRUCTURAL_PUNCTUATION_TOKEN_PATTERN.test(value)) return 0.05;
|
|
277
|
-
return 1;
|
|
278
|
-
}
|
|
279
|
-
function splitIdentifierToken(value, start) {
|
|
280
|
-
const parts = [];
|
|
281
|
-
const partPattern = new RegExp("[$_]+|(?:\\p{Lu}\\p{Mark}*)+(?=(?:\\p{Lu}\\p{Mark}*)(?:\\p{Ll}\\p{Mark}*)|\\p{N}|$)|(?:\\p{Lu}\\p{Mark}*)?(?:\\p{Ll}\\p{Mark}*)+|\\p{N}+|(?:\\p{Lu}\\p{Mark}*)+|(?:\\p{L}\\p{Mark}*)+", "gu");
|
|
282
|
-
for (const match of value.matchAll(partPattern)) {
|
|
283
|
-
const part = match[0];
|
|
284
|
-
const offset = match.index;
|
|
285
|
-
parts.push({ value: part, start: start + offset, end: start + offset + part.length });
|
|
286
|
-
}
|
|
287
|
-
return parts.length > 0 ? parts : [{ value, start, end: start + value.length }];
|
|
288
|
-
}
|
|
289
|
-
function wordEmphasisSimilarityTokenValues(tokens) {
|
|
290
|
-
const values = [];
|
|
291
|
-
for (const token of tokens) {
|
|
292
|
-
if (!isIdentifierToken(token.value)) {
|
|
293
|
-
values.push(token.value);
|
|
294
|
-
continue;
|
|
295
|
-
}
|
|
296
|
-
const parts = splitIdentifierToken(token.value, 0).map((part) => part.value).filter(isIdentifierSimilarityPart);
|
|
297
|
-
if (parts.length === 0) values.push(token.value.toLowerCase());
|
|
298
|
-
else values.push(...parts.map((part) => part.toLowerCase()));
|
|
299
|
-
}
|
|
300
|
-
return values;
|
|
301
|
-
}
|
|
302
|
-
function isIdentifierSimilarityPart(value) {
|
|
303
|
-
return !/^[$_]+$/.test(value);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// src/ui/word-diff/changed-line.ts
|
|
307
|
-
function indexedChangedLine(index, line) {
|
|
308
|
-
return { index, line };
|
|
309
|
-
}
|
|
310
|
-
function normalizedChangedContent(line) {
|
|
311
|
-
return line.normalizedContent ??= normalizeDiffContent(line.line.content);
|
|
312
|
-
}
|
|
313
|
-
function changedLineTokens(line) {
|
|
314
|
-
return line.tokens ??= wordEmphasisTokens(normalizedChangedContent(line));
|
|
315
|
-
}
|
|
316
|
-
function normalizeDiffContent(content) {
|
|
317
|
-
return escapeControlChars(expandPreviewTabs(content));
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
// src/ui/word-diff/alignment.ts
|
|
321
|
-
var ALIGNMENT_SCORE_EPSILON = 1e-9;
|
|
322
|
-
function sameAlignmentScore(a, b) {
|
|
323
|
-
return Math.abs(a - b) < ALIGNMENT_SCORE_EPSILON;
|
|
324
|
-
}
|
|
325
|
-
function suffixAlignedPairs(beforeLength, afterLength, scoreAt) {
|
|
326
|
-
const columns = afterLength + 1;
|
|
327
|
-
const dp = new Float64Array((beforeLength + 1) * columns);
|
|
328
|
-
for (let i2 = beforeLength - 1; i2 >= 0; i2--) {
|
|
329
|
-
const rowOffset = i2 * columns;
|
|
330
|
-
const nextRowOffset = rowOffset + columns;
|
|
331
|
-
for (let j2 = afterLength - 1; j2 >= 0; j2--) {
|
|
332
|
-
const pairScore = scoreAt(i2, j2);
|
|
333
|
-
const align = Number.isFinite(pairScore) ? dp[nextRowOffset + j2 + 1] + pairScore : pairScore;
|
|
334
|
-
dp[rowOffset + j2] = Math.max(align, dp[nextRowOffset + j2], dp[rowOffset + j2 + 1]);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
const pairs = [];
|
|
338
|
-
let i = 0;
|
|
339
|
-
let j = 0;
|
|
340
|
-
while (i < beforeLength && j < afterLength) {
|
|
341
|
-
const rowOffset = i * columns;
|
|
342
|
-
const nextRowOffset = rowOffset + columns;
|
|
343
|
-
const pairScore = scoreAt(i, j);
|
|
344
|
-
const align = Number.isFinite(pairScore) ? dp[nextRowOffset + j + 1] + pairScore : pairScore;
|
|
345
|
-
if (Number.isFinite(pairScore) && sameAlignmentScore(dp[rowOffset + j], align)) {
|
|
346
|
-
pairs.push([i, j]);
|
|
347
|
-
i++;
|
|
348
|
-
j++;
|
|
349
|
-
} else if (dp[nextRowOffset + j] >= dp[rowOffset + j + 1]) {
|
|
350
|
-
i++;
|
|
351
|
-
} else {
|
|
352
|
-
j++;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
return pairs;
|
|
356
|
-
}
|
|
357
|
-
function prefixAlignedPairs(beforeLength, afterLength, scoreAt) {
|
|
358
|
-
const columns = afterLength + 1;
|
|
359
|
-
const dp = new Float64Array((beforeLength + 1) * columns);
|
|
360
|
-
for (let i2 = 1; i2 <= beforeLength; i2++) {
|
|
361
|
-
const rowOffset = i2 * columns;
|
|
362
|
-
const previousRowOffset = rowOffset - columns;
|
|
363
|
-
for (let j2 = 1; j2 <= afterLength; j2++) {
|
|
364
|
-
const pairScore = scoreAt(i2 - 1, j2 - 1);
|
|
365
|
-
const pair = Number.isFinite(pairScore) ? dp[previousRowOffset + j2 - 1] + pairScore : pairScore;
|
|
366
|
-
dp[rowOffset + j2] = Math.max(dp[previousRowOffset + j2], dp[rowOffset + j2 - 1], pair);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
const pairs = [];
|
|
370
|
-
let i = beforeLength;
|
|
371
|
-
let j = afterLength;
|
|
372
|
-
while (i > 0 && j > 0) {
|
|
373
|
-
const rowOffset = i * columns;
|
|
374
|
-
const previousRowOffset = rowOffset - columns;
|
|
375
|
-
const pairScore = scoreAt(i - 1, j - 1);
|
|
376
|
-
const pair = Number.isFinite(pairScore) ? dp[previousRowOffset + j - 1] + pairScore : pairScore;
|
|
377
|
-
if (Number.isFinite(pairScore) && sameAlignmentScore(dp[rowOffset + j], pair)) {
|
|
378
|
-
pairs.push([i - 1, j - 1]);
|
|
379
|
-
i--;
|
|
380
|
-
j--;
|
|
381
|
-
} else if (dp[previousRowOffset + j] >= dp[rowOffset + j - 1]) {
|
|
382
|
-
i--;
|
|
383
|
-
} else {
|
|
384
|
-
j--;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
return pairs.reverse();
|
|
388
|
-
}
|
|
389
|
-
function suffixAlignmentScore(beforeLength, afterLength, scoreAt) {
|
|
390
|
-
let next = new Float64Array(afterLength + 1);
|
|
391
|
-
let current = new Float64Array(afterLength + 1);
|
|
392
|
-
for (let i = beforeLength - 1; i >= 0; i--) {
|
|
393
|
-
current[afterLength] = 0;
|
|
394
|
-
for (let j = afterLength - 1; j >= 0; j--) {
|
|
395
|
-
const pairScore = scoreAt(i, j);
|
|
396
|
-
const match = Number.isFinite(pairScore) ? numericAt(next, j + 1) + pairScore : pairScore;
|
|
397
|
-
current[j] = Math.max(match, numericAt(next, j), numericAt(current, j + 1));
|
|
398
|
-
}
|
|
399
|
-
[next, current] = [current, next];
|
|
400
|
-
}
|
|
401
|
-
return numericAt(next, 0);
|
|
402
|
-
}
|
|
403
|
-
function numericAt(values, index) {
|
|
404
|
-
const value = values[index];
|
|
405
|
-
if (value === void 0) throw new RangeError(`Missing alignment cell ${index}`);
|
|
406
|
-
return value;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// src/ui/word-diff/line-similarity.ts
|
|
410
|
-
var SIMILARITY_BIGRAM_PREFIX = "\0PI_SIM_BIGRAM\0";
|
|
411
|
-
var MAX_LINE_TOKEN_SIMILARITY_CELLS = 16384;
|
|
412
|
-
function changedLineSimilarityTokenValues(line) {
|
|
413
|
-
return line.similarityTokenValues ??= wordEmphasisSimilarityTokenValues(
|
|
414
|
-
changedLineTokens(line)
|
|
415
|
-
);
|
|
416
|
-
}
|
|
417
|
-
function changedLineSimilarityFeatureValues(line) {
|
|
418
|
-
return line.similarityFeatureValues ??= similarityFeatures(
|
|
419
|
-
changedLineSimilarityTokenValues(line)
|
|
420
|
-
);
|
|
421
|
-
}
|
|
422
|
-
function changedLineSimilarityDocuments(removed, added) {
|
|
423
|
-
const removedFeatures = removed.map(changedLineSimilarityFeatureValues);
|
|
424
|
-
const addedFeatures = added.map(changedLineSimilarityFeatureValues);
|
|
425
|
-
const documentCounts = /* @__PURE__ */ new Map();
|
|
426
|
-
countSimilarityDocuments(removedFeatures, documentCounts);
|
|
427
|
-
countSimilarityDocuments(addedFeatures, documentCounts);
|
|
428
|
-
return { removedFeatures, addedFeatures, documentCounts };
|
|
429
|
-
}
|
|
430
|
-
function countSimilarityDocuments(featureLists, documentCounts) {
|
|
431
|
-
for (const features of featureLists) {
|
|
432
|
-
for (const feature of new Set(features))
|
|
433
|
-
documentCounts.set(feature, (documentCounts.get(feature) ?? 0) + 1);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
function hasUniqueSharedSimilarityFeature(removed, added, documents) {
|
|
437
|
-
const addedFeatures = new Set(changedLineSimilarityFeatureValues(added));
|
|
438
|
-
for (const feature of new Set(changedLineSimilarityFeatureValues(removed))) {
|
|
439
|
-
if (!addedFeatures.has(feature)) continue;
|
|
440
|
-
if (documents.documentCounts.get(feature) === 2 && tokenWeight(feature) >= 1) return true;
|
|
441
|
-
}
|
|
442
|
-
return false;
|
|
443
|
-
}
|
|
444
|
-
function similarityFeatures(tokens) {
|
|
445
|
-
const features = [...tokens];
|
|
446
|
-
appendSimilarityShingles(
|
|
447
|
-
features,
|
|
448
|
-
tokens.filter(isSimilarityShingleToken),
|
|
449
|
-
2,
|
|
450
|
-
SIMILARITY_BIGRAM_PREFIX
|
|
451
|
-
);
|
|
452
|
-
return features;
|
|
453
|
-
}
|
|
454
|
-
function appendSimilarityShingles(features, tokens, size, prefix) {
|
|
455
|
-
for (let index = 0; index + size <= tokens.length; index++)
|
|
456
|
-
features.push(`${prefix}${tokens.slice(index, index + size).join("\0")}`);
|
|
457
|
-
}
|
|
458
|
-
function isSimilarityShingleToken(token) {
|
|
459
|
-
return wordEmphasisTokenWeight(token) >= 1;
|
|
460
|
-
}
|
|
461
|
-
function similarityTokenWeight(documents) {
|
|
462
|
-
const weights = /* @__PURE__ */ new Map();
|
|
463
|
-
const lineCount = documents.removedFeatures.length + documents.addedFeatures.length;
|
|
464
|
-
return (token) => {
|
|
465
|
-
const cached = weights.get(token);
|
|
466
|
-
if (cached !== void 0) return cached;
|
|
467
|
-
const documentCount = documents.documentCounts.get(token) ?? lineCount;
|
|
468
|
-
const rarity = Math.min(3, 1 + Math.log((lineCount + 1) / (documentCount + 1)));
|
|
469
|
-
const weight = tokenWeight(token) * rarity;
|
|
470
|
-
weights.set(token, weight);
|
|
471
|
-
return weight;
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
function fallbackLineSimilarity(removed, added, weight, removedWeight, addedWeight) {
|
|
475
|
-
return unorderedTokenSimilarity(
|
|
476
|
-
changedLineSimilarityFeatureValues(removed),
|
|
477
|
-
changedLineSimilarityFeatureValues(added),
|
|
478
|
-
weight,
|
|
479
|
-
removedWeight,
|
|
480
|
-
addedWeight
|
|
481
|
-
);
|
|
482
|
-
}
|
|
483
|
-
function tokenSimilarity(beforeTokens, afterTokens, weight = tokenWeight, minimumRelevantSimilarity = 0, beforeWeight, afterWeight) {
|
|
484
|
-
if (beforeTokens.length === 0 || afterTokens.length === 0)
|
|
485
|
-
return beforeTokens.length === afterTokens.length ? 1 : 0;
|
|
486
|
-
const bagSimilarity = unorderedTokenSimilarity(
|
|
487
|
-
beforeTokens,
|
|
488
|
-
afterTokens,
|
|
489
|
-
weight,
|
|
490
|
-
beforeWeight,
|
|
491
|
-
afterWeight
|
|
492
|
-
);
|
|
493
|
-
if (bagSimilarity < minimumRelevantSimilarity) return bagSimilarity;
|
|
494
|
-
const orderedSimilarity = orderedTokenSimilarity(
|
|
495
|
-
beforeTokens,
|
|
496
|
-
afterTokens,
|
|
497
|
-
weight,
|
|
498
|
-
beforeWeight ?? similarityTokenListWeight(beforeTokens, weight),
|
|
499
|
-
afterWeight ?? similarityTokenListWeight(afterTokens, weight)
|
|
500
|
-
);
|
|
501
|
-
if (orderedSimilarity === void 0) return bagSimilarity;
|
|
502
|
-
return Math.max(
|
|
503
|
-
orderedSimilarity,
|
|
504
|
-
bagSimilarity * 0.8,
|
|
505
|
-
orderedSimilarity * 0.75 + bagSimilarity * 0.25
|
|
506
|
-
);
|
|
507
|
-
}
|
|
508
|
-
function unorderedTokenSimilarity(beforeTokens, afterTokens, weight, beforeWeight = similarityTokenListWeight(beforeTokens, weight), afterWeight = similarityTokenListWeight(afterTokens, weight)) {
|
|
509
|
-
const remaining = /* @__PURE__ */ new Map();
|
|
510
|
-
for (const token of beforeTokens) remaining.set(token, (remaining.get(token) ?? 0) + 1);
|
|
511
|
-
let sharedWeight = 0;
|
|
512
|
-
for (const token of afterTokens) {
|
|
513
|
-
const count = remaining.get(token) ?? 0;
|
|
514
|
-
if (count === 0) continue;
|
|
515
|
-
sharedWeight += weight(token);
|
|
516
|
-
if (count === 1) remaining.delete(token);
|
|
517
|
-
else remaining.set(token, count - 1);
|
|
518
|
-
}
|
|
519
|
-
return 2 * sharedWeight / (beforeWeight + afterWeight);
|
|
520
|
-
}
|
|
521
|
-
function orderedTokenSimilarity(beforeTokens, afterTokens, weight, beforeWeight, afterWeight) {
|
|
522
|
-
if (beforeTokens.length * afterTokens.length > MAX_LINE_TOKEN_SIMILARITY_CELLS) return void 0;
|
|
523
|
-
const score = suffixAlignmentScore(
|
|
524
|
-
beforeTokens.length,
|
|
525
|
-
afterTokens.length,
|
|
526
|
-
(beforeIndex, afterIndex) => {
|
|
527
|
-
const beforeToken = stringAt(beforeTokens, beforeIndex);
|
|
528
|
-
return beforeToken === stringAt(afterTokens, afterIndex) ? weight(beforeToken) : Number.NEGATIVE_INFINITY;
|
|
529
|
-
}
|
|
530
|
-
);
|
|
531
|
-
return 2 * score / (beforeWeight + afterWeight);
|
|
532
|
-
}
|
|
533
|
-
function similarityTokenListWeight(tokens, weight) {
|
|
534
|
-
return tokens.reduce((total, token) => total + weight(token), 0);
|
|
535
|
-
}
|
|
536
|
-
function tokenWeight(token) {
|
|
537
|
-
if (token.startsWith(SIMILARITY_BIGRAM_PREFIX)) return 1.15;
|
|
538
|
-
return wordEmphasisTokenWeight(token);
|
|
539
|
-
}
|
|
540
|
-
function stringAt(values, index) {
|
|
541
|
-
const value = values[index];
|
|
542
|
-
if (value === void 0) throw new RangeError(`Missing similarity token ${index}`);
|
|
543
|
-
return value;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
// src/ui/word-diff/sparse-line-matching.ts
|
|
547
|
-
var MAX_POSITIONAL_FALLBACK_AMBIGUITY_CELLS = 1e4;
|
|
548
|
-
var MAX_SPARSE_FEATURE_DOCUMENTS = 6;
|
|
549
|
-
var MAX_SPARSE_FEATURE_DOCUMENTS_PER_SIDE = 3;
|
|
550
|
-
var MAX_SPARSE_CANDIDATES_PER_LINE = 8;
|
|
551
|
-
var MIN_SPARSE_RARE_FEATURE_COUNT = 2;
|
|
552
|
-
var MIN_SPARSE_EVIDENCE_MARGIN = 1;
|
|
553
|
-
var MIN_SPARSE_EVIDENCE_RATIO = 0.9;
|
|
554
|
-
function matchChangedLinesSparse(removed, added, policy) {
|
|
555
|
-
const similarityDocuments = changedLineSimilarityDocuments(removed, added);
|
|
556
|
-
const tokenWeight2 = similarityTokenWeight(similarityDocuments);
|
|
557
|
-
const removedWeights = [];
|
|
558
|
-
const addedWeights = [];
|
|
559
|
-
const canCheckAmbiguity = removed.length * added.length <= MAX_POSITIONAL_FALLBACK_AMBIGUITY_CELLS;
|
|
560
|
-
const scoreCache = canCheckAmbiguity ? /* @__PURE__ */ new Map() : void 0;
|
|
561
|
-
const scoreAt = (removedPosition, addedPosition) => {
|
|
562
|
-
const key = removedPosition * added.length + addedPosition;
|
|
563
|
-
const cached = scoreCache?.get(key);
|
|
564
|
-
if (cached !== void 0) return cached;
|
|
565
|
-
const removedFeatures = similarityDocuments.removedFeatures[removedPosition];
|
|
566
|
-
const addedFeatures = similarityDocuments.addedFeatures[addedPosition];
|
|
567
|
-
if (removedFeatures === void 0 || addedFeatures === void 0)
|
|
568
|
-
throw new RangeError(`Missing similarity features ${removedPosition}:${addedPosition}`);
|
|
569
|
-
const removedWeight = removedWeights[removedPosition] ??= similarityTokenListWeight(
|
|
570
|
-
removedFeatures,
|
|
571
|
-
tokenWeight2
|
|
572
|
-
);
|
|
573
|
-
const addedWeight = addedWeights[addedPosition] ??= similarityTokenListWeight(
|
|
574
|
-
addedFeatures,
|
|
575
|
-
tokenWeight2
|
|
576
|
-
);
|
|
577
|
-
const score = fallbackLineSimilarity(
|
|
578
|
-
changedLineAt(removed, removedPosition),
|
|
579
|
-
changedLineAt(added, addedPosition),
|
|
580
|
-
tokenWeight2,
|
|
581
|
-
removedWeight,
|
|
582
|
-
addedWeight
|
|
583
|
-
);
|
|
584
|
-
scoreCache?.set(key, score);
|
|
585
|
-
return score;
|
|
586
|
-
};
|
|
587
|
-
const sparseCandidates = sparseChangedLinePairCandidates(similarityDocuments, tokenWeight2);
|
|
588
|
-
const pairs = sparseChangedLineAnchors(removed, added, sparseCandidates, scoreAt, policy);
|
|
589
|
-
const positions = changedLinePositions(removed, added);
|
|
590
|
-
const usedRemoved = /* @__PURE__ */ new Set();
|
|
591
|
-
const usedAdded = /* @__PURE__ */ new Set();
|
|
592
|
-
for (const pair of pairs) {
|
|
593
|
-
const removedPosition = positions.removed.get(pair.removedIndex);
|
|
594
|
-
const addedPosition = positions.added.get(pair.addedIndex);
|
|
595
|
-
if (removedPosition !== void 0) usedRemoved.add(removedPosition);
|
|
596
|
-
if (addedPosition !== void 0) usedAdded.add(addedPosition);
|
|
597
|
-
}
|
|
598
|
-
for (let index = 0; index < Math.min(removed.length, added.length); index++) {
|
|
599
|
-
if (usedRemoved.has(index) || usedAdded.has(index)) continue;
|
|
600
|
-
const score = scoreAt(index, index);
|
|
601
|
-
if (score < policy.minPositionalFallbackPairScore) continue;
|
|
602
|
-
const removedLine = changedLineAt(removed, index);
|
|
603
|
-
const addedLine = changedLineAt(added, index);
|
|
604
|
-
if (hasUniqueSharedSimilarityFeature(removedLine, addedLine, similarityDocuments)) {
|
|
605
|
-
pairs.push({
|
|
606
|
-
removedIndex: removedLine.index,
|
|
607
|
-
addedIndex: addedLine.index,
|
|
608
|
-
confidence: policy.linePairConfidence(score, 0)
|
|
609
|
-
});
|
|
610
|
-
usedRemoved.add(index);
|
|
611
|
-
usedAdded.add(index);
|
|
612
|
-
continue;
|
|
613
|
-
}
|
|
614
|
-
if (!canCheckAmbiguity) continue;
|
|
615
|
-
const competingScore = policy.competingChangedLineScoreAt(
|
|
616
|
-
removed.length,
|
|
617
|
-
added.length,
|
|
618
|
-
index,
|
|
619
|
-
index,
|
|
620
|
-
scoreAt
|
|
621
|
-
);
|
|
622
|
-
if (policy.isAmbiguousChangedLinePairScore(score, competingScore)) continue;
|
|
623
|
-
pairs.push({
|
|
624
|
-
removedIndex: removedLine.index,
|
|
625
|
-
addedIndex: addedLine.index,
|
|
626
|
-
confidence: policy.linePairConfidence(score, competingScore)
|
|
627
|
-
});
|
|
628
|
-
usedRemoved.add(index);
|
|
629
|
-
usedAdded.add(index);
|
|
630
|
-
}
|
|
631
|
-
return pairs.sort(
|
|
632
|
-
(a, b) => (positions.removed.get(a.removedIndex) ?? 0) - (positions.removed.get(b.removedIndex) ?? 0)
|
|
633
|
-
);
|
|
634
|
-
}
|
|
635
|
-
function sparseChangedLinePairCandidates(documents, tokenWeight2) {
|
|
636
|
-
const removedPositions = similarityFeaturePositions(documents.removedFeatures);
|
|
637
|
-
const addedPositions = similarityFeaturePositions(documents.addedFeatures);
|
|
638
|
-
const candidates = /* @__PURE__ */ new Map();
|
|
639
|
-
const addedLength = documents.addedFeatures.length;
|
|
640
|
-
for (const [feature, featureRemovedPositions] of removedPositions) {
|
|
641
|
-
const featureAddedPositions = addedPositions.get(feature);
|
|
642
|
-
if (!featureAddedPositions) continue;
|
|
643
|
-
const documentCount = documents.documentCounts.get(feature) ?? Number.POSITIVE_INFINITY;
|
|
644
|
-
if (documentCount > MAX_SPARSE_FEATURE_DOCUMENTS || featureRemovedPositions.length > MAX_SPARSE_FEATURE_DOCUMENTS_PER_SIDE || featureAddedPositions.length > MAX_SPARSE_FEATURE_DOCUMENTS_PER_SIDE)
|
|
645
|
-
continue;
|
|
646
|
-
const weight = tokenWeight2(feature);
|
|
647
|
-
if (weight < 1) continue;
|
|
648
|
-
const uniqueFeature = documentCount === 2 && featureRemovedPositions.length === 1 && featureAddedPositions.length === 1;
|
|
649
|
-
for (const removedPosition of featureRemovedPositions) {
|
|
650
|
-
for (const addedPosition of featureAddedPositions) {
|
|
651
|
-
const key = removedPosition * addedLength + addedPosition;
|
|
652
|
-
const candidate = candidates.get(key);
|
|
653
|
-
if (candidate) {
|
|
654
|
-
candidate.evidence += weight;
|
|
655
|
-
candidate.sharedFeatureCount++;
|
|
656
|
-
candidate.hasUniqueFeature ||= uniqueFeature;
|
|
657
|
-
} else {
|
|
658
|
-
candidates.set(key, {
|
|
659
|
-
removedPosition,
|
|
660
|
-
addedPosition,
|
|
661
|
-
evidence: weight,
|
|
662
|
-
sharedFeatureCount: 1,
|
|
663
|
-
hasUniqueFeature: uniqueFeature,
|
|
664
|
-
competingEvidence: 0
|
|
665
|
-
});
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
const candidateList = [...candidates.values()];
|
|
671
|
-
addCompetingSparseEvidence(candidateList);
|
|
672
|
-
return boundedSparseChangedLinePairCandidates(candidateList);
|
|
673
|
-
}
|
|
674
|
-
function similarityFeaturePositions(featureLists) {
|
|
675
|
-
const positions = /* @__PURE__ */ new Map();
|
|
676
|
-
for (let position = 0; position < featureLists.length; position++) {
|
|
677
|
-
const features = featureLists[position];
|
|
678
|
-
if (!features) continue;
|
|
679
|
-
for (const feature of new Set(features)) {
|
|
680
|
-
const featurePositions = positions.get(feature);
|
|
681
|
-
if (featurePositions) featurePositions.push(position);
|
|
682
|
-
else positions.set(feature, [position]);
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
return positions;
|
|
686
|
-
}
|
|
687
|
-
function addCompetingSparseEvidence(candidates) {
|
|
688
|
-
const removedEvidence = topTwoCandidateValues(
|
|
689
|
-
candidates,
|
|
690
|
-
(candidate) => candidate.removedPosition,
|
|
691
|
-
(candidate) => candidate.evidence
|
|
692
|
-
);
|
|
693
|
-
const addedEvidence = topTwoCandidateValues(
|
|
694
|
-
candidates,
|
|
695
|
-
(candidate) => candidate.addedPosition,
|
|
696
|
-
(candidate) => candidate.evidence
|
|
697
|
-
);
|
|
698
|
-
for (const candidate of candidates) {
|
|
699
|
-
candidate.competingEvidence = Math.max(
|
|
700
|
-
competingCandidateValue(removedEvidence.get(candidate.removedPosition), candidate.evidence),
|
|
701
|
-
competingCandidateValue(addedEvidence.get(candidate.addedPosition), candidate.evidence)
|
|
702
|
-
);
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
function topTwoCandidateValues(candidates, position, value) {
|
|
706
|
-
const values = /* @__PURE__ */ new Map();
|
|
707
|
-
for (const candidate of candidates) {
|
|
708
|
-
const current = values.get(position(candidate)) ?? { best: 0, second: 0 };
|
|
709
|
-
const candidateValue = value(candidate);
|
|
710
|
-
if (candidateValue >= current.best) {
|
|
711
|
-
current.second = current.best;
|
|
712
|
-
current.best = candidateValue;
|
|
713
|
-
} else if (candidateValue > current.second) current.second = candidateValue;
|
|
714
|
-
values.set(position(candidate), current);
|
|
715
|
-
}
|
|
716
|
-
return values;
|
|
717
|
-
}
|
|
718
|
-
function competingCandidateValue(values, candidateValue) {
|
|
719
|
-
if (!values) return 0;
|
|
720
|
-
return candidateValue === values.best ? values.second : values.best;
|
|
721
|
-
}
|
|
722
|
-
function boundedSparseChangedLinePairCandidates(candidates) {
|
|
723
|
-
const byRemoved = /* @__PURE__ */ new Map();
|
|
724
|
-
const byAdded = /* @__PURE__ */ new Map();
|
|
725
|
-
for (const candidate of candidates) {
|
|
726
|
-
appendSparseCandidate(byRemoved, candidate.removedPosition, candidate);
|
|
727
|
-
appendSparseCandidate(byAdded, candidate.addedPosition, candidate);
|
|
728
|
-
}
|
|
729
|
-
const selectedByRemoved = topSparseCandidates(byRemoved);
|
|
730
|
-
const selectedByAdded = topSparseCandidates(byAdded);
|
|
731
|
-
return candidates.filter(
|
|
732
|
-
(candidate) => selectedByRemoved.has(candidate) && selectedByAdded.has(candidate)
|
|
733
|
-
);
|
|
734
|
-
}
|
|
735
|
-
function appendSparseCandidate(candidates, position, candidate) {
|
|
736
|
-
const atPosition = candidates.get(position);
|
|
737
|
-
if (atPosition) atPosition.push(candidate);
|
|
738
|
-
else candidates.set(position, [candidate]);
|
|
739
|
-
}
|
|
740
|
-
function topSparseCandidates(candidates) {
|
|
741
|
-
const selected = /* @__PURE__ */ new Set();
|
|
742
|
-
for (const atPosition of candidates.values()) {
|
|
743
|
-
atPosition.sort(compareSparseCandidates);
|
|
744
|
-
for (const candidate of atPosition.slice(0, MAX_SPARSE_CANDIDATES_PER_LINE))
|
|
745
|
-
selected.add(candidate);
|
|
746
|
-
}
|
|
747
|
-
return selected;
|
|
748
|
-
}
|
|
749
|
-
function compareSparseCandidates(a, b) {
|
|
750
|
-
return Number(b.hasUniqueFeature) - Number(a.hasUniqueFeature) || b.evidence - a.evidence || b.sharedFeatureCount - a.sharedFeatureCount || Math.abs(a.removedPosition - a.addedPosition) - Math.abs(b.removedPosition - b.addedPosition) || a.removedPosition - b.removedPosition || a.addedPosition - b.addedPosition;
|
|
751
|
-
}
|
|
752
|
-
function sparseChangedLineAnchors(removed, added, sparseCandidates, scoreAt, policy) {
|
|
753
|
-
const scoredCandidates = sparseCandidates.map((candidate) => ({
|
|
754
|
-
...candidate,
|
|
755
|
-
score: scoreAt(candidate.removedPosition, candidate.addedPosition)
|
|
756
|
-
})).sort((a, b) => b.score - a.score || compareSparseCandidates(a, b));
|
|
757
|
-
const removedScores = topTwoCandidateValues(
|
|
758
|
-
scoredCandidates,
|
|
759
|
-
(candidate) => candidate.removedPosition,
|
|
760
|
-
(candidate) => candidate.score
|
|
761
|
-
);
|
|
762
|
-
const addedScores = topTwoCandidateValues(
|
|
763
|
-
scoredCandidates,
|
|
764
|
-
(candidate) => candidate.addedPosition,
|
|
765
|
-
(candidate) => candidate.score
|
|
766
|
-
);
|
|
767
|
-
const usedRemoved = /* @__PURE__ */ new Set();
|
|
768
|
-
const usedAdded = /* @__PURE__ */ new Set();
|
|
769
|
-
const pairs = [];
|
|
770
|
-
for (const candidate of scoredCandidates) {
|
|
771
|
-
if (candidate.score < policy.minChangedLinePairScore) continue;
|
|
772
|
-
if (usedRemoved.has(candidate.removedPosition) || usedAdded.has(candidate.addedPosition))
|
|
773
|
-
continue;
|
|
774
|
-
if (!hasStrongSparseEvidence(candidate)) continue;
|
|
775
|
-
const competingScore = Math.max(
|
|
776
|
-
competingCandidateValue(removedScores.get(candidate.removedPosition), candidate.score),
|
|
777
|
-
competingCandidateValue(addedScores.get(candidate.addedPosition), candidate.score),
|
|
778
|
-
sparsePositionalCompetingScore(candidate, removed.length, added.length, scoreAt)
|
|
779
|
-
);
|
|
780
|
-
if (!policy.isReciprocalBestChangedLinePair(candidate.score, competingScore)) continue;
|
|
781
|
-
usedRemoved.add(candidate.removedPosition);
|
|
782
|
-
usedAdded.add(candidate.addedPosition);
|
|
783
|
-
pairs.push({
|
|
784
|
-
removedIndex: changedLineAt(removed, candidate.removedPosition).index,
|
|
785
|
-
addedIndex: changedLineAt(added, candidate.addedPosition).index,
|
|
786
|
-
confidence: policy.linePairConfidence(candidate.score, competingScore)
|
|
787
|
-
});
|
|
788
|
-
}
|
|
789
|
-
return pairs;
|
|
790
|
-
}
|
|
791
|
-
function sparsePositionalCompetingScore(candidate, removedLength, addedLength, scoreAt) {
|
|
792
|
-
let competingScore = 0;
|
|
793
|
-
if (candidate.removedPosition < addedLength && candidate.addedPosition !== candidate.removedPosition)
|
|
794
|
-
competingScore = scoreAt(candidate.removedPosition, candidate.removedPosition);
|
|
795
|
-
if (candidate.addedPosition < removedLength && candidate.removedPosition !== candidate.addedPosition)
|
|
796
|
-
competingScore = Math.max(
|
|
797
|
-
competingScore,
|
|
798
|
-
scoreAt(candidate.addedPosition, candidate.addedPosition)
|
|
799
|
-
);
|
|
800
|
-
return competingScore;
|
|
801
|
-
}
|
|
802
|
-
function hasStrongSparseEvidence(candidate) {
|
|
803
|
-
if (!candidate.hasUniqueFeature && candidate.sharedFeatureCount < MIN_SPARSE_RARE_FEATURE_COUNT)
|
|
804
|
-
return false;
|
|
805
|
-
return candidate.evidence - candidate.competingEvidence > MIN_SPARSE_EVIDENCE_MARGIN && candidate.competingEvidence < candidate.evidence * MIN_SPARSE_EVIDENCE_RATIO;
|
|
806
|
-
}
|
|
807
|
-
function changedLinePositions(removed, added) {
|
|
808
|
-
return {
|
|
809
|
-
removed: new Map(removed.map((line, index) => [line.index, index])),
|
|
810
|
-
added: new Map(added.map((line, index) => [line.index, index]))
|
|
811
|
-
};
|
|
812
|
-
}
|
|
813
|
-
function changedLineAt(lines, index) {
|
|
814
|
-
const line = lines[index];
|
|
815
|
-
if (line === void 0) throw new RangeError(`Missing changed line ${index}`);
|
|
816
|
-
return line;
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
// src/ui/word-diff/line-matching.ts
|
|
820
|
-
function matchChangedLines(removed, added) {
|
|
821
|
-
if (removed.length === 0 || added.length === 0) return [];
|
|
822
|
-
if (removed.length * added.length > MAX_CHANGED_LINE_PAIR_CELLS)
|
|
823
|
-
return matchChangedLinesSparse(removed, added, SPARSE_LINE_MATCHING_POLICY);
|
|
824
|
-
const similarityDocuments = changedLineSimilarityDocuments(removed, added);
|
|
825
|
-
const tokenWeight2 = similarityTokenWeight(similarityDocuments);
|
|
826
|
-
const { removedFeatures, addedFeatures } = similarityDocuments;
|
|
827
|
-
const removedWeights = removedFeatures.map(
|
|
828
|
-
(tokens) => similarityTokenListWeight(tokens, tokenWeight2)
|
|
829
|
-
);
|
|
830
|
-
const addedWeights = addedFeatures.map(
|
|
831
|
-
(tokens) => similarityTokenListWeight(tokens, tokenWeight2)
|
|
832
|
-
);
|
|
833
|
-
const scores = removedFeatures.map(
|
|
834
|
-
(beforeTokens, removedPosition) => addedFeatures.map(
|
|
835
|
-
(afterTokens, addedPosition) => tokenSimilarity(
|
|
836
|
-
beforeTokens,
|
|
837
|
-
afterTokens,
|
|
838
|
-
tokenWeight2,
|
|
839
|
-
MIN_POSITIONAL_FALLBACK_PAIR_SCORE,
|
|
840
|
-
removedWeights[removedPosition],
|
|
841
|
-
addedWeights[addedPosition]
|
|
842
|
-
)
|
|
843
|
-
)
|
|
844
|
-
);
|
|
845
|
-
const similarPairs = prefixAlignedPairs(
|
|
846
|
-
removed.length,
|
|
847
|
-
added.length,
|
|
848
|
-
(removedPosition, addedPosition) => {
|
|
849
|
-
const score = scores[removedPosition]?.[addedPosition] ?? 0;
|
|
850
|
-
return score >= MIN_CHANGED_LINE_PAIR_SCORE ? score + 0.01 : Number.NEGATIVE_INFINITY;
|
|
851
|
-
}
|
|
852
|
-
);
|
|
853
|
-
if (similarPairs.length === 0 && removed.length === 1 && added.length === 1)
|
|
854
|
-
return [
|
|
855
|
-
{
|
|
856
|
-
removedIndex: changedLineAt2(removed, 0).index,
|
|
857
|
-
addedIndex: changedLineAt2(added, 0).index,
|
|
858
|
-
confidence: "medium"
|
|
859
|
-
}
|
|
860
|
-
];
|
|
861
|
-
const positions = changedLinePositions2(removed, added);
|
|
862
|
-
const confidentPairs = confidentChangedLinePairs(
|
|
863
|
-
positions,
|
|
864
|
-
scores,
|
|
865
|
-
addPositionalFallbackPairs(removed, added, scores, similarPairs)
|
|
866
|
-
);
|
|
867
|
-
return addCrossingPairs(removed, added, scores, positions, confidentPairs);
|
|
868
|
-
}
|
|
869
|
-
var MIN_CHANGED_LINE_PAIR_SCORE = 0.45;
|
|
870
|
-
var MIN_POSITIONAL_FALLBACK_PAIR_SCORE = 0.28;
|
|
871
|
-
var CHANGED_LINE_PAIR_AMBIGUITY_MARGIN = 0.06;
|
|
872
|
-
var CHANGED_LINE_PAIR_AMBIGUITY_RATIO = 0.92;
|
|
873
|
-
var MIN_HIGH_CONFIDENCE_CROSSING_PAIR_SCORE = 0.72;
|
|
874
|
-
var HIGH_CONFIDENCE_CROSSING_PAIR_MARGIN = 0.12;
|
|
875
|
-
var HIGH_CONFIDENCE_CROSSING_PAIR_RATIO = 0.85;
|
|
876
|
-
var MAX_CHANGED_LINE_PAIR_CELLS = 1024;
|
|
877
|
-
var SPARSE_LINE_MATCHING_POLICY = {
|
|
878
|
-
minPositionalFallbackPairScore: MIN_POSITIONAL_FALLBACK_PAIR_SCORE,
|
|
879
|
-
minChangedLinePairScore: MIN_CHANGED_LINE_PAIR_SCORE,
|
|
880
|
-
competingChangedLineScoreAt,
|
|
881
|
-
isAmbiguousChangedLinePairScore,
|
|
882
|
-
isReciprocalBestChangedLinePair,
|
|
883
|
-
linePairConfidence
|
|
884
|
-
};
|
|
885
|
-
function changedLinePositions2(removed, added) {
|
|
886
|
-
return {
|
|
887
|
-
removed: new Map(removed.map((line, index) => [line.index, index])),
|
|
888
|
-
added: new Map(added.map((line, index) => [line.index, index]))
|
|
889
|
-
};
|
|
890
|
-
}
|
|
891
|
-
function confidentChangedLinePairs(positions, scores, pairs) {
|
|
892
|
-
const confidentPairs = [];
|
|
893
|
-
for (const [removedIndex, addedIndex] of pairs) {
|
|
894
|
-
const removedPosition = positions.removed.get(removedIndex);
|
|
895
|
-
const addedPosition = positions.added.get(addedIndex);
|
|
896
|
-
if (removedPosition === void 0 || addedPosition === void 0) continue;
|
|
897
|
-
const score = scores[removedPosition]?.[addedPosition] ?? 0;
|
|
898
|
-
const competingScore = competingChangedLineScore(scores, removedPosition, addedPosition);
|
|
899
|
-
if (isAmbiguousChangedLinePairScore(score, competingScore)) continue;
|
|
900
|
-
confidentPairs.push({
|
|
901
|
-
removedIndex,
|
|
902
|
-
addedIndex,
|
|
903
|
-
confidence: linePairConfidence(score, competingScore)
|
|
904
|
-
});
|
|
905
|
-
}
|
|
906
|
-
return confidentPairs;
|
|
907
|
-
}
|
|
908
|
-
function competingChangedLineScore(scores, removedPosition, addedPosition, usedRemoved, usedAdded) {
|
|
909
|
-
return competingChangedLineScoreAt(
|
|
910
|
-
scores.length,
|
|
911
|
-
scores[removedPosition]?.length ?? 0,
|
|
912
|
-
removedPosition,
|
|
913
|
-
addedPosition,
|
|
914
|
-
(candidateRemovedPosition, candidateAddedPosition) => scores[candidateRemovedPosition]?.[candidateAddedPosition] ?? 0,
|
|
915
|
-
usedRemoved,
|
|
916
|
-
usedAdded
|
|
917
|
-
);
|
|
918
|
-
}
|
|
919
|
-
function competingChangedLineScoreAt(removedLength, addedLength, removedPosition, addedPosition, scoreAt, usedRemoved, usedAdded) {
|
|
920
|
-
let competingScore = 0;
|
|
921
|
-
for (let candidateAddedPosition = 0; candidateAddedPosition < addedLength; candidateAddedPosition++) {
|
|
922
|
-
if (candidateAddedPosition === addedPosition || usedAdded?.has(candidateAddedPosition))
|
|
923
|
-
continue;
|
|
924
|
-
competingScore = Math.max(competingScore, scoreAt(removedPosition, candidateAddedPosition));
|
|
925
|
-
}
|
|
926
|
-
for (let candidateRemovedPosition = 0; candidateRemovedPosition < removedLength; candidateRemovedPosition++) {
|
|
927
|
-
if (candidateRemovedPosition === removedPosition || usedRemoved?.has(candidateRemovedPosition))
|
|
928
|
-
continue;
|
|
929
|
-
competingScore = Math.max(competingScore, scoreAt(candidateRemovedPosition, addedPosition));
|
|
930
|
-
}
|
|
931
|
-
return competingScore;
|
|
932
|
-
}
|
|
933
|
-
function isAmbiguousChangedLinePairScore(score, competingScore) {
|
|
934
|
-
return competingScore >= MIN_POSITIONAL_FALLBACK_PAIR_SCORE && (score - competingScore <= CHANGED_LINE_PAIR_AMBIGUITY_MARGIN || competingScore >= score * CHANGED_LINE_PAIR_AMBIGUITY_RATIO);
|
|
935
|
-
}
|
|
936
|
-
function isReciprocalBestChangedLinePair(score, competingScore) {
|
|
937
|
-
return score > competingScore && !isAmbiguousChangedLinePairScore(score, competingScore);
|
|
938
|
-
}
|
|
939
|
-
function linePairConfidence(score, competingScore) {
|
|
940
|
-
if (score >= MIN_HIGH_CONFIDENCE_CROSSING_PAIR_SCORE && score - competingScore >= HIGH_CONFIDENCE_CROSSING_PAIR_MARGIN && competingScore <= score * HIGH_CONFIDENCE_CROSSING_PAIR_RATIO)
|
|
941
|
-
return "high";
|
|
942
|
-
return "medium";
|
|
943
|
-
}
|
|
944
|
-
function addCrossingPairs(removed, added, scores, positions, pairs) {
|
|
945
|
-
const usedRemoved = /* @__PURE__ */ new Set();
|
|
946
|
-
const usedAdded = /* @__PURE__ */ new Set();
|
|
947
|
-
for (const pair of pairs) {
|
|
948
|
-
const removedPosition = positions.removed.get(pair.removedIndex);
|
|
949
|
-
const addedPosition = positions.added.get(pair.addedIndex);
|
|
950
|
-
if (removedPosition !== void 0) usedRemoved.add(removedPosition);
|
|
951
|
-
if (addedPosition !== void 0) usedAdded.add(addedPosition);
|
|
952
|
-
}
|
|
953
|
-
const candidates = [];
|
|
954
|
-
for (let removedPosition = 0; removedPosition < removed.length; removedPosition++) {
|
|
955
|
-
if (usedRemoved.has(removedPosition)) continue;
|
|
956
|
-
for (let addedPosition = 0; addedPosition < added.length; addedPosition++) {
|
|
957
|
-
if (usedAdded.has(addedPosition)) continue;
|
|
958
|
-
const score = scores[removedPosition]?.[addedPosition] ?? 0;
|
|
959
|
-
if (score >= MIN_CHANGED_LINE_PAIR_SCORE)
|
|
960
|
-
candidates.push({ removedPosition, addedPosition, score });
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
candidates.sort((a, b) => b.score - a.score);
|
|
964
|
-
const competingScores = changedLineCompetingScores(scores);
|
|
965
|
-
const out = [...pairs];
|
|
966
|
-
for (const candidate of candidates) {
|
|
967
|
-
if (usedRemoved.has(candidate.removedPosition) || usedAdded.has(candidate.addedPosition))
|
|
968
|
-
continue;
|
|
969
|
-
let confidence;
|
|
970
|
-
if (candidate.score >= MIN_HIGH_CONFIDENCE_CROSSING_PAIR_SCORE) {
|
|
971
|
-
const availableCompetingScore = competingChangedLineScore(
|
|
972
|
-
scores,
|
|
973
|
-
candidate.removedPosition,
|
|
974
|
-
candidate.addedPosition,
|
|
975
|
-
usedRemoved,
|
|
976
|
-
usedAdded
|
|
977
|
-
);
|
|
978
|
-
if (linePairConfidence(candidate.score, availableCompetingScore) === "high")
|
|
979
|
-
confidence = "high";
|
|
980
|
-
}
|
|
981
|
-
confidence ??= reciprocalCrossingPairConfidence(competingScores, candidate);
|
|
982
|
-
if (!confidence) continue;
|
|
983
|
-
usedRemoved.add(candidate.removedPosition);
|
|
984
|
-
usedAdded.add(candidate.addedPosition);
|
|
985
|
-
out.push({
|
|
986
|
-
removedIndex: changedLineAt2(removed, candidate.removedPosition).index,
|
|
987
|
-
addedIndex: changedLineAt2(added, candidate.addedPosition).index,
|
|
988
|
-
confidence
|
|
989
|
-
});
|
|
990
|
-
}
|
|
991
|
-
return out.sort(
|
|
992
|
-
(a, b) => (positions.removed.get(a.removedIndex) ?? 0) - (positions.removed.get(b.removedIndex) ?? 0)
|
|
993
|
-
);
|
|
994
|
-
}
|
|
995
|
-
function changedLineCompetingScores(scores) {
|
|
996
|
-
const removed = [];
|
|
997
|
-
const added = [];
|
|
998
|
-
for (let removedPosition = 0; removedPosition < scores.length; removedPosition++) {
|
|
999
|
-
const removedScores = scores[removedPosition] ?? [];
|
|
1000
|
-
for (let addedPosition = 0; addedPosition < removedScores.length; addedPosition++) {
|
|
1001
|
-
const score = removedScores[addedPosition] ?? 0;
|
|
1002
|
-
addCandidateValue(removed, removedPosition, score);
|
|
1003
|
-
addCandidateValue(added, addedPosition, score);
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
return { removed, added };
|
|
1007
|
-
}
|
|
1008
|
-
function addCandidateValue(values, position, value) {
|
|
1009
|
-
const current = values[position] ?? { best: 0, second: 0 };
|
|
1010
|
-
if (value >= current.best) {
|
|
1011
|
-
current.second = current.best;
|
|
1012
|
-
current.best = value;
|
|
1013
|
-
} else if (value > current.second) current.second = value;
|
|
1014
|
-
values[position] = current;
|
|
1015
|
-
}
|
|
1016
|
-
function reciprocalCrossingPairConfidence(competingScores, candidate) {
|
|
1017
|
-
const competingScore = Math.max(
|
|
1018
|
-
competingCandidateValue(competingScores.removed[candidate.removedPosition], candidate.score),
|
|
1019
|
-
competingCandidateValue(competingScores.added[candidate.addedPosition], candidate.score)
|
|
1020
|
-
);
|
|
1021
|
-
if (!isReciprocalBestChangedLinePair(candidate.score, competingScore)) return void 0;
|
|
1022
|
-
return linePairConfidence(candidate.score, competingScore);
|
|
1023
|
-
}
|
|
1024
|
-
function addPositionalFallbackPairs(removed, added, scores, similarPairs) {
|
|
1025
|
-
const pairs = [];
|
|
1026
|
-
let removedCursor = 0;
|
|
1027
|
-
let addedCursor = 0;
|
|
1028
|
-
for (const [removedPosition, addedPosition] of similarPairs) {
|
|
1029
|
-
pairs.push(
|
|
1030
|
-
...positionPairs(
|
|
1031
|
-
removed,
|
|
1032
|
-
added,
|
|
1033
|
-
scores,
|
|
1034
|
-
removedCursor,
|
|
1035
|
-
removedPosition,
|
|
1036
|
-
addedCursor,
|
|
1037
|
-
addedPosition
|
|
1038
|
-
)
|
|
1039
|
-
);
|
|
1040
|
-
pairs.push([
|
|
1041
|
-
changedLineAt2(removed, removedPosition).index,
|
|
1042
|
-
changedLineAt2(added, addedPosition).index
|
|
1043
|
-
]);
|
|
1044
|
-
removedCursor = removedPosition + 1;
|
|
1045
|
-
addedCursor = addedPosition + 1;
|
|
1046
|
-
}
|
|
1047
|
-
pairs.push(
|
|
1048
|
-
...positionPairs(
|
|
1049
|
-
removed,
|
|
1050
|
-
added,
|
|
1051
|
-
scores,
|
|
1052
|
-
removedCursor,
|
|
1053
|
-
removed.length,
|
|
1054
|
-
addedCursor,
|
|
1055
|
-
added.length
|
|
1056
|
-
)
|
|
1057
|
-
);
|
|
1058
|
-
return pairs;
|
|
1059
|
-
}
|
|
1060
|
-
function positionPairs(removed, added, scores, removedStart, removedEnd, addedStart, addedEnd) {
|
|
1061
|
-
const pairs = [];
|
|
1062
|
-
const count = Math.min(removedEnd - removedStart, addedEnd - addedStart);
|
|
1063
|
-
for (let offset = 0; offset < count; offset++) {
|
|
1064
|
-
const removedPosition = removedStart + offset;
|
|
1065
|
-
const addedPosition = addedStart + offset;
|
|
1066
|
-
const score = scores[removedPosition]?.[addedPosition] ?? 0;
|
|
1067
|
-
if (score < MIN_POSITIONAL_FALLBACK_PAIR_SCORE) continue;
|
|
1068
|
-
pairs.push([
|
|
1069
|
-
changedLineAt2(removed, removedPosition).index,
|
|
1070
|
-
changedLineAt2(added, addedPosition).index
|
|
1071
|
-
]);
|
|
1072
|
-
}
|
|
1073
|
-
return pairs;
|
|
1074
|
-
}
|
|
1075
|
-
function changedLineAt2(lines, index) {
|
|
1076
|
-
const line = lines[index];
|
|
1077
|
-
if (line === void 0) throw new RangeError(`Missing changed line ${index}`);
|
|
1078
|
-
return line;
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
// src/ui/word-diff/parse.ts
|
|
1082
|
-
function diffLineNumberWidth(lines) {
|
|
1083
|
-
return lines.reduce((width, line) => Math.max(width, normalizedDiffLineNumber(line).length), 0);
|
|
1084
|
-
}
|
|
1085
|
-
function formatDiffLineNumber(lineNumber, width) {
|
|
1086
|
-
return lineNumber.trim().padStart(width, " ");
|
|
1087
|
-
}
|
|
1088
|
-
function normalizedDiffLineNumber(line) {
|
|
1089
|
-
return line?.lineNumber.trim() ?? "";
|
|
1090
|
-
}
|
|
1091
|
-
function parseDiffLine(line) {
|
|
1092
|
-
const numbered = line.match(/^([+\- ])(\s*\d+)\s(.*)$/);
|
|
1093
|
-
if (numbered) {
|
|
1094
|
-
const [, kind, lineNumber, content] = numbered;
|
|
1095
|
-
if (kind !== "+" && kind !== "-" && kind !== " " || lineNumber === void 0 || content === void 0)
|
|
1096
|
-
return null;
|
|
1097
|
-
return { kind, lineNumber, content };
|
|
1098
|
-
}
|
|
1099
|
-
if (line.startsWith("+++") || line.startsWith("---")) return null;
|
|
1100
|
-
const prefix = line[0];
|
|
1101
|
-
if (prefix !== "+" && prefix !== "-" && prefix !== " ") return null;
|
|
1102
|
-
return { kind: prefix, lineNumber: "", content: line.slice(1) };
|
|
1103
|
-
}
|
|
1104
|
-
function isAddedDiffLine(line) {
|
|
1105
|
-
return line?.kind === "+";
|
|
1106
|
-
}
|
|
1107
|
-
function isRemovedDiffLine(line) {
|
|
1108
|
-
return line?.kind === "-";
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
// src/ui/word-diff/ranges.ts
|
|
1112
|
-
function rangesForTokenGroup(tokens, group) {
|
|
1113
|
-
const ranges = [];
|
|
1114
|
-
for (let index = group.start; index < group.end; index++) {
|
|
1115
|
-
const token = tokens[index];
|
|
1116
|
-
if (token) appendTokenRange(ranges, token);
|
|
1117
|
-
}
|
|
1118
|
-
return ranges;
|
|
1119
|
-
}
|
|
1120
|
-
function pushTokenRange(ranges, token) {
|
|
1121
|
-
ranges.push([token.start, token.end]);
|
|
1122
|
-
}
|
|
1123
|
-
function mergeRangesByStart(ranges) {
|
|
1124
|
-
return mergeRanges([...ranges].sort((a, b) => a[0] - b[0]));
|
|
1125
|
-
}
|
|
1126
|
-
function mergeRanges(ranges) {
|
|
1127
|
-
const merged = [];
|
|
1128
|
-
for (const range of ranges) {
|
|
1129
|
-
const previous = merged.at(-1);
|
|
1130
|
-
if (previous && range[0] - previous[1] <= 1) previous[1] = range[1];
|
|
1131
|
-
else merged.push([...range]);
|
|
1132
|
-
}
|
|
1133
|
-
return merged;
|
|
1134
|
-
}
|
|
1135
|
-
function appendTokenRange(ranges, token) {
|
|
1136
|
-
const previous = ranges.at(-1);
|
|
1137
|
-
if (previous && token.start - previous[1] <= 1) previous[1] = token.end;
|
|
1138
|
-
else ranges.push([token.start, token.end]);
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
// src/ui/word-diff/text-boundaries.ts
|
|
1142
|
-
var NON_ASCII_TEXT_PATTERN = /[^\x00-\x7F]/;
|
|
1143
|
-
var graphemeSegmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
1144
|
-
function commonPrefixLength(before, after) {
|
|
1145
|
-
const prefix = commonPrefixCodeUnitLength(before, after);
|
|
1146
|
-
if (!needsBoundarySafeOffsets(before) && !needsBoundarySafeOffsets(after)) return prefix;
|
|
1147
|
-
return commonGraphemePrefixLength(before, after, prefix);
|
|
1148
|
-
}
|
|
1149
|
-
function commonSuffixLength(before, after, prefixLength) {
|
|
1150
|
-
const suffix = commonSuffixCodeUnitLength(before, after, prefixLength);
|
|
1151
|
-
if (!needsBoundarySafeOffsets(before) && !needsBoundarySafeOffsets(after)) return suffix;
|
|
1152
|
-
return commonGraphemeSuffixLength(before, after, suffix);
|
|
1153
|
-
}
|
|
1154
|
-
function needsBoundarySafeOffsets(text) {
|
|
1155
|
-
return NON_ASCII_TEXT_PATTERN.test(text) || text.includes("\r\n");
|
|
1156
|
-
}
|
|
1157
|
-
function textBoundarySegments(text) {
|
|
1158
|
-
if (!needsBoundarySafeOffsets(text)) {
|
|
1159
|
-
return Array.from({ length: text.length }, (_, index) => ({
|
|
1160
|
-
value: text[index] ?? "",
|
|
1161
|
-
start: index,
|
|
1162
|
-
end: index + 1
|
|
1163
|
-
}));
|
|
1164
|
-
}
|
|
1165
|
-
return Array.from(graphemeSegmenter.segment(text), (segment) => ({
|
|
1166
|
-
value: segment.segment,
|
|
1167
|
-
start: segment.index,
|
|
1168
|
-
end: segment.index + segment.segment.length
|
|
1169
|
-
}));
|
|
1170
|
-
}
|
|
1171
|
-
function rangesAtGraphemeBoundaries(text, ranges) {
|
|
1172
|
-
if (ranges.length === 0 || !needsBoundarySafeOffsets(text)) return ranges;
|
|
1173
|
-
const segmentedText = graphemeSegmenter.segment(text);
|
|
1174
|
-
return ranges.map(([start, end]) => [
|
|
1175
|
-
graphemeStartAtOrBefore(segmentedText, start, text.length),
|
|
1176
|
-
graphemeEndAtOrAfter(segmentedText, end, text.length)
|
|
1177
|
-
]);
|
|
1178
|
-
}
|
|
1179
|
-
function commonPrefixCodeUnitLength(before, after) {
|
|
1180
|
-
const end = Math.min(before.length, after.length);
|
|
1181
|
-
let index = 0;
|
|
1182
|
-
while (index < end && before[index] === after[index]) index++;
|
|
1183
|
-
return index;
|
|
1184
|
-
}
|
|
1185
|
-
function commonSuffixCodeUnitLength(before, after, prefixLength) {
|
|
1186
|
-
const maxLength = Math.min(before.length, after.length) - prefixLength;
|
|
1187
|
-
let length = 0;
|
|
1188
|
-
while (length < maxLength && before[before.length - 1 - length] === after[after.length - 1 - length])
|
|
1189
|
-
length++;
|
|
1190
|
-
return length;
|
|
1191
|
-
}
|
|
1192
|
-
function commonGraphemePrefixLength(before, after, prefix) {
|
|
1193
|
-
const beforeSegments = graphemeSegmenter.segment(before);
|
|
1194
|
-
const afterSegments = graphemeSegmenter.segment(after);
|
|
1195
|
-
let safePrefix = prefix;
|
|
1196
|
-
while (safePrefix > 0) {
|
|
1197
|
-
const beforeBoundary = graphemeBoundaryAtOrBefore(beforeSegments, safePrefix);
|
|
1198
|
-
const afterBoundary = graphemeBoundaryAtOrBefore(afterSegments, safePrefix);
|
|
1199
|
-
const nextPrefix = Math.min(beforeBoundary, afterBoundary);
|
|
1200
|
-
if (nextPrefix === safePrefix) break;
|
|
1201
|
-
safePrefix = nextPrefix;
|
|
1202
|
-
}
|
|
1203
|
-
return safePrefix;
|
|
1204
|
-
}
|
|
1205
|
-
function commonGraphemeSuffixLength(before, after, suffix) {
|
|
1206
|
-
const beforeSegments = graphemeSegmenter.segment(before);
|
|
1207
|
-
const afterSegments = graphemeSegmenter.segment(after);
|
|
1208
|
-
let safeSuffix = suffix;
|
|
1209
|
-
while (safeSuffix > 0) {
|
|
1210
|
-
const beforeStart = before.length - safeSuffix;
|
|
1211
|
-
const afterStart = after.length - safeSuffix;
|
|
1212
|
-
const beforeTrim = graphemeBoundaryAtOrAfter(beforeSegments, beforeStart, before.length) - beforeStart;
|
|
1213
|
-
const afterTrim = graphemeBoundaryAtOrAfter(afterSegments, afterStart, after.length) - afterStart;
|
|
1214
|
-
const trim = Math.max(beforeTrim, afterTrim);
|
|
1215
|
-
if (trim === 0) break;
|
|
1216
|
-
safeSuffix = Math.max(0, safeSuffix - trim);
|
|
1217
|
-
}
|
|
1218
|
-
return safeSuffix;
|
|
1219
|
-
}
|
|
1220
|
-
function graphemeBoundaryAtOrBefore(segments, offset) {
|
|
1221
|
-
if (offset <= 0) return 0;
|
|
1222
|
-
const segment = segments.containing(offset - 1);
|
|
1223
|
-
if (!segment) return offset;
|
|
1224
|
-
const segmentEnd = segment.index + segment.segment.length;
|
|
1225
|
-
return segmentEnd === offset ? offset : segment.index;
|
|
1226
|
-
}
|
|
1227
|
-
function graphemeBoundaryAtOrAfter(segments, offset, textLength) {
|
|
1228
|
-
if (offset <= 0) return 0;
|
|
1229
|
-
if (offset >= textLength) return textLength;
|
|
1230
|
-
const segment = segments.containing(offset);
|
|
1231
|
-
if (!segment || segment.index === offset) return offset;
|
|
1232
|
-
return segment.index + segment.segment.length;
|
|
1233
|
-
}
|
|
1234
|
-
function graphemeStartAtOrBefore(segments, offset, textLength) {
|
|
1235
|
-
if (offset <= 0) return 0;
|
|
1236
|
-
if (offset >= textLength) return textLength;
|
|
1237
|
-
return segments.containing(offset)?.index ?? offset;
|
|
1238
|
-
}
|
|
1239
|
-
function graphemeEndAtOrAfter(segments, offset, textLength) {
|
|
1240
|
-
if (offset <= 0) return 0;
|
|
1241
|
-
if (offset >= textLength) return textLength;
|
|
1242
|
-
const segment = segments.containing(offset - 1);
|
|
1243
|
-
return segment ? segment.index + segment.segment.length : offset;
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
// src/ui/word-diff/token-alignment.ts
|
|
1247
|
-
var WORD_EMPHASIS_EXACT_LCS_MAX_CELLS = 262144;
|
|
1248
|
-
function collectChangedTokenGaps(before, beforeStart, beforeEnd, after, afterStart, afterEnd, gaps) {
|
|
1249
|
-
while (beforeStart < beforeEnd && afterStart < afterEnd && tokenAt(before, beforeStart).value === tokenAt(after, afterStart).value) {
|
|
1250
|
-
beforeStart++;
|
|
1251
|
-
afterStart++;
|
|
1252
|
-
}
|
|
1253
|
-
while (beforeStart < beforeEnd && afterStart < afterEnd && tokenAt(before, beforeEnd - 1).value === tokenAt(after, afterEnd - 1).value) {
|
|
1254
|
-
beforeEnd--;
|
|
1255
|
-
afterEnd--;
|
|
1256
|
-
}
|
|
1257
|
-
if (beforeStart === beforeEnd || afterStart === afterEnd) {
|
|
1258
|
-
appendChangedTokenGap(gaps, beforeStart, beforeEnd, afterStart, afterEnd);
|
|
1259
|
-
return "high";
|
|
1260
|
-
}
|
|
1261
|
-
const beforeLength = beforeEnd - beforeStart;
|
|
1262
|
-
const afterLength = afterEnd - afterStart;
|
|
1263
|
-
if (beforeLength * afterLength <= WORD_EMPHASIS_EXACT_LCS_MAX_CELLS) {
|
|
1264
|
-
collectChangedTokenGapsByLcs(before, beforeStart, beforeEnd, after, afterStart, afterEnd, gaps);
|
|
1265
|
-
return "high";
|
|
1266
|
-
}
|
|
1267
|
-
const anchors = uniqueOrderedAnchors(before, beforeStart, beforeEnd, after, afterStart, afterEnd);
|
|
1268
|
-
if (anchors.length === 0) {
|
|
1269
|
-
appendChangedTokenGap(gaps, beforeStart, beforeEnd, afterStart, afterEnd);
|
|
1270
|
-
return "low";
|
|
1271
|
-
}
|
|
1272
|
-
let confidence = "high";
|
|
1273
|
-
let previousBefore = beforeStart;
|
|
1274
|
-
let previousAfter = afterStart;
|
|
1275
|
-
for (const anchor of anchors) {
|
|
1276
|
-
confidence = lowerWordChangeConfidence(
|
|
1277
|
-
confidence,
|
|
1278
|
-
collectChangedTokenGaps(
|
|
1279
|
-
before,
|
|
1280
|
-
previousBefore,
|
|
1281
|
-
anchor.beforeIndex,
|
|
1282
|
-
after,
|
|
1283
|
-
previousAfter,
|
|
1284
|
-
anchor.afterIndex,
|
|
1285
|
-
gaps
|
|
1286
|
-
)
|
|
1287
|
-
);
|
|
1288
|
-
previousBefore = anchor.beforeIndex + 1;
|
|
1289
|
-
previousAfter = anchor.afterIndex + 1;
|
|
1290
|
-
}
|
|
1291
|
-
confidence = lowerWordChangeConfidence(
|
|
1292
|
-
confidence,
|
|
1293
|
-
collectChangedTokenGaps(
|
|
1294
|
-
before,
|
|
1295
|
-
previousBefore,
|
|
1296
|
-
beforeEnd,
|
|
1297
|
-
after,
|
|
1298
|
-
previousAfter,
|
|
1299
|
-
afterEnd,
|
|
1300
|
-
gaps
|
|
1301
|
-
)
|
|
1302
|
-
);
|
|
1303
|
-
return lowerWordChangeConfidence(confidence, "medium");
|
|
1304
|
-
}
|
|
1305
|
-
function lowerWordChangeConfidence(a, b) {
|
|
1306
|
-
return WORD_CHANGE_CONFIDENCE_RANK[a] <= WORD_CHANGE_CONFIDENCE_RANK[b] ? a : b;
|
|
1307
|
-
}
|
|
1308
|
-
var WORD_CHANGE_CONFIDENCE_RANK = {
|
|
1309
|
-
low: 0,
|
|
1310
|
-
medium: 1,
|
|
1311
|
-
high: 2
|
|
1312
|
-
};
|
|
1313
|
-
function collectChangedTokenGapsByLcs(before, beforeStart, beforeEnd, after, afterStart, afterEnd, gaps) {
|
|
1314
|
-
const beforeLength = beforeEnd - beforeStart;
|
|
1315
|
-
const afterLength = afterEnd - afterStart;
|
|
1316
|
-
const pairs = suffixAlignedPairs(beforeLength, afterLength, (beforeIndex2, afterIndex2) => {
|
|
1317
|
-
const beforeToken = tokenAt(before, beforeStart + beforeIndex2);
|
|
1318
|
-
const afterToken = tokenAt(after, afterStart + afterIndex2);
|
|
1319
|
-
return beforeToken.value === afterToken.value ? wordEmphasisTokenWeight(beforeToken.value) : Number.NEGATIVE_INFINITY;
|
|
1320
|
-
});
|
|
1321
|
-
let beforeIndex = 0;
|
|
1322
|
-
let afterIndex = 0;
|
|
1323
|
-
for (const [nextBeforeIndex, nextAfterIndex] of pairs) {
|
|
1324
|
-
appendChangedTokenGap(
|
|
1325
|
-
gaps,
|
|
1326
|
-
beforeStart + beforeIndex,
|
|
1327
|
-
beforeStart + nextBeforeIndex,
|
|
1328
|
-
afterStart + afterIndex,
|
|
1329
|
-
afterStart + nextAfterIndex
|
|
1330
|
-
);
|
|
1331
|
-
beforeIndex = nextBeforeIndex + 1;
|
|
1332
|
-
afterIndex = nextAfterIndex + 1;
|
|
1333
|
-
}
|
|
1334
|
-
appendChangedTokenGap(
|
|
1335
|
-
gaps,
|
|
1336
|
-
beforeStart + beforeIndex,
|
|
1337
|
-
beforeEnd,
|
|
1338
|
-
afterStart + afterIndex,
|
|
1339
|
-
afterEnd
|
|
1340
|
-
);
|
|
1341
|
-
}
|
|
1342
|
-
function uniqueOrderedAnchors(before, beforeStart, beforeEnd, after, afterStart, afterEnd) {
|
|
1343
|
-
const beforeCounts = tokenCounts(before, beforeStart, beforeEnd);
|
|
1344
|
-
const afterCounts = tokenCounts(after, afterStart, afterEnd);
|
|
1345
|
-
const afterUniqueIndexes = /* @__PURE__ */ new Map();
|
|
1346
|
-
for (let index = afterStart; index < afterEnd; index++) {
|
|
1347
|
-
const value = tokenAt(after, index).value;
|
|
1348
|
-
if (beforeCounts.get(value) === 1 && afterCounts.get(value) === 1)
|
|
1349
|
-
afterUniqueIndexes.set(value, index);
|
|
1350
|
-
}
|
|
1351
|
-
const candidates = [];
|
|
1352
|
-
for (let index = beforeStart; index < beforeEnd; index++) {
|
|
1353
|
-
const value = tokenAt(before, index).value;
|
|
1354
|
-
if (beforeCounts.get(value) !== 1 || afterCounts.get(value) !== 1) continue;
|
|
1355
|
-
const afterIndex = afterUniqueIndexes.get(value);
|
|
1356
|
-
if (afterIndex !== void 0) candidates.push({ beforeIndex: index, afterIndex });
|
|
1357
|
-
}
|
|
1358
|
-
return longestIncreasingAfterIndexes(candidates);
|
|
1359
|
-
}
|
|
1360
|
-
function longestIncreasingAfterIndexes(candidates) {
|
|
1361
|
-
if (candidates.length <= 1) return candidates;
|
|
1362
|
-
const tails = [];
|
|
1363
|
-
const previous = Array.from({ length: candidates.length }, () => -1);
|
|
1364
|
-
const tailCandidateIndexes = [];
|
|
1365
|
-
for (let index2 = 0; index2 < candidates.length; index2++) {
|
|
1366
|
-
const afterIndex = candidateAt(candidates, index2).afterIndex;
|
|
1367
|
-
let low = 0;
|
|
1368
|
-
let high = tails.length;
|
|
1369
|
-
while (low < high) {
|
|
1370
|
-
const middle = low + high >> 1;
|
|
1371
|
-
if (numberAt(tails, middle) < afterIndex) low = middle + 1;
|
|
1372
|
-
else high = middle;
|
|
1373
|
-
}
|
|
1374
|
-
if (low > 0) previous[index2] = numberAt(tailCandidateIndexes, low - 1);
|
|
1375
|
-
tails[low] = afterIndex;
|
|
1376
|
-
tailCandidateIndexes[low] = index2;
|
|
1377
|
-
}
|
|
1378
|
-
const ordered = [];
|
|
1379
|
-
let index = tailCandidateIndexes[tails.length - 1] ?? -1;
|
|
1380
|
-
while (index >= 0) {
|
|
1381
|
-
ordered.push(candidateAt(candidates, index));
|
|
1382
|
-
index = previous[index] ?? -1;
|
|
1383
|
-
}
|
|
1384
|
-
return ordered.reverse();
|
|
1385
|
-
}
|
|
1386
|
-
function tokenCounts(tokens, start, end) {
|
|
1387
|
-
const counts = /* @__PURE__ */ new Map();
|
|
1388
|
-
for (let index = start; index < end; index++) {
|
|
1389
|
-
const value = tokenAt(tokens, index).value;
|
|
1390
|
-
counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
1391
|
-
}
|
|
1392
|
-
return counts;
|
|
1393
|
-
}
|
|
1394
|
-
function appendChangedTokenGap(gaps, beforeStart, beforeEnd, afterStart, afterEnd) {
|
|
1395
|
-
if (beforeStart === beforeEnd && afterStart === afterEnd) return;
|
|
1396
|
-
gaps.push({
|
|
1397
|
-
removed: { start: beforeStart, end: beforeEnd },
|
|
1398
|
-
added: { start: afterStart, end: afterEnd }
|
|
1399
|
-
});
|
|
1400
|
-
}
|
|
1401
|
-
function tokenAt(tokens, index) {
|
|
1402
|
-
const token = tokens[index];
|
|
1403
|
-
if (token === void 0) throw new RangeError(`Missing word-emphasis token ${index}`);
|
|
1404
|
-
return token;
|
|
1405
|
-
}
|
|
1406
|
-
function candidateAt(candidates, index) {
|
|
1407
|
-
const candidate = candidates[index];
|
|
1408
|
-
if (candidate === void 0) throw new RangeError(`Missing anchor candidate ${index}`);
|
|
1409
|
-
return candidate;
|
|
1410
|
-
}
|
|
1411
|
-
function numberAt(values, index) {
|
|
1412
|
-
const value = values[index];
|
|
1413
|
-
if (value === void 0) throw new RangeError(`Missing numeric value ${index}`);
|
|
1414
|
-
return value;
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
// src/ui/word-diff/token-text-refinement.ts
|
|
1418
|
-
var MAX_REFINED_TEXT_ALIGNMENT_CELLS = 1024;
|
|
1419
|
-
var MAX_REFINED_TEXT_GRAPHEMES = 48;
|
|
1420
|
-
var MAX_REFINED_TEXT_INTERNAL_RUNS = 4;
|
|
1421
|
-
var MIN_REFINED_TEXT_INTERNAL_RUN_GRAPHEMES = 3;
|
|
1422
|
-
function refinedTokenTextRanges(beforeToken, afterToken) {
|
|
1423
|
-
if (beforeToken.value === afterToken.value) return void 0;
|
|
1424
|
-
const prefix = commonPrefixLength(beforeToken.value, afterToken.value);
|
|
1425
|
-
const suffix = commonSuffixLength(beforeToken.value, afterToken.value, prefix);
|
|
1426
|
-
if (!shouldRefineTokenText(beforeToken.value, afterToken.value, prefix, suffix)) return void 0;
|
|
1427
|
-
const aligned = refinedTokenTextRangesByAlignment(beforeToken, afterToken, prefix, suffix);
|
|
1428
|
-
if (aligned) return aligned;
|
|
1429
|
-
return tokenTextGapRanges(
|
|
1430
|
-
beforeToken,
|
|
1431
|
-
afterToken,
|
|
1432
|
-
prefix,
|
|
1433
|
-
beforeToken.value.length - suffix,
|
|
1434
|
-
prefix,
|
|
1435
|
-
afterToken.value.length - suffix
|
|
1436
|
-
);
|
|
1437
|
-
}
|
|
1438
|
-
function refinedTokenTextRangesByAlignment(beforeToken, afterToken, prefix, suffix) {
|
|
1439
|
-
const beforeValue = beforeToken.value;
|
|
1440
|
-
const afterValue = afterToken.value;
|
|
1441
|
-
if (!isIdentifierToken(beforeValue) || !isIdentifierToken(afterValue)) return void 0;
|
|
1442
|
-
if (beforeValue.length * afterValue.length > MAX_REFINED_TEXT_ALIGNMENT_CELLS) return void 0;
|
|
1443
|
-
if (!hasPotentialInternalCommonText(beforeValue, afterValue, prefix, suffix)) return void 0;
|
|
1444
|
-
const beforeSegments = textBoundarySegments(beforeValue);
|
|
1445
|
-
const afterSegments = textBoundarySegments(afterValue);
|
|
1446
|
-
if (beforeSegments.length > MAX_REFINED_TEXT_GRAPHEMES || afterSegments.length > MAX_REFINED_TEXT_GRAPHEMES || beforeSegments.length * afterSegments.length > MAX_REFINED_TEXT_ALIGNMENT_CELLS)
|
|
1447
|
-
return void 0;
|
|
1448
|
-
const pairs = suffixAlignedPairs(
|
|
1449
|
-
beforeSegments.length,
|
|
1450
|
-
afterSegments.length,
|
|
1451
|
-
(before, after) => segmentAt(beforeSegments, before).value === segmentAt(afterSegments, after).value ? 1 : Number.NEGATIVE_INFINITY
|
|
1452
|
-
);
|
|
1453
|
-
const runs = commonTextRuns(pairs);
|
|
1454
|
-
const keptRuns = runs.filter(
|
|
1455
|
-
(run) => isEdgeTextRun(run, beforeSegments.length, afterSegments.length) || run.beforeEnd - run.beforeStart >= MIN_REFINED_TEXT_INTERNAL_RUN_GRAPHEMES
|
|
1456
|
-
);
|
|
1457
|
-
const internalRunCount = keptRuns.filter(
|
|
1458
|
-
(run) => !isEdgeTextRun(run, beforeSegments.length, afterSegments.length)
|
|
1459
|
-
).length;
|
|
1460
|
-
if (internalRunCount === 0 || internalRunCount > MAX_REFINED_TEXT_INTERNAL_RUNS) return void 0;
|
|
1461
|
-
const removed = [];
|
|
1462
|
-
const added = [];
|
|
1463
|
-
let beforeIndex = 0;
|
|
1464
|
-
let afterIndex = 0;
|
|
1465
|
-
for (const run of keptRuns) {
|
|
1466
|
-
pushTextSegmentRange(removed, beforeToken, beforeSegments, beforeIndex, run.beforeStart);
|
|
1467
|
-
pushTextSegmentRange(added, afterToken, afterSegments, afterIndex, run.afterStart);
|
|
1468
|
-
beforeIndex = run.beforeEnd;
|
|
1469
|
-
afterIndex = run.afterEnd;
|
|
1470
|
-
}
|
|
1471
|
-
pushTextSegmentRange(removed, beforeToken, beforeSegments, beforeIndex, beforeSegments.length);
|
|
1472
|
-
pushTextSegmentRange(added, afterToken, afterSegments, afterIndex, afterSegments.length);
|
|
1473
|
-
return removed.length > 0 || added.length > 0 ? { removed, added } : void 0;
|
|
1474
|
-
}
|
|
1475
|
-
function tokenTextGapRanges(beforeToken, afterToken, beforeStart, beforeEnd, afterStart, afterEnd) {
|
|
1476
|
-
const removed = beforeStart < beforeEnd ? [[beforeToken.start + beforeStart, beforeToken.start + beforeEnd]] : [];
|
|
1477
|
-
const added = afterStart < afterEnd ? [[afterToken.start + afterStart, afterToken.start + afterEnd]] : [];
|
|
1478
|
-
return removed.length > 0 || added.length > 0 ? { removed, added } : void 0;
|
|
1479
|
-
}
|
|
1480
|
-
function hasPotentialInternalCommonText(before, after, prefix, suffix) {
|
|
1481
|
-
const beforeMiddle = before.slice(prefix, before.length - suffix);
|
|
1482
|
-
const afterMiddle = after.slice(prefix, after.length - suffix);
|
|
1483
|
-
const [shorter, longer] = beforeMiddle.length <= afterMiddle.length ? [beforeMiddle, afterMiddle] : [afterMiddle, beforeMiddle];
|
|
1484
|
-
if (shorter.length < MIN_REFINED_TEXT_INTERNAL_RUN_GRAPHEMES) return false;
|
|
1485
|
-
for (let index = 0; index <= shorter.length - MIN_REFINED_TEXT_INTERNAL_RUN_GRAPHEMES; index++) {
|
|
1486
|
-
const candidate = shorter.slice(index, index + MIN_REFINED_TEXT_INTERNAL_RUN_GRAPHEMES);
|
|
1487
|
-
if (longer.includes(candidate)) return true;
|
|
1488
|
-
}
|
|
1489
|
-
return false;
|
|
1490
|
-
}
|
|
1491
|
-
function commonTextRuns(pairs) {
|
|
1492
|
-
const runs = [];
|
|
1493
|
-
for (const [beforeIndex, afterIndex] of pairs) {
|
|
1494
|
-
const previous = runs.at(-1);
|
|
1495
|
-
if (previous?.beforeEnd === beforeIndex && previous.afterEnd === afterIndex) {
|
|
1496
|
-
previous.beforeEnd++;
|
|
1497
|
-
previous.afterEnd++;
|
|
1498
|
-
} else {
|
|
1499
|
-
runs.push({
|
|
1500
|
-
beforeStart: beforeIndex,
|
|
1501
|
-
beforeEnd: beforeIndex + 1,
|
|
1502
|
-
afterStart: afterIndex,
|
|
1503
|
-
afterEnd: afterIndex + 1
|
|
1504
|
-
});
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
return runs;
|
|
1508
|
-
}
|
|
1509
|
-
function isEdgeTextRun(run, beforeLength, afterLength) {
|
|
1510
|
-
return run.beforeStart === 0 && run.afterStart === 0 || run.beforeEnd === beforeLength && run.afterEnd === afterLength;
|
|
1511
|
-
}
|
|
1512
|
-
function pushTextSegmentRange(ranges, token, segments, start, end) {
|
|
1513
|
-
if (start >= end) return;
|
|
1514
|
-
ranges.push([
|
|
1515
|
-
token.start + textSegmentOffset(segments, start, token.value.length),
|
|
1516
|
-
token.start + textSegmentOffset(segments, end, token.value.length)
|
|
1517
|
-
]);
|
|
1518
|
-
}
|
|
1519
|
-
function textSegmentOffset(segments, index, textLength) {
|
|
1520
|
-
return index === segments.length ? textLength : segmentAt(segments, index).start;
|
|
1521
|
-
}
|
|
1522
|
-
function segmentAt(segments, index) {
|
|
1523
|
-
const segment = segments[index];
|
|
1524
|
-
if (segment === void 0) throw new RangeError(`Missing text segment ${index}`);
|
|
1525
|
-
return segment;
|
|
1526
|
-
}
|
|
1527
|
-
function shouldRefineTokenText(before, after, prefix, suffix) {
|
|
1528
|
-
const sharedEdgeLength = prefix + suffix;
|
|
1529
|
-
if (sharedEdgeLength === 0) return false;
|
|
1530
|
-
if (isIdentifierToken(before) && isIdentifierToken(after)) {
|
|
1531
|
-
if (sharedEdgeLength < 2 && !needsBoundarySafeOffsets(before) && !needsBoundarySafeOffsets(after))
|
|
1532
|
-
return false;
|
|
1533
|
-
if (prefix === 0 && suffix > 0) {
|
|
1534
|
-
const beforeChangedLength = before.length - suffix;
|
|
1535
|
-
const afterChangedLength = after.length - suffix;
|
|
1536
|
-
if (beforeChangedLength !== afterChangedLength && Math.min(beforeChangedLength, afterChangedLength) < 2)
|
|
1537
|
-
return false;
|
|
1538
|
-
}
|
|
1539
|
-
return true;
|
|
1540
|
-
}
|
|
1541
|
-
if (isNumberToken(before) && isNumberToken(after)) return true;
|
|
1542
|
-
if (isMeaningfulOperatorToken(before) && isMeaningfulOperatorToken(after)) return true;
|
|
1543
|
-
return false;
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
// src/ui/word-diff/range-refinement.ts
|
|
1547
|
-
var MAX_SOFT_TOKEN_ALIGNMENT_CELLS = 4096;
|
|
1548
|
-
var MIN_SOFT_TOKEN_SUBSTITUTION_SIMILARITY = 0.45;
|
|
1549
|
-
function refinedRangesForChangedTokens(beforeText, beforeTokens, afterText, afterTokens, gaps) {
|
|
1550
|
-
const ranges = refinedRangesForTokenGaps(beforeTokens, afterTokens, gaps);
|
|
1551
|
-
return {
|
|
1552
|
-
removed: mergeRanges(rangesAtGraphemeBoundaries(beforeText, ranges.removed)),
|
|
1553
|
-
added: mergeRanges(rangesAtGraphemeBoundaries(afterText, ranges.added))
|
|
1554
|
-
};
|
|
1555
|
-
}
|
|
1556
|
-
function refinedRangesForTokenGaps(beforeTokens, afterTokens, gaps) {
|
|
1557
|
-
const removed = [];
|
|
1558
|
-
const added = [];
|
|
1559
|
-
for (const gap of gaps) {
|
|
1560
|
-
const removedGroup = nonEmptyTokenGroup(gap.removed);
|
|
1561
|
-
const addedGroup = nonEmptyTokenGroup(gap.added);
|
|
1562
|
-
const refined = removedGroup && addedGroup ? refinedChangedTokenGroupRanges(beforeTokens, removedGroup, afterTokens, addedGroup) : void 0;
|
|
1563
|
-
if (refined) {
|
|
1564
|
-
removed.push(...refined.removed);
|
|
1565
|
-
added.push(...refined.added);
|
|
1566
|
-
continue;
|
|
1567
|
-
}
|
|
1568
|
-
if (removedGroup) removed.push(...rangesForTokenGroup(beforeTokens, removedGroup));
|
|
1569
|
-
if (addedGroup) added.push(...rangesForTokenGroup(afterTokens, addedGroup));
|
|
1570
|
-
}
|
|
1571
|
-
return { removed: mergeRanges(removed), added: mergeRanges(added) };
|
|
1572
|
-
}
|
|
1573
|
-
function nonEmptyTokenGroup(group) {
|
|
1574
|
-
return group.start < group.end ? group : void 0;
|
|
1575
|
-
}
|
|
1576
|
-
function refinedChangedTokenGroupRanges(beforeTokens, beforeGroup, afterTokens, afterGroup) {
|
|
1577
|
-
return refinedSingleTokenRanges(beforeTokens, beforeGroup, afterTokens, afterGroup) ?? refinedSoftTokenGroupRanges(beforeTokens, beforeGroup, afterTokens, afterGroup);
|
|
1578
|
-
}
|
|
1579
|
-
function refinedSingleTokenRanges(beforeTokens, beforeGroup, afterTokens, afterGroup) {
|
|
1580
|
-
if (beforeGroup.end - beforeGroup.start !== 1 || afterGroup.end - afterGroup.start !== 1)
|
|
1581
|
-
return void 0;
|
|
1582
|
-
return refinedTokenPairRanges(
|
|
1583
|
-
tokenAt2(beforeTokens, beforeGroup.start),
|
|
1584
|
-
tokenAt2(afterTokens, afterGroup.start)
|
|
1585
|
-
);
|
|
1586
|
-
}
|
|
1587
|
-
function refinedTokenPairRanges(beforeToken, afterToken) {
|
|
1588
|
-
const identifierRanges = refinedIdentifierTokenRanges(beforeToken, afterToken);
|
|
1589
|
-
const textRanges = refinedTokenTextRanges(beforeToken, afterToken);
|
|
1590
|
-
if (identifierRanges && isNarrowerThanWholeTokens(identifierRanges, beforeToken, afterToken)) {
|
|
1591
|
-
if (shouldSuppressUnbalancedIdentifierPartRefinement(beforeToken, afterToken, textRanges))
|
|
1592
|
-
return textRanges;
|
|
1593
|
-
if (textRanges && (textRanges.removed.length === 0 || textRanges.added.length === 0) && highlightedRangeWidth(textRanges) < highlightedRangeWidth(identifierRanges))
|
|
1594
|
-
return textRanges;
|
|
1595
|
-
return identifierRanges;
|
|
1596
|
-
}
|
|
1597
|
-
return textRanges ?? identifierRanges;
|
|
1598
|
-
}
|
|
1599
|
-
function highlightedRangeWidth(ranges) {
|
|
1600
|
-
let width = 0;
|
|
1601
|
-
for (const [start, end] of ranges.removed) width += end - start;
|
|
1602
|
-
for (const [start, end] of ranges.added) width += end - start;
|
|
1603
|
-
return width;
|
|
1604
|
-
}
|
|
1605
|
-
function shouldSuppressUnbalancedIdentifierPartRefinement(beforeToken, afterToken, textRanges) {
|
|
1606
|
-
if (textRanges) return false;
|
|
1607
|
-
if (!isIdentifierToken(beforeToken.value) || !isIdentifierToken(afterToken.value)) return false;
|
|
1608
|
-
const beforePartCount = splitIdentifierToken(beforeToken.value, 0).filter(
|
|
1609
|
-
(part) => isIdentifierSimilarityPart(part.value)
|
|
1610
|
-
).length;
|
|
1611
|
-
const afterPartCount = splitIdentifierToken(afterToken.value, 0).filter(
|
|
1612
|
-
(part) => isIdentifierSimilarityPart(part.value)
|
|
1613
|
-
).length;
|
|
1614
|
-
return Math.min(beforePartCount, afterPartCount) === 1 && beforePartCount !== afterPartCount;
|
|
1615
|
-
}
|
|
1616
|
-
function refinedSoftTokenGroupRanges(beforeTokens, beforeGroup, afterTokens, afterGroup) {
|
|
1617
|
-
const before = beforeTokens.slice(beforeGroup.start, beforeGroup.end);
|
|
1618
|
-
const after = afterTokens.slice(afterGroup.start, afterGroup.end);
|
|
1619
|
-
if (before.length * after.length > MAX_SOFT_TOKEN_ALIGNMENT_CELLS) return void 0;
|
|
1620
|
-
const pairs = softAlignedTokenPairs(before, after);
|
|
1621
|
-
if (pairs.length === 0) return void 0;
|
|
1622
|
-
const pairedBefore = /* @__PURE__ */ new Set();
|
|
1623
|
-
const pairedAfter = /* @__PURE__ */ new Set();
|
|
1624
|
-
const removed = [];
|
|
1625
|
-
const added = [];
|
|
1626
|
-
for (const [beforeIndex, afterIndex] of pairs) {
|
|
1627
|
-
pairedBefore.add(beforeIndex);
|
|
1628
|
-
pairedAfter.add(afterIndex);
|
|
1629
|
-
const beforeToken = tokenAt2(before, beforeIndex);
|
|
1630
|
-
const afterToken = tokenAt2(after, afterIndex);
|
|
1631
|
-
if (beforeToken.value === afterToken.value) continue;
|
|
1632
|
-
const refined = refinedTokenPairRanges(beforeToken, afterToken);
|
|
1633
|
-
if (refined) {
|
|
1634
|
-
removed.push(...refined.removed);
|
|
1635
|
-
added.push(...refined.added);
|
|
1636
|
-
} else {
|
|
1637
|
-
pushTokenRange(removed, beforeToken);
|
|
1638
|
-
pushTokenRange(added, afterToken);
|
|
1639
|
-
}
|
|
1640
|
-
}
|
|
1641
|
-
for (let index = 0; index < before.length; index++) {
|
|
1642
|
-
if (!pairedBefore.has(index)) pushTokenRange(removed, tokenAt2(before, index));
|
|
1643
|
-
}
|
|
1644
|
-
for (let index = 0; index < after.length; index++) {
|
|
1645
|
-
if (!pairedAfter.has(index)) pushTokenRange(added, tokenAt2(after, index));
|
|
1646
|
-
}
|
|
1647
|
-
const result = { removed: mergeRangesByStart(removed), added: mergeRangesByStart(added) };
|
|
1648
|
-
return result.removed.length > 0 || result.added.length > 0 ? result : void 0;
|
|
1649
|
-
}
|
|
1650
|
-
function softAlignedTokenPairs(before, after) {
|
|
1651
|
-
return suffixAlignedPairs(before.length, after.length, (beforeIndex, afterIndex) => {
|
|
1652
|
-
const substitution = softTokenSubstitutionWeight(
|
|
1653
|
-
tokenAt2(before, beforeIndex),
|
|
1654
|
-
tokenAt2(after, afterIndex)
|
|
1655
|
-
);
|
|
1656
|
-
return substitution > 0 ? substitution : Number.NEGATIVE_INFINITY;
|
|
1657
|
-
});
|
|
1658
|
-
}
|
|
1659
|
-
function softTokenSubstitutionWeight(beforeToken, afterToken) {
|
|
1660
|
-
if (beforeToken.value === afterToken.value) return wordEmphasisTokenWeight(beforeToken.value);
|
|
1661
|
-
const similarity = softTokenSimilarity(beforeToken.value, afterToken.value);
|
|
1662
|
-
return similarity >= MIN_SOFT_TOKEN_SUBSTITUTION_SIMILARITY ? Math.min(
|
|
1663
|
-
wordEmphasisTokenWeight(beforeToken.value),
|
|
1664
|
-
wordEmphasisTokenWeight(afterToken.value)
|
|
1665
|
-
) * similarity : 0;
|
|
1666
|
-
}
|
|
1667
|
-
function softTokenSimilarity(before, after) {
|
|
1668
|
-
if (isIdentifierToken(before) && isIdentifierToken(after))
|
|
1669
|
-
return identifierTokenSimilarity(before, after);
|
|
1670
|
-
if (isNumberToken(before) && isNumberToken(after)) return edgeTextSimilarity(before, after);
|
|
1671
|
-
if (isMeaningfulOperatorToken(before) && isMeaningfulOperatorToken(after))
|
|
1672
|
-
return edgeTextSimilarity(before, after);
|
|
1673
|
-
return 0;
|
|
1674
|
-
}
|
|
1675
|
-
function identifierTokenSimilarity(before, after) {
|
|
1676
|
-
const beforeParts = splitIdentifierToken(before, 0).map((part) => part.value.toLowerCase()).filter(isIdentifierSimilarityPart);
|
|
1677
|
-
const afterParts = splitIdentifierToken(after, 0).map((part) => part.value.toLowerCase()).filter(isIdentifierSimilarityPart);
|
|
1678
|
-
const partSimilarity = tokenDiceSimilarity(beforeParts, afterParts);
|
|
1679
|
-
return Math.max(partSimilarity, edgeTextSimilarity(before, after));
|
|
1680
|
-
}
|
|
1681
|
-
function tokenDiceSimilarity(before, after) {
|
|
1682
|
-
if (before.length === 0 || after.length === 0) return 0;
|
|
1683
|
-
const remaining = /* @__PURE__ */ new Map();
|
|
1684
|
-
for (const token of before) remaining.set(token, (remaining.get(token) ?? 0) + 1);
|
|
1685
|
-
let shared = 0;
|
|
1686
|
-
for (const token of after) {
|
|
1687
|
-
const count = remaining.get(token) ?? 0;
|
|
1688
|
-
if (count === 0) continue;
|
|
1689
|
-
shared++;
|
|
1690
|
-
if (count === 1) remaining.delete(token);
|
|
1691
|
-
else remaining.set(token, count - 1);
|
|
1692
|
-
}
|
|
1693
|
-
return 2 * shared / (before.length + after.length);
|
|
1694
|
-
}
|
|
1695
|
-
function edgeTextSimilarity(before, after) {
|
|
1696
|
-
const prefix = commonPrefixLength(before, after);
|
|
1697
|
-
const suffix = commonSuffixLength(before, after, prefix);
|
|
1698
|
-
return 2 * (prefix + suffix) / (before.length + after.length);
|
|
1699
|
-
}
|
|
1700
|
-
function refinedIdentifierTokenRanges(beforeToken, afterToken) {
|
|
1701
|
-
if (!isIdentifierToken(beforeToken.value) || !isIdentifierToken(afterToken.value))
|
|
1702
|
-
return void 0;
|
|
1703
|
-
const beforeParts = splitIdentifierToken(beforeToken.value, beforeToken.start);
|
|
1704
|
-
const afterParts = splitIdentifierToken(afterToken.value, afterToken.start);
|
|
1705
|
-
if (beforeParts.length <= 1 && afterParts.length <= 1) return void 0;
|
|
1706
|
-
const gaps = [];
|
|
1707
|
-
collectChangedTokenGaps(
|
|
1708
|
-
beforeParts,
|
|
1709
|
-
0,
|
|
1710
|
-
beforeParts.length,
|
|
1711
|
-
afterParts,
|
|
1712
|
-
0,
|
|
1713
|
-
afterParts.length,
|
|
1714
|
-
gaps
|
|
1715
|
-
);
|
|
1716
|
-
const ranges = refinedRangesForTokenGaps(beforeParts, afterParts, gaps);
|
|
1717
|
-
return hasWordChangeRanges(ranges) ? ranges : void 0;
|
|
1718
|
-
}
|
|
1719
|
-
function isNarrowerThanWholeTokens(ranges, beforeToken, afterToken) {
|
|
1720
|
-
return ranges.removed.some((range) => range[0] > beforeToken.start || range[1] < beforeToken.end) || ranges.added.some((range) => range[0] > afterToken.start || range[1] < afterToken.end) || ranges.removed.length === 0 || ranges.added.length === 0;
|
|
1721
|
-
}
|
|
1722
|
-
function hasWordChangeRanges(ranges) {
|
|
1723
|
-
return ranges.removed.length > 0 || ranges.added.length > 0;
|
|
1724
|
-
}
|
|
1725
|
-
function tokenAt2(tokens, index) {
|
|
1726
|
-
const token = tokens[index];
|
|
1727
|
-
if (token === void 0) throw new RangeError(`Missing word-emphasis token ${index}`);
|
|
1728
|
-
return token;
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
|
-
// src/ui/word-diff/smart-filter.ts
|
|
1732
|
-
function filterLowSignalWordEmphasis(before, after, ranges) {
|
|
1733
|
-
const hasRemovedSignal = ranges.removed.some((range) => hasSmartRangeSignal(before, range));
|
|
1734
|
-
const hasAddedSignal = ranges.added.some((range) => hasSmartRangeSignal(after, range));
|
|
1735
|
-
return {
|
|
1736
|
-
removed: ranges.removed.filter(
|
|
1737
|
-
(range) => shouldKeepSmartRange(before.slice(range[0], range[1]), hasAddedSignal)
|
|
1738
|
-
),
|
|
1739
|
-
added: ranges.added.filter(
|
|
1740
|
-
(range) => shouldKeepSmartRange(after.slice(range[0], range[1]), hasRemovedSignal)
|
|
1741
|
-
)
|
|
1742
|
-
};
|
|
1743
|
-
}
|
|
1744
|
-
function hasSmartRangeSignal(content, range) {
|
|
1745
|
-
const tokens = wordTokenValues(content.slice(range[0], range[1]));
|
|
1746
|
-
return tokens.some(isSmartSignalToken);
|
|
1747
|
-
}
|
|
1748
|
-
function shouldKeepSmartRange(text, oppositeSideHasSignal) {
|
|
1749
|
-
const tokens = wordTokenValues(text);
|
|
1750
|
-
const signalTokens = tokens.filter(isSmartSignalToken);
|
|
1751
|
-
if (signalTokens.length === 0) return false;
|
|
1752
|
-
const wordTokens = signalTokens.filter(
|
|
1753
|
-
(token) => isIdentifierToken(token) || isNumberToken(token)
|
|
1754
|
-
);
|
|
1755
|
-
const hasIntrinsicSignal = signalTokens.some(
|
|
1756
|
-
(token) => isMeaningfulOperatorToken(token) || isSymbolToken(token)
|
|
1757
|
-
);
|
|
1758
|
-
if (!oppositeSideHasSignal && !hasIntrinsicSignal && wordTokens.every((token) => LOW_SIGNAL_SYNTAX_TOKENS.has(token)))
|
|
1759
|
-
return false;
|
|
1760
|
-
if (!oppositeSideHasSignal && !hasIntrinsicSignal && isWrapperCallNoise(text, wordTokens))
|
|
1761
|
-
return false;
|
|
1762
|
-
return true;
|
|
1763
|
-
}
|
|
1764
|
-
function isSmartSignalToken(token) {
|
|
1765
|
-
return isIdentifierToken(token) || isNumberToken(token) || isMeaningfulOperatorToken(token) || isSymbolToken(token);
|
|
1766
|
-
}
|
|
1767
|
-
var LOW_SIGNAL_SYNTAX_TOKENS = /* @__PURE__ */ new Set([
|
|
1768
|
-
"as",
|
|
1769
|
-
"const",
|
|
1770
|
-
"else",
|
|
1771
|
-
"export",
|
|
1772
|
-
"from",
|
|
1773
|
-
"function",
|
|
1774
|
-
"if",
|
|
1775
|
-
"import",
|
|
1776
|
-
"let",
|
|
1777
|
-
"var"
|
|
1778
|
-
]);
|
|
1779
|
-
var WRAPPER_CALL_TOKENS = /* @__PURE__ */ new Set(["filter", "flatMap", "forEach", "map", "reduce"]);
|
|
1780
|
-
function isWrapperCallNoise(text, tokens) {
|
|
1781
|
-
return tokens.length === 1 && tokens[0] !== void 0 && WRAPPER_CALL_TOKENS.has(tokens[0]) && /^[\s.()[\]{};,]*[$_\p{L}][$_\p{L}\p{N}\p{Mark}]*[\s.()[\]{};,]*$/u.test(text);
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
// src/ui/word-diff/emphasis.ts
|
|
1785
|
-
function shouldEmphasizeChangedPair(ranges, lineConfidence) {
|
|
1786
|
-
if (ranges.removed.length === 0 && ranges.added.length === 0) return false;
|
|
1787
|
-
if (lineConfidence === "low") return false;
|
|
1788
|
-
if (ranges.confidence === "low" && lineConfidence !== "high") return false;
|
|
1789
|
-
return true;
|
|
1790
|
-
}
|
|
1791
|
-
function changedRangesForTokensWithConfidence(before, after, beforeTokens, afterTokens, wordEmphasis) {
|
|
1792
|
-
if (wordEmphasis === "off") return emptyWordChangeRanges();
|
|
1793
|
-
const gaps = [];
|
|
1794
|
-
const alignmentConfidence = collectChangedTokenGaps(
|
|
1795
|
-
beforeTokens,
|
|
1796
|
-
0,
|
|
1797
|
-
beforeTokens.length,
|
|
1798
|
-
afterTokens,
|
|
1799
|
-
0,
|
|
1800
|
-
afterTokens.length,
|
|
1801
|
-
gaps
|
|
1802
|
-
);
|
|
1803
|
-
const ranges = refinedRangesForChangedTokens(before, beforeTokens, after, afterTokens, gaps);
|
|
1804
|
-
const confidence = hasWordChangeRanges2(ranges) ? alignmentConfidence : "low";
|
|
1805
|
-
if (wordEmphasis !== "smart") return { ...ranges, confidence };
|
|
1806
|
-
const filtered = filterLowSignalWordEmphasis(before, after, ranges);
|
|
1807
|
-
return { ...filtered, confidence: hasWordChangeRanges2(filtered) ? confidence : "low" };
|
|
1808
|
-
}
|
|
1809
|
-
function hasWordChangeRanges2(ranges) {
|
|
1810
|
-
return ranges.removed.length > 0 || ranges.added.length > 0;
|
|
1811
|
-
}
|
|
1812
|
-
function emptyWordChangeRanges() {
|
|
1813
|
-
return { removed: [], added: [], confidence: "low" };
|
|
1814
|
-
}
|
|
1815
|
-
|
|
1816
|
-
// src/ui/word-diff/change-block.ts
|
|
1817
|
-
function analyzeChangedLineBlock(block, wordEmphasis) {
|
|
1818
|
-
const removed = [];
|
|
1819
|
-
const added = [];
|
|
1820
|
-
for (let index = 0; index < block.length; index++) {
|
|
1821
|
-
const line = block[index];
|
|
1822
|
-
if (line === void 0) continue;
|
|
1823
|
-
if (isRemovedDiffLine(line)) removed.push(indexedChangedLine(index, line));
|
|
1824
|
-
else if (isAddedDiffLine(line)) added.push(indexedChangedLine(index, line));
|
|
1825
|
-
}
|
|
1826
|
-
const removedByIndex = new Map(removed.map((line) => [line.index, line]));
|
|
1827
|
-
const addedByIndex = new Map(added.map((line) => [line.index, line]));
|
|
1828
|
-
const pairs = matchChangedLines(removed, added);
|
|
1829
|
-
const ranges = [];
|
|
1830
|
-
for (const pair of pairs) {
|
|
1831
|
-
const removedLine = removedByIndex.get(pair.removedIndex);
|
|
1832
|
-
const addedLine = addedByIndex.get(pair.addedIndex);
|
|
1833
|
-
if (!removedLine || !addedLine) continue;
|
|
1834
|
-
ranges.push({
|
|
1835
|
-
pair,
|
|
1836
|
-
ranges: changedRangesForTokensWithConfidence(
|
|
1837
|
-
normalizedChangedContent(removedLine),
|
|
1838
|
-
normalizedChangedContent(addedLine),
|
|
1839
|
-
changedLineTokens(removedLine),
|
|
1840
|
-
changedLineTokens(addedLine),
|
|
1841
|
-
wordEmphasis
|
|
1842
|
-
)
|
|
1843
|
-
});
|
|
1844
|
-
}
|
|
1845
|
-
return { removed, added, pairs, ranges };
|
|
1846
|
-
}
|
|
1847
|
-
|
|
1848
|
-
// src/ui/word-diff/line-emphasis.ts
|
|
1849
|
-
var changedLineEmphasis = (block, wordEmphasis) => {
|
|
1850
|
-
const emphasis = /* @__PURE__ */ new Map();
|
|
1851
|
-
if (wordEmphasis === "off") return emphasis;
|
|
1852
|
-
for (const { pair, ranges } of analyzeChangedLineBlock(block, wordEmphasis).ranges) {
|
|
1853
|
-
if (!shouldEmphasizeChangedPair(ranges, pair.confidence)) continue;
|
|
1854
|
-
emphasis.set(pair.removedIndex, { ranges: ranges.removed, kind: "remove" });
|
|
1855
|
-
emphasis.set(pair.addedIndex, { ranges: ranges.added, kind: "add" });
|
|
1856
|
-
}
|
|
1857
|
-
return emphasis;
|
|
1858
|
-
};
|
|
1859
|
-
|
|
1860
242
|
// src/ui/core-tool-render.ts
|
|
1861
243
|
var CORE_TOOLS = /* @__PURE__ */ new Set(["bash", "powershell", "read", "write", "edit", "grep", "find", "ls"]);
|
|
1862
244
|
var isCoreToolAudit = (audit) => audit.tool !== void 0 && CORE_TOOLS.has(audit.tool) && (audit.provider === "pi" || audit.ref === `pi.${audit.tool}`);
|
|
@@ -1874,7 +256,7 @@ var recordOf = (value) => typeof value === "object" && value !== null && !Array.
|
|
|
1874
256
|
var stringOf = (value) => typeof value === "string" ? value : void 0;
|
|
1875
257
|
var numberOf = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1876
258
|
var argString = (audit, key) => stringOf(audit.args?.[key]);
|
|
1877
|
-
var
|
|
259
|
+
var escapeControlChars = (text) => text.replace(/\x1b/g, "\u241B").replace(/\r/g, "\u240D").replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/g, "\uFFFD");
|
|
1878
260
|
var expandTabs = (text) => text.replace(/\t/g, " ");
|
|
1879
261
|
var formatBytes = (bytes) => {
|
|
1880
262
|
if (bytes < 1024) return `${bytes} B`;
|
|
@@ -1902,7 +284,7 @@ var formatDisplayPath = (filePath, cwd) => {
|
|
|
1902
284
|
}
|
|
1903
285
|
return filePath;
|
|
1904
286
|
};
|
|
1905
|
-
var renderPath = (filePath, cwd, theme, fallback = "...") => theme.fg("accent",
|
|
287
|
+
var renderPath = (filePath, cwd, theme, fallback = "...") => theme.fg("accent", escapeControlChars(formatDisplayPath(filePath, cwd) || fallback));
|
|
1906
288
|
var normalizedResult = (audit) => {
|
|
1907
289
|
const preview = recordOf(audit.preview);
|
|
1908
290
|
return preview && "result" in preview ? preview.result : audit.result;
|
|
@@ -2063,7 +445,7 @@ var renderContent = (content, filePath, theme, options, config) => {
|
|
|
2063
445
|
let chunk = [];
|
|
2064
446
|
const flush = () => {
|
|
2065
447
|
if (chunk.length === 0) return;
|
|
2066
|
-
const normalized = chunk.map((entry) => expandTabs(
|
|
448
|
+
const normalized = chunk.map((entry) => expandTabs(escapeControlChars(entry.line)));
|
|
2067
449
|
const first = chunk[0];
|
|
2068
450
|
const from = (config.firstLine ?? 1) - 1 + first.index;
|
|
2069
451
|
const fileLines = absoluteFilePath && language && first.index + chunk.length <= selected.total ? highlightFileLines(
|
|
@@ -2094,7 +476,7 @@ var renderContent = (content, filePath, theme, options, config) => {
|
|
|
2094
476
|
rendered.push(theme.fg("muted", ` --- ${entry.hidden} lines hidden ---`));
|
|
2095
477
|
} else if (isBashTruncationNotice(entry.line)) {
|
|
2096
478
|
flush();
|
|
2097
|
-
const notice = theme.fg("muted",
|
|
479
|
+
const notice = theme.fg("muted", escapeControlChars(entry.line));
|
|
2098
480
|
if (config.lineNumbers) {
|
|
2099
481
|
const width = String((config.firstLine ?? 1) + selected.total - 1).length;
|
|
2100
482
|
const lineNumber = String((config.firstLine ?? 1) + entry.index).padStart(width, " ");
|
|
@@ -2197,8 +579,33 @@ var injectVisibleRanges = (ansi, ranges, open, close) => {
|
|
|
2197
579
|
if (active) out += close;
|
|
2198
580
|
return out;
|
|
2199
581
|
};
|
|
2200
|
-
var
|
|
582
|
+
var lineEmphasis;
|
|
583
|
+
var lineEmphasisLoad;
|
|
584
|
+
var lineEmphasisReadyCallbacks = /* @__PURE__ */ new Set();
|
|
585
|
+
var loadWordEmphasis = (invalidate) => {
|
|
586
|
+
if (invalidate && !lineEmphasis) lineEmphasisReadyCallbacks.add(invalidate);
|
|
587
|
+
return lineEmphasisLoad ??= import("../ui/word-diff/line-emphasis.js").then((module) => {
|
|
588
|
+
lineEmphasis = module;
|
|
589
|
+
const callbacks = [...lineEmphasisReadyCallbacks];
|
|
590
|
+
lineEmphasisReadyCallbacks.clear();
|
|
591
|
+
for (const callback of callbacks) {
|
|
592
|
+
try {
|
|
593
|
+
callback();
|
|
594
|
+
} catch {
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}, () => {
|
|
598
|
+
lineEmphasisReadyCallbacks.clear();
|
|
599
|
+
});
|
|
600
|
+
};
|
|
601
|
+
var wordEmphasisFor = (parsed, mode, invalidate) => {
|
|
2201
602
|
const emphasis = /* @__PURE__ */ new Map();
|
|
603
|
+
if (mode === "off") return emphasis;
|
|
604
|
+
if (!lineEmphasis) {
|
|
605
|
+
void loadWordEmphasis(invalidate);
|
|
606
|
+
return emphasis;
|
|
607
|
+
}
|
|
608
|
+
const { changedLineEmphasis } = lineEmphasis;
|
|
2202
609
|
let start = 0;
|
|
2203
610
|
while (start < parsed.length) {
|
|
2204
611
|
if (!parsed[start] || parsed[start].kind === " ") {
|
|
@@ -2258,8 +665,10 @@ var describeDiffShape = (summary) => {
|
|
|
2258
665
|
if (summary.deletions > 0) parts.push(countLabel(summary.deletions, "deletion"));
|
|
2259
666
|
return parts.length > 0 ? parts.join(", ") : "changes";
|
|
2260
667
|
};
|
|
668
|
+
var require2 = createRequire(import.meta.url);
|
|
669
|
+
var jsdiff;
|
|
2261
670
|
var createSimpleDiff = (before, after) => {
|
|
2262
|
-
const changes = diffLines(before, after);
|
|
671
|
+
const changes = (jsdiff ??= require2("diff")).diffLines(before, after);
|
|
2263
672
|
const hasChangeAfter = changes.map(() => false);
|
|
2264
673
|
let futureChange = false;
|
|
2265
674
|
for (let index = changes.length - 1; index >= 0; index--) {
|
|
@@ -2495,12 +904,12 @@ var renderDiff = (diff, filePath, theme, options, limitOverride) => {
|
|
|
2495
904
|
start = end;
|
|
2496
905
|
}
|
|
2497
906
|
}
|
|
2498
|
-
const emphasis = wordEmphasisFor(parsed, options.settings.wordEmphasis);
|
|
907
|
+
const emphasis = wordEmphasisFor(parsed, options.settings.wordEmphasis, options.invalidate);
|
|
2499
908
|
const emphasisColors = effectiveShikiThemeIsLight() ? { add: "\x1B[48;2;194;209;194m", remove: "\x1B[48;2;216;182;182m" } : { add: "\x1B[48;2;64;132;82m", remove: "\x1B[48;2;148;62;70m" };
|
|
2500
909
|
const lines = shown.map((raw, index) => {
|
|
2501
910
|
const line = parsed[index];
|
|
2502
911
|
if (!line) {
|
|
2503
|
-
const safe =
|
|
912
|
+
const safe = escapeControlChars(raw);
|
|
2504
913
|
const trimmed = safe.trim();
|
|
2505
914
|
if (trimmed === "...") return theme.fg("muted", " --- unchanged lines hidden ---");
|
|
2506
915
|
if (trimmed.startsWith("@@")) return theme.fg("accent", theme.bold(safe));
|
|
@@ -2510,7 +919,7 @@ var renderDiff = (diff, filePath, theme, options, limitOverride) => {
|
|
|
2510
919
|
return theme.fg("toolDiffContext", safe);
|
|
2511
920
|
}
|
|
2512
921
|
const truncationNotice = isBashTruncationNotice(line.content);
|
|
2513
|
-
let content = truncationNotice ? theme.fg("muted",
|
|
922
|
+
let content = truncationNotice ? theme.fg("muted", escapeControlChars(line.content)) : highlighted[index] ?? theme.fg("toolOutput", escapeControlChars(expandTabs(line.content)) || " ");
|
|
2514
923
|
const match = truncationNotice ? void 0 : emphasis.get(index);
|
|
2515
924
|
if (match && match.ranges.length > 0) {
|
|
2516
925
|
content = injectVisibleRanges(
|
|
@@ -2540,7 +949,7 @@ var renderRead = (audit, theme, options) => {
|
|
|
2540
949
|
if (output === void 0) return null;
|
|
2541
950
|
const filePath = argString(audit, "path") ?? "";
|
|
2542
951
|
if (/^Read image file/i.test(output)) {
|
|
2543
|
-
return { lines: [theme.fg("dim",
|
|
952
|
+
return { lines: [theme.fg("dim", escapeControlChars(output))], hidden: 0 };
|
|
2544
953
|
}
|
|
2545
954
|
const truncated = nativeTruncated(audit);
|
|
2546
955
|
const { content, notice } = truncated || typeof audit.args?.limit === "number" ? splitReadContinuationNotice(output) : { content: output };
|
|
@@ -2772,7 +1181,7 @@ var renderGrep = (audit, theme, options) => {
|
|
|
2772
1181
|
const highlighted = syntaxOn ? highlightGrepRun(run, currentLanguage, options) : [];
|
|
2773
1182
|
for (let index = 0; index < run.length; index++) {
|
|
2774
1183
|
const row = run[index];
|
|
2775
|
-
const content = highlighted[index] ?? theme.fg("toolOutput",
|
|
1184
|
+
const content = highlighted[index] ?? theme.fg("toolOutput", escapeControlChars(row.code));
|
|
2776
1185
|
lines.push(renderGrepRowLine(row, content, audit, theme));
|
|
2777
1186
|
}
|
|
2778
1187
|
run = [];
|
|
@@ -2789,7 +1198,7 @@ var renderGrep = (audit, theme, options) => {
|
|
|
2789
1198
|
if (!row) {
|
|
2790
1199
|
flushRun();
|
|
2791
1200
|
lines.push(
|
|
2792
|
-
entry.line.startsWith("[") && entry.line.endsWith("]") ? theme.fg("warning",
|
|
1201
|
+
entry.line.startsWith("[") && entry.line.endsWith("]") ? theme.fg("warning", escapeControlChars(entry.line)) : theme.fg("toolOutput", escapeControlChars(entry.line) || " ")
|
|
2793
1202
|
);
|
|
2794
1203
|
continue;
|
|
2795
1204
|
}
|
|
@@ -2797,7 +1206,7 @@ var renderGrep = (audit, theme, options) => {
|
|
|
2797
1206
|
flushRun();
|
|
2798
1207
|
currentPath = row.filePath;
|
|
2799
1208
|
currentLanguage = syntaxOn ? languageFromPath(row.filePath) : void 0;
|
|
2800
|
-
lines.push(theme.fg("accent",
|
|
1209
|
+
lines.push(theme.fg("accent", escapeControlChars(row.filePath)));
|
|
2801
1210
|
run.push(row);
|
|
2802
1211
|
continue;
|
|
2803
1212
|
}
|
|
@@ -2876,7 +1285,7 @@ var renderPathList = (audit, theme, options) => {
|
|
|
2876
1285
|
const raw = output.split("\n");
|
|
2877
1286
|
if (options.expanded && !enabled) {
|
|
2878
1287
|
return {
|
|
2879
|
-
lines: raw.map((line) => theme.fg("toolOutput",
|
|
1288
|
+
lines: raw.map((line) => theme.fg("toolOutput", escapeControlChars(line) || " ")),
|
|
2880
1289
|
hidden: 0
|
|
2881
1290
|
};
|
|
2882
1291
|
}
|
|
@@ -2889,7 +1298,7 @@ var renderPathList = (audit, theme, options) => {
|
|
|
2889
1298
|
const seenDirectories = /* @__PURE__ */ new Set();
|
|
2890
1299
|
for (const rawPath of chunk) {
|
|
2891
1300
|
if (rawPath.startsWith("[") && rawPath.endsWith("]")) {
|
|
2892
|
-
lines.push(theme.fg("warning",
|
|
1301
|
+
lines.push(theme.fg("warning", escapeControlChars(rawPath)));
|
|
2893
1302
|
continue;
|
|
2894
1303
|
}
|
|
2895
1304
|
if (!rawPath) {
|
|
@@ -2920,7 +1329,7 @@ var renderPathList = (audit, theme, options) => {
|
|
|
2920
1329
|
if (isDirectory) seenDirectories.add(key);
|
|
2921
1330
|
const icon = pathIcon(part, isDirectory, options.settings.pathIcons);
|
|
2922
1331
|
const indent = " ".repeat(index);
|
|
2923
|
-
const label = isDirectory ? theme.fg("accent", `${
|
|
1332
|
+
const label = isDirectory ? theme.fg("accent", `${escapeControlChars(part)}/`) : theme.fg("toolOutput", escapeControlChars(part));
|
|
2924
1333
|
lines.push(`${theme.fg("dim", indent + icon)}${icon ? " " : ""}${label}`);
|
|
2925
1334
|
}
|
|
2926
1335
|
prefix = key;
|
|
@@ -2944,7 +1353,7 @@ var renderBash = (audit, theme, options) => {
|
|
|
2944
1353
|
const resultEnabled = options.settings.bashResultPreview && (commandName === "grep" || commandName === "egrep" || commandName === "fgrep" ? options.settings.grepResultPreview : commandName === "find" ? options.settings.findResultPreview : commandName === "ls" ? options.settings.lsResultPreview : true);
|
|
2945
1354
|
if (!options.expanded && !resultEnabled) return null;
|
|
2946
1355
|
const command = bashCommand(audit);
|
|
2947
|
-
const displayCommand =
|
|
1356
|
+
const displayCommand = escapeControlChars(command.replace(/\r\n/g, "\n"));
|
|
2948
1357
|
const commandLines = displayCommand.split("\n");
|
|
2949
1358
|
const highlightedCommand = command ? highlightCode(
|
|
2950
1359
|
displayCommand,
|
|
@@ -2973,14 +1382,14 @@ var renderBash = (audit, theme, options) => {
|
|
|
2973
1382
|
lines.push(theme.fg("muted", ` --- ${entry.hidden} lines hidden ---`));
|
|
2974
1383
|
continue;
|
|
2975
1384
|
}
|
|
2976
|
-
const text = theme.fg(audit.success === false ? "error" : "muted",
|
|
1385
|
+
const text = theme.fg(audit.success === false ? "error" : "muted", escapeControlChars(entry.line) || " ");
|
|
2977
1386
|
lines.push(text);
|
|
2978
1387
|
}
|
|
2979
1388
|
if (nativeTruncated(audit)) {
|
|
2980
1389
|
pushArcItem(lines, arcItem(theme, `Output truncated by ${audit.tool ?? "shell"}`));
|
|
2981
1390
|
}
|
|
2982
1391
|
const fullOutputPath = stringOf(resultDetails(audit)?.fullOutputPath);
|
|
2983
|
-
if (fullOutputPath) pushArcItem(lines, arcItem(theme, `Full output: ${
|
|
1392
|
+
if (fullOutputPath) pushArcItem(lines, arcItem(theme, `Full output: ${escapeControlChars(fullOutputPath)}`));
|
|
2984
1393
|
return { lines, hidden: selected.hidden };
|
|
2985
1394
|
};
|
|
2986
1395
|
var coreToolRendererEnabled = (audit, settings) => isCoreToolAudit(audit) && audit.tool !== void 0 && settings.tools.includes(audit.tool);
|
|
@@ -3050,7 +1459,7 @@ var coreToolTitle = (audit, theme, options) => {
|
|
|
3050
1459
|
const timeout = numberOf(audit.args?.timeout);
|
|
3051
1460
|
const warnings = audit.tool === "bash" && options.settings.bashWarnings ? bashWarnings(command) : [];
|
|
3052
1461
|
const prompt = audit.tool === "powershell" ? "PS>" : "$";
|
|
3053
|
-
return `${title} ${theme.fg("dim", prompt)} ${highlighted ?? theme.fg("accent",
|
|
1462
|
+
return `${title} ${theme.fg("dim", prompt)} ${highlighted ?? theme.fg("accent", escapeControlChars(firstLine))}${metadata(theme, [
|
|
3054
1463
|
timeout !== void 0 ? `timeout ${timeout}s` : void 0,
|
|
3055
1464
|
warnings.length > 0 ? `\u26A0 ${warnings.join(", ")}` : void 0,
|
|
3056
1465
|
timing
|
|
@@ -3060,15 +1469,15 @@ var coreToolTitle = (audit, theme, options) => {
|
|
|
3060
1469
|
const pattern = argString(audit, "pattern") ?? "";
|
|
3061
1470
|
const glob = argString(audit, "glob");
|
|
3062
1471
|
const limit = numberOf(audit.args?.limit);
|
|
3063
|
-
return `${title} ${theme.fg("accent", `/${
|
|
3064
|
-
glob ?
|
|
1472
|
+
return `${title} ${theme.fg("accent", `/${escapeControlChars(pattern)}/`)} ${theme.fg("muted", "in")} ${renderPath(filePath || ".", options.cwd, theme)}${metadata(theme, [
|
|
1473
|
+
glob ? escapeControlChars(glob) : void 0,
|
|
3065
1474
|
limit !== void 0 ? `limit ${limit}` : void 0,
|
|
3066
1475
|
timing
|
|
3067
1476
|
])}`;
|
|
3068
1477
|
}
|
|
3069
1478
|
if (audit.tool === "find") {
|
|
3070
1479
|
const pattern = argString(audit, "pattern") || "*";
|
|
3071
|
-
return `${title} ${theme.fg("accent",
|
|
1480
|
+
return `${title} ${theme.fg("accent", escapeControlChars(pattern))} ${theme.fg("muted", "in")} ${renderPath(filePath || ".", options.cwd, theme)}${metadata(theme, [timing])}`;
|
|
3072
1481
|
}
|
|
3073
1482
|
if (audit.tool === "ls") {
|
|
3074
1483
|
return `${title} ${renderPath(filePath || ".", options.cwd, theme)}${metadata(theme, [timing])}`;
|
|
@@ -3480,6 +1889,8 @@ var providerCallDetail = (provider, tool, args, result, preview, previewHeadline
|
|
|
3480
1889
|
case "list":
|
|
3481
1890
|
case "models":
|
|
3482
1891
|
case "peers":
|
|
1892
|
+
case "departed":
|
|
1893
|
+
case "definitions":
|
|
3483
1894
|
return countOf(result);
|
|
3484
1895
|
default:
|
|
3485
1896
|
return previewName ?? id ?? "";
|
|
@@ -3549,7 +1960,7 @@ var callHeadlinePreview = (audit) => {
|
|
|
3549
1960
|
const provider = audit.provider ?? ref.split(".")[0] ?? ref;
|
|
3550
1961
|
const tool = audit.tool ?? ref.split(".")[1] ?? ref;
|
|
3551
1962
|
const args = audit.args ?? {};
|
|
3552
|
-
return providerCallDetail(provider, tool, args, audit.result, audit.preview) || headlineArg(args) || structuralCallDetail(provider, tool, args, audit.result);
|
|
1963
|
+
return providerCallDetail(provider, tool, args, audit.result, audit.preview) || (providerCallMetadata(ref, args)?.detail ?? headlineArg(args)) || structuralCallDetail(provider, tool, args, audit.result);
|
|
3553
1964
|
};
|
|
3554
1965
|
var nestedResultTruncated = (audit) => {
|
|
3555
1966
|
if (audit.resultTruncated === true) return true;
|
|
@@ -3573,7 +1984,9 @@ var nestedCallTitleText = (audit, theme, invalidate, core) => {
|
|
|
3573
1984
|
const ref = audit.ref;
|
|
3574
1985
|
const provider = audit.provider ?? ref.split(".")[0] ?? ref;
|
|
3575
1986
|
const tool = audit.tool ?? ref.split(".")[1] ?? ref;
|
|
3576
|
-
const
|
|
1987
|
+
const metadata2 = providerCallMetadata(ref, audit.args);
|
|
1988
|
+
const scopedTitle = metadata2 && !["agents", "mesh", "mcp", "fabric"].includes(provider) ? metadata2.title : tool;
|
|
1989
|
+
const title = theme.fg("toolTitle", theme.bold(scopedTitle));
|
|
3577
1990
|
const args = audit.args ?? {};
|
|
3578
1991
|
const providerDetail = providerCallDetail(
|
|
3579
1992
|
provider,
|
|
@@ -3584,6 +1997,10 @@ var nestedCallTitleText = (audit, theme, invalidate, core) => {
|
|
|
3584
1997
|
audit.previewHeadline
|
|
3585
1998
|
);
|
|
3586
1999
|
if (providerDetail) return withTiming(`${title} ${theme.fg("accent", providerDetail)}`);
|
|
2000
|
+
if (metadata2) {
|
|
2001
|
+
const detail2 = metadata2.detail || structuralCallDetail(provider, tool, args, audit.result) || audit.previewHeadline;
|
|
2002
|
+
return withTiming(detail2 ? `${title} ${theme.fg("accent", detail2)}` : title);
|
|
2003
|
+
}
|
|
3587
2004
|
const command = argString2(args, "command");
|
|
3588
2005
|
if (command) {
|
|
3589
2006
|
const firstLine = command.split("\n")[0] ?? "";
|
|
@@ -3731,6 +2148,10 @@ var renderAgentToolPreviewNodeLines = (preview, theme, options, depth) => {
|
|
|
3731
2148
|
}
|
|
3732
2149
|
return lines;
|
|
3733
2150
|
};
|
|
2151
|
+
var shellBackgroundShortcut = (audit) => {
|
|
2152
|
+
const preview = audit.preview;
|
|
2153
|
+
return audit.success === void 0 && (audit.tool === "bash" || audit.tool === "powershell") && typeof preview === "object" && preview !== null && preview.shellBackgroundShortcut === true;
|
|
2154
|
+
};
|
|
3734
2155
|
var singleCallProgressLine = (progress, previewLines) => progress && previewLines.length === 0 ? safeTerminalText(progress) : "";
|
|
3735
2156
|
var compactProgressPreview = (progress) => {
|
|
3736
2157
|
const lines = safeTerminalText(progress).split("\n").map((line) => line.replace(/\s+/g, " ").trim()).filter(Boolean);
|
|
@@ -3739,14 +2160,26 @@ var compactProgressPreview = (progress) => {
|
|
|
3739
2160
|
return `\u2026 ${lines.length - 1} ${lines.length === 2 ? "line" : "lines"} \xB7 ${latest}`;
|
|
3740
2161
|
};
|
|
3741
2162
|
var renderFabricMulticallPartial = (input, theme, invalidate) => {
|
|
3742
|
-
const
|
|
2163
|
+
const visible = input.audits.map((audit, index) => ({ audit, index })).filter(({ audit }) => !isRoutineInternalCall(audit));
|
|
2164
|
+
const previewIndex = input.preview ? visible.findIndex(({ index }) => index === input.preview.auditIndex) : -1;
|
|
2165
|
+
input = {
|
|
2166
|
+
...input,
|
|
2167
|
+
audits: visible.map(({ audit }) => audit),
|
|
2168
|
+
preview: input.preview && previewIndex >= 0 ? { ...input.preview, auditIndex: previewIndex } : void 0
|
|
2169
|
+
};
|
|
2170
|
+
const internal = input.omittedCalls?.internal ?? 0;
|
|
2171
|
+
const omitted = Math.max(0, (input.omittedCalls?.count ?? 0) - internal);
|
|
2172
|
+
const done = input.audits.filter((audit) => audit.success !== void 0).length + Math.max(0, (input.omittedCalls?.done ?? 0) - internal);
|
|
3743
2173
|
let header = theme.fg(
|
|
3744
2174
|
"warning",
|
|
3745
|
-
`\u25C6 ${input.activityLabel ?? "Fabric"} running \xB7 ${done}/${input.audits.length} calls`
|
|
2175
|
+
`\u25C6 ${input.activityLabel ?? "Fabric"} running \xB7 ${done}/${input.audits.length + omitted} calls`
|
|
3746
2176
|
);
|
|
3747
2177
|
const progress = input.progress ? compactProgressPreview(input.progress) : "";
|
|
3748
2178
|
if (progress) header += theme.fg("dim", ` \xB7 ${progress}`);
|
|
3749
2179
|
const rows = [header];
|
|
2180
|
+
if (input.audits.some(shellBackgroundShortcut)) {
|
|
2181
|
+
rows.push(theme.fg("dim", "Ctrl+B twice \xB7 background waiting shell"));
|
|
2182
|
+
}
|
|
3750
2183
|
const wrapLineIndexes = input.expanded ? /* @__PURE__ */ new Set() : void 0;
|
|
3751
2184
|
if (input.phases.length > 0) {
|
|
3752
2185
|
rows.push(theme.fg("dim", input.phases.map((phase) => `\u25C6 ${phase}`).join(" ")));
|
|
@@ -3789,7 +2222,7 @@ var renderFabricMulticallPartial = (input, theme, invalidate) => {
|
|
|
3789
2222
|
}
|
|
3790
2223
|
}
|
|
3791
2224
|
}
|
|
3792
|
-
const callsHidden = input.audits.length - callsShown.length;
|
|
2225
|
+
const callsHidden = input.audits.length + omitted - callsShown.length;
|
|
3793
2226
|
if (callsHidden > 0) {
|
|
3794
2227
|
const label = `\u2026 ${callsHidden} nested ${callsHidden === 1 ? "call" : "calls"} hidden`;
|
|
3795
2228
|
rows.push(
|
|
@@ -3919,7 +2352,7 @@ function nestedCallBody(audit) {
|
|
|
3919
2352
|
}
|
|
3920
2353
|
return void 0;
|
|
3921
2354
|
}
|
|
3922
|
-
var
|
|
2355
|
+
var escapeControlChars2 = (text) => text.replace(/\x1b/g, "\u241B").replace(/\r/g, "\u240D").replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, "\uFFFD");
|
|
3923
2356
|
var lineDiff = (oldLines, newLines) => {
|
|
3924
2357
|
const m = oldLines.length;
|
|
3925
2358
|
const n = newLines.length;
|
|
@@ -4004,7 +2437,7 @@ function nestedEditDiff(audit, theme, invalidate) {
|
|
|
4004
2437
|
oldCursor++;
|
|
4005
2438
|
text = newHighlighted?.[newCursor++];
|
|
4006
2439
|
}
|
|
4007
|
-
const content = text != null ? text || " " : theme.fg("toolOutput",
|
|
2440
|
+
const content = text != null ? text || " " : theme.fg("toolOutput", escapeControlChars2(entry.content) || " ");
|
|
4008
2441
|
if (entry.kind === "+") {
|
|
4009
2442
|
lines.push(`${theme.fg("toolDiffAdded", "+")} ${content}`);
|
|
4010
2443
|
} else if (entry.kind === "-") {
|
|
@@ -4043,9 +2476,9 @@ function modelReadHint(audits, output, theme) {
|
|
|
4043
2476
|
}
|
|
4044
2477
|
|
|
4045
2478
|
// src/ui/structured.ts
|
|
4046
|
-
import { createRequire } from "node:module";
|
|
2479
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
4047
2480
|
import { fileURLToPath } from "node:url";
|
|
4048
|
-
var
|
|
2481
|
+
var require3 = createRequire2(import.meta.url);
|
|
4049
2482
|
var yaml;
|
|
4050
2483
|
var normalizeJsonValue = (value) => {
|
|
4051
2484
|
try {
|
|
@@ -4058,7 +2491,7 @@ var normalizeJsonValue = (value) => {
|
|
|
4058
2491
|
var formatJsonAsYaml = (value) => {
|
|
4059
2492
|
const normalized = normalizeJsonValue(value);
|
|
4060
2493
|
if (normalized === void 0) return void 0;
|
|
4061
|
-
return (yaml ??=
|
|
2494
|
+
return (yaml ??= require3(fileURLToPath(import.meta.resolve("yaml")))).stringify(normalized, { indent: 2, lineWidth: 0 }).trimEnd();
|
|
4062
2495
|
};
|
|
4063
2496
|
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4064
2497
|
var hoistMultilineStrings = (value, path, sections, seen) => {
|
|
@@ -4180,6 +2613,7 @@ export {
|
|
|
4180
2613
|
renderFabricWriteArgumentPreview,
|
|
4181
2614
|
nestedCallTitle,
|
|
4182
2615
|
renderAgentToolPreviewLines,
|
|
2616
|
+
shellBackgroundShortcut,
|
|
4183
2617
|
singleCallProgressLine,
|
|
4184
2618
|
renderFabricMulticallPartial,
|
|
4185
2619
|
captureFabricCoreToolPreviews,
|
|
@@ -4196,4 +2630,4 @@ export {
|
|
|
4196
2630
|
formatJsonAsYaml,
|
|
4197
2631
|
formatFabricValue
|
|
4198
2632
|
};
|
|
4199
|
-
//# sourceMappingURL=chunk-
|
|
2633
|
+
//# sourceMappingURL=chunk-RKJPBTBB.js.map
|