harness-everything 0.58.0 → 1.0.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +8 -2
- package/CHANGELOG.md +17 -0
- package/README.md +4 -4
- package/benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/README.md +40 -0
- package/benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/edit-state-final.json +11 -0
- package/benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/events-2026-11-24.jsonl +103 -0
- package/benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/host-version.txt +3 -0
- package/benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/live-event-trace-probe.js +11 -0
- package/benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/plugin-load-lines.txt +2 -0
- package/benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/reminder-excerpt.txt +1 -0
- package/ci/doc-capability-consistency.test.js +4 -2
- package/ci/lib/opencode-v2-driver.js +169 -0
- package/ci/mechanism-2n-opencode-plugin.test.js +387 -223
- package/ci/mechanism-2p-opencode-v2-entrypoint.test.js +24 -15
- package/ci/mechanism-2u-issue-42-regressions.test.js +41 -2
- package/ci/mechanism-2w-platform-compatibility.test.js +16 -3
- package/ci/mechanism-30-opencode-plugin-loadability.test.js +78 -45
- package/ci/mechanism-338-opencode-async.test.js +367 -194
- package/ci/mechanism-341-opencode-lane.test.js +143 -183
- package/ci/mechanism-39-opencode-verify-outcomes.test.js +118 -86
- package/ci/mechanism-394-opencode-ledger-lesson.test.js +46 -97
- package/ci/mechanism-397-opencode-observations.test.js +58 -47
- package/ci/mechanism-453-opencode-v2-driver.test.js +51 -0
- package/ci/mechanism-453-opencode-v2-only-events.test.js +241 -0
- package/ci/telemetry.test.js +31 -24
- package/docs/architecture.md +4 -2
- package/docs/platform-capabilities.md +60 -26
- package/docs/platform-compatibility.json +8 -6
- package/docs/system-one-observations.md +1 -1
- package/docs/telemetry.md +1 -1
- package/docs/troubleshooting.md +2 -2
- package/opencode-plugin/README.md +60 -66
- package/opencode-plugin/index.mjs +11 -13
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/rules/AGENTS.md +8 -2
- package/sbom.cdx.json +12 -12
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Shared OpenCode V2 test driver (#453). Drives the plugin only through its
|
|
4
|
+
// default definition: `default.setup(ctx)` with a host-shaped ctx. It never
|
|
5
|
+
// imports or calls any named factory and writes no plugin state by hand.
|
|
6
|
+
//
|
|
7
|
+
// const d = await createV2Driver({ plugin?, workspace?, scripts?, sessionLookup? });
|
|
8
|
+
// d.toolHook('execute.before') -> registered callback (also d.toolHooks Map)
|
|
9
|
+
// d.sessionHook('prompt') -> registered callback (also d.sessionHooks Map)
|
|
10
|
+
// d.emit('session.execution.succeeded', 's1', extra) -> V2 envelope pushed onto the stream
|
|
11
|
+
// d.prompts -> recorded ctx.session.prompt inputs {sessionID, text}
|
|
12
|
+
// d.waitFor(pred, {label, timeoutMs}) -> poll an effect with a deadline (rejects with diagnostics)
|
|
13
|
+
// d.settled({quietMs}) -> consumption + quiescence, for "nothing happened" assertions
|
|
14
|
+
// d.teardown() -> dispose setup, end the stream, restore env, remove temp dir
|
|
15
|
+
|
|
16
|
+
const fs = require('node:fs');
|
|
17
|
+
const os = require('node:os');
|
|
18
|
+
const path = require('node:path');
|
|
19
|
+
const { pathToFileURL } = require('node:url');
|
|
20
|
+
|
|
21
|
+
const ROOT = path.resolve(__dirname, '..', '..');
|
|
22
|
+
const DEFAULT_PLUGIN = path.join(ROOT, 'opencode-plugin', 'index.mjs');
|
|
23
|
+
const ENV_KEYS = ['HOME', 'USERPROFILE', 'HARNESS_STATE_HOME', 'HARNESS_OBSERVATIONS_DIR', 'HARNESS_OBSERVATIONS'];
|
|
24
|
+
const DEFAULT_TIMEOUT_MS = 5000;
|
|
25
|
+
const POLL_MS = 10;
|
|
26
|
+
|
|
27
|
+
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
28
|
+
|
|
29
|
+
// OpenCode 2.x events are flat: {id, created, type, durable, data:{sessionID,...}}.
|
|
30
|
+
function v2Event(type, sessionID, data = {}) {
|
|
31
|
+
return { id: `evt-${type}-${sessionID}-${Date.now()}`, created: Date.now(), type, durable: true, data: { sessionID, ...data } };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function createV2Driver(options = {}) {
|
|
35
|
+
const pluginPath = path.resolve(options.plugin || DEFAULT_PLUGIN);
|
|
36
|
+
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'opencode-v2-driver-'));
|
|
37
|
+
// Canonicalise (macOS /var -> /private/var, Windows short names) so the
|
|
38
|
+
// workspace the host reports matches the key the plugin derives.
|
|
39
|
+
const canonicalRoot = fs.realpathSync.native(tempRoot);
|
|
40
|
+
const workspace = options.workspace ? path.resolve(options.workspace) : path.join(canonicalRoot, 'workspace');
|
|
41
|
+
fs.mkdirSync(workspace, { recursive: true });
|
|
42
|
+
const stateHome = path.join(canonicalRoot, 'harness-state');
|
|
43
|
+
if (options.scripts) {
|
|
44
|
+
fs.writeFileSync(path.join(workspace, 'package.json'),
|
|
45
|
+
JSON.stringify({ name: 'fixture', version: '0.0.0', scripts: options.scripts }, null, 2));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const envBefore = Object.fromEntries(ENV_KEYS.map(key => [key, process.env[key]]));
|
|
49
|
+
process.env.HOME = canonicalRoot;
|
|
50
|
+
process.env.USERPROFILE = canonicalRoot;
|
|
51
|
+
process.env.HARNESS_STATE_HOME = stateHome;
|
|
52
|
+
process.env.HARNESS_OBSERVATIONS_DIR = path.join(canonicalRoot, 'observations');
|
|
53
|
+
process.env.HARNESS_OBSERVATIONS = options.observations || 'off';
|
|
54
|
+
const restoreEnv = () => {
|
|
55
|
+
for (const [key, value] of Object.entries(envBefore)) {
|
|
56
|
+
if (value === undefined) delete process.env[key]; else process.env[key] = value;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const prompts = [];
|
|
61
|
+
const toolHooks = new Map();
|
|
62
|
+
const sessionHooks = new Map();
|
|
63
|
+
const queue = [];
|
|
64
|
+
let wake = null;
|
|
65
|
+
let activity = 0;
|
|
66
|
+
let consumed = 0;
|
|
67
|
+
let subscribeCount = 0;
|
|
68
|
+
let streamEnded = false;
|
|
69
|
+
const sessionLookup = options.sessionLookup
|
|
70
|
+
|| (async ({ sessionID }) => ({ id: sessionID, location: { directory: workspace } }));
|
|
71
|
+
|
|
72
|
+
const ctx = {
|
|
73
|
+
location: { directory: workspace },
|
|
74
|
+
tool: {
|
|
75
|
+
hook: async (name, callback) => {
|
|
76
|
+
toolHooks.set(name, async event => { activity++; return callback(event); });
|
|
77
|
+
return { dispose: async () => { toolHooks.delete(name); } };
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
session: {
|
|
81
|
+
get: async input => { activity++; return sessionLookup(input); },
|
|
82
|
+
prompt: async input => { activity++; prompts.push(input); return {}; },
|
|
83
|
+
hook: async (name, callback) => {
|
|
84
|
+
sessionHooks.set(name, async event => { activity++; return callback(event); });
|
|
85
|
+
return { dispose: async () => { sessionHooks.delete(name); } };
|
|
86
|
+
},
|
|
87
|
+
context: async () => [],
|
|
88
|
+
},
|
|
89
|
+
event: {
|
|
90
|
+
subscribe: ({ signal }) => {
|
|
91
|
+
subscribeCount++;
|
|
92
|
+
return {
|
|
93
|
+
[Symbol.asyncIterator]: () => ({
|
|
94
|
+
next: async () => {
|
|
95
|
+
while (!queue.length) {
|
|
96
|
+
if (signal.aborted) { streamEnded = true; return { done: true, value: undefined }; }
|
|
97
|
+
await new Promise(resolve => {
|
|
98
|
+
const onAbort = () => resolve();
|
|
99
|
+
wake = () => { signal.removeEventListener('abort', onAbort); resolve(); };
|
|
100
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
101
|
+
});
|
|
102
|
+
wake = null;
|
|
103
|
+
}
|
|
104
|
+
consumed++;
|
|
105
|
+
activity++;
|
|
106
|
+
return { done: false, value: queue.shift() };
|
|
107
|
+
},
|
|
108
|
+
return: async () => { streamEnded = true; return { done: true, value: undefined }; },
|
|
109
|
+
}),
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const mod = await import(pathToFileURL(pluginPath).href);
|
|
116
|
+
const definition = mod.default;
|
|
117
|
+
const disposeSetup = await definition.setup(ctx);
|
|
118
|
+
|
|
119
|
+
const diagnostics = () => `prompts=${prompts.length}; queued=${queue.length}; consumed=${consumed}; streamEnded=${streamEnded}; hooks=${[...toolHooks.keys(), ...sessionHooks.keys()].join(',')}`;
|
|
120
|
+
|
|
121
|
+
async function waitFor(predicate, { label = 'effect', timeoutMs = DEFAULT_TIMEOUT_MS } = {}) {
|
|
122
|
+
const deadline = Date.now() + timeoutMs;
|
|
123
|
+
while (!predicate()) {
|
|
124
|
+
if (Date.now() > deadline) throw new Error(`V2 driver: ${label} did not occur within ${timeoutMs}ms (${diagnostics()})`);
|
|
125
|
+
await sleep(POLL_MS);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
let tornDown = false;
|
|
130
|
+
return {
|
|
131
|
+
workspace, stateHome, definition, prompts, toolHooks, sessionHooks,
|
|
132
|
+
toolHook: name => toolHooks.get(name),
|
|
133
|
+
sessionHook: name => sessionHooks.get(name),
|
|
134
|
+
subscribeCount: () => subscribeCount,
|
|
135
|
+
eventStreamEnded: () => streamEnded,
|
|
136
|
+
emit(type, sessionID, data) {
|
|
137
|
+
queue.push(v2Event(type, sessionID, data));
|
|
138
|
+
if (wake) wake();
|
|
139
|
+
},
|
|
140
|
+
waitFor,
|
|
141
|
+
// Waits until queued events are consumed, then until no hook/prompt/session
|
|
142
|
+
// activity occurs for `quietMs`. Proves "nothing (more) happened" within
|
|
143
|
+
// a bounded window; use waitFor() for positive effects.
|
|
144
|
+
async settled({ quietMs = 200, timeoutMs = DEFAULT_TIMEOUT_MS } = {}) {
|
|
145
|
+
await waitFor(() => queue.length === 0, { label: 'event queue drain', timeoutMs });
|
|
146
|
+
const deadline = Date.now() + timeoutMs;
|
|
147
|
+
let last = -1;
|
|
148
|
+
let since = Date.now();
|
|
149
|
+
while (Date.now() - since < quietMs) {
|
|
150
|
+
if (Date.now() > deadline) throw new Error(`V2 driver: did not become quiet within ${timeoutMs}ms (${diagnostics()})`);
|
|
151
|
+
if (activity !== last) { last = activity; since = Date.now(); }
|
|
152
|
+
await sleep(POLL_MS);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
async teardown() {
|
|
156
|
+
if (tornDown) return;
|
|
157
|
+
tornDown = true;
|
|
158
|
+
try {
|
|
159
|
+
if (typeof disposeSetup === 'function') await disposeSetup();
|
|
160
|
+
await waitFor(() => streamEnded, { label: 'event stream end' });
|
|
161
|
+
} finally {
|
|
162
|
+
restoreEnv();
|
|
163
|
+
fs.rmSync(tempRoot, { recursive: true, force: true });
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
module.exports = { createV2Driver, v2Event, DEFAULT_PLUGIN };
|