@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,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 0 contract placeholders for the task/messaging test suite.
|
|
3
|
+
*
|
|
4
|
+
* These are intentionally data-only. They describe the future model-facing
|
|
5
|
+
* surface without registering tools or changing runtime behavior. Later phase
|
|
6
|
+
* tests should import these contracts instead of duplicating strings.
|
|
7
|
+
*/
|
|
8
|
+
export const plannedToolContracts = Object.freeze({
|
|
9
|
+
shepherd_delegate: Object.freeze({
|
|
10
|
+
surface: 'parent',
|
|
11
|
+
rootType: 'object',
|
|
12
|
+
required: Object.freeze(['target', 'task']),
|
|
13
|
+
}),
|
|
14
|
+
shepherd_message: Object.freeze({
|
|
15
|
+
surface: 'parent-and-child',
|
|
16
|
+
rootType: 'object',
|
|
17
|
+
required: Object.freeze(['target', 'message']),
|
|
18
|
+
}),
|
|
19
|
+
shepherd_done: Object.freeze({
|
|
20
|
+
surface: 'child',
|
|
21
|
+
rootType: 'object',
|
|
22
|
+
required: Object.freeze(['taskId', 'status']),
|
|
23
|
+
}),
|
|
24
|
+
shepherd_watch: Object.freeze({
|
|
25
|
+
surface: 'parent',
|
|
26
|
+
rootType: 'object',
|
|
27
|
+
required: Object.freeze(['id']),
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const plannedTaskStates = Object.freeze([
|
|
32
|
+
'created',
|
|
33
|
+
'running',
|
|
34
|
+
'waiting',
|
|
35
|
+
'completed',
|
|
36
|
+
'blocked',
|
|
37
|
+
'failed',
|
|
38
|
+
'cancelled',
|
|
39
|
+
'timed_out',
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
export const plannedParentOnlyTools = Object.freeze(['shepherd_delegate', 'shepherd_watch']);
|
|
43
|
+
|
|
44
|
+
export const plannedChildOnlyTools = Object.freeze(['shepherd_done']);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as os from 'node:os';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
|
|
5
|
+
/** Create an isolated filesystem root for tests that need temporary state. */
|
|
6
|
+
export function createTempDirectory(prefix = 'pi-shepherd-test-') {
|
|
7
|
+
return fs.mkdtempSync(path.join(os.tmpdir(), prefix));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Run a test with an isolated temporary root and always remove it afterward. */
|
|
11
|
+
export async function withTempDirectory(prefix, callback) {
|
|
12
|
+
const directory = createTempDirectory(prefix);
|
|
13
|
+
try {
|
|
14
|
+
return await callback(directory);
|
|
15
|
+
} finally {
|
|
16
|
+
fs.rmSync(directory, { recursive: true, force: true });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Stable parent identity for transport and lifecycle unit tests. */
|
|
21
|
+
export function createFakeParentIdentity(overrides = {}) {
|
|
22
|
+
return {
|
|
23
|
+
sessionId: 'test-parent-session',
|
|
24
|
+
ownerId: 'test-parent-owner',
|
|
25
|
+
role: 'parent',
|
|
26
|
+
...overrides,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Stable child identity for transport and lifecycle unit tests. */
|
|
31
|
+
export function createFakeChildIdentity(overrides = {}) {
|
|
32
|
+
return {
|
|
33
|
+
sessionId: 'test-parent-session',
|
|
34
|
+
agentId: 'shepherd-agent-test-child',
|
|
35
|
+
role: 'child',
|
|
36
|
+
...overrides,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Resolve one turn of queued promises without relying on arbitrary sleeps. */
|
|
41
|
+
export async function flushMicrotasks() {
|
|
42
|
+
await Promise.resolve();
|
|
43
|
+
await Promise.resolve();
|
|
44
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Filesystem-only verification for the Phase 1 sessions persistence layer. */
|
|
3
|
+
import * as assert from 'node:assert/strict';
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
import * as os from 'node:os';
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
import { spawn } from 'node:child_process';
|
|
8
|
+
|
|
9
|
+
const mod = await import('../src/core/artifact-sessions.ts');
|
|
10
|
+
const {
|
|
11
|
+
slugifySessionName,
|
|
12
|
+
slugifyAgentName,
|
|
13
|
+
deriveSessionName,
|
|
14
|
+
createOrResumeSession,
|
|
15
|
+
resolveOrCreateParentArtifactSession,
|
|
16
|
+
reserveArtifacts,
|
|
17
|
+
markArtifactStarted,
|
|
18
|
+
finalizeArtifact,
|
|
19
|
+
markArtifactStatus,
|
|
20
|
+
updateSessionMoc,
|
|
21
|
+
readSessionMetadata,
|
|
22
|
+
} = mod;
|
|
23
|
+
let failures = 0;
|
|
24
|
+
async function check(label, fn) {
|
|
25
|
+
try {
|
|
26
|
+
await fn();
|
|
27
|
+
console.log(`PASS ${label}`);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
failures++;
|
|
30
|
+
console.log(`FAIL ${label} — ${error.message}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const project = fs.mkdtempSync(path.join(os.tmpdir(), 'pi-shepherd-sessions-'));
|
|
34
|
+
|
|
35
|
+
await check('safe deterministic session slug', () => {
|
|
36
|
+
assert.equal(slugifySessionName(' Fix OAuth_Login! '), 'fix-oauth-login');
|
|
37
|
+
assert.equal(slugifySessionName('À very long name '.repeat(20)).length, 64);
|
|
38
|
+
assert.equal(deriveSessionName(), 'delegation');
|
|
39
|
+
assert.equal(slugifyAgentName('Scout / unsafe'), 'scout-unsafe');
|
|
40
|
+
});
|
|
41
|
+
await check('reject traversal and separators', () => {
|
|
42
|
+
for (const value of ['../escape', 'foo/bar', 'foo\\bar', '/tmp/name', '..', '.']) {
|
|
43
|
+
assert.throws(() => slugifySessionName(value));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
let first;
|
|
48
|
+
await check('create numbered session and metadata/MOC', () => {
|
|
49
|
+
first = createOrResumeSession({
|
|
50
|
+
projectRoot: project,
|
|
51
|
+
sessionName: 'fix-oauth-login',
|
|
52
|
+
mode: 'single',
|
|
53
|
+
});
|
|
54
|
+
assert.equal(first.directoryName, '0001-fix-oauth-login');
|
|
55
|
+
assert.equal(fs.existsSync(first.mocPath), true);
|
|
56
|
+
assert.equal(fs.existsSync(first.sessionMetadataPath), true);
|
|
57
|
+
assert.equal(fs.existsSync(path.join(project, '.shepherd', 'shepherd.md')), false);
|
|
58
|
+
const metadata = JSON.parse(fs.readFileSync(first.sessionMetadataPath, 'utf8'));
|
|
59
|
+
assert.equal(metadata.sessionName, 'fix-oauth-login');
|
|
60
|
+
});
|
|
61
|
+
await check('same exact name resumes rather than duplicates', () => {
|
|
62
|
+
const resumed = createOrResumeSession({
|
|
63
|
+
projectRoot: project,
|
|
64
|
+
sessionName: 'fix-oauth-login',
|
|
65
|
+
mode: 'parallel',
|
|
66
|
+
});
|
|
67
|
+
assert.equal(resumed.sessionPath, first.sessionPath);
|
|
68
|
+
assert.equal(resumed.resumed, true);
|
|
69
|
+
assert.equal(
|
|
70
|
+
fs.readdirSync(path.join(project, '.shepherd', 'sessions')).filter(x => x.match(/^0001-/))
|
|
71
|
+
.length,
|
|
72
|
+
1
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
await check('same slug different names remain separate', () => {
|
|
76
|
+
const other = createOrResumeSession({
|
|
77
|
+
projectRoot: project,
|
|
78
|
+
sessionName: 'fix oauth login',
|
|
79
|
+
mode: 'chain',
|
|
80
|
+
});
|
|
81
|
+
assert.notEqual(other.sessionPath, first.sessionPath);
|
|
82
|
+
assert.equal(other.ordinal, 2);
|
|
83
|
+
const otherMetadata = JSON.parse(fs.readFileSync(other.sessionMetadataPath, 'utf8'));
|
|
84
|
+
assert.equal(otherMetadata.sessionName, 'fix oauth login');
|
|
85
|
+
assert.match(other.directoryName, /^0002-fix-oauth-login-[0-9a-f]{8}$/);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
await check('parent pi binding reuses one session across calls', () => {
|
|
89
|
+
const firstParent = resolveOrCreateParentArtifactSession({
|
|
90
|
+
projectRoot: project,
|
|
91
|
+
parentPiSessionId: 'parent-pi-a',
|
|
92
|
+
parentSessionFile: '/tmp/parent-a.jsonl',
|
|
93
|
+
});
|
|
94
|
+
const secondParent = resolveOrCreateParentArtifactSession({
|
|
95
|
+
projectRoot: project,
|
|
96
|
+
parentPiSessionId: 'parent-pi-a',
|
|
97
|
+
parentSessionFile: '/tmp/parent-a-resumed.jsonl',
|
|
98
|
+
});
|
|
99
|
+
const otherParent = resolveOrCreateParentArtifactSession({
|
|
100
|
+
projectRoot: project,
|
|
101
|
+
parentPiSessionId: 'parent-pi-b',
|
|
102
|
+
});
|
|
103
|
+
assert.equal(firstParent.sessionPath, secondParent.sessionPath);
|
|
104
|
+
assert.notEqual(firstParent.sessionPath, otherParent.sessionPath);
|
|
105
|
+
assert.equal(firstParent.artifactSessionVersion, 2);
|
|
106
|
+
assert.equal(firstParent.parentPiSession?.identity, 'parent-pi-a');
|
|
107
|
+
assert.equal(
|
|
108
|
+
JSON.parse(fs.readFileSync(firstParent.sessionMetadataPath, 'utf8')).parentPiSession
|
|
109
|
+
.sessionFile,
|
|
110
|
+
'/tmp/parent-a-resumed.jsonl'
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
await check('legacy unbound sessions are not implicitly claimed', () => {
|
|
114
|
+
const legacy = createOrResumeSession({ projectRoot: project, sessionName: 'legacy-unbound' });
|
|
115
|
+
const bound = resolveOrCreateParentArtifactSession({
|
|
116
|
+
projectRoot: project,
|
|
117
|
+
parentPiSessionId: 'parent-pi-legacy',
|
|
118
|
+
});
|
|
119
|
+
assert.notEqual(bound.sessionPath, legacy.sessionPath);
|
|
120
|
+
assert.equal(
|
|
121
|
+
JSON.parse(fs.readFileSync(legacy.sessionMetadataPath, 'utf8')).artifactSessionVersion,
|
|
122
|
+
undefined
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
let artifacts;
|
|
127
|
+
await check('reserve per-agent artifacts before execution with relative links', () => {
|
|
128
|
+
artifacts = reserveArtifacts(first, [
|
|
129
|
+
{ agent: 'Scout', mode: 'parallel', task: 'survey' },
|
|
130
|
+
{ agent: 'Scout', mode: 'parallel', task: 'survey again' },
|
|
131
|
+
{ agent: 'worker / unsafe', mode: 'parallel' },
|
|
132
|
+
{ agent: 'worker-unsafe', mode: 'parallel' },
|
|
133
|
+
]);
|
|
134
|
+
assert.deepEqual(
|
|
135
|
+
artifacts.slice(0, 2).map(a => a.fileName),
|
|
136
|
+
['scout-01.md', 'scout-02.md']
|
|
137
|
+
);
|
|
138
|
+
assert.equal(new Set(artifacts.map(a => a.fileName)).size, artifacts.length);
|
|
139
|
+
assert.ok(
|
|
140
|
+
artifacts.every(a => !path.isAbsolute(a.relativePath) && a.relativePath.includes('.shepherd'))
|
|
141
|
+
);
|
|
142
|
+
const moc = fs.readFileSync(first.mocPath, 'utf8');
|
|
143
|
+
assert.match(moc, /\(\.\/scout-01\.md\)/);
|
|
144
|
+
assert.match(moc, /\(\.\/scout-02\.md\)/);
|
|
145
|
+
assert.match(moc, /Mode\(s\):\*\* single, parallel/);
|
|
146
|
+
assert.match(fs.readFileSync(artifacts[0].filePath, 'utf8'), /sessionName: fix-oauth-login/);
|
|
147
|
+
assert.equal(
|
|
148
|
+
fs.readdirSync(first.sessionPath).some(name => name.includes('.tmp-')),
|
|
149
|
+
false
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
await check('lifecycle metadata and output/error persistence', () => {
|
|
153
|
+
markArtifactStarted(first, artifacts[0], { pane: 'test-pane' });
|
|
154
|
+
// The in-memory reservation must track the canonical state immediately,
|
|
155
|
+
// not stay at the "pending" snapshot from reserve time.
|
|
156
|
+
assert.equal(artifacts[0].status, 'running');
|
|
157
|
+
assert.ok(artifacts[0].startedAt);
|
|
158
|
+
finalizeArtifact(first, artifacts[0], { status: 'completed', output: 'survey output' });
|
|
159
|
+
finalizeArtifact(first, artifacts[1], { status: 'failed', error: 'boom' });
|
|
160
|
+
markArtifactStatus(first, artifacts[2], 'timed-out', { reason: 'deadline' });
|
|
161
|
+
markArtifactStatus(first, artifacts[3], 'cancelled');
|
|
162
|
+
const firstText = fs.readFileSync(artifacts[0].filePath, 'utf8');
|
|
163
|
+
assert.match(firstText, /status: completed/);
|
|
164
|
+
assert.match(firstText, /survey output/);
|
|
165
|
+
assert.match(fs.readFileSync(artifacts[1].filePath, 'utf8'), /boom/);
|
|
166
|
+
const metadata = JSON.parse(fs.readFileSync(first.sessionMetadataPath, 'utf8'));
|
|
167
|
+
assert.deepEqual(
|
|
168
|
+
metadata.artifacts.map(a => a.status),
|
|
169
|
+
['completed', 'failed', 'timed-out', 'cancelled']
|
|
170
|
+
);
|
|
171
|
+
// Handles passed around in memory (prompt/wait payloads) mirror the
|
|
172
|
+
// on-disk metadata — the shepherd_wait artifact status regression.
|
|
173
|
+
assert.deepEqual(
|
|
174
|
+
artifacts.map(a => a.status),
|
|
175
|
+
['completed', 'failed', 'timed-out', 'cancelled'],
|
|
176
|
+
'in-memory reservations mirror canonical status'
|
|
177
|
+
);
|
|
178
|
+
for (const a of artifacts) {
|
|
179
|
+
const stored = metadata.artifacts.find(m => m.id === a.id);
|
|
180
|
+
assert.equal(a.startedAt, stored.startedAt);
|
|
181
|
+
assert.equal(a.completedAt, stored.completedAt);
|
|
182
|
+
}
|
|
183
|
+
// The held session object's artifacts array must be synced too: payloads
|
|
184
|
+
// serialize both the per-prompt artifact and artifactSession.artifacts.
|
|
185
|
+
assert.deepEqual(
|
|
186
|
+
first.artifacts.map(a => a.status),
|
|
187
|
+
['completed', 'failed', 'timed-out', 'cancelled'],
|
|
188
|
+
'held session artifacts array mirrors canonical state'
|
|
189
|
+
);
|
|
190
|
+
const heldFromArray = first.artifacts.find(a => a.id === artifacts[0].id);
|
|
191
|
+
const canonical = metadata.artifacts.find(m => m.id === artifacts[0].id);
|
|
192
|
+
assert.equal(heldFromArray.startedAt, canonical.startedAt);
|
|
193
|
+
assert.equal(heldFromArray.completedAt, canonical.completedAt);
|
|
194
|
+
});
|
|
195
|
+
await check('session remains resumable after failure', () => {
|
|
196
|
+
const resumed = createOrResumeSession({ projectRoot: project, sessionName: 'fix-oauth-login' });
|
|
197
|
+
assert.equal(resumed.sessionPath, first.sessionPath);
|
|
198
|
+
assert.equal(readSessionMetadata(first.sessionPath).sessionName, 'fix-oauth-login');
|
|
199
|
+
updateSessionMoc(resumed, { status: 'completed' });
|
|
200
|
+
assert.match(fs.readFileSync(first.mocPath, 'utf8'), /Status:\*\* completed/);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// Child processes contend on the same project root. The allocator's .alloc
|
|
204
|
+
// mkdir tokens must make every ordinal unique.
|
|
205
|
+
await check('chain mode is retained across continuation', () => {
|
|
206
|
+
const resumed = createOrResumeSession({
|
|
207
|
+
projectRoot: project,
|
|
208
|
+
sessionName: 'fix-oauth-login',
|
|
209
|
+
mode: 'chain',
|
|
210
|
+
});
|
|
211
|
+
const metadata = JSON.parse(fs.readFileSync(resumed.sessionMetadataPath, 'utf8'));
|
|
212
|
+
assert.deepEqual(metadata.modes, ['single', 'parallel', 'chain']);
|
|
213
|
+
assert.match(fs.readFileSync(resumed.mocPath, 'utf8'), /Mode\(s\):\*\* single, parallel, chain/);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
await check('concurrent numbering uses unique ordinals', async () => {
|
|
217
|
+
const concurrentRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'pi-shepherd-concurrent-'));
|
|
218
|
+
const script = `import { createOrResumeSession } from ${JSON.stringify(path.resolve('src/core/artifact-sessions.ts'))}; createOrResumeSession({projectRoot:process.argv[1],sessionName:process.argv[2]});`;
|
|
219
|
+
const jobs = Array.from(
|
|
220
|
+
{ length: 8 },
|
|
221
|
+
(_, i) =>
|
|
222
|
+
new Promise((resolve, reject) => {
|
|
223
|
+
const child = spawn(
|
|
224
|
+
process.execPath,
|
|
225
|
+
[
|
|
226
|
+
'--experimental-strip-types',
|
|
227
|
+
'--disable-warning=ExperimentalWarning',
|
|
228
|
+
'--input-type=module',
|
|
229
|
+
'-e',
|
|
230
|
+
script,
|
|
231
|
+
concurrentRoot,
|
|
232
|
+
`name-${i}`,
|
|
233
|
+
],
|
|
234
|
+
{ stdio: 'ignore' }
|
|
235
|
+
);
|
|
236
|
+
child.on('error', reject);
|
|
237
|
+
child.on('exit', code =>
|
|
238
|
+
code === 0 ? resolve() : reject(new Error(`child exited ${code}`))
|
|
239
|
+
);
|
|
240
|
+
})
|
|
241
|
+
);
|
|
242
|
+
await Promise.all(jobs);
|
|
243
|
+
const dirs = fs
|
|
244
|
+
.readdirSync(path.join(concurrentRoot, '.shepherd', 'sessions'))
|
|
245
|
+
.filter(x => /^\d{4,}-/.test(x));
|
|
246
|
+
assert.equal(dirs.length, 8);
|
|
247
|
+
assert.equal(new Set(dirs.map(x => x.split('-')[0])).size, 8);
|
|
248
|
+
assert.equal(
|
|
249
|
+
fs.existsSync(path.join(concurrentRoot, '.shepherd', 'sessions', '.alloc', '0001')),
|
|
250
|
+
true
|
|
251
|
+
);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
if (failures) {
|
|
255
|
+
console.error(`\n${failures} assertion(s) FAILED`);
|
|
256
|
+
process.exit(1);
|
|
257
|
+
}
|
|
258
|
+
console.log('\nAll session assertions passed.');
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Unit test for the Phase 0.2 backend resolver (src/runtimes/backend.ts).
|
|
3
|
+
// Covers: pin wins over caller, caller mapping (herdr-tui->herdr,
|
|
4
|
+
// hc-app->hc, plain->reachable-or-error), pinned-but-unreachable throws
|
|
5
|
+
// with setup hint and no fallback, plain-unreachable throws with both hints,
|
|
6
|
+
// throwing probes are safe, errors never leak pane/terminal ids or sockets.
|
|
7
|
+
import { DEFAULT_SETTINGS } from '../src/core/config.ts';
|
|
8
|
+
import {
|
|
9
|
+
HC_SETUP_HINT,
|
|
10
|
+
HERDR_SETUP_HINT_FALLBACK,
|
|
11
|
+
resolveBackend,
|
|
12
|
+
} from '../src/runtimes/backend.ts';
|
|
13
|
+
import { detectCaller } from '../src/runtimes/detect.ts';
|
|
14
|
+
|
|
15
|
+
let failures = 0;
|
|
16
|
+
function assert(ok, label) {
|
|
17
|
+
if (ok) console.log(`PASS ${label}`);
|
|
18
|
+
else {
|
|
19
|
+
failures++;
|
|
20
|
+
console.log(`FAIL ${label}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function throws(fn) {
|
|
25
|
+
try {
|
|
26
|
+
fn();
|
|
27
|
+
} catch (e) {
|
|
28
|
+
return e;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const alwaysTrue = () => true;
|
|
34
|
+
const alwaysFalse = () => false;
|
|
35
|
+
const throwing = () => {
|
|
36
|
+
throw new Error('probe boom');
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
function callsProbe(ret) {
|
|
40
|
+
const wrapped = () => {
|
|
41
|
+
wrapped.calls++;
|
|
42
|
+
return ret;
|
|
43
|
+
};
|
|
44
|
+
wrapped.calls = 0;
|
|
45
|
+
return wrapped;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ── default ──────────────────────────────────────────────────────────────
|
|
49
|
+
assert(DEFAULT_SETTINGS.backend === 'auto', 'DEFAULT_SETTINGS.backend is auto');
|
|
50
|
+
|
|
51
|
+
// ── pin wins over caller ─────────────────────────────────────────────────
|
|
52
|
+
{
|
|
53
|
+
const hcProbe = callsProbe(true);
|
|
54
|
+
const out = resolveBackend('herdr', 'hc-app', {
|
|
55
|
+
isHerdrReachable: alwaysTrue,
|
|
56
|
+
isHcReachable: hcProbe,
|
|
57
|
+
});
|
|
58
|
+
assert(out === 'herdr', 'pin herdr wins over hc-app caller -> herdr');
|
|
59
|
+
assert(hcProbe.calls === 0, 'pin herdr never probes hc (no fallback check)');
|
|
60
|
+
}
|
|
61
|
+
{
|
|
62
|
+
const herdrProbe = callsProbe(true);
|
|
63
|
+
const out = resolveBackend('hc', 'herdr-tui', {
|
|
64
|
+
isHerdrReachable: herdrProbe,
|
|
65
|
+
isHcReachable: alwaysTrue,
|
|
66
|
+
});
|
|
67
|
+
assert(out === 'hc', 'pin hc wins over herdr-tui caller -> hc');
|
|
68
|
+
assert(herdrProbe.calls === 0, 'pin hc never probes herdr (no fallback check)');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ── pinned-but-unreachable: clean refusal, no fallback ───────────────────
|
|
72
|
+
{
|
|
73
|
+
const err = throws(() =>
|
|
74
|
+
resolveBackend('herdr', 'herdr-tui', {
|
|
75
|
+
isHerdrReachable: alwaysFalse,
|
|
76
|
+
isHcReachable: alwaysTrue, // reachable other backend must NOT be used
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
assert(err !== null, 'pin herdr unreachable throws (even when hc reachable)');
|
|
80
|
+
assert(
|
|
81
|
+
err && err.message.includes(HERDR_SETUP_HINT_FALLBACK),
|
|
82
|
+
'pin herdr error names herdr setup hint'
|
|
83
|
+
);
|
|
84
|
+
assert(err && /no fallback/i.test(err.message), 'pin herdr error states no fallback');
|
|
85
|
+
assert(err && err.message.includes('"auto"'), 'pin herdr error points back to auto');
|
|
86
|
+
}
|
|
87
|
+
{
|
|
88
|
+
const err = throws(() =>
|
|
89
|
+
resolveBackend('hc', 'hc-app', {
|
|
90
|
+
isHerdrReachable: alwaysTrue, // reachable other backend must NOT be used
|
|
91
|
+
isHcReachable: alwaysFalse,
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
assert(err !== null, 'pin hc unreachable throws (even when herdr reachable)');
|
|
95
|
+
assert(err && err.message.includes(HC_SETUP_HINT), 'pin hc error names hc setup hint');
|
|
96
|
+
assert(err && /no fallback/i.test(err.message), 'pin hc error states no fallback');
|
|
97
|
+
assert(err && err.message.includes('"auto"'), 'pin hc error points back to auto');
|
|
98
|
+
}
|
|
99
|
+
{
|
|
100
|
+
// Throwing probes are treated as unreachable, not a crash.
|
|
101
|
+
const errHerdr = throws(() =>
|
|
102
|
+
resolveBackend('herdr', 'plain', {
|
|
103
|
+
isHerdrReachable: throwing,
|
|
104
|
+
isHcReachable: alwaysTrue,
|
|
105
|
+
})
|
|
106
|
+
);
|
|
107
|
+
assert(errHerdr !== null, 'pin herdr with throwing probe still throws cleanly');
|
|
108
|
+
const errHc = throws(() =>
|
|
109
|
+
resolveBackend('hc', 'plain', {
|
|
110
|
+
isHerdrReachable: alwaysTrue,
|
|
111
|
+
isHcReachable: throwing,
|
|
112
|
+
})
|
|
113
|
+
);
|
|
114
|
+
assert(errHc !== null, 'pin hc with throwing probe still throws cleanly');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ── auto: run where called from (no reachability gate) ───────────────────
|
|
118
|
+
{
|
|
119
|
+
const out = resolveBackend('auto', 'herdr-tui', {
|
|
120
|
+
isHerdrReachable: alwaysFalse,
|
|
121
|
+
isHcReachable: alwaysFalse,
|
|
122
|
+
});
|
|
123
|
+
assert(out === 'herdr', 'auto + herdr-tui -> herdr (no reachability gate)');
|
|
124
|
+
}
|
|
125
|
+
{
|
|
126
|
+
const out = resolveBackend('auto', 'hc-app', {
|
|
127
|
+
isHerdrReachable: alwaysFalse,
|
|
128
|
+
isHcReachable: alwaysFalse,
|
|
129
|
+
});
|
|
130
|
+
assert(out === 'hc', 'auto + hc-app -> hc (no reachability gate)');
|
|
131
|
+
}
|
|
132
|
+
{
|
|
133
|
+
// Caller-mapped auto must not probe at all.
|
|
134
|
+
let probed = false;
|
|
135
|
+
const mark = () => {
|
|
136
|
+
probed = true;
|
|
137
|
+
return true;
|
|
138
|
+
};
|
|
139
|
+
const out = resolveBackend('auto', 'herdr-tui', {
|
|
140
|
+
isHerdrReachable: mark,
|
|
141
|
+
isHcReachable: mark,
|
|
142
|
+
});
|
|
143
|
+
assert(out === 'herdr' && probed === false, 'auto + caller mapping probes nothing');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// ── auto + plain: prefer herdr, else hc, else both hints ──────────────────
|
|
147
|
+
{
|
|
148
|
+
const out = resolveBackend('auto', 'plain', {
|
|
149
|
+
isHerdrReachable: alwaysTrue,
|
|
150
|
+
isHcReachable: alwaysTrue,
|
|
151
|
+
});
|
|
152
|
+
assert(out === 'herdr', 'auto + plain + both reachable -> herdr first');
|
|
153
|
+
}
|
|
154
|
+
{
|
|
155
|
+
const order = [];
|
|
156
|
+
const out = resolveBackend('auto', 'plain', {
|
|
157
|
+
isHerdrReachable: () => {
|
|
158
|
+
order.push('herdr');
|
|
159
|
+
return false;
|
|
160
|
+
},
|
|
161
|
+
isHcReachable: () => {
|
|
162
|
+
order.push('hc');
|
|
163
|
+
return true;
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
assert(out === 'hc', 'auto + plain + only hc reachable -> hc');
|
|
167
|
+
assert(order.join(',') === 'herdr,hc', 'plain probes herdr before hc');
|
|
168
|
+
}
|
|
169
|
+
{
|
|
170
|
+
const err = throws(() =>
|
|
171
|
+
resolveBackend('auto', 'plain', {
|
|
172
|
+
isHerdrReachable: alwaysFalse,
|
|
173
|
+
isHcReachable: alwaysFalse,
|
|
174
|
+
})
|
|
175
|
+
);
|
|
176
|
+
assert(err !== null, 'auto + plain + none reachable throws');
|
|
177
|
+
assert(
|
|
178
|
+
err && err.message.includes(HERDR_SETUP_HINT_FALLBACK),
|
|
179
|
+
'plain error names herdr hint'
|
|
180
|
+
);
|
|
181
|
+
assert(err && err.message.includes(HC_SETUP_HINT), 'plain error names hc hint');
|
|
182
|
+
}
|
|
183
|
+
{
|
|
184
|
+
const err = throws(() =>
|
|
185
|
+
resolveBackend('auto', 'plain', {
|
|
186
|
+
isHerdrReachable: throwing,
|
|
187
|
+
isHcReachable: throwing,
|
|
188
|
+
})
|
|
189
|
+
);
|
|
190
|
+
assert(err !== null, 'plain with throwing probes throws cleanly (no crash)');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// ── never returns auto, never leaks ids/sockets ──────────────────────────
|
|
194
|
+
{
|
|
195
|
+
const results = [
|
|
196
|
+
resolveBackend('herdr', 'plain', {
|
|
197
|
+
isHerdrReachable: alwaysTrue,
|
|
198
|
+
isHcReachable: alwaysFalse,
|
|
199
|
+
}),
|
|
200
|
+
resolveBackend('hc', 'plain', {
|
|
201
|
+
isHerdrReachable: alwaysFalse,
|
|
202
|
+
isHcReachable: alwaysTrue,
|
|
203
|
+
}),
|
|
204
|
+
resolveBackend('auto', 'herdr-tui', {
|
|
205
|
+
isHerdrReachable: alwaysFalse,
|
|
206
|
+
isHcReachable: alwaysFalse,
|
|
207
|
+
}),
|
|
208
|
+
resolveBackend('auto', 'hc-app', {
|
|
209
|
+
isHerdrReachable: alwaysFalse,
|
|
210
|
+
isHcReachable: alwaysFalse,
|
|
211
|
+
}),
|
|
212
|
+
resolveBackend('auto', 'plain', {
|
|
213
|
+
isHerdrReachable: alwaysTrue,
|
|
214
|
+
isHcReachable: alwaysFalse,
|
|
215
|
+
}),
|
|
216
|
+
];
|
|
217
|
+
assert(
|
|
218
|
+
results.every(r => r === 'herdr' || r === 'hc'),
|
|
219
|
+
'resolveBackend never returns auto'
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
{
|
|
223
|
+
const errs = [
|
|
224
|
+
throws(() =>
|
|
225
|
+
resolveBackend('herdr', 'plain', {
|
|
226
|
+
isHerdrReachable: alwaysFalse,
|
|
227
|
+
isHcReachable: alwaysTrue,
|
|
228
|
+
})
|
|
229
|
+
),
|
|
230
|
+
throws(() =>
|
|
231
|
+
resolveBackend('hc', 'plain', {
|
|
232
|
+
isHerdrReachable: alwaysTrue,
|
|
233
|
+
isHcReachable: alwaysFalse,
|
|
234
|
+
})
|
|
235
|
+
),
|
|
236
|
+
throws(() =>
|
|
237
|
+
resolveBackend('auto', 'plain', {
|
|
238
|
+
isHerdrReachable: alwaysFalse,
|
|
239
|
+
isHcReachable: alwaysFalse,
|
|
240
|
+
})
|
|
241
|
+
),
|
|
242
|
+
].filter(Boolean);
|
|
243
|
+
// Setup hints may name env vars (HC_TERMINAL_ID, HERDR_ENV) as guidance;
|
|
244
|
+
// leaks are concrete values: pane/terminal ids and socket paths.
|
|
245
|
+
const banned = ['pane-1', 'pane-42', '/run/hc.sock', '/run/user/1000/herdr', 't11'];
|
|
246
|
+
for (const e of errs) {
|
|
247
|
+
const msg = String(e && e.message);
|
|
248
|
+
assert(
|
|
249
|
+
!banned.some(s => msg.includes(s)),
|
|
250
|
+
`error leaks no ids/sockets: ${msg.slice(0, 60)}...`
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// ── live session info (non-asserting; varies by caller) ───────────────────
|
|
256
|
+
{
|
|
257
|
+
const caller = detectCaller();
|
|
258
|
+
let live;
|
|
259
|
+
try {
|
|
260
|
+
live = resolveBackend('auto', caller);
|
|
261
|
+
} catch (e) {
|
|
262
|
+
live = `throw: ${String(e && e.message).slice(0, 80)}...`;
|
|
263
|
+
}
|
|
264
|
+
console.log(`INFO live detectCaller()=${caller} resolveBackend(auto)=${live}`);
|
|
265
|
+
// Phase 1.1 scaffold: src/runtimes/hc/ exists with the spawn/read surface
|
|
266
|
+
// but stays unwired from the resolver (wiring is 1.2), so app resolution
|
|
267
|
+
// is still a clean refusal downstream, never a cross-spawn. This file
|
|
268
|
+
// still only proves the resolver mapping; live spawn proof goes through
|
|
269
|
+
// shepherd_* + hc.
|
|
270
|
+
const fs = await import('node:fs');
|
|
271
|
+
assert(fs.existsSync('src/runtimes/hc/hc.ts'), 'Phase 1.1 hc.ts scaffold exists');
|
|
272
|
+
assert(fs.existsSync('src/runtimes/hc/runtime.ts'), 'Phase 1.1 runtime.ts scaffold exists');
|
|
273
|
+
const hcRuntimeSource = fs.readFileSync('src/runtimes/hc/runtime.ts', 'utf8');
|
|
274
|
+
assert(
|
|
275
|
+
!hcRuntimeSource.includes('herdr'),
|
|
276
|
+
'hc runtime drives hc terminals only (no pane-backend import)'
|
|
277
|
+
);
|
|
278
|
+
const hc = await import('../src/runtimes/hc/hc.ts');
|
|
279
|
+
for (const fn of [
|
|
280
|
+
'isHcAvailable',
|
|
281
|
+
'hcExec',
|
|
282
|
+
'recordCreatedTerminal',
|
|
283
|
+
'pruneStaleCreatedTerminals',
|
|
284
|
+
'writePiLaunchFiles',
|
|
285
|
+
'launchPiInHcTerminal',
|
|
286
|
+
]) {
|
|
287
|
+
assert(typeof hc[fn] === 'function', `hc.ts exports ${fn}`);
|
|
288
|
+
}
|
|
289
|
+
const { createHcRuntime } = await import('../src/runtimes/hc/runtime.ts');
|
|
290
|
+
const hcRuntime = createHcRuntime({ cwd: process.cwd() });
|
|
291
|
+
for (const method of ['spawn', 'delegate', 'message', 'watch', 'status', 'close', 'read']) {
|
|
292
|
+
assert(typeof hcRuntime[method] === 'function', `hc runtime implements ${method}`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (failures) process.exit(1);
|
|
297
|
+
console.log('All backend assertions passed.');
|