@selesai/code 0.5.19 → 0.5.21
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/dist/extensions/handoff-new.test.ts +8 -9
- package/dist/extensions/handoff-new.ts +6 -8
- package/dist/extensions/pi-intercom/broker/spawn.test.ts +31 -0
- package/dist/extensions/pi-intercom/broker/spawn.ts +5 -3
- package/dist/extensions/pi-subagents/CHANGELOG.md +1367 -0
- package/dist/extensions/pi-subagents/README.md +602 -220
- package/dist/extensions/pi-subagents/banner.png +0 -0
- package/dist/extensions/pi-subagents/index.ts +1 -0
- package/dist/extensions/pi-subagents/install.mjs +3 -3
- package/dist/extensions/pi-subagents/package-lock.json +3405 -0
- package/dist/extensions/pi-subagents/package.json +26 -14
- package/dist/extensions/pi-subagents/prompts/gather-context-and-clarify.md +1 -1
- package/dist/extensions/pi-subagents/prompts/parallel-cleanup.md +9 -9
- package/dist/extensions/pi-subagents/prompts/parallel-context-build.md +3 -3
- package/dist/extensions/pi-subagents/prompts/parallel-handoff-plan.md +7 -7
- package/dist/extensions/pi-subagents/prompts/parallel-research.md +6 -6
- package/dist/extensions/pi-subagents/prompts/parallel-review.md +8 -8
- package/dist/extensions/pi-subagents/prompts/review-loop.md +13 -11
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +267 -176
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +89 -16
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +19 -0
- package/dist/extensions/pi-subagents/src/agents/agents.ts +218 -120
- package/dist/extensions/pi-subagents/src/agents/frontmatter.ts +67 -13
- package/dist/extensions/pi-subagents/src/agents/proactive-skills.ts +2 -2
- package/dist/extensions/pi-subagents/src/agents/skills.ts +25 -12
- package/dist/extensions/pi-subagents/src/api/background-work.ts +197 -0
- package/dist/extensions/pi-subagents/src/api/capability-ceiling.ts +17 -0
- package/dist/extensions/pi-subagents/src/api/delegation.ts +285 -0
- package/dist/extensions/pi-subagents/src/api/preflight.ts +399 -0
- package/dist/extensions/pi-subagents/src/extension/chain-validation.ts +165 -0
- package/dist/extensions/pi-subagents/src/extension/config.ts +7 -1
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +15 -0
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +3 -1
- package/dist/extensions/pi-subagents/src/extension/index.ts +113 -157
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +41 -4
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +45 -15
- package/dist/extensions/pi-subagents/src/extension/steering-notices.ts +35 -0
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +28 -15
- package/dist/extensions/pi-subagents/src/intercom/intercom-bridge.ts +4 -3
- package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +225 -29
- package/dist/extensions/pi-subagents/src/intercom/result-intercom.ts +11 -0
- package/dist/extensions/pi-subagents/src/profiles/profiles.ts +8 -10
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +452 -62
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +60 -9
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +198 -52
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +119 -21
- package/dist/extensions/pi-subagents/src/runs/background/auto-drain.ts +67 -0
- package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +16 -8
- package/dist/extensions/pi-subagents/src/runs/background/completion-batcher.ts +6 -4
- package/dist/extensions/pi-subagents/src/runs/background/completion-dedupe.ts +2 -11
- package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +260 -13
- package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +32 -6
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +171 -90
- package/dist/extensions/pi-subagents/src/runs/background/process-terminal.ts +280 -0
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +149 -88
- package/dist/extensions/pi-subagents/src/runs/background/run-id-resolver.ts +14 -2
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +33 -17
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +9 -1
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +38 -10
- package/dist/extensions/pi-subagents/src/runs/background/steering.ts +237 -0
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +1297 -307
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +610 -0
- package/dist/extensions/pi-subagents/src/runs/background/top-level-async.ts +2 -1
- package/dist/extensions/pi-subagents/src/runs/background/wait-config.ts +36 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-tool.ts +26 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +230 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-clarify.ts +22 -6
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +228 -140
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +452 -138
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +90 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +1001 -416
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +443 -132
- package/dist/extensions/pi-subagents/src/runs/shared/agent-contract.ts +38 -0
- package/dist/extensions/pi-subagents/src/runs/shared/capability-ceiling.ts +178 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-protocol.ts +121 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +41 -93
- package/dist/extensions/pi-subagents/src/runs/shared/context-mode.ts +44 -0
- package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +11 -9
- package/dist/extensions/pi-subagents/src/runs/shared/long-running-guard.ts +4 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +12 -6
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +36 -0
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +44 -7
- package/dist/extensions/pi-subagents/src/runs/shared/nested-render.ts +4 -1
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +154 -0
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +18 -0
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +174 -54
- package/dist/extensions/pi-subagents/src/runs/shared/pi-spawn.ts +38 -31
- package/dist/extensions/pi-subagents/src/runs/shared/run-history.ts +90 -5
- package/dist/extensions/pi-subagents/src/runs/shared/session-lease.ts +299 -0
- package/dist/extensions/pi-subagents/src/runs/shared/single-output.ts +61 -6
- package/dist/extensions/pi-subagents/src/runs/shared/spawn-budget.ts +128 -0
- package/dist/extensions/pi-subagents/src/runs/shared/structured-output.ts +112 -7
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +14 -6
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +149 -36
- package/dist/extensions/pi-subagents/src/runs/shared/task-intent.ts +181 -0
- package/dist/extensions/pi-subagents/src/runs/shared/tool-availability.ts +83 -0
- package/dist/extensions/pi-subagents/src/runs/shared/tool-budget.ts +11 -5
- package/dist/extensions/pi-subagents/src/runs/shared/turn-budget.ts +50 -4
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +63 -14
- package/dist/extensions/pi-subagents/src/shared/accessible-dir.ts +25 -0
- package/dist/extensions/pi-subagents/src/shared/artifacts.ts +37 -7
- package/dist/extensions/pi-subagents/src/shared/atomic-json.ts +18 -43
- package/dist/extensions/pi-subagents/src/shared/child-transcript.ts +52 -0
- package/dist/extensions/pi-subagents/src/shared/env.ts +16 -0
- package/dist/extensions/pi-subagents/src/shared/file-system-retry.ts +47 -0
- package/dist/extensions/pi-subagents/src/shared/fork-context.ts +28 -3
- package/dist/extensions/pi-subagents/src/shared/launch-contract.ts +123 -0
- package/dist/extensions/pi-subagents/src/shared/model-info.ts +8 -5
- package/dist/extensions/pi-subagents/src/shared/settings.ts +9 -1
- package/dist/extensions/pi-subagents/src/shared/status-format.ts +7 -1
- package/dist/extensions/pi-subagents/src/shared/types.ts +522 -51
- package/dist/extensions/pi-subagents/src/shared/utils.ts +59 -53
- package/dist/extensions/pi-subagents/src/slash/delegation-adapters.ts +604 -0
- package/dist/extensions/pi-subagents/src/slash/delegation-json.ts +108 -0
- package/dist/extensions/pi-subagents/src/slash/delegation-request.ts +249 -0
- package/dist/extensions/pi-subagents/src/slash/prompt-template-bridge.ts +353 -345
- package/dist/extensions/pi-subagents/src/slash/prompt-workflows.ts +2 -2
- package/dist/extensions/pi-subagents/src/slash/selector.ts +147 -0
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +265 -23
- package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +2 -2
- package/dist/extensions/pi-subagents/src/slash/subagents-admin.ts +428 -0
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +362 -0
- package/dist/extensions/pi-subagents/src/tui/fleet-transcript.ts +472 -0
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +664 -0
- package/dist/extensions/pi-subagents/src/tui/render.ts +115 -31
- package/dist/extensions/pi-subagents/src/watchdog/change-signature.ts +220 -0
- package/dist/extensions/pi-subagents/src/watchdog/child-status.ts +205 -0
- package/dist/extensions/pi-subagents/src/watchdog/emission-guard.ts +123 -0
- package/dist/extensions/pi-subagents/src/watchdog/lsp-diagnostics.ts +532 -0
- package/dist/extensions/pi-subagents/src/watchdog/model-selection.ts +167 -0
- package/dist/extensions/pi-subagents/src/watchdog/register-child.ts +117 -0
- package/dist/extensions/pi-subagents/src/watchdog/register-main.ts +433 -0
- package/dist/extensions/pi-subagents/src/watchdog/render.ts +54 -0
- package/dist/extensions/pi-subagents/src/watchdog/review.ts +298 -0
- package/dist/extensions/pi-subagents/src/watchdog/runtime.ts +714 -0
- package/dist/extensions/pi-subagents/src/watchdog/settings.ts +528 -0
- package/dist/extensions/pi-subagents/src/watchdog/tool-actions.ts +155 -0
- package/dist/extensions/pi-subagents/src/watchdog/turn-delta.ts +161 -0
- package/dist/extensions/pi-subagents/src/watchdog/types.ts +188 -0
- package/dist/extensions/pi-subagents/src/watchdog/warning-format.ts +73 -0
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +130 -2
- package/dist/extensions/pi-subagents/test/integration/acceptance-file-report.test.ts +439 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +1632 -61
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +54 -1
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +112 -0
- package/dist/extensions/pi-subagents/test/integration/chain-clarify.test.ts +98 -1
- package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +179 -9
- package/dist/extensions/pi-subagents/test/integration/detect-error.test.ts +16 -9
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +6 -5
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +589 -9
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +528 -21
- package/dist/extensions/pi-subagents/test/integration/parallel-execution.test.ts +227 -3
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +235 -7
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +172 -2
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +1502 -18
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +993 -4
- package/dist/extensions/pi-subagents/test/integration/slash-live-state.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/integration/top-level-async.test.ts +7 -1
- package/dist/extensions/pi-subagents/test/support/helpers.ts +32 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +59 -2
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +32 -6
- package/dist/extensions/pi-subagents/test/support/real-session-child-cli.mjs +25 -24
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +59 -35
- package/dist/extensions/pi-subagents/test/support/session-lease-child.mjs +42 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +703 -69
- package/dist/extensions/pi-subagents/test/unit/accessible-dir.test.ts +82 -0
- package/dist/extensions/pi-subagents/test/unit/agent-disabled.test.ts +15 -15
- package/dist/extensions/pi-subagents/test/unit/agent-eject-disable.test.ts +66 -66
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +478 -19
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +228 -7
- package/dist/extensions/pi-subagents/test/unit/agent-memory.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +198 -78
- package/dist/extensions/pi-subagents/test/unit/async-execution.test.ts +15 -1
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +102 -7
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +439 -6
- package/dist/extensions/pi-subagents/test/unit/atomic-json.test.ts +41 -1
- package/dist/extensions/pi-subagents/test/unit/auto-drain.test.ts +79 -0
- package/dist/extensions/pi-subagents/test/unit/background-work.test.ts +285 -0
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-pi-args.test.ts +84 -0
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling.test.ts +68 -0
- package/dist/extensions/pi-subagents/test/unit/chain-validation.test.ts +326 -0
- package/dist/extensions/pi-subagents/test/unit/child-protocol.test.ts +82 -0
- package/dist/extensions/pi-subagents/test/unit/child-transcript.test.ts +46 -4
- package/dist/extensions/pi-subagents/test/unit/completion-batcher.test.ts +3 -1
- package/dist/extensions/pi-subagents/test/unit/completion-dedupe.test.ts +9 -17
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +175 -3
- package/dist/extensions/pi-subagents/test/unit/config-dir-runtime.test.ts +10 -5
- package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +126 -6
- package/dist/extensions/pi-subagents/test/unit/default-extensions.test.ts +219 -0
- package/dist/extensions/pi-subagents/test/unit/delegation-api.test.ts +913 -0
- package/dist/extensions/pi-subagents/test/unit/doctor.test.ts +13 -2
- package/dist/extensions/pi-subagents/test/unit/dynamic-fanout.test.ts +3 -3
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +351 -0
- package/dist/extensions/pi-subagents/test/unit/fleet-transcript.test.ts +280 -0
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +575 -0
- package/dist/extensions/pi-subagents/test/unit/foreground-control.test.ts +65 -0
- package/dist/extensions/pi-subagents/test/unit/fork-context.test.ts +94 -1
- package/dist/extensions/pi-subagents/test/unit/get-final-output.test.ts +23 -0
- package/dist/extensions/pi-subagents/test/unit/host-peer-runtime-imports.test.ts +157 -0
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +367 -5
- package/dist/extensions/pi-subagents/test/unit/intercom-bridge.test.ts +11 -0
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +36 -0
- package/dist/extensions/pi-subagents/test/unit/model-info.test.ts +25 -3
- package/dist/extensions/pi-subagents/test/unit/model-scope.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +341 -10
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +16 -0
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +52 -0
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +168 -7
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +85 -7
- package/dist/extensions/pi-subagents/test/unit/parallel-handoff.test.ts +175 -0
- package/dist/extensions/pi-subagents/test/unit/path-resolution.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +243 -16
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +79 -36
- package/dist/extensions/pi-subagents/test/unit/pi-spawn.test.ts +174 -56
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +322 -0
- package/dist/extensions/pi-subagents/test/unit/process-terminal.test.ts +204 -0
- package/dist/extensions/pi-subagents/test/unit/recursion-guard.test.ts +20 -12
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +117 -4
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +40 -7
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +48 -1
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +21 -3
- package/dist/extensions/pi-subagents/test/unit/selector.test.ts +57 -0
- package/dist/extensions/pi-subagents/test/unit/session-lease.test.ts +326 -0
- package/dist/extensions/pi-subagents/test/unit/single-output.test.ts +101 -2
- package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +111 -1
- package/dist/extensions/pi-subagents/test/unit/spawn-budget.test.ts +124 -0
- package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +6 -4
- package/dist/extensions/pi-subagents/test/unit/status-format.test.ts +7 -0
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +397 -0
- package/dist/extensions/pi-subagents/test/unit/steering-notices.test.ts +58 -0
- package/dist/extensions/pi-subagents/test/unit/steering.test.ts +173 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-control.test.ts +25 -4
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +390 -25
- package/dist/extensions/pi-subagents/test/unit/subagent-wait.test.ts +837 -0
- package/dist/extensions/pi-subagents/test/unit/task-intent.test.ts +86 -0
- package/dist/extensions/pi-subagents/test/unit/tool-budget.test.ts +15 -0
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +47 -1
- package/dist/extensions/pi-subagents/test/unit/turn-budget.test.ts +56 -10
- package/dist/extensions/pi-subagents/test/unit/watchdog-change-signature.test.ts +387 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-child-status.test.ts +110 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-emission-guard.test.ts +62 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-lsp-diagnostics.test.ts +144 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-model-selection.test.ts +121 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-render.test.ts +76 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-review.test.ts +327 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-runtime.test.ts +863 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-settings.test.ts +290 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-tool-actions.test.ts +91 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-turn-delta.test.ts +130 -0
- package/dist/extensions/pi-subagents/test/unit/widget-nested-render.test.ts +32 -4
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +5 -1
- package/dist/extensions/pi-subagents/test/unit/writer-budget-guidance.test.ts +30 -0
- package/dist/extensions/question/batch.ts +39 -0
- package/dist/extensions/question/dialog-adapter.ts +23 -1
- package/dist/extensions/question/index.ts +237 -7
- package/dist/extensions/question/schemas.ts +28 -15
- package/dist/extensions/question/tests/batch.test.ts +26 -0
- package/dist/extensions/question/tests/ui-protocol.test.ts +23 -3
- package/dist/extensions/question/tui-adapter.ts +2 -3
- package/dist/extensions/question/types.ts +37 -0
- package/dist/extensions/question/ui-protocol.ts +3 -3
- package/dist/skills/batch-grill-me/SKILL.md +3 -1
- package/package.json +2 -1
|
@@ -7,6 +7,9 @@ import { handleManagementAction } from "../../src/agents/agent-management.ts";
|
|
|
7
7
|
import { serializeAgent } from "../../src/agents/agent-serializer.ts";
|
|
8
8
|
import { parseChain, serializeChain } from "../../src/agents/chain-serializer.ts";
|
|
9
9
|
import { discoverAgents, discoverAgentsAll, type AgentConfig } from "../../src/agents/agents.ts";
|
|
10
|
+
import { parseFrontmatter } from "../../src/agents/frontmatter.ts";
|
|
11
|
+
import { buildPiArgs } from "../../src/runs/shared/pi-args.ts";
|
|
12
|
+
import { THINKING_LEVELS } from "../../src/shared/model-info.ts";
|
|
10
13
|
|
|
11
14
|
const tempDirs: string[] = [];
|
|
12
15
|
|
|
@@ -53,6 +56,195 @@ afterEach(() => {
|
|
|
53
56
|
}
|
|
54
57
|
});
|
|
55
58
|
|
|
59
|
+
describe("folded frontmatter blocks", () => {
|
|
60
|
+
it("folds ordinary lines and paragraph breaks for > and >-", () => {
|
|
61
|
+
const expected = "first line second line\nthird line";
|
|
62
|
+
const folded = parseFrontmatter(`---
|
|
63
|
+
name: worker
|
|
64
|
+
description: >
|
|
65
|
+
first line
|
|
66
|
+
second line
|
|
67
|
+
|
|
68
|
+
third line
|
|
69
|
+
---
|
|
70
|
+
body`);
|
|
71
|
+
const stripped = parseFrontmatter(`---
|
|
72
|
+
name: worker
|
|
73
|
+
description: >-
|
|
74
|
+
first line
|
|
75
|
+
second line
|
|
76
|
+
|
|
77
|
+
third line
|
|
78
|
+
---
|
|
79
|
+
body`);
|
|
80
|
+
|
|
81
|
+
assert.equal(folded.frontmatter.description, expected);
|
|
82
|
+
assert.equal(stripped.frontmatter.description, expected);
|
|
83
|
+
assert.equal(folded.frontmatter.name, "worker");
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("keeps quoted indicators as literal values", () => {
|
|
87
|
+
const parsed = parseFrontmatter(`---
|
|
88
|
+
description: ">"
|
|
89
|
+
other: '>-'
|
|
90
|
+
---
|
|
91
|
+
body`);
|
|
92
|
+
|
|
93
|
+
assert.equal(parsed.frontmatter.description, ">");
|
|
94
|
+
assert.equal(parsed.frontmatter.other, ">-");
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("preserves more-indented lines and repeated whitespace-only separators", () => {
|
|
98
|
+
const parsed = parseFrontmatter(`---
|
|
99
|
+
description: >
|
|
100
|
+
normal
|
|
101
|
+
code
|
|
102
|
+
next
|
|
103
|
+
|
|
104
|
+
first
|
|
105
|
+
|
|
106
|
+
${" ".repeat(3)}
|
|
107
|
+
second
|
|
108
|
+
name: worker
|
|
109
|
+
---
|
|
110
|
+
body`);
|
|
111
|
+
|
|
112
|
+
assert.equal(parsed.frontmatter.description, "normal\n code\nnext\nfirst\n\nsecond");
|
|
113
|
+
assert.equal(parsed.frontmatter.name, "worker");
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("keeps paragraph breaks adjacent to more-indented lines", () => {
|
|
117
|
+
const afterIndented = parseFrontmatter(`---
|
|
118
|
+
description: >
|
|
119
|
+
normal
|
|
120
|
+
code
|
|
121
|
+
|
|
122
|
+
next
|
|
123
|
+
---
|
|
124
|
+
body`);
|
|
125
|
+
const beforeIndented = parseFrontmatter(`---
|
|
126
|
+
description: >
|
|
127
|
+
normal
|
|
128
|
+
|
|
129
|
+
code
|
|
130
|
+
next
|
|
131
|
+
---
|
|
132
|
+
body`);
|
|
133
|
+
|
|
134
|
+
assert.equal(afterIndented.frontmatter.description, "normal\n code\n\nnext");
|
|
135
|
+
assert.equal(beforeIndented.frontmatter.description, "normal\n\n code\nnext");
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
describe("agent skillPath frontmatter", () => {
|
|
140
|
+
it("parses and serializes comma-separated paths", () => withTempHome(() => {
|
|
141
|
+
const project = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-skill-path-agent-"));
|
|
142
|
+
tempDirs.push(project);
|
|
143
|
+
writeAgent(path.join(project, ".selesai", "agents", "worker.md"), `---
|
|
144
|
+
name: worker
|
|
145
|
+
description: Worker
|
|
146
|
+
skillPath: ./skills, ../shared-skills
|
|
147
|
+
---
|
|
148
|
+
body`);
|
|
149
|
+
|
|
150
|
+
const worker = discoverAgents(project, "both").agents.find((agent) => agent.name === "worker")!;
|
|
151
|
+
assert.deepEqual(worker.skillPath, ["./skills", "../shared-skills"]);
|
|
152
|
+
assert.match(serializeAgent(worker), /^skillPath: \.\/skills, \.\.\/shared-skills$/m);
|
|
153
|
+
}));
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe("agent simple-scalar list frontmatter", () => {
|
|
157
|
+
it("discovers newline block lists for all list fields and routes MCP tools", () => {
|
|
158
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-agent-block-list-frontmatter-"));
|
|
159
|
+
tempDirs.push(dir);
|
|
160
|
+
writeAgent(path.join(dir, ".selesai", "agents", "worker.md"), `---
|
|
161
|
+
name: worker
|
|
162
|
+
description: Worker
|
|
163
|
+
tools:
|
|
164
|
+
- read-only
|
|
165
|
+
- mcp:github/search_repositories
|
|
166
|
+
defaultReads:
|
|
167
|
+
- input-one.md
|
|
168
|
+
- input-two.md
|
|
169
|
+
skill:
|
|
170
|
+
- review-checklist
|
|
171
|
+
- safe-bash
|
|
172
|
+
skillPath:
|
|
173
|
+
- ./private-skills
|
|
174
|
+
- ../shared-skills
|
|
175
|
+
fallbackModels:
|
|
176
|
+
- openai/gpt-5-mini
|
|
177
|
+
- anthropic/claude-sonnet-4
|
|
178
|
+
extensions:
|
|
179
|
+
- ./extension-one.ts
|
|
180
|
+
- ./extension-two.ts
|
|
181
|
+
subagentOnlyExtensions:
|
|
182
|
+
- ./child-only.ts
|
|
183
|
+
- ./child-helper.ts
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
Do work
|
|
187
|
+
`);
|
|
188
|
+
|
|
189
|
+
const worker = discoverAgents(dir, "project").agents.find((agent) => agent.name === "worker");
|
|
190
|
+
assert.deepEqual(worker?.tools, ["read-only"]);
|
|
191
|
+
assert.deepEqual(worker?.mcpDirectTools, ["github/search_repositories"]);
|
|
192
|
+
assert.deepEqual(worker?.defaultReads, ["input-one.md", "input-two.md"]);
|
|
193
|
+
assert.deepEqual(worker?.skills, ["review-checklist", "safe-bash"]);
|
|
194
|
+
assert.deepEqual(worker?.skillPath, ["./private-skills", "../shared-skills"]);
|
|
195
|
+
assert.deepEqual(worker?.fallbackModels, ["openai/gpt-5-mini", "anthropic/claude-sonnet-4"]);
|
|
196
|
+
assert.deepEqual(worker?.extensions, ["./extension-one.ts", "./extension-two.ts"]);
|
|
197
|
+
assert.deepEqual(worker?.subagentOnlyExtensions, ["./child-only.ts", "./child-helper.ts"]);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it("preserves MCP-only tools as an explicit empty builtin allowlist", () => {
|
|
201
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-agent-mcp-only-frontmatter-"));
|
|
202
|
+
tempDirs.push(dir);
|
|
203
|
+
writeAgent(path.join(dir, ".selesai", "agents", "mcp-only.md"), `---
|
|
204
|
+
name: mcp-only
|
|
205
|
+
description: MCP only
|
|
206
|
+
tools: mcp:github/search_repositories
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
Do MCP work
|
|
210
|
+
`);
|
|
211
|
+
|
|
212
|
+
const agent = discoverAgents(dir, "project").agents.find((candidate) => candidate.name === "mcp-only");
|
|
213
|
+
assert.deepEqual(agent?.tools, []);
|
|
214
|
+
assert.deepEqual(agent?.mcpDirectTools, ["github/search_repositories"]);
|
|
215
|
+
assert.match(serializeAgent(agent!), /^tools: mcp:github\/search_repositories$/m);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("preserves comma-separated syntax across all list fields", () => {
|
|
219
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-agent-comma-list-frontmatter-"));
|
|
220
|
+
tempDirs.push(dir);
|
|
221
|
+
writeAgent(path.join(dir, ".selesai", "agents", "worker.md"), `---
|
|
222
|
+
name: worker
|
|
223
|
+
description: Worker
|
|
224
|
+
tools: read-only, mcp:github/search_repositories
|
|
225
|
+
defaultReads: input-one.md, input-two.md
|
|
226
|
+
skills: review-checklist, safe-bash
|
|
227
|
+
skillPath: ./private-skills, ../shared-skills
|
|
228
|
+
fallbackModels: openai/gpt-5-mini, anthropic/claude-sonnet-4
|
|
229
|
+
extensions: ./extension-one.ts, ./extension-two.ts
|
|
230
|
+
subagentOnlyExtensions: ./child-only.ts, ./child-helper.ts
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
Do work
|
|
234
|
+
`);
|
|
235
|
+
|
|
236
|
+
const worker = discoverAgents(dir, "project").agents.find((agent) => agent.name === "worker");
|
|
237
|
+
assert.deepEqual(worker?.tools, ["read-only"]);
|
|
238
|
+
assert.deepEqual(worker?.mcpDirectTools, ["github/search_repositories"]);
|
|
239
|
+
assert.deepEqual(worker?.defaultReads, ["input-one.md", "input-two.md"]);
|
|
240
|
+
assert.deepEqual(worker?.skills, ["review-checklist", "safe-bash"]);
|
|
241
|
+
assert.deepEqual(worker?.skillPath, ["./private-skills", "../shared-skills"]);
|
|
242
|
+
assert.deepEqual(worker?.fallbackModels, ["openai/gpt-5-mini", "anthropic/claude-sonnet-4"]);
|
|
243
|
+
assert.deepEqual(worker?.extensions, ["./extension-one.ts", "./extension-two.ts"]);
|
|
244
|
+
assert.deepEqual(worker?.subagentOnlyExtensions, ["./child-only.ts", "./child-helper.ts"]);
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
|
|
56
248
|
describe("agent permission frontmatter", () => {
|
|
57
249
|
it("preserves nested permission YAML blocks through discovery and serialization", () => {
|
|
58
250
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-agent-permission-frontmatter-"));
|
|
@@ -124,18 +316,144 @@ Do work
|
|
|
124
316
|
assert.equal(worker?.defaultContext, "fork");
|
|
125
317
|
});
|
|
126
318
|
|
|
127
|
-
it("loads packaged
|
|
319
|
+
it("loads packaged architect and recapper with fork defaultContext", () => {
|
|
128
320
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-builtin-default-context-"));
|
|
129
321
|
tempDirs.push(dir);
|
|
130
322
|
const agents = discoverAgentsAll(dir).builtin;
|
|
131
323
|
|
|
132
|
-
for (const name of ["
|
|
324
|
+
for (const name of ["architect", "recapper"]) {
|
|
133
325
|
const agent = agents.find((candidate) => candidate.name === name);
|
|
134
326
|
assert.equal(agent?.defaultContext, "fork", `${name} should default to fork context`);
|
|
135
327
|
}
|
|
136
328
|
});
|
|
137
329
|
});
|
|
138
330
|
|
|
331
|
+
describe("agent frontmatter launch defaults", () => {
|
|
332
|
+
it("serializes and discovers single-agent launch defaults", () => {
|
|
333
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-agent-launch-defaults-"));
|
|
334
|
+
tempDirs.push(dir);
|
|
335
|
+
const filePath = path.join(dir, ".selesai", "agents", "worker.md");
|
|
336
|
+
const agent: AgentConfig = {
|
|
337
|
+
name: "worker",
|
|
338
|
+
description: "Worker",
|
|
339
|
+
systemPrompt: "Do work",
|
|
340
|
+
systemPromptMode: "replace",
|
|
341
|
+
inheritProjectContext: false,
|
|
342
|
+
inheritSkills: false,
|
|
343
|
+
source: "project",
|
|
344
|
+
filePath,
|
|
345
|
+
defaultAsync: false,
|
|
346
|
+
defaultTimeoutMs: 90_000,
|
|
347
|
+
defaultTurnBudget: { maxTurns: 12, graceTurns: 2 },
|
|
348
|
+
defaultAcceptance: { level: "none", reason: "lightweight lookup" },
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
const serialized = serializeAgent(agent);
|
|
352
|
+
assert.match(serialized, /^async: false$/m);
|
|
353
|
+
assert.match(serialized, /^timeoutMs: 90000$/m);
|
|
354
|
+
assert.match(serialized, /^turnBudget: \{"maxTurns":12,"graceTurns":2\}$/m);
|
|
355
|
+
assert.match(serialized, /^acceptance: \{"level":"none","reason":"lightweight lookup"\}$/m);
|
|
356
|
+
writeAgent(filePath, serialized);
|
|
357
|
+
|
|
358
|
+
const worker = discoverAgents(dir, "project").agents.find((candidate) => candidate.name === "worker");
|
|
359
|
+
assert.equal(worker?.defaultAsync, false);
|
|
360
|
+
assert.equal(worker?.defaultTimeoutMs, 90_000);
|
|
361
|
+
assert.deepEqual(worker?.defaultTurnBudget, { maxTurns: 12, graceTurns: 2 });
|
|
362
|
+
assert.deepEqual(worker?.defaultAcceptance, { level: "none", reason: "lightweight lookup" });
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
it("parses scalar acceptance defaults and rejects invalid policies", () => {
|
|
366
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-agent-acceptance-defaults-"));
|
|
367
|
+
tempDirs.push(dir);
|
|
368
|
+
const filePath = path.join(dir, ".selesai", "agents", "worker.md");
|
|
369
|
+
writeAgent(filePath, `---
|
|
370
|
+
name: worker
|
|
371
|
+
description: Worker
|
|
372
|
+
acceptance: checked
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
Do work
|
|
376
|
+
`);
|
|
377
|
+
assert.equal(discoverAgents(dir, "project").agents.find((agent) => agent.name === "worker")?.defaultAcceptance, "checked");
|
|
378
|
+
|
|
379
|
+
writeAgent(filePath, `---
|
|
380
|
+
name: worker
|
|
381
|
+
description: Worker
|
|
382
|
+
acceptance: { level: "none", reason: "NA" }
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
Do work
|
|
386
|
+
`);
|
|
387
|
+
assert.deepEqual(
|
|
388
|
+
discoverAgents(dir, "project").agents.find((agent) => agent.name === "worker")?.defaultAcceptance,
|
|
389
|
+
{ level: "none", reason: "NA" },
|
|
390
|
+
);
|
|
391
|
+
|
|
392
|
+
writeAgent(filePath, `---
|
|
393
|
+
name: worker
|
|
394
|
+
description: Worker
|
|
395
|
+
acceptance: none
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
Do work
|
|
399
|
+
`);
|
|
400
|
+
assert.throws(
|
|
401
|
+
() => discoverAgents(dir, "project"),
|
|
402
|
+
/Agent 'worker' acceptance frontmatter level "none" requires a reason/,
|
|
403
|
+
);
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
it("parses, serializes, and validates acceptance roles", () => {
|
|
407
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-agent-acceptance-role-"));
|
|
408
|
+
tempDirs.push(dir);
|
|
409
|
+
const filePath = path.join(dir, ".selesai", "agents", "explorer.md");
|
|
410
|
+
writeAgent(filePath, `---
|
|
411
|
+
name: explorer
|
|
412
|
+
description: Explorer
|
|
413
|
+
acceptanceRole: read-only
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
Explore the codebase
|
|
417
|
+
`);
|
|
418
|
+
|
|
419
|
+
const explorer = discoverAgents(dir, "project").agents.find((agent) => agent.name === "explorer");
|
|
420
|
+
assert.equal(explorer?.acceptanceRole, "read-only");
|
|
421
|
+
assert.match(serializeAgent(explorer!), /^acceptanceRole: read-only$/m);
|
|
422
|
+
assert.equal(explorer?.extraFields?.acceptanceRole, undefined);
|
|
423
|
+
|
|
424
|
+
writeAgent(filePath, `---
|
|
425
|
+
name: explorer
|
|
426
|
+
description: Explorer
|
|
427
|
+
acceptanceRole: observer
|
|
428
|
+
---
|
|
429
|
+
|
|
430
|
+
Explore the codebase
|
|
431
|
+
`);
|
|
432
|
+
assert.throws(
|
|
433
|
+
() => discoverAgents(dir, "project"),
|
|
434
|
+
/Agent 'explorer' has invalid acceptanceRole frontmatter; expected 'read-only' or 'writer'/,
|
|
435
|
+
);
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
it("rejects invalid launch defaults instead of silently ignoring them", () => {
|
|
439
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-agent-invalid-launch-defaults-"));
|
|
440
|
+
tempDirs.push(dir);
|
|
441
|
+
writeAgent(path.join(dir, ".selesai", "agents", "worker.md"), `---
|
|
442
|
+
name: worker
|
|
443
|
+
description: Worker
|
|
444
|
+
async: sometimes
|
|
445
|
+
---
|
|
446
|
+
|
|
447
|
+
Do work
|
|
448
|
+
`);
|
|
449
|
+
|
|
450
|
+
assert.throws(
|
|
451
|
+
() => discoverAgents(dir, "project"),
|
|
452
|
+
/Agent 'worker' has invalid async frontmatter; expected true or false/,
|
|
453
|
+
);
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
|
|
139
457
|
describe("chain discovery", () => {
|
|
140
458
|
it("prefers same-scope .chain.json over .chain.md for the same runtime name", () => {
|
|
141
459
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-chain-format-precedence-"));
|
|
@@ -324,6 +642,83 @@ Agent prompt
|
|
|
324
642
|
assert.equal(packageAgents.some((agent) => agent.name === "package-skill"), false);
|
|
325
643
|
}));
|
|
326
644
|
|
|
645
|
+
it("prunes repo internals and nested project roots from broad package discovery", () => withTempHome(() => {
|
|
646
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-broad-package-prune-"));
|
|
647
|
+
tempDirs.push(dir);
|
|
648
|
+
writeJson(path.join(dir, "package.json"), {
|
|
649
|
+
name: "repo-root-workflow",
|
|
650
|
+
pi: {
|
|
651
|
+
subagents: {
|
|
652
|
+
agents: ["."],
|
|
653
|
+
chains: ["."],
|
|
654
|
+
},
|
|
655
|
+
},
|
|
656
|
+
});
|
|
657
|
+
writeAgent(path.join(dir, "root-agent.md"), `---
|
|
658
|
+
name: root-agent
|
|
659
|
+
description: Root package agent
|
|
660
|
+
---
|
|
661
|
+
|
|
662
|
+
Root prompt
|
|
663
|
+
`);
|
|
664
|
+
writeAgent(path.join(dir, "root.chain.md"), `---
|
|
665
|
+
name: root-chain
|
|
666
|
+
description: Root package chain
|
|
667
|
+
---
|
|
668
|
+
|
|
669
|
+
## root-agent
|
|
670
|
+
|
|
671
|
+
Run root agent
|
|
672
|
+
`);
|
|
673
|
+
writeAgent(path.join(dir, "node_modules", "bad-agent.md"), `---
|
|
674
|
+
name: node-modules-agent
|
|
675
|
+
description: Should not be discovered
|
|
676
|
+
---
|
|
677
|
+
|
|
678
|
+
Ignored
|
|
679
|
+
`);
|
|
680
|
+
writeAgent(path.join(dir, ".git", "hooks", "bad-agent.md"), `---
|
|
681
|
+
name: git-agent
|
|
682
|
+
description: Should not be discovered
|
|
683
|
+
---
|
|
684
|
+
|
|
685
|
+
Ignored
|
|
686
|
+
`);
|
|
687
|
+
writeAgent(path.join(dir, "vendor", "submodule", "submodule-agent.md"), `---
|
|
688
|
+
name: submodule-agent
|
|
689
|
+
description: Should not be discovered
|
|
690
|
+
---
|
|
691
|
+
|
|
692
|
+
Ignored
|
|
693
|
+
`);
|
|
694
|
+
fs.writeFileSync(path.join(dir, "vendor", "submodule", ".git"), "gitdir: ../.git/modules/submodule\n", "utf-8");
|
|
695
|
+
writeAgent(path.join(dir, "packages", "app", "local-agent.md"), `---
|
|
696
|
+
name: nested-project-agent
|
|
697
|
+
description: Should not be discovered
|
|
698
|
+
---
|
|
699
|
+
|
|
700
|
+
Ignored
|
|
701
|
+
`);
|
|
702
|
+
fs.mkdirSync(path.join(dir, "packages", "app", ".selesai"), { recursive: true });
|
|
703
|
+
writeAgent(path.join(dir, "node_modules", "bad.chain.md"), `---
|
|
704
|
+
name: node-modules-chain
|
|
705
|
+
description: Should not be discovered
|
|
706
|
+
---
|
|
707
|
+
|
|
708
|
+
## root-agent
|
|
709
|
+
|
|
710
|
+
Ignored
|
|
711
|
+
`);
|
|
712
|
+
|
|
713
|
+
const all = discoverAgentsAll(dir);
|
|
714
|
+
assert.ok(all.package.find((agent) => agent.name === "root-agent" && agent.filePath === path.join(dir, "root-agent.md")));
|
|
715
|
+
for (const name of ["node-modules-agent", "git-agent", "submodule-agent", "nested-project-agent"]) {
|
|
716
|
+
assert.equal(all.package.some((agent) => agent.name === name), false, `${name} should be pruned`);
|
|
717
|
+
}
|
|
718
|
+
assert.ok(all.chains.find((chain) => chain.name === "root-chain" && chain.filePath === path.join(dir, "root.chain.md")));
|
|
719
|
+
assert.equal(all.chains.some((chain) => chain.name === "node-modules-chain"), false);
|
|
720
|
+
}));
|
|
721
|
+
|
|
327
722
|
it("keeps package definitions below user and project overrides", () => withTempHome((home) => {
|
|
328
723
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-package-precedence-"));
|
|
329
724
|
tempDirs.push(dir);
|
|
@@ -516,6 +911,73 @@ Inspect code
|
|
|
516
911
|
});
|
|
517
912
|
});
|
|
518
913
|
|
|
914
|
+
describe("agent frontmatter thinking", () => {
|
|
915
|
+
it("coerces frontmatter false strings to disabled thinking", () => {
|
|
916
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-agent-thinking-false-"));
|
|
917
|
+
tempDirs.push(dir);
|
|
918
|
+
const agentsDir = path.join(dir, ".selesai", "agents");
|
|
919
|
+
fs.mkdirSync(agentsDir, { recursive: true });
|
|
920
|
+
|
|
921
|
+
for (const [name, value] of [["unquoted", "false"], ["quoted", "\"false\""]] as const) {
|
|
922
|
+
fs.writeFileSync(path.join(agentsDir, `${name}.md`), `---
|
|
923
|
+
name: ${name}
|
|
924
|
+
description: ${name}
|
|
925
|
+
model: glm-5.2-short-fast
|
|
926
|
+
thinking: ${value}
|
|
927
|
+
---
|
|
928
|
+
|
|
929
|
+
Do work
|
|
930
|
+
`, "utf-8");
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
const agents = discoverAgents(dir, "project").agents;
|
|
934
|
+
for (const name of ["unquoted", "quoted"]) {
|
|
935
|
+
const agent = agents.find((candidate) => candidate.name === name);
|
|
936
|
+
assert.ok(agent);
|
|
937
|
+
assert.equal(agent.thinking, false);
|
|
938
|
+
|
|
939
|
+
const { args } = buildPiArgs({
|
|
940
|
+
baseArgs: ["-p"],
|
|
941
|
+
task: "hello",
|
|
942
|
+
sessionEnabled: false,
|
|
943
|
+
model: agent.model,
|
|
944
|
+
thinking: agent.thinking,
|
|
945
|
+
inheritProjectContext: agent.inheritProjectContext,
|
|
946
|
+
inheritSkills: agent.inheritSkills,
|
|
947
|
+
});
|
|
948
|
+
|
|
949
|
+
assert.ok(args.includes("--model"));
|
|
950
|
+
assert.ok(args.includes("glm-5.2-short-fast"));
|
|
951
|
+
assert.ok(!args.some((arg) => arg.includes(":false")));
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
|
|
955
|
+
it("preserves supported frontmatter thinking strings", () => {
|
|
956
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-agent-thinking-levels-"));
|
|
957
|
+
tempDirs.push(dir);
|
|
958
|
+
const agentsDir = path.join(dir, ".selesai", "agents");
|
|
959
|
+
fs.mkdirSync(agentsDir, { recursive: true });
|
|
960
|
+
|
|
961
|
+
for (const level of THINKING_LEVELS) {
|
|
962
|
+
fs.writeFileSync(path.join(agentsDir, `${level}.md`), `---
|
|
963
|
+
name: thinker-${level}
|
|
964
|
+
description: Thinking ${level}
|
|
965
|
+
thinking: ${level}
|
|
966
|
+
---
|
|
967
|
+
|
|
968
|
+
Do work
|
|
969
|
+
`, "utf-8");
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
const agents = discoverAgents(dir, "project").agents;
|
|
973
|
+
for (const level of THINKING_LEVELS) {
|
|
974
|
+
const agent = agents.find((candidate) => candidate.name === `thinker-${level}`);
|
|
975
|
+
assert.ok(agent);
|
|
976
|
+
assert.equal(agent.thinking, level);
|
|
977
|
+
}
|
|
978
|
+
});
|
|
979
|
+
});
|
|
980
|
+
|
|
519
981
|
describe("agent frontmatter fallbackModels", () => {
|
|
520
982
|
it("serializes fallbackModels into agent frontmatter", () => {
|
|
521
983
|
const agent: AgentConfig = {
|
|
@@ -703,12 +1165,12 @@ Do work
|
|
|
703
1165
|
process.env.USERPROFILE = homeDir;
|
|
704
1166
|
|
|
705
1167
|
const result = discoverAgents(dir, "both");
|
|
706
|
-
const
|
|
707
|
-
const
|
|
708
|
-
const
|
|
709
|
-
assert.equal(
|
|
710
|
-
assert.equal(
|
|
711
|
-
assert.equal(
|
|
1168
|
+
const architect = result.agents.find((agent) => agent.name === "architect");
|
|
1169
|
+
const builder = result.agents.find((agent) => agent.name === "builder");
|
|
1170
|
+
const commentator = result.agents.find((agent) => agent.name === "commentator");
|
|
1171
|
+
assert.equal(architect?.inheritProjectContext, true);
|
|
1172
|
+
assert.equal(builder?.inheritProjectContext, true);
|
|
1173
|
+
assert.equal(commentator?.inheritProjectContext, true);
|
|
712
1174
|
} finally {
|
|
713
1175
|
if (previousHome === undefined) delete process.env.HOME;
|
|
714
1176
|
else process.env.HOME = previousHome;
|
|
@@ -741,7 +1203,7 @@ Do work
|
|
|
741
1203
|
}
|
|
742
1204
|
});
|
|
743
1205
|
|
|
744
|
-
it("
|
|
1206
|
+
it("builder includes the child-facing supervisor tool", () => {
|
|
745
1207
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-builtin-supervisor-tool-"));
|
|
746
1208
|
const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-builtin-supervisor-tool-home-"));
|
|
747
1209
|
tempDirs.push(dir);
|
|
@@ -752,12 +1214,9 @@ Do work
|
|
|
752
1214
|
try {
|
|
753
1215
|
process.env.HOME = homeDir;
|
|
754
1216
|
process.env.USERPROFILE = homeDir;
|
|
755
|
-
const
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
assert.ok(agent, `${name} builtin should be discovered`);
|
|
759
|
-
assert.deepEqual(agent?.tools, ["read", "grep", "find", "ls", "bash", "edit", "write", "contact_supervisor"]);
|
|
760
|
-
}
|
|
1217
|
+
const agent = discoverAgentsAll(dir).builtin.find((candidate) => candidate.name === "builder");
|
|
1218
|
+
assert.ok(agent, "builder builtin should be discovered");
|
|
1219
|
+
assert.deepEqual(agent?.tools, ["read", "grep", "find", "ls", "bash", "edit", "write", "contact_supervisor"]);
|
|
761
1220
|
} finally {
|
|
762
1221
|
if (previousHome === undefined) delete process.env.HOME;
|
|
763
1222
|
else process.env.HOME = previousHome;
|
|
@@ -989,7 +1448,7 @@ Review
|
|
|
989
1448
|
});
|
|
990
1449
|
|
|
991
1450
|
describe("project agent directory discovery", () => {
|
|
992
|
-
it("discovers project agents from both .agents and .
|
|
1451
|
+
it("discovers project agents from both .agents and .selesai/agents", () => {
|
|
993
1452
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-project-agent-dirs-"));
|
|
994
1453
|
tempDirs.push(dir);
|
|
995
1454
|
fs.mkdirSync(path.join(dir, ".agents", "skills"), { recursive: true });
|
|
@@ -1079,7 +1538,7 @@ Skill prompt
|
|
|
1079
1538
|
assert.equal(agents.some((agent) => agent.name === "user-skill"), false);
|
|
1080
1539
|
}));
|
|
1081
1540
|
|
|
1082
|
-
it("prefers .
|
|
1541
|
+
it("prefers .selesai/agents over .agents on project agent name collisions", () => {
|
|
1083
1542
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-project-agent-collision-"));
|
|
1084
1543
|
tempDirs.push(dir);
|
|
1085
1544
|
fs.mkdirSync(path.join(dir, ".agents"), { recursive: true });
|
|
@@ -1117,7 +1576,7 @@ Canonical prompt
|
|
|
1117
1576
|
assert.equal(result.projectDir, path.join(dir, ".selesai", "agents"));
|
|
1118
1577
|
});
|
|
1119
1578
|
|
|
1120
|
-
it("discovers project chains from .
|
|
1579
|
+
it("discovers project chains from .selesai/chains", () => {
|
|
1121
1580
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-project-chain-dirs-"));
|
|
1122
1581
|
tempDirs.push(dir);
|
|
1123
1582
|
fs.mkdirSync(path.join(dir, ".selesai", "agents"), { recursive: true });
|
|
@@ -1148,7 +1607,7 @@ Inspect canonical
|
|
|
1148
1607
|
assert.equal(result.projectChainDir, path.join(dir, ".selesai", "chains"));
|
|
1149
1608
|
});
|
|
1150
1609
|
|
|
1151
|
-
it("prefers project .
|
|
1610
|
+
it("prefers project .selesai/chains over user chains on name collisions", () => {
|
|
1152
1611
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-project-chain-collision-"));
|
|
1153
1612
|
const home = fs.mkdtempSync(path.join(os.tmpdir(), "pi-subagents-user-chain-home-"));
|
|
1154
1613
|
tempDirs.push(dir, home);
|