@linghun/tui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -0
- package/dist/agent-completion-finalizer.d.ts +31 -0
- package/dist/agent-completion-finalizer.d.ts.map +1 -0
- package/dist/agent-completion-finalizer.js +20 -0
- package/dist/agent-handoff-safety.d.ts +13 -0
- package/dist/agent-handoff-safety.d.ts.map +1 -0
- package/dist/agent-handoff-safety.js +43 -0
- package/dist/agent-workflow-registry.d.ts +45 -0
- package/dist/agent-workflow-registry.d.ts.map +1 -0
- package/dist/agent-workflow-registry.js +12 -0
- package/dist/architecture-boundary.d.ts +151 -0
- package/dist/architecture-boundary.d.ts.map +1 -0
- package/dist/architecture-boundary.js +24 -0
- package/dist/architecture-runtime.d.ts +56 -0
- package/dist/architecture-runtime.d.ts.map +1 -0
- package/dist/architecture-runtime.js +18 -0
- package/dist/background-control-runtime.d.ts +29 -0
- package/dist/background-control-runtime.d.ts.map +1 -0
- package/dist/background-control-runtime.js +148 -0
- package/dist/bash-subcommand-parser.d.ts +34 -0
- package/dist/bash-subcommand-parser.d.ts.map +1 -0
- package/dist/bash-subcommand-parser.js +8 -0
- package/dist/batch-tool-confirmation.d.ts +18 -0
- package/dist/batch-tool-confirmation.d.ts.map +1 -0
- package/dist/batch-tool-confirmation.js +100 -0
- package/dist/break-cache-runtime.d.ts +40 -0
- package/dist/break-cache-runtime.d.ts.map +1 -0
- package/dist/break-cache-runtime.js +17 -0
- package/dist/btw-runtime.d.ts +45 -0
- package/dist/btw-runtime.d.ts.map +1 -0
- package/dist/btw-runtime.js +14 -0
- package/dist/cache-command-runtime.d.ts +22 -0
- package/dist/cache-command-runtime.d.ts.map +1 -0
- package/dist/cache-command-runtime.js +33 -0
- package/dist/cache-freshness.d.ts +26 -0
- package/dist/cache-freshness.d.ts.map +1 -0
- package/dist/cache-freshness.js +14 -0
- package/dist/capability-runtime.d.ts +75 -0
- package/dist/capability-runtime.d.ts.map +1 -0
- package/dist/capability-runtime.js +97 -0
- package/dist/chunk-2FVEKTKN.js +86 -0
- package/dist/chunk-2YL5VKJ5.js +531 -0
- package/dist/chunk-3AKXDMVS.js +85 -0
- package/dist/chunk-3GCIXKCI.js +221 -0
- package/dist/chunk-3LT6OWQ2.js +258 -0
- package/dist/chunk-3XNUDLOM.js +91 -0
- package/dist/chunk-4EIC5BCT.js +475 -0
- package/dist/chunk-4EP3TUFF.js +238 -0
- package/dist/chunk-4I2NWBOM.js +117 -0
- package/dist/chunk-4K6UB524.js +443 -0
- package/dist/chunk-4T5DJW54.js +88 -0
- package/dist/chunk-4WHZ6JKD.js +8105 -0
- package/dist/chunk-5H7RRF7C.js +6 -0
- package/dist/chunk-64MJP6FK.js +558 -0
- package/dist/chunk-66BNE332.js +1617 -0
- package/dist/chunk-6CI6TKLN.js +50 -0
- package/dist/chunk-6RJVTUWI.js +16 -0
- package/dist/chunk-6SMM5CMP.js +100 -0
- package/dist/chunk-6USL33ZO.js +289 -0
- package/dist/chunk-7ZE5JFAZ.js +760 -0
- package/dist/chunk-AKPXMCVF.js +1373 -0
- package/dist/chunk-AO4CXI37.js +284 -0
- package/dist/chunk-APJIC2O5.js +150 -0
- package/dist/chunk-B4GQTZMT.js +607 -0
- package/dist/chunk-BFVPLGAC.js +93 -0
- package/dist/chunk-BOV4K7FP.js +588 -0
- package/dist/chunk-CFMSB6ST.js +59 -0
- package/dist/chunk-CFXB5SE5.js +502 -0
- package/dist/chunk-CRQORMFF.js +32 -0
- package/dist/chunk-CRSLDQOA.js +146 -0
- package/dist/chunk-CRW3636S.js +214 -0
- package/dist/chunk-D3UTL2QX.js +86 -0
- package/dist/chunk-D7TCSOAZ.js +331 -0
- package/dist/chunk-DDXS2RDZ.js +228 -0
- package/dist/chunk-DICVLZHH.js +144 -0
- package/dist/chunk-DNQN74CC.js +1186 -0
- package/dist/chunk-DTK5NBTV.js +912 -0
- package/dist/chunk-E72U7WW7.js +50 -0
- package/dist/chunk-EBACIBJP.js +356 -0
- package/dist/chunk-ECFLCY5V.js +530 -0
- package/dist/chunk-EORRZP3F.js +109 -0
- package/dist/chunk-F43AMWLZ.js +115 -0
- package/dist/chunk-F46N43MG.js +56 -0
- package/dist/chunk-F6TVBCZV.js +51 -0
- package/dist/chunk-FRIMDSRU.js +242 -0
- package/dist/chunk-FTAEPAVY.js +314 -0
- package/dist/chunk-GC55DMZV.js +156 -0
- package/dist/chunk-GCMH5P4W.js +422 -0
- package/dist/chunk-GDQQNPBP.js +251 -0
- package/dist/chunk-GKZYTPN2.js +279 -0
- package/dist/chunk-GLWTWEGX.js +272 -0
- package/dist/chunk-GMUCSNUD.js +586 -0
- package/dist/chunk-GTP2KPLY.js +167 -0
- package/dist/chunk-GW5YDCRZ.js +42 -0
- package/dist/chunk-H3T4EF5F.js +87 -0
- package/dist/chunk-HAEU6OTS.js +381 -0
- package/dist/chunk-HQIJGQYU.js +172 -0
- package/dist/chunk-HW2TBXVK.js +34 -0
- package/dist/chunk-HWD22O6F.js +94 -0
- package/dist/chunk-I3NTAIMF.js +280 -0
- package/dist/chunk-IN42UISW.js +372 -0
- package/dist/chunk-IWUIOLMF.js +82 -0
- package/dist/chunk-J7ZE2JKP.js +283 -0
- package/dist/chunk-JBLVBO3U.js +109 -0
- package/dist/chunk-JDWXC2OQ.js +800 -0
- package/dist/chunk-JGDIO2NF.js +74 -0
- package/dist/chunk-JHGWGH2C.js +182 -0
- package/dist/chunk-JLCPHVBN.js +42 -0
- package/dist/chunk-JO5ANTMR.js +6027 -0
- package/dist/chunk-JPXSFZFC.js +100 -0
- package/dist/chunk-JQCRCDOC.js +1195 -0
- package/dist/chunk-K4FSYBSY.js +41 -0
- package/dist/chunk-K56D3X7S.js +1225 -0
- package/dist/chunk-KI7C6ZOD.js +92 -0
- package/dist/chunk-KO64OFSG.js +58 -0
- package/dist/chunk-KQJHVJZB.js +227 -0
- package/dist/chunk-KTWV5JC5.js +59 -0
- package/dist/chunk-L4XXW6Y5.js +374 -0
- package/dist/chunk-L5GOCMZP.js +18 -0
- package/dist/chunk-LDABZV5V.js +278 -0
- package/dist/chunk-LHHKPGLX.js +903 -0
- package/dist/chunk-LL7LBRDL.js +60 -0
- package/dist/chunk-LQTVYUT3.js +421 -0
- package/dist/chunk-LVIM2PA7.js +663 -0
- package/dist/chunk-M4AIK2SP.js +215 -0
- package/dist/chunk-MLUIOBKL.js +420 -0
- package/dist/chunk-MOJL4X4L.js +47 -0
- package/dist/chunk-MVONSJEN.js +300 -0
- package/dist/chunk-N7G2X2LK.js +709 -0
- package/dist/chunk-NKFKOEYX.js +146 -0
- package/dist/chunk-NMNOAFFT.js +167 -0
- package/dist/chunk-NSIKYD3X.js +74 -0
- package/dist/chunk-O7EFPSMC.js +60 -0
- package/dist/chunk-O7S3HYE6.js +210 -0
- package/dist/chunk-OEYW3JE3.js +262 -0
- package/dist/chunk-OF3K3CU5.js +159 -0
- package/dist/chunk-OMZYPQVA.js +298 -0
- package/dist/chunk-OZMX3E35.js +248 -0
- package/dist/chunk-P277M7Z5.js +303 -0
- package/dist/chunk-P4CPRJLI.js +65 -0
- package/dist/chunk-PBIPV4LD.js +494 -0
- package/dist/chunk-PGNALDEH.js +2003 -0
- package/dist/chunk-PGWW3DVE.js +157 -0
- package/dist/chunk-QB4VWH7W.js +515 -0
- package/dist/chunk-QBCGAIU7.js +120 -0
- package/dist/chunk-QIU3FJPC.js +99 -0
- package/dist/chunk-QLRTQHTR.js +744 -0
- package/dist/chunk-QTDGRZMZ.js +171 -0
- package/dist/chunk-RBOQJFIZ.js +183 -0
- package/dist/chunk-RDGM4RUE.js +178 -0
- package/dist/chunk-RM5JDRCW.js +71 -0
- package/dist/chunk-RM5QMOFY.js +189 -0
- package/dist/chunk-RMLTVKOY.js +588 -0
- package/dist/chunk-RVY34HK4.js +79 -0
- package/dist/chunk-S3YWTBXL.js +43 -0
- package/dist/chunk-SJOS5PM6.js +64 -0
- package/dist/chunk-SOPYWTFV.js +90 -0
- package/dist/chunk-SQIBPLLV.js +15 -0
- package/dist/chunk-SRZIA6B4.js +136 -0
- package/dist/chunk-SYBNJZEL.js +250 -0
- package/dist/chunk-TFZEFIQT.js +17 -0
- package/dist/chunk-THZBFYAH.js +136 -0
- package/dist/chunk-TJLC3QAS.js +83 -0
- package/dist/chunk-TYF4GJR3.js +598 -0
- package/dist/chunk-UDQT5CWK.js +252 -0
- package/dist/chunk-UOHZQIVL.js +168 -0
- package/dist/chunk-URNQUECO.js +187 -0
- package/dist/chunk-UT2TYK2A.js +148 -0
- package/dist/chunk-UT5BOJKU.js +190 -0
- package/dist/chunk-V7GDHHBL.js +526 -0
- package/dist/chunk-VCSRBS47.js +133 -0
- package/dist/chunk-VIBENDE3.js +152 -0
- package/dist/chunk-VTQL23UM.js +302 -0
- package/dist/chunk-W3KHJNSH.js +281 -0
- package/dist/chunk-W6NU7ZAV.js +52 -0
- package/dist/chunk-WHFDDZHY.js +407 -0
- package/dist/chunk-WJWYRBWH.js +48 -0
- package/dist/chunk-WKMBK5UP.js +145 -0
- package/dist/chunk-WQMSRO4D.js +489 -0
- package/dist/chunk-WV6YJGZR.js +81 -0
- package/dist/chunk-WVAQYKGL.js +269 -0
- package/dist/chunk-X7A22JHP.js +106 -0
- package/dist/chunk-XFPNU42I.js +59 -0
- package/dist/chunk-YH6UIHNF.js +161 -0
- package/dist/chunk-YPQFSFYK.js +19 -0
- package/dist/chunk-YTQFOZRZ.js +110 -0
- package/dist/chunk-ZJK25VFP.js +506 -0
- package/dist/chunk-ZOSK2UEU.js +1555 -0
- package/dist/chunk-ZYSN7AWW.js +336 -0
- package/dist/chunk-ZZ2CNCXJ.js +282 -0
- package/dist/command-panel-runtime.d.ts +33 -0
- package/dist/command-panel-runtime.d.ts.map +1 -0
- package/dist/command-panel-runtime.js +80 -0
- package/dist/compact-cache-command-runtime.d.ts +38 -0
- package/dist/compact-cache-command-runtime.d.ts.map +1 -0
- package/dist/compact-cache-command-runtime.js +146 -0
- package/dist/compact-context.d.ts +35 -0
- package/dist/compact-context.d.ts.map +1 -0
- package/dist/compact-context.js +16 -0
- package/dist/compact-preflight-runtime.d.ts +46 -0
- package/dist/compact-preflight-runtime.d.ts.map +1 -0
- package/dist/compact-preflight-runtime.js +62 -0
- package/dist/connector-runtime.d.ts +72 -0
- package/dist/connector-runtime.d.ts.map +1 -0
- package/dist/connector-runtime.js +88 -0
- package/dist/context-estimator.d.ts +20 -0
- package/dist/context-estimator.d.ts.map +1 -0
- package/dist/context-estimator.js +18 -0
- package/dist/context-window-runtime.d.ts +12 -0
- package/dist/context-window-runtime.d.ts.map +1 -0
- package/dist/context-window-runtime.js +10 -0
- package/dist/deep-compact-runtime.d.ts +53 -0
- package/dist/deep-compact-runtime.d.ts.map +1 -0
- package/dist/deep-compact-runtime.js +35 -0
- package/dist/deferred-tools-catalog.d.ts +52 -0
- package/dist/deferred-tools-catalog.d.ts.map +1 -0
- package/dist/deferred-tools-catalog.js +42 -0
- package/dist/details-status-runtime.d.ts +48 -0
- package/dist/details-status-runtime.d.ts.map +1 -0
- package/dist/details-status-runtime.js +102 -0
- package/dist/evidence-runtime.d.ts +48 -0
- package/dist/evidence-runtime.d.ts.map +1 -0
- package/dist/evidence-runtime.js +92 -0
- package/dist/extension-command-runtime.d.ts +63 -0
- package/dist/extension-command-runtime.d.ts.map +1 -0
- package/dist/extension-command-runtime.js +67 -0
- package/dist/extension-slash-runtime.d.ts +11 -0
- package/dist/extension-slash-runtime.d.ts.map +1 -0
- package/dist/extension-slash-runtime.js +79 -0
- package/dist/external-editor-runtime.d.ts +32 -0
- package/dist/external-editor-runtime.d.ts.map +1 -0
- package/dist/external-editor-runtime.js +71 -0
- package/dist/failure-learning-command-runtime.d.ts +10 -0
- package/dist/failure-learning-command-runtime.d.ts.map +1 -0
- package/dist/failure-learning-command-runtime.js +78 -0
- package/dist/failure-learning-presenter.d.ts +6 -0
- package/dist/failure-learning-presenter.d.ts.map +1 -0
- package/dist/failure-learning-presenter.js +12 -0
- package/dist/failure-learning-runtime.d.ts +39 -0
- package/dist/failure-learning-runtime.d.ts.map +1 -0
- package/dist/failure-learning-runtime.js +39 -0
- package/dist/feature-flag-runtime.d.ts +8 -0
- package/dist/feature-flag-runtime.d.ts.map +1 -0
- package/dist/feature-flag-runtime.js +12 -0
- package/dist/feishu-long-connection-runtime.d.ts +12 -0
- package/dist/feishu-long-connection-runtime.d.ts.map +1 -0
- package/dist/feishu-long-connection-runtime.js +7 -0
- package/dist/final-answer-gate.d.ts +24 -0
- package/dist/final-answer-gate.d.ts.map +1 -0
- package/dist/final-answer-gate.js +26 -0
- package/dist/ghost-text.d.ts +16 -0
- package/dist/ghost-text.d.ts.map +1 -0
- package/dist/ghost-text.js +8 -0
- package/dist/git-branch-runtime.d.ts +14 -0
- package/dist/git-branch-runtime.d.ts.map +1 -0
- package/dist/git-branch-runtime.js +68 -0
- package/dist/git-command-runtime.d.ts +22 -0
- package/dist/git-command-runtime.d.ts.map +1 -0
- package/dist/git-command-runtime.js +89 -0
- package/dist/git-operation-runtime.d.ts +188 -0
- package/dist/git-operation-runtime.d.ts.map +1 -0
- package/dist/git-operation-runtime.js +45 -0
- package/dist/git-runtime.d.ts +113 -0
- package/dist/git-runtime.d.ts.map +1 -0
- package/dist/git-runtime.js +16 -0
- package/dist/git-slash-runtime.d.ts +38 -0
- package/dist/git-slash-runtime.d.ts.map +1 -0
- package/dist/git-slash-runtime.js +18 -0
- package/dist/git-tool-dispatch-runtime.d.ts +108 -0
- package/dist/git-tool-dispatch-runtime.d.ts.map +1 -0
- package/dist/git-tool-dispatch-runtime.js +25 -0
- package/dist/git-tool-runtime.d.ts +64 -0
- package/dist/git-tool-runtime.d.ts.map +1 -0
- package/dist/git-tool-runtime.js +36 -0
- package/dist/guard-wiring.d.ts +67 -0
- package/dist/guard-wiring.d.ts.map +1 -0
- package/dist/guard-wiring.js +21 -0
- package/dist/handoff-session-runtime.d.ts +11 -0
- package/dist/handoff-session-runtime.d.ts.map +1 -0
- package/dist/handoff-session-runtime.js +36 -0
- package/dist/index-result-presenter.d.ts +14 -0
- package/dist/index-result-presenter.d.ts.map +1 -0
- package/dist/index-result-presenter.js +28 -0
- package/dist/index-runtime.d.ts +64 -0
- package/dist/index-runtime.d.ts.map +1 -0
- package/dist/index-runtime.js +28 -0
- package/dist/index-tool-runtime.d.ts +44 -0
- package/dist/index-tool-runtime.d.ts.map +1 -0
- package/dist/index-tool-runtime.js +24 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2346 -0
- package/dist/job-agent-command-runtime.d.ts +127 -0
- package/dist/job-agent-command-runtime.d.ts.map +1 -0
- package/dist/job-agent-command-runtime.js +138 -0
- package/dist/job-runner-presenter.d.ts +32 -0
- package/dist/job-runner-presenter.d.ts.map +1 -0
- package/dist/job-runner-presenter.js +30 -0
- package/dist/job-runtime.d.ts +65 -0
- package/dist/job-runtime.d.ts.map +1 -0
- package/dist/job-runtime.js +88 -0
- package/dist/keybinding-runtime.d.ts +29 -0
- package/dist/keybinding-runtime.d.ts.map +1 -0
- package/dist/keybinding-runtime.js +14 -0
- package/dist/log-artifact.d.ts +55 -0
- package/dist/log-artifact.d.ts.map +1 -0
- package/dist/log-artifact.js +10 -0
- package/dist/mcp-index-command-runtime.d.ts +21 -0
- package/dist/mcp-index-command-runtime.d.ts.map +1 -0
- package/dist/mcp-index-command-runtime.js +18 -0
- package/dist/mcp-index-runtime.d.ts +106 -0
- package/dist/mcp-index-runtime.d.ts.map +1 -0
- package/dist/mcp-index-runtime.js +142 -0
- package/dist/mcp-sse-runtime.d.ts +13 -0
- package/dist/mcp-sse-runtime.d.ts.map +1 -0
- package/dist/mcp-sse-runtime.js +8 -0
- package/dist/mcp-stdio-runtime.d.ts +37 -0
- package/dist/mcp-stdio-runtime.d.ts.map +1 -0
- package/dist/mcp-stdio-runtime.js +15 -0
- package/dist/memory-command-runtime.d.ts +37 -0
- package/dist/memory-command-runtime.d.ts.map +1 -0
- package/dist/memory-command-runtime.js +88 -0
- package/dist/memory-eviction-runtime.d.ts +7 -0
- package/dist/memory-eviction-runtime.d.ts.map +1 -0
- package/dist/memory-eviction-runtime.js +12 -0
- package/dist/memory-extraction-runtime.d.ts +40 -0
- package/dist/memory-extraction-runtime.d.ts.map +1 -0
- package/dist/memory-extraction-runtime.js +20 -0
- package/dist/memory-rules-runtime.d.ts +15 -0
- package/dist/memory-rules-runtime.d.ts.map +1 -0
- package/dist/memory-rules-runtime.js +14 -0
- package/dist/meta-scheduler-complexity.d.ts +16 -0
- package/dist/meta-scheduler-complexity.d.ts.map +1 -0
- package/dist/meta-scheduler-complexity.js +37 -0
- package/dist/meta-scheduler-runtime.d.ts +288 -0
- package/dist/meta-scheduler-runtime.d.ts.map +1 -0
- package/dist/meta-scheduler-runtime.js +17 -0
- package/dist/model-command-runtime.d.ts +12 -0
- package/dist/model-command-runtime.d.ts.map +1 -0
- package/dist/model-command-runtime.js +84 -0
- package/dist/model-doctor-runtime.d.ts +81 -0
- package/dist/model-doctor-runtime.d.ts.map +1 -0
- package/dist/model-doctor-runtime.js +46 -0
- package/dist/model-loop-runtime.d.ts +189 -0
- package/dist/model-loop-runtime.d.ts.map +1 -0
- package/dist/model-loop-runtime.js +141 -0
- package/dist/model-prompt-runtime.d.ts +25 -0
- package/dist/model-prompt-runtime.d.ts.map +1 -0
- package/dist/model-prompt-runtime.js +33 -0
- package/dist/model-setup-runtime.d.ts +28 -0
- package/dist/model-setup-runtime.d.ts.map +1 -0
- package/dist/model-setup-runtime.js +26 -0
- package/dist/model-stream-runtime.d.ts +47 -0
- package/dist/model-stream-runtime.d.ts.map +1 -0
- package/dist/model-stream-runtime.js +136 -0
- package/dist/model-tool-runtime.d.ts +114 -0
- package/dist/model-tool-runtime.d.ts.map +1 -0
- package/dist/model-tool-runtime.js +144 -0
- package/dist/natural-command-bridge.d.ts +158 -0
- package/dist/natural-command-bridge.d.ts.map +1 -0
- package/dist/natural-command-bridge.js +36 -0
- package/dist/pending-details-presenter.d.ts +8 -0
- package/dist/pending-details-presenter.d.ts.map +1 -0
- package/dist/pending-details-presenter.js +12 -0
- package/dist/permission-approval-runtime.d.ts +28 -0
- package/dist/permission-approval-runtime.d.ts.map +1 -0
- package/dist/permission-approval-runtime.js +136 -0
- package/dist/permission-continuation-runtime.d.ts +90 -0
- package/dist/permission-continuation-runtime.d.ts.map +1 -0
- package/dist/permission-continuation-runtime.js +68 -0
- package/dist/permission-policy-engine.d.ts +51 -0
- package/dist/permission-policy-engine.d.ts.map +1 -0
- package/dist/permission-policy-engine.js +12 -0
- package/dist/permission-presenter.d.ts +13 -0
- package/dist/permission-presenter.d.ts.map +1 -0
- package/dist/permission-presenter.js +8 -0
- package/dist/persistent-history.d.ts +18 -0
- package/dist/persistent-history.d.ts.map +1 -0
- package/dist/persistent-history.js +126 -0
- package/dist/platform-security.d.ts +4 -0
- package/dist/platform-security.d.ts.map +1 -0
- package/dist/platform-security.js +10 -0
- package/dist/process-command-runtime.d.ts +9 -0
- package/dist/process-command-runtime.d.ts.map +1 -0
- package/dist/process-command-runtime.js +11 -0
- package/dist/process-guard.d.ts +56 -0
- package/dist/process-guard.d.ts.map +1 -0
- package/dist/process-guard.js +22 -0
- package/dist/prompt-command-runtime.d.ts +12 -0
- package/dist/prompt-command-runtime.d.ts.map +1 -0
- package/dist/prompt-command-runtime.js +10 -0
- package/dist/prompt-stash.d.ts +15 -0
- package/dist/prompt-stash.d.ts.map +1 -0
- package/dist/prompt-stash.js +8 -0
- package/dist/provider-circuit-breaker.d.ts +132 -0
- package/dist/provider-circuit-breaker.d.ts.map +1 -0
- package/dist/provider-circuit-breaker.js +31 -0
- package/dist/provider-loop-runtime.d.ts +18 -0
- package/dist/provider-loop-runtime.d.ts.map +1 -0
- package/dist/provider-loop-runtime.js +16 -0
- package/dist/remote-command-runtime.d.ts +47 -0
- package/dist/remote-command-runtime.d.ts.map +1 -0
- package/dist/remote-command-runtime.js +125 -0
- package/dist/remote-inbound-bridge-runtime.d.ts +152 -0
- package/dist/remote-inbound-bridge-runtime.d.ts.map +1 -0
- package/dist/remote-inbound-bridge-runtime.js +44 -0
- package/dist/remote-mcp-presenter.d.ts +5 -0
- package/dist/remote-mcp-presenter.d.ts.map +1 -0
- package/dist/remote-mcp-presenter.js +10 -0
- package/dist/remote-repl-bridge-runtime.d.ts +134 -0
- package/dist/remote-repl-bridge-runtime.d.ts.map +1 -0
- package/dist/remote-repl-bridge-runtime.js +20 -0
- package/dist/remote-transport.d.ts +50 -0
- package/dist/remote-transport.d.ts.map +1 -0
- package/dist/remote-transport.js +14 -0
- package/dist/request-lifecycle-presenter.d.ts +25 -0
- package/dist/request-lifecycle-presenter.d.ts.map +1 -0
- package/dist/request-lifecycle-presenter.js +22 -0
- package/dist/runner-runtime.d.ts +41 -0
- package/dist/runner-runtime.d.ts.map +1 -0
- package/dist/runner-runtime.js +35 -0
- package/dist/runtime-budget.d.ts +38 -0
- package/dist/runtime-budget.d.ts.map +1 -0
- package/dist/runtime-budget.js +78 -0
- package/dist/runtime-path-marker.d.ts +112 -0
- package/dist/runtime-path-marker.d.ts.map +1 -0
- package/dist/runtime-path-marker.js +18 -0
- package/dist/runtime-status-presenter.d.ts +22 -0
- package/dist/runtime-status-presenter.d.ts.map +1 -0
- package/dist/runtime-status-presenter.js +15 -0
- package/dist/runtime-status-snapshot.d.ts +52 -0
- package/dist/runtime-status-snapshot.d.ts.map +1 -0
- package/dist/runtime-status-snapshot.js +11 -0
- package/dist/runtime-utils.d.ts +2 -0
- package/dist/runtime-utils.d.ts.map +1 -0
- package/dist/runtime-utils.js +6 -0
- package/dist/shell/clipboard.d.ts +23 -0
- package/dist/shell/clipboard.d.ts.map +1 -0
- package/dist/shell/clipboard.js +8 -0
- package/dist/shell/components/AgentProgressTree.d.ts +9 -0
- package/dist/shell/components/AgentProgressTree.d.ts.map +1 -0
- package/dist/shell/components/AgentProgressTree.js +9 -0
- package/dist/shell/components/BackgroundTaskOverlay.d.ts +8 -0
- package/dist/shell/components/BackgroundTaskOverlay.d.ts.map +1 -0
- package/dist/shell/components/BackgroundTaskOverlay.js +8 -0
- package/dist/shell/components/BtwPanel.d.ts +16 -0
- package/dist/shell/components/BtwPanel.d.ts.map +1 -0
- package/dist/shell/components/BtwPanel.js +8 -0
- package/dist/shell/components/CommandPanel.d.ts +11 -0
- package/dist/shell/components/CommandPanel.d.ts.map +1 -0
- package/dist/shell/components/CommandPanel.js +8 -0
- package/dist/shell/components/Composer.d.ts +187 -0
- package/dist/shell/components/Composer.d.ts.map +1 -0
- package/dist/shell/components/Composer.js +99 -0
- package/dist/shell/components/ConfigPanel.d.ts +11 -0
- package/dist/shell/components/ConfigPanel.d.ts.map +1 -0
- package/dist/shell/components/ConfigPanel.js +8 -0
- package/dist/shell/components/CtrlOToExpand.d.ts +30 -0
- package/dist/shell/components/CtrlOToExpand.d.ts.map +1 -0
- package/dist/shell/components/CtrlOToExpand.js +16 -0
- package/dist/shell/components/HelpPanel.d.ts +19 -0
- package/dist/shell/components/HelpPanel.d.ts.map +1 -0
- package/dist/shell/components/HelpPanel.js +8 -0
- package/dist/shell/components/HistorySearchPanel.d.ts +14 -0
- package/dist/shell/components/HistorySearchPanel.d.ts.map +1 -0
- package/dist/shell/components/HistorySearchPanel.js +104 -0
- package/dist/shell/components/MessageMarkdown.d.ts +34 -0
- package/dist/shell/components/MessageMarkdown.d.ts.map +1 -0
- package/dist/shell/components/MessageMarkdown.js +18 -0
- package/dist/shell/components/MessageResponse.d.ts +14 -0
- package/dist/shell/components/MessageResponse.d.ts.map +1 -0
- package/dist/shell/components/MessageResponse.js +6 -0
- package/dist/shell/components/MouseInputRouter.d.ts +28 -0
- package/dist/shell/components/MouseInputRouter.d.ts.map +1 -0
- package/dist/shell/components/MouseInputRouter.js +84 -0
- package/dist/shell/components/NotificationStack.d.ts +19 -0
- package/dist/shell/components/NotificationStack.d.ts.map +1 -0
- package/dist/shell/components/NotificationStack.js +6 -0
- package/dist/shell/components/OutputLine.d.ts +19 -0
- package/dist/shell/components/OutputLine.d.ts.map +1 -0
- package/dist/shell/components/OutputLine.js +38 -0
- package/dist/shell/components/ProductBlock.d.ts +10 -0
- package/dist/shell/components/ProductBlock.d.ts.map +1 -0
- package/dist/shell/components/ProductBlock.js +12 -0
- package/dist/shell/components/ScrollViewport.d.ts +43 -0
- package/dist/shell/components/ScrollViewport.d.ts.map +1 -0
- package/dist/shell/components/ScrollViewport.js +86 -0
- package/dist/shell/components/SessionsPanel.d.ts +24 -0
- package/dist/shell/components/SessionsPanel.d.ts.map +1 -0
- package/dist/shell/components/SessionsPanel.js +8 -0
- package/dist/shell/components/ShellApp.d.ts +8 -0
- package/dist/shell/components/ShellApp.d.ts.map +1 -0
- package/dist/shell/components/ShellApp.js +45 -0
- package/dist/shell/components/ShortcutPanel.d.ts +14 -0
- package/dist/shell/components/ShortcutPanel.d.ts.map +1 -0
- package/dist/shell/components/ShortcutPanel.js +59 -0
- package/dist/shell/components/SlashSuggestions.d.ts +24 -0
- package/dist/shell/components/SlashSuggestions.d.ts.map +1 -0
- package/dist/shell/components/SlashSuggestions.js +7 -0
- package/dist/shell/components/StatusFooter.d.ts +30 -0
- package/dist/shell/components/StatusFooter.d.ts.map +1 -0
- package/dist/shell/components/StatusFooter.js +7 -0
- package/dist/shell/components/StatusTray.d.ts +9 -0
- package/dist/shell/components/StatusTray.d.ts.map +1 -0
- package/dist/shell/components/StatusTray.js +6 -0
- package/dist/shell/components/StructuredDiff.d.ts +9 -0
- package/dist/shell/components/StructuredDiff.d.ts.map +1 -0
- package/dist/shell/components/StructuredDiff.js +7 -0
- package/dist/shell/components/TaskListView.d.ts +9 -0
- package/dist/shell/components/TaskListView.d.ts.map +1 -0
- package/dist/shell/components/TaskListView.js +9 -0
- package/dist/shell/components/TaskSuggestionBar.d.ts +15 -0
- package/dist/shell/components/TaskSuggestionBar.d.ts.map +1 -0
- package/dist/shell/components/TaskSuggestionBar.js +8 -0
- package/dist/shell/components/UnseenMessagePill.d.ts +12 -0
- package/dist/shell/components/UnseenMessagePill.d.ts.map +1 -0
- package/dist/shell/components/UnseenMessagePill.js +6 -0
- package/dist/shell/components/WorkflowProgressView.d.ts +9 -0
- package/dist/shell/components/WorkflowProgressView.d.ts.map +1 -0
- package/dist/shell/components/WorkflowProgressView.js +9 -0
- package/dist/shell/components/useAnchoredCursor.d.ts +32 -0
- package/dist/shell/components/useAnchoredCursor.d.ts.map +1 -0
- package/dist/shell/components/useAnchoredCursor.js +6 -0
- package/dist/shell/hooks/useRenderThrottle.d.ts +2 -0
- package/dist/shell/hooks/useRenderThrottle.d.ts.map +1 -0
- package/dist/shell/hooks/useRenderThrottle.js +35 -0
- package/dist/shell/hooks/useScrollBatcher.d.ts +10 -0
- package/dist/shell/hooks/useScrollBatcher.d.ts.map +1 -0
- package/dist/shell/hooks/useScrollBatcher.js +23 -0
- package/dist/shell/hooks/useScrollRuntime.d.ts +2 -0
- package/dist/shell/hooks/useScrollRuntime.d.ts.map +1 -0
- package/dist/shell/hooks/useScrollRuntime.js +6 -0
- package/dist/shell/hyperlink-utils.d.ts +18 -0
- package/dist/shell/hyperlink-utils.d.ts.map +1 -0
- package/dist/shell/hyperlink-utils.js +8 -0
- package/dist/shell/ink-renderer.d.ts +18 -0
- package/dist/shell/ink-renderer.d.ts.map +1 -0
- package/dist/shell/ink-renderer.js +54 -0
- package/dist/shell/models/command-transcript-presenter.d.ts +73 -0
- package/dist/shell/models/command-transcript-presenter.d.ts.map +1 -0
- package/dist/shell/models/command-transcript-presenter.js +26 -0
- package/dist/shell/models/help-panel.d.ts +37 -0
- package/dist/shell/models/help-panel.d.ts.map +1 -0
- package/dist/shell/models/help-panel.js +10 -0
- package/dist/shell/models/permission-elevation.d.ts +65 -0
- package/dist/shell/models/permission-elevation.d.ts.map +1 -0
- package/dist/shell/models/permission-elevation.js +10 -0
- package/dist/shell/models/permission-explanation.d.ts +45 -0
- package/dist/shell/models/permission-explanation.d.ts.map +1 -0
- package/dist/shell/models/permission-explanation.js +14 -0
- package/dist/shell/models/session-panel.d.ts +22 -0
- package/dist/shell/models/session-panel.d.ts.map +1 -0
- package/dist/shell/models/session-panel.js +18 -0
- package/dist/shell/models/task-scroll-state.d.ts +24 -0
- package/dist/shell/models/task-scroll-state.d.ts.map +1 -0
- package/dist/shell/models/task-scroll-state.js +26 -0
- package/dist/shell/models/terminal-input-runtime.d.ts +37 -0
- package/dist/shell/models/terminal-input-runtime.d.ts.map +1 -0
- package/dist/shell/models/terminal-input-runtime.js +18 -0
- package/dist/shell/models/transcript-scroll-state.d.ts +57 -0
- package/dist/shell/models/transcript-scroll-state.d.ts.map +1 -0
- package/dist/shell/models/transcript-scroll-state.js +12 -0
- package/dist/shell/models/transcript-selection-state.d.ts +39 -0
- package/dist/shell/models/transcript-selection-state.d.ts.map +1 -0
- package/dist/shell/models/transcript-selection-state.js +25 -0
- package/dist/shell/models/wheel-acceleration.d.ts +52 -0
- package/dist/shell/models/wheel-acceleration.d.ts.map +1 -0
- package/dist/shell/models/wheel-acceleration.js +6 -0
- package/dist/shell/output-utils.d.ts +22 -0
- package/dist/shell/output-utils.d.ts.map +1 -0
- package/dist/shell/output-utils.js +12 -0
- package/dist/shell/plain-renderer.d.ts +12 -0
- package/dist/shell/plain-renderer.d.ts.map +1 -0
- package/dist/shell/plain-renderer.js +13 -0
- package/dist/shell/progress-views.d.ts +10 -0
- package/dist/shell/progress-views.d.ts.map +1 -0
- package/dist/shell/progress-views.js +17 -0
- package/dist/shell/stdout-flush-barrier.d.ts +39 -0
- package/dist/shell/stdout-flush-barrier.d.ts.map +1 -0
- package/dist/shell/stdout-flush-barrier.js +10 -0
- package/dist/shell/terminal-capability.d.ts +54 -0
- package/dist/shell/terminal-capability.d.ts.map +1 -0
- package/dist/shell/terminal-capability.js +10 -0
- package/dist/shell/terminal-interaction-runtime.d.ts +11 -0
- package/dist/shell/terminal-interaction-runtime.d.ts.map +1 -0
- package/dist/shell/terminal-interaction-runtime.js +38 -0
- package/dist/shell/terminal-state-recovery.d.ts +52 -0
- package/dist/shell/terminal-state-recovery.d.ts.map +1 -0
- package/dist/shell/terminal-state-recovery.js +11 -0
- package/dist/shell/text-utils.d.ts +40 -0
- package/dist/shell/text-utils.d.ts.map +1 -0
- package/dist/shell/text-utils.js +26 -0
- package/dist/shell/theme.d.ts +41 -0
- package/dist/shell/theme.d.ts.map +1 -0
- package/dist/shell/theme.js +8 -0
- package/dist/shell/types.d.ts +784 -0
- package/dist/shell/types.d.ts.map +1 -0
- package/dist/shell/types.js +0 -0
- package/dist/shell/view-model.d.ts +82 -0
- package/dist/shell/view-model.d.ts.map +1 -0
- package/dist/shell/view-model.js +48 -0
- package/dist/slash-command-runtime.d.ts +64 -0
- package/dist/slash-command-runtime.d.ts.map +1 -0
- package/dist/slash-command-runtime.js +186 -0
- package/dist/slash-dispatch.d.ts +48 -0
- package/dist/slash-dispatch.d.ts.map +1 -0
- package/dist/slash-dispatch.js +53 -0
- package/dist/startup-runtime.d.ts +48 -0
- package/dist/startup-runtime.d.ts.map +1 -0
- package/dist/startup-runtime.js +43 -0
- package/dist/terminal-readiness-presenter.d.ts +131 -0
- package/dist/terminal-readiness-presenter.d.ts.map +1 -0
- package/dist/terminal-readiness-presenter.js +16 -0
- package/dist/terminal-readiness-runtime.d.ts +5 -0
- package/dist/terminal-readiness-runtime.d.ts.map +1 -0
- package/dist/terminal-readiness-runtime.js +15 -0
- package/dist/terminal-setup-runtime.d.ts +34 -0
- package/dist/terminal-setup-runtime.d.ts.map +1 -0
- package/dist/terminal-setup-runtime.js +257 -0
- package/dist/tool-output-presenter.d.ts +38 -0
- package/dist/tool-output-presenter.d.ts.map +1 -0
- package/dist/tool-output-presenter.js +16 -0
- package/dist/tool-result-budget.d.ts +42 -0
- package/dist/tool-result-budget.d.ts.map +1 -0
- package/dist/tool-result-budget.js +11 -0
- package/dist/tui-agent-job-runtime.d.ts +38 -0
- package/dist/tui-agent-job-runtime.d.ts.map +1 -0
- package/dist/tui-agent-job-runtime.js +86 -0
- package/dist/tui-context-runtime.d.ts +426 -0
- package/dist/tui-context-runtime.d.ts.map +1 -0
- package/dist/tui-context-runtime.js +65 -0
- package/dist/tui-data-types.d.ts +923 -0
- package/dist/tui-data-types.d.ts.map +1 -0
- package/dist/tui-data-types.js +0 -0
- package/dist/tui-details-runtime.d.ts +25 -0
- package/dist/tui-details-runtime.d.ts.map +1 -0
- package/dist/tui-details-runtime.js +29 -0
- package/dist/tui-memory-runtime.d.ts +33 -0
- package/dist/tui-memory-runtime.d.ts.map +1 -0
- package/dist/tui-memory-runtime.js +58 -0
- package/dist/tui-messages.d.ts +4 -0
- package/dist/tui-messages.d.ts.map +1 -0
- package/dist/tui-messages.js +6 -0
- package/dist/tui-model-runtime.d.ts +30 -0
- package/dist/tui-model-runtime.d.ts.map +1 -0
- package/dist/tui-model-runtime.js +39 -0
- package/dist/tui-output-surface.d.ts +141 -0
- package/dist/tui-output-surface.d.ts.map +1 -0
- package/dist/tui-output-surface.js +55 -0
- package/dist/tui-permission-runtime.d.ts +62 -0
- package/dist/tui-permission-runtime.d.ts.map +1 -0
- package/dist/tui-permission-runtime.js +24 -0
- package/dist/tui-state-runtime.d.ts +21 -0
- package/dist/tui-state-runtime.d.ts.map +1 -0
- package/dist/tui-state-runtime.js +47 -0
- package/dist/turn-continuity-runtime.d.ts +30 -0
- package/dist/turn-continuity-runtime.d.ts.map +1 -0
- package/dist/turn-continuity-runtime.js +8 -0
- package/dist/undo-ring.d.ts +16 -0
- package/dist/undo-ring.d.ts.map +1 -0
- package/dist/undo-ring.js +12 -0
- package/dist/usage-stats-presenter.d.ts +17 -0
- package/dist/usage-stats-presenter.d.ts.map +1 -0
- package/dist/usage-stats-presenter.js +22 -0
- package/dist/user-state-signal-runtime.d.ts +33 -0
- package/dist/user-state-signal-runtime.d.ts.map +1 -0
- package/dist/user-state-signal-runtime.js +8 -0
- package/dist/verification-command-runtime.d.ts +25 -0
- package/dist/verification-command-runtime.d.ts.map +1 -0
- package/dist/verification-command-runtime.js +51 -0
- package/dist/verification-level.d.ts +93 -0
- package/dist/verification-level.d.ts.map +1 -0
- package/dist/verification-level.js +18 -0
- package/dist/workflow-agent-runtime-bridge.d.ts +169 -0
- package/dist/workflow-agent-runtime-bridge.d.ts.map +1 -0
- package/dist/workflow-agent-runtime-bridge.js +9 -0
- package/dist/workflow-command-runtime.d.ts +94 -0
- package/dist/workflow-command-runtime.d.ts.map +1 -0
- package/dist/workflow-command-runtime.js +114 -0
- package/dist/workflow-plan-schema.d.ts +161 -0
- package/dist/workflow-plan-schema.d.ts.map +1 -0
- package/dist/workflow-plan-schema.js +12 -0
- package/dist/workflow-planner-entry.d.ts +52 -0
- package/dist/workflow-planner-entry.d.ts.map +1 -0
- package/dist/workflow-planner-entry.js +328 -0
- package/dist/workflow-task-surface.d.ts +39 -0
- package/dist/workflow-task-surface.d.ts.map +1 -0
- package/dist/workflow-task-surface.js +7 -0
- package/dist/workspace-reference-cache.d.ts +110 -0
- package/dist/workspace-reference-cache.d.ts.map +1 -0
- package/dist/workspace-reference-cache.js +12 -0
- package/package.json +41 -0
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createOutputBlock
|
|
3
|
+
} from "./chunk-AKPXMCVF.js";
|
|
4
|
+
import {
|
|
5
|
+
writeLine
|
|
6
|
+
} from "./chunk-OMZYPQVA.js";
|
|
7
|
+
|
|
8
|
+
// src/tui-output-surface.ts
|
|
9
|
+
import { createHash, randomUUID } from "crypto";
|
|
10
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
11
|
+
import { join, relative } from "path";
|
|
12
|
+
import { Writable } from "stream";
|
|
13
|
+
import { TOGGLE_DETAILS_KEYBIND, formatDiagnosticError } from "@linghun/shared";
|
|
14
|
+
var MAX_OUTPUT_BLOCKS = 80;
|
|
15
|
+
var PRESERVE_RECENT_EPHEMERAL_BLOCKS = 12;
|
|
16
|
+
var MAX_LAST_FULL_OUTPUT_CHARS = 12e3;
|
|
17
|
+
var MAX_BLOCK_FULL_TEXT_CHARS = 12e3;
|
|
18
|
+
var LAST_FULL_OUTPUT_PREVIEW_CHARS = 2e3;
|
|
19
|
+
var OUTPUT_MEMORY_ARTIFACT_DIR = "tui-output";
|
|
20
|
+
var MAX_STREAMING_SUMMARY_CHARS = 500;
|
|
21
|
+
function isRuntimeStatusDump(line) {
|
|
22
|
+
if (line.startsWith("[Linghun] \u4F1A\u8BDD ")) return true;
|
|
23
|
+
if (line.startsWith("[Linghun] \u6A21\u578B ") && line.includes(" \xB7 \u540E\u53F0 ")) return true;
|
|
24
|
+
if (line.startsWith("Status: Session ")) return true;
|
|
25
|
+
if (line.startsWith("Status: Model ") && line.includes(" \xB7 background ")) return true;
|
|
26
|
+
if (line.includes("\u786E\u8BA4 ") && line.includes("\u540E\u53F0 ")) return true;
|
|
27
|
+
if (line.includes("Gate ") && line.includes("BG ")) return true;
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
var ShellBlockOutput = class extends Writable {
|
|
31
|
+
constructor(context, blocks, onWrite) {
|
|
32
|
+
super();
|
|
33
|
+
this.context = context;
|
|
34
|
+
this.blocks = blocks;
|
|
35
|
+
this.onWrite = onWrite;
|
|
36
|
+
}
|
|
37
|
+
context;
|
|
38
|
+
blocks;
|
|
39
|
+
onWrite;
|
|
40
|
+
/**
|
|
41
|
+
* 当前 active 的 assistant streaming block id(keep:true,由
|
|
42
|
+
* beginAssistantStream 注册)。endAssistantStream 之后清空,下一轮
|
|
43
|
+
* 再 begin 时换新 id。
|
|
44
|
+
*
|
|
45
|
+
* 这条路径专门绕开 _write 的 createOutputBlock + ephemeral splice 逻辑:
|
|
46
|
+
* 流式 assistant_text_delta 不应被当作普通 writeLine 反复 push/splice,
|
|
47
|
+
* 否则只会留下最后一片 chunk 而非完整文本。
|
|
48
|
+
*/
|
|
49
|
+
assistantBlockId;
|
|
50
|
+
compactOutputMemoryQueue = Promise.resolve();
|
|
51
|
+
assistantStreamText = "";
|
|
52
|
+
assistantPreviewText = "";
|
|
53
|
+
_write(chunk, _encoding, callback) {
|
|
54
|
+
const text = chunk.toString();
|
|
55
|
+
const normalized = text.trim();
|
|
56
|
+
if (normalized) {
|
|
57
|
+
if (isRuntimeStatusDump(normalized)) {
|
|
58
|
+
callback();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.blocks.push(createOutputBlock(normalized, this.context.language));
|
|
62
|
+
if (!this.context.suppressLastFullOutputCapture) {
|
|
63
|
+
this.context.lastFullOutput = normalized;
|
|
64
|
+
}
|
|
65
|
+
this.compactOutputMemory().catch((error) => {
|
|
66
|
+
void this.appendCompactOutputMemoryWarning(error);
|
|
67
|
+
});
|
|
68
|
+
this.onWrite();
|
|
69
|
+
}
|
|
70
|
+
callback();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 注册一条 assistant streaming preview id,但 **不立即** 推入 blocks 数组。
|
|
74
|
+
* 真正的 keep:true block 只在 end/replace 时提交。这样在
|
|
75
|
+
* thinking-only / 空响应 / 慢请求等场景下,
|
|
76
|
+
* 主屏不会出现一条空 block 渲染成"没有可见输出。"占位行 —— 等待态由
|
|
77
|
+
* requestActivityPhase / mapRequestActivityToView 驱动的 ActivityIndicator
|
|
78
|
+
* 单独负责("正在思考…" / "Thinking…")。
|
|
79
|
+
*
|
|
80
|
+
* id 由调用方传入(每个 request 用一个稳定 id),便于多轮请求各自占用
|
|
81
|
+
* 独立 block,互不覆盖。
|
|
82
|
+
*/
|
|
83
|
+
beginAssistantStream(id) {
|
|
84
|
+
if (this.assistantBlockId && this.assistantBlockId !== id) {
|
|
85
|
+
this.clearStreamingPreview(this.assistantBlockId);
|
|
86
|
+
}
|
|
87
|
+
this.assistantBlockId = id;
|
|
88
|
+
this.assistantStreamText = "";
|
|
89
|
+
this.assistantPreviewText = "";
|
|
90
|
+
this.context.streamingAssistant = void 0;
|
|
91
|
+
this.setStreamingPreview(id, "");
|
|
92
|
+
this.onWrite();
|
|
93
|
+
}
|
|
94
|
+
ensureAssistantBlock(id) {
|
|
95
|
+
const existing = this.blocks.find((b) => b.id === id);
|
|
96
|
+
if (existing) return existing;
|
|
97
|
+
const block = createOutputBlock("", this.context.language, id);
|
|
98
|
+
block.keep = true;
|
|
99
|
+
block.fullText = "";
|
|
100
|
+
block.nextAction = void 0;
|
|
101
|
+
this.blocks.push(block);
|
|
102
|
+
return block;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 将一段 assistant_text_delta 追加到当前 streaming preview。
|
|
106
|
+
* - 流式期间只更新 visible-only streaming state,不写历史 ProductBlock
|
|
107
|
+
* - 正式 assistant block 在 end/replace 时一次性接管,避免重复显示
|
|
108
|
+
* - 找不到 active id 时静默 fallback 到 _write,保持非交互回退
|
|
109
|
+
*/
|
|
110
|
+
appendAssistantDelta(text) {
|
|
111
|
+
if (!text) return;
|
|
112
|
+
const id = this.assistantBlockId;
|
|
113
|
+
if (!id) {
|
|
114
|
+
this._write(text, "utf8", () => {
|
|
115
|
+
});
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this.assistantStreamText += text;
|
|
119
|
+
this.assistantPreviewText = this.assistantStreamText;
|
|
120
|
+
this.setStreamingPreview(id, this.assistantPreviewText);
|
|
121
|
+
this.onWrite();
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 结束当前 streaming block 的 active 状态。block 保留在 this.blocks
|
|
125
|
+
* 中作为 transcript row(keep:true 已确保 view-model 不会 slice 它),
|
|
126
|
+
* 只清掉 active id,下一轮 beginAssistantStream 会换新 id。
|
|
127
|
+
*/
|
|
128
|
+
endAssistantStream() {
|
|
129
|
+
const id = this.assistantBlockId;
|
|
130
|
+
if (id) {
|
|
131
|
+
const visibleText = this.assistantStreamText || this.assistantPreviewText;
|
|
132
|
+
if (visibleText) {
|
|
133
|
+
this.commitAssistantBlock(id, visibleText);
|
|
134
|
+
}
|
|
135
|
+
this.clearStreamingPreview(id);
|
|
136
|
+
}
|
|
137
|
+
this.assistantBlockId = void 0;
|
|
138
|
+
this.assistantStreamText = "";
|
|
139
|
+
this.assistantPreviewText = "";
|
|
140
|
+
this.compactOutputMemory().catch((error) => {
|
|
141
|
+
void this.appendCompactOutputMemoryWarning(error);
|
|
142
|
+
});
|
|
143
|
+
this.onWrite();
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* D.13V — Final Answer Gate 在 retry 前丢弃当前 streaming block 的全部累计
|
|
147
|
+
* 内容。保留 active id,让接下来的 delta 可以重新填回同一条 block;
|
|
148
|
+
* 同时清掉 lastFullOutput 中可能残留的违规原文,避免 Ctrl+O / details 拉到。
|
|
149
|
+
*/
|
|
150
|
+
discardAssistantBlock(id) {
|
|
151
|
+
if (this.assistantBlockId === id) {
|
|
152
|
+
this.assistantStreamText = "";
|
|
153
|
+
this.assistantPreviewText = "";
|
|
154
|
+
}
|
|
155
|
+
this.clearStreamingPreview(id);
|
|
156
|
+
const block = this.blocks.find((b) => b.id === id);
|
|
157
|
+
if (block) {
|
|
158
|
+
block.fullText = "";
|
|
159
|
+
block.summary = "";
|
|
160
|
+
}
|
|
161
|
+
if (!this.context.suppressLastFullOutputCapture) {
|
|
162
|
+
this.context.lastFullOutput = void 0;
|
|
163
|
+
}
|
|
164
|
+
this.onWrite();
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* D.13V — Final Answer Gate 在本地降级时把 streaming block 的 fullText
|
|
168
|
+
* 替换成已经过 buildDowngradedFinalAnswer 处理过的安全文本;同时把
|
|
169
|
+
* lastFullOutput 同步为同一份安全文本,让 Ctrl+O / details 也只看降级版。
|
|
170
|
+
*/
|
|
171
|
+
replaceAssistantBlockContent(id, text) {
|
|
172
|
+
if (this.assistantBlockId === id) {
|
|
173
|
+
this.assistantStreamText = "";
|
|
174
|
+
this.assistantPreviewText = "";
|
|
175
|
+
}
|
|
176
|
+
this.clearStreamingPreview(id);
|
|
177
|
+
this.commitAssistantBlock(id, text);
|
|
178
|
+
if (!this.context.suppressLastFullOutputCapture) {
|
|
179
|
+
this.context.lastFullOutput = text;
|
|
180
|
+
}
|
|
181
|
+
this.compactOutputMemory().catch((error) => {
|
|
182
|
+
void this.appendCompactOutputMemoryWarning(error);
|
|
183
|
+
});
|
|
184
|
+
this.onWrite();
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* D.13Q-UX Real Smoke Fix v3 — 把一段诊断正文(/mcp status / /index status
|
|
188
|
+
* 等)显式当作 messageKind=diagnostic block 写入 transcript:
|
|
189
|
+
* - 不走 createOutputBlock 的 assistant_text 默认分支,避免被当作普通 AI 正文;
|
|
190
|
+
* - 不进入 fail/blocked 状态,不再被任何关键词扫描误伤;
|
|
191
|
+
* - 仍累计到 lastFullOutput,让 /details + Ctrl+O 能展开完整诊断。
|
|
192
|
+
* 调用方应自己保证只用于真正的诊断输出(status / doctor 概要 / state dump)。
|
|
193
|
+
*/
|
|
194
|
+
writeDiagnosticLine(text) {
|
|
195
|
+
const normalized = text.replace(/\r/g, "").trim();
|
|
196
|
+
if (!normalized) return;
|
|
197
|
+
const firstLine = normalized.split("\n").find((line) => line.trim()) ?? normalized;
|
|
198
|
+
const nonEmptyLines = normalized.split("\n").filter((line) => line.trim().length > 0).length;
|
|
199
|
+
const hasMore = normalized.length > 0 && (nonEmptyLines >= 2 || normalized.length > firstLine.length + 16);
|
|
200
|
+
const detailsHint = this.context.language === "en-US" ? `${TOGGLE_DETAILS_KEYBIND} for details` : `${TOGGLE_DETAILS_KEYBIND} \u67E5\u770B\u5B8C\u6574\u5185\u5BB9`;
|
|
201
|
+
this.blocks.push({
|
|
202
|
+
id: `diag-${Date.now()}-${Math.floor(Math.random() * 1e3)}`,
|
|
203
|
+
kind: "details",
|
|
204
|
+
status: "info",
|
|
205
|
+
title: "",
|
|
206
|
+
summary: firstLine,
|
|
207
|
+
fullText: normalized,
|
|
208
|
+
nextAction: hasMore ? detailsHint : void 0,
|
|
209
|
+
messageKind: "diagnostic"
|
|
210
|
+
});
|
|
211
|
+
if (!this.context.suppressLastFullOutputCapture) {
|
|
212
|
+
this.context.lastFullOutput = normalized;
|
|
213
|
+
}
|
|
214
|
+
this.compactOutputMemory().catch((error) => {
|
|
215
|
+
void this.appendCompactOutputMemoryWarning(error);
|
|
216
|
+
});
|
|
217
|
+
this.onWrite();
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* D.13Q-UX Real Smoke Fix v3 复核 — 显式结构化错误写入路径:
|
|
221
|
+
* - 与 createOutputBlock(不再扫关键词)解耦,由调用方明确表态"这是错误";
|
|
222
|
+
* - 走 messageKind="tool_result_error" / kind="error" / status="fail",
|
|
223
|
+
* ProductBlock 命中红边卡片(带 fail marker + tool_result_error tone);
|
|
224
|
+
* - Ctrl+O hint 沿用 v3 规则:只有多行或单行明显超长才挂 errorDetailsHint;
|
|
225
|
+
* - fullText 累计到 lastFullOutput,/details + Ctrl+O 能展开完整错误正文。
|
|
226
|
+
* 调用点限定为真实错误:provider stream error / final no-tools provider error /
|
|
227
|
+
* slash/tool catch / executeIndexIgnoreWritePlan ignore 写入失败 等。
|
|
228
|
+
* 普通 writeLine / /mcp status / 普通 assistant 正文不要走这条路径。
|
|
229
|
+
*/
|
|
230
|
+
writeErrorLine(text, title) {
|
|
231
|
+
const normalized = text.replace(/\r/g, "").trim();
|
|
232
|
+
if (!normalized) return;
|
|
233
|
+
const firstLine = normalized.split("\n").find((line) => line.trim()) ?? normalized;
|
|
234
|
+
const nonEmptyLines = normalized.split("\n").filter((line) => line.trim().length > 0).length;
|
|
235
|
+
const hasMore = normalized.length > 0 && (nonEmptyLines >= 2 || normalized.length > firstLine.length + 16);
|
|
236
|
+
const errorHint = this.context.language === "en-US" ? `${TOGGLE_DETAILS_KEYBIND} for full error` : `${TOGGLE_DETAILS_KEYBIND} \u67E5\u770B\u5B8C\u6574\u9519\u8BEF`;
|
|
237
|
+
this.blocks.push({
|
|
238
|
+
id: `err-${Date.now()}-${Math.floor(Math.random() * 1e3)}`,
|
|
239
|
+
kind: "error",
|
|
240
|
+
status: "fail",
|
|
241
|
+
title: title ?? (this.context.language === "en-US" ? "output failed" : "output \u5931\u8D25"),
|
|
242
|
+
summary: firstLine,
|
|
243
|
+
fullText: normalized,
|
|
244
|
+
nextAction: hasMore ? errorHint : void 0,
|
|
245
|
+
messageKind: "tool_result_error",
|
|
246
|
+
retrySeconds: this.context.retryInfo?.delaySec,
|
|
247
|
+
retryAttempt: this.context.retryInfo?.attempt,
|
|
248
|
+
retryMax: this.context.retryInfo?.max
|
|
249
|
+
});
|
|
250
|
+
if (!this.context.suppressLastFullOutputCapture) {
|
|
251
|
+
this.context.lastFullOutput = normalized;
|
|
252
|
+
}
|
|
253
|
+
this.compactOutputMemory().catch((error) => {
|
|
254
|
+
void this.appendCompactOutputMemoryWarning(error);
|
|
255
|
+
});
|
|
256
|
+
this.onWrite();
|
|
257
|
+
}
|
|
258
|
+
writeLocalCommandOutputLine(text) {
|
|
259
|
+
const normalized = text.replace(/\r/g, "").trim();
|
|
260
|
+
if (!normalized) return;
|
|
261
|
+
const firstLine = normalized.split("\n").find((line) => line.trim()) ?? normalized;
|
|
262
|
+
const nonEmptyLines = normalized.split("\n").filter((line) => line.trim().length > 0).length;
|
|
263
|
+
const hasMore = normalized.length > 0 && (nonEmptyLines >= 2 || normalized.length > firstLine.length + 16);
|
|
264
|
+
const detailsHint = this.context.language === "en-US" ? `${TOGGLE_DETAILS_KEYBIND} for details` : `${TOGGLE_DETAILS_KEYBIND} \u67E5\u770B\u5B8C\u6574\u5185\u5BB9`;
|
|
265
|
+
this.blocks.push({
|
|
266
|
+
id: `local-${Date.now()}-${Math.floor(Math.random() * 1e3)}`,
|
|
267
|
+
kind: "tool",
|
|
268
|
+
status: "info",
|
|
269
|
+
title: "",
|
|
270
|
+
summary: firstLine,
|
|
271
|
+
fullText: normalized,
|
|
272
|
+
nextAction: hasMore ? detailsHint : void 0,
|
|
273
|
+
messageKind: "local_command_output"
|
|
274
|
+
});
|
|
275
|
+
if (!this.context.suppressLastFullOutputCapture) {
|
|
276
|
+
this.context.lastFullOutput = normalized;
|
|
277
|
+
}
|
|
278
|
+
this.compactOutputMemory().catch((error) => {
|
|
279
|
+
void this.appendCompactOutputMemoryWarning(error);
|
|
280
|
+
});
|
|
281
|
+
this.onWrite();
|
|
282
|
+
}
|
|
283
|
+
async compactOutputMemory() {
|
|
284
|
+
this.compactOutputMemoryQueue = this.compactOutputMemoryQueue.then(
|
|
285
|
+
() => this.compactOutputMemoryOnce()
|
|
286
|
+
);
|
|
287
|
+
return this.compactOutputMemoryQueue;
|
|
288
|
+
}
|
|
289
|
+
async appendCompactOutputMemoryWarning(error) {
|
|
290
|
+
if (!this.context.sessionId) {
|
|
291
|
+
process.stderr.write(
|
|
292
|
+
`[linghun] compact_output_memory_failed reason=${formatDiagnosticError(error)}
|
|
293
|
+
`
|
|
294
|
+
);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
try {
|
|
298
|
+
await this.context.store.appendEvent(this.context.sessionId, {
|
|
299
|
+
type: "system_event",
|
|
300
|
+
id: randomUUID(),
|
|
301
|
+
level: "warning",
|
|
302
|
+
message: `compact_output_memory_failed reason=${formatDiagnosticError(error)}`,
|
|
303
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
304
|
+
});
|
|
305
|
+
} catch (writeError) {
|
|
306
|
+
process.stderr.write(
|
|
307
|
+
`[linghun] compact_output_memory_failed reason=${formatDiagnosticError(error)}; warning_write_failed=${formatDiagnosticError(writeError)}
|
|
308
|
+
`
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
commitAssistantBlock(id, text) {
|
|
313
|
+
if (!text) return void 0;
|
|
314
|
+
const block = this.ensureAssistantBlock(id);
|
|
315
|
+
if (!block) return void 0;
|
|
316
|
+
const firstLine = text.split("\n").find((line) => line.trim()) ?? text;
|
|
317
|
+
block.fullText = text;
|
|
318
|
+
block.summary = firstLine.length > MAX_STREAMING_SUMMARY_CHARS ? `${firstLine.slice(0, MAX_STREAMING_SUMMARY_CHARS)}\u2026` : firstLine;
|
|
319
|
+
if (!this.context.suppressLastFullOutputCapture) {
|
|
320
|
+
this.context.lastFullOutput = text;
|
|
321
|
+
}
|
|
322
|
+
return block;
|
|
323
|
+
}
|
|
324
|
+
setStreamingPreview(id, text) {
|
|
325
|
+
if (!text) {
|
|
326
|
+
if (this.context.streamingAssistant?.id === id) {
|
|
327
|
+
this.context.streamingAssistant = void 0;
|
|
328
|
+
}
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
this.context.streamingAssistant = { id, text };
|
|
332
|
+
}
|
|
333
|
+
clearStreamingPreview(id) {
|
|
334
|
+
if (this.context.streamingAssistant?.id === id) {
|
|
335
|
+
this.context.streamingAssistant = void 0;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
async compactOutputMemoryOnce() {
|
|
339
|
+
trimOutputBlocks(this.blocks);
|
|
340
|
+
try {
|
|
341
|
+
await compactBlockFullText(this.context, this.blocks);
|
|
342
|
+
await compactLastFullOutput(this.context);
|
|
343
|
+
} catch (error) {
|
|
344
|
+
compactBlockFullTextInMemory(this.blocks, error);
|
|
345
|
+
compactLastFullOutputInMemory(this.context, error);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
function trimOutputBlocks(blocks) {
|
|
350
|
+
if (blocks.length <= MAX_OUTPUT_BLOCKS) return;
|
|
351
|
+
const isPreserved = (block) => block.keep === true || block.status === "fail" || block.status === "blocked";
|
|
352
|
+
const ephemeralIndices = blocks.map((block, index) => isPreserved(block) ? -1 : index).filter((index) => index >= 0);
|
|
353
|
+
const keepEphemeral = new Set(
|
|
354
|
+
ephemeralIndices.slice(Math.max(0, ephemeralIndices.length - PRESERVE_RECENT_EPHEMERAL_BLOCKS))
|
|
355
|
+
);
|
|
356
|
+
const selected = blocks.filter((block, index) => isPreserved(block) || keepEphemeral.has(index));
|
|
357
|
+
if (selected.length > MAX_OUTPUT_BLOCKS) {
|
|
358
|
+
const overflow = selected.length - MAX_OUTPUT_BLOCKS;
|
|
359
|
+
const removable = selected.map((block, index) => isPreserved(block) ? -1 : index).filter((index) => index >= 0).slice(0, overflow);
|
|
360
|
+
const drop = new Set(removable);
|
|
361
|
+
selected.splice(0, selected.length, ...selected.filter((_block, index) => !drop.has(index)));
|
|
362
|
+
}
|
|
363
|
+
blocks.splice(0, blocks.length, ...selected);
|
|
364
|
+
}
|
|
365
|
+
async function compactBlockFullText(context, blocks) {
|
|
366
|
+
for (const block of blocks) {
|
|
367
|
+
const value = block.fullText;
|
|
368
|
+
if (!value || value.length <= MAX_BLOCK_FULL_TEXT_CHARS || isCompactedOutputText(value)) {
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
const artifact = await writeOutputArtifact(context, value);
|
|
372
|
+
if (block.fullText !== value) {
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
block.fullText = buildCompactedOutputSummary({
|
|
376
|
+
tag: "persisted-tui-block-output",
|
|
377
|
+
relativePath: artifact.relativePath,
|
|
378
|
+
originalChars: value.length,
|
|
379
|
+
sha256: artifact.sha256,
|
|
380
|
+
preview: value.slice(0, LAST_FULL_OUTPUT_PREVIEW_CHARS)
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function compactBlockFullTextInMemory(blocks, error) {
|
|
385
|
+
for (const block of blocks) {
|
|
386
|
+
const value = block.fullText;
|
|
387
|
+
if (!value || value.length <= MAX_BLOCK_FULL_TEXT_CHARS || isCompactedOutputText(value)) {
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
block.fullText = buildCompactedOutputSummary({
|
|
391
|
+
tag: "compacted-tui-block-output",
|
|
392
|
+
archiveFailed: error instanceof Error ? error.message : String(error),
|
|
393
|
+
originalChars: value.length,
|
|
394
|
+
preview: value.slice(0, LAST_FULL_OUTPUT_PREVIEW_CHARS)
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
async function compactLastFullOutput(context) {
|
|
399
|
+
const value = context.lastFullOutput;
|
|
400
|
+
if (!value || value.length <= MAX_LAST_FULL_OUTPUT_CHARS || isCompactedOutputText(value)) return;
|
|
401
|
+
const artifact = await writeOutputArtifact(context, value);
|
|
402
|
+
if (context.lastFullOutput !== value) return;
|
|
403
|
+
context.lastFullOutput = buildCompactedOutputSummary({
|
|
404
|
+
tag: "persisted-tui-output",
|
|
405
|
+
relativePath: artifact.relativePath,
|
|
406
|
+
originalChars: value.length,
|
|
407
|
+
sha256: artifact.sha256,
|
|
408
|
+
preview: value.slice(0, LAST_FULL_OUTPUT_PREVIEW_CHARS)
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
function compactLastFullOutputInMemory(context, error) {
|
|
412
|
+
const value = context.lastFullOutput;
|
|
413
|
+
if (!value || value.length <= MAX_LAST_FULL_OUTPUT_CHARS || isCompactedOutputText(value)) return;
|
|
414
|
+
context.lastFullOutput = buildCompactedOutputSummary({
|
|
415
|
+
tag: "compacted-tui-output",
|
|
416
|
+
archiveFailed: error instanceof Error ? error.message : String(error),
|
|
417
|
+
originalChars: value.length,
|
|
418
|
+
preview: value.slice(0, LAST_FULL_OUTPUT_PREVIEW_CHARS)
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
async function writeOutputArtifact(context, text) {
|
|
422
|
+
const sessionId = context.sessionId ?? "unsaved";
|
|
423
|
+
const dir = join(
|
|
424
|
+
context.projectPath,
|
|
425
|
+
".linghun",
|
|
426
|
+
"session",
|
|
427
|
+
OUTPUT_MEMORY_ARTIFACT_DIR,
|
|
428
|
+
sessionId
|
|
429
|
+
);
|
|
430
|
+
await mkdir(dir, { recursive: true });
|
|
431
|
+
const sha256 = createHash("sha256").update(text).digest("hex");
|
|
432
|
+
const path = join(dir, `${randomUUID()}-${sha256.slice(0, 12)}.txt`);
|
|
433
|
+
await writeFile(path, text, "utf8");
|
|
434
|
+
return {
|
|
435
|
+
relativePath: relative(context.projectPath, path).replace(/\\/g, "/"),
|
|
436
|
+
sha256
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function buildCompactedOutputSummary(input) {
|
|
440
|
+
return [
|
|
441
|
+
`<${input.tag}>`,
|
|
442
|
+
input.relativePath ? `artifactPath: ${input.relativePath}` : "",
|
|
443
|
+
input.archiveFailed ? `archiveFailed: ${input.archiveFailed}` : "",
|
|
444
|
+
`originalChars: ${input.originalChars}`,
|
|
445
|
+
input.sha256 ? `sha256: ${input.sha256}` : "",
|
|
446
|
+
`previewChars: ${input.preview.length}`,
|
|
447
|
+
"read: use the artifact path if you need the full TUI output.",
|
|
448
|
+
"preview:",
|
|
449
|
+
input.preview,
|
|
450
|
+
input.originalChars > input.preview.length ? "..." : "",
|
|
451
|
+
`</${input.tag}>`
|
|
452
|
+
].filter((line) => line !== "").join("\n");
|
|
453
|
+
}
|
|
454
|
+
function isCompactedOutputText(value) {
|
|
455
|
+
return value.startsWith("<persisted-tui-output>") || value.startsWith("<compacted-tui-output>") || value.startsWith("<persisted-tui-block-output>") || value.startsWith("<compacted-tui-block-output>");
|
|
456
|
+
}
|
|
457
|
+
function beginAssistantStream(output, id) {
|
|
458
|
+
const candidate = output;
|
|
459
|
+
if (typeof candidate.beginAssistantStream === "function") {
|
|
460
|
+
candidate.beginAssistantStream(id);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
function writeAssistantDelta(output, _id, text) {
|
|
464
|
+
if (!text) return;
|
|
465
|
+
const candidate = output;
|
|
466
|
+
if (typeof candidate.appendAssistantDelta === "function") {
|
|
467
|
+
candidate.appendAssistantDelta(text);
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
output.write(text);
|
|
471
|
+
}
|
|
472
|
+
function endAssistantStream(output) {
|
|
473
|
+
const candidate = output;
|
|
474
|
+
if (typeof candidate.endAssistantStream === "function") {
|
|
475
|
+
candidate.endAssistantStream();
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
function discardAssistantBlock(output, id) {
|
|
479
|
+
const candidate = output;
|
|
480
|
+
if (typeof candidate.discardAssistantBlock === "function") {
|
|
481
|
+
candidate.discardAssistantBlock(id);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
function replaceAssistantBlockContent(output, id, text) {
|
|
485
|
+
const candidate = output;
|
|
486
|
+
if (typeof candidate.replaceAssistantBlockContent === "function") {
|
|
487
|
+
candidate.replaceAssistantBlockContent(id, text);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
function writeDiagnosticLine(output, text) {
|
|
491
|
+
const candidate = output;
|
|
492
|
+
if (typeof candidate.writeDiagnosticLine === "function") {
|
|
493
|
+
candidate.writeDiagnosticLine(text);
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
writeLine(output, text);
|
|
497
|
+
}
|
|
498
|
+
function writeErrorLine(output, text, title) {
|
|
499
|
+
const candidate = output;
|
|
500
|
+
if (typeof candidate.writeErrorLine === "function") {
|
|
501
|
+
candidate.writeErrorLine(text, title);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
writeLine(output, text);
|
|
505
|
+
}
|
|
506
|
+
function writeLocalCommandOutputLine(output, text) {
|
|
507
|
+
const candidate = output;
|
|
508
|
+
if (typeof candidate.writeLocalCommandOutputLine === "function") {
|
|
509
|
+
candidate.writeLocalCommandOutputLine(text);
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
writeLine(output, text);
|
|
513
|
+
}
|
|
514
|
+
function createShellBlockOutputForTest(context, blocks, onWrite = () => {
|
|
515
|
+
}) {
|
|
516
|
+
return new ShellBlockOutput(context, blocks, onWrite);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
export {
|
|
520
|
+
ShellBlockOutput,
|
|
521
|
+
beginAssistantStream,
|
|
522
|
+
writeAssistantDelta,
|
|
523
|
+
endAssistantStream,
|
|
524
|
+
discardAssistantBlock,
|
|
525
|
+
replaceAssistantBlockContent,
|
|
526
|
+
writeDiagnosticLine,
|
|
527
|
+
writeErrorLine,
|
|
528
|
+
writeLocalCommandOutputLine,
|
|
529
|
+
createShellBlockOutputForTest
|
|
530
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
truncateDisplay
|
|
3
|
+
} from "./chunk-OMZYPQVA.js";
|
|
4
|
+
|
|
5
|
+
// src/memory-rules-runtime.ts
|
|
6
|
+
import { readFile } from "fs/promises";
|
|
7
|
+
import { dirname, isAbsolute, relative, resolve } from "path";
|
|
8
|
+
var MAX_MEMORY_CHARACTER_COUNT = 4e4;
|
|
9
|
+
var MAX_INCLUDE_DEPTH = 5;
|
|
10
|
+
async function loadMemoryRulesFile(path) {
|
|
11
|
+
const root = resolve(path);
|
|
12
|
+
const warnings = [];
|
|
13
|
+
const includedPaths = [];
|
|
14
|
+
const content = await loadMemoryFileRecursive(root, root, /* @__PURE__ */ new Set(), 0, includedPaths, warnings);
|
|
15
|
+
if (content.length <= MAX_MEMORY_CHARACTER_COUNT) {
|
|
16
|
+
return { content, truncated: false, includedPaths, warnings };
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
content: truncateDisplay(content, MAX_MEMORY_CHARACTER_COUNT),
|
|
20
|
+
truncated: true,
|
|
21
|
+
includedPaths,
|
|
22
|
+
warnings: [...warnings, `memory rules truncated at ${MAX_MEMORY_CHARACTER_COUNT} chars`]
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function parseMemoryRuleFrontmatter(content) {
|
|
26
|
+
const match = /^---\r?\n(?<frontmatter>[\s\S]*?)\r?\n---\r?\n?/u.exec(content);
|
|
27
|
+
if (!match?.groups?.frontmatter) {
|
|
28
|
+
return { paths: [], body: content };
|
|
29
|
+
}
|
|
30
|
+
const paths = [];
|
|
31
|
+
for (const line of match.groups.frontmatter.split(/\r?\n/u)) {
|
|
32
|
+
const trimmed = line.trim();
|
|
33
|
+
if (trimmed.startsWith("paths:")) {
|
|
34
|
+
const inline = trimmed.slice("paths:".length).trim();
|
|
35
|
+
if (inline.startsWith("[") && inline.endsWith("]")) {
|
|
36
|
+
paths.push(
|
|
37
|
+
...inline.slice(1, -1).split(",").map((item) => cleanFrontmatterPath(item)).filter(Boolean)
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (trimmed.startsWith("- ")) {
|
|
43
|
+
paths.push(cleanFrontmatterPath(trimmed.slice(2)));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return { paths: [...new Set(paths)], body: content.slice(match[0].length) };
|
|
47
|
+
}
|
|
48
|
+
function shouldApplyMemoryRule(paths, changedPaths) {
|
|
49
|
+
if (paths.length === 0) return true;
|
|
50
|
+
return changedPaths.some((file) => paths.some((pattern) => globLikeMatch(pattern, file)));
|
|
51
|
+
}
|
|
52
|
+
async function loadMemoryFileRecursive(root, path, seen, depth, includedPaths, warnings) {
|
|
53
|
+
const resolved = resolve(path);
|
|
54
|
+
if (!isInside(dirname(root), resolved) && resolved !== root) {
|
|
55
|
+
warnings.push(`include skipped outside project rules directory: ${relative(dirname(root), resolved)}`);
|
|
56
|
+
return "";
|
|
57
|
+
}
|
|
58
|
+
if (seen.has(resolved)) {
|
|
59
|
+
warnings.push(`include cycle skipped: ${relative(dirname(root), resolved)}`);
|
|
60
|
+
return "";
|
|
61
|
+
}
|
|
62
|
+
if (depth > MAX_INCLUDE_DEPTH) {
|
|
63
|
+
warnings.push(`include depth limit reached at ${relative(dirname(root), resolved)}`);
|
|
64
|
+
return "";
|
|
65
|
+
}
|
|
66
|
+
seen.add(resolved);
|
|
67
|
+
includedPaths.push(resolved);
|
|
68
|
+
const raw = await readFile(resolved, "utf8");
|
|
69
|
+
const withIncludes = await replaceIncludes(root, resolved, raw, seen, depth, includedPaths, warnings);
|
|
70
|
+
return withIncludes;
|
|
71
|
+
}
|
|
72
|
+
async function replaceIncludes(root, currentPath, content, seen, depth, includedPaths, warnings) {
|
|
73
|
+
const lines = content.split(/\r?\n/u);
|
|
74
|
+
const output = [];
|
|
75
|
+
for (const line of lines) {
|
|
76
|
+
const match = line.match(/^\s*@include\s+(.+?)\s*$/u);
|
|
77
|
+
if (!match?.[1]) {
|
|
78
|
+
output.push(line);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const includePath = resolve(dirname(currentPath), match[1].trim());
|
|
82
|
+
const included = await loadMemoryFileRecursive(root, includePath, seen, depth + 1, includedPaths, warnings);
|
|
83
|
+
output.push(included);
|
|
84
|
+
}
|
|
85
|
+
return output.join("\n");
|
|
86
|
+
}
|
|
87
|
+
function cleanFrontmatterPath(value) {
|
|
88
|
+
return value.trim().replace(/^["']|["']$/g, "");
|
|
89
|
+
}
|
|
90
|
+
function globLikeMatch(pattern, file) {
|
|
91
|
+
const normalizedPattern = pattern.replaceAll("\\", "/");
|
|
92
|
+
const normalizedFile = file.replaceAll("\\", "/");
|
|
93
|
+
const optionalDoubleStarSlash = normalizedPattern.startsWith("**/");
|
|
94
|
+
const escaped = normalizedPattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "::DOUBLE_STAR::").replace(/\*/g, "[^/]*").replace(/::DOUBLE_STAR::/g, ".*");
|
|
95
|
+
const source = optionalDoubleStarSlash ? escaped.replace(/^\.\*\//u, "(?:.*/)?") : escaped;
|
|
96
|
+
const nestedOptional = source.replace(/\/\.\*\//gu, "/(?:.*/)?");
|
|
97
|
+
return new RegExp(`^${nestedOptional}$`, "u").test(normalizedFile);
|
|
98
|
+
}
|
|
99
|
+
function isInside(parent, child) {
|
|
100
|
+
const rel = relative(parent, child);
|
|
101
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
MAX_MEMORY_CHARACTER_COUNT,
|
|
106
|
+
loadMemoryRulesFile,
|
|
107
|
+
parseMemoryRuleFrontmatter,
|
|
108
|
+
shouldApplyMemoryRule
|
|
109
|
+
};
|