@selesai/code 0.5.28 → 0.6.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 +24 -0
- package/README.md +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +9 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/credential-print.d.ts +23 -0
- package/dist/cli/credential-print.d.ts.map +1 -0
- package/dist/cli/credential-print.js +117 -0
- package/dist/cli/credential-print.js.map +1 -0
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +1 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +3 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +12 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +20 -14
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +11 -3
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +11 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +14 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +10 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +1 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/llama/provider.d.ts.map +1 -1
- package/dist/core/llama/provider.js +8 -3
- package/dist/core/llama/provider.js.map +1 -1
- package/dist/core/model-config.d.ts +30 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +6 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +2 -2
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +20 -3
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +2 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +5 -4
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +13 -6
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +24 -11
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +15 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +66 -9
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +19 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/system-prompt.test.d.ts +2 -0
- package/dist/core/system-prompt.test.d.ts.map +1 -0
- package/dist/core/system-prompt.test.js +89 -0
- package/dist/core/system-prompt.test.js.map +1 -0
- package/dist/core/tools/bash.d.ts +2 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +34 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +3 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/defaults/models.json +13 -45
- package/dist/defaults/settings.json +1 -2
- package/dist/extensions/copy-turn.test.ts +131 -0
- package/dist/extensions/copy-turn.ts +6 -1
- package/dist/extensions/package.json +0 -1
- package/dist/extensions/pi-intercom/CHANGELOG.md +249 -0
- package/dist/extensions/pi-intercom/README.md +102 -39
- package/dist/extensions/pi-intercom/broker/broker.ts +1233 -36
- package/dist/extensions/pi-intercom/broker/client.test.ts +83 -0
- package/dist/extensions/pi-intercom/broker/client.ts +315 -12
- package/dist/extensions/pi-intercom/broker/extension-state.ts +186 -0
- package/dist/extensions/pi-intercom/broker/extension.test.ts +387 -0
- package/dist/extensions/pi-intercom/broker/framing.test.ts +114 -0
- package/dist/extensions/pi-intercom/broker/framing.ts +82 -24
- package/dist/extensions/pi-intercom/broker/paths.test.ts +153 -0
- package/dist/extensions/pi-intercom/broker/paths.ts +117 -8
- package/dist/extensions/pi-intercom/broker/runtime-claim.test.ts +34 -0
- package/dist/extensions/pi-intercom/broker/runtime-claim.ts +21 -0
- package/dist/extensions/pi-intercom/broker/spawn.test.ts +160 -23
- package/dist/extensions/pi-intercom/broker/spawn.ts +113 -27
- package/dist/extensions/pi-intercom/config.test.ts +93 -0
- package/dist/extensions/pi-intercom/config.ts +55 -6
- package/dist/extensions/pi-intercom/cwd.test.ts +40 -0
- package/dist/extensions/pi-intercom/cwd.ts +31 -0
- package/dist/extensions/pi-intercom/extension-api.ts +44 -0
- package/dist/extensions/pi-intercom/format-context.test.ts +31 -0
- package/dist/extensions/pi-intercom/format-context.ts +32 -0
- package/dist/extensions/pi-intercom/index.ts +742 -145
- package/dist/extensions/pi-intercom/intercom.integration.test.ts +2646 -0
- package/dist/extensions/pi-intercom/package.json +15 -5
- package/dist/extensions/pi-intercom/reply-tracker.test.ts +134 -0
- package/dist/extensions/pi-intercom/reply-tracker.ts +31 -13
- package/dist/extensions/pi-intercom/skills/pi-intercom/SKILL.md +13 -11
- package/dist/extensions/pi-intercom/test/inline-message.test.ts +184 -0
- package/dist/extensions/pi-intercom/test/overlay-width.test.ts +66 -0
- package/dist/extensions/pi-intercom/types.ts +94 -4
- package/dist/extensions/pi-intercom/ui/compose.ts +8 -4
- package/dist/extensions/pi-intercom/ui/inline-message.ts +61 -25
- package/dist/extensions/pi-intercom/ui/session-list.ts +7 -3
- package/dist/extensions/pi-subagents/CHANGELOG.md +88 -0
- package/dist/extensions/pi-subagents/LICENSE +21 -0
- package/dist/extensions/pi-subagents/README.md +158 -69
- package/dist/extensions/pi-subagents/agents/architect.md +5 -4
- package/dist/extensions/pi-subagents/agents/builder.md +6 -4
- package/dist/extensions/pi-subagents/agents/commentator.md +3 -2
- package/dist/extensions/pi-subagents/agents/explorer.md +3 -2
- package/dist/extensions/pi-subagents/agents/recapper.md +3 -2
- package/dist/extensions/pi-subagents/agents/researcher.md +4 -3
- package/dist/extensions/pi-subagents/package-lock.json +2 -2
- package/dist/extensions/pi-subagents/package.json +3 -3
- package/dist/extensions/pi-subagents/prompts/review-loop.md +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +22 -988
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +257 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +431 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +144 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +281 -0
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +125 -37
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +4 -0
- package/dist/extensions/pi-subagents/src/agents/agents.ts +118 -9
- package/dist/extensions/pi-subagents/src/agents/skills.ts +14 -12
- package/dist/extensions/pi-subagents/src/agents/task-aware-routing.ts +125 -0
- package/dist/extensions/pi-subagents/src/api/delegation.ts +3 -0
- package/dist/extensions/pi-subagents/src/api/preflight.ts +17 -13
- package/dist/extensions/pi-subagents/src/extension/chain-validation.ts +17 -1
- package/dist/extensions/pi-subagents/src/extension/index.ts +22 -8
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +248 -6
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +33 -8
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +32 -14
- package/dist/extensions/pi-subagents/src/intercom/intercom-bridge.ts +9 -4
- package/dist/extensions/pi-subagents/src/intercom/result-intercom.ts +33 -4
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +86 -21
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +24 -13
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +7 -5
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +18 -2
- package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +48 -5
- package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +68 -1
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +56 -5
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +92 -11
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +29 -3
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +388 -29
- package/dist/extensions/pi-subagents/src/runs/foreground/async-stop-action.ts +65 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-clarify.ts +3 -3
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +214 -60
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +546 -252
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +42 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +553 -154
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +19 -13
- package/dist/extensions/pi-subagents/src/runs/shared/capability-ceiling.ts +51 -19
- package/dist/extensions/pi-subagents/src/runs/shared/chain-outputs.ts +3 -1
- package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +44 -11
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +8 -0
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +97 -20
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +43 -12
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +52 -4
- package/dist/extensions/pi-subagents/src/runs/shared/process-signal.ts +19 -0
- package/dist/extensions/pi-subagents/src/runs/shared/run-history.ts +45 -9
- package/dist/extensions/pi-subagents/src/runs/shared/runtime-acknowledged-extensions.ts +71 -0
- package/dist/extensions/pi-subagents/src/runs/shared/single-output.ts +63 -9
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +31 -1
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-startup-retry.ts +101 -0
- package/dist/extensions/pi-subagents/src/runs/shared/task-intent.ts +22 -1
- package/dist/extensions/pi-subagents/src/runs/shared/usage-budget.ts +65 -0
- package/dist/extensions/pi-subagents/src/runs/shared/workflow-graph.ts +26 -1
- package/dist/extensions/pi-subagents/src/shared/settings.ts +17 -1
- package/dist/extensions/pi-subagents/src/shared/types.ts +196 -12
- package/dist/extensions/pi-subagents/src/shared/utils.ts +102 -5
- package/dist/extensions/pi-subagents/src/slash/delegation-adapters.ts +10 -1
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +46 -4
- package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +5 -3
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +87 -24
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +182 -9
- package/dist/extensions/pi-subagents/src/tui/render.ts +55 -34
- package/dist/extensions/pi-subagents/src/watchdog/register-main.ts +14 -7
- package/dist/extensions/pi-subagents/src/watchdog/review.ts +5 -4
- package/dist/extensions/pi-subagents/src/watchdog/runtime.ts +170 -17
- package/dist/extensions/pi-subagents/src/watchdog/scope.ts +62 -0
- package/dist/extensions/pi-subagents/src/watchdog/settings.ts +41 -1
- package/dist/extensions/pi-subagents/src/watchdog/types.ts +10 -0
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +113 -8
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +419 -47
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +84 -0
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +4 -2
- package/dist/extensions/pi-subagents/test/integration/chain-clarify.test.ts +51 -2
- package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +62 -22
- package/dist/extensions/pi-subagents/test/integration/detect-error.test.ts +48 -0
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +8 -6
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +231 -19
- package/dist/extensions/pi-subagents/test/integration/parallel-execution.test.ts +48 -7
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +44 -0
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +199 -17
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +898 -16
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +112 -23
- package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +17 -5
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +2 -0
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +18 -2
- package/dist/extensions/pi-subagents/test/support/register-loader.mjs +3 -3
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +3 -1
- package/dist/extensions/pi-subagents/test/unit/agent-disabled.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +198 -6
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +161 -1
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +47 -2
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +60 -0
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +8 -0
- package/dist/extensions/pi-subagents/test/unit/builtin-agent-documentation.test.ts +63 -0
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-agent-allowlist.test.ts +136 -0
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/chain-append.test.ts +6 -0
- package/dist/extensions/pi-subagents/test/unit/chain-validation.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +48 -48
- package/dist/extensions/pi-subagents/test/unit/config-dir-runtime.test.ts +23 -0
- package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/unit/delegation-api.test.ts +28 -2
- package/dist/extensions/pi-subagents/test/unit/dynamic-fanout.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +176 -8
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +164 -5
- package/dist/extensions/pi-subagents/test/unit/foreground-control.test.ts +41 -1
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +17 -12
- package/dist/extensions/pi-subagents/test/unit/intercom-bridge.test.ts +18 -2
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +20 -1
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +30 -2
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +39 -2
- package/dist/extensions/pi-subagents/test/unit/parallel-utils.test.ts +22 -0
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +103 -0
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +18 -0
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +48 -0
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +13 -1
- package/dist/extensions/pi-subagents/test/unit/result-intercom.test.ts +29 -4
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +223 -4
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +30 -0
- package/dist/extensions/pi-subagents/test/unit/runtime-acknowledged-extensions.test.ts +52 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +46 -2
- package/dist/extensions/pi-subagents/test/unit/single-output.test.ts +91 -1
- package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/streamed-progress-bounds.test.ts +78 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +41 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-startup-retry.test.ts +77 -0
- package/dist/extensions/pi-subagents/test/unit/task-aware-routing.test.ts +213 -0
- package/dist/extensions/pi-subagents/test/unit/task-intent.test.ts +26 -1
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +61 -10
- package/dist/extensions/pi-subagents/test/unit/total-cost.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-runtime.test.ts +210 -1
- package/dist/extensions/pi-subagents/test/unit/watchdog-scope.test.ts +33 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-settings.test.ts +32 -0
- package/dist/extensions/pi-subagents/test/unit/writer-budget-guidance.test.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +43 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +3 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +10 -2
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -2
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +16 -46
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +4 -1
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +22 -13
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +12 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -0
- package/dist/modes/interactive/external-editor.js +37 -0
- package/dist/modes/interactive/external-editor.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +72 -64
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +14 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/skills/ponytail/SKILL.md +1 -3
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +19 -8
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +1 -1
- package/dist/utils/version-check.js.map +1 -1
- package/docs/compaction.md +1 -1
- package/docs/custom-provider.md +14 -5
- package/docs/environment-variables.md +86 -0
- package/docs/extensions.md +15 -5
- package/docs/index.md +1 -0
- package/docs/models.md +9 -2
- package/docs/plans/subagent-delegation/phase-0-correctness.md +265 -0
- package/docs/plans/subagent-delegation/phase-1-behavioral-contract.md +486 -0
- package/docs/plans/subagent-delegation/phase-2-context-controls.md +282 -0
- package/docs/plans/subagent-delegation/phase-3-advisory-routing.md +362 -0
- package/docs/plans/subagent-delegation/phase-4-optional-enforcement.md +381 -0
- package/docs/providers.md +21 -2
- package/docs/rpc.md +23 -6
- package/docs/session-format.md +2 -0
- package/docs/settings.md +1 -1
- package/docs/usage.md +0 -13
- package/examples/extensions/custom-compaction.ts +5 -2
- package/examples/extensions/custom-provider-anthropic/index.ts +9 -3
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/handoff.ts +11 -3
- package/examples/extensions/message-renderer.ts +3 -3
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/summarize.ts +5 -2
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/12-full-control.ts +3 -1
- package/package.json +16 -7
- package/dist/extensions/caveman/caveman-instructions.cjs +0 -11
- package/dist/extensions/caveman/index.js +0 -118
- package/dist/extensions/caveman/package.json +0 -8
- package/dist/extensions/caveman/test/extension.test.js +0 -203
- package/dist/extensions/caveman/test/helpers.test.js +0 -58
- package/dist/skills/caveman/SKILL.md +0 -50
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-gondolin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.83.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-gondolin",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.83.0",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@earendil-works/gondolin": "0.12.0"
|
|
12
12
|
}
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import type { AgentMessage } from "@earendil-works/pi-agent-core";
|
|
16
|
+
import { uuidv7 } from "@earendil-works/pi-ai";
|
|
16
17
|
import { complete, type Message } from "@earendil-works/pi-ai/compat";
|
|
17
|
-
import type { ExtensionAPI, SessionEntry } from "@
|
|
18
|
-
import { BorderedLoader, convertToLlm, serializeConversation } from "@
|
|
18
|
+
import type { ExtensionAPI, SessionEntry } from "@selesai/code";
|
|
19
|
+
import { BorderedLoader, convertToLlm, serializeConversation } from "@selesai/code";
|
|
19
20
|
|
|
20
21
|
const SYSTEM_PROMPT = `You are a context transfer assistant. Given a conversation history and the user's goal for a new thread, generate a focused prompt that:
|
|
21
22
|
|
|
@@ -136,7 +137,14 @@ export default function (pi: ExtensionAPI) {
|
|
|
136
137
|
const response = await complete(
|
|
137
138
|
ctx.model!,
|
|
138
139
|
{ systemPrompt: SYSTEM_PROMPT, messages: [userMessage] },
|
|
139
|
-
{
|
|
140
|
+
{
|
|
141
|
+
apiKey: auth.apiKey,
|
|
142
|
+
headers: auth.headers,
|
|
143
|
+
env: auth.env,
|
|
144
|
+
signal: loader.signal,
|
|
145
|
+
cacheRetention: "none",
|
|
146
|
+
sessionId: uuidv7(),
|
|
147
|
+
},
|
|
140
148
|
);
|
|
141
149
|
|
|
142
150
|
if (response.stopReason === "aborted") {
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
* Usage: /status [message] - sends a status message with custom rendering
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { ExtensionAPI } from "@
|
|
10
|
+
import type { ExtensionAPI } from "@selesai/code";
|
|
11
11
|
import { Box, Text } from "@earendil-works/pi-tui";
|
|
12
12
|
|
|
13
13
|
export default function (pi: ExtensionAPI) {
|
|
14
14
|
// Register custom renderer for "status-update" messages
|
|
15
|
-
pi.registerMessageRenderer("status-update", (message, { expanded }, theme) => {
|
|
15
|
+
pi.registerMessageRenderer("status-update", (message, { expanded, outputPad }, theme) => {
|
|
16
16
|
const details = message.details as { level: string; timestamp: number } | undefined;
|
|
17
17
|
const level = details?.level ?? "info";
|
|
18
18
|
|
|
@@ -29,7 +29,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// Use Box with customMessageBg for consistent styling
|
|
32
|
-
const box = new Box(
|
|
32
|
+
const box = new Box(outputPad, 1, (t) => theme.bg("customMessageBg", t));
|
|
33
33
|
box.addChild(new Text(text, 0, 0));
|
|
34
34
|
return box;
|
|
35
35
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-sandbox",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-sandbox",
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.13.0",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sandbox-runtime": "^0.0.26"
|
|
12
12
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { uuidv7 } from "@earendil-works/pi-ai";
|
|
1
2
|
import { complete, getModel } from "@earendil-works/pi-ai/compat";
|
|
2
|
-
import type { ExtensionAPI, ExtensionCommandContext } from "@
|
|
3
|
-
import { DynamicBorder, getMarkdownTheme } from "@
|
|
3
|
+
import type { ExtensionAPI, ExtensionCommandContext } from "@selesai/code";
|
|
4
|
+
import { DynamicBorder, getMarkdownTheme } from "@selesai/code";
|
|
4
5
|
import { Container, Markdown, matchesKey, Text } from "@earendil-works/pi-tui";
|
|
5
6
|
|
|
6
7
|
type ContentBlock = {
|
|
@@ -192,6 +193,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
192
193
|
apiKey: auth.apiKey,
|
|
193
194
|
headers: auth.headers,
|
|
194
195
|
reasoningEffort: "high",
|
|
196
|
+
cacheRetention: "none",
|
|
197
|
+
sessionId: uuidv7(),
|
|
195
198
|
},
|
|
196
199
|
);
|
|
197
200
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-with-deps",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.83.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-with-deps",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.83.0",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ms": "^2.1.3"
|
|
12
12
|
},
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
type ResourceLoader,
|
|
14
14
|
SessionManager,
|
|
15
15
|
SettingsManager,
|
|
16
|
-
} from "@
|
|
16
|
+
} from "@selesai/code";
|
|
17
17
|
|
|
18
18
|
// Custom auth storage location
|
|
19
19
|
const authStorage = AuthStorage.create("/tmp/my-agent/auth.json");
|
|
@@ -45,7 +45,9 @@ const resourceLoader: ResourceLoader = {
|
|
|
45
45
|
getAgentsFiles: () => ({ agentsFiles: [] }),
|
|
46
46
|
getSystemPrompt: () => `You are a minimal assistant.
|
|
47
47
|
Available: read, bash. Be concise.`,
|
|
48
|
+
getSystemPromptSource: () => undefined,
|
|
48
49
|
getAppendSystemPrompt: () => [],
|
|
50
|
+
getAppendSystemPromptSources: () => [],
|
|
49
51
|
extendResources: () => {},
|
|
50
52
|
reload: async () => {},
|
|
51
53
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@selesai/code",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Maintained, extension-first Pi coding agent with built-in workflows, subagents, web research, questions, skills, and an enhanced terminal UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -54,11 +54,10 @@
|
|
|
54
54
|
"copy-assets": "shx mkdir -p dist/modes/interactive/theme && shx cp src/modes/interactive/theme/*.json dist/modes/interactive/theme/ && shx mkdir -p dist/modes/interactive/assets && shx cp src/modes/interactive/assets/*.png dist/modes/interactive/assets/ && shx mkdir -p dist/core/export-html/vendor && shx cp src/core/export-html/template.html src/core/export-html/template.css src/core/export-html/template.js dist/core/export-html/ && shx cp src/core/export-html/vendor/*.js dist/core/export-html/vendor/ && shx mkdir -p dist/defaults && shx cp src/defaults/* dist/defaults/ && shx mkdir -p dist/extensions && shx cp -r src/extensions/. dist/extensions/ && shx mkdir -p dist/themes && shx cp -r src/themes/. dist/themes/ && shx mkdir -p dist/skills && shx cp -r src/skills/. dist/skills/"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@earendil-works/pi-agent-core": "0.
|
|
58
|
-
"@earendil-works/pi-ai": "0.
|
|
59
|
-
"@earendil-works/pi-tui": "0.
|
|
60
|
-
"@
|
|
61
|
-
"@mozilla/readability": "^0.6.0",
|
|
57
|
+
"@earendil-works/pi-agent-core": "0.83.0",
|
|
58
|
+
"@earendil-works/pi-ai": "0.83.0",
|
|
59
|
+
"@earendil-works/pi-tui": "0.83.0",
|
|
60
|
+
"@mozilla/readability": "^0.6.1",
|
|
62
61
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
63
62
|
"chalk": "5.6.2",
|
|
64
63
|
"cheerio": "^1.1.0",
|
|
@@ -75,7 +74,7 @@
|
|
|
75
74
|
"proper-lockfile": "4.1.2",
|
|
76
75
|
"semver": "7.8.0",
|
|
77
76
|
"tsx": "^4.20.0",
|
|
78
|
-
"typebox": "1.
|
|
77
|
+
"typebox": "1.3.7",
|
|
79
78
|
"undici": "8.5.0",
|
|
80
79
|
"yaml": "2.9.0"
|
|
81
80
|
},
|
|
@@ -91,5 +90,15 @@
|
|
|
91
90
|
"shx": "0.4.0",
|
|
92
91
|
"typescript": "5.9.3",
|
|
93
92
|
"vitest": "4.1.9"
|
|
93
|
+
},
|
|
94
|
+
"overrides": {
|
|
95
|
+
"protobufjs": "7.6.5",
|
|
96
|
+
"rimraf": "6.1.2",
|
|
97
|
+
"gaxios": {
|
|
98
|
+
"rimraf": "6.1.2"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"optionalDependencies": {
|
|
102
|
+
"@mariozechner/clipboard": "0.3.9"
|
|
94
103
|
}
|
|
95
104
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// The skill is user-facing documentation. This short runtime prompt is injected
|
|
3
|
-
// on every turn, while extension state owns activation and deactivation.
|
|
4
|
-
const CAVEMAN_INSTRUCTIONS =
|
|
5
|
-
'CAVEMAN MODE ACTIVE. Terse, technically complete: omit articles, filler, pleasantries, and hedging; fragments, short terms, standard abbreviations, and -> are OK. Preserve technical terms, code blocks, and quoted errors exactly. Use clear normal prose for security warnings, irreversible confirmations, risky multi-step instructions, or requested/repeated clarification; then resume terse mode.';
|
|
6
|
-
|
|
7
|
-
function getCavemanInstructions() {
|
|
8
|
-
return CAVEMAN_INSTRUCTIONS;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
module.exports = { getCavemanInstructions };
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
const require = createRequire(import.meta.url);
|
|
4
|
-
const { getCavemanInstructions } = require("./caveman-instructions.cjs");
|
|
5
|
-
|
|
6
|
-
export { getCavemanInstructions };
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export function parseCavemanCommand(text) {
|
|
11
|
-
const normalizedText = String(text || "").trim().toLowerCase();
|
|
12
|
-
if (!normalizedText) return { type: "toggle" };
|
|
13
|
-
|
|
14
|
-
const [primary] = normalizedText.split(/\s+/);
|
|
15
|
-
if (primary === "status") return { type: "status" };
|
|
16
|
-
if (primary === "on" || primary === "enable") return { type: "set", active: true };
|
|
17
|
-
if (primary === "off" || primary === "disable") return { type: "set", active: false };
|
|
18
|
-
return { type: "invalid", reason: "unknown-subcommand", arg: primary };
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function isDeactivationCommand(text) {
|
|
22
|
-
const t = String(text || "").trim().toLowerCase().replace(/[.!?\s]+$/, "");
|
|
23
|
-
return t === "stop caveman" || t === "normal mode";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function resolveSessionActive(entries, fallback = true) {
|
|
27
|
-
if (!Array.isArray(entries)) return fallback;
|
|
28
|
-
|
|
29
|
-
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
30
|
-
const entry = entries[i];
|
|
31
|
-
if (entry?.type !== "custom" || entry?.customType !== "caveman-mode") continue;
|
|
32
|
-
|
|
33
|
-
const active = entry?.data?.active;
|
|
34
|
-
if (typeof active === "boolean") return active;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return fallback;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export default function cavemanExtension(pi) {
|
|
41
|
-
let active = true;
|
|
42
|
-
let isActive = false;
|
|
43
|
-
let lastCtx = null;
|
|
44
|
-
|
|
45
|
-
function syncStatus(ctx) {
|
|
46
|
-
if (ctx) lastCtx = ctx;
|
|
47
|
-
const c = ctx || lastCtx;
|
|
48
|
-
if (!c?.ui?.setStatus || !c.ui.theme?.fg) return;
|
|
49
|
-
const theme = c.ui.theme;
|
|
50
|
-
if (!active) {
|
|
51
|
-
c.ui.setStatus("caveman", "");
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const indicator = isActive ? theme.fg("accent", "●") : theme.fg("dim", "○");
|
|
55
|
-
c.ui.setStatus("caveman", indicator + " 🦴 " + theme.fg("muted", "caveman: ") + theme.fg("text", active ? "ON" : "OFF"));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const setActive = (value, ctx) => {
|
|
59
|
-
active = Boolean(value);
|
|
60
|
-
pi.appendEntry("caveman-mode", { active });
|
|
61
|
-
syncStatus(ctx);
|
|
62
|
-
ctx?.ui?.notify?.(`Caveman mode ${active ? "enabled" : "disabled"}.`, "info");
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
pi.registerCommand("caveman", {
|
|
66
|
-
description: "Toggle or report Caveman mode",
|
|
67
|
-
handler: async (args, ctx) => {
|
|
68
|
-
const parsed = parseCavemanCommand(args);
|
|
69
|
-
|
|
70
|
-
if (parsed.type === "status") {
|
|
71
|
-
ctx?.ui?.notify?.(`Caveman: ${active ? "ON" : "OFF"}`, "info");
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (parsed.type === "toggle") {
|
|
76
|
-
setActive(!active, ctx);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (parsed.type === "set") {
|
|
81
|
-
setActive(parsed.active, ctx);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
ctx?.ui?.notify?.("Unknown /caveman subcommand. Use: on, off, status.", "warning");
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
pi.on("input", async (event) => {
|
|
90
|
-
if (event?.source === "extension") return;
|
|
91
|
-
const text = String(event?.text || "");
|
|
92
|
-
if (active && isDeactivationCommand(text)) {
|
|
93
|
-
setActive(false);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
pi.on("session_start", async (_event, ctx) => {
|
|
98
|
-
const entries = ctx?.sessionManager?.getBranch?.() || ctx?.sessionManager?.getEntries?.() || [];
|
|
99
|
-
active = resolveSessionActive(entries);
|
|
100
|
-
syncStatus(ctx);
|
|
101
|
-
ctx?.ui?.notify?.(`Caveman loaded: ${active ? "ON" : "OFF"}`, "info");
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
pi.on("agent_start", async (_event, ctx) => {
|
|
105
|
-
isActive = true;
|
|
106
|
-
syncStatus(ctx);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
pi.on("agent_end", async (_event, ctx) => {
|
|
110
|
-
isActive = false;
|
|
111
|
-
syncStatus(ctx);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
pi.on("before_agent_start", async (event) => {
|
|
115
|
-
if (!active) return;
|
|
116
|
-
return { systemPrompt: `${event.systemPrompt}\n\n${getCavemanInstructions()}` };
|
|
117
|
-
});
|
|
118
|
-
}
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import test from "node:test";
|
|
3
|
-
|
|
4
|
-
import cavemanExtension from "../index.js";
|
|
5
|
-
|
|
6
|
-
function createPiHarness() {
|
|
7
|
-
const events = new Map();
|
|
8
|
-
const commands = new Map();
|
|
9
|
-
const appendedEntries = [];
|
|
10
|
-
const sentUserMessages = [];
|
|
11
|
-
|
|
12
|
-
const pi = {
|
|
13
|
-
on(eventName, handler) { events.set(eventName, handler); },
|
|
14
|
-
registerCommand(name, options) { commands.set(name, options); },
|
|
15
|
-
appendEntry(customType, data) { appendedEntries.push({ customType, data }); },
|
|
16
|
-
sendUserMessage(text, options) { sentUserMessages.push({ text, options }); },
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
cavemanExtension(pi);
|
|
20
|
-
return { events, commands, appendedEntries, sentUserMessages };
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function createCommandContext(overrides = {}) {
|
|
24
|
-
return {
|
|
25
|
-
isIdle: () => true,
|
|
26
|
-
sessionManager: { getEntries: () => [] },
|
|
27
|
-
ui: { notify() {} },
|
|
28
|
-
...overrides,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
test("extension registers the /caveman command", () => {
|
|
33
|
-
const { commands } = createPiHarness();
|
|
34
|
-
assert.deepEqual([...commands.keys()], ["caveman"]);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test("/caveman on/off appends a caveman-mode entry", async () => {
|
|
38
|
-
const { commands, events, appendedEntries } = createPiHarness();
|
|
39
|
-
const ctx = createCommandContext();
|
|
40
|
-
|
|
41
|
-
await events.get("session_start")({ reason: "startup" }, ctx);
|
|
42
|
-
await commands.get("caveman").handler("off", ctx);
|
|
43
|
-
|
|
44
|
-
assert.deepEqual(appendedEntries.at(-1), { customType: "caveman-mode", data: { active: false } });
|
|
45
|
-
|
|
46
|
-
await commands.get("caveman").handler("on", ctx);
|
|
47
|
-
assert.deepEqual(appendedEntries.at(-1), { customType: "caveman-mode", data: { active: true } });
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test("bare /caveman toggles off then back on", async () => {
|
|
51
|
-
const { commands, events, appendedEntries } = createPiHarness();
|
|
52
|
-
const ctx = createCommandContext();
|
|
53
|
-
|
|
54
|
-
await events.get("session_start")({ reason: "startup" }, ctx); // starts on
|
|
55
|
-
await commands.get("caveman").handler("", ctx);
|
|
56
|
-
assert.equal(appendedEntries.at(-1).data.active, false);
|
|
57
|
-
await commands.get("caveman").handler("", ctx);
|
|
58
|
-
assert.equal(appendedEntries.at(-1).data.active, true);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test("before_agent_start injects instructions while active", async () => {
|
|
62
|
-
const { events } = createPiHarness();
|
|
63
|
-
const ctx = createCommandContext();
|
|
64
|
-
|
|
65
|
-
await events.get("session_start")({ reason: "startup" }, ctx);
|
|
66
|
-
const result = await events.get("before_agent_start")({ systemPrompt: "BASE" }, ctx);
|
|
67
|
-
|
|
68
|
-
assert.ok(result.systemPrompt.startsWith("BASE"));
|
|
69
|
-
assert.ok(result.systemPrompt.includes("CAVEMAN MODE ACTIVE"));
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test("disabled caveman skips instruction injection", async () => {
|
|
73
|
-
const { commands, events } = createPiHarness();
|
|
74
|
-
const ctx = createCommandContext();
|
|
75
|
-
|
|
76
|
-
await events.get("session_start")({ reason: "startup" }, ctx);
|
|
77
|
-
await commands.get("caveman").handler("off", ctx);
|
|
78
|
-
const result = await events.get("before_agent_start")({ systemPrompt: "BASE" }, ctx);
|
|
79
|
-
|
|
80
|
-
assert.equal(result, undefined);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test("session_start restores persisted OFF state", async () => {
|
|
84
|
-
const { events } = createPiHarness();
|
|
85
|
-
const ctx = createCommandContext({
|
|
86
|
-
sessionManager: {
|
|
87
|
-
getBranch: () => [
|
|
88
|
-
{ type: "custom", customType: "caveman-mode", data: { active: false } },
|
|
89
|
-
],
|
|
90
|
-
getEntries: () => [
|
|
91
|
-
{ type: "custom", customType: "caveman-mode", data: { active: true } },
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
await events.get("session_start")({ reason: "resume" }, ctx);
|
|
97
|
-
const result = await events.get("before_agent_start")({ systemPrompt: "BASE" }, ctx);
|
|
98
|
-
|
|
99
|
-
assert.equal(result, undefined);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
test("session_start defaults to ON when no persisted entry exists", async () => {
|
|
103
|
-
const { commands, events } = createPiHarness();
|
|
104
|
-
const ctx = createCommandContext();
|
|
105
|
-
|
|
106
|
-
await events.get("session_start")({ reason: "startup" }, ctx);
|
|
107
|
-
await commands.get("caveman").handler("off", ctx);
|
|
108
|
-
|
|
109
|
-
// Simulate a fresh session_start (new harness = fresh active state)
|
|
110
|
-
const { events: events2 } = createPiHarness();
|
|
111
|
-
await events2.get("session_start")({ reason: "new" }, ctx);
|
|
112
|
-
const result = await events2.get("before_agent_start")({ systemPrompt: "BASE" }, ctx);
|
|
113
|
-
|
|
114
|
-
assert.ok(result.systemPrompt.includes("CAVEMAN MODE ACTIVE"));
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test("'stop caveman' as a whole message deactivates mid-session", async () => {
|
|
118
|
-
const { events } = createPiHarness();
|
|
119
|
-
const ctx = createCommandContext();
|
|
120
|
-
|
|
121
|
-
await events.get("session_start")({ reason: "startup" }, ctx);
|
|
122
|
-
await events.get("input")({ text: "stop caveman", source: "interactive" }, ctx);
|
|
123
|
-
|
|
124
|
-
const result = await events.get("before_agent_start")({ systemPrompt: "BASE" }, ctx);
|
|
125
|
-
assert.equal(result, undefined);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
test("a request merely mentioning 'stop caveman' stays active", async () => {
|
|
129
|
-
const { events } = createPiHarness();
|
|
130
|
-
const ctx = createCommandContext();
|
|
131
|
-
|
|
132
|
-
await events.get("session_start")({ reason: "startup" }, ctx);
|
|
133
|
-
await events.get("input")({ text: "how do I stop caveman re-rendering?", source: "interactive" }, ctx);
|
|
134
|
-
|
|
135
|
-
const result = await events.get("before_agent_start")({ systemPrompt: "BASE" }, ctx);
|
|
136
|
-
assert.ok(result.systemPrompt.includes("CAVEMAN MODE ACTIVE"));
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
test("status bar renders ON and flips active on agent_start", async () => {
|
|
140
|
-
const { events } = createPiHarness();
|
|
141
|
-
const statusWrites = [];
|
|
142
|
-
const ctx = createCommandContext({
|
|
143
|
-
sessionManager: { getEntries: () => [] },
|
|
144
|
-
ui: { notify() {}, setStatus: (key, text) => statusWrites.push({ key, text }), theme: { fg: (_c, t) => t } },
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
await events.get("session_start")({ reason: "startup" }, ctx);
|
|
148
|
-
await events.get("agent_start")({}, ctx);
|
|
149
|
-
|
|
150
|
-
assert.equal(statusWrites.at(-2).key, "caveman");
|
|
151
|
-
assert.match(statusWrites.at(-2).text, /○.*ON/);
|
|
152
|
-
assert.match(statusWrites.at(-1).text, /●.*ON/);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
test("status bar clears when disabled", async () => {
|
|
156
|
-
const { events, commands } = createPiHarness();
|
|
157
|
-
const statusWrites = [];
|
|
158
|
-
const ctx = createCommandContext({
|
|
159
|
-
ui: { notify() {}, setStatus: (key, text) => statusWrites.push({ key, text }), theme: { fg: (_c, t) => t } },
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
await events.get("session_start")({ reason: "startup" }, ctx);
|
|
163
|
-
await commands.get("caveman").handler("off", ctx);
|
|
164
|
-
|
|
165
|
-
assert.deepEqual(statusWrites.at(-1), { key: "caveman", text: "" });
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
test("status bar stays silent when ui lacks a theme", async () => {
|
|
169
|
-
const { events } = createPiHarness();
|
|
170
|
-
const calls = [];
|
|
171
|
-
const ctx = createCommandContext({
|
|
172
|
-
sessionManager: { getEntries: () => [] },
|
|
173
|
-
ui: { notify() {}, setStatus: (_key, text) => calls.push(text) }, // no theme
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
await events.get("session_start")({ reason: "startup" }, ctx);
|
|
177
|
-
await events.get("agent_start")({}, ctx);
|
|
178
|
-
|
|
179
|
-
assert.deepEqual(calls, []);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
test("invalid subcommand notifies warning and does not append", async () => {
|
|
183
|
-
const { commands, appendedEntries } = createPiHarness();
|
|
184
|
-
let notified = null;
|
|
185
|
-
const ctx = createCommandContext({ ui: { notify: (_m, kind) => { notified = kind; } } });
|
|
186
|
-
|
|
187
|
-
await commands.get("caveman").handler("banana", ctx);
|
|
188
|
-
|
|
189
|
-
assert.equal(notified, "warning");
|
|
190
|
-
assert.equal(appendedEntries.length, 0);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
test("status subcommand reports without changing state", async () => {
|
|
194
|
-
const { commands, events, appendedEntries } = createPiHarness();
|
|
195
|
-
let reported = null;
|
|
196
|
-
const ctx = createCommandContext({ ui: { notify: (m) => { reported = m; } } });
|
|
197
|
-
|
|
198
|
-
await events.get("session_start")({ reason: "startup" }, ctx); // starts on
|
|
199
|
-
await commands.get("caveman").handler("status", ctx);
|
|
200
|
-
|
|
201
|
-
assert.match(reported, /ON/);
|
|
202
|
-
assert.equal(appendedEntries.length, 0);
|
|
203
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import test from "node:test";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
getCavemanInstructions,
|
|
6
|
-
isDeactivationCommand,
|
|
7
|
-
parseCavemanCommand,
|
|
8
|
-
resolveSessionActive,
|
|
9
|
-
} from "../index.js";
|
|
10
|
-
|
|
11
|
-
test("parseCavemanCommand: bare toggles", () => {
|
|
12
|
-
assert.deepEqual(parseCavemanCommand(""), { type: "toggle" });
|
|
13
|
-
assert.deepEqual(parseCavemanCommand(" "), { type: "toggle" });
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test("parseCavemanCommand: on/off/status", () => {
|
|
17
|
-
assert.deepEqual(parseCavemanCommand("on"), { type: "set", active: true });
|
|
18
|
-
assert.deepEqual(parseCavemanCommand("ENABLE"), { type: "set", active: true });
|
|
19
|
-
assert.deepEqual(parseCavemanCommand("off"), { type: "set", active: false });
|
|
20
|
-
assert.deepEqual(parseCavemanCommand("disable"), { type: "set", active: false });
|
|
21
|
-
assert.deepEqual(parseCavemanCommand("status"), { type: "status" });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("parseCavemanCommand: unknown arg is invalid", () => {
|
|
25
|
-
assert.deepEqual(parseCavemanCommand("banana"), { type: "invalid", reason: "unknown-subcommand", arg: "banana" });
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test("resolveSessionActive: returns last persisted boolean, defaults to true", () => {
|
|
29
|
-
assert.equal(resolveSessionActive([]), true);
|
|
30
|
-
assert.equal(resolveSessionActive([{ type: "custom", customType: "caveman-mode", data: { active: false } }]), false);
|
|
31
|
-
assert.equal(resolveSessionActive([{ type: "custom", customType: "caveman-mode", data: { active: true } }]), true);
|
|
32
|
-
assert.equal(resolveSessionActive([
|
|
33
|
-
{ type: "custom", customType: "caveman-mode", data: { active: false } },
|
|
34
|
-
{ type: "custom", customType: "caveman-mode", data: { active: true } },
|
|
35
|
-
]), true);
|
|
36
|
-
assert.equal(resolveSessionActive([{ type: "custom", customType: "other", data: {} }]), true);
|
|
37
|
-
assert.equal(resolveSessionActive(null), true);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test("isDeactivationCommand: only the whole message, case-insensitive, trailing punct ok", () => {
|
|
41
|
-
assert.equal(isDeactivationCommand("stop caveman"), true);
|
|
42
|
-
assert.equal(isDeactivationCommand("STOP CAVEMAN!"), true);
|
|
43
|
-
assert.equal(isDeactivationCommand("normal mode"), true);
|
|
44
|
-
assert.equal(isDeactivationCommand("Normal Mode."), true);
|
|
45
|
-
assert.equal(isDeactivationCommand("add a normal mode toggle"), false);
|
|
46
|
-
assert.equal(isDeactivationCommand("how do I stop caveman re-rendering"), false);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test("getCavemanInstructions returns the compact runtime prompt", () => {
|
|
50
|
-
const instructions = getCavemanInstructions();
|
|
51
|
-
|
|
52
|
-
assert.equal(instructions,
|
|
53
|
-
"CAVEMAN MODE ACTIVE. Terse, technically complete: omit articles, filler, pleasantries, and hedging; fragments, short terms, standard abbreviations, and -> are OK. Preserve technical terms, code blocks, and quoted errors exactly. Use clear normal prose for security warnings, irreversible confirmations, risky multi-step instructions, or requested/repeated clarification; then resume terse mode.");
|
|
54
|
-
assert.ok(!instructions.includes("Persistence"));
|
|
55
|
-
assert.ok(!instructions.includes("stop caveman"));
|
|
56
|
-
assert.ok(!instructions.includes("normal mode"));
|
|
57
|
-
assert.ok(instructions.length < 400);
|
|
58
|
-
});
|