@aria_asi/cli 0.2.33 → 0.2.34

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.
Files changed (74) hide show
  1. package/dist/aria-connector/src/connectors/codex.d.ts.map +1 -1
  2. package/dist/aria-connector/src/connectors/codex.js +47 -0
  3. package/dist/aria-connector/src/connectors/codex.js.map +1 -1
  4. package/dist/assets/hooks/aria-harness-via-sdk.mjs +16 -3
  5. package/dist/assets/hooks/aria-pre-tool-gate.mjs +41 -1
  6. package/dist/assets/hooks/aria-stop-gate.mjs +42 -1
  7. package/dist/assets/hooks/doctrine_trigger_map.json +43 -0
  8. package/dist/assets/hooks/lib/skill-autoload-gate.mjs +14 -1
  9. package/dist/assets/opencode-plugins/harness-context/index.js +1 -1
  10. package/dist/assets/opencode-plugins/harness-gate/index.js +49 -9
  11. package/dist/assets/opencode-plugins/harness-gate/lib/skill-autoload-gate.js +14 -1
  12. package/dist/assets/opencode-plugins/harness-stop/index.js +201 -166
  13. package/dist/assets/opencode-plugins/harness-stop/lib/skill-autoload-gate.js +14 -1
  14. package/dist/runtime/codex-bridge.mjs +1 -1
  15. package/dist/runtime/discipline/CLAUDE.md +2 -2
  16. package/dist/runtime/discipline/doctrine_trigger_map.json +43 -0
  17. package/dist/runtime/discipline/skills/aria-harness/aria-harness-onboarding/SKILL.md +3 -3
  18. package/dist/runtime/doctrine_trigger_map.json +43 -0
  19. package/dist/runtime/hooks/aria-agent-handoff.mjs +247 -0
  20. package/dist/runtime/hooks/aria-agent-ledger-merge.mjs +164 -0
  21. package/dist/runtime/hooks/aria-architect-fallback.mjs +267 -0
  22. package/dist/runtime/hooks/aria-cognition-substrate-binding.mjs +761 -0
  23. package/dist/runtime/hooks/aria-discovery-record.mjs +101 -0
  24. package/dist/runtime/hooks/aria-harness-via-sdk.mjs +544 -0
  25. package/dist/runtime/hooks/aria-import-resolution-gate.mjs +330 -0
  26. package/dist/runtime/hooks/aria-outcome-record.mjs +84 -0
  27. package/dist/runtime/hooks/aria-pre-emit-dryrun.mjs +329 -0
  28. package/dist/runtime/hooks/aria-pre-text-gate.mjs +112 -0
  29. package/dist/runtime/hooks/aria-pre-tool-gate.mjs +2482 -0
  30. package/dist/runtime/hooks/aria-preprompt-consult.mjs +464 -0
  31. package/dist/runtime/hooks/aria-preturn-memory-gate.mjs +647 -0
  32. package/dist/runtime/hooks/aria-repo-doctrine-gate.mjs +429 -0
  33. package/dist/runtime/hooks/aria-stop-gate.mjs +1882 -0
  34. package/dist/runtime/hooks/aria-trigger-autolearn.mjs +229 -0
  35. package/dist/runtime/hooks/aria-userprompt-abandon-detect.mjs +192 -0
  36. package/dist/runtime/hooks/doctrine_trigger_map.json +577 -0
  37. package/dist/runtime/hooks/lib/canonical-lenses.mjs +65 -0
  38. package/dist/runtime/hooks/lib/domain-output-quality.mjs +103 -0
  39. package/dist/runtime/hooks/lib/gate-audit.mjs +43 -0
  40. package/dist/runtime/hooks/lib/gate-loop-state.mjs +50 -0
  41. package/dist/runtime/hooks/lib/hook-message-window.mjs +121 -0
  42. package/dist/runtime/hooks/lib/skill-autoload-gate.mjs +14 -0
  43. package/dist/runtime/hooks/test-aria-preturn-memory-gate.mjs +245 -0
  44. package/dist/runtime/hooks/test-tier-lens-labeling.mjs +367 -0
  45. package/dist/runtime/manifest.json +2 -2
  46. package/dist/runtime/sdk/BUNDLED.json +2 -2
  47. package/dist/runtime/sdk/index.d.ts +39 -0
  48. package/dist/runtime/sdk/index.js +117 -0
  49. package/dist/runtime/sdk/index.js.map +1 -1
  50. package/dist/runtime/sdk/runWithGovernance.d.ts +16 -0
  51. package/dist/runtime/sdk/runWithGovernance.js +54 -0
  52. package/dist/runtime/sdk/runWithGovernance.js.map +1 -0
  53. package/dist/sdk/BUNDLED.json +2 -2
  54. package/dist/sdk/index.d.ts +39 -0
  55. package/dist/sdk/index.js +117 -0
  56. package/dist/sdk/index.js.map +1 -1
  57. package/dist/sdk/runWithGovernance.d.ts +16 -0
  58. package/dist/sdk/runWithGovernance.js +54 -0
  59. package/dist/sdk/runWithGovernance.js.map +1 -0
  60. package/hooks/aria-harness-via-sdk.mjs +16 -3
  61. package/hooks/aria-pre-tool-gate.mjs +41 -1
  62. package/hooks/aria-stop-gate.mjs +42 -1
  63. package/hooks/doctrine_trigger_map.json +43 -0
  64. package/hooks/lib/skill-autoload-gate.mjs +14 -1
  65. package/opencode-plugins/harness-context/index.js +1 -1
  66. package/opencode-plugins/harness-gate/index.js +49 -9
  67. package/opencode-plugins/harness-gate/lib/skill-autoload-gate.js +14 -1
  68. package/opencode-plugins/harness-stop/index.js +201 -166
  69. package/opencode-plugins/harness-stop/lib/skill-autoload-gate.js +14 -1
  70. package/package.json +12 -5
  71. package/runtime-src/codex-bridge.mjs +1 -1
  72. package/scripts/bundle-sdk.mjs +2 -0
  73. package/scripts/self-test-harness-gates.mjs +79 -0
  74. package/src/connectors/codex.ts +47 -0
