pi-better-server 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -1
- package/scripts/copy-pi-test-providers.mjs +10 -0
- package/scripts/event-publication/README.md +26 -0
- package/scripts/event-publication/commit.mjs +21 -0
- package/scripts/event-publication/measure.mjs +87 -0
- package/scripts/event-publication/writer.mjs +6 -0
- package/scripts/measure-full-runtime/frontend.ts +24 -0
- package/scripts/measure-full-runtime/hosted-extension.ts +28 -0
- package/scripts/measure-full-runtime/probe.mjs +29 -0
- package/scripts/measure-full-runtime/recovery-trace-loader.mjs +51 -0
- package/scripts/measure-full-runtime/recovery-trace.mjs +16 -0
- package/scripts/measure-full-runtime.mjs +146 -0
- package/scripts/measure-shared-reads/probe.mjs +26 -2
- package/scripts/measure-shared-reads.mjs +44 -9
- package/scripts/private-runtime/package-lock.json +66 -4
- package/scripts/private-runtime/package.json +10 -2
- package/scripts/source-provenance.mjs +31 -0
- package/scripts/test-on-pi.sh +3 -9
- package/src/handshake.ts +1 -1
- package/src/hosted-session.ts +32 -4
- package/src/maintenance.ts +35 -7
- package/src/registry.ts +28 -4
- package/src/runtime/attempt-invalidation.ts +54 -0
- package/src/runtime/background-history.ts +151 -45
- package/src/runtime/background-policy.ts +27 -0
- package/src/runtime/background-tools.ts +389 -0
- package/src/runtime/background.ts +410 -48
- package/src/runtime/cancellation.ts +28 -7
- package/src/runtime/catalog-sources.ts +199 -0
- package/src/runtime/catalog.ts +53 -21
- package/src/runtime/client.ts +22 -2
- package/src/runtime/domain/assignment-inbox.mjs +119 -0
- package/src/runtime/domain/assignment-observation.d.mts +1 -1
- package/src/runtime/domain/assignment-observation.mjs +71 -33
- package/src/runtime/domain/background/process-identity.mjs +20 -2
- package/src/runtime/domain/background/process.mjs +3 -3
- package/src/runtime/domain/background/registry.mjs +89 -4
- package/src/runtime/domain/background/types.mjs +1 -0
- package/src/runtime/domain/background-service/adapter-contract.domain.mjs +83 -0
- package/src/runtime/domain/background-service/adapter-contract.ts +70 -0
- package/src/runtime/domain/background-service/batch.domain.mjs +91 -0
- package/src/runtime/domain/background-service/batch.ts +111 -0
- package/src/runtime/domain/background-service/conditions.domain.mjs +94 -0
- package/src/runtime/domain/background-service/conditions.ts +99 -0
- package/src/runtime/domain/background-service/delivery-observer.domain.mjs +37 -0
- package/src/runtime/domain/background-service/delivery-observer.ts +42 -0
- package/src/runtime/domain/background-service/failures.domain.mjs +209 -0
- package/src/runtime/domain/background-service/failures.ts +212 -0
- package/src/runtime/domain/background-service/goal-provider.domain.mjs +193 -0
- package/src/runtime/domain/background-service/goal-provider.ts +209 -0
- package/src/runtime/domain/background-service/index.domain.mjs +54 -0
- package/src/runtime/domain/background-service/index.ts +55 -0
- package/src/runtime/domain/background-service/logs.domain.mjs +129 -0
- package/src/runtime/domain/background-service/logs.ts +134 -0
- package/src/runtime/domain/background-service/maintenance.domain.mjs +95 -0
- package/src/runtime/domain/background-service/maintenance.ts +98 -0
- package/src/runtime/domain/background-service/managed-authority.domain.mjs +32 -0
- package/src/runtime/domain/background-service/managed-authority.ts +30 -0
- package/src/runtime/domain/background-service/managed-client.domain.mjs +79 -0
- package/src/runtime/domain/background-service/managed-client.ts +73 -0
- package/src/runtime/domain/background-service/managed-frontend.domain.mjs +225 -0
- package/src/runtime/domain/background-service/managed-frontend.ts +176 -0
- package/src/runtime/domain/background-service/navigator-provider.domain.mjs +492 -0
- package/src/runtime/domain/background-service/navigator-provider.ts +485 -0
- package/src/runtime/domain/background-service/observed-wait-client.domain.mjs +6 -0
- package/src/runtime/domain/background-service/observed-wait-client.ts +10 -0
- package/src/runtime/domain/background-service/observed-waits.domain.mjs +4080 -0
- package/src/runtime/domain/background-service/observed-waits.ts +4513 -0
- package/src/runtime/domain/background-service/output.domain.mjs +867 -0
- package/src/runtime/domain/background-service/output.ts +952 -0
- package/src/runtime/domain/background-service/process-identity.domain.mjs +129 -0
- package/src/runtime/domain/background-service/process-identity.ts +134 -0
- package/src/runtime/domain/background-service/process.domain.mjs +512 -0
- package/src/runtime/domain/background-service/process.ts +532 -0
- package/src/runtime/domain/background-service/prompt.domain.mjs +58 -0
- package/src/runtime/domain/background-service/prompt.ts +72 -0
- package/src/runtime/domain/background-service/registry.domain.mjs +460 -0
- package/src/runtime/domain/background-service/registry.ts +450 -0
- package/src/runtime/domain/background-service/remote-task-preset.domain.mjs +67 -0
- package/src/runtime/domain/background-service/remote-task-preset.ts +127 -0
- package/src/runtime/domain/background-service/runtime.domain.mjs +1511 -0
- package/src/runtime/domain/background-service/runtime.ts +1636 -0
- package/src/runtime/domain/background-service/sandbox.domain.mjs +735 -0
- package/src/runtime/domain/background-service/sandbox.ts +913 -0
- package/src/runtime/domain/background-service/shared-callback-batcher.domain.mjs +777 -0
- package/src/runtime/domain/background-service/shared-callback-batcher.ts +956 -0
- package/src/runtime/domain/background-service/shared-execution-policy.domain.mjs +50 -0
- package/src/runtime/domain/background-service/shared-execution-policy.ts +61 -0
- package/src/runtime/domain/background-service/shared-failure-observations.domain.mjs +1078 -0
- package/src/runtime/domain/background-service/shared-failure-observations.ts +1166 -0
- package/src/runtime/domain/background-service/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/background-service/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/background-service/shared-log-utils.domain.mjs +1223 -0
- package/src/runtime/domain/background-service/shared-log-utils.ts +1492 -0
- package/src/runtime/domain/background-service/shared-navigator-panels.domain.mjs +289 -0
- package/src/runtime/domain/background-service/shared-navigator-panels.ts +272 -0
- package/src/runtime/domain/background-service/shared-navigator.domain.mjs +1930 -0
- package/src/runtime/domain/background-service/shared-navigator.ts +1962 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-inbox.mjs +144 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-observation.mjs +189 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/index.domain.mjs +51 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/index.ts +122 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.ts +73 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +163 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.ts +174 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-parent-callbacks.domain.mjs +66 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-parent-callbacks.ts +68 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.domain.mjs +87 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.ts +90 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.domain.mjs +97 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.ts +139 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/errors.domain.mjs +12 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/errors.ts +79 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.domain.mjs +342 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.ts +513 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.domain.mjs +283 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.ts +458 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/recovery.domain.mjs +52 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/recovery.ts +55 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.domain.mjs +114 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.ts +140 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.domain.mjs +280 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.ts +442 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.domain.mjs +420 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.ts +441 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/sqlite.domain.mjs +194 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/sqlite.ts +239 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.domain.mjs +275 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.ts +585 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.domain.mjs +120 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.ts +142 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-cancellation.domain.mjs +188 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/task-cancellation.ts +224 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.domain.mjs +25 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.ts +707 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/upgrade.domain.mjs +22 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/upgrade.ts +22 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/validate.domain.mjs +234 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/validate.ts +241 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.domain.mjs +851 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/waits.ts +1424 -0
- package/src/runtime/domain/background-service/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/background-service/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/background-service/shared-render-scheduler.domain.mjs +41 -0
- package/src/runtime/domain/background-service/shared-render-scheduler.ts +47 -0
- package/src/runtime/domain/background-service/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/background-service/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/background-service/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/background-service/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/background-service/shared-ssh-core/index.domain.mjs +698 -0
- package/src/runtime/domain/background-service/shared-ssh-core/index.ts +979 -0
- package/src/runtime/domain/background-service/shared-stall-detector.domain.mjs +37 -0
- package/src/runtime/domain/background-service/shared-stall-detector.ts +69 -0
- package/src/runtime/domain/background-service/shared-work-client.mjs +303 -0
- package/src/runtime/domain/background-service/stall-attention.domain.mjs +29 -0
- package/src/runtime/domain/background-service/stall-attention.ts +31 -0
- package/src/runtime/domain/background-service/stall.domain.mjs +57 -0
- package/src/runtime/domain/background-service/stall.ts +57 -0
- package/src/runtime/domain/background-service/supervisor/README.md +111 -0
- package/src/runtime/domain/background-service/supervisor/emit-runner.mjs +90 -0
- package/src/runtime/domain/background-service/supervisor/generated/conditions.mjs +96 -0
- package/src/runtime/domain/background-service/supervisor/generated/identity.mjs +95 -0
- package/src/runtime/domain/background-service/supervisor/generated/process-identity.mjs +131 -0
- package/src/runtime/domain/background-service/supervisor/generated/process.mjs +514 -0
- package/src/runtime/domain/background-service/supervisor/generated/runner.mjs +872 -0
- package/src/runtime/domain/background-service/supervisor/generated/store.mjs +609 -0
- package/src/runtime/domain/background-service/supervisor/generated/types.mjs +50 -0
- package/src/runtime/domain/background-service/supervisor/identity.domain.mjs +93 -0
- package/src/runtime/domain/background-service/supervisor/identity.ts +99 -0
- package/src/runtime/domain/background-service/supervisor/index.domain.mjs +22 -0
- package/src/runtime/domain/background-service/supervisor/index.ts +37 -0
- package/src/runtime/domain/background-service/supervisor/invocation.domain.mjs +30 -0
- package/src/runtime/domain/background-service/supervisor/invocation.ts +44 -0
- package/src/runtime/domain/background-service/supervisor/runner.domain.mjs +870 -0
- package/src/runtime/domain/background-service/supervisor/runner.ts +982 -0
- package/src/runtime/domain/background-service/supervisor/store.domain.mjs +605 -0
- package/src/runtime/domain/background-service/supervisor/store.ts +651 -0
- package/src/runtime/domain/background-service/supervisor/supervisor.domain.mjs +721 -0
- package/src/runtime/domain/background-service/supervisor/supervisor.ts +804 -0
- package/src/runtime/domain/background-service/supervisor/types.domain.mjs +48 -0
- package/src/runtime/domain/background-service/supervisor/types.ts +394 -0
- package/src/runtime/domain/background-service/task-diagnostics.domain.mjs +60 -0
- package/src/runtime/domain/background-service/task-diagnostics.ts +71 -0
- package/src/runtime/domain/background-service/tools.domain.mjs +1050 -0
- package/src/runtime/domain/background-service/tools.ts +1142 -0
- package/src/runtime/domain/background-service/types.domain.mjs +5 -0
- package/src/runtime/domain/background-service/types.ts +236 -0
- package/src/runtime/domain/background-service/work-observation.domain.mjs +176 -0
- package/src/runtime/domain/background-service/work-observation.ts +144 -0
- package/src/runtime/domain/catalog/catalog-store.d.mts +9 -1
- package/src/runtime/domain/catalog/catalog-store.mjs +20 -22
- package/src/runtime/domain/coordinator/src/assignment-changes.mjs +75 -0
- package/src/runtime/domain/coordinator/src/assignment-outcomes.mjs +2 -0
- package/src/runtime/domain/coordinator/src/background-parent-callbacks.mjs +65 -0
- package/src/runtime/domain/coordinator/src/background-requests.mjs +86 -0
- package/src/runtime/domain/coordinator/src/discovery.mjs +4 -2
- package/src/runtime/domain/coordinator/src/operations.mjs +44 -4
- package/src/runtime/domain/coordinator/src/result-supervision.mjs +12 -0
- package/src/runtime/domain/coordinator/src/rows.mjs +2 -0
- package/src/runtime/domain/coordinator/src/schema.mjs +73 -21
- package/src/runtime/domain/coordinator/src/store.mjs +32 -3
- package/src/runtime/domain/coordinator/src/subagent-launch.mjs +119 -0
- package/src/runtime/domain/coordinator/src/types.mjs +1 -1
- package/src/runtime/domain/coordinator/src/upgrade.mjs +22 -0
- package/src/runtime/domain/health-observation.d.mts +3 -1
- package/src/runtime/domain/health-observation.mjs +189 -190
- package/src/runtime/domain/log-cursor.d.mts +2 -0
- package/src/runtime/domain/log-cursor.mjs +85 -16
- package/src/runtime/domain/parse.d.mts +4 -1
- package/src/runtime/domain/parse.mjs +50 -5
- package/src/runtime/domain/sandbox-policy/README.md +633 -0
- package/src/runtime/domain/sandbox-policy/background-admission.domain.mjs +83 -0
- package/src/runtime/domain/sandbox-policy/background-admission.ts +75 -0
- package/src/runtime/domain/sandbox-policy/commands.domain.mjs +245 -0
- package/src/runtime/domain/sandbox-policy/commands.ts +336 -0
- package/src/runtime/domain/sandbox-policy/deny-rules.domain.mjs +440 -0
- package/src/runtime/domain/sandbox-policy/deny-rules.ts +620 -0
- package/src/runtime/domain/sandbox-policy/diagnostics-command.domain.mjs +30 -0
- package/src/runtime/domain/sandbox-policy/diagnostics-command.ts +27 -0
- package/src/runtime/domain/sandbox-policy/events.domain.mjs +49 -0
- package/src/runtime/domain/sandbox-policy/events.ts +85 -0
- package/src/runtime/domain/sandbox-policy/files.domain.mjs +153 -0
- package/src/runtime/domain/sandbox-policy/files.ts +224 -0
- package/src/runtime/domain/sandbox-policy/index.domain.mjs +289 -0
- package/src/runtime/domain/sandbox-policy/index.ts +386 -0
- package/src/runtime/domain/sandbox-policy/package.json +66 -0
- package/src/runtime/domain/sandbox-policy/permission-settings.domain.mjs +36 -0
- package/src/runtime/domain/sandbox-policy/permission-settings.ts +46 -0
- package/src/runtime/domain/sandbox-policy/permissions-page.domain.mjs +309 -0
- package/src/runtime/domain/sandbox-policy/permissions-page.ts +295 -0
- package/src/runtime/domain/sandbox-policy/permissions.domain.mjs +98 -0
- package/src/runtime/domain/sandbox-policy/permissions.ts +125 -0
- package/src/runtime/domain/sandbox-policy/policy.domain.mjs +80 -0
- package/src/runtime/domain/sandbox-policy/policy.ts +102 -0
- package/src/runtime/domain/sandbox-policy/preferences.domain.mjs +55 -0
- package/src/runtime/domain/sandbox-policy/preferences.ts +82 -0
- package/src/runtime/domain/sandbox-policy/rules-page.domain.mjs +138 -0
- package/src/runtime/domain/sandbox-policy/rules-page.ts +176 -0
- package/src/runtime/domain/sandbox-policy/session-permissions.domain.mjs +22 -0
- package/src/runtime/domain/sandbox-policy/session-permissions.ts +24 -0
- package/src/runtime/domain/sandbox-policy/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/sandbox-policy/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/sandbox-policy/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/sandbox-policy/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/sandbox-policy/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/sandbox-policy/shared-task-application.domain.mjs +185 -0
- package/src/runtime/domain/sandbox-policy/shared-task-application.ts +185 -0
- package/src/runtime/domain/sandbox-policy/shared-task-apply-patch.domain.mjs +416 -0
- package/src/runtime/domain/sandbox-policy/shared-task-apply-patch.ts +409 -0
- package/src/runtime/domain/sandbox-policy/shared-task-exec.domain.mjs +325 -0
- package/src/runtime/domain/sandbox-policy/shared-task-exec.ts +335 -0
- package/src/runtime/domain/sandbox-policy/shared-task-files.domain.mjs +346 -0
- package/src/runtime/domain/sandbox-policy/shared-task-files.ts +342 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-identity.domain.mjs +140 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-identity.ts +126 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-list.domain.mjs +220 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-list.ts +209 -0
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.domain.mjs +227 -0
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.ts +224 -0
- package/src/runtime/domain/sandbox-policy/shared-task-tools.domain.mjs +92 -0
- package/src/runtime/domain/sandbox-policy/shared-task-tools.ts +123 -0
- package/src/runtime/domain/sandbox-policy/shell.domain.mjs +93 -0
- package/src/runtime/domain/sandbox-policy/shell.ts +129 -0
- package/src/runtime/domain/sandbox-policy/state.domain.mjs +307 -0
- package/src/runtime/domain/sandbox-policy/state.ts +408 -0
- package/src/runtime/domain/sandbox-policy/status.domain.mjs +64 -0
- package/src/runtime/domain/sandbox-policy/status.ts +76 -0
- package/src/runtime/domain/sandbox-policy/subagent-admission.domain.mjs +69 -0
- package/src/runtime/domain/sandbox-policy/subagent-admission.ts +60 -0
- package/src/runtime/domain/subagents/CONTEXT.md +202 -0
- package/src/runtime/domain/subagents/PRODUCT.md +49 -0
- package/src/runtime/domain/subagents/README.md +201 -0
- package/src/runtime/domain/subagents/agent-catalog.mjs +64 -0
- package/src/runtime/domain/subagents/agent-commands.domain.mjs +822 -0
- package/src/runtime/domain/subagents/agent-commands.ts +905 -0
- package/src/runtime/domain/subagents/agent-inspection.domain.mjs +398 -0
- package/src/runtime/domain/subagents/agent-inspection.ts +574 -0
- package/src/runtime/domain/subagents/agent-operations.domain.mjs +40 -0
- package/src/runtime/domain/subagents/agent-operations.ts +61 -0
- package/src/runtime/domain/subagents/agent-session-settings.domain.mjs +112 -0
- package/src/runtime/domain/subagents/agent-session-settings.ts +118 -0
- package/src/runtime/domain/subagents/agents-catalog-tool.domain.mjs +84 -0
- package/src/runtime/domain/subagents/agents-catalog-tool.ts +118 -0
- package/src/runtime/domain/subagents/assignment-outcomes.domain.mjs +276 -0
- package/src/runtime/domain/subagents/assignment-outcomes.ts +212 -0
- package/src/runtime/domain/subagents/assignment-projection.mjs +261 -0
- package/src/runtime/domain/subagents/assignment-report.domain.mjs +174 -0
- package/src/runtime/domain/subagents/assignment-report.ts +156 -0
- package/src/runtime/domain/subagents/batch.mjs +275 -0
- package/src/runtime/domain/subagents/callback-fields.domain.mjs +72 -0
- package/src/runtime/domain/subagents/callback-fields.ts +95 -0
- package/src/runtime/domain/subagents/capacity.mjs +108 -0
- package/src/runtime/domain/subagents/catalog-editor.domain.mjs +98 -0
- package/src/runtime/domain/subagents/catalog-editor.ts +125 -0
- package/src/runtime/domain/subagents/catalog-host-admission.domain.mjs +104 -0
- package/src/runtime/domain/subagents/catalog-host-admission.ts +85 -0
- package/src/runtime/domain/subagents/catalog-identity.domain.mjs +222 -0
- package/src/runtime/domain/subagents/catalog-identity.ts +258 -0
- package/src/runtime/domain/subagents/catalog-overlay.domain.mjs +9 -0
- package/src/runtime/domain/subagents/catalog-overlay.ts +10 -0
- package/src/runtime/domain/subagents/catalog-preferences.domain.mjs +164 -0
- package/src/runtime/domain/subagents/catalog-preferences.ts +139 -0
- package/src/runtime/domain/subagents/catalog-resolver.domain.mjs +366 -0
- package/src/runtime/domain/subagents/catalog-resolver.ts +540 -0
- package/src/runtime/domain/subagents/catalog-runtime.domain.mjs +570 -0
- package/src/runtime/domain/subagents/catalog-runtime.ts +680 -0
- package/src/runtime/domain/subagents/catalog-schema.domain.mjs +1331 -0
- package/src/runtime/domain/subagents/catalog-schema.ts +1563 -0
- package/src/runtime/domain/subagents/catalog-skill-edits.domain.mjs +95 -0
- package/src/runtime/domain/subagents/catalog-skill-edits.ts +116 -0
- package/src/runtime/domain/subagents/catalog-store.domain.mjs +808 -0
- package/src/runtime/domain/subagents/catalog-store.ts +1006 -0
- package/src/runtime/domain/subagents/catalog-ui.domain.mjs +651 -0
- package/src/runtime/domain/subagents/catalog-ui.ts +611 -0
- package/src/runtime/domain/subagents/child-apply-patch.domain.mjs +13 -0
- package/src/runtime/domain/subagents/child-apply-patch.ts +13 -0
- package/src/runtime/domain/subagents/child-codemode.domain.mjs +16 -0
- package/src/runtime/domain/subagents/child-codemode.ts +17 -0
- package/src/runtime/domain/subagents/child-dependencies.mjs +193 -0
- package/src/runtime/domain/subagents/child-incidents.domain.mjs +170 -0
- package/src/runtime/domain/subagents/child-incidents.ts +169 -0
- package/src/runtime/domain/subagents/child-operations.domain.mjs +986 -0
- package/src/runtime/domain/subagents/child-operations.ts +1191 -0
- package/src/runtime/domain/subagents/child-ownership.domain.mjs +205 -0
- package/src/runtime/domain/subagents/child-ownership.ts +160 -0
- package/src/runtime/domain/subagents/child-preflight.mjs +38 -0
- package/src/runtime/domain/subagents/child-process-list.domain.mjs +7 -0
- package/src/runtime/domain/subagents/child-process-list.ts +8 -0
- package/src/runtime/domain/subagents/child-runtime.mjs +67 -0
- package/src/runtime/domain/subagents/child-steer.domain.mjs +109 -0
- package/src/runtime/domain/subagents/child-steer.ts +102 -0
- package/src/runtime/domain/subagents/cleanup.domain.mjs +818 -0
- package/src/runtime/domain/subagents/cleanup.ts +1017 -0
- package/src/runtime/domain/subagents/codex-import.domain.mjs +575 -0
- package/src/runtime/domain/subagents/codex-import.ts +717 -0
- package/src/runtime/domain/subagents/completion.domain.mjs +6 -0
- package/src/runtime/domain/subagents/completion.mjs +152 -0
- package/src/runtime/domain/subagents/completion.ts +11 -0
- package/src/runtime/domain/subagents/config.domain.mjs +248 -0
- package/src/runtime/domain/subagents/config.json +15 -0
- package/src/runtime/domain/subagents/config.ts +328 -0
- package/src/runtime/domain/subagents/continuation-authority.domain.mjs +38 -0
- package/src/runtime/domain/subagents/continuation-authority.ts +31 -0
- package/src/runtime/domain/subagents/continuation-runtime.domain.mjs +89 -0
- package/src/runtime/domain/subagents/continuation-runtime.ts +88 -0
- package/src/runtime/domain/subagents/continuation.domain.mjs +942 -0
- package/src/runtime/domain/subagents/continuation.ts +1051 -0
- package/src/runtime/domain/subagents/delegation.domain.mjs +19 -0
- package/src/runtime/domain/subagents/delegation.ts +24 -0
- package/src/runtime/domain/subagents/effective-settings.domain.mjs +130 -0
- package/src/runtime/domain/subagents/effective-settings.ts +184 -0
- package/src/runtime/domain/subagents/extensions.domain.mjs +6 -0
- package/src/runtime/domain/subagents/extensions.mjs +164 -0
- package/src/runtime/domain/subagents/extensions.ts +19 -0
- package/src/runtime/domain/subagents/failures.domain.mjs +362 -0
- package/src/runtime/domain/subagents/failures.ts +319 -0
- package/src/runtime/domain/subagents/finalization.domain.mjs +168 -0
- package/src/runtime/domain/subagents/finalization.ts +218 -0
- package/src/runtime/domain/subagents/git-remotes.domain.mjs +351 -0
- package/src/runtime/domain/subagents/git-remotes.ts +413 -0
- package/src/runtime/domain/subagents/git-workspace.domain.mjs +337 -0
- package/src/runtime/domain/subagents/git-workspace.ts +430 -0
- package/src/runtime/domain/subagents/goal-provider.domain.mjs +125 -0
- package/src/runtime/domain/subagents/goal-provider.ts +132 -0
- package/src/runtime/domain/subagents/health-observation.domain.mjs +617 -0
- package/src/runtime/domain/subagents/health-observation.ts +818 -0
- package/src/runtime/domain/subagents/health-surface.mjs +284 -0
- package/src/runtime/domain/subagents/health.domain.mjs +261 -0
- package/src/runtime/domain/subagents/health.ts +343 -0
- package/src/runtime/domain/subagents/historical-attention.domain.mjs +37 -0
- package/src/runtime/domain/subagents/historical-attention.ts +35 -0
- package/src/runtime/domain/subagents/incident-model.domain.mjs +322 -0
- package/src/runtime/domain/subagents/incident-model.ts +358 -0
- package/src/runtime/domain/subagents/index.domain.mjs +4731 -0
- package/src/runtime/domain/subagents/index.ts +4781 -0
- package/src/runtime/domain/subagents/launch-abort.domain.mjs +13 -0
- package/src/runtime/domain/subagents/launch-abort.ts +21 -0
- package/src/runtime/domain/subagents/launch-context.domain.mjs +24 -0
- package/src/runtime/domain/subagents/launch-context.ts +23 -0
- package/src/runtime/domain/subagents/launch-digest.mjs +6 -0
- package/src/runtime/domain/subagents/lifecycle.domain.mjs +265 -0
- package/src/runtime/domain/subagents/lifecycle.ts +360 -0
- package/src/runtime/domain/subagents/list.domain.mjs +2 -0
- package/src/runtime/domain/subagents/list.mjs +152 -0
- package/src/runtime/domain/subagents/list.ts +19 -0
- package/src/runtime/domain/subagents/log-cursor.domain.mjs +217 -0
- package/src/runtime/domain/subagents/log-cursor.ts +268 -0
- package/src/runtime/domain/subagents/managed-background-capability.domain.mjs +10 -0
- package/src/runtime/domain/subagents/managed-background-capability.ts +9 -0
- package/src/runtime/domain/subagents/managed-failure-worker.mjs +36 -0
- package/src/runtime/domain/subagents/managed-launch-bootstrap.mjs +48 -0
- package/src/runtime/domain/subagents/managed-launch-client.domain.mjs +75 -0
- package/src/runtime/domain/subagents/managed-launch-client.ts +59 -0
- package/src/runtime/domain/subagents/managed-launch-host.domain.mjs +627 -0
- package/src/runtime/domain/subagents/managed-launch-host.ts +504 -0
- package/src/runtime/domain/subagents/managed-launch-journal.mjs +17 -0
- package/src/runtime/domain/subagents/managed-launch-ownership.domain.mjs +29 -0
- package/src/runtime/domain/subagents/managed-launch-ownership.ts +22 -0
- package/src/runtime/domain/subagents/managed-launch-port.domain.mjs +2 -0
- package/src/runtime/domain/subagents/managed-launch-port.ts +25 -0
- package/src/runtime/domain/subagents/managed-launch-recovery.domain.mjs +29 -0
- package/src/runtime/domain/subagents/managed-launch-recovery.ts +45 -0
- package/src/runtime/domain/subagents/managed-worker-bridge.domain.mjs +63 -0
- package/src/runtime/domain/subagents/managed-worker-bridge.ts +48 -0
- package/src/runtime/domain/subagents/managed-worker.mjs +13 -0
- package/src/runtime/domain/subagents/model-resolution-core.domain.mjs +822 -0
- package/src/runtime/domain/subagents/model-resolution-core.ts +1074 -0
- package/src/runtime/domain/subagents/model-resolution.domain.mjs +22 -0
- package/src/runtime/domain/subagents/model-resolution.ts +32 -0
- package/src/runtime/domain/subagents/navigator.domain.mjs +6 -0
- package/src/runtime/domain/subagents/navigator.mjs +1233 -0
- package/src/runtime/domain/subagents/navigator.ts +39 -0
- package/src/runtime/domain/subagents/operation-bridge-types.domain.mjs +1012 -0
- package/src/runtime/domain/subagents/operation-bridge-types.ts +1156 -0
- package/src/runtime/domain/subagents/outage-observations.domain.mjs +84 -0
- package/src/runtime/domain/subagents/outage-observations.ts +73 -0
- package/src/runtime/domain/subagents/output-payload.domain.mjs +767 -0
- package/src/runtime/domain/subagents/output-payload.ts +987 -0
- package/src/runtime/domain/subagents/owned-exit.domain.mjs +12 -0
- package/src/runtime/domain/subagents/owned-exit.ts +12 -0
- package/src/runtime/domain/subagents/package.json +86 -0
- package/src/runtime/domain/subagents/park-checkpoint.domain.mjs +55 -0
- package/src/runtime/domain/subagents/park-checkpoint.ts +61 -0
- package/src/runtime/domain/subagents/parse.domain.mjs +1218 -0
- package/src/runtime/domain/subagents/parse.ts +1451 -0
- package/src/runtime/domain/subagents/permission-policy.domain.mjs +232 -0
- package/src/runtime/domain/subagents/permission-policy.ts +291 -0
- package/src/runtime/domain/subagents/process-identity.mjs +33 -0
- package/src/runtime/domain/subagents/registry.domain.mjs +1584 -0
- package/src/runtime/domain/subagents/registry.ts +1904 -0
- package/src/runtime/domain/subagents/role-assignment.domain.mjs +104 -0
- package/src/runtime/domain/subagents/role-assignment.ts +141 -0
- package/src/runtime/domain/subagents/roles/role.architect.md +13 -0
- package/src/runtime/domain/subagents/roles/role.developer.md +16 -0
- package/src/runtime/domain/subagents/roles/role.explorer.md +13 -0
- package/src/runtime/domain/subagents/roles/role.product-manager.md +13 -0
- package/src/runtime/domain/subagents/roles/role.researcher.md +13 -0
- package/src/runtime/domain/subagents/roles/role.reviewer.md +13 -0
- package/src/runtime/domain/subagents/roles/role.writer.md +12 -0
- package/src/runtime/domain/subagents/sandbox.domain.mjs +64 -0
- package/src/runtime/domain/subagents/sandbox.ts +92 -0
- package/src/runtime/domain/subagents/session-selection.domain.mjs +32 -0
- package/src/runtime/domain/subagents/session-selection.ts +35 -0
- package/src/runtime/domain/subagents/session-store.domain.mjs +489 -0
- package/src/runtime/domain/subagents/session-store.ts +468 -0
- package/src/runtime/domain/subagents/settings-page.domain.mjs +313 -0
- package/src/runtime/domain/subagents/settings-page.ts +363 -0
- package/src/runtime/domain/subagents/shared-callback-batcher.domain.mjs +777 -0
- package/src/runtime/domain/subagents/shared-callback-batcher.ts +956 -0
- package/src/runtime/domain/subagents/shared-catalog.domain.mjs +70 -0
- package/src/runtime/domain/subagents/shared-catalog.ts +61 -0
- package/src/runtime/domain/subagents/shared-execution-policy.domain.mjs +50 -0
- package/src/runtime/domain/subagents/shared-execution-policy.ts +61 -0
- package/src/runtime/domain/subagents/shared-failure-observations.domain.mjs +1078 -0
- package/src/runtime/domain/subagents/shared-failure-observations.ts +1166 -0
- package/src/runtime/domain/subagents/shared-harness-settings.domain.mjs +126 -0
- package/src/runtime/domain/subagents/shared-harness-settings.ts +116 -0
- package/src/runtime/domain/subagents/shared-log-utils.domain.mjs +1223 -0
- package/src/runtime/domain/subagents/shared-log-utils.ts +1492 -0
- package/src/runtime/domain/subagents/shared-navigator-panels.domain.mjs +289 -0
- package/src/runtime/domain/subagents/shared-navigator-panels.ts +272 -0
- package/src/runtime/domain/subagents/shared-navigator.domain.mjs +1930 -0
- package/src/runtime/domain/subagents/shared-navigator.ts +1962 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-inbox.mjs +144 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-observation.mjs +189 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/index.domain.mjs +51 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/index.ts +122 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.ts +73 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +163 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.ts +174 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-parent-callbacks.domain.mjs +66 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-parent-callbacks.ts +68 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.domain.mjs +87 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.ts +90 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.domain.mjs +97 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.ts +139 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/errors.domain.mjs +12 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/errors.ts +79 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.domain.mjs +342 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.ts +513 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.domain.mjs +283 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.ts +458 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/recovery.domain.mjs +52 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/recovery.ts +55 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.domain.mjs +114 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.ts +140 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.domain.mjs +280 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.ts +442 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.domain.mjs +420 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.ts +441 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/sqlite.domain.mjs +194 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/sqlite.ts +239 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.domain.mjs +275 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.ts +585 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.domain.mjs +120 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.ts +142 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-cancellation.domain.mjs +188 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/task-cancellation.ts +224 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.domain.mjs +25 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.ts +707 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/upgrade.domain.mjs +22 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/upgrade.ts +22 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/validate.domain.mjs +234 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/validate.ts +241 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.domain.mjs +851 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/waits.ts +1424 -0
- package/src/runtime/domain/subagents/shared-permission-blocker.domain.mjs +40 -0
- package/src/runtime/domain/subagents/shared-permission-blocker.ts +48 -0
- package/src/runtime/domain/subagents/shared-render-scheduler.domain.mjs +41 -0
- package/src/runtime/domain/subagents/shared-render-scheduler.ts +47 -0
- package/src/runtime/domain/subagents/shared-sandbox-core.domain.mjs +1531 -0
- package/src/runtime/domain/subagents/shared-sandbox-core.ts +1757 -0
- package/src/runtime/domain/subagents/shared-sandbox-diagnostics.domain.mjs +591 -0
- package/src/runtime/domain/subagents/shared-sandbox-diagnostics.ts +491 -0
- package/src/runtime/domain/subagents/shared-stall-detector.domain.mjs +37 -0
- package/src/runtime/domain/subagents/shared-stall-detector.ts +69 -0
- package/src/runtime/domain/subagents/shared-task-application.domain.mjs +185 -0
- package/src/runtime/domain/subagents/shared-task-application.ts +185 -0
- package/src/runtime/domain/subagents/shared-task-apply-patch.domain.mjs +416 -0
- package/src/runtime/domain/subagents/shared-task-apply-patch.ts +409 -0
- package/src/runtime/domain/subagents/shared-task-exec.domain.mjs +325 -0
- package/src/runtime/domain/subagents/shared-task-exec.ts +335 -0
- package/src/runtime/domain/subagents/shared-task-files.domain.mjs +346 -0
- package/src/runtime/domain/subagents/shared-task-files.ts +342 -0
- package/src/runtime/domain/subagents/shared-task-process-identity.domain.mjs +140 -0
- package/src/runtime/domain/subagents/shared-task-process-identity.ts +126 -0
- package/src/runtime/domain/subagents/shared-task-process-list.domain.mjs +220 -0
- package/src/runtime/domain/subagents/shared-task-process-list.ts +209 -0
- package/src/runtime/domain/subagents/shared-task-sandbox.domain.mjs +227 -0
- package/src/runtime/domain/subagents/shared-task-sandbox.ts +224 -0
- package/src/runtime/domain/subagents/shared-task-tools.domain.mjs +92 -0
- package/src/runtime/domain/subagents/shared-task-tools.ts +123 -0
- package/src/runtime/domain/subagents/shared-work-client.mjs +303 -0
- package/src/runtime/domain/subagents/shared-worktree-context.domain.mjs +142 -0
- package/src/runtime/domain/subagents/shared-worktree-context.ts +158 -0
- package/src/runtime/domain/subagents/skill-picker.domain.mjs +316 -0
- package/src/runtime/domain/subagents/skill-picker.ts +353 -0
- package/src/runtime/domain/subagents/skills.domain.mjs +138 -0
- package/src/runtime/domain/subagents/skills.ts +183 -0
- package/src/runtime/domain/subagents/spawn.domain.mjs +72 -0
- package/src/runtime/domain/subagents/spawn.ts +80 -0
- package/src/runtime/domain/subagents/stop.domain.mjs +184 -0
- package/src/runtime/domain/subagents/stop.ts +217 -0
- package/src/runtime/domain/subagents/subagent-tools.domain.mjs +101 -0
- package/src/runtime/domain/subagents/subagent-tools.ts +137 -0
- package/src/runtime/domain/subagents/task-guard.domain.mjs +163 -0
- package/src/runtime/domain/subagents/task-guard.ts +144 -0
- package/src/runtime/domain/subagents/task-policy.domain.mjs +201 -0
- package/src/runtime/domain/subagents/task-policy.ts +236 -0
- package/src/runtime/domain/subagents/task-runtime.mjs +53 -0
- package/src/runtime/domain/subagents/task-tool-owner.domain.mjs +18 -0
- package/src/runtime/domain/subagents/task-tool-owner.ts +21 -0
- package/src/runtime/domain/subagents/thinking.domain.mjs +22 -0
- package/src/runtime/domain/subagents/thinking.ts +28 -0
- package/src/runtime/domain/subagents/tier-policy.domain.mjs +75 -0
- package/src/runtime/domain/subagents/tier-policy.ts +126 -0
- package/src/runtime/domain/subagents/timing-notifications.domain.mjs +51 -0
- package/src/runtime/domain/subagents/timing-notifications.ts +37 -0
- package/src/runtime/domain/subagents/timing.domain.mjs +487 -0
- package/src/runtime/domain/subagents/timing.ts +634 -0
- package/src/runtime/domain/subagents/tools.domain.mjs +558 -0
- package/src/runtime/domain/subagents/tools.ts +629 -0
- package/src/runtime/domain/subagents/widget.domain.mjs +6 -0
- package/src/runtime/domain/subagents/widget.mjs +246 -0
- package/src/runtime/domain/subagents/widget.ts +30 -0
- package/src/runtime/domain/subagents/work-observation.domain.mjs +316 -0
- package/src/runtime/domain/subagents/work-observation.ts +248 -0
- package/src/runtime/domain/subagents/worker-catalog.domain.mjs +120 -0
- package/src/runtime/domain/subagents/worker-catalog.ts +162 -0
- package/src/runtime/domain/subagents/worker-operations-host.domain.mjs +1009 -0
- package/src/runtime/domain/subagents/worker-operations-host.ts +1238 -0
- package/src/runtime/domain/subagents/worker-waits.domain.mjs +2336 -0
- package/src/runtime/domain/subagents/worker-waits.ts +2878 -0
- package/src/runtime/domain/subagents/workspace-scope.domain.mjs +52 -0
- package/src/runtime/domain/subagents/workspace-scope.ts +50 -0
- package/src/runtime/health-config.ts +27 -11
- package/src/runtime/log-checkpoints.ts +117 -0
- package/src/runtime/mutation-store.ts +5 -4
- package/src/runtime/queries.ts +27 -3
- package/src/runtime/query-executor.ts +178 -34
- package/src/runtime/query-worker.mjs +119 -22
- package/src/runtime/read-model.ts +939 -113
- package/src/runtime/read-watchdog-probe.ts +4 -0
- package/src/runtime/result-supervision.ts +188 -16
- package/src/runtime/source-watch.ts +175 -0
- package/src/runtime/subagent-launch.ts +73 -0
- package/src/runtime/work-budget.ts +130 -0
- package/src/runtime/work-client.d.mts +8 -0
- package/src/runtime/work-client.mjs +150 -7
- package/src/server.ts +185 -22
- package/src/session-activity.ts +26 -4
- package/src/version.ts +1 -1
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
// Generated fixed launch domain from packages/pi-better-subagents/skill-picker.ts. Do not edit directly.
|
|
2
|
+
/**
|
|
3
|
+
* Shared searchable skill checkbox picker.
|
|
4
|
+
*
|
|
5
|
+
* Both selected-skill entry points use this component: `/subagents settings`
|
|
6
|
+
* for the global default and `/agents` for a role or named agent. It only
|
|
7
|
+
* renders metadata and returns paths; it never loads a model or writes files.
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync } from "node:fs";
|
|
10
|
+
import { basename, dirname, isAbsolute, resolve } from "node:path";
|
|
11
|
+
import * as Tui from "@earendil-works/pi-tui";
|
|
12
|
+
function pathKey(path) {
|
|
13
|
+
try {
|
|
14
|
+
return resolve(path);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return path;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function skillKeys(skill) {
|
|
21
|
+
return [pathKey(skill.path), ...(skill.baseDir ? [pathKey(skill.baseDir)] : [])];
|
|
22
|
+
}
|
|
23
|
+
function unavailableName(path) {
|
|
24
|
+
const parent = basename(dirname(path));
|
|
25
|
+
return parent || basename(path);
|
|
26
|
+
}
|
|
27
|
+
function errorText(error) {
|
|
28
|
+
return error instanceof Error ? error.message : String(error);
|
|
29
|
+
}
|
|
30
|
+
function cell(text, width) {
|
|
31
|
+
const clipped = Tui.truncateToWidth(text, width, "");
|
|
32
|
+
return clipped + " ".repeat(Math.max(0, width - Tui.visibleWidth(clipped)));
|
|
33
|
+
}
|
|
34
|
+
export function createSkillPicker(options) {
|
|
35
|
+
const { theme } = options;
|
|
36
|
+
const search = new Tui.Input();
|
|
37
|
+
const pathInput = new Tui.Input();
|
|
38
|
+
let focused = false;
|
|
39
|
+
let cursor = 0;
|
|
40
|
+
let adding = false;
|
|
41
|
+
let message = "";
|
|
42
|
+
let error = false;
|
|
43
|
+
let scroll = 0;
|
|
44
|
+
const checked = new Map();
|
|
45
|
+
for (const path of options.selected)
|
|
46
|
+
checked.set(pathKey(path), path);
|
|
47
|
+
// Keep saved/manual rows available even after they are unchecked.
|
|
48
|
+
const extraPaths = new Map(checked);
|
|
49
|
+
const skills = [...options.skills].sort((left, right) => left.name.localeCompare(right.name) || left.path.localeCompare(right.path));
|
|
50
|
+
function request() {
|
|
51
|
+
options.requestRender();
|
|
52
|
+
}
|
|
53
|
+
function checkedKeysFor(skill) {
|
|
54
|
+
const keys = new Set(skillKeys(skill));
|
|
55
|
+
return [...checked.keys()].filter((key) => keys.has(key));
|
|
56
|
+
}
|
|
57
|
+
function isChecked(skill) {
|
|
58
|
+
return checkedKeysFor(skill).length > 0;
|
|
59
|
+
}
|
|
60
|
+
function matches(value, query) {
|
|
61
|
+
return value.toLowerCase().includes(query);
|
|
62
|
+
}
|
|
63
|
+
function rows() {
|
|
64
|
+
const query = search.getValue().trim().toLowerCase();
|
|
65
|
+
const available = skills
|
|
66
|
+
.filter((skill) => !query || matches(skill.name, query) || matches(skill.description, query) || matches(skill.path, query))
|
|
67
|
+
.map((skill) => ({ kind: "skill", skill, key: skillKeys(skill)[0] }));
|
|
68
|
+
const known = new Set(skills.flatMap(skillKeys));
|
|
69
|
+
const extras = [...extraPaths.entries()]
|
|
70
|
+
.filter(([key, path]) => !known.has(key)
|
|
71
|
+
&& (!query || matches(path, query) || matches(unavailableName(path), query)))
|
|
72
|
+
.map(([key, path]) => ({ kind: "extra", path, key }));
|
|
73
|
+
return [...available, ...extras, { kind: "apply" }, { kind: "add" }];
|
|
74
|
+
}
|
|
75
|
+
function current(entries = rows()) {
|
|
76
|
+
return entries[Math.min(cursor, entries.length - 1)];
|
|
77
|
+
}
|
|
78
|
+
function report(text, failed = false) {
|
|
79
|
+
message = text;
|
|
80
|
+
error = failed;
|
|
81
|
+
request();
|
|
82
|
+
}
|
|
83
|
+
function toggle(row) {
|
|
84
|
+
if (!row || row.kind === "apply" || row.kind === "add")
|
|
85
|
+
return;
|
|
86
|
+
if (row.kind === "skill") {
|
|
87
|
+
const keys = checkedKeysFor(row.skill);
|
|
88
|
+
if (keys.length > 0)
|
|
89
|
+
keys.forEach((key) => checked.delete(key));
|
|
90
|
+
else
|
|
91
|
+
checked.set(pathKey(row.skill.path), row.skill.path);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
if (checked.has(row.key))
|
|
95
|
+
checked.delete(row.key);
|
|
96
|
+
else
|
|
97
|
+
checked.set(row.key, row.path);
|
|
98
|
+
}
|
|
99
|
+
request();
|
|
100
|
+
}
|
|
101
|
+
function apply() {
|
|
102
|
+
const finish = (result) => {
|
|
103
|
+
if (result.ok) {
|
|
104
|
+
options.finish();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
report(result.message ?? "Skills were not applied.", true);
|
|
108
|
+
};
|
|
109
|
+
const result = options.apply([...checked.values()]);
|
|
110
|
+
if (result instanceof Promise)
|
|
111
|
+
void result.then(finish, error => report(String(error), true));
|
|
112
|
+
else
|
|
113
|
+
finish(result);
|
|
114
|
+
}
|
|
115
|
+
function startAdd() {
|
|
116
|
+
adding = true;
|
|
117
|
+
pathInput.setValue("");
|
|
118
|
+
pathInput.handleInput("\x05");
|
|
119
|
+
pathInput.focused = focused;
|
|
120
|
+
message = "";
|
|
121
|
+
error = false;
|
|
122
|
+
request();
|
|
123
|
+
}
|
|
124
|
+
function cancelAdd() {
|
|
125
|
+
adding = false;
|
|
126
|
+
pathInput.focused = false;
|
|
127
|
+
message = "Add path cancelled.";
|
|
128
|
+
error = false;
|
|
129
|
+
request();
|
|
130
|
+
}
|
|
131
|
+
function submitAdd(value) {
|
|
132
|
+
const path = value.trim();
|
|
133
|
+
if (!path) {
|
|
134
|
+
report("Enter an absolute path to a SKILL.md file or skill directory. Esc cancels.", true);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (!isAbsolute(path)) {
|
|
138
|
+
report("Enter an absolute path so every child resolves the same skill.", true);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (!existsSync(path)) {
|
|
142
|
+
report("No file or directory exists at that path.", true);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const key = pathKey(path);
|
|
146
|
+
if (checked.has(key)) {
|
|
147
|
+
report("That skill path is already selected.", true);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
checked.set(key, path);
|
|
151
|
+
extraPaths.set(key, path);
|
|
152
|
+
adding = false;
|
|
153
|
+
pathInput.focused = false;
|
|
154
|
+
message = "Skill path added. Press Enter to apply.";
|
|
155
|
+
error = false;
|
|
156
|
+
request();
|
|
157
|
+
}
|
|
158
|
+
pathInput.onSubmit = submitAdd;
|
|
159
|
+
pathInput.onEscape = cancelAdd;
|
|
160
|
+
return {
|
|
161
|
+
get focused() { return focused; },
|
|
162
|
+
set focused(value) {
|
|
163
|
+
focused = value;
|
|
164
|
+
search.focused = value && !adding;
|
|
165
|
+
pathInput.focused = value && adding;
|
|
166
|
+
},
|
|
167
|
+
invalidate() {
|
|
168
|
+
search.invalidate();
|
|
169
|
+
pathInput.invalidate();
|
|
170
|
+
},
|
|
171
|
+
handleInput(data) {
|
|
172
|
+
if (adding) {
|
|
173
|
+
if (Tui.matchesKey(data, Tui.Key.escape))
|
|
174
|
+
cancelAdd();
|
|
175
|
+
else {
|
|
176
|
+
pathInput.handleInput(data);
|
|
177
|
+
request();
|
|
178
|
+
}
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const entries = rows();
|
|
182
|
+
if (Tui.matchesKey(data, Tui.Key.escape)) {
|
|
183
|
+
options.cancel();
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (Tui.matchesKey(data, Tui.Key.up)) {
|
|
187
|
+
cursor = Math.max(0, Math.min(cursor, entries.length - 1) - 1);
|
|
188
|
+
request();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (Tui.matchesKey(data, Tui.Key.down)) {
|
|
192
|
+
cursor = Math.min(entries.length - 1, Math.min(cursor, entries.length - 1) + 1);
|
|
193
|
+
request();
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (Tui.matchesKey(data, Tui.Key.space)) {
|
|
197
|
+
toggle(current(entries));
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (Tui.matchesKey(data, Tui.Key.enter)) {
|
|
201
|
+
const row = current(entries);
|
|
202
|
+
if (row?.kind === "add")
|
|
203
|
+
startAdd();
|
|
204
|
+
else
|
|
205
|
+
apply();
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
search.handleInput(data);
|
|
209
|
+
cursor = 0;
|
|
210
|
+
scroll = 0;
|
|
211
|
+
request();
|
|
212
|
+
},
|
|
213
|
+
render(width) {
|
|
214
|
+
const w = Math.max(1, Math.floor(width));
|
|
215
|
+
const height = Math.max(1, Math.floor(options.getHeight?.() ?? process.stdout.rows ?? 30));
|
|
216
|
+
const title = options.title ?? "Select skills";
|
|
217
|
+
const entries = rows();
|
|
218
|
+
cursor = Math.max(0, Math.min(cursor, entries.length - 1));
|
|
219
|
+
const marker = (isSelected) => isSelected ? "> " : " ";
|
|
220
|
+
const highlight = (text, isSelected) => isSelected
|
|
221
|
+
? theme.bg("selectedBg", theme.bold?.(cell(text, w)) ?? cell(text, w))
|
|
222
|
+
: text;
|
|
223
|
+
const skillLines = (skill, ticked, isSelected) => {
|
|
224
|
+
const mark = marker(isSelected);
|
|
225
|
+
const box = `[${ticked ? "x" : " "}] `;
|
|
226
|
+
if (w >= 64) {
|
|
227
|
+
const nameWidth = Math.min(30, Math.max(12, Math.floor(w * 0.3)));
|
|
228
|
+
const text = `${mark}${box}${cell(skill.name, nameWidth)}${theme.fg("dim", skill.description)}`;
|
|
229
|
+
return [highlight(text, isSelected)];
|
|
230
|
+
}
|
|
231
|
+
return [
|
|
232
|
+
highlight(theme.fg(isSelected ? "accent" : "text", `${mark}${box}${skill.name}`), isSelected),
|
|
233
|
+
theme.fg("dim", ` ${skill.description}`),
|
|
234
|
+
];
|
|
235
|
+
};
|
|
236
|
+
const extraLines = (path, isSelected) => {
|
|
237
|
+
const mark = marker(isSelected);
|
|
238
|
+
return [
|
|
239
|
+
highlight(theme.fg(isSelected ? "accent" : "text", `${mark}[${checked.has(pathKey(path)) ? "x" : " "}] ${unavailableName(path)} (unavailable)`), isSelected),
|
|
240
|
+
theme.fg("dim", ` ${Tui.truncateToWidth(path, Math.max(1, w - 4), "")}`),
|
|
241
|
+
];
|
|
242
|
+
};
|
|
243
|
+
const header = [
|
|
244
|
+
theme.fg("accent", theme.bold?.(` ${title}`) ?? ` ${title}`),
|
|
245
|
+
theme.fg("dim", " Up/Down Move · Space Toggle · Enter Apply · Esc Cancel"),
|
|
246
|
+
];
|
|
247
|
+
if (adding) {
|
|
248
|
+
header.push("", theme.fg("text", " Add skill path"), theme.fg("dim", " Absolute SKILL.md or skill directory · Enter add · Esc cancel"));
|
|
249
|
+
header.push(" " + pathOrSearch(pathInput, Math.max(1, w - 2)));
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
const label = " Search ";
|
|
253
|
+
const searchWidth = Math.max(1, w - Tui.visibleWidth(label));
|
|
254
|
+
header.push("", label + pathOrSearch(search, searchWidth));
|
|
255
|
+
}
|
|
256
|
+
const body = [];
|
|
257
|
+
if (skills.length === 0) {
|
|
258
|
+
body.push(theme.fg("dim", " No loaded skills were reported; use Add skill path."));
|
|
259
|
+
}
|
|
260
|
+
if (entries.every((row) => row.kind === "apply" || row.kind === "add") && search.getValue().trim()) {
|
|
261
|
+
body.push(theme.fg("dim", " No skills match this filter."));
|
|
262
|
+
}
|
|
263
|
+
let selectedLine = 0;
|
|
264
|
+
const visibleChecked = new Set();
|
|
265
|
+
for (const [index, row] of entries.entries()) {
|
|
266
|
+
if (index === cursor)
|
|
267
|
+
selectedLine = body.length;
|
|
268
|
+
if (row.kind === "skill") {
|
|
269
|
+
const ticked = isChecked(row.skill);
|
|
270
|
+
if (ticked) {
|
|
271
|
+
for (const key of checkedKeysFor(row.skill))
|
|
272
|
+
visibleChecked.add(key);
|
|
273
|
+
}
|
|
274
|
+
body.push(...skillLines(row.skill, ticked, index === cursor));
|
|
275
|
+
}
|
|
276
|
+
else if (row.kind === "extra") {
|
|
277
|
+
if (checked.has(row.key))
|
|
278
|
+
visibleChecked.add(row.key);
|
|
279
|
+
body.push(...extraLines(row.path, index === cursor));
|
|
280
|
+
}
|
|
281
|
+
else if (row.kind === "apply") {
|
|
282
|
+
body.push(highlight(theme.fg(index === cursor ? "accent" : "text", marker(index === cursor) + `✓ Apply selection (${checked.size} checked)`), index === cursor));
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
body.push(highlight(theme.fg(index === cursor ? "accent" : "text", marker(index === cursor) + "+ Add skill path…"), index === cursor));
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const hiddenChecked = [...checked.keys()].filter((key) => !visibleChecked.has(key)).length;
|
|
289
|
+
const footer = [
|
|
290
|
+
theme.fg("dim", ` ${checked.size} checked${hiddenChecked ? ` · ${hiddenChecked} checked hidden by filter` : ""}`),
|
|
291
|
+
theme.fg("dim", " 0 checked applies No skill catalog, not discovery."),
|
|
292
|
+
];
|
|
293
|
+
if (message)
|
|
294
|
+
footer.unshift(theme.fg(error ? "error" : "muted", " " + message.replace(/[\r\n]+/g, " ")));
|
|
295
|
+
if (height < header.length + footer.length + 1) {
|
|
296
|
+
const active = adding ? [header[header.length - 1], ...(message ? [footer[0]] : [])]
|
|
297
|
+
: height === 1 ? [body[selectedLine]]
|
|
298
|
+
: [header[header.length - 1], body[selectedLine]];
|
|
299
|
+
return active.slice(0, height).map((line) => Tui.truncateToWidth(line, w, ""));
|
|
300
|
+
}
|
|
301
|
+
const room = Math.max(1, height - header.length - footer.length);
|
|
302
|
+
if (selectedLine < scroll)
|
|
303
|
+
scroll = selectedLine;
|
|
304
|
+
if (selectedLine >= scroll + room)
|
|
305
|
+
scroll = selectedLine - room + 1;
|
|
306
|
+
scroll = Math.max(0, Math.min(scroll, Math.max(0, body.length - room)));
|
|
307
|
+
const lines = [...header, ...body.slice(scroll, scroll + room), ...footer];
|
|
308
|
+
if (height < lines.length)
|
|
309
|
+
lines.splice(0, Math.max(0, lines.length - height));
|
|
310
|
+
return lines.map((line) => Tui.truncateToWidth(line, w, ""));
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
function pathOrSearch(input, width) {
|
|
314
|
+
return input.render(width)[0] ?? "";
|
|
315
|
+
}
|
|
316
|
+
}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared searchable skill checkbox picker.
|
|
3
|
+
*
|
|
4
|
+
* Both selected-skill entry points use this component: `/subagents settings`
|
|
5
|
+
* for the global default and `/agents` for a role or named agent. It only
|
|
6
|
+
* renders metadata and returns paths; it never loads a model or writes files.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync } from "node:fs";
|
|
9
|
+
import { basename, dirname, isAbsolute, resolve } from "node:path";
|
|
10
|
+
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
11
|
+
import * as Tui from "@earendil-works/pi-tui";
|
|
12
|
+
|
|
13
|
+
/** Metadata Pi already loaded for the current session. */
|
|
14
|
+
export interface DiscoveredSkill {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
/** Absolute path to SKILL.md. */
|
|
18
|
+
path: string;
|
|
19
|
+
/** Skill directory, when Pi reports one. */
|
|
20
|
+
baseDir?: string;
|
|
21
|
+
/** Resource source, such as a package or user directory. */
|
|
22
|
+
source?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface SkillPickerApplyResult {
|
|
26
|
+
ok: boolean;
|
|
27
|
+
message?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface SkillPickerOptions {
|
|
31
|
+
theme: Theme;
|
|
32
|
+
skills: readonly DiscoveredSkill[];
|
|
33
|
+
selected: readonly string[];
|
|
34
|
+
requestRender: () => void;
|
|
35
|
+
/** Caller applies the draft. A failed apply keeps the picker and checked items. */
|
|
36
|
+
apply(paths: string[]): SkillPickerApplyResult | Promise<SkillPickerApplyResult>;
|
|
37
|
+
finish(): void;
|
|
38
|
+
cancel(): void;
|
|
39
|
+
getHeight?: () => number;
|
|
40
|
+
title?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type Row =
|
|
44
|
+
| { kind: "skill"; skill: DiscoveredSkill; key: string }
|
|
45
|
+
| { kind: "extra"; path: string; key: string }
|
|
46
|
+
| { kind: "apply" }
|
|
47
|
+
| { kind: "add" };
|
|
48
|
+
|
|
49
|
+
function pathKey(path: string): string {
|
|
50
|
+
try { return resolve(path); }
|
|
51
|
+
catch { return path; }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function skillKeys(skill: DiscoveredSkill): string[] {
|
|
55
|
+
return [pathKey(skill.path), ...(skill.baseDir ? [pathKey(skill.baseDir)] : [])];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function unavailableName(path: string): string {
|
|
59
|
+
const parent = basename(dirname(path));
|
|
60
|
+
return parent || basename(path);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function errorText(error: unknown): string {
|
|
64
|
+
return error instanceof Error ? error.message : String(error);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function cell(text: string, width: number): string {
|
|
68
|
+
const clipped = Tui.truncateToWidth(text, width, "");
|
|
69
|
+
return clipped + " ".repeat(Math.max(0, width - Tui.visibleWidth(clipped)));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function createSkillPicker(options: SkillPickerOptions): Tui.Component & Tui.Focusable {
|
|
73
|
+
const { theme } = options;
|
|
74
|
+
const search = new Tui.Input();
|
|
75
|
+
const pathInput = new Tui.Input();
|
|
76
|
+
let focused = false;
|
|
77
|
+
let cursor = 0;
|
|
78
|
+
let adding = false;
|
|
79
|
+
let message = "";
|
|
80
|
+
let error = false;
|
|
81
|
+
let scroll = 0;
|
|
82
|
+
|
|
83
|
+
const checked = new Map<string, string>();
|
|
84
|
+
for (const path of options.selected) checked.set(pathKey(path), path);
|
|
85
|
+
// Keep saved/manual rows available even after they are unchecked.
|
|
86
|
+
const extraPaths = new Map(checked);
|
|
87
|
+
|
|
88
|
+
const skills = [...options.skills].sort((left, right) =>
|
|
89
|
+
left.name.localeCompare(right.name) || left.path.localeCompare(right.path));
|
|
90
|
+
|
|
91
|
+
function request(): void {
|
|
92
|
+
options.requestRender();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function checkedKeysFor(skill: DiscoveredSkill): string[] {
|
|
96
|
+
const keys = new Set(skillKeys(skill));
|
|
97
|
+
return [...checked.keys()].filter((key) => keys.has(key));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function isChecked(skill: DiscoveredSkill): boolean {
|
|
101
|
+
return checkedKeysFor(skill).length > 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function matches(value: string, query: string): boolean {
|
|
105
|
+
return value.toLowerCase().includes(query);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function rows(): Row[] {
|
|
109
|
+
const query = search.getValue().trim().toLowerCase();
|
|
110
|
+
const available = skills
|
|
111
|
+
.filter((skill) => !query || matches(skill.name, query) || matches(skill.description, query) || matches(skill.path, query))
|
|
112
|
+
.map((skill): Row => ({ kind: "skill", skill, key: skillKeys(skill)[0]! }));
|
|
113
|
+
const known = new Set(skills.flatMap(skillKeys));
|
|
114
|
+
const extras = [...extraPaths.entries()]
|
|
115
|
+
.filter(([key, path]) => !known.has(key)
|
|
116
|
+
&& (!query || matches(path, query) || matches(unavailableName(path), query)))
|
|
117
|
+
.map(([key, path]): Row => ({ kind: "extra", path, key }));
|
|
118
|
+
return [...available, ...extras, { kind: "apply" }, { kind: "add" }];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function current(entries = rows()): Row | undefined {
|
|
122
|
+
return entries[Math.min(cursor, entries.length - 1)];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function report(text: string, failed = false): void {
|
|
126
|
+
message = text;
|
|
127
|
+
error = failed;
|
|
128
|
+
request();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function toggle(row: Row | undefined): void {
|
|
132
|
+
if (!row || row.kind === "apply" || row.kind === "add") return;
|
|
133
|
+
if (row.kind === "skill") {
|
|
134
|
+
const keys = checkedKeysFor(row.skill);
|
|
135
|
+
if (keys.length > 0) keys.forEach((key) => checked.delete(key));
|
|
136
|
+
else checked.set(pathKey(row.skill.path), row.skill.path);
|
|
137
|
+
} else {
|
|
138
|
+
if (checked.has(row.key)) checked.delete(row.key);
|
|
139
|
+
else checked.set(row.key, row.path);
|
|
140
|
+
}
|
|
141
|
+
request();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function apply(): void {
|
|
145
|
+
const finish = (result: SkillPickerApplyResult) => {
|
|
146
|
+
if (result.ok) {
|
|
147
|
+
options.finish();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
report(result.message ?? "Skills were not applied.", true);
|
|
151
|
+
};
|
|
152
|
+
const result = options.apply([...checked.values()]);
|
|
153
|
+
if (result instanceof Promise) void result.then(finish, error => report(String(error), true));
|
|
154
|
+
else finish(result);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function startAdd(): void {
|
|
158
|
+
adding = true;
|
|
159
|
+
pathInput.setValue("");
|
|
160
|
+
pathInput.handleInput("\x05");
|
|
161
|
+
pathInput.focused = focused;
|
|
162
|
+
message = "";
|
|
163
|
+
error = false;
|
|
164
|
+
request();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function cancelAdd(): void {
|
|
168
|
+
adding = false;
|
|
169
|
+
pathInput.focused = false;
|
|
170
|
+
message = "Add path cancelled.";
|
|
171
|
+
error = false;
|
|
172
|
+
request();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function submitAdd(value: string): void {
|
|
176
|
+
const path = value.trim();
|
|
177
|
+
if (!path) {
|
|
178
|
+
report("Enter an absolute path to a SKILL.md file or skill directory. Esc cancels.", true);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (!isAbsolute(path)) {
|
|
182
|
+
report("Enter an absolute path so every child resolves the same skill.", true);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (!existsSync(path)) {
|
|
186
|
+
report("No file or directory exists at that path.", true);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const key = pathKey(path);
|
|
190
|
+
if (checked.has(key)) {
|
|
191
|
+
report("That skill path is already selected.", true);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
checked.set(key, path);
|
|
195
|
+
extraPaths.set(key, path);
|
|
196
|
+
adding = false;
|
|
197
|
+
pathInput.focused = false;
|
|
198
|
+
message = "Skill path added. Press Enter to apply.";
|
|
199
|
+
error = false;
|
|
200
|
+
request();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
pathInput.onSubmit = submitAdd;
|
|
204
|
+
pathInput.onEscape = cancelAdd;
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
get focused() { return focused; },
|
|
208
|
+
set focused(value: boolean) {
|
|
209
|
+
focused = value;
|
|
210
|
+
search.focused = value && !adding;
|
|
211
|
+
pathInput.focused = value && adding;
|
|
212
|
+
},
|
|
213
|
+
invalidate() {
|
|
214
|
+
search.invalidate();
|
|
215
|
+
pathInput.invalidate();
|
|
216
|
+
},
|
|
217
|
+
handleInput(data: string) {
|
|
218
|
+
if (adding) {
|
|
219
|
+
if (Tui.matchesKey(data, Tui.Key.escape)) cancelAdd();
|
|
220
|
+
else {
|
|
221
|
+
pathInput.handleInput(data);
|
|
222
|
+
request();
|
|
223
|
+
}
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const entries = rows();
|
|
227
|
+
if (Tui.matchesKey(data, Tui.Key.escape)) {
|
|
228
|
+
options.cancel();
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (Tui.matchesKey(data, Tui.Key.up)) {
|
|
232
|
+
cursor = Math.max(0, Math.min(cursor, entries.length - 1) - 1);
|
|
233
|
+
request();
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (Tui.matchesKey(data, Tui.Key.down)) {
|
|
237
|
+
cursor = Math.min(entries.length - 1, Math.min(cursor, entries.length - 1) + 1);
|
|
238
|
+
request();
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (Tui.matchesKey(data, Tui.Key.space)) {
|
|
242
|
+
toggle(current(entries));
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (Tui.matchesKey(data, Tui.Key.enter)) {
|
|
246
|
+
const row = current(entries);
|
|
247
|
+
if (row?.kind === "add") startAdd();
|
|
248
|
+
else apply();
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
search.handleInput(data);
|
|
252
|
+
cursor = 0;
|
|
253
|
+
scroll = 0;
|
|
254
|
+
request();
|
|
255
|
+
},
|
|
256
|
+
render(width: number) {
|
|
257
|
+
const w = Math.max(1, Math.floor(width));
|
|
258
|
+
const height = Math.max(1, Math.floor(options.getHeight?.() ?? process.stdout.rows ?? 30));
|
|
259
|
+
const title = options.title ?? "Select skills";
|
|
260
|
+
const entries = rows();
|
|
261
|
+
cursor = Math.max(0, Math.min(cursor, entries.length - 1));
|
|
262
|
+
const marker = (isSelected: boolean) => isSelected ? "> " : " ";
|
|
263
|
+
const highlight = (text: string, isSelected: boolean): string => isSelected
|
|
264
|
+
? theme.bg("selectedBg", theme.bold?.(cell(text, w)) ?? cell(text, w))
|
|
265
|
+
: text;
|
|
266
|
+
const skillLines = (skill: DiscoveredSkill, ticked: boolean, isSelected: boolean): string[] => {
|
|
267
|
+
const mark = marker(isSelected);
|
|
268
|
+
const box = `[${ticked ? "x" : " "}] `;
|
|
269
|
+
if (w >= 64) {
|
|
270
|
+
const nameWidth = Math.min(30, Math.max(12, Math.floor(w * 0.3)));
|
|
271
|
+
const text = `${mark}${box}${cell(skill.name, nameWidth)}${theme.fg("dim", skill.description)}`;
|
|
272
|
+
return [highlight(text, isSelected)];
|
|
273
|
+
}
|
|
274
|
+
return [
|
|
275
|
+
highlight(theme.fg(isSelected ? "accent" : "text", `${mark}${box}${skill.name}`), isSelected),
|
|
276
|
+
theme.fg("dim", ` ${skill.description}`),
|
|
277
|
+
];
|
|
278
|
+
};
|
|
279
|
+
const extraLines = (path: string, isSelected: boolean): string[] => {
|
|
280
|
+
const mark = marker(isSelected);
|
|
281
|
+
return [
|
|
282
|
+
highlight(theme.fg(isSelected ? "accent" : "text", `${mark}[${checked.has(pathKey(path)) ? "x" : " "}] ${unavailableName(path)} (unavailable)`), isSelected),
|
|
283
|
+
theme.fg("dim", ` ${Tui.truncateToWidth(path, Math.max(1, w - 4), "")}`),
|
|
284
|
+
];
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const header: string[] = [
|
|
288
|
+
theme.fg("accent", theme.bold?.(` ${title}`) ?? ` ${title}`),
|
|
289
|
+
theme.fg("dim", " Up/Down Move · Space Toggle · Enter Apply · Esc Cancel"),
|
|
290
|
+
];
|
|
291
|
+
if (adding) {
|
|
292
|
+
header.push("", theme.fg("text", " Add skill path"), theme.fg("dim", " Absolute SKILL.md or skill directory · Enter add · Esc cancel"));
|
|
293
|
+
header.push(" " + pathOrSearch(pathInput, Math.max(1, w - 2)));
|
|
294
|
+
} else {
|
|
295
|
+
const label = " Search ";
|
|
296
|
+
const searchWidth = Math.max(1, w - Tui.visibleWidth(label));
|
|
297
|
+
header.push("", label + pathOrSearch(search, searchWidth));
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const body: string[] = [];
|
|
301
|
+
if (skills.length === 0) {
|
|
302
|
+
body.push(theme.fg("dim", " No loaded skills were reported; use Add skill path."));
|
|
303
|
+
}
|
|
304
|
+
if (entries.every((row) => row.kind === "apply" || row.kind === "add") && search.getValue().trim()) {
|
|
305
|
+
body.push(theme.fg("dim", " No skills match this filter."));
|
|
306
|
+
}
|
|
307
|
+
let selectedLine = 0;
|
|
308
|
+
const visibleChecked = new Set<string>();
|
|
309
|
+
for (const [index, row] of entries.entries()) {
|
|
310
|
+
if (index === cursor) selectedLine = body.length;
|
|
311
|
+
if (row.kind === "skill") {
|
|
312
|
+
const ticked = isChecked(row.skill);
|
|
313
|
+
if (ticked) {
|
|
314
|
+
for (const key of checkedKeysFor(row.skill)) visibleChecked.add(key);
|
|
315
|
+
}
|
|
316
|
+
body.push(...skillLines(row.skill, ticked, index === cursor));
|
|
317
|
+
} else if (row.kind === "extra") {
|
|
318
|
+
if (checked.has(row.key)) visibleChecked.add(row.key);
|
|
319
|
+
body.push(...extraLines(row.path, index === cursor));
|
|
320
|
+
} else if (row.kind === "apply") {
|
|
321
|
+
body.push(highlight(theme.fg(index === cursor ? "accent" : "text", marker(index === cursor) + `✓ Apply selection (${checked.size} checked)`), index === cursor));
|
|
322
|
+
} else {
|
|
323
|
+
body.push(highlight(theme.fg(index === cursor ? "accent" : "text", marker(index === cursor) + "+ Add skill path…"), index === cursor));
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
const hiddenChecked = [...checked.keys()].filter((key) => !visibleChecked.has(key)).length;
|
|
327
|
+
const footer = [
|
|
328
|
+
theme.fg("dim", ` ${checked.size} checked${hiddenChecked ? ` · ${hiddenChecked} checked hidden by filter` : ""}`),
|
|
329
|
+
theme.fg("dim", " 0 checked applies No skill catalog, not discovery."),
|
|
330
|
+
];
|
|
331
|
+
if (message) footer.unshift(theme.fg(error ? "error" : "muted", " " + message.replace(/[\r\n]+/g, " ")));
|
|
332
|
+
if (height < header.length + footer.length + 1) {
|
|
333
|
+
const active = adding ? [header[header.length - 1]!, ...(message ? [footer[0]!] : [])]
|
|
334
|
+
: height === 1 ? [body[selectedLine]!]
|
|
335
|
+
: [header[header.length - 1]!, body[selectedLine]!];
|
|
336
|
+
return active.slice(0, height).map((line) => Tui.truncateToWidth(line, w, ""));
|
|
337
|
+
}
|
|
338
|
+
const room = Math.max(1, height - header.length - footer.length);
|
|
339
|
+
if (selectedLine < scroll) scroll = selectedLine;
|
|
340
|
+
if (selectedLine >= scroll + room) scroll = selectedLine - room + 1;
|
|
341
|
+
scroll = Math.max(0, Math.min(scroll, Math.max(0, body.length - room)));
|
|
342
|
+
const lines = [...header, ...body.slice(scroll, scroll + room), ...footer];
|
|
343
|
+
if (height < lines.length) lines.splice(0, Math.max(0, lines.length - height));
|
|
344
|
+
return lines.map((line) => Tui.truncateToWidth(line, w, ""));
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
function pathOrSearch(input: Tui.Input, width: number): string {
|
|
349
|
+
return input.render(width)[0] ?? "";
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
}
|