avorelo 0.3.7 → 0.3.8
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/README.md +3 -3
- package/dist/avorelo.mjs +363 -161
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,13 +16,13 @@ locally.
|
|
|
16
16
|
npx -y avorelo@latest activate --scope project-wide
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
**Account-linked activation (
|
|
19
|
+
**Account-linked activation (optional):**
|
|
20
20
|
|
|
21
21
|
```
|
|
22
|
-
npx -y avorelo@latest activate --scope project-wide --
|
|
22
|
+
npx -y avorelo@latest activate --scope project-wide --link-code YOUR_CODE
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
Generate a short-lived
|
|
25
|
+
Generate a short-lived account link code from your [dashboard](https://avorelo.com/dashboard). Codes expire in 15 minutes.
|
|
26
26
|
|
|
27
27
|
**Other commands:**
|
|
28
28
|
|
package/dist/avorelo.mjs
CHANGED
|
@@ -7338,8 +7338,8 @@ init_run();
|
|
|
7338
7338
|
init_work_contract();
|
|
7339
7339
|
init_receipts();
|
|
7340
7340
|
init_state_ledger();
|
|
7341
|
-
import { writeFileSync as writeFileSync39, mkdirSync as mkdirSync41, existsSync as
|
|
7342
|
-
import { join as
|
|
7341
|
+
import { writeFileSync as writeFileSync39, mkdirSync as mkdirSync41, existsSync as existsSync66, readFileSync as readFileSync51, appendFileSync as appendFileSync12, rmSync as rmSync3, unlinkSync as unlinkSync5 } from "node:fs";
|
|
7342
|
+
import { join as join68 } from "node:path";
|
|
7343
7343
|
|
|
7344
7344
|
// src/avorelo/capabilities/activation/index.ts
|
|
7345
7345
|
import { mkdtempSync, writeFileSync as writeFileSync11, mkdirSync as mkdirSync11, rmSync as rmSync2, existsSync as existsSync24 } from "node:fs";
|
|
@@ -7462,7 +7462,7 @@ function runPreflight(targetDir) {
|
|
|
7462
7462
|
label: "npm cache directory accessible",
|
|
7463
7463
|
passed: false,
|
|
7464
7464
|
details: "cache path does not exist",
|
|
7465
|
-
recovery: isWindows ? 'Use a temporary cache. PowerShell: $env:npm_config_cache="$env:TEMP\\npm-cache-avorelo"; npx -y avorelo@latest activate --scope project-wide --
|
|
7465
|
+
recovery: isWindows ? 'Use a temporary cache. PowerShell: $env:npm_config_cache="$env:TEMP\\npm-cache-avorelo"; npx -y avorelo@latest activate --scope project-wide --link-code YOUR_CODE. cmd.exe: cmd /c "set npm_config_cache=%TEMP%\\npm-cache-avorelo && npx -y avorelo@latest activate --scope project-wide --link-code YOUR_CODE"' : "Use a temporary cache: npm_config_cache=$(mktemp -d) npx -y avorelo@latest activate --scope project-wide --link-code YOUR_CODE"
|
|
7466
7466
|
});
|
|
7467
7467
|
}
|
|
7468
7468
|
} catch {
|
|
@@ -7471,7 +7471,7 @@ function runPreflight(targetDir) {
|
|
|
7471
7471
|
label: "npm cache directory accessible",
|
|
7472
7472
|
passed: false,
|
|
7473
7473
|
details: "could not read npm cache config",
|
|
7474
|
-
recovery: isWindows ? 'Use a temporary cache. PowerShell: $env:npm_config_cache="$env:TEMP\\npm-cache-avorelo"; npx -y avorelo@latest activate --scope project-wide --
|
|
7474
|
+
recovery: isWindows ? 'Use a temporary cache. PowerShell: $env:npm_config_cache="$env:TEMP\\npm-cache-avorelo"; npx -y avorelo@latest activate --scope project-wide --link-code YOUR_CODE. cmd.exe: cmd /c "set npm_config_cache=%TEMP%\\npm-cache-avorelo && npx -y avorelo@latest activate --scope project-wide --link-code YOUR_CODE"' : "Use a temporary cache: npm_config_cache=$(mktemp -d) npx -y avorelo@latest activate --scope project-wide --link-code YOUR_CODE"
|
|
7475
7475
|
});
|
|
7476
7476
|
}
|
|
7477
7477
|
let tempOk = false;
|
|
@@ -7500,7 +7500,7 @@ function runPreflight(targetDir) {
|
|
|
7500
7500
|
label: "PowerShell execution policy",
|
|
7501
7501
|
passed: psOk,
|
|
7502
7502
|
details: `Policy: ${policy}`,
|
|
7503
|
-
recovery: blocked ? "PowerShell is blocking script execution. Use Command Prompt instead:\n cmd /c npx -y avorelo@latest activate --scope project-wide --
|
|
7503
|
+
recovery: blocked ? "PowerShell is blocking script execution. Use Command Prompt instead:\n cmd /c npx -y avorelo@latest activate --scope project-wide --link-code YOUR_CODE" : void 0
|
|
7504
7504
|
});
|
|
7505
7505
|
} catch {
|
|
7506
7506
|
checks.push({ id: "powershell_execution_policy", label: "PowerShell execution policy", passed: true, details: "could not check (non-PowerShell shell)" });
|
|
@@ -7531,7 +7531,7 @@ function buildWindowsFallbackCommand() {
|
|
|
7531
7531
|
"mkdir %AVORELO_TEMP%",
|
|
7532
7532
|
"set npm_config_cache=%AVORELO_TEMP%\\npm-cache",
|
|
7533
7533
|
"cd /d %AVORELO_TEMP%",
|
|
7534
|
-
"npx -y avorelo@latest activate --scope project-wide --
|
|
7534
|
+
"npx -y avorelo@latest activate --scope project-wide --link-code YOUR_CODE",
|
|
7535
7535
|
"npx -y avorelo@latest status"
|
|
7536
7536
|
].join("\n");
|
|
7537
7537
|
}
|
|
@@ -16620,13 +16620,13 @@ import { readFileSync as readFileSync32, existsSync as existsSync47, statSync as
|
|
|
16620
16620
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
16621
16621
|
function readBack(dir, check) {
|
|
16622
16622
|
const id = check.artifactId ?? `sot_${check.kind}`;
|
|
16623
|
-
const
|
|
16623
|
+
const resolve6 = (p) => p.startsWith("/") || /^[A-Za-z]:/.test(p) ? p : `${dir}/${p}`;
|
|
16624
16624
|
try {
|
|
16625
16625
|
if (check.kind === "file_absent") {
|
|
16626
|
-
const passed2 = !existsSync47(
|
|
16626
|
+
const passed2 = !existsSync47(resolve6(check.path));
|
|
16627
16627
|
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 };
|
|
16628
16628
|
}
|
|
16629
|
-
const p =
|
|
16629
|
+
const p = resolve6(check.path);
|
|
16630
16630
|
if (!existsSync47(p)) return { artifact: null, passed: false, reasonCode: "READBACK_FILE_MISSING", check };
|
|
16631
16631
|
const actual = readFileSync32(p, "utf8");
|
|
16632
16632
|
const passed = check.kind === "file_equals" ? actual.trim() === check.expected.trim() : actual.includes(check.expected);
|
|
@@ -16775,12 +16775,12 @@ function serve(root, opts) {
|
|
|
16775
16775
|
res.end("500");
|
|
16776
16776
|
}
|
|
16777
16777
|
});
|
|
16778
|
-
return new Promise((
|
|
16778
|
+
return new Promise((resolve6, reject) => {
|
|
16779
16779
|
server.once("error", reject);
|
|
16780
16780
|
server.listen(opts?.port ?? 0, host, () => {
|
|
16781
16781
|
const addr = server.address();
|
|
16782
16782
|
const port = typeof addr === "object" && addr ? addr.port : opts?.port ?? 0;
|
|
16783
|
-
|
|
16783
|
+
resolve6({
|
|
16784
16784
|
url: `http://${host}:${port}/`,
|
|
16785
16785
|
port,
|
|
16786
16786
|
server,
|
|
@@ -17072,7 +17072,7 @@ var CustomDataIdentityResolver = class {
|
|
|
17072
17072
|
|
|
17073
17073
|
// src/avorelo/surfaces/webhook-server/index.ts
|
|
17074
17074
|
function collectRawBody(req, maxBytes = 1048576) {
|
|
17075
|
-
return new Promise((
|
|
17075
|
+
return new Promise((resolve6, reject) => {
|
|
17076
17076
|
const chunks = [];
|
|
17077
17077
|
let size = 0;
|
|
17078
17078
|
req.on("data", (chunk) => {
|
|
@@ -17084,7 +17084,7 @@ function collectRawBody(req, maxBytes = 1048576) {
|
|
|
17084
17084
|
}
|
|
17085
17085
|
chunks.push(chunk);
|
|
17086
17086
|
});
|
|
17087
|
-
req.on("end", () =>
|
|
17087
|
+
req.on("end", () => resolve6(Buffer.concat(chunks).toString("utf8")));
|
|
17088
17088
|
req.on("error", reject);
|
|
17089
17089
|
});
|
|
17090
17090
|
}
|
|
@@ -17131,12 +17131,12 @@ function serve2(storeDir, opts) {
|
|
|
17131
17131
|
}
|
|
17132
17132
|
jsonResponse(res, 404, { error: "not_found" });
|
|
17133
17133
|
});
|
|
17134
|
-
return new Promise((
|
|
17134
|
+
return new Promise((resolve6, reject) => {
|
|
17135
17135
|
server.once("error", reject);
|
|
17136
17136
|
server.listen(opts?.port ?? 3848, host, () => {
|
|
17137
17137
|
const addr = server.address();
|
|
17138
17138
|
const port = typeof addr === "object" && addr ? addr.port : opts?.port ?? 3848;
|
|
17139
|
-
|
|
17139
|
+
resolve6({
|
|
17140
17140
|
url: `http://${host}:${port}/`,
|
|
17141
17141
|
port,
|
|
17142
17142
|
server,
|
|
@@ -17725,9 +17725,119 @@ function detectMonorepo(dir) {
|
|
|
17725
17725
|
return { isMonorepo: false, strategy: "none", workspaces: [], rootPath: dir };
|
|
17726
17726
|
}
|
|
17727
17727
|
|
|
17728
|
+
// src/avorelo/capabilities/activation/discover-projects.ts
|
|
17729
|
+
import { existsSync as existsSync54, readdirSync as readdirSync15 } from "node:fs";
|
|
17730
|
+
import { join as join53, resolve as resolve5, relative as relative4 } from "node:path";
|
|
17731
|
+
var PROJECT_INDICATORS = [
|
|
17732
|
+
".git",
|
|
17733
|
+
"package.json",
|
|
17734
|
+
"pyproject.toml",
|
|
17735
|
+
"Cargo.toml",
|
|
17736
|
+
"go.mod",
|
|
17737
|
+
"pnpm-workspace.yaml",
|
|
17738
|
+
"turbo.json"
|
|
17739
|
+
];
|
|
17740
|
+
var EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
17741
|
+
"node_modules",
|
|
17742
|
+
".git",
|
|
17743
|
+
"dist",
|
|
17744
|
+
"build",
|
|
17745
|
+
".next",
|
|
17746
|
+
"coverage",
|
|
17747
|
+
"vendor",
|
|
17748
|
+
"__pycache__",
|
|
17749
|
+
".venv",
|
|
17750
|
+
"venv",
|
|
17751
|
+
".tox",
|
|
17752
|
+
"target",
|
|
17753
|
+
".cache",
|
|
17754
|
+
".parcel-cache",
|
|
17755
|
+
".turbo",
|
|
17756
|
+
".output",
|
|
17757
|
+
".nuxt",
|
|
17758
|
+
".svelte-kit"
|
|
17759
|
+
]);
|
|
17760
|
+
var MAX_DEPTH2 = 3;
|
|
17761
|
+
var MAX_PROJECTS = 50;
|
|
17762
|
+
function discoverProjects(rootDir) {
|
|
17763
|
+
const root = resolve5(rootDir);
|
|
17764
|
+
const projects = [];
|
|
17765
|
+
function scan2(dir, depth) {
|
|
17766
|
+
if (depth > MAX_DEPTH2) return;
|
|
17767
|
+
if (projects.length >= MAX_PROJECTS) return;
|
|
17768
|
+
let entries;
|
|
17769
|
+
try {
|
|
17770
|
+
entries = readdirSync15(dir, { withFileTypes: true });
|
|
17771
|
+
} catch {
|
|
17772
|
+
return;
|
|
17773
|
+
}
|
|
17774
|
+
for (const entry of entries) {
|
|
17775
|
+
if (!entry.isDirectory()) continue;
|
|
17776
|
+
if (EXCLUDED_DIRS.has(entry.name)) continue;
|
|
17777
|
+
if (entry.name.startsWith(".") && entry.name !== ".git") continue;
|
|
17778
|
+
const fullPath = join53(dir, entry.name);
|
|
17779
|
+
const indicators = [];
|
|
17780
|
+
for (const indicator of PROJECT_INDICATORS) {
|
|
17781
|
+
if (existsSync54(join53(fullPath, indicator))) {
|
|
17782
|
+
indicators.push(indicator);
|
|
17783
|
+
}
|
|
17784
|
+
}
|
|
17785
|
+
if (indicators.length > 0) {
|
|
17786
|
+
const alreadyActivated = existsSync54(join53(fullPath, ".avorelo"));
|
|
17787
|
+
projects.push({
|
|
17788
|
+
path: fullPath,
|
|
17789
|
+
relativePath: relative4(root, fullPath) || ".",
|
|
17790
|
+
indicators,
|
|
17791
|
+
alreadyActivated,
|
|
17792
|
+
recommended: !alreadyActivated
|
|
17793
|
+
});
|
|
17794
|
+
}
|
|
17795
|
+
if (depth < MAX_DEPTH2 && projects.length < MAX_PROJECTS) {
|
|
17796
|
+
scan2(fullPath, depth + 1);
|
|
17797
|
+
}
|
|
17798
|
+
}
|
|
17799
|
+
}
|
|
17800
|
+
scan2(root, 0);
|
|
17801
|
+
return { rootDir: root, projects, searchDepth: MAX_DEPTH2 };
|
|
17802
|
+
}
|
|
17803
|
+
function formatDiscoveryPreview(result3) {
|
|
17804
|
+
const lines = [];
|
|
17805
|
+
if (result3.projects.length === 0) {
|
|
17806
|
+
lines.push("");
|
|
17807
|
+
lines.push(`No local projects found under ${result3.rootDir}`);
|
|
17808
|
+
lines.push("Run this from a parent folder that contains your repos.");
|
|
17809
|
+
lines.push("");
|
|
17810
|
+
return lines.join("\n");
|
|
17811
|
+
}
|
|
17812
|
+
const recommended = result3.projects.filter((p) => p.recommended);
|
|
17813
|
+
const skipped = result3.projects.filter((p) => !p.recommended);
|
|
17814
|
+
lines.push("");
|
|
17815
|
+
lines.push(`Found ${result3.projects.length} local project${result3.projects.length === 1 ? "" : "s"} under ${result3.rootDir}:`);
|
|
17816
|
+
lines.push("");
|
|
17817
|
+
for (let i = 0; i < result3.projects.length; i++) {
|
|
17818
|
+
const p = result3.projects[i];
|
|
17819
|
+
const marker = p.recommended ? "[*]" : "[ ]";
|
|
17820
|
+
const status = p.alreadyActivated ? " (already activated)" : "";
|
|
17821
|
+
const indicators = p.indicators.join(", ");
|
|
17822
|
+
lines.push(` ${marker} ${p.relativePath}${status}`);
|
|
17823
|
+
lines.push(` detected: ${indicators}`);
|
|
17824
|
+
}
|
|
17825
|
+
lines.push("");
|
|
17826
|
+
lines.push(` [*] = selected for activation (${recommended.length})`);
|
|
17827
|
+
if (skipped.length > 0) {
|
|
17828
|
+
lines.push(` [ ] = already activated, skipped (${skipped.length})`);
|
|
17829
|
+
}
|
|
17830
|
+
if (result3.projects.length >= MAX_PROJECTS) {
|
|
17831
|
+
lines.push("");
|
|
17832
|
+
lines.push(` Warning: stopped at ${MAX_PROJECTS} projects. Use a more specific parent folder.`);
|
|
17833
|
+
}
|
|
17834
|
+
lines.push("");
|
|
17835
|
+
return lines.join("\n");
|
|
17836
|
+
}
|
|
17837
|
+
|
|
17728
17838
|
// src/avorelo/capabilities/feedback/config.ts
|
|
17729
|
-
import { existsSync as
|
|
17730
|
-
import { join as
|
|
17839
|
+
import { existsSync as existsSync55, readFileSync as readFileSync38, writeFileSync as writeFileSync31, mkdirSync as mkdirSync33 } from "node:fs";
|
|
17840
|
+
import { join as join54, dirname as dirname10 } from "node:path";
|
|
17731
17841
|
var CONFIG_PATH = ".avorelo/config.json";
|
|
17732
17842
|
var DEFAULTS = {
|
|
17733
17843
|
enabled: false,
|
|
@@ -17737,8 +17847,8 @@ var DEFAULTS = {
|
|
|
17737
17847
|
optedOutAt: null
|
|
17738
17848
|
};
|
|
17739
17849
|
function readConfig(dir) {
|
|
17740
|
-
const p =
|
|
17741
|
-
if (!
|
|
17850
|
+
const p = join54(dir, CONFIG_PATH);
|
|
17851
|
+
if (!existsSync55(p)) return {};
|
|
17742
17852
|
try {
|
|
17743
17853
|
return JSON.parse(readFileSync38(p, "utf8"));
|
|
17744
17854
|
} catch {
|
|
@@ -17746,7 +17856,7 @@ function readConfig(dir) {
|
|
|
17746
17856
|
}
|
|
17747
17857
|
}
|
|
17748
17858
|
function writeConfig(dir, config2) {
|
|
17749
|
-
const p =
|
|
17859
|
+
const p = join54(dir, CONFIG_PATH);
|
|
17750
17860
|
mkdirSync33(dirname10(p), { recursive: true });
|
|
17751
17861
|
writeFileSync31(p, JSON.stringify(config2, null, 2));
|
|
17752
17862
|
}
|
|
@@ -17769,30 +17879,30 @@ function optOut(dir) {
|
|
|
17769
17879
|
|
|
17770
17880
|
// src/avorelo/capabilities/feedback/bundle.ts
|
|
17771
17881
|
init_redaction();
|
|
17772
|
-
import { existsSync as
|
|
17773
|
-
import { join as
|
|
17882
|
+
import { existsSync as existsSync56, readFileSync as readFileSync39, writeFileSync as writeFileSync32, mkdirSync as mkdirSync34, readdirSync as readdirSync16 } from "node:fs";
|
|
17883
|
+
import { join as join55 } from "node:path";
|
|
17774
17884
|
import { platform as platform3, release, arch } from "node:os";
|
|
17775
17885
|
init_registry();
|
|
17776
17886
|
init_session_store();
|
|
17777
17887
|
function getVersion() {
|
|
17778
17888
|
try {
|
|
17779
|
-
const pkg = JSON.parse(readFileSync39(
|
|
17889
|
+
const pkg = JSON.parse(readFileSync39(join55(process.cwd(), "package.json"), "utf8"));
|
|
17780
17890
|
return pkg.version ?? "unknown";
|
|
17781
17891
|
} catch {
|
|
17782
17892
|
return "unknown";
|
|
17783
17893
|
}
|
|
17784
17894
|
}
|
|
17785
17895
|
function detectPackageManager(dir) {
|
|
17786
|
-
if (
|
|
17787
|
-
if (
|
|
17788
|
-
if (
|
|
17789
|
-
if (
|
|
17790
|
-
if (
|
|
17896
|
+
if (existsSync56(join55(dir, "pnpm-lock.yaml"))) return "pnpm";
|
|
17897
|
+
if (existsSync56(join55(dir, "yarn.lock"))) return "yarn";
|
|
17898
|
+
if (existsSync56(join55(dir, "bun.lockb"))) return "bun";
|
|
17899
|
+
if (existsSync56(join55(dir, "package-lock.json"))) return "npm";
|
|
17900
|
+
if (existsSync56(join55(dir, "package.json"))) return "npm";
|
|
17791
17901
|
return null;
|
|
17792
17902
|
}
|
|
17793
17903
|
function detectFramework(dir) {
|
|
17794
17904
|
try {
|
|
17795
|
-
const pkg = JSON.parse(readFileSync39(
|
|
17905
|
+
const pkg = JSON.parse(readFileSync39(join55(dir, "package.json"), "utf8"));
|
|
17796
17906
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
17797
17907
|
if (deps["next"]) return "next";
|
|
17798
17908
|
if (deps["nuxt"]) return "nuxt";
|
|
@@ -17807,13 +17917,13 @@ function detectFramework(dir) {
|
|
|
17807
17917
|
}
|
|
17808
17918
|
}
|
|
17809
17919
|
function countReceipts(dir) {
|
|
17810
|
-
const receiptsDir =
|
|
17811
|
-
if (!
|
|
17920
|
+
const receiptsDir = join55(dir, ".avorelo", "receipts");
|
|
17921
|
+
if (!existsSync56(receiptsDir)) return { total: 0, done: 0, blocked: 0, inProgress: 0 };
|
|
17812
17922
|
let done = 0, blocked = 0, inProgress = 0;
|
|
17813
17923
|
try {
|
|
17814
|
-
for (const f of
|
|
17924
|
+
for (const f of readdirSync16(receiptsDir).filter((f2) => f2.endsWith(".json"))) {
|
|
17815
17925
|
try {
|
|
17816
|
-
const r2 = JSON.parse(readFileSync39(
|
|
17926
|
+
const r2 = JSON.parse(readFileSync39(join55(receiptsDir, f), "utf8"));
|
|
17817
17927
|
if (r2.decision === "STOP_DONE") done++;
|
|
17818
17928
|
else if (r2.decision === "STOP_BLOCKED") blocked++;
|
|
17819
17929
|
else inProgress++;
|
|
@@ -17870,17 +17980,17 @@ function prepareFeedbackBundle(dir) {
|
|
|
17870
17980
|
redaction: "applied"
|
|
17871
17981
|
};
|
|
17872
17982
|
const redacted = redact(bundle).value;
|
|
17873
|
-
const bundleDir =
|
|
17983
|
+
const bundleDir = join55(dir, ".avorelo", "feedback");
|
|
17874
17984
|
mkdirSync34(bundleDir, { recursive: true });
|
|
17875
|
-
const bundlePath =
|
|
17985
|
+
const bundlePath = join55(bundleDir, `${redacted.bundleId}.json`);
|
|
17876
17986
|
writeFileSync32(bundlePath, JSON.stringify(redacted, null, 2));
|
|
17877
17987
|
return { bundle: redacted, path: bundlePath };
|
|
17878
17988
|
}
|
|
17879
17989
|
function prepareSupportBundle(dir) {
|
|
17880
17990
|
const { bundle, path: fbPath } = prepareFeedbackBundle(dir);
|
|
17881
|
-
const supportDir =
|
|
17991
|
+
const supportDir = join55(dir, ".avorelo", "support");
|
|
17882
17992
|
mkdirSync34(supportDir, { recursive: true });
|
|
17883
|
-
const supportPath =
|
|
17993
|
+
const supportPath = join55(supportDir, `support_${bundle.bundleId}.json`);
|
|
17884
17994
|
writeFileSync32(supportPath, JSON.stringify(bundle, null, 2));
|
|
17885
17995
|
return { bundle, path: supportPath };
|
|
17886
17996
|
}
|
|
@@ -18073,11 +18183,11 @@ function result(classification, risk, reasonCodes, humanGateConditions) {
|
|
|
18073
18183
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
18074
18184
|
|
|
18075
18185
|
// src/avorelo/capabilities/loop-control/check-detection.ts
|
|
18076
|
-
import { readFileSync as readFileSync40, existsSync as
|
|
18077
|
-
import { join as
|
|
18186
|
+
import { readFileSync as readFileSync40, existsSync as existsSync57 } from "node:fs";
|
|
18187
|
+
import { join as join56 } from "node:path";
|
|
18078
18188
|
function detectFromPackageJson(cwd) {
|
|
18079
|
-
const pkgPath =
|
|
18080
|
-
if (!
|
|
18189
|
+
const pkgPath = join56(cwd, "package.json");
|
|
18190
|
+
if (!existsSync57(pkgPath)) return [];
|
|
18081
18191
|
try {
|
|
18082
18192
|
const pkg = JSON.parse(readFileSync40(pkgPath, "utf8"));
|
|
18083
18193
|
const scripts = pkg.scripts ?? {};
|
|
@@ -18100,19 +18210,19 @@ function detectFromPackageJson(cwd) {
|
|
|
18100
18210
|
}
|
|
18101
18211
|
}
|
|
18102
18212
|
function detectFromPython(cwd) {
|
|
18103
|
-
if (
|
|
18213
|
+
if (existsSync57(join56(cwd, "pytest.ini")) || existsSync57(join56(cwd, "pyproject.toml")) || existsSync57(join56(cwd, "setup.py"))) {
|
|
18104
18214
|
return [{ checkId: "chk_pytest", label: "pytest", command: "python -m pytest", source: "python" }];
|
|
18105
18215
|
}
|
|
18106
18216
|
return [];
|
|
18107
18217
|
}
|
|
18108
18218
|
function detectFromGo(cwd) {
|
|
18109
|
-
if (
|
|
18219
|
+
if (existsSync57(join56(cwd, "go.mod"))) {
|
|
18110
18220
|
return [{ checkId: "chk_go_test", label: "go test", command: "go test ./...", source: "go.mod" }];
|
|
18111
18221
|
}
|
|
18112
18222
|
return [];
|
|
18113
18223
|
}
|
|
18114
18224
|
function detectFromRust(cwd) {
|
|
18115
|
-
if (
|
|
18225
|
+
if (existsSync57(join56(cwd, "Cargo.toml"))) {
|
|
18116
18226
|
return [{ checkId: "chk_cargo_test", label: "cargo test", command: "cargo test", source: "Cargo.toml" }];
|
|
18117
18227
|
}
|
|
18118
18228
|
return [];
|
|
@@ -18409,8 +18519,8 @@ function getCurrentHead(cwd) {
|
|
|
18409
18519
|
|
|
18410
18520
|
// src/avorelo/capabilities/loop-control/loop-metadata.ts
|
|
18411
18521
|
init_redaction();
|
|
18412
|
-
import { mkdirSync as mkdirSync35, writeFileSync as writeFileSync33, readFileSync as readFileSync41, existsSync as
|
|
18413
|
-
import { join as
|
|
18522
|
+
import { mkdirSync as mkdirSync35, writeFileSync as writeFileSync33, readFileSync as readFileSync41, existsSync as existsSync58, readdirSync as readdirSync17 } from "node:fs";
|
|
18523
|
+
import { join as join57 } from "node:path";
|
|
18414
18524
|
function classifyFile(file, allowed, disallowed) {
|
|
18415
18525
|
for (const d of disallowed) {
|
|
18416
18526
|
const pat = d.replace(/\/?\*+$/, "");
|
|
@@ -18477,7 +18587,7 @@ function buildLoopMetadata(input) {
|
|
|
18477
18587
|
};
|
|
18478
18588
|
}
|
|
18479
18589
|
function loopDir(dir) {
|
|
18480
|
-
return
|
|
18590
|
+
return join57(dir, ".avorelo", "loops");
|
|
18481
18591
|
}
|
|
18482
18592
|
function persistLoopMetadata(dir, metadata) {
|
|
18483
18593
|
const d = loopDir(dir);
|
|
@@ -18491,13 +18601,13 @@ function persistLoopMetadata(dir, metadata) {
|
|
|
18491
18601
|
containsTerminalLog: false,
|
|
18492
18602
|
containsGitDiff: false
|
|
18493
18603
|
};
|
|
18494
|
-
const path =
|
|
18604
|
+
const path = join57(d, `${metadata.loopId}.json`);
|
|
18495
18605
|
writeFileSync33(path, JSON.stringify(safe, null, 2));
|
|
18496
18606
|
return path;
|
|
18497
18607
|
}
|
|
18498
18608
|
function readLoopMetadata(dir, loopId) {
|
|
18499
|
-
const path =
|
|
18500
|
-
if (!
|
|
18609
|
+
const path = join57(loopDir(dir), `${loopId}.json`);
|
|
18610
|
+
if (!existsSync58(path)) return null;
|
|
18501
18611
|
try {
|
|
18502
18612
|
const data = JSON.parse(readFileSync41(path, "utf8"));
|
|
18503
18613
|
return data && data.contract === "avorelo.loopMetadata.v1" ? data : null;
|
|
@@ -18507,15 +18617,15 @@ function readLoopMetadata(dir, loopId) {
|
|
|
18507
18617
|
}
|
|
18508
18618
|
function readLatestLoopMetadata(dir) {
|
|
18509
18619
|
const d = loopDir(dir);
|
|
18510
|
-
if (!
|
|
18620
|
+
if (!existsSync58(d)) return null;
|
|
18511
18621
|
try {
|
|
18512
|
-
const files =
|
|
18622
|
+
const files = readdirSync17(d).filter((f) => f.startsWith("loop_") && f.endsWith(".json"));
|
|
18513
18623
|
if (files.length === 0) return null;
|
|
18514
18624
|
let latest = null;
|
|
18515
18625
|
let latestTime = "";
|
|
18516
18626
|
for (const f of files) {
|
|
18517
18627
|
try {
|
|
18518
|
-
const data = JSON.parse(readFileSync41(
|
|
18628
|
+
const data = JSON.parse(readFileSync41(join57(d, f), "utf8"));
|
|
18519
18629
|
if (data && data.contract === "avorelo.loopMetadata.v1" && data.createdAt > latestTime) {
|
|
18520
18630
|
latest = data;
|
|
18521
18631
|
latestTime = data.createdAt;
|
|
@@ -18529,8 +18639,8 @@ function readLatestLoopMetadata(dir) {
|
|
|
18529
18639
|
}
|
|
18530
18640
|
}
|
|
18531
18641
|
function readActiveLoop(dir) {
|
|
18532
|
-
const path =
|
|
18533
|
-
if (!
|
|
18642
|
+
const path = join57(loopDir(dir), "active.json");
|
|
18643
|
+
if (!existsSync58(path)) return null;
|
|
18534
18644
|
try {
|
|
18535
18645
|
return JSON.parse(readFileSync41(path, "utf8"));
|
|
18536
18646
|
} catch {
|
|
@@ -18540,11 +18650,11 @@ function readActiveLoop(dir) {
|
|
|
18540
18650
|
function writeActiveLoop(dir, loopId, status) {
|
|
18541
18651
|
const d = loopDir(dir);
|
|
18542
18652
|
mkdirSync35(d, { recursive: true });
|
|
18543
|
-
writeFileSync33(
|
|
18653
|
+
writeFileSync33(join57(d, "active.json"), JSON.stringify({ loopId, status }));
|
|
18544
18654
|
}
|
|
18545
18655
|
function clearActiveLoop(dir) {
|
|
18546
|
-
const path =
|
|
18547
|
-
if (
|
|
18656
|
+
const path = join57(loopDir(dir), "active.json");
|
|
18657
|
+
if (existsSync58(path)) {
|
|
18548
18658
|
writeFileSync33(path, JSON.stringify({ loopId: null, status: "none" }));
|
|
18549
18659
|
}
|
|
18550
18660
|
}
|
|
@@ -18888,13 +18998,13 @@ var claudeCodeLoopAdapter = {
|
|
|
18888
18998
|
};
|
|
18889
18999
|
|
|
18890
19000
|
// src/avorelo/capabilities/settings/index.ts
|
|
18891
|
-
import { existsSync as
|
|
18892
|
-
import { join as
|
|
19001
|
+
import { existsSync as existsSync59, readFileSync as readFileSync42, writeFileSync as writeFileSync34, mkdirSync as mkdirSync36 } from "node:fs";
|
|
19002
|
+
import { join as join58, dirname as dirname11 } from "node:path";
|
|
18893
19003
|
var SETTINGS_CONTRACT = "avorelo.settings.v1";
|
|
18894
19004
|
var SETTINGS_PATH = ".avorelo/settings.json";
|
|
18895
19005
|
function getCurrentVersion3() {
|
|
18896
19006
|
try {
|
|
18897
|
-
const pkgPath =
|
|
19007
|
+
const pkgPath = join58(dirname11(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/, "$1")), "../../../../package.json");
|
|
18898
19008
|
const pkg = JSON.parse(readFileSync42(pkgPath, "utf8"));
|
|
18899
19009
|
return pkg.version ?? "0.0.0";
|
|
18900
19010
|
} catch {
|
|
@@ -18954,8 +19064,8 @@ function buildDefaultSettings(opts) {
|
|
|
18954
19064
|
};
|
|
18955
19065
|
}
|
|
18956
19066
|
function loadSettings(dir) {
|
|
18957
|
-
const p =
|
|
18958
|
-
if (!
|
|
19067
|
+
const p = join58(dir, SETTINGS_PATH);
|
|
19068
|
+
if (!existsSync59(p)) return null;
|
|
18959
19069
|
try {
|
|
18960
19070
|
const s = JSON.parse(readFileSync42(p, "utf8"));
|
|
18961
19071
|
return s.contract === SETTINGS_CONTRACT ? s : null;
|
|
@@ -18964,7 +19074,7 @@ function loadSettings(dir) {
|
|
|
18964
19074
|
}
|
|
18965
19075
|
}
|
|
18966
19076
|
function writeSettings(dir, settings) {
|
|
18967
|
-
const p =
|
|
19077
|
+
const p = join58(dir, SETTINGS_PATH);
|
|
18968
19078
|
mkdirSync36(dirname11(p), { recursive: true });
|
|
18969
19079
|
writeFileSync34(p, JSON.stringify(settings, null, 2));
|
|
18970
19080
|
}
|
|
@@ -19062,13 +19172,13 @@ var ALPHA_NOTICE = [
|
|
|
19062
19172
|
].join("\n");
|
|
19063
19173
|
|
|
19064
19174
|
// src/avorelo/capabilities/update-channel/index.ts
|
|
19065
|
-
import { existsSync as
|
|
19066
|
-
import { join as
|
|
19175
|
+
import { existsSync as existsSync60, readFileSync as readFileSync43, writeFileSync as writeFileSync35, mkdirSync as mkdirSync37 } from "node:fs";
|
|
19176
|
+
import { join as join59, dirname as dirname12 } from "node:path";
|
|
19067
19177
|
var UPDATE_CHANNEL_CONTRACT = "avorelo.updateChannel.v1";
|
|
19068
19178
|
var UPDATE_MANIFEST_CONTRACT = "avorelo.updateManifest.v1";
|
|
19069
19179
|
function getCurrentVersion4() {
|
|
19070
19180
|
try {
|
|
19071
|
-
const pkgPath =
|
|
19181
|
+
const pkgPath = join59(dirname12(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/, "$1")), "../../../../package.json");
|
|
19072
19182
|
const pkg = JSON.parse(readFileSync43(pkgPath, "utf8"));
|
|
19073
19183
|
return pkg.version ?? "0.0.0";
|
|
19074
19184
|
} catch {
|
|
@@ -19076,11 +19186,11 @@ function getCurrentVersion4() {
|
|
|
19076
19186
|
}
|
|
19077
19187
|
}
|
|
19078
19188
|
function detectInstallMethod(root) {
|
|
19079
|
-
const r2 = root ??
|
|
19080
|
-
if (
|
|
19189
|
+
const r2 = root ?? join59(dirname12(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/, "$1")), "../../../..");
|
|
19190
|
+
if (existsSync60(join59(r2, ".git"))) return "source-checkout";
|
|
19081
19191
|
try {
|
|
19082
|
-
const p =
|
|
19083
|
-
if (
|
|
19192
|
+
const p = join59(r2, "package.json");
|
|
19193
|
+
if (existsSync60(p)) {
|
|
19084
19194
|
const pkg = JSON.parse(readFileSync43(p, "utf8"));
|
|
19085
19195
|
if (pkg._resolved) return "npm-global";
|
|
19086
19196
|
if (pkg._where) return "npm-local";
|
|
@@ -19090,8 +19200,8 @@ function detectInstallMethod(root) {
|
|
|
19090
19200
|
return "unknown";
|
|
19091
19201
|
}
|
|
19092
19202
|
function loadManifest(dir) {
|
|
19093
|
-
const p =
|
|
19094
|
-
if (!
|
|
19203
|
+
const p = join59(dir, ".avorelo", "update-manifest.json");
|
|
19204
|
+
if (!existsSync60(p)) return null;
|
|
19095
19205
|
try {
|
|
19096
19206
|
const m = JSON.parse(readFileSync43(p, "utf8"));
|
|
19097
19207
|
return m.contract === UPDATE_MANIFEST_CONTRACT ? m : null;
|
|
@@ -19233,8 +19343,8 @@ function renderUpdateApply(r2) {
|
|
|
19233
19343
|
}
|
|
19234
19344
|
|
|
19235
19345
|
// src/avorelo/capabilities/dogfood-learning/index.ts
|
|
19236
|
-
import { existsSync as
|
|
19237
|
-
import { join as
|
|
19346
|
+
import { existsSync as existsSync61, readFileSync as readFileSync44, writeFileSync as writeFileSync36, mkdirSync as mkdirSync38, readdirSync as readdirSync18, unlinkSync as unlinkSync3 } from "node:fs";
|
|
19347
|
+
import { join as join60, dirname as dirname13 } from "node:path";
|
|
19238
19348
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
19239
19349
|
var DOGFOOD_LEARNING_CONTRACT = "avorelo.dogfoodLearning.v1";
|
|
19240
19350
|
var ALLOWED_KEYS2 = /* @__PURE__ */ new Set([
|
|
@@ -19366,7 +19476,7 @@ function inspectStringValue(val, key) {
|
|
|
19366
19476
|
}
|
|
19367
19477
|
function getCurrentVersion5() {
|
|
19368
19478
|
try {
|
|
19369
|
-
const pkgPath =
|
|
19479
|
+
const pkgPath = join60(dirname13(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/, "$1")), "../../../../package.json");
|
|
19370
19480
|
const pkg = JSON.parse(readFileSync44(pkgPath, "utf8"));
|
|
19371
19481
|
return pkg.version ?? "0.0.0";
|
|
19372
19482
|
} catch {
|
|
@@ -19421,7 +19531,7 @@ function buildLearningPayload(dir, opts) {
|
|
|
19421
19531
|
var QUEUE_DIR = ".avorelo/learning-queue";
|
|
19422
19532
|
var MAX_QUEUED_EVENTS = 500;
|
|
19423
19533
|
function queueDir(dir) {
|
|
19424
|
-
return
|
|
19534
|
+
return join60(dir, QUEUE_DIR);
|
|
19425
19535
|
}
|
|
19426
19536
|
function ensureQueueDir(dir) {
|
|
19427
19537
|
const qd = queueDir(dir);
|
|
@@ -19430,9 +19540,9 @@ function ensureQueueDir(dir) {
|
|
|
19430
19540
|
}
|
|
19431
19541
|
function countQueuedEvents(dir) {
|
|
19432
19542
|
const qd = queueDir(dir);
|
|
19433
|
-
if (!
|
|
19543
|
+
if (!existsSync61(qd)) return 0;
|
|
19434
19544
|
try {
|
|
19435
|
-
return
|
|
19545
|
+
return readdirSync18(qd).filter((f) => f.endsWith(".json")).length;
|
|
19436
19546
|
} catch {
|
|
19437
19547
|
return 0;
|
|
19438
19548
|
}
|
|
@@ -19442,18 +19552,18 @@ function queueEvent(dir, payload) {
|
|
|
19442
19552
|
if (count >= MAX_QUEUED_EVENTS) return { queued: false };
|
|
19443
19553
|
const qd = ensureQueueDir(dir);
|
|
19444
19554
|
const filename = `${payload.createdAt.replace(/[:.]/g, "-")}_${payload.eventId}.json`;
|
|
19445
|
-
const p =
|
|
19555
|
+
const p = join60(qd, filename);
|
|
19446
19556
|
writeFileSync36(p, JSON.stringify(payload));
|
|
19447
19557
|
return { queued: true, path: p };
|
|
19448
19558
|
}
|
|
19449
19559
|
function loadQueuedEvents(dir) {
|
|
19450
19560
|
const qd = queueDir(dir);
|
|
19451
|
-
if (!
|
|
19452
|
-
const files =
|
|
19561
|
+
if (!existsSync61(qd)) return [];
|
|
19562
|
+
const files = readdirSync18(qd).filter((f) => f.endsWith(".json")).sort();
|
|
19453
19563
|
const events = [];
|
|
19454
19564
|
for (const f of files) {
|
|
19455
19565
|
try {
|
|
19456
|
-
const e = JSON.parse(readFileSync44(
|
|
19566
|
+
const e = JSON.parse(readFileSync44(join60(qd, f), "utf8"));
|
|
19457
19567
|
if (e.contract === DOGFOOD_LEARNING_CONTRACT) events.push(e);
|
|
19458
19568
|
} catch {
|
|
19459
19569
|
}
|
|
@@ -19462,11 +19572,11 @@ function loadQueuedEvents(dir) {
|
|
|
19462
19572
|
}
|
|
19463
19573
|
function purgeQueue(dir) {
|
|
19464
19574
|
const qd = queueDir(dir);
|
|
19465
|
-
if (!
|
|
19466
|
-
const files =
|
|
19575
|
+
if (!existsSync61(qd)) return { purged: 0 };
|
|
19576
|
+
const files = readdirSync18(qd).filter((f) => f.endsWith(".json"));
|
|
19467
19577
|
for (const f of files) {
|
|
19468
19578
|
try {
|
|
19469
|
-
unlinkSync3(
|
|
19579
|
+
unlinkSync3(join60(qd, f));
|
|
19470
19580
|
} catch {
|
|
19471
19581
|
}
|
|
19472
19582
|
}
|
|
@@ -19601,13 +19711,13 @@ async function flushQueue(dir) {
|
|
|
19601
19711
|
let sent = 0;
|
|
19602
19712
|
let failed = 0;
|
|
19603
19713
|
const qd = queueDir(dir);
|
|
19604
|
-
const files =
|
|
19714
|
+
const files = readdirSync18(qd).filter((f) => f.endsWith(".json")).sort();
|
|
19605
19715
|
for (const f of files) {
|
|
19606
19716
|
try {
|
|
19607
|
-
const event = JSON.parse(readFileSync44(
|
|
19717
|
+
const event = JSON.parse(readFileSync44(join60(qd, f), "utf8"));
|
|
19608
19718
|
const result3 = await sendToEndpoint(endpointUrl, event);
|
|
19609
19719
|
if (result3.ok) {
|
|
19610
|
-
unlinkSync3(
|
|
19720
|
+
unlinkSync3(join60(qd, f));
|
|
19611
19721
|
sent++;
|
|
19612
19722
|
} else {
|
|
19613
19723
|
failed++;
|
|
@@ -19657,13 +19767,13 @@ function generateLocalFingerprint(target) {
|
|
|
19657
19767
|
var CLAIM_EXPIRY_MS = 24 * 60 * 60 * 1e3;
|
|
19658
19768
|
|
|
19659
19769
|
// src/avorelo/capabilities/cloud-sync/cli-auth-state.ts
|
|
19660
|
-
import { existsSync as
|
|
19661
|
-
import { join as
|
|
19770
|
+
import { existsSync as existsSync62, readFileSync as readFileSync45, writeFileSync as writeFileSync37, mkdirSync as mkdirSync39 } from "node:fs";
|
|
19771
|
+
import { join as join61 } from "node:path";
|
|
19662
19772
|
function authDir(baseDir) {
|
|
19663
|
-
return
|
|
19773
|
+
return join61(baseDir, ".avorelo", "auth");
|
|
19664
19774
|
}
|
|
19665
19775
|
function authPath(baseDir) {
|
|
19666
|
-
return
|
|
19776
|
+
return join61(authDir(baseDir), "session.json");
|
|
19667
19777
|
}
|
|
19668
19778
|
function writeCliAuthState(baseDir, state) {
|
|
19669
19779
|
const dir = authDir(baseDir);
|
|
@@ -19674,7 +19784,7 @@ function writeCliAuthState(baseDir, state) {
|
|
|
19674
19784
|
}
|
|
19675
19785
|
function readCliAuthState(baseDir) {
|
|
19676
19786
|
const path = authPath(baseDir);
|
|
19677
|
-
if (!
|
|
19787
|
+
if (!existsSync62(path)) return null;
|
|
19678
19788
|
try {
|
|
19679
19789
|
const raw = JSON.parse(readFileSync45(path, "utf8"));
|
|
19680
19790
|
if (!raw || typeof raw.token !== "string" || typeof raw.workspaceId !== "string") return null;
|
|
@@ -19929,11 +20039,11 @@ function renderTelemetryPreview(preview) {
|
|
|
19929
20039
|
}
|
|
19930
20040
|
|
|
19931
20041
|
// src/avorelo/telemetry/integration-detection.ts
|
|
19932
|
-
import { existsSync as
|
|
19933
|
-
import { join as
|
|
20042
|
+
import { existsSync as existsSync63, readFileSync as readFileSync46 } from "node:fs";
|
|
20043
|
+
import { join as join62 } from "node:path";
|
|
19934
20044
|
function detectGitProviderFromConfig(dir) {
|
|
19935
|
-
const configPath =
|
|
19936
|
-
if (!
|
|
20045
|
+
const configPath = join62(dir, ".git", "config");
|
|
20046
|
+
if (!existsSync63(configPath)) return "unknown";
|
|
19937
20047
|
try {
|
|
19938
20048
|
const content = readFileSync46(configPath, "utf8").toLowerCase();
|
|
19939
20049
|
if (content.includes("github.com")) return "github";
|
|
@@ -19945,15 +20055,15 @@ function detectGitProviderFromConfig(dir) {
|
|
|
19945
20055
|
}
|
|
19946
20056
|
}
|
|
19947
20057
|
function detectCiProvider(dir) {
|
|
19948
|
-
if (
|
|
19949
|
-
if (
|
|
19950
|
-
if (
|
|
19951
|
-
if (
|
|
20058
|
+
if (existsSync63(join62(dir, ".github", "workflows"))) return "github_actions";
|
|
20059
|
+
if (existsSync63(join62(dir, ".gitlab-ci.yml"))) return "gitlab_ci";
|
|
20060
|
+
if (existsSync63(join62(dir, ".circleci", "config.yml"))) return "circle";
|
|
20061
|
+
if (existsSync63(join62(dir, "Jenkinsfile"))) return "jenkins";
|
|
19952
20062
|
return "unknown";
|
|
19953
20063
|
}
|
|
19954
20064
|
function detectRepoVisibility(dir) {
|
|
19955
|
-
const configPath =
|
|
19956
|
-
if (!
|
|
20065
|
+
const configPath = join62(dir, ".git", "config");
|
|
20066
|
+
if (!existsSync63(configPath)) return "unknown";
|
|
19957
20067
|
try {
|
|
19958
20068
|
const content = readFileSync46(configPath, "utf8").toLowerCase();
|
|
19959
20069
|
if (content.includes("github.com")) {
|
|
@@ -20087,16 +20197,16 @@ async function sendDueTelemetry(dir, opts) {
|
|
|
20087
20197
|
}
|
|
20088
20198
|
|
|
20089
20199
|
// src/avorelo/kernel/agent-artifact-guard/guard-handler.ts
|
|
20090
|
-
import { existsSync as
|
|
20091
|
-
import { join as
|
|
20200
|
+
import { existsSync as existsSync65, readFileSync as readFileSync50 } from "node:fs";
|
|
20201
|
+
import { join as join67 } from "node:path";
|
|
20092
20202
|
|
|
20093
20203
|
// src/avorelo/kernel/agent-artifact-guard/index.ts
|
|
20094
|
-
import { join as
|
|
20204
|
+
import { join as join66 } from "node:path";
|
|
20095
20205
|
import { readFileSync as readFileSync49 } from "node:fs";
|
|
20096
20206
|
|
|
20097
20207
|
// src/avorelo/kernel/agent-artifact-guard/artifact-discovery.ts
|
|
20098
|
-
import { readdirSync as
|
|
20099
|
-
import { join as
|
|
20208
|
+
import { readdirSync as readdirSync19, statSync as statSync14, existsSync as existsSync64 } from "node:fs";
|
|
20209
|
+
import { join as join63, relative as relative5, extname as extname2 } from "node:path";
|
|
20100
20210
|
var SCANNED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
20101
20211
|
".md",
|
|
20102
20212
|
".js",
|
|
@@ -20131,16 +20241,16 @@ var ARTIFACT_PATTERNS = [
|
|
|
20131
20241
|
function walkDir2(dir, results) {
|
|
20132
20242
|
let entries;
|
|
20133
20243
|
try {
|
|
20134
|
-
entries =
|
|
20244
|
+
entries = readdirSync19(dir);
|
|
20135
20245
|
} catch {
|
|
20136
20246
|
return;
|
|
20137
20247
|
}
|
|
20138
20248
|
for (const entry of entries) {
|
|
20139
20249
|
if (IGNORED_DIRS.has(entry)) continue;
|
|
20140
|
-
const full =
|
|
20250
|
+
const full = join63(dir, entry);
|
|
20141
20251
|
let st;
|
|
20142
20252
|
try {
|
|
20143
|
-
st =
|
|
20253
|
+
st = statSync14(full);
|
|
20144
20254
|
} catch {
|
|
20145
20255
|
continue;
|
|
20146
20256
|
}
|
|
@@ -20155,11 +20265,11 @@ function discoverArtifacts(projectRoot) {
|
|
|
20155
20265
|
const artifacts = [];
|
|
20156
20266
|
for (const pattern of ARTIFACT_PATTERNS) {
|
|
20157
20267
|
for (const p of pattern.paths) {
|
|
20158
|
-
const fullPath =
|
|
20159
|
-
if (!
|
|
20268
|
+
const fullPath = join63(projectRoot, p);
|
|
20269
|
+
if (!existsSync64(fullPath)) continue;
|
|
20160
20270
|
let st;
|
|
20161
20271
|
try {
|
|
20162
|
-
st =
|
|
20272
|
+
st = statSync14(fullPath);
|
|
20163
20273
|
} catch {
|
|
20164
20274
|
continue;
|
|
20165
20275
|
}
|
|
@@ -20167,7 +20277,7 @@ function discoverArtifacts(projectRoot) {
|
|
|
20167
20277
|
if (SCANNED_EXTENSIONS.has(extname2(fullPath).toLowerCase()) || fullPath.endsWith(".json")) {
|
|
20168
20278
|
artifacts.push({
|
|
20169
20279
|
kind: pattern.kind,
|
|
20170
|
-
path:
|
|
20280
|
+
path: relative5(projectRoot, fullPath)
|
|
20171
20281
|
});
|
|
20172
20282
|
}
|
|
20173
20283
|
} else if (st.isDirectory() && pattern.recursive) {
|
|
@@ -20176,7 +20286,7 @@ function discoverArtifacts(projectRoot) {
|
|
|
20176
20286
|
for (const f of files) {
|
|
20177
20287
|
artifacts.push({
|
|
20178
20288
|
kind: pattern.kind,
|
|
20179
|
-
path:
|
|
20289
|
+
path: relative5(projectRoot, f)
|
|
20180
20290
|
});
|
|
20181
20291
|
}
|
|
20182
20292
|
}
|
|
@@ -20742,9 +20852,9 @@ function toJson(result3) {
|
|
|
20742
20852
|
|
|
20743
20853
|
// src/avorelo/kernel/agent-artifact-guard/allowlist.ts
|
|
20744
20854
|
import { readFileSync as readFileSync47 } from "node:fs";
|
|
20745
|
-
import { join as
|
|
20855
|
+
import { join as join64 } from "node:path";
|
|
20746
20856
|
function loadAllowlist(projectRoot) {
|
|
20747
|
-
const filePath =
|
|
20857
|
+
const filePath = join64(projectRoot, ".avorelo", "artifact-guard", "allowlist.json");
|
|
20748
20858
|
try {
|
|
20749
20859
|
const raw = readFileSync47(filePath, "utf-8");
|
|
20750
20860
|
const parsed = JSON.parse(raw);
|
|
@@ -20766,12 +20876,12 @@ function isAllowlisted(finding, allowlist) {
|
|
|
20766
20876
|
}
|
|
20767
20877
|
|
|
20768
20878
|
// src/avorelo/kernel/agent-artifact-guard/receipt-store.ts
|
|
20769
|
-
import { mkdirSync as mkdirSync40, writeFileSync as writeFileSync38, readdirSync as
|
|
20770
|
-
import { join as
|
|
20879
|
+
import { mkdirSync as mkdirSync40, writeFileSync as writeFileSync38, readdirSync as readdirSync20, readFileSync as readFileSync48, unlinkSync as unlinkSync4 } from "node:fs";
|
|
20880
|
+
import { join as join65 } from "node:path";
|
|
20771
20881
|
var RECEIPT_DIR = "artifact-guard";
|
|
20772
20882
|
var MAX_STORED_RECEIPTS = 50;
|
|
20773
20883
|
function receiptDir(projectRoot) {
|
|
20774
|
-
return
|
|
20884
|
+
return join65(projectRoot, ".avorelo", RECEIPT_DIR);
|
|
20775
20885
|
}
|
|
20776
20886
|
function receiptFilename(receipt) {
|
|
20777
20887
|
const ts = receipt.scannedAt.replace(/[:.]/g, "-");
|
|
@@ -20781,7 +20891,7 @@ function storeReceipt(projectRoot, receipt) {
|
|
|
20781
20891
|
const dir = receiptDir(projectRoot);
|
|
20782
20892
|
mkdirSync40(dir, { recursive: true });
|
|
20783
20893
|
const filename = receiptFilename(receipt);
|
|
20784
|
-
const filePath =
|
|
20894
|
+
const filePath = join65(dir, filename);
|
|
20785
20895
|
writeFileSync38(filePath, JSON.stringify(receipt, null, 2), "utf-8");
|
|
20786
20896
|
pruneOldReceipts(dir);
|
|
20787
20897
|
return filePath;
|
|
@@ -20790,7 +20900,7 @@ function loadLatestReceipt(projectRoot) {
|
|
|
20790
20900
|
const dir = receiptDir(projectRoot);
|
|
20791
20901
|
let files;
|
|
20792
20902
|
try {
|
|
20793
|
-
files =
|
|
20903
|
+
files = readdirSync20(dir).filter((f) => f.startsWith("receipt-") && f.endsWith(".json"));
|
|
20794
20904
|
} catch {
|
|
20795
20905
|
return null;
|
|
20796
20906
|
}
|
|
@@ -20798,7 +20908,7 @@ function loadLatestReceipt(projectRoot) {
|
|
|
20798
20908
|
files.sort();
|
|
20799
20909
|
const latest = files[files.length - 1];
|
|
20800
20910
|
try {
|
|
20801
|
-
const raw = readFileSync48(
|
|
20911
|
+
const raw = readFileSync48(join65(dir, latest), "utf-8");
|
|
20802
20912
|
return JSON.parse(raw);
|
|
20803
20913
|
} catch {
|
|
20804
20914
|
return null;
|
|
@@ -20806,11 +20916,11 @@ function loadLatestReceipt(projectRoot) {
|
|
|
20806
20916
|
}
|
|
20807
20917
|
function pruneOldReceipts(dir) {
|
|
20808
20918
|
try {
|
|
20809
|
-
const files =
|
|
20919
|
+
const files = readdirSync20(dir).filter((f) => f.startsWith("receipt-") && f.endsWith(".json")).sort();
|
|
20810
20920
|
while (files.length > MAX_STORED_RECEIPTS) {
|
|
20811
20921
|
const oldest = files.shift();
|
|
20812
20922
|
try {
|
|
20813
|
-
unlinkSync4(
|
|
20923
|
+
unlinkSync4(join65(dir, oldest));
|
|
20814
20924
|
} catch {
|
|
20815
20925
|
break;
|
|
20816
20926
|
}
|
|
@@ -20824,7 +20934,7 @@ function scan(projectRoot, options) {
|
|
|
20824
20934
|
const artifacts = discoverArtifacts(projectRoot);
|
|
20825
20935
|
const allFindings = [];
|
|
20826
20936
|
for (const artifact of artifacts) {
|
|
20827
|
-
const fullPath =
|
|
20937
|
+
const fullPath = join66(projectRoot, artifact.path);
|
|
20828
20938
|
let content;
|
|
20829
20939
|
try {
|
|
20830
20940
|
content = readFileSync49(fullPath, "utf-8");
|
|
@@ -20871,9 +20981,9 @@ function scan(projectRoot, options) {
|
|
|
20871
20981
|
|
|
20872
20982
|
// src/avorelo/kernel/agent-artifact-guard/guard-handler.ts
|
|
20873
20983
|
function checkActivation(dir) {
|
|
20874
|
-
const configPath =
|
|
20984
|
+
const configPath = join67(dir, ".avorelo", "model-routing", "config.json");
|
|
20875
20985
|
try {
|
|
20876
|
-
if (
|
|
20986
|
+
if (existsSync65(configPath)) {
|
|
20877
20987
|
const raw = JSON.parse(readFileSync50(configPath, "utf-8"));
|
|
20878
20988
|
return {
|
|
20879
20989
|
activated: true,
|
|
@@ -21370,11 +21480,11 @@ function multiArg(args, name) {
|
|
|
21370
21480
|
return values;
|
|
21371
21481
|
}
|
|
21372
21482
|
function contextControlArtifactPath(target) {
|
|
21373
|
-
return
|
|
21483
|
+
return join68(target, ".avorelo", "context-control", "latest.json");
|
|
21374
21484
|
}
|
|
21375
21485
|
function loadContextControlArtifact(target) {
|
|
21376
21486
|
const path = contextControlArtifactPath(target);
|
|
21377
|
-
if (!
|
|
21487
|
+
if (!existsSync66(path)) return null;
|
|
21378
21488
|
try {
|
|
21379
21489
|
return JSON.parse(readFileSync51(path, "utf8"));
|
|
21380
21490
|
} catch {
|
|
@@ -21412,6 +21522,7 @@ function help() {
|
|
|
21412
21522
|
" prompt [--target <dir>] Copy-ready prompt for any AI tool",
|
|
21413
21523
|
"",
|
|
21414
21524
|
" activate [--target <dir>] Full activation: detect, repair, run-entry",
|
|
21525
|
+
" activate --discover-projects [--dry-run] [--yes] [--target <dir>] Discover and activate multiple local projects",
|
|
21415
21526
|
" activate --install-hooks --approve [--target <dir>] Activate + install Claude Code hooks",
|
|
21416
21527
|
" status [--target <dir>] Show activation and session status",
|
|
21417
21528
|
" open [--target <dir>] [--format html|json|text] Local receipts dashboard",
|
|
@@ -21498,6 +21609,98 @@ async function cmdActivate(args) {
|
|
|
21498
21609
|
const approve = args.includes("--approve");
|
|
21499
21610
|
const claimToken = arg(args, "--link-code") ?? arg(args, "--claim");
|
|
21500
21611
|
const scope = arg(args, "--scope") ?? "project-wide";
|
|
21612
|
+
const discoverFlag = args.includes("--discover-projects");
|
|
21613
|
+
const dryRunFlag = args.includes("--dry-run");
|
|
21614
|
+
const yesFlag = args.includes("--yes");
|
|
21615
|
+
const apiBaseUrl = process.env.APP_BASE_URL ?? "https://app.avorelo.com";
|
|
21616
|
+
if (discoverFlag) {
|
|
21617
|
+
const result3 = discoverProjects(target);
|
|
21618
|
+
process.stdout.write(formatDiscoveryPreview(result3));
|
|
21619
|
+
if (result3.projects.length === 0) return 0;
|
|
21620
|
+
if (dryRunFlag) {
|
|
21621
|
+
process.stdout.write("Dry run: no projects were activated. No files were written.\n\n");
|
|
21622
|
+
return 0;
|
|
21623
|
+
}
|
|
21624
|
+
const selected = result3.projects.filter((p) => p.recommended);
|
|
21625
|
+
if (selected.length === 0) {
|
|
21626
|
+
process.stdout.write("All discovered projects are already activated. Nothing to do.\n\n");
|
|
21627
|
+
return 0;
|
|
21628
|
+
}
|
|
21629
|
+
process.stdout.write(`${selected.length} project${selected.length === 1 ? "" : "s"} selected for activation.
|
|
21630
|
+
`);
|
|
21631
|
+
if (!yesFlag) {
|
|
21632
|
+
process.stdout.write("\nNo changes were made. To activate the selected projects, run again with --yes:\n");
|
|
21633
|
+
process.stdout.write(` npx -y avorelo@latest activate --scope ${scope} --link-code <code> --discover-projects --yes
|
|
21634
|
+
|
|
21635
|
+
`);
|
|
21636
|
+
return 0;
|
|
21637
|
+
}
|
|
21638
|
+
process.stdout.write("\nActivating selected projects...\n");
|
|
21639
|
+
let activated = 0;
|
|
21640
|
+
let failed = 0;
|
|
21641
|
+
for (const project of selected) {
|
|
21642
|
+
process.stdout.write(`
|
|
21643
|
+
--- ${project.relativePath} ---
|
|
21644
|
+
`);
|
|
21645
|
+
try {
|
|
21646
|
+
const preflight2 = runPreflight(project.path);
|
|
21647
|
+
if (!preflight2.canStart) {
|
|
21648
|
+
process.stderr.write(` Skipped: preflight failed (${preflight2.taxonomy})
|
|
21649
|
+
`);
|
|
21650
|
+
failed++;
|
|
21651
|
+
continue;
|
|
21652
|
+
}
|
|
21653
|
+
const state2 = runFullActivation(project.path);
|
|
21654
|
+
const contract2 = createWorkContract({ contractId: "canonical-activate", objective: "multi-project activation", allowedPaths: [join68(project.path, ".avorelo")], planTier: "Free" });
|
|
21655
|
+
const ledger2 = new StateLedger();
|
|
21656
|
+
const receipt2 = writeReceipt(ledger2, {
|
|
21657
|
+
contractId: contract2.contractId,
|
|
21658
|
+
decision: "STOP_DONE",
|
|
21659
|
+
graded: [{ artifactId: "g1", level: "OUTCOME", ref: "ev:activation-state-written" }],
|
|
21660
|
+
safeNextActions: ["run: avorelo status"],
|
|
21661
|
+
decisionBasis: { method: "deterministic", confidence: "HIGH", evidenceRefs: ["ev:activation-state-written"], reasonCodes: ["MULTI_PROJECT_ACTIVATION"], fallbackUsed: false },
|
|
21662
|
+
sampleSize: 1,
|
|
21663
|
+
redactionClasses: [],
|
|
21664
|
+
receiptId: `rcpt_multi_activate_${activated}`
|
|
21665
|
+
});
|
|
21666
|
+
persistActivationV2(project.path, state2);
|
|
21667
|
+
persistReceipt(project.path, receipt2);
|
|
21668
|
+
if (claimToken) {
|
|
21669
|
+
const fingerprint2 = generateLocalFingerprint(project.path);
|
|
21670
|
+
const detection2 = runFullDetection(project.path);
|
|
21671
|
+
try {
|
|
21672
|
+
await fetch(`${apiBaseUrl}/api/activation/link`, {
|
|
21673
|
+
method: "POST",
|
|
21674
|
+
headers: { "Content-Type": "application/json" },
|
|
21675
|
+
body: JSON.stringify({
|
|
21676
|
+
token: claimToken,
|
|
21677
|
+
fingerprint: fingerprint2,
|
|
21678
|
+
version: avoreloVersion(),
|
|
21679
|
+
toolsDetected: detection2.summary.toolsDetected,
|
|
21680
|
+
osFamily: detection2.environment.os,
|
|
21681
|
+
nodeVersion: detection2.environment.nodeVersion ?? null,
|
|
21682
|
+
taxonomy: "ACTIVATION_SUCCEEDED_LOCALLY"
|
|
21683
|
+
})
|
|
21684
|
+
});
|
|
21685
|
+
} catch {
|
|
21686
|
+
}
|
|
21687
|
+
}
|
|
21688
|
+
process.stdout.write(` Activated: ${state2.activationMode} (${state2.activationStatus})
|
|
21689
|
+
`);
|
|
21690
|
+
activated++;
|
|
21691
|
+
} catch (e) {
|
|
21692
|
+
process.stderr.write(` Failed: ${e.message}
|
|
21693
|
+
`);
|
|
21694
|
+
failed++;
|
|
21695
|
+
}
|
|
21696
|
+
}
|
|
21697
|
+
const skippedCount = result3.projects.length - selected.length;
|
|
21698
|
+
process.stdout.write(`
|
|
21699
|
+
Done: ${activated} activated, ${failed} failed, ${skippedCount} skipped (already activated).
|
|
21700
|
+
|
|
21701
|
+
`);
|
|
21702
|
+
return failed > 0 ? 1 : 0;
|
|
21703
|
+
}
|
|
21501
21704
|
if (installHooksFlag) {
|
|
21502
21705
|
if (!approve) {
|
|
21503
21706
|
process.stderr.write("Hook installation requires explicit approval. Add --approve to confirm.\n");
|
|
@@ -21507,8 +21710,8 @@ async function cmdActivate(args) {
|
|
|
21507
21710
|
const r2 = activate(target, { approve: true });
|
|
21508
21711
|
persistReceipt(target, r2.receipt);
|
|
21509
21712
|
const state2 = runFullActivation(target);
|
|
21510
|
-
state2.setupSteps.push({ id: "hooks_installed", label: "Claude Code hooks installed", status: r2.ok ? "passed" : "blocked", evidencePath:
|
|
21511
|
-
if (r2.ok) state2.receipts.push({ id: r2.receipt.receiptId, path:
|
|
21713
|
+
state2.setupSteps.push({ id: "hooks_installed", label: "Claude Code hooks installed", status: r2.ok ? "passed" : "blocked", evidencePath: join68(target, ".claude", "settings.json") });
|
|
21714
|
+
if (r2.ok) state2.receipts.push({ id: r2.receipt.receiptId, path: join68(target, ".avorelo", "receipts", `${r2.receipt.receiptId}.json`), type: "activation_with_hooks" });
|
|
21512
21715
|
persistActivationV2(target, state2);
|
|
21513
21716
|
process.stdout.write(JSON.stringify({ ok: r2.ok, mode: "activate-with-hooks", target, installed: r2.validate.wellFormed, receipt: r2.receipt.receiptId }, null, 2) + "\n");
|
|
21514
21717
|
return r2.ok ? 0 : 1;
|
|
@@ -21531,7 +21734,7 @@ Activation taxonomy: ${preflight.taxonomy}
|
|
|
21531
21734
|
process.stderr.write("Continuing with activation despite warnings...\n\n");
|
|
21532
21735
|
}
|
|
21533
21736
|
const state = runFullActivation(target);
|
|
21534
|
-
const contract = createWorkContract({ contractId: "canonical-activate", objective: "full local-first activation", allowedPaths: [
|
|
21737
|
+
const contract = createWorkContract({ contractId: "canonical-activate", objective: "full local-first activation", allowedPaths: [join68(target, ".avorelo")], planTier: "Free" });
|
|
21535
21738
|
const ledger = new StateLedger();
|
|
21536
21739
|
const receipt = writeReceipt(ledger, {
|
|
21537
21740
|
contractId: contract.contractId,
|
|
@@ -21546,7 +21749,7 @@ Activation taxonomy: ${preflight.taxonomy}
|
|
|
21546
21749
|
redactionClasses: [],
|
|
21547
21750
|
receiptId: "rcpt_canonical_activation"
|
|
21548
21751
|
});
|
|
21549
|
-
state.receipts.push({ id: receipt.receiptId, path:
|
|
21752
|
+
state.receipts.push({ id: receipt.receiptId, path: join68(target, ".avorelo", "receipts", `${receipt.receiptId}.json`), type: "canonical_activation" });
|
|
21550
21753
|
persistActivationV2(target, state);
|
|
21551
21754
|
persistReceipt(target, receipt);
|
|
21552
21755
|
const detection = runFullDetection(target);
|
|
@@ -21561,7 +21764,7 @@ Activation taxonomy: ${preflight.taxonomy}
|
|
|
21561
21764
|
` Mode: ${state.activationMode}`,
|
|
21562
21765
|
` Scope: ${scope}`,
|
|
21563
21766
|
` Status: ${state.activationStatus}`,
|
|
21564
|
-
` State: ${
|
|
21767
|
+
` State: ${join68(target, ACTIVATION_STATE_DIR, ACTIVATION_STATE_FILE)}`
|
|
21565
21768
|
];
|
|
21566
21769
|
if (fv.found.length > 0) {
|
|
21567
21770
|
lines.push("", " Found:");
|
|
@@ -21595,9 +21798,8 @@ Activation taxonomy: ${preflight.taxonomy}
|
|
|
21595
21798
|
);
|
|
21596
21799
|
let linkResult = "no claim provided";
|
|
21597
21800
|
if (claimToken) {
|
|
21598
|
-
const baseUrl = process.env.APP_BASE_URL ?? "https://app.avorelo.com";
|
|
21599
21801
|
try {
|
|
21600
|
-
const resp = await fetch(`${
|
|
21802
|
+
const resp = await fetch(`${apiBaseUrl}/api/activation/link`, {
|
|
21601
21803
|
method: "POST",
|
|
21602
21804
|
headers: { "Content-Type": "application/json" },
|
|
21603
21805
|
body: JSON.stringify({
|
|
@@ -21854,7 +22056,7 @@ function cmdStatus(args) {
|
|
|
21854
22056
|
` activation: ${displayStatus}`,
|
|
21855
22057
|
` mode: ${state.activationMode}`,
|
|
21856
22058
|
` contract: ${state.contract}`,
|
|
21857
|
-
` state: ${
|
|
22059
|
+
` state: ${join68(target, ACTIVATION_STATE_DIR, ACTIVATION_STATE_FILE)}`,
|
|
21858
22060
|
` hooks: ${v.installed ? v.wellFormed ? "installed (6/6)" : `partial` : "not installed"}`
|
|
21859
22061
|
];
|
|
21860
22062
|
if (isV2) {
|
|
@@ -21924,7 +22126,7 @@ function cmdVerify(args) {
|
|
|
21924
22126
|
}
|
|
21925
22127
|
const input = loadProofInput(target);
|
|
21926
22128
|
if (input) {
|
|
21927
|
-
const contract = createWorkContract({ contractId: "verify", objective: input.objective ?? "verify real-workflow proof", allowedPaths: [
|
|
22129
|
+
const contract = createWorkContract({ contractId: "verify", objective: input.objective ?? "verify real-workflow proof", allowedPaths: [join68(target, "src")], planTier: "Free" });
|
|
21928
22130
|
const r2 = evaluateProof({ contract, artifacts: input.artifacts, readbacks: input.readbacks, dir: target, sampleSize: input.sampleSize, receiptId: "rcpt_verify" });
|
|
21929
22131
|
process.stdout.write(JSON.stringify({ scope: "full", activationState: { valid: true }, proof: { decision: r2.decision, confidence: r2.confidence } }, null, 2) + "\n");
|
|
21930
22132
|
return r2.decision === "STOP_DONE" ? 0 : 1;
|
|
@@ -21933,13 +22135,13 @@ function cmdVerify(args) {
|
|
|
21933
22135
|
return 0;
|
|
21934
22136
|
}
|
|
21935
22137
|
function cmdSite(args) {
|
|
21936
|
-
const outDir = arg(args, "--out",
|
|
22138
|
+
const outDir = arg(args, "--out", join68(process.cwd(), ".avorelo", "site"));
|
|
21937
22139
|
const r2 = buildSite(outDir);
|
|
21938
22140
|
process.stdout.write(JSON.stringify({ ok: r2.ok, outDir: r2.outDir, indexPath: r2.indexPath, pages: r2.pages }, null, 2) + "\n");
|
|
21939
22141
|
return r2.ok ? 0 : 1;
|
|
21940
22142
|
}
|
|
21941
22143
|
function cmdServe(args) {
|
|
21942
|
-
const outDir = arg(args, "--out",
|
|
22144
|
+
const outDir = arg(args, "--out", join68(process.cwd(), ".avorelo", "site"));
|
|
21943
22145
|
const port = Number(arg(args, "--port", "0"));
|
|
21944
22146
|
buildSite(outDir);
|
|
21945
22147
|
serve(outDir, { port: Number.isFinite(port) ? port : 0 }).then((h) => {
|
|
@@ -21995,9 +22197,9 @@ function cmdLifecycleHook(args) {
|
|
|
21995
22197
|
const sourceLabel = String(ccEvent.tool_name ?? "").toLowerCase().includes("mcp") ? "tool_output" : "tool_output";
|
|
21996
22198
|
const r3 = scanContent({ content: toolOutput, sourceKind: sourceLabel });
|
|
21997
22199
|
try {
|
|
21998
|
-
const dir =
|
|
22200
|
+
const dir = join68(cwd, ".avorelo", "secret-boundary");
|
|
21999
22201
|
mkdirSync41(dir, { recursive: true });
|
|
22000
|
-
appendFileSync12(
|
|
22202
|
+
appendFileSync12(join68(dir, "receipts.jsonl"), JSON.stringify(redact(r3.receipt).value) + "\n");
|
|
22001
22203
|
} catch {
|
|
22002
22204
|
}
|
|
22003
22205
|
process.stdout.write(JSON.stringify({
|
|
@@ -22014,13 +22216,13 @@ function cmdLifecycleHook(args) {
|
|
|
22014
22216
|
}
|
|
22015
22217
|
const looksLikeToolRequest = payloadRaw && ccEvent.tool !== void 0 && ccEvent.workingDir !== void 0;
|
|
22016
22218
|
const req = looksLikeToolRequest ? ccEvent : mapClaudeCodeEvent(ccEvent, cwd);
|
|
22017
|
-
const contract = createWorkContract({ contractId: "hook", objective: "lifecycle hook", allowedPaths: [
|
|
22219
|
+
const contract = createWorkContract({ contractId: "hook", objective: "lifecycle hook", allowedPaths: [join68(cwd, "src")], planTier: "Free" });
|
|
22018
22220
|
const r2 = handleLifecycleHook(event, req, { contract });
|
|
22019
22221
|
try {
|
|
22020
|
-
const dir =
|
|
22222
|
+
const dir = join68(cwd, ".avorelo", "events");
|
|
22021
22223
|
mkdirSync41(dir, { recursive: true });
|
|
22022
22224
|
const entry = redact({ ts: Date.now(), event: r2.event, tool: req.tool, verdict: r2.verdict, reasonCodes: r2.reasonCodes, redactionClasses: r2.redactionClasses, latencyMs: r2.latencyMs }).value;
|
|
22023
|
-
appendFileSync12(
|
|
22225
|
+
appendFileSync12(join68(dir, "hook-fires.jsonl"), JSON.stringify(entry) + "\n");
|
|
22024
22226
|
} catch {
|
|
22025
22227
|
}
|
|
22026
22228
|
if (r2.exitCode === 2) {
|
|
@@ -22569,7 +22771,7 @@ function cmdTokenCost(args) {
|
|
|
22569
22771
|
}
|
|
22570
22772
|
if (sub === "import" || sub === "validate") {
|
|
22571
22773
|
const file = arg(args, "--file");
|
|
22572
|
-
if (!file || !
|
|
22774
|
+
if (!file || !existsSync66(file)) {
|
|
22573
22775
|
process.stderr.write("Usage: avorelo token-cost " + sub + " --file <path> [--json]\n");
|
|
22574
22776
|
return 2;
|
|
22575
22777
|
}
|
|
@@ -22716,7 +22918,7 @@ function cmdContextCheck(args) {
|
|
|
22716
22918
|
const ci = args.includes("--ci");
|
|
22717
22919
|
const wcPath = arg(args, "--work-contract");
|
|
22718
22920
|
let workContract;
|
|
22719
|
-
if (wcPath &&
|
|
22921
|
+
if (wcPath && existsSync66(wcPath)) {
|
|
22720
22922
|
try {
|
|
22721
22923
|
workContract = JSON.parse(readFileSync51(wcPath, "utf8"));
|
|
22722
22924
|
} catch {
|
|
@@ -22968,7 +23170,7 @@ function cmdSecretBoundary(args) {
|
|
|
22968
23170
|
const asJson = args.includes("--json");
|
|
22969
23171
|
let content = arg(args, "--content");
|
|
22970
23172
|
const file = arg(args, "--file");
|
|
22971
|
-
if (file &&
|
|
23173
|
+
if (file && existsSync66(file)) content = readFileSync51(file, "utf8");
|
|
22972
23174
|
if (content === void 0) content = "";
|
|
22973
23175
|
if (sub === "scan" || sub === void 0) {
|
|
22974
23176
|
const r2 = scanContent({ content, sourceKind: file ? "file" : "tool_output" });
|
|
@@ -23035,7 +23237,7 @@ function cmdExplain(args) {
|
|
|
23035
23237
|
const changedFiles = [];
|
|
23036
23238
|
for (const { adapter } of detected) {
|
|
23037
23239
|
const surface = adapter.getInstructionSurface(target);
|
|
23038
|
-
if (surface &&
|
|
23240
|
+
if (surface && existsSync66(surface)) changedFiles.push(surface);
|
|
23039
23241
|
}
|
|
23040
23242
|
if (changedFiles.length > 0) {
|
|
23041
23243
|
lines.push(" Changed:");
|
|
@@ -23049,7 +23251,7 @@ function cmdExplain(args) {
|
|
|
23049
23251
|
lines.push("");
|
|
23050
23252
|
lines.push(` Hooks: ${hookValidation.installed ? "installed" : "not installed"}`);
|
|
23051
23253
|
lines.push(" Cloud: off (local-first)");
|
|
23052
|
-
lines.push(` Receipts: ${
|
|
23254
|
+
lines.push(` Receipts: ${join68(target, ".avorelo", "receipts")}`);
|
|
23053
23255
|
const sessionStatus = getSessionStatus(target);
|
|
23054
23256
|
if (sessionStatus) {
|
|
23055
23257
|
lines.push("");
|
|
@@ -23209,7 +23411,7 @@ function cmdFeedback(args) {
|
|
|
23209
23411
|
}
|
|
23210
23412
|
if (sub === "share") {
|
|
23211
23413
|
const file = arg(args, "--file");
|
|
23212
|
-
if (!file || !
|
|
23414
|
+
if (!file || !existsSync66(file)) {
|
|
23213
23415
|
process.stderr.write("Usage: avorelo feedback share --file <bundle-path>\n");
|
|
23214
23416
|
return 2;
|
|
23215
23417
|
}
|
|
@@ -23513,7 +23715,7 @@ No loop metadata found for ${loopId}.
|
|
|
23513
23715
|
if (sub === "doctor") {
|
|
23514
23716
|
const issues = [];
|
|
23515
23717
|
const ok = [];
|
|
23516
|
-
if (
|
|
23718
|
+
if (existsSync66(join68(target, ".git"))) {
|
|
23517
23719
|
ok.push("Git repository detected");
|
|
23518
23720
|
} else {
|
|
23519
23721
|
issues.push("Not a git repository \u2014 loop needs git for drift detection");
|
|
@@ -23523,10 +23725,10 @@ No loop metadata found for ${loopId}.
|
|
|
23523
23725
|
} else {
|
|
23524
23726
|
issues.push("Claude Code CLI not found \u2014 install it or ensure `claude` is on PATH");
|
|
23525
23727
|
}
|
|
23526
|
-
const testDir =
|
|
23728
|
+
const testDir = join68(target, ".avorelo", "loops");
|
|
23527
23729
|
try {
|
|
23528
23730
|
mkdirSync41(testDir, { recursive: true });
|
|
23529
|
-
const testFile =
|
|
23731
|
+
const testFile = join68(testDir, ".doctor_probe");
|
|
23530
23732
|
writeFileSync39(testFile, "probe");
|
|
23531
23733
|
unlinkSync5(testFile);
|
|
23532
23734
|
ok.push("Storage writable (.avorelo/loops/)");
|
|
@@ -23569,11 +23771,11 @@ function cmdUninstallAll(args) {
|
|
|
23569
23771
|
const target = arg(args, "--target", process.cwd());
|
|
23570
23772
|
const adapterResult = uninstallAll(target);
|
|
23571
23773
|
const hookResult = uninstall(target);
|
|
23572
|
-
const removed = [...adapterResult.removed, ...hookResult.restored ? [
|
|
23774
|
+
const removed = [...adapterResult.removed, ...hookResult.restored ? [join68(target, ".claude", "settings.json")] : []];
|
|
23573
23775
|
const preserved = adapterResult.preserved;
|
|
23574
|
-
const avoreloDir2 =
|
|
23776
|
+
const avoreloDir2 = join68(target, ".avorelo");
|
|
23575
23777
|
try {
|
|
23576
|
-
if (
|
|
23778
|
+
if (existsSync66(avoreloDir2)) {
|
|
23577
23779
|
rmSync3(avoreloDir2, { recursive: true, force: true });
|
|
23578
23780
|
removed.push(avoreloDir2);
|
|
23579
23781
|
}
|
|
@@ -24166,7 +24368,7 @@ function cmdConfig(args) {
|
|
|
24166
24368
|
function avoreloVersion() {
|
|
24167
24369
|
for (const rel of ["../package.json", "../../package.json", "../../../package.json", "../../../../package.json"]) {
|
|
24168
24370
|
try {
|
|
24169
|
-
const pkg = JSON.parse(readFileSync51(
|
|
24371
|
+
const pkg = JSON.parse(readFileSync51(join68(import.meta.dirname, rel), "utf8"));
|
|
24170
24372
|
if (pkg.name === "avorelo" && pkg.version) return pkg.version;
|
|
24171
24373
|
} catch {
|
|
24172
24374
|
}
|
package/package.json
CHANGED