harness-everything 0.57.4 → 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/.releaserc.json +2 -0
- package/AGENTS.md +8 -2
- package/CHANGELOG.md +23 -0
- package/README.md +4 -4
- package/benchmarks/results/live-host/agy-2026-11-22/README.md +49 -0
- package/benchmarks/results/live-host/agy-2026-11-23/README.md +48 -0
- 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 +15 -3
- package/ci/lib/opencode-v2-driver.js +169 -0
- package/ci/mechanism-2ao-plugin-sync.test.js +235 -2
- 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 +29 -5
- package/ci/mechanism-2x-release-automation.test.js +3 -1
- 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/mechanism-agy-hooks.test.js +1096 -0
- package/ci/mechanism-agy-plugin-package.test.js +76 -0
- package/ci/telemetry.test.js +31 -24
- package/docs/architecture.md +4 -2
- package/docs/platform-capabilities.md +62 -26
- package/docs/platform-compatibility.json +41 -6
- package/docs/system-one-observations.md +1 -1
- package/docs/telemetry.md +1 -1
- package/docs/troubleshooting.md +2 -2
- package/hooks/scripts/agy-post-tool.js +124 -0
- package/hooks/scripts/agy-pre-invocation.js +185 -0
- package/hooks/scripts/agy-pre-tool.js +158 -0
- package/hooks/scripts/agy-session-start.js +54 -0
- package/hooks/scripts/agy-stop.js +152 -0
- package/hooks/scripts/lib/agy-adapter-core.js +168 -0
- package/hooks/scripts/state-persist.js +50 -10
- 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 +18 -0
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/scripts/agy-post-tool.js +124 -0
- package/plugins/harness-everything/hooks/scripts/agy-pre-invocation.js +185 -0
- package/plugins/harness-everything/hooks/scripts/agy-pre-tool.js +158 -0
- package/plugins/harness-everything/hooks/scripts/agy-session-start.js +54 -0
- package/plugins/harness-everything/hooks/scripts/agy-stop.js +152 -0
- package/plugins/harness-everything/hooks/scripts/lib/agy-adapter-core.js +168 -0
- package/plugins/harness-everything/hooks/scripts/state-persist.js +50 -10
- package/plugins/harness-everything/hooks.json +44 -0
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/rules/AGENTS.md +117 -0
- package/sbom.cdx.json +12 -12
- package/scripts/plugin-sync.js +105 -14
- package/scripts/sync-openai-plugin.js +16 -1
- package/scripts/sync-release-version.js +1 -0
|
@@ -157,7 +157,8 @@ requireText('submission/openai/README.md', [
|
|
|
157
157
|
{ name: 'submission excludes local hooks', re: /does not contain the local `\.codex-plugin` lifecycle hooks/i },
|
|
158
158
|
]);
|
|
159
159
|
|
|
160
|
-
const OPENCODE_EVIDENCE = 'benchmarks/results/live-host/opencode-2026-
|
|
160
|
+
const OPENCODE_EVIDENCE = 'benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/README.md';
|
|
161
|
+
const OPENCODE_HISTORICAL_EVIDENCE = 'benchmarks/results/live-host/opencode-2026-09-16/README.md';
|
|
161
162
|
const OPENCODE_SURFACES = [
|
|
162
163
|
'README.md',
|
|
163
164
|
'AGENTS.md',
|
|
@@ -170,6 +171,7 @@ const OPENCODE_SURFACES = [
|
|
|
170
171
|
];
|
|
171
172
|
|
|
172
173
|
read(OPENCODE_EVIDENCE);
|
|
174
|
+
read(OPENCODE_HISTORICAL_EVIDENCE);
|
|
173
175
|
for (const rel of OPENCODE_SURFACES) {
|
|
174
176
|
requireText(rel, [
|
|
175
177
|
{ name: 'OpenCode retained artifact path', re: /benchmarks\/results\/live-host\/opencode-2026-09-16\/README\.md/ },
|
|
@@ -191,13 +193,14 @@ for (const rel of OPENCODE_SURFACES) {
|
|
|
191
193
|
const matrix = JSON.parse(read('docs/platform-compatibility.json'));
|
|
192
194
|
const opencode = matrix.platforms.find(platform => platform.id === 'opencode');
|
|
193
195
|
const codex = matrix.platforms.find(platform => platform.id === 'codex');
|
|
196
|
+
const agy = matrix.platforms.find(platform => platform.id === 'agy');
|
|
194
197
|
for (const dimension of ['hooksLifecycle', 'liveHostVerification']) {
|
|
195
198
|
if (opencode?.capabilities[dimension]?.status !== 'Partial') {
|
|
196
199
|
fail(`OpenCode ${dimension}: must remain Partial`);
|
|
197
200
|
}
|
|
198
201
|
}
|
|
199
202
|
if (opencode?.capabilities.liveHostVerification.evidence !== OPENCODE_EVIDENCE) {
|
|
200
|
-
fail('OpenCode liveHostVerification: missing exact
|
|
203
|
+
fail('OpenCode liveHostVerification: missing exact V2 artifact path');
|
|
201
204
|
}
|
|
202
205
|
if (codex?.capabilities.hooksLifecycle.status !== 'Partial') {
|
|
203
206
|
fail('Codex hooksLifecycle: expected partial live verification for the compatibility fallback');
|
|
@@ -208,7 +211,16 @@ if (codex?.capabilities.liveHostVerification.status !== 'Partial') {
|
|
|
208
211
|
if (codex?.capabilities.liveHostVerification.evidence !== 'benchmarks/results/live-host/codex-2026-10-13/README.md') {
|
|
209
212
|
fail('Codex liveHostVerification: missing exact retained artifact path');
|
|
210
213
|
}
|
|
211
|
-
|
|
214
|
+
if (agy?.capabilities.hooksLifecycle.status !== 'Partial') {
|
|
215
|
+
fail('AGY hooksLifecycle: expected Partial status matching bounded live/mechanism evidence');
|
|
216
|
+
}
|
|
217
|
+
if (agy?.capabilities.liveHostVerification.status !== 'Partial') {
|
|
218
|
+
fail('AGY liveHostVerification: expected Partial status with preserved evidence');
|
|
219
|
+
}
|
|
220
|
+
if (agy?.capabilities.liveHostVerification.evidence !== 'benchmarks/results/live-host/agy-2026-11-23/README.md') {
|
|
221
|
+
fail('AGY liveHostVerification: missing exact retained artifact path');
|
|
222
|
+
}
|
|
223
|
+
for (const platform of matrix.platforms.filter(platform => !['opencode', 'codex', 'agy'].includes(platform.id))) {
|
|
212
224
|
if (platform.capabilities.liveHostVerification.status !== 'Unknown') {
|
|
213
225
|
fail(`${platform.id}: liveHostVerification must remain Unknown without its own evidence`);
|
|
214
226
|
}
|
|
@@ -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 };
|
|
@@ -387,7 +387,7 @@ for (const sourceType of ['git', 'npm', 'remote', 'unknown']) {
|
|
|
387
387
|
|
|
388
388
|
{
|
|
389
389
|
const result = sync({ host: 'all' }, { commandAvailable: () => false, log: () => {}, warn: () => {} });
|
|
390
|
-
assert.strictEqual(result.skipped,
|
|
390
|
+
assert.strictEqual(result.skipped, 3);
|
|
391
391
|
assert.strictEqual(result.failed, 0);
|
|
392
392
|
assert.ok(result.results.every(entry => entry.reasonCode === 'cli-not-found'), 'an absent CLI must stay distinguishable from a capability boundary');
|
|
393
393
|
}
|
|
@@ -403,7 +403,7 @@ for (const sourceType of ['git', 'npm', 'remote', 'unknown']) {
|
|
|
403
403
|
events.push(`call:${command}`);
|
|
404
404
|
return fake.runner(command, args, opts);
|
|
405
405
|
};
|
|
406
|
-
const result = sync({ host: 'all', codexHome, repository: 'dyphn1/Harness-everything', ref: 'main' }, {
|
|
406
|
+
const result = sync({ host: 'all', codexHome, agyHome: codexHome, repository: 'dyphn1/Harness-everything', ref: 'main' }, {
|
|
407
407
|
runner,
|
|
408
408
|
codexHooksInstall: fake.codexHooksInstall,
|
|
409
409
|
commandAvailable: () => true,
|
|
@@ -415,10 +415,243 @@ for (const sourceType of ['git', 'npm', 'remote', 'unknown']) {
|
|
|
415
415
|
assert.strictEqual(fake.codexHookInstalls.length, 1, 'progress test must mock hook installation as well as host commands');
|
|
416
416
|
assert.ok(events.includes('warn:[...] claude: syncing'), 'a claude progress notice must be emitted');
|
|
417
417
|
assert.ok(events.includes('warn:[...] codex: syncing'), 'a codex progress notice must be emitted');
|
|
418
|
+
assert.ok(events.includes('warn:[...] agy: syncing'), 'an agy progress notice must be emitted');
|
|
418
419
|
assert.ok(events.indexOf('warn:[...] claude: syncing') < events.indexOf('call:claude'), 'the claude notice must be emitted before its first host command, not buffered until the run finishes');
|
|
419
420
|
assert.ok(events.indexOf('warn:[...] codex: syncing') < events.indexOf('call:codex'), 'the codex notice must be emitted before its first host command');
|
|
420
421
|
}
|
|
421
422
|
|
|
423
|
+
{
|
|
424
|
+
const agyTemp = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-agy-sync-'));
|
|
425
|
+
const target = path.join(agyTemp, 'plugins', 'harness-everything');
|
|
426
|
+
|
|
427
|
+
// Test absent -> install
|
|
428
|
+
const installResult = sync({ host: 'agy', agyTarget: target }, {
|
|
429
|
+
commandAvailable: () => true,
|
|
430
|
+
log: () => {},
|
|
431
|
+
warn: () => {}
|
|
432
|
+
});
|
|
433
|
+
assert.strictEqual(installResult.failed, 0);
|
|
434
|
+
assert.strictEqual(installResult.results[0].action, 'install');
|
|
435
|
+
assert.ok(fs.existsSync(path.join(target, 'plugin.json')), 'plugin.json must be installed');
|
|
436
|
+
|
|
437
|
+
// Test present -> update
|
|
438
|
+
const updateResult = sync({ host: 'agy', agyTarget: target }, {
|
|
439
|
+
commandAvailable: () => true,
|
|
440
|
+
log: () => {},
|
|
441
|
+
warn: () => {}
|
|
442
|
+
});
|
|
443
|
+
assert.strictEqual(updateResult.failed, 0);
|
|
444
|
+
assert.strictEqual(updateResult.results[0].action, 'update');
|
|
445
|
+
|
|
446
|
+
// Test dry-run on absent target: reports dry-run (not synchronized) and writes nothing
|
|
447
|
+
const absentTarget = path.join(agyTemp, 'plugins', 'absent-dry-run');
|
|
448
|
+
const absentDryLogs = [];
|
|
449
|
+
const absentDryResult = sync({ host: 'agy', agyTarget: absentTarget, dryRun: true }, {
|
|
450
|
+
commandAvailable: () => true,
|
|
451
|
+
log: msg => absentDryLogs.push(msg),
|
|
452
|
+
warn: () => {}
|
|
453
|
+
});
|
|
454
|
+
assert.strictEqual(absentDryResult.failed, 0);
|
|
455
|
+
assert.strictEqual(absentDryResult.synchronized, 0, 'dry-run must not increment synchronized count');
|
|
456
|
+
assert.strictEqual(absentDryResult.planned, 1, 'dry-run must increment planned count');
|
|
457
|
+
assert.strictEqual(absentDryResult.results[0].status, 'dry-run', 'dry-run must report status=dry-run');
|
|
458
|
+
assert.strictEqual(absentDryResult.results[0].action, 'install');
|
|
459
|
+
assert.ok(!fs.existsSync(absentTarget), 'dry-run must not create target directory');
|
|
460
|
+
assert.ok(absentDryLogs.some(log => log.includes('[dry-run] agy plugin install')), 'dry-run install log must be emitted');
|
|
461
|
+
|
|
462
|
+
// Test dry-run on existing target: reports dry-run (not synchronized)
|
|
463
|
+
const dryLogs = [];
|
|
464
|
+
const dryResult = sync({ host: 'agy', agyTarget: target, dryRun: true }, {
|
|
465
|
+
commandAvailable: () => true,
|
|
466
|
+
log: msg => dryLogs.push(msg),
|
|
467
|
+
warn: () => {}
|
|
468
|
+
});
|
|
469
|
+
assert.strictEqual(dryResult.failed, 0);
|
|
470
|
+
assert.strictEqual(dryResult.synchronized, 0, 'dry-run update must not report synchronized');
|
|
471
|
+
assert.strictEqual(dryResult.planned, 1);
|
|
472
|
+
assert.strictEqual(dryResult.results[0].status, 'dry-run');
|
|
473
|
+
assert.strictEqual(dryResult.results[0].action, 'update');
|
|
474
|
+
assert.ok(dryLogs.some(log => log.includes('[dry-run] agy plugin update')), 'dry-run log must be emitted');
|
|
475
|
+
|
|
476
|
+
// Test CLI exit code 0 for `--host agy --dry-run` in a repo with bare `.agents/` -> targets global ~/.gemini, never pollutes .agents/plugins/
|
|
477
|
+
const bareAgentsRepo = path.join(agyTemp, 'codex-repo');
|
|
478
|
+
fs.mkdirSync(path.join(bareAgentsRepo, '.agents', 'skills'), { recursive: true });
|
|
479
|
+
const cliDryRun = require('child_process').spawnSync(
|
|
480
|
+
process.execPath,
|
|
481
|
+
[path.join(ROOT, 'scripts', 'plugin-sync.js'), '--host', 'agy', '--dry-run', '--json'],
|
|
482
|
+
{
|
|
483
|
+
cwd: bareAgentsRepo,
|
|
484
|
+
encoding: 'utf8',
|
|
485
|
+
env: { ...process.env, HOME: agyTemp, USERPROFILE: agyTemp, PATH: '' }
|
|
486
|
+
}
|
|
487
|
+
);
|
|
488
|
+
assert.strictEqual(cliDryRun.status, 0, `CLI --host agy --dry-run must exit 0: ${cliDryRun.stderr}`);
|
|
489
|
+
const cliDryJson = JSON.parse(cliDryRun.stdout);
|
|
490
|
+
assert.strictEqual(cliDryJson.results[0].status, 'dry-run', 'CLI JSON output must report status=dry-run');
|
|
491
|
+
assert.strictEqual(cliDryJson.synchronized, 0);
|
|
492
|
+
assert.strictEqual(cliDryJson.planned, 1);
|
|
493
|
+
assert.strictEqual(
|
|
494
|
+
cliDryJson.results[0].target,
|
|
495
|
+
path.join(agyTemp, '.gemini', 'config', 'plugins', 'harness-everything'),
|
|
496
|
+
'Fresh --host agy inside a repo with bare .agents/ must target global ~/.gemini, not .agents/plugins/'
|
|
497
|
+
);
|
|
498
|
+
assert.ok(
|
|
499
|
+
!fs.existsSync(path.join(bareAgentsRepo, '.agents', 'plugins')),
|
|
500
|
+
'Fresh --host agy must not pollute bare .agents/plugins/'
|
|
501
|
+
);
|
|
502
|
+
|
|
503
|
+
// Test real CLI `--host all --dry-run --json` discovers an existing global $HOME/.gemini/config/plugins/harness-everything
|
|
504
|
+
const globalExisting = path.join(agyTemp, '.gemini', 'config', 'plugins', 'harness-everything', '.antigravity-plugin');
|
|
505
|
+
fs.mkdirSync(globalExisting, { recursive: true });
|
|
506
|
+
fs.writeFileSync(path.join(globalExisting, 'plugin.json'), '{"name":"harness-everything"}\n', 'utf8');
|
|
507
|
+
const cliAllDryRun = require('child_process').spawnSync(
|
|
508
|
+
process.execPath,
|
|
509
|
+
[path.join(ROOT, 'scripts', 'plugin-sync.js'), '--host', 'all', '--dry-run', '--json'],
|
|
510
|
+
{
|
|
511
|
+
cwd: bareAgentsRepo,
|
|
512
|
+
encoding: 'utf8',
|
|
513
|
+
env: { ...process.env, HOME: agyTemp, USERPROFILE: agyTemp, PATH: '' }
|
|
514
|
+
}
|
|
515
|
+
);
|
|
516
|
+
assert.strictEqual(cliAllDryRun.status, 0, `CLI --host all --dry-run with existing global AGY install must exit 0: ${cliAllDryRun.stderr}`);
|
|
517
|
+
const cliAllDryJson = JSON.parse(cliAllDryRun.stdout);
|
|
518
|
+
const agyAllEntry = cliAllDryJson.results.find(r => r.host === 'agy');
|
|
519
|
+
assert.ok(agyAllEntry, 'agy entry must be present in --host all output');
|
|
520
|
+
assert.strictEqual(agyAllEntry.status, 'dry-run', 'Existing global AGY install must be discovered under real CLI --host all');
|
|
521
|
+
assert.strictEqual(agyAllEntry.action, 'update', 'Existing global AGY install must take update action');
|
|
522
|
+
assert.strictEqual(
|
|
523
|
+
agyAllEntry.target,
|
|
524
|
+
path.join(agyTemp, '.gemini', 'config', 'plugins', 'harness-everything')
|
|
525
|
+
);
|
|
526
|
+
|
|
527
|
+
fs.rmSync(agyTemp, { recursive: true, force: true });
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// AGY sync acceptance: --host all with Codex .agents (including bare plugin.json) skips AGY
|
|
531
|
+
{
|
|
532
|
+
const projectTemp = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-codex-only-'));
|
|
533
|
+
fs.mkdirSync(path.join(projectTemp, '.agents', 'skills'), { recursive: true });
|
|
534
|
+
const codexOnlyPluginDir = path.join(projectTemp, '.agents', 'plugins', 'harness-everything');
|
|
535
|
+
fs.mkdirSync(codexOnlyPluginDir, { recursive: true });
|
|
536
|
+
fs.writeFileSync(path.join(codexOnlyPluginDir, 'plugin.json'), '{"name":"harness-everything"}\n', 'utf8');
|
|
537
|
+
|
|
538
|
+
const result = sync({ host: 'all', cwd: projectTemp, agyHome: projectTemp }, {
|
|
539
|
+
commandAvailable: cmd => cmd === 'codex',
|
|
540
|
+
log: () => {},
|
|
541
|
+
warn: () => {},
|
|
542
|
+
codexHooksInstall: () => ({ status: 'installed' })
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
const agyRes = result.results.find(r => r.host === 'agy');
|
|
546
|
+
assert.ok(agyRes, 'agy result should be present');
|
|
547
|
+
assert.strictEqual(agyRes.status, 'skipped', 'agy must be skipped when .agents/plugins lacks .antigravity-plugin/plugin.json');
|
|
548
|
+
assert.strictEqual(agyRes.reasonCode, 'cli-not-found');
|
|
549
|
+
assert.ok(
|
|
550
|
+
!fs.existsSync(path.join(codexOnlyPluginDir, '.antigravity-plugin', 'plugin.json')),
|
|
551
|
+
'No AGY manifest should be installed into Codex-only project'
|
|
552
|
+
);
|
|
553
|
+
|
|
554
|
+
fs.rmSync(projectTemp, { recursive: true, force: true });
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// AGY sync acceptance: partial/corrupted target dir without plugin.json is replaced cleanly
|
|
558
|
+
{
|
|
559
|
+
const partialTemp = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-agy-partial-'));
|
|
560
|
+
const target = path.join(partialTemp, 'plugins', 'harness-everything');
|
|
561
|
+
fs.mkdirSync(target, { recursive: true });
|
|
562
|
+
const brokenMarker = path.join(target, 'corrupted-partial.tmp');
|
|
563
|
+
fs.writeFileSync(brokenMarker, 'incomplete install', 'utf8');
|
|
564
|
+
|
|
565
|
+
const repairResult = sync({ host: 'agy', agyTarget: target }, {
|
|
566
|
+
commandAvailable: () => true,
|
|
567
|
+
log: () => {},
|
|
568
|
+
warn: () => {}
|
|
569
|
+
});
|
|
570
|
+
assert.strictEqual(repairResult.failed, 0, `Partial dir replacement must not fail: ${JSON.stringify(repairResult)}`);
|
|
571
|
+
assert.strictEqual(repairResult.results[0].status, 'synchronized');
|
|
572
|
+
assert.strictEqual(repairResult.results[0].action, 'install');
|
|
573
|
+
assert.ok(!fs.existsSync(brokenMarker), 'Corrupted leftover file must be removed');
|
|
574
|
+
assert.ok(fs.existsSync(path.join(target, '.antigravity-plugin', 'plugin.json')), 'Valid AGY manifest must be installed');
|
|
575
|
+
|
|
576
|
+
fs.rmSync(partialTemp, { recursive: true, force: true });
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// AGY sync acceptance: atomic refresh removes obsolete files
|
|
580
|
+
{
|
|
581
|
+
const agyTemp = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-agy-update-'));
|
|
582
|
+
const target = path.join(agyTemp, 'plugins', 'harness-everything');
|
|
583
|
+
|
|
584
|
+
// Initial install
|
|
585
|
+
sync({ host: 'agy', agyTarget: target }, {
|
|
586
|
+
commandAvailable: () => true,
|
|
587
|
+
log: () => {},
|
|
588
|
+
warn: () => {}
|
|
589
|
+
});
|
|
590
|
+
assert.ok(fs.existsSync(path.join(target, 'plugin.json')));
|
|
591
|
+
|
|
592
|
+
// Add an obsolete file
|
|
593
|
+
const obsoleteFile = path.join(target, 'obsolete-leftover.txt');
|
|
594
|
+
fs.writeFileSync(obsoleteFile, 'legacy content', 'utf8');
|
|
595
|
+
assert.ok(fs.existsSync(obsoleteFile));
|
|
596
|
+
|
|
597
|
+
// Run update
|
|
598
|
+
const updateResult = sync({ host: 'agy', agyTarget: target }, {
|
|
599
|
+
commandAvailable: () => true,
|
|
600
|
+
log: () => {},
|
|
601
|
+
warn: () => {}
|
|
602
|
+
});
|
|
603
|
+
assert.strictEqual(updateResult.failed, 0);
|
|
604
|
+
assert.strictEqual(updateResult.results[0].action, 'update');
|
|
605
|
+
assert.ok(!fs.existsSync(obsoleteFile), 'Obsolete file must be removed on atomic refresh update');
|
|
606
|
+
|
|
607
|
+
fs.rmSync(agyTemp, { recursive: true, force: true });
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// AGY sync acceptance: simulated copy failure leaves previous valid install intact
|
|
611
|
+
{
|
|
612
|
+
const agyTemp = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-agy-rollback-'));
|
|
613
|
+
const target = path.join(agyTemp, 'plugins', 'harness-everything');
|
|
614
|
+
|
|
615
|
+
// Initial valid install
|
|
616
|
+
sync({ host: 'agy', agyTarget: target }, {
|
|
617
|
+
commandAvailable: () => true,
|
|
618
|
+
log: () => {},
|
|
619
|
+
warn: () => {}
|
|
620
|
+
});
|
|
621
|
+
assert.ok(fs.existsSync(path.join(target, 'plugin.json')));
|
|
622
|
+
const markerFile = path.join(target, 'valid-install.txt');
|
|
623
|
+
fs.writeFileSync(markerFile, 'pre-existing valid state', 'utf8');
|
|
624
|
+
|
|
625
|
+
// Simulate copy failure
|
|
626
|
+
const originalCpSync = fs.cpSync;
|
|
627
|
+
let simulatedFailureTriggered = false;
|
|
628
|
+
fs.cpSync = (src, dest, opts) => {
|
|
629
|
+
if (typeof dest === 'string' && dest.includes(target) && dest.includes('.tmp')) {
|
|
630
|
+
simulatedFailureTriggered = true;
|
|
631
|
+
throw new Error('Simulated disk full or copy interruption');
|
|
632
|
+
}
|
|
633
|
+
return originalCpSync(src, dest, opts);
|
|
634
|
+
};
|
|
635
|
+
|
|
636
|
+
try {
|
|
637
|
+
const failResult = sync({ host: 'agy', agyTarget: target }, {
|
|
638
|
+
commandAvailable: () => true,
|
|
639
|
+
log: () => {},
|
|
640
|
+
warn: () => {}
|
|
641
|
+
});
|
|
642
|
+
assert.strictEqual(failResult.failed, 1);
|
|
643
|
+
assert.strictEqual(failResult.results[0].status, 'failed');
|
|
644
|
+
} finally {
|
|
645
|
+
fs.cpSync = originalCpSync;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
assert.ok(simulatedFailureTriggered, 'Simulated failure must have triggered');
|
|
649
|
+
assert.ok(fs.existsSync(markerFile), 'Previous valid install must remain intact after copy failure');
|
|
650
|
+
assert.strictEqual(fs.readFileSync(markerFile, 'utf8'), 'pre-existing valid state');
|
|
651
|
+
|
|
652
|
+
fs.rmSync(agyTemp, { recursive: true, force: true });
|
|
653
|
+
}
|
|
654
|
+
|
|
422
655
|
// resolveOnPath() is pure filesystem logic (platform choice happens only at
|
|
423
656
|
// the defaultRunner call site), so its directory-order-first contract runs
|
|
424
657
|
// on every CI OS, not only Windows.
|