@aria_asi/cli 0.2.33 → 0.2.35
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/dist/aria-connector/src/connectors/codex.d.ts.map +1 -1
- package/dist/aria-connector/src/connectors/codex.js +60 -5
- package/dist/aria-connector/src/connectors/codex.js.map +1 -1
- package/dist/assets/hooks/aria-harness-via-sdk.mjs +16 -3
- package/dist/assets/hooks/aria-pre-tool-gate.mjs +41 -1
- package/dist/assets/hooks/aria-stop-gate.mjs +42 -1
- package/dist/assets/hooks/doctrine_trigger_map.json +43 -0
- package/dist/assets/hooks/lib/skill-autoload-gate.mjs +14 -1
- package/dist/assets/opencode-plugins/harness-context/index.js +1 -1
- package/dist/assets/opencode-plugins/harness-gate/index.js +49 -9
- package/dist/assets/opencode-plugins/harness-gate/lib/skill-autoload-gate.js +14 -1
- package/dist/assets/opencode-plugins/harness-stop/index.js +201 -166
- package/dist/assets/opencode-plugins/harness-stop/lib/skill-autoload-gate.js +14 -1
- package/dist/runtime/codex-bridge.mjs +1 -1
- package/dist/runtime/discipline/CLAUDE.md +2 -2
- package/dist/runtime/discipline/doctrine_trigger_map.json +43 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-onboarding/SKILL.md +3 -3
- package/dist/runtime/doctrine_trigger_map.json +43 -0
- package/dist/runtime/hooks/aria-agent-handoff.mjs +247 -0
- package/dist/runtime/hooks/aria-agent-ledger-merge.mjs +164 -0
- package/dist/runtime/hooks/aria-architect-fallback.mjs +267 -0
- package/dist/runtime/hooks/aria-cognition-substrate-binding.mjs +761 -0
- package/dist/runtime/hooks/aria-discovery-record.mjs +101 -0
- package/dist/runtime/hooks/aria-harness-via-sdk.mjs +544 -0
- package/dist/runtime/hooks/aria-import-resolution-gate.mjs +330 -0
- package/dist/runtime/hooks/aria-outcome-record.mjs +84 -0
- package/dist/runtime/hooks/aria-pre-emit-dryrun.mjs +329 -0
- package/dist/runtime/hooks/aria-pre-text-gate.mjs +112 -0
- package/dist/runtime/hooks/aria-pre-tool-gate.mjs +2482 -0
- package/dist/runtime/hooks/aria-preprompt-consult.mjs +464 -0
- package/dist/runtime/hooks/aria-preturn-memory-gate.mjs +647 -0
- package/dist/runtime/hooks/aria-repo-doctrine-gate.mjs +429 -0
- package/dist/runtime/hooks/aria-stop-gate.mjs +1882 -0
- package/dist/runtime/hooks/aria-trigger-autolearn.mjs +229 -0
- package/dist/runtime/hooks/aria-userprompt-abandon-detect.mjs +192 -0
- package/dist/runtime/hooks/doctrine_trigger_map.json +577 -0
- package/dist/runtime/hooks/lib/canonical-lenses.mjs +65 -0
- package/dist/runtime/hooks/lib/domain-output-quality.mjs +103 -0
- package/dist/runtime/hooks/lib/gate-audit.mjs +43 -0
- package/dist/runtime/hooks/lib/gate-loop-state.mjs +50 -0
- package/dist/runtime/hooks/lib/hook-message-window.mjs +121 -0
- package/dist/runtime/hooks/lib/skill-autoload-gate.mjs +14 -0
- package/dist/runtime/hooks/test-aria-preturn-memory-gate.mjs +245 -0
- package/dist/runtime/hooks/test-tier-lens-labeling.mjs +367 -0
- package/dist/runtime/manifest.json +2 -2
- package/dist/runtime/sdk/BUNDLED.json +2 -2
- package/dist/runtime/sdk/index.d.ts +39 -0
- package/dist/runtime/sdk/index.js +117 -0
- package/dist/runtime/sdk/index.js.map +1 -1
- package/dist/runtime/sdk/runWithGovernance.d.ts +16 -0
- package/dist/runtime/sdk/runWithGovernance.js +54 -0
- package/dist/runtime/sdk/runWithGovernance.js.map +1 -0
- package/dist/sdk/BUNDLED.json +2 -2
- package/dist/sdk/index.d.ts +39 -0
- package/dist/sdk/index.js +117 -0
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/runWithGovernance.d.ts +16 -0
- package/dist/sdk/runWithGovernance.js +54 -0
- package/dist/sdk/runWithGovernance.js.map +1 -0
- package/hooks/aria-harness-via-sdk.mjs +16 -3
- package/hooks/aria-pre-tool-gate.mjs +41 -1
- package/hooks/aria-stop-gate.mjs +42 -1
- package/hooks/doctrine_trigger_map.json +43 -0
- package/hooks/lib/skill-autoload-gate.mjs +14 -1
- package/opencode-plugins/harness-context/index.js +1 -1
- package/opencode-plugins/harness-gate/index.js +49 -9
- package/opencode-plugins/harness-gate/lib/skill-autoload-gate.js +14 -1
- package/opencode-plugins/harness-stop/index.js +201 -166
- package/opencode-plugins/harness-stop/lib/skill-autoload-gate.js +14 -1
- package/package.json +12 -5
- package/runtime-src/codex-bridge.mjs +1 -1
- package/scripts/bundle-sdk.mjs +2 -0
- package/scripts/self-test-harness-gates.mjs +79 -0
- package/src/connectors/codex.ts +60 -5
package/scripts/bundle-sdk.mjs
CHANGED
|
@@ -54,6 +54,7 @@ const REQUIRED_HOOK_FILES = [
|
|
|
54
54
|
const REQUIRED_HOOK_HELPERS = [
|
|
55
55
|
'lib/canonical-lenses.mjs',
|
|
56
56
|
'lib/gate-audit.mjs',
|
|
57
|
+
'lib/skill-autoload-gate.mjs',
|
|
57
58
|
];
|
|
58
59
|
const REQUIRED_OPENCODE_PLUGINS = [
|
|
59
60
|
'harness-context',
|
|
@@ -293,6 +294,7 @@ if (existsSync(DOCTRINE_TRIGGER_MAP_SRC)) {
|
|
|
293
294
|
copyFileSync(DOCTRINE_TRIGGER_MAP_SRC, join(RUNTIME_DST, 'doctrine_trigger_map.json'));
|
|
294
295
|
}
|
|
295
296
|
if (existsSync(CONNECTOR_HOOKS_SRC)) {
|
|
297
|
+
copyTree(CONNECTOR_HOOKS_SRC, join(RUNTIME_DST, 'hooks'));
|
|
296
298
|
copyTree(CONNECTOR_HOOKS_SRC, join(DIST_ASSETS_DST, 'hooks'));
|
|
297
299
|
}
|
|
298
300
|
if (existsSync(OPENCODE_PLUGINS_SRC)) {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { pathToFileURL } from 'node:url';
|
|
8
|
+
|
|
9
|
+
const repoRoot = join(import.meta.dirname, '..', '..', '..');
|
|
10
|
+
const gateModule = await import(pathToFileURL(join(repoRoot, 'ops/claude-hooks/lib/skill-autoload-gate.mjs')));
|
|
11
|
+
|
|
12
|
+
assert.equal(typeof gateModule.evaluateSkillGate, 'function', 'evaluateSkillGate export missing');
|
|
13
|
+
assert.equal(typeof gateModule.formatSkillGateBlock, 'function', 'formatSkillGateBlock export missing');
|
|
14
|
+
|
|
15
|
+
const broadClaim = gateModule.evaluateSkillGate({
|
|
16
|
+
sessionId: 'self-test-broad-readiness',
|
|
17
|
+
surface: 'self-test-output',
|
|
18
|
+
isOutputCloseout: true,
|
|
19
|
+
text: 'This is production-ready in general for client npm packages, SDKs, runtimes, and harnesses.',
|
|
20
|
+
autoLoadAvailable: false,
|
|
21
|
+
});
|
|
22
|
+
assert.equal(broadClaim.ok, false, 'broad readiness claim must block without required skills');
|
|
23
|
+
assert.ok(broadClaim.missingSkills.includes('architecture-decision'), 'architecture-decision must be required');
|
|
24
|
+
assert.ok(broadClaim.missingSkills.includes('testing-strategy'), 'testing-strategy must be required');
|
|
25
|
+
assert.ok(broadClaim.missingSkills.includes('aria-forge-guardrails'), 'aria-forge-guardrails must be required');
|
|
26
|
+
|
|
27
|
+
const deployAction = gateModule.evaluateSkillGate({
|
|
28
|
+
sessionId: 'self-test-deploy',
|
|
29
|
+
surface: 'self-test-action',
|
|
30
|
+
isDeploy: true,
|
|
31
|
+
toolName: 'Bash',
|
|
32
|
+
action: 'bash scripts/deploy-service.sh aria-soul',
|
|
33
|
+
text: 'deploy service',
|
|
34
|
+
autoLoadAvailable: false,
|
|
35
|
+
});
|
|
36
|
+
assert.equal(deployAction.ok, false, 'deploy action must block without aria-harness-deploy');
|
|
37
|
+
assert.ok(deployAction.missingSkills.includes('aria-harness-deploy'), 'aria-harness-deploy must be required');
|
|
38
|
+
|
|
39
|
+
const missingProof = gateModule.evaluateSkillGate({
|
|
40
|
+
sessionId: 'self-test-missing-proof',
|
|
41
|
+
surface: 'self-test-output',
|
|
42
|
+
isOutputCloseout: true,
|
|
43
|
+
text: [
|
|
44
|
+
'<skill_content name="aria-harness-output-discipline"></skill_content>',
|
|
45
|
+
'Completed, but tests were not run and this still has a blocker.',
|
|
46
|
+
].join('\n'),
|
|
47
|
+
autoLoadAvailable: false,
|
|
48
|
+
});
|
|
49
|
+
assert.equal(missingProof.ok, false, 'completion with failed/missing proof must block');
|
|
50
|
+
assert.ok(missingProof.recoveryMissing.includes('successful proof from a concrete command/probe'), 'successful proof must be required');
|
|
51
|
+
assert.ok(missingProof.recoveryMissing.includes('re-submission'), 're-submission must be required');
|
|
52
|
+
assert.ok(missingProof.recoveryMissing.includes('re-write'), 're-write must be required');
|
|
53
|
+
assert.ok(missingProof.recoveryMissing.includes('re-test'), 're-test must be required');
|
|
54
|
+
assert.ok(missingProof.recoveryMissing.includes('ARIA console escalation'), 'ARIA console escalation must be required');
|
|
55
|
+
|
|
56
|
+
const loaded = gateModule.evaluateSkillGate({
|
|
57
|
+
sessionId: 'self-test-loaded',
|
|
58
|
+
surface: 'self-test-output',
|
|
59
|
+
isOutputCloseout: true,
|
|
60
|
+
text: [
|
|
61
|
+
'<skill_content name="architecture-decision"></skill_content>',
|
|
62
|
+
'<skill_content name="testing-strategy"></skill_content>',
|
|
63
|
+
'<skill_content name="aria-forge-guardrails"></skill_content>',
|
|
64
|
+
'<skill_content name="aria-harness-output-discipline"></skill_content>',
|
|
65
|
+
'This production-ready statement is backed by a full readiness matrix. Verified: npm run check:hooks passed successfully.',
|
|
66
|
+
].join('\n'),
|
|
67
|
+
autoLoadAvailable: false,
|
|
68
|
+
});
|
|
69
|
+
assert.equal(loaded.ok, true, gateModule.formatSkillGateBlock(loaded));
|
|
70
|
+
|
|
71
|
+
const installedStop = await import(pathToFileURL(join(repoRoot, 'packages/aria-connector/opencode-plugins/harness-stop/index.js')));
|
|
72
|
+
assert.equal(typeof installedStop.default, 'function', 'harness-stop default export missing');
|
|
73
|
+
const installedGate = await import(pathToFileURL(join(repoRoot, 'packages/aria-connector/opencode-plugins/harness-gate/index.js')));
|
|
74
|
+
assert.equal(typeof installedGate.default, 'function', 'harness-gate default export missing');
|
|
75
|
+
|
|
76
|
+
const temp = mkdtempSync(join(tmpdir(), 'aria-harness-gates-'));
|
|
77
|
+
rmSync(temp, { recursive: true, force: true });
|
|
78
|
+
|
|
79
|
+
console.log('harness gate self-test passed');
|
package/src/connectors/codex.ts
CHANGED
|
@@ -90,6 +90,7 @@ function tomlString(value: string): string {
|
|
|
90
90
|
|
|
91
91
|
function buildCodexHookRuntimeClient(): string {
|
|
92
92
|
return `import { readFileSync, existsSync, mkdirSync, writeFileSync, unlinkSync } from 'node:fs';
|
|
93
|
+
import { spawnSync } from 'node:child_process';
|
|
93
94
|
import { createHash, randomUUID } from 'node:crypto';
|
|
94
95
|
import { homedir } from 'node:os';
|
|
95
96
|
import path from 'node:path';
|
|
@@ -98,6 +99,7 @@ import { HTTPHarnessClient } from '@aria_asi/harness-http-client';
|
|
|
98
99
|
const HOME = homedir();
|
|
99
100
|
const DEFAULT_RUNTIME_URL = (process.env.ARIA_RUNTIME_URL || 'http://127.0.0.1:4319').replace(/\\/+$/, '');
|
|
100
101
|
const TURN_STATE_DIR = path.join(HOME, '.codex', 'tmp', 'aria-hook-turn-state');
|
|
102
|
+
const GOVERNANCE_GATE_PATH = path.join(HOME, '.aria', 'bin', 'aria-governance-gate');
|
|
101
103
|
|
|
102
104
|
function readToken() {
|
|
103
105
|
const envToken = process.env.ARIA_API_KEY || process.env.ARIA_MASTER_TOKEN || process.env.OPENAI_API_KEY;
|
|
@@ -323,6 +325,22 @@ export function emitJson(payload, code = 0) {
|
|
|
323
325
|
process.stdout.write(\`\${JSON.stringify(payload)}\\n\`);
|
|
324
326
|
process.exit(code);
|
|
325
327
|
}
|
|
328
|
+
|
|
329
|
+
export function runGovernanceGate(payload = {}) {
|
|
330
|
+
if (!existsSync(GOVERNANCE_GATE_PATH)) return null;
|
|
331
|
+
const child = spawnSync(GOVERNANCE_GATE_PATH, {
|
|
332
|
+
input: \`\${JSON.stringify(payload)}\\n\`,
|
|
333
|
+
encoding: 'utf8',
|
|
334
|
+
maxBuffer: 1024 * 1024,
|
|
335
|
+
});
|
|
336
|
+
const stdout = String(child.stdout || '').trim();
|
|
337
|
+
let result = null;
|
|
338
|
+
try { result = stdout ? JSON.parse(stdout) : null; } catch {}
|
|
339
|
+
if (child.status !== 0 || result?.ok === false || result?.decision === 'block') {
|
|
340
|
+
throw new Error(stdout || child.stderr || 'aria-governance-gate blocked this Codex hook.');
|
|
341
|
+
}
|
|
342
|
+
return result;
|
|
343
|
+
}
|
|
326
344
|
`;
|
|
327
345
|
}
|
|
328
346
|
|
|
@@ -339,6 +357,7 @@ import {
|
|
|
339
357
|
runtimePost,
|
|
340
358
|
loadTurnState,
|
|
341
359
|
saveTurnState,
|
|
360
|
+
runGovernanceGate,
|
|
342
361
|
emitJson,
|
|
343
362
|
} from './lib/runtime-client.mjs';
|
|
344
363
|
|
|
@@ -357,6 +376,13 @@ try {
|
|
|
357
376
|
message: userText || 'codex turn start',
|
|
358
377
|
});
|
|
359
378
|
const packetRef = makeEvidenceRef('harness_packet', packet, { sessionId, platform: 'codex' });
|
|
379
|
+
runGovernanceGate({
|
|
380
|
+
sessionId,
|
|
381
|
+
sourceRuntime: 'codex',
|
|
382
|
+
surface: 'codex-userprompt-submit',
|
|
383
|
+
text: userText.slice(0, 8000),
|
|
384
|
+
evidence: packetRef,
|
|
385
|
+
});
|
|
360
386
|
const result = await runtimePost('/mizan/pre', {
|
|
361
387
|
sessionId,
|
|
362
388
|
packet,
|
|
@@ -400,7 +426,6 @@ try {
|
|
|
400
426
|
function buildCodexPreToolHook(): string {
|
|
401
427
|
return `#!/usr/bin/env node
|
|
402
428
|
import {
|
|
403
|
-
getHarnessClient,
|
|
404
429
|
inferSessionId,
|
|
405
430
|
classifyAction,
|
|
406
431
|
summarizeTarget,
|
|
@@ -408,11 +433,11 @@ import {
|
|
|
408
433
|
loadTurnState,
|
|
409
434
|
makeEvidenceRef,
|
|
410
435
|
saveTurnState,
|
|
436
|
+
runGovernanceGate,
|
|
411
437
|
emitJson,
|
|
412
438
|
} from './lib/runtime-client.mjs';
|
|
413
439
|
|
|
414
440
|
const event = readEventFromStdin();
|
|
415
|
-
const client = getHarnessClient();
|
|
416
441
|
const sessionId = inferSessionId(event);
|
|
417
442
|
const action = classifyAction(event);
|
|
418
443
|
const target = summarizeTarget(event);
|
|
@@ -433,6 +458,17 @@ try {
|
|
|
433
458
|
});
|
|
434
459
|
}
|
|
435
460
|
const toolName = String(event?.tool_name || event?.toolName || '').trim() || null;
|
|
461
|
+
runGovernanceGate({
|
|
462
|
+
sessionId,
|
|
463
|
+
sourceRuntime: 'codex',
|
|
464
|
+
surface: 'codex-pre-tool-use',
|
|
465
|
+
text: JSON.stringify(event).slice(0, 8000),
|
|
466
|
+
action,
|
|
467
|
+
toolName,
|
|
468
|
+
isDeploy: action === 'deploy',
|
|
469
|
+
isMutation: action === 'write' || action === 'delete',
|
|
470
|
+
evidence: makeEvidenceRef('codex_tool_request', { action, toolName, target }, { sessionId }),
|
|
471
|
+
});
|
|
436
472
|
const tools = Array.isArray(state?.tools) ? state.tools.slice(-24) : [];
|
|
437
473
|
tools.push({
|
|
438
474
|
at: new Date().toISOString(),
|
|
@@ -496,7 +532,6 @@ try {
|
|
|
496
532
|
function buildCodexStopHook(): string {
|
|
497
533
|
return `#!/usr/bin/env node
|
|
498
534
|
import {
|
|
499
|
-
getHarnessClient,
|
|
500
535
|
inferSessionId,
|
|
501
536
|
extractAssistantText,
|
|
502
537
|
readEventFromStdin,
|
|
@@ -505,11 +540,11 @@ import {
|
|
|
505
540
|
makeEvidenceRef,
|
|
506
541
|
clearTurnState,
|
|
507
542
|
formatValidationFailure,
|
|
543
|
+
runGovernanceGate,
|
|
508
544
|
emitJson,
|
|
509
545
|
} from './lib/runtime-client.mjs';
|
|
510
546
|
|
|
511
547
|
const event = readEventFromStdin();
|
|
512
|
-
const client = getHarnessClient();
|
|
513
548
|
const sessionId = inferSessionId(event);
|
|
514
549
|
const state = loadTurnState(sessionId);
|
|
515
550
|
const text = extractAssistantText(event);
|
|
@@ -520,6 +555,14 @@ try {
|
|
|
520
555
|
if (!text) {
|
|
521
556
|
emitJson({ continue: true });
|
|
522
557
|
}
|
|
558
|
+
runGovernanceGate({
|
|
559
|
+
sessionId,
|
|
560
|
+
sourceRuntime: 'codex',
|
|
561
|
+
surface: 'codex-stop',
|
|
562
|
+
text: text.slice(0, 8000),
|
|
563
|
+
isOutputCloseout: true,
|
|
564
|
+
evidence: outputRef,
|
|
565
|
+
});
|
|
523
566
|
const validation = await runtimePost('/validate-output', {
|
|
524
567
|
text,
|
|
525
568
|
sessionId,
|
|
@@ -584,7 +627,19 @@ try {
|
|
|
584
627
|
},
|
|
585
628
|
});
|
|
586
629
|
if (typeof state?.userText === 'string' && state.userText.trim()) {
|
|
587
|
-
await
|
|
630
|
+
await runtimePost('/garden/turn', {
|
|
631
|
+
sessionId,
|
|
632
|
+
message: state.userText,
|
|
633
|
+
response: text,
|
|
634
|
+
userId: state?.userId || undefined,
|
|
635
|
+
requireCognitionBlock: false,
|
|
636
|
+
metadata: {
|
|
637
|
+
decision_type: 'codex-stop-garden-turn',
|
|
638
|
+
decision_category: 'codex-hooks',
|
|
639
|
+
trace_id: state?.traceId || null,
|
|
640
|
+
output_ref: outputRef,
|
|
641
|
+
},
|
|
642
|
+
});
|
|
588
643
|
}
|
|
589
644
|
clearTurnState(sessionId);
|
|
590
645
|
emitJson({ continue: true });
|