@selesai/code 0.12.0 → 0.13.1
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 +17 -0
- package/dist/core/agent-session.d.ts +1 -1
- package/dist/core/agent-session.js +1 -1
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.js +1 -1
- package/dist/core/system-prompt.d.ts +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/usage-totals.d.ts +2 -0
- package/dist/core/usage-totals.js +10 -0
- package/dist/extensions/ascii.txt +9 -0
- package/dist/extensions/package.json +1 -2
- package/dist/extensions/pi-hermes-memory/CHANGELOG.md +371 -0
- package/dist/extensions/pi-hermes-memory/LICENSE +21 -0
- package/dist/extensions/pi-hermes-memory/README.md +643 -0
- package/dist/extensions/pi-hermes-memory/docs/0.1/TASKS.md +197 -0
- package/dist/extensions/pi-hermes-memory/docs/0.2/PLAN.md +290 -0
- package/dist/extensions/pi-hermes-memory/docs/0.2/TASKS.md +134 -0
- package/dist/extensions/pi-hermes-memory/docs/0.2/TEST-PLAN.md +216 -0
- package/dist/extensions/pi-hermes-memory/docs/0.3/PLAN.md +330 -0
- package/dist/extensions/pi-hermes-memory/docs/0.3/TASKS.md +125 -0
- package/dist/extensions/pi-hermes-memory/docs/0.4/PLAN.md +160 -0
- package/dist/extensions/pi-hermes-memory/docs/0.4/TASKS.md +113 -0
- package/dist/extensions/pi-hermes-memory/docs/0.6/CHANGELOG.md +57 -0
- package/dist/extensions/pi-hermes-memory/docs/0.6/PLAN.md +202 -0
- package/dist/extensions/pi-hermes-memory/docs/0.6/TASKS.md +144 -0
- package/dist/extensions/pi-hermes-memory/docs/0.7/PLAN.md +349 -0
- package/dist/extensions/pi-hermes-memory/docs/0.7/TASKS.md +110 -0
- package/dist/extensions/pi-hermes-memory/docs/PUBLISHING.md +149 -0
- package/dist/extensions/pi-hermes-memory/docs/ROADMAP.md +468 -0
- package/dist/extensions/pi-hermes-memory/docs/images/memory-architecture.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/images/pi-logo.svg +22 -0
- package/dist/extensions/pi-hermes-memory/docs/images/pi_memory.png +0 -0
- package/dist/extensions/pi-hermes-memory/docs/images/pi_memory.svg +19 -0
- package/dist/extensions/pi-hermes-memory/docs/images/security-flow.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/images/session-lifecycle.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/images/source-architecture.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/memory-architecture.mmd +49 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/security-flow.mmd +40 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/session-lifecycle.mmd +56 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/source-architecture.mmd +54 -0
- package/dist/extensions/pi-hermes-memory/package-lock.json +3799 -0
- package/dist/extensions/pi-hermes-memory/package.json +66 -0
- package/dist/extensions/pi-hermes-memory/scripts/check-min-sdk.mjs +99 -0
- package/dist/extensions/pi-hermes-memory/scripts/ensure-dev.mjs +57 -0
- package/dist/extensions/pi-hermes-memory/src/auto-consolidation-warning.ts +6 -0
- package/dist/extensions/pi-hermes-memory/src/config.ts +178 -0
- package/dist/extensions/pi-hermes-memory/src/constants.ts +424 -0
- package/dist/extensions/pi-hermes-memory/src/extension-root-migration.ts +639 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/auto-consolidate.ts +401 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/background-review.ts +297 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/child-process-watchdog.mjs +90 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/correction-detector.ts +300 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/index-sessions.ts +86 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/insights.ts +78 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/interview.ts +37 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/learn-memory.ts +186 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/message-parts.ts +27 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/pi-child-process.ts +485 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/preview-context.ts +105 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/review-memory-ops.ts +506 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/session-backfill.ts +145 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/session-flush.ts +151 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/session-live-index.ts +94 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/skills-command.ts +1334 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/standing-pin.ts +111 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/switch-project.ts +75 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/sync-markdown-memories.ts +266 -0
- package/dist/extensions/pi-hermes-memory/src/index.ts +378 -0
- package/dist/extensions/pi-hermes-memory/src/lifecycle-timing.ts +54 -0
- package/dist/extensions/pi-hermes-memory/src/paths.ts +61 -0
- package/dist/extensions/pi-hermes-memory/src/project-context.ts +13 -0
- package/dist/extensions/pi-hermes-memory/src/project-memory-migration.ts +93 -0
- package/dist/extensions/pi-hermes-memory/src/project.ts +157 -0
- package/dist/extensions/pi-hermes-memory/src/prompt-context.ts +55 -0
- package/dist/extensions/pi-hermes-memory/src/store/atomic-lock-coordinator.ts +375 -0
- package/dist/extensions/pi-hermes-memory/src/store/canonical-storage-path.ts +54 -0
- package/dist/extensions/pi-hermes-memory/src/store/content-scanner.ts +101 -0
- package/dist/extensions/pi-hermes-memory/src/store/db.ts +1180 -0
- package/dist/extensions/pi-hermes-memory/src/store/fts-query.ts +101 -0
- package/dist/extensions/pi-hermes-memory/src/store/markdown-mutation-lock.ts +38 -0
- package/dist/extensions/pi-hermes-memory/src/store/memory-lookup.ts +24 -0
- package/dist/extensions/pi-hermes-memory/src/store/memory-store.ts +1191 -0
- package/dist/extensions/pi-hermes-memory/src/store/recovery-maintenance.ts +66 -0
- package/dist/extensions/pi-hermes-memory/src/store/schema.ts +118 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-anchor-search.ts +472 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-indexer.ts +511 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-parser.ts +213 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-search.ts +234 -0
- package/dist/extensions/pi-hermes-memory/src/store/skill-store.ts +950 -0
- package/dist/extensions/pi-hermes-memory/src/store/skill-utils.ts +133 -0
- package/dist/extensions/pi-hermes-memory/src/store/sqlite-memory-store.ts +1002 -0
- package/dist/extensions/pi-hermes-memory/src/store/sqlite-native.ts +241 -0
- package/dist/extensions/pi-hermes-memory/src/store/standing-instructions.ts +247 -0
- package/dist/extensions/pi-hermes-memory/src/tools/memory-search-tool.ts +95 -0
- package/dist/extensions/pi-hermes-memory/src/tools/memory-tool.ts +469 -0
- package/dist/extensions/pi-hermes-memory/src/tools/session-search-tool.ts +246 -0
- package/dist/extensions/pi-hermes-memory/src/tools/shared-output-view.ts +170 -0
- package/dist/extensions/pi-hermes-memory/src/tools/skill-tool.ts +333 -0
- package/dist/extensions/pi-hermes-memory/src/tools/tool-result-views.ts +105 -0
- package/dist/extensions/pi-hermes-memory/src/types.ts +214 -0
- package/dist/extensions/pi-hermes-memory/tests/config.test.ts +434 -0
- package/dist/extensions/pi-hermes-memory/tests/extension-root-migration.test.ts +368 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/auto-consolidate.test.ts +984 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/background-review.test.ts +950 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/correction-detector.test.ts +671 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/insights.test.ts +157 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/interview.test.ts +127 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/pi-child-process.test.ts +905 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/preview-context.test.ts +152 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/prompt-context.test.ts +166 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/resources-discover.test.ts +71 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/review-memory-ops.test.ts +614 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-backfill.test.ts +192 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-flush.test.ts +677 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-live-index.test.ts +225 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/skills-command.test.ts +827 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/standing-pin.test.ts +134 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/sync-markdown-memories.test.ts +491 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/system-prompt.test.ts +199 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/thinking-max.test.ts +64 -0
- package/dist/extensions/pi-hermes-memory/tests/index.test.ts +30 -0
- package/dist/extensions/pi-hermes-memory/tests/integration/flow.test.ts +126 -0
- package/dist/extensions/pi-hermes-memory/tests/lifecycle-timing.test.ts +76 -0
- package/dist/extensions/pi-hermes-memory/tests/paths.test.ts +23 -0
- package/dist/extensions/pi-hermes-memory/tests/project-memory-migration.test.ts +80 -0
- package/dist/extensions/pi-hermes-memory/tests/project-rebinding.test.ts +115 -0
- package/dist/extensions/pi-hermes-memory/tests/project.test.ts +120 -0
- package/dist/extensions/pi-hermes-memory/tests/run-all-timeout.test.ts +107 -0
- package/dist/extensions/pi-hermes-memory/tests/run-all.sh +45 -0
- package/dist/extensions/pi-hermes-memory/tests/store/atomic-lock-coordinator.test.ts +381 -0
- package/dist/extensions/pi-hermes-memory/tests/store/content-scanner.test.ts +388 -0
- package/dist/extensions/pi-hermes-memory/tests/store/db.test.ts +1046 -0
- package/dist/extensions/pi-hermes-memory/tests/store/markdown-mutation-lock.test.ts +34 -0
- package/dist/extensions/pi-hermes-memory/tests/store/memory-store.test.ts +2150 -0
- package/dist/extensions/pi-hermes-memory/tests/store/recovery-maintenance.test.ts +170 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-anchor-search.test.ts +210 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-indexer.test.ts +643 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-parser.test.ts +282 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-search.test.ts +287 -0
- package/dist/extensions/pi-hermes-memory/tests/store/skill-store.test.ts +678 -0
- package/dist/extensions/pi-hermes-memory/tests/store/skill-utils.test.ts +21 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-lazy-load.test.ts +78 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-memory-store.test.ts +543 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-native.test.ts +164 -0
- package/dist/extensions/pi-hermes-memory/tests/store/standing-instructions.test.ts +171 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-search-tool.test.ts +84 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-tool.test.ts +709 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/session-search-tool.test.ts +345 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/shared-output-view.test.ts +362 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/skill-tool.test.ts +478 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/tool-result-renderer-wiring.test.ts +40 -0
- package/dist/extensions/pi-hermes-memory/tsconfig.json +19 -0
- package/dist/extensions/pi-subagents/.oxlintrc.json +43 -0
- package/dist/extensions/pi-subagents/AGENTS.md +5 -0
- package/dist/extensions/pi-subagents/CHANGELOG.md +157 -0
- package/dist/extensions/pi-subagents/README.md +12 -6
- package/dist/extensions/pi-subagents/VISION.md +81 -0
- package/dist/extensions/pi-subagents/agents/claude-code-writer.md +15 -0
- package/dist/extensions/pi-subagents/agents/claude-code.md +15 -0
- package/dist/extensions/pi-subagents/agents/codex-exec-writer.md +15 -0
- package/dist/extensions/pi-subagents/agents/codex-exec.md +15 -0
- package/dist/extensions/pi-subagents/agents/cursor-agent-writer.md +14 -0
- package/dist/extensions/pi-subagents/agents/cursor-agent.md +14 -0
- package/dist/extensions/pi-subagents/agents/reviewer.md +1 -3
- package/dist/extensions/pi-subagents/docs/agents.md +488 -0
- package/dist/extensions/pi-subagents/docs/configuration.md +46 -9
- package/dist/extensions/pi-subagents/docs/extension-api.md +42 -3
- package/dist/extensions/pi-subagents/docs/models.md +27 -4
- package/dist/extensions/pi-subagents/docs/observability.md +10 -9
- package/dist/extensions/pi-subagents/docs/tool-reference.md +102 -6
- package/dist/extensions/pi-subagents/docs/workflows.md +135 -0
- package/dist/extensions/pi-subagents/package-lock.json +389 -2
- package/dist/extensions/pi-subagents/package.json +3 -1
- package/dist/extensions/pi-subagents/prompts/review-loop.md +2 -2
- package/dist/extensions/pi-subagents/skills/council-mode/SKILL.md +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +3 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +7 -3
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +2 -2
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +26 -5
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +41 -22
- package/dist/extensions/pi-subagents/src/agents/agent-refinements.ts +4 -4
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +9 -2
- package/dist/extensions/pi-subagents/src/agents/agents.ts +322 -75
- package/dist/extensions/pi-subagents/src/agents/builtin-names.ts +6 -0
- package/dist/extensions/pi-subagents/src/agents/runtime-agent-events.ts +70 -0
- package/dist/extensions/pi-subagents/src/agents/runtime-agent-registry.ts +27 -20
- package/dist/extensions/pi-subagents/src/api/agents.ts +10 -5
- package/dist/extensions/pi-subagents/src/api/background-work.ts +5 -1
- package/dist/extensions/pi-subagents/src/api/delegation.ts +0 -7
- package/dist/extensions/pi-subagents/src/api/preflight.ts +34 -12
- package/dist/extensions/pi-subagents/src/extension/config.ts +70 -0
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +3 -3
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +5 -3
- package/dist/extensions/pi-subagents/src/extension/index.ts +83 -30
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +44 -15
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +55 -19
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +41 -15
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +28 -31
- package/dist/extensions/pi-subagents/src/inspectors/herdr/actions.ts +2 -1
- package/dist/extensions/pi-subagents/src/inspectors/herdr/inspector-runner.ts +2 -10
- package/dist/extensions/pi-subagents/src/inspectors/herdr/session-roots-codec.ts +42 -0
- package/dist/extensions/pi-subagents/src/integrations/herdr-status.ts +51 -3
- package/dist/extensions/pi-subagents/src/intercom/result-intercom.ts +2 -0
- package/dist/extensions/pi-subagents/src/profiles/profiles.ts +5 -6
- package/dist/extensions/pi-subagents/src/runs/background/active-async-capacity.ts +77 -10
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +176 -53
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +19 -12
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +29 -27
- package/dist/extensions/pi-subagents/src/runs/background/async-retention.ts +20 -3
- package/dist/extensions/pi-subagents/src/runs/background/async-status-snapshot.ts +23 -261
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +73 -7
- package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +8 -3
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +74 -8
- package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +37 -21
- package/dist/extensions/pi-subagents/src/runs/background/inspect-rpc.ts +8 -8
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +184 -9
- package/dist/extensions/pi-subagents/src/runs/background/result-delivery-ownership.ts +45 -0
- package/dist/extensions/pi-subagents/src/runs/background/result-files.ts +28 -14
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +38 -15
- package/dist/extensions/pi-subagents/src/runs/background/resume-guidance.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/background/retained-children.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +50 -13
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +93 -8
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +10 -4
- package/dist/extensions/pi-subagents/src/runs/background/steering.ts +4 -14
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +549 -377
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +58 -10
- package/dist/extensions/pi-subagents/src/runs/background/terminal-run-index.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/background/wait-completions.ts +26 -1
- package/dist/extensions/pi-subagents/src/runs/background/wait-config.ts +23 -9
- package/dist/extensions/pi-subagents/src/runs/background/wait-tool.ts +9 -2
- package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +2 -2
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +204 -129
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +9 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +23 -1
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +773 -311
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-detach-reconcile.ts +140 -115
- package/dist/extensions/pi-subagents/src/runs/shared/abort-recovery.ts +119 -0
- package/dist/extensions/pi-subagents/src/runs/shared/async-status-projection.ts +463 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-identity.ts +19 -4
- package/dist/extensions/pi-subagents/src/runs/shared/child-launch-plan.ts +151 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-protocol.ts +21 -7
- package/dist/extensions/pi-subagents/src/runs/shared/claude-code-adapter.ts +129 -0
- package/dist/extensions/pi-subagents/src/runs/shared/codex-exec-adapter.ts +129 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-evidence.ts +89 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +5 -4
- package/dist/extensions/pi-subagents/src/runs/shared/cursor-agent-adapter.ts +114 -0
- package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +3 -3
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-contract.ts +167 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-preflight.ts +122 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-runner.ts +348 -55
- package/dist/extensions/pi-subagents/src/runs/shared/fast-mode-extension.ts +5 -5
- package/dist/extensions/pi-subagents/src/runs/shared/host-step-status.ts +230 -0
- package/dist/extensions/pi-subagents/src/runs/shared/lane-metadata.ts +105 -0
- package/dist/extensions/pi-subagents/src/runs/shared/launch-cwd.ts +16 -0
- package/dist/extensions/pi-subagents/src/runs/shared/long-running-guard.ts +2 -1
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-config-sources.ts +422 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +221 -158
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-grant.ts +197 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-exclusions.ts +69 -7
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +47 -6
- package/dist/extensions/pi-subagents/src/runs/shared/mutation-evidence.ts +7 -2
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +9 -3
- package/dist/extensions/pi-subagents/src/runs/shared/nested-render.ts +9 -5
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +419 -7
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +15 -1
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +81 -8
- package/dist/extensions/pi-subagents/src/runs/shared/process-signal.ts +13 -0
- package/dist/extensions/pi-subagents/src/runs/shared/run-history.ts +21 -1
- package/dist/extensions/pi-subagents/src/runs/shared/single-output.ts +44 -4
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +98 -13
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-startup-retry.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/worktree-cleanup-plan.ts +847 -0
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +18 -0
- package/dist/extensions/pi-subagents/src/shared/child-session-name.ts +46 -0
- package/dist/extensions/pi-subagents/src/shared/extension-context.ts +24 -0
- package/dist/extensions/pi-subagents/src/shared/fork-context.ts +21 -0
- package/dist/extensions/pi-subagents/src/shared/formatters.ts +18 -3
- package/dist/extensions/pi-subagents/src/shared/launch-contract.ts +5 -1
- package/dist/extensions/pi-subagents/src/shared/pruned-fork.ts +450 -0
- package/dist/extensions/pi-subagents/src/shared/session-file-trust.ts +19 -0
- package/dist/extensions/pi-subagents/src/shared/session-tokens.ts +14 -3
- package/dist/extensions/pi-subagents/src/shared/settings.ts +19 -105
- package/dist/extensions/pi-subagents/src/shared/shortcuts.ts +17 -0
- package/dist/extensions/pi-subagents/src/shared/types.ts +359 -40
- package/dist/extensions/pi-subagents/src/shared/utils.ts +41 -84
- package/dist/extensions/pi-subagents/src/shared/workflow-child-permit.ts +116 -0
- package/dist/extensions/pi-subagents/src/slash/delegation-adapters.ts +1 -9
- package/dist/extensions/pi-subagents/src/slash/delegation-request.ts +0 -4
- package/dist/extensions/pi-subagents/src/slash/slash-bridge.ts +1 -2
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +378 -88
- package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +22 -11
- package/dist/extensions/pi-subagents/src/slash/subagents-admin.ts +3 -0
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +147 -79
- package/dist/extensions/pi-subagents/src/tui/fleet-transcript.ts +11 -5
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +39 -18
- package/dist/extensions/pi-subagents/src/tui/render.ts +369 -46
- package/dist/extensions/pi-subagents/src/watchdog/turn-delta.ts +1 -1
- package/dist/extensions/pi-subagents/src/workflows/chat-progress.ts +6 -3
- package/dist/extensions/pi-subagents/src/workflows/host-command.ts +230 -0
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +740 -58
- package/dist/extensions/pi-subagents/src/workflows/workflow-child-summary.ts +121 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-preflight.ts +270 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-receipt.ts +195 -6
- package/dist/extensions/pi-subagents/src/workflows/workflow-settlement.ts +246 -0
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +1114 -260
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +150 -3
- package/dist/extensions/pi-subagents/test/integration/claude-code-smoke.test.ts +52 -0
- package/dist/extensions/pi-subagents/test/integration/claude-code-writer-smoke.test.ts +55 -0
- package/dist/extensions/pi-subagents/test/integration/codex-exec-smoke.test.ts +53 -0
- package/dist/extensions/pi-subagents/test/integration/codex-exec-writer-smoke.test.ts +57 -0
- package/dist/extensions/pi-subagents/test/integration/cursor-agent-smoke.test.ts +59 -0
- package/dist/extensions/pi-subagents/test/integration/cursor-agent-writer-smoke.test.ts +62 -0
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +57 -1
- package/dist/extensions/pi-subagents/test/integration/external-cli-runner.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +20 -0
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +4 -3
- package/dist/extensions/pi-subagents/test/integration/orca-progress-tabs.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +54 -4
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +482 -4
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +157 -9
- package/dist/extensions/pi-subagents/test/integration/session-tokens.test.ts +5 -5
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +1508 -291
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +423 -1
- package/dist/extensions/pi-subagents/test/integration/template-resolution.test.ts +8 -0
- package/dist/extensions/pi-subagents/test/support/cursor-smoke-inputs.ts +51 -0
- package/dist/extensions/pi-subagents/test/support/helpers.ts +2 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +5 -5
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +6 -6
- package/dist/extensions/pi-subagents/test/unit/abort-recovery.test.ts +152 -0
- package/dist/extensions/pi-subagents/test/unit/active-async-capacity.test.ts +48 -0
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +184 -6
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +66 -6
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +77 -0
- package/dist/extensions/pi-subagents/test/unit/agent-refinements.test.ts +18 -0
- package/dist/extensions/pi-subagents/test/unit/anti-slop-oxlint.test.ts +86 -0
- package/dist/extensions/pi-subagents/test/unit/artifacts.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/async-execution.test.ts +101 -1
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +121 -0
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +28 -0
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +14 -7
- package/dist/extensions/pi-subagents/test/unit/async-retention.test.ts +53 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-projection.test.ts +190 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-snapshot.test.ts +42 -0
- package/dist/extensions/pi-subagents/test/unit/auto-drain.test.ts +8 -4
- package/dist/extensions/pi-subagents/test/unit/background-work.test.ts +23 -0
- package/dist/extensions/pi-subagents/test/unit/chain-root-attachment.test.ts +78 -1
- package/dist/extensions/pi-subagents/test/unit/child-launch-plan.test.ts +94 -0
- package/dist/extensions/pi-subagents/test/unit/child-protocol.test.ts +21 -0
- package/dist/extensions/pi-subagents/test/unit/child-session-name.test.ts +50 -0
- package/dist/extensions/pi-subagents/test/unit/claude-code-adapter.test.ts +245 -0
- package/dist/extensions/pi-subagents/test/unit/codex-exec-adapter.test.ts +192 -0
- package/dist/extensions/pi-subagents/test/unit/compaction-resume.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/unit/completion-evidence.test.ts +150 -0
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +21 -0
- package/dist/extensions/pi-subagents/test/unit/cursor-agent-adapter.test.ts +259 -0
- package/dist/extensions/pi-subagents/test/unit/cursor-smoke-inputs.test.ts +77 -0
- package/dist/extensions/pi-subagents/test/unit/delegation-api.test.ts +1 -4
- package/dist/extensions/pi-subagents/test/unit/doctor.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/extension-context.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/unit/external-cli-runner.test.ts +223 -0
- package/dist/extensions/pi-subagents/test/unit/fast-mode-extension.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +208 -2
- package/dist/extensions/pi-subagents/test/unit/fleet-transcript.test.ts +29 -1
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +110 -1
- package/dist/extensions/pi-subagents/test/unit/foreground-control.test.ts +10 -0
- package/dist/extensions/pi-subagents/test/unit/formatters.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-inspector.test.ts +18 -9
- package/dist/extensions/pi-subagents/test/unit/herdr-session-roots-codec.test.ts +63 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-shell-command.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/herdr-status-bridge.test.ts +132 -0
- package/dist/extensions/pi-subagents/test/unit/host-command.test.ts +156 -0
- package/dist/extensions/pi-subagents/test/unit/host-step-status.test.ts +98 -0
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +178 -26
- package/dist/extensions/pi-subagents/test/unit/index-segment.test.ts +2 -1
- package/dist/extensions/pi-subagents/test/unit/inspect-rpc.test.ts +21 -0
- package/dist/extensions/pi-subagents/test/unit/mcp-direct-tool-grant.test.ts +138 -0
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/model-exclusions.test.ts +91 -0
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +72 -7
- package/dist/extensions/pi-subagents/test/unit/mutation-evidence.test.ts +21 -0
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +20 -2
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +129 -1
- package/dist/extensions/pi-subagents/test/unit/orca-progress-tabs.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +4 -0
- package/dist/extensions/pi-subagents/test/unit/parallel-handoff.test.ts +358 -0
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +574 -21
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +109 -1
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +71 -1
- package/dist/extensions/pi-subagents/test/unit/profiles.test.ts +7 -7
- package/dist/extensions/pi-subagents/test/unit/pruned-fork.test.ts +214 -0
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +29 -8
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +53 -0
- package/dist/extensions/pi-subagents/test/unit/result-delivery-ownership.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/unit/result-files.test.ts +101 -3
- package/dist/extensions/pi-subagents/test/unit/retained-children.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +10 -8
- package/dist/extensions/pi-subagents/test/unit/run-fanout-budget.test.ts +71 -1
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +41 -7
- package/dist/extensions/pi-subagents/test/unit/runtime-agent-registration.test.ts +136 -2
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +137 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +33 -12
- package/dist/extensions/pi-subagents/test/unit/scripted-workflow.test.ts +504 -1
- package/dist/extensions/pi-subagents/test/unit/single-output.test.ts +8 -0
- package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +12 -1
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +3 -5
- package/dist/extensions/pi-subagents/test/unit/steering.test.ts +5 -6
- package/dist/extensions/pi-subagents/test/unit/subagent-action-recovery.test.ts +0 -8
- package/dist/extensions/pi-subagents/test/unit/subagent-guide.test.ts +5 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +157 -2
- package/dist/extensions/pi-subagents/test/unit/subagent-startup-retry.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/subagent-wait.test.ts +63 -4
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +27 -23
- package/dist/extensions/pi-subagents/test/unit/wait-completions.test.ts +44 -0
- package/dist/extensions/pi-subagents/test/unit/wait-subscriptions.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/widget-nested-render.test.ts +7 -5
- package/dist/extensions/pi-subagents/test/unit/workflow-chat-progress.test.ts +106 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-detach-reconcile.test.ts +484 -9
- package/dist/extensions/pi-subagents/test/unit/workflow-launch-params.test.ts +38 -4
- package/dist/extensions/pi-subagents/test/unit/workflow-preflight.test.ts +155 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-receipt.test.ts +318 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-resume-hint.test.ts +365 -0
- package/dist/extensions/pi-subagents/test/unit/worktree-cleanup-plan.test.ts +349 -0
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +21 -0
- package/dist/extensions/pi-subagents/test/unit/writer-budget-guidance.test.ts +2 -7
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/effect/index.ts +13 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/effect/rules/no-service-constructor-imports.ts +52 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/index.ts +41 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-chained-type-assertions.ts +77 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-conditional-empty-object-spread.ts +49 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-known-value-widening.ts +247 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-module-mocking.ts +91 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-object-parameters.ts +126 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-reflect-apply.ts +28 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-reflect-get.ts +28 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-runtime-typeof.ts +67 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-shape-in-symbol-names.ts +39 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unknown-parameters.ts +83 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unknown-returns.ts +115 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unknown-type-aliases.ts +72 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unsafe-dictionary-type.ts +134 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-widen-then-assert.ts +366 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/require-safety-comment-for-type-assertion.ts +62 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/shared/dictionary-types.ts +502 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/shared/lexical-type-parameters.ts +60 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/shared/reflect-method.ts +35 -0
- package/dist/extensions/pi-tool-display/tests/capabilities.test.ts +1 -1
- package/dist/extensions/pi-tool-display/tests/settings-inspector.test.ts +2 -2
- package/dist/extensions/pi-tool-display/tests/tool-overrides-mcp.test.ts +1 -1
- package/dist/extensions/pi-zentui/extensions/zentui/format.ts +2 -1
- package/dist/extensions/pi-zentui/test/format.test.ts +15 -1
- package/dist/modes/interactive/components/footer.js +2 -2
- package/dist/modes/interactive/interactive-mode.js +11 -11
- package/dist/skills/workflow/SKILL.md +65 -50
- package/package.json +112 -110
- package/dist/extensions/enable-readonly-tools.test.ts +0 -63
- package/dist/extensions/enable-readonly-tools.ts +0 -24
- package/dist/extensions/model-prompt-injector/config.json +0 -16
- package/dist/extensions/model-prompt-injector/index.test.ts +0 -102
- package/dist/extensions/model-prompt-injector/index.ts +0 -148
- package/dist/extensions/pi-subagents/src/runs/shared/turn-budget.ts +0 -98
- package/dist/extensions/pi-subagents/test/unit/turn-budget.test.ts +0 -250
|
@@ -0,0 +1,827 @@
|
|
|
1
|
+
import { describe, it } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import {
|
|
4
|
+
buildSkillRows,
|
|
5
|
+
buildUnifiedSkillRows,
|
|
6
|
+
collectLoadedSkillsFromCommands,
|
|
7
|
+
confirmDeleteSelectedSkills,
|
|
8
|
+
deleteSelectedSkills,
|
|
9
|
+
filterSkillRows,
|
|
10
|
+
moveSelectedSkills,
|
|
11
|
+
registerSkillsCommand,
|
|
12
|
+
SkillsManagerModal,
|
|
13
|
+
type SkillBatchActionResult,
|
|
14
|
+
} from "../../src/handlers/skills-command.js";
|
|
15
|
+
import type { SkillIndex, SkillResult } from "../../src/types.js";
|
|
16
|
+
|
|
17
|
+
const SAMPLE_SKILLS: SkillIndex[] = [
|
|
18
|
+
{
|
|
19
|
+
skillId: "global:debug-typescript-errors",
|
|
20
|
+
scope: "global",
|
|
21
|
+
fileName: "SKILL.md",
|
|
22
|
+
path: "/tmp/global/debug-typescript-errors/SKILL.md",
|
|
23
|
+
name: "debug-typescript-errors",
|
|
24
|
+
displayName: "Debug TypeScript Errors",
|
|
25
|
+
description: "Trace compiler issues step by step",
|
|
26
|
+
created: "2026-05-19",
|
|
27
|
+
updated: "2026-05-21",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
skillId: "project:demo-project:deploy-checklist",
|
|
31
|
+
scope: "project",
|
|
32
|
+
fileName: "SKILL.md",
|
|
33
|
+
path: "/tmp/project/deploy-checklist/SKILL.md",
|
|
34
|
+
projectName: "demo-project",
|
|
35
|
+
name: "deploy-checklist",
|
|
36
|
+
displayName: "Deploy Checklist",
|
|
37
|
+
description: "Project release checklist",
|
|
38
|
+
created: "2026-05-18",
|
|
39
|
+
updated: "2026-05-20",
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
const SORT_MODE_SKILLS: SkillIndex[] = [
|
|
44
|
+
{
|
|
45
|
+
skillId: "global:zebra-runbook",
|
|
46
|
+
scope: "global",
|
|
47
|
+
fileName: "SKILL.md",
|
|
48
|
+
path: "/tmp/global/zebra-runbook/SKILL.md",
|
|
49
|
+
name: "zebra-runbook",
|
|
50
|
+
displayName: "Zebra Runbook",
|
|
51
|
+
description: "Older creation date, newer update date",
|
|
52
|
+
created: "2026-05-18",
|
|
53
|
+
updated: "2026-05-21",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
skillId: "project:demo-project:alpha-checklist",
|
|
57
|
+
scope: "project",
|
|
58
|
+
fileName: "SKILL.md",
|
|
59
|
+
path: "/tmp/project/alpha-checklist/SKILL.md",
|
|
60
|
+
projectName: "demo-project",
|
|
61
|
+
name: "alpha-checklist",
|
|
62
|
+
displayName: "Alpha Checklist",
|
|
63
|
+
description: "Newer creation date, older update date",
|
|
64
|
+
created: "2026-05-22",
|
|
65
|
+
updated: "2026-05-20",
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
const LOADED_SKILL_COMMANDS = [
|
|
70
|
+
{
|
|
71
|
+
name: "skill:debug-typescript-errors",
|
|
72
|
+
description: "Trace compiler issues step by step",
|
|
73
|
+
source: "skill",
|
|
74
|
+
sourceInfo: { path: "/tmp/global/debug-typescript-errors/SKILL.md" },
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "skill:langgraph-fundamentals",
|
|
78
|
+
description: "LangGraph patterns",
|
|
79
|
+
source: "skill",
|
|
80
|
+
sourceInfo: { path: "/Users/demo/.agents/skills/langgraph-fundamentals/SKILL.md" },
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "memory-skills",
|
|
84
|
+
description: "not a skill command",
|
|
85
|
+
source: "extension",
|
|
86
|
+
sourceInfo: { path: "/tmp/ignore" },
|
|
87
|
+
},
|
|
88
|
+
] as const;
|
|
89
|
+
|
|
90
|
+
describe("skills command helpers", () => {
|
|
91
|
+
it("buildSkillRows preserves selected ids", () => {
|
|
92
|
+
const rows = buildSkillRows(SAMPLE_SKILLS, new Set(["project:demo-project:deploy-checklist"]));
|
|
93
|
+
|
|
94
|
+
assert.strictEqual(rows.length, 2);
|
|
95
|
+
assert.strictEqual(rows[0].selected, false);
|
|
96
|
+
assert.strictEqual(rows[1].selected, true);
|
|
97
|
+
assert.strictEqual(rows[0].searchText.includes("Debug TypeScript Errors"), true);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("filterSkillRows uses fuzzy skill-name matching", () => {
|
|
101
|
+
const rows = buildSkillRows(SAMPLE_SKILLS);
|
|
102
|
+
const filtered = filterSkillRows(rows, "dbg ts err");
|
|
103
|
+
|
|
104
|
+
assert.strictEqual(filtered.length, 1);
|
|
105
|
+
assert.strictEqual(filtered[0].skillId, "global:debug-typescript-errors");
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("collectLoadedSkillsFromCommands returns loaded runtime skills only", () => {
|
|
109
|
+
const loaded = collectLoadedSkillsFromCommands(LOADED_SKILL_COMMANDS as any);
|
|
110
|
+
|
|
111
|
+
assert.strictEqual(loaded.length, 2);
|
|
112
|
+
assert.strictEqual(loaded[0]?.name, "debug-typescript-errors");
|
|
113
|
+
assert.strictEqual(loaded[1]?.name, "langgraph-fundamentals");
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("collectLoadedSkillsFromCommands ignores malformed and pathless commands", () => {
|
|
117
|
+
const loaded = collectLoadedSkillsFromCommands([
|
|
118
|
+
{ source: "skill", name: "skill:valid", sourceInfo: { path: "/tmp/valid/SKILL.md" } },
|
|
119
|
+
{ source: "skill", name: "skill:no-path", sourceInfo: {} },
|
|
120
|
+
{ source: "skill", name: "skill:blank-path", sourceInfo: { path: " " } },
|
|
121
|
+
{ source: "skill", name: " ", sourceInfo: { path: "/tmp/blank-name/SKILL.md" } },
|
|
122
|
+
{ source: "skill", sourceInfo: { path: "/tmp/missing-name/SKILL.md" } },
|
|
123
|
+
{ source: "skill", name: 123, sourceInfo: { path: "/tmp/invalid-name/SKILL.md" } },
|
|
124
|
+
{ source: "extension", name: "memory-skills", sourceInfo: { path: "/tmp/ignore/SKILL.md" } },
|
|
125
|
+
null as any,
|
|
126
|
+
] as any);
|
|
127
|
+
|
|
128
|
+
assert.strictEqual(loaded.length, 1);
|
|
129
|
+
assert.strictEqual(loaded[0]?.name, "valid");
|
|
130
|
+
assert.strictEqual(loaded[0]?.path, "/tmp/valid/SKILL.md");
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("buildUnifiedSkillRows merges managed and external skills", () => {
|
|
134
|
+
const loaded = collectLoadedSkillsFromCommands(LOADED_SKILL_COMMANDS as any);
|
|
135
|
+
const rows = buildUnifiedSkillRows(SAMPLE_SKILLS, loaded);
|
|
136
|
+
|
|
137
|
+
assert.strictEqual(rows.length, 3);
|
|
138
|
+
const external = rows.find((row) => row.category === "E");
|
|
139
|
+
assert.ok(external);
|
|
140
|
+
assert.strictEqual(external?.mutable, false);
|
|
141
|
+
assert.ok(external?.displayPath.includes(".agents"));
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("buildUnifiedSkillRows keeps managed skills sorted by updated recency", () => {
|
|
145
|
+
const loaded = collectLoadedSkillsFromCommands(LOADED_SKILL_COMMANDS as any);
|
|
146
|
+
const rows = buildUnifiedSkillRows(SAMPLE_SKILLS, loaded);
|
|
147
|
+
|
|
148
|
+
assert.strictEqual(rows[0]?.skillId, "global:debug-typescript-errors");
|
|
149
|
+
assert.strictEqual(rows[1]?.skillId, "project:demo-project:deploy-checklist");
|
|
150
|
+
assert.strictEqual(rows[2]?.category, "E");
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("buildUnifiedSkillRows can sort by created date or name", () => {
|
|
154
|
+
const loaded = collectLoadedSkillsFromCommands(LOADED_SKILL_COMMANDS as any);
|
|
155
|
+
|
|
156
|
+
const createdRows = buildUnifiedSkillRows(SORT_MODE_SKILLS, loaded, new Set<string>(), "created");
|
|
157
|
+
assert.strictEqual(createdRows[0]?.skillId, "project:demo-project:alpha-checklist");
|
|
158
|
+
assert.strictEqual(createdRows[1]?.skillId, "global:zebra-runbook");
|
|
159
|
+
|
|
160
|
+
const nameRows = buildUnifiedSkillRows(SORT_MODE_SKILLS, loaded, new Set<string>(), "name");
|
|
161
|
+
assert.strictEqual(nameRows[0]?.skillId, "project:demo-project:alpha-checklist");
|
|
162
|
+
assert.strictEqual(nameRows[1]?.displayName, "debug-typescript-errors");
|
|
163
|
+
assert.strictEqual(nameRows[2]?.displayName, "langgraph-fundamentals");
|
|
164
|
+
assert.strictEqual(nameRows[3]?.skillId, "global:zebra-runbook");
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("moveSelectedSkills blocks project moves without an active project", async () => {
|
|
168
|
+
const store = {
|
|
169
|
+
getProjectName: () => null,
|
|
170
|
+
loadIndex: async () => SAMPLE_SKILLS,
|
|
171
|
+
move: async () => ({ success: true } as SkillResult),
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const result = await moveSelectedSkills(store as any, ["global:debug-typescript-errors"], "project");
|
|
175
|
+
|
|
176
|
+
assert.strictEqual(result.summaryLines[0], "Move to project is unavailable: no active project detected.");
|
|
177
|
+
assert.deepStrictEqual(result.retainSelectedSkillIds, ["global:debug-typescript-errors"]);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("moveSelectedSkills keeps partial successes and retains blocked selection", async () => {
|
|
181
|
+
const moves = new Map<string, SkillResult>([
|
|
182
|
+
[
|
|
183
|
+
"global:debug-typescript-errors",
|
|
184
|
+
{
|
|
185
|
+
success: true,
|
|
186
|
+
skillId: "project:demo-project:debug-typescript-errors",
|
|
187
|
+
scope: "project",
|
|
188
|
+
message: "Skill 'Debug TypeScript Errors' moved to project.",
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
[
|
|
192
|
+
"project:demo-project:deploy-checklist",
|
|
193
|
+
{
|
|
194
|
+
success: false,
|
|
195
|
+
error: "Destination already exists.",
|
|
196
|
+
conflictType: "scope-conflict",
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
]);
|
|
200
|
+
|
|
201
|
+
const refreshed: SkillIndex[] = [
|
|
202
|
+
{
|
|
203
|
+
...SAMPLE_SKILLS[1],
|
|
204
|
+
skillId: "project:demo-project:debug-typescript-errors",
|
|
205
|
+
name: "debug-typescript-errors",
|
|
206
|
+
displayName: "Debug TypeScript Errors",
|
|
207
|
+
path: "/tmp/project/debug-typescript-errors/SKILL.md",
|
|
208
|
+
description: "Trace compiler issues step by step",
|
|
209
|
+
},
|
|
210
|
+
SAMPLE_SKILLS[1],
|
|
211
|
+
];
|
|
212
|
+
|
|
213
|
+
const store = {
|
|
214
|
+
getProjectName: () => "demo-project",
|
|
215
|
+
loadIndex: async () => refreshed,
|
|
216
|
+
move: async (skillId: string) => moves.get(skillId)!,
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const result = await moveSelectedSkills(
|
|
220
|
+
store as any,
|
|
221
|
+
["global:debug-typescript-errors", "project:demo-project:deploy-checklist"],
|
|
222
|
+
"project",
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
assert.ok(result.summaryLines[0].includes("Moved 1 skill"));
|
|
226
|
+
assert.ok(result.summaryLines.some((line) => line.includes("Blocked 1 skill")));
|
|
227
|
+
assert.deepStrictEqual(result.retainSelectedSkillIds, ["project:demo-project:deploy-checklist"]);
|
|
228
|
+
assert.strictEqual(result.focusSkillId, "project:demo-project:deploy-checklist");
|
|
229
|
+
assert.strictEqual(result.skills.length, 2);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("deleteSelectedSkills reports blocked deletes and refreshes skills", async () => {
|
|
233
|
+
const store = {
|
|
234
|
+
loadIndex: async () => [SAMPLE_SKILLS[1]],
|
|
235
|
+
delete: async (skillId: string) => skillId === SAMPLE_SKILLS[0].skillId
|
|
236
|
+
? { success: true, skillId, scope: "global" as const }
|
|
237
|
+
: { success: false, error: "Skill missing." },
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const result = await deleteSelectedSkills(
|
|
241
|
+
store as any,
|
|
242
|
+
[SAMPLE_SKILLS[0].skillId, SAMPLE_SKILLS[1].skillId],
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
assert.ok(result.summaryLines[0].includes("Deleted 1 skill"));
|
|
246
|
+
assert.ok(result.summaryLines.some((line) => line.includes("Blocked 1 skill")));
|
|
247
|
+
assert.deepStrictEqual(result.retainSelectedSkillIds, [SAMPLE_SKILLS[1].skillId]);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it("moveSelectedSkills treats thrown move errors as blocked items", async () => {
|
|
251
|
+
const store = {
|
|
252
|
+
getProjectName: () => "demo-project",
|
|
253
|
+
loadIndex: async () => SAMPLE_SKILLS,
|
|
254
|
+
move: async (skillId: string) => {
|
|
255
|
+
if (skillId === SAMPLE_SKILLS[0].skillId) {
|
|
256
|
+
throw new Error("permission denied");
|
|
257
|
+
}
|
|
258
|
+
return { success: true, skillId: "global:deploy-checklist", scope: "global" as const };
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
const result = await moveSelectedSkills(store as any, [SAMPLE_SKILLS[0].skillId, SAMPLE_SKILLS[1].skillId], "global");
|
|
263
|
+
|
|
264
|
+
assert.ok(result.summaryLines.some((line) => line.includes("Blocked 1 skill")));
|
|
265
|
+
assert.ok(result.summaryLines.some((line) => line.includes("permission denied")));
|
|
266
|
+
assert.deepStrictEqual(result.retainSelectedSkillIds, [SAMPLE_SKILLS[0].skillId]);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it("deleteSelectedSkills treats thrown delete errors as blocked items", async () => {
|
|
270
|
+
const store = {
|
|
271
|
+
loadIndex: async () => SAMPLE_SKILLS,
|
|
272
|
+
delete: async (skillId: string) => {
|
|
273
|
+
if (skillId === SAMPLE_SKILLS[1].skillId) {
|
|
274
|
+
throw new Error("unlink denied");
|
|
275
|
+
}
|
|
276
|
+
return { success: true, skillId, scope: "global" as const };
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
const result = await deleteSelectedSkills(store as any, [SAMPLE_SKILLS[0].skillId, SAMPLE_SKILLS[1].skillId]);
|
|
281
|
+
|
|
282
|
+
assert.ok(result.summaryLines.some((line) => line.includes("Blocked 1 skill")));
|
|
283
|
+
assert.ok(result.summaryLines.some((line) => line.includes("unlink denied")));
|
|
284
|
+
assert.deepStrictEqual(result.retainSelectedSkillIds, [SAMPLE_SKILLS[1].skillId]);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it("confirmDeleteSelectedSkills keeps selection when user cancels", async () => {
|
|
288
|
+
let prompts = 0;
|
|
289
|
+
const store = {
|
|
290
|
+
loadIndex: async () => SAMPLE_SKILLS,
|
|
291
|
+
delete: async () => ({ success: true }),
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
const result = await confirmDeleteSelectedSkills(
|
|
295
|
+
async () => {
|
|
296
|
+
prompts++;
|
|
297
|
+
return false;
|
|
298
|
+
},
|
|
299
|
+
store as any,
|
|
300
|
+
[SAMPLE_SKILLS[0].skillId],
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
assert.strictEqual(prompts, 1);
|
|
304
|
+
assert.deepStrictEqual(result.retainSelectedSkillIds, [SAMPLE_SKILLS[0].skillId]);
|
|
305
|
+
assert.strictEqual(result.summaryLines[0], "Delete cancelled.");
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
function createModalHarness() {
|
|
310
|
+
let renderCount = 0;
|
|
311
|
+
return {
|
|
312
|
+
tui: {
|
|
313
|
+
requestRender: () => {
|
|
314
|
+
renderCount++;
|
|
315
|
+
},
|
|
316
|
+
terminal: { rows: 42 },
|
|
317
|
+
},
|
|
318
|
+
theme: {
|
|
319
|
+
fg: (_color: string, text: string) => text,
|
|
320
|
+
bg: (_color: string, text: string) => text,
|
|
321
|
+
bold: (text: string) => text,
|
|
322
|
+
},
|
|
323
|
+
getRenderCount: () => renderCount,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function nextTick(): Promise<void> {
|
|
328
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
describe("SkillsManagerModal", () => {
|
|
332
|
+
it("toggles selection and sends selected ids for move action", async () => {
|
|
333
|
+
const harness = createModalHarness();
|
|
334
|
+
const captured: Array<{ scope: string; skillIds: string[] }> = [];
|
|
335
|
+
|
|
336
|
+
const modal = new SkillsManagerModal(
|
|
337
|
+
harness.tui as any,
|
|
338
|
+
harness.theme as any,
|
|
339
|
+
buildSkillRows(SAMPLE_SKILLS),
|
|
340
|
+
{
|
|
341
|
+
moveSelected: async (scope, skillIds) => {
|
|
342
|
+
captured.push({ scope, skillIds });
|
|
343
|
+
return { skills: SAMPLE_SKILLS, summaryLines: ["done"] };
|
|
344
|
+
},
|
|
345
|
+
deleteSelected: async () => ({ skills: SAMPLE_SKILLS, summaryLines: ["done"] }),
|
|
346
|
+
close: () => undefined,
|
|
347
|
+
projectName: "demo-project",
|
|
348
|
+
},
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
modal.handleInput(" ");
|
|
352
|
+
modal.handleInput("g");
|
|
353
|
+
await nextTick();
|
|
354
|
+
|
|
355
|
+
assert.strictEqual(captured.length, 1);
|
|
356
|
+
assert.strictEqual(captured[0].scope, "global");
|
|
357
|
+
assert.deepStrictEqual(captured[0].skillIds, ["global:debug-typescript-errors"]);
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
it("supports slash search and typed filtering", () => {
|
|
361
|
+
const harness = createModalHarness();
|
|
362
|
+
const modal = new SkillsManagerModal(
|
|
363
|
+
harness.tui as any,
|
|
364
|
+
harness.theme as any,
|
|
365
|
+
buildSkillRows(SAMPLE_SKILLS),
|
|
366
|
+
{
|
|
367
|
+
moveSelected: async () => ({ skills: SAMPLE_SKILLS, summaryLines: ["done"] }),
|
|
368
|
+
deleteSelected: async () => ({ skills: SAMPLE_SKILLS, summaryLines: ["done"] }),
|
|
369
|
+
close: () => undefined,
|
|
370
|
+
projectName: "demo-project",
|
|
371
|
+
},
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
modal.handleInput("/");
|
|
375
|
+
modal.handleInput("z");
|
|
376
|
+
modal.handleInput("z");
|
|
377
|
+
|
|
378
|
+
const output = modal.render(100).join("\n");
|
|
379
|
+
assert.ok(output.includes("No skills match the current filters/search."));
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it("redirects printable keys to search from list focus", () => {
|
|
383
|
+
const harness = createModalHarness();
|
|
384
|
+
const modal = new SkillsManagerModal(
|
|
385
|
+
harness.tui as any,
|
|
386
|
+
harness.theme as any,
|
|
387
|
+
buildSkillRows(SAMPLE_SKILLS),
|
|
388
|
+
{
|
|
389
|
+
moveSelected: async () => ({ skills: SAMPLE_SKILLS, summaryLines: ["done"] }),
|
|
390
|
+
deleteSelected: async () => ({ skills: SAMPLE_SKILLS, summaryLines: ["done"] }),
|
|
391
|
+
close: () => undefined,
|
|
392
|
+
projectName: "demo-project",
|
|
393
|
+
},
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
modal.handleInput("z");
|
|
397
|
+
const output = modal.render(100).join("\n");
|
|
398
|
+
assert.ok(output.includes("No skills match the current filters/search."));
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
it("uses in-modal delete confirmation and cancels with n", () => {
|
|
402
|
+
const harness = createModalHarness();
|
|
403
|
+
let deleteCalls = 0;
|
|
404
|
+
|
|
405
|
+
const modal = new SkillsManagerModal(
|
|
406
|
+
harness.tui as any,
|
|
407
|
+
harness.theme as any,
|
|
408
|
+
buildSkillRows(SAMPLE_SKILLS),
|
|
409
|
+
{
|
|
410
|
+
moveSelected: async () => ({ skills: SAMPLE_SKILLS, summaryLines: ["done"] }),
|
|
411
|
+
deleteSelected: async () => {
|
|
412
|
+
deleteCalls++;
|
|
413
|
+
return { skills: SAMPLE_SKILLS, summaryLines: ["deleted"] };
|
|
414
|
+
},
|
|
415
|
+
close: () => undefined,
|
|
416
|
+
projectName: "demo-project",
|
|
417
|
+
},
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
modal.handleInput(" ");
|
|
421
|
+
modal.handleInput("d");
|
|
422
|
+
let output = modal.render(100).join("\n");
|
|
423
|
+
assert.ok(output.includes("Press y to confirm or n to cancel"));
|
|
424
|
+
|
|
425
|
+
modal.handleInput("n");
|
|
426
|
+
output = modal.render(100).join("\n");
|
|
427
|
+
assert.ok(output.includes("Delete cancelled."));
|
|
428
|
+
assert.strictEqual(deleteCalls, 0);
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
it("confirms delete in-modal with y", async () => {
|
|
432
|
+
const harness = createModalHarness();
|
|
433
|
+
const capturedDeletes: string[][] = [];
|
|
434
|
+
|
|
435
|
+
const modal = new SkillsManagerModal(
|
|
436
|
+
harness.tui as any,
|
|
437
|
+
harness.theme as any,
|
|
438
|
+
buildSkillRows(SAMPLE_SKILLS),
|
|
439
|
+
{
|
|
440
|
+
moveSelected: async () => ({ skills: SAMPLE_SKILLS, summaryLines: ["done"] }),
|
|
441
|
+
deleteSelected: async (skillIds) => {
|
|
442
|
+
capturedDeletes.push(skillIds);
|
|
443
|
+
return { skills: [SAMPLE_SKILLS[1]], summaryLines: ["deleted"] };
|
|
444
|
+
},
|
|
445
|
+
close: () => undefined,
|
|
446
|
+
projectName: "demo-project",
|
|
447
|
+
},
|
|
448
|
+
);
|
|
449
|
+
|
|
450
|
+
modal.handleInput(" ");
|
|
451
|
+
modal.handleInput("d");
|
|
452
|
+
modal.handleInput("y");
|
|
453
|
+
await nextTick();
|
|
454
|
+
|
|
455
|
+
assert.strictEqual(capturedDeletes.length, 1);
|
|
456
|
+
assert.deepStrictEqual(capturedDeletes[0], ["global:debug-typescript-errors"]);
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
it("stops rendering updates after close during async actions", async () => {
|
|
460
|
+
const harness = createModalHarness();
|
|
461
|
+
let resolveMove: ((result: SkillBatchActionResult) => void) | null = null;
|
|
462
|
+
let closeCount = 0;
|
|
463
|
+
|
|
464
|
+
const modal = new SkillsManagerModal(
|
|
465
|
+
harness.tui as any,
|
|
466
|
+
harness.theme as any,
|
|
467
|
+
buildSkillRows(SAMPLE_SKILLS),
|
|
468
|
+
{
|
|
469
|
+
moveSelected: async () => {
|
|
470
|
+
return await new Promise<SkillBatchActionResult>((resolve) => {
|
|
471
|
+
resolveMove = resolve;
|
|
472
|
+
});
|
|
473
|
+
},
|
|
474
|
+
deleteSelected: async () => ({ skills: SAMPLE_SKILLS, summaryLines: ["done"] }),
|
|
475
|
+
close: () => {
|
|
476
|
+
closeCount++;
|
|
477
|
+
},
|
|
478
|
+
projectName: "demo-project",
|
|
479
|
+
},
|
|
480
|
+
);
|
|
481
|
+
|
|
482
|
+
modal.handleInput("g");
|
|
483
|
+
modal.handleInput("\u001b");
|
|
484
|
+
assert.strictEqual(closeCount, 1);
|
|
485
|
+
|
|
486
|
+
const renderCountBeforeResolve = harness.getRenderCount();
|
|
487
|
+
resolveMove?.({ skills: SAMPLE_SKILLS, summaryLines: ["moved"] });
|
|
488
|
+
await nextTick();
|
|
489
|
+
|
|
490
|
+
assert.strictEqual(harness.getRenderCount(), renderCountBeforeResolve);
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
it("supports in-modal category filters", () => {
|
|
494
|
+
const harness = createModalHarness();
|
|
495
|
+
const loaded = collectLoadedSkillsFromCommands(LOADED_SKILL_COMMANDS as any);
|
|
496
|
+
const rows = buildUnifiedSkillRows(SAMPLE_SKILLS, loaded);
|
|
497
|
+
|
|
498
|
+
const modal = new SkillsManagerModal(
|
|
499
|
+
harness.tui as any,
|
|
500
|
+
harness.theme as any,
|
|
501
|
+
rows,
|
|
502
|
+
{
|
|
503
|
+
moveSelected: async () => ({ skills: SAMPLE_SKILLS, summaryLines: ["done"] }),
|
|
504
|
+
deleteSelected: async () => ({ skills: SAMPLE_SKILLS, summaryLines: ["done"] }),
|
|
505
|
+
close: () => undefined,
|
|
506
|
+
projectName: "demo-project",
|
|
507
|
+
},
|
|
508
|
+
{ managedSkills: SAMPLE_SKILLS, loadedSkills: loaded },
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
modal.handleInput("f");
|
|
512
|
+
modal.handleInput(" "); // disable global
|
|
513
|
+
modal.handleInput("\u001b[B");
|
|
514
|
+
modal.handleInput(" "); // disable project
|
|
515
|
+
modal.handleInput("\r"); // apply
|
|
516
|
+
|
|
517
|
+
const output = modal.render(120).join("\n");
|
|
518
|
+
assert.ok(output.includes("langgraph-fundamentals"));
|
|
519
|
+
assert.ok(!output.includes("Deploy Checklist"));
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
it("cycles sort mode with s and shows the active mode in the modal", () => {
|
|
523
|
+
const harness = createModalHarness();
|
|
524
|
+
const loaded = collectLoadedSkillsFromCommands(LOADED_SKILL_COMMANDS as any);
|
|
525
|
+
const rows = buildUnifiedSkillRows(SORT_MODE_SKILLS, loaded);
|
|
526
|
+
|
|
527
|
+
const modal = new SkillsManagerModal(
|
|
528
|
+
harness.tui as any,
|
|
529
|
+
harness.theme as any,
|
|
530
|
+
rows,
|
|
531
|
+
{
|
|
532
|
+
moveSelected: async () => ({ skills: SORT_MODE_SKILLS, summaryLines: ["done"] }),
|
|
533
|
+
deleteSelected: async () => ({ skills: SORT_MODE_SKILLS, summaryLines: ["done"] }),
|
|
534
|
+
close: () => undefined,
|
|
535
|
+
projectName: "demo-project",
|
|
536
|
+
},
|
|
537
|
+
{ managedSkills: SORT_MODE_SKILLS, loadedSkills: loaded },
|
|
538
|
+
);
|
|
539
|
+
|
|
540
|
+
let output = modal.render(120).join("\n");
|
|
541
|
+
assert.ok(output.includes("sort: Updated"));
|
|
542
|
+
assert.ok(output.includes("Zebra Runbook"));
|
|
543
|
+
|
|
544
|
+
modal.handleInput("s");
|
|
545
|
+
output = modal.render(120).join("\n");
|
|
546
|
+
assert.ok(output.includes("sort: Created"));
|
|
547
|
+
assert.ok(output.includes("Sort mode: Created."));
|
|
548
|
+
|
|
549
|
+
modal.handleInput("s");
|
|
550
|
+
output = modal.render(120).join("\n");
|
|
551
|
+
assert.ok(output.includes("sort: Name"));
|
|
552
|
+
assert.ok(output.includes("Alpha Checklist"));
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
it("blocks external skill mutations as read-only", async () => {
|
|
556
|
+
const harness = createModalHarness();
|
|
557
|
+
const loaded = collectLoadedSkillsFromCommands(LOADED_SKILL_COMMANDS as any);
|
|
558
|
+
const rows = buildUnifiedSkillRows(SAMPLE_SKILLS, loaded);
|
|
559
|
+
let moveCalls = 0;
|
|
560
|
+
|
|
561
|
+
const modal = new SkillsManagerModal(
|
|
562
|
+
harness.tui as any,
|
|
563
|
+
harness.theme as any,
|
|
564
|
+
rows,
|
|
565
|
+
{
|
|
566
|
+
moveSelected: async () => {
|
|
567
|
+
moveCalls++;
|
|
568
|
+
return { skills: SAMPLE_SKILLS, summaryLines: ["done"] };
|
|
569
|
+
},
|
|
570
|
+
deleteSelected: async () => ({ skills: SAMPLE_SKILLS, summaryLines: ["done"] }),
|
|
571
|
+
close: () => undefined,
|
|
572
|
+
projectName: "demo-project",
|
|
573
|
+
},
|
|
574
|
+
{ managedSkills: SAMPLE_SKILLS, loadedSkills: loaded },
|
|
575
|
+
);
|
|
576
|
+
|
|
577
|
+
modal.handleInput("f");
|
|
578
|
+
modal.handleInput(" ");
|
|
579
|
+
modal.handleInput("\u001b[B");
|
|
580
|
+
modal.handleInput(" ");
|
|
581
|
+
modal.handleInput("\r");
|
|
582
|
+
|
|
583
|
+
modal.handleInput(" ");
|
|
584
|
+
modal.handleInput("g");
|
|
585
|
+
await nextTick();
|
|
586
|
+
|
|
587
|
+
const output = modal.render(120).join("\n");
|
|
588
|
+
assert.strictEqual(moveCalls, 0);
|
|
589
|
+
assert.ok(output.includes("read-only"));
|
|
590
|
+
});
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
describe("registerSkillsCommand", () => {
|
|
594
|
+
it("falls back to notify output when custom UI is unavailable", async () => {
|
|
595
|
+
const commands: Array<{ name: string; handler: Function }> = [];
|
|
596
|
+
const notifications: Array<{ message: string; severity: string }> = [];
|
|
597
|
+
const pi = {
|
|
598
|
+
registerCommand: (name: string, opts: { handler: Function }) => {
|
|
599
|
+
commands.push({ name, handler: opts.handler });
|
|
600
|
+
},
|
|
601
|
+
};
|
|
602
|
+
const store = {
|
|
603
|
+
loadIndex: async () => SAMPLE_SKILLS,
|
|
604
|
+
getProjectName: () => "demo-project",
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
registerSkillsCommand(pi as any, store as any);
|
|
608
|
+
assert.strictEqual(commands.length, 1);
|
|
609
|
+
|
|
610
|
+
await commands[0].handler({}, {
|
|
611
|
+
hasUI: false,
|
|
612
|
+
ui: {
|
|
613
|
+
notify: (message: string, severity: string) => notifications.push({ message, severity }),
|
|
614
|
+
},
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
assert.strictEqual(notifications.length, 1);
|
|
618
|
+
assert.strictEqual(notifications[0].severity, "info");
|
|
619
|
+
assert.ok(notifications[0].message.includes("Procedural Skills"));
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
it("uses pi.getCommands runtime inventory for external skills", async () => {
|
|
623
|
+
const commands: Array<{ name: string; handler: Function }> = [];
|
|
624
|
+
const notifications: Array<{ message: string; severity: string }> = [];
|
|
625
|
+
const pi = {
|
|
626
|
+
registerCommand: (name: string, opts: { handler: Function }) => {
|
|
627
|
+
commands.push({ name, handler: opts.handler });
|
|
628
|
+
},
|
|
629
|
+
getCommands: () => LOADED_SKILL_COMMANDS,
|
|
630
|
+
};
|
|
631
|
+
const store = {
|
|
632
|
+
loadIndex: async () => SAMPLE_SKILLS,
|
|
633
|
+
getProjectName: () => "demo-project",
|
|
634
|
+
};
|
|
635
|
+
|
|
636
|
+
registerSkillsCommand(pi as any, store as any);
|
|
637
|
+
|
|
638
|
+
await commands[0].handler({}, {
|
|
639
|
+
hasUI: false,
|
|
640
|
+
ui: {
|
|
641
|
+
notify: (message: string, severity: string) => notifications.push({ message, severity }),
|
|
642
|
+
},
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
assert.strictEqual(notifications.length, 1);
|
|
646
|
+
assert.strictEqual(notifications[0].severity, "info");
|
|
647
|
+
assert.ok(notifications[0].message.includes("[E] External Skills"));
|
|
648
|
+
assert.ok(notifications[0].message.includes("langgraph-fundamentals"));
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
it("gracefully handles getCommands errors without custom UI", async () => {
|
|
652
|
+
const commands: Array<{ name: string; handler: Function }> = [];
|
|
653
|
+
const notifications: Array<{ message: string; severity: string }> = [];
|
|
654
|
+
const pi = {
|
|
655
|
+
registerCommand: (name: string, opts: { handler: Function }) => {
|
|
656
|
+
commands.push({ name, handler: opts.handler });
|
|
657
|
+
},
|
|
658
|
+
};
|
|
659
|
+
const store = {
|
|
660
|
+
loadIndex: async () => SAMPLE_SKILLS,
|
|
661
|
+
getProjectName: () => "demo-project",
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
registerSkillsCommand(pi as any, store as any);
|
|
665
|
+
assert.strictEqual(commands.length, 1);
|
|
666
|
+
|
|
667
|
+
await commands[0].handler({}, {
|
|
668
|
+
hasUI: false,
|
|
669
|
+
getCommands: () => {
|
|
670
|
+
throw new Error("command registry unavailable");
|
|
671
|
+
},
|
|
672
|
+
ui: {
|
|
673
|
+
notify: (message: string, severity: string) => notifications.push({ message, severity }),
|
|
674
|
+
},
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
assert.strictEqual(notifications.length, 1);
|
|
678
|
+
assert.strictEqual(notifications[0].severity, "info");
|
|
679
|
+
assert.ok(notifications[0].message.includes("Procedural Skills"));
|
|
680
|
+
});
|
|
681
|
+
|
|
682
|
+
it("opens a custom modal when interactive UI is available", async () => {
|
|
683
|
+
const commands: Array<{ name: string; handler: Function }> = [];
|
|
684
|
+
let customInvoked = false;
|
|
685
|
+
const pi = {
|
|
686
|
+
registerCommand: (name: string, opts: { handler: Function }) => {
|
|
687
|
+
commands.push({ name, handler: opts.handler });
|
|
688
|
+
},
|
|
689
|
+
};
|
|
690
|
+
const store = {
|
|
691
|
+
loadIndex: async () => SAMPLE_SKILLS,
|
|
692
|
+
getProjectName: () => "demo-project",
|
|
693
|
+
move: async () => ({ success: true } as SkillResult),
|
|
694
|
+
delete: async () => ({ success: true } as SkillResult),
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
registerSkillsCommand(pi as any, store as any);
|
|
698
|
+
|
|
699
|
+
await commands[0].handler({}, {
|
|
700
|
+
hasUI: true,
|
|
701
|
+
ui: {
|
|
702
|
+
custom: async (
|
|
703
|
+
factory: Function,
|
|
704
|
+
options: { overlay?: boolean },
|
|
705
|
+
) => {
|
|
706
|
+
customInvoked = true;
|
|
707
|
+
assert.strictEqual(options.overlay, true);
|
|
708
|
+
// factory invocation is unnecessary for this contract-level test
|
|
709
|
+
return undefined;
|
|
710
|
+
},
|
|
711
|
+
confirm: async () => true,
|
|
712
|
+
notify: () => undefined,
|
|
713
|
+
},
|
|
714
|
+
});
|
|
715
|
+
|
|
716
|
+
assert.strictEqual(customInvoked, true);
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
it("opens custom modal even when getCommands throws", async () => {
|
|
720
|
+
const commands: Array<{ name: string; handler: Function }> = [];
|
|
721
|
+
let customInvoked = false;
|
|
722
|
+
const pi = {
|
|
723
|
+
registerCommand: (name: string, opts: { handler: Function }) => {
|
|
724
|
+
commands.push({ name, handler: opts.handler });
|
|
725
|
+
},
|
|
726
|
+
};
|
|
727
|
+
const store = {
|
|
728
|
+
loadIndex: async () => SAMPLE_SKILLS,
|
|
729
|
+
getProjectName: () => "demo-project",
|
|
730
|
+
move: async () => ({ success: true } as SkillResult),
|
|
731
|
+
delete: async () => ({ success: true } as SkillResult),
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
registerSkillsCommand(pi as any, store as any);
|
|
735
|
+
|
|
736
|
+
await commands[0].handler({}, {
|
|
737
|
+
hasUI: true,
|
|
738
|
+
getCommands: () => {
|
|
739
|
+
throw new Error("command registry unavailable");
|
|
740
|
+
},
|
|
741
|
+
ui: {
|
|
742
|
+
custom: async (factory: Function, options: { overlay?: boolean }) => {
|
|
743
|
+
customInvoked = true;
|
|
744
|
+
assert.strictEqual(options.overlay, true);
|
|
745
|
+
return undefined;
|
|
746
|
+
},
|
|
747
|
+
confirm: async () => true,
|
|
748
|
+
notify: () => undefined,
|
|
749
|
+
},
|
|
750
|
+
});
|
|
751
|
+
|
|
752
|
+
assert.strictEqual(customInvoked, true);
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
it("falls back to read-only notify output when custom modal throws", async () => {
|
|
756
|
+
const commands: Array<{ name: string; handler: Function }> = [];
|
|
757
|
+
const notifications: Array<{ message: string; severity: string }> = [];
|
|
758
|
+
const pi = {
|
|
759
|
+
registerCommand: (name: string, opts: { handler: Function }) => {
|
|
760
|
+
commands.push({ name, handler: opts.handler });
|
|
761
|
+
},
|
|
762
|
+
};
|
|
763
|
+
const store = {
|
|
764
|
+
loadIndex: async () => SAMPLE_SKILLS,
|
|
765
|
+
getProjectName: () => "demo-project",
|
|
766
|
+
move: async () => ({ success: true } as SkillResult),
|
|
767
|
+
delete: async () => ({ success: true } as SkillResult),
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
registerSkillsCommand(pi as any, store as any);
|
|
771
|
+
|
|
772
|
+
await commands[0].handler({}, {
|
|
773
|
+
hasUI: true,
|
|
774
|
+
ui: {
|
|
775
|
+
custom: async () => {
|
|
776
|
+
throw new Error("UI backend unavailable");
|
|
777
|
+
},
|
|
778
|
+
confirm: async () => true,
|
|
779
|
+
notify: (message: string, severity: string) => notifications.push({ message, severity }),
|
|
780
|
+
},
|
|
781
|
+
});
|
|
782
|
+
|
|
783
|
+
assert.strictEqual(notifications.length, 2);
|
|
784
|
+
assert.strictEqual(notifications[0].severity, "warning");
|
|
785
|
+
assert.ok(notifications[0].message.includes("read-only list fallback"));
|
|
786
|
+
assert.strictEqual(notifications[1].severity, "info");
|
|
787
|
+
assert.ok(notifications[1].message.includes("Procedural Skills"));
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
it("falls back to read-only list when both custom modal and getCommands fail", async () => {
|
|
791
|
+
const commands: Array<{ name: string; handler: Function }> = [];
|
|
792
|
+
const notifications: Array<{ message: string; severity: string }> = [];
|
|
793
|
+
const pi = {
|
|
794
|
+
registerCommand: (name: string, opts: { handler: Function }) => {
|
|
795
|
+
commands.push({ name, handler: opts.handler });
|
|
796
|
+
},
|
|
797
|
+
};
|
|
798
|
+
const store = {
|
|
799
|
+
loadIndex: async () => SAMPLE_SKILLS,
|
|
800
|
+
getProjectName: () => "demo-project",
|
|
801
|
+
move: async () => ({ success: true } as SkillResult),
|
|
802
|
+
delete: async () => ({ success: true } as SkillResult),
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
registerSkillsCommand(pi as any, store as any);
|
|
806
|
+
|
|
807
|
+
await commands[0].handler({}, {
|
|
808
|
+
hasUI: true,
|
|
809
|
+
getCommands: () => {
|
|
810
|
+
throw new Error("command registry unavailable");
|
|
811
|
+
},
|
|
812
|
+
ui: {
|
|
813
|
+
custom: async () => {
|
|
814
|
+
throw new Error("UI backend unavailable");
|
|
815
|
+
},
|
|
816
|
+
confirm: async () => true,
|
|
817
|
+
notify: (message: string, severity: string) => notifications.push({ message, severity }),
|
|
818
|
+
},
|
|
819
|
+
});
|
|
820
|
+
|
|
821
|
+
assert.strictEqual(notifications.length, 2);
|
|
822
|
+
assert.strictEqual(notifications[0].severity, "warning");
|
|
823
|
+
assert.ok(notifications[0].message.includes("read-only list fallback"));
|
|
824
|
+
assert.strictEqual(notifications[1].severity, "info");
|
|
825
|
+
assert.ok(notifications[1].message.includes("Procedural Skills"));
|
|
826
|
+
});
|
|
827
|
+
});
|