@ftrdotdev/pi-delegates 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/OPERATIONS.md +79 -6
- package/README.md +25 -17
- package/ROADMAP.md +21 -0
- package/TESTING.md +153 -318
- package/package.json +4 -3
- package/skills/pi-delegates/SKILL.md +29 -0
- package/skills/pi-delegates/references/launch.md +28 -0
- package/src/docs-contract.test.ts +106 -0
- package/src/domain/definitions.ts +3 -1
- package/src/domain/failure.ts +33 -0
- package/src/domain/model-source.ts +30 -0
- package/src/domain/orchestration/control.test.ts +69 -35
- package/src/domain/orchestration/control.ts +110 -89
- package/src/domain/orchestration/fanout.test.ts +125 -20
- package/src/domain/orchestration/fanout.ts +60 -22
- package/src/domain/orchestration/gates.test.ts +14 -15
- package/src/domain/orchestration/launch.test.ts +210 -11
- package/src/domain/orchestration/launch.ts +142 -32
- package/src/domain/orchestration/requests.test.ts +11 -16
- package/src/domain/orchestration/requests.ts +14 -1
- package/src/domain/orchestration/review.test.ts +89 -11
- package/src/domain/orchestration/run-wait.test.ts +4 -1
- package/src/domain/orchestration/run-wait.ts +1 -1
- package/src/domain/orchestration/workflow.test.ts +157 -16
- package/src/domain/orchestration/workflow.ts +269 -196
- package/src/domain/run-records.ts +214 -52
- package/src/domain/settlement.test.ts +186 -0
- package/src/domain/settlement.ts +137 -0
- package/src/domain/shapes.test.ts +20 -0
- package/src/domain/skills.test.ts +31 -20
- package/src/domain/skills.ts +36 -19
- package/src/domain/toolkit.test.ts +15 -1
- package/src/domain/toolkit.ts +8 -13
- package/src/domain/turn-budget.test.ts +37 -0
- package/src/domain/turn-budget.ts +23 -0
- package/src/domain/view.test.ts +78 -14
- package/src/domain/view.ts +67 -35
- package/src/extension/commands.test.ts +27 -23
- package/src/extension/commands.ts +10 -7
- package/src/extension/entry.test.ts +214 -56
- package/src/extension/entry.ts +78 -40
- package/src/extension/gate-alerts.test.ts +10 -8
- package/src/extension/inspector-command.test.ts +173 -21
- package/src/extension/inspector-command.ts +100 -53
- package/src/extension/prompt.test.ts +2 -4
- package/src/extension/retry-observer.test.ts +292 -0
- package/src/extension/retry-observer.ts +150 -0
- package/src/extension/settle-alerts.test.ts +579 -0
- package/src/extension/settle-alerts.ts +175 -0
- package/src/extension/shortcut.test.ts +6 -8
- package/src/extension/tools.test.ts +325 -24
- package/src/extension/tools.ts +61 -13
- package/src/extension/version.test.ts +21 -29
- package/src/goldens.test.ts +294 -0
- package/src/harness-policy.test.ts +13 -11
- package/src/layers.test.ts +309 -0
- package/src/layers.ts +405 -0
- package/src/package-manifest.test.ts +32 -19
- package/src/presentation/actions.test.ts +8 -8
- package/src/presentation/activity.test.ts +7 -8
- package/src/presentation/close.test.ts +14 -16
- package/src/presentation/inspector.test.ts +14 -11
- package/src/presentation/inspector.ts +27 -25
- package/src/presentation/overlay.test.ts +1 -3
- package/src/presentation/repaint.test.ts +226 -190
- package/src/presentation/snapshot.test.ts +5 -0
- package/src/presentation/status.test.ts +43 -0
- package/src/presentation/status.ts +30 -0
- package/src/presentation/strip.test.ts +13 -6
- package/src/presentation/strip.ts +7 -14
- package/src/presentation/wording.test.ts +153 -3
- package/src/presentation/wording.ts +78 -6
- package/src/runtime/bridge.ts +38 -44
- package/src/runtime/{timers.test.ts → clock.test.ts} +1 -1
- package/src/runtime/clock.ts +31 -0
- package/src/runtime/config.test.ts +26 -7
- package/src/runtime/config.ts +6 -1
- package/src/runtime/execution-env.test.ts +6 -8
- package/src/runtime/extensions.test.ts +4 -4
- package/src/runtime/extensions.ts +23 -11
- package/src/runtime/handle.ts +54 -0
- package/src/runtime/log.test.ts +19 -7
- package/src/runtime/log.ts +23 -0
- package/src/runtime/mcp.test.ts +29 -32
- package/src/runtime/mcp.ts +70 -3
- package/src/runtime/runtime-state.test.ts +25 -0
- package/src/runtime/runtime-state.ts +36 -0
- package/src/runtime/session-tag.ts +11 -0
- package/src/runtime/session.test.ts +24 -31
- package/src/runtime/session.ts +99 -261
- package/src/runtime/storage.ts +29 -0
- package/src/test-hygiene.test.ts +97 -0
- package/src/runtime/timers.ts +0 -10
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assert, it } from "@effect/vitest";
|
|
2
|
+
import { join, makeDir, makeTempDir, writeText } from "../../test-support/platform.ts";
|
|
2
3
|
import { readVersionSignals, resolveFromPackage, versionVerdict } from "./version.ts";
|
|
3
4
|
|
|
4
5
|
it("a version mismatch is refused and names both versions", () => {
|
|
@@ -21,28 +22,25 @@ it("a matching or unknown host version passes", () => {
|
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
it("reads durable's pin and the host's installed pi-ai", async () => {
|
|
24
|
-
const
|
|
25
|
-
const { tmpdir } = await import("node:os");
|
|
26
|
-
const { join } = await import("node:path");
|
|
27
|
-
const root = await mkdtemp(join(tmpdir(), "delegates-version-"));
|
|
25
|
+
const root = await makeTempDir("delegates-version-");
|
|
28
26
|
const durableDir = join(root, "durable");
|
|
29
27
|
const hostDir = join(root, "host");
|
|
30
28
|
const piAiDir = join(root, "pi-ai");
|
|
31
|
-
await
|
|
32
|
-
await
|
|
33
|
-
await
|
|
29
|
+
await makeDir(durableDir);
|
|
30
|
+
await makeDir(hostDir);
|
|
31
|
+
await makeDir(piAiDir);
|
|
34
32
|
const durable = join(durableDir, "package.json");
|
|
35
33
|
const host = join(hostDir, "package.json");
|
|
36
34
|
const piAi = join(piAiDir, "package.json");
|
|
37
|
-
await
|
|
35
|
+
await writeText(
|
|
38
36
|
durable,
|
|
39
37
|
JSON.stringify({ version: "1.6.1", dependencies: { "@earendil-works/pi-ai": "1.6.0" } }),
|
|
40
38
|
);
|
|
41
|
-
await
|
|
39
|
+
await writeText(
|
|
42
40
|
host,
|
|
43
41
|
JSON.stringify({ version: "1.6.0", dependencies: { "@earendil-works/pi-ai": "1.6.0" } }),
|
|
44
42
|
);
|
|
45
|
-
await
|
|
43
|
+
await writeText(piAi, JSON.stringify({ version: "1.5.0" }));
|
|
46
44
|
const signals = readVersionSignals((specifier) =>
|
|
47
45
|
specifier.includes("pi-durable")
|
|
48
46
|
? durable
|
|
@@ -56,31 +54,28 @@ it("reads durable's pin and the host's installed pi-ai", async () => {
|
|
|
56
54
|
});
|
|
57
55
|
|
|
58
56
|
it("reads pi-ai from the host copy, not the extension's nested copy", async () => {
|
|
59
|
-
const
|
|
60
|
-
const { tmpdir } = await import("node:os");
|
|
61
|
-
const { join } = await import("node:path");
|
|
62
|
-
const root = await mkdtemp(join(tmpdir(), "delegates-version-host-"));
|
|
57
|
+
const root = await makeTempDir("delegates-version-host-");
|
|
63
58
|
const durableDir = join(root, "durable");
|
|
64
59
|
const hostDir = join(root, "host");
|
|
65
60
|
const nestedDir = join(root, "extension", "pi-ai");
|
|
66
61
|
const hostAiDir = join(hostDir, "node_modules", "@earendil-works", "pi-ai");
|
|
67
|
-
await
|
|
68
|
-
await
|
|
69
|
-
await
|
|
62
|
+
await makeDir(durableDir);
|
|
63
|
+
await makeDir(hostAiDir);
|
|
64
|
+
await makeDir(nestedDir);
|
|
70
65
|
const durable = join(durableDir, "package.json");
|
|
71
66
|
const host = join(hostDir, "package.json");
|
|
72
67
|
const nested = join(nestedDir, "package.json");
|
|
73
68
|
const hostAi = join(hostAiDir, "package.json");
|
|
74
|
-
await
|
|
69
|
+
await writeText(
|
|
75
70
|
durable,
|
|
76
71
|
JSON.stringify({ version: "1.6.1", dependencies: { "@earendil-works/pi-ai": "1.6.0" } }),
|
|
77
72
|
);
|
|
78
|
-
await
|
|
73
|
+
await writeText(
|
|
79
74
|
host,
|
|
80
75
|
JSON.stringify({ version: "1.6.0", dependencies: { "@earendil-works/pi-ai": "1.5.0" } }),
|
|
81
76
|
);
|
|
82
|
-
await
|
|
83
|
-
await
|
|
77
|
+
await writeText(nested, JSON.stringify({ version: "1.6.0" }));
|
|
78
|
+
await writeText(hostAi, JSON.stringify({ version: "1.5.0" }));
|
|
84
79
|
const signals = readVersionSignals((specifier, parent) => {
|
|
85
80
|
if (specifier === "@earendil-works/pi-durable") return durable;
|
|
86
81
|
if (specifier === "@earendil-works/pi-coding-agent") return host;
|
|
@@ -92,19 +87,16 @@ it("reads pi-ai from the host copy, not the extension's nested copy", async () =
|
|
|
92
87
|
});
|
|
93
88
|
|
|
94
89
|
it("a malformed manifest reads as unverified", async () => {
|
|
95
|
-
const
|
|
96
|
-
const { tmpdir } = await import("node:os");
|
|
97
|
-
const { join } = await import("node:path");
|
|
98
|
-
const root = await mkdtemp(join(tmpdir(), "delegates-version-bad-"));
|
|
90
|
+
const root = await makeTempDir("delegates-version-bad-");
|
|
99
91
|
const durableDir = join(root, "durable");
|
|
100
92
|
const hostDir = join(root, "host");
|
|
101
|
-
await
|
|
102
|
-
await
|
|
93
|
+
await makeDir(durableDir);
|
|
94
|
+
await makeDir(hostDir);
|
|
103
95
|
const durable = join(durableDir, "package.json");
|
|
104
96
|
const host = join(hostDir, "package.json");
|
|
105
97
|
// A version that is not a string and a dependency map that is not a map.
|
|
106
|
-
await
|
|
107
|
-
await
|
|
98
|
+
await writeText(durable, JSON.stringify({ version: 5 }));
|
|
99
|
+
await writeText(host, JSON.stringify({ dependencies: "x" }));
|
|
108
100
|
const signals = readVersionSignals((specifier) => {
|
|
109
101
|
if (specifier === "@earendil-works/pi-durable") return durable;
|
|
110
102
|
if (specifier === "@earendil-works/pi-coding-agent") return host;
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { assert, it } from "@effect/vitest";
|
|
2
|
+
import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
|
|
3
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
4
|
+
import { MemoryStorage } from "@earendil-works/pi-durable";
|
|
5
|
+
import {
|
|
6
|
+
Context,
|
|
7
|
+
Deferred,
|
|
8
|
+
Effect,
|
|
9
|
+
Exit,
|
|
10
|
+
Fiber,
|
|
11
|
+
Layer,
|
|
12
|
+
PlatformError,
|
|
13
|
+
Scope,
|
|
14
|
+
Stream,
|
|
15
|
+
} from "effect";
|
|
16
|
+
import * as FileSystem from "effect/FileSystem";
|
|
17
|
+
import * as Path from "effect/Path";
|
|
18
|
+
import { fakeObservations } from "../test-support/fake-observations.ts";
|
|
19
|
+
import { inspectorClock } from "../test-support/inspector-clock.ts";
|
|
20
|
+
import { stubHostSource } from "../test-support/stub-model-source.ts";
|
|
21
|
+
import { makeStubPi } from "../test-support/stub-pi.ts";
|
|
22
|
+
import { createCatalogue, defineAgent } from "./domain/definitions.ts";
|
|
23
|
+
import { CODING_EXTENSION } from "./domain/names.ts";
|
|
24
|
+
import type { HostDefaults } from "./domain/orchestration/launch.ts";
|
|
25
|
+
import type { RunView } from "./domain/view.ts";
|
|
26
|
+
import { registerDelegateTools } from "./extension/tools.ts";
|
|
27
|
+
import { Inspector, liveAddress, type InspectorReadFailed } from "./presentation/inspector.ts";
|
|
28
|
+
import { nullLogSink } from "./runtime/log.ts";
|
|
29
|
+
import { HostModelAdapter } from "./runtime/models.ts";
|
|
30
|
+
import { type SessionRuntime } from "./runtime/session.ts";
|
|
31
|
+
import { openTestSession, type TestSession } from "../test-support/seams.ts";
|
|
32
|
+
import type { SessionHandle } from "./runtime/handle.ts";
|
|
33
|
+
import { handleFor } from "../test-support/session-handle.ts";
|
|
34
|
+
import { Ref } from "effect";
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Four behaviour goldens, recorded once from the tree before the composition
|
|
38
|
+
* rework and diffed by every later slice. A plain run is verify-only: the files
|
|
39
|
+
* change only under an explicit `GOLDENS=record`.
|
|
40
|
+
*/
|
|
41
|
+
const suite = it.layer(Layer.mergeAll(NodeFileSystem.layer, NodePath.layer));
|
|
42
|
+
|
|
43
|
+
const host: HostDefaults = {
|
|
44
|
+
model: { provider: "stub", modelId: "stub-1" },
|
|
45
|
+
thinkingLevel: "low",
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const deployer = defineAgent({
|
|
49
|
+
name: "deployer",
|
|
50
|
+
role: "Deploy agent",
|
|
51
|
+
prompt: { role: "You deploy things." },
|
|
52
|
+
tools: ["bash"],
|
|
53
|
+
extensions: [CODING_EXTENSION],
|
|
54
|
+
approval: { gates: [{ name: "deploy", tools: ["bash"], match: "deploy" }] },
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const catalogue = (): ReturnType<typeof createCatalogue> => createCatalogue([deployer]);
|
|
58
|
+
|
|
59
|
+
const golden = <E>(
|
|
60
|
+
name: string,
|
|
61
|
+
produce: Effect.Effect<unknown, E, FileSystem.FileSystem | Path.Path>,
|
|
62
|
+
): Effect.Effect<void, E | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path> =>
|
|
63
|
+
Effect.gen(function* () {
|
|
64
|
+
const fs = yield* FileSystem.FileSystem;
|
|
65
|
+
const path = yield* Path.Path;
|
|
66
|
+
// Module-relative: a bare relative path would resolve against the vitest cwd.
|
|
67
|
+
const file = path.join(import.meta.dirname, "..", "test-support", "goldens", `${name}.json`);
|
|
68
|
+
const value = yield* produce;
|
|
69
|
+
const actual = `${JSON.stringify(value, null, 2)}\n`;
|
|
70
|
+
if (process.env.GOLDENS === "record") {
|
|
71
|
+
yield* fs.makeDirectory(path.dirname(file), { recursive: true });
|
|
72
|
+
yield* fs.writeFileString(file, actual);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const recorded = yield* fs.readFileString(file);
|
|
76
|
+
assert.strictEqual(recorded, actual);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
interface ToolResult {
|
|
80
|
+
readonly content: readonly { readonly type: string; readonly text: string }[];
|
|
81
|
+
readonly details?: unknown;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface RegisteredTool {
|
|
85
|
+
readonly execute: (
|
|
86
|
+
id: string,
|
|
87
|
+
params: unknown,
|
|
88
|
+
signal: undefined,
|
|
89
|
+
onUpdate: undefined,
|
|
90
|
+
ctx: unknown,
|
|
91
|
+
) => Promise<ToolResult>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface Opened {
|
|
95
|
+
readonly runtime: TestSession;
|
|
96
|
+
readonly tool: (name: string) => RegisteredTool;
|
|
97
|
+
readonly context: unknown;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** One opened session with the launch and control tools registered against it. */
|
|
101
|
+
const withSession = <A, E, R>(
|
|
102
|
+
use: (opened: Opened) => Effect.Effect<A, E, R>,
|
|
103
|
+
): Effect.Effect<A, E | PlatformError.PlatformError, R | FileSystem.FileSystem | Scope.Scope> =>
|
|
104
|
+
Effect.acquireUseRelease(
|
|
105
|
+
Effect.gen(function* () {
|
|
106
|
+
const fs = yield* FileSystem.FileSystem;
|
|
107
|
+
// Scoped: the directory is removed when the test's scope closes.
|
|
108
|
+
const directory = yield* fs.makeTempDirectoryScoped({ prefix: "delegates-golden-" });
|
|
109
|
+
const runtime = yield* Effect.promise(() =>
|
|
110
|
+
openTestSession({
|
|
111
|
+
identity: {
|
|
112
|
+
sessionId: "s-1",
|
|
113
|
+
sessionDir: directory,
|
|
114
|
+
cwd: directory,
|
|
115
|
+
agentDir: directory,
|
|
116
|
+
},
|
|
117
|
+
models: new HostModelAdapter(
|
|
118
|
+
stubHostSource({
|
|
119
|
+
text: "deployed",
|
|
120
|
+
toolCall: { name: "bash", arguments: { command: "echo deploy" } },
|
|
121
|
+
}),
|
|
122
|
+
),
|
|
123
|
+
storage: new MemoryStorage(),
|
|
124
|
+
catalogue: catalogue(),
|
|
125
|
+
}),
|
|
126
|
+
);
|
|
127
|
+
const stub = makeStubPi({ settings: { packages: [] } });
|
|
128
|
+
registerDelegateTools(stub.api, {
|
|
129
|
+
session: Ref.makeUnsafe<SessionHandle | undefined>(handleFor(runtime)),
|
|
130
|
+
catalogue: catalogue(),
|
|
131
|
+
host,
|
|
132
|
+
launchWaitMs: () => 10_000,
|
|
133
|
+
log: () => nullLogSink,
|
|
134
|
+
});
|
|
135
|
+
const definitions = stub.registrations.toolDefinitions;
|
|
136
|
+
return {
|
|
137
|
+
runtime,
|
|
138
|
+
context: stub.context,
|
|
139
|
+
tool: (name: string) => definitions.get(name) as unknown as RegisteredTool,
|
|
140
|
+
};
|
|
141
|
+
}),
|
|
142
|
+
use,
|
|
143
|
+
(opened) => Effect.promise(() => opened.runtime.close()),
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
/** One parked single run, so every later payload carries no terminal duration. */
|
|
147
|
+
const parkedLaunch = (opened: Opened): Effect.Effect<ToolResult> =>
|
|
148
|
+
Effect.promise(() =>
|
|
149
|
+
opened
|
|
150
|
+
.tool("delegate_launch")
|
|
151
|
+
.execute(
|
|
152
|
+
"",
|
|
153
|
+
{ request: { kind: "single", agent: "deployer", task: "deploy it" } },
|
|
154
|
+
undefined,
|
|
155
|
+
undefined,
|
|
156
|
+
opened.context,
|
|
157
|
+
),
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
const runIdOf = (result: ToolResult): string =>
|
|
161
|
+
(result.details as { readonly run: RunView }).run.runId;
|
|
162
|
+
|
|
163
|
+
/** One instance from the real layer, built in a scope this test owns and closes. */
|
|
164
|
+
const withInspector = <A>(
|
|
165
|
+
runtime: SessionRuntime,
|
|
166
|
+
observe: ReturnType<typeof fakeObservations>,
|
|
167
|
+
use: (inspector: Inspector["Service"]) => Effect.Effect<A>,
|
|
168
|
+
): Effect.Effect<A, InspectorReadFailed> =>
|
|
169
|
+
Effect.acquireUseRelease(
|
|
170
|
+
Effect.gen(function* () {
|
|
171
|
+
const scope = yield* Scope.make("sequential");
|
|
172
|
+
const built = yield* Effect.provideService(
|
|
173
|
+
Layer.build(
|
|
174
|
+
Inspector.layer({
|
|
175
|
+
runtime,
|
|
176
|
+
observe,
|
|
177
|
+
view: async () => ({
|
|
178
|
+
runs: [
|
|
179
|
+
{
|
|
180
|
+
runId: "run:golden",
|
|
181
|
+
definition: "deployer",
|
|
182
|
+
mode: "single",
|
|
183
|
+
lane: "default",
|
|
184
|
+
conversationId: 10,
|
|
185
|
+
taskId: 8,
|
|
186
|
+
status: "running",
|
|
187
|
+
answer: null,
|
|
188
|
+
durationMs: null,
|
|
189
|
+
children: [],
|
|
190
|
+
missing: [],
|
|
191
|
+
gates: [],
|
|
192
|
+
requests: [],
|
|
193
|
+
diagnostic: null,
|
|
194
|
+
execution: "wait",
|
|
195
|
+
maxTurns: null,
|
|
196
|
+
failure: null,
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
lanes: [],
|
|
200
|
+
gates: [],
|
|
201
|
+
reviews: [],
|
|
202
|
+
requests: [],
|
|
203
|
+
}),
|
|
204
|
+
now: () => 4_000,
|
|
205
|
+
timers: inspectorClock(),
|
|
206
|
+
}),
|
|
207
|
+
),
|
|
208
|
+
Scope.Scope,
|
|
209
|
+
scope,
|
|
210
|
+
).pipe(Effect.onError((cause) => Scope.close(scope, Exit.failCause(cause))));
|
|
211
|
+
return { inspector: Context.get(built, Inspector), scope };
|
|
212
|
+
}),
|
|
213
|
+
(built) => use(built.inspector),
|
|
214
|
+
(built) => Scope.close(built.scope, Exit.void),
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
suite((it) => {
|
|
218
|
+
it.effect("the launch golden matches when a gated run parks", () =>
|
|
219
|
+
withSession((opened) =>
|
|
220
|
+
golden(
|
|
221
|
+
"delegate-launch",
|
|
222
|
+
Effect.map(parkedLaunch(opened), (result) => result),
|
|
223
|
+
),
|
|
224
|
+
),
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
it.effect("the control golden matches when a parked run is steered", () =>
|
|
228
|
+
withSession((opened) =>
|
|
229
|
+
golden(
|
|
230
|
+
"delegate-control",
|
|
231
|
+
Effect.gen(function* () {
|
|
232
|
+
const launched = yield* parkedLaunch(opened);
|
|
233
|
+
return yield* Effect.promise(() =>
|
|
234
|
+
opened
|
|
235
|
+
.tool("delegate_control")
|
|
236
|
+
.execute(
|
|
237
|
+
"",
|
|
238
|
+
{ action: "steer", run: runIdOf(launched), message: "keep going" },
|
|
239
|
+
undefined,
|
|
240
|
+
undefined,
|
|
241
|
+
opened.context,
|
|
242
|
+
),
|
|
243
|
+
);
|
|
244
|
+
}),
|
|
245
|
+
),
|
|
246
|
+
),
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
it.effect("the invalid-control golden matches when the action misses its field", () =>
|
|
250
|
+
withSession((opened) =>
|
|
251
|
+
golden(
|
|
252
|
+
"invalid-control",
|
|
253
|
+
Effect.orDie(
|
|
254
|
+
Effect.promise(() =>
|
|
255
|
+
opened
|
|
256
|
+
.tool("delegate_control")
|
|
257
|
+
.execute("", { action: "answer" }, undefined, undefined, opened.context),
|
|
258
|
+
),
|
|
259
|
+
),
|
|
260
|
+
),
|
|
261
|
+
),
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
it.effect("the inspector golden matches when one publication is projected", () =>
|
|
265
|
+
withSession((opened) =>
|
|
266
|
+
golden(
|
|
267
|
+
"inspector-publication",
|
|
268
|
+
Effect.gen(function* () {
|
|
269
|
+
const observe = fakeObservations();
|
|
270
|
+
return yield* withInspector(opened.runtime, observe, (inspector) =>
|
|
271
|
+
Effect.gen(function* () {
|
|
272
|
+
const subscribed = Deferred.makeUnsafe<void>();
|
|
273
|
+
const changes = yield* Stream.map(inspector.changes, (snapshot) => {
|
|
274
|
+
Deferred.doneUnsafe(subscribed, Exit.void);
|
|
275
|
+
return snapshot;
|
|
276
|
+
}).pipe(Stream.take(2), Stream.runCollect, Effect.forkChild);
|
|
277
|
+
yield* Deferred.await(subscribed);
|
|
278
|
+
yield* Effect.sync(() => {
|
|
279
|
+
observe.pushActivity(liveAddress(10), {
|
|
280
|
+
tool: "bash",
|
|
281
|
+
slot: "running",
|
|
282
|
+
turns: 1,
|
|
283
|
+
at: 1_000,
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
const collected = yield* Fiber.join(changes);
|
|
287
|
+
return [...collected].at(-1);
|
|
288
|
+
}),
|
|
289
|
+
);
|
|
290
|
+
}),
|
|
291
|
+
),
|
|
292
|
+
),
|
|
293
|
+
);
|
|
294
|
+
});
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { expect, it, vi } from "@effect/vitest";
|
|
2
|
-
import { readdirSync, readFileSync } from "node:fs";
|
|
3
|
-
import { join, relative } from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
2
|
import { createVitest } from "vitest/node";
|
|
3
|
+
import { dirEntries, join, readText, relativePath } from "../test-support/platform.ts";
|
|
6
4
|
|
|
7
|
-
const PACKAGE_ROOT =
|
|
5
|
+
const PACKAGE_ROOT = join(import.meta.dirname, "..");
|
|
8
6
|
const PROBE = "PI_HARNESS_PROBE";
|
|
9
7
|
const REAL_LOG = console.log;
|
|
10
8
|
|
|
11
9
|
/** Every `*.test.ts` under `dir`, as paths relative to `PACKAGE_ROOT`. */
|
|
12
|
-
const walkTests = (dir: string, found: string[] = []): string[] => {
|
|
13
|
-
for (const entry of
|
|
10
|
+
const walkTests = async (dir: string, found: string[] = []): Promise<string[]> => {
|
|
11
|
+
for (const entry of await dirEntries(join(PACKAGE_ROOT, dir))) {
|
|
14
12
|
const path = join(dir, entry.name);
|
|
15
|
-
if (entry.
|
|
13
|
+
if (entry.directory) await walkTests(path, found);
|
|
16
14
|
else if (entry.name.endsWith(".test.ts")) found.push(path);
|
|
17
15
|
}
|
|
18
16
|
return found;
|
|
@@ -38,8 +36,8 @@ it("this package resolves the shared policy without stating it", async () => {
|
|
|
38
36
|
expect(config?.isolate).toBe(false);
|
|
39
37
|
});
|
|
40
38
|
|
|
41
|
-
it("the package config states no shared key", () => {
|
|
42
|
-
const source =
|
|
39
|
+
it("the package config states no shared key", async () => {
|
|
40
|
+
const source = await readText(join(import.meta.dirname, "../vitest.config.ts"));
|
|
43
41
|
|
|
44
42
|
expect(source).toContain("baseTestConfig");
|
|
45
43
|
for (const key of ["restoreMocks", "unstubEnvs", "unstubGlobals", "fakeTimers", "isolate"]) {
|
|
@@ -49,10 +47,14 @@ it("the package config states no shared key", () => {
|
|
|
49
47
|
|
|
50
48
|
it("the project collects the source tree, the scripts and the test support", async () => {
|
|
51
49
|
const { specs } = await project();
|
|
52
|
-
const collected = specs.map((spec) =>
|
|
50
|
+
const collected = specs.map((spec) => relativePath(PACKAGE_ROOT, spec.moduleId)).sort();
|
|
53
51
|
|
|
54
52
|
expect(collected).toEqual(
|
|
55
|
-
[
|
|
53
|
+
[
|
|
54
|
+
...(await walkTests("src")),
|
|
55
|
+
...(await walkTests("scripts")),
|
|
56
|
+
...(await walkTests("test-support")),
|
|
57
|
+
].sort(),
|
|
56
58
|
);
|
|
57
59
|
});
|
|
58
60
|
|