harness-everything 0.57.3 → 0.58.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/CHANGELOG.md +15 -0
- 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/ci/action-gate.test.js +162 -0
- package/ci/doc-capability-consistency.test.js +11 -1
- package/ci/mechanism-2aa-codex-action-gate-policy.test.js +37 -0
- package/ci/mechanism-2ao-plugin-sync.test.js +235 -2
- package/ci/mechanism-2w-platform-compatibility.test.js +13 -2
- package/ci/mechanism-2x-release-automation.test.js +3 -1
- package/ci/mechanism-agy-hooks.test.js +1096 -0
- package/ci/mechanism-agy-plugin-package.test.js +76 -0
- package/docs/codex-action-gate.md +2 -0
- package/docs/platform-capabilities.md +3 -1
- package/docs/platform-compatibility.json +34 -1
- package/hooks/scripts/action-gate.js +71 -5
- 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/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/action-gate.js +71 -5
- 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 +111 -0
- package/sbom.cdx.json +7 -7
- package/scripts/plugin-sync.js +105 -14
- package/scripts/sync-openai-plugin.js +16 -1
- package/scripts/sync-release-version.js +1 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Antigravity (AGY) Stop Hook Adapter
|
|
6
|
+
*
|
|
7
|
+
* Implements the Verify-Before-Claim gate:
|
|
8
|
+
* - Inspects real session verification state (handoff-state.json in sessionDir).
|
|
9
|
+
* - If unverified edits exist or an unresolved tool failure exists, returns
|
|
10
|
+
* {"decision": "continue", "reason": "..."} to keep the agent in the loop.
|
|
11
|
+
* - If verified (or no unverified edits), returns {"decision": "allow"}.
|
|
12
|
+
* - Tracks the last continued state fingerprint in agy-stop-state.json so each
|
|
13
|
+
* unverified edit or failure triggers at most one forced continuation (preventing
|
|
14
|
+
* infinite loops on hosts that omit exitCode or continuationActive).
|
|
15
|
+
* - Respects compatibility recursion guards (continuationActive / stop_hook_active)
|
|
16
|
+
* to prevent infinite continuation loops, and allows stop on explicit abnormal
|
|
17
|
+
* terminationReason values (USER_CANCELED, ERROR, limits, etc.) while evaluating
|
|
18
|
+
* NO_TOOL_CALL, model_stop, and empty/normal reasons.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const fs = require('fs');
|
|
22
|
+
const path = require('path');
|
|
23
|
+
const {
|
|
24
|
+
readJsonStdin,
|
|
25
|
+
getAgySessionId,
|
|
26
|
+
normalizeAgyStatePayload
|
|
27
|
+
} = require('./lib/agy-adapter-core');
|
|
28
|
+
const { getWorkspaceRoot, getSessionDir } = require('./lib/harness-state');
|
|
29
|
+
|
|
30
|
+
const STOP_STATE_FILE = 'agy-stop-state.json';
|
|
31
|
+
|
|
32
|
+
function readStopState(filePath) {
|
|
33
|
+
try {
|
|
34
|
+
if (!fs.existsSync(filePath)) return null;
|
|
35
|
+
const parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
36
|
+
return parsed && typeof parsed === 'object' ? parsed : null;
|
|
37
|
+
} catch (_) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function writeStopState(filePath, state) {
|
|
43
|
+
try {
|
|
44
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
45
|
+
const temp = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
46
|
+
fs.writeFileSync(temp, JSON.stringify(state, null, 2) + '\n', 'utf8');
|
|
47
|
+
fs.renameSync(temp, filePath);
|
|
48
|
+
} catch (_) {
|
|
49
|
+
// Best-effort marker write; never fail stop evaluation on state IO.
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const ABNORMAL_TERMINATION_REASONS = new Set([
|
|
54
|
+
'USER_CANCELED',
|
|
55
|
+
'CANCELED',
|
|
56
|
+
'CANCELLED',
|
|
57
|
+
'ERROR',
|
|
58
|
+
'MAX_INVOCATIONS',
|
|
59
|
+
'MAX_STEPS_EXCEEDED',
|
|
60
|
+
'MAX_TOKEN_BUDGET_EXCEEDED',
|
|
61
|
+
'TERMINAL_CUSTOM_HOOK',
|
|
62
|
+
'INTERRUPTED',
|
|
63
|
+
'ABORTED'
|
|
64
|
+
]);
|
|
65
|
+
|
|
66
|
+
function evaluateStop(payload) {
|
|
67
|
+
if (!payload || typeof payload !== 'object') return { decision: 'allow' };
|
|
68
|
+
|
|
69
|
+
// 1. Compatibility recursion guards (not official documented Stop input fields):
|
|
70
|
+
// if a previous Stop hook already continued work during this turn, allow stop to prevent loops.
|
|
71
|
+
if (payload.continuationActive || payload.stop_hook_active) {
|
|
72
|
+
return { decision: 'allow' };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 2. Allow stop only on explicit abnormal termination reasons; normal reasons
|
|
76
|
+
// (NO_TOOL_CALL, model_stop, empty/unknown) must still evaluate handoff-state.json.
|
|
77
|
+
const terminationReason = typeof payload.terminationReason === 'string'
|
|
78
|
+
? payload.terminationReason.trim().toUpperCase()
|
|
79
|
+
: '';
|
|
80
|
+
if (terminationReason && ABNORMAL_TERMINATION_REASONS.has(terminationReason)) {
|
|
81
|
+
return { decision: 'allow' };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// 3. Locate session state using normalized AGY workspace/session context
|
|
85
|
+
const normalized = normalizeAgyStatePayload(payload);
|
|
86
|
+
const sessionId = getAgySessionId(payload);
|
|
87
|
+
const root = getWorkspaceRoot(normalized) || normalized.cwd;
|
|
88
|
+
const sessionDir = getSessionDir(root, sessionId);
|
|
89
|
+
const handoffFile = path.join(sessionDir, 'handoff-state.json');
|
|
90
|
+
|
|
91
|
+
let handoff = null;
|
|
92
|
+
if (fs.existsSync(handoffFile)) {
|
|
93
|
+
try {
|
|
94
|
+
handoff = JSON.parse(fs.readFileSync(handoffFile, 'utf8'));
|
|
95
|
+
} catch (_) {}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const lastEditAt = (handoff && handoff.lastEditAt) || 0;
|
|
99
|
+
const lastVerifyAt = (handoff && handoff.lastVerifyAt) || 0;
|
|
100
|
+
const isFailed = handoff && handoff.status === 'failed';
|
|
101
|
+
|
|
102
|
+
// 4. Check for unverified edits or unresolved failure (bounded to 1 continuation per pending state)
|
|
103
|
+
let pending = null;
|
|
104
|
+
if (isFailed) {
|
|
105
|
+
pending = {
|
|
106
|
+
fingerprint: `failed:${handoff.timestamp || ''}:${handoff.tool || ''}:${handoff.exitCode ?? ''}`,
|
|
107
|
+
reason: 'Harness Verify-Before-Claim: pending tool failure must be resolved before claiming completion.'
|
|
108
|
+
};
|
|
109
|
+
} else if (lastEditAt > 0 && lastVerifyAt < lastEditAt) {
|
|
110
|
+
pending = {
|
|
111
|
+
fingerprint: `edit:${lastEditAt}`,
|
|
112
|
+
reason: 'Harness Verify-Before-Claim: unverified edits exist in session. Run relevant test/build/lint verification before claiming completion.'
|
|
113
|
+
};
|
|
114
|
+
} else if (process.env.HARNESS_REQUIRE_VERIFICATION === '1' && (!lastVerifyAt || lastVerifyAt < lastEditAt)) {
|
|
115
|
+
pending = {
|
|
116
|
+
fingerprint: `strict:${lastVerifyAt}`,
|
|
117
|
+
reason: 'Harness Verify-Before-Claim: objective test verification is required before claiming completion.'
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (pending) {
|
|
122
|
+
const stopStateFile = path.join(sessionDir, STOP_STATE_FILE);
|
|
123
|
+
const saved = readStopState(stopStateFile);
|
|
124
|
+
if (saved && saved.lastContinuedFingerprint === pending.fingerprint) {
|
|
125
|
+
return { decision: 'allow' };
|
|
126
|
+
}
|
|
127
|
+
writeStopState(stopStateFile, {
|
|
128
|
+
lastContinuedFingerprint: pending.fingerprint,
|
|
129
|
+
updatedAt: new Date().toISOString()
|
|
130
|
+
});
|
|
131
|
+
return {
|
|
132
|
+
decision: 'continue',
|
|
133
|
+
reason: pending.reason
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return { decision: 'allow' };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async function main() {
|
|
141
|
+
const payload = await readJsonStdin();
|
|
142
|
+
const result = evaluateStop(payload);
|
|
143
|
+
process.stdout.write(JSON.stringify(result) + '\n');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (require.main === module) {
|
|
147
|
+
main().catch(() => {
|
|
148
|
+
process.stdout.write('{"decision":"allow"}\n');
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
module.exports = { main, evaluateStop };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
|
|
6
|
+
function readJsonStdin(timeoutMs = 1500) {
|
|
7
|
+
return new Promise(resolve => {
|
|
8
|
+
let raw = '';
|
|
9
|
+
let settled = false;
|
|
10
|
+
|
|
11
|
+
const timer = setTimeout(() => {
|
|
12
|
+
if (settled) return;
|
|
13
|
+
settled = true;
|
|
14
|
+
try {
|
|
15
|
+
resolve(raw.trim() ? JSON.parse(raw) : {});
|
|
16
|
+
} catch (_) {
|
|
17
|
+
resolve({});
|
|
18
|
+
}
|
|
19
|
+
}, timeoutMs);
|
|
20
|
+
|
|
21
|
+
process.stdin.setEncoding('utf8');
|
|
22
|
+
process.stdin.on('data', chunk => { raw += chunk; });
|
|
23
|
+
process.stdin.on('end', () => {
|
|
24
|
+
if (settled) return;
|
|
25
|
+
settled = true;
|
|
26
|
+
clearTimeout(timer);
|
|
27
|
+
try {
|
|
28
|
+
resolve(raw.trim() ? JSON.parse(raw) : {});
|
|
29
|
+
} catch (_) {
|
|
30
|
+
resolve({});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
process.stdin.on('error', () => {
|
|
34
|
+
if (settled) return;
|
|
35
|
+
settled = true;
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
resolve({});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function resolveKernelRouter() {
|
|
43
|
+
const candidates = [
|
|
44
|
+
path.join(__dirname, '..', '..', '..', 'skills', 'harness-everything', 'scripts', 'kernel-router.js'),
|
|
45
|
+
path.join(__dirname, '..', '..', '..', 'harness-everything', 'scripts', 'kernel-router.js'),
|
|
46
|
+
path.join(__dirname, '..', '..', 'harness-everything', 'scripts', 'kernel-router.js')
|
|
47
|
+
];
|
|
48
|
+
return candidates.find(candidate => fs.existsSync(candidate)) || null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getAgySessionId(payload) {
|
|
52
|
+
if (!payload || typeof payload !== 'object') return '';
|
|
53
|
+
const candidate = payload.conversationId || payload.session_id || payload.sessionId || '';
|
|
54
|
+
return typeof candidate === 'string' ? candidate.trim() : String(candidate || '').trim();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function getAgyWorkspacePaths(payload) {
|
|
58
|
+
if (!payload || typeof payload !== 'object') return [];
|
|
59
|
+
const roots = [];
|
|
60
|
+
if (Array.isArray(payload.workspacePaths)) {
|
|
61
|
+
for (const entry of payload.workspacePaths) {
|
|
62
|
+
if (typeof entry === 'string' && entry.trim()) roots.push(entry.trim());
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (typeof payload.cwd === 'string' && payload.cwd.trim()) {
|
|
66
|
+
roots.push(payload.cwd.trim());
|
|
67
|
+
}
|
|
68
|
+
return [...new Set(roots)];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function getAgyEffectiveCwd(payload) {
|
|
72
|
+
if (payload && typeof payload === 'object') {
|
|
73
|
+
if (typeof payload.cwd === 'string' && payload.cwd.trim()) {
|
|
74
|
+
return payload.cwd.trim();
|
|
75
|
+
}
|
|
76
|
+
if (Array.isArray(payload.workspacePaths)) {
|
|
77
|
+
const first = payload.workspacePaths.find(entry => typeof entry === 'string' && entry.trim());
|
|
78
|
+
if (first) return first.trim();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return process.cwd();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function normalizeAgyStatePayload(payload, overrideCwd) {
|
|
85
|
+
const base = payload && typeof payload === 'object' ? payload : {};
|
|
86
|
+
const sessionId = getAgySessionId(base);
|
|
87
|
+
const effectiveCwd = (typeof overrideCwd === 'string' && overrideCwd.trim())
|
|
88
|
+
? overrideCwd.trim()
|
|
89
|
+
: getAgyEffectiveCwd(base);
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
...base,
|
|
93
|
+
...(sessionId ? { session_id: sessionId, sessionId, conversationId: sessionId } : {}),
|
|
94
|
+
cwd: effectiveCwd
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const MAX_SYMLINK_HOPS = 40;
|
|
99
|
+
const realpath = fs.realpathSync.native || fs.realpathSync;
|
|
100
|
+
|
|
101
|
+
function canonicalizePath(targetPath, baseDir, depth = 0) {
|
|
102
|
+
if (depth > MAX_SYMLINK_HOPS) return null;
|
|
103
|
+
if (typeof targetPath !== 'string' || !targetPath.trim()) return null;
|
|
104
|
+
const resolved = (typeof baseDir === 'string' && baseDir.trim())
|
|
105
|
+
? path.resolve(baseDir, targetPath)
|
|
106
|
+
: path.resolve(targetPath);
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
return realpath(resolved);
|
|
110
|
+
} catch (_) {
|
|
111
|
+
const suffix = [];
|
|
112
|
+
let current = resolved;
|
|
113
|
+
while (true) {
|
|
114
|
+
try {
|
|
115
|
+
const stat = fs.lstatSync(current);
|
|
116
|
+
if (stat.isSymbolicLink()) {
|
|
117
|
+
const linkTarget = fs.readlinkSync(current);
|
|
118
|
+
const resolvedLink = path.resolve(path.dirname(current), linkTarget);
|
|
119
|
+
const nextPath = suffix.length > 0 ? path.join(resolvedLink, ...suffix) : resolvedLink;
|
|
120
|
+
return canonicalizePath(nextPath, null, depth + 1);
|
|
121
|
+
}
|
|
122
|
+
} catch (_) {
|
|
123
|
+
// Entry does not exist yet; continue ascending to nearest existing ancestor.
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const parent = path.dirname(current);
|
|
127
|
+
if (parent === current) return resolved;
|
|
128
|
+
suffix.unshift(path.basename(current));
|
|
129
|
+
current = parent;
|
|
130
|
+
try {
|
|
131
|
+
const realAncestor = realpath(current);
|
|
132
|
+
return path.join(realAncestor, ...suffix);
|
|
133
|
+
} catch (_) {}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function isOutOfBoundsPath(filePath, allowedRoots, baseDir) {
|
|
139
|
+
if (typeof filePath !== 'string' || !filePath.trim()) return true;
|
|
140
|
+
const roots = (Array.isArray(allowedRoots) ? allowedRoots : [allowedRoots])
|
|
141
|
+
.filter(root => typeof root === 'string' && root.trim());
|
|
142
|
+
if (roots.length === 0) return false;
|
|
143
|
+
|
|
144
|
+
const resolveBase = (typeof baseDir === 'string' && baseDir.trim()) ? baseDir : roots[0];
|
|
145
|
+
const canonicalTarget = canonicalizePath(filePath, resolveBase);
|
|
146
|
+
if (!canonicalTarget) return true;
|
|
147
|
+
|
|
148
|
+
const normTarget = process.platform === 'win32' ? canonicalTarget.toLowerCase() : canonicalTarget;
|
|
149
|
+
return !roots.some(root => {
|
|
150
|
+
const canonicalRoot = canonicalizePath(root);
|
|
151
|
+
if (!canonicalRoot) return false;
|
|
152
|
+
const normRoot = process.platform === 'win32' ? canonicalRoot.toLowerCase() : canonicalRoot;
|
|
153
|
+
if (normTarget === normRoot) return true;
|
|
154
|
+
const prefix = normRoot.endsWith(path.sep) ? normRoot : normRoot + path.sep;
|
|
155
|
+
return normTarget.startsWith(prefix);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
module.exports = {
|
|
160
|
+
readJsonStdin,
|
|
161
|
+
resolveKernelRouter,
|
|
162
|
+
getAgySessionId,
|
|
163
|
+
getAgyWorkspacePaths,
|
|
164
|
+
getAgyEffectiveCwd,
|
|
165
|
+
normalizeAgyStatePayload,
|
|
166
|
+
canonicalizePath,
|
|
167
|
+
isOutOfBoundsPath
|
|
168
|
+
};
|
|
@@ -2,10 +2,40 @@
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const { getWorkspaceRoot, getSessionDir } = require('./lib/harness-state');
|
|
5
|
-
const { cwdOf, classifyShell, isVerificationShell, directMutationInWorkspace } = require('./lib/workflow-isolation');
|
|
5
|
+
const { cwdOf, classifyShell, isVerificationShell, directMutationInWorkspace, mutationPaths } = require('./lib/workflow-isolation');
|
|
6
|
+
const { getAgyWorkspacePaths, isOutOfBoundsPath } = require('./lib/agy-adapter-core');
|
|
6
7
|
const { observeTool } = require('./lib/telemetry');
|
|
7
8
|
const { readCodexToolOutcome } = require('./lib/codex-tool-outcome');
|
|
8
9
|
const codex = process.argv.includes('--codex');
|
|
10
|
+
const agy = process.argv.includes('--agy');
|
|
11
|
+
|
|
12
|
+
function agyMutationTargets(payload, toolName) {
|
|
13
|
+
if (toolName === 'apply_patch') {
|
|
14
|
+
return mutationPaths(payload).map(v => String(v || '').trim()).filter(Boolean);
|
|
15
|
+
}
|
|
16
|
+
const input = (payload && (payload.tool_input ?? payload.toolInput ?? payload.input)) || {};
|
|
17
|
+
const candidates = [
|
|
18
|
+
input.file_path,
|
|
19
|
+
input.filePath,
|
|
20
|
+
input.path,
|
|
21
|
+
input.TargetFile,
|
|
22
|
+
input.Path,
|
|
23
|
+
input.targetFile
|
|
24
|
+
];
|
|
25
|
+
const target = candidates.find(value => typeof value === 'string' && value.trim());
|
|
26
|
+
return target ? [target.trim()] : [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function agyDirectMutationInWorkspace(payload, mutationCwd, root, toolName) {
|
|
30
|
+
const targets = agyMutationTargets(payload, toolName);
|
|
31
|
+
if (targets.length === 0) return false;
|
|
32
|
+
const agyRoots = getAgyWorkspacePaths(payload);
|
|
33
|
+
if (typeof root === 'string' && root.trim() && !agyRoots.includes(root.trim())) {
|
|
34
|
+
agyRoots.push(root.trim());
|
|
35
|
+
}
|
|
36
|
+
if (agyRoots.length === 0) return false;
|
|
37
|
+
return targets.some(target => !isOutOfBoundsPath(target, agyRoots, mutationCwd));
|
|
38
|
+
}
|
|
9
39
|
|
|
10
40
|
function isSuccessfulMetadataStep(command, cwd) {
|
|
11
41
|
// A line break starts a second shell command, so it can never be metadata-only.
|
|
@@ -83,14 +113,19 @@ function processState(payload) {
|
|
|
83
113
|
const stdout = codexResult?.stdout ?? toolResponse.stdout ?? payload.stdout ?? '';
|
|
84
114
|
const stderr = codexResult?.stderr ?? toolResponse.stderr ?? payload.stderr ?? payload.error ?? '';
|
|
85
115
|
const rawExitCode = toolResponse.exitCode ?? toolResponse.exit_code ?? payload.exitCode;
|
|
86
|
-
const exitCode = codex ? codexResult.exitCode
|
|
116
|
+
const exitCode = codex ? codexResult.exitCode
|
|
117
|
+
: agy ? (Number.isInteger(rawExitCode) ? rawExitCode : undefined)
|
|
118
|
+
: typeof rawExitCode === 'number' ? rawExitCode : undefined;
|
|
87
119
|
const stderrSignal = typeof stderr === 'string' && stderr.trim().length > 0;
|
|
88
120
|
const hookEvent = captureEventName;
|
|
89
121
|
const isSuccessEvent = hookEvent === 'PostToolUse';
|
|
122
|
+
const agyErrorSignal = agy && typeof payload.error === 'string' && payload.error.trim().length > 0;
|
|
90
123
|
const isFailed = codex ? codexResult.outcome === 'failure' :
|
|
91
|
-
hookEvent === 'PostToolUseFailure' || (exitCode !== undefined && exitCode !== 0) ||
|
|
124
|
+
hookEvent === 'PostToolUseFailure' || agyErrorSignal || (exitCode !== undefined && exitCode !== 0) ||
|
|
92
125
|
(!isSuccessEvent && exitCode === undefined && stderrSignal);
|
|
93
|
-
const verifiedSuccess = codex ? codexResult.outcome === 'success'
|
|
126
|
+
const verifiedSuccess = codex ? codexResult.outcome === 'success'
|
|
127
|
+
: agy ? (!isFailed && exitCode === 0)
|
|
128
|
+
: !isFailed && (isSuccessEvent || exitCode === 0);
|
|
94
129
|
const toolName = payload.tool_name || payload.tool || 'command';
|
|
95
130
|
let editAfterCapture = false;
|
|
96
131
|
let stateOnlyCandidate = false;
|
|
@@ -98,11 +133,13 @@ function processState(payload) {
|
|
|
98
133
|
let output = (stderrSignal ? stderr : stdout) || (typeof payload.output === 'string' ? payload.output : '');
|
|
99
134
|
if (output.length > 500) output = '...' + output.slice(-500);
|
|
100
135
|
state.status = 'failed'; state.timestamp = new Date().toISOString(); state.tool = toolName; state.exitCode = exitCode; state.errorSummary = output.trim();
|
|
101
|
-
} else if ((!codex || verifiedSuccess) && state.status === 'failed') {
|
|
136
|
+
} else if (((!codex && !agy) || verifiedSuccess) && state.status === 'failed') {
|
|
102
137
|
state.lastResolved = { tool: state.tool, timestamp: state.timestamp }; state.status = 'idle'; state.timestamp = new Date().toISOString(); delete state.exitCode; delete state.errorSummary;
|
|
103
138
|
}
|
|
104
139
|
const isDirectTool = toolName === 'Edit' || toolName === 'Write' || toolName === 'apply_patch';
|
|
105
|
-
if (isDirectTool &&
|
|
140
|
+
if (isDirectTool && (agy
|
|
141
|
+
? agyDirectMutationInWorkspace(payload, cwdOf(payload, root), root, toolName)
|
|
142
|
+
: directMutationInWorkspace(payload, cwdOf(payload, root), root))) state.lastEditAt = Date.now();
|
|
106
143
|
const isShell = toolName === 'Bash' || toolName === 'PowerShell' || toolName === 'exec_command';
|
|
107
144
|
const command = (payload.tool_input && payload.tool_input.command) || '';
|
|
108
145
|
if (isShell) {
|
|
@@ -114,10 +151,6 @@ function processState(payload) {
|
|
|
114
151
|
{ toolName, sessionId, agentId: payload.agent_id }));
|
|
115
152
|
const metadataStep = !stateOnlyCandidate && verifiedSuccess
|
|
116
153
|
&& isSuccessfulMetadataStep(command, cwdOf(payload, root));
|
|
117
|
-
if (!metadataStep && commandClass !== 'read-only' && commandClass !== 'worktree-setup') {
|
|
118
|
-
if (stateOnlyCandidate) editAfterCapture = true;
|
|
119
|
-
else state.lastEditAt = Date.now();
|
|
120
|
-
}
|
|
121
154
|
// The host-specific outcome must confirm success before verification advances.
|
|
122
155
|
// Pilot ON only: a registered, argv-validated doc-check that resolves to this install's own runtime is the document
|
|
123
156
|
// verification evidence, and only at the shipped pin (R3-02). Any other path earns no verification evidence. OFF stays legacy.
|
|
@@ -129,6 +162,13 @@ function processState(payload) {
|
|
|
129
162
|
const verifies = stateOnlyCandidate ? false : docCheckCandidate
|
|
130
163
|
? Boolean(pinCheckable) && docCheck.fileDigest(installedCheck.installed) === docCheck.SHIPPED_DOC_CHECK_DIGEST
|
|
131
164
|
: !(pilotEnabled && docCheck.trustRisk(command)) && isVerificationShell(command, { cwd: cwdOf(payload, root), root });
|
|
165
|
+
// On AGY hosts that omit shell error/exitCode, an unconfirmed verification-only command must not advance lastEditAt
|
|
166
|
+
// and defeat agy-stop.js's bounded continuation fingerprint.
|
|
167
|
+
const agyUnknownOutcomeVerify = agy && !verifiedSuccess && !isFailed && verifies;
|
|
168
|
+
if (!metadataStep && !agyUnknownOutcomeVerify && commandClass !== 'read-only' && commandClass !== 'worktree-setup') {
|
|
169
|
+
if (stateOnlyCandidate) editAfterCapture = true;
|
|
170
|
+
else state.lastEditAt = Date.now();
|
|
171
|
+
}
|
|
132
172
|
if (verifiedSuccess && verifies) {
|
|
133
173
|
const verifiedAt = Date.now();
|
|
134
174
|
const verifiedExitCode = exitCode ?? null;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"harness-everything": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{
|
|
5
|
+
"type": "command",
|
|
6
|
+
"command": "node ./hooks/scripts/agy-session-start.js"
|
|
7
|
+
}
|
|
8
|
+
],
|
|
9
|
+
"PreInvocation": [
|
|
10
|
+
{
|
|
11
|
+
"type": "command",
|
|
12
|
+
"command": "node ./hooks/scripts/agy-pre-invocation.js"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"PreToolUse": [
|
|
16
|
+
{
|
|
17
|
+
"matcher": "run_command|write_file|edit_file|write_to_file|replace_file_content|multi_replace_file_content",
|
|
18
|
+
"hooks": [
|
|
19
|
+
{
|
|
20
|
+
"type": "command",
|
|
21
|
+
"command": "node ./hooks/scripts/agy-pre-tool.js"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"PostToolUse": [
|
|
27
|
+
{
|
|
28
|
+
"matcher": "run_command|write_file|edit_file|write_to_file|replace_file_content|multi_replace_file_content",
|
|
29
|
+
"hooks": [
|
|
30
|
+
{
|
|
31
|
+
"type": "command",
|
|
32
|
+
"command": "node ./hooks/scripts/agy-post-tool.js"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"Stop": [
|
|
38
|
+
{
|
|
39
|
+
"type": "command",
|
|
40
|
+
"command": "node ./hooks/scripts/agy-stop.js"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -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.
|
|
4
|
+
"version": "0.58.0",
|
|
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",
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Operating guide for AI agents working inside the Harness-everything repository — how we work, layout, change rules, quality gates, and release policy.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# AGENTS.md — Working in This Repository
|
|
6
|
+
|
|
7
|
+
You are modifying **Harness**: an orchestrated agent operating system (skills + hooks/plugins + routing) for AI coding agents. Changes here ship to real agent sessions. A vague `SKILL.md`, a stale manifest, a contradictory platform claim or a bypassable selected workflow can misroute other people's agents. Precision is the product.
|
|
8
|
+
|
|
9
|
+
## How We Work
|
|
10
|
+
|
|
11
|
+
Harness exists to put agents on the **fastest path to a working result**, not to fence them in. Prefer mechanisms that make the right action the easy one over written demands that agents talk themselves out of.
|
|
12
|
+
|
|
13
|
+
```mermaid
|
|
14
|
+
flowchart LR
|
|
15
|
+
A["1. Wire the whole path<br/>(smallest end-to-end version)"] --> B["2. Record a baseline<br/>on that path"]
|
|
16
|
+
B --> C["3. Improve one thing per stage,<br/>compare to the baseline"]
|
|
17
|
+
C --> D["4. Lock behaviour<br/>with tests against drift"]
|
|
18
|
+
C -. "effect not measurable<br/>on the full path" .-> A
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- **Whole path first.** Do not polish details or add tests for parts that are not connected yet.
|
|
22
|
+
- **Stages follow the full path.** A stage whose effect cannot be measured end to end is split wrongly.
|
|
23
|
+
- **Mechanisms over mandates.** Put recurring rules in CI, hooks, mods or templates so actions match them naturally. A new prose MUST is the last resort.
|
|
24
|
+
- **Dogfood the rules.** Docs, packets and reports written here follow the same doc rules Harness ships.
|
|
25
|
+
- **Coordinator role.** In multi-agent work the coordinator dispatches and analyses. Agents and the reviewer check each step; the coordinator re-verifies everything at the final stage.
|
|
26
|
+
|
|
27
|
+
### Writing docs (this file included)
|
|
28
|
+
|
|
29
|
+
1. **Mermaid** for anything that can be drawn: flows, stages, dependencies, state.
|
|
30
|
+
2. **Short bullets or tables** for rules and facts.
|
|
31
|
+
3. **Prose** only for detail that needs it; link it rather than inline it.
|
|
32
|
+
|
|
33
|
+
## Repository Layout
|
|
34
|
+
|
|
35
|
+
| Path | What it is |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `<skill-name>/SKILL.md` | One canonical skill per top-level directory. Frontmatter: `name`, `description`, `metadata.author`, `metadata.version`. |
|
|
38
|
+
| `hooks/` | Claude Code lifecycle hooks and shared mechanisms (circuit breaker, workflow/action/scope guards, stop gates). Not every host packages every hook. |
|
|
39
|
+
| `harness-everything/scripts/` | Runtime: kernel/tier routing, workflow contract, verification, bootstrap, self-heal. |
|
|
40
|
+
| `opencode-plugin/` | OpenCode native plugin. Mechanism-tested, with partial live-host evidence (see the boundary below). |
|
|
41
|
+
| `.agents/plugins/` + `plugins/harness-everything/` | Local OpenAI/Codex marketplace + `.codex-plugin` package with canonical skill copies and packaged session/prompt hooks. |
|
|
42
|
+
| `submission/openai/` | Public OpenAI Skills-only listing/test inputs. The public artifact does not include local `.codex-plugin` lifecycle hooks. |
|
|
43
|
+
| `evals/<skill>/` | Trigger/routing eval per skill (waza format). Required for every canonical routed skill. |
|
|
44
|
+
| `behavioral-evals/` | LLM-behavior cases run via headless CLI sessions, structurally validated by CI. |
|
|
45
|
+
| `benchmarks/` | BENCHMARK_SOP fixtures and recorded results. Evidence lives here or nowhere. |
|
|
46
|
+
| `.claude-plugin/` | Claude Code plugin manifests. Must list exactly the on-disk canonical skills. |
|
|
47
|
+
| `docs/platform-capabilities.md` | Canonical platform/install/enforcement/evidence matrix. |
|
|
48
|
+
| `docs/repository-contract.md` | Generated Node/workflow/action/gate contract. Regenerate with `npm run docs:sync`; never hand-edit. |
|
|
49
|
+
| `.nvmrc` | Primary dev/CI Node runtime. `package.json#engines.node` stays the supported minimum. |
|
|
50
|
+
| `docs/`, `references/` | Philosophy, architecture, workflow docs, shared checklists. |
|
|
51
|
+
|
|
52
|
+
## OpenCode evidence boundary
|
|
53
|
+
|
|
54
|
+
The retained [OpenCode evidence](benchmarks/results/live-host/opencode-2026-09-16/README.md) supports project-scope `.js` loading and edit/verification state on OpenCode 1.18.31 (macOS).
|
|
55
|
+
|
|
56
|
+
- The final snapshot is post-reset (`hardLock: false`, `count: 1`).
|
|
57
|
+
- Hard lock is only an interactive observation with no retained blocked-tool trace.
|
|
58
|
+
- Historical reflection was operator-seeded, then agent-rewritten; agent-controlled state deletion reset the breaker. Rule-of-3 enforcement has since been retired.
|
|
59
|
+
- Global scope, npm-package installation, and other OpenCode versions remain unverified.
|
|
60
|
+
|
|
61
|
+
## Change Rules
|
|
62
|
+
|
|
63
|
+
**Skills and routing**
|
|
64
|
+
|
|
65
|
+
1. **Every canonical SKILL.md keeps ≤ 500 tokens** (CI gate) and contains `## USE FOR:` and `## DO NOT USE FOR:`. Detail goes in references/guides.
|
|
66
|
+
2. **Descriptions are routing surfaces.** Differentiate neighbouring skills deliberately; `test:collision` guards overlap.
|
|
67
|
+
3. **A new canonical skill ships with a routing eval.** The positive task `description:` exactly matches the skill frontmatter description.
|
|
68
|
+
|
|
69
|
+
**Release and distribution**
|
|
70
|
+
|
|
71
|
+
4. **Versions:** normal PRs never bump versions. `semantic-release` owns SemVer; `scripts/sync-release-version.js` syncs distributions. Nested sub-skills inherit their parent's version.
|
|
72
|
+
5. **Distribution manifests are generated facts.** After add/remove/rename run `npm run plugin:sync`, `npm run test:consistency` and `npm run test:plugin:openai`.
|
|
73
|
+
6. **Platform capability claims are tested contracts.** Update `docs/platform-capabilities.md` with integration changes. Package/mechanism evidence is not live-host evidence; public Skills-only behavior has no local lifecycle hooks.
|
|
74
|
+
7. **Runtime/workflow claims are generated facts.** `package.json`, `.nvmrc`, Dockerfile and active workflows feed `scripts/repository-contract.js`; run `npm run docs:sync` after relevant changes.
|
|
75
|
+
8. **CHANGELOG.md:** human notes go under `[Unreleased]`; semantic-release owns stable headings, tags and release notes.
|
|
76
|
+
9. **Conventional Commit type is release input:** breaking→major, `feat`→minor, `fix`/`perf`/`refactor`/`build`/`revert`→patch; docs/test/ci/style/chore do not release alone.
|
|
77
|
+
|
|
78
|
+
**Workflow behaviour**
|
|
79
|
+
|
|
80
|
+
10. **Selected workflow is a semantic contract; tactics remain flexible.** Compose ordered requirement steps with declared required/optional skill or reference bindings. Resolve a binding only when its step (or dependency-ready Fable stage) is active; required bindings MUST resolve before that step passes, and applicable skill core contracts MUST be followed. Unknown/unavailable bindings stay visible. Selected-topology obligations MUST resolve; missing host evidence yields reminders, not a persistent Harness lock.
|
|
81
|
+
11. **User-visible Harness Status is mandatory for non-trivial work.** One Markdown block headed `### 🚦 Harness Status` with bold `Current`, `Read / Evidence`, `Next`, optional `Risk / Blocked`; use nested evidence bullets when useful. Emit it before substantive execution, after major phases, on direction changes, at long-run boundaries and before completion. The routing checkpoint is internal state, not a second block. Not a hard lock.
|
|
82
|
+
12. **Tier-3/Fable isolation disposition is mandatory before broad mutation.** Use a verified linked Git worktree, or record an explicit degraded fallback when isolation is unavailable or the user chooses to stay in place. Ordinary isolation SHOULD be used when it materially reduces collision risk. Failure to isolate is a visible gap, not a Harness deadlock. See [workflow-runtime.md](docs/workflow-runtime.md).
|
|
83
|
+
13. **Use contract strength deliberately** ([philosophy.md](docs/philosophy.md#contract-strength-must--should--may)): MUST = required semantic obligation, SHOULD = default with an evidence-based exception, MAY = optional. Do not use recommend/prefer/advisory/guidance to weaken a MUST.
|
|
84
|
+
14. **The turn label line is mandatory on every turn, trivial ones included.** End each turn's final message with one hidden `<!-- harness-label {...} -->` line giving your post-work judgement ([docs/routing.md](docs/routing.md#turn-label-line)). It records data and never gates routing.
|
|
85
|
+
|
|
86
|
+
## Verification Before You Claim Done
|
|
87
|
+
|
|
88
|
+
```mermaid
|
|
89
|
+
flowchart LR
|
|
90
|
+
F["npm run verify:all -- --fast<br/>(pre-push subset)"] --> V["npm run verify:all<br/>(CI order, PASS/FAIL/UNCHECKED report)"]
|
|
91
|
+
V -. optional .-> C["-- --clean<br/>(fresh worktree of HEAD)"]
|
|
92
|
+
V -. optional .-> N["-- --node22<br/>(Node 22 smoke lane)"]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
- `npm run verify:all` runs a local subset of the hosted `ci.yml` gates and prints paste-ready PASS/FAIL/UNCHECKED evidence: 12 rows in the full plan, 4 with `--fast` (`npm test`, `test:mutations`, `test:consistency`, `test:portability`).
|
|
96
|
+
- Full rows: `npm test`, `test:mutations`, `test:consistency`, `test:references`, `test:release`, `test:collision`, `test:routing:skills`, `test:routing:invariants`, `test:plugin:openai`, `test:plugin:submission`, `test:platform:compatibility`, `test:portability`. `test:mechanism` runs inside `npm test`; `test:repo-contract` and `test:docs:capabilities` run inside `test:consistency`. Hosted CI runs the two `test:routing:*` rows inside `self-regression`.
|
|
97
|
+
- Hosted `ci.yml` jobs it does not run: `pilot-offline-evidence`, both System One Windows runtime-pin jobs, `release-semantics` (`test:release:semantics`), `skill-quality` (waza per-skill checks; only the optional `waza:check` row runs, and only when waza is installed), `installer-e2e` (`ci/installer-roundtrip.test.js`) and `npm ci` under Node 22 in `runtime-floor`. Local rows also run on one OS, where hosted `self-regression` and `consistency` run three.
|
|
98
|
+
- With waza (`~/bin/waza`): `waza check <skill-dir>`, `waza spec verify <skill> evals/<skill>/eval.yaml --fail --threshold 1`, `waza tokens check`.
|
|
99
|
+
- CI runs Node.js 24 on Ubuntu/Windows/macOS plus a Node.js 22 floor lane ([repository-contract.md](docs/repository-contract.md)). Node 22 install compatibility stays UNCHECKED locally.
|
|
100
|
+
- Never report "it works" from code reading. Name the evidence layer: package, deterministic mechanism, live host or behavior.
|
|
101
|
+
|
|
102
|
+
## Behavioral & Benchmark Evidence
|
|
103
|
+
|
|
104
|
+
| Claim | Evidence required |
|
|
105
|
+
|---|---|
|
|
106
|
+
| Hook/plugin contract holds | Deterministic mechanism test |
|
|
107
|
+
| A real host loaded and fired it | Preserved host/session artifact |
|
|
108
|
+
| Behavior improved | Paired evidence per #71 (baseline vs treatment) |
|
|
109
|
+
|
|
110
|
+
- Behavior runs: `node behavioral-evals/run.js run --engine opencode` (or `--engine claude`). On demand; costs tokens. The weekly workflow validates structure and runs live cases only where the CLI exists.
|
|
111
|
+
- Benchmarks: `node benchmarks/run.js scaffold <scenario>`, run both variants, then `record` with evidence logs.
|
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:7f8aadbc-1cb7-58e9-bb1e-e6b4169c51e7",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-11-
|
|
8
|
+
"timestamp": "2026-11-23T23:51:13.987Z",
|
|
9
9
|
"tools": [
|
|
10
10
|
{
|
|
11
11
|
"vendor": "Harness Everything",
|
|
12
12
|
"name": "generate-sbom.js",
|
|
13
|
-
"version": "0.
|
|
13
|
+
"version": "0.58.0"
|
|
14
14
|
}
|
|
15
15
|
],
|
|
16
16
|
"component": {
|
|
17
17
|
"type": "application",
|
|
18
|
-
"bom-ref": "pkg:npm/harness-everything@0.
|
|
18
|
+
"bom-ref": "pkg:npm/harness-everything@0.58.0",
|
|
19
19
|
"name": "harness-everything",
|
|
20
|
-
"version": "0.
|
|
21
|
-
"purl": "pkg:npm/harness-everything@0.
|
|
20
|
+
"version": "0.58.0",
|
|
21
|
+
"purl": "pkg:npm/harness-everything@0.58.0"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"components": [
|
|
@@ -2033,7 +2033,7 @@
|
|
|
2033
2033
|
]
|
|
2034
2034
|
},
|
|
2035
2035
|
{
|
|
2036
|
-
"ref": "pkg:npm/harness-everything@0.
|
|
2036
|
+
"ref": "pkg:npm/harness-everything@0.58.0",
|
|
2037
2037
|
"dependsOn": [
|
|
2038
2038
|
"pkg:npm/%40commitlint/cli@19.8.1",
|
|
2039
2039
|
"pkg:npm/%40commitlint/config-conventional@19.8.1",
|