harness-everything 0.55.2 → 0.55.3
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/CHANGELOG.md +9 -0
- package/ci/invariant-routing.test.js +6 -1
- package/ci/mechanism-397-opencode-observations.test.js +58 -2
- package/ci/mechanism-check-packet-write-set.test.js +163 -8
- package/ci/router-workflow-plan.test.js +8 -8
- package/code-review/SKILL.md +1 -1
- package/code-review/templates/finding.template.md +17 -1
- package/docs/platform-capabilities.md +2 -1
- package/opencode-plugin/README.md +6 -0
- package/opencode-plugin/index.mjs +31 -12
- package/opencode-plugin/plugin.json +1 -1
- package/package.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/skills/code-review/SKILL.md +1 -1
- package/plugins/harness-everything/skills/code-review/templates/finding.template.md +17 -1
- package/sbom.cdx.json +7 -7
- package/scripts/check-packet-write-set.js +76 -1
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"name": "harness-everything",
|
|
11
11
|
"source": "./",
|
|
12
12
|
"description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
|
|
13
|
-
"version": "0.55.
|
|
13
|
+
"version": "0.55.3",
|
|
14
14
|
"author": {
|
|
15
15
|
"name": "Miya Daniel"
|
|
16
16
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "harness-everything",
|
|
3
3
|
"description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
|
|
4
|
-
"version": "0.55.
|
|
4
|
+
"version": "0.55.3",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Miya Daniel"
|
|
7
7
|
},
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.55.3](https://github.com/dyphn1/Harness-everything/compare/v0.55.2...v0.55.3) (2026-11-20)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* address four bounded Harness regressions ([fb27a44](https://github.com/dyphn1/Harness-everything/commit/fb27a4478890848038bec61d8c549ac9bc4eb4e6)), closes [#413](https://github.com/dyphn1/Harness-everything/issues/413) [#469](https://github.com/dyphn1/Harness-everything/issues/469) [#470](https://github.com/dyphn1/Harness-everything/issues/470) [#451](https://github.com/dyphn1/Harness-everything/issues/451)
|
|
10
|
+
* batch sparse checkout rule checks ([eb3bfa0](https://github.com/dyphn1/Harness-everything/commit/eb3bfa08f68d1514efc23528194ec958556e7361))
|
|
11
|
+
* distinguish in-cone sparse deletions ([ec602ab](https://github.com/dyphn1/Harness-everything/commit/ec602ab7b6c3c8eecf36c5fcb2b78341dac20718))
|
|
12
|
+
* encode sparse path checks with NUL delimiters ([d52d63f](https://github.com/dyphn1/Harness-everything/commit/d52d63f31991d15482a7e5877d1b5b319667fce3))
|
|
13
|
+
|
|
5
14
|
## [0.55.2](https://github.com/dyphn1/Harness-everything/compare/v0.55.1...v0.55.2) (2026-11-20)
|
|
6
15
|
|
|
7
16
|
### Bug Fixes
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
const fs=require('fs'),path=require('path'),{spawnSync:spawnNodeSync}=require('child_process');
|
|
4
4
|
function spawnSync(command,args,options={}){
|
|
5
5
|
const {systemOneMode='off',...spawnOptions}=options;
|
|
6
|
-
|
|
6
|
+
const inheritedEnv = Object.fromEntries(Object.entries(process.env)
|
|
7
|
+
.filter(([key]) => !key.toUpperCase().startsWith('HARNESS_')));
|
|
8
|
+
return spawnNodeSync(command, args, {
|
|
9
|
+
...spawnOptions,
|
|
10
|
+
env: { ...inheritedEnv, ...spawnOptions.env, HARNESS_SYSTEM_ONE_MODE: systemOneMode },
|
|
11
|
+
});
|
|
7
12
|
}
|
|
8
13
|
const ROOT=path.resolve(__dirname,'..');let failed=0;
|
|
9
14
|
function check(c,m){if(c)console.log(' PASS '+m);else{console.error(' FAIL '+m);failed++;}}
|
|
@@ -148,8 +148,8 @@ function fixture(observationMode = 'on') {
|
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
async function install(f) {
|
|
152
|
-
const mod = await import(pathToFileURL(
|
|
151
|
+
async function install(f, plugin = PLUGIN) {
|
|
152
|
+
const mod = await import(pathToFileURL(plugin).href);
|
|
153
153
|
return mod.default.setup(f.ctx);
|
|
154
154
|
}
|
|
155
155
|
|
|
@@ -286,6 +286,8 @@ test('inject: the documented OpenCode hooks deliver the kernel router output and
|
|
|
286
286
|
test('runtime: a non-Node host binary still runs the router on Node and injects its output', { concurrency: false }, async () => {
|
|
287
287
|
const f = fixture();
|
|
288
288
|
let dispose;
|
|
289
|
+
const warnings = [];
|
|
290
|
+
const originalWarn = console.warn;
|
|
289
291
|
const originalExecPath = process.execPath;
|
|
290
292
|
const hadBun = Object.hasOwn(process.versions, 'bun');
|
|
291
293
|
const originalBun = process.versions.bun;
|
|
@@ -299,16 +301,20 @@ test('runtime: a non-Node host binary still runs the router on Node and injects
|
|
|
299
301
|
fs.writeFileSync(stubRuntime, process.platform === 'win32' ? '@exit /b 1\r\n' : '#!/bin/sh\nexit 1\n', { mode: 0o755 });
|
|
300
302
|
Object.defineProperty(process, 'execPath', { value: stubRuntime, configurable: true, writable: true });
|
|
301
303
|
Object.defineProperty(process.versions, 'bun', { value: '1.2.0', configurable: true });
|
|
304
|
+
console.warn = message => warnings.push(String(message));
|
|
302
305
|
|
|
303
306
|
dispose = await install(f);
|
|
307
|
+
assert.deepEqual(warnings, [], 'setup without traffic produces no warnings');
|
|
304
308
|
const prompt = { sessionID: 'runtime-session', messageID: 'runtime-turn', prompt: { text: 'add a small behavior change' } };
|
|
305
309
|
await f.sessionHooks.get('prompt')(prompt);
|
|
306
310
|
const context = { sessionID: 'runtime-session', kind: 'primary', system: [], messages: [] };
|
|
307
311
|
await f.sessionHooks.get('context')(context);
|
|
308
312
|
const injected = context.system.map(part => part.text || '').join('\n');
|
|
309
313
|
assert.match(injected, /=> ROUTER WORKFLOW PLAN/, 'the router ran on Node despite a non-Node host binary');
|
|
314
|
+
assert.deepEqual(warnings, []);
|
|
310
315
|
} finally {
|
|
311
316
|
if (dispose) await dispose();
|
|
317
|
+
console.warn = originalWarn;
|
|
312
318
|
Object.defineProperty(process, 'execPath', { value: originalExecPath, configurable: true, writable: true });
|
|
313
319
|
if (hadBun) Object.defineProperty(process.versions, 'bun', { value: originalBun, configurable: true });
|
|
314
320
|
else delete process.versions.bun;
|
|
@@ -316,6 +322,56 @@ test('runtime: a non-Node host binary still runs the router on Node and injects
|
|
|
316
322
|
}
|
|
317
323
|
});
|
|
318
324
|
|
|
325
|
+
for (const reason of ['spawn-failed', 'runtime-failed', 'runtime-missing']) {
|
|
326
|
+
test(`runtime: ${reason} warns without prompt content and admits the prompt`, async () => {
|
|
327
|
+
const f = fixture('off');
|
|
328
|
+
const originalExecPath = process.execPath;
|
|
329
|
+
const originalWarn = console.warn;
|
|
330
|
+
const warnings = [];
|
|
331
|
+
let dispose;
|
|
332
|
+
try {
|
|
333
|
+
let plugin = PLUGIN;
|
|
334
|
+
if (reason === 'spawn-failed') {
|
|
335
|
+
// Exercise the same ENOENT as a missing Node on PATH, including on
|
|
336
|
+
// Windows where executable lookup can also use the host directory.
|
|
337
|
+
Object.defineProperty(process, 'execPath', {
|
|
338
|
+
value: path.join(f.dir, 'missing-node'), configurable: true, writable: true,
|
|
339
|
+
});
|
|
340
|
+
} else {
|
|
341
|
+
plugin = path.join(f.dir, 'opencode-plugin', 'index.mjs');
|
|
342
|
+
fs.mkdirSync(path.dirname(plugin));
|
|
343
|
+
fs.copyFileSync(PLUGIN, plugin);
|
|
344
|
+
if (reason === 'runtime-failed') {
|
|
345
|
+
const router = path.join(f.dir, 'harness-everything/scripts/kernel-router.js');
|
|
346
|
+
const observationsFile = path.join(f.dir, 'hooks/scripts/lib/observations.js');
|
|
347
|
+
fs.mkdirSync(path.dirname(router), { recursive: true });
|
|
348
|
+
fs.mkdirSync(path.dirname(observationsFile), { recursive: true });
|
|
349
|
+
fs.writeFileSync(router, "console.log('PRIVATE-ROUTER-OUTPUT'); require('./missing-router-runtime');\n");
|
|
350
|
+
fs.writeFileSync(observationsFile, 'module.exports = { enabled: () => false };\n');
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
console.warn = message => warnings.push(String(message));
|
|
354
|
+
dispose = await install(f, plugin);
|
|
355
|
+
assert.deepEqual(warnings, []);
|
|
356
|
+
for (const count of [1, 2]) {
|
|
357
|
+
const sessionID = 'private-router-failure-session';
|
|
358
|
+
const prompt = { sessionID, messageID: `private-turn-${count}`, prompt: { text: 'private prompt text' } };
|
|
359
|
+
await assert.doesNotReject(() => f.sessionHooks.get('prompt')(prompt));
|
|
360
|
+
const context = { sessionID, kind: 'primary', system: [], messages: [] };
|
|
361
|
+
await f.sessionHooks.get('context')(context);
|
|
362
|
+
assert.deepEqual(context.system, [], 'failed output is never injected');
|
|
363
|
+
assert.equal(warnings.length, count);
|
|
364
|
+
assert.equal(warnings.at(-1), `[Harness] OpenCode router-unavailable (${reason}; count=${count})`);
|
|
365
|
+
}
|
|
366
|
+
} finally {
|
|
367
|
+
if (dispose) await dispose();
|
|
368
|
+
console.warn = originalWarn;
|
|
369
|
+
Object.defineProperty(process, 'execPath', { value: originalExecPath, configurable: true, writable: true });
|
|
370
|
+
f.restore();
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
|
|
319
375
|
test('record: OpenCode prompt, tool and idle events append one host-tagged record to the shared store', { concurrency: false }, async () => {
|
|
320
376
|
const f = fixture();
|
|
321
377
|
let dispose;
|
|
@@ -81,7 +81,7 @@ function makeRepo(t) {
|
|
|
81
81
|
return { repo, tempRoot };
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
function runChecker(repo, tempRoot, { base, head, allow = [], allowFile } = {}) {
|
|
84
|
+
function runChecker(repo, tempRoot, { base, head, allow = [], allowFile } = {}, extraEnv = {}) {
|
|
85
85
|
const args = [CHECKER_SOURCE, '--base', base];
|
|
86
86
|
if (head) args.push('--head', head);
|
|
87
87
|
for (const pattern of allow) args.push('--allow', pattern);
|
|
@@ -89,12 +89,48 @@ function runChecker(repo, tempRoot, { base, head, allow = [], allowFile } = {})
|
|
|
89
89
|
const result = spawnSync(process.execPath, args, {
|
|
90
90
|
cwd: repo,
|
|
91
91
|
encoding: 'utf8',
|
|
92
|
-
env: gitEnv(tempRoot),
|
|
92
|
+
env: { ...gitEnv(tempRoot), ...extraEnv },
|
|
93
93
|
});
|
|
94
94
|
assert.equal(result.error, undefined, result.error && result.error.message);
|
|
95
95
|
return result;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
function sparseRuleCounter(tempRoot, { fail = false } = {}) {
|
|
99
|
+
const directory = path.join(tempRoot, 'git counter');
|
|
100
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
101
|
+
const log = path.join(directory, 'check-rules calls');
|
|
102
|
+
const realGit = execFileSync('which', ['git'], { encoding: 'utf8' }).trim();
|
|
103
|
+
const wrapper = path.join(directory, 'git');
|
|
104
|
+
fs.writeFileSync(wrapper, [
|
|
105
|
+
'#!/usr/bin/env node',
|
|
106
|
+
"'use strict';",
|
|
107
|
+
"const fs = require('node:fs');",
|
|
108
|
+
"const { spawnSync } = require('node:child_process');",
|
|
109
|
+
`const realGit = ${JSON.stringify(realGit)};`,
|
|
110
|
+
'const args = process.argv.slice(2);',
|
|
111
|
+
"const checkRules = args.includes('sparse-checkout') && args.includes('check-rules');",
|
|
112
|
+
'if (checkRules) {',
|
|
113
|
+
" if (process.env.WRITE_SET_FAIL_CHECK_RULES === '1') {",
|
|
114
|
+
" process.stderr.write('injected check-rules failure\\n');",
|
|
115
|
+
' process.exit(1);',
|
|
116
|
+
' }',
|
|
117
|
+
" fs.appendFileSync(process.env.WRITE_SET_CHECK_RULES_LOG, 'x');",
|
|
118
|
+
'}',
|
|
119
|
+
"const child = spawnSync(realGit, args, { stdio: 'inherit' });",
|
|
120
|
+
"if (child.error) { console.error(child.error.message); process.exitCode = 1; }",
|
|
121
|
+
'else process.exitCode = child.status ?? 1;',
|
|
122
|
+
'',
|
|
123
|
+
].join('\n'), { mode: 0o755 });
|
|
124
|
+
return {
|
|
125
|
+
env: {
|
|
126
|
+
PATH: `${directory}${path.delimiter}${process.env.PATH}`,
|
|
127
|
+
WRITE_SET_CHECK_RULES_LOG: log,
|
|
128
|
+
WRITE_SET_FAIL_CHECK_RULES: fail ? '1' : '0',
|
|
129
|
+
},
|
|
130
|
+
count: () => fs.existsSync(log) ? fs.readFileSync(log, 'utf8').length : 0,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
98
134
|
function outOfSetPaths(result) {
|
|
99
135
|
return result.stdout.split(/\r?\n/).filter(line => line.startsWith('OUT_OF_SET '))
|
|
100
136
|
.map(line => JSON.parse(line.slice('OUT_OF_SET '.length)));
|
|
@@ -217,13 +253,132 @@ test('compares only the requested commits when --head is not the worktree HEAD',
|
|
|
217
253
|
const head = commitAll(repo, tempRoot, 'requested head');
|
|
218
254
|
write(repo, 'later.txt', 'after requested head\n');
|
|
219
255
|
commitAll(repo, tempRoot, 'worktree HEAD');
|
|
220
|
-
|
|
256
|
+
runGit(repo, tempRoot, ['update-index', '--assume-unchanged', '--', 'base.txt']);
|
|
257
|
+
try {
|
|
258
|
+
write(repo, 'base.txt', 'hidden workspace-only change\n');
|
|
259
|
+
write(repo, 'dirty.txt', 'uncommitted\n');
|
|
221
260
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
261
|
+
const result = runChecker(repo, tempRoot, { base, head, allow: ['allowed.txt'] });
|
|
262
|
+
assert.equal(result.status, 0, result.stderr);
|
|
263
|
+
assert.deepEqual(outOfSetPaths(result), []);
|
|
264
|
+
assert.match(result.stdout, /commits only/i);
|
|
265
|
+
assert.doesNotMatch(result.stdout, /base\.txt|later\.txt|dirty\.txt/);
|
|
266
|
+
} finally {
|
|
267
|
+
runGit(repo, tempRoot, ['update-index', '--no-assume-unchanged', '--', 'base.txt']);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
test('batches sparse-rule checks and distinguishes hidden deletions from omissions', { skip: process.platform === 'win32' }, t => {
|
|
272
|
+
const { repo, tempRoot } = makeRepo(t);
|
|
273
|
+
const includedPath = 'included/tracked\nname.txt';
|
|
274
|
+
const omittedPaths = ['omitted/space name.txt', 'omitted/new\nline.txt'];
|
|
275
|
+
write(repo, includedPath, 'inside sparse cone\n');
|
|
276
|
+
for (const file of omittedPaths) write(repo, file, `outside sparse cone: ${file}\n`);
|
|
277
|
+
const base = commitAll(repo, tempRoot, 'baseline');
|
|
278
|
+
write(repo, 'later.txt', 'committed after the requested head\n');
|
|
279
|
+
commitAll(repo, tempRoot, 'later commit');
|
|
280
|
+
|
|
281
|
+
runGit(repo, tempRoot, ['sparse-checkout', 'set', 'included']);
|
|
282
|
+
for (const file of omittedPaths) assert.equal(fs.existsSync(path.join(repo, ...file.split('/'))), false, `${file} is outside the sparse cone`);
|
|
283
|
+
runGit(repo, tempRoot, ['update-index', '--skip-worktree', '--', includedPath]);
|
|
284
|
+
fs.rmSync(path.join(repo, ...includedPath.split('/')));
|
|
285
|
+
assert.equal(gitText(repo, tempRoot, 'status', '--porcelain'), '', 'Git hides the in-cone deletion');
|
|
286
|
+
|
|
287
|
+
const counter = sparseRuleCounter(tempRoot);
|
|
288
|
+
const before = snapshotTree(repo);
|
|
289
|
+
const result = runChecker(repo, tempRoot, { base, allow: ['later.txt'] }, counter.env);
|
|
290
|
+
assert.equal(result.status, 1, result.stderr);
|
|
291
|
+
assert.deepEqual(outOfSetPaths(result), [includedPath]);
|
|
292
|
+
for (const file of omittedPaths) assert.ok(!result.stdout.includes(JSON.stringify(file)), `${file} is not reported`);
|
|
293
|
+
assert.equal(counter.count(), 1, 'all sparse candidates use one check-rules subprocess');
|
|
294
|
+
assert.deepEqual(snapshotTree(repo), before, 'inspection preserves the index flags and repository state');
|
|
295
|
+
|
|
296
|
+
const allowed = runChecker(repo, tempRoot, { base, head: 'HEAD', allow: [includedPath, 'later.txt'] }, counter.env);
|
|
297
|
+
assert.equal(allowed.status, 0, allowed.stderr);
|
|
298
|
+
assert.ok(allowed.stdout.includes(`ALLOWED ${JSON.stringify(includedPath)}`));
|
|
299
|
+
assert.equal(counter.count(), 2, 'the second candidate batch also uses one subprocess');
|
|
300
|
+
assert.deepEqual(snapshotTree(repo), before, 'allowed inspection preserves the index flags and repository state');
|
|
301
|
+
|
|
302
|
+
const historical = runChecker(repo, tempRoot, { base, head: base, allow: ['later.txt'] }, counter.env);
|
|
303
|
+
assert.equal(historical.status, 0, historical.stderr);
|
|
304
|
+
assert.match(historical.stdout, /commits only/);
|
|
305
|
+
assert.equal(counter.count(), 2, 'a non-current --head does not inspect sparse worktree paths');
|
|
306
|
+
|
|
307
|
+
const cleanFixture = makeRepo(t);
|
|
308
|
+
write(cleanFixture.repo, 'included/only.txt', 'present\n');
|
|
309
|
+
const cleanBase = commitAll(cleanFixture.repo, cleanFixture.tempRoot, 'baseline');
|
|
310
|
+
runGit(cleanFixture.repo, cleanFixture.tempRoot, ['sparse-checkout', 'set', 'included']);
|
|
311
|
+
const cleanCounter = sparseRuleCounter(cleanFixture.tempRoot);
|
|
312
|
+
const clean = runChecker(cleanFixture.repo, cleanFixture.tempRoot, { base: cleanBase, allow: ['included/**'] }, cleanCounter.env);
|
|
313
|
+
assert.equal(clean.status, 0, clean.stderr);
|
|
314
|
+
assert.equal(cleanCounter.count(), 0, 'no sparse-rule process is needed without missing skip-worktree paths');
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
test('fails closed when batched sparse-rule inspection fails', { skip: process.platform === 'win32' }, t => {
|
|
318
|
+
const { repo, tempRoot } = makeRepo(t);
|
|
319
|
+
write(repo, 'included/deleted.txt', 'inside sparse cone\n');
|
|
320
|
+
write(repo, 'omitted/hidden.txt', 'outside sparse cone\n');
|
|
321
|
+
const base = commitAll(repo, tempRoot, 'baseline');
|
|
322
|
+
runGit(repo, tempRoot, ['sparse-checkout', 'set', 'included']);
|
|
323
|
+
runGit(repo, tempRoot, ['update-index', '--skip-worktree', '--', 'included/deleted.txt']);
|
|
324
|
+
fs.rmSync(path.join(repo, 'included', 'deleted.txt'));
|
|
325
|
+
assert.equal(gitText(repo, tempRoot, 'status', '--porcelain'), '');
|
|
326
|
+
const before = snapshotTree(repo);
|
|
327
|
+
|
|
328
|
+
const counter = sparseRuleCounter(tempRoot, { fail: true });
|
|
329
|
+
const result = runChecker(repo, tempRoot, { base, allow: ['allowed/**'] }, counter.env);
|
|
330
|
+
assert.equal(result.status, 2, result.stdout);
|
|
331
|
+
assert.match(result.stderr, /git sparse-checkout failed/);
|
|
332
|
+
assert.equal(counter.count(), 0, 'the injected failing inspection is not recorded as a successful invocation');
|
|
333
|
+
assert.deepEqual(snapshotTree(repo), before, 'failed inspection does not mutate the index or worktree');
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
for (const flag of ['assume-unchanged', 'skip-worktree']) {
|
|
337
|
+
test(`checks actual worktree content hidden by --${flag}`, t => {
|
|
338
|
+
const { repo, tempRoot } = makeRepo(t);
|
|
339
|
+
const file = process.platform === 'win32' ? 'hidden [file].txt' : 'hidden [file]\nname.txt';
|
|
340
|
+
write(repo, file, 'before\n');
|
|
341
|
+
const base = commitAll(repo, tempRoot, 'baseline');
|
|
342
|
+
runGit(repo, tempRoot, ['update-index', `--${flag}`, '--', file]);
|
|
343
|
+
try {
|
|
344
|
+
const clean = runChecker(repo, tempRoot, { base, allow: ['allowed/**'] });
|
|
345
|
+
assert.equal(clean.status, 0, clean.stderr);
|
|
346
|
+
assert.equal(clean.stdout, '');
|
|
347
|
+
|
|
348
|
+
write(repo, file, 'after!\n');
|
|
349
|
+
assert.equal(gitText(repo, tempRoot, 'status', '--porcelain'), '', 'Git hides the edit');
|
|
350
|
+
const before = snapshotTree(repo);
|
|
351
|
+
const rejected = runChecker(repo, tempRoot, { base, allow: ['allowed/**'] });
|
|
352
|
+
assert.equal(rejected.status, 1, rejected.stderr);
|
|
353
|
+
assert.deepEqual(outOfSetPaths(rejected), [file]);
|
|
354
|
+
|
|
355
|
+
const allowed = runChecker(repo, tempRoot, { base, head: 'HEAD', allow: [file] });
|
|
356
|
+
assert.equal(allowed.status, 0, allowed.stderr);
|
|
357
|
+
assert.ok(allowed.stdout.includes(`ALLOWED ${JSON.stringify(file)}`));
|
|
358
|
+
assert.deepEqual(snapshotTree(repo), before, 'inspection preserves the index flags');
|
|
359
|
+
} finally {
|
|
360
|
+
runGit(repo, tempRoot, ['update-index', `--no-${flag}`, '--', file]);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
test('reports a flagged-file inspection error when Git cannot clean its content', t => {
|
|
366
|
+
const { repo, tempRoot } = makeRepo(t);
|
|
367
|
+
const file = 'hidden.txt';
|
|
368
|
+
write(repo, '.gitattributes', 'hidden.txt filter=broken\n');
|
|
369
|
+
write(repo, file, 'tracked\n');
|
|
370
|
+
const base = commitAll(repo, tempRoot, 'baseline');
|
|
371
|
+
runGit(repo, tempRoot, ['update-index', '--assume-unchanged', '--', file]);
|
|
372
|
+
try {
|
|
373
|
+
runGit(repo, tempRoot, ['config', 'filter.broken.clean', 'exit 1']);
|
|
374
|
+
runGit(repo, tempRoot, ['config', 'filter.broken.required', 'true']);
|
|
375
|
+
const result = runChecker(repo, tempRoot, { base, allow: ['allowed/**'] });
|
|
376
|
+
assert.equal(result.status, 2, result.stderr);
|
|
377
|
+
assert.match(result.stderr, /git hash-object failed/);
|
|
378
|
+
} finally {
|
|
379
|
+
runGit(repo, tempRoot, ['config', '--remove-section', 'filter.broken']);
|
|
380
|
+
runGit(repo, tempRoot, ['update-index', '--no-assume-unchanged', '--', file]);
|
|
381
|
+
}
|
|
227
382
|
});
|
|
228
383
|
|
|
229
384
|
test('returns usage errors for an unknown base and a missing allow list', t => {
|
|
@@ -7,10 +7,12 @@ const { spawnSync: spawnNodeSync } = require('child_process');
|
|
|
7
7
|
|
|
8
8
|
function spawnSync(command, args, options = {}) {
|
|
9
9
|
const { systemOneMode = 'off', ...spawnOptions } = options;
|
|
10
|
+
const inheritedEnv = Object.fromEntries(Object.entries(process.env)
|
|
11
|
+
.filter(([key]) => !key.toUpperCase().startsWith('HARNESS_')));
|
|
10
12
|
return spawnNodeSync(command, args, {
|
|
11
13
|
...spawnOptions,
|
|
12
14
|
env: {
|
|
13
|
-
...
|
|
15
|
+
...inheritedEnv,
|
|
14
16
|
...(spawnOptions.env || {}),
|
|
15
17
|
HARNESS_SYSTEM_ONE_MODE: systemOneMode,
|
|
16
18
|
},
|
|
@@ -65,7 +67,6 @@ function runTier(prompt, options = {}) {
|
|
|
65
67
|
encoding: 'utf8',
|
|
66
68
|
input: context ? JSON.stringify({ ...context, prompt }) : undefined,
|
|
67
69
|
env: {
|
|
68
|
-
...process.env,
|
|
69
70
|
...(options.env || {}),
|
|
70
71
|
HARNESS_ROUTER_CONTRACT_PATH: contractPath,
|
|
71
72
|
},
|
|
@@ -488,7 +489,7 @@ const kernelNotificationPersistFailure = spawnSync(process.execPath, [kernelRout
|
|
|
488
489
|
hook_event_name: 'UserPromptSubmit',
|
|
489
490
|
prompt: '<task-notification><task-id>background-1</task-id><status>completed</status></task-notification>',
|
|
490
491
|
}),
|
|
491
|
-
env: {
|
|
492
|
+
env: { HARNESS_STATE_HOME: notificationStateFile, HARNESS_WORKSPACE_ROOT: ROOT },
|
|
492
493
|
});
|
|
493
494
|
check(kernelNotificationPersistFailure.status === 0, 'host notification persistence failure stays fail-open');
|
|
494
495
|
check(kernelNotificationPersistFailure.stdout.includes('Host notification: no active execution contract; ignored for routing.'), 'host notification remains a routing no-op when state persistence fails');
|
|
@@ -510,18 +511,17 @@ check(!kernelIterative.stdout.includes('evaluate-suggestions-before-skip'), 'leg
|
|
|
510
511
|
|
|
511
512
|
const retainedStateHome = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-router-retained-step-'));
|
|
512
513
|
const retainedSession = 'issue297-retained-step';
|
|
513
|
-
const retainedEnv =
|
|
514
|
-
...process.env,
|
|
514
|
+
const retainedEnv = {
|
|
515
515
|
HARNESS_STATE_HOME: retainedStateHome,
|
|
516
516
|
HARNESS_WORKSPACE_ROOT: ROOT,
|
|
517
|
-
}
|
|
517
|
+
};
|
|
518
518
|
const retainedInput = prompt => JSON.stringify({ session_id: retainedSession, cwd: ROOT, hook_event_name: 'UserPromptSubmit', prompt });
|
|
519
|
-
const initialRetainedRoute = spawnSync(process.execPath, [kernelRouter], {
|
|
519
|
+
const initialRetainedRoute = withInheritedSystemOneLive(() => spawnSync(process.execPath, [kernelRouter], {
|
|
520
520
|
cwd: ROOT,
|
|
521
521
|
encoding: 'utf8',
|
|
522
522
|
input: retainedInput('Fix this checkout bug and add a regression test.'),
|
|
523
523
|
env: retainedEnv,
|
|
524
|
-
});
|
|
524
|
+
}));
|
|
525
525
|
check(initialRetainedRoute.status === 0, 'retained workflow fixture routes successfully');
|
|
526
526
|
check(!initialRetainedRoute.stdout.includes('SYSTEM ONE REFERENCE CONFIDENCE'), 'retained kernel route ignores inherited live mode');
|
|
527
527
|
check(initialRetainedRoute.stdout.includes('PLANNING STEP: decompose → compose'), 'new selected workflow exposes its planning step');
|
package/code-review/SKILL.md
CHANGED
|
@@ -9,9 +9,25 @@
|
|
|
9
9
|
- Prior rounds (findings per decision class, for re-review):
|
|
10
10
|
- Changed files and relevant callers/consumers:
|
|
11
11
|
- CI state and commands observed:
|
|
12
|
-
- Counterexample categories covered:
|
|
13
12
|
- Risks not examined / evidence limits:
|
|
14
13
|
|
|
14
|
+
### Counterexample categories covered
|
|
15
|
+
|
|
16
|
+
Derive the families from the scope anchor and the implementation's supported syntax. Include equivalent spellings or transformations and unknown syntax that could affect the scoped decision. Keep unverified families visible as `UNCHECKED`.
|
|
17
|
+
|
|
18
|
+
| family | representative / equivalent spelling | expected | actual per implementation | evidence tier or UNCHECKED |
|
|
19
|
+
| --- | --- | --- | --- | --- |
|
|
20
|
+
| <family from scope> | <representative inputs> | <expected decision> | <observed or source-traced decision, or blank> | <tier and evidence reference, or UNCHECKED> |
|
|
21
|
+
|
|
22
|
+
<!--
|
|
23
|
+
Illustrative example for a scope that treats inputs as literal strings (fictional contract and implementation):
|
|
24
|
+
|
|
25
|
+
| family | representative / equivalent spelling | expected | actual per implementation | evidence tier or UNCHECKED |
|
|
26
|
+
| --- | --- | --- | --- | --- |
|
|
27
|
+
| Repeated literal | `abc` compared with `abc` | Equal | Equal via the example implementation's `left === right` | source-traced (illustrative expression) |
|
|
28
|
+
| Unknown escape syntax | `\a` compared with `a` | Distinct literals | | UNCHECKED |
|
|
29
|
+
-->
|
|
30
|
+
|
|
15
31
|
## Findings
|
|
16
32
|
|
|
17
33
|
### [P1/P2/P3] <Short, specific title>
|
|
@@ -201,7 +201,8 @@ sessions whose directories matched setup; it establishes field availability,
|
|
|
201
201
|
not mismatch handling or V2 hook behavior ([trace notes](../benchmarks/results/live-host/opencode-2026-11-15-workspace/README.md)). The adapter itself has deterministic mechanism
|
|
202
202
|
coverage (`ci/mechanism-2n-opencode-plugin.test.js`, V1 shapes;
|
|
203
203
|
`ci/mechanism-2p-opencode-v2-entrypoint.test.js`, V2 lifecycle shapes;
|
|
204
|
-
`ci/mechanism-397-opencode-observations.test.js`, router injection,
|
|
204
|
+
`ci/mechanism-397-opencode-observations.test.js`, router injection, fail-open
|
|
205
|
+
router diagnostics on launch or runtime failure, turn capture,
|
|
205
206
|
malformed-label export counts and opt-out). The injection/capture path has
|
|
206
207
|
mechanism evidence only; no live-host hook-fire or mismatch-handling artifact
|
|
207
208
|
exists. Retained
|
|
@@ -121,6 +121,12 @@ enforcement logic is shared, not duplicated.
|
|
|
121
121
|
The prompt/context routing and System One observation hooks are V2-only. The
|
|
122
122
|
V1 factory keeps its existing enforcement hooks; it does not capture turns.
|
|
123
123
|
|
|
124
|
+
When OpenCode runs on Bun, its Harness router needs `node` on the OpenCode
|
|
125
|
+
process's `PATH`. Run `node --version` from the same environment that launches
|
|
126
|
+
OpenCode and check it against the [Harness Node.js baseline](../docs/repository-contract.md).
|
|
127
|
+
If the router cannot start or load, OpenCode still admits prompts and logs a
|
|
128
|
+
`router-unavailable` warning with a reason and per-plugin count.
|
|
129
|
+
|
|
124
130
|
Direction:
|
|
125
131
|
named factory (V1 hosts/tests) → default-export setup adapter → V2 domains.
|
|
126
132
|
|
|
@@ -89,11 +89,15 @@ function harnessRuntime() {
|
|
|
89
89
|
return process.versions.bun ? "node" : process.execPath
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
function runKernelRouter(payload, signal) {
|
|
93
|
-
if (
|
|
92
|
+
function runKernelRouter(payload, signal, unavailable) {
|
|
93
|
+
if (signal?.aborted) return Promise.resolve(null)
|
|
94
|
+
if (!ROUTER_FILE) {
|
|
95
|
+
unavailable("runtime-missing")
|
|
96
|
+
return Promise.resolve(null)
|
|
97
|
+
}
|
|
94
98
|
return new Promise(resolveOutput => {
|
|
95
99
|
let stdout = ""
|
|
96
|
-
let child, timeout, termination,
|
|
100
|
+
let child, timeout, termination, failureReason, timedOut = false, settled = false
|
|
97
101
|
const terminate = () => {
|
|
98
102
|
if (!termination && child) termination = terminateVerificationChild(child)
|
|
99
103
|
}
|
|
@@ -101,11 +105,19 @@ function runKernelRouter(payload, signal) {
|
|
|
101
105
|
if (settled) return
|
|
102
106
|
settled = true
|
|
103
107
|
clearTimeout(timeout)
|
|
104
|
-
signal?.removeEventListener("abort",
|
|
108
|
+
signal?.removeEventListener("abort", terminate)
|
|
105
109
|
if (termination) await termination
|
|
106
|
-
|
|
110
|
+
if (signal?.aborted || timedOut) {
|
|
111
|
+
resolveOutput(null)
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
if (failureReason || code !== 0) {
|
|
115
|
+
unavailable(failureReason || "runtime-failed")
|
|
116
|
+
resolveOutput(null)
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
resolveOutput(stdout.trim())
|
|
107
120
|
}
|
|
108
|
-
const abort = () => { cancelled = true; terminate() }
|
|
109
121
|
try {
|
|
110
122
|
child = spawn(harnessRuntime(), [ROUTER_FILE], {
|
|
111
123
|
cwd: payload.cwd || HARNESS_ROOT,
|
|
@@ -115,21 +127,22 @@ function runKernelRouter(payload, signal) {
|
|
|
115
127
|
windowsHide: true,
|
|
116
128
|
})
|
|
117
129
|
} catch {
|
|
130
|
+
unavailable("spawn-failed")
|
|
118
131
|
resolveOutput(null)
|
|
119
132
|
return
|
|
120
133
|
}
|
|
121
134
|
child.stdout.on("data", chunk => { stdout += chunk })
|
|
122
|
-
child.stdin.on("error", () => {
|
|
135
|
+
child.stdin.on("error", () => { failureReason ||= "runtime-failed"; terminate() })
|
|
123
136
|
child.once("error", () => {
|
|
124
|
-
|
|
137
|
+
failureReason = child.pid ? "runtime-failed" : "spawn-failed"
|
|
125
138
|
if (!child.pid) void finish(null)
|
|
126
139
|
else terminate()
|
|
127
140
|
})
|
|
128
141
|
child.once("close", code => { void finish(code) })
|
|
129
|
-
signal?.addEventListener("abort",
|
|
130
|
-
if (signal?.aborted)
|
|
142
|
+
signal?.addEventListener("abort", terminate, { once: true })
|
|
143
|
+
if (signal?.aborted) terminate()
|
|
131
144
|
timeout = setTimeout(() => { timedOut = true; terminate() }, 5000)
|
|
132
|
-
try { child.stdin.end(JSON.stringify(payload)) } catch {
|
|
145
|
+
try { child.stdin.end(JSON.stringify(payload)) } catch { failureReason ||= "runtime-failed"; terminate() }
|
|
133
146
|
})
|
|
134
147
|
}
|
|
135
148
|
|
|
@@ -1344,7 +1357,13 @@ export default {
|
|
|
1344
1357
|
return pending
|
|
1345
1358
|
}
|
|
1346
1359
|
let unresolvedIdentityCount = 0
|
|
1360
|
+
const routerUnavailableCounts = new Map()
|
|
1347
1361
|
|
|
1362
|
+
const routerUnavailable = reason => {
|
|
1363
|
+
const count = (routerUnavailableCounts.get(reason) || 0) + 1
|
|
1364
|
+
routerUnavailableCounts.set(reason, count)
|
|
1365
|
+
try { console.warn(`[Harness] OpenCode router-unavailable (${reason}; count=${count})`) } catch {}
|
|
1366
|
+
}
|
|
1348
1367
|
const unresolvedIdentity = reason => {
|
|
1349
1368
|
unresolvedIdentityCount++
|
|
1350
1369
|
try { console.warn(`[Harness] OpenCode session workspace unresolved (${reason}; count=${unresolvedIdentityCount}); workspace-dependent handling skipped.`) } catch {}
|
|
@@ -1483,7 +1502,7 @@ export default {
|
|
|
1483
1502
|
if (events.signal.aborted) return
|
|
1484
1503
|
const routerPayload = { host: "opencode", session_id: event.sessionID,
|
|
1485
1504
|
...(prompt.messageID ? { turn_id: prompt.messageID } : {}), cwd: prompt.workspace, prompt: event.prompt.text }
|
|
1486
|
-
const routerOutput = await runKernelRouter(routerPayload, events.signal)
|
|
1505
|
+
const routerOutput = await runKernelRouter(routerPayload, events.signal, routerUnavailable)
|
|
1487
1506
|
if (!events.signal.aborted && promptRoutes.get(event.sessionID) === prompt) prompt.routerOutput = routerOutput
|
|
1488
1507
|
})
|
|
1489
1508
|
await prompt.routerPromise
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
3
|
"name": "harness-everything",
|
|
4
|
-
"version": "0.55.
|
|
4
|
+
"version": "0.55.3",
|
|
5
5
|
"description": "Invariant-first engineering harness for routing, verification, and failure recovery while preserving agent autonomy.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Miya Daniel",
|
|
@@ -9,9 +9,25 @@
|
|
|
9
9
|
- Prior rounds (findings per decision class, for re-review):
|
|
10
10
|
- Changed files and relevant callers/consumers:
|
|
11
11
|
- CI state and commands observed:
|
|
12
|
-
- Counterexample categories covered:
|
|
13
12
|
- Risks not examined / evidence limits:
|
|
14
13
|
|
|
14
|
+
### Counterexample categories covered
|
|
15
|
+
|
|
16
|
+
Derive the families from the scope anchor and the implementation's supported syntax. Include equivalent spellings or transformations and unknown syntax that could affect the scoped decision. Keep unverified families visible as `UNCHECKED`.
|
|
17
|
+
|
|
18
|
+
| family | representative / equivalent spelling | expected | actual per implementation | evidence tier or UNCHECKED |
|
|
19
|
+
| --- | --- | --- | --- | --- |
|
|
20
|
+
| <family from scope> | <representative inputs> | <expected decision> | <observed or source-traced decision, or blank> | <tier and evidence reference, or UNCHECKED> |
|
|
21
|
+
|
|
22
|
+
<!--
|
|
23
|
+
Illustrative example for a scope that treats inputs as literal strings (fictional contract and implementation):
|
|
24
|
+
|
|
25
|
+
| family | representative / equivalent spelling | expected | actual per implementation | evidence tier or UNCHECKED |
|
|
26
|
+
| --- | --- | --- | --- | --- |
|
|
27
|
+
| Repeated literal | `abc` compared with `abc` | Equal | Equal via the example implementation's `left === right` | source-traced (illustrative expression) |
|
|
28
|
+
| Unknown escape syntax | `\a` compared with `a` | Distinct literals | | UNCHECKED |
|
|
29
|
+
-->
|
|
30
|
+
|
|
15
31
|
## Findings
|
|
16
32
|
|
|
17
33
|
### [P1/P2/P3] <Short, specific title>
|
package/sbom.cdx.json
CHANGED
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
"$schema": "https://cyclonedx.org/schema/bom-1.7.schema.json",
|
|
3
3
|
"bomFormat": "CycloneDX",
|
|
4
4
|
"specVersion": "1.7",
|
|
5
|
-
"serialNumber": "urn:uuid:
|
|
5
|
+
"serialNumber": "urn:uuid:357f2bfc-3684-5644-89c6-2434fe189716",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-11-
|
|
8
|
+
"timestamp": "2026-11-20T15:47:31.044Z",
|
|
9
9
|
"tools": [
|
|
10
10
|
{
|
|
11
11
|
"vendor": "Harness Everything",
|
|
12
12
|
"name": "generate-sbom.js",
|
|
13
|
-
"version": "0.55.
|
|
13
|
+
"version": "0.55.3"
|
|
14
14
|
}
|
|
15
15
|
],
|
|
16
16
|
"component": {
|
|
17
17
|
"type": "application",
|
|
18
|
-
"bom-ref": "pkg:npm/harness-everything@0.55.
|
|
18
|
+
"bom-ref": "pkg:npm/harness-everything@0.55.3",
|
|
19
19
|
"name": "harness-everything",
|
|
20
|
-
"version": "0.55.
|
|
21
|
-
"purl": "pkg:npm/harness-everything@0.55.
|
|
20
|
+
"version": "0.55.3",
|
|
21
|
+
"purl": "pkg:npm/harness-everything@0.55.3"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"components": [
|
|
@@ -2033,7 +2033,7 @@
|
|
|
2033
2033
|
]
|
|
2034
2034
|
},
|
|
2035
2035
|
{
|
|
2036
|
-
"ref": "pkg:npm/harness-everything@0.55.
|
|
2036
|
+
"ref": "pkg:npm/harness-everything@0.55.3",
|
|
2037
2037
|
"dependsOn": [
|
|
2038
2038
|
"pkg:npm/%40commitlint/cli@19.8.1",
|
|
2039
2039
|
"pkg:npm/%40commitlint/config-conventional@19.8.1",
|
|
@@ -32,7 +32,7 @@ function parseArgs(argv) {
|
|
|
32
32
|
return options;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
function git(args, cwd = process.cwd()) {
|
|
35
|
+
function git(args, cwd = process.cwd(), input) {
|
|
36
36
|
const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith('GIT_')));
|
|
37
37
|
if (process.env.GIT_CONFIG_GLOBAL !== undefined) env.GIT_CONFIG_GLOBAL = process.env.GIT_CONFIG_GLOBAL;
|
|
38
38
|
Object.assign(env, {
|
|
@@ -43,6 +43,7 @@ function git(args, cwd = process.cwd()) {
|
|
|
43
43
|
const result = spawnSync('git', ['-c', 'core.fsmonitor=false', '-c', 'core.untrackedCache=false', ...args], {
|
|
44
44
|
cwd,
|
|
45
45
|
encoding: null,
|
|
46
|
+
input,
|
|
46
47
|
shell: false,
|
|
47
48
|
env,
|
|
48
49
|
maxBuffer: 16 * 1024 * 1024,
|
|
@@ -110,6 +111,79 @@ function readAllowPatterns(options) {
|
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
|
|
114
|
+
function gitBooleanConfig(repo, key, fallback) {
|
|
115
|
+
const args = ['config', '--bool', '--get', key];
|
|
116
|
+
const result = git(args, repo);
|
|
117
|
+
if (result.status === 1 && !result.stderr.length) return fallback;
|
|
118
|
+
return pathsFrom(result, args)[0]?.trim() === 'true';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function sparseCheckoutIncludes(repo, files) {
|
|
122
|
+
const args = ['sparse-checkout', 'check-rules', '-z'];
|
|
123
|
+
const input = Buffer.from(`${files.join('\0')}\0`);
|
|
124
|
+
return new Set(pathsFrom(git(args, repo, input), args));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function flaggedWorkingTreeChanges(repo) {
|
|
128
|
+
const args = ['ls-files', '-v', '--stage', '-z'];
|
|
129
|
+
const changes = [];
|
|
130
|
+
const sparseRuleCandidates = [];
|
|
131
|
+
let sparseCheckout;
|
|
132
|
+
for (const entry of pathsFrom(git(args, repo), args)) {
|
|
133
|
+
// Lowercase tags mark assume-unchanged; S/s marks skip-worktree.
|
|
134
|
+
if (!/^[a-zS] /.test(entry)) continue;
|
|
135
|
+
const separator = entry.indexOf('\t');
|
|
136
|
+
const [tag, mode, oid, stage] = entry.slice(0, separator).split(' ');
|
|
137
|
+
if (stage !== '0') continue;
|
|
138
|
+
const file = entry.slice(separator + 1);
|
|
139
|
+
const absolute = path.join(repo, file);
|
|
140
|
+
const stat = fs.lstatSync(absolute, { throwIfNoEntry: false });
|
|
141
|
+
if (!stat) {
|
|
142
|
+
// Skip only paths excluded by the active sparse rules; an in-cone deletion
|
|
143
|
+
// can also carry the skip-worktree bit.
|
|
144
|
+
if (tag.toUpperCase() === 'S'
|
|
145
|
+
&& (sparseCheckout ??= gitBooleanConfig(repo, 'core.sparseCheckout', false))) {
|
|
146
|
+
sparseRuleCandidates.push(file);
|
|
147
|
+
} else {
|
|
148
|
+
changes.push(file);
|
|
149
|
+
}
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
let hashArgs;
|
|
154
|
+
let hashCwd = repo;
|
|
155
|
+
let input;
|
|
156
|
+
if (mode === '160000' && stat.isDirectory()) {
|
|
157
|
+
// An uninitialized submodule has no checked-out commit to compare.
|
|
158
|
+
if (!fs.lstatSync(path.join(absolute, '.git'), { throwIfNoEntry: false })) continue;
|
|
159
|
+
hashArgs = ['rev-parse', '--verify', 'HEAD'];
|
|
160
|
+
hashCwd = absolute;
|
|
161
|
+
} else if (mode === '120000' && stat.isSymbolicLink()) {
|
|
162
|
+
hashArgs = ['hash-object', '--stdin'];
|
|
163
|
+
input = fs.readlinkSync(absolute, { encoding: 'buffer' });
|
|
164
|
+
} else if (mode === '120000' && stat.isFile() && !gitBooleanConfig(repo, 'core.symlinks', true)) {
|
|
165
|
+
// Git can check out a symlink as a plain file containing its target.
|
|
166
|
+
hashArgs = ['hash-object', '--no-filters', '--', file];
|
|
167
|
+
} else if (mode.startsWith('100') && stat.isFile()) {
|
|
168
|
+
// Apply Git's clean filters just as when comparing normal tracked files.
|
|
169
|
+
hashArgs = ['hash-object', `--path=${file}`, '--', file];
|
|
170
|
+
} else {
|
|
171
|
+
changes.push(file);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const actual = pathsFrom(git(hashArgs, hashCwd, input), hashArgs)[0]?.trim();
|
|
175
|
+
if (!actual) throw new Error(`could not compare tracked path ${JSON.stringify(file)}`);
|
|
176
|
+
if (actual !== oid) changes.push(file);
|
|
177
|
+
}
|
|
178
|
+
if (sparseRuleCandidates.length) {
|
|
179
|
+
const included = sparseCheckoutIncludes(repo, sparseRuleCandidates);
|
|
180
|
+
for (const file of sparseRuleCandidates) {
|
|
181
|
+
if (included.has(file)) changes.push(file);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return changes;
|
|
185
|
+
}
|
|
186
|
+
|
|
113
187
|
function changedPaths(base, head, includeWorkingTree, repo) {
|
|
114
188
|
const paths = new Set();
|
|
115
189
|
const diffs = [['diff', '--no-ext-diff', '--no-textconv', '--no-renames', '--name-only', '-z', base, head]];
|
|
@@ -123,6 +197,7 @@ function changedPaths(base, head, includeWorkingTree, repo) {
|
|
|
123
197
|
if (includeWorkingTree) {
|
|
124
198
|
const untrackedArgs = ['ls-files', '--others', '--exclude-standard', '-z'];
|
|
125
199
|
for (const file of pathsFrom(git(untrackedArgs, repo), untrackedArgs)) paths.add(file);
|
|
200
|
+
for (const file of flaggedWorkingTreeChanges(repo)) paths.add(file);
|
|
126
201
|
}
|
|
127
202
|
return [...paths].sort();
|
|
128
203
|
}
|