@luminascale/shepherd 0.0.0-stage → 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/.agents/agents/README.md +12 -0
- package/.agents/agents/planner.md +38 -0
- package/.agents/agents/reviewer.md +38 -0
- package/.agents/agents/scout.md +43 -0
- package/.agents/agents/worker.md +33 -0
- package/.agents/skills/smoke-test/SKILL.md +155 -0
- package/.agents/skills/smoke-test/references/forensics.md +46 -0
- package/.agents/skills/smoke-test/scripts/live-smoke-poll.mjs +130 -0
- package/.github/workflows/publish.yml +77 -0
- package/.pi/prompts/release.md +21 -0
- package/.prettierrc +10 -0
- package/AGENTS.md +88 -0
- package/CONTRIBUTING.md +177 -0
- package/LICENSE +201 -0
- package/README.md +397 -2
- package/docs/README.md +26 -0
- package/docs/guides/agent-definitions.md +42 -0
- package/docs/guides/diagnostics.md +199 -0
- package/docs/guides/installation.md +61 -0
- package/docs/guides/tool-reference.md +55 -0
- package/docs/manual-tests/ping-pong-peer-messaging.md +147 -0
- package/docs/plans/agent-labels.md +257 -0
- package/docs/plans/architecture.md +110 -0
- package/docs/plans/settings-scope.md +163 -0
- package/docs/plans/tool-surface-split.md +278 -0
- package/docs/reference/dictionary +26 -0
- package/docs/releasing.md +47 -0
- package/docs/specs/005-agent-messaging-and-task-lifecycle/baseline.md +115 -0
- package/docs/specs/005-agent-messaging-and-task-lifecycle/handoff.md +564 -0
- package/docs/specs/005-agent-messaging-and-task-lifecycle/phase10-notes.md +109 -0
- package/docs/specs/005-agent-messaging-and-task-lifecycle/phase6-notes.md +69 -0
- package/docs/specs/005-agent-messaging-and-task-lifecycle/phase7-notes.md +100 -0
- package/docs/specs/005-agent-messaging-and-task-lifecycle/phase8-notes.md +127 -0
- package/docs/specs/005-agent-messaging-and-task-lifecycle/phase9-notes.md +104 -0
- package/docs/specs/005-agent-messaging-and-task-lifecycle/plan.md +1093 -0
- package/docs/specs/005-agent-messaging-and-task-lifecycle/spec.md +583 -0
- package/docs/specs/005-agent-messaging-and-task-lifecycle/tasks.md +838 -0
- package/docs/specs/006-shepherd-tool-rendering/plan.md +175 -0
- package/docs/specs/006-shepherd-tool-rendering/spec.md +469 -0
- package/index.ts +602 -0
- package/package.json +112 -4
- package/scripts/capture-system-prompt.mjs +45 -0
- package/scripts/extract-pi-system-prompt.mjs +277 -0
- package/scripts/host-impact.mjs +74 -0
- package/scripts/resolve-agent.mjs +43 -0
- package/scripts/show-shepherd-orchestrator.mjs +58 -0
- package/scripts/show-shepherd-prompt.mjs +96 -0
- package/scripts/verify-suites.mjs +67 -0
- package/specs/001-artifacts/spec.md +436 -0
- package/specs/002-simplify-agent-orchestration/plan.md +287 -0
- package/specs/002-simplify-agent-orchestration/spec.md +323 -0
- package/specs/002-simplify-agent-orchestration/tasks.md +212 -0
- package/specs/003-orchestrator-session-artifacts/plan.md +396 -0
- package/specs/003-orchestrator-session-artifacts/spec.md +453 -0
- package/specs/003-orchestrator-session-artifacts/tasks.md +141 -0
- package/specs/004-asynchronous-prompt-watchers/plan.md +139 -0
- package/specs/004-asynchronous-prompt-watchers/spec.md +202 -0
- package/specs/004-asynchronous-prompt-watchers/tasks.md +126 -0
- package/specs/005-per-workspace-settings/plan.md +230 -0
- package/specs/005-per-workspace-settings/spec.md +368 -0
- package/specs/005-per-workspace-settings/tasks.md +178 -0
- package/specs/006-dual-runtime-herdr-durable/intent.md +86 -0
- package/specs/006-dual-runtime-herdr-durable/journal.md +80 -0
- package/specs/006-dual-runtime-herdr-durable/plan.md +242 -0
- package/specs/006-dual-runtime-herdr-durable/spec.md +389 -0
- package/specs/006-dual-runtime-herdr-durable/tasks.md +199 -0
- package/specs/007-unwatched-completion-notice/journal.md +145 -0
- package/specs/007-unwatched-completion-notice/plan.md +186 -0
- package/specs/007-unwatched-completion-notice/spec.md +284 -0
- package/specs/007-unwatched-completion-notice/tasks.md +147 -0
- package/specs/008-remote-machine-sheep/intent.md +174 -0
- package/specs/008-remote-machine-sheep/journal.md +57 -0
- package/specs/008-remote-machine-sheep/prerequisites.md +219 -0
- package/specs/009-hc-runtime/intent.md +44 -0
- package/specs/009-hc-runtime/plan.md +49 -0
- package/specs/009-hc-runtime/spec.md +118 -0
- package/specs/009-hc-runtime/tasks.md +62 -0
- package/specs/010-unseen-watch-parity/intent.md +57 -0
- package/specs/010-unseen-watch-parity/journal.md +172 -0
- package/specs/010-unseen-watch-parity/plan.md +74 -0
- package/specs/010-unseen-watch-parity/spec.md +191 -0
- package/specs/010-unseen-watch-parity/tasks.md +119 -0
- package/specs/011-hc-background-poll/intent.md +57 -0
- package/specs/011-hc-background-poll/journal.md +95 -0
- package/specs/011-hc-background-poll/plan.md +87 -0
- package/specs/011-hc-background-poll/spec.md +141 -0
- package/specs/011-hc-background-poll/tasks.md +83 -0
- package/specs/012-steer-default/intent.md +12 -0
- package/specs/012-steer-default/journal.md +40 -0
- package/specs/012-steer-default/plan.md +7 -0
- package/specs/012-steer-default/spec.md +42 -0
- package/specs/012-steer-default/tasks.md +6 -0
- package/specs/013-opencode-shepherd/handoff-t011.md +94 -0
- package/specs/013-opencode-shepherd/intent.md +59 -0
- package/specs/013-opencode-shepherd/plan.md +204 -0
- package/specs/013-opencode-shepherd/spec.md +258 -0
- package/specs/013-opencode-shepherd/tasks.md +263 -0
- package/src/core/artifact-sessions.ts +835 -0
- package/src/core/config.ts +329 -0
- package/src/core/discovery.ts +342 -0
- package/src/core/herdr.ts +1 -0
- package/src/core/host.ts +77 -0
- package/src/core/ids.ts +78 -0
- package/src/core/lifecycle.ts +1 -0
- package/src/core/messaging.ts +1 -0
- package/src/core/migration.ts +55 -0
- package/src/core/orchestration.ts +1 -0
- package/src/core/types.ts +143 -0
- package/src/core/unseen-completions.ts +114 -0
- package/src/extension/cli.ts +417 -0
- package/src/extension/config.ts +1 -0
- package/src/extension/settings-ui.ts +296 -0
- package/src/extension/shepherd-done.ts +768 -0
- package/src/extension/shepherd.ts +2548 -0
- package/src/extension/system-prompt.ts +38 -0
- package/src/extension/unseen-completions.ts +237 -0
- package/src/opencode/actions.ts +794 -0
- package/src/opencode/bridge.ts +777 -0
- package/src/opencode/display.ts +36 -0
- package/src/opencode/fieldnotes.ts +60 -0
- package/src/opencode/host.ts +62 -0
- package/src/opencode/orphans.ts +162 -0
- package/src/opencode/server.ts +458 -0
- package/src/runtimes/backend.ts +119 -0
- package/src/runtimes/detect.ts +102 -0
- package/src/runtimes/hc/hc.ts +527 -0
- package/src/runtimes/hc/runtime.ts +1898 -0
- package/src/runtimes/herdr/herdr.ts +912 -0
- package/src/runtimes/herdr/lifecycle.ts +1712 -0
- package/src/runtimes/herdr/messaging.ts +703 -0
- package/src/runtimes/herdr/orchestration.ts +1583 -0
- package/src/runtimes/herdr/runtime.ts +224 -0
- package/src/runtimes/runtime.ts +133 -0
- package/src/runtimes/settle-observations.ts +114 -0
- package/test/fixtures/context-project/AGENTS.md +2 -0
- package/test/fixtures/home/.agents/agents/same.md +6 -0
- package/test/fixtures/home/.agents/agents/shared-only.md +6 -0
- package/test/fixtures/home/.pi/agent/agents/invalid-thinking.md +6 -0
- package/test/fixtures/home/.pi/agent/agents/model-empty.md +7 -0
- package/test/fixtures/home/.pi/agent/agents/model-explicit.md +7 -0
- package/test/fixtures/home/.pi/agent/agents/omit-context-absent.md +5 -0
- package/test/fixtures/home/.pi/agent/agents/omit-context-false.md +6 -0
- package/test/fixtures/home/.pi/agent/agents/omit-context-invalid.md +6 -0
- package/test/fixtures/home/.pi/agent/agents/omit-context-true.md +6 -0
- package/test/fixtures/home/.pi/agent/agents/omit-false.md +6 -0
- package/test/fixtures/home/.pi/agent/agents/omit-invalid.md +6 -0
- package/test/fixtures/home/.pi/agent/agents/omit-pi-docs.md +7 -0
- package/test/fixtures/home/.pi/agent/agents/omit-true.md +6 -0
- package/test/fixtures/home/.pi/agent/agents/only-user.md +9 -0
- package/test/fixtures/home/.pi/agent/agents/same.md +6 -0
- package/test/fixtures/proj/.agents/agents/proj-shared.md +6 -0
- package/test/fixtures/proj/.pi/agents/project-pi.md +6 -0
- package/test/fixtures/proj/.pi/agents/same.md +6 -0
- package/test/helpers/fake-clock.mjs +39 -0
- package/test/helpers/feature-contracts.mjs +44 -0
- package/test/helpers/test-utils.mjs +44 -0
- package/test/verify-artifact-sessions.mjs +258 -0
- package/test/verify-backend.mjs +297 -0
- package/test/verify-child-mislabel.mjs +135 -0
- package/test/verify-child-surface.mjs +321 -0
- package/test/verify-cli.mjs +197 -0
- package/test/verify-command-ux.mjs +100 -0
- package/test/verify-compat.mjs +32 -0
- package/test/verify-cross-host-notes.mjs +128 -0
- package/test/verify-delegate.mjs +161 -0
- package/test/verify-detect.mjs +151 -0
- package/test/verify-discovery.mjs +239 -0
- package/test/verify-done-nudge.mjs +238 -0
- package/test/verify-effective-prompt.mjs +98 -0
- package/test/verify-hc-matrix.mjs +246 -0
- package/test/verify-hc-poll.mjs +260 -0
- package/test/verify-host-docs.mjs +66 -0
- package/test/verify-host-impact.mjs +49 -0
- package/test/verify-ids.mjs +141 -0
- package/test/verify-launch.mjs +183 -0
- package/test/verify-message-routing.mjs +560 -0
- package/test/verify-messaging.mjs +303 -0
- package/test/verify-migration-notice.mjs +74 -0
- package/test/verify-multi-wait.mjs +42 -0
- package/test/verify-opencode-display.mjs +47 -0
- package/test/verify-opencode-fieldnotes.mjs +121 -0
- package/test/verify-opencode-notice.mjs +77 -0
- package/test/verify-opencode-nudge.mjs +116 -0
- package/test/verify-opencode-orphans.mjs +160 -0
- package/test/verify-opencode-surface.mjs +107 -0
- package/test/verify-packaging.mjs +82 -0
- package/test/verify-parent-surface.mjs +118 -0
- package/test/verify-phase0.mjs +95 -0
- package/test/verify-registry.mjs +124 -0
- package/test/verify-rename-migration.mjs +111 -0
- package/test/verify-rendering.mjs +379 -0
- package/test/verify-session-boundary.mjs +146 -0
- package/test/verify-settings.mjs +260 -0
- package/test/verify-stale-wait.mjs +339 -0
- package/test/verify-status-widget.mjs +377 -0
- package/test/verify-status.mjs +172 -0
- package/test/verify-task-completion.mjs +156 -0
- package/test/verify-task-failures.mjs +201 -0
- package/test/verify-task-mislabel.mjs +143 -0
- package/test/verify-task-registry.mjs +194 -0
- package/test/verify-task-watchers.mjs +217 -0
- package/test/verify-tool-schemas.mjs +120 -0
- package/test/verify-unseen-completions.mjs +1211 -0
- package/test/verify-watchers.mjs +181 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Unit test for the shared opaque-id codec (src/core/ids.ts) and its wiring
|
|
3
|
+
// into LifecycleRegistry. Formats and invalid-handle messages are part of the
|
|
4
|
+
// model-facing contract: these assertions must stay byte-identical.
|
|
5
|
+
const { mintId, mintMessageId, normalizeHandleId } = await import('../src/core/ids.ts');
|
|
6
|
+
const { LifecycleRegistry, LifecycleError } = await import('../src/core/orchestration.ts');
|
|
7
|
+
|
|
8
|
+
let failures = 0;
|
|
9
|
+
function assert(ok, label) {
|
|
10
|
+
if (ok) console.log(`PASS ${label}`);
|
|
11
|
+
else {
|
|
12
|
+
failures++;
|
|
13
|
+
console.log(`FAIL ${label}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const UUID = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}';
|
|
18
|
+
|
|
19
|
+
// ── mint formats ─────────────────────────────────────────────────────────
|
|
20
|
+
for (const kind of ['agent', 'prompt', 'task', 'watch']) {
|
|
21
|
+
const id = mintId(kind, 'sess1234');
|
|
22
|
+
assert(
|
|
23
|
+
new RegExp(`^shepherd-${kind}-sess1234-${UUID}$`).test(id),
|
|
24
|
+
`mintId('${kind}') mints shepherd-${kind}-<session>-<uuid>`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
assert(
|
|
28
|
+
new RegExp(`^shepherd-message-${UUID}$`).test(mintMessageId()),
|
|
29
|
+
'mintMessageId() mints shepherd-message-<uuid>'
|
|
30
|
+
);
|
|
31
|
+
assert(mintId('agent', 's') !== mintId('agent', 's'), 'mintId mints a fresh uuid per call');
|
|
32
|
+
assert(mintMessageId() !== mintMessageId(), 'mintMessageId mints a fresh uuid per call');
|
|
33
|
+
assert(
|
|
34
|
+
mintId('watch', 'session-1').startsWith('shepherd-watch-session-1-'),
|
|
35
|
+
'mintId uses the literal session segment verbatim'
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// ── normalize accepts the two historical handle inputs ───────────────────
|
|
39
|
+
const agentString = normalizeHandleId('shepherd-agent-1', 'AgentHandle');
|
|
40
|
+
assert(agentString.ok && agentString.id === 'shepherd-agent-1', 'agent handle string accepted');
|
|
41
|
+
const agentObject = normalizeHandleId({ id: 'shepherd-agent-1' }, 'AgentHandle');
|
|
42
|
+
assert(agentObject.ok && agentObject.id === 'shepherd-agent-1', 'agent handle object accepted');
|
|
43
|
+
const padded = normalizeHandleId(' shepherd-agent-1 ', 'AgentHandle');
|
|
44
|
+
assert(padded.ok && padded.id === ' shepherd-agent-1 ', 'handle string is returned untrimmed');
|
|
45
|
+
const emptyObjectId = normalizeHandleId({ id: '' }, 'AgentHandle');
|
|
46
|
+
assert(
|
|
47
|
+
emptyObjectId.ok && emptyObjectId.id === '',
|
|
48
|
+
'object id remains accepted as-is (historical behavior)'
|
|
49
|
+
);
|
|
50
|
+
const promptHandle = normalizeHandleId({ id: 'shepherd-prompt-1' }, 'PromptHandle');
|
|
51
|
+
assert(promptHandle.ok && promptHandle.id === 'shepherd-prompt-1', 'prompt handle object accepted');
|
|
52
|
+
const taskString = normalizeHandleId('shepherd-task-1', 'TaskHandle');
|
|
53
|
+
assert(taskString.ok && taskString.id === 'shepherd-task-1', 'task handle string accepted');
|
|
54
|
+
const taskObject = normalizeHandleId({ id: 'shepherd-task-1' }, 'TaskHandle');
|
|
55
|
+
assert(taskObject.ok && taskObject.id === 'shepherd-task-1', 'task handle object accepted');
|
|
56
|
+
|
|
57
|
+
// ── normalize rejects with byte-stable messages, never throws ────────────
|
|
58
|
+
const AGENT_INVALID =
|
|
59
|
+
'Expected the opaque agent id as a string. Do not pass a quoted JSON object, array, or Herdr pane id. Correct syntax: { id: "shepherd-agent-..." }.';
|
|
60
|
+
const PROMPT_INVALID =
|
|
61
|
+
'Expected the opaque prompt id as a string. Do not pass a quoted JSON object, array, or Herdr pane id. Correct syntax: { id: "shepherd-prompt-..." } (or { id: ["prompt-a", "prompt-b"] } for parallel wait).';
|
|
62
|
+
// The historical task message ends with a literal trailing space; keep it.
|
|
63
|
+
const TASK_INVALID =
|
|
64
|
+
'Expected the opaque TaskHandle id as a string. Do not pass a quoted JSON object, array, agent id, or Herdr pane id. Correct syntax: { id: "shepherd-task-..." }.' +
|
|
65
|
+
' ';
|
|
66
|
+
|
|
67
|
+
const badInputs = [undefined, null, 0, false, '', ' ', [], ['id'], {}, { id: 42 }, { id: null }];
|
|
68
|
+
for (const [kind, message] of [
|
|
69
|
+
['AgentHandle', AGENT_INVALID],
|
|
70
|
+
['PromptHandle', PROMPT_INVALID],
|
|
71
|
+
['TaskHandle', TASK_INVALID],
|
|
72
|
+
]) {
|
|
73
|
+
for (const input of badInputs) {
|
|
74
|
+
const result = normalizeHandleId(input, kind);
|
|
75
|
+
assert(
|
|
76
|
+
result.ok === false && result.message === message,
|
|
77
|
+
`${kind} rejection message is byte-identical (${JSON.stringify(input)})`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
let threw = false;
|
|
82
|
+
try {
|
|
83
|
+
normalizeHandleId(null, 'AgentHandle');
|
|
84
|
+
} catch {
|
|
85
|
+
threw = true;
|
|
86
|
+
}
|
|
87
|
+
assert(!threw, 'normalizeHandleId returns the error instead of throwing');
|
|
88
|
+
|
|
89
|
+
// ── LifecycleRegistry mints and validates through the codec ──────────────
|
|
90
|
+
const registry = new LifecycleRegistry();
|
|
91
|
+
const agent = registry.registerAgent({ agent: 'scout', paneId: 'pane-1' });
|
|
92
|
+
assert(
|
|
93
|
+
new RegExp(`^shepherd-agent-[0-9a-f]{8}-${UUID}$`).test(agent.id),
|
|
94
|
+
'LifecycleRegistry mints agent ids via mintId'
|
|
95
|
+
);
|
|
96
|
+
const task = registry.createTask(agent, 'verify ids');
|
|
97
|
+
assert(
|
|
98
|
+
new RegExp(`^shepherd-task-[0-9a-f]{8}-${UUID}$`).test(task.id),
|
|
99
|
+
'LifecycleRegistry mints task ids via mintId'
|
|
100
|
+
);
|
|
101
|
+
const prompt = registry.createPrompt(agent);
|
|
102
|
+
assert(
|
|
103
|
+
new RegExp(`^shepherd-prompt-[0-9a-f]{8}-${UUID}$`).test(prompt.id),
|
|
104
|
+
'LifecycleRegistry mints prompt ids via mintId'
|
|
105
|
+
);
|
|
106
|
+
const roundTrip = normalizeHandleId(agent, 'AgentHandle');
|
|
107
|
+
assert(roundTrip.ok && roundTrip.id === agent.id, 'registry handle round-trips through normalize');
|
|
108
|
+
|
|
109
|
+
function capture(fn) {
|
|
110
|
+
try {
|
|
111
|
+
fn();
|
|
112
|
+
return undefined;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
return error;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const agentError = capture(() => registry.getAgent(' '));
|
|
118
|
+
assert(
|
|
119
|
+
agentError instanceof LifecycleError &&
|
|
120
|
+
agentError.code === 'invalid_handle' &&
|
|
121
|
+
agentError.message === AGENT_INVALID,
|
|
122
|
+
'getAgent keeps invalid_handle error and exact message'
|
|
123
|
+
);
|
|
124
|
+
const promptError = capture(() => registry.getPrompt([]));
|
|
125
|
+
assert(
|
|
126
|
+
promptError instanceof LifecycleError &&
|
|
127
|
+
promptError.code === 'invalid_handle' &&
|
|
128
|
+
promptError.message === PROMPT_INVALID,
|
|
129
|
+
'getPrompt keeps invalid_handle error and exact message'
|
|
130
|
+
);
|
|
131
|
+
const taskError = capture(() => registry.getTask(null));
|
|
132
|
+
assert(
|
|
133
|
+
taskError instanceof LifecycleError &&
|
|
134
|
+
taskError.code === 'invalid_handle' &&
|
|
135
|
+
taskError.message === TASK_INVALID,
|
|
136
|
+
'getTask keeps invalid_handle error and exact message'
|
|
137
|
+
);
|
|
138
|
+
registry.close(agent);
|
|
139
|
+
|
|
140
|
+
if (failures) process.exit(1);
|
|
141
|
+
console.log('All id codec assertions passed.');
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Herdr-independent verification of delegated pi launch argument construction. */
|
|
3
|
+
import * as fs from 'node:fs';
|
|
4
|
+
|
|
5
|
+
const { writePiLaunchFiles } = await import('../src/core/herdr.ts');
|
|
6
|
+
let failures = 0;
|
|
7
|
+
function assert(condition, label) {
|
|
8
|
+
if (condition) console.log(`PASS ${label}`);
|
|
9
|
+
else {
|
|
10
|
+
failures++;
|
|
11
|
+
console.log(`FAIL ${label}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function check(label, omit, includeOption = true, model, omitContextFiles) {
|
|
15
|
+
const name = label;
|
|
16
|
+
const options = {
|
|
17
|
+
name,
|
|
18
|
+
task: 'do the task',
|
|
19
|
+
systemPrompt: 'agent Markdown body',
|
|
20
|
+
stayOpen: false,
|
|
21
|
+
tools: ['read'],
|
|
22
|
+
omitPiDocumentation: true,
|
|
23
|
+
};
|
|
24
|
+
if (model !== undefined) options.model = model;
|
|
25
|
+
if (omitContextFiles !== undefined) options.omitContextFiles = omitContextFiles;
|
|
26
|
+
if (includeOption) options.omitSystemPrompt = omit;
|
|
27
|
+
let files;
|
|
28
|
+
try {
|
|
29
|
+
files = writePiLaunchFiles(options);
|
|
30
|
+
const script = fs.readFileSync(files.scriptFile, 'utf8');
|
|
31
|
+
const task = fs.readFileSync(`${files.dir}/task-${name}.md`, 'utf8');
|
|
32
|
+
assert(
|
|
33
|
+
script.includes('--append-system-prompt') === false,
|
|
34
|
+
`${label}: no duplicate append system prompt flag`
|
|
35
|
+
);
|
|
36
|
+
assert(
|
|
37
|
+
script.includes("--system-prompt '") === !!omit,
|
|
38
|
+
`${label}: replacement system prompt flag`
|
|
39
|
+
);
|
|
40
|
+
assert(script.includes(`'@${files.dir}/task-${name}.md'`), `${label}: task file argument`);
|
|
41
|
+
assert(
|
|
42
|
+
task.includes('do the task') &&
|
|
43
|
+
task.includes('FINAL assistant message') &&
|
|
44
|
+
task.includes('shepherd_message') &&
|
|
45
|
+
task.includes('shepherd_done') &&
|
|
46
|
+
task.includes('does not complete the task'),
|
|
47
|
+
`${label}: task and completion instructions`
|
|
48
|
+
);
|
|
49
|
+
assert(
|
|
50
|
+
script.includes('shepherd-done.ts') &&
|
|
51
|
+
script.includes('--tools read,shepherd_message,shepherd_done'),
|
|
52
|
+
`${label}: completion extension wiring + child-surface tools kept in --tools allowlist`
|
|
53
|
+
);
|
|
54
|
+
assert(
|
|
55
|
+
script.includes("PI_SHEPHERD_AGENT_SYSTEM_PROMPT_FILE='"),
|
|
56
|
+
`${label}: agent system prompt wiring`
|
|
57
|
+
);
|
|
58
|
+
assert(
|
|
59
|
+
script.includes('PI_SHEPHERD_OMIT_PI_DOCUMENTATION=1'),
|
|
60
|
+
`${label}: Pi documentation omission wiring`
|
|
61
|
+
);
|
|
62
|
+
assert(
|
|
63
|
+
script.includes('--no-context-files') === (omitContextFiles === true),
|
|
64
|
+
`${label}: context-file omission argument`
|
|
65
|
+
);
|
|
66
|
+
assert(
|
|
67
|
+
script.includes("--model 'anthropic/claude-sonnet-4-5'") === (model !== undefined),
|
|
68
|
+
`${label}: model argument`
|
|
69
|
+
);
|
|
70
|
+
assert(!script.includes('--thinking '), `${label}: no thinking argument`);
|
|
71
|
+
assert(fs.existsSync(`${files.dir}/sysprompt-${name}.md`), `${label}: system prompt file`);
|
|
72
|
+
assert(
|
|
73
|
+
fs.readFileSync(`${files.dir}/sysprompt-${name}.md`, 'utf8') === 'agent Markdown body',
|
|
74
|
+
`${label}: prompt file content`
|
|
75
|
+
);
|
|
76
|
+
} finally {
|
|
77
|
+
if (files) fs.rmSync(files.dir, { recursive: true, force: true });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
check('default', false);
|
|
81
|
+
check('implicit-default', false, false);
|
|
82
|
+
check('omit', true);
|
|
83
|
+
check('context-true', false, true, undefined, true);
|
|
84
|
+
check('context-false', false, true, undefined, false);
|
|
85
|
+
check('context-absent', false, false);
|
|
86
|
+
check('model', false, true, 'anthropic/claude-sonnet-4-5');
|
|
87
|
+
|
|
88
|
+
const thinkingLaunch = writePiLaunchFiles({
|
|
89
|
+
name: 'thinking',
|
|
90
|
+
task: 'use the requested thinking level',
|
|
91
|
+
model: 'anthropic/claude-sonnet-4-5',
|
|
92
|
+
thinking: 'xhigh',
|
|
93
|
+
});
|
|
94
|
+
try {
|
|
95
|
+
const script = fs.readFileSync(thinkingLaunch.scriptFile, 'utf8');
|
|
96
|
+
assert(script.includes("--thinking 'xhigh'"), 'thinking: explicit level argument');
|
|
97
|
+
} finally {
|
|
98
|
+
fs.rmSync(thinkingLaunch.dir, { recursive: true, force: true });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const offThinkingLaunch = writePiLaunchFiles({
|
|
102
|
+
name: 'thinking-off',
|
|
103
|
+
task: 'disable thinking',
|
|
104
|
+
thinking: 'off',
|
|
105
|
+
});
|
|
106
|
+
try {
|
|
107
|
+
const script = fs.readFileSync(offThinkingLaunch.scriptFile, 'utf8');
|
|
108
|
+
assert(script.includes("--thinking 'off'"), 'thinking: off argument');
|
|
109
|
+
} finally {
|
|
110
|
+
fs.rmSync(offThinkingLaunch.dir, { recursive: true, force: true });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const defaultThinkingLaunch = writePiLaunchFiles({
|
|
114
|
+
name: 'thinking-default',
|
|
115
|
+
task: 'inherit thinking',
|
|
116
|
+
thinking: 'default',
|
|
117
|
+
});
|
|
118
|
+
try {
|
|
119
|
+
const script = fs.readFileSync(defaultThinkingLaunch.scriptFile, 'utf8');
|
|
120
|
+
assert(!script.includes('--thinking '), 'thinking: default omits override');
|
|
121
|
+
} finally {
|
|
122
|
+
fs.rmSync(defaultThinkingLaunch.dir, { recursive: true, force: true });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let invalidThinkingLaunchRejected = false;
|
|
126
|
+
try {
|
|
127
|
+
writePiLaunchFiles({ name: 'thinking-invalid', thinking: 'none' });
|
|
128
|
+
} catch {
|
|
129
|
+
invalidThinkingLaunchRejected = true;
|
|
130
|
+
}
|
|
131
|
+
assert(invalidThinkingLaunchRejected, 'thinking: launch rejects invalid level');
|
|
132
|
+
|
|
133
|
+
const brokerLaunch = writePiLaunchFiles({
|
|
134
|
+
name: 'broker-wired',
|
|
135
|
+
task: 'use the broker',
|
|
136
|
+
childBroker: {
|
|
137
|
+
rootDir: '/tmp/shepherd-broker',
|
|
138
|
+
sessionId: 'session-1',
|
|
139
|
+
brokerId: 'broker-1',
|
|
140
|
+
agentId: 'shepherd-agent-1',
|
|
141
|
+
token: 'secret-token',
|
|
142
|
+
inboxPath: '/tmp/shepherd-broker/agents/child/inbox',
|
|
143
|
+
},
|
|
144
|
+
taskId: 'shepherd-task-1',
|
|
145
|
+
});
|
|
146
|
+
try {
|
|
147
|
+
const script = fs.readFileSync(brokerLaunch.scriptFile, 'utf8');
|
|
148
|
+
const task = fs.readFileSync(`${brokerLaunch.dir}/task-broker-wired.md`, 'utf8');
|
|
149
|
+
assert(
|
|
150
|
+
task.includes('Task ID: shepherd-task-1') &&
|
|
151
|
+
task.includes('replyTo') &&
|
|
152
|
+
task.includes('status blocked'),
|
|
153
|
+
'broker launch: tracked task context and reply instructions'
|
|
154
|
+
);
|
|
155
|
+
assert(
|
|
156
|
+
script.includes("PI_SHEPHERD_BROKER_DIR='/tmp/shepherd-broker'"),
|
|
157
|
+
'broker launch: broker directory wiring'
|
|
158
|
+
);
|
|
159
|
+
assert(
|
|
160
|
+
script.includes("PI_SHEPHERD_BROKER_SESSION_ID='session-1'"),
|
|
161
|
+
'broker launch: session wiring'
|
|
162
|
+
);
|
|
163
|
+
assert(script.includes("PI_SHEPHERD_BROKER_ID='broker-1'"), 'broker launch: broker id wiring');
|
|
164
|
+
assert(
|
|
165
|
+
script.includes("PI_SHEPHERD_AGENT_ID='shepherd-agent-1'"),
|
|
166
|
+
'broker launch: agent id wiring'
|
|
167
|
+
);
|
|
168
|
+
assert(
|
|
169
|
+
script.includes("PI_SHEPHERD_BROKER_TOKEN='secret-token'"),
|
|
170
|
+
'broker launch: capability wiring'
|
|
171
|
+
);
|
|
172
|
+
assert(
|
|
173
|
+
script.includes("PI_SHEPHERD_AGENT_INBOX='/tmp/shepherd-broker/agents/child/inbox'"),
|
|
174
|
+
'broker launch: inbox wiring'
|
|
175
|
+
);
|
|
176
|
+
assert(script.includes("PI_SHEPHERD_TASK_ID='shepherd-task-1'"), 'broker launch: task id wiring');
|
|
177
|
+
} finally {
|
|
178
|
+
fs.rmSync(brokerLaunch.dir, { recursive: true, force: true });
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Inheritance is resolved before launch; absent model must omit --model.
|
|
182
|
+
if (failures) process.exit(1);
|
|
183
|
+
console.log('All launch assertions passed.');
|