@event4u/agent-config 14.7.0 → 14.8.0
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/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +245 -388
- package/README.md +1 -1
- package/dist/agent-src/commands/evals/git-pr-merge.json +13 -0
- package/dist/agent-src/commands/evals/roadmap.json +17 -1
- package/dist/agent-src/commands/pr/create.md +14 -2
- package/dist/agent-src/commands/pr/merge.md +379 -0
- package/dist/agent-src/commands/roadmap/process-full.md +157 -3
- package/dist/agent-src/commands/roadmap.md +1 -1
- package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +46 -36
- package/dist/agent-src/contexts/execution/autonomy-mechanics.md +37 -2
- package/dist/agent-src/contexts/execution/roadmap-execution-contract.md +64 -2
- package/dist/agent-src/contexts/execution/roadmap-process-loop.md +154 -2
- package/dist/agent-src/rules/artifact-drafting-protocol.md +5 -1
- package/dist/agent-src/rules/decision-revisit-gate.md +65 -33
- package/dist/agent-src/rules/recurring-criticism.md +1 -1
- package/dist/agent-src/rules/roadmap-progress-sync.md +19 -0
- package/dist/agent-src/rules/source-confidentiality.md +1 -1
- package/dist/agent-src/scripts/archive_completed_roadmaps.ts +7 -4
- package/dist/agent-src/scripts/dashboard_mode.ts +212 -0
- package/dist/agent-src/scripts/update_roadmap_progress.ts +47 -48
- package/dist/agent-src/skills/adr-create/SKILL.md +124 -5
- package/dist/agent-src/skills/decision-record/SKILL.md +61 -3
- package/dist/agent-src/skills/decision-review/SKILL.md +65 -0
- package/dist/agent-src/skills/merge-conflicts/SKILL.md +26 -0
- package/dist/agent-src/skills/security/SKILL.md +8 -0
- package/dist/agent-src/skills/security-audit/SKILL.md +12 -1
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/dist/agent-src/templates/roadmaps.md +20 -2
- package/dist/cli/registry.js +1 -0
- package/dist/cli/registry.js.map +1 -1
- package/dist/cli-delegate/{chunk-JZ4NR2TW.js → chunk-7PRE6ZV2.js} +1 -1
- package/dist/cli-delegate/{chunk-7F3VYSM2.js → chunk-EEJUMCDZ.js} +14 -14
- package/dist/cli-delegate/{chunk-74E3TKWV.js → chunk-H4VIVD4C.js} +5 -5
- package/dist/cli-delegate/chunk-I3EIN2YG.js +36 -0
- package/dist/cli-delegate/{chunk-4VR4ORQ6.js → chunk-LPPWO5CE.js} +4 -3
- package/dist/cli-delegate/{chunk-UEZ7D35A.js → chunk-N7CDDGI3.js} +4 -23
- package/dist/cli-delegate/cmd_adr_effective.js +1162 -0
- package/dist/cli-delegate/cmd_conformance.js +14 -14
- package/dist/cli-delegate/cmd_converge.js +3 -3
- package/dist/cli-delegate/cmd_doctor.js +7 -7
- package/dist/cli-delegate/cmd_export.js +6 -6
- package/dist/cli-delegate/cmd_handoff.js +7 -6
- package/dist/cli-delegate/cmd_memory_get.js +2 -1
- package/dist/cli-delegate/cmd_migrate.js +2 -2
- package/dist/cli-delegate/cmd_preflight.js +5 -5
- package/dist/cli-delegate/cmd_prune.js +6 -6
- package/dist/cli-delegate/cmd_route_audit.js +6 -5
- package/dist/cli-delegate/cmd_route_explain.js +3 -3
- package/dist/cli-delegate/cmd_session_recycle.js +3 -3
- package/dist/cli-delegate/cmd_settings_get.js +3 -3
- package/dist/cli-delegate/cmd_settings_migrate.js +6 -6
- package/dist/cli-delegate/cmd_sync.js +6 -6
- package/dist/cli-delegate/cmd_uninstall.js +6 -6
- package/dist/cli-delegate/cmd_update.js +3 -3
- package/dist/cli-delegate/cmd_upgrade.js +3 -3
- package/dist/cli-delegate/cmd_validate.js +6 -6
- package/dist/cli-delegate/cmd_versions.js +3 -3
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +53 -22
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +3 -3
- package/dist/discovery/dormancy-report.md +1 -1
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +7 -6
- package/dist/discovery/trust-report.md +2 -2
- package/dist/discovery/workspaces.json +6 -5
- package/dist/hooks/dispatch.js +806 -681
- package/dist/install/globalRuleLayers.js +169 -0
- package/dist/install/globalRuleLayers.js.map +1 -0
- package/dist/install/partitionEligibility.js +156 -0
- package/dist/install/partitionEligibility.js.map +1 -1
- package/dist/install/ruleLayerPartition.js +157 -0
- package/dist/install/ruleLayerPartition.js.map +1 -0
- package/dist/mcp/registry-manifest.json +3 -3
- package/dist/mcp/server.json +2 -2
- package/dist/mcp/server.mjs +654 -578
- package/dist/scripts/_lib/prune_empty_dirs.js +85 -0
- package/dist/scripts/_lib/prune_empty_dirs.js.map +1 -0
- package/dist/scripts/condense.js +52 -89
- package/dist/scripts/condense.js.map +1 -1
- package/docs/guidelines/agent-infra/artifact-drafting-protocol-mechanics.md +45 -1
- package/docs/guidelines/agent-infra/false-green.md +47 -1
- package/package.json +1 -1
- package/src/agent-src/scripts/archive_completed_roadmaps.ts +7 -4
- package/src/agent-src/scripts/dashboard_mode.ts +212 -0
- package/src/agent-src/scripts/update_roadmap_progress.ts +47 -48
- package/src/config/ci-local-parity.yml +21 -0
- package/src/config/estate-count-budget.json +275 -2
- package/src/config/evaluator-budgets.json +3 -3
- package/src/config/gate-coverage.yml +220 -12
- package/src/config/gate-violation-baselines.json +73 -63
- package/src/config/gitignore-block.txt +15 -2
- package/src/config/hook-latency-budget.json +5 -0
- package/src/config/rule-stub-ceilings.json +17 -3
- package/src/install/globalRuleLayers.ts +197 -0
- package/src/install/partitionEligibility.ts +177 -0
- package/src/install/ruleLayerPartition.ts +212 -0
- package/src/scripts/_cli/cmd_adr_effective.ts +484 -0
- package/src/scripts/_dispatch.bash +11 -0
- package/src/scripts/_lib/adr_frontmatter.test.ts +365 -0
- package/src/scripts/_lib/adr_frontmatter.ts +459 -0
- package/src/scripts/_lib/envelope_grounding.ts +11 -1
- package/src/scripts/_lib/layer_overlap_notice.ts +11 -2
- package/src/scripts/_lib/prune_empty_dirs.ts +80 -0
- package/src/scripts/adr/evidence_census.ts +899 -0
- package/src/scripts/adr/regenerate_index.ts +12 -32
- package/src/scripts/adr_cite_check.ts +540 -39
- package/src/scripts/audit_adr_coverage.ts +103 -17
- package/src/scripts/bench_hook_latency.ts +204 -0
- package/src/scripts/build_archive_index.ts +34 -0
- package/src/scripts/check_adr_frontmatter.ts +574 -39
- package/src/scripts/check_hook_bundle_content.ts +219 -0
- package/src/scripts/check_new_adr_evidence.ts +529 -0
- package/src/scripts/check_references.ts +18 -0
- package/src/scripts/check_rule_layer_partition.ts +531 -0
- package/src/scripts/check_single_delivery.ts +137 -4
- package/src/scripts/check_standing_rule_delivery.ts +8 -2
- package/src/scripts/condense.ts +61 -91
- package/src/scripts/external_sources_denylist.json +4 -1
- package/src/scripts/hooks/block_unauthorized_git.ts +22 -2
- package/src/scripts/hooks/dispatch_hook.ts +154 -187
- package/src/scripts/hooks/dispatch_issues.ts +38 -19
- package/src/scripts/hooks/fallback_yaml.ts +66 -0
- package/src/scripts/hooks/host_semantics.ts +21 -0
- package/src/scripts/hooks/injection_budget.ts +13 -3
- package/src/scripts/hooks/py_json_dumps.ts +103 -0
- package/src/scripts/hooks/state_io.ts +88 -1
- package/src/scripts/hooks/stdin_failure_policy.ts +96 -0
- package/src/scripts/injection_scan_hook.ts +137 -5
- package/src/scripts/lint_hook_manifest.ts +49 -0
- package/src/scripts/lint_provenance_vocabulary.ts +472 -4
- package/src/scripts/routing_doctor.ts +5 -1
- package/src/scripts/sync_pr_branch.ts +163 -20
- package/dist/cli-delegate/{chunk-PPQO4NGR.js → chunk-6RJA2F5A.js} +3 -3
- package/dist/cli-delegate/{chunk-6EOCNQAM.js → chunk-E4XIZDIB.js} +0 -0
- package/dist/cli-delegate/{chunk-FBKL6JWT.js → chunk-MMSGVZKV.js} +3 -3
- package/dist/cli-delegate/{chunk-GJ5BVHXM.js → chunk-PMEKGDED.js} +3 -3
package/dist/hooks/dispatch.js
CHANGED
|
@@ -6913,14 +6913,14 @@ var require_parser = __commonJS({
|
|
|
6913
6913
|
case "scalar":
|
|
6914
6914
|
case "single-quoted-scalar":
|
|
6915
6915
|
case "double-quoted-scalar": {
|
|
6916
|
-
const
|
|
6916
|
+
const fs88 = this.flowScalar(this.type);
|
|
6917
6917
|
if (atNextItem || it.value) {
|
|
6918
|
-
map.items.push({ start, key:
|
|
6918
|
+
map.items.push({ start, key: fs88, sep: [] });
|
|
6919
6919
|
this.onKeyLine = true;
|
|
6920
6920
|
} else if (it.sep) {
|
|
6921
|
-
this.stack.push(
|
|
6921
|
+
this.stack.push(fs88);
|
|
6922
6922
|
} else {
|
|
6923
|
-
Object.assign(it, { key:
|
|
6923
|
+
Object.assign(it, { key: fs88, sep: [] });
|
|
6924
6924
|
this.onKeyLine = true;
|
|
6925
6925
|
}
|
|
6926
6926
|
return;
|
|
@@ -7048,13 +7048,13 @@ var require_parser = __commonJS({
|
|
|
7048
7048
|
case "scalar":
|
|
7049
7049
|
case "single-quoted-scalar":
|
|
7050
7050
|
case "double-quoted-scalar": {
|
|
7051
|
-
const
|
|
7051
|
+
const fs88 = this.flowScalar(this.type);
|
|
7052
7052
|
if (!it || it.value)
|
|
7053
|
-
fc.items.push({ start: [], key:
|
|
7053
|
+
fc.items.push({ start: [], key: fs88, sep: [] });
|
|
7054
7054
|
else if (it.sep)
|
|
7055
|
-
this.stack.push(
|
|
7055
|
+
this.stack.push(fs88);
|
|
7056
7056
|
else
|
|
7057
|
-
Object.assign(it, { key:
|
|
7057
|
+
Object.assign(it, { key: fs88, sep: [] });
|
|
7058
7058
|
return;
|
|
7059
7059
|
}
|
|
7060
7060
|
case "flow-map-end":
|
|
@@ -7369,7 +7369,7 @@ import { fileURLToPath as fileURLToPath60 } from "node:url";
|
|
|
7369
7369
|
// src/scripts/hooks/dispatch_hook.ts
|
|
7370
7370
|
var import_yaml6 = __toESM(require_dist(), 1);
|
|
7371
7371
|
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
7372
|
-
import
|
|
7372
|
+
import fs87 from "node:fs";
|
|
7373
7373
|
import path89 from "node:path";
|
|
7374
7374
|
import * as tty2 from "node:tty";
|
|
7375
7375
|
import { fileURLToPath as fileURLToPath59, pathToFileURL as pathToFileURL53 } from "node:url";
|
|
@@ -7732,6 +7732,39 @@ function owns_session_state(state, session_id) {
|
|
|
7732
7732
|
if (typeof state !== "object" || state === null || Array.isArray(state)) return false;
|
|
7733
7733
|
return state["session_id"] === session_id;
|
|
7734
7734
|
}
|
|
7735
|
+
function update_text_under_lock(target, transform, options = {}) {
|
|
7736
|
+
if (is_replay_mode()) return "failed";
|
|
7737
|
+
const targetPath = path.resolve(target);
|
|
7738
|
+
const state_dir = path.dirname(targetPath);
|
|
7739
|
+
try {
|
|
7740
|
+
fs.mkdirSync(state_dir, { recursive: true });
|
|
7741
|
+
} catch {
|
|
7742
|
+
return "failed";
|
|
7743
|
+
}
|
|
7744
|
+
const lock_path = _target_lock_path(targetPath);
|
|
7745
|
+
let fd;
|
|
7746
|
+
try {
|
|
7747
|
+
fd = _acquire_lock(lock_path, { blocking: options.blocking ?? true });
|
|
7748
|
+
} catch {
|
|
7749
|
+
return "failed";
|
|
7750
|
+
}
|
|
7751
|
+
if (fd === null) return "failed";
|
|
7752
|
+
try {
|
|
7753
|
+
let loaded = null;
|
|
7754
|
+
try {
|
|
7755
|
+
loaded = fs.readFileSync(targetPath, "utf-8");
|
|
7756
|
+
} catch {
|
|
7757
|
+
}
|
|
7758
|
+
const next = transform(loaded);
|
|
7759
|
+
if (next === null) return "skipped";
|
|
7760
|
+
_publish_text_locked(targetPath, next);
|
|
7761
|
+
return "written";
|
|
7762
|
+
} catch {
|
|
7763
|
+
return "failed";
|
|
7764
|
+
} finally {
|
|
7765
|
+
_release_lock(fd, lock_path);
|
|
7766
|
+
}
|
|
7767
|
+
}
|
|
7735
7768
|
function update_json_under_lock(target, mutate, options = {}) {
|
|
7736
7769
|
if (is_replay_mode()) return "failed";
|
|
7737
7770
|
const targetPath = path.resolve(target);
|
|
@@ -7771,7 +7804,6 @@ function update_json_under_lock(target, mutate, options = {}) {
|
|
|
7771
7804
|
}
|
|
7772
7805
|
|
|
7773
7806
|
// src/scripts/hooks/dispatch_issues.ts
|
|
7774
|
-
import fs2 from "node:fs";
|
|
7775
7807
|
import path2 from "node:path";
|
|
7776
7808
|
var LOG_CAP = 200;
|
|
7777
7809
|
var VALID_ISSUE = /* @__PURE__ */ new Set([
|
|
@@ -7867,23 +7899,21 @@ function log_dispatch_issue(workspace_root, hook, issue, detail, resolution) {
|
|
|
7867
7899
|
resolution: String(resolution)
|
|
7868
7900
|
};
|
|
7869
7901
|
try {
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
existing = fs2.readFileSync(log, "utf-8").split("\n");
|
|
7875
|
-
if (existing.length > 0 && existing[existing.length - 1] === "") {
|
|
7876
|
-
existing.pop();
|
|
7877
|
-
}
|
|
7878
|
-
} catch {
|
|
7879
|
-
existing = [];
|
|
7902
|
+
const outcome = update_text_under_lock(log, (loaded) => {
|
|
7903
|
+
const existing = loaded === null ? [] : loaded.split("\n");
|
|
7904
|
+
if (existing.length > 0 && existing[existing.length - 1] === "") {
|
|
7905
|
+
existing.pop();
|
|
7880
7906
|
}
|
|
7907
|
+
existing.push(_json_dumps_flat(entry));
|
|
7908
|
+
const capped = existing.length > LOG_CAP ? existing.slice(existing.length - LOG_CAP) : existing;
|
|
7909
|
+
return capped.join("\n") + "\n";
|
|
7910
|
+
});
|
|
7911
|
+
if (outcome !== "written") {
|
|
7912
|
+
process.stderr.write(
|
|
7913
|
+
`dispatch_issues: could not append to ${log} (${outcome}) \u2014 the entry was dropped: ${entry.issue} on ${entry.hook}
|
|
7914
|
+
`
|
|
7915
|
+
);
|
|
7881
7916
|
}
|
|
7882
|
-
existing.push(_json_dumps_flat(entry));
|
|
7883
|
-
if (existing.length > LOG_CAP) {
|
|
7884
|
-
existing = existing.slice(existing.length - LOG_CAP);
|
|
7885
|
-
}
|
|
7886
|
-
fs2.writeFileSync(log, existing.join("\n") + "\n", { encoding: "utf-8" });
|
|
7887
7917
|
} catch (exc) {
|
|
7888
7918
|
const msg = exc instanceof Error ? exc.message : String(exc);
|
|
7889
7919
|
process.stderr.write(`dispatch_issues: failed to append to ${log}: ${msg}
|
|
@@ -7895,7 +7925,7 @@ function fix_hint(_workspace_root) {
|
|
|
7895
7925
|
}
|
|
7896
7926
|
|
|
7897
7927
|
// src/scripts/hooks/injection_budget.ts
|
|
7898
|
-
import * as
|
|
7928
|
+
import * as fs2 from "node:fs";
|
|
7899
7929
|
import * as path3 from "node:path";
|
|
7900
7930
|
|
|
7901
7931
|
// src/scripts/hooks/host_semantics.ts
|
|
@@ -7916,6 +7946,10 @@ var CLAUDE_BLOCK_CAPABLE_EVENTS = /* @__PURE__ */ new Set([
|
|
|
7916
7946
|
"user_prompt_submit",
|
|
7917
7947
|
"stop"
|
|
7918
7948
|
]);
|
|
7949
|
+
function isBlockCapable(platform, event) {
|
|
7950
|
+
if (!VERIFIED_PLATFORMS.has(platform)) return false;
|
|
7951
|
+
return CLAUDE_BLOCK_CAPABLE_EVENTS.has(event);
|
|
7952
|
+
}
|
|
7919
7953
|
function _joinReasons(reasons) {
|
|
7920
7954
|
return reasons.map((r) => r.trim()).filter((r) => r.length > 0).join(" \xB7 ");
|
|
7921
7955
|
}
|
|
@@ -8059,17 +8093,17 @@ function turnSpendPath(workspaceRoot2, session) {
|
|
|
8059
8093
|
}
|
|
8060
8094
|
function _pruneTurnSpend(dir) {
|
|
8061
8095
|
try {
|
|
8062
|
-
const entries =
|
|
8096
|
+
const entries = fs2.readdirSync(dir).filter((n) => n.endsWith(".json") || n.endsWith(".tmp")).map((n) => {
|
|
8063
8097
|
const p = path3.join(dir, n);
|
|
8064
8098
|
try {
|
|
8065
|
-
return { p, mtime:
|
|
8099
|
+
return { p, mtime: fs2.statSync(p).mtimeMs };
|
|
8066
8100
|
} catch {
|
|
8067
8101
|
return { p, mtime: 0 };
|
|
8068
8102
|
}
|
|
8069
8103
|
}).sort((a, b) => b.mtime - a.mtime);
|
|
8070
8104
|
for (const stale of entries.slice(TURN_SPEND_MAX_FILES)) {
|
|
8071
8105
|
try {
|
|
8072
|
-
|
|
8106
|
+
fs2.unlinkSync(stale.p);
|
|
8073
8107
|
} catch {
|
|
8074
8108
|
}
|
|
8075
8109
|
}
|
|
@@ -8078,7 +8112,7 @@ function _pruneTurnSpend(dir) {
|
|
|
8078
8112
|
}
|
|
8079
8113
|
function readTurnSpend(workspaceRoot2, session) {
|
|
8080
8114
|
try {
|
|
8081
|
-
const raw =
|
|
8115
|
+
const raw = fs2.readFileSync(turnSpendPath(workspaceRoot2, session), "utf-8");
|
|
8082
8116
|
const parsed = JSON.parse(raw);
|
|
8083
8117
|
if (parsed.session !== session) return 0;
|
|
8084
8118
|
return typeof parsed.bytes === "number" && Number.isFinite(parsed.bytes) && parsed.bytes >= 0 ? parsed.bytes : 0;
|
|
@@ -8093,10 +8127,10 @@ function recordTurnSpend(workspaceRoot2, session, bytes, opts = {}) {
|
|
|
8093
8127
|
try {
|
|
8094
8128
|
const target = turnSpendPath(workspaceRoot2, session);
|
|
8095
8129
|
const dir = path3.dirname(target);
|
|
8096
|
-
|
|
8130
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
8097
8131
|
const tmp = `${target}.${String(process.pid)}.tmp`;
|
|
8098
|
-
|
|
8099
|
-
|
|
8132
|
+
fs2.writeFileSync(tmp, JSON.stringify(entry) + "\n", { encoding: "utf-8" });
|
|
8133
|
+
fs2.renameSync(tmp, target);
|
|
8100
8134
|
_pruneTurnSpend(dir);
|
|
8101
8135
|
} catch {
|
|
8102
8136
|
}
|
|
@@ -8107,7 +8141,7 @@ function _turnStartBound(packageRoot, platform) {
|
|
|
8107
8141
|
["src", "scripts", "hook_manifest.yaml"]
|
|
8108
8142
|
]) {
|
|
8109
8143
|
try {
|
|
8110
|
-
const raw =
|
|
8144
|
+
const raw = fs2.readFileSync(path3.join(packageRoot, ...rel), "utf-8");
|
|
8111
8145
|
if (rel[2] === "hook_manifest.json") {
|
|
8112
8146
|
const parsed = JSON.parse(raw);
|
|
8113
8147
|
const platforms = parsed.manifest?.["platforms"];
|
|
@@ -8134,7 +8168,7 @@ function resolveVolumeCap(ctx) {
|
|
|
8134
8168
|
if (_sessionKey(ctx) === null) return null;
|
|
8135
8169
|
if (!_turnStartBound(ctx.packageRoot, ctx.platform)) return null;
|
|
8136
8170
|
try {
|
|
8137
|
-
const raw =
|
|
8171
|
+
const raw = fs2.readFileSync(
|
|
8138
8172
|
path3.join(ctx.packageRoot, "src", "config", "hook-token-budget.json"),
|
|
8139
8173
|
"utf-8"
|
|
8140
8174
|
);
|
|
@@ -8201,26 +8235,26 @@ function shapeAndRecord(ctx, messages, finalRc) {
|
|
|
8201
8235
|
|
|
8202
8236
|
// src/scripts/chat_history.ts
|
|
8203
8237
|
import { createHash as createHash3 } from "node:crypto";
|
|
8204
|
-
import * as
|
|
8238
|
+
import * as fs13 from "node:fs";
|
|
8205
8239
|
import * as path13 from "node:path";
|
|
8206
8240
|
import { fileURLToPath as fileURLToPath8, pathToFileURL as pathToFileURL5 } from "node:url";
|
|
8207
8241
|
|
|
8208
8242
|
// src/scripts/memory_lookup.ts
|
|
8209
8243
|
var import_yaml2 = __toESM(require_dist(), 1);
|
|
8210
|
-
import * as
|
|
8244
|
+
import * as fs9 from "node:fs";
|
|
8211
8245
|
import * as path10 from "node:path";
|
|
8212
8246
|
import process5 from "node:process";
|
|
8213
8247
|
import { fileURLToPath as fileURLToPath6, pathToFileURL as pathToFileURL4 } from "node:url";
|
|
8214
8248
|
import { createRequire as createRequire2 } from "node:module";
|
|
8215
8249
|
|
|
8216
8250
|
// src/scripts/lint_hidden_unicode.ts
|
|
8217
|
-
import * as
|
|
8251
|
+
import * as fs4 from "node:fs";
|
|
8218
8252
|
import * as path5 from "node:path";
|
|
8219
8253
|
import { spawnSync } from "node:child_process";
|
|
8220
8254
|
import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
|
|
8221
8255
|
|
|
8222
8256
|
// src/scripts/_lib/security_lint.ts
|
|
8223
|
-
import * as
|
|
8257
|
+
import * as fs3 from "node:fs";
|
|
8224
8258
|
import * as path4 from "node:path";
|
|
8225
8259
|
import { fileURLToPath } from "node:url";
|
|
8226
8260
|
var _HERE = path4.dirname(fileURLToPath(import.meta.url));
|
|
@@ -8365,7 +8399,7 @@ function scan_file(filePath) {
|
|
|
8365
8399
|
} else {
|
|
8366
8400
|
rel = filePath.split(path4.sep).join("/");
|
|
8367
8401
|
}
|
|
8368
|
-
const raw =
|
|
8402
|
+
const raw = fs3.readFileSync(filePath, "utf-8");
|
|
8369
8403
|
const lines = _splitlines(raw);
|
|
8370
8404
|
const n = lines.length;
|
|
8371
8405
|
const in_example = new Array(n + 1).fill(false);
|
|
@@ -8420,7 +8454,7 @@ function _rglobSorted(base) {
|
|
|
8420
8454
|
const walk = (dir) => {
|
|
8421
8455
|
let entries;
|
|
8422
8456
|
try {
|
|
8423
|
-
entries =
|
|
8457
|
+
entries = fs3.readdirSync(dir, { withFileTypes: true });
|
|
8424
8458
|
} catch {
|
|
8425
8459
|
return;
|
|
8426
8460
|
}
|
|
@@ -8451,13 +8485,13 @@ function _pathCmp(a, b) {
|
|
|
8451
8485
|
function* iter_corpus(roots = DEFAULT_SCAN_ROOTS, exts = [".md"]) {
|
|
8452
8486
|
for (const root of roots) {
|
|
8453
8487
|
const base = path4.join(ROOT, root);
|
|
8454
|
-
if (!
|
|
8488
|
+
if (!fs3.existsSync(base)) {
|
|
8455
8489
|
continue;
|
|
8456
8490
|
}
|
|
8457
8491
|
for (const p of _rglobSorted(base)) {
|
|
8458
8492
|
let st;
|
|
8459
8493
|
try {
|
|
8460
|
-
st =
|
|
8494
|
+
st = fs3.statSync(p);
|
|
8461
8495
|
} catch {
|
|
8462
8496
|
continue;
|
|
8463
8497
|
}
|
|
@@ -9018,7 +9052,7 @@ function _scanSourceControlBytes(files = null) {
|
|
|
9018
9052
|
if (_BINARY_EXT.has(_extensionOf(rel))) continue;
|
|
9019
9053
|
let data;
|
|
9020
9054
|
try {
|
|
9021
|
-
data =
|
|
9055
|
+
data = fs4.readFileSync(path5.join(ROOT, rel));
|
|
9022
9056
|
} catch {
|
|
9023
9057
|
continue;
|
|
9024
9058
|
}
|
|
@@ -9052,7 +9086,7 @@ function _scanSourceControlBytes(files = null) {
|
|
|
9052
9086
|
return out;
|
|
9053
9087
|
}
|
|
9054
9088
|
function _sanitize(filePath) {
|
|
9055
|
-
const raw =
|
|
9089
|
+
const raw = fs4.readFileSync(filePath, "utf-8");
|
|
9056
9090
|
let cleaned = "";
|
|
9057
9091
|
for (const ch of raw) {
|
|
9058
9092
|
const cp = ch.codePointAt(0);
|
|
@@ -9062,7 +9096,7 @@ function _sanitize(filePath) {
|
|
|
9062
9096
|
}
|
|
9063
9097
|
cleaned = cleaned.normalize("NFKC");
|
|
9064
9098
|
const out = filePath + ".sanitized";
|
|
9065
|
-
|
|
9099
|
+
fs4.writeFileSync(out, cleaned, "utf-8");
|
|
9066
9100
|
return out;
|
|
9067
9101
|
}
|
|
9068
9102
|
function _argError(msg) {
|
|
@@ -9159,8 +9193,8 @@ function _isCliEntry() {
|
|
|
9159
9193
|
return true;
|
|
9160
9194
|
}
|
|
9161
9195
|
try {
|
|
9162
|
-
const here =
|
|
9163
|
-
const argv =
|
|
9196
|
+
const here = fs4.realpathSync(fileURLToPath2(import.meta.url));
|
|
9197
|
+
const argv = fs4.realpathSync(path5.resolve(process.argv[1]));
|
|
9164
9198
|
return here === argv;
|
|
9165
9199
|
} catch {
|
|
9166
9200
|
return false;
|
|
@@ -9338,7 +9372,7 @@ var LexicalIndex = class {
|
|
|
9338
9372
|
};
|
|
9339
9373
|
|
|
9340
9374
|
// src/scripts/_lib/memory_fts_index.ts
|
|
9341
|
-
import * as
|
|
9375
|
+
import * as fs7 from "node:fs";
|
|
9342
9376
|
import * as path8 from "node:path";
|
|
9343
9377
|
|
|
9344
9378
|
// src/scripts/_lib/sqlite_guard.ts
|
|
@@ -9417,14 +9451,14 @@ function stampUserVersion(conn, version) {
|
|
|
9417
9451
|
|
|
9418
9452
|
// src/scripts/memory_report.ts
|
|
9419
9453
|
var import_yaml = __toESM(require_dist(), 1);
|
|
9420
|
-
import * as
|
|
9454
|
+
import * as fs6 from "node:fs";
|
|
9421
9455
|
import * as path7 from "node:path";
|
|
9422
9456
|
import process3 from "node:process";
|
|
9423
9457
|
import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
9424
9458
|
|
|
9425
9459
|
// src/scripts/memory_status.ts
|
|
9426
9460
|
import process2 from "node:process";
|
|
9427
|
-
import * as
|
|
9461
|
+
import * as fs5 from "node:fs";
|
|
9428
9462
|
import * as path6 from "node:path";
|
|
9429
9463
|
import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
9430
9464
|
var CONTRACT_VERSION = 1;
|
|
@@ -9567,8 +9601,8 @@ function _isCliEntry2() {
|
|
|
9567
9601
|
return true;
|
|
9568
9602
|
}
|
|
9569
9603
|
try {
|
|
9570
|
-
const here =
|
|
9571
|
-
const argv =
|
|
9604
|
+
const here = fs5.realpathSync(fileURLToPath3(import.meta.url));
|
|
9605
|
+
const argv = fs5.realpathSync(path6.resolve(process2.argv[1]));
|
|
9572
9606
|
return here === argv;
|
|
9573
9607
|
} catch {
|
|
9574
9608
|
return false;
|
|
@@ -9637,20 +9671,20 @@ function _isPlainObject2(v) {
|
|
|
9637
9671
|
}
|
|
9638
9672
|
function _isFile(p) {
|
|
9639
9673
|
try {
|
|
9640
|
-
return
|
|
9674
|
+
return fs6.statSync(p).isFile();
|
|
9641
9675
|
} catch {
|
|
9642
9676
|
return false;
|
|
9643
9677
|
}
|
|
9644
9678
|
}
|
|
9645
9679
|
function _isDir(p) {
|
|
9646
9680
|
try {
|
|
9647
|
-
return
|
|
9681
|
+
return fs6.statSync(p).isDirectory();
|
|
9648
9682
|
} catch {
|
|
9649
9683
|
return false;
|
|
9650
9684
|
}
|
|
9651
9685
|
}
|
|
9652
9686
|
function _load_yaml(p) {
|
|
9653
|
-
const text =
|
|
9687
|
+
const text = fs6.readFileSync(p, "utf-8");
|
|
9654
9688
|
const doc = (0, import_yaml.parseDocument)(text, { version: "1.1", prettyErrors: false });
|
|
9655
9689
|
if (doc.errors.length > 0) {
|
|
9656
9690
|
const err = doc.errors[0];
|
|
@@ -9746,7 +9780,7 @@ function _rglobYml(root) {
|
|
|
9746
9780
|
const walk = (dir) => {
|
|
9747
9781
|
let entries;
|
|
9748
9782
|
try {
|
|
9749
|
-
entries =
|
|
9783
|
+
entries = fs6.readdirSync(dir, { withFileTypes: true });
|
|
9750
9784
|
} catch {
|
|
9751
9785
|
return;
|
|
9752
9786
|
}
|
|
@@ -9766,7 +9800,7 @@ function _rglobYml(root) {
|
|
|
9766
9800
|
function _globJsonl(root) {
|
|
9767
9801
|
let names;
|
|
9768
9802
|
try {
|
|
9769
|
-
names =
|
|
9803
|
+
names = fs6.readdirSync(root);
|
|
9770
9804
|
} catch {
|
|
9771
9805
|
return [];
|
|
9772
9806
|
}
|
|
@@ -9805,7 +9839,7 @@ function _intake_stats() {
|
|
|
9805
9839
|
function _readJsonl(p) {
|
|
9806
9840
|
let text;
|
|
9807
9841
|
try {
|
|
9808
|
-
text =
|
|
9842
|
+
text = fs6.readFileSync(p, "utf-8");
|
|
9809
9843
|
} catch {
|
|
9810
9844
|
return [];
|
|
9811
9845
|
}
|
|
@@ -9968,7 +10002,7 @@ function _role_mode_stats() {
|
|
|
9968
10002
|
for (const md of _rglobMd(root)) {
|
|
9969
10003
|
let text;
|
|
9970
10004
|
try {
|
|
9971
|
-
text =
|
|
10005
|
+
text = fs6.readFileSync(md, "utf-8");
|
|
9972
10006
|
} catch {
|
|
9973
10007
|
continue;
|
|
9974
10008
|
}
|
|
@@ -9997,7 +10031,7 @@ function _role_mode_stats() {
|
|
|
9997
10031
|
}
|
|
9998
10032
|
function _exists(p) {
|
|
9999
10033
|
try {
|
|
10000
|
-
|
|
10034
|
+
fs6.statSync(p);
|
|
10001
10035
|
return true;
|
|
10002
10036
|
} catch {
|
|
10003
10037
|
return false;
|
|
@@ -10008,7 +10042,7 @@ function _rglobMd(root) {
|
|
|
10008
10042
|
const walk = (dir) => {
|
|
10009
10043
|
let entries;
|
|
10010
10044
|
try {
|
|
10011
|
-
entries =
|
|
10045
|
+
entries = fs6.readdirSync(dir, { withFileTypes: true });
|
|
10012
10046
|
} catch {
|
|
10013
10047
|
return;
|
|
10014
10048
|
}
|
|
@@ -10262,8 +10296,8 @@ function _isCliEntry3() {
|
|
|
10262
10296
|
return true;
|
|
10263
10297
|
}
|
|
10264
10298
|
try {
|
|
10265
|
-
const here =
|
|
10266
|
-
const argv =
|
|
10299
|
+
const here = fs6.realpathSync(fileURLToPath4(import.meta.url));
|
|
10300
|
+
const argv = fs6.realpathSync(path7.resolve(process3.argv[1]));
|
|
10267
10301
|
return here === argv;
|
|
10268
10302
|
} catch {
|
|
10269
10303
|
return false;
|
|
@@ -10319,7 +10353,7 @@ function _collectCurated(memoryRoot) {
|
|
|
10319
10353
|
function _globJsonl2(intakeRoot) {
|
|
10320
10354
|
let names;
|
|
10321
10355
|
try {
|
|
10322
|
-
names =
|
|
10356
|
+
names = fs7.readdirSync(intakeRoot);
|
|
10323
10357
|
} catch {
|
|
10324
10358
|
return [];
|
|
10325
10359
|
}
|
|
@@ -10332,7 +10366,7 @@ function _collectIntake(intakeRoot) {
|
|
|
10332
10366
|
const superseded = /* @__PURE__ */ new Set();
|
|
10333
10367
|
let content;
|
|
10334
10368
|
try {
|
|
10335
|
-
content =
|
|
10369
|
+
content = fs7.readFileSync(jsonl, "utf-8");
|
|
10336
10370
|
} catch {
|
|
10337
10371
|
continue;
|
|
10338
10372
|
}
|
|
@@ -10369,7 +10403,7 @@ function _sourcesMaxMtimeMs(memoryRoot, intakeRoot) {
|
|
|
10369
10403
|
let max = 0;
|
|
10370
10404
|
const bump = (p) => {
|
|
10371
10405
|
try {
|
|
10372
|
-
const st =
|
|
10406
|
+
const st = fs7.statSync(p);
|
|
10373
10407
|
if (st.mtimeMs > max) max = st.mtimeMs;
|
|
10374
10408
|
} catch {
|
|
10375
10409
|
}
|
|
@@ -10377,7 +10411,7 @@ function _sourcesMaxMtimeMs(memoryRoot, intakeRoot) {
|
|
|
10377
10411
|
const walk = (dir) => {
|
|
10378
10412
|
let entries;
|
|
10379
10413
|
try {
|
|
10380
|
-
entries =
|
|
10414
|
+
entries = fs7.readdirSync(dir, { withFileTypes: true });
|
|
10381
10415
|
} catch {
|
|
10382
10416
|
return;
|
|
10383
10417
|
}
|
|
@@ -10389,7 +10423,7 @@ function _sourcesMaxMtimeMs(memoryRoot, intakeRoot) {
|
|
|
10389
10423
|
};
|
|
10390
10424
|
let memEntries;
|
|
10391
10425
|
try {
|
|
10392
|
-
memEntries =
|
|
10426
|
+
memEntries = fs7.readdirSync(memoryRoot, { withFileTypes: true });
|
|
10393
10427
|
for (const e of memEntries) {
|
|
10394
10428
|
const full = path8.join(memoryRoot, e.name);
|
|
10395
10429
|
if (e.isFile() && e.name.endsWith(".yml")) bump(full);
|
|
@@ -10402,7 +10436,7 @@ function _sourcesMaxMtimeMs(memoryRoot, intakeRoot) {
|
|
|
10402
10436
|
}
|
|
10403
10437
|
var META_KEY_SOURCES_MTIME = "sources_mtime_ms";
|
|
10404
10438
|
function isStale(indexPath, memoryRoot, intakeRoot) {
|
|
10405
|
-
if (!
|
|
10439
|
+
if (!fs7.existsSync(indexPath)) return true;
|
|
10406
10440
|
let sqlite;
|
|
10407
10441
|
try {
|
|
10408
10442
|
sqlite = loadSqliteSync("memory_fts_index.isStale");
|
|
@@ -10428,11 +10462,11 @@ function isStale(indexPath, memoryRoot, intakeRoot) {
|
|
|
10428
10462
|
}
|
|
10429
10463
|
}
|
|
10430
10464
|
function buildIndex(indexPath, memoryRoot, intakeRoot) {
|
|
10431
|
-
|
|
10465
|
+
fs7.mkdirSync(path8.dirname(indexPath), { recursive: true });
|
|
10432
10466
|
try {
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
|
|
10467
|
+
fs7.rmSync(indexPath, { force: true });
|
|
10468
|
+
fs7.rmSync(`${indexPath}-wal`, { force: true });
|
|
10469
|
+
fs7.rmSync(`${indexPath}-shm`, { force: true });
|
|
10436
10470
|
} catch {
|
|
10437
10471
|
}
|
|
10438
10472
|
const { DatabaseSync } = loadSqliteSync("memory_fts_index.buildIndex");
|
|
@@ -10517,7 +10551,7 @@ function queryIndex(indexPath, keys, types) {
|
|
|
10517
10551
|
|
|
10518
10552
|
// src/scripts/learning_sidecar.ts
|
|
10519
10553
|
import { createHash as createHash2 } from "node:crypto";
|
|
10520
|
-
import * as
|
|
10554
|
+
import * as fs8 from "node:fs";
|
|
10521
10555
|
import * as path9 from "node:path";
|
|
10522
10556
|
import process4 from "node:process";
|
|
10523
10557
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
@@ -10537,7 +10571,7 @@ function _bodyHash(body) {
|
|
|
10537
10571
|
function _globSignalFiles(dir) {
|
|
10538
10572
|
let names;
|
|
10539
10573
|
try {
|
|
10540
|
-
names =
|
|
10574
|
+
names = fs8.readdirSync(dir);
|
|
10541
10575
|
} catch {
|
|
10542
10576
|
return [];
|
|
10543
10577
|
}
|
|
@@ -10548,7 +10582,7 @@ function readSignals(intakeDir) {
|
|
|
10548
10582
|
for (const file of _globSignalFiles(intakeDir)) {
|
|
10549
10583
|
let content;
|
|
10550
10584
|
try {
|
|
10551
|
-
content =
|
|
10585
|
+
content = fs8.readFileSync(file, "utf-8");
|
|
10552
10586
|
} catch {
|
|
10553
10587
|
continue;
|
|
10554
10588
|
}
|
|
@@ -10708,9 +10742,9 @@ function main4(argv) {
|
|
|
10708
10742
|
return 3;
|
|
10709
10743
|
}
|
|
10710
10744
|
if (write) {
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
|
|
10745
|
+
fs8.mkdirSync(outDir, { recursive: true });
|
|
10746
|
+
fs8.writeFileSync(path9.join(outDir, SIDECAR_NAME), JSON.stringify(sidecar, null, 2) + "\n");
|
|
10747
|
+
fs8.writeFileSync(path9.join(outDir, LESSONS_NAME), renderLessonsMd(sidecar));
|
|
10714
10748
|
}
|
|
10715
10749
|
if (format === "json") {
|
|
10716
10750
|
process4.stdout.write(JSON.stringify(sidecar, null, 2) + "\n");
|
|
@@ -10760,7 +10794,7 @@ function _loadLearningOverlay() {
|
|
|
10760
10794
|
if (_learningOverlay !== void 0) return _learningOverlay;
|
|
10761
10795
|
const file = path10.join(MEMORY_ROOT2, SIDECAR_NAME);
|
|
10762
10796
|
try {
|
|
10763
|
-
const parsed = JSON.parse(
|
|
10797
|
+
const parsed = JSON.parse(fs9.readFileSync(file, "utf-8"));
|
|
10764
10798
|
const lessons = _isPlainObject4(parsed) ? parsed["lessons"] : null;
|
|
10765
10799
|
if (!Array.isArray(lessons)) {
|
|
10766
10800
|
_learningOverlay = null;
|
|
@@ -10838,20 +10872,20 @@ function _isPlainObject4(v) {
|
|
|
10838
10872
|
}
|
|
10839
10873
|
function _isFile2(p) {
|
|
10840
10874
|
try {
|
|
10841
|
-
return
|
|
10875
|
+
return fs9.statSync(p).isFile();
|
|
10842
10876
|
} catch {
|
|
10843
10877
|
return false;
|
|
10844
10878
|
}
|
|
10845
10879
|
}
|
|
10846
10880
|
function _isDir2(p) {
|
|
10847
10881
|
try {
|
|
10848
|
-
return
|
|
10882
|
+
return fs9.statSync(p).isDirectory();
|
|
10849
10883
|
} catch {
|
|
10850
10884
|
return false;
|
|
10851
10885
|
}
|
|
10852
10886
|
}
|
|
10853
10887
|
function _load_yaml2(p) {
|
|
10854
|
-
const text =
|
|
10888
|
+
const text = fs9.readFileSync(p, "utf-8");
|
|
10855
10889
|
const doc = (0, import_yaml2.parseDocument)(text, { version: "1.1", prettyErrors: false });
|
|
10856
10890
|
if (doc.errors.length > 0) {
|
|
10857
10891
|
const err = doc.errors[0];
|
|
@@ -10982,7 +11016,7 @@ function* _iter_intake_entries(mtype) {
|
|
|
10982
11016
|
for (const jsonl of _globJsonlSorted(INTAKE_ROOT2)) {
|
|
10983
11017
|
const by_id = /* @__PURE__ */ new Map();
|
|
10984
11018
|
const superseded = /* @__PURE__ */ new Set();
|
|
10985
|
-
const content =
|
|
11019
|
+
const content = fs9.readFileSync(jsonl, "utf-8");
|
|
10986
11020
|
for (let line of content.split(/\n/)) {
|
|
10987
11021
|
line = line.trim();
|
|
10988
11022
|
if (!line) {
|
|
@@ -11032,7 +11066,7 @@ function* _iter_knowledge_entries() {
|
|
|
11032
11066
|
let manifest = {};
|
|
11033
11067
|
if (_isFile2(manifest_path)) {
|
|
11034
11068
|
try {
|
|
11035
|
-
const parsed = JSON.parse(
|
|
11069
|
+
const parsed = JSON.parse(fs9.readFileSync(manifest_path, "utf-8"));
|
|
11036
11070
|
manifest = _isPlainObject4(parsed) ? parsed : {};
|
|
11037
11071
|
} catch {
|
|
11038
11072
|
manifest = {};
|
|
@@ -11048,7 +11082,7 @@ function* _iter_knowledge_entries() {
|
|
|
11048
11082
|
for (const chunk of _globMdSorted(chunks_dir)) {
|
|
11049
11083
|
let body;
|
|
11050
11084
|
try {
|
|
11051
|
-
body =
|
|
11085
|
+
body = fs9.readFileSync(chunk, "utf-8");
|
|
11052
11086
|
} catch {
|
|
11053
11087
|
continue;
|
|
11054
11088
|
}
|
|
@@ -11194,7 +11228,7 @@ function _entry_tokens_estimate(envelope_entry) {
|
|
|
11194
11228
|
function _countMdFiles(dir) {
|
|
11195
11229
|
let entries;
|
|
11196
11230
|
try {
|
|
11197
|
-
entries =
|
|
11231
|
+
entries = fs9.readdirSync(dir, { withFileTypes: true });
|
|
11198
11232
|
} catch {
|
|
11199
11233
|
return 0;
|
|
11200
11234
|
}
|
|
@@ -11210,7 +11244,7 @@ function _countCorpusFiles() {
|
|
|
11210
11244
|
const perType = /* @__PURE__ */ new Map();
|
|
11211
11245
|
let total = 0;
|
|
11212
11246
|
for (const t of CURATED_TYPES2) {
|
|
11213
|
-
const exists =
|
|
11247
|
+
const exists = fs9.existsSync(path10.join(MEMORY_ROOT2, `${t}.yml`));
|
|
11214
11248
|
const c = exists ? 1 : 0;
|
|
11215
11249
|
perType.set(t, c);
|
|
11216
11250
|
total += c;
|
|
@@ -11219,7 +11253,7 @@ function _countCorpusFiles() {
|
|
|
11219
11253
|
perType.set(KNOWLEDGE_TYPE, kn);
|
|
11220
11254
|
total += kn;
|
|
11221
11255
|
try {
|
|
11222
|
-
for (const e of
|
|
11256
|
+
for (const e of fs9.readdirSync(INTAKE_ROOT2, { withFileTypes: true })) {
|
|
11223
11257
|
if (e.isFile() && e.name.endsWith(".jsonl")) total += 1;
|
|
11224
11258
|
}
|
|
11225
11259
|
} catch {
|
|
@@ -11724,7 +11758,7 @@ function _rglobYmlSorted(root) {
|
|
|
11724
11758
|
const walk = (dir) => {
|
|
11725
11759
|
let entries;
|
|
11726
11760
|
try {
|
|
11727
|
-
entries =
|
|
11761
|
+
entries = fs9.readdirSync(dir, { withFileTypes: true });
|
|
11728
11762
|
} catch {
|
|
11729
11763
|
return;
|
|
11730
11764
|
}
|
|
@@ -11751,7 +11785,7 @@ function _globMdSorted(dir) {
|
|
|
11751
11785
|
function _globSorted(dir, suffix) {
|
|
11752
11786
|
let entries;
|
|
11753
11787
|
try {
|
|
11754
|
-
entries =
|
|
11788
|
+
entries = fs9.readdirSync(dir, { withFileTypes: true });
|
|
11755
11789
|
} catch {
|
|
11756
11790
|
return [];
|
|
11757
11791
|
}
|
|
@@ -11762,7 +11796,7 @@ function _globSorted(dir, suffix) {
|
|
|
11762
11796
|
function _iterdirSorted(dir) {
|
|
11763
11797
|
let names;
|
|
11764
11798
|
try {
|
|
11765
|
-
names =
|
|
11799
|
+
names = fs9.readdirSync(dir);
|
|
11766
11800
|
} catch {
|
|
11767
11801
|
return [];
|
|
11768
11802
|
}
|
|
@@ -11897,8 +11931,8 @@ function _isCliEntry4() {
|
|
|
11897
11931
|
return true;
|
|
11898
11932
|
}
|
|
11899
11933
|
try {
|
|
11900
|
-
const here =
|
|
11901
|
-
const argv =
|
|
11934
|
+
const here = fs9.realpathSync(fileURLToPath6(import.meta.url));
|
|
11935
|
+
const argv = fs9.realpathSync(path10.resolve(process5.argv[1]));
|
|
11902
11936
|
return here === argv;
|
|
11903
11937
|
} catch {
|
|
11904
11938
|
return false;
|
|
@@ -11911,12 +11945,12 @@ if (_isMain3) {
|
|
|
11911
11945
|
|
|
11912
11946
|
// src/scripts/_lib/agent_settings.ts
|
|
11913
11947
|
import { createRequire as createRequire3 } from "node:module";
|
|
11914
|
-
import * as
|
|
11948
|
+
import * as fs11 from "node:fs";
|
|
11915
11949
|
import * as path12 from "node:path";
|
|
11916
11950
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
11917
11951
|
|
|
11918
11952
|
// src/scripts/_lib/user_global_paths.ts
|
|
11919
|
-
import * as
|
|
11953
|
+
import * as fs10 from "node:fs";
|
|
11920
11954
|
import * as os from "node:os";
|
|
11921
11955
|
import * as path11 from "node:path";
|
|
11922
11956
|
var EVENT4U_HOME_ENV = "EVENT4U_CONFIG_HOME";
|
|
@@ -11955,11 +11989,11 @@ function resolve_with_fallback(relative_name, options = {}) {
|
|
|
11955
11989
|
);
|
|
11956
11990
|
}
|
|
11957
11991
|
const new_path = path11.join(event4u_root(options.env ?? null), relative_name);
|
|
11958
|
-
if (
|
|
11992
|
+
if (fs10.existsSync(new_path)) {
|
|
11959
11993
|
return new_path;
|
|
11960
11994
|
}
|
|
11961
11995
|
const legacy_path = path11.join(legacy_xdg_root(), relative_name);
|
|
11962
|
-
if (
|
|
11996
|
+
if (fs10.existsSync(legacy_path)) {
|
|
11963
11997
|
return legacy_path;
|
|
11964
11998
|
}
|
|
11965
11999
|
return null;
|
|
@@ -12177,8 +12211,8 @@ var _AGENTS_DIR_MARKERS = [
|
|
|
12177
12211
|
var _LEGACY_ANCHOR_ENV = "AGENT_CONFIG_LEGACY_ANCHOR";
|
|
12178
12212
|
function _exists2(p) {
|
|
12179
12213
|
try {
|
|
12180
|
-
|
|
12181
|
-
|
|
12214
|
+
fs11.lstatSync(p);
|
|
12215
|
+
fs11.statSync(p);
|
|
12182
12216
|
return true;
|
|
12183
12217
|
} catch {
|
|
12184
12218
|
return false;
|
|
@@ -12186,14 +12220,14 @@ function _exists2(p) {
|
|
|
12186
12220
|
}
|
|
12187
12221
|
function _is_dir(p) {
|
|
12188
12222
|
try {
|
|
12189
|
-
return
|
|
12223
|
+
return fs11.statSync(p).isDirectory();
|
|
12190
12224
|
} catch {
|
|
12191
12225
|
return false;
|
|
12192
12226
|
}
|
|
12193
12227
|
}
|
|
12194
12228
|
function _is_file(p) {
|
|
12195
12229
|
try {
|
|
12196
|
-
return
|
|
12230
|
+
return fs11.statSync(p).isFile();
|
|
12197
12231
|
} catch {
|
|
12198
12232
|
return false;
|
|
12199
12233
|
}
|
|
@@ -12201,7 +12235,7 @@ function _is_file(p) {
|
|
|
12201
12235
|
function _resolve(p) {
|
|
12202
12236
|
const absolute = path12.resolve(p);
|
|
12203
12237
|
try {
|
|
12204
|
-
return
|
|
12238
|
+
return fs11.realpathSync(absolute);
|
|
12205
12239
|
} catch {
|
|
12206
12240
|
return absolute;
|
|
12207
12241
|
}
|
|
@@ -12381,7 +12415,7 @@ function _read_yaml(p) {
|
|
|
12381
12415
|
}
|
|
12382
12416
|
let data;
|
|
12383
12417
|
try {
|
|
12384
|
-
const text =
|
|
12418
|
+
const text = fs11.readFileSync(p, "utf-8");
|
|
12385
12419
|
data = YAML4.parse(text, { version: "1.1" });
|
|
12386
12420
|
if (data === null || data === void 0) {
|
|
12387
12421
|
data = {};
|
|
@@ -12484,7 +12518,7 @@ function _is_plain_dict(value) {
|
|
|
12484
12518
|
import * as tty from "node:tty";
|
|
12485
12519
|
|
|
12486
12520
|
// src/scripts/_lib/stdin.ts
|
|
12487
|
-
import * as
|
|
12521
|
+
import * as fs12 from "node:fs";
|
|
12488
12522
|
var CHUNK = 64 * 1024;
|
|
12489
12523
|
var RETRY_SLEEP_MS = 5;
|
|
12490
12524
|
var MAX_RETRIES = 2e3;
|
|
@@ -12500,7 +12534,7 @@ function readStdinText(fd = 0, opts = {}) {
|
|
|
12500
12534
|
for (; ; ) {
|
|
12501
12535
|
let read;
|
|
12502
12536
|
try {
|
|
12503
|
-
read =
|
|
12537
|
+
read = fs12.readSync(fd, buf, 0, CHUNK, null);
|
|
12504
12538
|
retries = 0;
|
|
12505
12539
|
} catch (exc) {
|
|
12506
12540
|
const code = exc.code;
|
|
@@ -12777,14 +12811,14 @@ function derive_session_tag(session_id) {
|
|
|
12777
12811
|
}
|
|
12778
12812
|
function _isFile3(p) {
|
|
12779
12813
|
try {
|
|
12780
|
-
return
|
|
12814
|
+
return fs13.statSync(p).isFile();
|
|
12781
12815
|
} catch {
|
|
12782
12816
|
return false;
|
|
12783
12817
|
}
|
|
12784
12818
|
}
|
|
12785
12819
|
function _statSize(p) {
|
|
12786
12820
|
try {
|
|
12787
|
-
return
|
|
12821
|
+
return fs13.statSync(p).size;
|
|
12788
12822
|
} catch {
|
|
12789
12823
|
return -1;
|
|
12790
12824
|
}
|
|
@@ -12835,7 +12869,7 @@ function _session_tag_enabled() {
|
|
|
12835
12869
|
return (process.env.AGENT_CHAT_HISTORY_SESSION_TAG ?? "true").trim().toLowerCase() !== "false";
|
|
12836
12870
|
}
|
|
12837
12871
|
function _readLines(p) {
|
|
12838
|
-
const raw =
|
|
12872
|
+
const raw = fs13.readFileSync(p, "utf-8");
|
|
12839
12873
|
if (raw === "") {
|
|
12840
12874
|
return [];
|
|
12841
12875
|
}
|
|
@@ -12881,7 +12915,7 @@ function read_header(p) {
|
|
|
12881
12915
|
}
|
|
12882
12916
|
let first;
|
|
12883
12917
|
try {
|
|
12884
|
-
const raw =
|
|
12918
|
+
const raw = fs13.readFileSync(target, "utf-8");
|
|
12885
12919
|
first = _strip(raw.split("\n", 1)[0] ?? "");
|
|
12886
12920
|
} catch {
|
|
12887
12921
|
return null;
|
|
@@ -12911,8 +12945,8 @@ function init(freq = "per_phase", options = {}) {
|
|
|
12911
12945
|
if (_is_replay_mode()) {
|
|
12912
12946
|
return header;
|
|
12913
12947
|
}
|
|
12914
|
-
|
|
12915
|
-
|
|
12948
|
+
fs13.mkdirSync(path13.dirname(target), { recursive: true });
|
|
12949
|
+
fs13.writeFileSync(target, _pyDumps(header) + "\n", { encoding: "utf-8" });
|
|
12916
12950
|
return header;
|
|
12917
12951
|
}
|
|
12918
12952
|
function migrate_header(p, options = {}) {
|
|
@@ -12938,7 +12972,7 @@ function migrate_header(p, options = {}) {
|
|
|
12938
12972
|
if (typeof existing.started === "string") {
|
|
12939
12973
|
new_header.started = existing.started;
|
|
12940
12974
|
}
|
|
12941
|
-
const raw =
|
|
12975
|
+
const raw = fs13.readFileSync(target, "utf-8");
|
|
12942
12976
|
const lines = _pySplitlines(raw);
|
|
12943
12977
|
if (lines.length === 0) {
|
|
12944
12978
|
return null;
|
|
@@ -12993,7 +13027,7 @@ function append(entry, options = {}) {
|
|
|
12993
13027
|
if (_is_replay_mode()) {
|
|
12994
13028
|
return;
|
|
12995
13029
|
}
|
|
12996
|
-
|
|
13030
|
+
fs13.appendFileSync(target, _pyDumps(entry) + "\n", { encoding: "utf-8" });
|
|
12997
13031
|
}
|
|
12998
13032
|
function _atomic_write_text2(target, text) {
|
|
12999
13033
|
if (_is_replay_mode()) {
|
|
@@ -13003,11 +13037,11 @@ function _atomic_write_text2(target, text) {
|
|
|
13003
13037
|
const uniq = `${process.pid}.${createHash3("sha256").update(`${process.pid}:${Date.now()}:${Math.random()}`).digest("hex").slice(0, 8)}`;
|
|
13004
13038
|
const tmp = target.slice(0, target.length - suffix.length) + `${suffix}.${uniq}.tmp`;
|
|
13005
13039
|
try {
|
|
13006
|
-
|
|
13007
|
-
|
|
13040
|
+
fs13.writeFileSync(tmp, text, { encoding: "utf-8" });
|
|
13041
|
+
fs13.renameSync(tmp, target);
|
|
13008
13042
|
} catch (exc) {
|
|
13009
13043
|
try {
|
|
13010
|
-
|
|
13044
|
+
fs13.unlinkSync(tmp);
|
|
13011
13045
|
} catch {
|
|
13012
13046
|
}
|
|
13013
13047
|
throw exc;
|
|
@@ -13037,7 +13071,7 @@ function reset_with_entries(entries, freq = "per_phase", options = {}) {
|
|
|
13037
13071
|
const target = options.path ?? file_path();
|
|
13038
13072
|
const header = _build_header(freq);
|
|
13039
13073
|
const body = _normalize_entries(entries);
|
|
13040
|
-
|
|
13074
|
+
fs13.mkdirSync(path13.dirname(target), { recursive: true });
|
|
13041
13075
|
const lines = [_pyDumps(header), ...body.map((e) => _pyDumps(e))];
|
|
13042
13076
|
_atomic_write_text2(target, lines.join("\n") + "\n");
|
|
13043
13077
|
return header;
|
|
@@ -13058,7 +13092,7 @@ function prepend_entries(entries, options = {}) {
|
|
|
13058
13092
|
return new_lines.length;
|
|
13059
13093
|
}
|
|
13060
13094
|
function _readLinesKeepNewline(p) {
|
|
13061
|
-
const raw =
|
|
13095
|
+
const raw = fs13.readFileSync(p, "utf-8");
|
|
13062
13096
|
if (raw === "") {
|
|
13063
13097
|
return [];
|
|
13064
13098
|
}
|
|
@@ -13080,8 +13114,8 @@ function clear(options = {}) {
|
|
|
13080
13114
|
return;
|
|
13081
13115
|
}
|
|
13082
13116
|
const target = options.path ?? file_path();
|
|
13083
|
-
if (
|
|
13084
|
-
|
|
13117
|
+
if (fs13.existsSync(target)) {
|
|
13118
|
+
fs13.unlinkSync(target);
|
|
13085
13119
|
}
|
|
13086
13120
|
}
|
|
13087
13121
|
function read_entries(options = {}) {
|
|
@@ -14538,8 +14572,8 @@ function _isCliEntry5() {
|
|
|
14538
14572
|
return true;
|
|
14539
14573
|
}
|
|
14540
14574
|
try {
|
|
14541
|
-
const here =
|
|
14542
|
-
const argv =
|
|
14575
|
+
const here = fs13.realpathSync(fileURLToPath8(import.meta.url));
|
|
14576
|
+
const argv = fs13.realpathSync(path13.resolve(process.argv[1]));
|
|
14543
14577
|
return here === argv;
|
|
14544
14578
|
} catch {
|
|
14545
14579
|
return false;
|
|
@@ -14562,7 +14596,7 @@ if (_invokedDirectly) {
|
|
|
14562
14596
|
|
|
14563
14597
|
// src/scripts/hot_context_hook.ts
|
|
14564
14598
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
14565
|
-
import * as
|
|
14599
|
+
import * as fs18 from "node:fs";
|
|
14566
14600
|
import { createRequire as createRequire4 } from "node:module";
|
|
14567
14601
|
import * as path18 from "node:path";
|
|
14568
14602
|
import process6 from "node:process";
|
|
@@ -14570,12 +14604,12 @@ import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
|
14570
14604
|
|
|
14571
14605
|
// src/scripts/ai_council/config.ts
|
|
14572
14606
|
var import_yaml3 = __toESM(require_dist(), 1);
|
|
14573
|
-
import * as
|
|
14607
|
+
import * as fs17 from "node:fs";
|
|
14574
14608
|
import * as os3 from "node:os";
|
|
14575
14609
|
import * as path17 from "node:path";
|
|
14576
14610
|
|
|
14577
14611
|
// src/scripts/ai_council/cli_call_budget.ts
|
|
14578
|
-
import * as
|
|
14612
|
+
import * as fs14 from "node:fs";
|
|
14579
14613
|
import * as path14 from "node:path";
|
|
14580
14614
|
var CLI_CALLS_ATTRIBUTION_SUFFIX = ".attribution.json";
|
|
14581
14615
|
var CLI_CONSUMER_UNKNOWN = "unknown";
|
|
@@ -14606,14 +14640,14 @@ function resolveCliCallCaps(raw, validProviders) {
|
|
|
14606
14640
|
return out;
|
|
14607
14641
|
}
|
|
14608
14642
|
function writeStateAtomically(target, payload) {
|
|
14609
|
-
|
|
14643
|
+
fs14.mkdirSync(path14.dirname(target), { recursive: true });
|
|
14610
14644
|
const tmp = `${target}.${process.pid}.${_monotonicish()}.tmp`;
|
|
14611
14645
|
try {
|
|
14612
|
-
|
|
14613
|
-
|
|
14646
|
+
fs14.writeFileSync(tmp, payload, { encoding: "utf-8" });
|
|
14647
|
+
fs14.renameSync(tmp, target);
|
|
14614
14648
|
} catch (exc) {
|
|
14615
14649
|
try {
|
|
14616
|
-
|
|
14650
|
+
fs14.unlinkSync(tmp);
|
|
14617
14651
|
} catch {
|
|
14618
14652
|
}
|
|
14619
14653
|
throw exc;
|
|
@@ -14626,14 +14660,14 @@ function withStateLock(target, fn) {
|
|
|
14626
14660
|
const started = _monotonicish();
|
|
14627
14661
|
while (_monotonicish() - started < waitMs) {
|
|
14628
14662
|
try {
|
|
14629
|
-
|
|
14630
|
-
|
|
14663
|
+
fs14.mkdirSync(path14.dirname(lockPath), { recursive: true });
|
|
14664
|
+
fs14.closeSync(fs14.openSync(lockPath, "wx"));
|
|
14631
14665
|
held = true;
|
|
14632
14666
|
break;
|
|
14633
14667
|
} catch {
|
|
14634
14668
|
try {
|
|
14635
|
-
if (_monotonicish() -
|
|
14636
|
-
|
|
14669
|
+
if (_monotonicish() - fs14.statSync(lockPath).mtimeMs > waitMs) {
|
|
14670
|
+
fs14.unlinkSync(lockPath);
|
|
14637
14671
|
continue;
|
|
14638
14672
|
}
|
|
14639
14673
|
} catch {
|
|
@@ -14646,7 +14680,7 @@ function withStateLock(target, fn) {
|
|
|
14646
14680
|
} finally {
|
|
14647
14681
|
if (held) {
|
|
14648
14682
|
try {
|
|
14649
|
-
|
|
14683
|
+
fs14.unlinkSync(lockPath);
|
|
14650
14684
|
} catch {
|
|
14651
14685
|
}
|
|
14652
14686
|
}
|
|
@@ -14654,12 +14688,12 @@ function withStateLock(target, fn) {
|
|
|
14654
14688
|
}
|
|
14655
14689
|
function readAttribution(target, todayIso) {
|
|
14656
14690
|
const p = attributionPath(target);
|
|
14657
|
-
if (!
|
|
14691
|
+
if (!fs14.existsSync(p)) {
|
|
14658
14692
|
return {};
|
|
14659
14693
|
}
|
|
14660
14694
|
let data;
|
|
14661
14695
|
try {
|
|
14662
|
-
data = JSON.parse(
|
|
14696
|
+
data = JSON.parse(fs14.readFileSync(p, { encoding: "utf-8" }));
|
|
14663
14697
|
} catch {
|
|
14664
14698
|
return {};
|
|
14665
14699
|
}
|
|
@@ -14709,7 +14743,7 @@ function _spin(ms) {
|
|
|
14709
14743
|
|
|
14710
14744
|
// src/scripts/ai_council/clients.ts
|
|
14711
14745
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
14712
|
-
import * as
|
|
14746
|
+
import * as fs16 from "node:fs";
|
|
14713
14747
|
import * as os2 from "node:os";
|
|
14714
14748
|
import * as path16 from "node:path";
|
|
14715
14749
|
|
|
@@ -14809,7 +14843,7 @@ function _pyJsonStringAscii(s) {
|
|
|
14809
14843
|
|
|
14810
14844
|
// src/scripts/ai_council/events_log.ts
|
|
14811
14845
|
import * as crypto from "node:crypto";
|
|
14812
|
-
import * as
|
|
14846
|
+
import * as fs15 from "node:fs";
|
|
14813
14847
|
import * as path15 from "node:path";
|
|
14814
14848
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
14815
14849
|
|
|
@@ -14939,9 +14973,9 @@ function appendEvent(event, opts = {}) {
|
|
|
14939
14973
|
}
|
|
14940
14974
|
}
|
|
14941
14975
|
const target = opts.logPath != null ? opts.logPath : _DEFAULT_LOG_PATH;
|
|
14942
|
-
|
|
14976
|
+
fs15.mkdirSync(path15.dirname(target), { recursive: true });
|
|
14943
14977
|
const line = _pyJsonDumpsCompact(record);
|
|
14944
|
-
|
|
14978
|
+
fs15.appendFileSync(target, line + "\n", { encoding: "utf-8" });
|
|
14945
14979
|
return true;
|
|
14946
14980
|
}
|
|
14947
14981
|
function _isoSecondsZ(d) {
|
|
@@ -15154,12 +15188,12 @@ function _today_utc_iso() {
|
|
|
15154
15188
|
}
|
|
15155
15189
|
function load_cli_call_counts(p = null) {
|
|
15156
15190
|
const target = p !== null ? p : _cliCallsStatePath();
|
|
15157
|
-
if (!
|
|
15191
|
+
if (!fs16.existsSync(target)) {
|
|
15158
15192
|
return {};
|
|
15159
15193
|
}
|
|
15160
15194
|
let data;
|
|
15161
15195
|
try {
|
|
15162
|
-
data = JSON.parse(
|
|
15196
|
+
data = JSON.parse(fs16.readFileSync(target, { encoding: "utf-8" }));
|
|
15163
15197
|
} catch {
|
|
15164
15198
|
return {};
|
|
15165
15199
|
}
|
|
@@ -16118,7 +16152,7 @@ function _which(name) {
|
|
|
16118
16152
|
}
|
|
16119
16153
|
function _isExecutable(p) {
|
|
16120
16154
|
try {
|
|
16121
|
-
const st =
|
|
16155
|
+
const st = fs16.statSync(p);
|
|
16122
16156
|
if (!st.isFile()) {
|
|
16123
16157
|
return false;
|
|
16124
16158
|
}
|
|
@@ -16407,14 +16441,14 @@ function resolve_config_path(project_root, options = {}) {
|
|
|
16407
16441
|
});
|
|
16408
16442
|
}
|
|
16409
16443
|
function load_council_config(p) {
|
|
16410
|
-
if (!
|
|
16444
|
+
if (!fs17.existsSync(p)) {
|
|
16411
16445
|
throw new CouncilConfigError(
|
|
16412
16446
|
`Council config not found at ${p}. Create it per docs/contracts/ai-council-config.md.`
|
|
16413
16447
|
);
|
|
16414
16448
|
}
|
|
16415
16449
|
let raw;
|
|
16416
16450
|
try {
|
|
16417
|
-
const text =
|
|
16451
|
+
const text = fs17.readFileSync(p, "utf-8");
|
|
16418
16452
|
const parsed = (0, import_yaml3.parse)(text, { version: "1.1" });
|
|
16419
16453
|
raw = parsed === null || parsed === void 0 ? {} : parsed;
|
|
16420
16454
|
} catch (exc) {
|
|
@@ -17653,7 +17687,7 @@ function _current_branch(root) {
|
|
|
17653
17687
|
function _read_history(root) {
|
|
17654
17688
|
let text;
|
|
17655
17689
|
try {
|
|
17656
|
-
text =
|
|
17690
|
+
text = fs18.readFileSync(_history_path(root), "utf-8");
|
|
17657
17691
|
} catch {
|
|
17658
17692
|
return [];
|
|
17659
17693
|
}
|
|
@@ -17766,22 +17800,22 @@ function build_hot_context(root, now = /* @__PURE__ */ new Date()) {
|
|
|
17766
17800
|
function _write_hot_context(root) {
|
|
17767
17801
|
const target = _hot_context_path(root);
|
|
17768
17802
|
const text = build_hot_context(root);
|
|
17769
|
-
|
|
17803
|
+
fs18.mkdirSync(path18.dirname(target), { recursive: true });
|
|
17770
17804
|
const tmp = `${target}.tmp-${process6.pid}`;
|
|
17771
|
-
|
|
17772
|
-
|
|
17805
|
+
fs18.writeFileSync(tmp, text, { encoding: "utf-8" });
|
|
17806
|
+
fs18.renameSync(tmp, target);
|
|
17773
17807
|
}
|
|
17774
17808
|
function restore_hot_context(root, source, now = /* @__PURE__ */ new Date()) {
|
|
17775
17809
|
const target = _hot_context_path(root);
|
|
17776
17810
|
let text;
|
|
17777
17811
|
try {
|
|
17778
|
-
text =
|
|
17812
|
+
text = fs18.readFileSync(target, "utf-8");
|
|
17779
17813
|
} catch {
|
|
17780
17814
|
return { action: "absent", reason: "no cache file" };
|
|
17781
17815
|
}
|
|
17782
17816
|
const discard = (reason) => {
|
|
17783
17817
|
try {
|
|
17784
|
-
|
|
17818
|
+
fs18.unlinkSync(target);
|
|
17785
17819
|
} catch {
|
|
17786
17820
|
}
|
|
17787
17821
|
return { action: "discard", reason };
|
|
@@ -17890,17 +17924,17 @@ if (!_bundled2 && fileURLToPath10(import.meta.url) === path18.resolve(process6.a
|
|
|
17890
17924
|
}
|
|
17891
17925
|
|
|
17892
17926
|
// src/scripts/handoff_context_hook.ts
|
|
17893
|
-
import * as
|
|
17927
|
+
import * as fs22 from "node:fs";
|
|
17894
17928
|
import * as path22 from "node:path";
|
|
17895
17929
|
import process7 from "node:process";
|
|
17896
17930
|
import { fileURLToPath as fileURLToPath12 } from "node:url";
|
|
17897
17931
|
|
|
17898
17932
|
// src/scripts/_lib/envelope_grounding.ts
|
|
17899
17933
|
import { execFileSync } from "node:child_process";
|
|
17900
|
-
import * as
|
|
17934
|
+
import * as fs21 from "node:fs";
|
|
17901
17935
|
|
|
17902
17936
|
// src/scripts/before_complete_hook.ts
|
|
17903
|
-
import
|
|
17937
|
+
import fs19 from "node:fs";
|
|
17904
17938
|
import path19 from "node:path";
|
|
17905
17939
|
import { fileURLToPath as fileURLToPath11, pathToFileURL as pathToFileURL6 } from "node:url";
|
|
17906
17940
|
var STATE_FILE = path19.join("agents", "state", "verify-before-complete.json");
|
|
@@ -18211,8 +18245,8 @@ function _isCliEntry6() {
|
|
|
18211
18245
|
return true;
|
|
18212
18246
|
}
|
|
18213
18247
|
try {
|
|
18214
|
-
const here =
|
|
18215
|
-
const argv =
|
|
18248
|
+
const here = fs19.realpathSync(fileURLToPath11(import.meta.url));
|
|
18249
|
+
const argv = fs19.realpathSync(path19.resolve(process.argv[1]));
|
|
18216
18250
|
return here === argv;
|
|
18217
18251
|
} catch {
|
|
18218
18252
|
return false;
|
|
@@ -18224,11 +18258,11 @@ if (isCliEntry) {
|
|
|
18224
18258
|
}
|
|
18225
18259
|
|
|
18226
18260
|
// src/scripts/_lib/git_common_dir.ts
|
|
18227
|
-
import
|
|
18261
|
+
import fs20 from "node:fs";
|
|
18228
18262
|
import path20 from "node:path";
|
|
18229
18263
|
function realpath_or_self(p) {
|
|
18230
18264
|
try {
|
|
18231
|
-
return
|
|
18265
|
+
return fs20.realpathSync(p);
|
|
18232
18266
|
} catch {
|
|
18233
18267
|
return p;
|
|
18234
18268
|
}
|
|
@@ -18236,11 +18270,11 @@ function realpath_or_self(p) {
|
|
|
18236
18270
|
function git_dir(project_root) {
|
|
18237
18271
|
const dot_git = path20.join(project_root, ".git");
|
|
18238
18272
|
try {
|
|
18239
|
-
const st =
|
|
18273
|
+
const st = fs20.statSync(dot_git);
|
|
18240
18274
|
if (st.isDirectory()) {
|
|
18241
18275
|
return realpath_or_self(dot_git);
|
|
18242
18276
|
}
|
|
18243
|
-
const m =
|
|
18277
|
+
const m = fs20.readFileSync(dot_git, "utf-8").match(/^gitdir:\s*(.+)\s*$/m);
|
|
18244
18278
|
if (m === null) {
|
|
18245
18279
|
return null;
|
|
18246
18280
|
}
|
|
@@ -18253,7 +18287,7 @@ function current_branch(project_root) {
|
|
|
18253
18287
|
const gd = git_dir(project_root);
|
|
18254
18288
|
if (gd === null) return null;
|
|
18255
18289
|
try {
|
|
18256
|
-
const head =
|
|
18290
|
+
const head = fs20.readFileSync(path20.join(gd, "HEAD"), "utf-8").trim();
|
|
18257
18291
|
const m = head.match(/^ref:\s*refs\/heads\/(.+)$/);
|
|
18258
18292
|
return m === null ? null : m[1].trim();
|
|
18259
18293
|
} catch {
|
|
@@ -18263,18 +18297,18 @@ function current_branch(project_root) {
|
|
|
18263
18297
|
function git_common_dir(project_root) {
|
|
18264
18298
|
const dot_git = path20.join(project_root, ".git");
|
|
18265
18299
|
try {
|
|
18266
|
-
const st =
|
|
18300
|
+
const st = fs20.statSync(dot_git);
|
|
18267
18301
|
if (st.isDirectory()) {
|
|
18268
18302
|
return realpath_or_self(dot_git);
|
|
18269
18303
|
}
|
|
18270
|
-
const m =
|
|
18304
|
+
const m = fs20.readFileSync(dot_git, "utf-8").match(/^gitdir:\s*(.+)\s*$/m);
|
|
18271
18305
|
if (m === null) {
|
|
18272
18306
|
return null;
|
|
18273
18307
|
}
|
|
18274
18308
|
const gitdir = path20.resolve(project_root, m[1].trim());
|
|
18275
18309
|
const commondir_file = path20.join(gitdir, "commondir");
|
|
18276
|
-
if (
|
|
18277
|
-
const common = path20.resolve(gitdir,
|
|
18310
|
+
if (fs20.existsSync(commondir_file)) {
|
|
18311
|
+
const common = path20.resolve(gitdir, fs20.readFileSync(commondir_file, "utf-8").trim());
|
|
18278
18312
|
return realpath_or_self(common);
|
|
18279
18313
|
}
|
|
18280
18314
|
return realpath_or_self(gitdir);
|
|
@@ -18340,7 +18374,7 @@ function collectRepoAnchor(root) {
|
|
|
18340
18374
|
const common = git_common_dir(root);
|
|
18341
18375
|
if (common !== null) {
|
|
18342
18376
|
try {
|
|
18343
|
-
identity =
|
|
18377
|
+
identity = fs21.realpathSync(common);
|
|
18344
18378
|
} catch {
|
|
18345
18379
|
identity = common;
|
|
18346
18380
|
}
|
|
@@ -18880,13 +18914,13 @@ function consume_handoff_context(root, now = /* @__PURE__ */ new Date()) {
|
|
|
18880
18914
|
const target = _handoff_context_path(root);
|
|
18881
18915
|
let text;
|
|
18882
18916
|
try {
|
|
18883
|
-
text =
|
|
18917
|
+
text = fs22.readFileSync(target, "utf-8");
|
|
18884
18918
|
} catch {
|
|
18885
18919
|
return { action: "absent", reason: "no handoff file" };
|
|
18886
18920
|
}
|
|
18887
18921
|
const remove = () => {
|
|
18888
18922
|
try {
|
|
18889
|
-
|
|
18923
|
+
fs22.unlinkSync(target);
|
|
18890
18924
|
} catch {
|
|
18891
18925
|
}
|
|
18892
18926
|
};
|
|
@@ -18917,16 +18951,16 @@ function consume_recycle_envelope(root, now = /* @__PURE__ */ new Date()) {
|
|
|
18917
18951
|
const target = process7.env.AGENT_RECYCLE_ENVELOPE_FILE || path22.join(root, RECYCLE_ENVELOPE_REL);
|
|
18918
18952
|
let text;
|
|
18919
18953
|
try {
|
|
18920
|
-
text =
|
|
18954
|
+
text = fs22.readFileSync(target, "utf-8");
|
|
18921
18955
|
} catch {
|
|
18922
18956
|
return { action: "absent", reason: "no recycle envelope" };
|
|
18923
18957
|
}
|
|
18924
18958
|
const consume = () => {
|
|
18925
18959
|
try {
|
|
18926
|
-
|
|
18960
|
+
fs22.renameSync(target, path22.join(path22.dirname(target), path22.basename(RECYCLE_CONSUMED_REL)));
|
|
18927
18961
|
} catch {
|
|
18928
18962
|
try {
|
|
18929
|
-
|
|
18963
|
+
fs22.unlinkSync(target);
|
|
18930
18964
|
} catch {
|
|
18931
18965
|
}
|
|
18932
18966
|
}
|
|
@@ -18953,8 +18987,8 @@ function consume_recycle_envelope(root, now = /* @__PURE__ */ new Date()) {
|
|
|
18953
18987
|
return { action: "discard", reason: `recycle envelope stale: ${ageHours.toFixed(1)}h > ${RECYCLE_MAX_AGE_HOURS}h` };
|
|
18954
18988
|
}
|
|
18955
18989
|
try {
|
|
18956
|
-
const envelopeWs =
|
|
18957
|
-
const thisWs =
|
|
18990
|
+
const envelopeWs = fs22.realpathSync(String(envelope["workspace"]));
|
|
18991
|
+
const thisWs = fs22.realpathSync(root);
|
|
18958
18992
|
if (envelopeWs !== thisWs) {
|
|
18959
18993
|
consume();
|
|
18960
18994
|
return { action: "discard", reason: `recycle envelope belongs to ${envelopeWs}, not ${thisWs}` };
|
|
@@ -19037,7 +19071,7 @@ if (!_bundled3 && fileURLToPath12(import.meta.url) === path22.resolve(process7.a
|
|
|
19037
19071
|
// src/scripts/roadmap_progress_hook.ts
|
|
19038
19072
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
19039
19073
|
import * as crypto2 from "node:crypto";
|
|
19040
|
-
import
|
|
19074
|
+
import fs23 from "node:fs";
|
|
19041
19075
|
import path23 from "node:path";
|
|
19042
19076
|
import { fileURLToPath as fileURLToPath13, pathToFileURL as pathToFileURL7 } from "node:url";
|
|
19043
19077
|
var REPLAY_ENV_VAR5 = "AGENT_CONFIG_REPLAY";
|
|
@@ -19076,7 +19110,7 @@ function _entry_path(consumer_root, root) {
|
|
|
19076
19110
|
function read_dirty_roots(consumer_root) {
|
|
19077
19111
|
let names;
|
|
19078
19112
|
try {
|
|
19079
|
-
names =
|
|
19113
|
+
names = fs23.readdirSync(_ledger_dir(consumer_root));
|
|
19080
19114
|
} catch {
|
|
19081
19115
|
return [];
|
|
19082
19116
|
}
|
|
@@ -19084,7 +19118,7 @@ function read_dirty_roots(consumer_root) {
|
|
|
19084
19118
|
for (const name of names.sort()) {
|
|
19085
19119
|
if (!name.endsWith(".json")) continue;
|
|
19086
19120
|
try {
|
|
19087
|
-
const raw =
|
|
19121
|
+
const raw = fs23.readFileSync(path23.join(_ledger_dir(consumer_root), name), "utf8");
|
|
19088
19122
|
const parsed = JSON.parse(raw);
|
|
19089
19123
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) continue;
|
|
19090
19124
|
const root = parsed.root;
|
|
@@ -19111,7 +19145,7 @@ function mark_dirty(consumer_root, roots) {
|
|
|
19111
19145
|
}
|
|
19112
19146
|
function clear_dirty(consumer_root) {
|
|
19113
19147
|
try {
|
|
19114
|
-
|
|
19148
|
+
fs23.rmSync(_ledger_dir(consumer_root), { recursive: true, force: true });
|
|
19115
19149
|
} catch {
|
|
19116
19150
|
}
|
|
19117
19151
|
}
|
|
@@ -19233,7 +19267,7 @@ function _resolve_regenerator(consumer_root) {
|
|
|
19233
19267
|
var _module = { _package_roots };
|
|
19234
19268
|
function _isFile4(p) {
|
|
19235
19269
|
try {
|
|
19236
|
-
return
|
|
19270
|
+
return fs23.statSync(p).isFile();
|
|
19237
19271
|
} catch {
|
|
19238
19272
|
return false;
|
|
19239
19273
|
}
|
|
@@ -19424,8 +19458,8 @@ function _isCliEntry7() {
|
|
|
19424
19458
|
return true;
|
|
19425
19459
|
}
|
|
19426
19460
|
try {
|
|
19427
|
-
const here =
|
|
19428
|
-
const argv =
|
|
19461
|
+
const here = fs23.realpathSync(fileURLToPath13(import.meta.url));
|
|
19462
|
+
const argv = fs23.realpathSync(path23.resolve(process.argv[1]));
|
|
19429
19463
|
return here === argv;
|
|
19430
19464
|
} catch {
|
|
19431
19465
|
return false;
|
|
@@ -19437,7 +19471,7 @@ if (isCliEntry2) {
|
|
|
19437
19471
|
}
|
|
19438
19472
|
|
|
19439
19473
|
// src/scripts/onboarding_gate_hook.ts
|
|
19440
|
-
import
|
|
19474
|
+
import fs24 from "node:fs";
|
|
19441
19475
|
import path24 from "node:path";
|
|
19442
19476
|
import { fileURLToPath as fileURLToPath14, pathToFileURL as pathToFileURL8 } from "node:url";
|
|
19443
19477
|
var SETTINGS_FILE = ".agent-settings.yml";
|
|
@@ -19449,7 +19483,7 @@ function resolve_settings_path(consumer_root) {
|
|
|
19449
19483
|
for (const rel of SETTINGS_CANDIDATES) {
|
|
19450
19484
|
const candidate = path24.join(consumer_root, rel);
|
|
19451
19485
|
try {
|
|
19452
|
-
if (
|
|
19486
|
+
if (fs24.statSync(candidate).isFile()) {
|
|
19453
19487
|
return candidate;
|
|
19454
19488
|
}
|
|
19455
19489
|
} catch {
|
|
@@ -19463,7 +19497,7 @@ var STATE_FILE2 = path24.join(STATE_DIR2, "onboarding-gate.json");
|
|
|
19463
19497
|
function _read_onboarded(settings_path) {
|
|
19464
19498
|
let isFile = false;
|
|
19465
19499
|
try {
|
|
19466
|
-
isFile =
|
|
19500
|
+
isFile = fs24.statSync(settings_path).isFile();
|
|
19467
19501
|
} catch {
|
|
19468
19502
|
isFile = false;
|
|
19469
19503
|
}
|
|
@@ -19472,7 +19506,7 @@ function _read_onboarded(settings_path) {
|
|
|
19472
19506
|
}
|
|
19473
19507
|
let text;
|
|
19474
19508
|
try {
|
|
19475
|
-
text =
|
|
19509
|
+
text = fs24.readFileSync(settings_path, "utf-8");
|
|
19476
19510
|
} catch {
|
|
19477
19511
|
return [false, "settings_file_unreadable"];
|
|
19478
19512
|
}
|
|
@@ -19526,7 +19560,7 @@ function run3(options) {
|
|
|
19526
19560
|
const settings_path = resolve_settings_path(consumer_root);
|
|
19527
19561
|
let settings_present = false;
|
|
19528
19562
|
try {
|
|
19529
|
-
settings_present =
|
|
19563
|
+
settings_present = fs24.statSync(settings_path).isFile();
|
|
19530
19564
|
} catch {
|
|
19531
19565
|
settings_present = false;
|
|
19532
19566
|
}
|
|
@@ -19592,8 +19626,8 @@ function _isCliEntry8() {
|
|
|
19592
19626
|
return true;
|
|
19593
19627
|
}
|
|
19594
19628
|
try {
|
|
19595
|
-
const here =
|
|
19596
|
-
const argv =
|
|
19629
|
+
const here = fs24.realpathSync(fileURLToPath14(import.meta.url));
|
|
19630
|
+
const argv = fs24.realpathSync(path24.resolve(process.argv[1]));
|
|
19597
19631
|
return here === argv;
|
|
19598
19632
|
} catch {
|
|
19599
19633
|
return false;
|
|
@@ -19605,7 +19639,7 @@ if (isCliEntry3) {
|
|
|
19605
19639
|
}
|
|
19606
19640
|
|
|
19607
19641
|
// src/scripts/context_hygiene_hook.ts
|
|
19608
|
-
import
|
|
19642
|
+
import fs25 from "node:fs";
|
|
19609
19643
|
import path25 from "node:path";
|
|
19610
19644
|
import { fileURLToPath as fileURLToPath15, pathToFileURL as pathToFileURL9 } from "node:url";
|
|
19611
19645
|
var STATE_DIR3 = path25.join("agents", "state");
|
|
@@ -19626,7 +19660,7 @@ function _empty_state2() {
|
|
|
19626
19660
|
function _load_state(target) {
|
|
19627
19661
|
let isFile = false;
|
|
19628
19662
|
try {
|
|
19629
|
-
isFile =
|
|
19663
|
+
isFile = fs25.statSync(target).isFile();
|
|
19630
19664
|
} catch {
|
|
19631
19665
|
isFile = false;
|
|
19632
19666
|
}
|
|
@@ -19634,7 +19668,7 @@ function _load_state(target) {
|
|
|
19634
19668
|
return _empty_state2();
|
|
19635
19669
|
}
|
|
19636
19670
|
try {
|
|
19637
|
-
const decoded = JSON.parse(
|
|
19671
|
+
const decoded = JSON.parse(fs25.readFileSync(target, "utf-8"));
|
|
19638
19672
|
if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
|
|
19639
19673
|
return decoded;
|
|
19640
19674
|
}
|
|
@@ -19784,8 +19818,8 @@ function _isCliEntry9() {
|
|
|
19784
19818
|
return true;
|
|
19785
19819
|
}
|
|
19786
19820
|
try {
|
|
19787
|
-
const here =
|
|
19788
|
-
const argv =
|
|
19821
|
+
const here = fs25.realpathSync(fileURLToPath15(import.meta.url));
|
|
19822
|
+
const argv = fs25.realpathSync(path25.resolve(process.argv[1]));
|
|
19789
19823
|
return here === argv;
|
|
19790
19824
|
} catch {
|
|
19791
19825
|
return false;
|
|
@@ -19797,7 +19831,7 @@ if (isCliEntry4) {
|
|
|
19797
19831
|
}
|
|
19798
19832
|
|
|
19799
19833
|
// src/scripts/minimal_safe_diff_hook.ts
|
|
19800
|
-
import
|
|
19834
|
+
import fs26 from "node:fs";
|
|
19801
19835
|
import path26 from "node:path";
|
|
19802
19836
|
import { fileURLToPath as fileURLToPath16, pathToFileURL as pathToFileURL10 } from "node:url";
|
|
19803
19837
|
var STATE_FILE4 = path26.join("agents", "state", "minimal-safe-diff.json");
|
|
@@ -19845,7 +19879,7 @@ function _read_threshold(consumer_root) {
|
|
|
19845
19879
|
const settings = path26.join(consumer_root, SETTINGS_FILE2);
|
|
19846
19880
|
let isFile = false;
|
|
19847
19881
|
try {
|
|
19848
|
-
isFile =
|
|
19882
|
+
isFile = fs26.statSync(settings).isFile();
|
|
19849
19883
|
} catch {
|
|
19850
19884
|
isFile = false;
|
|
19851
19885
|
}
|
|
@@ -19854,7 +19888,7 @@ function _read_threshold(consumer_root) {
|
|
|
19854
19888
|
}
|
|
19855
19889
|
let text;
|
|
19856
19890
|
try {
|
|
19857
|
-
text =
|
|
19891
|
+
text = fs26.readFileSync(settings, "utf-8");
|
|
19858
19892
|
} catch {
|
|
19859
19893
|
return DEFAULT_THRESHOLD;
|
|
19860
19894
|
}
|
|
@@ -19892,7 +19926,7 @@ function _read_threshold(consumer_root) {
|
|
|
19892
19926
|
function _load_state2(target, threshold) {
|
|
19893
19927
|
let isFile = false;
|
|
19894
19928
|
try {
|
|
19895
|
-
isFile =
|
|
19929
|
+
isFile = fs26.statSync(target).isFile();
|
|
19896
19930
|
} catch {
|
|
19897
19931
|
isFile = false;
|
|
19898
19932
|
}
|
|
@@ -19900,7 +19934,7 @@ function _load_state2(target, threshold) {
|
|
|
19900
19934
|
return _empty_state3(threshold);
|
|
19901
19935
|
}
|
|
19902
19936
|
try {
|
|
19903
|
-
const decoded = JSON.parse(
|
|
19937
|
+
const decoded = JSON.parse(fs26.readFileSync(target, "utf-8"));
|
|
19904
19938
|
if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
|
|
19905
19939
|
const base = _empty_state3(threshold);
|
|
19906
19940
|
Object.assign(base, decoded);
|
|
@@ -20062,8 +20096,8 @@ function _isCliEntry10() {
|
|
|
20062
20096
|
return true;
|
|
20063
20097
|
}
|
|
20064
20098
|
try {
|
|
20065
|
-
const here =
|
|
20066
|
-
const argv =
|
|
20099
|
+
const here = fs26.realpathSync(fileURLToPath16(import.meta.url));
|
|
20100
|
+
const argv = fs26.realpathSync(path26.resolve(process.argv[1]));
|
|
20067
20101
|
return here === argv;
|
|
20068
20102
|
} catch {
|
|
20069
20103
|
return false;
|
|
@@ -20076,7 +20110,7 @@ if (isCliEntry5) {
|
|
|
20076
20110
|
|
|
20077
20111
|
// src/scripts/hooks/ship_diff_volume_hook.ts
|
|
20078
20112
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
20079
|
-
import
|
|
20113
|
+
import fs27 from "node:fs";
|
|
20080
20114
|
import path27 from "node:path";
|
|
20081
20115
|
import { fileURLToPath as fileURLToPath17, pathToFileURL as pathToFileURL11 } from "node:url";
|
|
20082
20116
|
|
|
@@ -20348,7 +20382,7 @@ function main14(argv) {
|
|
|
20348
20382
|
const { volume, excluded, files } = correctedVolume(numstat);
|
|
20349
20383
|
const over = volume >= DEFAULT_THRESHOLD2;
|
|
20350
20384
|
try {
|
|
20351
|
-
|
|
20385
|
+
fs27.mkdirSync(path27.dirname(STATE_FILE5), { recursive: true });
|
|
20352
20386
|
atomic_write_json(STATE_FILE5, {
|
|
20353
20387
|
schema_version: 1,
|
|
20354
20388
|
base,
|
|
@@ -20373,7 +20407,7 @@ function _isCliEntry11() {
|
|
|
20373
20407
|
if (process.argv[1] === void 0) return false;
|
|
20374
20408
|
if (import.meta.url === pathToFileURL11(path27.resolve(process.argv[1])).href) return true;
|
|
20375
20409
|
try {
|
|
20376
|
-
return
|
|
20410
|
+
return fs27.realpathSync(fileURLToPath17(import.meta.url)) === fs27.realpathSync(path27.resolve(process.argv[1]));
|
|
20377
20411
|
} catch {
|
|
20378
20412
|
return false;
|
|
20379
20413
|
}
|
|
@@ -20383,7 +20417,7 @@ if (_isCliEntry11()) {
|
|
|
20383
20417
|
}
|
|
20384
20418
|
|
|
20385
20419
|
// src/scripts/injection_scan_hook.ts
|
|
20386
|
-
import
|
|
20420
|
+
import fs28 from "node:fs";
|
|
20387
20421
|
import path28 from "node:path";
|
|
20388
20422
|
import { fileURLToPath as fileURLToPath18, pathToFileURL as pathToFileURL12 } from "node:url";
|
|
20389
20423
|
var SETTINGS_FILE3 = ".agent-settings.yml";
|
|
@@ -20434,7 +20468,7 @@ function _enabled(root) {
|
|
|
20434
20468
|
const f = path28.join(root, SETTINGS_FILE3);
|
|
20435
20469
|
let isFile = false;
|
|
20436
20470
|
try {
|
|
20437
|
-
isFile =
|
|
20471
|
+
isFile = fs28.statSync(f).isFile();
|
|
20438
20472
|
} catch {
|
|
20439
20473
|
isFile = false;
|
|
20440
20474
|
}
|
|
@@ -20443,7 +20477,7 @@ function _enabled(root) {
|
|
|
20443
20477
|
}
|
|
20444
20478
|
let text;
|
|
20445
20479
|
try {
|
|
20446
|
-
text =
|
|
20480
|
+
text = fs28.readFileSync(f, "utf-8");
|
|
20447
20481
|
} catch {
|
|
20448
20482
|
return false;
|
|
20449
20483
|
}
|
|
@@ -20478,9 +20512,38 @@ function _enabled(root) {
|
|
|
20478
20512
|
}
|
|
20479
20513
|
return false;
|
|
20480
20514
|
}
|
|
20515
|
+
var OUTPUT_KEYS = [
|
|
20516
|
+
// payload_stub.BODY_KEYS.result — the spellings the dispatcher serves.
|
|
20517
|
+
"tool_response",
|
|
20518
|
+
"toolResponse",
|
|
20519
|
+
"tool_result",
|
|
20520
|
+
"toolUseResult",
|
|
20521
|
+
// Generic spellings accepted since this concern shipped.
|
|
20522
|
+
"output",
|
|
20523
|
+
"result"
|
|
20524
|
+
];
|
|
20525
|
+
var STUB_MARKER2 = "_agent_config_body_omitted";
|
|
20526
|
+
function _isStub(v) {
|
|
20527
|
+
return _isObject2(v) && v[STUB_MARKER2] === true;
|
|
20528
|
+
}
|
|
20529
|
+
function _payload_of(root) {
|
|
20530
|
+
const inner = root["payload"];
|
|
20531
|
+
return _isObject2(inner) ? inner : root;
|
|
20532
|
+
}
|
|
20481
20533
|
function _tool_output(envelope) {
|
|
20482
|
-
|
|
20483
|
-
|
|
20534
|
+
const payload = _payload_of(envelope);
|
|
20535
|
+
for (const key of OUTPUT_KEYS) {
|
|
20536
|
+
const v = payload[key];
|
|
20537
|
+
if (v === void 0 || v === null) {
|
|
20538
|
+
continue;
|
|
20539
|
+
}
|
|
20540
|
+
if (_isStub(v)) {
|
|
20541
|
+
process.stderr.write(
|
|
20542
|
+
`injection-scan: ${key} arrived stubbed; the concern declares needs_payload_bodies: [input, result] and cannot scan tool output without it. Nothing was scanned on this event.
|
|
20543
|
+
`
|
|
20544
|
+
);
|
|
20545
|
+
return "";
|
|
20546
|
+
}
|
|
20484
20547
|
if (typeof v === "string") {
|
|
20485
20548
|
return v;
|
|
20486
20549
|
}
|
|
@@ -20488,7 +20551,14 @@ function _tool_output(envelope) {
|
|
|
20488
20551
|
return _pyJsonDumpsCompact2(v);
|
|
20489
20552
|
}
|
|
20490
20553
|
}
|
|
20491
|
-
|
|
20554
|
+
const names = Object.keys(payload);
|
|
20555
|
+
if (names.length > 0) {
|
|
20556
|
+
process.stderr.write(
|
|
20557
|
+
`injection-scan: no recognised tool-output key in this payload; nothing scanned. Present keys: ${names.sort().join(", ")}. Expected one of: ${OUTPUT_KEYS.join(", ")}.
|
|
20558
|
+
`
|
|
20559
|
+
);
|
|
20560
|
+
}
|
|
20561
|
+
return "";
|
|
20492
20562
|
}
|
|
20493
20563
|
function _scan2(text) {
|
|
20494
20564
|
const hits = [];
|
|
@@ -20605,8 +20675,8 @@ function _isCliEntry12() {
|
|
|
20605
20675
|
return true;
|
|
20606
20676
|
}
|
|
20607
20677
|
try {
|
|
20608
|
-
const here =
|
|
20609
|
-
const argv =
|
|
20678
|
+
const here = fs28.realpathSync(fileURLToPath18(import.meta.url));
|
|
20679
|
+
const argv = fs28.realpathSync(path28.resolve(process.argv[1]));
|
|
20610
20680
|
return here === argv;
|
|
20611
20681
|
} catch {
|
|
20612
20682
|
return false;
|
|
@@ -20617,7 +20687,7 @@ if (_isCliEntry12()) {
|
|
|
20617
20687
|
}
|
|
20618
20688
|
|
|
20619
20689
|
// src/scripts/memory_learn_hook.ts
|
|
20620
|
-
import
|
|
20690
|
+
import fs29 from "node:fs";
|
|
20621
20691
|
import path29 from "node:path";
|
|
20622
20692
|
import { fileURLToPath as fileURLToPath19, pathToFileURL as pathToFileURL13 } from "node:url";
|
|
20623
20693
|
|
|
@@ -20668,7 +20738,7 @@ function readLearnValue(root) {
|
|
|
20668
20738
|
const p = path29.join(root, SETTINGS_FILE4);
|
|
20669
20739
|
let text;
|
|
20670
20740
|
try {
|
|
20671
|
-
text =
|
|
20741
|
+
text = fs29.readFileSync(p, "utf8");
|
|
20672
20742
|
} catch {
|
|
20673
20743
|
return void 0;
|
|
20674
20744
|
}
|
|
@@ -20704,13 +20774,13 @@ function runLearn(root, nowIso, budgetMs = BUDGET_MS) {
|
|
|
20704
20774
|
const started = Date.now();
|
|
20705
20775
|
const intakeDir = path29.join(root, "agents", "memory", "intake");
|
|
20706
20776
|
const outDir = path29.join(root, "agents", "memory");
|
|
20707
|
-
if (!
|
|
20777
|
+
if (!fs29.existsSync(intakeDir)) return null;
|
|
20708
20778
|
const sidecar = buildSidecar(intakeDir, nowIso);
|
|
20709
20779
|
if (Date.now() - started > budgetMs) return null;
|
|
20710
20780
|
if (sidecar.lessons.length === 0) return null;
|
|
20711
|
-
|
|
20781
|
+
fs29.writeFileSync(path29.join(outDir, SIDECAR_NAME), `${JSON.stringify(sidecar, null, 2)}
|
|
20712
20782
|
`, "utf8");
|
|
20713
|
-
|
|
20783
|
+
fs29.writeFileSync(path29.join(outDir, LESSONS_NAME), renderLessonsMd(sidecar), "utf8");
|
|
20714
20784
|
const promoted = sidecar.lessons.filter((l) => l.verdict === "preferred").length;
|
|
20715
20785
|
const deadEnds = sidecar.lessons.filter((l) => l.verdict === "dead_end").length;
|
|
20716
20786
|
return `\u{1F9E0} Memory: sidecar refreshed \u2014 ${sidecar.lessons.length} lesson(s) (${promoted} preferred \xB7 ${deadEnds} dead-end); promote via /memory:propose`;
|
|
@@ -20730,7 +20800,7 @@ var _isMain4 = (() => {
|
|
|
20730
20800
|
if (true) return false;
|
|
20731
20801
|
if (process.argv[1] === void 0) return false;
|
|
20732
20802
|
try {
|
|
20733
|
-
return pathToFileURL13(
|
|
20803
|
+
return pathToFileURL13(fs29.realpathSync(path29.resolve(process.argv[1]))).href === import.meta.url;
|
|
20734
20804
|
} catch {
|
|
20735
20805
|
return pathToFileURL13(path29.resolve(process.argv[1])).href === import.meta.url;
|
|
20736
20806
|
}
|
|
@@ -20741,7 +20811,7 @@ if (_isMain4) {
|
|
|
20741
20811
|
var _HERE3 = fileURLToPath19(import.meta.url);
|
|
20742
20812
|
|
|
20743
20813
|
// src/scripts/first_run_gate_hook.ts
|
|
20744
|
-
import
|
|
20814
|
+
import fs30 from "node:fs";
|
|
20745
20815
|
import path30 from "node:path";
|
|
20746
20816
|
import { fileURLToPath as fileURLToPath20, pathToFileURL as pathToFileURL14 } from "node:url";
|
|
20747
20817
|
var PLUGIN_ID = "agent-config@event4u-agent-config";
|
|
@@ -20781,14 +20851,14 @@ this file manually.
|
|
|
20781
20851
|
`;
|
|
20782
20852
|
function _isFile5(p) {
|
|
20783
20853
|
try {
|
|
20784
|
-
return
|
|
20854
|
+
return fs30.statSync(p).isFile();
|
|
20785
20855
|
} catch {
|
|
20786
20856
|
return false;
|
|
20787
20857
|
}
|
|
20788
20858
|
}
|
|
20789
20859
|
function _exists3(p) {
|
|
20790
20860
|
try {
|
|
20791
|
-
|
|
20861
|
+
fs30.statSync(p);
|
|
20792
20862
|
return true;
|
|
20793
20863
|
} catch {
|
|
20794
20864
|
return false;
|
|
@@ -20801,7 +20871,7 @@ function _plugin_enabled(consumer_root) {
|
|
|
20801
20871
|
}
|
|
20802
20872
|
let data;
|
|
20803
20873
|
try {
|
|
20804
|
-
data = JSON.parse(
|
|
20874
|
+
data = JSON.parse(fs30.readFileSync(settings, "utf-8"));
|
|
20805
20875
|
} catch {
|
|
20806
20876
|
return false;
|
|
20807
20877
|
}
|
|
@@ -20820,7 +20890,7 @@ function _agent_config_executable(consumer_root) {
|
|
|
20820
20890
|
return false;
|
|
20821
20891
|
}
|
|
20822
20892
|
try {
|
|
20823
|
-
|
|
20893
|
+
fs30.accessSync(p, fs30.constants.X_OK);
|
|
20824
20894
|
return true;
|
|
20825
20895
|
} catch {
|
|
20826
20896
|
return false;
|
|
@@ -20837,8 +20907,8 @@ function _setup_complete(consumer_root) {
|
|
|
20837
20907
|
function _write_action_file(consumer_root) {
|
|
20838
20908
|
const target = path30.join(consumer_root, ACTION_NEEDED_FILE);
|
|
20839
20909
|
try {
|
|
20840
|
-
|
|
20841
|
-
|
|
20910
|
+
fs30.mkdirSync(path30.dirname(target), { recursive: true });
|
|
20911
|
+
fs30.writeFileSync(target, ACTION_NEEDED_BODY, { encoding: "utf-8" });
|
|
20842
20912
|
return true;
|
|
20843
20913
|
} catch (exc) {
|
|
20844
20914
|
process.stderr.write(
|
|
@@ -20852,7 +20922,7 @@ function _cleanup_action_file(consumer_root) {
|
|
|
20852
20922
|
const target = path30.join(consumer_root, ACTION_NEEDED_FILE);
|
|
20853
20923
|
if (_exists3(target)) {
|
|
20854
20924
|
try {
|
|
20855
|
-
|
|
20925
|
+
fs30.unlinkSync(target);
|
|
20856
20926
|
} catch {
|
|
20857
20927
|
}
|
|
20858
20928
|
}
|
|
@@ -20909,8 +20979,8 @@ function _isCliEntry13() {
|
|
|
20909
20979
|
return true;
|
|
20910
20980
|
}
|
|
20911
20981
|
try {
|
|
20912
|
-
const here =
|
|
20913
|
-
const argv =
|
|
20982
|
+
const here = fs30.realpathSync(fileURLToPath20(import.meta.url));
|
|
20983
|
+
const argv = fs30.realpathSync(path30.resolve(process.argv[1]));
|
|
20914
20984
|
return here === argv;
|
|
20915
20985
|
} catch {
|
|
20916
20986
|
return false;
|
|
@@ -20923,12 +20993,12 @@ if (isCliEntry6) {
|
|
|
20923
20993
|
|
|
20924
20994
|
// src/scripts/profile_staleness_hook.ts
|
|
20925
20995
|
var import_yaml4 = __toESM(require_dist(), 1);
|
|
20926
|
-
import
|
|
20996
|
+
import fs32 from "node:fs";
|
|
20927
20997
|
import path32 from "node:path";
|
|
20928
20998
|
import { fileURLToPath as fileURLToPath21, pathToFileURL as pathToFileURL15 } from "node:url";
|
|
20929
20999
|
|
|
20930
21000
|
// src/scripts/hooks/probe_throttle.ts
|
|
20931
|
-
import
|
|
21001
|
+
import fs31 from "node:fs";
|
|
20932
21002
|
import path31 from "node:path";
|
|
20933
21003
|
var STATE_SUBDIR = ["agents", "runtime", "state", "probe-throttle"];
|
|
20934
21004
|
function _stampPath(projectRoot, concern) {
|
|
@@ -20943,7 +21013,7 @@ function _localDay(d) {
|
|
|
20943
21013
|
function probeRanToday(projectRoot, concern) {
|
|
20944
21014
|
if (is_replay_mode()) return false;
|
|
20945
21015
|
try {
|
|
20946
|
-
const st =
|
|
21016
|
+
const st = fs31.statSync(_stampPath(projectRoot, concern));
|
|
20947
21017
|
return _localDay(st.mtime) === _localDay(/* @__PURE__ */ new Date());
|
|
20948
21018
|
} catch {
|
|
20949
21019
|
return false;
|
|
@@ -20953,8 +21023,8 @@ function stampProbeRun(projectRoot, concern) {
|
|
|
20953
21023
|
if (is_replay_mode()) return;
|
|
20954
21024
|
try {
|
|
20955
21025
|
const p = _stampPath(projectRoot, concern);
|
|
20956
|
-
|
|
20957
|
-
|
|
21026
|
+
fs31.mkdirSync(path31.dirname(p), { recursive: true });
|
|
21027
|
+
fs31.writeFileSync(p, `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
20958
21028
|
`);
|
|
20959
21029
|
} catch {
|
|
20960
21030
|
}
|
|
@@ -20969,10 +21039,10 @@ function _isObject3(v) {
|
|
|
20969
21039
|
}
|
|
20970
21040
|
function _read_yaml2(p) {
|
|
20971
21041
|
try {
|
|
20972
|
-
if (!
|
|
21042
|
+
if (!fs32.existsSync(p)) {
|
|
20973
21043
|
return null;
|
|
20974
21044
|
}
|
|
20975
|
-
return (0, import_yaml4.parse)(
|
|
21045
|
+
return (0, import_yaml4.parse)(fs32.readFileSync(p, "utf-8"), { version: "1.1" });
|
|
20976
21046
|
} catch {
|
|
20977
21047
|
return null;
|
|
20978
21048
|
}
|
|
@@ -21057,8 +21127,8 @@ function _isCliEntry14() {
|
|
|
21057
21127
|
return true;
|
|
21058
21128
|
}
|
|
21059
21129
|
try {
|
|
21060
|
-
const here =
|
|
21061
|
-
const argv =
|
|
21130
|
+
const here = fs32.realpathSync(fileURLToPath21(import.meta.url));
|
|
21131
|
+
const argv = fs32.realpathSync(path32.resolve(process.argv[1]));
|
|
21062
21132
|
return here === argv;
|
|
21063
21133
|
} catch {
|
|
21064
21134
|
return false;
|
|
@@ -21070,12 +21140,12 @@ if (isCliEntry7) {
|
|
|
21070
21140
|
}
|
|
21071
21141
|
|
|
21072
21142
|
// src/scripts/wrapper_freshness_hook.ts
|
|
21073
|
-
import
|
|
21143
|
+
import fs34 from "node:fs";
|
|
21074
21144
|
import path34 from "node:path";
|
|
21075
21145
|
import { fileURLToPath as fileURLToPath23, pathToFileURL as pathToFileURL16 } from "node:url";
|
|
21076
21146
|
|
|
21077
21147
|
// src/scripts/_lib/cli_wrapper.ts
|
|
21078
|
-
import
|
|
21148
|
+
import fs33 from "node:fs";
|
|
21079
21149
|
import path33 from "node:path";
|
|
21080
21150
|
import { fileURLToPath as fileURLToPath22 } from "node:url";
|
|
21081
21151
|
var _PACKAGE_ROOT2 = path33.resolve(
|
|
@@ -21092,7 +21162,7 @@ var _TEMPLATE = path33.join(
|
|
|
21092
21162
|
);
|
|
21093
21163
|
function _is_file2(p) {
|
|
21094
21164
|
try {
|
|
21095
|
-
return
|
|
21165
|
+
return fs33.statSync(p).isFile();
|
|
21096
21166
|
} catch {
|
|
21097
21167
|
return false;
|
|
21098
21168
|
}
|
|
@@ -21105,7 +21175,7 @@ function needs_refresh(project_root) {
|
|
|
21105
21175
|
const target = _target(project_root);
|
|
21106
21176
|
if (!_is_file2(target)) return true;
|
|
21107
21177
|
try {
|
|
21108
|
-
return
|
|
21178
|
+
return fs33.readFileSync(target, "utf-8") !== fs33.readFileSync(_TEMPLATE, "utf-8");
|
|
21109
21179
|
} catch {
|
|
21110
21180
|
return true;
|
|
21111
21181
|
}
|
|
@@ -21113,8 +21183,8 @@ function needs_refresh(project_root) {
|
|
|
21113
21183
|
function install_cli_wrapper(project_root) {
|
|
21114
21184
|
if (!_is_file2(_TEMPLATE)) return null;
|
|
21115
21185
|
const target = _target(project_root);
|
|
21116
|
-
|
|
21117
|
-
|
|
21186
|
+
fs33.copyFileSync(_TEMPLATE, target);
|
|
21187
|
+
fs33.chmodSync(target, 493);
|
|
21118
21188
|
return target;
|
|
21119
21189
|
}
|
|
21120
21190
|
|
|
@@ -21130,14 +21200,14 @@ function _project_root2() {
|
|
|
21130
21200
|
}
|
|
21131
21201
|
function _isDir3(p) {
|
|
21132
21202
|
try {
|
|
21133
|
-
return
|
|
21203
|
+
return fs34.statSync(p).isDirectory();
|
|
21134
21204
|
} catch {
|
|
21135
21205
|
return false;
|
|
21136
21206
|
}
|
|
21137
21207
|
}
|
|
21138
21208
|
function _isFile6(p) {
|
|
21139
21209
|
try {
|
|
21140
|
-
return
|
|
21210
|
+
return fs34.statSync(p).isFile();
|
|
21141
21211
|
} catch {
|
|
21142
21212
|
return false;
|
|
21143
21213
|
}
|
|
@@ -21149,7 +21219,7 @@ function _is_source_repo(project_root) {
|
|
|
21149
21219
|
try {
|
|
21150
21220
|
const packagesDir = path34.join(project_root, "packages");
|
|
21151
21221
|
if (_isDir3(packagesDir)) {
|
|
21152
|
-
for (const entry of
|
|
21222
|
+
for (const entry of fs34.readdirSync(packagesDir)) {
|
|
21153
21223
|
if (_isDir3(path34.join(packagesDir, entry, ".agent-src.uncondensed"))) {
|
|
21154
21224
|
return true;
|
|
21155
21225
|
}
|
|
@@ -21160,7 +21230,7 @@ function _is_source_repo(project_root) {
|
|
|
21160
21230
|
const pkg = path34.join(project_root, "package.json");
|
|
21161
21231
|
if (_isFile6(pkg)) {
|
|
21162
21232
|
try {
|
|
21163
|
-
const data = JSON.parse(
|
|
21233
|
+
const data = JSON.parse(fs34.readFileSync(pkg, "utf-8"));
|
|
21164
21234
|
if (typeof data === "object" && data !== null && data["name"] === "@event4u/agent-config") {
|
|
21165
21235
|
return true;
|
|
21166
21236
|
}
|
|
@@ -21192,7 +21262,7 @@ function _git_hooks_dir(root) {
|
|
|
21192
21262
|
}
|
|
21193
21263
|
if (_isFile6(dotGit)) {
|
|
21194
21264
|
try {
|
|
21195
|
-
const m = /^gitdir:\s*(.+)\s*$/m.exec(
|
|
21265
|
+
const m = /^gitdir:\s*(.+)\s*$/m.exec(fs34.readFileSync(dotGit, "utf-8"));
|
|
21196
21266
|
if (m && m[1] !== void 0) {
|
|
21197
21267
|
const gitDir = path34.isAbsolute(m[1]) ? m[1] : path34.join(root, m[1]);
|
|
21198
21268
|
return path34.join(gitDir, "hooks");
|
|
@@ -21223,16 +21293,16 @@ function refresh_precommit_hook(root) {
|
|
|
21223
21293
|
if (!_isFile6(target)) {
|
|
21224
21294
|
return null;
|
|
21225
21295
|
}
|
|
21226
|
-
const current =
|
|
21296
|
+
const current = fs34.readFileSync(target, "utf-8");
|
|
21227
21297
|
if (!current.includes(_PRECOMMIT_MARKER)) {
|
|
21228
21298
|
return null;
|
|
21229
21299
|
}
|
|
21230
|
-
const canonical2 =
|
|
21300
|
+
const canonical2 = fs34.readFileSync(template, "utf-8");
|
|
21231
21301
|
if (current === canonical2) {
|
|
21232
21302
|
return null;
|
|
21233
21303
|
}
|
|
21234
|
-
|
|
21235
|
-
|
|
21304
|
+
fs34.writeFileSync(target, canonical2);
|
|
21305
|
+
fs34.chmodSync(target, 493);
|
|
21236
21306
|
return target;
|
|
21237
21307
|
} catch {
|
|
21238
21308
|
return null;
|
|
@@ -21298,8 +21368,8 @@ function _isCliEntry15() {
|
|
|
21298
21368
|
return true;
|
|
21299
21369
|
}
|
|
21300
21370
|
try {
|
|
21301
|
-
const here =
|
|
21302
|
-
const argv =
|
|
21371
|
+
const here = fs34.realpathSync(fileURLToPath23(import.meta.url));
|
|
21372
|
+
const argv = fs34.realpathSync(path34.resolve(process.argv[1]));
|
|
21303
21373
|
return here === argv;
|
|
21304
21374
|
} catch {
|
|
21305
21375
|
return false;
|
|
@@ -21312,7 +21382,7 @@ if (isCliEntry8) {
|
|
|
21312
21382
|
|
|
21313
21383
|
// src/scripts/surface_probe_hook.ts
|
|
21314
21384
|
var import_yaml5 = __toESM(require_dist(), 1);
|
|
21315
|
-
import
|
|
21385
|
+
import fs35 from "node:fs";
|
|
21316
21386
|
import os4 from "node:os";
|
|
21317
21387
|
import path35 from "node:path";
|
|
21318
21388
|
import { fileURLToPath as fileURLToPath24, pathToFileURL as pathToFileURL17 } from "node:url";
|
|
@@ -21337,7 +21407,7 @@ function _readStdinIfNotTty3() {
|
|
|
21337
21407
|
}
|
|
21338
21408
|
function _exists4(p) {
|
|
21339
21409
|
try {
|
|
21340
|
-
|
|
21410
|
+
fs35.statSync(p);
|
|
21341
21411
|
return true;
|
|
21342
21412
|
} catch {
|
|
21343
21413
|
return false;
|
|
@@ -21345,7 +21415,7 @@ function _exists4(p) {
|
|
|
21345
21415
|
}
|
|
21346
21416
|
function _auto_converge(global_settings_path) {
|
|
21347
21417
|
try {
|
|
21348
|
-
const raw = (0, import_yaml5.parse)(
|
|
21418
|
+
const raw = (0, import_yaml5.parse)(fs35.readFileSync(global_settings_path, "utf-8"), { version: "1.1" });
|
|
21349
21419
|
const install = raw?.["install"];
|
|
21350
21420
|
if (install && typeof install === "object" && !Array.isArray(install)) {
|
|
21351
21421
|
return install["auto_converge"] === true;
|
|
@@ -21359,7 +21429,7 @@ function _default_global_settings(home) {
|
|
|
21359
21429
|
}
|
|
21360
21430
|
function _rate_limited(state_path, now_ms) {
|
|
21361
21431
|
try {
|
|
21362
|
-
const raw = JSON.parse(
|
|
21432
|
+
const raw = JSON.parse(fs35.readFileSync(state_path, "utf-8"));
|
|
21363
21433
|
const last = raw["last_check_utc"];
|
|
21364
21434
|
if (typeof last === "number" && now_ms - last < CHECK_WINDOW_MS && last <= now_ms) {
|
|
21365
21435
|
return true;
|
|
@@ -21370,8 +21440,8 @@ function _rate_limited(state_path, now_ms) {
|
|
|
21370
21440
|
}
|
|
21371
21441
|
function _stamp(state_path, now_ms) {
|
|
21372
21442
|
try {
|
|
21373
|
-
|
|
21374
|
-
|
|
21443
|
+
fs35.mkdirSync(path35.dirname(state_path), { recursive: true });
|
|
21444
|
+
fs35.writeFileSync(state_path, `${JSON.stringify({ last_check_utc: now_ms })}
|
|
21375
21445
|
`, "utf-8");
|
|
21376
21446
|
} catch {
|
|
21377
21447
|
}
|
|
@@ -21380,7 +21450,7 @@ function _detect(pkg_root, home) {
|
|
|
21380
21450
|
const matrix_path = path35.join(pkg_root, "src", "config", "surface-matrix.yml");
|
|
21381
21451
|
let tools = {};
|
|
21382
21452
|
try {
|
|
21383
|
-
const raw = (0, import_yaml5.parse)(
|
|
21453
|
+
const raw = (0, import_yaml5.parse)(fs35.readFileSync(matrix_path, "utf-8"), { version: "1.1" });
|
|
21384
21454
|
const t = raw?.["tools"];
|
|
21385
21455
|
if (t && typeof t === "object" && !Array.isArray(t)) {
|
|
21386
21456
|
tools = t;
|
|
@@ -21457,8 +21527,8 @@ function _isCliEntry16() {
|
|
|
21457
21527
|
return true;
|
|
21458
21528
|
}
|
|
21459
21529
|
try {
|
|
21460
|
-
const here =
|
|
21461
|
-
const argv =
|
|
21530
|
+
const here = fs35.realpathSync(fileURLToPath24(import.meta.url));
|
|
21531
|
+
const argv = fs35.realpathSync(path35.resolve(process.argv[1]));
|
|
21462
21532
|
return here === argv;
|
|
21463
21533
|
} catch {
|
|
21464
21534
|
return false;
|
|
@@ -21469,13 +21539,13 @@ if (_isCliEntry16()) {
|
|
|
21469
21539
|
}
|
|
21470
21540
|
|
|
21471
21541
|
// src/scripts/team_review_gate_hook.ts
|
|
21472
|
-
import
|
|
21542
|
+
import fs37 from "node:fs";
|
|
21473
21543
|
import path38 from "node:path";
|
|
21474
21544
|
import { fileURLToPath as fileURLToPath25, pathToFileURL as pathToFileURL18 } from "node:url";
|
|
21475
21545
|
|
|
21476
21546
|
// src/scripts/ai_team/review_gate.ts
|
|
21477
21547
|
import * as crypto3 from "node:crypto";
|
|
21478
|
-
import * as
|
|
21548
|
+
import * as fs36 from "node:fs";
|
|
21479
21549
|
import * as os6 from "node:os";
|
|
21480
21550
|
import * as path37 from "node:path";
|
|
21481
21551
|
|
|
@@ -21668,7 +21738,7 @@ function _read_state(state_path) {
|
|
|
21668
21738
|
const empty = { schema_version: 1, sessions: {} };
|
|
21669
21739
|
let parsed;
|
|
21670
21740
|
try {
|
|
21671
|
-
parsed = JSON.parse(
|
|
21741
|
+
parsed = JSON.parse(fs36.readFileSync(state_path, "utf-8"));
|
|
21672
21742
|
} catch {
|
|
21673
21743
|
return empty;
|
|
21674
21744
|
}
|
|
@@ -21724,8 +21794,8 @@ function _append_ledger_line(target, entry) {
|
|
|
21724
21794
|
if (_kill_switch_active2()) {
|
|
21725
21795
|
return false;
|
|
21726
21796
|
}
|
|
21727
|
-
|
|
21728
|
-
|
|
21797
|
+
fs36.mkdirSync(path37.dirname(target), { recursive: true });
|
|
21798
|
+
fs36.appendFileSync(target, JSON.stringify(entry) + "\n", { encoding: "utf-8" });
|
|
21729
21799
|
return true;
|
|
21730
21800
|
}
|
|
21731
21801
|
function format_gate_ledger_line(entry) {
|
|
@@ -21821,7 +21891,7 @@ var UPSTREAM_GATE_JOB_TITLE = "Codex Stop Gate Review";
|
|
|
21821
21891
|
function _workspace_state_segment(workspace_root) {
|
|
21822
21892
|
let canonical2 = workspace_root;
|
|
21823
21893
|
try {
|
|
21824
|
-
canonical2 =
|
|
21894
|
+
canonical2 = fs36.realpathSync.native(workspace_root);
|
|
21825
21895
|
} catch {
|
|
21826
21896
|
canonical2 = workspace_root;
|
|
21827
21897
|
}
|
|
@@ -21849,7 +21919,7 @@ function find_latest_gate_transcript(workspace_root, session_id) {
|
|
|
21849
21919
|
const jobs_dir = path37.join(dir, "jobs");
|
|
21850
21920
|
let names;
|
|
21851
21921
|
try {
|
|
21852
|
-
names =
|
|
21922
|
+
names = fs36.readdirSync(jobs_dir);
|
|
21853
21923
|
} catch {
|
|
21854
21924
|
continue;
|
|
21855
21925
|
}
|
|
@@ -21859,7 +21929,7 @@ function find_latest_gate_transcript(workspace_root, session_id) {
|
|
|
21859
21929
|
}
|
|
21860
21930
|
let job;
|
|
21861
21931
|
try {
|
|
21862
|
-
job = JSON.parse(
|
|
21932
|
+
job = JSON.parse(fs36.readFileSync(path37.join(jobs_dir, name), "utf-8"));
|
|
21863
21933
|
} catch {
|
|
21864
21934
|
continue;
|
|
21865
21935
|
}
|
|
@@ -22003,8 +22073,8 @@ function _isCliEntry17() {
|
|
|
22003
22073
|
return true;
|
|
22004
22074
|
}
|
|
22005
22075
|
try {
|
|
22006
|
-
const here =
|
|
22007
|
-
const argv =
|
|
22076
|
+
const here = fs37.realpathSync(fileURLToPath25(import.meta.url));
|
|
22077
|
+
const argv = fs37.realpathSync(path38.resolve(process.argv[1]));
|
|
22008
22078
|
return here === argv;
|
|
22009
22079
|
} catch {
|
|
22010
22080
|
return false;
|
|
@@ -22015,7 +22085,7 @@ if (_isCliEntry17()) {
|
|
|
22015
22085
|
}
|
|
22016
22086
|
|
|
22017
22087
|
// src/scripts/pr_url_reminder_hook.ts
|
|
22018
|
-
import
|
|
22088
|
+
import fs38 from "node:fs";
|
|
22019
22089
|
import path39 from "node:path";
|
|
22020
22090
|
import { fileURLToPath as fileURLToPath26, pathToFileURL as pathToFileURL19 } from "node:url";
|
|
22021
22091
|
var EXIT_ALLOW3 = 0;
|
|
@@ -22128,8 +22198,8 @@ function _isCliEntry18() {
|
|
|
22128
22198
|
return true;
|
|
22129
22199
|
}
|
|
22130
22200
|
try {
|
|
22131
|
-
const here =
|
|
22132
|
-
const argv =
|
|
22201
|
+
const here = fs38.realpathSync(fileURLToPath26(import.meta.url));
|
|
22202
|
+
const argv = fs38.realpathSync(path39.resolve(process.argv[1]));
|
|
22133
22203
|
return here === argv;
|
|
22134
22204
|
} catch {
|
|
22135
22205
|
return false;
|
|
@@ -22140,7 +22210,7 @@ if (_isCliEntry18()) {
|
|
|
22140
22210
|
}
|
|
22141
22211
|
|
|
22142
22212
|
// src/scripts/session_canary_hook.ts
|
|
22143
|
-
import
|
|
22213
|
+
import fs39 from "node:fs";
|
|
22144
22214
|
import path40 from "node:path";
|
|
22145
22215
|
import { fileURLToPath as fileURLToPath27, pathToFileURL as pathToFileURL20 } from "node:url";
|
|
22146
22216
|
var EXIT_ALLOW4 = 0;
|
|
@@ -22151,10 +22221,10 @@ function _isObject6(v) {
|
|
|
22151
22221
|
function read_canary_name(settings_path) {
|
|
22152
22222
|
let text;
|
|
22153
22223
|
try {
|
|
22154
|
-
if (!
|
|
22224
|
+
if (!fs39.statSync(settings_path).isFile()) {
|
|
22155
22225
|
return null;
|
|
22156
22226
|
}
|
|
22157
|
-
text =
|
|
22227
|
+
text = fs39.readFileSync(settings_path, "utf-8");
|
|
22158
22228
|
} catch {
|
|
22159
22229
|
return null;
|
|
22160
22230
|
}
|
|
@@ -22179,10 +22249,10 @@ function read_canary_name(settings_path) {
|
|
|
22179
22249
|
function read_identity_name(user_yml_path) {
|
|
22180
22250
|
let text;
|
|
22181
22251
|
try {
|
|
22182
|
-
if (!
|
|
22252
|
+
if (!fs39.statSync(user_yml_path).isFile()) {
|
|
22183
22253
|
return null;
|
|
22184
22254
|
}
|
|
22185
|
-
text =
|
|
22255
|
+
text = fs39.readFileSync(user_yml_path, "utf-8");
|
|
22186
22256
|
} catch {
|
|
22187
22257
|
return null;
|
|
22188
22258
|
}
|
|
@@ -22303,8 +22373,8 @@ function _isCliEntry19() {
|
|
|
22303
22373
|
return true;
|
|
22304
22374
|
}
|
|
22305
22375
|
try {
|
|
22306
|
-
const here =
|
|
22307
|
-
const argv =
|
|
22376
|
+
const here = fs39.realpathSync(fileURLToPath27(import.meta.url));
|
|
22377
|
+
const argv = fs39.realpathSync(path40.resolve(process.argv[1]));
|
|
22308
22378
|
return here === argv;
|
|
22309
22379
|
} catch {
|
|
22310
22380
|
return false;
|
|
@@ -22315,7 +22385,7 @@ if (_isCliEntry19()) {
|
|
|
22315
22385
|
}
|
|
22316
22386
|
|
|
22317
22387
|
// src/scripts/council_availability_hook.ts
|
|
22318
|
-
import * as
|
|
22388
|
+
import * as fs40 from "node:fs";
|
|
22319
22389
|
import * as path41 from "node:path";
|
|
22320
22390
|
import { fileURLToPath as fileURLToPath28, pathToFileURL as pathToFileURL21 } from "node:url";
|
|
22321
22391
|
var EXIT_ALLOW5 = 0;
|
|
@@ -22326,7 +22396,7 @@ function resolveAvailability(cwd, env) {
|
|
|
22326
22396
|
} catch {
|
|
22327
22397
|
return null;
|
|
22328
22398
|
}
|
|
22329
|
-
const exists =
|
|
22399
|
+
const exists = fs40.existsSync(p);
|
|
22330
22400
|
const provenance2 = env[COUNCIL_CONFIG_ENV] ? "env-override" : "user-global";
|
|
22331
22401
|
if (!exists) {
|
|
22332
22402
|
return { configured: false, path: p, exists: false, provenance: provenance2, membersEnabled: 0, memberNames: [] };
|
|
@@ -22421,7 +22491,7 @@ if (_isCliEntry20()) {
|
|
|
22421
22491
|
}
|
|
22422
22492
|
|
|
22423
22493
|
// src/scripts/telemetry_disclosure_hook.ts
|
|
22424
|
-
import * as
|
|
22494
|
+
import * as fs45 from "node:fs";
|
|
22425
22495
|
import * as path45 from "node:path";
|
|
22426
22496
|
import { pathToFileURL as pathToFileURL23 } from "node:url";
|
|
22427
22497
|
|
|
@@ -22429,11 +22499,11 @@ import { pathToFileURL as pathToFileURL23 } from "node:url";
|
|
|
22429
22499
|
import * as os7 from "node:os";
|
|
22430
22500
|
import * as path44 from "node:path";
|
|
22431
22501
|
import { fileURLToPath as fileURLToPath29, pathToFileURL as pathToFileURL22 } from "node:url";
|
|
22432
|
-
import * as
|
|
22502
|
+
import * as fs44 from "node:fs";
|
|
22433
22503
|
|
|
22434
22504
|
// src/agent-src/templates/scripts/telemetry/settings.ts
|
|
22435
22505
|
import { createRequire as createRequire5 } from "node:module";
|
|
22436
|
-
import * as
|
|
22506
|
+
import * as fs41 from "node:fs";
|
|
22437
22507
|
var YAML3 = createRequire5(import.meta.url)("yaml");
|
|
22438
22508
|
function _isPlainObject7(v) {
|
|
22439
22509
|
return typeof v === "object" && v !== null && !Array.isArray(v) && !(v instanceof Date);
|
|
@@ -22471,7 +22541,7 @@ function _coerce_path(value, def) {
|
|
|
22471
22541
|
}
|
|
22472
22542
|
function _isFile7(p) {
|
|
22473
22543
|
try {
|
|
22474
|
-
return
|
|
22544
|
+
return fs41.statSync(p).isFile();
|
|
22475
22545
|
} catch {
|
|
22476
22546
|
return false;
|
|
22477
22547
|
}
|
|
@@ -22482,7 +22552,7 @@ function _read_telemetry_section(p, key) {
|
|
|
22482
22552
|
}
|
|
22483
22553
|
let raw = {};
|
|
22484
22554
|
try {
|
|
22485
|
-
raw = YAML3.parse(
|
|
22555
|
+
raw = YAML3.parse(fs41.readFileSync(p, "utf-8"), { version: "1.1" });
|
|
22486
22556
|
if (raw === null || raw === void 0) {
|
|
22487
22557
|
raw = {};
|
|
22488
22558
|
}
|
|
@@ -22593,7 +22663,7 @@ function read_remote_settings(p) {
|
|
|
22593
22663
|
|
|
22594
22664
|
// src/agent-src/templates/scripts/telemetry/remote.ts
|
|
22595
22665
|
import * as crypto4 from "node:crypto";
|
|
22596
|
-
import * as
|
|
22666
|
+
import * as fs42 from "node:fs";
|
|
22597
22667
|
import * as path42 from "node:path";
|
|
22598
22668
|
|
|
22599
22669
|
// src/agent-src/templates/scripts/telemetry/engagement.ts
|
|
@@ -22892,13 +22962,13 @@ var RETENTION_HEAD_WINDOW_BYTES = 8192;
|
|
|
22892
22962
|
function _oldest_datable_ms(log_path) {
|
|
22893
22963
|
let fd;
|
|
22894
22964
|
try {
|
|
22895
|
-
fd =
|
|
22965
|
+
fd = fs42.openSync(log_path, "r");
|
|
22896
22966
|
} catch {
|
|
22897
22967
|
return null;
|
|
22898
22968
|
}
|
|
22899
22969
|
try {
|
|
22900
22970
|
const buf = Buffer.alloc(RETENTION_HEAD_WINDOW_BYTES);
|
|
22901
|
-
const read =
|
|
22971
|
+
const read = fs42.readSync(fd, buf, 0, buf.length, 0);
|
|
22902
22972
|
if (read <= 0) {
|
|
22903
22973
|
return null;
|
|
22904
22974
|
}
|
|
@@ -22915,13 +22985,13 @@ function _oldest_datable_ms(log_path) {
|
|
|
22915
22985
|
} catch {
|
|
22916
22986
|
return null;
|
|
22917
22987
|
} finally {
|
|
22918
|
-
|
|
22988
|
+
fs42.closeSync(fd);
|
|
22919
22989
|
}
|
|
22920
22990
|
}
|
|
22921
22991
|
function retention_due(log_path, policy = DEFAULT_RETENTION_POLICY, now = /* @__PURE__ */ new Date()) {
|
|
22922
22992
|
let size;
|
|
22923
22993
|
try {
|
|
22924
|
-
size =
|
|
22994
|
+
size = fs42.statSync(log_path).size;
|
|
22925
22995
|
} catch {
|
|
22926
22996
|
return false;
|
|
22927
22997
|
}
|
|
@@ -22940,7 +23010,7 @@ function retention_due(log_path, policy = DEFAULT_RETENTION_POLICY, now = /* @__
|
|
|
22940
23010
|
function enforce_retention(log_path, policy = DEFAULT_RETENTION_POLICY, now = /* @__PURE__ */ new Date()) {
|
|
22941
23011
|
let raw;
|
|
22942
23012
|
try {
|
|
22943
|
-
raw =
|
|
23013
|
+
raw = fs42.readFileSync(log_path, "utf-8");
|
|
22944
23014
|
} catch {
|
|
22945
23015
|
return { kept: 0, dropped_by_age: 0, dropped_by_size: 0 };
|
|
22946
23016
|
}
|
|
@@ -22972,13 +23042,13 @@ function enforce_retention(log_path, policy = DEFAULT_RETENTION_POLICY, now = /*
|
|
|
22972
23042
|
const payload = kept_lines.length === 0 ? "" : `${kept_lines.join("\n")}
|
|
22973
23043
|
`;
|
|
22974
23044
|
const tmp = `${log_path}.retention.${process.pid}.tmp`;
|
|
22975
|
-
|
|
22976
|
-
|
|
23045
|
+
fs42.writeFileSync(tmp, payload, { encoding: "utf-8" });
|
|
23046
|
+
fs42.renameSync(tmp, log_path);
|
|
22977
23047
|
return { kept: kept_lines.length, dropped_by_age, dropped_by_size };
|
|
22978
23048
|
}
|
|
22979
23049
|
function _append_and_bound(target, payload, policy, now) {
|
|
22980
|
-
|
|
22981
|
-
|
|
23050
|
+
fs42.mkdirSync(path42.dirname(target) || ".", { recursive: true });
|
|
23051
|
+
fs42.appendFileSync(target, payload, { encoding: "utf-8" });
|
|
22982
23052
|
if (retention_due(target, policy, now)) {
|
|
22983
23053
|
enforce_retention(target, policy, now);
|
|
22984
23054
|
}
|
|
@@ -22994,7 +23064,7 @@ function append_class_a_record(log_path, record, policy = DEFAULT_RETENTION_POLI
|
|
|
22994
23064
|
|
|
22995
23065
|
// src/agent-src/templates/scripts/telemetry/transport.ts
|
|
22996
23066
|
import { spawn } from "node:child_process";
|
|
22997
|
-
import * as
|
|
23067
|
+
import * as fs43 from "node:fs";
|
|
22998
23068
|
import * as path43 from "node:path";
|
|
22999
23069
|
var DEFAULT_FLUSH_TIMEOUT_MS = 1e3;
|
|
23000
23070
|
var FLUSH_SESSION_END = "session-end";
|
|
@@ -23026,7 +23096,7 @@ function spawn_detached_sender(input) {
|
|
|
23026
23096
|
}
|
|
23027
23097
|
function spool_has_work(spool_path) {
|
|
23028
23098
|
try {
|
|
23029
|
-
return
|
|
23099
|
+
return fs43.statSync(spool_path).size > 0;
|
|
23030
23100
|
} catch {
|
|
23031
23101
|
return false;
|
|
23032
23102
|
}
|
|
@@ -23092,7 +23162,7 @@ function resolveSettingsPath(start) {
|
|
|
23092
23162
|
for (; ; ) {
|
|
23093
23163
|
const candidate = path44.join(dir, SETTINGS_FILENAME);
|
|
23094
23164
|
try {
|
|
23095
|
-
if (
|
|
23165
|
+
if (fs44.statSync(candidate).isFile()) return candidate;
|
|
23096
23166
|
} catch {
|
|
23097
23167
|
}
|
|
23098
23168
|
const parent = path44.dirname(dir);
|
|
@@ -23106,7 +23176,7 @@ function readSettingsFor(consumerRoot) {
|
|
|
23106
23176
|
if (cached !== void 0) return cached;
|
|
23107
23177
|
let text = "";
|
|
23108
23178
|
try {
|
|
23109
|
-
text =
|
|
23179
|
+
text = fs44.readFileSync(p, "utf-8");
|
|
23110
23180
|
} catch {
|
|
23111
23181
|
text = "";
|
|
23112
23182
|
}
|
|
@@ -23179,7 +23249,7 @@ function _isCliEntry21() {
|
|
|
23179
23249
|
const argvUrl = pathToFileURL22(path44.resolve(process.argv[1])).href;
|
|
23180
23250
|
if (import.meta.url === argvUrl) return true;
|
|
23181
23251
|
try {
|
|
23182
|
-
return
|
|
23252
|
+
return fs44.realpathSync(fileURLToPath29(import.meta.url)) === fs44.realpathSync(path44.resolve(process.argv[1]));
|
|
23183
23253
|
} catch {
|
|
23184
23254
|
return false;
|
|
23185
23255
|
}
|
|
@@ -23205,7 +23275,7 @@ function disclosureKey(facts) {
|
|
|
23205
23275
|
}
|
|
23206
23276
|
function alreadyDisclosed(root, facts) {
|
|
23207
23277
|
try {
|
|
23208
|
-
const raw =
|
|
23278
|
+
const raw = fs45.readFileSync(path45.join(root, DISCLOSURE_STATE_REL), "utf-8");
|
|
23209
23279
|
const parsed = JSON.parse(raw);
|
|
23210
23280
|
if (parsed === null || typeof parsed !== "object") {
|
|
23211
23281
|
return false;
|
|
@@ -23218,8 +23288,8 @@ function alreadyDisclosed(root, facts) {
|
|
|
23218
23288
|
function recordDisclosure(root, facts, at) {
|
|
23219
23289
|
try {
|
|
23220
23290
|
const p = path45.join(root, DISCLOSURE_STATE_REL);
|
|
23221
|
-
|
|
23222
|
-
|
|
23291
|
+
fs45.mkdirSync(path45.dirname(p), { recursive: true });
|
|
23292
|
+
fs45.writeFileSync(
|
|
23223
23293
|
p,
|
|
23224
23294
|
`${JSON.stringify({ disclosed: disclosureKey(facts), at }, null, 2)}
|
|
23225
23295
|
`,
|
|
@@ -23307,7 +23377,7 @@ if (_isCliEntry22()) {
|
|
|
23307
23377
|
}
|
|
23308
23378
|
|
|
23309
23379
|
// src/scripts/self_repair_hook.ts
|
|
23310
|
-
import * as
|
|
23380
|
+
import * as fs47 from "node:fs";
|
|
23311
23381
|
import * as path48 from "node:path";
|
|
23312
23382
|
import { fileURLToPath as fileURLToPath30, pathToFileURL as pathToFileURL24 } from "node:url";
|
|
23313
23383
|
|
|
@@ -23546,7 +23616,7 @@ function mergeRecord(existing, finding, now) {
|
|
|
23546
23616
|
}
|
|
23547
23617
|
|
|
23548
23618
|
// src/scripts/_lib/self_repair_store.ts
|
|
23549
|
-
import * as
|
|
23619
|
+
import * as fs46 from "node:fs";
|
|
23550
23620
|
import * as path46 from "node:path";
|
|
23551
23621
|
var STORE_REL = path46.join("agents", "runtime", "self-repair");
|
|
23552
23622
|
function storeDir(root) {
|
|
@@ -23564,7 +23634,7 @@ function isRecord(v) {
|
|
|
23564
23634
|
}
|
|
23565
23635
|
function readRecord(root, fp) {
|
|
23566
23636
|
try {
|
|
23567
|
-
const parsed = JSON.parse(
|
|
23637
|
+
const parsed = JSON.parse(fs46.readFileSync(recordPath(root, fp), "utf-8"));
|
|
23568
23638
|
return isRecord(parsed) ? parsed : null;
|
|
23569
23639
|
} catch {
|
|
23570
23640
|
return null;
|
|
@@ -23572,8 +23642,8 @@ function readRecord(root, fp) {
|
|
|
23572
23642
|
}
|
|
23573
23643
|
function writeRecord(root, record) {
|
|
23574
23644
|
const dir = storeDir(root);
|
|
23575
|
-
|
|
23576
|
-
|
|
23645
|
+
fs46.mkdirSync(dir, { recursive: true });
|
|
23646
|
+
fs46.writeFileSync(
|
|
23577
23647
|
recordPath(root, record.fingerprint),
|
|
23578
23648
|
`${JSON.stringify(record, null, 2)}
|
|
23579
23649
|
`,
|
|
@@ -23583,7 +23653,7 @@ function writeRecord(root, record) {
|
|
|
23583
23653
|
function listRecords(root) {
|
|
23584
23654
|
let names;
|
|
23585
23655
|
try {
|
|
23586
|
-
names =
|
|
23656
|
+
names = fs46.readdirSync(storeDir(root));
|
|
23587
23657
|
} catch {
|
|
23588
23658
|
return [];
|
|
23589
23659
|
}
|
|
@@ -23609,7 +23679,7 @@ function overflowPath(root) {
|
|
|
23609
23679
|
}
|
|
23610
23680
|
function readOverflow(root) {
|
|
23611
23681
|
try {
|
|
23612
|
-
const parsed = JSON.parse(
|
|
23682
|
+
const parsed = JSON.parse(fs46.readFileSync(overflowPath(root), "utf-8"));
|
|
23613
23683
|
return typeof parsed === "object" && parsed !== null ? parsed : {};
|
|
23614
23684
|
} catch {
|
|
23615
23685
|
return {};
|
|
@@ -23620,8 +23690,8 @@ function bumpOverflow(root, source, now) {
|
|
|
23620
23690
|
const prev = counts[source]?.dropped ?? 0;
|
|
23621
23691
|
counts[source] = { dropped: prev + 1, last_seen: now };
|
|
23622
23692
|
const dir = storeDir(root);
|
|
23623
|
-
|
|
23624
|
-
|
|
23693
|
+
fs46.mkdirSync(dir, { recursive: true });
|
|
23694
|
+
fs46.writeFileSync(overflowPath(root), `${JSON.stringify(counts, null, 2)}
|
|
23625
23695
|
`, "utf-8");
|
|
23626
23696
|
}
|
|
23627
23697
|
function upsertFinding(root, finding, now) {
|
|
@@ -23707,7 +23777,7 @@ function readTurn(transcriptPath, pinned) {
|
|
|
23707
23777
|
}
|
|
23708
23778
|
let lines;
|
|
23709
23779
|
try {
|
|
23710
|
-
lines =
|
|
23780
|
+
lines = fs47.readFileSync(transcriptPath, "utf-8").split("\n");
|
|
23711
23781
|
} catch {
|
|
23712
23782
|
return empty;
|
|
23713
23783
|
}
|
|
@@ -23853,7 +23923,7 @@ function isCliEntry9() {
|
|
|
23853
23923
|
return true;
|
|
23854
23924
|
}
|
|
23855
23925
|
try {
|
|
23856
|
-
return
|
|
23926
|
+
return fs47.realpathSync(fileURLToPath30(import.meta.url)) === fs47.realpathSync(path48.resolve(process.argv[1]));
|
|
23857
23927
|
} catch {
|
|
23858
23928
|
return false;
|
|
23859
23929
|
}
|
|
@@ -23863,17 +23933,17 @@ if (isCliEntry9()) {
|
|
|
23863
23933
|
}
|
|
23864
23934
|
|
|
23865
23935
|
// src/scripts/session_register_hook.ts
|
|
23866
|
-
import * as
|
|
23936
|
+
import * as fs52 from "node:fs";
|
|
23867
23937
|
import * as path53 from "node:path";
|
|
23868
23938
|
import process9 from "node:process";
|
|
23869
23939
|
import { fileURLToPath as fileURLToPath31 } from "node:url";
|
|
23870
23940
|
|
|
23871
23941
|
// src/scripts/_lib/session_register.ts
|
|
23872
|
-
import
|
|
23942
|
+
import fs49 from "node:fs";
|
|
23873
23943
|
import path50 from "node:path";
|
|
23874
23944
|
|
|
23875
23945
|
// src/scripts/_lib/fs_atomic.ts
|
|
23876
|
-
import
|
|
23946
|
+
import fs48 from "node:fs";
|
|
23877
23947
|
import path49 from "node:path";
|
|
23878
23948
|
import { randomBytes } from "node:crypto";
|
|
23879
23949
|
function _normalize_encoding(encoding) {
|
|
@@ -23892,7 +23962,7 @@ function write_atomic(p, data, options = {}) {
|
|
|
23892
23962
|
const encoding = options.encoding ?? "utf-8";
|
|
23893
23963
|
const target = path49.normalize(p);
|
|
23894
23964
|
const parent = path49.dirname(target);
|
|
23895
|
-
|
|
23965
|
+
fs48.mkdirSync(parent, { recursive: true });
|
|
23896
23966
|
let payload;
|
|
23897
23967
|
if (typeof data === "string") {
|
|
23898
23968
|
payload = Buffer.from(data, _normalize_encoding(encoding));
|
|
@@ -23911,7 +23981,7 @@ function write_atomic(p, data, options = {}) {
|
|
|
23911
23981
|
`.${path49.basename(target)}.tmp.${randomBytes(6).toString("hex")}`
|
|
23912
23982
|
);
|
|
23913
23983
|
try {
|
|
23914
|
-
fd =
|
|
23984
|
+
fd = fs48.openSync(tmp_path, "wx", 384);
|
|
23915
23985
|
break;
|
|
23916
23986
|
} catch (err) {
|
|
23917
23987
|
if (err.code === "EEXIST") continue;
|
|
@@ -23925,24 +23995,24 @@ function write_atomic(p, data, options = {}) {
|
|
|
23925
23995
|
try {
|
|
23926
23996
|
let offset = 0;
|
|
23927
23997
|
while (offset < payload.length) {
|
|
23928
|
-
offset +=
|
|
23998
|
+
offset += fs48.writeSync(fd, payload, offset, payload.length - offset);
|
|
23929
23999
|
}
|
|
23930
24000
|
try {
|
|
23931
|
-
|
|
24001
|
+
fs48.fsyncSync(fd);
|
|
23932
24002
|
} catch {
|
|
23933
24003
|
}
|
|
23934
|
-
|
|
24004
|
+
fs48.closeSync(fd);
|
|
23935
24005
|
closed = true;
|
|
23936
|
-
|
|
24006
|
+
fs48.renameSync(tmp_path, target);
|
|
23937
24007
|
} catch (err) {
|
|
23938
24008
|
if (!closed) {
|
|
23939
24009
|
try {
|
|
23940
|
-
|
|
24010
|
+
fs48.closeSync(fd);
|
|
23941
24011
|
} catch {
|
|
23942
24012
|
}
|
|
23943
24013
|
}
|
|
23944
24014
|
try {
|
|
23945
|
-
|
|
24015
|
+
fs48.unlinkSync(tmp_path);
|
|
23946
24016
|
} catch {
|
|
23947
24017
|
}
|
|
23948
24018
|
throw err;
|
|
@@ -23953,17 +24023,17 @@ function write_atomic(p, data, options = {}) {
|
|
|
23953
24023
|
function _fsync_dir(directory) {
|
|
23954
24024
|
let dir_fd;
|
|
23955
24025
|
try {
|
|
23956
|
-
dir_fd =
|
|
24026
|
+
dir_fd = fs48.openSync(directory, fs48.constants.O_RDONLY);
|
|
23957
24027
|
} catch {
|
|
23958
24028
|
return;
|
|
23959
24029
|
}
|
|
23960
24030
|
try {
|
|
23961
24031
|
try {
|
|
23962
|
-
|
|
24032
|
+
fs48.fsyncSync(dir_fd);
|
|
23963
24033
|
} catch {
|
|
23964
24034
|
}
|
|
23965
24035
|
} finally {
|
|
23966
|
-
|
|
24036
|
+
fs48.closeSync(dir_fd);
|
|
23967
24037
|
}
|
|
23968
24038
|
}
|
|
23969
24039
|
|
|
@@ -24035,7 +24105,7 @@ function write_record(dir, rec) {
|
|
|
24035
24105
|
function read_own_record(dir, session_id) {
|
|
24036
24106
|
try {
|
|
24037
24107
|
const target = path50.join(dir, `${safe_stem(session_id)}.json`);
|
|
24038
|
-
const parsed = JSON.parse(
|
|
24108
|
+
const parsed = JSON.parse(fs49.readFileSync(target, "utf-8"));
|
|
24039
24109
|
return is_record(parsed) ? parsed : null;
|
|
24040
24110
|
} catch {
|
|
24041
24111
|
return null;
|
|
@@ -24043,7 +24113,7 @@ function read_own_record(dir, session_id) {
|
|
|
24043
24113
|
}
|
|
24044
24114
|
function delete_record(dir, session_id) {
|
|
24045
24115
|
try {
|
|
24046
|
-
|
|
24116
|
+
fs49.unlinkSync(path50.join(dir, `${safe_stem(session_id)}.json`));
|
|
24047
24117
|
return true;
|
|
24048
24118
|
} catch {
|
|
24049
24119
|
return false;
|
|
@@ -24056,7 +24126,7 @@ function read_live_records(dir, options = {}) {
|
|
|
24056
24126
|
const grace = options.prune_grace_ms ?? PRUNE_GRACE_MS;
|
|
24057
24127
|
let names;
|
|
24058
24128
|
try {
|
|
24059
|
-
names =
|
|
24129
|
+
names = fs49.readdirSync(dir).filter((n) => n.endsWith(".json"));
|
|
24060
24130
|
} catch {
|
|
24061
24131
|
return [];
|
|
24062
24132
|
}
|
|
@@ -24065,7 +24135,7 @@ function read_live_records(dir, options = {}) {
|
|
|
24065
24135
|
const full = path50.join(dir, name);
|
|
24066
24136
|
let rec = null;
|
|
24067
24137
|
try {
|
|
24068
|
-
const parsed = JSON.parse(
|
|
24138
|
+
const parsed = JSON.parse(fs49.readFileSync(full, "utf-8"));
|
|
24069
24139
|
rec = is_record(parsed) ? parsed : null;
|
|
24070
24140
|
} catch {
|
|
24071
24141
|
rec = null;
|
|
@@ -24073,7 +24143,7 @@ function read_live_records(dir, options = {}) {
|
|
|
24073
24143
|
if (rec === null || is_expired(rec, now)) {
|
|
24074
24144
|
if (prune && (rec === null || is_expired(rec, new Date(now.getTime() - grace)))) {
|
|
24075
24145
|
try {
|
|
24076
|
-
|
|
24146
|
+
fs49.unlinkSync(full);
|
|
24077
24147
|
} catch {
|
|
24078
24148
|
}
|
|
24079
24149
|
}
|
|
@@ -24104,11 +24174,11 @@ function classify_collisions(others, here) {
|
|
|
24104
24174
|
|
|
24105
24175
|
// src/scripts/_lib/turn_end_refusals.ts
|
|
24106
24176
|
import * as crypto5 from "node:crypto";
|
|
24107
|
-
import * as
|
|
24177
|
+
import * as fs51 from "node:fs";
|
|
24108
24178
|
import * as path52 from "node:path";
|
|
24109
24179
|
|
|
24110
24180
|
// src/scripts/_lib/installed_lock.ts
|
|
24111
|
-
import * as
|
|
24181
|
+
import * as fs50 from "node:fs";
|
|
24112
24182
|
import * as os9 from "node:os";
|
|
24113
24183
|
import * as path51 from "node:path";
|
|
24114
24184
|
var LOCKFILE_ENV = "AGENT_CONFIG_INSTALLED_LOCK";
|
|
@@ -24147,7 +24217,7 @@ function read_lockfile(path91) {
|
|
|
24147
24217
|
const target = path91 ?? lockfile_path();
|
|
24148
24218
|
let text;
|
|
24149
24219
|
try {
|
|
24150
|
-
text =
|
|
24220
|
+
text = fs50.readFileSync(target, { encoding: "utf-8" });
|
|
24151
24221
|
} catch {
|
|
24152
24222
|
return null;
|
|
24153
24223
|
}
|
|
@@ -24226,7 +24296,7 @@ function sessionRefusalFile(workspaceRoot2, sessionKey) {
|
|
|
24226
24296
|
}
|
|
24227
24297
|
function readSessionCounts(workspaceRoot2, sessionId2) {
|
|
24228
24298
|
try {
|
|
24229
|
-
const raw =
|
|
24299
|
+
const raw = fs51.readFileSync(
|
|
24230
24300
|
sessionRefusalFile(workspaceRoot2, deriveSessionKey(sessionId2)),
|
|
24231
24301
|
"utf-8"
|
|
24232
24302
|
);
|
|
@@ -24328,7 +24398,7 @@ function pruneAgedRefusalState(workspaceRoot2, opts = {}) {
|
|
|
24328
24398
|
const result = { scanned: 0, pruned: 0, kept: 0 };
|
|
24329
24399
|
let entries;
|
|
24330
24400
|
try {
|
|
24331
|
-
entries =
|
|
24401
|
+
entries = fs51.readdirSync(dir);
|
|
24332
24402
|
} catch {
|
|
24333
24403
|
return result;
|
|
24334
24404
|
}
|
|
@@ -24339,7 +24409,7 @@ function pruneAgedRefusalState(workspaceRoot2, opts = {}) {
|
|
|
24339
24409
|
const file = path52.join(dir, name);
|
|
24340
24410
|
let rec = null;
|
|
24341
24411
|
try {
|
|
24342
|
-
rec = parseRecord(
|
|
24412
|
+
rec = parseRecord(fs51.readFileSync(file, "utf-8"));
|
|
24343
24413
|
} catch {
|
|
24344
24414
|
rec = null;
|
|
24345
24415
|
}
|
|
@@ -24353,7 +24423,7 @@ function pruneAgedRefusalState(workspaceRoot2, opts = {}) {
|
|
|
24353
24423
|
continue;
|
|
24354
24424
|
}
|
|
24355
24425
|
try {
|
|
24356
|
-
|
|
24426
|
+
fs51.unlinkSync(file);
|
|
24357
24427
|
result.pruned += 1;
|
|
24358
24428
|
} catch {
|
|
24359
24429
|
result.kept += 1;
|
|
@@ -24404,7 +24474,7 @@ function _is_replay_mode4() {
|
|
|
24404
24474
|
}
|
|
24405
24475
|
function _read_claim_file(file) {
|
|
24406
24476
|
try {
|
|
24407
|
-
const parsed = JSON.parse(
|
|
24477
|
+
const parsed = JSON.parse(fs52.readFileSync(file, "utf-8"));
|
|
24408
24478
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
24409
24479
|
return null;
|
|
24410
24480
|
}
|
|
@@ -24468,7 +24538,7 @@ function claim_is_stale(workspace_root, slug, peer_worktree) {
|
|
|
24468
24538
|
);
|
|
24469
24539
|
for (const root of roots) {
|
|
24470
24540
|
try {
|
|
24471
|
-
if (
|
|
24541
|
+
if (fs52.existsSync(path53.join(root, rel))) {
|
|
24472
24542
|
return false;
|
|
24473
24543
|
}
|
|
24474
24544
|
} catch {
|
|
@@ -24483,8 +24553,8 @@ function session_checkout(workspace_root, payload_cwd) {
|
|
|
24483
24553
|
if (cwd === "") return fallback;
|
|
24484
24554
|
let start;
|
|
24485
24555
|
try {
|
|
24486
|
-
if (!
|
|
24487
|
-
start =
|
|
24556
|
+
if (!fs52.statSync(cwd).isDirectory()) return fallback;
|
|
24557
|
+
start = fs52.realpathSync(cwd);
|
|
24488
24558
|
} catch {
|
|
24489
24559
|
return fallback;
|
|
24490
24560
|
}
|
|
@@ -24498,7 +24568,7 @@ function session_checkout(workspace_root, payload_cwd) {
|
|
|
24498
24568
|
function canonical(p) {
|
|
24499
24569
|
const abs = path53.resolve(p);
|
|
24500
24570
|
try {
|
|
24501
|
-
return
|
|
24571
|
+
return fs52.realpathSync(abs);
|
|
24502
24572
|
} catch {
|
|
24503
24573
|
return abs;
|
|
24504
24574
|
}
|
|
@@ -24671,7 +24741,7 @@ function main28() {
|
|
|
24671
24741
|
for (const p of claim_read_paths(root, session_id)) {
|
|
24672
24742
|
if (path53.basename(p) !== path53.basename(roadmap_claim_rel(session_id))) continue;
|
|
24673
24743
|
try {
|
|
24674
|
-
|
|
24744
|
+
fs52.unlinkSync(p);
|
|
24675
24745
|
} catch {
|
|
24676
24746
|
}
|
|
24677
24747
|
}
|
|
@@ -24724,7 +24794,7 @@ if (!_bundled4 && fileURLToPath31(import.meta.url) === path53.resolve(process9.a
|
|
|
24724
24794
|
}
|
|
24725
24795
|
|
|
24726
24796
|
// src/scripts/language_mirror_hook.ts
|
|
24727
|
-
import
|
|
24797
|
+
import fs53 from "node:fs";
|
|
24728
24798
|
import path54 from "node:path";
|
|
24729
24799
|
import { fileURLToPath as fileURLToPath32, pathToFileURL as pathToFileURL25 } from "node:url";
|
|
24730
24800
|
|
|
@@ -24856,7 +24926,7 @@ This pin exists because the trigger is not observable from the transcript alone:
|
|
|
24856
24926
|
}
|
|
24857
24927
|
function _loadState(target) {
|
|
24858
24928
|
try {
|
|
24859
|
-
const raw =
|
|
24929
|
+
const raw = fs53.readFileSync(target, "utf8");
|
|
24860
24930
|
const decoded = JSON.parse(raw);
|
|
24861
24931
|
return _isObject7(decoded) ? decoded : {};
|
|
24862
24932
|
} catch {
|
|
@@ -24913,8 +24983,8 @@ function _sessionId(envelope) {
|
|
|
24913
24983
|
function _migrateLegacyMarker(consumer_root) {
|
|
24914
24984
|
const legacy = path54.join(consumer_root, PIN_LOST_DIR);
|
|
24915
24985
|
try {
|
|
24916
|
-
if (
|
|
24917
|
-
|
|
24986
|
+
if (fs53.statSync(legacy).isFile()) {
|
|
24987
|
+
fs53.rmSync(legacy, { force: true });
|
|
24918
24988
|
}
|
|
24919
24989
|
} catch {
|
|
24920
24990
|
}
|
|
@@ -24929,7 +24999,7 @@ function _setPinLost(consumer_root, session_id) {
|
|
|
24929
24999
|
}
|
|
24930
25000
|
function _pinLost(consumer_root, session_id) {
|
|
24931
25001
|
try {
|
|
24932
|
-
return
|
|
25002
|
+
return fs53.existsSync(path54.join(consumer_root, pinLostMarker(session_id)));
|
|
24933
25003
|
} catch {
|
|
24934
25004
|
return false;
|
|
24935
25005
|
}
|
|
@@ -24937,7 +25007,7 @@ function _pinLost(consumer_root, session_id) {
|
|
|
24937
25007
|
function _clearPinLost(consumer_root, session_id) {
|
|
24938
25008
|
if (is_replay_mode()) return;
|
|
24939
25009
|
try {
|
|
24940
|
-
|
|
25010
|
+
fs53.rmSync(path54.join(consumer_root, pinLostMarker(session_id)), { force: true });
|
|
24941
25011
|
} catch {
|
|
24942
25012
|
}
|
|
24943
25013
|
}
|
|
@@ -24976,7 +25046,7 @@ function _reEmitAfterCompaction(consumer_root, session_id, write_json = atomic_w
|
|
|
24976
25046
|
function _pruneLegacyState(consumer_root) {
|
|
24977
25047
|
prune_legacy_state_file(path54.join(consumer_root, STATE_FILE6));
|
|
24978
25048
|
}
|
|
24979
|
-
function _pruneStaleSessions(consumer_root, now_ms, mtimeOf = (target) =>
|
|
25049
|
+
function _pruneStaleSessions(consumer_root, now_ms, mtimeOf = (target) => fs53.statSync(target).mtimeMs) {
|
|
24980
25050
|
return prune_stale_session_states(
|
|
24981
25051
|
path54.join(consumer_root, STATE_DIR4),
|
|
24982
25052
|
now_ms,
|
|
@@ -24990,20 +25060,20 @@ function _withToolWriteLock(consumer_root, session_id, when_busy, body, now_ms =
|
|
|
24990
25060
|
let fd;
|
|
24991
25061
|
const acquire = () => {
|
|
24992
25062
|
try {
|
|
24993
|
-
|
|
24994
|
-
return
|
|
25063
|
+
fs53.mkdirSync(path54.dirname(lock), { recursive: true });
|
|
25064
|
+
return fs53.openSync(lock, "wx");
|
|
24995
25065
|
} catch (err) {
|
|
24996
25066
|
if (err.code !== "EEXIST") return null;
|
|
24997
25067
|
let age;
|
|
24998
25068
|
try {
|
|
24999
|
-
age = now_ms -
|
|
25069
|
+
age = now_ms - fs53.statSync(lock).mtimeMs;
|
|
25000
25070
|
} catch {
|
|
25001
25071
|
return null;
|
|
25002
25072
|
}
|
|
25003
25073
|
if (age < LOCK_STALE_MS2) return null;
|
|
25004
25074
|
try {
|
|
25005
|
-
|
|
25006
|
-
return
|
|
25075
|
+
fs53.rmSync(lock, { force: true });
|
|
25076
|
+
return fs53.openSync(lock, "wx");
|
|
25007
25077
|
} catch {
|
|
25008
25078
|
return null;
|
|
25009
25079
|
}
|
|
@@ -25016,11 +25086,11 @@ function _withToolWriteLock(consumer_root, session_id, when_busy, body, now_ms =
|
|
|
25016
25086
|
return body();
|
|
25017
25087
|
} finally {
|
|
25018
25088
|
try {
|
|
25019
|
-
|
|
25089
|
+
fs53.closeSync(fd);
|
|
25020
25090
|
} catch {
|
|
25021
25091
|
}
|
|
25022
25092
|
try {
|
|
25023
|
-
|
|
25093
|
+
fs53.rmSync(lock, { force: true });
|
|
25024
25094
|
} catch {
|
|
25025
25095
|
}
|
|
25026
25096
|
}
|
|
@@ -25188,8 +25258,8 @@ function _isCliEntry23() {
|
|
|
25188
25258
|
return true;
|
|
25189
25259
|
}
|
|
25190
25260
|
try {
|
|
25191
|
-
const here =
|
|
25192
|
-
const argv =
|
|
25261
|
+
const here = fs53.realpathSync(fileURLToPath32(import.meta.url));
|
|
25262
|
+
const argv = fs53.realpathSync(path54.resolve(process.argv[1]));
|
|
25193
25263
|
return here === argv;
|
|
25194
25264
|
} catch {
|
|
25195
25265
|
return false;
|
|
@@ -25200,7 +25270,7 @@ if (_isCliEntry23()) {
|
|
|
25200
25270
|
}
|
|
25201
25271
|
|
|
25202
25272
|
// src/scripts/git_authorization_hook.ts
|
|
25203
|
-
import
|
|
25273
|
+
import fs54 from "node:fs";
|
|
25204
25274
|
import path55 from "node:path";
|
|
25205
25275
|
import { fileURLToPath as fileURLToPath33, pathToFileURL as pathToFileURL26 } from "node:url";
|
|
25206
25276
|
var EXIT_ALLOW10 = 0;
|
|
@@ -25338,12 +25408,12 @@ function takePending(consumer_root, session_id, now) {
|
|
|
25338
25408
|
const file = path55.join(consumer_root, pendingFileFor(session_id));
|
|
25339
25409
|
let raw;
|
|
25340
25410
|
try {
|
|
25341
|
-
raw =
|
|
25411
|
+
raw = fs54.readFileSync(file, "utf8");
|
|
25342
25412
|
} catch {
|
|
25343
25413
|
return null;
|
|
25344
25414
|
}
|
|
25345
25415
|
try {
|
|
25346
|
-
|
|
25416
|
+
fs54.rmSync(file, { force: true });
|
|
25347
25417
|
} catch {
|
|
25348
25418
|
}
|
|
25349
25419
|
try {
|
|
@@ -25438,8 +25508,8 @@ function _isCliEntry24() {
|
|
|
25438
25508
|
return true;
|
|
25439
25509
|
}
|
|
25440
25510
|
try {
|
|
25441
|
-
const here =
|
|
25442
|
-
const argv =
|
|
25511
|
+
const here = fs54.realpathSync(fileURLToPath33(import.meta.url));
|
|
25512
|
+
const argv = fs54.realpathSync(path55.resolve(process.argv[1]));
|
|
25443
25513
|
return here === argv;
|
|
25444
25514
|
} catch {
|
|
25445
25515
|
return false;
|
|
@@ -25450,7 +25520,7 @@ if (_isCliEntry24()) {
|
|
|
25450
25520
|
}
|
|
25451
25521
|
|
|
25452
25522
|
// src/scripts/hooks/block_unauthorized_git.ts
|
|
25453
|
-
import
|
|
25523
|
+
import fs55 from "node:fs";
|
|
25454
25524
|
import path56 from "node:path";
|
|
25455
25525
|
import { fileURLToPath as fileURLToPath34, pathToFileURL as pathToFileURL27 } from "node:url";
|
|
25456
25526
|
var EXIT_ALLOW11 = 0;
|
|
@@ -25691,7 +25761,7 @@ function commandOp(command) {
|
|
|
25691
25761
|
}
|
|
25692
25762
|
return found;
|
|
25693
25763
|
}
|
|
25694
|
-
var LEDGER_MAX_AGE_MS =
|
|
25764
|
+
var LEDGER_MAX_AGE_MS = 30 * 60 * 1e3;
|
|
25695
25765
|
function _loadLedger(consumer_root, session_id, now) {
|
|
25696
25766
|
const candidates = [ledgerFileFor(session_id)];
|
|
25697
25767
|
if (!candidates.includes(STATE_FILE7)) {
|
|
@@ -25707,7 +25777,7 @@ function _loadLedger(consumer_root, session_id, now) {
|
|
|
25707
25777
|
}
|
|
25708
25778
|
function _readLedgerFile(file, session_id, now) {
|
|
25709
25779
|
try {
|
|
25710
|
-
const raw =
|
|
25780
|
+
const raw = fs55.readFileSync(file, "utf8");
|
|
25711
25781
|
const decoded = JSON.parse(raw);
|
|
25712
25782
|
if (_isObject9(decoded) && Array.isArray(decoded["authorized"])) {
|
|
25713
25783
|
const ledgerSession = typeof decoded["session_id"] === "string" ? decoded["session_id"] : "";
|
|
@@ -25813,8 +25883,8 @@ function _isCliEntry25() {
|
|
|
25813
25883
|
return true;
|
|
25814
25884
|
}
|
|
25815
25885
|
try {
|
|
25816
|
-
const here =
|
|
25817
|
-
const argv =
|
|
25886
|
+
const here = fs55.realpathSync(fileURLToPath34(import.meta.url));
|
|
25887
|
+
const argv = fs55.realpathSync(path56.resolve(process.argv[1]));
|
|
25818
25888
|
return here === argv;
|
|
25819
25889
|
} catch {
|
|
25820
25890
|
return false;
|
|
@@ -25826,7 +25896,7 @@ if (_isCliEntry25()) {
|
|
|
25826
25896
|
|
|
25827
25897
|
// src/scripts/hooks/evidence_independence.ts
|
|
25828
25898
|
import crypto6 from "node:crypto";
|
|
25829
|
-
import
|
|
25899
|
+
import fs56 from "node:fs";
|
|
25830
25900
|
import path57 from "node:path";
|
|
25831
25901
|
import { fileURLToPath as fileURLToPath35, pathToFileURL as pathToFileURL28 } from "node:url";
|
|
25832
25902
|
var EXIT_ALLOW12 = 0;
|
|
@@ -25899,7 +25969,7 @@ function extractDispatch(envelope) {
|
|
|
25899
25969
|
}
|
|
25900
25970
|
function _ledgerStamp(consumer_root) {
|
|
25901
25971
|
try {
|
|
25902
|
-
const raw =
|
|
25972
|
+
const raw = fs56.readFileSync(
|
|
25903
25973
|
path57.join(consumer_root, "agents", "state", "git-authorization.json"),
|
|
25904
25974
|
"utf8"
|
|
25905
25975
|
);
|
|
@@ -25911,7 +25981,7 @@ function _ledgerStamp(consumer_root) {
|
|
|
25911
25981
|
}
|
|
25912
25982
|
function _load(target) {
|
|
25913
25983
|
try {
|
|
25914
|
-
const decoded = JSON.parse(
|
|
25984
|
+
const decoded = JSON.parse(fs56.readFileSync(target, "utf8"));
|
|
25915
25985
|
if (_isObject10(decoded) && Array.isArray(decoded["evaluations"])) {
|
|
25916
25986
|
return decoded;
|
|
25917
25987
|
}
|
|
@@ -26025,8 +26095,8 @@ function _isCliEntry26() {
|
|
|
26025
26095
|
return true;
|
|
26026
26096
|
}
|
|
26027
26097
|
try {
|
|
26028
|
-
const here =
|
|
26029
|
-
const argv =
|
|
26098
|
+
const here = fs56.realpathSync(fileURLToPath35(import.meta.url));
|
|
26099
|
+
const argv = fs56.realpathSync(path57.resolve(process.argv[1]));
|
|
26030
26100
|
return here === argv;
|
|
26031
26101
|
} catch {
|
|
26032
26102
|
return false;
|
|
@@ -26037,7 +26107,7 @@ if (_isCliEntry26()) {
|
|
|
26037
26107
|
}
|
|
26038
26108
|
|
|
26039
26109
|
// src/scripts/hooks/block_no_verify.ts
|
|
26040
|
-
import * as
|
|
26110
|
+
import * as fs57 from "node:fs";
|
|
26041
26111
|
import { fileURLToPath as fileURLToPath36, pathToFileURL as pathToFileURL29 } from "node:url";
|
|
26042
26112
|
import * as path58 from "node:path";
|
|
26043
26113
|
var _HERE4 = fileURLToPath36(import.meta.url);
|
|
@@ -26488,8 +26558,8 @@ function _isCliEntry27() {
|
|
|
26488
26558
|
return true;
|
|
26489
26559
|
}
|
|
26490
26560
|
try {
|
|
26491
|
-
const here =
|
|
26492
|
-
const argv =
|
|
26561
|
+
const here = fs57.realpathSync(fileURLToPath36(import.meta.url));
|
|
26562
|
+
const argv = fs57.realpathSync(path58.resolve(process.argv[1]));
|
|
26493
26563
|
return here === argv;
|
|
26494
26564
|
} catch {
|
|
26495
26565
|
return false;
|
|
@@ -26500,7 +26570,7 @@ if (_isCliEntry27() || false) {
|
|
|
26500
26570
|
}
|
|
26501
26571
|
|
|
26502
26572
|
// src/scripts/hooks/block_kernel_rule_writes.ts
|
|
26503
|
-
import * as
|
|
26573
|
+
import * as fs58 from "node:fs";
|
|
26504
26574
|
import { fileURLToPath as fileURLToPath37, pathToFileURL as pathToFileURL30 } from "node:url";
|
|
26505
26575
|
import * as path59 from "node:path";
|
|
26506
26576
|
var _HERE5 = fileURLToPath37(import.meta.url);
|
|
@@ -26706,8 +26776,8 @@ function _isCliEntry28() {
|
|
|
26706
26776
|
return true;
|
|
26707
26777
|
}
|
|
26708
26778
|
try {
|
|
26709
|
-
const here =
|
|
26710
|
-
const argv =
|
|
26779
|
+
const here = fs58.realpathSync(fileURLToPath37(import.meta.url));
|
|
26780
|
+
const argv = fs58.realpathSync(path59.resolve(process.argv[1]));
|
|
26711
26781
|
return here === argv;
|
|
26712
26782
|
} catch {
|
|
26713
26783
|
return false;
|
|
@@ -26718,7 +26788,7 @@ if (_isCliEntry28() || false) {
|
|
|
26718
26788
|
}
|
|
26719
26789
|
|
|
26720
26790
|
// src/scripts/hooks/block_config_weakening.ts
|
|
26721
|
-
import * as
|
|
26791
|
+
import * as fs59 from "node:fs";
|
|
26722
26792
|
import * as path60 from "node:path";
|
|
26723
26793
|
import { fileURLToPath as fileURLToPath38, pathToFileURL as pathToFileURL31 } from "node:url";
|
|
26724
26794
|
var _HERE6 = fileURLToPath38(import.meta.url);
|
|
@@ -26812,7 +26882,7 @@ function bump_session(root, session, key, added) {
|
|
|
26812
26882
|
const f = _state_file(root);
|
|
26813
26883
|
let data = {};
|
|
26814
26884
|
try {
|
|
26815
|
-
data = JSON.parse(
|
|
26885
|
+
data = JSON.parse(fs59.readFileSync(f, "utf-8"));
|
|
26816
26886
|
} catch {
|
|
26817
26887
|
data = {};
|
|
26818
26888
|
}
|
|
@@ -26821,8 +26891,8 @@ function bump_session(root, session, key, added) {
|
|
|
26821
26891
|
bucket[key] = total;
|
|
26822
26892
|
data[session] = bucket;
|
|
26823
26893
|
try {
|
|
26824
|
-
|
|
26825
|
-
|
|
26894
|
+
fs59.mkdirSync(path60.dirname(f), { recursive: true });
|
|
26895
|
+
fs59.writeFileSync(f, `${JSON.stringify(data, null, 2)}
|
|
26826
26896
|
`, "utf-8");
|
|
26827
26897
|
} catch {
|
|
26828
26898
|
}
|
|
@@ -26872,7 +26942,7 @@ function main35() {
|
|
|
26872
26942
|
const abs = path60.isAbsolute(p) ? p : path60.join(root, p);
|
|
26873
26943
|
let on_disk = null;
|
|
26874
26944
|
try {
|
|
26875
|
-
on_disk =
|
|
26945
|
+
on_disk = fs59.readFileSync(abs, "utf-8");
|
|
26876
26946
|
} catch {
|
|
26877
26947
|
on_disk = null;
|
|
26878
26948
|
}
|
|
@@ -26908,7 +26978,7 @@ function _isCliEntry29() {
|
|
|
26908
26978
|
return true;
|
|
26909
26979
|
}
|
|
26910
26980
|
try {
|
|
26911
|
-
return
|
|
26981
|
+
return fs59.realpathSync(fileURLToPath38(import.meta.url)) === fs59.realpathSync(path60.resolve(process.argv[1]));
|
|
26912
26982
|
} catch {
|
|
26913
26983
|
return false;
|
|
26914
26984
|
}
|
|
@@ -26918,7 +26988,7 @@ if (_isCliEntry29() || process.argv[1] === _HERE6) {
|
|
|
26918
26988
|
}
|
|
26919
26989
|
|
|
26920
26990
|
// src/scripts/hooks/rtk_wrap_hook.ts
|
|
26921
|
-
import
|
|
26991
|
+
import fs60 from "node:fs";
|
|
26922
26992
|
import path61 from "node:path";
|
|
26923
26993
|
import { fileURLToPath as fileURLToPath39, pathToFileURL as pathToFileURL32 } from "node:url";
|
|
26924
26994
|
|
|
@@ -27064,13 +27134,13 @@ function _isObject13(v) {
|
|
|
27064
27134
|
function _enabled2(root) {
|
|
27065
27135
|
const f = path61.join(root, SETTINGS_FILE6);
|
|
27066
27136
|
try {
|
|
27067
|
-
if (!
|
|
27137
|
+
if (!fs60.statSync(f).isFile()) return false;
|
|
27068
27138
|
} catch {
|
|
27069
27139
|
return false;
|
|
27070
27140
|
}
|
|
27071
27141
|
let text;
|
|
27072
27142
|
try {
|
|
27073
|
-
text =
|
|
27143
|
+
text = fs60.readFileSync(f, "utf-8");
|
|
27074
27144
|
} catch {
|
|
27075
27145
|
return false;
|
|
27076
27146
|
}
|
|
@@ -27106,7 +27176,7 @@ function rtk_available(env = process.env) {
|
|
|
27106
27176
|
for (const ext of exts) {
|
|
27107
27177
|
const candidate = path61.join(dir, `rtk${ext}`);
|
|
27108
27178
|
try {
|
|
27109
|
-
const st =
|
|
27179
|
+
const st = fs60.statSync(candidate);
|
|
27110
27180
|
if (st.isFile()) {
|
|
27111
27181
|
if (process.platform === "win32" || (st.mode & 73) !== 0) return true;
|
|
27112
27182
|
}
|
|
@@ -27258,8 +27328,8 @@ function _isCliEntry30() {
|
|
|
27258
27328
|
return true;
|
|
27259
27329
|
}
|
|
27260
27330
|
try {
|
|
27261
|
-
const here =
|
|
27262
|
-
const argv =
|
|
27331
|
+
const here = fs60.realpathSync(fileURLToPath39(import.meta.url));
|
|
27332
|
+
const argv = fs60.realpathSync(path61.resolve(process.argv[1]));
|
|
27263
27333
|
return here === argv;
|
|
27264
27334
|
} catch {
|
|
27265
27335
|
return false;
|
|
@@ -27270,7 +27340,7 @@ if (_isCliEntry30()) {
|
|
|
27270
27340
|
}
|
|
27271
27341
|
|
|
27272
27342
|
// src/scripts/hooks/design_slop_hook.ts
|
|
27273
|
-
import
|
|
27343
|
+
import fs62 from "node:fs";
|
|
27274
27344
|
import path63 from "node:path";
|
|
27275
27345
|
import { fileURLToPath as fileURLToPath40, pathToFileURL as pathToFileURL33 } from "node:url";
|
|
27276
27346
|
|
|
@@ -27313,7 +27383,7 @@ function isUiTreePath(p) {
|
|
|
27313
27383
|
}
|
|
27314
27384
|
|
|
27315
27385
|
// src/scripts/lint_design_slop.ts
|
|
27316
|
-
import
|
|
27386
|
+
import fs61 from "node:fs";
|
|
27317
27387
|
import path62 from "node:path";
|
|
27318
27388
|
|
|
27319
27389
|
// src/scripts/design_slop_rules.ts
|
|
@@ -27819,8 +27889,8 @@ function enginesForExt(ext) {
|
|
|
27819
27889
|
return /* @__PURE__ */ new Set();
|
|
27820
27890
|
}
|
|
27821
27891
|
function* walkDir(dir, ext) {
|
|
27822
|
-
if (!
|
|
27823
|
-
for (const entry of
|
|
27892
|
+
if (!fs61.existsSync(dir)) return;
|
|
27893
|
+
for (const entry of fs61.readdirSync(dir, { withFileTypes: true })) {
|
|
27824
27894
|
const full = path62.join(dir, entry.name);
|
|
27825
27895
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
27826
27896
|
if (entry.isDirectory()) yield* walkDir(full, ext);
|
|
@@ -27829,9 +27899,9 @@ function* walkDir(dir, ext) {
|
|
|
27829
27899
|
}
|
|
27830
27900
|
function loadConfig(dir) {
|
|
27831
27901
|
const p = path62.join(dir, ".design-quality.json");
|
|
27832
|
-
if (!
|
|
27902
|
+
if (!fs61.existsSync(p)) return {};
|
|
27833
27903
|
try {
|
|
27834
|
-
return JSON.parse(
|
|
27904
|
+
return JSON.parse(fs61.readFileSync(p, "utf-8"));
|
|
27835
27905
|
} catch {
|
|
27836
27906
|
return {};
|
|
27837
27907
|
}
|
|
@@ -27844,8 +27914,8 @@ function loadDesignContext(scanDir) {
|
|
|
27844
27914
|
];
|
|
27845
27915
|
let raw = "";
|
|
27846
27916
|
for (const c of candidates) {
|
|
27847
|
-
if (
|
|
27848
|
-
raw =
|
|
27917
|
+
if (fs61.existsSync(c)) {
|
|
27918
|
+
raw = fs61.readFileSync(c, "utf-8").toLowerCase();
|
|
27849
27919
|
break;
|
|
27850
27920
|
}
|
|
27851
27921
|
}
|
|
@@ -27914,7 +27984,7 @@ function main37() {
|
|
|
27914
27984
|
const scanDir = dirIdx >= 0 && args[dirIdx + 1] ? path62.resolve(args[dirIdx + 1]) : path62.resolve(process.cwd(), "src");
|
|
27915
27985
|
const failIdx = args.indexOf("--fail-on");
|
|
27916
27986
|
const failOn = failIdx >= 0 ? args[failIdx + 1] : void 0;
|
|
27917
|
-
if (!
|
|
27987
|
+
if (!fs61.existsSync(scanDir)) {
|
|
27918
27988
|
if (!quiet) {
|
|
27919
27989
|
process.stderr.write(`[lint_design_slop] scan directory not found: ${scanDir}
|
|
27920
27990
|
`);
|
|
@@ -27950,7 +28020,7 @@ function main37() {
|
|
|
27950
28020
|
for (const fp of files) {
|
|
27951
28021
|
const rel = path62.relative(process.cwd(), fp);
|
|
27952
28022
|
try {
|
|
27953
|
-
const fileFindings = scanFile(
|
|
28023
|
+
const fileFindings = scanFile(fs61.readFileSync(fp, "utf-8"), rel, ctx).filter(
|
|
27954
28024
|
(f) => !ignoreRules.has(f.rule.toLowerCase())
|
|
27955
28025
|
);
|
|
27956
28026
|
findings.push(...fileFindings);
|
|
@@ -27997,8 +28067,8 @@ function enabled2(root) {
|
|
|
27997
28067
|
const f = path63.join(root, SETTINGS_FILE7);
|
|
27998
28068
|
let text;
|
|
27999
28069
|
try {
|
|
28000
|
-
if (!
|
|
28001
|
-
text =
|
|
28070
|
+
if (!fs62.statSync(f).isFile()) return false;
|
|
28071
|
+
text = fs62.readFileSync(f, "utf-8");
|
|
28002
28072
|
} catch {
|
|
28003
28073
|
return false;
|
|
28004
28074
|
}
|
|
@@ -28044,7 +28114,7 @@ function stateFile(root) {
|
|
|
28044
28114
|
}
|
|
28045
28115
|
function readState(root) {
|
|
28046
28116
|
try {
|
|
28047
|
-
const t =
|
|
28117
|
+
const t = fs62.readFileSync(stateFile(root), "utf-8");
|
|
28048
28118
|
const parsed = JSON.parse(t);
|
|
28049
28119
|
return isObject4(parsed) ? parsed : {};
|
|
28050
28120
|
} catch {
|
|
@@ -28054,8 +28124,8 @@ function readState(root) {
|
|
|
28054
28124
|
function writeState(root, state) {
|
|
28055
28125
|
try {
|
|
28056
28126
|
const sf = stateFile(root);
|
|
28057
|
-
|
|
28058
|
-
|
|
28127
|
+
fs62.mkdirSync(path63.dirname(sf), { recursive: true });
|
|
28128
|
+
fs62.writeFileSync(sf, JSON.stringify(state, null, 2) + "\n");
|
|
28059
28129
|
} catch {
|
|
28060
28130
|
}
|
|
28061
28131
|
}
|
|
@@ -28118,8 +28188,8 @@ function _isCliEntry31() {
|
|
|
28118
28188
|
return true;
|
|
28119
28189
|
}
|
|
28120
28190
|
try {
|
|
28121
|
-
const here =
|
|
28122
|
-
const argv =
|
|
28191
|
+
const here = fs62.realpathSync(fileURLToPath40(import.meta.url));
|
|
28192
|
+
const argv = fs62.realpathSync(path63.resolve(process.argv[1]));
|
|
28123
28193
|
return here === argv;
|
|
28124
28194
|
} catch {
|
|
28125
28195
|
return false;
|
|
@@ -28129,13 +28199,13 @@ var isCliEntry10 = _isCliEntry31();
|
|
|
28129
28199
|
if (isCliEntry10) process.exit(main38());
|
|
28130
28200
|
|
|
28131
28201
|
// src/scripts/hooks/code_graph_nudge_hook.ts
|
|
28132
|
-
import
|
|
28202
|
+
import fs64 from "node:fs";
|
|
28133
28203
|
import path65 from "node:path";
|
|
28134
28204
|
import { fileURLToPath as fileURLToPath41, pathToFileURL as pathToFileURL34 } from "node:url";
|
|
28135
28205
|
|
|
28136
28206
|
// src/scripts/code_graph/detect.ts
|
|
28137
28207
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
28138
|
-
import * as
|
|
28208
|
+
import * as fs63 from "node:fs";
|
|
28139
28209
|
import * as path64 from "node:path";
|
|
28140
28210
|
|
|
28141
28211
|
// src/scripts/code_graph/validate.ts
|
|
@@ -28217,7 +28287,7 @@ function freshness(root, file, embeddedSha) {
|
|
|
28217
28287
|
const last = gitLastCommitEpoch(root);
|
|
28218
28288
|
if (last === null) return {};
|
|
28219
28289
|
try {
|
|
28220
|
-
const mtime = Math.floor(
|
|
28290
|
+
const mtime = Math.floor(fs63.statSync(file).mtimeMs / 1e3);
|
|
28221
28291
|
return { stale: mtime < last };
|
|
28222
28292
|
} catch {
|
|
28223
28293
|
return {};
|
|
@@ -28225,7 +28295,7 @@ function freshness(root, file, embeddedSha) {
|
|
|
28225
28295
|
}
|
|
28226
28296
|
function looksLikeGraph(p) {
|
|
28227
28297
|
try {
|
|
28228
|
-
const raw = JSON.parse(
|
|
28298
|
+
const raw = JSON.parse(fs63.readFileSync(p, "utf-8"));
|
|
28229
28299
|
if (validateGraph(raw).ok) return { ok: true, sha: raw["head_at_build"] ?? null };
|
|
28230
28300
|
const nodes = raw["nodes"];
|
|
28231
28301
|
const edges = raw["edges"] ?? raw["links"];
|
|
@@ -28240,19 +28310,19 @@ function detectSources(root, nativeCache) {
|
|
|
28240
28310
|
const out = [];
|
|
28241
28311
|
for (const rel of CONSUMER_CANDIDATES) {
|
|
28242
28312
|
const p = path64.join(abs, rel);
|
|
28243
|
-
if (
|
|
28313
|
+
if (fs63.existsSync(p)) {
|
|
28244
28314
|
const { ok, sha } = looksLikeGraph(p);
|
|
28245
28315
|
if (ok) out.push({ kind: "consumer", path: p, present: true, ...freshness(abs, p, sha) });
|
|
28246
28316
|
}
|
|
28247
28317
|
}
|
|
28248
28318
|
const scipCandidates = [path64.join(abs, "index.scip")];
|
|
28249
28319
|
try {
|
|
28250
|
-
for (const e of
|
|
28320
|
+
for (const e of fs63.readdirSync(abs)) if (e.endsWith(".scip")) scipCandidates.push(path64.join(abs, e));
|
|
28251
28321
|
} catch {
|
|
28252
28322
|
}
|
|
28253
|
-
const scip = scipCandidates.find((p) =>
|
|
28323
|
+
const scip = scipCandidates.find((p) => fs63.existsSync(p));
|
|
28254
28324
|
if (scip) out.push({ kind: "scip", path: scip, present: true, note: "SCIP detected \u2014 peer tooling required (no owned reader)" });
|
|
28255
|
-
if (
|
|
28325
|
+
if (fs63.existsSync(nativeCache)) out.push({ kind: "native", path: nativeCache, present: true, ...freshness(abs, nativeCache, null) });
|
|
28256
28326
|
return out;
|
|
28257
28327
|
}
|
|
28258
28328
|
function pickSource(verdicts) {
|
|
@@ -28275,8 +28345,8 @@ function enabled3(root) {
|
|
|
28275
28345
|
const f = path65.join(root, SETTINGS_FILE8);
|
|
28276
28346
|
let text;
|
|
28277
28347
|
try {
|
|
28278
|
-
if (!
|
|
28279
|
-
text =
|
|
28348
|
+
if (!fs64.statSync(f).isFile()) return false;
|
|
28349
|
+
text = fs64.readFileSync(f, "utf-8");
|
|
28280
28350
|
} catch {
|
|
28281
28351
|
return false;
|
|
28282
28352
|
}
|
|
@@ -28323,7 +28393,7 @@ function latchFile(root) {
|
|
|
28323
28393
|
}
|
|
28324
28394
|
function alreadyNudged(root, session) {
|
|
28325
28395
|
try {
|
|
28326
|
-
const state = JSON.parse(
|
|
28396
|
+
const state = JSON.parse(fs64.readFileSync(latchFile(root), "utf-8"));
|
|
28327
28397
|
return state[session] === true;
|
|
28328
28398
|
} catch {
|
|
28329
28399
|
return false;
|
|
@@ -28334,12 +28404,12 @@ function latch(root, session) {
|
|
|
28334
28404
|
const p = latchFile(root);
|
|
28335
28405
|
let state = {};
|
|
28336
28406
|
try {
|
|
28337
|
-
state = JSON.parse(
|
|
28407
|
+
state = JSON.parse(fs64.readFileSync(p, "utf-8"));
|
|
28338
28408
|
} catch {
|
|
28339
28409
|
}
|
|
28340
28410
|
state[session] = true;
|
|
28341
|
-
|
|
28342
|
-
|
|
28411
|
+
fs64.mkdirSync(path65.dirname(p), { recursive: true });
|
|
28412
|
+
fs64.writeFileSync(p, JSON.stringify(state));
|
|
28343
28413
|
} catch {
|
|
28344
28414
|
}
|
|
28345
28415
|
}
|
|
@@ -28391,7 +28461,7 @@ function isCliEntry11() {
|
|
|
28391
28461
|
const argvUrl = pathToFileURL34(path65.resolve(process.argv[1])).href;
|
|
28392
28462
|
if (import.meta.url === argvUrl) return true;
|
|
28393
28463
|
try {
|
|
28394
|
-
return
|
|
28464
|
+
return fs64.realpathSync(fileURLToPath41(import.meta.url)) === fs64.realpathSync(path65.resolve(process.argv[1]));
|
|
28395
28465
|
} catch {
|
|
28396
28466
|
return false;
|
|
28397
28467
|
}
|
|
@@ -28399,20 +28469,20 @@ function isCliEntry11() {
|
|
|
28399
28469
|
if (isCliEntry11()) process.exit(main39());
|
|
28400
28470
|
|
|
28401
28471
|
// src/scripts/hooks/ui_route_nudge_hook.ts
|
|
28402
|
-
import * as
|
|
28472
|
+
import * as fs66 from "node:fs";
|
|
28403
28473
|
import * as path67 from "node:path";
|
|
28404
28474
|
import { fileURLToPath as fileURLToPath42, pathToFileURL as pathToFileURL35 } from "node:url";
|
|
28405
28475
|
|
|
28406
28476
|
// src/scripts/_lib/hook_settings.ts
|
|
28407
|
-
import * as
|
|
28477
|
+
import * as fs65 from "node:fs";
|
|
28408
28478
|
import * as path66 from "node:path";
|
|
28409
28479
|
var SETTINGS_FILE9 = ".agent-settings.yml";
|
|
28410
28480
|
function hookSectionEnabled(root, section) {
|
|
28411
28481
|
const file = path66.join(root, SETTINGS_FILE9);
|
|
28412
28482
|
let text;
|
|
28413
28483
|
try {
|
|
28414
|
-
if (!
|
|
28415
|
-
text =
|
|
28484
|
+
if (!fs65.statSync(file).isFile()) return false;
|
|
28485
|
+
text = fs65.readFileSync(file, "utf-8");
|
|
28416
28486
|
} catch {
|
|
28417
28487
|
return false;
|
|
28418
28488
|
}
|
|
@@ -28487,7 +28557,7 @@ function stateFile2(root) {
|
|
|
28487
28557
|
}
|
|
28488
28558
|
function readState2(root, session) {
|
|
28489
28559
|
try {
|
|
28490
|
-
const all = JSON.parse(
|
|
28560
|
+
const all = JSON.parse(fs66.readFileSync(stateFile2(root), "utf-8"));
|
|
28491
28561
|
const entry = all[session];
|
|
28492
28562
|
if (entry && typeof entry.consulted === "boolean" && typeof entry.nudges === "number") {
|
|
28493
28563
|
return entry;
|
|
@@ -28510,13 +28580,13 @@ function writeState2(root, session, state) {
|
|
|
28510
28580
|
const file = stateFile2(root);
|
|
28511
28581
|
let all = {};
|
|
28512
28582
|
try {
|
|
28513
|
-
all = JSON.parse(
|
|
28583
|
+
all = JSON.parse(fs66.readFileSync(file, "utf-8"));
|
|
28514
28584
|
} catch {
|
|
28515
28585
|
}
|
|
28516
28586
|
if (typeof all !== "object" || all === null || Array.isArray(all)) all = {};
|
|
28517
28587
|
all[session] = state;
|
|
28518
|
-
|
|
28519
|
-
|
|
28588
|
+
fs66.mkdirSync(path67.dirname(file), { recursive: true });
|
|
28589
|
+
fs66.writeFileSync(file, JSON.stringify(pruneSessions(all)));
|
|
28520
28590
|
} catch {
|
|
28521
28591
|
}
|
|
28522
28592
|
}
|
|
@@ -28572,7 +28642,7 @@ var _HOOK_FILE = fileURLToPath42(import.meta.url);
|
|
|
28572
28642
|
|
|
28573
28643
|
// src/scripts/hooks/orchestration_record_hook.ts
|
|
28574
28644
|
import * as crypto8 from "node:crypto";
|
|
28575
|
-
import * as
|
|
28645
|
+
import * as fs68 from "node:fs";
|
|
28576
28646
|
import * as path69 from "node:path";
|
|
28577
28647
|
import { fileURLToPath as fileURLToPath43, pathToFileURL as pathToFileURL37 } from "node:url";
|
|
28578
28648
|
|
|
@@ -28770,7 +28840,7 @@ function buildOrchestrationLine(input) {
|
|
|
28770
28840
|
|
|
28771
28841
|
// src/scripts/orchestration_record.ts
|
|
28772
28842
|
import * as crypto7 from "node:crypto";
|
|
28773
|
-
import * as
|
|
28843
|
+
import * as fs67 from "node:fs";
|
|
28774
28844
|
import * as path68 from "node:path";
|
|
28775
28845
|
import { pathToFileURL as pathToFileURL36 } from "node:url";
|
|
28776
28846
|
var DEFAULT_DIR = "agents/runtime/state/audit";
|
|
@@ -28883,9 +28953,9 @@ function main41(argv = process.argv.slice(2)) {
|
|
|
28883
28953
|
process.stdout.write(serialized + "\n");
|
|
28884
28954
|
return 0;
|
|
28885
28955
|
}
|
|
28886
|
-
|
|
28956
|
+
fs67.mkdirSync(dir, { recursive: true });
|
|
28887
28957
|
const file = path68.join(dir, `${ts.slice(0, 7)}.jsonl`);
|
|
28888
|
-
|
|
28958
|
+
fs67.appendFileSync(file, serialized + "\n", "utf8");
|
|
28889
28959
|
process.stdout.write(`orchestration telemetry recorded \u2192 ${file} (id ${line.id})
|
|
28890
28960
|
`);
|
|
28891
28961
|
return 0;
|
|
@@ -28992,8 +29062,8 @@ function auditFileFor(consumerRoot, ts) {
|
|
|
28992
29062
|
function appendLine(consumerRoot, ts, line) {
|
|
28993
29063
|
if (is_replay_mode()) return;
|
|
28994
29064
|
const file = auditFileFor(consumerRoot, ts);
|
|
28995
|
-
|
|
28996
|
-
|
|
29065
|
+
fs68.mkdirSync(path69.dirname(file), { recursive: true });
|
|
29066
|
+
fs68.appendFileSync(file, `${JSON.stringify(line)}
|
|
28997
29067
|
`, "utf8");
|
|
28998
29068
|
}
|
|
28999
29069
|
function processEnvelope2(envelope, consumer_root) {
|
|
@@ -29041,7 +29111,7 @@ function _isCliEntry32() {
|
|
|
29041
29111
|
const argvUrl = pathToFileURL37(path69.resolve(process.argv[1])).href;
|
|
29042
29112
|
if (import.meta.url === argvUrl) return true;
|
|
29043
29113
|
try {
|
|
29044
|
-
return
|
|
29114
|
+
return fs68.realpathSync(fileURLToPath43(import.meta.url)) === fs68.realpathSync(path69.resolve(process.argv[1]));
|
|
29045
29115
|
} catch {
|
|
29046
29116
|
return false;
|
|
29047
29117
|
}
|
|
@@ -29049,7 +29119,7 @@ function _isCliEntry32() {
|
|
|
29049
29119
|
if (_isCliEntry32()) process.exit(main42());
|
|
29050
29120
|
|
|
29051
29121
|
// src/scripts/hooks/telemetry_flush_hook.ts
|
|
29052
|
-
import * as
|
|
29122
|
+
import * as fs69 from "node:fs";
|
|
29053
29123
|
import * as path70 from "node:path";
|
|
29054
29124
|
import { fileURLToPath as fileURLToPath44, pathToFileURL as pathToFileURL38 } from "node:url";
|
|
29055
29125
|
var EXIT_ALLOW19 = 0;
|
|
@@ -29058,7 +29128,7 @@ function resolveSenderScript() {
|
|
|
29058
29128
|
try {
|
|
29059
29129
|
const here = path70.dirname(fileURLToPath44(import.meta.url));
|
|
29060
29130
|
const candidate = path70.resolve(here, SENDER_REL);
|
|
29061
|
-
return
|
|
29131
|
+
return fs69.statSync(candidate).isFile() ? candidate : null;
|
|
29062
29132
|
} catch {
|
|
29063
29133
|
return null;
|
|
29064
29134
|
}
|
|
@@ -29103,7 +29173,7 @@ function _isCliEntry33() {
|
|
|
29103
29173
|
const argvUrl = pathToFileURL38(path70.resolve(process.argv[1])).href;
|
|
29104
29174
|
if (import.meta.url === argvUrl) return true;
|
|
29105
29175
|
try {
|
|
29106
|
-
return
|
|
29176
|
+
return fs69.realpathSync(fileURLToPath44(import.meta.url)) === fs69.realpathSync(path70.resolve(process.argv[1]));
|
|
29107
29177
|
} catch {
|
|
29108
29178
|
return false;
|
|
29109
29179
|
}
|
|
@@ -29111,7 +29181,7 @@ function _isCliEntry33() {
|
|
|
29111
29181
|
if (_isCliEntry33()) process.exit(main43());
|
|
29112
29182
|
|
|
29113
29183
|
// src/scripts/hooks/delegation_nudge_hook.ts
|
|
29114
|
-
import
|
|
29184
|
+
import fs70 from "node:fs";
|
|
29115
29185
|
import path71 from "node:path";
|
|
29116
29186
|
import { fileURLToPath as fileURLToPath45, pathToFileURL as pathToFileURL39 } from "node:url";
|
|
29117
29187
|
|
|
@@ -29652,8 +29722,8 @@ function _isCliEntry34() {
|
|
|
29652
29722
|
return true;
|
|
29653
29723
|
}
|
|
29654
29724
|
try {
|
|
29655
|
-
const here =
|
|
29656
|
-
const argv =
|
|
29725
|
+
const here = fs70.realpathSync(fileURLToPath45(import.meta.url));
|
|
29726
|
+
const argv = fs70.realpathSync(path71.resolve(process.argv[1]));
|
|
29657
29727
|
return here === argv;
|
|
29658
29728
|
} catch {
|
|
29659
29729
|
return false;
|
|
@@ -29664,19 +29734,19 @@ if (_isCliEntry34()) {
|
|
|
29664
29734
|
}
|
|
29665
29735
|
|
|
29666
29736
|
// src/scripts/hooks/skill_route_hook.ts
|
|
29667
|
-
import
|
|
29737
|
+
import fs73 from "node:fs";
|
|
29668
29738
|
import path74 from "node:path";
|
|
29669
29739
|
import { fileURLToPath as fileURLToPath47, pathToFileURL as pathToFileURL41 } from "node:url";
|
|
29670
29740
|
|
|
29671
29741
|
// src/scripts/_lib/skill_catalogue.ts
|
|
29672
|
-
import * as
|
|
29742
|
+
import * as fs71 from "node:fs";
|
|
29673
29743
|
import * as path72 from "node:path";
|
|
29674
29744
|
var DEFAULT_CATALOGUE_ROOTS = [".claude/skills", "src/skills"];
|
|
29675
29745
|
function resolveSkillsRoot(workspaceRoot2) {
|
|
29676
29746
|
for (const candidate of DEFAULT_CATALOGUE_ROOTS) {
|
|
29677
29747
|
const abs = path72.join(workspaceRoot2, candidate);
|
|
29678
29748
|
try {
|
|
29679
|
-
if (
|
|
29749
|
+
if (fs71.existsSync(abs) && fs71.statSync(abs).isDirectory()) return abs;
|
|
29680
29750
|
} catch {
|
|
29681
29751
|
}
|
|
29682
29752
|
}
|
|
@@ -29708,9 +29778,9 @@ function headlineRecordPerHost(records) {
|
|
|
29708
29778
|
return out;
|
|
29709
29779
|
}
|
|
29710
29780
|
function readObservationLog(logPath) {
|
|
29711
|
-
if (!
|
|
29781
|
+
if (!fs71.existsSync(logPath)) return [];
|
|
29712
29782
|
const out = [];
|
|
29713
|
-
for (const line of
|
|
29783
|
+
for (const line of fs71.readFileSync(logPath, "utf-8").split("\n")) {
|
|
29714
29784
|
const trimmed = line.trim();
|
|
29715
29785
|
if (trimmed.length === 0) continue;
|
|
29716
29786
|
try {
|
|
@@ -29735,7 +29805,7 @@ function knownBareNames(records, host) {
|
|
|
29735
29805
|
}
|
|
29736
29806
|
|
|
29737
29807
|
// src/scripts/skill_tools/score_skill_relevance.ts
|
|
29738
|
-
import * as
|
|
29808
|
+
import * as fs72 from "node:fs";
|
|
29739
29809
|
import * as path73 from "node:path";
|
|
29740
29810
|
import { fileURLToPath as fileURLToPath46, pathToFileURL as pathToFileURL40 } from "node:url";
|
|
29741
29811
|
|
|
@@ -29868,7 +29938,7 @@ function _tokenize(text) {
|
|
|
29868
29938
|
return out;
|
|
29869
29939
|
}
|
|
29870
29940
|
function _parse_frontmatter(filePath) {
|
|
29871
|
-
const text =
|
|
29941
|
+
const text = fs72.readFileSync(filePath, "utf-8");
|
|
29872
29942
|
if (!text.startsWith("---")) {
|
|
29873
29943
|
return {};
|
|
29874
29944
|
}
|
|
@@ -29951,7 +30021,7 @@ function _truthyStr(v) {
|
|
|
29951
30021
|
function _globSkillMd(root) {
|
|
29952
30022
|
let names;
|
|
29953
30023
|
try {
|
|
29954
|
-
names =
|
|
30024
|
+
names = fs72.readdirSync(root);
|
|
29955
30025
|
} catch {
|
|
29956
30026
|
return [];
|
|
29957
30027
|
}
|
|
@@ -29960,7 +30030,7 @@ function _globSkillMd(root) {
|
|
|
29960
30030
|
const dir = path73.join(root, name);
|
|
29961
30031
|
const skillMd = path73.join(dir, "SKILL.md");
|
|
29962
30032
|
try {
|
|
29963
|
-
if (
|
|
30033
|
+
if (fs72.statSync(dir).isDirectory() && fs72.statSync(skillMd).isFile()) {
|
|
29964
30034
|
dirs.push(name);
|
|
29965
30035
|
}
|
|
29966
30036
|
} catch {
|
|
@@ -30199,8 +30269,8 @@ function _isCliEntry35() {
|
|
|
30199
30269
|
return true;
|
|
30200
30270
|
}
|
|
30201
30271
|
try {
|
|
30202
|
-
const here =
|
|
30203
|
-
const argv =
|
|
30272
|
+
const here = fs72.realpathSync(fileURLToPath46(import.meta.url));
|
|
30273
|
+
const argv = fs72.realpathSync(path73.resolve(process.argv[1]));
|
|
30204
30274
|
return here === argv;
|
|
30205
30275
|
} catch {
|
|
30206
30276
|
return false;
|
|
@@ -30318,8 +30388,8 @@ function _isCliEntry36() {
|
|
|
30318
30388
|
const argvUrl = pathToFileURL41(path74.resolve(process.argv[1])).href;
|
|
30319
30389
|
if (import.meta.url === argvUrl) return true;
|
|
30320
30390
|
try {
|
|
30321
|
-
const here =
|
|
30322
|
-
const argv =
|
|
30391
|
+
const here = fs73.realpathSync(fileURLToPath47(import.meta.url));
|
|
30392
|
+
const argv = fs73.realpathSync(path74.resolve(process.argv[1]));
|
|
30323
30393
|
return here === argv;
|
|
30324
30394
|
} catch {
|
|
30325
30395
|
return false;
|
|
@@ -30332,7 +30402,7 @@ if (_isCliEntry36()) {
|
|
|
30332
30402
|
// src/scripts/hooks/end_review_nudge_hook.ts
|
|
30333
30403
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
30334
30404
|
import * as crypto9 from "node:crypto";
|
|
30335
|
-
import * as
|
|
30405
|
+
import * as fs74 from "node:fs";
|
|
30336
30406
|
import * as os10 from "node:os";
|
|
30337
30407
|
import * as path75 from "node:path";
|
|
30338
30408
|
import { fileURLToPath as fileURLToPath48, pathToFileURL as pathToFileURL42 } from "node:url";
|
|
@@ -30382,13 +30452,13 @@ function isSafeTranscriptPath(rawPath, opts = {}) {
|
|
|
30382
30452
|
const homeDir = opts.homeDir ?? os10.homedir();
|
|
30383
30453
|
const maxBytes = opts.maxBytes ?? TRANSCRIPT_SCAN_MAX_BYTES;
|
|
30384
30454
|
try {
|
|
30385
|
-
const realHome =
|
|
30386
|
-
const realPath =
|
|
30455
|
+
const realHome = fs74.realpathSync(homeDir);
|
|
30456
|
+
const realPath = fs74.realpathSync(rawPath);
|
|
30387
30457
|
const relative9 = path75.relative(realHome, realPath);
|
|
30388
30458
|
if (relative9 === "" || relative9.startsWith("..") || path75.isAbsolute(relative9)) {
|
|
30389
30459
|
return false;
|
|
30390
30460
|
}
|
|
30391
|
-
const { size } =
|
|
30461
|
+
const { size } = fs74.statSync(realPath);
|
|
30392
30462
|
return size <= maxBytes;
|
|
30393
30463
|
} catch {
|
|
30394
30464
|
return false;
|
|
@@ -30448,12 +30518,12 @@ var UNTRACKED_FILE_READ_CAP_BYTES = 8 * 1024 * 1024;
|
|
|
30448
30518
|
function untrackedFileLineCount(cwd, relPath) {
|
|
30449
30519
|
try {
|
|
30450
30520
|
const abs = path75.resolve(cwd, relPath);
|
|
30451
|
-
const size =
|
|
30521
|
+
const size = fs74.statSync(abs).size;
|
|
30452
30522
|
if (size === 0) return 0;
|
|
30453
30523
|
if (size > UNTRACKED_FILE_READ_CAP_BYTES) {
|
|
30454
30524
|
return MUTATION_LINE_THRESHOLD + 1;
|
|
30455
30525
|
}
|
|
30456
|
-
const buf =
|
|
30526
|
+
const buf = fs74.readFileSync(abs);
|
|
30457
30527
|
if (buf.length === 0) return 0;
|
|
30458
30528
|
const probe = buf.subarray(0, Math.min(buf.length, BINARY_PROBE_BYTES));
|
|
30459
30529
|
if (probe.includes(0)) return 0;
|
|
@@ -30544,9 +30614,9 @@ function appendReviewSkippedTelemetry(workspaceRoot2, diffLines, mutationMeasure
|
|
|
30544
30614
|
if (errors.length || line === null) return;
|
|
30545
30615
|
try {
|
|
30546
30616
|
const dir = path75.join(workspaceRoot2, "agents", "runtime", "state", "audit");
|
|
30547
|
-
|
|
30617
|
+
fs74.mkdirSync(dir, { recursive: true });
|
|
30548
30618
|
const file = path75.join(dir, `${ts.slice(0, 7)}.jsonl`);
|
|
30549
|
-
|
|
30619
|
+
fs74.appendFileSync(file, `${JSON.stringify(line)}
|
|
30550
30620
|
`, "utf8");
|
|
30551
30621
|
} catch {
|
|
30552
30622
|
}
|
|
@@ -30564,7 +30634,7 @@ function deriveSessionKey2(envelope, payload) {
|
|
|
30564
30634
|
}
|
|
30565
30635
|
function hasFiredThisSession(workspaceRoot2, sessionKey) {
|
|
30566
30636
|
try {
|
|
30567
|
-
return
|
|
30637
|
+
return fs74.existsSync(sessionStateFile(workspaceRoot2, sessionKey));
|
|
30568
30638
|
} catch {
|
|
30569
30639
|
return false;
|
|
30570
30640
|
}
|
|
@@ -30607,7 +30677,7 @@ function main47() {
|
|
|
30607
30677
|
let reviewerRan = false;
|
|
30608
30678
|
if (transcriptPath && isSafeTranscriptPath(transcriptPath)) {
|
|
30609
30679
|
try {
|
|
30610
|
-
reviewerRan = scanTranscriptForReviewer(
|
|
30680
|
+
reviewerRan = scanTranscriptForReviewer(fs74.readFileSync(transcriptPath, "utf-8"));
|
|
30611
30681
|
} catch {
|
|
30612
30682
|
reviewerRan = false;
|
|
30613
30683
|
}
|
|
@@ -30642,8 +30712,8 @@ function _isCliEntry37() {
|
|
|
30642
30712
|
return true;
|
|
30643
30713
|
}
|
|
30644
30714
|
try {
|
|
30645
|
-
const here =
|
|
30646
|
-
const argv =
|
|
30715
|
+
const here = fs74.realpathSync(fileURLToPath48(import.meta.url));
|
|
30716
|
+
const argv = fs74.realpathSync(path75.resolve(process.argv[1]));
|
|
30647
30717
|
return here === argv;
|
|
30648
30718
|
} catch {
|
|
30649
30719
|
return false;
|
|
@@ -30654,13 +30724,13 @@ if (_isCliEntry37()) {
|
|
|
30654
30724
|
}
|
|
30655
30725
|
|
|
30656
30726
|
// src/scripts/hooks/turn_end_gate_hook.ts
|
|
30657
|
-
import * as
|
|
30727
|
+
import * as fs76 from "node:fs";
|
|
30658
30728
|
import * as path77 from "node:path";
|
|
30659
30729
|
import { fileURLToPath as fileURLToPath50, pathToFileURL as pathToFileURL44 } from "node:url";
|
|
30660
30730
|
|
|
30661
30731
|
// src/scripts/hooks/subagent_ledger_hook.ts
|
|
30662
30732
|
import * as crypto10 from "node:crypto";
|
|
30663
|
-
import * as
|
|
30733
|
+
import * as fs75 from "node:fs";
|
|
30664
30734
|
import * as path76 from "node:path";
|
|
30665
30735
|
import { fileURLToPath as fileURLToPath49, pathToFileURL as pathToFileURL43 } from "node:url";
|
|
30666
30736
|
|
|
@@ -30867,7 +30937,7 @@ function readOpenRecords(root) {
|
|
|
30867
30937
|
const out = /* @__PURE__ */ new Map();
|
|
30868
30938
|
let names;
|
|
30869
30939
|
try {
|
|
30870
|
-
names =
|
|
30940
|
+
names = fs75.readdirSync(openDir(root));
|
|
30871
30941
|
} catch {
|
|
30872
30942
|
return out;
|
|
30873
30943
|
}
|
|
@@ -30875,7 +30945,7 @@ function readOpenRecords(root) {
|
|
|
30875
30945
|
if (!name.endsWith(".json")) continue;
|
|
30876
30946
|
const expectedRef = name.slice(0, -".json".length);
|
|
30877
30947
|
try {
|
|
30878
|
-
const raw =
|
|
30948
|
+
const raw = fs75.readFileSync(path76.join(openDir(root), name), "utf8");
|
|
30879
30949
|
const rec = _asOpenRecord(JSON.parse(raw), expectedRef);
|
|
30880
30950
|
if (rec) out.set(rec.ref, rec);
|
|
30881
30951
|
} catch {
|
|
@@ -30895,8 +30965,8 @@ function ledgerFileFor2(root, ts) {
|
|
|
30895
30965
|
function appendLedgerLine(root, ts, line) {
|
|
30896
30966
|
if (is_replay_mode()) return;
|
|
30897
30967
|
const file = ledgerFileFor2(root, ts);
|
|
30898
|
-
|
|
30899
|
-
|
|
30968
|
+
fs75.mkdirSync(path76.dirname(file), { recursive: true });
|
|
30969
|
+
fs75.appendFileSync(file, `${JSON.stringify(line)}
|
|
30900
30970
|
`, "utf8");
|
|
30901
30971
|
}
|
|
30902
30972
|
var WALL_CLOCK_ARMS_MS = [
|
|
@@ -30910,7 +30980,7 @@ function armsExceeded(elapsedMs) {
|
|
|
30910
30980
|
return WALL_CLOCK_ARMS_MS.filter((a) => elapsedMs >= a.ms).map((a) => a.label);
|
|
30911
30981
|
}
|
|
30912
30982
|
function openRecordStats(root, nowMs = Date.now()) {
|
|
30913
|
-
const ledgerPresent =
|
|
30983
|
+
const ledgerPresent = fs75.existsSync(path76.join(root, LEDGER_DIR));
|
|
30914
30984
|
const open = readOpenRecords(root);
|
|
30915
30985
|
let maxDepth = 0;
|
|
30916
30986
|
let counted = 0;
|
|
@@ -30938,13 +31008,13 @@ function writeOpenRecord(root, rec) {
|
|
|
30938
31008
|
function removeOpenRecord(root, ref) {
|
|
30939
31009
|
if (is_replay_mode()) return;
|
|
30940
31010
|
try {
|
|
30941
|
-
|
|
31011
|
+
fs75.unlinkSync(openFile(root, ref));
|
|
30942
31012
|
} catch {
|
|
30943
31013
|
}
|
|
30944
31014
|
}
|
|
30945
31015
|
function countOpen(root) {
|
|
30946
31016
|
try {
|
|
30947
|
-
return
|
|
31017
|
+
return fs75.readdirSync(openDir(root)).filter((n) => n.endsWith(".json")).length;
|
|
30948
31018
|
} catch {
|
|
30949
31019
|
return 0;
|
|
30950
31020
|
}
|
|
@@ -31110,7 +31180,7 @@ function _isCliEntry38() {
|
|
|
31110
31180
|
const argvUrl = pathToFileURL43(path76.resolve(process.argv[1])).href;
|
|
31111
31181
|
if (import.meta.url === argvUrl) return true;
|
|
31112
31182
|
try {
|
|
31113
|
-
return
|
|
31183
|
+
return fs75.realpathSync(fileURLToPath49(import.meta.url)) === fs75.realpathSync(path76.resolve(process.argv[1]));
|
|
31114
31184
|
} catch {
|
|
31115
31185
|
return false;
|
|
31116
31186
|
}
|
|
@@ -31224,7 +31294,7 @@ function detectPromissory(reply) {
|
|
|
31224
31294
|
function readCiSettled(workspaceRoot2, session_id) {
|
|
31225
31295
|
if (!hasStableSessionId(session_id)) return { seen: false, settled: false };
|
|
31226
31296
|
try {
|
|
31227
|
-
const raw =
|
|
31297
|
+
const raw = fs76.readFileSync(path77.join(workspaceRoot2, statePathFor(session_id)), "utf-8");
|
|
31228
31298
|
const decoded = JSON.parse(raw);
|
|
31229
31299
|
if (!owns_session_state(decoded, session_id)) return { seen: false, settled: false };
|
|
31230
31300
|
if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
|
|
@@ -31260,7 +31330,7 @@ function detectCompletionClaim(reply, ci) {
|
|
|
31260
31330
|
function readLanguagePin(workspaceRoot2, session_id) {
|
|
31261
31331
|
if (!hasStableSessionId(session_id)) return "und";
|
|
31262
31332
|
try {
|
|
31263
|
-
const raw =
|
|
31333
|
+
const raw = fs76.readFileSync(
|
|
31264
31334
|
path77.join(workspaceRoot2, statePathFor2(session_id)),
|
|
31265
31335
|
"utf-8"
|
|
31266
31336
|
);
|
|
@@ -31317,7 +31387,7 @@ function sessionStateFile2(workspaceRoot2, sessionKey) {
|
|
|
31317
31387
|
}
|
|
31318
31388
|
function alreadyRefusedTurn(workspaceRoot2, sessionKey, turnOrdinal) {
|
|
31319
31389
|
try {
|
|
31320
|
-
const raw =
|
|
31390
|
+
const raw = fs76.readFileSync(sessionStateFile2(workspaceRoot2, sessionKey), "utf-8");
|
|
31321
31391
|
const decoded = JSON.parse(raw);
|
|
31322
31392
|
if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded)) {
|
|
31323
31393
|
return decoded["refused_turn"] === turnOrdinal;
|
|
@@ -31331,7 +31401,7 @@ function markRefusedTurn(workspaceRoot2, sessionKey, turnOrdinal, detectors) {
|
|
|
31331
31401
|
const file = sessionStateFile2(workspaceRoot2, sessionKey);
|
|
31332
31402
|
let prev = null;
|
|
31333
31403
|
try {
|
|
31334
|
-
prev = parseRecord(
|
|
31404
|
+
prev = parseRecord(fs76.readFileSync(file, "utf-8"));
|
|
31335
31405
|
} catch {
|
|
31336
31406
|
}
|
|
31337
31407
|
let version;
|
|
@@ -31358,10 +31428,10 @@ function readTranscriptTail(transcriptPath, opts = {}) {
|
|
|
31358
31428
|
if (!transcriptPath || !isSafeTranscriptPath(transcriptPath, opts)) return empty;
|
|
31359
31429
|
let lines;
|
|
31360
31430
|
try {
|
|
31361
|
-
if (opts.maxBytes !== void 0 &&
|
|
31431
|
+
if (opts.maxBytes !== void 0 && fs76.statSync(transcriptPath).size > opts.maxBytes) {
|
|
31362
31432
|
return empty;
|
|
31363
31433
|
}
|
|
31364
|
-
lines =
|
|
31434
|
+
lines = fs76.readFileSync(transcriptPath, "utf-8").split("\n");
|
|
31365
31435
|
} catch {
|
|
31366
31436
|
return empty;
|
|
31367
31437
|
}
|
|
@@ -31516,8 +31586,8 @@ function _isCliEntry39() {
|
|
|
31516
31586
|
return true;
|
|
31517
31587
|
}
|
|
31518
31588
|
try {
|
|
31519
|
-
const here =
|
|
31520
|
-
const argv =
|
|
31589
|
+
const here = fs76.realpathSync(fileURLToPath50(import.meta.url));
|
|
31590
|
+
const argv = fs76.realpathSync(path77.resolve(process.argv[1]));
|
|
31521
31591
|
return here === argv;
|
|
31522
31592
|
} catch {
|
|
31523
31593
|
return false;
|
|
@@ -31530,7 +31600,7 @@ if (_isCliEntry39()) {
|
|
|
31530
31600
|
// src/scripts/hooks/edit_shape_hook.ts
|
|
31531
31601
|
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
31532
31602
|
import * as crypto11 from "node:crypto";
|
|
31533
|
-
import * as
|
|
31603
|
+
import * as fs77 from "node:fs";
|
|
31534
31604
|
import * as path78 from "node:path";
|
|
31535
31605
|
import { fileURLToPath as fileURLToPath51, pathToFileURL as pathToFileURL45 } from "node:url";
|
|
31536
31606
|
var EXIT_ALLOW24 = 0;
|
|
@@ -31585,7 +31655,7 @@ function effectiveDiffLines(cwd, relPath) {
|
|
|
31585
31655
|
}
|
|
31586
31656
|
function fileLineCount(absPath) {
|
|
31587
31657
|
try {
|
|
31588
|
-
const text =
|
|
31658
|
+
const text = fs77.readFileSync(absPath, "utf8");
|
|
31589
31659
|
if (text.length === 0) return 0;
|
|
31590
31660
|
return text.split("\n").length - (text.endsWith("\n") ? 1 : 0);
|
|
31591
31661
|
} catch {
|
|
@@ -31606,7 +31676,7 @@ function sessionStateFile3(workspaceRoot2, sessionKey) {
|
|
|
31606
31676
|
}
|
|
31607
31677
|
function hasFiredThisSession2(workspaceRoot2, sessionKey) {
|
|
31608
31678
|
try {
|
|
31609
|
-
return
|
|
31679
|
+
return fs77.existsSync(sessionStateFile3(workspaceRoot2, sessionKey));
|
|
31610
31680
|
} catch {
|
|
31611
31681
|
return false;
|
|
31612
31682
|
}
|
|
@@ -31673,8 +31743,8 @@ function _isCliEntry40() {
|
|
|
31673
31743
|
return true;
|
|
31674
31744
|
}
|
|
31675
31745
|
try {
|
|
31676
|
-
const here =
|
|
31677
|
-
const argv =
|
|
31746
|
+
const here = fs77.realpathSync(fileURLToPath51(import.meta.url));
|
|
31747
|
+
const argv = fs77.realpathSync(path78.resolve(process.argv[1]));
|
|
31678
31748
|
return here === argv;
|
|
31679
31749
|
} catch {
|
|
31680
31750
|
return false;
|
|
@@ -31686,7 +31756,7 @@ if (_isCliEntry40()) {
|
|
|
31686
31756
|
|
|
31687
31757
|
// src/scripts/hooks/reread_guard_hook.ts
|
|
31688
31758
|
import * as crypto12 from "node:crypto";
|
|
31689
|
-
import * as
|
|
31759
|
+
import * as fs78 from "node:fs";
|
|
31690
31760
|
import * as path79 from "node:path";
|
|
31691
31761
|
import { fileURLToPath as fileURLToPath52, pathToFileURL as pathToFileURL46 } from "node:url";
|
|
31692
31762
|
var EXIT_ALLOW25 = 0;
|
|
@@ -31728,7 +31798,7 @@ function ledgerFile(workspaceRoot2, sessionKey) {
|
|
|
31728
31798
|
}
|
|
31729
31799
|
function readLedger(workspaceRoot2, sessionKey) {
|
|
31730
31800
|
try {
|
|
31731
|
-
const parsed = JSON.parse(
|
|
31801
|
+
const parsed = JSON.parse(fs78.readFileSync(ledgerFile(workspaceRoot2, sessionKey), "utf8"));
|
|
31732
31802
|
if (!isObject11(parsed)) return emptyLedger();
|
|
31733
31803
|
return {
|
|
31734
31804
|
reads: isObject11(parsed["reads"]) ? parsed["reads"] : {},
|
|
@@ -31799,7 +31869,7 @@ function main51() {
|
|
|
31799
31869
|
let mtime;
|
|
31800
31870
|
let size;
|
|
31801
31871
|
try {
|
|
31802
|
-
const st =
|
|
31872
|
+
const st = fs78.statSync(absPath);
|
|
31803
31873
|
mtime = st.mtimeMs;
|
|
31804
31874
|
size = st.size;
|
|
31805
31875
|
} catch {
|
|
@@ -31844,8 +31914,8 @@ function _isCliEntry41() {
|
|
|
31844
31914
|
return true;
|
|
31845
31915
|
}
|
|
31846
31916
|
try {
|
|
31847
|
-
const here =
|
|
31848
|
-
const argv =
|
|
31917
|
+
const here = fs78.realpathSync(fileURLToPath52(import.meta.url));
|
|
31918
|
+
const argv = fs78.realpathSync(path79.resolve(process.argv[1]));
|
|
31849
31919
|
return here === argv;
|
|
31850
31920
|
} catch {
|
|
31851
31921
|
return false;
|
|
@@ -31856,7 +31926,7 @@ if (_isCliEntry41()) {
|
|
|
31856
31926
|
}
|
|
31857
31927
|
|
|
31858
31928
|
// src/scripts/hooks/session_eol_hook.ts
|
|
31859
|
-
import * as
|
|
31929
|
+
import * as fs81 from "node:fs";
|
|
31860
31930
|
import * as path83 from "node:path";
|
|
31861
31931
|
import process11 from "node:process";
|
|
31862
31932
|
import { fileURLToPath as fileURLToPath53, pathToFileURL as pathToFileURL47 } from "node:url";
|
|
@@ -31877,7 +31947,7 @@ var recycle_threshold_budget_default = {
|
|
|
31877
31947
|
|
|
31878
31948
|
// src/scripts/_lib/session_eol.ts
|
|
31879
31949
|
import * as crypto13 from "node:crypto";
|
|
31880
|
-
import * as
|
|
31950
|
+
import * as fs79 from "node:fs";
|
|
31881
31951
|
import * as path81 from "node:path";
|
|
31882
31952
|
|
|
31883
31953
|
// src/scripts/_lib/cc_transcript.ts
|
|
@@ -32002,7 +32072,7 @@ function eolSessionKey(raw) {
|
|
|
32002
32072
|
}
|
|
32003
32073
|
function readNewCompleteLines(filePath, fromByte) {
|
|
32004
32074
|
try {
|
|
32005
|
-
const { size } =
|
|
32075
|
+
const { size } = fs79.statSync(filePath);
|
|
32006
32076
|
if (size < fromByte) {
|
|
32007
32077
|
return { text: "", nextOffset: 0, truncated: true };
|
|
32008
32078
|
}
|
|
@@ -32011,11 +32081,11 @@ function readNewCompleteLines(filePath, fromByte) {
|
|
|
32011
32081
|
}
|
|
32012
32082
|
const length = size - fromByte;
|
|
32013
32083
|
const buffer = Buffer.alloc(length);
|
|
32014
|
-
const fd =
|
|
32084
|
+
const fd = fs79.openSync(filePath, "r");
|
|
32015
32085
|
try {
|
|
32016
|
-
|
|
32086
|
+
fs79.readSync(fd, buffer, 0, length, fromByte);
|
|
32017
32087
|
} finally {
|
|
32018
|
-
|
|
32088
|
+
fs79.closeSync(fd);
|
|
32019
32089
|
}
|
|
32020
32090
|
const lastNewline = buffer.lastIndexOf(10);
|
|
32021
32091
|
if (lastNewline === -1) {
|
|
@@ -32032,7 +32102,7 @@ function readNewCompleteLines(filePath, fromByte) {
|
|
|
32032
32102
|
}
|
|
32033
32103
|
|
|
32034
32104
|
// src/scripts/_lib/run_checkpoint.ts
|
|
32035
|
-
import * as
|
|
32105
|
+
import * as fs80 from "node:fs";
|
|
32036
32106
|
import * as path82 from "node:path";
|
|
32037
32107
|
|
|
32038
32108
|
// src/scripts/_lib/roadmap_checkboxes.ts
|
|
@@ -32092,26 +32162,26 @@ function roadmapPath(repoRoot, slug) {
|
|
|
32092
32162
|
function readHead(repoRoot) {
|
|
32093
32163
|
try {
|
|
32094
32164
|
let gitDir = path82.join(repoRoot, ".git");
|
|
32095
|
-
if (
|
|
32096
|
-
const m = /^gitdir:\s*(.+)$/m.exec(
|
|
32165
|
+
if (fs80.statSync(gitDir).isFile()) {
|
|
32166
|
+
const m = /^gitdir:\s*(.+)$/m.exec(fs80.readFileSync(gitDir, "utf-8").trim());
|
|
32097
32167
|
if (m === null) return null;
|
|
32098
32168
|
gitDir = path82.resolve(repoRoot, m[1]);
|
|
32099
32169
|
}
|
|
32100
32170
|
let refRoot = gitDir;
|
|
32101
32171
|
try {
|
|
32102
|
-
const common =
|
|
32172
|
+
const common = fs80.readFileSync(path82.join(gitDir, "commondir"), "utf-8").trim();
|
|
32103
32173
|
if (common !== "") refRoot = path82.resolve(gitDir, common);
|
|
32104
32174
|
} catch {
|
|
32105
32175
|
}
|
|
32106
|
-
const head =
|
|
32176
|
+
const head = fs80.readFileSync(path82.join(gitDir, "HEAD"), "utf-8").trim();
|
|
32107
32177
|
if (/^[0-9a-f]{40}$/.test(head)) return head;
|
|
32108
32178
|
const ref = /^ref:\s*(.+)$/.exec(head);
|
|
32109
32179
|
if (ref === null) return null;
|
|
32110
32180
|
const refName = ref[1];
|
|
32111
32181
|
try {
|
|
32112
|
-
return
|
|
32182
|
+
return fs80.readFileSync(path82.join(refRoot, refName), "utf-8").trim() || null;
|
|
32113
32183
|
} catch {
|
|
32114
|
-
const packed =
|
|
32184
|
+
const packed = fs80.readFileSync(path82.join(refRoot, "packed-refs"), "utf-8");
|
|
32115
32185
|
for (const line of packed.split("\n")) {
|
|
32116
32186
|
const pm = /^([0-9a-f]{40})\s+(.+)$/.exec(line.trim());
|
|
32117
32187
|
if (pm !== null && pm[2] === refName) return pm[1];
|
|
@@ -32125,7 +32195,7 @@ function readHead(repoRoot) {
|
|
|
32125
32195
|
function buildCheckpoint(repoRoot, runId, slug, opts = {}) {
|
|
32126
32196
|
let text;
|
|
32127
32197
|
try {
|
|
32128
|
-
text =
|
|
32198
|
+
text = fs80.readFileSync(roadmapPath(repoRoot, slug), "utf-8");
|
|
32129
32199
|
} catch {
|
|
32130
32200
|
return null;
|
|
32131
32201
|
}
|
|
@@ -32145,8 +32215,8 @@ function buildCheckpoint(repoRoot, runId, slug, opts = {}) {
|
|
|
32145
32215
|
function writeCheckpoint(repoRoot, cp) {
|
|
32146
32216
|
const file = checkpointFile(repoRoot, cp.run_id);
|
|
32147
32217
|
try {
|
|
32148
|
-
|
|
32149
|
-
|
|
32218
|
+
fs80.mkdirSync(path82.dirname(file), { recursive: true });
|
|
32219
|
+
fs80.writeFileSync(file, `${JSON.stringify(cp, null, 2)}
|
|
32150
32220
|
`, "utf-8");
|
|
32151
32221
|
return file;
|
|
32152
32222
|
} catch {
|
|
@@ -32172,7 +32242,7 @@ function payloadSessionId(payload, envelope) {
|
|
|
32172
32242
|
}
|
|
32173
32243
|
function readState3(file) {
|
|
32174
32244
|
try {
|
|
32175
|
-
const parsed = JSON.parse(
|
|
32245
|
+
const parsed = JSON.parse(fs81.readFileSync(file, "utf-8"));
|
|
32176
32246
|
if (parsed && typeof parsed === "object" && parsed.schema_version === 1 && parsed.counters && typeof parsed.counters.scanned_bytes === "number") {
|
|
32177
32247
|
return {
|
|
32178
32248
|
schema_version: 1,
|
|
@@ -32196,7 +32266,7 @@ function envelopeExists(workspaceRoot2, since = null) {
|
|
|
32196
32266
|
const target = path83.join(workspaceRoot2, RECYCLE_ENVELOPE_REL);
|
|
32197
32267
|
let raw;
|
|
32198
32268
|
try {
|
|
32199
|
-
raw =
|
|
32269
|
+
raw = fs81.readFileSync(target, "utf-8");
|
|
32200
32270
|
} catch (exc) {
|
|
32201
32271
|
return exc?.code !== "ENOENT";
|
|
32202
32272
|
}
|
|
@@ -32331,8 +32401,8 @@ function _isCliEntry42() {
|
|
|
32331
32401
|
return true;
|
|
32332
32402
|
}
|
|
32333
32403
|
try {
|
|
32334
|
-
const here =
|
|
32335
|
-
const argv =
|
|
32404
|
+
const here = fs81.realpathSync(fileURLToPath53(import.meta.url));
|
|
32405
|
+
const argv = fs81.realpathSync(path83.resolve(process11.argv[1]));
|
|
32336
32406
|
return here === argv;
|
|
32337
32407
|
} catch {
|
|
32338
32408
|
return false;
|
|
@@ -32343,7 +32413,7 @@ if (_isCliEntry42()) {
|
|
|
32343
32413
|
}
|
|
32344
32414
|
|
|
32345
32415
|
// src/scripts/hooks/tool_result_bytes_hook.ts
|
|
32346
|
-
import * as
|
|
32416
|
+
import * as fs82 from "node:fs";
|
|
32347
32417
|
import * as path84 from "node:path";
|
|
32348
32418
|
import { fileURLToPath as fileURLToPath54, pathToFileURL as pathToFileURL48 } from "node:url";
|
|
32349
32419
|
var EXIT_ALLOW26 = 0;
|
|
@@ -32390,8 +32460,8 @@ function censusFile(consumerRoot) {
|
|
|
32390
32460
|
function _appendCensusLine(consumerRoot, line) {
|
|
32391
32461
|
if (is_replay_mode()) return;
|
|
32392
32462
|
const file = censusFile(consumerRoot);
|
|
32393
|
-
|
|
32394
|
-
|
|
32463
|
+
fs82.mkdirSync(path84.dirname(file), { recursive: true });
|
|
32464
|
+
fs82.appendFileSync(file, `${JSON.stringify(line)}
|
|
32395
32465
|
`, "utf8");
|
|
32396
32466
|
}
|
|
32397
32467
|
function processEnvelope4(envelope, consumerRoot) {
|
|
@@ -32440,7 +32510,7 @@ function _isCliEntry43() {
|
|
|
32440
32510
|
const argvUrl = pathToFileURL48(path84.resolve(process.argv[1])).href;
|
|
32441
32511
|
if (import.meta.url === argvUrl) return true;
|
|
32442
32512
|
try {
|
|
32443
|
-
return
|
|
32513
|
+
return fs82.realpathSync(fileURLToPath54(import.meta.url)) === fs82.realpathSync(path84.resolve(process.argv[1]));
|
|
32444
32514
|
} catch {
|
|
32445
32515
|
return false;
|
|
32446
32516
|
}
|
|
@@ -32448,7 +32518,7 @@ function _isCliEntry43() {
|
|
|
32448
32518
|
if (_isCliEntry43()) process.exit(main53());
|
|
32449
32519
|
|
|
32450
32520
|
// src/scripts/hooks/spawn_guard_shadow_hook.ts
|
|
32451
|
-
import * as
|
|
32521
|
+
import * as fs83 from "node:fs";
|
|
32452
32522
|
import * as path85 from "node:path";
|
|
32453
32523
|
import { fileURLToPath as fileURLToPath55, pathToFileURL as pathToFileURL49 } from "node:url";
|
|
32454
32524
|
var EXIT_ALLOW27 = 0;
|
|
@@ -32530,7 +32600,7 @@ function _isCliEntry44() {
|
|
|
32530
32600
|
const argvUrl = pathToFileURL49(path85.resolve(process.argv[1])).href;
|
|
32531
32601
|
if (import.meta.url === argvUrl) return true;
|
|
32532
32602
|
try {
|
|
32533
|
-
return
|
|
32603
|
+
return fs83.realpathSync(fileURLToPath55(import.meta.url)) === fs83.realpathSync(path85.resolve(process.argv[1]));
|
|
32534
32604
|
} catch {
|
|
32535
32605
|
return false;
|
|
32536
32606
|
}
|
|
@@ -32538,7 +32608,7 @@ function _isCliEntry44() {
|
|
|
32538
32608
|
if (_isCliEntry44()) process.exit(main54());
|
|
32539
32609
|
|
|
32540
32610
|
// src/scripts/hooks/source_first_gate_hook.ts
|
|
32541
|
-
import * as
|
|
32611
|
+
import * as fs84 from "node:fs";
|
|
32542
32612
|
import * as path86 from "node:path";
|
|
32543
32613
|
import { fileURLToPath as fileURLToPath56, pathToFileURL as pathToFileURL50 } from "node:url";
|
|
32544
32614
|
var EXIT_ALLOW28 = 0;
|
|
@@ -32618,7 +32688,7 @@ var EMPTY_STATE = { handoverSeen: false, sourceRead: false, wouldWarn: 0 };
|
|
|
32618
32688
|
var MAX_SESSIONS2 = 50;
|
|
32619
32689
|
function readState4(root, session) {
|
|
32620
32690
|
try {
|
|
32621
|
-
const all = JSON.parse(
|
|
32691
|
+
const all = JSON.parse(fs84.readFileSync(path86.join(root, STATE_FILE9), "utf-8"));
|
|
32622
32692
|
const entry = all[session];
|
|
32623
32693
|
if (entry && typeof entry.handoverSeen === "boolean" && typeof entry.sourceRead === "boolean" && typeof entry.wouldWarn === "number") {
|
|
32624
32694
|
return entry;
|
|
@@ -32633,7 +32703,7 @@ function writeState3(root, session, state) {
|
|
|
32633
32703
|
const file = path86.join(root, STATE_FILE9);
|
|
32634
32704
|
let all = {};
|
|
32635
32705
|
try {
|
|
32636
|
-
all = JSON.parse(
|
|
32706
|
+
all = JSON.parse(fs84.readFileSync(file, "utf-8"));
|
|
32637
32707
|
} catch {
|
|
32638
32708
|
}
|
|
32639
32709
|
if (!isObject14(all)) all = {};
|
|
@@ -32644,8 +32714,8 @@ function writeState3(root, session, state) {
|
|
|
32644
32714
|
for (const key of keys.slice(keys.length - MAX_SESSIONS2)) pruned[key] = all[key];
|
|
32645
32715
|
all = pruned;
|
|
32646
32716
|
}
|
|
32647
|
-
|
|
32648
|
-
|
|
32717
|
+
fs84.mkdirSync(path86.dirname(file), { recursive: true });
|
|
32718
|
+
fs84.writeFileSync(file, JSON.stringify(all));
|
|
32649
32719
|
} catch {
|
|
32650
32720
|
}
|
|
32651
32721
|
}
|
|
@@ -32666,7 +32736,7 @@ function evaluateCandidates2(handoverSeen, handoverOnDisk, sourceRead) {
|
|
|
32666
32736
|
}
|
|
32667
32737
|
function handoverPresentOnDisk(root) {
|
|
32668
32738
|
try {
|
|
32669
|
-
return
|
|
32739
|
+
return fs84.statSync(path86.join(root, ".claude", "design-system")).isDirectory();
|
|
32670
32740
|
} catch {
|
|
32671
32741
|
return false;
|
|
32672
32742
|
}
|
|
@@ -32675,8 +32745,8 @@ function appendShadowLine(root, line) {
|
|
|
32675
32745
|
if (is_replay_mode()) return;
|
|
32676
32746
|
try {
|
|
32677
32747
|
const file = path86.join(root, SHADOW_LOG);
|
|
32678
|
-
|
|
32679
|
-
|
|
32748
|
+
fs84.mkdirSync(path86.dirname(file), { recursive: true });
|
|
32749
|
+
fs84.appendFileSync(file, `${JSON.stringify(line)}
|
|
32680
32750
|
`, "utf8");
|
|
32681
32751
|
} catch {
|
|
32682
32752
|
}
|
|
@@ -32755,7 +32825,7 @@ function _isCliEntry45() {
|
|
|
32755
32825
|
const argvUrl = pathToFileURL50(path86.resolve(process.argv[1])).href;
|
|
32756
32826
|
if (import.meta.url === argvUrl) return true;
|
|
32757
32827
|
try {
|
|
32758
|
-
return
|
|
32828
|
+
return fs84.realpathSync(fileURLToPath56(import.meta.url)) === fs84.realpathSync(path86.resolve(process.argv[1]));
|
|
32759
32829
|
} catch {
|
|
32760
32830
|
return false;
|
|
32761
32831
|
}
|
|
@@ -32763,7 +32833,7 @@ function _isCliEntry45() {
|
|
|
32763
32833
|
if (_isCliEntry45()) process.exit(main55());
|
|
32764
32834
|
|
|
32765
32835
|
// src/scripts/hooks/interruption_ledger_hook.ts
|
|
32766
|
-
import * as
|
|
32836
|
+
import * as fs85 from "node:fs";
|
|
32767
32837
|
import * as path87 from "node:path";
|
|
32768
32838
|
import { fileURLToPath as fileURLToPath57, pathToFileURL as pathToFileURL51 } from "node:url";
|
|
32769
32839
|
var EXIT_OK2 = 0;
|
|
@@ -32799,7 +32869,7 @@ function readClaimedRoadmap(workspaceRoot2, sessionId2) {
|
|
|
32799
32869
|
"state",
|
|
32800
32870
|
`roadmap-claim-${sessionId2}.json`
|
|
32801
32871
|
);
|
|
32802
|
-
const parsed = JSON.parse(
|
|
32872
|
+
const parsed = JSON.parse(fs85.readFileSync(file, "utf8"));
|
|
32803
32873
|
if (parsed === null || typeof parsed !== "object") return null;
|
|
32804
32874
|
const slug = parsed["slug"];
|
|
32805
32875
|
return typeof slug === "string" && slug.length > 0 ? slug : null;
|
|
@@ -32810,7 +32880,7 @@ function readClaimedRoadmap(workspaceRoot2, sessionId2) {
|
|
|
32810
32880
|
function alreadyRecorded(ledgerPath, runId, turn) {
|
|
32811
32881
|
let raw;
|
|
32812
32882
|
try {
|
|
32813
|
-
raw =
|
|
32883
|
+
raw = fs85.readFileSync(ledgerPath, "utf8");
|
|
32814
32884
|
} catch {
|
|
32815
32885
|
return false;
|
|
32816
32886
|
}
|
|
@@ -32866,8 +32936,8 @@ function main56() {
|
|
|
32866
32936
|
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
32867
32937
|
};
|
|
32868
32938
|
try {
|
|
32869
|
-
|
|
32870
|
-
|
|
32939
|
+
fs85.mkdirSync(path87.dirname(ledgerPath), { recursive: true });
|
|
32940
|
+
fs85.appendFileSync(ledgerPath, `${JSON.stringify(record)}
|
|
32871
32941
|
`, "utf8");
|
|
32872
32942
|
} catch {
|
|
32873
32943
|
}
|
|
@@ -32882,8 +32952,8 @@ function _isCliEntry46() {
|
|
|
32882
32952
|
return true;
|
|
32883
32953
|
}
|
|
32884
32954
|
try {
|
|
32885
|
-
const here =
|
|
32886
|
-
const argv =
|
|
32955
|
+
const here = fs85.realpathSync(fileURLToPath57(import.meta.url));
|
|
32956
|
+
const argv = fs85.realpathSync(path87.resolve(process.argv[1]));
|
|
32887
32957
|
return here === argv;
|
|
32888
32958
|
} catch {
|
|
32889
32959
|
return false;
|
|
@@ -32894,7 +32964,7 @@ if (_isCliEntry46()) {
|
|
|
32894
32964
|
}
|
|
32895
32965
|
|
|
32896
32966
|
// src/scripts/hooks/run_continuation_hook.ts
|
|
32897
|
-
import * as
|
|
32967
|
+
import * as fs86 from "node:fs";
|
|
32898
32968
|
import * as path88 from "node:path";
|
|
32899
32969
|
import { fileURLToPath as fileURLToPath58, pathToFileURL as pathToFileURL52 } from "node:url";
|
|
32900
32970
|
var EXIT_ALLOW29 = 0;
|
|
@@ -33027,8 +33097,8 @@ function readRunState(workspaceRoot2, runId, slug) {
|
|
|
33027
33097
|
}
|
|
33028
33098
|
function writeState4(file, state) {
|
|
33029
33099
|
try {
|
|
33030
|
-
|
|
33031
|
-
|
|
33100
|
+
fs86.mkdirSync(path88.dirname(file), { recursive: true });
|
|
33101
|
+
fs86.writeFileSync(file, `${JSON.stringify(state)}
|
|
33032
33102
|
`, "utf8");
|
|
33033
33103
|
return true;
|
|
33034
33104
|
} catch {
|
|
@@ -33037,25 +33107,25 @@ function writeState4(file, state) {
|
|
|
33037
33107
|
}
|
|
33038
33108
|
function clearRunState(workspaceRoot2, runId, keyedFile, adoptedLegacy) {
|
|
33039
33109
|
try {
|
|
33040
|
-
|
|
33110
|
+
fs86.rmSync(keyedFile, { force: true });
|
|
33041
33111
|
} catch {
|
|
33042
33112
|
}
|
|
33043
33113
|
if (!adoptedLegacy) return;
|
|
33044
33114
|
try {
|
|
33045
|
-
|
|
33115
|
+
fs86.rmSync(path88.join(workspaceRoot2, legacyStateRelPath(runId)), { force: true });
|
|
33046
33116
|
} catch {
|
|
33047
33117
|
}
|
|
33048
33118
|
}
|
|
33049
33119
|
function fileExists(p) {
|
|
33050
33120
|
try {
|
|
33051
|
-
return
|
|
33121
|
+
return fs86.statSync(p).isFile();
|
|
33052
33122
|
} catch {
|
|
33053
33123
|
return false;
|
|
33054
33124
|
}
|
|
33055
33125
|
}
|
|
33056
33126
|
function readState5(file) {
|
|
33057
33127
|
try {
|
|
33058
|
-
const parsed = JSON.parse(
|
|
33128
|
+
const parsed = JSON.parse(fs86.readFileSync(file, "utf8"));
|
|
33059
33129
|
if (parsed === null || typeof parsed !== "object") return null;
|
|
33060
33130
|
const o = parsed;
|
|
33061
33131
|
if (typeof o["started_at"] !== "string") return null;
|
|
@@ -33097,7 +33167,7 @@ function readState5(file) {
|
|
|
33097
33167
|
function normalizeDir(p) {
|
|
33098
33168
|
const abs = path88.resolve(p);
|
|
33099
33169
|
try {
|
|
33100
|
-
return
|
|
33170
|
+
return fs86.realpathSync(abs);
|
|
33101
33171
|
} catch {
|
|
33102
33172
|
return abs;
|
|
33103
33173
|
}
|
|
@@ -33143,7 +33213,7 @@ function resolveRoadmap(sessionRoot, workspaceRoot2, slug) {
|
|
|
33143
33213
|
}
|
|
33144
33214
|
function isDirectory(p) {
|
|
33145
33215
|
try {
|
|
33146
|
-
return
|
|
33216
|
+
return fs86.statSync(p).isDirectory();
|
|
33147
33217
|
} catch {
|
|
33148
33218
|
return false;
|
|
33149
33219
|
}
|
|
@@ -33151,16 +33221,16 @@ function isDirectory(p) {
|
|
|
33151
33221
|
function eventAlreadyLogged(workspaceRoot2, runId, slug, event) {
|
|
33152
33222
|
try {
|
|
33153
33223
|
const file = path88.join(workspaceRoot2, EVENTS_RELPATH);
|
|
33154
|
-
const size =
|
|
33224
|
+
const size = fs86.statSync(file).size;
|
|
33155
33225
|
const start = Math.max(0, size - LEDGER_TAIL_MAX_BYTES);
|
|
33156
|
-
const fd =
|
|
33226
|
+
const fd = fs86.openSync(file, "r");
|
|
33157
33227
|
let text;
|
|
33158
33228
|
try {
|
|
33159
33229
|
const buf = Buffer.alloc(size - start);
|
|
33160
|
-
const read =
|
|
33230
|
+
const read = fs86.readSync(fd, buf, 0, buf.length, start);
|
|
33161
33231
|
text = buf.subarray(0, read).toString("utf8");
|
|
33162
33232
|
} finally {
|
|
33163
|
-
|
|
33233
|
+
fs86.closeSync(fd);
|
|
33164
33234
|
}
|
|
33165
33235
|
for (const line of text.split("\n")) {
|
|
33166
33236
|
if (line === "") continue;
|
|
@@ -33184,8 +33254,8 @@ function eventAlreadyLogged(workspaceRoot2, runId, slug, event) {
|
|
|
33184
33254
|
function appendEvent2(workspaceRoot2, record) {
|
|
33185
33255
|
try {
|
|
33186
33256
|
const file = path88.join(workspaceRoot2, EVENTS_RELPATH);
|
|
33187
|
-
|
|
33188
|
-
|
|
33257
|
+
fs86.mkdirSync(path88.dirname(file), { recursive: true });
|
|
33258
|
+
fs86.appendFileSync(file, `${JSON.stringify(record)}
|
|
33189
33259
|
`, "utf8");
|
|
33190
33260
|
} catch {
|
|
33191
33261
|
}
|
|
@@ -33193,7 +33263,7 @@ function appendEvent2(workspaceRoot2, record) {
|
|
|
33193
33263
|
function refusedThisTurn(workspaceRoot2, sessionId2, turnOrdinal) {
|
|
33194
33264
|
try {
|
|
33195
33265
|
const file = sessionRefusalFile(workspaceRoot2, deriveSessionKey(sessionId2 || "unknown-session"));
|
|
33196
|
-
const rec = parseRecord(
|
|
33266
|
+
const rec = parseRecord(fs86.readFileSync(file, "utf-8"));
|
|
33197
33267
|
return rec !== null && rec.refused_turn === turnOrdinal;
|
|
33198
33268
|
} catch {
|
|
33199
33269
|
return false;
|
|
@@ -33227,7 +33297,7 @@ function main57() {
|
|
|
33227
33297
|
let roadmapText = null;
|
|
33228
33298
|
if (roadmapPath2 !== null) {
|
|
33229
33299
|
try {
|
|
33230
|
-
roadmapText =
|
|
33300
|
+
roadmapText = fs86.readFileSync(roadmapPath2, "utf8");
|
|
33231
33301
|
roadmapFile = roadmapPath2;
|
|
33232
33302
|
} catch {
|
|
33233
33303
|
roadmapText = null;
|
|
@@ -33276,7 +33346,7 @@ function main57() {
|
|
|
33276
33346
|
);
|
|
33277
33347
|
if (!transcriptPath) return EXIT_ALLOW29;
|
|
33278
33348
|
try {
|
|
33279
|
-
if (
|
|
33349
|
+
if (fs86.statSync(transcriptPath).size > TRANSCRIPT_READ_MAX_BYTES) {
|
|
33280
33350
|
const inert = readRunState(workspaceRoot2, runId, slug);
|
|
33281
33351
|
if (inert.state !== null && inert.state.inert_reported !== true) {
|
|
33282
33352
|
const inertRoots = provenance(
|
|
@@ -33417,8 +33487,8 @@ function _isCliEntry47() {
|
|
|
33417
33487
|
const argvUrl = pathToFileURL52(path88.resolve(process.argv[1])).href;
|
|
33418
33488
|
if (import.meta.url === argvUrl) return true;
|
|
33419
33489
|
try {
|
|
33420
|
-
const here =
|
|
33421
|
-
const argv =
|
|
33490
|
+
const here = fs86.realpathSync(fileURLToPath58(import.meta.url));
|
|
33491
|
+
const argv = fs86.realpathSync(path88.resolve(process.argv[1]));
|
|
33422
33492
|
return here === argv;
|
|
33423
33493
|
} catch {
|
|
33424
33494
|
return false;
|
|
@@ -33481,6 +33551,101 @@ var CONCERN_REGISTRY = {
|
|
|
33481
33551
|
"src/scripts/hooks/run_continuation_hook.ts": main57
|
|
33482
33552
|
};
|
|
33483
33553
|
|
|
33554
|
+
// src/scripts/hooks/stdin_failure_policy.ts
|
|
33555
|
+
function stdinReadFailure(read = readFd0ToEnd) {
|
|
33556
|
+
try {
|
|
33557
|
+
return { text: read(), failure: null };
|
|
33558
|
+
} catch (exc) {
|
|
33559
|
+
return { text: "", failure: exc instanceof Error ? exc.message : String(exc) };
|
|
33560
|
+
}
|
|
33561
|
+
}
|
|
33562
|
+
function _is_fail_closed_blocking(concern) {
|
|
33563
|
+
const severity = String(concern["severity"] ?? "").trim().toLowerCase();
|
|
33564
|
+
return concern["fail_closed"] === true && severity === "blocking";
|
|
33565
|
+
}
|
|
33566
|
+
function denyOnStdinFailure(platform, event, concerns, failure) {
|
|
33567
|
+
if (!isBlockCapable(platform, event)) return null;
|
|
33568
|
+
const silenced = concerns.filter(_is_fail_closed_blocking).map((c) => String(c["name"]));
|
|
33569
|
+
if (silenced.length === 0) return null;
|
|
33570
|
+
return {
|
|
33571
|
+
reason: `agent-config: refusing this action \u2014 the hook payload could not be read (${failure}), so ${silenced.join(", ")} evaluated nothing. A fail-closed guard on a block-capable slot must not pass by default. Retry.`
|
|
33572
|
+
};
|
|
33573
|
+
}
|
|
33574
|
+
|
|
33575
|
+
// src/scripts/hooks/py_json_dumps.ts
|
|
33576
|
+
function _py_json_dumps2(value, indent) {
|
|
33577
|
+
const pad = " ".repeat(indent);
|
|
33578
|
+
const escapeString = (s) => {
|
|
33579
|
+
let out = '"';
|
|
33580
|
+
for (const ch of s) {
|
|
33581
|
+
const code = ch.codePointAt(0);
|
|
33582
|
+
switch (ch) {
|
|
33583
|
+
case '"':
|
|
33584
|
+
out += '\\"';
|
|
33585
|
+
break;
|
|
33586
|
+
case "\\":
|
|
33587
|
+
out += "\\\\";
|
|
33588
|
+
break;
|
|
33589
|
+
case "\n":
|
|
33590
|
+
out += "\\n";
|
|
33591
|
+
break;
|
|
33592
|
+
case "\r":
|
|
33593
|
+
out += "\\r";
|
|
33594
|
+
break;
|
|
33595
|
+
case " ":
|
|
33596
|
+
out += "\\t";
|
|
33597
|
+
break;
|
|
33598
|
+
case "\b":
|
|
33599
|
+
out += "\\b";
|
|
33600
|
+
break;
|
|
33601
|
+
case "\f":
|
|
33602
|
+
out += "\\f";
|
|
33603
|
+
break;
|
|
33604
|
+
default:
|
|
33605
|
+
if (code < 32 || code > 126) {
|
|
33606
|
+
if (code > 65535) {
|
|
33607
|
+
const c = code - 65536;
|
|
33608
|
+
const hi = 55296 + (c >> 10);
|
|
33609
|
+
const lo = 56320 + (c & 1023);
|
|
33610
|
+
out += "\\u" + hi.toString(16).padStart(4, "0") + "\\u" + lo.toString(16).padStart(4, "0");
|
|
33611
|
+
} else {
|
|
33612
|
+
out += "\\u" + code.toString(16).padStart(4, "0");
|
|
33613
|
+
}
|
|
33614
|
+
} else {
|
|
33615
|
+
out += ch;
|
|
33616
|
+
}
|
|
33617
|
+
}
|
|
33618
|
+
}
|
|
33619
|
+
return out + '"';
|
|
33620
|
+
};
|
|
33621
|
+
const render = (v, depth) => {
|
|
33622
|
+
if (v === null || v === void 0) return "null";
|
|
33623
|
+
if (typeof v === "boolean") return v ? "true" : "false";
|
|
33624
|
+
if (typeof v === "number") {
|
|
33625
|
+
if (!Number.isFinite(v)) {
|
|
33626
|
+
if (Number.isNaN(v)) return "NaN";
|
|
33627
|
+
return v > 0 ? "Infinity" : "-Infinity";
|
|
33628
|
+
}
|
|
33629
|
+
return String(v);
|
|
33630
|
+
}
|
|
33631
|
+
if (typeof v === "string") return escapeString(v);
|
|
33632
|
+
const curPad = pad.repeat(depth + 1);
|
|
33633
|
+
const closePad = pad.repeat(depth);
|
|
33634
|
+
if (Array.isArray(v)) {
|
|
33635
|
+
if (v.length === 0) return "[]";
|
|
33636
|
+
return "[\n" + v.map((item) => curPad + render(item, depth + 1)).join(",\n") + "\n" + closePad + "]";
|
|
33637
|
+
}
|
|
33638
|
+
if (typeof v === "object") {
|
|
33639
|
+
const obj = v;
|
|
33640
|
+
const keys = Object.keys(obj);
|
|
33641
|
+
if (keys.length === 0) return "{}";
|
|
33642
|
+
return "{\n" + keys.map((k) => curPad + escapeString(k) + ": " + render(obj[k], depth + 1)).join(",\n") + "\n" + closePad + "}";
|
|
33643
|
+
}
|
|
33644
|
+
throw new TypeError(`Object of type ${typeof v} is not JSON serializable`);
|
|
33645
|
+
};
|
|
33646
|
+
return render(value, 0);
|
|
33647
|
+
}
|
|
33648
|
+
|
|
33484
33649
|
// src/scripts/hooks/dispatch_hook.ts
|
|
33485
33650
|
var _IN_BUNDLE = true;
|
|
33486
33651
|
var REPO_ROOT = path89.resolve(
|
|
@@ -33549,11 +33714,11 @@ function _manifest_fingerprint(text) {
|
|
|
33549
33714
|
return `${h.toString(16)}:${String(text.length)}`;
|
|
33550
33715
|
}
|
|
33551
33716
|
function _load_yaml3(p) {
|
|
33552
|
-
const text =
|
|
33717
|
+
const text = fs87.readFileSync(p, "utf-8");
|
|
33553
33718
|
const compiled = p.replace(/\.ya?ml$/u, ".json");
|
|
33554
33719
|
if (compiled !== p) {
|
|
33555
33720
|
try {
|
|
33556
|
-
const raw = JSON.parse(
|
|
33721
|
+
const raw = JSON.parse(fs87.readFileSync(compiled, "utf-8"));
|
|
33557
33722
|
if (_isObject16(raw) && raw["fingerprint"] === _manifest_fingerprint(text) && _isObject16(raw["manifest"])) {
|
|
33558
33723
|
return raw["manifest"];
|
|
33559
33724
|
}
|
|
@@ -33652,78 +33817,6 @@ function _resolve_concerns(manifest, platform, event, role = "orchestrator", opt
|
|
|
33652
33817
|
}
|
|
33653
33818
|
return out;
|
|
33654
33819
|
}
|
|
33655
|
-
function _py_json_dumps2(value, indent) {
|
|
33656
|
-
const pad = " ".repeat(indent);
|
|
33657
|
-
const escapeString = (s) => {
|
|
33658
|
-
let out = '"';
|
|
33659
|
-
for (const ch of s) {
|
|
33660
|
-
const code = ch.codePointAt(0);
|
|
33661
|
-
switch (ch) {
|
|
33662
|
-
case '"':
|
|
33663
|
-
out += '\\"';
|
|
33664
|
-
break;
|
|
33665
|
-
case "\\":
|
|
33666
|
-
out += "\\\\";
|
|
33667
|
-
break;
|
|
33668
|
-
case "\n":
|
|
33669
|
-
out += "\\n";
|
|
33670
|
-
break;
|
|
33671
|
-
case "\r":
|
|
33672
|
-
out += "\\r";
|
|
33673
|
-
break;
|
|
33674
|
-
case " ":
|
|
33675
|
-
out += "\\t";
|
|
33676
|
-
break;
|
|
33677
|
-
case "\b":
|
|
33678
|
-
out += "\\b";
|
|
33679
|
-
break;
|
|
33680
|
-
case "\f":
|
|
33681
|
-
out += "\\f";
|
|
33682
|
-
break;
|
|
33683
|
-
default:
|
|
33684
|
-
if (code < 32 || code > 126) {
|
|
33685
|
-
if (code > 65535) {
|
|
33686
|
-
const c = code - 65536;
|
|
33687
|
-
const hi = 55296 + (c >> 10);
|
|
33688
|
-
const lo = 56320 + (c & 1023);
|
|
33689
|
-
out += "\\u" + hi.toString(16).padStart(4, "0") + "\\u" + lo.toString(16).padStart(4, "0");
|
|
33690
|
-
} else {
|
|
33691
|
-
out += "\\u" + code.toString(16).padStart(4, "0");
|
|
33692
|
-
}
|
|
33693
|
-
} else {
|
|
33694
|
-
out += ch;
|
|
33695
|
-
}
|
|
33696
|
-
}
|
|
33697
|
-
}
|
|
33698
|
-
return out + '"';
|
|
33699
|
-
};
|
|
33700
|
-
const render = (v, depth) => {
|
|
33701
|
-
if (v === null || v === void 0) return "null";
|
|
33702
|
-
if (typeof v === "boolean") return v ? "true" : "false";
|
|
33703
|
-
if (typeof v === "number") {
|
|
33704
|
-
if (!Number.isFinite(v)) {
|
|
33705
|
-
if (Number.isNaN(v)) return "NaN";
|
|
33706
|
-
return v > 0 ? "Infinity" : "-Infinity";
|
|
33707
|
-
}
|
|
33708
|
-
return String(v);
|
|
33709
|
-
}
|
|
33710
|
-
if (typeof v === "string") return escapeString(v);
|
|
33711
|
-
const curPad = pad.repeat(depth + 1);
|
|
33712
|
-
const closePad = pad.repeat(depth);
|
|
33713
|
-
if (Array.isArray(v)) {
|
|
33714
|
-
if (v.length === 0) return "[]";
|
|
33715
|
-
return "[\n" + v.map((item) => curPad + render(item, depth + 1)).join(",\n") + "\n" + closePad + "]";
|
|
33716
|
-
}
|
|
33717
|
-
if (typeof v === "object") {
|
|
33718
|
-
const obj = v;
|
|
33719
|
-
const keys = Object.keys(obj);
|
|
33720
|
-
if (keys.length === 0) return "{}";
|
|
33721
|
-
return "{\n" + keys.map((k) => curPad + escapeString(k) + ": " + render(obj[k], depth + 1)).join(",\n") + "\n" + closePad + "}";
|
|
33722
|
-
}
|
|
33723
|
-
throw new TypeError(`Object of type ${typeof v} is not JSON serializable`);
|
|
33724
|
-
};
|
|
33725
|
-
return render(value, 0);
|
|
33726
|
-
}
|
|
33727
33820
|
function _maybe_capture_payload(args, payload_text) {
|
|
33728
33821
|
const capture_dir = (process.env["AGENT_HOOK_CAPTURE_DIR"] ?? "").trim();
|
|
33729
33822
|
if (!capture_dir) {
|
|
@@ -33731,7 +33824,7 @@ function _maybe_capture_payload(args, payload_text) {
|
|
|
33731
33824
|
}
|
|
33732
33825
|
try {
|
|
33733
33826
|
const target = _expanduser3(capture_dir);
|
|
33734
|
-
|
|
33827
|
+
fs87.mkdirSync(target, { recursive: true });
|
|
33735
33828
|
let payload;
|
|
33736
33829
|
try {
|
|
33737
33830
|
payload = payload_text.trim() ? JSON.parse(payload_text) : {};
|
|
@@ -33748,7 +33841,7 @@ function _maybe_capture_payload(args, payload_text) {
|
|
|
33748
33841
|
const ts = Date.now();
|
|
33749
33842
|
const native = (args.native_event || args.event).replace(/\//g, "_");
|
|
33750
33843
|
const fname = `${args.platform}__${native}__${ts}__${process.pid}.json`;
|
|
33751
|
-
|
|
33844
|
+
fs87.writeFileSync(
|
|
33752
33845
|
path89.join(target, fname),
|
|
33753
33846
|
_py_json_dumps2(record, 2) + "\n",
|
|
33754
33847
|
{ encoding: "utf-8" }
|
|
@@ -33944,7 +34037,7 @@ function _run_concern(concern, envelope) {
|
|
|
33944
34037
|
}
|
|
33945
34038
|
function _isFile8(p) {
|
|
33946
34039
|
try {
|
|
33947
|
-
return
|
|
34040
|
+
return fs87.statSync(p).isFile();
|
|
33948
34041
|
} catch {
|
|
33949
34042
|
return false;
|
|
33950
34043
|
}
|
|
@@ -33969,7 +34062,7 @@ function _write_feedback(envelope, session_id, entries, final_rc, started_at) {
|
|
|
33969
34062
|
const state_root = path89.join(workspace, "agents", "runtime", "state");
|
|
33970
34063
|
const fb_dir = feedback_dir(state_root, session_id);
|
|
33971
34064
|
try {
|
|
33972
|
-
|
|
34065
|
+
fs87.mkdirSync(fb_dir, { recursive: true });
|
|
33973
34066
|
} catch (exc) {
|
|
33974
34067
|
const msg = exc instanceof Error ? exc.message : String(exc);
|
|
33975
34068
|
process.stderr.write(`dispatch_hook: feedback dir unavailable: ${msg}
|
|
@@ -34025,13 +34118,26 @@ function _write_feedback(envelope, session_id, entries, final_rc, started_at) {
|
|
|
34025
34118
|
})
|
|
34026
34119
|
};
|
|
34027
34120
|
try {
|
|
34028
|
-
|
|
34121
|
+
const invocation = `${String(process.pid)}-${process.hrtime.bigint().toString()}`;
|
|
34122
|
+
update_json_under_lock(path89.join(fb_dir, "summary.json"), (loaded) => {
|
|
34123
|
+
const priorRaw = loaded["invocations"];
|
|
34124
|
+
const prior = Array.isArray(priorRaw) ? priorRaw : [];
|
|
34125
|
+
const next = [...prior, { invocation, ...summary }];
|
|
34126
|
+
return {
|
|
34127
|
+
schema_version: 2,
|
|
34128
|
+
session_id,
|
|
34129
|
+
// Newest last, oldest dropped — the same rotation direction
|
|
34130
|
+
// `dispatch-issues.jsonl` uses, so a reader learns one convention.
|
|
34131
|
+
invocations: next.slice(Math.max(0, next.length - SUMMARY_INVOCATION_CAP))
|
|
34132
|
+
};
|
|
34133
|
+
});
|
|
34029
34134
|
} catch (exc) {
|
|
34030
34135
|
const msg = exc instanceof Error ? exc.message : String(exc);
|
|
34031
34136
|
process.stderr.write(`dispatch_hook: summary write failed: ${msg}
|
|
34032
34137
|
`);
|
|
34033
34138
|
}
|
|
34034
34139
|
}
|
|
34140
|
+
var SUMMARY_INVOCATION_CAP = 20;
|
|
34035
34141
|
function _record_rule_trips(envelope, entries) {
|
|
34036
34142
|
if (is_replay_mode()) return;
|
|
34037
34143
|
const tripped = entries.filter(
|
|
@@ -34042,27 +34148,25 @@ function _record_rule_trips(envelope, entries) {
|
|
|
34042
34148
|
const workspace = String(envelope["workspace_root"] || process.cwd());
|
|
34043
34149
|
const state_dir = path89.join(workspace, "agents", "runtime", "state");
|
|
34044
34150
|
const target = path89.join(state_dir, "rule-trips.json");
|
|
34045
|
-
fs88.mkdirSync(state_dir, { recursive: true });
|
|
34046
|
-
let doc = { schema_version: 1, concerns: {} };
|
|
34047
|
-
try {
|
|
34048
|
-
const parsed = JSON.parse(fs88.readFileSync(target, "utf-8"));
|
|
34049
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) doc = parsed;
|
|
34050
|
-
} catch {
|
|
34051
|
-
}
|
|
34052
|
-
const concerns = doc["concerns"] ?? {};
|
|
34053
34151
|
const today = _now_iso3().slice(0, 10);
|
|
34054
|
-
|
|
34055
|
-
const
|
|
34056
|
-
const
|
|
34057
|
-
concerns
|
|
34058
|
-
|
|
34059
|
-
|
|
34060
|
-
|
|
34061
|
-
|
|
34062
|
-
|
|
34063
|
-
|
|
34064
|
-
|
|
34065
|
-
|
|
34152
|
+
update_json_under_lock(target, (loaded) => {
|
|
34153
|
+
const doc = { schema_version: 1, concerns: {}, ...loaded };
|
|
34154
|
+
const concernsRaw = doc["concerns"];
|
|
34155
|
+
const concerns = _isObject16(concernsRaw) ? concernsRaw : {};
|
|
34156
|
+
for (const e of tripped) {
|
|
34157
|
+
const name = String(e["concern"]);
|
|
34158
|
+
const prevRaw = concerns[name];
|
|
34159
|
+
const prev = _isObject16(prevRaw) ? prevRaw : { block: 0, warn: 0 };
|
|
34160
|
+
concerns[name] = {
|
|
34161
|
+
block: (Number(prev["block"]) || 0) + (e["exit_code"] === EXIT_BLOCK6 ? 1 : 0),
|
|
34162
|
+
warn: (Number(prev["warn"]) || 0) + (e["exit_code"] === EXIT_WARN15 ? 1 : 0),
|
|
34163
|
+
last_trip: today
|
|
34164
|
+
};
|
|
34165
|
+
}
|
|
34166
|
+
doc["schema_version"] = 1;
|
|
34167
|
+
doc["concerns"] = concerns;
|
|
34168
|
+
return doc;
|
|
34169
|
+
});
|
|
34066
34170
|
} catch {
|
|
34067
34171
|
}
|
|
34068
34172
|
}
|
|
@@ -34074,7 +34178,8 @@ function _parse_args(argv) {
|
|
|
34074
34178
|
manifest: MANIFEST_PATH,
|
|
34075
34179
|
dry_run: false,
|
|
34076
34180
|
project_dir: "",
|
|
34077
|
-
min_version: 0
|
|
34181
|
+
min_version: 0,
|
|
34182
|
+
read_exit: false
|
|
34078
34183
|
};
|
|
34079
34184
|
let sawPlatform = false;
|
|
34080
34185
|
let sawEvent = false;
|
|
@@ -34098,6 +34203,9 @@ function _parse_args(argv) {
|
|
|
34098
34203
|
case "--dry-run":
|
|
34099
34204
|
args.dry_run = true;
|
|
34100
34205
|
break;
|
|
34206
|
+
case "--read-exit":
|
|
34207
|
+
args.read_exit = true;
|
|
34208
|
+
break;
|
|
34101
34209
|
case "--project-dir":
|
|
34102
34210
|
args.project_dir = argv[++i] ?? "";
|
|
34103
34211
|
break;
|
|
@@ -34157,6 +34265,20 @@ function main58(argv) {
|
|
|
34157
34265
|
);
|
|
34158
34266
|
}
|
|
34159
34267
|
}
|
|
34268
|
+
if (args.read_exit === true) {
|
|
34269
|
+
const probe = tty2.isatty(0) ? { text: "", failure: null } : stdinReadFailure();
|
|
34270
|
+
if (probe.failure !== null) {
|
|
34271
|
+
process.stderr.write(`dispatch_hook: --read-exit read failed: ${probe.failure}
|
|
34272
|
+
`);
|
|
34273
|
+
return EXIT_ALLOW30;
|
|
34274
|
+
}
|
|
34275
|
+
const envelope2 = _build_envelope(args, probe.text);
|
|
34276
|
+
process.stderr.write(
|
|
34277
|
+
`dispatch_hook: --read-exit ok (${probe.text.length} chars, ${Object.keys(_isObject16(envelope2["payload"]) ? envelope2["payload"] : {}).length} payload keys)
|
|
34278
|
+
`
|
|
34279
|
+
);
|
|
34280
|
+
return EXIT_ALLOW30;
|
|
34281
|
+
}
|
|
34160
34282
|
if (!EVENT_VOCABULARY.has(args.event)) {
|
|
34161
34283
|
process.stderr.write(
|
|
34162
34284
|
`dispatch_hook: unknown event '${args.event}'; allowed: ${_sortedRepr(EVENT_VOCABULARY)}
|
|
@@ -34165,7 +34287,7 @@ function main58(argv) {
|
|
|
34165
34287
|
return EXIT_ALLOW30;
|
|
34166
34288
|
}
|
|
34167
34289
|
const manifest_path = args.manifest;
|
|
34168
|
-
if (!
|
|
34290
|
+
if (!fs87.existsSync(manifest_path)) {
|
|
34169
34291
|
process.stderr.write(`dispatch_hook: manifest missing at ${manifest_path}
|
|
34170
34292
|
`);
|
|
34171
34293
|
return EXIT_ALLOW30;
|
|
@@ -34180,7 +34302,9 @@ function main58(argv) {
|
|
|
34180
34302
|
);
|
|
34181
34303
|
}
|
|
34182
34304
|
}
|
|
34183
|
-
const
|
|
34305
|
+
const read = tty2.isatty(0) ? { text: "", failure: null } : stdinReadFailure();
|
|
34306
|
+
const payload_text = read.text;
|
|
34307
|
+
_stdin_read_failed = read.failure;
|
|
34184
34308
|
if (_stdin_read_failed !== null) {
|
|
34185
34309
|
process.stderr.write(
|
|
34186
34310
|
`dispatch_hook: STDIN READ FAILED (${_stdin_read_failed}) \u2014 the concern chain for '${args.event}' ran against an EMPTY payload and could not evaluate anything. This is not an empty stdin.
|
|
@@ -34217,6 +34341,15 @@ function main58(argv) {
|
|
|
34217
34341
|
if (concerns.length === 0) {
|
|
34218
34342
|
return EXIT_ALLOW30;
|
|
34219
34343
|
}
|
|
34344
|
+
if (_stdin_read_failed !== null) {
|
|
34345
|
+
const deny = denyOnStdinFailure(args.platform, args.event, concerns, _stdin_read_failed);
|
|
34346
|
+
if (deny !== null) {
|
|
34347
|
+
const emission2 = emitFor(args.platform, args.event, "block", [deny.reason], EXIT_BLOCK6);
|
|
34348
|
+
if (emission2.stdout) process.stdout.write(emission2.stdout);
|
|
34349
|
+
if (emission2.stderr) process.stderr.write(emission2.stderr);
|
|
34350
|
+
return emission2.exit;
|
|
34351
|
+
}
|
|
34352
|
+
}
|
|
34220
34353
|
const envelope = _build_envelope(args, payload_text);
|
|
34221
34354
|
const session_id = _resolve_session_id(envelope);
|
|
34222
34355
|
const started_at = _now_iso3();
|
|
@@ -34321,7 +34454,7 @@ function main58(argv) {
|
|
|
34321
34454
|
}
|
|
34322
34455
|
function _isDir4(p) {
|
|
34323
34456
|
try {
|
|
34324
|
-
return
|
|
34457
|
+
return fs87.statSync(p).isDirectory();
|
|
34325
34458
|
} catch {
|
|
34326
34459
|
return false;
|
|
34327
34460
|
}
|
|
@@ -34331,14 +34464,6 @@ function _sortedRepr(s) {
|
|
|
34331
34464
|
return `[${items.map((x) => `'${x}'`).join(", ")}]`;
|
|
34332
34465
|
}
|
|
34333
34466
|
var _stdin_read_failed = null;
|
|
34334
|
-
function _readStdin14() {
|
|
34335
|
-
try {
|
|
34336
|
-
return readFd0ToEnd();
|
|
34337
|
-
} catch (exc) {
|
|
34338
|
-
_stdin_read_failed = exc instanceof Error ? exc.message : String(exc);
|
|
34339
|
-
return "";
|
|
34340
|
-
}
|
|
34341
|
-
}
|
|
34342
34467
|
function _isCliEntry48() {
|
|
34343
34468
|
if (true) {
|
|
34344
34469
|
return false;
|
|
@@ -34351,8 +34476,8 @@ function _isCliEntry48() {
|
|
|
34351
34476
|
return true;
|
|
34352
34477
|
}
|
|
34353
34478
|
try {
|
|
34354
|
-
const here =
|
|
34355
|
-
const argv =
|
|
34479
|
+
const here = fs87.realpathSync(fileURLToPath59(import.meta.url));
|
|
34480
|
+
const argv = fs87.realpathSync(path89.resolve(process.argv[1]));
|
|
34356
34481
|
return here === argv;
|
|
34357
34482
|
} catch {
|
|
34358
34483
|
return false;
|