@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,100 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Focused verification for /shepherd completions and command guardrails. */
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
|
|
8
|
+
// Isolate persisted settings and fieldnotes from the developer's real session.
|
|
9
|
+
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'pi-shepherd-command-ux-'));
|
|
10
|
+
process.env.HOME = home;
|
|
11
|
+
|
|
12
|
+
// Keep this command-surface test independent of a developer's Herdr install.
|
|
13
|
+
// The command handler only needs Herdr availability to reach the error path
|
|
14
|
+
// being tested; no actual Herdr operation should be performed here.
|
|
15
|
+
const fakeBinDir = path.join(home, 'bin');
|
|
16
|
+
fs.mkdirSync(fakeBinDir, { recursive: true });
|
|
17
|
+
const fakeHerdr = path.join(fakeBinDir, 'herdr');
|
|
18
|
+
fs.writeFileSync(fakeHerdr, '#!/bin/sh\n[ "$1" = "--version" ] && echo herdr-test\n');
|
|
19
|
+
fs.chmodSync(fakeHerdr, 0o755);
|
|
20
|
+
process.env.PATH = `${fakeBinDir}${path.delimiter}${process.env.PATH ?? ''}`;
|
|
21
|
+
process.env.HERDR_ENV = '1';
|
|
22
|
+
|
|
23
|
+
const settingsDir = path.join(home, '.pi', 'agent', 'pi-shepherd');
|
|
24
|
+
fs.mkdirSync(settingsDir, { recursive: true });
|
|
25
|
+
fs.writeFileSync(
|
|
26
|
+
path.join(settingsDir, 'config.json'),
|
|
27
|
+
JSON.stringify({
|
|
28
|
+
agentScope: 'both',
|
|
29
|
+
confirmProjectAgents: false,
|
|
30
|
+
fieldnotes: false,
|
|
31
|
+
timeout: 20,
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const commands = new Map();
|
|
36
|
+
const events = [];
|
|
37
|
+
const pi = {
|
|
38
|
+
registerTool() {},
|
|
39
|
+
registerMessageRenderer() {},
|
|
40
|
+
registerCommand(name, spec) {
|
|
41
|
+
commands.set(name, spec);
|
|
42
|
+
},
|
|
43
|
+
on(event) {
|
|
44
|
+
events.push(event);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const { default: extension } = await import('../index.ts');
|
|
48
|
+
extension(pi);
|
|
49
|
+
const command = commands.get('shepherd');
|
|
50
|
+
assert.ok(command, 'shepherd command registered');
|
|
51
|
+
const complete = prefix => command.getArgumentCompletions(prefix);
|
|
52
|
+
|
|
53
|
+
assert.ok(
|
|
54
|
+
(complete('spa') ?? []).some(item => item.value === 'spawn planner'),
|
|
55
|
+
'partial spawn completion expands to agent entries'
|
|
56
|
+
);
|
|
57
|
+
assert.ok(
|
|
58
|
+
(complete('spawn ') ?? []).some(item => item.value === 'spawn planner'),
|
|
59
|
+
'spawn completion includes discovered agent'
|
|
60
|
+
);
|
|
61
|
+
assert.ok(
|
|
62
|
+
(complete('sta') ?? []).some(item => item.value === 'status planner'),
|
|
63
|
+
'status completion includes discovered agent'
|
|
64
|
+
);
|
|
65
|
+
assert.ok(
|
|
66
|
+
(complete('read ') ?? []).some(item => item.value === 'read planner'),
|
|
67
|
+
'read completion includes discovered agent'
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const notifications = [];
|
|
71
|
+
const statuses = [];
|
|
72
|
+
const ctx = {
|
|
73
|
+
cwd: path.resolve('.'),
|
|
74
|
+
ui: {
|
|
75
|
+
notify(message, level) {
|
|
76
|
+
notifications.push({ message, level });
|
|
77
|
+
},
|
|
78
|
+
setStatus(_key, value) {
|
|
79
|
+
statuses.push(value);
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
sessionManager: { getSessionId: () => 'phase7-command', getSessionFile: () => undefined },
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
await command.handler('spawn', ctx);
|
|
86
|
+
assert.equal(notifications.at(-1).level, 'warning');
|
|
87
|
+
assert.match(notifications.at(-1).message, /Usage/);
|
|
88
|
+
await command.handler('status', ctx);
|
|
89
|
+
assert.equal(notifications.at(-1).level, 'warning');
|
|
90
|
+
assert.match(notifications.at(-1).message, /Usage/);
|
|
91
|
+
|
|
92
|
+
// A valid but unknown spawn reaches the long-running status guard, then clears
|
|
93
|
+
// it even when doAction fails before creating a pane.
|
|
94
|
+
await command.handler('spawn definitely-not-an-agent', ctx);
|
|
95
|
+
assert.deepEqual(statuses.slice(-2), ['Starting definitely-not-an-agent…', undefined]);
|
|
96
|
+
assert.equal(notifications.at(-1).level, 'error');
|
|
97
|
+
assert.match(notifications.at(-1).message, /Unknown agent/);
|
|
98
|
+
|
|
99
|
+
console.log('PASS command completions, usage hints, and spawn status cleanup');
|
|
100
|
+
console.log('All command UX assertions passed.');
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Compatibility verification after removal of the blocking shepherd_wait tool. */
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { registerShepherdTools } from '../src/extension/shepherd.ts';
|
|
7
|
+
|
|
8
|
+
const registered = [];
|
|
9
|
+
registerShepherdTools({
|
|
10
|
+
registerTool(tool) {
|
|
11
|
+
registered.push(tool);
|
|
12
|
+
},
|
|
13
|
+
registerMessageRenderer() {},
|
|
14
|
+
});
|
|
15
|
+
const byName = Object.fromEntries(registered.map(tool => [tool.name, tool]));
|
|
16
|
+
assert.equal(
|
|
17
|
+
byName.shepherd_wait,
|
|
18
|
+
undefined,
|
|
19
|
+
'blocking shepherd_wait is removed from the public surface'
|
|
20
|
+
);
|
|
21
|
+
assert.ok(byName.shepherd_watch, 'shepherd_watch remains available');
|
|
22
|
+
assert.match(byName.shepherd_watch.description, /non-blocking/i);
|
|
23
|
+
assert.match(JSON.stringify(byName.shepherd_watch.promptGuidelines), /status/i);
|
|
24
|
+
const promptParams = JSON.stringify(byName.shepherd_prompt.parameters);
|
|
25
|
+
assert.match(promptParams, /shepherd_watch/i, 'deprecated prompt path points at shepherd_watch');
|
|
26
|
+
const handoffPath = fileURLToPath(
|
|
27
|
+
new URL('../docs/specs/005-agent-messaging-and-task-lifecycle/handoff.md', import.meta.url)
|
|
28
|
+
);
|
|
29
|
+
const handoff = readFileSync(handoffPath, 'utf8');
|
|
30
|
+
assert.match(handoff, /shepherd_wait.*removed|removed.*shepherd_wait/i, 'handoff records removal');
|
|
31
|
+
console.log('PASS shepherd_wait is hard-removed from the model-facing surface');
|
|
32
|
+
console.log('All compatibility assertions passed.');
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* T013 acceptance — sequential delegated notes shared across hosts.
|
|
4
|
+
*
|
|
5
|
+
* Drives the Pi and OpenCode gates/resolvers against one project without a
|
|
6
|
+
* live TUI or Herdr: both hosts present the same opaque parent identity and
|
|
7
|
+
* project root, so their sequential delegations land in exactly one
|
|
8
|
+
* `.shepherd/sessions/NNNN-*` collection, linked by one MOC. Also proves
|
|
9
|
+
* disabled-notes mode stays off on both hosts, including mid-session flips.
|
|
10
|
+
*/
|
|
11
|
+
import assert from 'node:assert/strict';
|
|
12
|
+
import fs from 'node:fs';
|
|
13
|
+
import os from 'node:os';
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
|
|
16
|
+
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'pi-shepherd-t013-home-'));
|
|
17
|
+
process.env.HOME = home;
|
|
18
|
+
process.env.OPENCODE_CONFIG_DIR = path.join(home, 'config', 'opencode');
|
|
19
|
+
fs.mkdirSync(process.env.OPENCODE_CONFIG_DIR, { recursive: true });
|
|
20
|
+
const projectRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'pi-shepherd-t013-project-'));
|
|
21
|
+
|
|
22
|
+
const { installOpencodeHost } = await import('../src/opencode/host.ts');
|
|
23
|
+
installOpencodeHost();
|
|
24
|
+
const { parentArtifactSession, resetOpencodeFieldnotesCache } = await import(
|
|
25
|
+
'../src/opencode/fieldnotes.ts'
|
|
26
|
+
);
|
|
27
|
+
const {
|
|
28
|
+
resolveOrCreateParentArtifactSession,
|
|
29
|
+
reserveArtifacts,
|
|
30
|
+
markArtifactStarted,
|
|
31
|
+
finalizeArtifact,
|
|
32
|
+
readSessionMetadata,
|
|
33
|
+
} = await import('../src/core/artifact-sessions.ts');
|
|
34
|
+
const { fieldnotesEnabled, initializeSessionSettings } = await import('../src/core/config.ts');
|
|
35
|
+
|
|
36
|
+
const ctx = sessionId => ({ sessionId, cwd: projectRoot });
|
|
37
|
+
const sessionDirs = root =>
|
|
38
|
+
fs.readdirSync(path.join(root, '.shepherd', 'sessions')).filter(n => /^\d{4,}-/.test(n));
|
|
39
|
+
|
|
40
|
+
// 1. Pi opens the binding; OpenCode presents the SAME opaque identity.
|
|
41
|
+
const sharedIdentity = 'ses-t013-shared';
|
|
42
|
+
const piSession = resolveOrCreateParentArtifactSession({
|
|
43
|
+
parentPiSessionId: sharedIdentity,
|
|
44
|
+
projectRoot,
|
|
45
|
+
parentSessionFile: '/tmp/pi-parent.jsonl',
|
|
46
|
+
});
|
|
47
|
+
const ocSession = parentArtifactSession(ctx(sharedIdentity));
|
|
48
|
+
assert.equal(ocSession.sessionPath, piSession.sessionPath, 'OpenCode reuses the Pi-bound session');
|
|
49
|
+
assert.equal(ocSession.resumed, true);
|
|
50
|
+
assert.equal(ocSession.artifactSessionVersion, 2);
|
|
51
|
+
|
|
52
|
+
// 2. Sequential delegation 1 — Pi side leaves a note.
|
|
53
|
+
const a1 = reserveArtifacts(piSession, [{ agent: 'scout', mode: 'single', task: 'pi delegation' }])[0];
|
|
54
|
+
markArtifactStarted(piSession, a1);
|
|
55
|
+
finalizeArtifact(piSession, a1, { status: 'completed', output: 'note from Pi host' });
|
|
56
|
+
|
|
57
|
+
// 3. Sequential delegation 2 — OpenCode re-resolves (separate tool call) and
|
|
58
|
+
// leaves a follow-up note in the same collection.
|
|
59
|
+
const ocReresolved = parentArtifactSession(ctx(sharedIdentity));
|
|
60
|
+
assert.equal(ocReresolved.resumed, true, 'a later tool call reloads the same binding');
|
|
61
|
+
const a2 = reserveArtifacts(ocReresolved, [
|
|
62
|
+
{ agent: 'worker', mode: 'single', task: 'oc follow-up' },
|
|
63
|
+
])[0];
|
|
64
|
+
markArtifactStarted(ocReresolved, a2);
|
|
65
|
+
finalizeArtifact(ocReresolved, a2, { status: 'completed', output: 'note from OpenCode host' });
|
|
66
|
+
|
|
67
|
+
// 4. One session directory, two distinct notes, one MOC linking both.
|
|
68
|
+
assert.deepEqual(sessionDirs(projectRoot).length, 1, 'exactly one numbered session directory');
|
|
69
|
+
assert.equal(path.dirname(a1.filePath), piSession.sessionPath);
|
|
70
|
+
assert.equal(path.dirname(a2.filePath), piSession.sessionPath);
|
|
71
|
+
assert.notEqual(a1.filePath, a2.filePath, 'two distinct note files');
|
|
72
|
+
const stored = JSON.parse(fs.readFileSync(piSession.sessionMetadataPath, 'utf8'));
|
|
73
|
+
assert.equal(stored.artifacts.length, 2);
|
|
74
|
+
assert.deepEqual(stored.artifacts.map(a => a.status), ['completed', 'completed']);
|
|
75
|
+
const moc = fs.readFileSync(piSession.mocPath, 'utf8');
|
|
76
|
+
assert.match(moc, /\.\/scout-01\.md/);
|
|
77
|
+
assert.match(moc, /\.\/worker-01\.md/);
|
|
78
|
+
assert.match(fs.readFileSync(a1.filePath, 'utf8'), /note from Pi host/);
|
|
79
|
+
assert.match(fs.readFileSync(a2.filePath, 'utf8'), /note from OpenCode host/);
|
|
80
|
+
assert.equal(readSessionMetadata(piSession.sessionPath).artifacts.length, 2);
|
|
81
|
+
assert.equal(fs.existsSync(path.join(projectRoot, '.shepherd', 'shepherd.md')), false);
|
|
82
|
+
console.log('PASS sequential Pi→OpenCode delegations share one session and one MOC');
|
|
83
|
+
|
|
84
|
+
// 5. Reverse direction, self-contained: OpenCode opens a fresh binding, the
|
|
85
|
+
// Pi resolver finds it and adds a note.
|
|
86
|
+
const reverseRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'pi-shepherd-t013-reverse-'));
|
|
87
|
+
const reverseIdentity = 'ses-t013-reverse';
|
|
88
|
+
const reverseCtx = { sessionId: reverseIdentity, cwd: reverseRoot };
|
|
89
|
+
const ocFirst = parentArtifactSession(reverseCtx);
|
|
90
|
+
const piSecond = resolveOrCreateParentArtifactSession({
|
|
91
|
+
parentPiSessionId: reverseIdentity,
|
|
92
|
+
projectRoot: reverseRoot,
|
|
93
|
+
});
|
|
94
|
+
assert.equal(piSecond.sessionPath, ocFirst.sessionPath);
|
|
95
|
+
const a3 = reserveArtifacts(piSecond, [{ agent: 'reviewer', mode: 'single', task: 'pi follow-up' }])[0];
|
|
96
|
+
markArtifactStarted(piSecond, a3);
|
|
97
|
+
finalizeArtifact(piSecond, a3, { status: 'completed', output: 'note from Pi after OpenCode' });
|
|
98
|
+
assert.equal(sessionDirs(reverseRoot).length, 1);
|
|
99
|
+
assert.match(fs.readFileSync(ocFirst.mocPath, 'utf8'), /\.\/reviewer-01\.md/);
|
|
100
|
+
console.log('PASS sequential OpenCode→Pi delegations share one session and one MOC');
|
|
101
|
+
|
|
102
|
+
// 6. Disabled notes stay off on both hosts, including mid-session flips.
|
|
103
|
+
const offRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'pi-shepherd-t013-off-'));
|
|
104
|
+
const configFile = path.join(offRoot, '.shepherd', 'config.json');
|
|
105
|
+
fs.mkdirSync(path.dirname(configFile), { recursive: true });
|
|
106
|
+
const writeConfig = fieldnotes =>
|
|
107
|
+
fs.writeFileSync(configFile, JSON.stringify({ projectScope: true, fieldnotes }));
|
|
108
|
+
writeConfig(false);
|
|
109
|
+
initializeSessionSettings(offRoot);
|
|
110
|
+
resetOpencodeFieldnotesCache();
|
|
111
|
+
assert.equal(fieldnotesEnabled(), false, 'Pi gate sees disabled fieldnotes');
|
|
112
|
+
assert.equal(parentArtifactSession({ sessionId: 'ses-t013-off', cwd: offRoot }), undefined);
|
|
113
|
+
assert.equal(fs.existsSync(path.join(offRoot, '.shepherd', 'sessions')), false);
|
|
114
|
+
|
|
115
|
+
writeConfig(true);
|
|
116
|
+
assert.equal(fieldnotesEnabled(), false, 'Pi session snapshot stays disabled');
|
|
117
|
+
assert.equal(
|
|
118
|
+
parentArtifactSession({ sessionId: 'ses-t013-off', cwd: offRoot }),
|
|
119
|
+
undefined,
|
|
120
|
+
'OpenCode session snapshot stays disabled'
|
|
121
|
+
);
|
|
122
|
+
initializeSessionSettings(offRoot);
|
|
123
|
+
resetOpencodeFieldnotesCache();
|
|
124
|
+
assert.equal(fieldnotesEnabled(), true, 'a new Pi session observes the change');
|
|
125
|
+
assert.ok(parentArtifactSession({ sessionId: 'ses-t013-on', cwd: offRoot }));
|
|
126
|
+
console.log('PASS disabled fieldnotes stay off on both hosts; new sessions see changes');
|
|
127
|
+
|
|
128
|
+
console.log('\nAll T013 cross-host fieldnote assertions passed.');
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Phase 4 verification for the tracked delegation adapter contract. */
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
import { registerShepherdTools } from '../src/extension/shepherd.ts';
|
|
7
|
+
import {
|
|
8
|
+
currentParentBroker,
|
|
9
|
+
delegateAgent,
|
|
10
|
+
ensureParentBroker,
|
|
11
|
+
shutdownParentBroker,
|
|
12
|
+
} from '../src/core/lifecycle.ts';
|
|
13
|
+
import { createChildBroker, pollChildInbox } from '../src/core/messaging.ts';
|
|
14
|
+
import { createOrResumeSession } from '../src/core/artifact-sessions.ts';
|
|
15
|
+
import { LifecycleError, lifecycleRegistry } from '../src/core/orchestration.ts';
|
|
16
|
+
import { withTempDirectory } from './helpers/test-utils.mjs';
|
|
17
|
+
|
|
18
|
+
const registered = [];
|
|
19
|
+
registerShepherdTools({
|
|
20
|
+
registerTool(tool) {
|
|
21
|
+
registered.push(tool);
|
|
22
|
+
},
|
|
23
|
+
registerMessageRenderer() {},
|
|
24
|
+
});
|
|
25
|
+
const delegateTool = registered.find(tool => tool.name === 'shepherd_delegate');
|
|
26
|
+
assert.ok(delegateTool, 'parent registers shepherd_delegate');
|
|
27
|
+
assert.equal(delegateTool.parameters.type, 'object');
|
|
28
|
+
assert.deepEqual(delegateTool.parameters.required, ['target', 'task']);
|
|
29
|
+
assert.deepEqual(Object.keys(delegateTool.parameters.properties).sort(), [
|
|
30
|
+
'target',
|
|
31
|
+
'task',
|
|
32
|
+
'timeout',
|
|
33
|
+
]);
|
|
34
|
+
assert.match(delegateTool.description, /task id/i);
|
|
35
|
+
assert.match(delegateTool.description, /idle child/i);
|
|
36
|
+
console.log('PASS parent delegation tool exposes the tracked task contract');
|
|
37
|
+
|
|
38
|
+
await withTempDirectory('pi-shepherd-delegate-', async root => {
|
|
39
|
+
const bin = path.join(root, 'bin');
|
|
40
|
+
fs.mkdirSync(bin);
|
|
41
|
+
const fakeHerdr = path.join(bin, 'herdr');
|
|
42
|
+
fs.writeFileSync(
|
|
43
|
+
fakeHerdr,
|
|
44
|
+
`#!/bin/sh
|
|
45
|
+
if [ "$1" = "agent" ] && [ "$2" = "get" ]; then
|
|
46
|
+
printf '%s\\n' '{"result":{"agent":{"pane_id":"pane-delegate-test","agent_status":"idle"}}}'
|
|
47
|
+
exit 0
|
|
48
|
+
fi
|
|
49
|
+
if [ "$1" = "--version" ]; then printf '%s\\n' 'herdr test'; exit 0; fi
|
|
50
|
+
exit 1
|
|
51
|
+
`
|
|
52
|
+
);
|
|
53
|
+
fs.chmodSync(fakeHerdr, 0o700);
|
|
54
|
+
const oldPath = process.env.PATH;
|
|
55
|
+
process.env.PATH = `${bin}${path.delimiter}${oldPath ?? ''}`;
|
|
56
|
+
let task;
|
|
57
|
+
let agent;
|
|
58
|
+
try {
|
|
59
|
+
agent = lifecycleRegistry.registerAgent({
|
|
60
|
+
agent: 'scout',
|
|
61
|
+
label: 'delegate test',
|
|
62
|
+
paneId: 'pane-delegate-test',
|
|
63
|
+
});
|
|
64
|
+
const artifactSession = createOrResumeSession({
|
|
65
|
+
projectRoot: root,
|
|
66
|
+
sessionName: 'delegated-task',
|
|
67
|
+
mode: 'single',
|
|
68
|
+
});
|
|
69
|
+
const started = Date.now();
|
|
70
|
+
task = await delegateAgent(agent, 'Investigate the authentication flow.', {
|
|
71
|
+
sessionId: 'delegate-test-session',
|
|
72
|
+
artifactSession,
|
|
73
|
+
});
|
|
74
|
+
assert.ok(
|
|
75
|
+
Date.now() - started < 1_000,
|
|
76
|
+
'delegation returns without waiting for task completion'
|
|
77
|
+
);
|
|
78
|
+
assert.match(task.id, /^shepherd-task-/);
|
|
79
|
+
assert.equal(lifecycleRegistry.getTask(task.id).state, 'running');
|
|
80
|
+
const broker = currentParentBroker();
|
|
81
|
+
assert.ok(broker);
|
|
82
|
+
const capability = lifecycleRegistry.agentChildCapability(agent);
|
|
83
|
+
assert.ok(capability);
|
|
84
|
+
const child = createChildBroker({ rootDir: broker.rootDir, ...capability });
|
|
85
|
+
const taskEnvelope = pollChildInbox(child)[0];
|
|
86
|
+
assert.equal(taskEnvelope.kind, 'task');
|
|
87
|
+
assert.equal(taskEnvelope.taskId, task.id);
|
|
88
|
+
assert.equal(taskEnvelope.targetId, agent.id);
|
|
89
|
+
assert.equal(taskEnvelope.content, 'Investigate the authentication flow.');
|
|
90
|
+
const taskArtifact = lifecycleRegistry.taskArtifact(task).artifact;
|
|
91
|
+
assert.ok(taskArtifact);
|
|
92
|
+
assert.equal(taskArtifact.task, 'Investigate the authentication flow.');
|
|
93
|
+
assert.equal(taskArtifact.status, 'running');
|
|
94
|
+
console.log(
|
|
95
|
+
'PASS delegation creates a running task and queues a task envelope without waiting'
|
|
96
|
+
);
|
|
97
|
+
console.log('PASS delegation associates and starts one task artifact');
|
|
98
|
+
await assert.rejects(
|
|
99
|
+
() => delegateAgent(agent, 'A second active task.', { sessionId: 'delegate-test-session' }),
|
|
100
|
+
error => error?.code === 'active_task' || /active tracked task/.test(error?.message ?? '')
|
|
101
|
+
);
|
|
102
|
+
console.log('PASS delegation rejects a second active task for the same agent');
|
|
103
|
+
|
|
104
|
+
lifecycleRegistry.settleTask(task.id, { status: 'cancelled', error: 'test cleanup' });
|
|
105
|
+
assert.equal(lifecycleRegistry.getTask(task.id).state, 'cancelled');
|
|
106
|
+
assert.equal(lifecycleRegistry.taskArtifact(task).artifact.status, 'cancelled');
|
|
107
|
+
|
|
108
|
+
const failedAgent = lifecycleRegistry.registerAgent({
|
|
109
|
+
agent: 'worker',
|
|
110
|
+
label: 'publish failure',
|
|
111
|
+
paneId: 'pane-delegate-test',
|
|
112
|
+
});
|
|
113
|
+
await assert.rejects(
|
|
114
|
+
() => delegateAgent(failedAgent, 'x'.repeat(70_000), { sessionId: 'delegate-test-session' }),
|
|
115
|
+
/Task submission failed/
|
|
116
|
+
);
|
|
117
|
+
const failedTask = lifecycleRegistry
|
|
118
|
+
.allTasks()
|
|
119
|
+
.find(record => record.agentId === failedAgent.id);
|
|
120
|
+
assert.equal(failedTask.state, 'failed');
|
|
121
|
+
assert.equal(lifecycleRegistry.activeTaskForAgent(failedAgent), undefined);
|
|
122
|
+
console.log('PASS failed task publication rolls back the active task slot');
|
|
123
|
+
|
|
124
|
+
const closedAgent = lifecycleRegistry.registerAgent({
|
|
125
|
+
agent: 'planner',
|
|
126
|
+
label: 'closed target',
|
|
127
|
+
paneId: 'pane-delegate-test',
|
|
128
|
+
});
|
|
129
|
+
lifecycleRegistry.close(closedAgent);
|
|
130
|
+
await assert.rejects(
|
|
131
|
+
() =>
|
|
132
|
+
delegateAgent(closedAgent, 'This must not be submitted.', {
|
|
133
|
+
sessionId: 'delegate-test-session',
|
|
134
|
+
}),
|
|
135
|
+
error => error instanceof LifecycleError && error.code === 'closed_handle'
|
|
136
|
+
);
|
|
137
|
+
console.log('PASS delegation rejects a closed target agent');
|
|
138
|
+
|
|
139
|
+
assert.equal(
|
|
140
|
+
shutdownParentBroker(() => true),
|
|
141
|
+
true
|
|
142
|
+
);
|
|
143
|
+
} finally {
|
|
144
|
+
process.env.PATH = oldPath;
|
|
145
|
+
if (task && lifecycleRegistry.taskResult(task.id) === undefined) {
|
|
146
|
+
lifecycleRegistry.settleTask(task.id, { status: 'cancelled', error: 'test cleanup' });
|
|
147
|
+
}
|
|
148
|
+
if (currentParentBroker()) shutdownParentBroker(() => true);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
await assert.rejects(
|
|
153
|
+
() => delegateAgent('not-an-agent', 'Investigate this.'),
|
|
154
|
+
error => error instanceof LifecycleError && error.code === 'unknown_handle'
|
|
155
|
+
);
|
|
156
|
+
console.log('PASS delegation rejects unknown opaque agent ids before submission');
|
|
157
|
+
|
|
158
|
+
await assert.rejects(() => delegateAgent('not-an-agent', ''), /must not be empty/);
|
|
159
|
+
console.log('PASS delegation rejects empty task descriptions before submission');
|
|
160
|
+
|
|
161
|
+
console.log('All delegation assertions passed.');
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Unit test for the Phase 0.1 caller detector (src/runtimes/detect.ts).
|
|
3
|
+
// Matrix: TUI / app / plain / nested (innermost wins) / missing-binary.
|
|
4
|
+
// detectCaller() takes injected { env, execOk, fileExists } so no subprocess
|
|
5
|
+
// or filesystem is touched; fakes record calls to prove env-first order.
|
|
6
|
+
const { detectCaller } = await import('../src/runtimes/detect.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
|
+
// ── fakes ────────────────────────────────────────────────────────────────
|
|
18
|
+
function makeExec(okFor = {}) {
|
|
19
|
+
const calls = [];
|
|
20
|
+
const fn = (cmd, args) => {
|
|
21
|
+
calls.push(`${cmd} ${args.join(' ')}`);
|
|
22
|
+
return !!okFor[cmd];
|
|
23
|
+
};
|
|
24
|
+
fn.calls = calls;
|
|
25
|
+
return fn;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function makeExists(existing = []) {
|
|
29
|
+
const calls = [];
|
|
30
|
+
const fn = p => {
|
|
31
|
+
calls.push(p);
|
|
32
|
+
return existing.includes(p);
|
|
33
|
+
};
|
|
34
|
+
fn.calls = calls;
|
|
35
|
+
return fn;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const TUI_ENV = { HERDR_ENV: '1', HERDR_PANE_ID: 'pane-1' };
|
|
39
|
+
const APP_ENV = { HC_TERMINAL_ID: 't4', HC_TERMINAL_SOCKET: '/run/hc.sock' };
|
|
40
|
+
|
|
41
|
+
// ── TUI ──────────────────────────────────────────────────────────────────
|
|
42
|
+
{
|
|
43
|
+
const exec = makeExec({ herdr: true });
|
|
44
|
+
const exists = makeExists();
|
|
45
|
+
assert(
|
|
46
|
+
detectCaller({ env: { ...TUI_ENV }, execOk: exec, fileExists: exists }) === 'herdr-tui',
|
|
47
|
+
'TUI env + herdr binary -> herdr-tui'
|
|
48
|
+
);
|
|
49
|
+
assert(exec.calls.join(',') === 'herdr --version', 'TUI probes herdr --version');
|
|
50
|
+
assert(exists.calls.length === 0, 'TUI path never probes the hc socket');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ── app ──────────────────────────────────────────────────────────────────
|
|
54
|
+
{
|
|
55
|
+
const exec = makeExec({ hc: true });
|
|
56
|
+
const exists = makeExists(['/run/hc.sock']);
|
|
57
|
+
assert(
|
|
58
|
+
detectCaller({ env: { ...APP_ENV }, execOk: exec, fileExists: exists }) === 'hc-app',
|
|
59
|
+
'HC env + socket + hc binary -> hc-app'
|
|
60
|
+
);
|
|
61
|
+
assert(exec.calls.join(',') === 'hc ls', 'app probes hc ls');
|
|
62
|
+
assert(!exec.calls.some(c => c.startsWith('herdr')), 'app path never probes herdr');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ── plain ────────────────────────────────────────────────────────────────
|
|
66
|
+
{
|
|
67
|
+
const exec = makeExec({ herdr: true, hc: true });
|
|
68
|
+
const exists = makeExists(['/run/hc.sock']);
|
|
69
|
+
assert(
|
|
70
|
+
detectCaller({ env: {}, execOk: exec, fileExists: exists }) === 'plain',
|
|
71
|
+
'empty env -> plain'
|
|
72
|
+
);
|
|
73
|
+
assert(exec.calls.length === 0 && exists.calls.length === 0, 'plain probes nothing (env first)');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ── nested: both valid, innermost (hc) wins ───────────────────────────────
|
|
77
|
+
{
|
|
78
|
+
const exec = makeExec({ herdr: true, hc: true });
|
|
79
|
+
const exists = makeExists(['/run/hc.sock']);
|
|
80
|
+
assert(
|
|
81
|
+
detectCaller({ env: { ...TUI_ENV, ...APP_ENV }, execOk: exec, fileExists: exists }) ===
|
|
82
|
+
'hc-app',
|
|
83
|
+
'nested TUI+hc both valid -> hc-app (innermost wins)'
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ── nested: hc half-signal falls through to herdr ────────────────────────
|
|
88
|
+
{
|
|
89
|
+
const exec = makeExec({ herdr: true, hc: true });
|
|
90
|
+
const exists = makeExists([]); // socket missing
|
|
91
|
+
assert(
|
|
92
|
+
detectCaller({ env: { ...TUI_ENV, ...APP_ENV }, execOk: exec, fileExists: exists }) ===
|
|
93
|
+
'herdr-tui',
|
|
94
|
+
'nested hc socket missing -> herdr-tui (no masking)'
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ── missing binary ───────────────────────────────────────────────────────
|
|
99
|
+
{
|
|
100
|
+
const exec = makeExec({});
|
|
101
|
+
const exists = makeExists(['/run/hc.sock']);
|
|
102
|
+
assert(
|
|
103
|
+
detectCaller({ env: { ...TUI_ENV }, execOk: exec, fileExists: exists }) === 'plain',
|
|
104
|
+
'TUI env + missing herdr binary -> plain'
|
|
105
|
+
);
|
|
106
|
+
assert(
|
|
107
|
+
detectCaller({ env: { ...APP_ENV }, execOk: exec, fileExists: exists }) === 'plain',
|
|
108
|
+
'HC env + missing hc binary -> plain'
|
|
109
|
+
);
|
|
110
|
+
const execNoHc = makeExec({ herdr: true });
|
|
111
|
+
assert(
|
|
112
|
+
detectCaller({ env: { ...APP_ENV }, execOk: execNoHc, fileExists: exists }) === 'plain',
|
|
113
|
+
'HC env + failing hc ls -> plain (no cross-claim by herdr without its env)'
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ── strict env gates ─────────────────────────────────────────────────────
|
|
118
|
+
{
|
|
119
|
+
const exec = makeExec({ herdr: true, hc: true });
|
|
120
|
+
const exists = makeExists(['/run/hc.sock']);
|
|
121
|
+
assert(
|
|
122
|
+
detectCaller({
|
|
123
|
+
env: { HERDR_ENV: 'true', HERDR_PANE_ID: 'pane-1' },
|
|
124
|
+
execOk: exec,
|
|
125
|
+
fileExists: exists,
|
|
126
|
+
}) === 'plain',
|
|
127
|
+
'HERDR_ENV=true (not "1") -> plain'
|
|
128
|
+
);
|
|
129
|
+
assert(
|
|
130
|
+
detectCaller({ env: { HERDR_ENV: '1' }, execOk: exec, fileExists: exists }) === 'plain',
|
|
131
|
+
'HERDR_ENV without HERDR_PANE_ID -> plain'
|
|
132
|
+
);
|
|
133
|
+
assert(
|
|
134
|
+
detectCaller({
|
|
135
|
+
env: { HC_TERMINAL_ID: 't4' },
|
|
136
|
+
execOk: exec,
|
|
137
|
+
fileExists: exists,
|
|
138
|
+
}) === 'plain',
|
|
139
|
+
'HC_TERMINAL_ID without HC_TERMINAL_SOCKET -> plain'
|
|
140
|
+
);
|
|
141
|
+
assert(
|
|
142
|
+
detectCaller({ env: { ...APP_ENV }, execOk: exec, fileExists: makeExists([]) }) === 'plain',
|
|
143
|
+
'HC env + missing socket file -> plain'
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ── live session info (non-asserting; varies by caller) ───────────────────
|
|
148
|
+
console.log(`INFO live detectCaller() in this session -> ${detectCaller()}`);
|
|
149
|
+
|
|
150
|
+
if (failures) process.exit(1);
|
|
151
|
+
console.log('All detect assertions passed.');
|