@@ -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');
@@ -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,
@@ -408,6 +434,7 @@ import {
408
434
  loadTurnState,
409
435
  makeEvidenceRef,
410
436
  saveTurnState,
437
+ runGovernanceGate,
411
438
  emitJson,
412
439
  } from './lib/runtime-client.mjs';
413
440
 
@@ -433,6 +460,17 @@ try {
433
460
  });
434
461
  }
435
462
  const toolName = String(event?.tool_name || event?.toolName || '').trim() || null;
463
+ runGovernanceGate({
464
+ sessionId,
465
+ sourceRuntime: 'codex',
466
+ surface: 'codex-pre-tool-use',
467
+ text: JSON.stringify(event).slice(0, 8000),
468
+ action,
469
+ toolName,
470
+ isDeploy: action === 'deploy',
471
+ isMutation: action === 'write' || action === 'delete',
472
+ evidence: makeEvidenceRef('codex_tool_request', { action, toolName, target }, { sessionId }),
473
+ });
436
474
  const tools = Array.isArray(state?.tools) ? state.tools.slice(-24) : [];
437
475
  tools.push({
438
476
  at: new Date().toISOString(),
@@ -505,6 +543,7 @@ import {
505
543
  makeEvidenceRef,
506
544
  clearTurnState,
507
545
  formatValidationFailure,
546
+ runGovernanceGate,
508
547
  emitJson,
509
548
  } from './lib/runtime-client.mjs';
510
549
 
@@ -520,6 +559,14 @@ try {
520
559
  if (!text) {
521
560
  emitJson({ continue: true });
522
561
  }
562
+ runGovernanceGate({
563
+ sessionId,
564
+ sourceRuntime: 'codex',
565
+ surface: 'codex-stop',
566
+ text: text.slice(0, 8000),
567
+ isOutputCloseout: true,
568
+ evidence: outputRef,
569
+ });
523
570
  const validation = await runtimePost('/validate-output', {
524
571
  text,
525
572
  sessionId,