@aria_asi/cli 0.2.26 → 0.2.30
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/CLIENT-ONBOARDING.md +282 -0
- package/bin/aria.js +1140 -14
- package/dist/aria-connector/src/auth-commands.d.ts +1 -0
- package/dist/aria-connector/src/auth-commands.d.ts.map +1 -1
- package/dist/aria-connector/src/auth-commands.js +89 -41
- package/dist/aria-connector/src/auth-commands.js.map +1 -1
- package/dist/aria-connector/src/chat.d.ts +3 -0
- package/dist/aria-connector/src/chat.d.ts.map +1 -1
- package/dist/aria-connector/src/chat.js +146 -8
- package/dist/aria-connector/src/chat.js.map +1 -1
- package/dist/aria-connector/src/codebase-scanner.d.ts +2 -2
- package/dist/aria-connector/src/codebase-scanner.d.ts.map +1 -1
- package/dist/aria-connector/src/codebase-scanner.js +1 -1
- package/dist/aria-connector/src/codebase-scanner.js.map +1 -1
- package/dist/aria-connector/src/config.d.ts +12 -0
- package/dist/aria-connector/src/config.d.ts.map +1 -1
- package/dist/aria-connector/src/config.js +2 -0
- package/dist/aria-connector/src/config.js.map +1 -1
- package/dist/aria-connector/src/connectors/claude-code.d.ts.map +1 -1
- package/dist/aria-connector/src/connectors/claude-code.js +80 -24
- package/dist/aria-connector/src/connectors/claude-code.js.map +1 -1
- package/dist/aria-connector/src/connectors/codebase-awareness.d.ts +37 -0
- package/dist/aria-connector/src/connectors/codebase-awareness.d.ts.map +1 -0
- package/dist/aria-connector/src/connectors/codebase-awareness.js +335 -0
- package/dist/aria-connector/src/connectors/codebase-awareness.js.map +1 -0
- package/dist/aria-connector/src/connectors/codex.d.ts +3 -0
- package/dist/aria-connector/src/connectors/codex.d.ts.map +1 -0
- package/dist/aria-connector/src/connectors/codex.js +248 -0
- package/dist/aria-connector/src/connectors/codex.js.map +1 -0
- package/dist/aria-connector/src/connectors/cognitive-skills.d.ts +2 -0
- package/dist/aria-connector/src/connectors/cognitive-skills.d.ts.map +1 -0
- package/dist/aria-connector/src/connectors/cognitive-skills.js +47 -0
- package/dist/aria-connector/src/connectors/cognitive-skills.js.map +1 -0
- package/dist/aria-connector/src/connectors/opencode.d.ts.map +1 -1
- package/dist/aria-connector/src/connectors/opencode.js +90 -4
- package/dist/aria-connector/src/connectors/opencode.js.map +1 -1
- package/dist/aria-connector/src/connectors/repo-git-hooks.d.ts +3 -0
- package/dist/aria-connector/src/connectors/repo-git-hooks.d.ts.map +1 -0
- package/dist/aria-connector/src/connectors/repo-git-hooks.js +87 -0
- package/dist/aria-connector/src/connectors/repo-git-hooks.js.map +1 -0
- package/dist/aria-connector/src/connectors/repo-guard.d.ts +19 -0
- package/dist/aria-connector/src/connectors/repo-guard.d.ts.map +1 -0
- package/dist/aria-connector/src/connectors/repo-guard.js +509 -0
- package/dist/aria-connector/src/connectors/repo-guard.js.map +1 -0
- package/dist/aria-connector/src/connectors/runtime.d.ts +2 -0
- package/dist/aria-connector/src/connectors/runtime.d.ts.map +1 -0
- package/dist/aria-connector/src/connectors/runtime.js +330 -0
- package/dist/aria-connector/src/connectors/runtime.js.map +1 -0
- package/dist/aria-connector/src/connectors/shell.d.ts.map +1 -1
- package/dist/aria-connector/src/connectors/shell.js +78 -13
- package/dist/aria-connector/src/connectors/shell.js.map +1 -1
- package/dist/aria-connector/src/connectors/syncd.d.ts +27 -0
- package/dist/aria-connector/src/connectors/syncd.d.ts.map +1 -0
- package/dist/aria-connector/src/connectors/syncd.js +405 -0
- package/dist/aria-connector/src/connectors/syncd.js.map +1 -0
- package/dist/aria-connector/src/decisions.d.ts +207 -0
- package/dist/aria-connector/src/decisions.d.ts.map +1 -0
- package/dist/aria-connector/src/decisions.js +291 -0
- package/dist/aria-connector/src/decisions.js.map +1 -0
- package/dist/aria-connector/src/garden-control-plane.d.ts.map +1 -1
- package/dist/aria-connector/src/garden-control-plane.js +74 -17
- package/dist/aria-connector/src/garden-control-plane.js.map +1 -1
- package/dist/aria-connector/src/github-connect.d.ts +18 -0
- package/dist/aria-connector/src/github-connect.d.ts.map +1 -0
- package/dist/aria-connector/src/github-connect.js +117 -0
- package/dist/aria-connector/src/github-connect.js.map +1 -0
- package/dist/aria-connector/src/harness-client.d.ts +15 -0
- package/dist/aria-connector/src/harness-client.d.ts.map +1 -1
- package/dist/aria-connector/src/harness-client.js +106 -3
- package/dist/aria-connector/src/harness-client.js.map +1 -1
- package/dist/aria-connector/src/hive-client.d.ts +30 -0
- package/dist/aria-connector/src/hive-client.d.ts.map +1 -1
- package/dist/aria-connector/src/hive-client.js +124 -5
- package/dist/aria-connector/src/hive-client.js.map +1 -1
- package/dist/aria-connector/src/index.d.ts +13 -2
- package/dist/aria-connector/src/index.d.ts.map +1 -1
- package/dist/aria-connector/src/index.js +10 -1
- package/dist/aria-connector/src/index.js.map +1 -1
- package/dist/aria-connector/src/lib/aristotle-noor-wire.d.ts +102 -0
- package/dist/aria-connector/src/lib/aristotle-noor-wire.d.ts.map +1 -0
- package/dist/aria-connector/src/lib/aristotle-noor-wire.js +231 -0
- package/dist/aria-connector/src/lib/aristotle-noor-wire.js.map +1 -0
- package/dist/aria-connector/src/providers/types.d.ts +5 -0
- package/dist/aria-connector/src/providers/types.d.ts.map +1 -1
- package/dist/aria-connector/src/runtime-proof.d.ts +45 -0
- package/dist/aria-connector/src/runtime-proof.d.ts.map +1 -0
- package/dist/aria-connector/src/runtime-proof.js +340 -0
- package/dist/aria-connector/src/runtime-proof.js.map +1 -0
- package/dist/aria-connector/src/self-update.d.ts +2 -1
- package/dist/aria-connector/src/self-update.d.ts.map +1 -1
- package/dist/aria-connector/src/self-update.js +84 -8
- package/dist/aria-connector/src/self-update.js.map +1 -1
- package/dist/aria-connector/src/setup-wizard.d.ts.map +1 -1
- package/dist/aria-connector/src/setup-wizard.js +34 -2
- package/dist/aria-connector/src/setup-wizard.js.map +1 -1
- package/dist/assets/hooks/aria-agent-handoff.mjs +224 -0
- package/dist/assets/hooks/aria-agent-ledger-merge.mjs +164 -0
- package/dist/assets/hooks/aria-architect-fallback.mjs +267 -0
- package/dist/assets/hooks/aria-cognition-substrate-binding.mjs +668 -0
- package/dist/assets/hooks/aria-discovery-record.mjs +101 -0
- package/dist/assets/hooks/aria-harness-via-sdk.mjs +412 -0
- package/dist/assets/hooks/aria-import-resolution-gate.mjs +330 -0
- package/dist/assets/hooks/aria-outcome-record.mjs +84 -0
- package/dist/assets/hooks/aria-pre-emit-dryrun.mjs +294 -0
- package/dist/assets/hooks/aria-pre-text-gate.mjs +112 -0
- package/dist/assets/hooks/aria-pre-tool-gate.mjs +2133 -0
- package/dist/assets/hooks/aria-preprompt-consult.mjs +438 -0
- package/dist/assets/hooks/aria-preturn-memory-gate.mjs +570 -0
- package/dist/assets/hooks/aria-repo-doctrine-gate.mjs +397 -0
- package/dist/assets/hooks/aria-stop-gate.mjs +1551 -0
- package/dist/assets/hooks/aria-trigger-autolearn.mjs +229 -0
- package/dist/assets/hooks/aria-userprompt-abandon-detect.mjs +192 -0
- package/dist/assets/hooks/doctrine_trigger_map.json +479 -0
- package/dist/assets/hooks/lib/canonical-lenses.mjs +64 -0
- package/dist/assets/hooks/lib/gate-audit.mjs +43 -0
- package/dist/assets/hooks/test-aria-preturn-memory-gate.mjs +245 -0
- package/dist/assets/hooks/test-tier-lens-labeling.mjs +399 -0
- package/dist/assets/opencode-plugins/harness-context/index.js +60 -0
- package/dist/assets/opencode-plugins/harness-context/inject-context.mjs +179 -0
- package/dist/assets/opencode-plugins/harness-context/package.json +9 -0
- package/dist/assets/opencode-plugins/harness-gate/index.js +248 -0
- package/dist/assets/opencode-plugins/harness-outcome/index.js +129 -0
- package/dist/assets/opencode-plugins/harness-role/index.js +77 -0
- package/dist/assets/opencode-plugins/harness-role/package.json +9 -0
- package/dist/assets/opencode-plugins/harness-stop/index.js +241 -0
- package/dist/runtime/discipline/CLAUDE.md +339 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-essence/SKILL.md +63 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-essence/references/domain-matrix.md +80 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-essence/references/evolution-loop.md +30 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-essence/references/readable-cognition.md +27 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-forge-guardrails/SKILL.md +35 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-forge-guardrails/references/checklist.md +31 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-repo-doctrine/SKILL.md +39 -0
- package/dist/runtime/discipline/skills/aria-cognition/forge-quality-rules/SKILL.md +43 -0
- package/dist/runtime/discipline/skills/aria-cognition/ghazali-8lens/SKILL.md +38 -0
- package/dist/runtime/discipline/skills/aria-cognition/istiqra-induction/SKILL.md +26 -0
- package/dist/runtime/discipline/skills/aria-cognition/ladunni-22/SKILL.md +35 -0
- package/dist/runtime/discipline/skills/aria-cognition/mizan/SKILL.md +72 -0
- package/dist/runtime/discipline/skills/aria-cognition/nadia/SKILL.md +38 -0
- package/dist/runtime/discipline/skills/aria-cognition/nadia-psi/SKILL.md +38 -0
- package/dist/runtime/discipline/skills/aria-cognition/predictor/SKILL.md +25 -0
- package/dist/runtime/discipline/skills/aria-cognition/qiyas-analogy/SKILL.md +26 -0
- package/dist/runtime/discipline/skills/aria-cognition/soul-domains/SKILL.md +25 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-aristotle-intra-phase/SKILL.md +81 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-aristotle-post-phase/SKILL.md +98 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-aristotle-pre-phase/SKILL.md +99 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-deploy/SKILL.md +127 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-no-stripping/SKILL.md +117 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-onboarding/SKILL.md +112 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-output-discipline/SKILL.md +102 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-substrate-binding/SKILL.md +121 -0
- package/dist/runtime/doctor.mjs +23 -0
- package/dist/runtime/local-phase.mjs +650 -0
- package/dist/runtime/manifest.json +15 -0
- package/dist/runtime/mizan-scheduler.mjs +331 -0
- package/dist/runtime/package.json +6 -0
- package/dist/runtime/provider-proxy.mjs +594 -0
- package/dist/runtime/sdk/BUNDLED.json +5 -0
- package/dist/runtime/sdk/index.d.ts +477 -0
- package/dist/runtime/sdk/index.js +1469 -0
- package/dist/runtime/sdk/index.js.map +1 -0
- package/dist/runtime/sdk/package.json +8 -0
- package/dist/runtime/sdk/runWithCognition.d.ts +77 -0
- package/dist/runtime/sdk/runWithCognition.js +157 -0
- package/dist/runtime/sdk/runWithCognition.js.map +1 -0
- package/dist/runtime/service.mjs +3058 -0
- package/dist/runtime/vendor/aria-gate-runtime/index.d.ts +53 -0
- package/dist/runtime/vendor/aria-gate-runtime/index.d.ts.map +1 -0
- package/dist/runtime/vendor/aria-gate-runtime/index.js +292 -0
- package/dist/runtime/vendor/aria-gate-runtime/index.js.map +1 -0
- package/dist/runtime/vendor/aria-gate-runtime/package.json +6 -0
- package/dist/sdk/BUNDLED.json +2 -2
- package/dist/sdk/index.d.ts +283 -0
- package/dist/sdk/index.js +622 -85
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/runWithCognition.d.ts +77 -0
- package/dist/sdk/runWithCognition.js +157 -0
- package/dist/sdk/runWithCognition.js.map +1 -0
- package/hooks/aria-agent-handoff.mjs +11 -1
- package/hooks/aria-architect-fallback.mjs +109 -40
- package/hooks/aria-cognition-substrate-binding.mjs +668 -0
- package/hooks/aria-harness-via-sdk.mjs +34 -21
- package/hooks/aria-import-resolution-gate.mjs +330 -0
- package/hooks/aria-outcome-record.mjs +5 -1
- package/hooks/aria-pre-emit-dryrun.mjs +294 -0
- package/hooks/aria-pre-tool-gate.mjs +828 -41
- package/hooks/aria-preprompt-consult.mjs +113 -13
- package/hooks/aria-preturn-memory-gate.mjs +298 -6
- package/hooks/aria-repo-doctrine-gate.mjs +397 -0
- package/hooks/aria-stop-gate.mjs +739 -76
- package/hooks/aria-userprompt-abandon-detect.mjs +5 -1
- package/hooks/doctrine_trigger_map.json +209 -15
- package/hooks/lib/canonical-lenses.mjs +64 -0
- package/hooks/lib/gate-audit.mjs +43 -0
- package/opencode-plugins/harness-context/index.js +1 -1
- package/opencode-plugins/harness-context/inject-context.mjs +82 -23
- package/opencode-plugins/harness-gate/index.js +248 -0
- package/opencode-plugins/harness-outcome/index.js +129 -0
- package/opencode-plugins/harness-stop/index.js +241 -0
- package/package.json +9 -3
- package/runtime-src/doctor.mjs +23 -0
- package/runtime-src/local-phase.mjs +650 -0
- package/runtime-src/mizan-scheduler.mjs +331 -0
- package/runtime-src/provider-proxy.mjs +594 -0
- package/runtime-src/service.mjs +3058 -0
- package/scripts/bundle-sdk.mjs +317 -0
- package/scripts/install-client.sh +176 -0
- package/scripts/publish-all.sh +344 -0
- package/scripts/publish-docker.sh +27 -0
- package/scripts/validate-hook-contracts.mjs +54 -0
- package/scripts/validate-skill-prompts.mjs +95 -0
- package/skills/aria-cognition/aria-essence/SKILL.md +63 -0
- package/skills/aria-cognition/aria-essence/references/domain-matrix.md +80 -0
- package/skills/aria-cognition/aria-essence/references/evolution-loop.md +30 -0
- package/skills/aria-cognition/aria-essence/references/readable-cognition.md +27 -0
- package/skills/aria-cognition/aria-forge-guardrails/SKILL.md +35 -0
- package/skills/aria-cognition/aria-forge-guardrails/references/checklist.md +31 -0
- package/skills/aria-cognition/aria-repo-doctrine/SKILL.md +39 -0
- package/skills/aria-cognition/forge-quality-rules/SKILL.md +43 -0
- package/skills/aria-cognition/ghazali-8lens/SKILL.md +38 -0
- package/skills/aria-cognition/istiqra-induction/SKILL.md +26 -0
- package/skills/aria-cognition/ladunni-22/SKILL.md +35 -0
- package/skills/aria-cognition/mizan/SKILL.md +72 -0
- package/skills/aria-cognition/nadia/SKILL.md +38 -0
- package/skills/aria-cognition/nadia-psi/SKILL.md +38 -0
- package/skills/aria-cognition/predictor/SKILL.md +25 -0
- package/skills/aria-cognition/qiyas-analogy/SKILL.md +26 -0
- package/skills/aria-cognition/soul-domains/SKILL.md +25 -0
- package/src/auth-commands.ts +111 -45
- package/src/chat.ts +174 -13
- package/src/codebase-scanner.ts +4 -0
- package/src/config.ts +15 -0
- package/src/connectors/claude-code.ts +79 -25
- package/src/connectors/codebase-awareness.ts +408 -0
- package/src/connectors/codex.ts +274 -0
- package/src/connectors/cognitive-skills.ts +51 -0
- package/src/connectors/opencode.ts +93 -4
- package/src/connectors/repo-git-hooks.ts +86 -0
- package/src/connectors/repo-guard.ts +589 -0
- package/src/connectors/runtime.ts +374 -0
- package/src/connectors/shell.ts +83 -14
- package/src/connectors/syncd.ts +488 -0
- package/src/decisions.ts +469 -0
- package/src/garden-control-plane.ts +101 -26
- package/src/github-connect.ts +143 -0
- package/src/harness-client.ts +128 -3
- package/src/hive-client.ts +165 -5
- package/src/index.ts +41 -2
- package/src/lib/aristotle-noor-wire.ts +310 -0
- package/src/providers/types.ts +6 -0
- package/src/runtime-proof.ts +392 -0
- package/src/self-update.ts +89 -8
- package/src/setup-wizard.ts +37 -2
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
// ARIA_ALLOW_STUB: doctrine strings only; this source generates enforcement copy and is not a production stub implementation.
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
existsSync,
|
|
5
|
+
mkdirSync,
|
|
6
|
+
readdirSync,
|
|
7
|
+
statSync,
|
|
8
|
+
copyFileSync,
|
|
9
|
+
chmodSync,
|
|
10
|
+
writeFileSync,
|
|
11
|
+
} from 'fs';
|
|
12
|
+
import { homedir } from 'os';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
import { fileURLToPath } from 'node:url';
|
|
15
|
+
import type { AriaConfig } from '../config.js';
|
|
16
|
+
import { connectShell } from './shell.js';
|
|
17
|
+
import { installAriaCognitionSkills } from './cognitive-skills.js';
|
|
18
|
+
|
|
19
|
+
function packageSdkDir(): string {
|
|
20
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
return path.resolve(here, '..', '..', '..', 'sdk');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function installSdk(codexDir: string, logs: string[]): void {
|
|
25
|
+
const sdkSrc = packageSdkDir();
|
|
26
|
+
if (!existsSync(sdkSrc)) {
|
|
27
|
+
logs.push(`⚠ SDK bundle missing: ${sdkSrc} (run npm run build)`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const sdkDst = path.join(codexDir, 'aria-sdk');
|
|
32
|
+
if (!existsSync(sdkDst)) {
|
|
33
|
+
mkdirSync(sdkDst, { recursive: true, mode: 0o700 });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let copied = 0;
|
|
37
|
+
for (const name of readdirSync(sdkSrc)) {
|
|
38
|
+
const src = path.join(sdkSrc, name);
|
|
39
|
+
if (!statSync(src).isFile()) continue;
|
|
40
|
+
copyFileSync(src, path.join(sdkDst, name));
|
|
41
|
+
copied++;
|
|
42
|
+
}
|
|
43
|
+
logs.push(`Installed Aria SDK (${copied} files) → ${sdkDst}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function installNodePackage(codexDir: string, logs: string[]): void {
|
|
47
|
+
const sdkSrc = packageSdkDir();
|
|
48
|
+
if (!existsSync(sdkSrc)) return;
|
|
49
|
+
|
|
50
|
+
const pkgRoot = path.join(codexDir, 'node_modules', '@aria_asi', 'harness-http-client');
|
|
51
|
+
const distRoot = path.join(pkgRoot, 'dist');
|
|
52
|
+
mkdirSync(distRoot, { recursive: true, mode: 0o755 });
|
|
53
|
+
|
|
54
|
+
for (const name of readdirSync(sdkSrc)) {
|
|
55
|
+
const src = path.join(sdkSrc, name);
|
|
56
|
+
if (!statSync(src).isFile()) continue;
|
|
57
|
+
if (name === 'package.json' || name === 'BUNDLED.json') continue;
|
|
58
|
+
copyFileSync(src, path.join(distRoot, name));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
writeFileSync(
|
|
62
|
+
path.join(pkgRoot, 'package.json'),
|
|
63
|
+
JSON.stringify({
|
|
64
|
+
name: '@aria_asi/harness-http-client',
|
|
65
|
+
version: '0.1.1',
|
|
66
|
+
description: 'Bundled Aria harness HTTP client for Codex installs',
|
|
67
|
+
type: 'module',
|
|
68
|
+
main: './dist/index.js',
|
|
69
|
+
types: './dist/index.d.ts',
|
|
70
|
+
exports: {
|
|
71
|
+
'.': {
|
|
72
|
+
types: './dist/index.d.ts',
|
|
73
|
+
import: './dist/index.js',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
private: false,
|
|
77
|
+
}, null, 2) + '\n',
|
|
78
|
+
{ mode: 0o644 },
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
logs.push(`Installed Codex Node package → ${pkgRoot}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function buildCodexSkill(_config: AriaConfig): string {
|
|
85
|
+
return `---
|
|
86
|
+
name: aria-http-harness-client
|
|
87
|
+
description: "Use when the task needs Aria's canonical HTTP harness client from Codex, including HTTPHarnessClient imports, harness packet fetch and injection, consult calls, output validation, claim verification, discovery recording, garden turns, or harness-bound worker handoff. Trigger on \\"$aria-http-harness-client\\", \\"HTTPHarnessClient\\", \\"@aria_asi/harness-http-client\\", \\"harness client\\", \\"Aria harness SDK\\", \\"consult via harness\\", \\"verify claim\\", or \\"garden turn\\"."
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
# Aria HTTP Harness Client
|
|
91
|
+
|
|
92
|
+
Use this skill when Codex should route through Aria's canonical harness control plane instead of inventing an ad hoc wrapper.
|
|
93
|
+
|
|
94
|
+
## Installed Paths
|
|
95
|
+
|
|
96
|
+
- Shared runtime bundle: \`${path.join(homedir(), '.aria', 'sdk')}\`
|
|
97
|
+
- Codex local bundle: \`${path.join(homedir(), '.codex', 'aria-sdk')}\`
|
|
98
|
+
- Node import package: \`${path.join(homedir(), '.codex', 'node_modules', '@aria_asi', 'harness-http-client')}\`
|
|
99
|
+
- Smoke script: \`${path.join(homedir(), '.codex', 'skills', 'aria-http-harness-client', 'scripts', 'smoke.mjs')}\`
|
|
100
|
+
- Mounted runtime: \`http://127.0.0.1:4319\`
|
|
101
|
+
|
|
102
|
+
## Core Rule
|
|
103
|
+
|
|
104
|
+
Do not hardcode Aria tokens into code or the skill. Read them from environment variables such as \`ARIA_API_KEY\` or \`ARIA_MASTER_TOKEN\`, or retrieve them at runtime from the live environment.
|
|
105
|
+
|
|
106
|
+
## Reality Check
|
|
107
|
+
|
|
108
|
+
Codex should prefer the mounted runtime first, then the shared SDK, then the Codex-local SDK bundle.
|
|
109
|
+
|
|
110
|
+
That means:
|
|
111
|
+
|
|
112
|
+
- the mounted runtime is the universal control plane
|
|
113
|
+
- the shared SDK at \`~/.aria/sdk\` is the universal client substrate
|
|
114
|
+
- Codex still does not expose Claude-style native user hook interception, so explicit runtime or SDK calls are still required for hard guarantees on this platform
|
|
115
|
+
|
|
116
|
+
## Preferred Call Paths
|
|
117
|
+
|
|
118
|
+
Use the mounted runtime whenever possible:
|
|
119
|
+
|
|
120
|
+
\`\`\`bash
|
|
121
|
+
curl -s http://127.0.0.1:4319/health
|
|
122
|
+
\`\`\`
|
|
123
|
+
|
|
124
|
+
or from Node:
|
|
125
|
+
|
|
126
|
+
\`\`\`js
|
|
127
|
+
import { HTTPHarnessClient } from '@aria_asi/harness-http-client';
|
|
128
|
+
\`\`\`
|
|
129
|
+
|
|
130
|
+
## Fast Verification
|
|
131
|
+
|
|
132
|
+
Run:
|
|
133
|
+
|
|
134
|
+
\`\`\`bash
|
|
135
|
+
node ${path.join(homedir(), '.codex', 'skills', 'aria-http-harness-client', 'scripts', 'smoke.mjs')}
|
|
136
|
+
\`\`\`
|
|
137
|
+
|
|
138
|
+
For a live packet fetch, set \`ARIA_API_KEY\` or \`ARIA_MASTER_TOKEN\`, then run:
|
|
139
|
+
|
|
140
|
+
\`\`\`bash
|
|
141
|
+
node ${path.join(homedir(), '.codex', 'skills', 'aria-http-harness-client', 'scripts', 'smoke.mjs')} --packet
|
|
142
|
+
\`\`\`
|
|
143
|
+
`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function buildCodexAgentsMd(config: AriaConfig): string {
|
|
147
|
+
const repoList = config.repositories.map((r) => `- ${r.name} (${r.path})`).join('\n');
|
|
148
|
+
const schemaText = Object.entries(config.schemaImages)
|
|
149
|
+
.map(([name, image]) => `### ${name}\n${image}`)
|
|
150
|
+
.join('\n\n');
|
|
151
|
+
|
|
152
|
+
return `# Aria Harness — AGENTS.md
|
|
153
|
+
|
|
154
|
+
Automatically injected by @aria_asi/cli. These instructions are always on for Codex sessions.
|
|
155
|
+
|
|
156
|
+
## Connected Repositories
|
|
157
|
+
${repoList || '(none linked yet)'}
|
|
158
|
+
|
|
159
|
+
## Schema Images
|
|
160
|
+
${schemaText || '(no schema images yet — run \`aria repo scan\`)'}
|
|
161
|
+
|
|
162
|
+
## Self-Gate Protocol
|
|
163
|
+
1. Truth over deception — always.
|
|
164
|
+
2. No harm supersedes any advantage.
|
|
165
|
+
3. Sacred trust — never betray.
|
|
166
|
+
4. Power obligates service.
|
|
167
|
+
5. Reflection before action.
|
|
168
|
+
|
|
169
|
+
## Repo Doctrine
|
|
170
|
+
- Treat any repo edit, hook, runtime change, smoke script, migration, scaffold, or quick fix as production-intent unless it is clearly isolated under tests, specs, fixtures, examples, demos, or mocks.
|
|
171
|
+
- Never introduce stub, mock, fake, placeholder, "implementation pending", "not implemented", "coming soon", or "will be wired" semantics into doctrine-bound production paths.
|
|
172
|
+
- If verification needs a script, hit the real runtime, real endpoint, real handler, or real diff. Do not author fake validation just to satisfy a step.
|
|
173
|
+
- If a fix only works by weakening the contract, the mechanism is still broken. Debug the mechanism.
|
|
174
|
+
|
|
175
|
+
## 8-Lens Cognition
|
|
176
|
+
Apply multi-perspective analysis for every decision:
|
|
177
|
+
- Truth lens: Is this factually correct?
|
|
178
|
+
- Harm lens: Could this cause damage?
|
|
179
|
+
- Trust lens: Does this maintain sacred trust?
|
|
180
|
+
- Power lens: Am I using capability responsibly?
|
|
181
|
+
- Reflection lens: Have I thought deeply enough?
|
|
182
|
+
- Context lens: Do I have full context?
|
|
183
|
+
- Impact lens: What are second-order effects?
|
|
184
|
+
- Beauty lens: Is this elegant and sustainable?
|
|
185
|
+
`;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function buildSmokeScript(): string {
|
|
189
|
+
return `#!/usr/bin/env node
|
|
190
|
+
|
|
191
|
+
import { HTTPHarnessClient } from '@aria_asi/harness-http-client';
|
|
192
|
+
|
|
193
|
+
const args = new Set(process.argv.slice(2));
|
|
194
|
+
const wantsPacket = args.has('--packet');
|
|
195
|
+
|
|
196
|
+
const runtimeUrl = (process.env.ARIA_RUNTIME_URL || 'http://127.0.0.1:4319').replace(/\\/+$/, '');
|
|
197
|
+
let runtimeStatus = 'unreachable';
|
|
198
|
+
try {
|
|
199
|
+
const health = await fetch(\`\${runtimeUrl}/health\`);
|
|
200
|
+
if (health.ok) runtimeStatus = 'ok';
|
|
201
|
+
} catch {}
|
|
202
|
+
|
|
203
|
+
const proto = HTTPHarnessClient.prototype;
|
|
204
|
+
const methods = Object.getOwnPropertyNames(proto)
|
|
205
|
+
.filter((name) => name !== 'constructor' && typeof proto[name] === 'function')
|
|
206
|
+
.sort();
|
|
207
|
+
|
|
208
|
+
console.log('module=@aria_asi/harness-http-client');
|
|
209
|
+
console.log('class=HTTPHarnessClient');
|
|
210
|
+
console.log(\`runtime=\${runtimeUrl}\`);
|
|
211
|
+
console.log(\`runtime_status=\${runtimeStatus}\`);
|
|
212
|
+
console.log(\`methods=\${methods.join(',')}\`);
|
|
213
|
+
|
|
214
|
+
if (!wantsPacket) process.exit(0);
|
|
215
|
+
|
|
216
|
+
const apiKey = process.env.ARIA_API_KEY || process.env.ARIA_MASTER_TOKEN;
|
|
217
|
+
if (!apiKey) {
|
|
218
|
+
console.error('missing ARIA_API_KEY or ARIA_MASTER_TOKEN');
|
|
219
|
+
process.exit(1);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const baseUrl =
|
|
223
|
+
process.env.ARIA_HARNESS_BASE_URL ||
|
|
224
|
+
process.env.ARIA_HARNESS_URL ||
|
|
225
|
+
'https://harness.ariasos.com';
|
|
226
|
+
const client = new HTTPHarnessClient({ baseUrl, apiKey });
|
|
227
|
+
const packet = await client.getHarnessPacket({
|
|
228
|
+
sessionId: process.env.ARIA_HARNESS_SESSION_ID || 'codex-harness-smoke',
|
|
229
|
+
platform: 'codex',
|
|
230
|
+
message: 'refresh',
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
console.log(\`packetVersion=\${packet.version || 'unknown'}\`);
|
|
234
|
+
console.log(\`packetTimestamp=\${packet.timestamp || 'unknown'}\`);
|
|
235
|
+
console.log(\`packetKeys=\${Object.keys(packet.packet || {}).join(',')}\`);
|
|
236
|
+
`;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function installSkill(codexDir: string, config: AriaConfig, logs: string[]): void {
|
|
240
|
+
const skillDir = path.join(codexDir, 'skills', 'aria-http-harness-client');
|
|
241
|
+
const scriptDir = path.join(skillDir, 'scripts');
|
|
242
|
+
mkdirSync(scriptDir, { recursive: true, mode: 0o755 });
|
|
243
|
+
|
|
244
|
+
writeFileSync(path.join(skillDir, 'SKILL.md'), buildCodexSkill(config), { mode: 0o644 });
|
|
245
|
+
const smokePath = path.join(scriptDir, 'smoke.mjs');
|
|
246
|
+
writeFileSync(smokePath, buildSmokeScript(), { mode: 0o755 });
|
|
247
|
+
try { chmodSync(smokePath, 0o755); } catch {}
|
|
248
|
+
|
|
249
|
+
logs.push(`Installed Codex harness skill → ${skillDir}`);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function installAgentsMd(codexDir: string, config: AriaConfig, logs: string[]): void {
|
|
253
|
+
const agentsPath = path.join(codexDir, 'AGENTS.md');
|
|
254
|
+
writeFileSync(agentsPath, buildCodexAgentsMd(config), { mode: 0o644 });
|
|
255
|
+
logs.push(`Installed Codex AGENTS.md → ${agentsPath}`);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export async function connectCodex(config: AriaConfig): Promise<string[]> {
|
|
259
|
+
const logs: string[] = [];
|
|
260
|
+
const codexDir = path.join(homedir(), '.codex');
|
|
261
|
+
|
|
262
|
+
if (!existsSync(codexDir)) {
|
|
263
|
+
mkdirSync(codexDir, { recursive: true, mode: 0o700 });
|
|
264
|
+
logs.push(`Created ${codexDir}`);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
installSdk(codexDir, logs);
|
|
268
|
+
installNodePackage(codexDir, logs);
|
|
269
|
+
installAgentsMd(codexDir, config, logs);
|
|
270
|
+
installSkill(codexDir, config, logs);
|
|
271
|
+
installAriaCognitionSkills(codexDir, logs);
|
|
272
|
+
logs.push(...await connectShell('codex', config));
|
|
273
|
+
return logs;
|
|
274
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, statSync, copyFileSync } from 'fs';
|
|
2
|
+
import { homedir } from 'os';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
function packageSkillsRoot(): string {
|
|
7
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const candidates = [
|
|
9
|
+
path.resolve(here, '..', '..', '..', '..', 'skills', 'aria-cognition'),
|
|
10
|
+
path.resolve(here, '..', '..', '..', 'runtime', 'discipline', 'skills', 'aria-cognition'),
|
|
11
|
+
];
|
|
12
|
+
const found = candidates.find((candidate) => existsSync(candidate));
|
|
13
|
+
return found || candidates[0];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function copyTree(srcDir: string, dstDir: string): void {
|
|
17
|
+
mkdirSync(dstDir, { recursive: true, mode: 0o755 });
|
|
18
|
+
for (const name of readdirSync(srcDir)) {
|
|
19
|
+
const src = path.join(srcDir, name);
|
|
20
|
+
const dst = path.join(dstDir, name);
|
|
21
|
+
const stat = statSync(src);
|
|
22
|
+
if (stat.isDirectory()) {
|
|
23
|
+
copyTree(src, dst);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
copyFileSync(src, dst);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function installAriaCognitionSkills(codexDir: string, logs: string[]): void {
|
|
31
|
+
const skillsRoot = packageSkillsRoot();
|
|
32
|
+
if (!existsSync(skillsRoot)) {
|
|
33
|
+
logs.push(`⚠ Aria cognition skill pack missing: ${skillsRoot}`);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const codexSkillsDir = path.join(codexDir, 'skills');
|
|
38
|
+
const agentSkillsDir = path.join(homedir(), '.agents', 'skills');
|
|
39
|
+
mkdirSync(codexSkillsDir, { recursive: true, mode: 0o755 });
|
|
40
|
+
mkdirSync(agentSkillsDir, { recursive: true, mode: 0o755 });
|
|
41
|
+
|
|
42
|
+
for (const skillName of readdirSync(skillsRoot)) {
|
|
43
|
+
const src = path.join(skillsRoot, skillName);
|
|
44
|
+
if (!statSync(src).isDirectory()) continue;
|
|
45
|
+
copyTree(src, path.join(codexSkillsDir, skillName));
|
|
46
|
+
copyTree(src, path.join(agentSkillsDir, skillName));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
logs.push(`Installed Aria cognition skills → ${codexSkillsDir}`);
|
|
50
|
+
logs.push(`Installed Aria cognition skills → ${agentSkillsDir}`);
|
|
51
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// ARIA_ALLOW_STUB: doctrine strings only; this source generates enforcement copy and is not a production stub implementation.
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
4
|
existsSync,
|
|
3
5
|
mkdirSync,
|
|
@@ -13,14 +15,15 @@ import { homedir } from 'os';
|
|
|
13
15
|
import * as path from 'path';
|
|
14
16
|
import { fileURLToPath } from 'node:url';
|
|
15
17
|
import type { AriaConfig } from '../config.js';
|
|
18
|
+
import { connectShell } from './shell.js';
|
|
16
19
|
|
|
17
20
|
// ── Bundled OpenCode plugins ────────────────────────────────────────────────
|
|
18
21
|
//
|
|
19
22
|
// Two plugins ship with the connector:
|
|
20
23
|
// - harness-context: spawns the bundled inject-context.mjs on session start
|
|
21
24
|
// and prepends the resolved harness packet to OpenCode's
|
|
22
|
-
// system prompt. Routes through the
|
|
23
|
-
// ~/.
|
|
25
|
+
// system prompt. Routes through the mounted runtime
|
|
26
|
+
// first, then the shared SDK at ~/.aria/sdk/.
|
|
24
27
|
// - harness-role: injects the active role profile (default
|
|
25
28
|
// opencode_deepseek_engineer) — intro / continuity /
|
|
26
29
|
// post-action governance rules.
|
|
@@ -33,11 +36,17 @@ import type { AriaConfig } from '../config.js';
|
|
|
33
36
|
// <pkg>/dist/aria-connector/src/connectors/opencode.js
|
|
34
37
|
// Plugins ship at <pkg>/opencode-plugins/ → 4 dirs up + 'opencode-plugins'.
|
|
35
38
|
|
|
36
|
-
const PLUGIN_NAMES = ['harness-context', 'harness-role'] as const;
|
|
39
|
+
const PLUGIN_NAMES = ['harness-context', 'harness-role', 'harness-gate', 'harness-stop', 'harness-outcome'] as const;
|
|
40
|
+
const LOCAL_RUNTIME_V1_URL = 'http://127.0.0.1:4319/v1';
|
|
37
41
|
|
|
38
42
|
function packageOpenCodePluginsDir(): string {
|
|
39
43
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
40
|
-
|
|
44
|
+
const candidates = [
|
|
45
|
+
path.resolve(here, '..', '..', '..', '..', 'opencode-plugins'),
|
|
46
|
+
path.resolve(here, '..', '..', '..', 'assets', 'opencode-plugins'),
|
|
47
|
+
];
|
|
48
|
+
const found = candidates.find((candidate) => existsSync(candidate));
|
|
49
|
+
return found || candidates[0];
|
|
41
50
|
}
|
|
42
51
|
|
|
43
52
|
function copyPluginDir(srcDir: string, dstDir: string, logs: string[]): void {
|
|
@@ -61,6 +70,30 @@ function copyPluginDir(srcDir: string, dstDir: string, logs: string[]): void {
|
|
|
61
70
|
logs.push(`Installed plugin → ${dstDir}`);
|
|
62
71
|
}
|
|
63
72
|
|
|
73
|
+
function resolveLocalRuntimeToken(): string {
|
|
74
|
+
if (process.env.ARIA_HARNESS_TOKEN) return process.env.ARIA_HARNESS_TOKEN;
|
|
75
|
+
if (process.env.ARIA_API_KEY) return process.env.ARIA_API_KEY;
|
|
76
|
+
if (process.env.ARIA_MASTER_TOKEN) return process.env.ARIA_MASTER_TOKEN;
|
|
77
|
+
|
|
78
|
+
const ownerTokenPath = path.join(homedir(), '.aria', 'owner-token');
|
|
79
|
+
if (existsSync(ownerTokenPath)) {
|
|
80
|
+
try {
|
|
81
|
+
const token = readFileSync(ownerTokenPath, 'utf8').trim();
|
|
82
|
+
if (token) return token;
|
|
83
|
+
} catch {}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const licensePath = path.join(homedir(), '.aria', 'license.json');
|
|
87
|
+
if (existsSync(licensePath)) {
|
|
88
|
+
try {
|
|
89
|
+
const license = JSON.parse(readFileSync(licensePath, 'utf8'));
|
|
90
|
+
if (typeof license?.token === 'string' && license.token.trim()) return license.token.trim();
|
|
91
|
+
} catch {}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return '';
|
|
95
|
+
}
|
|
96
|
+
|
|
64
97
|
export async function connectOpenCode(config: AriaConfig): Promise<string[]> {
|
|
65
98
|
const logs: string[] = [];
|
|
66
99
|
const opencodeDir = path.join(homedir(), '.opencode');
|
|
@@ -161,6 +194,55 @@ export async function connectOpenCode(config: AriaConfig): Promise<string[]> {
|
|
|
161
194
|
logs.push('Set OpenCode AGENTS.md path to ~/.aria/AGENTS.md');
|
|
162
195
|
}
|
|
163
196
|
|
|
197
|
+
const providerMap = opencodeConfig.provider && typeof opencodeConfig.provider === 'object'
|
|
198
|
+
? opencodeConfig.provider as Record<string, unknown>
|
|
199
|
+
: {};
|
|
200
|
+
const currentAriaProvider = providerMap.aria && typeof providerMap.aria === 'object'
|
|
201
|
+
? providerMap.aria as Record<string, unknown>
|
|
202
|
+
: {};
|
|
203
|
+
const localToken = resolveLocalRuntimeToken();
|
|
204
|
+
const nextAriaProvider = {
|
|
205
|
+
npm: '@ai-sdk/openai-compatible',
|
|
206
|
+
name: 'Aria Runtime',
|
|
207
|
+
endpoint: LOCAL_RUNTIME_V1_URL,
|
|
208
|
+
apiKey: localToken || (typeof currentAriaProvider.apiKey === 'string' ? currentAriaProvider.apiKey : ''),
|
|
209
|
+
};
|
|
210
|
+
const currentEndpoint = typeof currentAriaProvider.endpoint === 'string' ? currentAriaProvider.endpoint : '';
|
|
211
|
+
const currentApiKey = typeof currentAriaProvider.apiKey === 'string' ? currentAriaProvider.apiKey : '';
|
|
212
|
+
const currentName = typeof currentAriaProvider.name === 'string' ? currentAriaProvider.name : '';
|
|
213
|
+
const currentNpm = typeof currentAriaProvider.npm === 'string' ? currentAriaProvider.npm : '';
|
|
214
|
+
if (
|
|
215
|
+
currentEndpoint !== nextAriaProvider.endpoint ||
|
|
216
|
+
currentApiKey !== nextAriaProvider.apiKey ||
|
|
217
|
+
currentName !== nextAriaProvider.name ||
|
|
218
|
+
currentNpm !== nextAriaProvider.npm
|
|
219
|
+
) {
|
|
220
|
+
opencodeConfig.provider = {
|
|
221
|
+
...providerMap,
|
|
222
|
+
aria: nextAriaProvider,
|
|
223
|
+
};
|
|
224
|
+
modified = true;
|
|
225
|
+
logs.push('Rewired OpenCode aria provider to the mounted local runtime');
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const enabledProviders = Array.isArray(opencodeConfig.enabled_providers)
|
|
229
|
+
? (opencodeConfig.enabled_providers as unknown[]).filter((entry): entry is string => typeof entry === 'string')
|
|
230
|
+
: [];
|
|
231
|
+
if (!enabledProviders.includes('aria')) {
|
|
232
|
+
opencodeConfig.enabled_providers = ['aria', ...enabledProviders];
|
|
233
|
+
modified = true;
|
|
234
|
+
logs.push('Enabled OpenCode aria provider');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (Array.isArray(opencodeConfig.disabled_providers)) {
|
|
238
|
+
const nextDisabled = (opencodeConfig.disabled_providers as unknown[]).filter((entry) => entry !== 'aria');
|
|
239
|
+
if (nextDisabled.length !== (opencodeConfig.disabled_providers as unknown[]).length) {
|
|
240
|
+
opencodeConfig.disabled_providers = nextDisabled;
|
|
241
|
+
modified = true;
|
|
242
|
+
logs.push('Removed aria from OpenCode disabled providers');
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
164
246
|
if (modified) {
|
|
165
247
|
writeFileSync(configPath, JSON.stringify(opencodeConfig, null, 2));
|
|
166
248
|
} else {
|
|
@@ -180,6 +262,7 @@ export async function connectOpenCode(config: AriaConfig): Promise<string[]> {
|
|
|
180
262
|
const agentsContent = buildOpenCodeAgentsMd(config);
|
|
181
263
|
writeFileSync(ariaAgentsPath, agentsContent);
|
|
182
264
|
logs.push(`Wrote Aria harness AGENTS.md to ${ariaAgentsPath}`);
|
|
265
|
+
logs.push(...await connectShell('opencode', config));
|
|
183
266
|
|
|
184
267
|
return logs;
|
|
185
268
|
}
|
|
@@ -247,6 +330,12 @@ ${schemaText || '(no schema images yet — run \`aria repo scan\`)'}
|
|
|
247
330
|
4. Power obligates service.
|
|
248
331
|
5. Reflection before action.
|
|
249
332
|
|
|
333
|
+
## Repo Doctrine
|
|
334
|
+
- Treat any repo edit, hook, runtime change, smoke script, migration, scaffold, or quick fix as production-intent unless it is clearly isolated under tests, specs, fixtures, examples, demos, or mocks.
|
|
335
|
+
- Never introduce stub, mock, fake, placeholder, "implementation pending", "not implemented", "coming soon", or "will be wired" semantics into doctrine-bound production paths.
|
|
336
|
+
- If verification needs a script, hit the real runtime, real endpoint, real handler, or real diff. Do not author fake validation just to satisfy a step.
|
|
337
|
+
- If a fix only works by weakening the contract, the mechanism is still broken. Debug the mechanism.
|
|
338
|
+
|
|
250
339
|
## 8-Lens Cognition
|
|
251
340
|
Apply multi-perspective analysis for every decision:
|
|
252
341
|
- Truth lens: Is this factually correct?
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { chmodSync, copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'fs';
|
|
2
|
+
import { execFileSync } from 'child_process';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import type { AriaConfig } from '../config.js';
|
|
5
|
+
|
|
6
|
+
function resolveGitDir(repoPath: string): string | null {
|
|
7
|
+
try {
|
|
8
|
+
const raw = execFileSync('git', ['-C', repoPath, 'rev-parse', '--git-dir'], {
|
|
9
|
+
encoding: 'utf8',
|
|
10
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
11
|
+
}).trim();
|
|
12
|
+
return path.isAbsolute(raw) ? raw : path.join(repoPath, raw);
|
|
13
|
+
} catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function writeHook(hooksDir: string, hookName: 'pre-commit' | 'pre-push', logs: string[]): void {
|
|
19
|
+
const hookPath = path.join(hooksDir, hookName);
|
|
20
|
+
const prevPath = `${hookPath}.pre-aria`;
|
|
21
|
+
const marker = 'ARIA_REPO_DOCTRINE_GATE';
|
|
22
|
+
|
|
23
|
+
if (existsSync(hookPath)) {
|
|
24
|
+
try {
|
|
25
|
+
const existing = readFileSync(hookPath, 'utf8');
|
|
26
|
+
if (!existing.includes(marker) && !existsSync(prevPath)) {
|
|
27
|
+
renameSync(hookPath, prevPath);
|
|
28
|
+
logs.push(`Backed up existing ${hookName} hook → ${path.basename(prevPath)}`);
|
|
29
|
+
} else if (existing.includes(marker)) {
|
|
30
|
+
// We overwrite our own wrapper idempotently below.
|
|
31
|
+
}
|
|
32
|
+
} catch {}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const body = hookName === 'pre-push'
|
|
36
|
+
? `#!/usr/bin/env bash
|
|
37
|
+
set -euo pipefail
|
|
38
|
+
# ${marker}
|
|
39
|
+
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
40
|
+
TMP_INPUT="$(mktemp)"
|
|
41
|
+
cat > "$TMP_INPUT"
|
|
42
|
+
cleanup() { rm -f "$TMP_INPUT"; }
|
|
43
|
+
trap cleanup EXIT
|
|
44
|
+
if [[ -x "$HOOK_DIR/${hookName}.pre-aria" ]]; then
|
|
45
|
+
"$HOOK_DIR/${hookName}.pre-aria" "$@" < "$TMP_INPUT"
|
|
46
|
+
fi
|
|
47
|
+
node "$HOME/.claude/hooks/aria-repo-doctrine-gate.mjs" --mode push --repo "$(git rev-parse --show-toplevel 2>/dev/null || pwd)" "$@" < "$TMP_INPUT"
|
|
48
|
+
`
|
|
49
|
+
: `#!/usr/bin/env bash
|
|
50
|
+
set -euo pipefail
|
|
51
|
+
# ${marker}
|
|
52
|
+
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
53
|
+
if [[ -x "$HOOK_DIR/${hookName}.pre-aria" ]]; then
|
|
54
|
+
"$HOOK_DIR/${hookName}.pre-aria" "$@"
|
|
55
|
+
fi
|
|
56
|
+
exec node "$HOME/.claude/hooks/aria-repo-doctrine-gate.mjs" --mode staged --repo "$(git rev-parse --show-toplevel 2>/dev/null || pwd)" "$@"
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
writeFileSync(hookPath, body, { mode: 0o755 });
|
|
60
|
+
try { chmodSync(hookPath, 0o755); } catch {}
|
|
61
|
+
logs.push(`Installed ${hookName} doctrine gate → ${hookPath}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function installRepoDoctrineGitHooks(config: AriaConfig, fallbackRepoPath?: string): Promise<string[]> {
|
|
65
|
+
const logs: string[] = [];
|
|
66
|
+
const repoSet = new Set<string>();
|
|
67
|
+
for (const repo of config.repositories || []) {
|
|
68
|
+
if (repo.path) repoSet.add(repo.path);
|
|
69
|
+
}
|
|
70
|
+
if (fallbackRepoPath) repoSet.add(fallbackRepoPath);
|
|
71
|
+
else repoSet.add(process.cwd());
|
|
72
|
+
|
|
73
|
+
for (const repoPath of repoSet) {
|
|
74
|
+
const gitDir = resolveGitDir(repoPath);
|
|
75
|
+
if (!gitDir) {
|
|
76
|
+
logs.push(`Skipped repo doctrine hooks (not a git repo): ${repoPath}`);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const hooksDir = path.join(gitDir, 'hooks');
|
|
80
|
+
mkdirSync(hooksDir, { recursive: true, mode: 0o755 });
|
|
81
|
+
writeHook(hooksDir, 'pre-commit', logs);
|
|
82
|
+
writeHook(hooksDir, 'pre-push', logs);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return logs;
|
|
86
|
+
}
|