avorelo 0.3.0 → 0.3.1
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/avorelo.mjs +443 -237
- package/package.json +1 -1
package/dist/avorelo.mjs
CHANGED
|
@@ -6523,7 +6523,7 @@ init_run();
|
|
|
6523
6523
|
init_work_contract();
|
|
6524
6524
|
init_receipts();
|
|
6525
6525
|
init_state_ledger();
|
|
6526
|
-
import { writeFileSync as writeFileSync37, mkdirSync as mkdirSync39, existsSync as
|
|
6526
|
+
import { writeFileSync as writeFileSync37, mkdirSync as mkdirSync39, existsSync as existsSync62, readFileSync as readFileSync46, appendFileSync as appendFileSync11, rmSync as rmSync3, unlinkSync as unlinkSync4 } from "node:fs";
|
|
6527
6527
|
import { join as join61 } from "node:path";
|
|
6528
6528
|
|
|
6529
6529
|
// src/avorelo/capabilities/activation/index.ts
|
|
@@ -6604,93 +6604,158 @@ function doctor(targetDir) {
|
|
|
6604
6604
|
return { ok: checks.every((c) => c.passed), checks, hookLatencyMs: fired.latencyMs };
|
|
6605
6605
|
}
|
|
6606
6606
|
|
|
6607
|
-
// src/avorelo/capabilities/activation/activation-
|
|
6608
|
-
import {
|
|
6609
|
-
import {
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
const dir = join23(targetDir, ACTIVATION_STATE_DIR);
|
|
6616
|
-
mkdirSync12(dir, { recursive: true });
|
|
6617
|
-
const path = join23(dir, ACTIVATION_STATE_FILE);
|
|
6618
|
-
const safe = redact(state).value;
|
|
6619
|
-
writeFileSync12(path, JSON.stringify(safe, null, 2));
|
|
6620
|
-
return path;
|
|
6621
|
-
}
|
|
6622
|
-
function readActivationState(targetDir) {
|
|
6623
|
-
const path = join23(targetDir, ACTIVATION_STATE_DIR, ACTIVATION_STATE_FILE);
|
|
6624
|
-
if (!existsSync25(path)) return null;
|
|
6607
|
+
// src/avorelo/capabilities/activation/activation-preflight.ts
|
|
6608
|
+
import { existsSync as existsSync25 } from "node:fs";
|
|
6609
|
+
import { execSync } from "node:child_process";
|
|
6610
|
+
import { platform, tmpdir as tmpdir2 } from "node:os";
|
|
6611
|
+
function runPreflight(targetDir) {
|
|
6612
|
+
const checks = [];
|
|
6613
|
+
const isWindows = platform() === "win32";
|
|
6614
|
+
let nodeOk = false;
|
|
6625
6615
|
try {
|
|
6626
|
-
const
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
return parsed;
|
|
6616
|
+
const v = execSync("node --version", { encoding: "utf8", timeout: 5e3 }).trim();
|
|
6617
|
+
nodeOk = v.startsWith("v");
|
|
6618
|
+
checks.push({ id: "node_available", label: "Node.js available", passed: nodeOk, details: v });
|
|
6630
6619
|
} catch {
|
|
6631
|
-
|
|
6620
|
+
checks.push({ id: "node_available", label: "Node.js available", passed: false, details: "node not found in PATH", recovery: "Install Node.js from https://nodejs.org (LTS recommended)" });
|
|
6632
6621
|
}
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6622
|
+
let npmOk = false;
|
|
6623
|
+
try {
|
|
6624
|
+
const v = execSync("npm --version", { encoding: "utf8", timeout: 5e3 }).trim();
|
|
6625
|
+
npmOk = true;
|
|
6626
|
+
checks.push({ id: "npm_available", label: "npm available", passed: true, details: `npm ${v}` });
|
|
6627
|
+
} catch {
|
|
6628
|
+
checks.push({ id: "npm_available", label: "npm available", passed: false, details: "npm not found in PATH", recovery: "npm is included with Node.js \u2014 reinstall Node.js from https://nodejs.org" });
|
|
6640
6629
|
}
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6630
|
+
let npxOk = false;
|
|
6631
|
+
try {
|
|
6632
|
+
const v = execSync("npx --version", { encoding: "utf8", timeout: 5e3 }).trim();
|
|
6633
|
+
npxOk = true;
|
|
6634
|
+
checks.push({ id: "npx_available", label: "npx available", passed: true, details: `npx ${v}` });
|
|
6635
|
+
} catch {
|
|
6636
|
+
checks.push({ id: "npx_available", label: "npx available", passed: false, details: "npx not found in PATH", recovery: "npx is included with npm 5.2+. Update Node.js to get a recent npm." });
|
|
6637
|
+
}
|
|
6638
|
+
let cacheOk = false;
|
|
6639
|
+
try {
|
|
6640
|
+
const cachePath = execSync("npm config get cache", { encoding: "utf8", timeout: 5e3 }).trim();
|
|
6641
|
+
if (cachePath && existsSync25(cachePath)) {
|
|
6642
|
+
cacheOk = true;
|
|
6643
|
+
checks.push({ id: "npm_cache_writable", label: "npm cache directory accessible", passed: true, details: "cache directory exists" });
|
|
6644
|
+
} else {
|
|
6645
|
+
checks.push({ id: "npm_cache_writable", label: "npm cache directory accessible", passed: false, details: "cache path does not exist", recovery: isWindows ? "Use a temporary cache: set npm_config_cache=%TEMP%\\npm-cache-avorelo && npx -y avorelo@latest activate" : "Use a temporary cache: npm_config_cache=$(mktemp -d) npx -y avorelo@latest activate" });
|
|
6646
|
+
}
|
|
6647
|
+
} catch {
|
|
6648
|
+
checks.push({ id: "npm_cache_writable", label: "npm cache directory accessible", passed: false, details: "could not read npm cache config", recovery: isWindows ? "Use a temporary cache: set npm_config_cache=%TEMP%\\npm-cache-avorelo && npx -y avorelo@latest activate" : "Use a temporary cache: npm_config_cache=$(mktemp -d) npx -y avorelo@latest activate" });
|
|
6649
|
+
}
|
|
6650
|
+
let tempOk = false;
|
|
6651
|
+
try {
|
|
6652
|
+
const td = tmpdir2();
|
|
6653
|
+
tempOk = existsSync25(td);
|
|
6654
|
+
checks.push({ id: "temp_dir_writable", label: "Temp directory writable", passed: tempOk, details: tempOk ? "temp dir accessible" : "temp dir not found" });
|
|
6655
|
+
} catch {
|
|
6656
|
+
checks.push({ id: "temp_dir_writable", label: "Temp directory writable", passed: false, details: "cannot access temp directory" });
|
|
6657
|
+
}
|
|
6658
|
+
let targetOk = false;
|
|
6659
|
+
try {
|
|
6660
|
+
targetOk = existsSync25(targetDir);
|
|
6661
|
+
checks.push({ id: "target_dir_writable", label: "Target directory exists", passed: targetOk, details: targetOk ? "directory accessible" : "directory not found" });
|
|
6662
|
+
} catch {
|
|
6663
|
+
checks.push({ id: "target_dir_writable", label: "Target directory exists", passed: false, details: "cannot access target directory" });
|
|
6664
|
+
}
|
|
6665
|
+
let psOk = true;
|
|
6666
|
+
if (isWindows) {
|
|
6667
|
+
try {
|
|
6668
|
+
const policy = execSync("powershell -NoProfile -Command Get-ExecutionPolicy", { encoding: "utf8", timeout: 5e3 }).trim().toLowerCase();
|
|
6669
|
+
const blocked = policy === "restricted" || policy === "allsigned";
|
|
6670
|
+
psOk = !blocked;
|
|
6671
|
+
checks.push({
|
|
6672
|
+
id: "powershell_execution_policy",
|
|
6673
|
+
label: "PowerShell execution policy",
|
|
6674
|
+
passed: psOk,
|
|
6675
|
+
details: `Policy: ${policy}`,
|
|
6676
|
+
recovery: blocked ? "PowerShell is blocking script execution. Use Command Prompt instead:\n cmd /c npx -y avorelo@latest activate" : void 0
|
|
6677
|
+
});
|
|
6678
|
+
} catch {
|
|
6679
|
+
checks.push({ id: "powershell_execution_policy", label: "PowerShell execution policy", passed: true, details: "could not check (non-PowerShell shell)" });
|
|
6680
|
+
}
|
|
6681
|
+
}
|
|
6682
|
+
let registryOk = false;
|
|
6683
|
+
try {
|
|
6684
|
+
const result3 = execSync("npm view avorelo@latest version", { encoding: "utf8", timeout: 15e3 }).trim();
|
|
6685
|
+
registryOk = /^\d+\.\d+\.\d+/.test(result3);
|
|
6686
|
+
checks.push({ id: "network_npm_registry", label: "npm registry reachable", passed: registryOk, details: registryOk ? `latest: ${result3}` : "unexpected response" });
|
|
6687
|
+
} catch {
|
|
6688
|
+
checks.push({ id: "network_npm_registry", label: "npm registry reachable", passed: false, details: "cannot reach npm registry", recovery: "Check your network connection. If behind a proxy, configure npm: npm config set proxy <url>" });
|
|
6689
|
+
}
|
|
6690
|
+
const allPassed = checks.every((c) => c.passed);
|
|
6691
|
+
const canStart = nodeOk && npmOk && npxOk;
|
|
6692
|
+
let fallbackCommand;
|
|
6693
|
+
if (!allPassed && isWindows) {
|
|
6694
|
+
fallbackCommand = buildWindowsFallbackCommand();
|
|
6695
|
+
}
|
|
6696
|
+
const taxonomy = allPassed ? "READY" : canStart ? "LOCAL_PREFLIGHT_FAILED" : "BLOCKED_BY_RUNNER_BEFORE_AVORELO_STARTED";
|
|
6697
|
+
return { ok: allPassed, canStart, checks, fallbackCommand, taxonomy };
|
|
6661
6698
|
}
|
|
6662
|
-
function
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6699
|
+
function buildWindowsFallbackCommand() {
|
|
6700
|
+
return [
|
|
6701
|
+
":: Avorelo activation \u2014 safe Windows fallback",
|
|
6702
|
+
":: Run this in Command Prompt (cmd.exe), not PowerShell",
|
|
6703
|
+
"set AVORELO_TEMP=%TEMP%\\avorelo-activate-%RANDOM%",
|
|
6704
|
+
"mkdir %AVORELO_TEMP%",
|
|
6705
|
+
"set npm_config_cache=%AVORELO_TEMP%\\npm-cache",
|
|
6706
|
+
"cd /d %AVORELO_TEMP%",
|
|
6707
|
+
"npx -y avorelo@latest activate",
|
|
6708
|
+
"npx -y avorelo@latest status"
|
|
6709
|
+
].join("\n");
|
|
6710
|
+
}
|
|
6711
|
+
function formatPreflightReport(result3) {
|
|
6712
|
+
const lines = ["", "Avorelo Activation Preflight", ""];
|
|
6713
|
+
for (const c of result3.checks) {
|
|
6714
|
+
const icon = c.passed ? "\u2713" : "\u2717";
|
|
6715
|
+
lines.push(` ${icon} ${c.label}: ${c.details}`);
|
|
6716
|
+
if (!c.passed && c.recovery) {
|
|
6717
|
+
for (const line of c.recovery.split("\n")) {
|
|
6718
|
+
lines.push(` \u2192 ${line}`);
|
|
6719
|
+
}
|
|
6720
|
+
}
|
|
6666
6721
|
}
|
|
6667
|
-
|
|
6668
|
-
if (
|
|
6669
|
-
|
|
6722
|
+
lines.push("");
|
|
6723
|
+
if (result3.ok) {
|
|
6724
|
+
lines.push(" All checks passed. Ready to activate.");
|
|
6725
|
+
} else if (result3.canStart) {
|
|
6726
|
+
lines.push(" Some checks failed but activation can attempt to proceed.");
|
|
6727
|
+
lines.push(" Fix the issues above for the best experience.");
|
|
6728
|
+
} else {
|
|
6729
|
+
lines.push(" Activation cannot start in this environment.");
|
|
6730
|
+
lines.push(" Avorelo requires Node.js and npm to be available.");
|
|
6731
|
+
if (result3.fallbackCommand) {
|
|
6732
|
+
lines.push("");
|
|
6733
|
+
lines.push(" Safe fallback command:");
|
|
6734
|
+
for (const line of result3.fallbackCommand.split("\n")) {
|
|
6735
|
+
lines.push(` ${line}`);
|
|
6736
|
+
}
|
|
6737
|
+
}
|
|
6670
6738
|
}
|
|
6671
|
-
|
|
6739
|
+
lines.push("");
|
|
6740
|
+
return lines.join("\n");
|
|
6672
6741
|
}
|
|
6673
6742
|
|
|
6674
|
-
// src/avorelo/capabilities/activation/activation-runner.ts
|
|
6675
|
-
import { join as join27 } from "node:path";
|
|
6676
|
-
import { existsSync as existsSync29 } from "node:fs";
|
|
6677
|
-
|
|
6678
6743
|
// src/avorelo/capabilities/activation/activation-detector.ts
|
|
6679
|
-
import { existsSync as existsSync26, readFileSync as
|
|
6680
|
-
import { join as
|
|
6681
|
-
import { execSync } from "node:child_process";
|
|
6682
|
-
import { platform } from "node:os";
|
|
6744
|
+
import { existsSync as existsSync26, readFileSync as readFileSync12 } from "node:fs";
|
|
6745
|
+
import { join as join23 } from "node:path";
|
|
6746
|
+
import { execSync as execSync2 } from "node:child_process";
|
|
6747
|
+
import { platform as platform2 } from "node:os";
|
|
6683
6748
|
function tryExec(cmd, cwd) {
|
|
6684
6749
|
try {
|
|
6685
|
-
return
|
|
6750
|
+
return execSync2(cmd, { cwd, stdio: "pipe", timeout: 5e3 }).toString().trim();
|
|
6686
6751
|
} catch {
|
|
6687
6752
|
return null;
|
|
6688
6753
|
}
|
|
6689
6754
|
}
|
|
6690
6755
|
function commandExists(cmd) {
|
|
6691
6756
|
try {
|
|
6692
|
-
const check =
|
|
6693
|
-
|
|
6757
|
+
const check = platform2() === "win32" ? `where ${cmd}` : `which ${cmd}`;
|
|
6758
|
+
execSync2(check, { stdio: "pipe", timeout: 3e3 });
|
|
6694
6759
|
return true;
|
|
6695
6760
|
} catch {
|
|
6696
6761
|
return false;
|
|
@@ -6707,18 +6772,18 @@ function detectRepoIdentity(dir) {
|
|
|
6707
6772
|
function detectEnvironment(dir) {
|
|
6708
6773
|
const nodeVersion = tryExec("node --version", dir);
|
|
6709
6774
|
let packageManager = null;
|
|
6710
|
-
if (existsSync26(
|
|
6711
|
-
else if (existsSync26(
|
|
6712
|
-
else if (existsSync26(
|
|
6713
|
-
else if (existsSync26(
|
|
6714
|
-
else if (existsSync26(
|
|
6775
|
+
if (existsSync26(join23(dir, "pnpm-lock.yaml"))) packageManager = "pnpm";
|
|
6776
|
+
else if (existsSync26(join23(dir, "yarn.lock"))) packageManager = "yarn";
|
|
6777
|
+
else if (existsSync26(join23(dir, "bun.lockb"))) packageManager = "bun";
|
|
6778
|
+
else if (existsSync26(join23(dir, "package-lock.json"))) packageManager = "npm";
|
|
6779
|
+
else if (existsSync26(join23(dir, "package.json"))) packageManager = "npm";
|
|
6715
6780
|
let framework = null;
|
|
6716
6781
|
let testCommand = null;
|
|
6717
6782
|
let sitePreviewCommand = null;
|
|
6718
|
-
const pkgPath =
|
|
6783
|
+
const pkgPath = join23(dir, "package.json");
|
|
6719
6784
|
if (existsSync26(pkgPath)) {
|
|
6720
6785
|
try {
|
|
6721
|
-
const pkg = JSON.parse(
|
|
6786
|
+
const pkg = JSON.parse(readFileSync12(pkgPath, "utf8"));
|
|
6722
6787
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
6723
6788
|
if (deps.next) framework = "next";
|
|
6724
6789
|
else if (deps.react) framework = "react";
|
|
@@ -6732,29 +6797,29 @@ function detectEnvironment(dir) {
|
|
|
6732
6797
|
} catch {
|
|
6733
6798
|
}
|
|
6734
6799
|
}
|
|
6735
|
-
if (existsSync26(
|
|
6736
|
-
return { os:
|
|
6800
|
+
if (existsSync26(join23(dir, "main.wasp"))) framework = "wasp";
|
|
6801
|
+
return { os: platform2(), nodeVersion, packageManager, framework, testCommand, sitePreviewCommand };
|
|
6737
6802
|
}
|
|
6738
6803
|
function detectAiTools(dir) {
|
|
6739
6804
|
return {
|
|
6740
|
-
claudeCodeDetected: existsSync26(
|
|
6741
|
-
codexDetected: existsSync26(
|
|
6742
|
-
cursorDetected: existsSync26(
|
|
6743
|
-
agentsMdDetected: existsSync26(
|
|
6744
|
-
claudeMdDetected: existsSync26(
|
|
6745
|
-
cursorRulesDetected: existsSync26(
|
|
6746
|
-
codexConfigDetected: existsSync26(
|
|
6805
|
+
claudeCodeDetected: existsSync26(join23(dir, ".claude")) || existsSync26(join23(dir, ".claude", "settings.json")),
|
|
6806
|
+
codexDetected: existsSync26(join23(dir, ".codex")),
|
|
6807
|
+
cursorDetected: existsSync26(join23(dir, ".cursor")),
|
|
6808
|
+
agentsMdDetected: existsSync26(join23(dir, "AGENTS.md")),
|
|
6809
|
+
claudeMdDetected: existsSync26(join23(dir, "CLAUDE.md")),
|
|
6810
|
+
cursorRulesDetected: existsSync26(join23(dir, ".cursor", "rules")),
|
|
6811
|
+
codexConfigDetected: existsSync26(join23(dir, ".codex", "config.toml")) || existsSync26(join23(dir, "codex.json"))
|
|
6747
6812
|
};
|
|
6748
6813
|
}
|
|
6749
6814
|
function detectModelsAndTools(dir) {
|
|
6750
|
-
const ROOT2 =
|
|
6815
|
+
const ROOT2 = join23(import.meta.dirname, "..", "..", "..", "..");
|
|
6751
6816
|
const env = process.env;
|
|
6752
6817
|
return {
|
|
6753
|
-
skillsRegistryAvailable: existsSync26(
|
|
6754
|
-
modelRouterAvailable: existsSync26(
|
|
6755
|
-
primitiveRouterAvailable: existsSync26(
|
|
6756
|
-
scannersAvailable: existsSync26(
|
|
6757
|
-
browserProofAvailable: commandExists("playwright") || commandExists("npx") && existsSync26(
|
|
6818
|
+
skillsRegistryAvailable: existsSync26(join23(ROOT2, "src/avorelo/validation/skill-operating-system/registry.ts")),
|
|
6819
|
+
modelRouterAvailable: existsSync26(join23(ROOT2, "src/avorelo/validation/model-routing/index.ts")),
|
|
6820
|
+
primitiveRouterAvailable: existsSync26(join23(ROOT2, "tools/route-primitive.ts")),
|
|
6821
|
+
scannersAvailable: existsSync26(join23(ROOT2, "src/avorelo/validation/scanners/index.ts")),
|
|
6822
|
+
browserProofAvailable: commandExists("playwright") || commandExists("npx") && existsSync26(join23(dir, "node_modules", "@playwright")),
|
|
6758
6823
|
githubAvailable: commandExists("gh"),
|
|
6759
6824
|
billingEnvDetected: !!(env.LEMON_SQUEEZY_PRO_CHECKOUT_URL || env.LEMON_SQUEEZY_API_KEY),
|
|
6760
6825
|
authEnvDetected: !!(env.AUTH_SECRET || env.JWT_SECRET || env.SESSION_SECRET),
|
|
@@ -6788,8 +6853,79 @@ function runFullDetection(dir) {
|
|
|
6788
6853
|
return { repo, environment, aiTools, modelsAndTools, summary: { toolsDetected, modelsDetected, missingAdvisory } };
|
|
6789
6854
|
}
|
|
6790
6855
|
|
|
6856
|
+
// src/avorelo/capabilities/activation/activation-state.ts
|
|
6857
|
+
import { readFileSync as readFileSync13, writeFileSync as writeFileSync12, mkdirSync as mkdirSync12, existsSync as existsSync27 } from "node:fs";
|
|
6858
|
+
import { join as join24, resolve as resolve3 } from "node:path";
|
|
6859
|
+
init_redaction();
|
|
6860
|
+
var ACTIVATION_STATE_CONTRACT = "avorelo.activationState.v1";
|
|
6861
|
+
var ACTIVATION_STATE_DIR = ".avorelo/activation";
|
|
6862
|
+
var ACTIVATION_STATE_FILE = "activation-state.json";
|
|
6863
|
+
function writeActivationState(targetDir, state) {
|
|
6864
|
+
const dir = join24(targetDir, ACTIVATION_STATE_DIR);
|
|
6865
|
+
mkdirSync12(dir, { recursive: true });
|
|
6866
|
+
const path = join24(dir, ACTIVATION_STATE_FILE);
|
|
6867
|
+
const safe = redact(state).value;
|
|
6868
|
+
writeFileSync12(path, JSON.stringify(safe, null, 2));
|
|
6869
|
+
return path;
|
|
6870
|
+
}
|
|
6871
|
+
function readActivationState(targetDir) {
|
|
6872
|
+
const path = join24(targetDir, ACTIVATION_STATE_DIR, ACTIVATION_STATE_FILE);
|
|
6873
|
+
if (!existsSync27(path)) return null;
|
|
6874
|
+
try {
|
|
6875
|
+
const raw = readFileSync13(path, "utf8");
|
|
6876
|
+
const parsed = JSON.parse(raw);
|
|
6877
|
+
if (parsed.contract !== ACTIVATION_STATE_CONTRACT && parsed.contract !== "avorelo.activationState.v2") return null;
|
|
6878
|
+
return parsed;
|
|
6879
|
+
} catch {
|
|
6880
|
+
return null;
|
|
6881
|
+
}
|
|
6882
|
+
}
|
|
6883
|
+
function verifyActivationState(targetDir) {
|
|
6884
|
+
const checks = [];
|
|
6885
|
+
const state = readActivationState(targetDir);
|
|
6886
|
+
if (!state) {
|
|
6887
|
+
checks.push({ id: "state_exists", passed: false, reason: "Activation state not found" });
|
|
6888
|
+
return { valid: false, checks };
|
|
6889
|
+
}
|
|
6890
|
+
checks.push({ id: "state_exists", passed: true, reason: "Activation state found" });
|
|
6891
|
+
const validContracts = [ACTIVATION_STATE_CONTRACT, "avorelo.activationState.v2"];
|
|
6892
|
+
const contractOk = validContracts.includes(state.contract);
|
|
6893
|
+
checks.push({ id: "contract_valid", passed: contractOk, reason: contractOk ? "Contract matches" : `Expected ${ACTIVATION_STATE_CONTRACT} or v2, got ${state.contract}` });
|
|
6894
|
+
checks.push({ id: "redacted", passed: state.redacted === true, reason: state.redacted ? "State is redacted" : "State is NOT redacted" });
|
|
6895
|
+
const raw2 = state;
|
|
6896
|
+
const billingLive = raw2.billing?.billingLive;
|
|
6897
|
+
checks.push({ id: "billing_not_live", passed: billingLive === false, reason: billingLive === false ? "Billing not live" : "BILLING IS LIVE \u2014 violation" });
|
|
6898
|
+
const authLive = raw2.cloud?.authLive ?? raw2.auth?.sessionAvailable === true;
|
|
6899
|
+
checks.push({ id: "auth_not_live", passed: !authLive, reason: !authLive ? "Auth not live" : "AUTH IS LIVE \u2014 violation" });
|
|
6900
|
+
const cloudSyncLive = raw2.cloud?.cloudSyncLive;
|
|
6901
|
+
checks.push({ id: "cloud_sync_not_live", passed: cloudSyncLive === false, reason: cloudSyncLive === false ? "Cloud sync not live" : "CLOUD SYNC IS LIVE \u2014 violation" });
|
|
6902
|
+
checks.push({ id: "production_not_ready", passed: state.productionReady === false, reason: state.productionReady === false ? "Production not ready (correct)" : "PRODUCTION MARKED READY \u2014 violation" });
|
|
6903
|
+
const raw = JSON.stringify(state);
|
|
6904
|
+
const hasSecret = carriesRawSecret(raw);
|
|
6905
|
+
checks.push({ id: "no_secrets", passed: !hasSecret, reason: hasSecret ? "RAW SECRET DETECTED in state" : "No raw secrets" });
|
|
6906
|
+
const legacyTokens = ["wuz", "cco", "claudecode-optimizer"];
|
|
6907
|
+
const oldNaming = legacyTokens.some((t) => raw.toLowerCase().includes(t));
|
|
6908
|
+
checks.push({ id: "no_old_naming", passed: !oldNaming, reason: oldNaming ? "Old naming leakage detected" : "No old naming leakage" });
|
|
6909
|
+
return { valid: checks.every((c) => c.passed), checks };
|
|
6910
|
+
}
|
|
6911
|
+
function repairActivationState(targetDir) {
|
|
6912
|
+
const state = readActivationState(targetDir);
|
|
6913
|
+
if (!state) {
|
|
6914
|
+
return { repaired: false, message: "No activation state found. Run: npx avorelo activate" };
|
|
6915
|
+
}
|
|
6916
|
+
const validContracts2 = [ACTIVATION_STATE_CONTRACT, "avorelo.activationState.v2"];
|
|
6917
|
+
if (!validContracts2.includes(state.contract)) {
|
|
6918
|
+
return { repaired: false, message: `Corrupt contract: ${state.contract}. Run: npx avorelo activate (will re-create)` };
|
|
6919
|
+
}
|
|
6920
|
+
return { repaired: true, message: "Activation state is valid." };
|
|
6921
|
+
}
|
|
6922
|
+
|
|
6923
|
+
// src/avorelo/capabilities/activation/activation-runner.ts
|
|
6924
|
+
import { join as join27 } from "node:path";
|
|
6925
|
+
import { existsSync as existsSync30 } from "node:fs";
|
|
6926
|
+
|
|
6791
6927
|
// src/avorelo/capabilities/activation/activation-repair.ts
|
|
6792
|
-
import { existsSync as
|
|
6928
|
+
import { existsSync as existsSync28, mkdirSync as mkdirSync13, writeFileSync as writeFileSync13, readFileSync as readFileSync14, appendFileSync as appendFileSync2 } from "node:fs";
|
|
6793
6929
|
import { join as join25 } from "node:path";
|
|
6794
6930
|
function runSafeRepairs(targetDir) {
|
|
6795
6931
|
const repairs = [];
|
|
@@ -6805,7 +6941,7 @@ function runSafeRepairs(targetDir) {
|
|
|
6805
6941
|
];
|
|
6806
6942
|
for (const d of dirs) {
|
|
6807
6943
|
const p = join25(targetDir, d);
|
|
6808
|
-
if (!
|
|
6944
|
+
if (!existsSync28(p)) {
|
|
6809
6945
|
try {
|
|
6810
6946
|
mkdirSync13(p, { recursive: true });
|
|
6811
6947
|
repairs.push({ id: `create_dir_${d.replace(/[/.]/g, "_")}`, label: `Create ${d}`, status: "applied", path: p });
|
|
@@ -6818,7 +6954,7 @@ function runSafeRepairs(targetDir) {
|
|
|
6818
6954
|
}
|
|
6819
6955
|
repairGitignore(targetDir, repairs);
|
|
6820
6956
|
const contractPath = join25(targetDir, ".avorelo", "run-entry", "activation-contract.json");
|
|
6821
|
-
if (!
|
|
6957
|
+
if (!existsSync28(contractPath)) {
|
|
6822
6958
|
try {
|
|
6823
6959
|
writeFileSync13(contractPath, JSON.stringify({
|
|
6824
6960
|
contract: "avorelo.activationContract.v1",
|
|
@@ -6843,7 +6979,7 @@ var GITIGNORE_BLOCK = `${GITIGNORE_MARKER_START}
|
|
|
6843
6979
|
${GITIGNORE_MARKER_END}`;
|
|
6844
6980
|
function repairGitignore(targetDir, repairs) {
|
|
6845
6981
|
const gitignorePath = join25(targetDir, ".gitignore");
|
|
6846
|
-
if (!
|
|
6982
|
+
if (!existsSync28(gitignorePath)) {
|
|
6847
6983
|
try {
|
|
6848
6984
|
writeFileSync13(gitignorePath, GITIGNORE_BLOCK + "\n");
|
|
6849
6985
|
repairs.push({ id: "gitignore_create", label: "Create .gitignore with Avorelo block", status: "applied", path: gitignorePath });
|
|
@@ -6870,7 +7006,7 @@ function repairGitignore(targetDir, repairs) {
|
|
|
6870
7006
|
}
|
|
6871
7007
|
|
|
6872
7008
|
// src/avorelo/capabilities/activation/activation-run-entry.ts
|
|
6873
|
-
import { existsSync as
|
|
7009
|
+
import { existsSync as existsSync29, readFileSync as readFileSync15, writeFileSync as writeFileSync14, mkdirSync as mkdirSync14 } from "node:fs";
|
|
6874
7010
|
import { join as join26, dirname as dirname3 } from "node:path";
|
|
6875
7011
|
var MARKER_START = "<!-- >>> Avorelo Run Entry (managed \u2014 do not edit between markers) >>> -->";
|
|
6876
7012
|
var MARKER_END = "<!-- <<< Avorelo Run Entry <<< -->";
|
|
@@ -6895,14 +7031,14 @@ Commands:
|
|
|
6895
7031
|
${MARKER_END}`;
|
|
6896
7032
|
function installBlock(filePath, blockContent) {
|
|
6897
7033
|
const dir = dirname3(filePath);
|
|
6898
|
-
if (!
|
|
7034
|
+
if (!existsSync29(dir)) {
|
|
6899
7035
|
try {
|
|
6900
7036
|
mkdirSync14(dir, { recursive: true });
|
|
6901
7037
|
} catch {
|
|
6902
7038
|
return { path: filePath, action: "blocked", reason: "Cannot create directory" };
|
|
6903
7039
|
}
|
|
6904
7040
|
}
|
|
6905
|
-
if (!
|
|
7041
|
+
if (!existsSync29(filePath)) {
|
|
6906
7042
|
try {
|
|
6907
7043
|
writeFileSync14(filePath, blockContent + "\n");
|
|
6908
7044
|
return { path: filePath, action: "created" };
|
|
@@ -6941,14 +7077,14 @@ function installRunEntry(targetDir) {
|
|
|
6941
7077
|
const claudeMd = join26(targetDir, "CLAUDE.md");
|
|
6942
7078
|
surfaces.push(installBlock(claudeMd, RUN_ENTRY_BLOCK));
|
|
6943
7079
|
const agentsMd = join26(targetDir, "AGENTS.md");
|
|
6944
|
-
if (
|
|
7080
|
+
if (existsSync29(agentsMd)) {
|
|
6945
7081
|
surfaces.push(installBlock(agentsMd, RUN_ENTRY_BLOCK));
|
|
6946
7082
|
} else {
|
|
6947
7083
|
surfaces.push({ path: agentsMd, action: "skipped", reason: "AGENTS.md does not exist \u2014 not creating" });
|
|
6948
7084
|
advisory.push("AGENTS.md not present");
|
|
6949
7085
|
}
|
|
6950
7086
|
const cursorDir = join26(targetDir, ".cursor", "rules");
|
|
6951
|
-
if (
|
|
7087
|
+
if (existsSync29(join26(targetDir, ".cursor"))) {
|
|
6952
7088
|
const cursorRule = join26(cursorDir, "avorelo.mdc");
|
|
6953
7089
|
const cursorBlock = [
|
|
6954
7090
|
"---",
|
|
@@ -6961,7 +7097,7 @@ function installRunEntry(targetDir) {
|
|
|
6961
7097
|
"Check `npx avorelo status` before starting work.",
|
|
6962
7098
|
"Use Avorelo validators for proof. Do not claim production readiness without receipts."
|
|
6963
7099
|
].join("\n");
|
|
6964
|
-
if (!
|
|
7100
|
+
if (!existsSync29(cursorRule)) {
|
|
6965
7101
|
try {
|
|
6966
7102
|
mkdirSync14(cursorDir, { recursive: true });
|
|
6967
7103
|
writeFileSync14(cursorRule, cursorBlock + "\n");
|
|
@@ -6975,7 +7111,7 @@ function installRunEntry(targetDir) {
|
|
|
6975
7111
|
} else {
|
|
6976
7112
|
advisory.push(".cursor not present");
|
|
6977
7113
|
}
|
|
6978
|
-
if (
|
|
7114
|
+
if (existsSync29(join26(targetDir, ".codex"))) {
|
|
6979
7115
|
advisory.push("Codex detected \u2014 manual run-entry recommended");
|
|
6980
7116
|
}
|
|
6981
7117
|
let contractPath;
|
|
@@ -7636,7 +7772,7 @@ function runFullActivation(targetDir) {
|
|
|
7636
7772
|
nextAction: "Run: npx avorelo status"
|
|
7637
7773
|
};
|
|
7638
7774
|
const dashboardPath = join27(targetDir, ".avorelo", "dashboard", "index.html");
|
|
7639
|
-
const localDashboard = { available:
|
|
7775
|
+
const localDashboard = { available: existsSync30(dashboardPath), path: existsSync30(dashboardPath) ? dashboardPath : void 0 };
|
|
7640
7776
|
const blockers = repairsBlocked.length;
|
|
7641
7777
|
const activationStatus = blockers > 0 ? "blocked" : "active_with_holds";
|
|
7642
7778
|
const existingState = readActivationState(targetDir);
|
|
@@ -8017,7 +8153,7 @@ function prepareDashboardHtmlWithEntitlements(html, model) {
|
|
|
8017
8153
|
|
|
8018
8154
|
// src/avorelo/adapters/lemon-squeezy/subscription-store.ts
|
|
8019
8155
|
init_redaction();
|
|
8020
|
-
import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync15, readFileSync as readFileSync16, readdirSync as readdirSync8, existsSync as
|
|
8156
|
+
import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync15, readFileSync as readFileSync16, readdirSync as readdirSync8, existsSync as existsSync31, renameSync } from "node:fs";
|
|
8021
8157
|
import { join as join28 } from "node:path";
|
|
8022
8158
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
8023
8159
|
function subscriptionDir(baseDir) {
|
|
@@ -8043,7 +8179,7 @@ function writeSubscription(baseDir, record) {
|
|
|
8043
8179
|
function readSubscription(baseDir, providerSubscriptionId) {
|
|
8044
8180
|
const dir = subscriptionDir(baseDir);
|
|
8045
8181
|
const path = join28(dir, `sub_${providerSubscriptionId}.json`);
|
|
8046
|
-
if (!
|
|
8182
|
+
if (!existsSync31(path)) return null;
|
|
8047
8183
|
try {
|
|
8048
8184
|
const r2 = JSON.parse(readFileSync16(path, "utf8"));
|
|
8049
8185
|
return r2 && typeof r2.id === "string" && typeof r2.plan === "string" ? r2 : null;
|
|
@@ -8065,7 +8201,7 @@ function readSubscriptionByUser(baseDir, userId) {
|
|
|
8065
8201
|
}
|
|
8066
8202
|
function listSubscriptions(baseDir) {
|
|
8067
8203
|
const dir = subscriptionDir(baseDir);
|
|
8068
|
-
if (!
|
|
8204
|
+
if (!existsSync31(dir)) return [];
|
|
8069
8205
|
const out = [];
|
|
8070
8206
|
for (const f of readdirSync8(dir)) {
|
|
8071
8207
|
if (!f.endsWith(".json") || f.includes(".tmp.")) continue;
|
|
@@ -8088,7 +8224,7 @@ function writeUnmatchedEvent(baseDir, event) {
|
|
|
8088
8224
|
}
|
|
8089
8225
|
function listUnmatchedEvents(baseDir) {
|
|
8090
8226
|
const dir = unmatchedDir(baseDir);
|
|
8091
|
-
if (!
|
|
8227
|
+
if (!existsSync31(dir)) return [];
|
|
8092
8228
|
const out = [];
|
|
8093
8229
|
for (const f of readdirSync8(dir)) {
|
|
8094
8230
|
if (!f.endsWith(".json") || f.includes(".tmp.")) continue;
|
|
@@ -8351,12 +8487,12 @@ function open(dir, opts) {
|
|
|
8351
8487
|
|
|
8352
8488
|
// src/avorelo/capabilities/control-center/index.ts
|
|
8353
8489
|
init_redaction();
|
|
8354
|
-
import { mkdirSync as mkdirSync25, writeFileSync as writeFileSync24, existsSync as
|
|
8490
|
+
import { mkdirSync as mkdirSync25, writeFileSync as writeFileSync24, existsSync as existsSync40, readFileSync as readFileSync24 } from "node:fs";
|
|
8355
8491
|
import { join as join40 } from "node:path";
|
|
8356
8492
|
|
|
8357
8493
|
// src/avorelo/capabilities/runtime-flow/index.ts
|
|
8358
8494
|
import { createHash as createHash12 } from "node:crypto";
|
|
8359
|
-
import { mkdirSync as mkdirSync24, writeFileSync as writeFileSync23, appendFileSync as appendFileSync9, readFileSync as readFileSync23, existsSync as
|
|
8495
|
+
import { mkdirSync as mkdirSync24, writeFileSync as writeFileSync23, appendFileSync as appendFileSync9, readFileSync as readFileSync23, existsSync as existsSync39 } from "node:fs";
|
|
8360
8496
|
import { join as join39 } from "node:path";
|
|
8361
8497
|
|
|
8362
8498
|
// src/avorelo/kernel/work-contract/routing.ts
|
|
@@ -8621,7 +8757,7 @@ init_session();
|
|
|
8621
8757
|
|
|
8622
8758
|
// src/avorelo/capabilities/context-compiler/index.ts
|
|
8623
8759
|
import { createHash as createHash7 } from "node:crypto";
|
|
8624
|
-
import { appendFileSync as appendFileSync3, existsSync as
|
|
8760
|
+
import { appendFileSync as appendFileSync3, existsSync as existsSync32, mkdirSync as mkdirSync17, readFileSync as readFileSync17, writeFileSync as writeFileSync17 } from "node:fs";
|
|
8625
8761
|
import { join as join30 } from "node:path";
|
|
8626
8762
|
|
|
8627
8763
|
// src/avorelo/capabilities/secret-boundary/index.ts
|
|
@@ -9281,7 +9417,7 @@ function writeContextPack(dir, pack) {
|
|
|
9281
9417
|
}
|
|
9282
9418
|
|
|
9283
9419
|
// src/avorelo/capabilities/continuity/index.ts
|
|
9284
|
-
import { mkdirSync as mkdirSync18, writeFileSync as writeFileSync18, readFileSync as readFileSync18, existsSync as
|
|
9420
|
+
import { mkdirSync as mkdirSync18, writeFileSync as writeFileSync18, readFileSync as readFileSync18, existsSync as existsSync33, appendFileSync as appendFileSync4 } from "node:fs";
|
|
9285
9421
|
import { join as join31 } from "node:path";
|
|
9286
9422
|
init_redactor();
|
|
9287
9423
|
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -9437,7 +9573,7 @@ function writeContinuity(dir, packet) {
|
|
|
9437
9573
|
}
|
|
9438
9574
|
function loadLatestContinuity(dir) {
|
|
9439
9575
|
const latest = join31(continuityDir(dir), "latest.json");
|
|
9440
|
-
if (!
|
|
9576
|
+
if (!existsSync33(latest)) return null;
|
|
9441
9577
|
try {
|
|
9442
9578
|
const p = JSON.parse(readFileSync18(latest, "utf8"));
|
|
9443
9579
|
return p && p.contract === "avorelo.nextRunContinuity.v1" ? p : null;
|
|
@@ -9448,7 +9584,7 @@ function loadLatestContinuity(dir) {
|
|
|
9448
9584
|
|
|
9449
9585
|
// src/avorelo/capabilities/token-cost-evidence/index.ts
|
|
9450
9586
|
init_redactor();
|
|
9451
|
-
import { mkdirSync as mkdirSync19, readFileSync as readFileSync19, existsSync as
|
|
9587
|
+
import { mkdirSync as mkdirSync19, readFileSync as readFileSync19, existsSync as existsSync34, appendFileSync as appendFileSync5 } from "node:fs";
|
|
9452
9588
|
import { join as join32 } from "node:path";
|
|
9453
9589
|
import { createHash as createHash8 } from "node:crypto";
|
|
9454
9590
|
var FORBIDDEN_IMPORT_KEYS = [
|
|
@@ -9744,7 +9880,7 @@ function writeTokenCostEvidence(dir, e) {
|
|
|
9744
9880
|
}
|
|
9745
9881
|
function loadTokenCostEvidence(dir) {
|
|
9746
9882
|
const path = join32(evidenceDir(dir), "token-cost.jsonl");
|
|
9747
|
-
if (!
|
|
9883
|
+
if (!existsSync34(path)) return [];
|
|
9748
9884
|
const out = [];
|
|
9749
9885
|
for (const line of readFileSync19(path, "utf8").split(/\r?\n/)) {
|
|
9750
9886
|
if (!line.trim()) continue;
|
|
@@ -9759,7 +9895,7 @@ function loadTokenCostEvidence(dir) {
|
|
|
9759
9895
|
|
|
9760
9896
|
// src/avorelo/capabilities/proof-report/index.ts
|
|
9761
9897
|
init_redactor();
|
|
9762
|
-
import { mkdirSync as mkdirSync20, writeFileSync as writeFileSync20, appendFileSync as appendFileSync6, existsSync as
|
|
9898
|
+
import { mkdirSync as mkdirSync20, writeFileSync as writeFileSync20, appendFileSync as appendFileSync6, existsSync as existsSync35, readFileSync as readFileSync20 } from "node:fs";
|
|
9763
9899
|
import { join as join33 } from "node:path";
|
|
9764
9900
|
import { createHash as createHash9 } from "node:crypto";
|
|
9765
9901
|
var rs = (s) => redactString2(String(s ?? ""), "handoff", "report").redacted;
|
|
@@ -9916,7 +10052,7 @@ function writeProofReport(dir, r2) {
|
|
|
9916
10052
|
}
|
|
9917
10053
|
function loadLatestProofReport(dir) {
|
|
9918
10054
|
const latest = join33(reportsDir(dir), "proof-report.latest.json");
|
|
9919
|
-
if (!
|
|
10055
|
+
if (!existsSync35(latest)) return null;
|
|
9920
10056
|
try {
|
|
9921
10057
|
return JSON.parse(readFileSync20(latest, "utf8"));
|
|
9922
10058
|
} catch {
|
|
@@ -9926,7 +10062,7 @@ function loadLatestProofReport(dir) {
|
|
|
9926
10062
|
|
|
9927
10063
|
// src/avorelo/capabilities/value-ledger/index.ts
|
|
9928
10064
|
init_redactor();
|
|
9929
|
-
import { mkdirSync as mkdirSync21, writeFileSync as writeFileSync21, readFileSync as readFileSync21, existsSync as
|
|
10065
|
+
import { mkdirSync as mkdirSync21, writeFileSync as writeFileSync21, readFileSync as readFileSync21, existsSync as existsSync36, appendFileSync as appendFileSync7 } from "node:fs";
|
|
9930
10066
|
import { join as join34 } from "node:path";
|
|
9931
10067
|
import { createHash as createHash10 } from "node:crypto";
|
|
9932
10068
|
function safeText2(s) {
|
|
@@ -10075,7 +10211,7 @@ function appendValueLedgerEntry(dir, e) {
|
|
|
10075
10211
|
}
|
|
10076
10212
|
function loadValueLedgerEntries(dir) {
|
|
10077
10213
|
const path = join34(ledgerDir(dir), "value-ledger.jsonl");
|
|
10078
|
-
if (!
|
|
10214
|
+
if (!existsSync36(path)) return [];
|
|
10079
10215
|
const out = [];
|
|
10080
10216
|
for (const line of readFileSync21(path, "utf8").split(/\r?\n/)) {
|
|
10081
10217
|
if (!line.trim()) continue;
|
|
@@ -10251,7 +10387,7 @@ import { mkdirSync as mkdirSync23, writeFileSync as writeFileSync22 } from "node
|
|
|
10251
10387
|
import { join as join38 } from "node:path";
|
|
10252
10388
|
|
|
10253
10389
|
// src/avorelo/capabilities/context-check/scanner.ts
|
|
10254
|
-
import { existsSync as
|
|
10390
|
+
import { existsSync as existsSync37, readdirSync as readdirSync9, statSync as statSync3, openSync, readSync, closeSync } from "node:fs";
|
|
10255
10391
|
import { join as join36, relative, sep as sep3 } from "node:path";
|
|
10256
10392
|
var BYTES_PER_TOKEN_ESTIMATE = 4;
|
|
10257
10393
|
var MAX_SCAN_DEPTH = 5;
|
|
@@ -10306,7 +10442,7 @@ function extractReferences(content) {
|
|
|
10306
10442
|
function scanClaude(repoRoot2) {
|
|
10307
10443
|
const sources = [];
|
|
10308
10444
|
const rootMd = join36(repoRoot2, "CLAUDE.md");
|
|
10309
|
-
if (
|
|
10445
|
+
if (existsSync37(rootMd)) {
|
|
10310
10446
|
const meta = fileMeta(rootMd);
|
|
10311
10447
|
if (meta) {
|
|
10312
10448
|
const content = safeRead(rootMd);
|
|
@@ -10320,7 +10456,7 @@ function scanClaude(repoRoot2) {
|
|
|
10320
10456
|
}
|
|
10321
10457
|
}
|
|
10322
10458
|
const claudeDir = join36(repoRoot2, ".claude");
|
|
10323
|
-
if (
|
|
10459
|
+
if (existsSync37(claudeDir)) {
|
|
10324
10460
|
try {
|
|
10325
10461
|
for (const entry of walkDir(claudeDir, 3)) {
|
|
10326
10462
|
if (!entry.endsWith(".md") && !entry.endsWith(".json") && !entry.endsWith(".txt")) continue;
|
|
@@ -10365,7 +10501,7 @@ function scanClaude(repoRoot2) {
|
|
|
10365
10501
|
}
|
|
10366
10502
|
function scanAgents(repoRoot2) {
|
|
10367
10503
|
const agentsMd = join36(repoRoot2, "AGENTS.md");
|
|
10368
|
-
if (!
|
|
10504
|
+
if (!existsSync37(agentsMd)) return [];
|
|
10369
10505
|
const meta = fileMeta(agentsMd);
|
|
10370
10506
|
if (!meta) return [];
|
|
10371
10507
|
const content = safeRead(agentsMd);
|
|
@@ -10380,9 +10516,9 @@ function scanAgents(repoRoot2) {
|
|
|
10380
10516
|
function scanCursor(repoRoot2) {
|
|
10381
10517
|
const sources = [];
|
|
10382
10518
|
const cursorDir = join36(repoRoot2, ".cursor");
|
|
10383
|
-
if (!
|
|
10519
|
+
if (!existsSync37(cursorDir)) return sources;
|
|
10384
10520
|
const rulesDir = join36(cursorDir, "rules");
|
|
10385
|
-
if (
|
|
10521
|
+
if (existsSync37(rulesDir)) {
|
|
10386
10522
|
try {
|
|
10387
10523
|
for (const entry of walkDir(rulesDir, 2)) {
|
|
10388
10524
|
if (!entry.endsWith(".mdc") && !entry.endsWith(".md") && !entry.endsWith(".txt")) continue;
|
|
@@ -10404,7 +10540,7 @@ function scanCursor(repoRoot2) {
|
|
|
10404
10540
|
}
|
|
10405
10541
|
}
|
|
10406
10542
|
const cursorrules = join36(repoRoot2, ".cursorrules");
|
|
10407
|
-
if (
|
|
10543
|
+
if (existsSync37(cursorrules)) {
|
|
10408
10544
|
const meta = fileMeta(cursorrules);
|
|
10409
10545
|
if (meta) {
|
|
10410
10546
|
sources.push({
|
|
@@ -10430,7 +10566,7 @@ function extractCursorGlobs(content) {
|
|
|
10430
10566
|
function scanCodex(repoRoot2) {
|
|
10431
10567
|
const sources = [];
|
|
10432
10568
|
const codexMd = join36(repoRoot2, "CODEX.md");
|
|
10433
|
-
if (
|
|
10569
|
+
if (existsSync37(codexMd)) {
|
|
10434
10570
|
const meta = fileMeta(codexMd);
|
|
10435
10571
|
if (meta) {
|
|
10436
10572
|
sources.push({
|
|
@@ -10443,7 +10579,7 @@ function scanCodex(repoRoot2) {
|
|
|
10443
10579
|
}
|
|
10444
10580
|
}
|
|
10445
10581
|
const codexDir = join36(repoRoot2, ".codex");
|
|
10446
|
-
if (
|
|
10582
|
+
if (existsSync37(codexDir)) {
|
|
10447
10583
|
try {
|
|
10448
10584
|
for (const entry of walkDir(codexDir, 2)) {
|
|
10449
10585
|
const meta = fileMeta(entry);
|
|
@@ -10467,7 +10603,7 @@ function scanGeneric(repoRoot2) {
|
|
|
10467
10603
|
const knownFiles = [".github/copilot-instructions.md", "CONTRIBUTING.md"];
|
|
10468
10604
|
for (const rel of knownFiles) {
|
|
10469
10605
|
const full = join36(repoRoot2, rel);
|
|
10470
|
-
if (
|
|
10606
|
+
if (existsSync37(full)) {
|
|
10471
10607
|
const meta = fileMeta(full);
|
|
10472
10608
|
if (meta) {
|
|
10473
10609
|
sources.push({
|
|
@@ -10503,7 +10639,7 @@ function* walkDir(dir, maxDepth, depth = 0) {
|
|
|
10503
10639
|
}
|
|
10504
10640
|
|
|
10505
10641
|
// src/avorelo/capabilities/context-check/classifier.ts
|
|
10506
|
-
import { existsSync as
|
|
10642
|
+
import { existsSync as existsSync38 } from "node:fs";
|
|
10507
10643
|
import { join as join37, dirname as dirname4 } from "node:path";
|
|
10508
10644
|
var OVERSIZE_WARNING_TOKENS = 8e3;
|
|
10509
10645
|
var OVERSIZE_ATTENTION_TOKENS = 25e3;
|
|
@@ -10529,7 +10665,7 @@ function checkBrokenReferences(src, repoRoot2) {
|
|
|
10529
10665
|
for (const ref of src.references) {
|
|
10530
10666
|
const resolvedPath = join37(repoRoot2, dirname4(src.path), ref);
|
|
10531
10667
|
const resolvedFromRoot = join37(repoRoot2, ref);
|
|
10532
|
-
if (!
|
|
10668
|
+
if (!existsSync38(resolvedPath) && !existsSync38(resolvedFromRoot)) {
|
|
10533
10669
|
findings.push({
|
|
10534
10670
|
code: "BROKEN_CONTEXT_REFERENCE",
|
|
10535
10671
|
severity: "warning",
|
|
@@ -10586,7 +10722,7 @@ function checkRuleMatchesNoFiles(src, repoRoot2) {
|
|
|
10586
10722
|
for (const glob of src.appliesToPaths) {
|
|
10587
10723
|
if (glob.includes("*")) continue;
|
|
10588
10724
|
const target = join37(repoRoot2, glob);
|
|
10589
|
-
if (!
|
|
10725
|
+
if (!existsSync38(target)) {
|
|
10590
10726
|
return [{
|
|
10591
10727
|
code: "RULE_MATCHES_NO_FILES",
|
|
10592
10728
|
severity: "info",
|
|
@@ -11653,7 +11789,7 @@ function writeRuntimeSession(dir, record) {
|
|
|
11653
11789
|
}
|
|
11654
11790
|
function loadLatestRuntimeSession(dir) {
|
|
11655
11791
|
const path = join39(runtimeDir(dir), "session.latest.json");
|
|
11656
|
-
if (!
|
|
11792
|
+
if (!existsSync39(path)) return null;
|
|
11657
11793
|
try {
|
|
11658
11794
|
return JSON.parse(readFileSync23(path, "utf8"));
|
|
11659
11795
|
} catch {
|
|
@@ -11836,7 +11972,7 @@ function buildControlCenter(dir, opts) {
|
|
|
11836
11972
|
let contextCheckSection = { status: "unavailable" };
|
|
11837
11973
|
try {
|
|
11838
11974
|
const ccPath = avoreloPath(dir, "context-check", "latest.json");
|
|
11839
|
-
if (
|
|
11975
|
+
if (existsSync40(ccPath)) {
|
|
11840
11976
|
const raw = JSON.parse(readFileSync24(ccPath, "utf8"));
|
|
11841
11977
|
contextCheckSection = {
|
|
11842
11978
|
status: "available",
|
|
@@ -12071,7 +12207,7 @@ function openControlCenter(dir, opts) {
|
|
|
12071
12207
|
|
|
12072
12208
|
// src/avorelo/capabilities/activation/init.ts
|
|
12073
12209
|
import { createHash as createHash13, randomUUID as randomUUID4 } from "node:crypto";
|
|
12074
|
-
import { existsSync as
|
|
12210
|
+
import { existsSync as existsSync41, mkdirSync as mkdirSync26, writeFileSync as writeFileSync25, readFileSync as readFileSync25, statSync as statSync4, accessSync, constants } from "node:fs";
|
|
12075
12211
|
import { join as join41 } from "node:path";
|
|
12076
12212
|
var ACTIVATION_V1_CONTRACT = "avorelo.activation.v1";
|
|
12077
12213
|
var WORKSPACE_V1_CONTRACT = "avorelo.workspace.v1";
|
|
@@ -12089,7 +12225,7 @@ function freshActivationId(seed) {
|
|
|
12089
12225
|
}
|
|
12090
12226
|
function loadWorkspace(dir) {
|
|
12091
12227
|
const p = workspacePath(dir);
|
|
12092
|
-
if (!
|
|
12228
|
+
if (!existsSync41(p)) return null;
|
|
12093
12229
|
try {
|
|
12094
12230
|
const w = JSON.parse(readFileSync25(p, "utf8"));
|
|
12095
12231
|
return w.contract === WORKSPACE_V1_CONTRACT && typeof w.workspaceId === "string" ? w : null;
|
|
@@ -12114,9 +12250,9 @@ function buildActivationContract(dir, opts) {
|
|
|
12114
12250
|
} catch {
|
|
12115
12251
|
packageManager = null;
|
|
12116
12252
|
}
|
|
12117
|
-
const packageDetected =
|
|
12253
|
+
const packageDetected = existsSync41(join41(dir, "package.json"));
|
|
12118
12254
|
const repoDetected = packageDetected || gitDetected;
|
|
12119
|
-
const avoreloDirReady =
|
|
12255
|
+
const avoreloDirReady = existsSync41(avoreloDir(dir));
|
|
12120
12256
|
const initialized = !!existing;
|
|
12121
12257
|
const firstRunRecommended = !initialized ? { command: `avorelo init --target ${dir}`, reason: "Initialize the local Avorelo workspace first." } : { command: `avorelo run "run tests" --target ${dir}`, reason: "Run your first focused task; Avorelo saves proof locally." };
|
|
12122
12258
|
const limitations = [
|
|
@@ -12151,7 +12287,7 @@ function buildActivationContract(dir, opts) {
|
|
|
12151
12287
|
function initWorkspace(dir, opts) {
|
|
12152
12288
|
const now = opts?.now ?? Date.now();
|
|
12153
12289
|
try {
|
|
12154
|
-
if (!
|
|
12290
|
+
if (!existsSync41(dir)) return { ok: false, created: false, reason: "target_does_not_exist" };
|
|
12155
12291
|
if (!statSync4(dir).isDirectory()) return { ok: false, created: false, reason: "target_not_a_directory" };
|
|
12156
12292
|
} catch {
|
|
12157
12293
|
return { ok: false, created: false, reason: "target_not_accessible" };
|
|
@@ -12291,11 +12427,11 @@ function renderDogfoodCheck(r2) {
|
|
|
12291
12427
|
|
|
12292
12428
|
// src/avorelo/capabilities/core-readiness/index.ts
|
|
12293
12429
|
import { createHash as createHash15 } from "node:crypto";
|
|
12294
|
-
import { existsSync as
|
|
12430
|
+
import { existsSync as existsSync43, readFileSync as readFileSync27 } from "node:fs";
|
|
12295
12431
|
import { join as join43 } from "node:path";
|
|
12296
12432
|
|
|
12297
12433
|
// src/avorelo/capabilities/canonical-readiness/index.ts
|
|
12298
|
-
import { existsSync as
|
|
12434
|
+
import { existsSync as existsSync42, readFileSync as readFileSync26, readdirSync as readdirSync11, statSync as statSync5 } from "node:fs";
|
|
12299
12435
|
import { join as join42 } from "node:path";
|
|
12300
12436
|
import { createHash as createHash14 } from "node:crypto";
|
|
12301
12437
|
var FORBIDDEN_CLAIM_PATTERNS = [
|
|
@@ -12380,7 +12516,7 @@ var OLD_CAP_SPECS = [
|
|
|
12380
12516
|
{ capability: "Seamless Model & Primitive Routing", evidence: ["src/avorelo/kernel/model-routing/index.ts", "src/avorelo/kernel/model-routing/resolver.ts", "src/avorelo/kernel/model-routing/verifier.ts"], status: "adapted", notes: ["Phase 10; deterministic-first cascade, upgrade-only session memory, safety-verified projections"] }
|
|
12381
12517
|
];
|
|
12382
12518
|
function has(root, rel) {
|
|
12383
|
-
return
|
|
12519
|
+
return existsSync42(join42(root, rel));
|
|
12384
12520
|
}
|
|
12385
12521
|
function read(root, rel) {
|
|
12386
12522
|
try {
|
|
@@ -12392,7 +12528,7 @@ function read(root, rel) {
|
|
|
12392
12528
|
function walkFiles(root, rel, exts) {
|
|
12393
12529
|
const out = [];
|
|
12394
12530
|
const base = join42(root, rel);
|
|
12395
|
-
if (!
|
|
12531
|
+
if (!existsSync42(base)) return out;
|
|
12396
12532
|
const rec = (dir) => {
|
|
12397
12533
|
for (const name of readdirSync11(dir)) {
|
|
12398
12534
|
const p = join42(dir, name);
|
|
@@ -12536,7 +12672,7 @@ function repoRoot() {
|
|
|
12536
12672
|
return join43(import.meta.dirname, "..", "..", "..", "..");
|
|
12537
12673
|
}
|
|
12538
12674
|
function has2(root, rel) {
|
|
12539
|
-
return
|
|
12675
|
+
return existsSync43(join43(root, rel));
|
|
12540
12676
|
}
|
|
12541
12677
|
function buildCoreReadiness(opts) {
|
|
12542
12678
|
const now = opts?.now ?? Date.now();
|
|
@@ -12843,18 +12979,18 @@ init_stop_continue_gate();
|
|
|
12843
12979
|
init_state_ledger();
|
|
12844
12980
|
init_receipts();
|
|
12845
12981
|
init_redaction();
|
|
12846
|
-
import { readFileSync as readFileSync28, existsSync as
|
|
12982
|
+
import { readFileSync as readFileSync28, existsSync as existsSync44, statSync as statSync6 } from "node:fs";
|
|
12847
12983
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
12848
12984
|
function readBack(dir, check) {
|
|
12849
12985
|
const id = check.artifactId ?? `sot_${check.kind}`;
|
|
12850
12986
|
const resolve5 = (p) => p.startsWith("/") || /^[A-Za-z]:/.test(p) ? p : `${dir}/${p}`;
|
|
12851
12987
|
try {
|
|
12852
12988
|
if (check.kind === "file_absent") {
|
|
12853
|
-
const passed2 = !
|
|
12989
|
+
const passed2 = !existsSync44(resolve5(check.path));
|
|
12854
12990
|
return { artifact: passed2 ? { artifactId: id, kind: "source_of_truth_readback", ref: `sot:absent:${check.path}` } : null, passed: passed2, reasonCode: passed2 ? "READBACK_ABSENT_OK" : "READBACK_UNEXPECTEDLY_PRESENT", check };
|
|
12855
12991
|
}
|
|
12856
12992
|
const p = resolve5(check.path);
|
|
12857
|
-
if (!
|
|
12993
|
+
if (!existsSync44(p)) return { artifact: null, passed: false, reasonCode: "READBACK_FILE_MISSING", check };
|
|
12858
12994
|
const actual = readFileSync28(p, "utf8");
|
|
12859
12995
|
const passed = check.kind === "file_equals" ? actual.trim() === check.expected.trim() : actual.includes(check.expected);
|
|
12860
12996
|
return { artifact: passed ? { artifactId: id, kind: "source_of_truth_readback", ref: `sot:${check.kind}:${check.path}` } : null, passed, reasonCode: passed ? "READBACK_MATCH" : "READBACK_MISMATCH", check };
|
|
@@ -12918,7 +13054,7 @@ function evaluateProof(input) {
|
|
|
12918
13054
|
}
|
|
12919
13055
|
function loadProofInput(dir) {
|
|
12920
13056
|
const p = `${dir}/.avorelo/proof-input.json`;
|
|
12921
|
-
if (!
|
|
13057
|
+
if (!existsSync44(p)) return null;
|
|
12922
13058
|
try {
|
|
12923
13059
|
return JSON.parse(readFileSync28(p, "utf8"));
|
|
12924
13060
|
} catch {
|
|
@@ -12927,17 +13063,18 @@ function loadProofInput(dir) {
|
|
|
12927
13063
|
}
|
|
12928
13064
|
|
|
12929
13065
|
// src/avorelo/surfaces/public-web/index.ts
|
|
12930
|
-
import { mkdirSync as mkdirSync27, copyFileSync as copyFileSync2, readdirSync as readdirSync12, existsSync as
|
|
13066
|
+
import { mkdirSync as mkdirSync27, copyFileSync as copyFileSync2, readdirSync as readdirSync12, existsSync as existsSync45 } from "node:fs";
|
|
12931
13067
|
import { join as join44, dirname as dirname5 } from "node:path";
|
|
12932
13068
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
12933
13069
|
var __dirname = dirname5(fileURLToPath2(import.meta.url));
|
|
12934
13070
|
var STATIC_DIR = join44(__dirname, "static");
|
|
12935
13071
|
function buildSite(outDir) {
|
|
12936
13072
|
mkdirSync27(outDir, { recursive: true });
|
|
12937
|
-
if (!
|
|
13073
|
+
if (!existsSync45(STATIC_DIR)) {
|
|
12938
13074
|
return { ok: false, outDir, pages: [], indexPath: "" };
|
|
12939
13075
|
}
|
|
12940
|
-
const
|
|
13076
|
+
const NETLIFY_FILES = ["_redirects", "_headers"];
|
|
13077
|
+
const files = readdirSync12(STATIC_DIR).filter((f) => /\.(html|js|css|png|svg|ico|json|txt|xml|webmanifest)$/.test(f) || NETLIFY_FILES.includes(f));
|
|
12941
13078
|
for (const f of files) {
|
|
12942
13079
|
copyFileSync2(join44(STATIC_DIR, f), join44(outDir, f));
|
|
12943
13080
|
}
|
|
@@ -12951,7 +13088,7 @@ function buildSite(outDir) {
|
|
|
12951
13088
|
|
|
12952
13089
|
// src/avorelo/surfaces/preview-server/index.ts
|
|
12953
13090
|
import { createServer } from "node:http";
|
|
12954
|
-
import { readFileSync as readFileSync29, existsSync as
|
|
13091
|
+
import { readFileSync as readFileSync29, existsSync as existsSync46, statSync as statSync7 } from "node:fs";
|
|
12955
13092
|
import { join as join45, normalize, extname, sep as sep4 } from "node:path";
|
|
12956
13093
|
var MIME = {
|
|
12957
13094
|
".html": "text/html; charset=utf-8",
|
|
@@ -12971,7 +13108,7 @@ function resolveRequestPath(root, urlPath) {
|
|
|
12971
13108
|
const abs = normalize(join45(rootNorm, candidate));
|
|
12972
13109
|
if (abs !== rootNorm && !abs.startsWith(rootNorm.endsWith(sep4) ? rootNorm : rootNorm + sep4)) return null;
|
|
12973
13110
|
try {
|
|
12974
|
-
if (!
|
|
13111
|
+
if (!existsSync46(abs) || !statSync7(abs).isFile()) return null;
|
|
12975
13112
|
} catch {
|
|
12976
13113
|
return null;
|
|
12977
13114
|
}
|
|
@@ -13486,12 +13623,12 @@ init_resume_packet();
|
|
|
13486
13623
|
init_registry();
|
|
13487
13624
|
|
|
13488
13625
|
// src/avorelo/capabilities/update-notice/index.ts
|
|
13489
|
-
import { existsSync as
|
|
13626
|
+
import { existsSync as existsSync47, readFileSync as readFileSync30, writeFileSync as writeFileSync26, mkdirSync as mkdirSync28 } from "node:fs";
|
|
13490
13627
|
import { join as join46, dirname as dirname6 } from "node:path";
|
|
13491
13628
|
var STATE_PATH = ".avorelo/notice-state.json";
|
|
13492
13629
|
function readNoticeState(dir) {
|
|
13493
13630
|
const filePath = join46(dir, STATE_PATH);
|
|
13494
|
-
if (!
|
|
13631
|
+
if (!existsSync47(filePath)) {
|
|
13495
13632
|
return { lastSeenVersion: "", dismissedVersions: [], quietMode: false, lastCheckedAt: "" };
|
|
13496
13633
|
}
|
|
13497
13634
|
try {
|
|
@@ -13503,7 +13640,7 @@ function readNoticeState(dir) {
|
|
|
13503
13640
|
function writeNoticeState(dir, state) {
|
|
13504
13641
|
const filePath = join46(dir, STATE_PATH);
|
|
13505
13642
|
const d = dirname6(filePath);
|
|
13506
|
-
if (!
|
|
13643
|
+
if (!existsSync47(d)) mkdirSync28(d, { recursive: true });
|
|
13507
13644
|
writeFileSync26(filePath, JSON.stringify(state, null, 2));
|
|
13508
13645
|
}
|
|
13509
13646
|
function getCurrentVersion() {
|
|
@@ -13559,7 +13696,7 @@ function getNoticeState(dir) {
|
|
|
13559
13696
|
}
|
|
13560
13697
|
|
|
13561
13698
|
// src/avorelo/capabilities/registry-freshness/index.ts
|
|
13562
|
-
import { existsSync as
|
|
13699
|
+
import { existsSync as existsSync48, readFileSync as readFileSync31, writeFileSync as writeFileSync27, mkdirSync as mkdirSync29 } from "node:fs";
|
|
13563
13700
|
import { join as join47, dirname as dirname7 } from "node:path";
|
|
13564
13701
|
var REGISTRY_FRESHNESS_CONTRACT = "avorelo.registryFreshness.v1";
|
|
13565
13702
|
var CACHE_FILE = ".avorelo/registry-freshness-cache.json";
|
|
@@ -13591,7 +13728,7 @@ function isSuppressed() {
|
|
|
13591
13728
|
}
|
|
13592
13729
|
function readCache(dir) {
|
|
13593
13730
|
const p = join47(dir, CACHE_FILE);
|
|
13594
|
-
if (!
|
|
13731
|
+
if (!existsSync48(p)) return null;
|
|
13595
13732
|
try {
|
|
13596
13733
|
return JSON.parse(readFileSync31(p, "utf8"));
|
|
13597
13734
|
} catch {
|
|
@@ -13695,10 +13832,10 @@ init_drift_detector();
|
|
|
13695
13832
|
init_intervention();
|
|
13696
13833
|
import { readdirSync as readdirSync13, statSync as statSync9 } from "node:fs";
|
|
13697
13834
|
import { join as join48, relative as relative2 } from "node:path";
|
|
13698
|
-
import { execSync as
|
|
13835
|
+
import { execSync as execSync3 } from "node:child_process";
|
|
13699
13836
|
function getGitChangedFiles(dir) {
|
|
13700
13837
|
try {
|
|
13701
|
-
const out =
|
|
13838
|
+
const out = execSync3("git diff --name-only", { cwd: dir, stdio: "pipe", timeout: 5e3 }).toString().trim();
|
|
13702
13839
|
if (!out) return [];
|
|
13703
13840
|
return out.split("\n").map((f) => f.trim()).filter(Boolean);
|
|
13704
13841
|
} catch {
|
|
@@ -13707,7 +13844,7 @@ function getGitChangedFiles(dir) {
|
|
|
13707
13844
|
}
|
|
13708
13845
|
function getGitUntrackedFiles(dir) {
|
|
13709
13846
|
try {
|
|
13710
|
-
const out =
|
|
13847
|
+
const out = execSync3("git ls-files --others --exclude-standard", { cwd: dir, stdio: "pipe", timeout: 5e3 }).toString().trim();
|
|
13711
13848
|
if (!out) return [];
|
|
13712
13849
|
return out.split("\n").map((f) => f.trim()).filter(Boolean);
|
|
13713
13850
|
} catch {
|
|
@@ -13833,7 +13970,7 @@ function watchWithFixture(dir, fixture) {
|
|
|
13833
13970
|
}
|
|
13834
13971
|
|
|
13835
13972
|
// src/avorelo/capabilities/workspace/monorepo.ts
|
|
13836
|
-
import { existsSync as
|
|
13973
|
+
import { existsSync as existsSync50, readFileSync as readFileSync33, readdirSync as readdirSync14, statSync as statSync10 } from "node:fs";
|
|
13837
13974
|
import { join as join49 } from "node:path";
|
|
13838
13975
|
function expandGlobDirs(dir, patterns) {
|
|
13839
13976
|
const results = [];
|
|
@@ -13841,16 +13978,16 @@ function expandGlobDirs(dir, patterns) {
|
|
|
13841
13978
|
const clean = pattern.replace(/\/\*$/, "").replace(/\*$/, "");
|
|
13842
13979
|
if (!clean) continue;
|
|
13843
13980
|
const base = join49(dir, clean);
|
|
13844
|
-
if (!
|
|
13981
|
+
if (!existsSync50(base)) continue;
|
|
13845
13982
|
if (clean.includes("*")) continue;
|
|
13846
13983
|
try {
|
|
13847
13984
|
const stat = statSync10(base);
|
|
13848
13985
|
if (stat.isDirectory()) {
|
|
13849
|
-
if (
|
|
13986
|
+
if (existsSync50(join49(base, "package.json"))) {
|
|
13850
13987
|
results.push(base);
|
|
13851
13988
|
} else {
|
|
13852
13989
|
for (const entry of readdirSync14(base, { withFileTypes: true })) {
|
|
13853
|
-
if (entry.isDirectory() &&
|
|
13990
|
+
if (entry.isDirectory() && existsSync50(join49(base, entry.name, "package.json"))) {
|
|
13854
13991
|
results.push(join49(base, entry.name));
|
|
13855
13992
|
}
|
|
13856
13993
|
}
|
|
@@ -13873,9 +14010,9 @@ function buildWorkspace(dir, wsPath) {
|
|
|
13873
14010
|
name,
|
|
13874
14011
|
path: wsPath,
|
|
13875
14012
|
relativePath: rel,
|
|
13876
|
-
hasPackageJson:
|
|
13877
|
-
hasAgentsMd:
|
|
13878
|
-
hasCursorRules:
|
|
14013
|
+
hasPackageJson: existsSync50(join49(wsPath, "package.json")),
|
|
14014
|
+
hasAgentsMd: existsSync50(join49(wsPath, "AGENTS.md")),
|
|
14015
|
+
hasCursorRules: existsSync50(join49(wsPath, ".cursor"))
|
|
13879
14016
|
};
|
|
13880
14017
|
}
|
|
13881
14018
|
function detectMonorepo(dir) {
|
|
@@ -13906,7 +14043,7 @@ function detectMonorepo(dir) {
|
|
|
13906
14043
|
} catch {
|
|
13907
14044
|
}
|
|
13908
14045
|
const pnpmPath = join49(dir, "pnpm-workspace.yaml");
|
|
13909
|
-
if (
|
|
14046
|
+
if (existsSync50(pnpmPath)) {
|
|
13910
14047
|
try {
|
|
13911
14048
|
const content = readFileSync33(pnpmPath, "utf8");
|
|
13912
14049
|
const match = content.match(/packages:\s*\n((?:\s*-\s*.+\n?)+)/);
|
|
@@ -13927,10 +14064,10 @@ function detectMonorepo(dir) {
|
|
|
13927
14064
|
}
|
|
13928
14065
|
for (const conventionDir of ["apps", "packages"]) {
|
|
13929
14066
|
const convPath = join49(dir, conventionDir);
|
|
13930
|
-
if (
|
|
14067
|
+
if (existsSync50(convPath)) {
|
|
13931
14068
|
try {
|
|
13932
14069
|
const entries = readdirSync14(convPath, { withFileTypes: true });
|
|
13933
|
-
const workspacePaths = entries.filter((e) => e.isDirectory() &&
|
|
14070
|
+
const workspacePaths = entries.filter((e) => e.isDirectory() && existsSync50(join49(convPath, e.name, "package.json"))).map((e) => join49(convPath, e.name));
|
|
13934
14071
|
if (workspacePaths.length > 0) {
|
|
13935
14072
|
return {
|
|
13936
14073
|
isMonorepo: true,
|
|
@@ -13947,7 +14084,7 @@ function detectMonorepo(dir) {
|
|
|
13947
14084
|
}
|
|
13948
14085
|
|
|
13949
14086
|
// src/avorelo/capabilities/feedback/config.ts
|
|
13950
|
-
import { existsSync as
|
|
14087
|
+
import { existsSync as existsSync51, readFileSync as readFileSync34, writeFileSync as writeFileSync28, mkdirSync as mkdirSync30 } from "node:fs";
|
|
13951
14088
|
import { join as join50, dirname as dirname8 } from "node:path";
|
|
13952
14089
|
var CONFIG_PATH = ".avorelo/config.json";
|
|
13953
14090
|
var DEFAULTS = {
|
|
@@ -13959,7 +14096,7 @@ var DEFAULTS = {
|
|
|
13959
14096
|
};
|
|
13960
14097
|
function readConfig(dir) {
|
|
13961
14098
|
const p = join50(dir, CONFIG_PATH);
|
|
13962
|
-
if (!
|
|
14099
|
+
if (!existsSync51(p)) return {};
|
|
13963
14100
|
try {
|
|
13964
14101
|
return JSON.parse(readFileSync34(p, "utf8"));
|
|
13965
14102
|
} catch {
|
|
@@ -13990,9 +14127,9 @@ function optOut(dir) {
|
|
|
13990
14127
|
|
|
13991
14128
|
// src/avorelo/capabilities/feedback/bundle.ts
|
|
13992
14129
|
init_redaction();
|
|
13993
|
-
import { existsSync as
|
|
14130
|
+
import { existsSync as existsSync52, readFileSync as readFileSync35, writeFileSync as writeFileSync29, mkdirSync as mkdirSync31, readdirSync as readdirSync15 } from "node:fs";
|
|
13994
14131
|
import { join as join51 } from "node:path";
|
|
13995
|
-
import { platform as
|
|
14132
|
+
import { platform as platform3, release, arch } from "node:os";
|
|
13996
14133
|
init_registry();
|
|
13997
14134
|
init_session_store();
|
|
13998
14135
|
function getVersion() {
|
|
@@ -14004,11 +14141,11 @@ function getVersion() {
|
|
|
14004
14141
|
}
|
|
14005
14142
|
}
|
|
14006
14143
|
function detectPackageManager(dir) {
|
|
14007
|
-
if (
|
|
14008
|
-
if (
|
|
14009
|
-
if (
|
|
14010
|
-
if (
|
|
14011
|
-
if (
|
|
14144
|
+
if (existsSync52(join51(dir, "pnpm-lock.yaml"))) return "pnpm";
|
|
14145
|
+
if (existsSync52(join51(dir, "yarn.lock"))) return "yarn";
|
|
14146
|
+
if (existsSync52(join51(dir, "bun.lockb"))) return "bun";
|
|
14147
|
+
if (existsSync52(join51(dir, "package-lock.json"))) return "npm";
|
|
14148
|
+
if (existsSync52(join51(dir, "package.json"))) return "npm";
|
|
14012
14149
|
return null;
|
|
14013
14150
|
}
|
|
14014
14151
|
function detectFramework(dir) {
|
|
@@ -14029,7 +14166,7 @@ function detectFramework(dir) {
|
|
|
14029
14166
|
}
|
|
14030
14167
|
function countReceipts(dir) {
|
|
14031
14168
|
const receiptsDir = join51(dir, ".avorelo", "receipts");
|
|
14032
|
-
if (!
|
|
14169
|
+
if (!existsSync52(receiptsDir)) return { total: 0, done: 0, blocked: 0, inProgress: 0 };
|
|
14033
14170
|
let done = 0, blocked = 0, inProgress = 0;
|
|
14034
14171
|
try {
|
|
14035
14172
|
for (const f of readdirSync15(receiptsDir).filter((f2) => f2.endsWith(".json"))) {
|
|
@@ -14056,7 +14193,7 @@ function prepareFeedbackBundle(dir) {
|
|
|
14056
14193
|
bundleId: `fb_${Date.now().toString(36)}`,
|
|
14057
14194
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
14058
14195
|
avorelo: { version: getVersion() },
|
|
14059
|
-
platform: { os:
|
|
14196
|
+
platform: { os: platform3(), release: release(), arch: arch(), nodeVersion: process.version },
|
|
14060
14197
|
workspace: {
|
|
14061
14198
|
packageManager: detectPackageManager(dir),
|
|
14062
14199
|
framework: detectFramework(dir),
|
|
@@ -14294,11 +14431,11 @@ function result(classification, risk, reasonCodes, humanGateConditions) {
|
|
|
14294
14431
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
14295
14432
|
|
|
14296
14433
|
// src/avorelo/capabilities/loop-control/check-detection.ts
|
|
14297
|
-
import { readFileSync as readFileSync36, existsSync as
|
|
14434
|
+
import { readFileSync as readFileSync36, existsSync as existsSync53 } from "node:fs";
|
|
14298
14435
|
import { join as join52 } from "node:path";
|
|
14299
14436
|
function detectFromPackageJson(cwd) {
|
|
14300
14437
|
const pkgPath = join52(cwd, "package.json");
|
|
14301
|
-
if (!
|
|
14438
|
+
if (!existsSync53(pkgPath)) return [];
|
|
14302
14439
|
try {
|
|
14303
14440
|
const pkg = JSON.parse(readFileSync36(pkgPath, "utf8"));
|
|
14304
14441
|
const scripts = pkg.scripts ?? {};
|
|
@@ -14321,19 +14458,19 @@ function detectFromPackageJson(cwd) {
|
|
|
14321
14458
|
}
|
|
14322
14459
|
}
|
|
14323
14460
|
function detectFromPython(cwd) {
|
|
14324
|
-
if (
|
|
14461
|
+
if (existsSync53(join52(cwd, "pytest.ini")) || existsSync53(join52(cwd, "pyproject.toml")) || existsSync53(join52(cwd, "setup.py"))) {
|
|
14325
14462
|
return [{ checkId: "chk_pytest", label: "pytest", command: "python -m pytest", source: "python" }];
|
|
14326
14463
|
}
|
|
14327
14464
|
return [];
|
|
14328
14465
|
}
|
|
14329
14466
|
function detectFromGo(cwd) {
|
|
14330
|
-
if (
|
|
14467
|
+
if (existsSync53(join52(cwd, "go.mod"))) {
|
|
14331
14468
|
return [{ checkId: "chk_go_test", label: "go test", command: "go test ./...", source: "go.mod" }];
|
|
14332
14469
|
}
|
|
14333
14470
|
return [];
|
|
14334
14471
|
}
|
|
14335
14472
|
function detectFromRust(cwd) {
|
|
14336
|
-
if (
|
|
14473
|
+
if (existsSync53(join52(cwd, "Cargo.toml"))) {
|
|
14337
14474
|
return [{ checkId: "chk_cargo_test", label: "cargo test", command: "cargo test", source: "Cargo.toml" }];
|
|
14338
14475
|
}
|
|
14339
14476
|
return [];
|
|
@@ -14573,7 +14710,7 @@ function detectIterationDrift(input) {
|
|
|
14573
14710
|
}
|
|
14574
14711
|
|
|
14575
14712
|
// src/avorelo/capabilities/loop-control/checks-runner.ts
|
|
14576
|
-
import { execSync as
|
|
14713
|
+
import { execSync as execSync4 } from "node:child_process";
|
|
14577
14714
|
var CHECK_TIMEOUT_MS = 12e4;
|
|
14578
14715
|
var MAX_OUTPUT_LENGTH = 200;
|
|
14579
14716
|
function truncateOutput(s) {
|
|
@@ -14589,7 +14726,7 @@ function runCheck(check, cwd) {
|
|
|
14589
14726
|
return { ...check, lastResult: "skipped", lastOutput: "no command configured" };
|
|
14590
14727
|
}
|
|
14591
14728
|
try {
|
|
14592
|
-
|
|
14729
|
+
execSync4(check.command, {
|
|
14593
14730
|
cwd,
|
|
14594
14731
|
timeout: CHECK_TIMEOUT_MS,
|
|
14595
14732
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -14606,10 +14743,10 @@ function runAllChecks(checks, cwd) {
|
|
|
14606
14743
|
}
|
|
14607
14744
|
|
|
14608
14745
|
// src/avorelo/capabilities/loop-control/git-observer.ts
|
|
14609
|
-
import { execSync as
|
|
14746
|
+
import { execSync as execSync5 } from "node:child_process";
|
|
14610
14747
|
function getChangedFiles(cwd, since) {
|
|
14611
14748
|
try {
|
|
14612
|
-
const output =
|
|
14749
|
+
const output = execSync5(`git diff --name-only ${since}`, {
|
|
14613
14750
|
cwd,
|
|
14614
14751
|
encoding: "utf-8",
|
|
14615
14752
|
timeout: 1e4,
|
|
@@ -14622,7 +14759,7 @@ function getChangedFiles(cwd, since) {
|
|
|
14622
14759
|
}
|
|
14623
14760
|
function getCurrentHead(cwd) {
|
|
14624
14761
|
try {
|
|
14625
|
-
return
|
|
14762
|
+
return execSync5("git rev-parse HEAD", { cwd, encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
14626
14763
|
} catch {
|
|
14627
14764
|
return null;
|
|
14628
14765
|
}
|
|
@@ -14630,7 +14767,7 @@ function getCurrentHead(cwd) {
|
|
|
14630
14767
|
|
|
14631
14768
|
// src/avorelo/capabilities/loop-control/loop-metadata.ts
|
|
14632
14769
|
init_redaction();
|
|
14633
|
-
import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync30, readFileSync as readFileSync37, existsSync as
|
|
14770
|
+
import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync30, readFileSync as readFileSync37, existsSync as existsSync54, readdirSync as readdirSync16 } from "node:fs";
|
|
14634
14771
|
import { join as join53 } from "node:path";
|
|
14635
14772
|
function classifyFile(file, allowed, disallowed) {
|
|
14636
14773
|
for (const d of disallowed) {
|
|
@@ -14718,7 +14855,7 @@ function persistLoopMetadata(dir, metadata) {
|
|
|
14718
14855
|
}
|
|
14719
14856
|
function readLoopMetadata(dir, loopId) {
|
|
14720
14857
|
const path = join53(loopDir(dir), `${loopId}.json`);
|
|
14721
|
-
if (!
|
|
14858
|
+
if (!existsSync54(path)) return null;
|
|
14722
14859
|
try {
|
|
14723
14860
|
const data = JSON.parse(readFileSync37(path, "utf8"));
|
|
14724
14861
|
return data && data.contract === "avorelo.loopMetadata.v1" ? data : null;
|
|
@@ -14728,7 +14865,7 @@ function readLoopMetadata(dir, loopId) {
|
|
|
14728
14865
|
}
|
|
14729
14866
|
function readLatestLoopMetadata(dir) {
|
|
14730
14867
|
const d = loopDir(dir);
|
|
14731
|
-
if (!
|
|
14868
|
+
if (!existsSync54(d)) return null;
|
|
14732
14869
|
try {
|
|
14733
14870
|
const files = readdirSync16(d).filter((f) => f.startsWith("loop_") && f.endsWith(".json"));
|
|
14734
14871
|
if (files.length === 0) return null;
|
|
@@ -14751,7 +14888,7 @@ function readLatestLoopMetadata(dir) {
|
|
|
14751
14888
|
}
|
|
14752
14889
|
function readActiveLoop(dir) {
|
|
14753
14890
|
const path = join53(loopDir(dir), "active.json");
|
|
14754
|
-
if (!
|
|
14891
|
+
if (!existsSync54(path)) return null;
|
|
14755
14892
|
try {
|
|
14756
14893
|
return JSON.parse(readFileSync37(path, "utf8"));
|
|
14757
14894
|
} catch {
|
|
@@ -14765,7 +14902,7 @@ function writeActiveLoop(dir, loopId, status) {
|
|
|
14765
14902
|
}
|
|
14766
14903
|
function clearActiveLoop(dir) {
|
|
14767
14904
|
const path = join53(loopDir(dir), "active.json");
|
|
14768
|
-
if (
|
|
14905
|
+
if (existsSync54(path)) {
|
|
14769
14906
|
writeFileSync30(path, JSON.stringify({ loopId: null, status: "none" }));
|
|
14770
14907
|
}
|
|
14771
14908
|
}
|
|
@@ -15006,7 +15143,7 @@ async function runLoop(input) {
|
|
|
15006
15143
|
}
|
|
15007
15144
|
|
|
15008
15145
|
// src/avorelo/adapters/claude-code/loop-adapter.ts
|
|
15009
|
-
import { execSync as
|
|
15146
|
+
import { execSync as execSync6 } from "node:child_process";
|
|
15010
15147
|
var MAX_LOG_LENGTH = 200;
|
|
15011
15148
|
var ITERATION_TIMEOUT_MS = 3e5;
|
|
15012
15149
|
function truncate(s) {
|
|
@@ -15036,7 +15173,7 @@ function buildPrompt2(input) {
|
|
|
15036
15173
|
}
|
|
15037
15174
|
function detectPermissionFlag() {
|
|
15038
15175
|
try {
|
|
15039
|
-
const help2 =
|
|
15176
|
+
const help2 = execSync6("claude --help", { timeout: 5e3, stdio: ["pipe", "pipe", "pipe"], encoding: "utf-8" });
|
|
15040
15177
|
if (help2.includes("--permission-mode")) return "--permission-mode bypassPermissions";
|
|
15041
15178
|
} catch {
|
|
15042
15179
|
}
|
|
@@ -15065,7 +15202,7 @@ var claudeCodeLoopAdapter = {
|
|
|
15065
15202
|
const prompt = buildPrompt2(input);
|
|
15066
15203
|
if (!_cachedPermFlag) _cachedPermFlag = detectPermissionFlag();
|
|
15067
15204
|
try {
|
|
15068
|
-
|
|
15205
|
+
execSync6(
|
|
15069
15206
|
`claude --print ${_cachedPermFlag} "${prompt.replace(/"/g, '\\"')}"`,
|
|
15070
15207
|
{
|
|
15071
15208
|
cwd: input.cwd,
|
|
@@ -15100,7 +15237,7 @@ var claudeCodeLoopAdapter = {
|
|
|
15100
15237
|
},
|
|
15101
15238
|
isAvailable() {
|
|
15102
15239
|
try {
|
|
15103
|
-
|
|
15240
|
+
execSync6("claude --version", { timeout: 5e3, stdio: ["pipe", "pipe", "pipe"], encoding: "utf-8" });
|
|
15104
15241
|
return true;
|
|
15105
15242
|
} catch {
|
|
15106
15243
|
return false;
|
|
@@ -15109,7 +15246,7 @@ var claudeCodeLoopAdapter = {
|
|
|
15109
15246
|
};
|
|
15110
15247
|
|
|
15111
15248
|
// src/avorelo/capabilities/settings/index.ts
|
|
15112
|
-
import { existsSync as
|
|
15249
|
+
import { existsSync as existsSync55, readFileSync as readFileSync38, writeFileSync as writeFileSync31, mkdirSync as mkdirSync33 } from "node:fs";
|
|
15113
15250
|
import { join as join54, dirname as dirname9 } from "node:path";
|
|
15114
15251
|
var SETTINGS_CONTRACT = "avorelo.settings.v1";
|
|
15115
15252
|
var SETTINGS_PATH = ".avorelo/settings.json";
|
|
@@ -15176,7 +15313,7 @@ function buildDefaultSettings(opts) {
|
|
|
15176
15313
|
}
|
|
15177
15314
|
function loadSettings(dir) {
|
|
15178
15315
|
const p = join54(dir, SETTINGS_PATH);
|
|
15179
|
-
if (!
|
|
15316
|
+
if (!existsSync55(p)) return null;
|
|
15180
15317
|
try {
|
|
15181
15318
|
const s = JSON.parse(readFileSync38(p, "utf8"));
|
|
15182
15319
|
return s.contract === SETTINGS_CONTRACT ? s : null;
|
|
@@ -15283,7 +15420,7 @@ var ALPHA_NOTICE = [
|
|
|
15283
15420
|
].join("\n");
|
|
15284
15421
|
|
|
15285
15422
|
// src/avorelo/capabilities/update-channel/index.ts
|
|
15286
|
-
import { existsSync as
|
|
15423
|
+
import { existsSync as existsSync56, readFileSync as readFileSync39, writeFileSync as writeFileSync32, mkdirSync as mkdirSync34 } from "node:fs";
|
|
15287
15424
|
import { join as join55, dirname as dirname10 } from "node:path";
|
|
15288
15425
|
var UPDATE_CHANNEL_CONTRACT = "avorelo.updateChannel.v1";
|
|
15289
15426
|
var UPDATE_MANIFEST_CONTRACT = "avorelo.updateManifest.v1";
|
|
@@ -15298,10 +15435,10 @@ function getCurrentVersion4() {
|
|
|
15298
15435
|
}
|
|
15299
15436
|
function detectInstallMethod(root) {
|
|
15300
15437
|
const r2 = root ?? join55(dirname10(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/, "$1")), "../../../..");
|
|
15301
|
-
if (
|
|
15438
|
+
if (existsSync56(join55(r2, ".git"))) return "source-checkout";
|
|
15302
15439
|
try {
|
|
15303
15440
|
const p = join55(r2, "package.json");
|
|
15304
|
-
if (
|
|
15441
|
+
if (existsSync56(p)) {
|
|
15305
15442
|
const pkg = JSON.parse(readFileSync39(p, "utf8"));
|
|
15306
15443
|
if (pkg._resolved) return "npm-global";
|
|
15307
15444
|
if (pkg._where) return "npm-local";
|
|
@@ -15312,7 +15449,7 @@ function detectInstallMethod(root) {
|
|
|
15312
15449
|
}
|
|
15313
15450
|
function loadManifest(dir) {
|
|
15314
15451
|
const p = join55(dir, ".avorelo", "update-manifest.json");
|
|
15315
|
-
if (!
|
|
15452
|
+
if (!existsSync56(p)) return null;
|
|
15316
15453
|
try {
|
|
15317
15454
|
const m = JSON.parse(readFileSync39(p, "utf8"));
|
|
15318
15455
|
return m.contract === UPDATE_MANIFEST_CONTRACT ? m : null;
|
|
@@ -15454,7 +15591,7 @@ function renderUpdateApply(r2) {
|
|
|
15454
15591
|
}
|
|
15455
15592
|
|
|
15456
15593
|
// src/avorelo/capabilities/dogfood-learning/index.ts
|
|
15457
|
-
import { existsSync as
|
|
15594
|
+
import { existsSync as existsSync57, readFileSync as readFileSync40, writeFileSync as writeFileSync33, mkdirSync as mkdirSync35, readdirSync as readdirSync17, unlinkSync as unlinkSync3 } from "node:fs";
|
|
15458
15595
|
import { join as join56, dirname as dirname11 } from "node:path";
|
|
15459
15596
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
15460
15597
|
var DOGFOOD_LEARNING_CONTRACT = "avorelo.dogfoodLearning.v1";
|
|
@@ -15651,7 +15788,7 @@ function ensureQueueDir(dir) {
|
|
|
15651
15788
|
}
|
|
15652
15789
|
function countQueuedEvents(dir) {
|
|
15653
15790
|
const qd = queueDir(dir);
|
|
15654
|
-
if (!
|
|
15791
|
+
if (!existsSync57(qd)) return 0;
|
|
15655
15792
|
try {
|
|
15656
15793
|
return readdirSync17(qd).filter((f) => f.endsWith(".json")).length;
|
|
15657
15794
|
} catch {
|
|
@@ -15669,7 +15806,7 @@ function queueEvent(dir, payload) {
|
|
|
15669
15806
|
}
|
|
15670
15807
|
function loadQueuedEvents(dir) {
|
|
15671
15808
|
const qd = queueDir(dir);
|
|
15672
|
-
if (!
|
|
15809
|
+
if (!existsSync57(qd)) return [];
|
|
15673
15810
|
const files = readdirSync17(qd).filter((f) => f.endsWith(".json")).sort();
|
|
15674
15811
|
const events = [];
|
|
15675
15812
|
for (const f of files) {
|
|
@@ -15683,7 +15820,7 @@ function loadQueuedEvents(dir) {
|
|
|
15683
15820
|
}
|
|
15684
15821
|
function purgeQueue(dir) {
|
|
15685
15822
|
const qd = queueDir(dir);
|
|
15686
|
-
if (!
|
|
15823
|
+
if (!existsSync57(qd)) return { purged: 0 };
|
|
15687
15824
|
const files = readdirSync17(qd).filter((f) => f.endsWith(".json"));
|
|
15688
15825
|
for (const f of files) {
|
|
15689
15826
|
try {
|
|
@@ -15878,7 +16015,7 @@ function generateLocalFingerprint(target) {
|
|
|
15878
16015
|
var CLAIM_EXPIRY_MS = 24 * 60 * 60 * 1e3;
|
|
15879
16016
|
|
|
15880
16017
|
// src/avorelo/capabilities/cloud-sync/cli-auth-state.ts
|
|
15881
|
-
import { existsSync as
|
|
16018
|
+
import { existsSync as existsSync58, readFileSync as readFileSync41, writeFileSync as writeFileSync34, mkdirSync as mkdirSync36 } from "node:fs";
|
|
15882
16019
|
import { join as join57 } from "node:path";
|
|
15883
16020
|
function authDir(baseDir) {
|
|
15884
16021
|
return join57(baseDir, ".avorelo", "auth");
|
|
@@ -15895,7 +16032,7 @@ function writeCliAuthState(baseDir, state) {
|
|
|
15895
16032
|
}
|
|
15896
16033
|
function readCliAuthState(baseDir) {
|
|
15897
16034
|
const path = authPath(baseDir);
|
|
15898
|
-
if (!
|
|
16035
|
+
if (!existsSync58(path)) return null;
|
|
15899
16036
|
try {
|
|
15900
16037
|
const raw = JSON.parse(readFileSync41(path, "utf8"));
|
|
15901
16038
|
if (!raw || typeof raw.token !== "string" || typeof raw.workspaceId !== "string") return null;
|
|
@@ -15911,7 +16048,7 @@ function buildAuthHeaders(authState) {
|
|
|
15911
16048
|
}
|
|
15912
16049
|
|
|
15913
16050
|
// src/avorelo/capabilities/cloud-sync/claim-state.ts
|
|
15914
|
-
import { existsSync as
|
|
16051
|
+
import { existsSync as existsSync59, readFileSync as readFileSync42, writeFileSync as writeFileSync35, mkdirSync as mkdirSync37 } from "node:fs";
|
|
15915
16052
|
import { join as join58 } from "node:path";
|
|
15916
16053
|
function claimDir(baseDir) {
|
|
15917
16054
|
return join58(baseDir, ".avorelo", "claim");
|
|
@@ -15928,7 +16065,7 @@ function writeClaimState(baseDir, state) {
|
|
|
15928
16065
|
}
|
|
15929
16066
|
function readClaimState(baseDir) {
|
|
15930
16067
|
const path = claimPath(baseDir);
|
|
15931
|
-
if (!
|
|
16068
|
+
if (!existsSync59(path)) return null;
|
|
15932
16069
|
try {
|
|
15933
16070
|
const raw = JSON.parse(readFileSync42(path, "utf8"));
|
|
15934
16071
|
if (!raw || typeof raw.workspaceId !== "string" || typeof raw.claimedAt !== "string") return null;
|
|
@@ -16070,7 +16207,7 @@ function formatCliGateMessage(gateResult) {
|
|
|
16070
16207
|
}
|
|
16071
16208
|
|
|
16072
16209
|
// src/avorelo/telemetry/local-store.ts
|
|
16073
|
-
import { appendFileSync as appendFileSync10, existsSync as
|
|
16210
|
+
import { appendFileSync as appendFileSync10, existsSync as existsSync60, mkdirSync as mkdirSync38, readFileSync as readFileSync44, writeFileSync as writeFileSync36 } from "node:fs";
|
|
16074
16211
|
import { dirname as dirname13 } from "node:path";
|
|
16075
16212
|
|
|
16076
16213
|
// src/avorelo/telemetry/config.ts
|
|
@@ -16084,7 +16221,7 @@ var TELEMETRY_STATE_FILE = "telemetry-state.json";
|
|
|
16084
16221
|
var TELEMETRY_BATCH_SIZE = 100;
|
|
16085
16222
|
var TELEMETRY_PERIOD_MS = 6 * 60 * 60 * 1e3;
|
|
16086
16223
|
var TELEMETRY_OPPORTUNISTIC_MS = 24 * 60 * 60 * 1e3;
|
|
16087
|
-
var TELEMETRY_TIMEOUT_MS =
|
|
16224
|
+
var TELEMETRY_TIMEOUT_MS = 2e3;
|
|
16088
16225
|
function getPackageVersion() {
|
|
16089
16226
|
for (const rel of ["../../../package.json", "../../../../package.json", "../../../../../package.json"]) {
|
|
16090
16227
|
try {
|
|
@@ -16392,7 +16529,7 @@ function safeParseJson(text) {
|
|
|
16392
16529
|
}
|
|
16393
16530
|
}
|
|
16394
16531
|
function readJsonl(path) {
|
|
16395
|
-
if (!
|
|
16532
|
+
if (!existsSync60(path)) return [];
|
|
16396
16533
|
const lines = readFileSync44(path, "utf8").split(/\r?\n/);
|
|
16397
16534
|
const values = [];
|
|
16398
16535
|
for (const line of lines) {
|
|
@@ -16415,7 +16552,7 @@ function writeJsonl(path, values) {
|
|
|
16415
16552
|
}
|
|
16416
16553
|
function ensureTelemetryState(dir, now = Date.now()) {
|
|
16417
16554
|
const paths = getTelemetryConfig(dir, buildTelemetryState(now));
|
|
16418
|
-
if (
|
|
16555
|
+
if (existsSync60(paths.statePath)) {
|
|
16419
16556
|
const parsed = safeParseJson(readFileSync44(paths.statePath, "utf8"));
|
|
16420
16557
|
if (parsed?.contract === "avorelo.telemetry.state.v1") return parsed;
|
|
16421
16558
|
}
|
|
@@ -16903,11 +17040,11 @@ function renderTelemetryPreview(preview) {
|
|
|
16903
17040
|
}
|
|
16904
17041
|
|
|
16905
17042
|
// src/avorelo/telemetry/integration-detection.ts
|
|
16906
|
-
import { existsSync as
|
|
17043
|
+
import { existsSync as existsSync61, readFileSync as readFileSync45 } from "node:fs";
|
|
16907
17044
|
import { join as join60 } from "node:path";
|
|
16908
17045
|
function detectGitProviderFromConfig(dir) {
|
|
16909
17046
|
const configPath = join60(dir, ".git", "config");
|
|
16910
|
-
if (!
|
|
17047
|
+
if (!existsSync61(configPath)) return "unknown";
|
|
16911
17048
|
try {
|
|
16912
17049
|
const content = readFileSync45(configPath, "utf8").toLowerCase();
|
|
16913
17050
|
if (content.includes("github.com")) return "github";
|
|
@@ -16919,15 +17056,15 @@ function detectGitProviderFromConfig(dir) {
|
|
|
16919
17056
|
}
|
|
16920
17057
|
}
|
|
16921
17058
|
function detectCiProvider(dir) {
|
|
16922
|
-
if (
|
|
16923
|
-
if (
|
|
16924
|
-
if (
|
|
16925
|
-
if (
|
|
17059
|
+
if (existsSync61(join60(dir, ".github", "workflows"))) return "github_actions";
|
|
17060
|
+
if (existsSync61(join60(dir, ".gitlab-ci.yml"))) return "gitlab_ci";
|
|
17061
|
+
if (existsSync61(join60(dir, ".circleci", "config.yml"))) return "circle";
|
|
17062
|
+
if (existsSync61(join60(dir, "Jenkinsfile"))) return "jenkins";
|
|
16926
17063
|
return "unknown";
|
|
16927
17064
|
}
|
|
16928
17065
|
function detectRepoVisibility(dir) {
|
|
16929
17066
|
const configPath = join60(dir, ".git", "config");
|
|
16930
|
-
if (!
|
|
17067
|
+
if (!existsSync61(configPath)) return "unknown";
|
|
16931
17068
|
try {
|
|
16932
17069
|
const content = readFileSync45(configPath, "utf8").toLowerCase();
|
|
16933
17070
|
if (content.includes("github.com")) {
|
|
@@ -17175,10 +17312,12 @@ function cmdRun(args) {
|
|
|
17175
17312
|
process.stdout.write(JSON.stringify({ fixture: name, decision: gate.decision, confidence: gate.confidence, reasonCodes: gate.reasonCodes, receipt }, null, 2) + "\n");
|
|
17176
17313
|
return gate.decision === "STOP_DONE" ? 0 : 1;
|
|
17177
17314
|
}
|
|
17178
|
-
function cmdActivate(args) {
|
|
17315
|
+
async function cmdActivate(args) {
|
|
17179
17316
|
const target = arg(args, "--target", process.cwd());
|
|
17180
17317
|
const installHooksFlag = args.includes("--install-hooks");
|
|
17181
17318
|
const approve = args.includes("--approve");
|
|
17319
|
+
const claimToken = arg(args, "--claim");
|
|
17320
|
+
const scope = arg(args, "--scope") ?? "project-wide";
|
|
17182
17321
|
if (installHooksFlag) {
|
|
17183
17322
|
if (!approve) {
|
|
17184
17323
|
process.stderr.write("Hook installation requires explicit approval. Add --approve to confirm.\n");
|
|
@@ -17199,6 +17338,18 @@ function cmdActivate(args) {
|
|
|
17199
17338
|
return 2;
|
|
17200
17339
|
}
|
|
17201
17340
|
}
|
|
17341
|
+
const preflight = runPreflight(target);
|
|
17342
|
+
if (!preflight.canStart) {
|
|
17343
|
+
process.stderr.write(formatPreflightReport(preflight));
|
|
17344
|
+
process.stderr.write(`
|
|
17345
|
+
Activation taxonomy: ${preflight.taxonomy}
|
|
17346
|
+
`);
|
|
17347
|
+
return 2;
|
|
17348
|
+
}
|
|
17349
|
+
if (!preflight.ok) {
|
|
17350
|
+
process.stderr.write(formatPreflightReport(preflight));
|
|
17351
|
+
process.stderr.write("Continuing with activation despite warnings...\n\n");
|
|
17352
|
+
}
|
|
17202
17353
|
const state = runFullActivation(target);
|
|
17203
17354
|
const contract = createWorkContract({ contractId: "canonical-activate", objective: "full local-first activation", allowedPaths: [join61(target, ".avorelo")], planTier: "Free" });
|
|
17204
17355
|
const ledger = new StateLedger();
|
|
@@ -17218,12 +17369,15 @@ function cmdActivate(args) {
|
|
|
17218
17369
|
state.receipts.push({ id: receipt.receiptId, path: join61(target, ".avorelo", "receipts", `${receipt.receiptId}.json`), type: "canonical_activation" });
|
|
17219
17370
|
persistActivationV2(target, state);
|
|
17220
17371
|
persistReceipt(target, receipt);
|
|
17372
|
+
const detection = runFullDetection(target);
|
|
17373
|
+
const fingerprint = generateLocalFingerprint(target);
|
|
17221
17374
|
const fv = state.firstValue;
|
|
17222
17375
|
const lines = [
|
|
17223
17376
|
"",
|
|
17224
17377
|
"Avorelo activated.",
|
|
17225
17378
|
"",
|
|
17226
17379
|
` Mode: ${state.activationMode}`,
|
|
17380
|
+
` Scope: ${scope}`,
|
|
17227
17381
|
` Status: ${state.activationStatus}`,
|
|
17228
17382
|
` State: ${join61(target, ACTIVATION_STATE_DIR, ACTIVATION_STATE_FILE)}`
|
|
17229
17383
|
];
|
|
@@ -17232,6 +17386,10 @@ function cmdActivate(args) {
|
|
|
17232
17386
|
for (const f of fv.found.slice(0, 8)) lines.push(` ${f}`);
|
|
17233
17387
|
if (fv.found.length > 8) lines.push(` ... and ${fv.found.length - 8} more`);
|
|
17234
17388
|
}
|
|
17389
|
+
if (detection.summary.toolsDetected.length > 0) {
|
|
17390
|
+
lines.push("", " Coding tools detected:");
|
|
17391
|
+
for (const t of detection.summary.toolsDetected) lines.push(` ${t}`);
|
|
17392
|
+
}
|
|
17235
17393
|
if (fv.fixed.length > 0) {
|
|
17236
17394
|
lines.push("", " Fixed:");
|
|
17237
17395
|
for (const f of fv.fixed) lines.push(` ${f}`);
|
|
@@ -17245,7 +17403,38 @@ function cmdActivate(args) {
|
|
|
17245
17403
|
` Run entry: ${state.runEntry.installed ? "installed" : "not installed"}`,
|
|
17246
17404
|
` Billing: ${state.billing.status}`,
|
|
17247
17405
|
` Auth: ${state.auth.status}`,
|
|
17248
|
-
` Production: not ready
|
|
17406
|
+
` Production: not ready`
|
|
17407
|
+
);
|
|
17408
|
+
let linkResult = "no claim provided";
|
|
17409
|
+
if (claimToken) {
|
|
17410
|
+
const baseUrl = process.env.APP_BASE_URL ?? "https://app.avorelo.com";
|
|
17411
|
+
try {
|
|
17412
|
+
const resp = await fetch(`${baseUrl}/api/activation/link`, {
|
|
17413
|
+
method: "POST",
|
|
17414
|
+
headers: { "Content-Type": "application/json" },
|
|
17415
|
+
body: JSON.stringify({
|
|
17416
|
+
token: claimToken,
|
|
17417
|
+
fingerprint,
|
|
17418
|
+
version: avoreloVersion(),
|
|
17419
|
+
toolsDetected: detection.summary.toolsDetected,
|
|
17420
|
+
osFamily: detection.environment.os,
|
|
17421
|
+
nodeVersion: detection.environment.nodeVersion ?? null,
|
|
17422
|
+
taxonomy: "ACTIVATION_SUCCEEDED_LOCALLY"
|
|
17423
|
+
})
|
|
17424
|
+
});
|
|
17425
|
+
if (resp.ok) {
|
|
17426
|
+
const data = await resp.json();
|
|
17427
|
+
linkResult = data.linked ? "linked" : data.error ?? "unknown";
|
|
17428
|
+
} else {
|
|
17429
|
+
const err = await resp.json().catch(() => ({ error: resp.statusText }));
|
|
17430
|
+
linkResult = `failed: ${err.error ?? resp.statusText}`;
|
|
17431
|
+
}
|
|
17432
|
+
} catch (e) {
|
|
17433
|
+
linkResult = `error: ${e.message}`;
|
|
17434
|
+
}
|
|
17435
|
+
lines.push(` Dashboard: ${linkResult === "linked" ? "linked to account" : linkResult}`);
|
|
17436
|
+
}
|
|
17437
|
+
lines.push(
|
|
17249
17438
|
"",
|
|
17250
17439
|
` Next: ${fv.nextAction}`,
|
|
17251
17440
|
""
|
|
@@ -17253,6 +17442,14 @@ function cmdActivate(args) {
|
|
|
17253
17442
|
process.stdout.write(lines.join("\n"));
|
|
17254
17443
|
return 0;
|
|
17255
17444
|
}
|
|
17445
|
+
function cmdPreflight(args) {
|
|
17446
|
+
const target = arg(args, "--target", process.cwd());
|
|
17447
|
+
const result3 = runPreflight(target);
|
|
17448
|
+
process.stdout.write(formatPreflightReport(result3));
|
|
17449
|
+
process.stdout.write(`Taxonomy: ${result3.taxonomy}
|
|
17450
|
+
`);
|
|
17451
|
+
return result3.canStart ? 0 : 2;
|
|
17452
|
+
}
|
|
17256
17453
|
async function cmdDoctor(args) {
|
|
17257
17454
|
const target = arg(args, "--target", process.cwd());
|
|
17258
17455
|
const r2 = doctor(target);
|
|
@@ -18039,7 +18236,7 @@ function cmdTokenCost(args) {
|
|
|
18039
18236
|
}
|
|
18040
18237
|
if (sub === "import" || sub === "validate") {
|
|
18041
18238
|
const file = arg(args, "--file");
|
|
18042
|
-
if (!file || !
|
|
18239
|
+
if (!file || !existsSync62(file)) {
|
|
18043
18240
|
process.stderr.write("Usage: avorelo token-cost " + sub + " --file <path> [--json]\n");
|
|
18044
18241
|
return 2;
|
|
18045
18242
|
}
|
|
@@ -18186,7 +18383,7 @@ function cmdContextCheck(args) {
|
|
|
18186
18383
|
const ci = args.includes("--ci");
|
|
18187
18384
|
const wcPath = arg(args, "--work-contract");
|
|
18188
18385
|
let workContract;
|
|
18189
|
-
if (wcPath &&
|
|
18386
|
+
if (wcPath && existsSync62(wcPath)) {
|
|
18190
18387
|
try {
|
|
18191
18388
|
workContract = JSON.parse(readFileSync46(wcPath, "utf8"));
|
|
18192
18389
|
} catch {
|
|
@@ -18251,7 +18448,7 @@ function cmdSecretBoundary(args) {
|
|
|
18251
18448
|
const asJson = args.includes("--json");
|
|
18252
18449
|
let content = arg(args, "--content");
|
|
18253
18450
|
const file = arg(args, "--file");
|
|
18254
|
-
if (file &&
|
|
18451
|
+
if (file && existsSync62(file)) content = readFileSync46(file, "utf8");
|
|
18255
18452
|
if (content === void 0) content = "";
|
|
18256
18453
|
if (sub === "scan" || sub === void 0) {
|
|
18257
18454
|
const r2 = scanContent({ content, sourceKind: file ? "file" : "tool_output" });
|
|
@@ -18318,7 +18515,7 @@ function cmdExplain(args) {
|
|
|
18318
18515
|
const changedFiles = [];
|
|
18319
18516
|
for (const { adapter } of detected) {
|
|
18320
18517
|
const surface = adapter.getInstructionSurface(target);
|
|
18321
|
-
if (surface &&
|
|
18518
|
+
if (surface && existsSync62(surface)) changedFiles.push(surface);
|
|
18322
18519
|
}
|
|
18323
18520
|
if (changedFiles.length > 0) {
|
|
18324
18521
|
lines.push(" Changed:");
|
|
@@ -18492,7 +18689,7 @@ function cmdFeedback(args) {
|
|
|
18492
18689
|
}
|
|
18493
18690
|
if (sub === "share") {
|
|
18494
18691
|
const file = arg(args, "--file");
|
|
18495
|
-
if (!file || !
|
|
18692
|
+
if (!file || !existsSync62(file)) {
|
|
18496
18693
|
process.stderr.write("Usage: avorelo feedback share --file <bundle-path>\n");
|
|
18497
18694
|
return 2;
|
|
18498
18695
|
}
|
|
@@ -18796,7 +18993,7 @@ No loop metadata found for ${loopId}.
|
|
|
18796
18993
|
if (sub === "doctor") {
|
|
18797
18994
|
const issues = [];
|
|
18798
18995
|
const ok = [];
|
|
18799
|
-
if (
|
|
18996
|
+
if (existsSync62(join61(target, ".git"))) {
|
|
18800
18997
|
ok.push("Git repository detected");
|
|
18801
18998
|
} else {
|
|
18802
18999
|
issues.push("Not a git repository \u2014 loop needs git for drift detection");
|
|
@@ -18856,7 +19053,7 @@ function cmdUninstallAll(args) {
|
|
|
18856
19053
|
const preserved = adapterResult.preserved;
|
|
18857
19054
|
const avoreloDir2 = join61(target, ".avorelo");
|
|
18858
19055
|
try {
|
|
18859
|
-
if (
|
|
19056
|
+
if (existsSync62(avoreloDir2)) {
|
|
18860
19057
|
rmSync3(avoreloDir2, { recursive: true, force: true });
|
|
18861
19058
|
removed.push(avoreloDir2);
|
|
18862
19059
|
}
|
|
@@ -19505,6 +19702,8 @@ function main(argv) {
|
|
|
19505
19702
|
return cmdSupport(rest);
|
|
19506
19703
|
case "activate":
|
|
19507
19704
|
return cmdActivate(rest);
|
|
19705
|
+
case "preflight":
|
|
19706
|
+
return cmdPreflight(rest);
|
|
19508
19707
|
case "doctor":
|
|
19509
19708
|
return cmdDoctor(rest);
|
|
19510
19709
|
case "uninstall":
|
|
@@ -19722,14 +19921,21 @@ async function finalize(exitCode) {
|
|
|
19722
19921
|
recordCliTelemetry(exitCode);
|
|
19723
19922
|
} catch {
|
|
19724
19923
|
}
|
|
19725
|
-
sendDueTelemetry(CLI_TELEMETRY_SNAPSHOT.target).catch(() => {
|
|
19726
|
-
});
|
|
19727
19924
|
if (_cmd && LEARNING_COMMANDS.has(_cmd)) {
|
|
19728
19925
|
try {
|
|
19729
19926
|
emitLearningEvent(process.cwd(), { commandName: _cmd, commandStatus: exitCode === 0 ? "ok" : "error", eventType: "command" });
|
|
19730
19927
|
} catch {
|
|
19731
19928
|
}
|
|
19732
19929
|
}
|
|
19930
|
+
try {
|
|
19931
|
+
const telemetryDone = sendDueTelemetry(CLI_TELEMETRY_SNAPSHOT.target).catch(() => {
|
|
19932
|
+
});
|
|
19933
|
+
await Promise.race([telemetryDone, new Promise((r2) => {
|
|
19934
|
+
const t = setTimeout(r2, 2e3);
|
|
19935
|
+
if (typeof t.unref === "function") t.unref();
|
|
19936
|
+
})]);
|
|
19937
|
+
} catch {
|
|
19938
|
+
}
|
|
19733
19939
|
if (_cmd !== "serve" && _cmd !== "webhook" && _cmd !== "sync") {
|
|
19734
19940
|
setTimeout(() => process.exit(exitCode), 50).unref();
|
|
19735
19941
|
}
|