@caupulican/pi-adaptative 0.81.39 → 0.81.41
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/CHANGELOG.md +77 -0
- package/README.md +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +3 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +4 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +9 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +290 -107
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +357 -122
- package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +2 -2
- package/dist/cli/args.d.ts +4 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +31 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-directory-layout.d.ts +15 -0
- package/dist/core/agent-directory-layout.d.ts.map +1 -0
- package/dist/core/agent-directory-layout.js +72 -0
- package/dist/core/agent-directory-layout.js.map +1 -0
- package/dist/core/agent-paths.d.ts +25 -2
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +79 -4
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session-contracts.d.ts +293 -0
- package/dist/core/agent-session-contracts.d.ts.map +1 -0
- package/dist/core/agent-session-contracts.js +26 -0
- package/dist/core/agent-session-contracts.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +52 -8
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +400 -79
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +74 -518
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +370 -1432
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +3 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/autonomy/approval-gate.d.ts +3 -2
- package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
- package/dist/core/autonomy/approval-gate.js +6 -28
- package/dist/core/autonomy/approval-gate.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js +1 -1
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts +20 -12
- package/dist/core/autonomy/contracts.d.ts.map +1 -1
- package/dist/core/autonomy/contracts.js.map +1 -1
- package/dist/core/autonomy/foreground-envelope.d.ts +8 -2
- package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
- package/dist/core/autonomy/foreground-envelope.js +8 -25
- package/dist/core/autonomy/foreground-envelope.js.map +1 -1
- package/dist/core/autonomy/gates.d.ts.map +1 -1
- package/dist/core/autonomy/gates.js +8 -10
- package/dist/core/autonomy/gates.js.map +1 -1
- package/dist/core/autonomy/lane-private-paths.d.ts +2 -0
- package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -0
- package/dist/core/autonomy/lane-private-paths.js +16 -0
- package/dist/core/autonomy/lane-private-paths.js.map +1 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts +10 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +48 -9
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts +14 -0
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +38 -0
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/autonomy/risk-assessment.d.ts +1 -2
- package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
- package/dist/core/autonomy/risk-assessment.js +1 -123
- package/dist/core/autonomy/risk-assessment.js.map +1 -1
- package/dist/core/autonomy/session-lane-record.d.ts +4 -4
- package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.js +16 -29
- package/dist/core/autonomy/session-lane-record.js.map +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
- package/dist/core/autonomy/telemetry-events.js +1 -1
- package/dist/core/autonomy/telemetry-events.js.map +1 -1
- package/dist/core/autonomy-telemetry.d.ts +7 -7
- package/dist/core/autonomy-telemetry.d.ts.map +1 -1
- package/dist/core/autonomy-telemetry.js +9 -9
- package/dist/core/autonomy-telemetry.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +56 -236
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +141 -1273
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bedrock-sso-login.d.ts +16 -0
- package/dist/core/bedrock-sso-login.d.ts.map +1 -0
- package/dist/core/bedrock-sso-login.js +98 -0
- package/dist/core/bedrock-sso-login.js.map +1 -0
- package/dist/core/capability-contract.d.ts +4 -0
- package/dist/core/capability-contract.d.ts.map +1 -0
- package/dist/core/capability-contract.js +28 -0
- package/dist/core/capability-contract.js.map +1 -0
- package/dist/core/compaction-controller.d.ts +90 -0
- package/dist/core/compaction-controller.d.ts.map +1 -0
- package/dist/core/compaction-controller.js +452 -0
- package/dist/core/compaction-controller.js.map +1 -0
- package/dist/core/compaction-support.d.ts +13 -17
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +3 -3
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/context-artifacts.d.ts +6 -2
- package/dist/core/context/context-artifacts.d.ts.map +1 -1
- package/dist/core/context/context-artifacts.js +34 -2
- package/dist/core/context/context-artifacts.js.map +1 -1
- package/dist/core/context/context-store-retention.d.ts +8 -2
- package/dist/core/context/context-store-retention.d.ts.map +1 -1
- package/dist/core/context/context-store-retention.js +158 -35
- package/dist/core/context/context-store-retention.js.map +1 -1
- package/dist/core/context/okf-memory.d.ts.map +1 -1
- package/dist/core/context/okf-memory.js +9 -11
- package/dist/core/context/okf-memory.js.map +1 -1
- package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.js +6 -8
- package/dist/core/context/sqlite-runtime-index.js.map +1 -1
- package/dist/core/context-gc.d.ts +3 -0
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +10 -5
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +1 -1
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +16 -37
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost/cost-summary.d.ts.map +1 -1
- package/dist/core/cost/cost-summary.js +5 -3
- package/dist/core/cost/cost-summary.js.map +1 -1
- package/dist/core/cost/daily-usage.d.ts.map +1 -1
- package/dist/core/cost/daily-usage.js +4 -5
- package/dist/core/cost/daily-usage.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +2 -0
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/delegation/managed-lane-controller.d.ts +34 -0
- package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -0
- package/dist/core/delegation/managed-lane-controller.js +217 -0
- package/dist/core/delegation/managed-lane-controller.js.map +1 -0
- package/dist/core/delegation/session-worker-claim.d.ts +44 -0
- package/dist/core/delegation/session-worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/session-worker-claim.js +98 -0
- package/dist/core/delegation/session-worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-actions.d.ts +7 -5
- package/dist/core/delegation/worker-actions.d.ts.map +1 -1
- package/dist/core/delegation/worker-actions.js +20 -4
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/{worker-result.d.ts → worker-claim.d.ts} +13 -13
- package/dist/core/delegation/worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/{worker-result.js → worker-claim.js} +61 -51
- package/dist/core/delegation/worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts +110 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.js +861 -0
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -0
- package/dist/core/delegation/worker-delegation-request.d.ts +11 -0
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-request.js +2 -0
- package/dist/core/delegation/worker-delegation-request.js.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts +40 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js +93 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -0
- package/dist/core/delegation/worker-execution-policy.d.ts +62 -0
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -0
- package/dist/core/delegation/worker-execution-policy.js +160 -0
- package/dist/core/delegation/worker-execution-policy.js.map +1 -0
- package/dist/core/delegation/worker-lane-projection.d.ts +14 -0
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -0
- package/dist/core/delegation/worker-lane-projection.js +100 -0
- package/dist/core/delegation/worker-lane-projection.js.map +1 -0
- package/dist/core/delegation/worker-lifecycle.d.ts +97 -0
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -0
- package/dist/core/delegation/worker-lifecycle.js +339 -0
- package/dist/core/delegation/worker-lifecycle.js.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts +36 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.js +90 -0
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts +55 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.js +113 -0
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -0
- package/dist/core/delegation/worker-runner.d.ts +25 -14
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +122 -53
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-task-label.d.ts +3 -0
- package/dist/core/delegation/worker-task-label.d.ts.map +1 -0
- package/dist/core/delegation/worker-task-label.js +11 -0
- package/dist/core/delegation/worker-task-label.js.map +1 -0
- package/dist/core/doctor.d.ts +8 -0
- package/dist/core/doctor.d.ts.map +1 -1
- package/dist/core/doctor.js +32 -1
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/extension-import-authority.d.ts +6 -0
- package/dist/core/extension-import-authority.d.ts.map +1 -0
- package/dist/core/extension-import-authority.js +10 -0
- package/dist/core/extension-import-authority.js.map +1 -0
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +5 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +52 -18
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +20 -5
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/stale-context.d.ts +2 -0
- package/dist/core/extensions/stale-context.d.ts.map +1 -0
- package/dist/core/extensions/stale-context.js +2 -0
- package/dist/core/extensions/stale-context.js.map +1 -0
- package/dist/core/extensions/storage.d.ts +8 -0
- package/dist/core/extensions/storage.d.ts.map +1 -0
- package/dist/core/extensions/storage.js +28 -0
- package/dist/core/extensions/storage.js.map +1 -0
- package/dist/core/extensions/types.d.ts +78 -21
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/failure-corpus.d.ts +1 -15
- package/dist/core/failure-corpus.d.ts.map +1 -1
- package/dist/core/failure-corpus.js +9 -37
- package/dist/core/failure-corpus.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts +53 -0
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -0
- package/dist/core/foreground-recovery-controller.js +111 -0
- package/dist/core/foreground-recovery-controller.js.map +1 -0
- package/dist/core/gateways/channel-provider.d.ts +3 -0
- package/dist/core/gateways/channel-provider.d.ts.map +1 -1
- package/dist/core/gateways/channel-provider.js +31 -6
- package/dist/core/gateways/channel-provider.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts +14 -9
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +47 -75
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/compact-goal-context.d.ts +11 -0
- package/dist/core/goals/compact-goal-context.d.ts.map +1 -0
- package/dist/core/goals/compact-goal-context.js +59 -0
- package/dist/core/goals/compact-goal-context.js.map +1 -0
- package/dist/core/goals/goal-acceptance.d.ts +11 -0
- package/dist/core/goals/goal-acceptance.d.ts.map +1 -0
- package/dist/core/goals/goal-acceptance.js +27 -0
- package/dist/core/goals/goal-acceptance.js.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts +28 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.js +90 -0
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -0
- package/dist/core/goals/goal-continuation-controller.d.ts +2 -2
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js +52 -11
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts +4 -29
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.js +4 -32
- package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts +8 -18
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js +9 -179
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts +43 -0
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -0
- package/dist/core/goals/goal-lifecycle.js +102 -0
- package/dist/core/goals/goal-lifecycle.js.map +1 -0
- package/dist/core/goals/goal-record.d.ts +17 -0
- package/dist/core/goals/goal-record.d.ts.map +1 -0
- package/dist/core/goals/goal-record.js +31 -0
- package/dist/core/goals/goal-record.js.map +1 -0
- package/dist/core/goals/goal-runtime-snapshot.d.ts +11 -9
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js +10 -8
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +42 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-session-controller.js +128 -0
- package/dist/core/goals/goal-session-controller.js.map +1 -0
- package/dist/core/goals/goal-state.d.ts +46 -25
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +91 -24
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +9 -10
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +60 -75
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/session-goal-state.d.ts +20 -12
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js +133 -33
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/human-input-controller.d.ts +47 -0
- package/dist/core/human-input-controller.d.ts.map +1 -0
- package/dist/core/human-input-controller.js +181 -0
- package/dist/core/human-input-controller.js.map +1 -0
- package/dist/core/human-input.d.ts +100 -0
- package/dist/core/human-input.d.ts.map +1 -0
- package/dist/core/human-input.js +362 -0
- package/dist/core/human-input.js.map +1 -0
- package/dist/core/index.d.ts +9 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +9 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/{telemetry.d.ts → install-telemetry.d.ts} +1 -1
- package/dist/core/install-telemetry.d.ts.map +1 -0
- package/dist/core/{telemetry.js → install-telemetry.js} +1 -1
- package/dist/core/install-telemetry.js.map +1 -0
- package/dist/core/keybindings.d.ts +17 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +24 -6
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/learning/learning-audit.d.ts +2 -4
- package/dist/core/learning/learning-audit.d.ts.map +1 -1
- package/dist/core/learning/learning-audit.js +9 -29
- package/dist/core/learning/learning-audit.js.map +1 -1
- package/dist/core/learning/learning-gate.d.ts.map +1 -1
- package/dist/core/learning/learning-gate.js +1 -6
- package/dist/core/learning/learning-gate.js.map +1 -1
- package/dist/core/learning/session-learning-decision.d.ts +2 -4
- package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
- package/dist/core/learning/session-learning-decision.js +9 -29
- package/dist/core/learning/session-learning-decision.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts +1 -1
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/memory-controller.d.ts.map +1 -1
- package/dist/core/memory-controller.js +4 -4
- package/dist/core/memory-controller.js.map +1 -1
- package/dist/core/model-capability.d.ts +0 -19
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +1 -19
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-registry.d.ts +6 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +13 -5
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +17 -2
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +38 -25
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-router/intent-classifier.d.ts +1 -4
- package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
- package/dist/core/model-router/intent-classifier.js +1 -156
- package/dist/core/model-router/intent-classifier.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +1 -1
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +2 -2
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +5 -5
- package/dist/core/model-selection-controller.d.ts.map +1 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/model-tool-protocol.d.ts +23 -0
- package/dist/core/model-tool-protocol.d.ts.map +1 -0
- package/dist/core/model-tool-protocol.js +43 -0
- package/dist/core/model-tool-protocol.js.map +1 -0
- package/dist/core/models/adaptation-store.d.ts +4 -6
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +95 -83
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts +2 -12
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +84 -57
- package/dist/core/models/fitness-store.js.map +1 -1
- package/dist/core/models/host-state-store.d.ts +34 -0
- package/dist/core/models/host-state-store.d.ts.map +1 -0
- package/dist/core/models/host-state-store.js +86 -0
- package/dist/core/models/host-state-store.js.map +1 -0
- package/dist/core/orchestration/agent-resume.d.ts +24 -0
- package/dist/core/orchestration/agent-resume.d.ts.map +1 -0
- package/dist/core/orchestration/agent-resume.js +90 -0
- package/dist/core/orchestration/agent-resume.js.map +1 -0
- package/dist/core/orchestration/capability-gateway.d.ts +61 -0
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -0
- package/dist/core/orchestration/capability-gateway.js +152 -0
- package/dist/core/orchestration/capability-gateway.js.map +1 -0
- package/dist/core/orchestration/contracts.d.ts +343 -0
- package/dist/core/orchestration/contracts.d.ts.map +1 -0
- package/dist/core/orchestration/contracts.js +135 -0
- package/dist/core/orchestration/contracts.js.map +1 -0
- package/dist/core/orchestration/delegation-ledger.d.ts +56 -0
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -0
- package/dist/core/orchestration/delegation-ledger.js +200 -0
- package/dist/core/orchestration/delegation-ledger.js.map +1 -0
- package/dist/core/orchestration/event-store.d.ts +83 -0
- package/dist/core/orchestration/event-store.d.ts.map +1 -0
- package/dist/core/orchestration/event-store.js +560 -0
- package/dist/core/orchestration/event-store.js.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts +9 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.js +37 -0
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -0
- package/dist/core/orchestration/model-binding.d.ts +15 -0
- package/dist/core/orchestration/model-binding.d.ts.map +1 -0
- package/dist/core/orchestration/model-binding.js +29 -0
- package/dist/core/orchestration/model-binding.js.map +1 -0
- package/dist/core/orchestration/policy-compiler.d.ts +49 -0
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -0
- package/dist/core/orchestration/policy-compiler.js +191 -0
- package/dist/core/orchestration/policy-compiler.js.map +1 -0
- package/dist/core/orchestration/policy-gate.d.ts +18 -0
- package/dist/core/orchestration/policy-gate.d.ts.map +1 -0
- package/dist/core/orchestration/policy-gate.js +24 -0
- package/dist/core/orchestration/policy-gate.js.map +1 -0
- package/dist/core/orchestration/profile-registry.d.ts +51 -0
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -0
- package/dist/core/orchestration/profile-registry.js +393 -0
- package/dist/core/orchestration/profile-registry.js.map +1 -0
- package/dist/core/orchestration/profile-store.d.ts +31 -0
- package/dist/core/orchestration/profile-store.d.ts.map +1 -0
- package/dist/core/orchestration/profile-store.js +136 -0
- package/dist/core/orchestration/profile-store.js.map +1 -0
- package/dist/core/orchestration/risk-budget.d.ts +9 -0
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -0
- package/dist/core/orchestration/risk-budget.js +48 -0
- package/dist/core/orchestration/risk-budget.js.map +1 -0
- package/dist/core/orchestration/task-runtime.d.ts +168 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime.js +1600 -0
- package/dist/core/orchestration/task-runtime.js.map +1 -0
- package/dist/core/orchestration/work-state-projection.d.ts +32 -0
- package/dist/core/orchestration/work-state-projection.d.ts.map +1 -0
- package/dist/core/orchestration/work-state-projection.js +116 -0
- package/dist/core/orchestration/work-state-projection.js.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts +21 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.js +179 -0
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts +21 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.js +109 -0
- package/dist/core/orchestration/worker-result-adapter.js.map +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +20 -3
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/process-identity.d.ts +11 -0
- package/dist/core/process-identity.d.ts.map +1 -0
- package/dist/core/process-identity.js +26 -0
- package/dist/core/process-identity.js.map +1 -0
- package/dist/core/process-matrix/codes.d.ts +14 -3
- package/dist/core/process-matrix/codes.d.ts.map +1 -1
- package/dist/core/process-matrix/codes.js.map +1 -1
- package/dist/core/process-matrix/resume-launcher.d.ts +26 -0
- package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -0
- package/dist/core/process-matrix/resume-launcher.js +62 -0
- package/dist/core/process-matrix/resume-launcher.js.map +1 -0
- package/dist/core/process-matrix/runtime.d.ts +37 -22
- package/dist/core/process-matrix/runtime.d.ts.map +1 -1
- package/dist/core/process-matrix/runtime.js +399 -76
- package/dist/core/process-matrix/runtime.js.map +1 -1
- package/dist/core/process-matrix/store.d.ts +5 -2
- package/dist/core/process-matrix/store.d.ts.map +1 -1
- package/dist/core/process-matrix/store.js +123 -14
- package/dist/core/process-matrix/store.js.map +1 -1
- package/dist/core/process-matrix/supervisor.d.ts +10 -7
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -1
- package/dist/core/process-matrix/supervisor.js +45 -14
- package/dist/core/process-matrix/supervisor.js.map +1 -1
- package/dist/core/profile-filter-controller.d.ts +8 -1
- package/dist/core/profile-filter-controller.d.ts.map +1 -1
- package/dist/core/profile-filter-controller.js +23 -5
- package/dist/core/profile-filter-controller.js.map +1 -1
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +6 -8
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +18 -29
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +5 -5
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +5 -2
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +6 -8
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/request-auth.d.ts +7 -0
- package/dist/core/request-auth.d.ts.map +1 -0
- package/dist/core/request-auth.js +8 -0
- package/dist/core/request-auth.js.map +1 -0
- package/dist/core/research/evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/evidence-bundle.js +1 -6
- package/dist/core/research/evidence-bundle.js.map +1 -1
- package/dist/core/research/lane-model-resolver.d.ts +33 -0
- package/dist/core/research/lane-model-resolver.d.ts.map +1 -0
- package/dist/core/research/lane-model-resolver.js +65 -0
- package/dist/core/research/lane-model-resolver.js.map +1 -0
- package/dist/core/research/model-fitness-controller.d.ts +38 -0
- package/dist/core/research/model-fitness-controller.d.ts.map +1 -0
- package/dist/core/research/model-fitness-controller.js +106 -0
- package/dist/core/research/model-fitness-controller.js.map +1 -0
- package/dist/core/research/model-fitness.d.ts +1 -1
- package/dist/core/research/model-fitness.d.ts.map +1 -1
- package/dist/core/research/model-fitness.js +4 -4
- package/dist/core/research/model-fitness.js.map +1 -1
- package/dist/core/research/research-gate.d.ts.map +1 -1
- package/dist/core/research/research-gate.js +7 -7
- package/dist/core/research/research-gate.js.map +1 -1
- package/dist/core/research/research-lane-controller.d.ts +62 -0
- package/dist/core/research/research-lane-controller.d.ts.map +1 -0
- package/dist/core/research/research-lane-controller.js +292 -0
- package/dist/core/research/research-lane-controller.js.map +1 -0
- package/dist/core/research/session-evidence-bundle.d.ts +2 -4
- package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/session-evidence-bundle.js +10 -46
- package/dist/core/research/session-evidence-bundle.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +23 -8
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/risk-classifier.d.ts +6 -0
- package/dist/core/risk-classifier.d.ts.map +1 -0
- package/dist/core/risk-classifier.js +233 -0
- package/dist/core/risk-classifier.js.map +1 -0
- package/dist/core/runtime-builder.d.ts +41 -23
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +365 -253
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/sdk.d.ts +6 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +68 -25
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.d.ts +9 -0
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -0
- package/dist/core/secrets/credential-exposure-guard.js +241 -0
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -0
- package/dist/core/secrets/secret-dotenv.d.ts +27 -0
- package/dist/core/secrets/secret-dotenv.d.ts.map +1 -0
- package/dist/core/secrets/secret-dotenv.js +183 -0
- package/dist/core/secrets/secret-dotenv.js.map +1 -0
- package/dist/core/secrets/secret-vault-format.d.ts +112 -0
- package/dist/core/secrets/secret-vault-format.d.ts.map +1 -0
- package/dist/core/secrets/secret-vault-format.js +397 -0
- package/dist/core/secrets/secret-vault-format.js.map +1 -0
- package/dist/core/secrets/secret-vault.d.ts +72 -0
- package/dist/core/secrets/secret-vault.d.ts.map +1 -0
- package/dist/core/secrets/secret-vault.js +671 -0
- package/dist/core/secrets/secret-vault.js.map +1 -0
- package/dist/core/session-analytics.d.ts +4 -23
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +67 -70
- package/dist/core/session-analytics.js.map +1 -1
- package/dist/core/session-image-store.d.ts +33 -0
- package/dist/core/session-image-store.d.ts.map +1 -0
- package/dist/core/session-image-store.js +283 -0
- package/dist/core/session-image-store.js.map +1 -0
- package/dist/core/session-role.d.ts +11 -4
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js +24 -5
- package/dist/core/session-role.js.map +1 -1
- package/dist/core/session-snapshot.d.ts +34 -0
- package/dist/core/session-snapshot.d.ts.map +1 -0
- package/dist/core/session-snapshot.js +68 -0
- package/dist/core/session-snapshot.js.map +1 -0
- package/dist/core/session-supervision-runtime.d.ts +31 -0
- package/dist/core/session-supervision-runtime.d.ts.map +1 -0
- package/dist/core/session-supervision-runtime.js +97 -0
- package/dist/core/session-supervision-runtime.js.map +1 -0
- package/dist/core/session-tree-navigator.d.ts +4 -6
- package/dist/core/session-tree-navigator.d.ts.map +1 -1
- package/dist/core/session-tree-navigator.js +4 -1
- package/dist/core/session-tree-navigator.js.map +1 -1
- package/dist/core/settings-manager.d.ts +10 -5
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +81 -29
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -2
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts +2 -4
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js +10 -28
- package/dist/core/tasks/session-task-state.js.map +1 -1
- package/dist/core/tasks/task-projection.d.ts +20 -0
- package/dist/core/tasks/task-projection.d.ts.map +1 -0
- package/dist/core/tasks/task-projection.js +47 -0
- package/dist/core/tasks/task-projection.js.map +1 -0
- package/dist/core/tasks/task-state.d.ts +4 -0
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js +28 -11
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts +13 -0
- package/dist/core/tool-capability-policy.d.ts.map +1 -0
- package/dist/core/tool-capability-policy.js +86 -0
- package/dist/core/tool-capability-policy.js.map +1 -0
- package/dist/core/tool-gate-controller.d.ts.map +1 -1
- package/dist/core/tool-gate-controller.js +8 -2
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts +89 -0
- package/dist/core/tool-protocol-controller.d.ts.map +1 -0
- package/dist/core/tool-protocol-controller.js +512 -0
- package/dist/core/tool-protocol-controller.js.map +1 -0
- package/dist/core/tool-recovery-log-records.d.ts +2 -3
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js +9 -35
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-recovery-stats.d.ts +21 -1
- package/dist/core/tool-recovery-stats.d.ts.map +1 -1
- package/dist/core/tool-recovery-stats.js.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.d.ts +3 -7
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +97 -138
- package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
- package/dist/core/tools/ask-question.d.ts +124 -0
- package/dist/core/tools/ask-question.d.ts.map +1 -0
- package/dist/core/tools/ask-question.js +693 -0
- package/dist/core/tools/ask-question.js.map +1 -0
- package/dist/core/tools/bash.d.ts +5 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +59 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +31 -3
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +148 -29
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +15 -13
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +106 -23
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/extensionify.d.ts.map +1 -1
- package/dist/core/tools/extensionify.js +1 -0
- package/dist/core/tools/extensionify.js.map +1 -1
- package/dist/core/tools/git-filter.d.ts +1 -8
- package/dist/core/tools/git-filter.d.ts.map +1 -1
- package/dist/core/tools/git-filter.js +2 -63
- package/dist/core/tools/git-filter.js.map +1 -1
- package/dist/core/tools/goal.d.ts +10 -8
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +106 -28
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -0
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +1 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js +2 -2
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +40 -0
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -0
- package/dist/core/tools/orchestration-panel.js +124 -0
- package/dist/core/tools/orchestration-panel.js.map +1 -0
- package/dist/core/tools/output-accumulator.d.ts +11 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +36 -3
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/python.d.ts +2 -0
- package/dist/core/tools/python.d.ts.map +1 -1
- package/dist/core/tools/python.js +3 -1
- package/dist/core/tools/python.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/run-process.d.ts +26 -0
- package/dist/core/tools/run-process.d.ts.map +1 -0
- package/dist/core/tools/run-process.js +138 -0
- package/dist/core/tools/run-process.js.map +1 -0
- package/dist/core/tools/search-command-guard.d.ts +14 -0
- package/dist/core/tools/search-command-guard.d.ts.map +1 -0
- package/dist/core/tools/search-command-guard.js +333 -0
- package/dist/core/tools/search-command-guard.js.map +1 -0
- package/dist/core/tools/secret-store.d.ts +38 -0
- package/dist/core/tools/secret-store.d.ts.map +1 -0
- package/dist/core/tools/secret-store.js +412 -0
- package/dist/core/tools/secret-store.js.map +1 -0
- package/dist/core/tools/shell-command-parser.d.ts +16 -0
- package/dist/core/tools/shell-command-parser.d.ts.map +1 -0
- package/dist/core/tools/shell-command-parser.js +113 -0
- package/dist/core/tools/shell-command-parser.js.map +1 -0
- package/dist/core/tools/task-steps.d.ts +2 -0
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +99 -0
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts +3 -5
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
- package/dist/core/tools/tmux-dispatch.js +4 -4
- package/dist/core/tools/tmux-dispatch.js.map +1 -1
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-engine.js +4 -6
- package/dist/core/tools/windows-shell-engine.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +6 -2
- package/dist/core/util/atomic-file.d.ts.map +1 -1
- package/dist/core/util/atomic-file.js +4 -4
- package/dist/core/util/atomic-file.js.map +1 -1
- package/dist/core/util/bounded-jsonl.d.ts +10 -0
- package/dist/core/util/bounded-jsonl.d.ts.map +1 -0
- package/dist/core/util/bounded-jsonl.js +75 -0
- package/dist/core/util/bounded-jsonl.js.map +1 -0
- package/dist/core/util/value-guards.d.ts +5 -0
- package/dist/core/util/value-guards.d.ts.map +1 -0
- package/dist/core/util/value-guards.js +12 -0
- package/dist/core/util/value-guards.js.map +1 -0
- package/dist/core/worktree-sync/store.d.ts +3 -3
- package/dist/core/worktree-sync/store.d.ts.map +1 -1
- package/dist/core/worktree-sync/store.js +10 -5
- package/dist/core/worktree-sync/store.js.map +1 -1
- package/dist/index.d.ts +15 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +149 -51
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +4 -6
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +186 -28
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.d.ts +4 -0
- package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.js +60 -1
- package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
- package/dist/modes/interactive/clipboard-input.d.ts +7 -1
- package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
- package/dist/modes/interactive/clipboard-input.js +44 -6
- package/dist/modes/interactive/clipboard-input.js.map +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts +55 -0
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -0
- package/dist/modes/interactive/components/activity-lane.js +304 -0
- package/dist/modes/interactive/components/activity-lane.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +19 -10
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/expandable-text.d.ts +12 -0
- package/dist/modes/interactive/components/expandable-text.d.ts.map +1 -0
- package/dist/modes/interactive/components/expandable-text.js +17 -0
- package/dist/modes/interactive/components/expandable-text.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +15 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +30 -21
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +6 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -2
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +23 -14
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +6 -6
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +19 -11
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +53 -20
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-group.js +3 -0
- package/dist/modes/interactive/components/tool-group.js.map +1 -1
- package/dist/modes/interactive/components/usage-action-selector.d.ts +16 -0
- package/dist/modes/interactive/components/usage-action-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/usage-action-selector.js +46 -0
- package/dist/modes/interactive/components/usage-action-selector.js.map +1 -0
- package/dist/modes/interactive/config-backup.d.ts.map +1 -1
- package/dist/modes/interactive/config-backup.js +5 -4
- package/dist/modes/interactive/config-backup.js.map +1 -1
- package/dist/modes/interactive/extension-ui-host.d.ts +14 -0
- package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
- package/dist/modes/interactive/extension-ui-host.js +77 -15
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +15 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +27 -19
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/history-reload-math.d.ts +6 -2
- package/dist/modes/interactive/history-reload-math.d.ts.map +1 -1
- package/dist/modes/interactive/history-reload-math.js +10 -5
- package/dist/modes/interactive/history-reload-math.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.d.ts +74 -0
- package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-event-controller.js +328 -0
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +22 -24
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +245 -595
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/key-handlers.js +1 -1
- package/dist/modes/interactive/key-handlers.js.map +1 -1
- package/dist/modes/interactive/loaded-resources-view.d.ts +20 -0
- package/dist/modes/interactive/loaded-resources-view.d.ts.map +1 -0
- package/dist/modes/interactive/loaded-resources-view.js +147 -0
- package/dist/modes/interactive/loaded-resources-view.js.map +1 -0
- package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.js +7 -7
- package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +21 -0
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/resource-display.d.ts.map +1 -1
- package/dist/modes/interactive/resource-display.js +8 -2
- package/dist/modes/interactive/resource-display.js.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.d.ts +1 -5
- package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.js +0 -5
- package/dist/modes/interactive/resource-shell-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts +27 -8
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +150 -64
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-io-commands.js +16 -6
- package/dist/modes/interactive/session-io-commands.js.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.d.ts +7 -0
- package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -0
- package/dist/modes/interactive/session-replacement-errors.js +15 -0
- package/dist/modes/interactive/session-replacement-errors.js.map +1 -0
- package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
- package/dist/modes/interactive/startup-checks.js +1 -1
- package/dist/modes/interactive/startup-checks.js.map +1 -1
- package/dist/modes/interactive/usage-commands.d.ts +34 -0
- package/dist/modes/interactive/usage-commands.d.ts.map +1 -0
- package/dist/modes/interactive/usage-commands.js +225 -0
- package/dist/modes/interactive/usage-commands.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +82 -23
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +15 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js +138 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +2 -13
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +1 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts +1 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +52 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/platform.d.ts +3 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +8 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +5 -3
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +3 -1
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/work-directory.d.ts +11 -0
- package/dist/utils/work-directory.d.ts.map +1 -1
- package/dist/utils/work-directory.js +30 -9
- package/dist/utils/work-directory.js.map +1 -1
- package/docs/UI_POLISH_ORCHESTRATION.md +38 -0
- package/docs/UI_QUALITY_ORCHESTRATION.md +28 -0
- package/docs/docs.json +4 -0
- package/docs/extensions.md +62 -2
- package/docs/harness-architecture.md +156 -0
- package/docs/keybindings.md +11 -1
- package/docs/process-matrix.md +59 -26
- package/docs/providers.md +9 -1
- package/docs/rpc.md +45 -2
- package/docs/sessions.md +15 -0
- package/docs/settings.md +125 -11
- package/docs/task-steps.md +8 -0
- package/docs/telemetry.md +19 -0
- package/docs/tmux-agent-manager.md +10 -3
- package/docs/ui-reference/README.md +9 -0
- package/docs/ui-reference/orchestration-after.txt +14 -0
- package/docs/ui-reference/orchestration-before.txt +13 -0
- package/docs/ui-reference/orchestration-reference.txt +16 -0
- package/docs/usage.md +22 -2
- package/docs/work-directory.md +19 -8
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/question.ts +34 -245
- package/examples/extensions/questionnaire.ts +41 -407
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +13 -13
- package/package.json +4 -4
- package/dist/core/delegation/session-worker-result.d.ts +0 -46
- package/dist/core/delegation/session-worker-result.d.ts.map +0 -1
- package/dist/core/delegation/session-worker-result.js +0 -113
- package/dist/core/delegation/session-worker-result.js.map +0 -1
- package/dist/core/delegation/worker-result.d.ts.map +0 -1
- package/dist/core/delegation/worker-result.js.map +0 -1
- package/dist/core/telemetry.d.ts.map +0 -1
- package/dist/core/telemetry.js.map +0 -1
|
@@ -63,8 +63,29 @@ export function handleUsageCommand(host) {
|
|
|
63
63
|
gateFailures: 0,
|
|
64
64
|
deterministicGapFills: 0,
|
|
65
65
|
compactionsWithGateFailures: 0,
|
|
66
|
+
checks: {},
|
|
66
67
|
};
|
|
67
68
|
info += `${theme.fg("dim", "Compaction gate failures:")} ${compactionGates.gateFailures} (${compactionGates.deterministicGapFills} deterministic gap-fill)\n`;
|
|
69
|
+
const failingChecks = Object.entries(compactionGates.checks).sort(([leftName, left], [rightName, right]) => right.failures - left.failures || leftName.localeCompare(rightName));
|
|
70
|
+
if (failingChecks.length > 0) {
|
|
71
|
+
const visibleChecks = failingChecks.slice(0, 3).map(([check, checkStats]) => {
|
|
72
|
+
let score = "";
|
|
73
|
+
if (checkStats.minScore !== undefined && checkStats.maxScore !== undefined) {
|
|
74
|
+
const range = checkStats.minScore === checkStats.maxScore
|
|
75
|
+
? checkStats.minScore.toFixed(2)
|
|
76
|
+
: `${checkStats.minScore.toFixed(2)}-${checkStats.maxScore.toFixed(2)}`;
|
|
77
|
+
const threshold = checkStats.threshold === undefined
|
|
78
|
+
? ""
|
|
79
|
+
: ` ${checkStats.comparator === "maximum" ? ">" : "<"} ${checkStats.threshold.toFixed(2)}`;
|
|
80
|
+
score = ` (${range}${threshold})`;
|
|
81
|
+
}
|
|
82
|
+
return `${check} x${checkStats.failures}${score}`;
|
|
83
|
+
});
|
|
84
|
+
if (failingChecks.length > visibleChecks.length) {
|
|
85
|
+
visibleChecks.push(`+${failingChecks.length - visibleChecks.length} more`);
|
|
86
|
+
}
|
|
87
|
+
info += `${theme.fg("dim", "Failing compaction checks:")} ${visibleChecks.join("; ")}\n`;
|
|
88
|
+
}
|
|
68
89
|
if (isChatGptSubscription) {
|
|
69
90
|
info += `${theme.fg("dim", "Cost guard:")} not applicable to ChatGPT subscription usage\n`;
|
|
70
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report-commands.js","sourceRoot":"","sources":["../../../src/modes/interactive/report-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIlD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OA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;AAED,MAAM,UAAU,aAAa,CAAC,IAAsB,EAAQ;IAC3D,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3D,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;AAAA,CACxB;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAsB,EAAE,KAAuC,EAAQ;IAC5G,IAAI,KAAK,CAAC,QAAQ,KAAK,UAAU,IAAI,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACnF,aAAa,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;AAAA,CACD","sourcesContent":["/**\n * Read-only report and easter-egg commands extracted from interactive-mode.\n *\n * These build informational output (usage/cost summary, changelog, hotkeys\n * table, render debug dump) or render an easter-egg component, appending to the\n * chat container and requesting a render. None mutate agent/session state, so\n * they operate through narrow `host` seams (chat container, TUI, and a few\n * read accessors) while interactive-mode keeps thin delegating wrappers.\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { Container, Keybinding, MarkdownTheme, TUI } from \"@caupulican/pi-tui\";\nimport { Markdown, Spacer, Text, visibleWidth } from \"@caupulican/pi-tui\";\nimport { getDebugLogPath } from \"../../config.ts\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport type { AppKeybinding, KeybindingsManager } from \"../../core/keybindings.ts\";\nimport type { AutoLearnSettings } from \"../../core/settings-manager.ts\";\nimport { getChangelogPath, parseChangelog } from \"../../utils/changelog.ts\";\nimport { getProcessMemoryMb } from \"../../utils/process-memory.ts\";\nimport { ArminComponent } from \"./components/armin.ts\";\nimport { DaxnutsComponent } from \"./components/daxnuts.ts\";\nimport { DynamicBorder } from \"./components/dynamic-border.ts\";\nimport { EarendilAnnouncementComponent } from \"./components/earendil-announcement.ts\";\nimport { formatKeyText } from \"./components/keybinding-hints.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\nexport interface ReportRenderHost {\n\treadonly chatContainer: Container;\n\treadonly ui: TUI;\n}\n\nexport interface UsageReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\tgetCurrentAutoLearnSettings(): Required<AutoLearnSettings>;\n}\n\nexport interface ChangelogReportHost extends ReportRenderHost {\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n}\n\nexport interface HotkeysReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\treadonly keybindings: KeybindingsManager;\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n\tgetAppKeyDisplay(action: AppKeybinding): string;\n\tgetEditorKeyDisplay(action: Keybinding): string;\n}\n\nexport interface DebugReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n}\n\nexport function handleUsageCommand(host: UsageReportHost): void {\n\tconst stats = host.session.getSessionStats();\n\tconst costs = host.session.getCostSummary();\n\tconst context = host.session.getContextUsage();\n\tconst autoLearn = host.getCurrentAutoLearnSettings();\n\tconst costGuard = host.session.getLastCostGuardDecision();\n\tconst activeModel = host.session.model;\n\tconst usingSubscription = activeModel ? host.session.modelRegistry.isUsingOAuth(activeModel) : false;\n\tconst isChatGptSubscription = usingSubscription && activeModel?.provider === \"openai-codex\";\n\n\tlet info = `${theme.bold(\"Usage & Optimization\")}\\n\\n`;\n\tinfo += `${theme.bold(\"Session tokens\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Input:\")} ${stats.tokens.input.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Output:\")} ${stats.tokens.output.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Cache read:\")} ${stats.tokens.cacheRead.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Cache write:\")} ${stats.tokens.cacheWrite.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.tokens.total.toLocaleString()}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Cost\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"CURRENT (session):\")} $${costs.currentCost.toFixed(4)}${usingSubscription ? \" (sub)\" : \"\"}\\n`;\n\tif (costs.subagentReports > 0 || costs.subagentCost > 0) {\n\t\tinfo += `${theme.fg(\"dim\", \"SUBAGENTS (included in CURRENT):\")} $${costs.subagentCost.toFixed(4)} (${costs.subagentReports} reports)\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"TODAY (host local day):\")} $${costs.todayCost.toFixed(4)}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Today rollover:\")} local midnight\\n\\n`;\n\n\tconst processMemory = getProcessMemoryMb();\n\tinfo += `${theme.bold(\"Process\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Memory:\")} rss ${processMemory.rssMb}MB, heap ${processMemory.heapUsedMb}MB, external ${processMemory.externalMb}MB\\n\\n`;\n\n\tinfo += `${theme.bold(\"Optimization state\")}\\n`;\n\tconst contextPercent = context?.percent;\n\tconst contextTokens = context?.tokens;\n\tif (\n\t\tcontext &&\n\t\tcontextPercent !== undefined &&\n\t\tcontextPercent !== null &&\n\t\tcontextTokens !== undefined &&\n\t\tcontextTokens !== null\n\t) {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} ${contextPercent.toFixed(1)}% (${contextTokens.toLocaleString()}/${context.contextWindow.toLocaleString()})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} unknown until next provider usage sample\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto-compaction:\")} ${host.session.autoCompactionEnabled ? \"enabled\" : \"disabled\"}\\n`;\n\tconst compactionGates = stats.compactionGates ?? {\n\t\tgateFailures: 0,\n\t\tdeterministicGapFills: 0,\n\t\tcompactionsWithGateFailures: 0,\n\t};\n\tinfo += `${theme.fg(\"dim\", \"Compaction gate failures:\")} ${compactionGates.gateFailures} (${compactionGates.deterministicGapFills} deterministic gap-fill)\\n`;\n\tif (isChatGptSubscription) {\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} not applicable to ChatGPT subscription usage\\n`;\n\t} else if (costGuard) {\n\t\tconst status = costGuard.over ? \"over\" : \"ok\";\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} ${status} $${costGuard.estUsd.toFixed(4)}/$${costGuard.thresholdUsd.toFixed(4)} (${costGuard.action})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} disabled\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn:\")} ${autoLearn.enabled ? \"enabled\" : \"disabled\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Scavenger model:\")} ${autoLearn.model || \"active\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Reflection review:\")} ${autoLearn.reflectionReview ? \"enabled\" : \"disabled\"} (${autoLearn.reflectionMinToolCalls} tool-call trigger)\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn concurrency:\")} ${autoLearn.maxConcurrentLearners} learner(s), ${autoLearn.cooldownMinutes}m cooldown\\n\\n`;\n\n\tinfo += `${theme.bold(\"Model Router\")}\\n`;\n\tinfo += `${host.session.getModelRouterStatus((label) => theme.fg(\"dim\", label))}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Manual controls\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/compact\")}: compact the active context now\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/settings\")}: adjust Auto Learn, cost guard, compaction, and model-router config\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/auto-learn status|run\")}: inspect or launch background learning\\n`;\n\tinfo += `${theme.fg(\"dim\", \"context_audit\")}: ask the agent to inspect provider-visible context contributors\\n`;\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Text(info, 1, 0));\n\thost.ui.requestRender();\n}\n\nexport function handleChangelogCommand(host: ChangelogReportHost): void {\n\tconst changelogPath = getChangelogPath();\n\tconst allEntries = parseChangelog(changelogPath);\n\n\tconst changelogMarkdown =\n\t\tallEntries.length > 0\n\t\t\t? allEntries\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.map((e) => e.content)\n\t\t\t\t\t.join(\"\\n\\n\")\n\t\t\t: \"No changelog entries found.\";\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"What's New\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(changelogMarkdown, 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleHotkeysCommand(host: HotkeysReportHost): void {\n\t// Navigation keybindings\n\tconst cursorUp = host.getEditorKeyDisplay(\"tui.editor.cursorUp\");\n\tconst cursorDown = host.getEditorKeyDisplay(\"tui.editor.cursorDown\");\n\tconst cursorLeft = host.getEditorKeyDisplay(\"tui.editor.cursorLeft\");\n\tconst cursorRight = host.getEditorKeyDisplay(\"tui.editor.cursorRight\");\n\tconst cursorWordLeft = host.getEditorKeyDisplay(\"tui.editor.cursorWordLeft\");\n\tconst cursorWordRight = host.getEditorKeyDisplay(\"tui.editor.cursorWordRight\");\n\tconst cursorLineStart = host.getEditorKeyDisplay(\"tui.editor.cursorLineStart\");\n\tconst cursorLineEnd = host.getEditorKeyDisplay(\"tui.editor.cursorLineEnd\");\n\tconst jumpForward = host.getEditorKeyDisplay(\"tui.editor.jumpForward\");\n\tconst jumpBackward = host.getEditorKeyDisplay(\"tui.editor.jumpBackward\");\n\tconst pageUp = host.getEditorKeyDisplay(\"tui.editor.pageUp\");\n\tconst pageDown = host.getEditorKeyDisplay(\"tui.editor.pageDown\");\n\n\t// Editing keybindings\n\tconst submit = host.getEditorKeyDisplay(\"tui.input.submit\");\n\tconst newLine = host.getEditorKeyDisplay(\"tui.input.newLine\");\n\tconst deleteWordBackward = host.getEditorKeyDisplay(\"tui.editor.deleteWordBackward\");\n\tconst deleteWordForward = host.getEditorKeyDisplay(\"tui.editor.deleteWordForward\");\n\tconst deleteToLineStart = host.getEditorKeyDisplay(\"tui.editor.deleteToLineStart\");\n\tconst deleteToLineEnd = host.getEditorKeyDisplay(\"tui.editor.deleteToLineEnd\");\n\tconst yank = host.getEditorKeyDisplay(\"tui.editor.yank\");\n\tconst yankPop = host.getEditorKeyDisplay(\"tui.editor.yankPop\");\n\tconst undo = host.getEditorKeyDisplay(\"tui.editor.undo\");\n\tconst tab = host.getEditorKeyDisplay(\"tui.input.tab\");\n\n\t// App keybindings\n\tconst interrupt = host.getAppKeyDisplay(\"app.interrupt\");\n\tconst clear = host.getAppKeyDisplay(\"app.clear\");\n\tconst exit = host.getAppKeyDisplay(\"app.exit\");\n\tconst suspend = host.getAppKeyDisplay(\"app.suspend\");\n\tconst cycleThinkingLevel = host.getAppKeyDisplay(\"app.thinking.cycle\");\n\tconst cycleModelForward = host.getAppKeyDisplay(\"app.model.cycleForward\");\n\tconst selectModel = host.getAppKeyDisplay(\"app.model.select\");\n\tconst expandTools = host.getAppKeyDisplay(\"app.tools.expand\");\n\tconst toggleThinking = host.getAppKeyDisplay(\"app.thinking.toggle\");\n\tconst externalEditor = host.getAppKeyDisplay(\"app.editor.external\");\n\tconst cycleModelBackward = host.getAppKeyDisplay(\"app.model.cycleBackward\");\n\tconst followUp = host.getAppKeyDisplay(\"app.message.followUp\");\n\tconst dequeue = host.getAppKeyDisplay(\"app.message.dequeue\");\n\tconst pasteImage = host.getAppKeyDisplay(\"app.clipboard.pasteImage\");\n\n\tlet hotkeys = `\n**Navigation**\n| Key | Action |\n|-----|--------|\n| \\`${cursorUp}\\` / \\`${cursorDown}\\` / \\`${cursorLeft}\\` / \\`${cursorRight}\\` | Move cursor / browse history (Up when empty) |\n| \\`${cursorWordLeft}\\` / \\`${cursorWordRight}\\` | Move by word |\n| \\`${cursorLineStart}\\` | Start of line |\n| \\`${cursorLineEnd}\\` | End of line |\n| \\`${jumpForward}\\` | Jump forward to character |\n| \\`${jumpBackward}\\` | Jump backward to character |\n| \\`${pageUp}\\` / \\`${pageDown}\\` | Scroll by page |\n\n**Editing**\n| Key | Action |\n|-----|--------|\n| \\`${submit}\\` | Send message |\n| \\`${newLine}\\` | New line${process.platform === \"win32\" ? \" (Ctrl+Enter on Windows Terminal)\" : \"\"} |\n| \\`${deleteWordBackward}\\` | Delete word backwards |\n| \\`${deleteWordForward}\\` | Delete word forwards |\n| \\`${deleteToLineStart}\\` | Delete to start of line |\n| \\`${deleteToLineEnd}\\` | Delete to end of line |\n| \\`${yank}\\` | Paste the most-recently-deleted text |\n| \\`${yankPop}\\` | Cycle through the deleted text after pasting |\n| \\`${undo}\\` | Undo |\n\n**Other**\n| Key | Action |\n|-----|--------|\n| \\`${tab}\\` | Path completion / accept autocomplete |\n| \\`${interrupt}\\` | Cancel autocomplete / abort streaming |\n| \\`${clear}\\` | Clear editor (first) / exit (second) |\n| \\`${exit}\\` | Exit (when editor is empty) |\n| \\`${suspend}\\` | Suspend to background |\n| \\`${cycleThinkingLevel}\\` | Cycle thinking level |\n| \\`${cycleModelForward}\\` / \\`${cycleModelBackward}\\` | Cycle models |\n| \\`${selectModel}\\` | Open model selector |\n| \\`${expandTools}\\` | Toggle tool output expansion |\n| \\`${toggleThinking}\\` | Toggle thinking block visibility |\n| \\`${externalEditor}\\` | Edit message in external editor |\n| \\`${followUp}\\` | Queue follow-up message |\n| \\`${dequeue}\\` | Restore queued messages |\n| \\`${pasteImage}\\` | Paste image from clipboard |\n| \\`/\\` | Slash commands |\n| \\`!\\` | Run bash command |\n| \\`!!\\` | Run bash command (excluded from context) |\n`;\n\n\t// Add extension-registered shortcuts\n\tconst extensionRunner = host.session.extensionRunner;\n\tconst shortcuts = extensionRunner.getShortcuts(host.keybindings.getEffectiveConfig());\n\tif (shortcuts.size > 0) {\n\t\thotkeys += `\n**Extensions**\n| Key | Action |\n|-----|--------|\n`;\n\t\tfor (const [key, shortcut] of shortcuts) {\n\t\t\tconst description = shortcut.description ?? shortcut.extensionPath;\n\t\t\tconst keyDisplay = formatKeyText(key, { capitalize: true });\n\t\t\thotkeys += `| \\`${keyDisplay}\\` | ${description} |\\n`;\n\t\t}\n\t}\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"Keyboard Shortcuts\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(hotkeys.trim(), 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleDebugCommand(host: DebugReportHost): void {\n\tconst width = host.ui.terminal.columns;\n\tconst height = host.ui.terminal.rows;\n\tconst allLines = host.ui.render(width);\n\n\tconst debugLogPath = getDebugLogPath();\n\tconst debugData = [\n\t\t`Debug output at ${new Date().toISOString()}`,\n\t\t`Terminal: ${width}x${height}`,\n\t\t`Total lines: ${allLines.length}`,\n\t\t\"\",\n\t\t\"=== All rendered lines with visible widths ===\",\n\t\t...allLines.map((line, idx) => {\n\t\t\tconst vw = visibleWidth(line);\n\t\t\tconst escaped = JSON.stringify(line);\n\t\t\treturn `[${idx}] (w=${vw}) ${escaped}`;\n\t\t}),\n\t\t\"\",\n\t\t\"=== Agent messages (JSONL) ===\",\n\t\t...host.session.messages.map((msg) => JSON.stringify(msg)),\n\t\t\"\",\n\t].join(\"\\n\");\n\n\tfs.mkdirSync(path.dirname(debugLogPath), { recursive: true });\n\tfs.writeFileSync(debugLogPath, debugData);\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(\n\t\tnew Text(`${theme.fg(\"accent\", \"✓ Debug log written\")}\\n${theme.fg(\"muted\", debugLogPath)}`, 1, 1),\n\t);\n\thost.ui.requestRender();\n}\n\nexport function handleArminSaysHi(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new ArminComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function handleDementedDelves(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new EarendilAnnouncementComponent());\n\thost.ui.requestRender();\n}\n\nexport function handleDaxnuts(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DaxnutsComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function checkDaxnutsEasterEgg(host: ReportRenderHost, model: { provider: string; id: string }): void {\n\tif (model.provider === \"opencode\" && model.id.toLowerCase().includes(\"kimi-k2.5\")) {\n\t\thandleDaxnuts(host);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"report-commands.js","sourceRoot":"","sources":["../../../src/modes/interactive/report-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIlD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;A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,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;AAAA,CACxB;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAsB,EAAQ;IAClE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,6BAA6B,EAAE,CAAC,CAAC;IACjE,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;AAAA,CACxB;AAED,MAAM,UAAU,aAAa,CAAC,IAAsB,EAAQ;IAC3D,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3D,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;AAAA,CACxB;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAsB,EAAE,KAAuC,EAAQ;IAC5G,IAAI,KAAK,CAAC,QAAQ,KAAK,UAAU,IAAI,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACnF,aAAa,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;AAAA,CACD","sourcesContent":["/**\n * Read-only report and easter-egg commands extracted from interactive-mode.\n *\n * These build informational output (usage/cost summary, changelog, hotkeys\n * table, render debug dump) or render an easter-egg component, appending to the\n * chat container and requesting a render. None mutate agent/session state, so\n * they operate through narrow `host` seams (chat container, TUI, and a few\n * read accessors) while interactive-mode keeps thin delegating wrappers.\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { Container, Keybinding, MarkdownTheme, TUI } from \"@caupulican/pi-tui\";\nimport { Markdown, Spacer, Text, visibleWidth } from \"@caupulican/pi-tui\";\nimport { getDebugLogPath } from \"../../config.ts\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport type { AppKeybinding, KeybindingsManager } from \"../../core/keybindings.ts\";\nimport type { AutoLearnSettings } from \"../../core/settings-manager.ts\";\nimport { getChangelogPath, parseChangelog } from \"../../utils/changelog.ts\";\nimport { getProcessMemoryMb } from \"../../utils/process-memory.ts\";\nimport { ArminComponent } from \"./components/armin.ts\";\nimport { DaxnutsComponent } from \"./components/daxnuts.ts\";\nimport { DynamicBorder } from \"./components/dynamic-border.ts\";\nimport { EarendilAnnouncementComponent } from \"./components/earendil-announcement.ts\";\nimport { formatKeyText } from \"./components/keybinding-hints.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\nexport interface ReportRenderHost {\n\treadonly chatContainer: Container;\n\treadonly ui: TUI;\n}\n\nexport interface UsageReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\tgetCurrentAutoLearnSettings(): Required<AutoLearnSettings>;\n}\n\nexport interface ChangelogReportHost extends ReportRenderHost {\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n}\n\nexport interface HotkeysReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\treadonly keybindings: KeybindingsManager;\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n\tgetAppKeyDisplay(action: AppKeybinding): string;\n\tgetEditorKeyDisplay(action: Keybinding): string;\n}\n\nexport interface DebugReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n}\n\nexport function handleUsageCommand(host: UsageReportHost): void {\n\tconst stats = host.session.getSessionStats();\n\tconst costs = host.session.getCostSummary();\n\tconst context = host.session.getContextUsage();\n\tconst autoLearn = host.getCurrentAutoLearnSettings();\n\tconst costGuard = host.session.getLastCostGuardDecision();\n\tconst activeModel = host.session.model;\n\tconst usingSubscription = activeModel ? host.session.modelRegistry.isUsingOAuth(activeModel) : false;\n\tconst isChatGptSubscription = usingSubscription && activeModel?.provider === \"openai-codex\";\n\n\tlet info = `${theme.bold(\"Usage & Optimization\")}\\n\\n`;\n\tinfo += `${theme.bold(\"Session tokens\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Input:\")} ${stats.tokens.input.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Output:\")} ${stats.tokens.output.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Cache read:\")} ${stats.tokens.cacheRead.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Cache write:\")} ${stats.tokens.cacheWrite.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.tokens.total.toLocaleString()}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Cost\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"CURRENT (session):\")} $${costs.currentCost.toFixed(4)}${usingSubscription ? \" (sub)\" : \"\"}\\n`;\n\tif (costs.subagentReports > 0 || costs.subagentCost > 0) {\n\t\tinfo += `${theme.fg(\"dim\", \"SUBAGENTS (included in CURRENT):\")} $${costs.subagentCost.toFixed(4)} (${costs.subagentReports} reports)\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"TODAY (host local day):\")} $${costs.todayCost.toFixed(4)}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Today rollover:\")} local midnight\\n\\n`;\n\n\tconst processMemory = getProcessMemoryMb();\n\tinfo += `${theme.bold(\"Process\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Memory:\")} rss ${processMemory.rssMb}MB, heap ${processMemory.heapUsedMb}MB, external ${processMemory.externalMb}MB\\n\\n`;\n\n\tinfo += `${theme.bold(\"Optimization state\")}\\n`;\n\tconst contextPercent = context?.percent;\n\tconst contextTokens = context?.tokens;\n\tif (\n\t\tcontext &&\n\t\tcontextPercent !== undefined &&\n\t\tcontextPercent !== null &&\n\t\tcontextTokens !== undefined &&\n\t\tcontextTokens !== null\n\t) {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} ${contextPercent.toFixed(1)}% (${contextTokens.toLocaleString()}/${context.contextWindow.toLocaleString()})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} unknown until next provider usage sample\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto-compaction:\")} ${host.session.autoCompactionEnabled ? \"enabled\" : \"disabled\"}\\n`;\n\tconst compactionGates = stats.compactionGates ?? {\n\t\tgateFailures: 0,\n\t\tdeterministicGapFills: 0,\n\t\tcompactionsWithGateFailures: 0,\n\t\tchecks: {},\n\t};\n\tinfo += `${theme.fg(\"dim\", \"Compaction gate failures:\")} ${compactionGates.gateFailures} (${compactionGates.deterministicGapFills} deterministic gap-fill)\\n`;\n\tconst failingChecks = Object.entries(compactionGates.checks).sort(\n\t\t([leftName, left], [rightName, right]) => right.failures - left.failures || leftName.localeCompare(rightName),\n\t);\n\tif (failingChecks.length > 0) {\n\t\tconst visibleChecks = failingChecks.slice(0, 3).map(([check, checkStats]) => {\n\t\t\tlet score = \"\";\n\t\t\tif (checkStats.minScore !== undefined && checkStats.maxScore !== undefined) {\n\t\t\t\tconst range =\n\t\t\t\t\tcheckStats.minScore === checkStats.maxScore\n\t\t\t\t\t\t? checkStats.minScore.toFixed(2)\n\t\t\t\t\t\t: `${checkStats.minScore.toFixed(2)}-${checkStats.maxScore.toFixed(2)}`;\n\t\t\t\tconst threshold =\n\t\t\t\t\tcheckStats.threshold === undefined\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: ` ${checkStats.comparator === \"maximum\" ? \">\" : \"<\"} ${checkStats.threshold.toFixed(2)}`;\n\t\t\t\tscore = ` (${range}${threshold})`;\n\t\t\t}\n\t\t\treturn `${check} x${checkStats.failures}${score}`;\n\t\t});\n\t\tif (failingChecks.length > visibleChecks.length) {\n\t\t\tvisibleChecks.push(`+${failingChecks.length - visibleChecks.length} more`);\n\t\t}\n\t\tinfo += `${theme.fg(\"dim\", \"Failing compaction checks:\")} ${visibleChecks.join(\"; \")}\\n`;\n\t}\n\tif (isChatGptSubscription) {\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} not applicable to ChatGPT subscription usage\\n`;\n\t} else if (costGuard) {\n\t\tconst status = costGuard.over ? \"over\" : \"ok\";\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} ${status} $${costGuard.estUsd.toFixed(4)}/$${costGuard.thresholdUsd.toFixed(4)} (${costGuard.action})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} disabled\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn:\")} ${autoLearn.enabled ? \"enabled\" : \"disabled\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Scavenger model:\")} ${autoLearn.model || \"active\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Reflection review:\")} ${autoLearn.reflectionReview ? \"enabled\" : \"disabled\"} (${autoLearn.reflectionMinToolCalls} tool-call trigger)\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn concurrency:\")} ${autoLearn.maxConcurrentLearners} learner(s), ${autoLearn.cooldownMinutes}m cooldown\\n\\n`;\n\n\tinfo += `${theme.bold(\"Model Router\")}\\n`;\n\tinfo += `${host.session.getModelRouterStatus((label) => theme.fg(\"dim\", label))}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Manual controls\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/compact\")}: compact the active context now\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/settings\")}: adjust Auto Learn, cost guard, compaction, and model-router config\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/auto-learn status|run\")}: inspect or launch background learning\\n`;\n\tinfo += `${theme.fg(\"dim\", \"context_audit\")}: ask the agent to inspect provider-visible context contributors\\n`;\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Text(info, 1, 0));\n\thost.ui.requestRender();\n}\n\nexport function handleChangelogCommand(host: ChangelogReportHost): void {\n\tconst changelogPath = getChangelogPath();\n\tconst allEntries = parseChangelog(changelogPath);\n\n\tconst changelogMarkdown =\n\t\tallEntries.length > 0\n\t\t\t? allEntries\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.map((e) => e.content)\n\t\t\t\t\t.join(\"\\n\\n\")\n\t\t\t: \"No changelog entries found.\";\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"What's New\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(changelogMarkdown, 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleHotkeysCommand(host: HotkeysReportHost): void {\n\t// Navigation keybindings\n\tconst cursorUp = host.getEditorKeyDisplay(\"tui.editor.cursorUp\");\n\tconst cursorDown = host.getEditorKeyDisplay(\"tui.editor.cursorDown\");\n\tconst cursorLeft = host.getEditorKeyDisplay(\"tui.editor.cursorLeft\");\n\tconst cursorRight = host.getEditorKeyDisplay(\"tui.editor.cursorRight\");\n\tconst cursorWordLeft = host.getEditorKeyDisplay(\"tui.editor.cursorWordLeft\");\n\tconst cursorWordRight = host.getEditorKeyDisplay(\"tui.editor.cursorWordRight\");\n\tconst cursorLineStart = host.getEditorKeyDisplay(\"tui.editor.cursorLineStart\");\n\tconst cursorLineEnd = host.getEditorKeyDisplay(\"tui.editor.cursorLineEnd\");\n\tconst jumpForward = host.getEditorKeyDisplay(\"tui.editor.jumpForward\");\n\tconst jumpBackward = host.getEditorKeyDisplay(\"tui.editor.jumpBackward\");\n\tconst pageUp = host.getEditorKeyDisplay(\"tui.editor.pageUp\");\n\tconst pageDown = host.getEditorKeyDisplay(\"tui.editor.pageDown\");\n\n\t// Editing keybindings\n\tconst submit = host.getEditorKeyDisplay(\"tui.input.submit\");\n\tconst newLine = host.getEditorKeyDisplay(\"tui.input.newLine\");\n\tconst deleteWordBackward = host.getEditorKeyDisplay(\"tui.editor.deleteWordBackward\");\n\tconst deleteWordForward = host.getEditorKeyDisplay(\"tui.editor.deleteWordForward\");\n\tconst deleteToLineStart = host.getEditorKeyDisplay(\"tui.editor.deleteToLineStart\");\n\tconst deleteToLineEnd = host.getEditorKeyDisplay(\"tui.editor.deleteToLineEnd\");\n\tconst yank = host.getEditorKeyDisplay(\"tui.editor.yank\");\n\tconst yankPop = host.getEditorKeyDisplay(\"tui.editor.yankPop\");\n\tconst undo = host.getEditorKeyDisplay(\"tui.editor.undo\");\n\tconst tab = host.getEditorKeyDisplay(\"tui.input.tab\");\n\n\t// App keybindings\n\tconst interrupt = host.getAppKeyDisplay(\"app.interrupt\");\n\tconst clear = host.getAppKeyDisplay(\"app.clear\");\n\tconst exit = host.getAppKeyDisplay(\"app.exit\");\n\tconst suspend = host.getAppKeyDisplay(\"app.suspend\");\n\tconst cycleThinkingLevel = host.getAppKeyDisplay(\"app.thinking.cycle\");\n\tconst cycleModelForward = host.getAppKeyDisplay(\"app.model.cycleForward\");\n\tconst selectModel = host.getAppKeyDisplay(\"app.model.select\");\n\tconst expandTools = host.getAppKeyDisplay(\"app.tools.expand\");\n\tconst toggleThinking = host.getAppKeyDisplay(\"app.thinking.toggle\");\n\tconst externalEditor = host.getAppKeyDisplay(\"app.editor.external\");\n\tconst cycleModelBackward = host.getAppKeyDisplay(\"app.model.cycleBackward\");\n\tconst followUp = host.getAppKeyDisplay(\"app.message.followUp\");\n\tconst dequeue = host.getAppKeyDisplay(\"app.message.dequeue\");\n\tconst pasteImage = host.getAppKeyDisplay(\"app.clipboard.pasteImage\");\n\n\tlet hotkeys = `\n**Navigation**\n| Key | Action |\n|-----|--------|\n| \\`${cursorUp}\\` / \\`${cursorDown}\\` / \\`${cursorLeft}\\` / \\`${cursorRight}\\` | Move cursor / browse history (Up when empty) |\n| \\`${cursorWordLeft}\\` / \\`${cursorWordRight}\\` | Move by word |\n| \\`${cursorLineStart}\\` | Start of line |\n| \\`${cursorLineEnd}\\` | End of line |\n| \\`${jumpForward}\\` | Jump forward to character |\n| \\`${jumpBackward}\\` | Jump backward to character |\n| \\`${pageUp}\\` / \\`${pageDown}\\` | Scroll by page |\n\n**Editing**\n| Key | Action |\n|-----|--------|\n| \\`${submit}\\` | Send message |\n| \\`${newLine}\\` | New line${process.platform === \"win32\" ? \" (Ctrl+Enter on Windows Terminal)\" : \"\"} |\n| \\`${deleteWordBackward}\\` | Delete word backwards |\n| \\`${deleteWordForward}\\` | Delete word forwards |\n| \\`${deleteToLineStart}\\` | Delete to start of line |\n| \\`${deleteToLineEnd}\\` | Delete to end of line |\n| \\`${yank}\\` | Paste the most-recently-deleted text |\n| \\`${yankPop}\\` | Cycle through the deleted text after pasting |\n| \\`${undo}\\` | Undo |\n\n**Other**\n| Key | Action |\n|-----|--------|\n| \\`${tab}\\` | Path completion / accept autocomplete |\n| \\`${interrupt}\\` | Cancel autocomplete / abort streaming |\n| \\`${clear}\\` | Clear editor (first) / exit (second) |\n| \\`${exit}\\` | Exit (when editor is empty) |\n| \\`${suspend}\\` | Suspend to background |\n| \\`${cycleThinkingLevel}\\` | Cycle thinking level |\n| \\`${cycleModelForward}\\` / \\`${cycleModelBackward}\\` | Cycle models |\n| \\`${selectModel}\\` | Open model selector |\n| \\`${expandTools}\\` | Toggle tool output expansion |\n| \\`${toggleThinking}\\` | Toggle thinking block visibility |\n| \\`${externalEditor}\\` | Edit message in external editor |\n| \\`${followUp}\\` | Queue follow-up message |\n| \\`${dequeue}\\` | Restore queued messages |\n| \\`${pasteImage}\\` | Paste image from clipboard |\n| \\`/\\` | Slash commands |\n| \\`!\\` | Run bash command |\n| \\`!!\\` | Run bash command (excluded from context) |\n`;\n\n\t// Add extension-registered shortcuts\n\tconst extensionRunner = host.session.extensionRunner;\n\tconst shortcuts = extensionRunner.getShortcuts(host.keybindings.getEffectiveConfig());\n\tif (shortcuts.size > 0) {\n\t\thotkeys += `\n**Extensions**\n| Key | Action |\n|-----|--------|\n`;\n\t\tfor (const [key, shortcut] of shortcuts) {\n\t\t\tconst description = shortcut.description ?? shortcut.extensionPath;\n\t\t\tconst keyDisplay = formatKeyText(key, { capitalize: true });\n\t\t\thotkeys += `| \\`${keyDisplay}\\` | ${description} |\\n`;\n\t\t}\n\t}\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"Keyboard Shortcuts\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(hotkeys.trim(), 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleDebugCommand(host: DebugReportHost): void {\n\tconst width = host.ui.terminal.columns;\n\tconst height = host.ui.terminal.rows;\n\tconst allLines = host.ui.render(width);\n\n\tconst debugLogPath = getDebugLogPath();\n\tconst debugData = [\n\t\t`Debug output at ${new Date().toISOString()}`,\n\t\t`Terminal: ${width}x${height}`,\n\t\t`Total lines: ${allLines.length}`,\n\t\t\"\",\n\t\t\"=== All rendered lines with visible widths ===\",\n\t\t...allLines.map((line, idx) => {\n\t\t\tconst vw = visibleWidth(line);\n\t\t\tconst escaped = JSON.stringify(line);\n\t\t\treturn `[${idx}] (w=${vw}) ${escaped}`;\n\t\t}),\n\t\t\"\",\n\t\t\"=== Agent messages (JSONL) ===\",\n\t\t...host.session.messages.map((msg) => JSON.stringify(msg)),\n\t\t\"\",\n\t].join(\"\\n\");\n\n\tfs.mkdirSync(path.dirname(debugLogPath), { recursive: true });\n\tfs.writeFileSync(debugLogPath, debugData);\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(\n\t\tnew Text(`${theme.fg(\"accent\", \"✓ Debug log written\")}\\n${theme.fg(\"muted\", debugLogPath)}`, 1, 1),\n\t);\n\thost.ui.requestRender();\n}\n\nexport function handleArminSaysHi(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new ArminComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function handleDementedDelves(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new EarendilAnnouncementComponent());\n\thost.ui.requestRender();\n}\n\nexport function handleDaxnuts(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DaxnutsComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function checkDaxnutsEasterEgg(host: ReportRenderHost, model: { provider: string; id: string }): void {\n\tif (model.provider === \"opencode\" && model.id.toLowerCase().includes(\"kimi-k2.5\")) {\n\t\thandleDaxnuts(host);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-display.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/resource-display.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAI5D,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAUnD;AAED,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAI5D;AAED,wBAAgB,eAAe,CAAC,UAAU,CAAC,EAAE,UAAU,GAAG,OAAO,CAGhE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,MAAM,CA2B9E;AAED,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,U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* Pure formatters for the startup \"loaded resources\" listing and diagnostics.\n *\n * Every function here reads only its arguments (paths, source metadata, diagnostics)\n * and returns strings/data; none touch UI components, session state, or `this`.\n * `showLoadedResources` and other stateful display code in interactive-mode delegate\n * to these so the presentation math is unit-testable in isolation.\n */\n\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport type { ResourceDiagnostic } from \"../../core/resource-loader.ts\";\nimport type { SourceInfo } from \"../../core/source-info.ts\";\nimport { parseGitUrl } from \"../../utils/git.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\nexport function formatDisplayPath(p: string): string {\n\tconst home = os.homedir();\n\tlet result = p;\n\n\t// Replace home directory with ~\n\tif (result.startsWith(home)) {\n\t\tresult = `~${result.slice(home.length)}`;\n\t}\n\n\treturn result;\n}\n\nexport function formatExtensionDisplayPath(p: string): string {\n\tlet result = formatDisplayPath(p);\n\tresult = result.replace(/\\/index\\.ts$/, \"\").replace(/\\/index\\.js$/, \"\");\n\treturn result;\n}\n\nexport function isPackageSource(sourceInfo?: SourceInfo): boolean {\n\tconst source = sourceInfo?.source ?? \"\";\n\treturn source.startsWith(\"npm:\") || source.startsWith(\"git:\");\n}\n\n/**\n * Get a short path relative to the package root for display.\n */\nexport function getShortPath(fullPath: string, sourceInfo?: SourceInfo): string {\n\tconst baseDir = sourceInfo?.baseDir;\n\tif (baseDir && isPackageSource(sourceInfo)) {\n\t\tconst relativePath = path.relative(path.resolve(baseDir), path.resolve(fullPath));\n\t\tif (\n\t\t\trelativePath &&\n\t\t\trelativePath !== \".\" &&\n\t\t\t!relativePath.startsWith(\"..\") &&\n\t\t\t!relativePath.startsWith(`..${path.sep}`) &&\n\t\t\t!path.isAbsolute(relativePath)\n\t\t) {\n\t\t\treturn relativePath.replace(/\\\\/g, \"/\");\n\t\t}\n\t}\n\n\tconst source = sourceInfo?.source ?? \"\";\n\tconst npmMatch = fullPath.match(/node_modules\\/(@?[^/]+(?:\\/[^/]+)?)\\/(.*)/);\n\tif (npmMatch && source.startsWith(\"npm:\")) {\n\t\treturn npmMatch[2];\n\t}\n\n\tconst gitMatch = fullPath.match(/git\\/[^/]+\\/[^/]+\\/(.*)/);\n\tif (gitMatch && source.startsWith(\"git:\")) {\n\t\treturn gitMatch[1];\n\t}\n\n\treturn formatDisplayPath(fullPath);\n}\n\nexport function getCompactPathLabel(resourcePath: string, sourceInfo?: SourceInfo): string {\n\tconst shortPath = getShortPath(resourcePath, sourceInfo);\n\tconst normalizedPath = shortPath.replace(/\\\\/g, \"/\");\n\tconst segments = normalizedPath.split(\"/\").filter((segment) => segment.length > 0 && segment !== \"~\");\n\tif (segments.length > 0) {\n\t\treturn segments[segments.length - 1]!;\n\t}\n\treturn shortPath;\n}\n\nexport function getCompactPackageSourceLabel(sourceInfo?: SourceInfo): string {\n\tconst source = sourceInfo?.source ?? \"\";\n\tif (source.startsWith(\"npm:\")) {\n\t\treturn source.slice(\"npm:\".length) || source;\n\t}\n\n\tconst gitSource = parseGitUrl(source);\n\tif (gitSource) {\n\t\treturn gitSource.path || source;\n\t}\n\n\treturn source;\n}\n\nexport function getCompactExtensionLabel(resourcePath: string, sourceInfo?: SourceInfo): string {\n\tif (!isPackageSource(sourceInfo)) {\n\t\treturn getCompactPathLabel(resourcePath, sourceInfo);\n\t}\n\n\tconst sourceLabel = getCompactPackageSourceLabel(sourceInfo);\n\tif (!sourceLabel) {\n\t\treturn getCompactPathLabel(resourcePath, sourceInfo);\n\t}\n\n\tconst shortPath = getShortPath(resourcePath, sourceInfo).replace(/\\\\/g, \"/\");\n\tconst packagePath = shortPath.startsWith(\"extensions/\") ? shortPath.slice(\"extensions/\".length) : shortPath;\n\tconst parsedPath = path.posix.parse(packagePath);\n\n\tif (parsedPath.name === \"index\") {\n\t\treturn !parsedPath.dir || parsedPath.dir === \".\" ? sourceLabel : `${sourceLabel}:${parsedPath.dir}`;\n\t}\n\n\treturn `${sourceLabel}:${packagePath}`;\n}\n\nexport function getCompactDisplayPathSegments(resourcePath: string): string[] {\n\treturn formatDisplayPath(resourcePath)\n\t\t.replace(/\\\\/g, \"/\")\n\t\t.split(\"/\")\n\t\t.filter((segment) => segment.length > 0 && segment !== \"~\");\n}\n\nexport function getCompactNonPackageExtensionLabel(\n\tresourcePath: string,\n\tindex: number,\n\tallPaths: Array<{ path: string; segments: string[] }>,\n): string {\n\tconst segments = allPaths[index]?.segments;\n\tif (!segments || segments.length === 0) {\n\t\treturn getCompactPathLabel(resourcePath);\n\t}\n\n\tfor (let segmentCount = 1; segmentCount <= segments.length; segmentCount += 1) {\n\t\tconst candidate = segments.slice(-segmentCount).join(\"/\");\n\t\tconst isUnique = allPaths.every((item, itemIndex) => {\n\t\t\tif (itemIndex === index) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn item.segments.slice(-segmentCount).join(\"/\") !== candidate;\n\t\t});\n\n\t\tif (isUnique) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn segments.join(\"/\");\n}\n\nexport function getCompactExtensionLabels(extensions: Array<{ path: string; sourceInfo?: SourceInfo }>): string[] {\n\tconst nonPackageExtensions = extensions\n\t\t.map((extension) => {\n\t\t\tconst segments = getCompactDisplayPathSegments(extension.path);\n\t\t\tconst lastSegment = segments[segments.length - 1];\n\t\t\tif (segments.length > 1 && (lastSegment === \"index.ts\" || lastSegment === \"index.js\")) {\n\t\t\t\tsegments.pop();\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpath: extension.path,\n\t\t\t\tsourceInfo: extension.sourceInfo,\n\t\t\t\tsegments,\n\t\t\t};\n\t\t})\n\t\t.filter((extension) => !isPackageSource(extension.sourceInfo));\n\n\treturn extensions.map((extension) => {\n\t\tif (isPackageSource(extension.sourceInfo)) {\n\t\t\treturn getCompactExtensionLabel(extension.path, extension.sourceInfo);\n\t\t}\n\n\t\tconst nonPackageIndex = nonPackageExtensions.findIndex((item) => item.path === extension.path);\n\t\tif (nonPackageIndex === -1) {\n\t\t\treturn getCompactPathLabel(extension.path, extension.sourceInfo);\n\t\t}\n\n\t\treturn getCompactNonPackageExtensionLabel(extension.path, nonPackageIndex, nonPackageExtensions);\n\t});\n}\n\nexport function getDisplaySourceInfo(sourceInfo?: SourceInfo): {\n\tlabel: string;\n\tscopeLabel?: string;\n\tcolor: \"accent\" | \"muted\";\n} {\n\tconst source = sourceInfo?.source ?? \"local\";\n\tconst scope = sourceInfo?.scope ?? \"project\";\n\tif (source === \"local\") {\n\t\tif (scope === \"user\") {\n\t\t\treturn { label: \"user\", color: \"muted\" };\n\t\t}\n\t\tif (scope === \"project\") {\n\t\t\treturn { label: \"project\", color: \"muted\" };\n\t\t}\n\t\tif (scope === \"temporary\") {\n\t\t\treturn { label: \"path\", scopeLabel: \"temp\", color: \"muted\" };\n\t\t}\n\t\treturn { label: \"path\", color: \"muted\" };\n\t}\n\n\tif (source === \"cli\") {\n\t\treturn { label: \"path\", scopeLabel: scope === \"temporary\" ? \"temp\" : undefined, color: \"muted\" };\n\t}\n\n\tconst scopeLabel =\n\t\tscope === \"user\" ? \"user\" : scope === \"project\" ? \"project\" : scope === \"temporary\" ? \"temp\" : undefined;\n\treturn { label: source, scopeLabel, color: \"accent\" };\n}\n\nexport function getScopeGroup(sourceInfo?: SourceInfo): \"user\" | \"project\" | \"path\" {\n\tconst source = sourceInfo?.source ?? \"local\";\n\tconst scope = sourceInfo?.scope ?? \"project\";\n\tif (source === \"cli\" || scope === \"temporary\") return \"path\";\n\tif (scope === \"user\") return \"user\";\n\tif (scope === \"project\") return \"project\";\n\treturn \"path\";\n}\n\nexport function buildScopeGroups(items: Array<{ path: string; sourceInfo?: SourceInfo }>): Array<{\n\tscope: \"user\" | \"project\" | \"path\";\n\tpaths: Array<{ path: string; sourceInfo?: SourceInfo }>;\n\tpackages: Map<string, Array<{ path: string; sourceInfo?: SourceInfo }>>;\n}> {\n\tconst groups: Record<\n\t\t\"user\" | \"project\" | \"path\",\n\t\t{\n\t\t\tscope: \"user\" | \"project\" | \"path\";\n\t\t\tpaths: Array<{ path: string; sourceInfo?: SourceInfo }>;\n\t\t\tpackages: Map<string, Array<{ path: string; sourceInfo?: SourceInfo }>>;\n\t\t}\n\t> = {\n\t\tuser: { scope: \"user\", paths: [], packages: new Map() },\n\t\tproject: { scope: \"project\", paths: [], packages: new Map() },\n\t\tpath: { scope: \"path\", paths: [], packages: new Map() },\n\t};\n\n\tfor (const item of items) {\n\t\tconst groupKey = getScopeGroup(item.sourceInfo);\n\t\tconst group = groups[groupKey];\n\t\tconst source = item.sourceInfo?.source ?? \"local\";\n\n\t\tif (isPackageSource(item.sourceInfo)) {\n\t\t\tconst list = group.packages.get(source) ?? [];\n\t\t\tlist.push(item);\n\t\t\tgroup.packages.set(source, list);\n\t\t} else {\n\t\t\tgroup.paths.push(item);\n\t\t}\n\t}\n\n\treturn [groups.project, groups.user, groups.path].filter(\n\t\t(group) => group.paths.length > 0 || group.packages.size > 0,\n\t);\n}\n\nexport function formatScopeGroups(\n\tgroups: Array<{\n\t\tscope: \"user\" | \"project\" | \"path\";\n\t\tpaths: Array<{ path: string; sourceInfo?: SourceInfo }>;\n\t\tpackages: Map<string, Array<{ path: string; sourceInfo?: SourceInfo }>>;\n\t}>,\n\toptions: {\n\t\tformatPath: (item: { path: string; sourceInfo?: SourceInfo }) => string;\n\t\tformatPackagePath: (item: { path: string; sourceInfo?: SourceInfo }, source: string) => string;\n\t},\n): string {\n\tconst lines: string[] = [];\n\n\tfor (const group of groups) {\n\t\tlines.push(` ${theme.fg(\"accent\", group.scope)}`);\n\n\t\tconst sortedPaths = [...group.paths].sort((a, b) => a.path.localeCompare(b.path));\n\t\tfor (const item of sortedPaths) {\n\t\t\tlines.push(theme.fg(\"dim\", ` ${options.formatPath(item)}`));\n\t\t}\n\n\t\tconst sortedPackages = Array.from(group.packages.entries()).sort(([a], [b]) => a.localeCompare(b));\n\t\tfor (const [source, items] of sortedPackages) {\n\t\t\tlines.push(` ${theme.fg(\"mdLink\", source)}`);\n\t\t\tconst sortedPackagePaths = [...items].sort((a, b) => a.path.localeCompare(b.path));\n\t\t\tfor (const item of sortedPackagePaths) {\n\t\t\t\tlines.push(theme.fg(\"dim\", ` ${options.formatPackagePath(item, source)}`));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\nexport function findSourceInfoForPath(p: string, sourceInfos: Map<string, SourceInfo>): SourceInfo | undefined {\n\tconst exact = sourceInfos.get(p);\n\tif (exact) return exact;\n\n\tlet current = p;\n\twhile (current.includes(\"/\")) {\n\t\tcurrent = current.substring(0, current.lastIndexOf(\"/\"));\n\t\tconst parent = sourceInfos.get(current);\n\t\tif (parent) return parent;\n\t}\n\n\treturn undefined;\n}\n\nexport function formatPathWithSource(p: string, sourceInfo?: SourceInfo): string {\n\tif (sourceInfo) {\n\t\tconst shortPath = getShortPath(p, sourceInfo);\n\t\tconst { label, scopeLabel } = getDisplaySourceInfo(sourceInfo);\n\t\tconst labelText = scopeLabel ? `${label} (${scopeLabel})` : label;\n\t\treturn `${labelText} ${shortPath}`;\n\t}\n\treturn formatDisplayPath(p);\n}\n\nexport function formatDiagnostics(\n\tdiagnostics: readonly ResourceDiagnostic[],\n\tsourceInfos: Map<string, SourceInfo>,\n): string {\n\tconst lines: string[] = [];\n\n\t// Group collision diagnostics by name\n\tconst collisions = new Map<string, ResourceDiagnostic[]>();\n\tconst otherDiagnostics: ResourceDiagnostic[] = [];\n\n\tfor (const d of diagnostics) {\n\t\tif (d.type === \"collision\" && d.collision) {\n\t\t\tconst list = collisions.get(d.collision.name) ?? [];\n\t\t\tlist.push(d);\n\t\t\tcollisions.set(d.collision.name, list);\n\t\t} else {\n\t\t\totherDiagnostics.push(d);\n\t\t}\n\t}\n\n\t// Format collision diagnostics grouped by name\n\tfor (const [name, collisionList] of collisions) {\n\t\tconst first = collisionList[0]?.collision;\n\t\tif (!first) continue;\n\t\tlines.push(theme.fg(\"warning\", ` \"${name}\" collision:`));\n\t\tlines.push(\n\t\t\ttheme.fg(\n\t\t\t\t\"dim\",\n\t\t\t\t` ${theme.fg(\"success\", \"✓\")} ${formatPathWithSource(first.winnerPath, findSourceInfoForPath(first.winnerPath, sourceInfos))}`,\n\t\t\t),\n\t\t);\n\t\tfor (const d of collisionList) {\n\t\t\tif (d.collision) {\n\t\t\t\tlines.push(\n\t\t\t\t\ttheme.fg(\n\t\t\t\t\t\t\"dim\",\n\t\t\t\t\t\t` ${theme.fg(\"warning\", \"✗\")} ${formatPathWithSource(d.collision.loserPath, findSourceInfoForPath(d.collision.loserPath, sourceInfos))} (skipped)`,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const d of otherDiagnostics) {\n\t\tif (d.path) {\n\t\t\tconst formattedPath = formatPathWithSource(d.path, findSourceInfoForPath(d.path, sourceInfos));\n\t\t\tlines.push(theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${formattedPath}`));\n\t\t\tlines.push(theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${d.message}`));\n\t\t} else {\n\t\t\tlines.push(theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${d.message}`));\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resource-display.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/resource-display.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAI5D,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAUnD;AAED,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAI5D;AAED,wBAAgB,eAAe,CAAC,UAAU,CAAC,EAAE,UAAU,GAAG,OAAO,CAGhE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,U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W,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAClC,MAAM,CAmDR","sourcesContent":["/**\n * Pure formatters for the startup \"loaded resources\" listing and diagnostics.\n *\n * Every function here reads only its arguments (paths, source metadata, diagnostics)\n * and returns strings/data; none touch UI components, session state, or `this`.\n * `showLoadedResources` and other stateful display code in interactive-mode delegate\n * to these so the presentation math is unit-testable in isolation.\n */\n\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport type { ResourceDiagnostic } from \"../../core/resource-loader.ts\";\nimport type { SourceInfo } from \"../../core/source-info.ts\";\nimport { parseGitUrl } from \"../../utils/git.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\nexport function formatDisplayPath(p: string): string {\n\tconst home = os.homedir();\n\tlet result = p;\n\n\t// Replace home directory with ~\n\tif (result.startsWith(home)) {\n\t\tresult = `~${result.slice(home.length)}`;\n\t}\n\n\treturn result;\n}\n\nexport function formatExtensionDisplayPath(p: string): string {\n\tlet result = formatDisplayPath(p);\n\tresult = result.replace(/\\/index\\.ts$/, \"\").replace(/\\/index\\.js$/, \"\");\n\treturn result;\n}\n\nexport function isPackageSource(sourceInfo?: SourceInfo): boolean {\n\tconst source = sourceInfo?.source ?? \"\";\n\treturn source.startsWith(\"npm:\") || source.startsWith(\"git:\");\n}\n\n/**\n * Get a short path relative to the package root for display.\n */\nexport function getShortPath(fullPath: string, sourceInfo?: SourceInfo): string {\n\tconst normalizedFullPath = fullPath.replace(/\\\\/g, \"/\");\n\tconst baseDir = sourceInfo?.baseDir;\n\tif (baseDir && isPackageSource(sourceInfo)) {\n\t\tconst normalizedBaseDir = baseDir.replace(/\\\\/g, \"/\");\n\t\tconst npmRootMatch = normalizedBaseDir.match(/^(.*\\/node_modules)\\/(@?[^/]+(?:\\/[^/]+)?)$/);\n\t\tif (npmRootMatch?.[1] && normalizedFullPath.startsWith(`${npmRootMatch[1]}/`)) {\n\t\t\treturn path.posix.relative(normalizedBaseDir, normalizedFullPath);\n\t\t}\n\n\t\tconst relativePath = path.relative(path.resolve(baseDir), path.resolve(fullPath));\n\t\tif (\n\t\t\trelativePath &&\n\t\t\trelativePath !== \".\" &&\n\t\t\t!relativePath.startsWith(\"..\") &&\n\t\t\t!relativePath.startsWith(`..${path.sep}`) &&\n\t\t\t!path.isAbsolute(relativePath)\n\t\t) {\n\t\t\treturn relativePath.replace(/\\\\/g, \"/\");\n\t\t}\n\t}\n\n\tconst source = sourceInfo?.source ?? \"\";\n\tconst npmMatch = normalizedFullPath.match(/node_modules\\/(@?[^/]+(?:\\/[^/]+)?)\\/(.*)/);\n\tif (npmMatch && source.startsWith(\"npm:\")) {\n\t\treturn npmMatch[2];\n\t}\n\n\tconst gitMatch = normalizedFullPath.match(/git\\/[^/]+\\/[^/]+\\/(.*)/);\n\tif (gitMatch && source.startsWith(\"git:\")) {\n\t\treturn gitMatch[1];\n\t}\n\n\treturn formatDisplayPath(fullPath);\n}\n\nexport function getCompactPathLabel(resourcePath: string, sourceInfo?: SourceInfo): string {\n\tconst shortPath = getShortPath(resourcePath, sourceInfo);\n\tconst normalizedPath = shortPath.replace(/\\\\/g, \"/\");\n\tconst segments = normalizedPath.split(\"/\").filter((segment) => segment.length > 0 && segment !== \"~\");\n\tif (segments.length > 0) {\n\t\treturn segments[segments.length - 1]!;\n\t}\n\treturn shortPath;\n}\n\nexport function getCompactPackageSourceLabel(sourceInfo?: SourceInfo): string {\n\tconst source = sourceInfo?.source ?? \"\";\n\tif (source.startsWith(\"npm:\")) {\n\t\treturn source.slice(\"npm:\".length) || source;\n\t}\n\n\tconst gitSource = parseGitUrl(source);\n\tif (gitSource) {\n\t\treturn gitSource.path || source;\n\t}\n\n\treturn source;\n}\n\nexport function getCompactExtensionLabel(resourcePath: string, sourceInfo?: SourceInfo): string {\n\tif (!isPackageSource(sourceInfo)) {\n\t\treturn getCompactPathLabel(resourcePath, sourceInfo);\n\t}\n\n\tconst sourceLabel = getCompactPackageSourceLabel(sourceInfo);\n\tif (!sourceLabel) {\n\t\treturn getCompactPathLabel(resourcePath, sourceInfo);\n\t}\n\n\tconst shortPath = getShortPath(resourcePath, sourceInfo).replace(/\\\\/g, \"/\");\n\tconst packagePath = shortPath.startsWith(\"extensions/\") ? shortPath.slice(\"extensions/\".length) : shortPath;\n\tconst parsedPath = path.posix.parse(packagePath);\n\n\tif (parsedPath.name === \"index\") {\n\t\treturn !parsedPath.dir || parsedPath.dir === \".\" ? sourceLabel : `${sourceLabel}:${parsedPath.dir}`;\n\t}\n\n\treturn `${sourceLabel}:${packagePath}`;\n}\n\nexport function getCompactDisplayPathSegments(resourcePath: string): string[] {\n\treturn formatDisplayPath(resourcePath)\n\t\t.replace(/\\\\/g, \"/\")\n\t\t.split(\"/\")\n\t\t.filter((segment) => segment.length > 0 && segment !== \"~\");\n}\n\nexport function getCompactNonPackageExtensionLabel(\n\tresourcePath: string,\n\tindex: number,\n\tallPaths: Array<{ path: string; segments: string[] }>,\n): string {\n\tconst segments = allPaths[index]?.segments;\n\tif (!segments || segments.length === 0) {\n\t\treturn getCompactPathLabel(resourcePath);\n\t}\n\n\tfor (let segmentCount = 1; segmentCount <= segments.length; segmentCount += 1) {\n\t\tconst candidate = segments.slice(-segmentCount).join(\"/\");\n\t\tconst isUnique = allPaths.every((item, itemIndex) => {\n\t\t\tif (itemIndex === index) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn item.segments.slice(-segmentCount).join(\"/\") !== candidate;\n\t\t});\n\n\t\tif (isUnique) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn segments.join(\"/\");\n}\n\nexport function getCompactExtensionLabels(extensions: Array<{ path: string; sourceInfo?: SourceInfo }>): string[] {\n\tconst nonPackageExtensions = extensions\n\t\t.map((extension) => {\n\t\t\tconst segments = getCompactDisplayPathSegments(extension.path);\n\t\t\tconst lastSegment = segments[segments.length - 1];\n\t\t\tif (segments.length > 1 && (lastSegment === \"index.ts\" || lastSegment === \"index.js\")) {\n\t\t\t\tsegments.pop();\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpath: extension.path,\n\t\t\t\tsourceInfo: extension.sourceInfo,\n\t\t\t\tsegments,\n\t\t\t};\n\t\t})\n\t\t.filter((extension) => !isPackageSource(extension.sourceInfo));\n\n\treturn extensions.map((extension) => {\n\t\tif (isPackageSource(extension.sourceInfo)) {\n\t\t\treturn getCompactExtensionLabel(extension.path, extension.sourceInfo);\n\t\t}\n\n\t\tconst nonPackageIndex = nonPackageExtensions.findIndex((item) => item.path === extension.path);\n\t\tif (nonPackageIndex === -1) {\n\t\t\treturn getCompactPathLabel(extension.path, extension.sourceInfo);\n\t\t}\n\n\t\treturn getCompactNonPackageExtensionLabel(extension.path, nonPackageIndex, nonPackageExtensions);\n\t});\n}\n\nexport function getDisplaySourceInfo(sourceInfo?: SourceInfo): {\n\tlabel: string;\n\tscopeLabel?: string;\n\tcolor: \"accent\" | \"muted\";\n} {\n\tconst source = sourceInfo?.source ?? \"local\";\n\tconst scope = sourceInfo?.scope ?? \"project\";\n\tif (source === \"local\") {\n\t\tif (scope === \"user\") {\n\t\t\treturn { label: \"user\", color: \"muted\" };\n\t\t}\n\t\tif (scope === \"project\") {\n\t\t\treturn { label: \"project\", color: \"muted\" };\n\t\t}\n\t\tif (scope === \"temporary\") {\n\t\t\treturn { label: \"path\", scopeLabel: \"temp\", color: \"muted\" };\n\t\t}\n\t\treturn { label: \"path\", color: \"muted\" };\n\t}\n\n\tif (source === \"cli\") {\n\t\treturn { label: \"path\", scopeLabel: scope === \"temporary\" ? \"temp\" : undefined, color: \"muted\" };\n\t}\n\n\tconst scopeLabel =\n\t\tscope === \"user\" ? \"user\" : scope === \"project\" ? \"project\" : scope === \"temporary\" ? \"temp\" : undefined;\n\treturn { label: source, scopeLabel, color: \"accent\" };\n}\n\nexport function getScopeGroup(sourceInfo?: SourceInfo): \"user\" | \"project\" | \"path\" {\n\tconst source = sourceInfo?.source ?? \"local\";\n\tconst scope = sourceInfo?.scope ?? \"project\";\n\tif (source === \"cli\" || scope === \"temporary\") return \"path\";\n\tif (scope === \"user\") return \"user\";\n\tif (scope === \"project\") return \"project\";\n\treturn \"path\";\n}\n\nexport function buildScopeGroups(items: Array<{ path: string; sourceInfo?: SourceInfo }>): Array<{\n\tscope: \"user\" | \"project\" | \"path\";\n\tpaths: Array<{ path: string; sourceInfo?: SourceInfo }>;\n\tpackages: Map<string, Array<{ path: string; sourceInfo?: SourceInfo }>>;\n}> {\n\tconst groups: Record<\n\t\t\"user\" | \"project\" | \"path\",\n\t\t{\n\t\t\tscope: \"user\" | \"project\" | \"path\";\n\t\t\tpaths: Array<{ path: string; sourceInfo?: SourceInfo }>;\n\t\t\tpackages: Map<string, Array<{ path: string; sourceInfo?: SourceInfo }>>;\n\t\t}\n\t> = {\n\t\tuser: { scope: \"user\", paths: [], packages: new Map() },\n\t\tproject: { scope: \"project\", paths: [], packages: new Map() },\n\t\tpath: { scope: \"path\", paths: [], packages: new Map() },\n\t};\n\n\tfor (const item of items) {\n\t\tconst groupKey = getScopeGroup(item.sourceInfo);\n\t\tconst group = groups[groupKey];\n\t\tconst source = item.sourceInfo?.source ?? \"local\";\n\n\t\tif (isPackageSource(item.sourceInfo)) {\n\t\t\tconst list = group.packages.get(source) ?? [];\n\t\t\tlist.push(item);\n\t\t\tgroup.packages.set(source, list);\n\t\t} else {\n\t\t\tgroup.paths.push(item);\n\t\t}\n\t}\n\n\treturn [groups.project, groups.user, groups.path].filter(\n\t\t(group) => group.paths.length > 0 || group.packages.size > 0,\n\t);\n}\n\nexport function formatScopeGroups(\n\tgroups: Array<{\n\t\tscope: \"user\" | \"project\" | \"path\";\n\t\tpaths: Array<{ path: string; sourceInfo?: SourceInfo }>;\n\t\tpackages: Map<string, Array<{ path: string; sourceInfo?: SourceInfo }>>;\n\t}>,\n\toptions: {\n\t\tformatPath: (item: { path: string; sourceInfo?: SourceInfo }) => string;\n\t\tformatPackagePath: (item: { path: string; sourceInfo?: SourceInfo }, source: string) => string;\n\t},\n): string {\n\tconst lines: string[] = [];\n\n\tfor (const group of groups) {\n\t\tlines.push(` ${theme.fg(\"accent\", group.scope)}`);\n\n\t\tconst sortedPaths = [...group.paths].sort((a, b) => a.path.localeCompare(b.path));\n\t\tfor (const item of sortedPaths) {\n\t\t\tlines.push(theme.fg(\"dim\", ` ${options.formatPath(item)}`));\n\t\t}\n\n\t\tconst sortedPackages = Array.from(group.packages.entries()).sort(([a], [b]) => a.localeCompare(b));\n\t\tfor (const [source, items] of sortedPackages) {\n\t\t\tlines.push(` ${theme.fg(\"mdLink\", source)}`);\n\t\t\tconst sortedPackagePaths = [...items].sort((a, b) => a.path.localeCompare(b.path));\n\t\t\tfor (const item of sortedPackagePaths) {\n\t\t\t\tlines.push(theme.fg(\"dim\", ` ${options.formatPackagePath(item, source)}`));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\nexport function findSourceInfoForPath(p: string, sourceInfos: Map<string, SourceInfo>): SourceInfo | undefined {\n\tconst exact = sourceInfos.get(p);\n\tif (exact) return exact;\n\n\tlet current = p;\n\twhile (current.includes(\"/\")) {\n\t\tcurrent = current.substring(0, current.lastIndexOf(\"/\"));\n\t\tconst parent = sourceInfos.get(current);\n\t\tif (parent) return parent;\n\t}\n\n\treturn undefined;\n}\n\nexport function formatPathWithSource(p: string, sourceInfo?: SourceInfo): string {\n\tif (sourceInfo) {\n\t\tconst shortPath = getShortPath(p, sourceInfo);\n\t\tconst { label, scopeLabel } = getDisplaySourceInfo(sourceInfo);\n\t\tconst labelText = scopeLabel ? `${label} (${scopeLabel})` : label;\n\t\treturn `${labelText} ${shortPath}`;\n\t}\n\treturn formatDisplayPath(p);\n}\n\nexport function formatDiagnostics(\n\tdiagnostics: readonly ResourceDiagnostic[],\n\tsourceInfos: Map<string, SourceInfo>,\n): string {\n\tconst lines: string[] = [];\n\n\t// Group collision diagnostics by name\n\tconst collisions = new Map<string, ResourceDiagnostic[]>();\n\tconst otherDiagnostics: ResourceDiagnostic[] = [];\n\n\tfor (const d of diagnostics) {\n\t\tif (d.type === \"collision\" && d.collision) {\n\t\t\tconst list = collisions.get(d.collision.name) ?? [];\n\t\t\tlist.push(d);\n\t\t\tcollisions.set(d.collision.name, list);\n\t\t} else {\n\t\t\totherDiagnostics.push(d);\n\t\t}\n\t}\n\n\t// Format collision diagnostics grouped by name\n\tfor (const [name, collisionList] of collisions) {\n\t\tconst first = collisionList[0]?.collision;\n\t\tif (!first) continue;\n\t\tlines.push(theme.fg(\"warning\", ` \"${name}\" collision:`));\n\t\tlines.push(\n\t\t\ttheme.fg(\n\t\t\t\t\"dim\",\n\t\t\t\t` ${theme.fg(\"success\", \"✓\")} ${formatPathWithSource(first.winnerPath, findSourceInfoForPath(first.winnerPath, sourceInfos))}`,\n\t\t\t),\n\t\t);\n\t\tfor (const d of collisionList) {\n\t\t\tif (d.collision) {\n\t\t\t\tlines.push(\n\t\t\t\t\ttheme.fg(\n\t\t\t\t\t\t\"dim\",\n\t\t\t\t\t\t` ${theme.fg(\"warning\", \"✗\")} ${formatPathWithSource(d.collision.loserPath, findSourceInfoForPath(d.collision.loserPath, sourceInfos))} (skipped)`,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const d of otherDiagnostics) {\n\t\tif (d.path) {\n\t\t\tconst formattedPath = formatPathWithSource(d.path, findSourceInfoForPath(d.path, sourceInfos));\n\t\t\tlines.push(theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${formattedPath}`));\n\t\t\tlines.push(theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${d.message}`));\n\t\t} else {\n\t\t\tlines.push(theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${d.message}`));\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n"]}
|
|
@@ -32,8 +32,14 @@ export function isPackageSource(sourceInfo) {
|
|
|
32
32
|
* Get a short path relative to the package root for display.
|
|
33
33
|
*/
|
|
34
34
|
export function getShortPath(fullPath, sourceInfo) {
|
|
35
|
+
const normalizedFullPath = fullPath.replace(/\\/g, "/");
|
|
35
36
|
const baseDir = sourceInfo?.baseDir;
|
|
36
37
|
if (baseDir && isPackageSource(sourceInfo)) {
|
|
38
|
+
const normalizedBaseDir = baseDir.replace(/\\/g, "/");
|
|
39
|
+
const npmRootMatch = normalizedBaseDir.match(/^(.*\/node_modules)\/(@?[^/]+(?:\/[^/]+)?)$/);
|
|
40
|
+
if (npmRootMatch?.[1] && normalizedFullPath.startsWith(`${npmRootMatch[1]}/`)) {
|
|
41
|
+
return path.posix.relative(normalizedBaseDir, normalizedFullPath);
|
|
42
|
+
}
|
|
37
43
|
const relativePath = path.relative(path.resolve(baseDir), path.resolve(fullPath));
|
|
38
44
|
if (relativePath &&
|
|
39
45
|
relativePath !== "." &&
|
|
@@ -44,11 +50,11 @@ export function getShortPath(fullPath, sourceInfo) {
|
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
52
|
const source = sourceInfo?.source ?? "";
|
|
47
|
-
const npmMatch =
|
|
53
|
+
const npmMatch = normalizedFullPath.match(/node_modules\/(@?[^/]+(?:\/[^/]+)?)\/(.*)/);
|
|
48
54
|
if (npmMatch && source.startsWith("npm:")) {
|
|
49
55
|
return npmMatch[2];
|
|
50
56
|
}
|
|
51
|
-
const gitMatch =
|
|
57
|
+
const gitMatch = normalizedFullPath.match(/git\/[^/]+\/[^/]+\/(.*)/);
|
|
52
58
|
if (gitMatch && source.startsWith("git:")) {
|
|
53
59
|
return gitMatch[1];
|
|
54
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-display.js","sourceRoot":"","sources":["../../../src/modes/interactive/resource-display.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,KAA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BAAoB,CAAC,CAAC,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;YAC/F,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,aAAa,EAAE,CAAC,CAAC,CAAC;YACrF,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACpF,CAAC;aAAM,CAAC;YACP,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAClF,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAA,CACxB","sourcesContent":["/**\n * Pure formatters for the startup \"loaded resources\" listing and diagnostics.\n *\n * Every function here reads only its arguments (paths, source metadata, diagnostics)\n * and returns strings/data; none touch UI components, session state, or `this`.\n * `showLoadedResources` and other stateful display code in interactive-mode delegate\n * to these so the presentation math is unit-testable in isolation.\n */\n\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport type { ResourceDiagnostic } from \"../../core/resource-loader.ts\";\nimport type { SourceInfo } from \"../../core/source-info.ts\";\nimport { parseGitUrl } from \"../../utils/git.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\nexport function formatDisplayPath(p: string): string {\n\tconst home = os.homedir();\n\tlet result = p;\n\n\t// Replace home directory with ~\n\tif (result.startsWith(home)) {\n\t\tresult = `~${result.slice(home.length)}`;\n\t}\n\n\treturn result;\n}\n\nexport function formatExtensionDisplayPath(p: string): string {\n\tlet result = formatDisplayPath(p);\n\tresult = result.replace(/\\/index\\.ts$/, \"\").replace(/\\/index\\.js$/, \"\");\n\treturn result;\n}\n\nexport function isPackageSource(sourceInfo?: SourceInfo): boolean {\n\tconst source = sourceInfo?.source ?? \"\";\n\treturn source.startsWith(\"npm:\") || source.startsWith(\"git:\");\n}\n\n/**\n * Get a short path relative to the package root for display.\n */\nexport function getShortPath(fullPath: string, sourceInfo?: SourceInfo): string {\n\tconst baseDir = sourceInfo?.baseDir;\n\tif (baseDir && isPackageSource(sourceInfo)) {\n\t\tconst relativePath = path.relative(path.resolve(baseDir), path.resolve(fullPath));\n\t\tif (\n\t\t\trelativePath &&\n\t\t\trelativePath !== \".\" &&\n\t\t\t!relativePath.startsWith(\"..\") &&\n\t\t\t!relativePath.startsWith(`..${path.sep}`) &&\n\t\t\t!path.isAbsolute(relativePath)\n\t\t) {\n\t\t\treturn relativePath.replace(/\\\\/g, \"/\");\n\t\t}\n\t}\n\n\tconst source = sourceInfo?.source ?? \"\";\n\tconst npmMatch = fullPath.match(/node_modules\\/(@?[^/]+(?:\\/[^/]+)?)\\/(.*)/);\n\tif (npmMatch && source.startsWith(\"npm:\")) {\n\t\treturn npmMatch[2];\n\t}\n\n\tconst gitMatch = fullPath.match(/git\\/[^/]+\\/[^/]+\\/(.*)/);\n\tif (gitMatch && source.startsWith(\"git:\")) {\n\t\treturn gitMatch[1];\n\t}\n\n\treturn formatDisplayPath(fullPath);\n}\n\nexport function getCompactPathLabel(resourcePath: string, sourceInfo?: SourceInfo): string {\n\tconst shortPath = getShortPath(resourcePath, sourceInfo);\n\tconst normalizedPath = shortPath.replace(/\\\\/g, \"/\");\n\tconst segments = normalizedPath.split(\"/\").filter((segment) => segment.length > 0 && segment !== \"~\");\n\tif (segments.length > 0) {\n\t\treturn segments[segments.length - 1]!;\n\t}\n\treturn shortPath;\n}\n\nexport function getCompactPackageSourceLabel(sourceInfo?: SourceInfo): string {\n\tconst source = sourceInfo?.source ?? \"\";\n\tif (source.startsWith(\"npm:\")) {\n\t\treturn source.slice(\"npm:\".length) || source;\n\t}\n\n\tconst gitSource = parseGitUrl(source);\n\tif (gitSource) {\n\t\treturn gitSource.path || source;\n\t}\n\n\treturn source;\n}\n\nexport function getCompactExtensionLabel(resourcePath: string, sourceInfo?: SourceInfo): string {\n\tif (!isPackageSource(sourceInfo)) {\n\t\treturn getCompactPathLabel(resourcePath, sourceInfo);\n\t}\n\n\tconst sourceLabel = getCompactPackageSourceLabel(sourceInfo);\n\tif (!sourceLabel) {\n\t\treturn getCompactPathLabel(resourcePath, sourceInfo);\n\t}\n\n\tconst shortPath = getShortPath(resourcePath, sourceInfo).replace(/\\\\/g, \"/\");\n\tconst packagePath = shortPath.startsWith(\"extensions/\") ? shortPath.slice(\"extensions/\".length) : shortPath;\n\tconst parsedPath = path.posix.parse(packagePath);\n\n\tif (parsedPath.name === \"index\") {\n\t\treturn !parsedPath.dir || parsedPath.dir === \".\" ? sourceLabel : `${sourceLabel}:${parsedPath.dir}`;\n\t}\n\n\treturn `${sourceLabel}:${packagePath}`;\n}\n\nexport function getCompactDisplayPathSegments(resourcePath: string): string[] {\n\treturn formatDisplayPath(resourcePath)\n\t\t.replace(/\\\\/g, \"/\")\n\t\t.split(\"/\")\n\t\t.filter((segment) => segment.length > 0 && segment !== \"~\");\n}\n\nexport function getCompactNonPackageExtensionLabel(\n\tresourcePath: string,\n\tindex: number,\n\tallPaths: Array<{ path: string; segments: string[] }>,\n): string {\n\tconst segments = allPaths[index]?.segments;\n\tif (!segments || segments.length === 0) {\n\t\treturn getCompactPathLabel(resourcePath);\n\t}\n\n\tfor (let segmentCount = 1; segmentCount <= segments.length; segmentCount += 1) {\n\t\tconst candidate = segments.slice(-segmentCount).join(\"/\");\n\t\tconst isUnique = allPaths.every((item, itemIndex) => {\n\t\t\tif (itemIndex === index) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn item.segments.slice(-segmentCount).join(\"/\") !== candidate;\n\t\t});\n\n\t\tif (isUnique) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn segments.join(\"/\");\n}\n\nexport function getCompactExtensionLabels(extensions: Array<{ path: string; sourceInfo?: SourceInfo }>): string[] {\n\tconst nonPackageExtensions = extensions\n\t\t.map((extension) => {\n\t\t\tconst segments = getCompactDisplayPathSegments(extension.path);\n\t\t\tconst lastSegment = segments[segments.length - 1];\n\t\t\tif (segments.length > 1 && (lastSegment === \"index.ts\" || lastSegment === \"index.js\")) {\n\t\t\t\tsegments.pop();\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpath: extension.path,\n\t\t\t\tsourceInfo: extension.sourceInfo,\n\t\t\t\tsegments,\n\t\t\t};\n\t\t})\n\t\t.filter((extension) => !isPackageSource(extension.sourceInfo));\n\n\treturn extensions.map((extension) => {\n\t\tif (isPackageSource(extension.sourceInfo)) {\n\t\t\treturn getCompactExtensionLabel(extension.path, extension.sourceInfo);\n\t\t}\n\n\t\tconst nonPackageIndex = nonPackageExtensions.findIndex((item) => item.path === extension.path);\n\t\tif (nonPackageIndex === -1) {\n\t\t\treturn getCompactPathLabel(extension.path, extension.sourceInfo);\n\t\t}\n\n\t\treturn getCompactNonPackageExtensionLabel(extension.path, nonPackageIndex, nonPackageExtensions);\n\t});\n}\n\nexport function getDisplaySourceInfo(sourceInfo?: SourceInfo): {\n\tlabel: string;\n\tscopeLabel?: string;\n\tcolor: \"accent\" | \"muted\";\n} {\n\tconst source = sourceInfo?.source ?? \"local\";\n\tconst scope = sourceInfo?.scope ?? \"project\";\n\tif (source === \"local\") {\n\t\tif (scope === \"user\") {\n\t\t\treturn { label: \"user\", color: \"muted\" };\n\t\t}\n\t\tif (scope === \"project\") {\n\t\t\treturn { label: \"project\", color: \"muted\" };\n\t\t}\n\t\tif (scope === \"temporary\") {\n\t\t\treturn { label: \"path\", scopeLabel: \"temp\", color: \"muted\" };\n\t\t}\n\t\treturn { label: \"path\", color: \"muted\" };\n\t}\n\n\tif (source === \"cli\") {\n\t\treturn { label: \"path\", scopeLabel: scope === \"temporary\" ? \"temp\" : undefined, color: \"muted\" };\n\t}\n\n\tconst scopeLabel =\n\t\tscope === \"user\" ? \"user\" : scope === \"project\" ? \"project\" : scope === \"temporary\" ? \"temp\" : undefined;\n\treturn { label: source, scopeLabel, color: \"accent\" };\n}\n\nexport function getScopeGroup(sourceInfo?: SourceInfo): \"user\" | \"project\" | \"path\" {\n\tconst source = sourceInfo?.source ?? \"local\";\n\tconst scope = sourceInfo?.scope ?? \"project\";\n\tif (source === \"cli\" || scope === \"temporary\") return \"path\";\n\tif (scope === \"user\") return \"user\";\n\tif (scope === \"project\") return \"project\";\n\treturn \"path\";\n}\n\nexport function buildScopeGroups(items: Array<{ path: string; sourceInfo?: SourceInfo }>): Array<{\n\tscope: \"user\" | \"project\" | \"path\";\n\tpaths: Array<{ path: string; sourceInfo?: SourceInfo }>;\n\tpackages: Map<string, Array<{ path: string; sourceInfo?: SourceInfo }>>;\n}> {\n\tconst groups: Record<\n\t\t\"user\" | \"project\" | \"path\",\n\t\t{\n\t\t\tscope: \"user\" | \"project\" | \"path\";\n\t\t\tpaths: Array<{ path: string; sourceInfo?: SourceInfo }>;\n\t\t\tpackages: Map<string, Array<{ path: string; sourceInfo?: SourceInfo }>>;\n\t\t}\n\t> = {\n\t\tuser: { scope: \"user\", paths: [], packages: new Map() },\n\t\tproject: { scope: \"project\", paths: [], packages: new Map() },\n\t\tpath: { scope: \"path\", paths: [], packages: new Map() },\n\t};\n\n\tfor (const item of items) {\n\t\tconst groupKey = getScopeGroup(item.sourceInfo);\n\t\tconst group = groups[groupKey];\n\t\tconst source = item.sourceInfo?.source ?? \"local\";\n\n\t\tif (isPackageSource(item.sourceInfo)) {\n\t\t\tconst list = group.packages.get(source) ?? [];\n\t\t\tlist.push(item);\n\t\t\tgroup.packages.set(source, list);\n\t\t} else {\n\t\t\tgroup.paths.push(item);\n\t\t}\n\t}\n\n\treturn [groups.project, groups.user, groups.path].filter(\n\t\t(group) => group.paths.length > 0 || group.packages.size > 0,\n\t);\n}\n\nexport function formatScopeGroups(\n\tgroups: Array<{\n\t\tscope: \"user\" | \"project\" | \"path\";\n\t\tpaths: Array<{ path: string; sourceInfo?: SourceInfo }>;\n\t\tpackages: Map<string, Array<{ path: string; sourceInfo?: SourceInfo }>>;\n\t}>,\n\toptions: {\n\t\tformatPath: (item: { path: string; sourceInfo?: SourceInfo }) => string;\n\t\tformatPackagePath: (item: { path: string; sourceInfo?: SourceInfo }, source: string) => string;\n\t},\n): string {\n\tconst lines: string[] = [];\n\n\tfor (const group of groups) {\n\t\tlines.push(` ${theme.fg(\"accent\", group.scope)}`);\n\n\t\tconst sortedPaths = [...group.paths].sort((a, b) => a.path.localeCompare(b.path));\n\t\tfor (const item of sortedPaths) {\n\t\t\tlines.push(theme.fg(\"dim\", ` ${options.formatPath(item)}`));\n\t\t}\n\n\t\tconst sortedPackages = Array.from(group.packages.entries()).sort(([a], [b]) => a.localeCompare(b));\n\t\tfor (const [source, items] of sortedPackages) {\n\t\t\tlines.push(` ${theme.fg(\"mdLink\", source)}`);\n\t\t\tconst sortedPackagePaths = [...items].sort((a, b) => a.path.localeCompare(b.path));\n\t\t\tfor (const item of sortedPackagePaths) {\n\t\t\t\tlines.push(theme.fg(\"dim\", ` ${options.formatPackagePath(item, source)}`));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\nexport function findSourceInfoForPath(p: string, sourceInfos: Map<string, SourceInfo>): SourceInfo | undefined {\n\tconst exact = sourceInfos.get(p);\n\tif (exact) return exact;\n\n\tlet current = p;\n\twhile (current.includes(\"/\")) {\n\t\tcurrent = current.substring(0, current.lastIndexOf(\"/\"));\n\t\tconst parent = sourceInfos.get(current);\n\t\tif (parent) return parent;\n\t}\n\n\treturn undefined;\n}\n\nexport function formatPathWithSource(p: string, sourceInfo?: SourceInfo): string {\n\tif (sourceInfo) {\n\t\tconst shortPath = getShortPath(p, sourceInfo);\n\t\tconst { label, scopeLabel } = getDisplaySourceInfo(sourceInfo);\n\t\tconst labelText = scopeLabel ? `${label} (${scopeLabel})` : label;\n\t\treturn `${labelText} ${shortPath}`;\n\t}\n\treturn formatDisplayPath(p);\n}\n\nexport function formatDiagnostics(\n\tdiagnostics: readonly ResourceDiagnostic[],\n\tsourceInfos: Map<string, SourceInfo>,\n): string {\n\tconst lines: string[] = [];\n\n\t// Group collision diagnostics by name\n\tconst collisions = new Map<string, ResourceDiagnostic[]>();\n\tconst otherDiagnostics: ResourceDiagnostic[] = [];\n\n\tfor (const d of diagnostics) {\n\t\tif (d.type === \"collision\" && d.collision) {\n\t\t\tconst list = collisions.get(d.collision.name) ?? [];\n\t\t\tlist.push(d);\n\t\t\tcollisions.set(d.collision.name, list);\n\t\t} else {\n\t\t\totherDiagnostics.push(d);\n\t\t}\n\t}\n\n\t// Format collision diagnostics grouped by name\n\tfor (const [name, collisionList] of collisions) {\n\t\tconst first = collisionList[0]?.collision;\n\t\tif (!first) continue;\n\t\tlines.push(theme.fg(\"warning\", ` \"${name}\" collision:`));\n\t\tlines.push(\n\t\t\ttheme.fg(\n\t\t\t\t\"dim\",\n\t\t\t\t` ${theme.fg(\"success\", \"✓\")} ${formatPathWithSource(first.winnerPath, findSourceInfoForPath(first.winnerPath, sourceInfos))}`,\n\t\t\t),\n\t\t);\n\t\tfor (const d of collisionList) {\n\t\t\tif (d.collision) {\n\t\t\t\tlines.push(\n\t\t\t\t\ttheme.fg(\n\t\t\t\t\t\t\"dim\",\n\t\t\t\t\t\t` ${theme.fg(\"warning\", \"✗\")} ${formatPathWithSource(d.collision.loserPath, findSourceInfoForPath(d.collision.loserPath, sourceInfos))} (skipped)`,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const d of otherDiagnostics) {\n\t\tif (d.path) {\n\t\t\tconst formattedPath = formatPathWithSource(d.path, findSourceInfoForPath(d.path, sourceInfos));\n\t\t\tlines.push(theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${formattedPath}`));\n\t\t\tlines.push(theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${d.message}`));\n\t\t} else {\n\t\t\tlines.push(theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${d.message}`));\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resource-display.js","sourceRoot":"","sources":["../../../src/modes/interactive/resource-display.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,MAAM,UAAU,iBAAiB,CAAC,CAAS,EAAU;IACpD,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;IAC1B,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,gCAAgC;IAChC,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;IAC1C,CAAC;IAED,OAAO,MAAM,CAAC;AAAA,CACd;AAED,MAAM,UAAU,0BAA0B,CAAC,CAAS,EAAU;IAC7D,IAAI,MAAM,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IACxE,OAAO,MAAM,CAAC;AAAA,CACd;AAED,MAAM,UAAU,eAAe,CAAC,UAAuB,EAAW;IACjE,MAAM,MAAM,GAAG,UAAU,EAAE,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AK,aAAa,EAAE,CAAC,CAAC,CAAC;YACrF,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACpF,CAAC;aAAM,CAAC;YACP,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAClF,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAA,CACxB","sourcesContent":["/**\n * Pure formatters for the startup \"loaded resources\" listing and diagnostics.\n *\n * Every function here reads only its arguments (paths, source metadata, diagnostics)\n * and returns strings/data; none touch UI components, session state, or `this`.\n * `showLoadedResources` and other stateful display code in interactive-mode delegate\n * to these so the presentation math is unit-testable in isolation.\n */\n\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport type { ResourceDiagnostic } from \"../../core/resource-loader.ts\";\nimport type { SourceInfo } from \"../../core/source-info.ts\";\nimport { parseGitUrl } from \"../../utils/git.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\nexport function formatDisplayPath(p: string): string {\n\tconst home = os.homedir();\n\tlet result = p;\n\n\t// Replace home directory with ~\n\tif (result.startsWith(home)) {\n\t\tresult = `~${result.slice(home.length)}`;\n\t}\n\n\treturn result;\n}\n\nexport function formatExtensionDisplayPath(p: string): string {\n\tlet result = formatDisplayPath(p);\n\tresult = result.replace(/\\/index\\.ts$/, \"\").replace(/\\/index\\.js$/, \"\");\n\treturn result;\n}\n\nexport function isPackageSource(sourceInfo?: SourceInfo): boolean {\n\tconst source = sourceInfo?.source ?? \"\";\n\treturn source.startsWith(\"npm:\") || source.startsWith(\"git:\");\n}\n\n/**\n * Get a short path relative to the package root for display.\n */\nexport function getShortPath(fullPath: string, sourceInfo?: SourceInfo): string {\n\tconst normalizedFullPath = fullPath.replace(/\\\\/g, \"/\");\n\tconst baseDir = sourceInfo?.baseDir;\n\tif (baseDir && isPackageSource(sourceInfo)) {\n\t\tconst normalizedBaseDir = baseDir.replace(/\\\\/g, \"/\");\n\t\tconst npmRootMatch = normalizedBaseDir.match(/^(.*\\/node_modules)\\/(@?[^/]+(?:\\/[^/]+)?)$/);\n\t\tif (npmRootMatch?.[1] && normalizedFullPath.startsWith(`${npmRootMatch[1]}/`)) {\n\t\t\treturn path.posix.relative(normalizedBaseDir, normalizedFullPath);\n\t\t}\n\n\t\tconst relativePath = path.relative(path.resolve(baseDir), path.resolve(fullPath));\n\t\tif (\n\t\t\trelativePath &&\n\t\t\trelativePath !== \".\" &&\n\t\t\t!relativePath.startsWith(\"..\") &&\n\t\t\t!relativePath.startsWith(`..${path.sep}`) &&\n\t\t\t!path.isAbsolute(relativePath)\n\t\t) {\n\t\t\treturn relativePath.replace(/\\\\/g, \"/\");\n\t\t}\n\t}\n\n\tconst source = sourceInfo?.source ?? \"\";\n\tconst npmMatch = normalizedFullPath.match(/node_modules\\/(@?[^/]+(?:\\/[^/]+)?)\\/(.*)/);\n\tif (npmMatch && source.startsWith(\"npm:\")) {\n\t\treturn npmMatch[2];\n\t}\n\n\tconst gitMatch = normalizedFullPath.match(/git\\/[^/]+\\/[^/]+\\/(.*)/);\n\tif (gitMatch && source.startsWith(\"git:\")) {\n\t\treturn gitMatch[1];\n\t}\n\n\treturn formatDisplayPath(fullPath);\n}\n\nexport function getCompactPathLabel(resourcePath: string, sourceInfo?: SourceInfo): string {\n\tconst shortPath = getShortPath(resourcePath, sourceInfo);\n\tconst normalizedPath = shortPath.replace(/\\\\/g, \"/\");\n\tconst segments = normalizedPath.split(\"/\").filter((segment) => segment.length > 0 && segment !== \"~\");\n\tif (segments.length > 0) {\n\t\treturn segments[segments.length - 1]!;\n\t}\n\treturn shortPath;\n}\n\nexport function getCompactPackageSourceLabel(sourceInfo?: SourceInfo): string {\n\tconst source = sourceInfo?.source ?? \"\";\n\tif (source.startsWith(\"npm:\")) {\n\t\treturn source.slice(\"npm:\".length) || source;\n\t}\n\n\tconst gitSource = parseGitUrl(source);\n\tif (gitSource) {\n\t\treturn gitSource.path || source;\n\t}\n\n\treturn source;\n}\n\nexport function getCompactExtensionLabel(resourcePath: string, sourceInfo?: SourceInfo): string {\n\tif (!isPackageSource(sourceInfo)) {\n\t\treturn getCompactPathLabel(resourcePath, sourceInfo);\n\t}\n\n\tconst sourceLabel = getCompactPackageSourceLabel(sourceInfo);\n\tif (!sourceLabel) {\n\t\treturn getCompactPathLabel(resourcePath, sourceInfo);\n\t}\n\n\tconst shortPath = getShortPath(resourcePath, sourceInfo).replace(/\\\\/g, \"/\");\n\tconst packagePath = shortPath.startsWith(\"extensions/\") ? shortPath.slice(\"extensions/\".length) : shortPath;\n\tconst parsedPath = path.posix.parse(packagePath);\n\n\tif (parsedPath.name === \"index\") {\n\t\treturn !parsedPath.dir || parsedPath.dir === \".\" ? sourceLabel : `${sourceLabel}:${parsedPath.dir}`;\n\t}\n\n\treturn `${sourceLabel}:${packagePath}`;\n}\n\nexport function getCompactDisplayPathSegments(resourcePath: string): string[] {\n\treturn formatDisplayPath(resourcePath)\n\t\t.replace(/\\\\/g, \"/\")\n\t\t.split(\"/\")\n\t\t.filter((segment) => segment.length > 0 && segment !== \"~\");\n}\n\nexport function getCompactNonPackageExtensionLabel(\n\tresourcePath: string,\n\tindex: number,\n\tallPaths: Array<{ path: string; segments: string[] }>,\n): string {\n\tconst segments = allPaths[index]?.segments;\n\tif (!segments || segments.length === 0) {\n\t\treturn getCompactPathLabel(resourcePath);\n\t}\n\n\tfor (let segmentCount = 1; segmentCount <= segments.length; segmentCount += 1) {\n\t\tconst candidate = segments.slice(-segmentCount).join(\"/\");\n\t\tconst isUnique = allPaths.every((item, itemIndex) => {\n\t\t\tif (itemIndex === index) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn item.segments.slice(-segmentCount).join(\"/\") !== candidate;\n\t\t});\n\n\t\tif (isUnique) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn segments.join(\"/\");\n}\n\nexport function getCompactExtensionLabels(extensions: Array<{ path: string; sourceInfo?: SourceInfo }>): string[] {\n\tconst nonPackageExtensions = extensions\n\t\t.map((extension) => {\n\t\t\tconst segments = getCompactDisplayPathSegments(extension.path);\n\t\t\tconst lastSegment = segments[segments.length - 1];\n\t\t\tif (segments.length > 1 && (lastSegment === \"index.ts\" || lastSegment === \"index.js\")) {\n\t\t\t\tsegments.pop();\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpath: extension.path,\n\t\t\t\tsourceInfo: extension.sourceInfo,\n\t\t\t\tsegments,\n\t\t\t};\n\t\t})\n\t\t.filter((extension) => !isPackageSource(extension.sourceInfo));\n\n\treturn extensions.map((extension) => {\n\t\tif (isPackageSource(extension.sourceInfo)) {\n\t\t\treturn getCompactExtensionLabel(extension.path, extension.sourceInfo);\n\t\t}\n\n\t\tconst nonPackageIndex = nonPackageExtensions.findIndex((item) => item.path === extension.path);\n\t\tif (nonPackageIndex === -1) {\n\t\t\treturn getCompactPathLabel(extension.path, extension.sourceInfo);\n\t\t}\n\n\t\treturn getCompactNonPackageExtensionLabel(extension.path, nonPackageIndex, nonPackageExtensions);\n\t});\n}\n\nexport function getDisplaySourceInfo(sourceInfo?: SourceInfo): {\n\tlabel: string;\n\tscopeLabel?: string;\n\tcolor: \"accent\" | \"muted\";\n} {\n\tconst source = sourceInfo?.source ?? \"local\";\n\tconst scope = sourceInfo?.scope ?? \"project\";\n\tif (source === \"local\") {\n\t\tif (scope === \"user\") {\n\t\t\treturn { label: \"user\", color: \"muted\" };\n\t\t}\n\t\tif (scope === \"project\") {\n\t\t\treturn { label: \"project\", color: \"muted\" };\n\t\t}\n\t\tif (scope === \"temporary\") {\n\t\t\treturn { label: \"path\", scopeLabel: \"temp\", color: \"muted\" };\n\t\t}\n\t\treturn { label: \"path\", color: \"muted\" };\n\t}\n\n\tif (source === \"cli\") {\n\t\treturn { label: \"path\", scopeLabel: scope === \"temporary\" ? \"temp\" : undefined, color: \"muted\" };\n\t}\n\n\tconst scopeLabel =\n\t\tscope === \"user\" ? \"user\" : scope === \"project\" ? \"project\" : scope === \"temporary\" ? \"temp\" : undefined;\n\treturn { label: source, scopeLabel, color: \"accent\" };\n}\n\nexport function getScopeGroup(sourceInfo?: SourceInfo): \"user\" | \"project\" | \"path\" {\n\tconst source = sourceInfo?.source ?? \"local\";\n\tconst scope = sourceInfo?.scope ?? \"project\";\n\tif (source === \"cli\" || scope === \"temporary\") return \"path\";\n\tif (scope === \"user\") return \"user\";\n\tif (scope === \"project\") return \"project\";\n\treturn \"path\";\n}\n\nexport function buildScopeGroups(items: Array<{ path: string; sourceInfo?: SourceInfo }>): Array<{\n\tscope: \"user\" | \"project\" | \"path\";\n\tpaths: Array<{ path: string; sourceInfo?: SourceInfo }>;\n\tpackages: Map<string, Array<{ path: string; sourceInfo?: SourceInfo }>>;\n}> {\n\tconst groups: Record<\n\t\t\"user\" | \"project\" | \"path\",\n\t\t{\n\t\t\tscope: \"user\" | \"project\" | \"path\";\n\t\t\tpaths: Array<{ path: string; sourceInfo?: SourceInfo }>;\n\t\t\tpackages: Map<string, Array<{ path: string; sourceInfo?: SourceInfo }>>;\n\t\t}\n\t> = {\n\t\tuser: { scope: \"user\", paths: [], packages: new Map() },\n\t\tproject: { scope: \"project\", paths: [], packages: new Map() },\n\t\tpath: { scope: \"path\", paths: [], packages: new Map() },\n\t};\n\n\tfor (const item of items) {\n\t\tconst groupKey = getScopeGroup(item.sourceInfo);\n\t\tconst group = groups[groupKey];\n\t\tconst source = item.sourceInfo?.source ?? \"local\";\n\n\t\tif (isPackageSource(item.sourceInfo)) {\n\t\t\tconst list = group.packages.get(source) ?? [];\n\t\t\tlist.push(item);\n\t\t\tgroup.packages.set(source, list);\n\t\t} else {\n\t\t\tgroup.paths.push(item);\n\t\t}\n\t}\n\n\treturn [groups.project, groups.user, groups.path].filter(\n\t\t(group) => group.paths.length > 0 || group.packages.size > 0,\n\t);\n}\n\nexport function formatScopeGroups(\n\tgroups: Array<{\n\t\tscope: \"user\" | \"project\" | \"path\";\n\t\tpaths: Array<{ path: string; sourceInfo?: SourceInfo }>;\n\t\tpackages: Map<string, Array<{ path: string; sourceInfo?: SourceInfo }>>;\n\t}>,\n\toptions: {\n\t\tformatPath: (item: { path: string; sourceInfo?: SourceInfo }) => string;\n\t\tformatPackagePath: (item: { path: string; sourceInfo?: SourceInfo }, source: string) => string;\n\t},\n): string {\n\tconst lines: string[] = [];\n\n\tfor (const group of groups) {\n\t\tlines.push(` ${theme.fg(\"accent\", group.scope)}`);\n\n\t\tconst sortedPaths = [...group.paths].sort((a, b) => a.path.localeCompare(b.path));\n\t\tfor (const item of sortedPaths) {\n\t\t\tlines.push(theme.fg(\"dim\", ` ${options.formatPath(item)}`));\n\t\t}\n\n\t\tconst sortedPackages = Array.from(group.packages.entries()).sort(([a], [b]) => a.localeCompare(b));\n\t\tfor (const [source, items] of sortedPackages) {\n\t\t\tlines.push(` ${theme.fg(\"mdLink\", source)}`);\n\t\t\tconst sortedPackagePaths = [...items].sort((a, b) => a.path.localeCompare(b.path));\n\t\t\tfor (const item of sortedPackagePaths) {\n\t\t\t\tlines.push(theme.fg(\"dim\", ` ${options.formatPackagePath(item, source)}`));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\nexport function findSourceInfoForPath(p: string, sourceInfos: Map<string, SourceInfo>): SourceInfo | undefined {\n\tconst exact = sourceInfos.get(p);\n\tif (exact) return exact;\n\n\tlet current = p;\n\twhile (current.includes(\"/\")) {\n\t\tcurrent = current.substring(0, current.lastIndexOf(\"/\"));\n\t\tconst parent = sourceInfos.get(current);\n\t\tif (parent) return parent;\n\t}\n\n\treturn undefined;\n}\n\nexport function formatPathWithSource(p: string, sourceInfo?: SourceInfo): string {\n\tif (sourceInfo) {\n\t\tconst shortPath = getShortPath(p, sourceInfo);\n\t\tconst { label, scopeLabel } = getDisplaySourceInfo(sourceInfo);\n\t\tconst labelText = scopeLabel ? `${label} (${scopeLabel})` : label;\n\t\treturn `${labelText} ${shortPath}`;\n\t}\n\treturn formatDisplayPath(p);\n}\n\nexport function formatDiagnostics(\n\tdiagnostics: readonly ResourceDiagnostic[],\n\tsourceInfos: Map<string, SourceInfo>,\n): string {\n\tconst lines: string[] = [];\n\n\t// Group collision diagnostics by name\n\tconst collisions = new Map<string, ResourceDiagnostic[]>();\n\tconst otherDiagnostics: ResourceDiagnostic[] = [];\n\n\tfor (const d of diagnostics) {\n\t\tif (d.type === \"collision\" && d.collision) {\n\t\t\tconst list = collisions.get(d.collision.name) ?? [];\n\t\t\tlist.push(d);\n\t\t\tcollisions.set(d.collision.name, list);\n\t\t} else {\n\t\t\totherDiagnostics.push(d);\n\t\t}\n\t}\n\n\t// Format collision diagnostics grouped by name\n\tfor (const [name, collisionList] of collisions) {\n\t\tconst first = collisionList[0]?.collision;\n\t\tif (!first) continue;\n\t\tlines.push(theme.fg(\"warning\", ` \"${name}\" collision:`));\n\t\tlines.push(\n\t\t\ttheme.fg(\n\t\t\t\t\"dim\",\n\t\t\t\t` ${theme.fg(\"success\", \"✓\")} ${formatPathWithSource(first.winnerPath, findSourceInfoForPath(first.winnerPath, sourceInfos))}`,\n\t\t\t),\n\t\t);\n\t\tfor (const d of collisionList) {\n\t\t\tif (d.collision) {\n\t\t\t\tlines.push(\n\t\t\t\t\ttheme.fg(\n\t\t\t\t\t\t\"dim\",\n\t\t\t\t\t\t` ${theme.fg(\"warning\", \"✗\")} ${formatPathWithSource(d.collision.loserPath, findSourceInfoForPath(d.collision.loserPath, sourceInfos))} (skipped)`,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const d of otherDiagnostics) {\n\t\tif (d.path) {\n\t\t\tconst formattedPath = formatPathWithSource(d.path, findSourceInfoForPath(d.path, sourceInfos));\n\t\t\tlines.push(theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${formattedPath}`));\n\t\t\tlines.push(theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${d.message}`));\n\t\t} else {\n\t\t\tlines.push(theme.fg(d.type === \"error\" ? \"error\" : \"warning\", ` ${d.message}`));\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n"]}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* install-resources test), so interactive-mode keeps thin delegating wrappers.
|
|
11
11
|
*/
|
|
12
12
|
import type { SessionManager } from "@caupulican/pi-agent-core/node";
|
|
13
|
-
import type { Component, Container,
|
|
13
|
+
import type { Component, Container, TUI } from "@caupulican/pi-tui";
|
|
14
14
|
import type { AgentSession } from "../../core/agent-session.ts";
|
|
15
15
|
import type { SettingsManager } from "../../core/settings-manager.ts";
|
|
16
16
|
import { BashExecutionComponent } from "./components/bash-execution.ts";
|
|
@@ -46,10 +46,6 @@ export interface BashCommandHost {
|
|
|
46
46
|
export interface CompactCommandHost {
|
|
47
47
|
readonly sessionManager: Pick<SessionManager, "getEntries">;
|
|
48
48
|
showWarning(message: string): void;
|
|
49
|
-
loadingAnimation: Loader | undefined;
|
|
50
|
-
readonly statusContainer: {
|
|
51
|
-
clear: () => void;
|
|
52
|
-
};
|
|
53
49
|
readonly session: Pick<AgentSession, "compact">;
|
|
54
50
|
}
|
|
55
51
|
export declare function handleInstallResourcesCommand(host: InstallResourcesHost, argsString: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-shell-commands.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/resource-shell-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,gCAAgC,CAAC;AACvF,OAAO,KAAK,EAAE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install and shell/compaction command bodies extracted from\n * interactive-mode.\n *\n * `/install-resources` copies a trusted external resource tree into the agent\n * dir; `/curate` proposes/applies skill-curation actions; `!`/`!!` bash runs a\n * shell command (rendering a BashExecutionComponent, deferred while streaming);\n * `/compact` triggers manual compaction. Each takes a narrow host seam;\n * `copyResourcesRecursively` stays host-side (referenced directly by the\n * install-resources test), so interactive-mode keeps thin delegating wrappers.\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { SessionManager, TruncationResult } from \"@caupulican/pi-agent-core/node\";\nimport type { Component, Container, Loader, TUI } from \"@caupulican/pi-tui\";\nimport { getAgentDir } from \"../../config.ts\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport type { SettingsManager } from \"../../core/settings-manager.ts\";\nimport { BashExecutionComponent } from \"./components/bash-execution.ts\";\nimport { SelectSubmenu } from \"./components/settings-selector.ts\";\n\nexport interface InstallResourcesHost {\n\treadonly settingsManager: Pick<\n\t\tSettingsManager,\n\t\t\"canonicalizePath\" | \"getTrustedResourceRoots\" | \"addTrustedResourceRoot\"\n\t>;\n\tshowError(message: string): void;\n\tshowStatus(message: string): void;\n\tshowSelector(\n\t\tcreate: (done: () => void) => {\n\t\t\tcomponent: Component;\n\t\t\tfocus: Component;\n\t\t\tonSuperseded?: () => void;\n\t\t},\n\t): void;\n\thandleReloadCommand(): Promise<void>;\n\tcopyResourcesRecursively(\n\t\tsrc: string,\n\t\tdest: string,\n\t\tforce: boolean,\n\t\tstats: { installed: string[]; skipped: string[] },\n\t): void;\n}\n\nexport interface CurateCommandHost {\n\treadonly session: Pick<AgentSession, \"archivePromotedSkill\" | \"restorePromotedSkill\" | \"proposeSkillCuration\">;\n\tshowStatus(message: string): void;\n}\n\nexport interface BashCommandHost {\n\treadonly session: Pick<AgentSession, \"extensionRunner\" | \"isStreaming\" | \"recordBashResult\" | \"executeBash\">;\n\treadonly sessionManager: Pick<SessionManager, \"getCwd\">;\n\treadonly ui: TUI;\n\treadonly chatContainer: Container;\n\treadonly pendingMessagesContainer: Container;\n\treadonly pendingBashComponents: BashExecutionComponent[];\n\tbashComponent: BashExecutionComponent | undefined;\n\tshowError(message: string): void;\n}\n\nexport interface CompactCommandHost {\n\treadonly sessionManager: Pick<SessionManager, \"getEntries\">;\n\tshowWarning(message: string): void;\n\tloadingAnimation: Loader | undefined;\n\treadonly statusContainer: { clear: () => void };\n\treadonly session: Pick<AgentSession, \"compact\">;\n}\n\nexport async function handleInstallResourcesCommand(host: InstallResourcesHost, argsString: string): Promise<void> {\n\ttry {\n\t\tconst tokens = argsString.split(/\\s+/).filter(Boolean);\n\t\tlet force = false;\n\t\tlet dir = \"\";\n\t\tfor (const t of tokens) {\n\t\t\tif (t === \"--force\") {\n\t\t\t\tforce = true;\n\t\t\t} else {\n\t\t\t\tdir = t;\n\t\t\t}\n\t\t}\n\n\t\tif (!dir) {\n\t\t\thost.showError(\"Usage: /install-resources <dir> [--force]\");\n\t\t\treturn;\n\t\t}\n\n\t\tconst canonical = host.settingsManager.canonicalizePath(dir);\n\t\tif (!canonical || !fs.existsSync(canonical)) {\n\t\t\thost.showError(`Source directory does not exist: ${dir}`);\n\t\t\treturn;\n\t\t}\n\n\t\tconst trustedRoots = host.settingsManager.getTrustedResourceRoots();\n\t\tconst trusted = trustedRoots.includes(canonical);\n\n\t\tif (!trusted) {\n\t\t\tconst trust = await new Promise<boolean>((resolve) => {\n\t\t\t\thost.showSelector((done) => {\n\t\t\t\t\tconst submenu = new SelectSubmenu(\n\t\t\t\t\t\t\"Trust external source for installation?\",\n\t\t\t\t\t\t`The directory \"${canonical}\" contains extensions/resources to install. Extensions can execute arbitrary code on your machine. Do you trust it?`,\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: \"yes\",\n\t\t\t\t\t\t\t\tlabel: \"Yes\",\n\t\t\t\t\t\t\t\tdescription: \"Trust this directory and proceed with installation.\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ value: \"no\", label: \"No\", description: \"Do not trust this directory. Abort.\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"no\",\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tdone();\n\t\t\t\t\t\t\tresolve(value === \"yes\");\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\tdone();\n\t\t\t\t\t\t\tresolve(false);\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcomponent: submenu,\n\t\t\t\t\t\tfocus: submenu.getSelectList(),\n\t\t\t\t\t\tonSuperseded: () => resolve(false),\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tif (!trust) {\n\t\t\t\thost.showStatus(\"Installation aborted. Source directory was not trusted.\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\thost.settingsManager.addTrustedResourceRoot(canonical, \"global\");\n\t\t}\n\n\t\tconst subdirs = [\"skills\", \"extensions\", \"prompts\", \"themes\", \"profiles\", \"agents\"];\n\t\tconst stats = { installed: [] as string[], skipped: [] as string[] };\n\t\tconst userAgentDir = getAgentDir();\n\n\t\tfor (const sub of subdirs) {\n\t\t\tconst srcSub = path.join(canonical, sub);\n\t\t\tconst destSub = path.join(userAgentDir, sub);\n\t\t\tif (fs.existsSync(srcSub)) {\n\t\t\t\thost.copyResourcesRecursively(srcSub, destSub, force, stats);\n\t\t\t}\n\t\t}\n\n\t\tconst installedCount = stats.installed.length;\n\t\tconst skippedCount = stats.skipped.length;\n\t\thost.showStatus(`Installation complete: ${installedCount} resources installed, ${skippedCount} skipped.`);\n\n\t\tawait host.handleReloadCommand();\n\t} catch (error) {\n\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t}\n}\n\n/**\n * `/curate` — skill curator (#32). With no args, lists reflection-promoted skills proposed for\n * archival (stale/unused) and pairs proposed for consolidation (overlapping). PROPOSE-ONLY: the user\n * applies actions explicitly via `/curate archive <name>` / `/curate restore <name>`. Never touches\n * hand-authored skills; archival is restorable.\n */\nexport function handleCurateCommand(host: CurateCommandHost, args: string): void {\n\tconst [sub, name] = args.split(/\\s+/, 2);\n\tif (sub === \"archive\" && name) {\n\t\thost.showStatus(\n\t\t\thost.session.archivePromotedSkill(name)\n\t\t\t\t? `Archived promoted skill '${name}'`\n\t\t\t\t: `Could not archive '${name}' (not a promoted skill?)`,\n\t\t);\n\t\treturn;\n\t}\n\tif (sub === \"restore\" && name) {\n\t\thost.showStatus(\n\t\t\thost.session.restorePromotedSkill(name) ? `Restored skill '${name}'` : `Could not restore '${name}'`,\n\t\t);\n\t\treturn;\n\t}\n\tconst proposals = host.session.proposeSkillCuration();\n\tif (proposals.archive.length === 0 && proposals.consolidate.length === 0) {\n\t\thost.showStatus(\"Curator: no stale or overlapping promoted skills. Nothing to propose.\");\n\t\treturn;\n\t}\n\tconst lines: string[] = [\"Skill curator proposals (nothing applied automatically):\"];\n\tfor (const a of proposals.archive) {\n\t\tlines.push(` • archive '${a.name}' — ${a.reason} → /curate archive ${a.name}`);\n\t}\n\tfor (const c of proposals.consolidate) {\n\t\tlines.push(` • consider merging '${c.names[0]}' + '${c.names[1]}' (overlap ${(c.overlap * 100) | 0}%)`);\n\t}\n\thost.showStatus(lines.join(\"\\n\"));\n}\n\nexport async function handleBashCommand(\n\thost: BashCommandHost,\n\tcommand: string,\n\texcludeFromContext = false,\n): Promise<void> {\n\tconst extensionRunner = host.session.extensionRunner;\n\n\t// Emit user_bash event to let extensions intercept\n\tconst eventResult = await extensionRunner.emitUserBash({\n\t\ttype: \"user_bash\",\n\t\tcommand,\n\t\texcludeFromContext,\n\t\tcwd: host.sessionManager.getCwd(),\n\t});\n\n\t// If extension returned a full result, use it directly\n\tif (eventResult?.result) {\n\t\tconst result = eventResult.result;\n\n\t\t// Create UI component for display\n\t\thost.bashComponent = new BashExecutionComponent(command, host.ui, excludeFromContext);\n\t\tif (host.session.isStreaming) {\n\t\t\thost.pendingMessagesContainer.addChild(host.bashComponent);\n\t\t\thost.pendingBashComponents.push(host.bashComponent);\n\t\t} else {\n\t\t\thost.chatContainer.addChild(host.bashComponent);\n\t\t}\n\n\t\t// Show output and complete\n\t\tif (result.output) {\n\t\t\thost.bashComponent.appendOutput(result.output);\n\t\t}\n\t\thost.bashComponent.setComplete(\n\t\t\tresult.exitCode,\n\t\t\tresult.cancelled,\n\t\t\tresult.truncated ? ({ truncated: true, content: result.output } as TruncationResult) : undefined,\n\t\t\tresult.fullOutputPath,\n\t\t);\n\n\t\t// Record the result in session\n\t\thost.session.recordBashResult(command, result, { excludeFromContext });\n\t\thost.bashComponent = undefined;\n\t\thost.ui.requestRender();\n\t\treturn;\n\t}\n\n\t// Normal execution path (possibly with custom operations)\n\tconst isDeferred = host.session.isStreaming;\n\thost.bashComponent = new BashExecutionComponent(command, host.ui, excludeFromContext);\n\n\tif (isDeferred) {\n\t\t// Show in pending area when agent is streaming\n\t\thost.pendingMessagesContainer.addChild(host.bashComponent);\n\t\thost.pendingBashComponents.push(host.bashComponent);\n\t} else {\n\t\t// Show in chat immediately when agent is idle\n\t\thost.chatContainer.addChild(host.bashComponent);\n\t}\n\thost.ui.requestRender();\n\n\ttry {\n\t\tconst result = await host.session.executeBash(\n\t\t\tcommand,\n\t\t\t(chunk) => {\n\t\t\t\tif (host.bashComponent) {\n\t\t\t\t\thost.bashComponent.appendOutput(chunk);\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ excludeFromContext, operations: eventResult?.operations },\n\t\t);\n\n\t\tif (host.bashComponent) {\n\t\t\thost.bashComponent.setComplete(\n\t\t\t\tresult.exitCode,\n\t\t\t\tresult.cancelled,\n\t\t\t\tresult.truncated ? ({ truncated: true, content: result.output } as TruncationResult) : undefined,\n\t\t\t\tresult.fullOutputPath,\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\tif (host.bashComponent) {\n\t\t\thost.bashComponent.setComplete(undefined, false);\n\t\t}\n\t\thost.showError(`Bash command failed: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t}\n\n\thost.bashComponent = undefined;\n\thost.ui.requestRender();\n}\n\nexport async function handleCompactCommand(host: CompactCommandHost, customInstructions?: string): Promise<void> {\n\tconst entries = host.sessionManager.getEntries();\n\tconst messageCount = entries.filter((e) => e.type === \"message\").length;\n\n\tif (messageCount < 2) {\n\t\thost.showWarning(\"Nothing to compact (no messages yet)\");\n\t\treturn;\n\t}\n\n\tif (host.loadingAnimation) {\n\t\thost.loadingAnimation.stop();\n\t\thost.loadingAnimation = undefined;\n\t}\n\thost.statusContainer.clear();\n\n\ttry {\n\t\tawait host.session.compact(customInstructions);\n\t} catch {\n\t\t// Ignore, will be emitted as an event\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resource-shell-commands.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/resource-shell-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,gCAAgC,CAAC;AACvF,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAGxE,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,eAAe,EAAE,IAAI,CAC7B,eAAe,EACf,kBAAkB,GAAG,yBAAyB,GAAG,wBAAwB,CACzE,CAAC;IACF,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,CACX,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,IAAI,KAAK;QAC7B,SAAS,EAAE,SAAS,CAAC;QACrB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I,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;CAChD;AAED,wBAAsB,6BAA6B,CAAC,IAAI,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuFjH;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CA6B/E;AAED,wBAAsB,iBAAiB,CACtC,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,MAAM,EACf,kBAAkB,UAAQ,GACxB,OAAO,CAAC,IAAI,CAAC,CAqFf;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,kBAAkB,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAc/G","sourcesContent":["/**\n * Resource-install and shell/compaction command bodies extracted from\n * interactive-mode.\n *\n * `/install-resources` copies a trusted external resource tree into the agent\n * dir; `/curate` proposes/applies skill-curation actions; `!`/`!!` bash runs a\n * shell command (rendering a BashExecutionComponent, deferred while streaming);\n * `/compact` triggers manual compaction. Each takes a narrow host seam;\n * `copyResourcesRecursively` stays host-side (referenced directly by the\n * install-resources test), so interactive-mode keeps thin delegating wrappers.\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { SessionManager, TruncationResult } from \"@caupulican/pi-agent-core/node\";\nimport type { Component, Container, TUI } from \"@caupulican/pi-tui\";\nimport { getAgentDir } from \"../../config.ts\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport type { SettingsManager } from \"../../core/settings-manager.ts\";\nimport { BashExecutionComponent } from \"./components/bash-execution.ts\";\nimport { SelectSubmenu } from \"./components/settings-selector.ts\";\n\nexport interface InstallResourcesHost {\n\treadonly settingsManager: Pick<\n\t\tSettingsManager,\n\t\t\"canonicalizePath\" | \"getTrustedResourceRoots\" | \"addTrustedResourceRoot\"\n\t>;\n\tshowError(message: string): void;\n\tshowStatus(message: string): void;\n\tshowSelector(\n\t\tcreate: (done: () => void) => {\n\t\t\tcomponent: Component;\n\t\t\tfocus: Component;\n\t\t\tonSuperseded?: () => void;\n\t\t},\n\t): void;\n\thandleReloadCommand(): Promise<void>;\n\tcopyResourcesRecursively(\n\t\tsrc: string,\n\t\tdest: string,\n\t\tforce: boolean,\n\t\tstats: { installed: string[]; skipped: string[] },\n\t): void;\n}\n\nexport interface CurateCommandHost {\n\treadonly session: Pick<AgentSession, \"archivePromotedSkill\" | \"restorePromotedSkill\" | \"proposeSkillCuration\">;\n\tshowStatus(message: string): void;\n}\n\nexport interface BashCommandHost {\n\treadonly session: Pick<AgentSession, \"extensionRunner\" | \"isStreaming\" | \"recordBashResult\" | \"executeBash\">;\n\treadonly sessionManager: Pick<SessionManager, \"getCwd\">;\n\treadonly ui: TUI;\n\treadonly chatContainer: Container;\n\treadonly pendingMessagesContainer: Container;\n\treadonly pendingBashComponents: BashExecutionComponent[];\n\tbashComponent: BashExecutionComponent | undefined;\n\tshowError(message: string): void;\n}\n\nexport interface CompactCommandHost {\n\treadonly sessionManager: Pick<SessionManager, \"getEntries\">;\n\tshowWarning(message: string): void;\n\treadonly session: Pick<AgentSession, \"compact\">;\n}\n\nexport async function handleInstallResourcesCommand(host: InstallResourcesHost, argsString: string): Promise<void> {\n\ttry {\n\t\tconst tokens = argsString.split(/\\s+/).filter(Boolean);\n\t\tlet force = false;\n\t\tlet dir = \"\";\n\t\tfor (const t of tokens) {\n\t\t\tif (t === \"--force\") {\n\t\t\t\tforce = true;\n\t\t\t} else {\n\t\t\t\tdir = t;\n\t\t\t}\n\t\t}\n\n\t\tif (!dir) {\n\t\t\thost.showError(\"Usage: /install-resources <dir> [--force]\");\n\t\t\treturn;\n\t\t}\n\n\t\tconst canonical = host.settingsManager.canonicalizePath(dir);\n\t\tif (!canonical || !fs.existsSync(canonical)) {\n\t\t\thost.showError(`Source directory does not exist: ${dir}`);\n\t\t\treturn;\n\t\t}\n\n\t\tconst trustedRoots = host.settingsManager.getTrustedResourceRoots();\n\t\tconst trusted = trustedRoots.includes(canonical);\n\n\t\tif (!trusted) {\n\t\t\tconst trust = await new Promise<boolean>((resolve) => {\n\t\t\t\thost.showSelector((done) => {\n\t\t\t\t\tconst submenu = new SelectSubmenu(\n\t\t\t\t\t\t\"Trust external source for installation?\",\n\t\t\t\t\t\t`The directory \"${canonical}\" contains extensions/resources to install. Extensions can execute arbitrary code on your machine. Do you trust it?`,\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: \"yes\",\n\t\t\t\t\t\t\t\tlabel: \"Yes\",\n\t\t\t\t\t\t\t\tdescription: \"Trust this directory and proceed with installation.\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ value: \"no\", label: \"No\", description: \"Do not trust this directory. Abort.\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"no\",\n\t\t\t\t\t\t(value) => {\n\t\t\t\t\t\t\tdone();\n\t\t\t\t\t\t\tresolve(value === \"yes\");\n\t\t\t\t\t\t},\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\tdone();\n\t\t\t\t\t\t\tresolve(false);\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcomponent: submenu,\n\t\t\t\t\t\tfocus: submenu.getSelectList(),\n\t\t\t\t\t\tonSuperseded: () => resolve(false),\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tif (!trust) {\n\t\t\t\thost.showStatus(\"Installation aborted. Source directory was not trusted.\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\thost.settingsManager.addTrustedResourceRoot(canonical, \"global\");\n\t\t}\n\n\t\tconst subdirs = [\"skills\", \"extensions\", \"prompts\", \"themes\", \"profiles\", \"agents\"];\n\t\tconst stats = { installed: [] as string[], skipped: [] as string[] };\n\t\tconst userAgentDir = getAgentDir();\n\n\t\tfor (const sub of subdirs) {\n\t\t\tconst srcSub = path.join(canonical, sub);\n\t\t\tconst destSub = path.join(userAgentDir, sub);\n\t\t\tif (fs.existsSync(srcSub)) {\n\t\t\t\thost.copyResourcesRecursively(srcSub, destSub, force, stats);\n\t\t\t}\n\t\t}\n\n\t\tconst installedCount = stats.installed.length;\n\t\tconst skippedCount = stats.skipped.length;\n\t\thost.showStatus(`Installation complete: ${installedCount} resources installed, ${skippedCount} skipped.`);\n\n\t\tawait host.handleReloadCommand();\n\t} catch (error) {\n\t\thost.showError(error instanceof Error ? error.message : String(error));\n\t}\n}\n\n/**\n * `/curate` — skill curator (#32). With no args, lists reflection-promoted skills proposed for\n * archival (stale/unused) and pairs proposed for consolidation (overlapping). PROPOSE-ONLY: the user\n * applies actions explicitly via `/curate archive <name>` / `/curate restore <name>`. Never touches\n * hand-authored skills; archival is restorable.\n */\nexport function handleCurateCommand(host: CurateCommandHost, args: string): void {\n\tconst [sub, name] = args.split(/\\s+/, 2);\n\tif (sub === \"archive\" && name) {\n\t\thost.showStatus(\n\t\t\thost.session.archivePromotedSkill(name)\n\t\t\t\t? `Archived promoted skill '${name}'`\n\t\t\t\t: `Could not archive '${name}' (not a promoted skill?)`,\n\t\t);\n\t\treturn;\n\t}\n\tif (sub === \"restore\" && name) {\n\t\thost.showStatus(\n\t\t\thost.session.restorePromotedSkill(name) ? `Restored skill '${name}'` : `Could not restore '${name}'`,\n\t\t);\n\t\treturn;\n\t}\n\tconst proposals = host.session.proposeSkillCuration();\n\tif (proposals.archive.length === 0 && proposals.consolidate.length === 0) {\n\t\thost.showStatus(\"Curator: no stale or overlapping promoted skills. Nothing to propose.\");\n\t\treturn;\n\t}\n\tconst lines: string[] = [\"Skill curator proposals (nothing applied automatically):\"];\n\tfor (const a of proposals.archive) {\n\t\tlines.push(` • archive '${a.name}' — ${a.reason} → /curate archive ${a.name}`);\n\t}\n\tfor (const c of proposals.consolidate) {\n\t\tlines.push(` • consider merging '${c.names[0]}' + '${c.names[1]}' (overlap ${(c.overlap * 100) | 0}%)`);\n\t}\n\thost.showStatus(lines.join(\"\\n\"));\n}\n\nexport async function handleBashCommand(\n\thost: BashCommandHost,\n\tcommand: string,\n\texcludeFromContext = false,\n): Promise<void> {\n\tconst extensionRunner = host.session.extensionRunner;\n\n\t// Emit user_bash event to let extensions intercept\n\tconst eventResult = await extensionRunner.emitUserBash({\n\t\ttype: \"user_bash\",\n\t\tcommand,\n\t\texcludeFromContext,\n\t\tcwd: host.sessionManager.getCwd(),\n\t});\n\n\t// If extension returned a full result, use it directly\n\tif (eventResult?.result) {\n\t\tconst result = eventResult.result;\n\n\t\t// Create UI component for display\n\t\thost.bashComponent = new BashExecutionComponent(command, host.ui, excludeFromContext);\n\t\tif (host.session.isStreaming) {\n\t\t\thost.pendingMessagesContainer.addChild(host.bashComponent);\n\t\t\thost.pendingBashComponents.push(host.bashComponent);\n\t\t} else {\n\t\t\thost.chatContainer.addChild(host.bashComponent);\n\t\t}\n\n\t\t// Show output and complete\n\t\tif (result.output) {\n\t\t\thost.bashComponent.appendOutput(result.output);\n\t\t}\n\t\thost.bashComponent.setComplete(\n\t\t\tresult.exitCode,\n\t\t\tresult.cancelled,\n\t\t\tresult.truncated ? ({ truncated: true, content: result.output } as TruncationResult) : undefined,\n\t\t\tresult.fullOutputPath,\n\t\t);\n\n\t\t// Record the result in session\n\t\thost.session.recordBashResult(command, result, { excludeFromContext });\n\t\thost.bashComponent = undefined;\n\t\thost.ui.requestRender();\n\t\treturn;\n\t}\n\n\t// Normal execution path (possibly with custom operations)\n\tconst isDeferred = host.session.isStreaming;\n\thost.bashComponent = new BashExecutionComponent(command, host.ui, excludeFromContext);\n\n\tif (isDeferred) {\n\t\t// Show in pending area when agent is streaming\n\t\thost.pendingMessagesContainer.addChild(host.bashComponent);\n\t\thost.pendingBashComponents.push(host.bashComponent);\n\t} else {\n\t\t// Show in chat immediately when agent is idle\n\t\thost.chatContainer.addChild(host.bashComponent);\n\t}\n\thost.ui.requestRender();\n\n\ttry {\n\t\tconst result = await host.session.executeBash(\n\t\t\tcommand,\n\t\t\t(chunk) => {\n\t\t\t\tif (host.bashComponent) {\n\t\t\t\t\thost.bashComponent.appendOutput(chunk);\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ excludeFromContext, operations: eventResult?.operations },\n\t\t);\n\n\t\tif (host.bashComponent) {\n\t\t\thost.bashComponent.setComplete(\n\t\t\t\tresult.exitCode,\n\t\t\t\tresult.cancelled,\n\t\t\t\tresult.truncated ? ({ truncated: true, content: result.output } as TruncationResult) : undefined,\n\t\t\t\tresult.fullOutputPath,\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\tif (host.bashComponent) {\n\t\t\thost.bashComponent.setComplete(undefined, false);\n\t\t}\n\t\thost.showError(`Bash command failed: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t}\n\n\thost.bashComponent = undefined;\n\thost.ui.requestRender();\n}\n\nexport async function handleCompactCommand(host: CompactCommandHost, customInstructions?: string): Promise<void> {\n\tconst entries = host.sessionManager.getEntries();\n\tconst messageCount = entries.filter((e) => e.type === \"message\").length;\n\n\tif (messageCount < 2) {\n\t\thost.showWarning(\"Nothing to compact (no messages yet)\");\n\t\treturn;\n\t}\n\n\ttry {\n\t\tawait host.session.compact(customInstructions);\n\t} catch {\n\t\t// Ignore, will be emitted as an event\n\t}\n}\n"]}
|
|
@@ -191,11 +191,6 @@ export async function handleCompactCommand(host, customInstructions) {
|
|
|
191
191
|
host.showWarning("Nothing to compact (no messages yet)");
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
194
|
-
if (host.loadingAnimation) {
|
|
195
|
-
host.loadingAnimation.stop();
|
|
196
|
-
host.loadingAnimation = undefined;
|
|
197
|
-
}
|
|
198
|
-
host.statusContainer.clear();
|
|
199
194
|
try {
|
|
200
195
|
await host.session.compact(customInstructions);
|
|
201
196
|
}
|