@event4u/agent-config 9.31.0 → 9.33.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 +146 -0
- package/dist/agent-src/commands/review/routing.md +3 -4
- package/dist/agent-src/contexts/communication/rules-auto/reply-close-mechanics.md +65 -0
- package/dist/agent-src/contexts/execution/host-capability-manifest.md +32 -1
- package/dist/agent-src/contexts/execution/orchestration-telemetry.md +3 -0
- package/dist/agent-src/rules/delegation-policy.md +17 -1
- package/dist/agent-src/scripts/roadmap_gates.ts +107 -3
- package/dist/agent-src/skills/docker/SKILL.md +11 -0
- package/dist/agent-src/skills/laravel/SKILL.md +11 -0
- package/dist/agent-src/skills/review-routing/SKILL.md +23 -6
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/dist/agent-src/templates/scripts/ownership-map.example.yml +1 -1
- package/dist/agent-src/templates/scripts/work_engine/delivery_state.ts +6 -0
- package/dist/agent-src/templates/scripts/work_engine/directives/backend/_self_fix.ts +332 -0
- package/dist/agent-src/templates/scripts/work_engine/directives/backend/refine.ts +106 -1
- package/dist/agent-src/templates/scripts/work_engine/directives/backend/test.ts +50 -15
- package/dist/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +49 -15
- package/dist/agent-src/templates/scripts/work_engine/state.ts +74 -0
- package/dist/agent-src/templates/scripts/work_engine/state_io.ts +6 -0
- package/dist/cli/registry.js +4 -4
- package/dist/cli/registry.js.map +1 -1
- package/dist/cli-delegate/chunk-2WELHO3P.js +582 -0
- package/dist/cli-delegate/chunk-HTIU3W56.js +66 -0
- package/dist/cli-delegate/{chunk-ITIQSGOQ.js → chunk-MA4GFWDY.js} +7 -4
- package/dist/cli-delegate/{chunk-2WCLVDWC.js → chunk-PMQ6Z3T3.js} +1642 -165
- package/dist/cli-delegate/chunk-PZWRPRWP.js +38 -0
- package/dist/cli-delegate/{chunk-PFBV6XRT.js → chunk-Q26HT4QT.js} +1 -63
- package/dist/cli-delegate/{chunk-LVRYBKTI.js → chunk-YPAWXXXR.js} +158 -0
- package/dist/cli-delegate/cmd_conformance.js +308 -227
- package/dist/cli-delegate/cmd_doctor.js +4 -2
- package/dist/cli-delegate/cmd_export.js +1 -1
- package/dist/cli-delegate/cmd_handoff.js +160 -58
- package/dist/cli-delegate/cmd_prune.js +1 -1
- package/dist/cli-delegate/cmd_session_recycle.js +30 -5
- package/dist/cli-delegate/cmd_settings_get.js +4 -2
- package/dist/cli-delegate/cmd_settings_migrate.js +1 -1
- package/dist/cli-delegate/cmd_settings_set.js +5 -3
- package/dist/cli-delegate/cmd_sync.js +1 -1
- package/dist/cli-delegate/cmd_uninstall.js +1 -1
- package/dist/cli-delegate/cmd_validate.js +1 -1
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +8 -8
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +1 -1
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +2 -2
- package/dist/discovery/trust-report.md +1 -1
- package/dist/discovery/workspaces.json +2 -2
- package/dist/hooks/dispatch.js +1136 -690
- package/dist/install/install.mjs +7 -4
- package/dist/mcp/registry-manifest.json +2 -2
- package/dist/mcp/server.json +2 -2
- package/dist/mcp/server.mjs +3688 -1159
- package/package.json +1 -1
- package/src/agent-src/scripts/roadmap_gates.ts +107 -3
- package/src/agent-src/templates/scripts/ownership-map.example.yml +1 -1
- package/src/agent-src/templates/scripts/work_engine/delivery_state.ts +6 -0
- package/src/agent-src/templates/scripts/work_engine/directives/backend/_self_fix.ts +332 -0
- package/src/agent-src/templates/scripts/work_engine/directives/backend/refine.ts +106 -1
- package/src/agent-src/templates/scripts/work_engine/directives/backend/test.ts +50 -15
- package/src/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +49 -15
- package/src/agent-src/templates/scripts/work_engine/state.ts +74 -0
- package/src/agent-src/templates/scripts/work_engine/state_io.ts +6 -0
- package/src/config/cost-parity-budget.json +167 -0
- package/src/config/gate-coverage.yml +44 -5
- package/src/config/quorum-attendance-budget.json +39 -0
- package/src/scripts/_cli/cmd_doctor.ts +69 -1
- package/src/scripts/_cli/cmd_session_recycle.ts +44 -3
- package/src/scripts/_cli/handoff_generate.ts +36 -1
- package/src/scripts/_cli/handoff_sessions.ts +140 -9
- package/src/scripts/_dispatch.bash +5 -3
- package/src/scripts/_lib/carrier_divergence.ts +98 -27
- package/src/scripts/_lib/envelope_grounding.ts +206 -0
- package/src/scripts/_lib/host_capability.ts +79 -0
- package/src/scripts/_lib/orchestration_record.ts +45 -0
- package/src/scripts/_lib/session_eol.ts +85 -0
- package/src/scripts/_lib/subagent_capsule.ts +256 -1
- package/src/scripts/ai_council/clients.ts +31 -0
- package/src/scripts/ai_council/events_log.ts +128 -6
- package/src/scripts/ai_council/orchestrator.ts +12 -3
- package/src/scripts/ai_council/pricing.ts +48 -1
- package/src/scripts/ai_council/quorum.ts +20 -0
- package/src/scripts/ai_council/session.ts +11 -0
- package/src/scripts/ask_transport.ts +20 -1
- package/src/scripts/cache_realization_report.ts +38 -0
- package/src/scripts/check_release_highlights.ts +7 -1
- package/src/scripts/check_secret_leak.test.ts +43 -0
- package/src/scripts/check_secret_leak.ts +12 -0
- package/src/scripts/conformance_scan.ts +105 -0
- package/src/scripts/cost/track.mjs +39 -0
- package/src/scripts/cost_summary.ts +104 -1
- package/src/scripts/council_cli.ts +131 -13
- package/src/scripts/dispatch_economy_report.ts +5 -2
- package/src/scripts/handoff_context_hook.ts +66 -18
- package/src/scripts/hooks/session_eol_hook.ts +12 -12
- package/src/scripts/install.ts +20 -6
- package/src/scripts/lint_budget_ownership.ts +81 -0
- package/src/scripts/lint_skill_frontmatter_safety.ts +55 -1
- package/src/scripts/lint_workflow_paths.ts +384 -0
- package/src/scripts/preamble_byte_census.ts +9 -1
- package/src/scripts/report_carrier_divergence.ts +104 -29
- package/src/scripts/report_conformance_funnel.ts +51 -4
- package/src/scripts/routing_doctor.ts +25 -2
- package/src/scripts/schemas/dod.schema.json +45 -0
- package/src/scripts/schemas/subagent.schema.json +3 -2
- package/dist/cli-delegate/chunk-RVGBH4XK.js +0 -142
|
@@ -11,9 +11,17 @@ import {
|
|
|
11
11
|
codex_plugin_identity
|
|
12
12
|
} from "./chunk-FTAISGDQ.js";
|
|
13
13
|
import {
|
|
14
|
+
DEFAULT_PROJECTS_ROOT,
|
|
15
|
+
aggregateByBucket,
|
|
16
|
+
billableInputTokens,
|
|
14
17
|
config_exports,
|
|
15
|
-
hardenedSpawnEnv
|
|
16
|
-
|
|
18
|
+
hardenedSpawnEnv,
|
|
19
|
+
scanTranscripts,
|
|
20
|
+
weightedInputUnits
|
|
21
|
+
} from "./chunk-YPAWXXXR.js";
|
|
22
|
+
import {
|
|
23
|
+
git_common_dir
|
|
24
|
+
} from "./chunk-PZWRPRWP.js";
|
|
17
25
|
import {
|
|
18
26
|
DEFAULT_GITATTRIBUTES,
|
|
19
27
|
SECTION_HEADER,
|
|
@@ -62,13 +70,13 @@ import {
|
|
|
62
70
|
} from "./chunk-J55WI3RR.js";
|
|
63
71
|
|
|
64
72
|
// src/scripts/_cli/cmd_doctor.ts
|
|
65
|
-
var
|
|
73
|
+
var YAML2 = __toESM(require_dist(), 1);
|
|
66
74
|
import * as crypto3 from "node:crypto";
|
|
67
|
-
import * as
|
|
75
|
+
import * as fs11 from "node:fs";
|
|
68
76
|
import * as os3 from "node:os";
|
|
69
|
-
import * as
|
|
77
|
+
import * as path15 from "node:path";
|
|
70
78
|
import process2 from "node:process";
|
|
71
|
-
import { fileURLToPath as
|
|
79
|
+
import { fileURLToPath as fileURLToPath6, pathToFileURL as pathToFileURL4 } from "node:url";
|
|
72
80
|
|
|
73
81
|
// src/scripts/_lib/duplicate_scope_census.ts
|
|
74
82
|
import * as fs from "node:fs";
|
|
@@ -109,39 +117,1442 @@ function censusDuplicateScope(userRulesDir, projectRulesDir) {
|
|
|
109
117
|
};
|
|
110
118
|
}
|
|
111
119
|
|
|
112
|
-
// src/scripts/
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
// src/scripts/preamble_byte_census.ts
|
|
121
|
+
var preamble_byte_census_exports = {};
|
|
122
|
+
__export(preamble_byte_census_exports, {
|
|
123
|
+
buildByteCensus: () => buildByteCensus,
|
|
124
|
+
buildReport: () => buildReport2,
|
|
125
|
+
censusClaudeMdHierarchy: () => censusClaudeMdHierarchy,
|
|
126
|
+
censusGlobalProfile: () => censusGlobalProfile,
|
|
127
|
+
censusRuleDir: () => censusRuleDir,
|
|
128
|
+
censusSkillsCatalog: () => censusSkillsCatalog,
|
|
129
|
+
main: () => main2,
|
|
130
|
+
parseArgs: () => parseArgs2,
|
|
131
|
+
renderText: () => renderText2,
|
|
132
|
+
topRulesByCost: () => topRulesByCost
|
|
133
|
+
});
|
|
134
|
+
var YAML = __toESM(require_dist(), 1);
|
|
135
|
+
import * as fs5 from "node:fs";
|
|
136
|
+
import { homedir as homedir2 } from "node:os";
|
|
137
|
+
import * as path8 from "node:path";
|
|
138
|
+
import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
139
|
+
|
|
140
|
+
// src/scripts/_lib/agent_user_profile.ts
|
|
141
|
+
import * as path4 from "node:path";
|
|
142
|
+
|
|
143
|
+
// src/scripts/_lib/user_global_revocations.ts
|
|
144
|
+
import * as path2 from "node:path";
|
|
145
|
+
var REVOCATIONS_RELATIVE = path2.join("user", ".revocations.jsonl");
|
|
146
|
+
|
|
147
|
+
// src/scripts/_lib/user_memory_gate_counters.ts
|
|
148
|
+
import * as path3 from "node:path";
|
|
149
|
+
var GATE_COUNTERS_RELATIVE = path3.join("user", "promotion-gate-counters.json");
|
|
150
|
+
|
|
151
|
+
// src/scripts/_lib/agent_user_profile.ts
|
|
152
|
+
var GLOBAL_PROFILE_RELATIVE = path4.join("user", "profile.md");
|
|
153
|
+
function resolveGlobalProfilePath(env) {
|
|
154
|
+
return resolve_with_fallback(GLOBAL_PROFILE_RELATIVE, { env: env ?? null });
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// src/scripts/_lib/carrier_divergence.ts
|
|
158
|
+
import * as fs2 from "node:fs";
|
|
159
|
+
import * as path5 from "node:path";
|
|
160
|
+
var OWNERSHIP_KEYS = ["package", "source_path"];
|
|
161
|
+
function stripOwnershipKeys(text) {
|
|
162
|
+
return text.split("\n").filter((line) => !OWNERSHIP_KEYS.some((k) => line.startsWith(`${k}:`))).join("\n");
|
|
163
|
+
}
|
|
164
|
+
function comparePair(a, b) {
|
|
165
|
+
if (a.equals(b)) {
|
|
166
|
+
return "identical";
|
|
167
|
+
}
|
|
168
|
+
if (stripOwnershipKeys(a.toString("utf-8")) === stripOwnershipKeys(b.toString("utf-8"))) {
|
|
169
|
+
return "provenance-only";
|
|
170
|
+
}
|
|
171
|
+
return "body-diff";
|
|
172
|
+
}
|
|
173
|
+
function splitFrontmatter(text) {
|
|
174
|
+
if (!text.startsWith("---")) return { hadFrontmatter: false, frontmatter: "", body: text };
|
|
175
|
+
const end = text.indexOf("\n---", 3);
|
|
176
|
+
if (end === -1) return { hadFrontmatter: false, frontmatter: "", body: text };
|
|
177
|
+
const afterFence = text.indexOf("\n", end + 1);
|
|
178
|
+
return {
|
|
179
|
+
hadFrontmatter: true,
|
|
180
|
+
frontmatter: text.slice(3, end),
|
|
181
|
+
body: afterFence === -1 ? "" : text.slice(afterFence + 1)
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function proseEqual(a, b) {
|
|
185
|
+
const sa = splitFrontmatter(a);
|
|
186
|
+
const sb = splitFrontmatter(b);
|
|
187
|
+
if (!sa.hadFrontmatter && !sb.hadFrontmatter) return false;
|
|
188
|
+
const leading = /^\n+/;
|
|
189
|
+
return sa.body.replace(leading, "") === sb.body.replace(leading, "");
|
|
190
|
+
}
|
|
191
|
+
function frontmatterPaths(text) {
|
|
192
|
+
const { hadFrontmatter, frontmatter } = splitFrontmatter(text);
|
|
193
|
+
if (!hadFrontmatter) return null;
|
|
194
|
+
const lines = frontmatter.split("\n");
|
|
195
|
+
const start = lines.findIndex((l) => /^paths:/.test(l));
|
|
196
|
+
if (start === -1) return null;
|
|
197
|
+
const block = [lines[start]];
|
|
198
|
+
for (const line of lines.slice(start + 1)) {
|
|
199
|
+
if (/^\s/.test(line) && line.trim() !== "") block.push(line);
|
|
200
|
+
else break;
|
|
201
|
+
}
|
|
202
|
+
return block.map((l) => l.trim()).join(" ");
|
|
203
|
+
}
|
|
204
|
+
function censusRuleDir(dir) {
|
|
205
|
+
let files = 0;
|
|
206
|
+
let chars = 0;
|
|
207
|
+
let entries;
|
|
116
208
|
try {
|
|
117
|
-
|
|
209
|
+
entries = fs2.readdirSync(dir);
|
|
118
210
|
} catch {
|
|
119
|
-
return
|
|
211
|
+
return { files: 0, chars: 0 };
|
|
212
|
+
}
|
|
213
|
+
for (const name of entries) {
|
|
214
|
+
if (!name.endsWith(".md")) continue;
|
|
215
|
+
try {
|
|
216
|
+
chars += fs2.statSync(path5.join(dir, name)).size;
|
|
217
|
+
files += 1;
|
|
218
|
+
} catch {
|
|
219
|
+
}
|
|
120
220
|
}
|
|
221
|
+
return { files, chars };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// src/scripts/cache_realization_report.ts
|
|
225
|
+
import { execFileSync } from "node:child_process";
|
|
226
|
+
import * as fs4 from "node:fs";
|
|
227
|
+
import { homedir } from "node:os";
|
|
228
|
+
import * as path7 from "node:path";
|
|
229
|
+
import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
|
|
230
|
+
|
|
231
|
+
// src/scripts/ai_council/pricing.ts
|
|
232
|
+
import * as fs3 from "node:fs";
|
|
233
|
+
import * as path6 from "node:path";
|
|
234
|
+
import { fileURLToPath } from "node:url";
|
|
235
|
+
|
|
236
|
+
// src/scripts/ai_council/_default_prices.ts
|
|
237
|
+
var LAST_UPDATED = "2026-05-14";
|
|
238
|
+
var DEFAULT_PRICES_ENTRIES = [
|
|
239
|
+
// ── Anthropic ────────────────────────────────────────────────────
|
|
240
|
+
["anthropic", "claude-sonnet-4-5", 3, 15],
|
|
241
|
+
["anthropic", "claude-opus-4-1", 15, 75],
|
|
242
|
+
["anthropic", "claude-haiku-4-5", 1, 5],
|
|
243
|
+
// ── OpenAI ───────────────────────────────────────────────────────
|
|
244
|
+
["openai", "gpt-4o", 2.5, 10],
|
|
245
|
+
["openai", "gpt-4o-mini", 0.15, 0.6],
|
|
246
|
+
["openai", "o1", 15, 60],
|
|
247
|
+
["openai", "o3-mini", 1.1, 4.4],
|
|
248
|
+
// ── Google Gemini ────────────────────────────────────────────────
|
|
249
|
+
["gemini", "gemini-2.5-pro", 1.25, 10],
|
|
250
|
+
["gemini", "gemini-2.5-flash", 0.3, 2.5],
|
|
251
|
+
// ── xAI Grok ─────────────────────────────────────────────────────
|
|
252
|
+
["xai", "grok-4", 3, 15],
|
|
253
|
+
["xai", "grok-3-mini", 0.3, 0.5],
|
|
254
|
+
// ── Perplexity ───────────────────────────────────────────────────
|
|
255
|
+
["perplexity", "sonar-pro", 3, 15],
|
|
256
|
+
["perplexity", "sonar", 1, 1]
|
|
257
|
+
];
|
|
258
|
+
function priceKey(provider, model) {
|
|
259
|
+
return `${provider} ${model}`;
|
|
260
|
+
}
|
|
261
|
+
var DEFAULT_PRICES = new Map(
|
|
262
|
+
DEFAULT_PRICES_ENTRIES.map(([p, m, i, o]) => [priceKey(p, m), [i, o]])
|
|
263
|
+
);
|
|
264
|
+
function as_rows() {
|
|
265
|
+
return [...DEFAULT_PRICES_ENTRIES].map(([p, m, i, o]) => [p, m, i, o]).sort((a, b) => {
|
|
266
|
+
if (a[0] !== b[0]) {
|
|
267
|
+
return a[0] < b[0] ? -1 : 1;
|
|
268
|
+
}
|
|
269
|
+
if (a[1] !== b[1]) {
|
|
270
|
+
return a[1] < b[1] ? -1 : 1;
|
|
271
|
+
}
|
|
272
|
+
return 0;
|
|
273
|
+
});
|
|
121
274
|
}
|
|
122
|
-
|
|
123
|
-
|
|
275
|
+
|
|
276
|
+
// src/scripts/ai_council/pricing.ts
|
|
277
|
+
var _HERE = fileURLToPath(import.meta.url);
|
|
278
|
+
var REPO_ROOT = path6.resolve(path6.dirname(_HERE), "..", "..", "..");
|
|
279
|
+
var PRICES_FILE = path6.join(REPO_ROOT, "agents", "runtime", ".agent-prices.md");
|
|
280
|
+
function lookup(table, provider, model) {
|
|
281
|
+
const exact = table.prices.get(priceKey(provider, model));
|
|
282
|
+
if (exact !== void 0) {
|
|
283
|
+
return exact;
|
|
284
|
+
}
|
|
285
|
+
const prefix = priceKey(provider, "");
|
|
286
|
+
let best = null;
|
|
287
|
+
let bestLen = -1;
|
|
288
|
+
for (const [key, price] of table.prices) {
|
|
289
|
+
if (!key.startsWith(prefix)) {
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
const candidate = key.slice(prefix.length);
|
|
293
|
+
if (!candidate || !model.startsWith(candidate)) {
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
const next = model.charAt(candidate.length);
|
|
297
|
+
if (next !== "" && next !== "-" && next !== "." && next !== ":" && next !== "@") {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (candidate.length > bestLen) {
|
|
301
|
+
best = price;
|
|
302
|
+
bestLen = candidate.length;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return best;
|
|
306
|
+
}
|
|
307
|
+
var CACHE_READ_MULTIPLIER = 0.1;
|
|
308
|
+
var CACHE_WRITE_MULTIPLIER_5M = 1.25;
|
|
309
|
+
var CACHE_WRITE_MULTIPLIER_1H = 2;
|
|
310
|
+
function reprice_with_cache(provider, model, tokens, table, ttl = "5m") {
|
|
311
|
+
const price = lookup(table, provider, model);
|
|
312
|
+
const read = tokens.cache_read_input_tokens ?? 0;
|
|
313
|
+
const write = tokens.cache_creation_input_tokens ?? 0;
|
|
314
|
+
const totalInput = tokens.input_tokens + read + write;
|
|
315
|
+
if (price === null) {
|
|
316
|
+
return {
|
|
317
|
+
provider,
|
|
318
|
+
model,
|
|
319
|
+
input_tokens: totalInput,
|
|
320
|
+
output_tokens: tokens.output_tokens,
|
|
321
|
+
input_usd: 0,
|
|
322
|
+
output_usd: 0
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
const writeMult = ttl === "1h" ? CACHE_WRITE_MULTIPLIER_1H : CACHE_WRITE_MULTIPLIER_5M;
|
|
326
|
+
const inputUsd = tokens.input_tokens / 1e6 * price.input_per_1m_usd + read / 1e6 * price.input_per_1m_usd * CACHE_READ_MULTIPLIER + write / 1e6 * price.input_per_1m_usd * writeMult;
|
|
327
|
+
const outputUsd = tokens.output_tokens / 1e6 * price.output_per_1m_usd;
|
|
328
|
+
return {
|
|
329
|
+
provider,
|
|
330
|
+
model,
|
|
331
|
+
input_tokens: totalInput,
|
|
332
|
+
output_tokens: tokens.output_tokens,
|
|
333
|
+
input_usd: inputUsd,
|
|
334
|
+
output_usd: outputUsd
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function load_prices(p = PRICES_FILE) {
|
|
338
|
+
if (!fs3.existsSync(p)) {
|
|
339
|
+
bootstrap_from_defaults(p);
|
|
340
|
+
}
|
|
341
|
+
return _parse(fs3.readFileSync(p, "utf-8"));
|
|
342
|
+
}
|
|
343
|
+
function bootstrap_from_defaults(p = PRICES_FILE) {
|
|
344
|
+
fs3.mkdirSync(path6.dirname(p), { recursive: true });
|
|
345
|
+
const rows = as_rows();
|
|
346
|
+
const body = _render_markdown(LAST_UPDATED, "shipped-default", rows);
|
|
347
|
+
fs3.writeFileSync(p, body, "utf-8");
|
|
348
|
+
}
|
|
349
|
+
function _fmt62f(x) {
|
|
350
|
+
const s = x.toFixed(2);
|
|
351
|
+
return s.length >= 6 ? s : " ".repeat(6 - s.length) + s;
|
|
352
|
+
}
|
|
353
|
+
function _ljust(s, width) {
|
|
354
|
+
return s.length >= width ? s : s + " ".repeat(width - s.length);
|
|
355
|
+
}
|
|
356
|
+
function _render_markdown(lastUpdated, source, rows) {
|
|
357
|
+
const lines = [
|
|
358
|
+
"---",
|
|
359
|
+
`last_updated: ${lastUpdated}`,
|
|
360
|
+
"currency: USD",
|
|
361
|
+
"unit: per_1M_tokens",
|
|
362
|
+
`source: ${source}`,
|
|
363
|
+
"---",
|
|
364
|
+
"",
|
|
365
|
+
"# Agent prices",
|
|
366
|
+
"",
|
|
367
|
+
"| provider | model | input | output |",
|
|
368
|
+
"|-----------|---------------------|--------|--------|"
|
|
369
|
+
];
|
|
370
|
+
for (const [provider, model, inp, outp] of rows) {
|
|
371
|
+
lines.push(`| ${_ljust(provider, 9)} | ${_ljust(model, 19)} | ${_fmt62f(inp)} | ${_fmt62f(outp)} |`);
|
|
372
|
+
}
|
|
373
|
+
lines.push("");
|
|
374
|
+
return lines.join("\n");
|
|
375
|
+
}
|
|
376
|
+
function _parse(text) {
|
|
377
|
+
const [front, body] = _split_frontmatter(text);
|
|
378
|
+
const meta = _parse_frontmatter(front);
|
|
379
|
+
const prices = _parse_table(body);
|
|
380
|
+
return {
|
|
381
|
+
last_updated: meta.last_updated ?? "1970-01-01",
|
|
382
|
+
currency: meta.currency ?? "USD",
|
|
383
|
+
unit: meta.unit ?? "per_1M_tokens",
|
|
384
|
+
source: meta.source ?? "unknown",
|
|
385
|
+
prices
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
function _split_frontmatter(text) {
|
|
389
|
+
if (!text.startsWith("---")) {
|
|
390
|
+
return ["", text];
|
|
391
|
+
}
|
|
392
|
+
const parts = _pySplit(text, "---", 2);
|
|
393
|
+
if (parts.length < 3) {
|
|
394
|
+
return ["", text];
|
|
395
|
+
}
|
|
396
|
+
return [parts[1], parts[2]];
|
|
397
|
+
}
|
|
398
|
+
function _pySplit(s, sep3, maxsplit) {
|
|
399
|
+
const out = [];
|
|
400
|
+
let rest = s;
|
|
401
|
+
let n = 0;
|
|
402
|
+
while (n < maxsplit) {
|
|
403
|
+
const idx = rest.indexOf(sep3);
|
|
404
|
+
if (idx === -1) {
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
out.push(rest.slice(0, idx));
|
|
408
|
+
rest = rest.slice(idx + sep3.length);
|
|
409
|
+
n++;
|
|
410
|
+
}
|
|
411
|
+
out.push(rest);
|
|
412
|
+
return out;
|
|
413
|
+
}
|
|
414
|
+
function _parse_frontmatter(front) {
|
|
415
|
+
const out = {};
|
|
416
|
+
for (let line of front.split("\n")) {
|
|
417
|
+
line = line.trim();
|
|
418
|
+
if (!line || !line.includes(":")) {
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
const idx = line.indexOf(":");
|
|
422
|
+
out[line.slice(0, idx).trim()] = line.slice(idx + 1).trim();
|
|
423
|
+
}
|
|
424
|
+
return out;
|
|
425
|
+
}
|
|
426
|
+
function _parse_table(body) {
|
|
427
|
+
const out = /* @__PURE__ */ new Map();
|
|
428
|
+
for (let line of body.split("\n")) {
|
|
429
|
+
line = line.trim();
|
|
430
|
+
if (!line.startsWith("|") || line.startsWith("|--") || line.startsWith("|-")) {
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
const stripped = line.replace(/^\|+/, "").replace(/\|+$/, "");
|
|
434
|
+
const cells = stripped.split("|").map((c) => c.trim());
|
|
435
|
+
if (cells.length !== 4) {
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
const [provider, model, inp, outp] = cells;
|
|
439
|
+
if (provider === "provider") {
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
const inV = _pyFloat(inp);
|
|
443
|
+
const outV = _pyFloat(outp);
|
|
444
|
+
if (inV === null || outV === null) {
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
out.set(priceKey(provider, model), {
|
|
448
|
+
provider,
|
|
449
|
+
model,
|
|
450
|
+
input_per_1m_usd: inV,
|
|
451
|
+
output_per_1m_usd: outV
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
return out;
|
|
455
|
+
}
|
|
456
|
+
function _pyFloat(s) {
|
|
457
|
+
const t = s.trim();
|
|
458
|
+
if (t === "") {
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
461
|
+
const n = Number(t);
|
|
462
|
+
return Number.isNaN(n) ? null : n;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// src/scripts/cache_realization_report.ts
|
|
466
|
+
var _HERE2 = fileURLToPath2(import.meta.url);
|
|
467
|
+
var REPO_ROOT2 = path7.resolve(path7.dirname(_HERE2), "..", "..");
|
|
468
|
+
var C1_COLD_START_DOMINANCE_THRESHOLD = 0.5;
|
|
469
|
+
var C2_DUPLICATE_SCOPE_THRESHOLD = 0.25;
|
|
470
|
+
var C4_COUNCIL_MISPRICING_THRESHOLD = 0.05;
|
|
471
|
+
var C5_CONFIRM_RATIO = 0.1;
|
|
472
|
+
var C5_FALSIFY_RATIO = 0.5;
|
|
473
|
+
var DRIFT_READ_SHARE_FLOOR = 0.9;
|
|
474
|
+
var DRIFT_COLD_START_SHARE_FLOOR = 0.5;
|
|
475
|
+
function median(nums) {
|
|
476
|
+
if (nums.length === 0) return 0;
|
|
477
|
+
const sorted = [...nums].sort((a, b) => a - b);
|
|
478
|
+
const mid = Math.floor(sorted.length / 2);
|
|
479
|
+
return sorted.length % 2 === 0 ? (sorted[mid - 1] + sorted[mid]) / 2 : sorted[mid];
|
|
480
|
+
}
|
|
481
|
+
function mean(nums) {
|
|
482
|
+
if (nums.length === 0) return 0;
|
|
483
|
+
return nums.reduce((a, b) => a + b, 0) / nums.length;
|
|
484
|
+
}
|
|
485
|
+
function firstCallsByLeg(records) {
|
|
486
|
+
const byAgent = /* @__PURE__ */ new Map();
|
|
487
|
+
for (const r of records) {
|
|
488
|
+
if (r.bucket !== "subagent" || r.agentId === null) continue;
|
|
489
|
+
const arr = byAgent.get(r.agentId) ?? [];
|
|
490
|
+
arr.push(r);
|
|
491
|
+
byAgent.set(r.agentId, arr);
|
|
492
|
+
}
|
|
493
|
+
const firstCalls = [];
|
|
494
|
+
for (const arr of byAgent.values()) {
|
|
495
|
+
const sorted = arr.map((r, idx) => ({ r, idx })).sort((a, b) => {
|
|
496
|
+
const ta = a.r.timestamp;
|
|
497
|
+
const tb = b.r.timestamp;
|
|
498
|
+
if (ta !== null && tb !== null && ta !== tb) return ta < tb ? -1 : 1;
|
|
499
|
+
if (ta !== null && tb === null) return -1;
|
|
500
|
+
if (ta === null && tb !== null) return 1;
|
|
501
|
+
return a.idx - b.idx;
|
|
502
|
+
}).map((x) => x.r);
|
|
503
|
+
firstCalls.push(sorted[0]);
|
|
504
|
+
}
|
|
505
|
+
return firstCalls;
|
|
506
|
+
}
|
|
507
|
+
function computeColdStarts(records) {
|
|
508
|
+
const subagentRecords = records.filter((r) => r.bucket === "subagent");
|
|
509
|
+
const totalWriteVolume = subagentRecords.reduce((s, r) => s + r.usage.cache_creation_input_tokens, 0);
|
|
510
|
+
const firstCalls = firstCallsByLeg(records);
|
|
511
|
+
const writtenOrUncached = firstCalls.map((r) => r.usage.cache_creation_input_tokens + r.usage.input_tokens);
|
|
512
|
+
const sumFirstCallRead = firstCalls.reduce((s, r) => s + r.usage.cache_read_input_tokens, 0);
|
|
513
|
+
const sumFirstCallBillable = firstCalls.reduce((s, r) => s + billableInputTokens(r.usage), 0);
|
|
514
|
+
const sumFirstCallWrite = firstCalls.reduce((s, r) => s + r.usage.cache_creation_input_tokens, 0);
|
|
515
|
+
const sumBillable = subagentRecords.reduce((s, r) => s + billableInputTokens(r.usage), 0);
|
|
516
|
+
const sumWrite = totalWriteVolume;
|
|
517
|
+
const sumRead = subagentRecords.reduce((s, r) => s + r.usage.cache_read_input_tokens, 0);
|
|
518
|
+
const sumUncached = subagentRecords.reduce((s, r) => s + r.usage.input_tokens, 0);
|
|
519
|
+
return {
|
|
520
|
+
legs: firstCalls.length,
|
|
521
|
+
median_first_call_written_or_uncached: median(writtenOrUncached),
|
|
522
|
+
mean_first_call_written_or_uncached: mean(writtenOrUncached),
|
|
523
|
+
first_call_cache_read_share: sumFirstCallBillable > 0 ? sumFirstCallRead / sumFirstCallBillable : 0,
|
|
524
|
+
cold_start_share_of_write_volume: totalWriteVolume > 0 ? sumFirstCallWrite / totalWriteVolume : 0,
|
|
525
|
+
write_share_of_billable: sumBillable > 0 ? sumWrite / sumBillable : 0,
|
|
526
|
+
read_share_of_billable: sumBillable > 0 ? sumRead / sumBillable : 0,
|
|
527
|
+
uncached_share_of_billable: sumBillable > 0 ? sumUncached / sumBillable : 0
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
function aggregateByAgent(records) {
|
|
531
|
+
const byAgent = /* @__PURE__ */ new Map();
|
|
532
|
+
for (const r of records) {
|
|
533
|
+
if (r.bucket !== "subagent" || r.agentId === null) continue;
|
|
534
|
+
const arr = byAgent.get(r.agentId) ?? [];
|
|
535
|
+
arr.push(r);
|
|
536
|
+
byAgent.set(r.agentId, arr);
|
|
537
|
+
}
|
|
538
|
+
const out = [];
|
|
539
|
+
for (const [agentId, recs] of byAgent) {
|
|
540
|
+
const agg = aggregateByBucket(recs).subagent;
|
|
541
|
+
out.push({ ...agg, agentId });
|
|
542
|
+
}
|
|
543
|
+
return out;
|
|
544
|
+
}
|
|
545
|
+
function computeDuplicateScope(userRulesDir, projectRulesDir, subagentWriteVolume, spawnCount) {
|
|
546
|
+
const census = censusDuplicateScope(userRulesDir, projectRulesDir);
|
|
547
|
+
if (!census.evaluable) {
|
|
548
|
+
return {
|
|
549
|
+
evaluable: false,
|
|
550
|
+
reason: census.reason,
|
|
551
|
+
shared_filenames: census.shared_filenames.length,
|
|
552
|
+
duplicate_tokens_per_spawn: 0,
|
|
553
|
+
spawn_count: spawnCount,
|
|
554
|
+
duplicate_token_estimate_total: 0,
|
|
555
|
+
share_of_subagent_write_volume: 0
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
const duplicateTokensPerSpawn = census.duplicate_chars / 4;
|
|
559
|
+
const totalEstimate = duplicateTokensPerSpawn * spawnCount;
|
|
560
|
+
const evaluable = spawnCount > 0 && subagentWriteVolume > 0;
|
|
561
|
+
return {
|
|
562
|
+
evaluable,
|
|
563
|
+
reason: evaluable ? void 0 : "no subagent legs or no subagent write volume observed in the window",
|
|
564
|
+
shared_filenames: census.shared_filenames.length,
|
|
565
|
+
duplicate_tokens_per_spawn: duplicateTokensPerSpawn,
|
|
566
|
+
spawn_count: spawnCount,
|
|
567
|
+
duplicate_token_estimate_total: totalEstimate,
|
|
568
|
+
share_of_subagent_write_volume: subagentWriteVolume > 0 ? totalEstimate / subagentWriteVolume : 0
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
function findDebateRoundFiles(councilRoot) {
|
|
572
|
+
const base = path7.join(councilRoot, "agents", "runtime", "council", "responses");
|
|
573
|
+
if (!fs4.existsSync(base)) return [];
|
|
574
|
+
const out = [];
|
|
575
|
+
const stack = [base];
|
|
576
|
+
while (stack.length > 0) {
|
|
577
|
+
const dir = stack.pop();
|
|
578
|
+
let entries;
|
|
579
|
+
try {
|
|
580
|
+
entries = fs4.readdirSync(dir, { withFileTypes: true });
|
|
581
|
+
} catch {
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
for (const entry of entries) {
|
|
585
|
+
const full = path7.join(dir, entry.name);
|
|
586
|
+
if (entry.isDirectory()) {
|
|
587
|
+
stack.push(full);
|
|
588
|
+
continue;
|
|
589
|
+
}
|
|
590
|
+
if (entry.isFile() && /^debate-round-\d+\.json$/.test(entry.name)) out.push(full);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
return out;
|
|
594
|
+
}
|
|
595
|
+
function numOrUndef(v) {
|
|
596
|
+
return typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
597
|
+
}
|
|
598
|
+
function computeCouncilMispricing(councilRoot) {
|
|
599
|
+
const files = findDebateRoundFiles(councilRoot);
|
|
600
|
+
if (files.length === 0) {
|
|
601
|
+
return {
|
|
602
|
+
status: "pending",
|
|
603
|
+
reason: "no agents/runtime/council/responses/**/debate-round-*.json artefact found under this root"
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
const groups = /* @__PURE__ */ new Map();
|
|
607
|
+
for (const f of files) {
|
|
608
|
+
const dir = path7.dirname(f);
|
|
609
|
+
const arr = groups.get(dir) ?? [];
|
|
610
|
+
arr.push(f);
|
|
611
|
+
groups.set(dir, arr);
|
|
612
|
+
}
|
|
613
|
+
let table;
|
|
124
614
|
try {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
615
|
+
table = load_prices();
|
|
616
|
+
} catch {
|
|
617
|
+
return { status: "pending", reason: "could not load the local price table (.agent-prices.md)" };
|
|
618
|
+
}
|
|
619
|
+
let best = null;
|
|
620
|
+
for (const [dir, groupFiles] of groups) {
|
|
621
|
+
let rounds = 0;
|
|
622
|
+
let recorded = 0;
|
|
623
|
+
let cacheAware = 0;
|
|
624
|
+
let tokens = 0;
|
|
625
|
+
let cacheVolume = 0;
|
|
626
|
+
for (const f of groupFiles) {
|
|
627
|
+
let data;
|
|
628
|
+
try {
|
|
629
|
+
data = JSON.parse(fs4.readFileSync(f, "utf-8"));
|
|
630
|
+
} catch {
|
|
631
|
+
continue;
|
|
632
|
+
}
|
|
633
|
+
rounds = Math.max(rounds, numOrUndef(data.debate_total_rounds) ?? 0);
|
|
634
|
+
recorded += numOrUndef(data.cost_usd_actual) ?? 0;
|
|
635
|
+
for (const r of data.responses ?? []) {
|
|
636
|
+
if (r.error) continue;
|
|
637
|
+
const input = numOrUndef(r.input_tokens) ?? 0;
|
|
638
|
+
const output = numOrUndef(r.output_tokens) ?? 0;
|
|
639
|
+
const read = numOrUndef(r.cache_read_input_tokens) ?? 0;
|
|
640
|
+
const write = numOrUndef(r.cache_creation_input_tokens) ?? 0;
|
|
641
|
+
tokens += input + read + write;
|
|
642
|
+
cacheVolume += read + write;
|
|
643
|
+
if (typeof r.provider !== "string" || typeof r.model !== "string") continue;
|
|
644
|
+
const est = reprice_with_cache(
|
|
645
|
+
r.provider,
|
|
646
|
+
r.model,
|
|
647
|
+
{ input_tokens: input, cache_read_input_tokens: read, cache_creation_input_tokens: write, output_tokens: output },
|
|
648
|
+
table,
|
|
649
|
+
"5m"
|
|
650
|
+
);
|
|
651
|
+
cacheAware += est.input_usd + est.output_usd;
|
|
652
|
+
}
|
|
128
653
|
}
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
|
|
654
|
+
if (rounds < 2 || tokens === 0 || recorded === 0) continue;
|
|
655
|
+
if (best === null || cacheVolume > best.cacheVolume || cacheVolume === best.cacheVolume && rounds > best.rounds || cacheVolume === best.cacheVolume && rounds === best.rounds && tokens > best.tokens) {
|
|
656
|
+
best = { dir, rounds, recorded, cacheAware, tokens, cacheVolume };
|
|
132
657
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
658
|
+
}
|
|
659
|
+
if (best === null) {
|
|
660
|
+
return {
|
|
661
|
+
status: "pending",
|
|
662
|
+
reason: "found debate-round artefacts, but none had \u22652 recorded rounds with non-error usage and a non-zero recorded cost"
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
const deltaPct = (best.cacheAware - best.recorded) / best.recorded;
|
|
666
|
+
const status = Math.abs(deltaPct) >= C4_COUNCIL_MISPRICING_THRESHOLD ? "confirmed" : "falsified";
|
|
667
|
+
return {
|
|
668
|
+
status,
|
|
669
|
+
session: path7.relative(councilRoot, best.dir) || "(top-level)",
|
|
670
|
+
rounds: best.rounds,
|
|
671
|
+
recorded_cost_usd: best.recorded,
|
|
672
|
+
cache_aware_cost_usd: best.cacheAware,
|
|
673
|
+
delta_pct: deltaPct
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
function encodeProjectPath(cwd) {
|
|
677
|
+
return cwd.replace(/[/.]/g, "-");
|
|
678
|
+
}
|
|
679
|
+
function listGitWorktrees(cwd) {
|
|
680
|
+
try {
|
|
681
|
+
const out = execFileSync("git", ["worktree", "list", "--porcelain"], { cwd, encoding: "utf-8", timeout: 1e4 });
|
|
682
|
+
const paths = [];
|
|
683
|
+
for (const line of out.split("\n")) {
|
|
684
|
+
if (line.startsWith("worktree ")) paths.push(line.slice("worktree ".length).trim());
|
|
138
685
|
}
|
|
139
|
-
return
|
|
686
|
+
return paths;
|
|
140
687
|
} catch {
|
|
141
|
-
return
|
|
688
|
+
return [];
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
function computeWorktreeFragmentation(projectsRoot, worktreePaths, maxAgeDays) {
|
|
692
|
+
if (worktreePaths.length < 2) {
|
|
693
|
+
return { status: "pending", reason: "fewer than 2 git worktrees found for this repo \u2014 nothing to compare" };
|
|
694
|
+
}
|
|
695
|
+
const established = worktreePaths[0];
|
|
696
|
+
const encodedEstablished = encodeProjectPath(established);
|
|
697
|
+
const worktreeDirs = worktreePaths.slice(1).map(encodeProjectPath).filter((d) => fs4.existsSync(path7.join(projectsRoot, d)));
|
|
698
|
+
if (!fs4.existsSync(path7.join(projectsRoot, encodedEstablished)) || worktreeDirs.length === 0) {
|
|
699
|
+
return {
|
|
700
|
+
status: "pending",
|
|
701
|
+
reason: "no transcript directory found for both an established and a fresh-worktree checkout of this repo"
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
const establishedScan = scanTranscripts({ root: projectsRoot, projectDir: encodedEstablished, maxAgeDays });
|
|
705
|
+
const establishedColdStart = computeColdStarts(establishedScan.records);
|
|
706
|
+
let worktreeRecords = [];
|
|
707
|
+
for (const d of worktreeDirs) {
|
|
708
|
+
worktreeRecords = worktreeRecords.concat(scanTranscripts({ root: projectsRoot, projectDir: d, maxAgeDays }).records);
|
|
709
|
+
}
|
|
710
|
+
const worktreeColdStart = computeColdStarts(worktreeRecords);
|
|
711
|
+
if (establishedColdStart.legs === 0 || worktreeColdStart.legs === 0) {
|
|
712
|
+
return {
|
|
713
|
+
status: "pending",
|
|
714
|
+
reason: `insufficient subagent legs in the ${maxAgeDays}-day window (established: ${establishedColdStart.legs}, worktrees: ${worktreeColdStart.legs})`,
|
|
715
|
+
established_project_dir: encodedEstablished,
|
|
716
|
+
worktree_project_dirs: worktreeDirs
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
const establishedShare = establishedColdStart.first_call_cache_read_share;
|
|
720
|
+
const worktreeShare = worktreeColdStart.first_call_cache_read_share;
|
|
721
|
+
const ratio = establishedShare > 0 ? worktreeShare / establishedShare : worktreeShare === 0 ? 0 : Number.POSITIVE_INFINITY;
|
|
722
|
+
if (!Number.isFinite(ratio)) {
|
|
723
|
+
return {
|
|
724
|
+
status: "pending",
|
|
725
|
+
reason: "established directory shows a zero first-call cache-read share \u2014 the comparison ratio is undefined",
|
|
726
|
+
established_project_dir: encodedEstablished,
|
|
727
|
+
worktree_project_dirs: worktreeDirs,
|
|
728
|
+
established_first_call_read_share: establishedShare,
|
|
729
|
+
worktree_first_call_read_share: worktreeShare
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
let status;
|
|
733
|
+
let reason;
|
|
734
|
+
if (ratio >= C5_FALSIFY_RATIO) {
|
|
735
|
+
status = "falsified";
|
|
736
|
+
} else if (ratio < C5_CONFIRM_RATIO) {
|
|
737
|
+
status = "confirmed";
|
|
738
|
+
} else {
|
|
739
|
+
status = "pending";
|
|
740
|
+
reason = `ratio ${(ratio * 100).toFixed(1)}% falls between the confirm (<10%) and falsify (>=50%) thresholds`;
|
|
741
|
+
}
|
|
742
|
+
return {
|
|
743
|
+
status,
|
|
744
|
+
reason,
|
|
745
|
+
established_project_dir: encodedEstablished,
|
|
746
|
+
worktree_project_dirs: worktreeDirs,
|
|
747
|
+
established_first_call_read_share: establishedShare,
|
|
748
|
+
worktree_first_call_read_share: worktreeShare,
|
|
749
|
+
ratio
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
function hostVersion() {
|
|
753
|
+
try {
|
|
754
|
+
const out = execFileSync("claude", ["--version"], { encoding: "utf-8", timeout: 5e3 }).trim();
|
|
755
|
+
return out.length > 0 ? out : "unknown";
|
|
756
|
+
} catch {
|
|
757
|
+
return "unknown";
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
function buildClaims(opts) {
|
|
761
|
+
const claims = [];
|
|
762
|
+
const c1Value = opts.subagentColdStart.cold_start_share_of_write_volume;
|
|
763
|
+
claims.push({
|
|
764
|
+
id: "C-1",
|
|
765
|
+
description: "cold-start dominance: cold starts are \u226550% of subagent write volume (baseline 69.4%)",
|
|
766
|
+
threshold: ">= 0.50",
|
|
767
|
+
verdict: opts.subagentColdStart.legs === 0 ? "pending" : c1Value >= C1_COLD_START_DOMINANCE_THRESHOLD ? "confirmed" : "falsified",
|
|
768
|
+
measured: opts.subagentColdStart.legs === 0 ? void 0 : c1Value,
|
|
769
|
+
reason: opts.subagentColdStart.legs === 0 ? "no subagent legs observed in the window" : void 0
|
|
770
|
+
});
|
|
771
|
+
const d = opts.duplicateScope;
|
|
772
|
+
claims.push({
|
|
773
|
+
id: "C-2",
|
|
774
|
+
description: "duplicate-scope share: the redundant rule-set copy is \u226525% of subagent write volume (baseline \u224837%)",
|
|
775
|
+
threshold: ">= 0.25",
|
|
776
|
+
verdict: !d.evaluable ? "pending" : d.share_of_subagent_write_volume >= C2_DUPLICATE_SCOPE_THRESHOLD ? "confirmed" : "falsified",
|
|
777
|
+
measured: d.evaluable ? d.share_of_subagent_write_volume : void 0,
|
|
778
|
+
reason: !d.evaluable ? d.reason : void 0
|
|
779
|
+
});
|
|
780
|
+
claims.push({
|
|
781
|
+
id: "C-3",
|
|
782
|
+
description: "preamble reducibility: a shipped reduction moves median cold-start tokens by \u226515% with no eval regression",
|
|
783
|
+
threshold: ">= 0.15",
|
|
784
|
+
verdict: "pending",
|
|
785
|
+
reason: "requires an implemented preamble-reduction intervention (Phase 3) \u2014 none has landed yet"
|
|
786
|
+
});
|
|
787
|
+
const c = opts.councilMispricing;
|
|
788
|
+
claims.push({
|
|
789
|
+
id: "C-4",
|
|
790
|
+
description: "council mispricing magnitude: cache-aware repricing changes a real multi-round debate\u2019s realized cost by \u22655%",
|
|
791
|
+
threshold: ">= 0.05 (absolute delta)",
|
|
792
|
+
verdict: c.status,
|
|
793
|
+
measured: c.delta_pct,
|
|
794
|
+
reason: c.reason
|
|
795
|
+
});
|
|
796
|
+
const w = opts.worktreeFragmentation;
|
|
797
|
+
claims.push({
|
|
798
|
+
id: "C-5",
|
|
799
|
+
description: "worktree fragmentation: a fresh worktree's first-call cache_read share is <10% of an established directory's (falsified at >=50%)",
|
|
800
|
+
threshold: "< 0.10 confirmed / >= 0.50 falsified",
|
|
801
|
+
verdict: w.status,
|
|
802
|
+
measured: w.ratio,
|
|
803
|
+
reason: w.reason
|
|
804
|
+
});
|
|
805
|
+
return claims;
|
|
806
|
+
}
|
|
807
|
+
function defaultOptions() {
|
|
808
|
+
return {
|
|
809
|
+
format: "text",
|
|
810
|
+
root: DEFAULT_PROJECTS_ROOT,
|
|
811
|
+
maxAgeDays: 14,
|
|
812
|
+
repoRoot: REPO_ROOT2,
|
|
813
|
+
councilRoot: REPO_ROOT2,
|
|
814
|
+
userRulesDir: path7.join(homedir(), ".claude", "rules"),
|
|
815
|
+
projectRulesDir: path7.join(REPO_ROOT2, "dist", "agent-src", "rules")
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
function parseArgs(argv) {
|
|
819
|
+
const opts = defaultOptions();
|
|
820
|
+
for (let i = 0; i < argv.length; i++) {
|
|
821
|
+
const a = argv[i];
|
|
822
|
+
if (a === void 0) continue;
|
|
823
|
+
if (a === "--format") opts.format = argv[++i] ?? opts.format;
|
|
824
|
+
else if (a.startsWith("--format=")) opts.format = a.slice("--format=".length);
|
|
825
|
+
else if (a === "--root") opts.root = argv[++i] ?? opts.root;
|
|
826
|
+
else if (a.startsWith("--root=")) opts.root = a.slice("--root=".length);
|
|
827
|
+
else if (a === "--max-age-days") opts.maxAgeDays = Number(argv[++i]) || opts.maxAgeDays;
|
|
828
|
+
else if (a.startsWith("--max-age-days=")) opts.maxAgeDays = Number(a.slice("--max-age-days=".length)) || opts.maxAgeDays;
|
|
829
|
+
else if (a === "--repo-root") opts.repoRoot = argv[++i] ?? opts.repoRoot;
|
|
830
|
+
else if (a.startsWith("--repo-root=")) opts.repoRoot = a.slice("--repo-root=".length);
|
|
831
|
+
else if (a === "--council-root") opts.councilRoot = argv[++i] ?? opts.councilRoot;
|
|
832
|
+
else if (a.startsWith("--council-root=")) opts.councilRoot = a.slice("--council-root=".length);
|
|
833
|
+
else if (a === "--user-rules-dir") opts.userRulesDir = argv[++i] ?? opts.userRulesDir;
|
|
834
|
+
else if (a.startsWith("--user-rules-dir=")) opts.userRulesDir = a.slice("--user-rules-dir=".length);
|
|
835
|
+
else if (a === "--project-rules-dir") opts.projectRulesDir = argv[++i] ?? opts.projectRulesDir;
|
|
836
|
+
else if (a.startsWith("--project-rules-dir=")) opts.projectRulesDir = a.slice("--project-rules-dir=".length);
|
|
837
|
+
}
|
|
838
|
+
if (opts.format !== "text" && opts.format !== "json") opts.format = "text";
|
|
839
|
+
return opts;
|
|
840
|
+
}
|
|
841
|
+
function buildReport(opts) {
|
|
842
|
+
const scan = scanTranscripts({ root: opts.root, maxAgeDays: opts.maxAgeDays });
|
|
843
|
+
const buckets = aggregateByBucket(scan.records);
|
|
844
|
+
const subagentColdStart = computeColdStarts(scan.records);
|
|
845
|
+
const byAgent = aggregateByAgent(scan.records);
|
|
846
|
+
const duplicateScope = computeDuplicateScope(
|
|
847
|
+
opts.userRulesDir,
|
|
848
|
+
opts.projectRulesDir,
|
|
849
|
+
buckets.subagent.cache_creation_input_tokens,
|
|
850
|
+
subagentColdStart.legs
|
|
851
|
+
);
|
|
852
|
+
const councilMispricing = computeCouncilMispricing(opts.councilRoot);
|
|
853
|
+
const worktreePaths = listGitWorktrees(opts.repoRoot);
|
|
854
|
+
const worktreeFragmentation = computeWorktreeFragmentation(opts.root, worktreePaths, opts.maxAgeDays);
|
|
855
|
+
const claims = buildClaims({ subagentColdStart, duplicateScope, councilMispricing, worktreeFragmentation });
|
|
856
|
+
return {
|
|
857
|
+
schema: "cache-realization-report/v1",
|
|
858
|
+
host_version: hostVersion(),
|
|
859
|
+
window_days: opts.maxAgeDays,
|
|
860
|
+
root: opts.root,
|
|
861
|
+
metric_definition: {
|
|
862
|
+
billable_input: "input_tokens + cache_read_input_tokens + cache_creation_input_tokens",
|
|
863
|
+
note: "Anthropic's usage.input_tokens EXCLUDES cache tokens \u2014 it is only the uncached portion of the prompt."
|
|
864
|
+
},
|
|
865
|
+
dedup_ratio: scan.dedup_ratio,
|
|
866
|
+
total_seen: scan.totalSeen,
|
|
867
|
+
deduped_count: scan.dedupedCount,
|
|
868
|
+
buckets,
|
|
869
|
+
subagent_cold_start: subagentColdStart,
|
|
870
|
+
by_agent: byAgent,
|
|
871
|
+
duplicate_scope: duplicateScope,
|
|
872
|
+
council_mispricing: councilMispricing,
|
|
873
|
+
worktree_fragmentation: worktreeFragmentation,
|
|
874
|
+
claims
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
function pct(v) {
|
|
878
|
+
return `${(v * 100).toFixed(1)}%`;
|
|
879
|
+
}
|
|
880
|
+
function renderText(r) {
|
|
881
|
+
const out = [];
|
|
882
|
+
out.push("Cache-realization report");
|
|
883
|
+
out.push(` host_version: ${r.host_version}`);
|
|
884
|
+
out.push(` window: last ${r.window_days} days`);
|
|
885
|
+
out.push(` root: ${r.root}`);
|
|
886
|
+
out.push(` metric: billable_input = ${r.metric_definition.billable_input}`);
|
|
887
|
+
out.push(` ${r.metric_definition.note}`);
|
|
888
|
+
out.push(` dedup: ${r.deduped_count}/${r.total_seen} unique records kept (dedup_ratio ${pct(r.dedup_ratio)})`);
|
|
889
|
+
out.push("");
|
|
890
|
+
out.push("By bucket:");
|
|
891
|
+
for (const bucket of ["main", "subagent"]) {
|
|
892
|
+
const b = r.buckets[bucket];
|
|
893
|
+
out.push(` ${bucket}: calls=${b.calls} read_share=${pct(b.read_share)} weighted_input_units=${Math.round(b.weighted_input_units)}`);
|
|
894
|
+
out.push(
|
|
895
|
+
` input=${b.input_tokens} cache_read=${b.cache_read_input_tokens} cache_creation=${b.cache_creation_input_tokens} (5m=${b.ephemeral_5m_input_tokens} 1h=${b.ephemeral_1h_input_tokens}) output=${b.output_tokens}`
|
|
896
|
+
);
|
|
142
897
|
}
|
|
898
|
+
out.push("");
|
|
899
|
+
const cs = r.subagent_cold_start;
|
|
900
|
+
out.push("Subagent cold start (first call per leg):");
|
|
901
|
+
out.push(
|
|
902
|
+
` legs=${cs.legs} median_written_or_uncached=${Math.round(cs.median_first_call_written_or_uncached)} mean=${Math.round(cs.mean_first_call_written_or_uncached)}`
|
|
903
|
+
);
|
|
904
|
+
out.push(` first_call_cache_read_share=${pct(cs.first_call_cache_read_share)}`);
|
|
905
|
+
out.push(` cold_start_share_of_subagent_write_volume=${pct(cs.cold_start_share_of_write_volume)}`);
|
|
906
|
+
out.push(
|
|
907
|
+
` write_share=${pct(cs.write_share_of_billable)} read_share=${pct(cs.read_share_of_billable)} uncached_share=${pct(cs.uncached_share_of_billable)} (of billable input, all subagent records)`
|
|
908
|
+
);
|
|
909
|
+
out.push("");
|
|
910
|
+
out.push(`Per-agent breakdown: ${r.by_agent.length} distinct subagent legs (--format json carries all; top 10 by weighted_input_units below)`);
|
|
911
|
+
const top10 = [...r.by_agent].sort((a, b) => b.weighted_input_units - a.weighted_input_units).slice(0, 10);
|
|
912
|
+
for (const a of top10) {
|
|
913
|
+
out.push(` ${a.agentId}: calls=${a.calls} read_share=${pct(a.read_share)} weighted_input_units=${Math.round(a.weighted_input_units)}`);
|
|
914
|
+
}
|
|
915
|
+
out.push("");
|
|
916
|
+
out.push("Pre-registered claims:");
|
|
917
|
+
for (const c of r.claims) {
|
|
918
|
+
const measured = c.measured !== void 0 ? ` (measured ${pct(c.measured)})` : "";
|
|
919
|
+
const reasonSuffix = c.verdict === "pending" && c.reason ? ` \u2014 ${c.reason}` : "";
|
|
920
|
+
out.push(` ${c.id} [${c.verdict}]${measured}: ${c.description}${reasonSuffix}`);
|
|
921
|
+
}
|
|
922
|
+
out.push("");
|
|
923
|
+
out.push("Re-verification:");
|
|
924
|
+
out.push(" command: ./scripts-run src/scripts/cache_realization_report --format text");
|
|
925
|
+
out.push(` host_version at this run: ${r.host_version}`);
|
|
926
|
+
out.push(
|
|
927
|
+
` re-run + restamp this report if: read_share drops below ${pct(DRIFT_READ_SHARE_FLOOR)}, OR cold-start share drops below ${pct(DRIFT_COLD_START_SHARE_FLOOR)}`
|
|
928
|
+
);
|
|
929
|
+
return out.join("\n");
|
|
930
|
+
}
|
|
931
|
+
function main(argv = process.argv.slice(2)) {
|
|
932
|
+
const opts = parseArgs(argv);
|
|
933
|
+
const report = buildReport(opts);
|
|
934
|
+
if (opts.format === "json") {
|
|
935
|
+
process.stdout.write(JSON.stringify(report, null, 2) + "\n");
|
|
936
|
+
} else {
|
|
937
|
+
process.stdout.write(renderText(report) + "\n");
|
|
938
|
+
}
|
|
939
|
+
return 0;
|
|
940
|
+
}
|
|
941
|
+
if (process.argv[1] !== void 0) {
|
|
942
|
+
const invokedUrl = pathToFileURL(path7.resolve(process.argv[1])).href;
|
|
943
|
+
if (import.meta.url === invokedUrl) process.exit(main());
|
|
143
944
|
}
|
|
144
945
|
|
|
946
|
+
// src/scripts/preamble_byte_census.ts
|
|
947
|
+
var _HERE3 = fileURLToPath3(import.meta.url);
|
|
948
|
+
var REPO_ROOT3 = path8.resolve(path8.dirname(_HERE3), "..", "..");
|
|
949
|
+
var CHARS_PER_TOKEN = 4;
|
|
950
|
+
var SUM_TOLERANCE_PCT = 0.1;
|
|
951
|
+
function tokensFromChars(chars) {
|
|
952
|
+
return chars / CHARS_PER_TOKEN;
|
|
953
|
+
}
|
|
954
|
+
function readCharsIfExists(p) {
|
|
955
|
+
try {
|
|
956
|
+
return fs5.statSync(p).size;
|
|
957
|
+
} catch {
|
|
958
|
+
return 0;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
function topRulesByCost(dir, limit = 10) {
|
|
962
|
+
if (!fs5.existsSync(dir)) return [];
|
|
963
|
+
const entries = [];
|
|
964
|
+
for (const name of fs5.readdirSync(dir)) {
|
|
965
|
+
if (!name.endsWith(".md")) continue;
|
|
966
|
+
let chars;
|
|
967
|
+
try {
|
|
968
|
+
chars = fs5.statSync(path8.join(dir, name)).size;
|
|
969
|
+
} catch {
|
|
970
|
+
continue;
|
|
971
|
+
}
|
|
972
|
+
entries.push({ file: name, chars, tokens_estimate: tokensFromChars(chars) });
|
|
973
|
+
}
|
|
974
|
+
entries.sort((a, b) => b.chars - a.chars || a.file.localeCompare(b.file));
|
|
975
|
+
return entries.slice(0, limit);
|
|
976
|
+
}
|
|
977
|
+
var IMPORT_LINE_RE = /^@(\S+)\s*$/;
|
|
978
|
+
function parseClaudeMdImports(claudeMdPath) {
|
|
979
|
+
let text;
|
|
980
|
+
try {
|
|
981
|
+
text = fs5.readFileSync(claudeMdPath, "utf-8");
|
|
982
|
+
} catch {
|
|
983
|
+
return [];
|
|
984
|
+
}
|
|
985
|
+
const base = path8.dirname(claudeMdPath);
|
|
986
|
+
const out = [];
|
|
987
|
+
for (const line of text.split("\n")) {
|
|
988
|
+
const m = IMPORT_LINE_RE.exec(line.trim());
|
|
989
|
+
if (!m) continue;
|
|
990
|
+
const rel = m[1];
|
|
991
|
+
const resolved = path8.isAbsolute(rel) ? rel : path8.join(base, rel);
|
|
992
|
+
const chars = readCharsIfExists(resolved);
|
|
993
|
+
if (chars > 0) out.push({ file: rel, chars });
|
|
994
|
+
}
|
|
995
|
+
return out;
|
|
996
|
+
}
|
|
997
|
+
function censusClaudeMdHierarchy(repoRoot, userHome) {
|
|
998
|
+
const projectClaudeMd = path8.join(repoRoot, "CLAUDE.md");
|
|
999
|
+
const projectClaudeLocalMd = path8.join(repoRoot, "CLAUDE.local.md");
|
|
1000
|
+
const userClaudeMd = path8.join(userHome, ".claude", "CLAUDE.md");
|
|
1001
|
+
return {
|
|
1002
|
+
project_claude_md_chars: readCharsIfExists(projectClaudeMd),
|
|
1003
|
+
project_claude_md_present: fs5.existsSync(projectClaudeMd),
|
|
1004
|
+
project_claude_local_md_chars: readCharsIfExists(projectClaudeLocalMd),
|
|
1005
|
+
project_claude_local_md_present: fs5.existsSync(projectClaudeLocalMd),
|
|
1006
|
+
user_claude_md_chars: readCharsIfExists(userClaudeMd),
|
|
1007
|
+
user_claude_md_present: fs5.existsSync(userClaudeMd),
|
|
1008
|
+
user_imports: parseClaudeMdImports(userClaudeMd)
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
function censusGlobalProfile(env) {
|
|
1012
|
+
const p = resolveGlobalProfilePath(env);
|
|
1013
|
+
if (p === null) return { present: false, chars: 0, path: null };
|
|
1014
|
+
return { present: true, chars: readCharsIfExists(p), path: p };
|
|
1015
|
+
}
|
|
1016
|
+
function parseFrontmatter(text) {
|
|
1017
|
+
if (!text.startsWith("---")) return {};
|
|
1018
|
+
const end = text.indexOf("\n---", 3);
|
|
1019
|
+
if (end === -1) return {};
|
|
1020
|
+
const block = text.slice(3, end);
|
|
1021
|
+
try {
|
|
1022
|
+
const parsed = YAML.parse(block);
|
|
1023
|
+
return typeof parsed === "object" && parsed !== null ? parsed : {};
|
|
1024
|
+
} catch {
|
|
1025
|
+
return {};
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
function censusSkillsCatalog(skillsDir) {
|
|
1029
|
+
if (!fs5.existsSync(skillsDir)) return { skills: 0, chars: 0 };
|
|
1030
|
+
let skills = 0;
|
|
1031
|
+
let chars = 0;
|
|
1032
|
+
for (const entry of fs5.readdirSync(skillsDir, { withFileTypes: true })) {
|
|
1033
|
+
if (!entry.isDirectory()) continue;
|
|
1034
|
+
const skillMd = path8.join(skillsDir, entry.name, "SKILL.md");
|
|
1035
|
+
let text;
|
|
1036
|
+
try {
|
|
1037
|
+
text = fs5.readFileSync(skillMd, "utf-8");
|
|
1038
|
+
} catch {
|
|
1039
|
+
continue;
|
|
1040
|
+
}
|
|
1041
|
+
const fm = parseFrontmatter(text);
|
|
1042
|
+
const name = typeof fm.name === "string" && fm.name.length > 0 ? fm.name : entry.name;
|
|
1043
|
+
const description = typeof fm.description === "string" ? fm.description : "";
|
|
1044
|
+
chars += `- ${name}: ${description}
|
|
1045
|
+
`.length;
|
|
1046
|
+
skills += 1;
|
|
1047
|
+
}
|
|
1048
|
+
return { skills, chars };
|
|
1049
|
+
}
|
|
1050
|
+
function defaultOptions2() {
|
|
1051
|
+
const userHome = homedir2();
|
|
1052
|
+
return {
|
|
1053
|
+
format: "text",
|
|
1054
|
+
repoRoot: REPO_ROOT3,
|
|
1055
|
+
userHome,
|
|
1056
|
+
userRulesDir: path8.join(userHome, ".claude", "rules"),
|
|
1057
|
+
projectRulesDir: path8.join(REPO_ROOT3, "dist", "agent-src", "rules"),
|
|
1058
|
+
skillsDir: path8.join(REPO_ROOT3, "dist", "agent-src", "skills"),
|
|
1059
|
+
root: DEFAULT_PROJECTS_ROOT,
|
|
1060
|
+
maxAgeDays: 14
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
function parseArgs2(argv) {
|
|
1064
|
+
const opts = defaultOptions2();
|
|
1065
|
+
for (let i = 0; i < argv.length; i++) {
|
|
1066
|
+
const a = argv[i];
|
|
1067
|
+
if (a === void 0) continue;
|
|
1068
|
+
if (a === "--format") opts.format = argv[++i] ?? opts.format;
|
|
1069
|
+
else if (a.startsWith("--format=")) opts.format = a.slice("--format=".length);
|
|
1070
|
+
else if (a === "--repo-root") opts.repoRoot = argv[++i] ?? opts.repoRoot;
|
|
1071
|
+
else if (a.startsWith("--repo-root=")) opts.repoRoot = a.slice("--repo-root=".length);
|
|
1072
|
+
else if (a === "--user-home") opts.userHome = argv[++i] ?? opts.userHome;
|
|
1073
|
+
else if (a.startsWith("--user-home=")) opts.userHome = a.slice("--user-home=".length);
|
|
1074
|
+
else if (a === "--user-rules-dir") opts.userRulesDir = argv[++i] ?? opts.userRulesDir;
|
|
1075
|
+
else if (a.startsWith("--user-rules-dir=")) opts.userRulesDir = a.slice("--user-rules-dir=".length);
|
|
1076
|
+
else if (a === "--project-rules-dir") opts.projectRulesDir = argv[++i] ?? opts.projectRulesDir;
|
|
1077
|
+
else if (a.startsWith("--project-rules-dir=")) opts.projectRulesDir = a.slice("--project-rules-dir=".length);
|
|
1078
|
+
else if (a === "--skills-dir") opts.skillsDir = argv[++i] ?? opts.skillsDir;
|
|
1079
|
+
else if (a.startsWith("--skills-dir=")) opts.skillsDir = a.slice("--skills-dir=".length);
|
|
1080
|
+
else if (a === "--root") opts.root = argv[++i] ?? opts.root;
|
|
1081
|
+
else if (a.startsWith("--root=")) opts.root = a.slice("--root=".length);
|
|
1082
|
+
else if (a === "--max-age-days") opts.maxAgeDays = Number(argv[++i]) || opts.maxAgeDays;
|
|
1083
|
+
else if (a.startsWith("--max-age-days=")) opts.maxAgeDays = Number(a.slice("--max-age-days=".length)) || opts.maxAgeDays;
|
|
1084
|
+
}
|
|
1085
|
+
if (opts.format !== "text" && opts.format !== "json") opts.format = "text";
|
|
1086
|
+
return opts;
|
|
1087
|
+
}
|
|
1088
|
+
function buildByteCensus(opts) {
|
|
1089
|
+
const claudeMdChars = opts.claudeMd.project_claude_md_chars + opts.claudeMd.project_claude_local_md_chars + opts.claudeMd.user_claude_md_chars + opts.claudeMd.user_imports.reduce((s, i) => s + i.chars, 0);
|
|
1090
|
+
const claudeMdFiles = (opts.claudeMd.project_claude_md_present ? 1 : 0) + (opts.claudeMd.project_claude_local_md_present ? 1 : 0) + (opts.claudeMd.user_claude_md_present ? 1 : 0) + opts.claudeMd.user_imports.length;
|
|
1091
|
+
const sources = [
|
|
1092
|
+
{
|
|
1093
|
+
name: "user-scope rules (~/.claude/rules/*.md)",
|
|
1094
|
+
files: opts.userRules.files,
|
|
1095
|
+
chars: opts.userRules.chars,
|
|
1096
|
+
tokens_estimate: tokensFromChars(opts.userRules.chars),
|
|
1097
|
+
provenance: "measured_local_file",
|
|
1098
|
+
basis: "\u03A3 byte size of every .md file in the user-scope rules directory, chars/4."
|
|
1099
|
+
},
|
|
1100
|
+
{
|
|
1101
|
+
name: "project-scope rules (dist/agent-src/rules/*.md)",
|
|
1102
|
+
files: opts.projectRules.files,
|
|
1103
|
+
chars: opts.projectRules.chars,
|
|
1104
|
+
tokens_estimate: tokensFromChars(opts.projectRules.chars),
|
|
1105
|
+
provenance: "measured_local_file",
|
|
1106
|
+
basis: "\u03A3 byte size of every .md file in the project-scope rules directory, chars/4."
|
|
1107
|
+
},
|
|
1108
|
+
{
|
|
1109
|
+
name: "CLAUDE.md hierarchy (project + project-local + user + user @-imports)",
|
|
1110
|
+
files: claudeMdFiles,
|
|
1111
|
+
chars: claudeMdChars,
|
|
1112
|
+
tokens_estimate: tokensFromChars(claudeMdChars),
|
|
1113
|
+
provenance: "measured_local_file",
|
|
1114
|
+
basis: 'Byte size of project CLAUDE.md + project CLAUDE.local.md (if present) + user ~/.claude/CLAUDE.md + every file pulled in by a top-level "@<path>" import line in the user CLAUDE.md, chars/4.'
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
name: "global user profile.md (road-to-global-user-memory)",
|
|
1118
|
+
files: opts.globalProfile.present ? 1 : 0,
|
|
1119
|
+
chars: opts.globalProfile.chars,
|
|
1120
|
+
tokens_estimate: tokensFromChars(opts.globalProfile.chars),
|
|
1121
|
+
provenance: "measured_local_file",
|
|
1122
|
+
basis: opts.globalProfile.present ? `Byte size of ${opts.globalProfile.path}, chars/4.` : "Layer not written yet on this machine (resolveGlobalProfilePath() returned null) \u2014 treated as 0, per the roadmap's own honesty caveat."
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
name: "preloaded skills catalog (name + description, dist/agent-src/skills)",
|
|
1126
|
+
files: opts.skillsCatalog.skills,
|
|
1127
|
+
chars: opts.skillsCatalog.chars,
|
|
1128
|
+
tokens_estimate: tokensFromChars(opts.skillsCatalog.chars),
|
|
1129
|
+
provenance: "measured_local_file",
|
|
1130
|
+
basis: `\u03A3 "- <name>: <description>\\n" over every SKILL.md frontmatter, chars/4 \u2014 the description-text component only; the host's exact on-wire catalog format is not independently file-measurable.`
|
|
1131
|
+
}
|
|
1132
|
+
];
|
|
1133
|
+
const measurableTokensTotal = sources.reduce((s, src) => s + src.tokens_estimate, 0);
|
|
1134
|
+
const median3 = opts.measuredColdStartMedian;
|
|
1135
|
+
const residualTokens = median3 !== null ? Math.max(0, median3 - measurableTokensTotal) : null;
|
|
1136
|
+
if (residualTokens !== null) {
|
|
1137
|
+
sources.push({
|
|
1138
|
+
name: "tool definitions + dispatch prompt (residual)",
|
|
1139
|
+
files: 0,
|
|
1140
|
+
chars: 0,
|
|
1141
|
+
tokens_estimate: residualTokens,
|
|
1142
|
+
provenance: "residual",
|
|
1143
|
+
basis: "measured_cold_start_median minus the sum of the file-measurable buckets above. No local transcript or file carries the request's raw tool-definition JSON or the per-spawn dispatch-prompt text (verified: ~/.claude/projects/**/*.jsonl records only message.usage counts and response content, never the request system/tool payload) \u2014 this bucket exists so the gap is named rather than silently dropped."
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
const grandTotal = sources.reduce((s, src) => s + src.tokens_estimate, 0);
|
|
1147
|
+
const measurableShare = median3 !== null && median3 > 0 ? measurableTokensTotal / median3 : null;
|
|
1148
|
+
const withinTolerance = median3 !== null ? Math.abs(grandTotal - median3) / Math.max(1, median3) <= SUM_TOLERANCE_PCT : null;
|
|
1149
|
+
const dup = opts.duplicateScope;
|
|
1150
|
+
let modelledNewMedian = null;
|
|
1151
|
+
let modelledReductionPct = null;
|
|
1152
|
+
let modelledApplicable = false;
|
|
1153
|
+
let modelledReason;
|
|
1154
|
+
if (median3 === null) {
|
|
1155
|
+
modelledReason = "no measured cold-start median available in this window";
|
|
1156
|
+
} else if (!dup.evaluable) {
|
|
1157
|
+
modelledReason = dup.reason ?? "duplicate-scope census not evaluable";
|
|
1158
|
+
} else {
|
|
1159
|
+
modelledApplicable = true;
|
|
1160
|
+
modelledNewMedian = Math.max(0, median3 - dup.duplicate_chars / CHARS_PER_TOKEN);
|
|
1161
|
+
modelledReductionPct = median3 > 0 ? (median3 - modelledNewMedian) / median3 : 0;
|
|
1162
|
+
}
|
|
1163
|
+
return {
|
|
1164
|
+
sources,
|
|
1165
|
+
measurable_tokens_total: measurableTokensTotal,
|
|
1166
|
+
grand_total_tokens: grandTotal,
|
|
1167
|
+
measured_cold_start_median: median3,
|
|
1168
|
+
cold_start_legs: opts.coldStartLegs,
|
|
1169
|
+
measurable_share_of_median: measurableShare,
|
|
1170
|
+
within_tolerance: withinTolerance,
|
|
1171
|
+
top_rules_by_cost: opts.topRules,
|
|
1172
|
+
duplicate_scope: {
|
|
1173
|
+
evaluable: dup.evaluable,
|
|
1174
|
+
reason: dup.reason,
|
|
1175
|
+
shared_filenames: dup.shared_filenames.length,
|
|
1176
|
+
duplicate_tokens_per_spawn: dup.evaluable ? dup.duplicate_chars / CHARS_PER_TOKEN : 0
|
|
1177
|
+
},
|
|
1178
|
+
modelled_duplicate_removal: {
|
|
1179
|
+
applicable: modelledApplicable,
|
|
1180
|
+
reason: modelledReason,
|
|
1181
|
+
modelled_new_median: modelledNewMedian,
|
|
1182
|
+
modelled_reduction_pct: modelledReductionPct
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
function buildReport2(opts) {
|
|
1187
|
+
const userRules = censusRuleDir(opts.userRulesDir);
|
|
1188
|
+
const projectRules = censusRuleDir(opts.projectRulesDir);
|
|
1189
|
+
const claudeMd = censusClaudeMdHierarchy(opts.repoRoot, opts.userHome);
|
|
1190
|
+
const globalProfile = censusGlobalProfile();
|
|
1191
|
+
const skillsCatalog = censusSkillsCatalog(opts.skillsDir);
|
|
1192
|
+
const topRules = topRulesByCost(opts.projectRulesDir, 10);
|
|
1193
|
+
const duplicateScope = censusDuplicateScope(opts.userRulesDir, opts.projectRulesDir);
|
|
1194
|
+
const scan = scanTranscripts({ root: opts.root, maxAgeDays: opts.maxAgeDays });
|
|
1195
|
+
const coldStart = computeColdStarts(scan.records);
|
|
1196
|
+
const measuredColdStartMedian = coldStart.legs > 0 ? coldStart.median_first_call_written_or_uncached : null;
|
|
1197
|
+
return buildByteCensus({
|
|
1198
|
+
userRules,
|
|
1199
|
+
projectRules,
|
|
1200
|
+
claudeMd,
|
|
1201
|
+
globalProfile,
|
|
1202
|
+
skillsCatalog,
|
|
1203
|
+
topRules,
|
|
1204
|
+
duplicateScope,
|
|
1205
|
+
measuredColdStartMedian,
|
|
1206
|
+
coldStartLegs: coldStart.legs
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
function pct2(v) {
|
|
1210
|
+
return `${(v * 100).toFixed(1)}%`;
|
|
1211
|
+
}
|
|
1212
|
+
function renderText2(r) {
|
|
1213
|
+
const out = [];
|
|
1214
|
+
out.push("Preamble byte census (road-to-cache-economy Phase 3, steps 1-2)");
|
|
1215
|
+
out.push("");
|
|
1216
|
+
out.push("Sources:");
|
|
1217
|
+
for (const s of r.sources) {
|
|
1218
|
+
out.push(` ${s.name}`);
|
|
1219
|
+
out.push(` files=${s.files} chars=${s.chars} tokens_estimate=${Math.round(s.tokens_estimate)} [${s.provenance}]`);
|
|
1220
|
+
out.push(` basis: ${s.basis}`);
|
|
1221
|
+
}
|
|
1222
|
+
out.push("");
|
|
1223
|
+
out.push(`measurable_tokens_total (excludes residual): ${Math.round(r.measurable_tokens_total)}`);
|
|
1224
|
+
out.push(`grand_total_tokens (includes residual): ${Math.round(r.grand_total_tokens)}`);
|
|
1225
|
+
if (r.measured_cold_start_median !== null) {
|
|
1226
|
+
out.push(`measured_cold_start_median: ${Math.round(r.measured_cold_start_median)} (${r.cold_start_legs} legs, this window)`);
|
|
1227
|
+
out.push(`measurable_share_of_median: ${pct2(r.measurable_share_of_median)} (the honest, non-tautological number)`);
|
|
1228
|
+
out.push(
|
|
1229
|
+
`sum check (grand_total vs median, \xB110%): ${r.within_tolerance ? "PASS" : "FAIL"} \u2014 trivially PASS by construction once the residual bucket exists; see the module doc comment for why.`
|
|
1230
|
+
);
|
|
1231
|
+
} else {
|
|
1232
|
+
out.push("measured_cold_start_median: pending \u2014 no subagent legs observed in this window; no residual computed.");
|
|
1233
|
+
}
|
|
1234
|
+
out.push("");
|
|
1235
|
+
out.push("Top-10 project-scope rules by per-spawn token cost:");
|
|
1236
|
+
for (const rule of r.top_rules_by_cost) {
|
|
1237
|
+
out.push(` ${rule.file}: chars=${rule.chars} tokens_estimate=${Math.round(rule.tokens_estimate)}`);
|
|
1238
|
+
}
|
|
1239
|
+
out.push("");
|
|
1240
|
+
out.push("Duplicate-scope census (C-2):");
|
|
1241
|
+
if (r.duplicate_scope.evaluable) {
|
|
1242
|
+
out.push(
|
|
1243
|
+
` ${r.duplicate_scope.shared_filenames} shared filename(s), ${Math.round(r.duplicate_scope.duplicate_tokens_per_spawn)} redundant tokens per spawn.`
|
|
1244
|
+
);
|
|
1245
|
+
} else {
|
|
1246
|
+
out.push(` not evaluable \u2014 ${r.duplicate_scope.reason ?? "unknown reason"}`);
|
|
1247
|
+
}
|
|
1248
|
+
out.push("");
|
|
1249
|
+
out.push("Modelled duplicate-copy removal (MODELLED, not measured):");
|
|
1250
|
+
if (r.modelled_duplicate_removal.applicable) {
|
|
1251
|
+
out.push(` modelled_new_median: ${Math.round(r.modelled_duplicate_removal.modelled_new_median)}`);
|
|
1252
|
+
out.push(` modelled_reduction_pct: ${pct2(r.modelled_duplicate_removal.modelled_reduction_pct)}`);
|
|
1253
|
+
} else {
|
|
1254
|
+
out.push(` not applicable \u2014 ${r.modelled_duplicate_removal.reason ?? "unknown reason"}`);
|
|
1255
|
+
}
|
|
1256
|
+
out.push("");
|
|
1257
|
+
out.push("The per-spawn payload ceiling (median \u2264 40k / p95 \u2264 50k) is a DOCUMENTED CANDIDATE, gated on C-3");
|
|
1258
|
+
out.push("(preamble reducibility, still pending \u2014 no reduction intervention has landed). See");
|
|
1259
|
+
out.push("docs/contracts/load-context-budget-model.md. This report does NOT enforce it.");
|
|
1260
|
+
return out.join("\n");
|
|
1261
|
+
}
|
|
1262
|
+
function main2(argv = process.argv.slice(2)) {
|
|
1263
|
+
const opts = parseArgs2(argv);
|
|
1264
|
+
const report = buildReport2(opts);
|
|
1265
|
+
if (opts.format === "json") {
|
|
1266
|
+
process.stdout.write(JSON.stringify(report, null, 2) + "\n");
|
|
1267
|
+
} else {
|
|
1268
|
+
process.stdout.write(renderText2(report) + "\n");
|
|
1269
|
+
}
|
|
1270
|
+
return 0;
|
|
1271
|
+
}
|
|
1272
|
+
var _isBundled = true;
|
|
1273
|
+
if (!_isBundled && process.argv[1] !== void 0) {
|
|
1274
|
+
const invokedUrl = pathToFileURL2(path8.resolve(process.argv[1])).href;
|
|
1275
|
+
if (import.meta.url === invokedUrl) process.exit(main2());
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
// src/scripts/dispatch_economy_report.ts
|
|
1279
|
+
var dispatch_economy_report_exports = {};
|
|
1280
|
+
__export(dispatch_economy_report_exports, {
|
|
1281
|
+
DEFAULT_AUDIT_DIR: () => DEFAULT_AUDIT_DIR,
|
|
1282
|
+
DEFAULT_PROJECTS_ROOT: () => DEFAULT_PROJECTS_ROOT,
|
|
1283
|
+
buildReport: () => buildReport3,
|
|
1284
|
+
computeLegs: () => computeLegs,
|
|
1285
|
+
main: () => main3,
|
|
1286
|
+
median: () => median2,
|
|
1287
|
+
readAuditOrchestrations: () => readAuditOrchestrations,
|
|
1288
|
+
renderText: () => renderText3
|
|
1289
|
+
});
|
|
1290
|
+
import * as fs6 from "node:fs";
|
|
1291
|
+
import * as path9 from "node:path";
|
|
1292
|
+
import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
1293
|
+
var _HERE4 = fileURLToPath4(import.meta.url);
|
|
1294
|
+
var REPO_ROOT4 = path9.resolve(path9.dirname(_HERE4), "..", "..");
|
|
1295
|
+
var REGISTRATION_FILE = path9.join(REPO_ROOT4, "src", "config", "dispatch-economy-metrics.json");
|
|
1296
|
+
var DEFAULT_AUDIT_DIR = path9.join("agents", "runtime", "state", "audit");
|
|
1297
|
+
var REVIEWER_TYPE_RE = /review|judge|validator/i;
|
|
1298
|
+
function median2(values) {
|
|
1299
|
+
if (values.length === 0) return null;
|
|
1300
|
+
const s = [...values].sort((a, b) => a - b);
|
|
1301
|
+
const mid = Math.floor(s.length / 2);
|
|
1302
|
+
const lo = s[mid - 1];
|
|
1303
|
+
const hi = s[mid];
|
|
1304
|
+
if (s.length % 2 === 1) return hi ?? null;
|
|
1305
|
+
return lo !== void 0 && hi !== void 0 ? (lo + hi) / 2 : null;
|
|
1306
|
+
}
|
|
1307
|
+
function computeLegs(records) {
|
|
1308
|
+
const byAgent = /* @__PURE__ */ new Map();
|
|
1309
|
+
for (const r of records) {
|
|
1310
|
+
if (r.bucket !== "subagent" || r.agentId === null) continue;
|
|
1311
|
+
const list = byAgent.get(r.agentId) ?? [];
|
|
1312
|
+
list.push(r);
|
|
1313
|
+
byAgent.set(r.agentId, list);
|
|
1314
|
+
}
|
|
1315
|
+
const legs = [];
|
|
1316
|
+
for (const [agentId, recs] of byAgent) {
|
|
1317
|
+
const sorted = [...recs].sort((a, b) => {
|
|
1318
|
+
if (a.timestamp === null || b.timestamp === null) return 0;
|
|
1319
|
+
return a.timestamp < b.timestamp ? -1 : a.timestamp > b.timestamp ? 1 : 0;
|
|
1320
|
+
});
|
|
1321
|
+
const first = sorted[0];
|
|
1322
|
+
if (first === void 0) continue;
|
|
1323
|
+
const init = billableInputTokens(first.usage);
|
|
1324
|
+
const total = sorted.reduce((acc, r) => acc + billableInputTokens(r.usage), 0);
|
|
1325
|
+
const work = total - init;
|
|
1326
|
+
const initUnits = weightedInputUnits(first.usage);
|
|
1327
|
+
const workUnits = sorted.slice(1).reduce((acc, r) => acc + weightedInputUnits(r.usage), 0);
|
|
1328
|
+
legs.push({
|
|
1329
|
+
agentId,
|
|
1330
|
+
calls: sorted.length,
|
|
1331
|
+
init_tokens: init,
|
|
1332
|
+
work_tokens: work,
|
|
1333
|
+
ratio: workUnits > 0 ? initUnits / workUnits : null
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
return legs.sort((a, b) => a.agentId < b.agentId ? -1 : 1);
|
|
1337
|
+
}
|
|
1338
|
+
function isFiniteNonNegInt(v) {
|
|
1339
|
+
return typeof v === "number" && Number.isInteger(v) && v >= 0;
|
|
1340
|
+
}
|
|
1341
|
+
function readAuditOrchestrations(auditDir, opts = {}) {
|
|
1342
|
+
if (!fs6.existsSync(auditDir)) return [];
|
|
1343
|
+
const out = [];
|
|
1344
|
+
const cutoffMs = opts.maxAgeDays !== void 0 ? (opts.now ?? /* @__PURE__ */ new Date()).getTime() - opts.maxAgeDays * 24 * 60 * 60 * 1e3 : null;
|
|
1345
|
+
let entries;
|
|
1346
|
+
try {
|
|
1347
|
+
entries = fs6.readdirSync(auditDir).filter((f) => f.endsWith(".jsonl")).sort();
|
|
1348
|
+
} catch {
|
|
1349
|
+
return [];
|
|
1350
|
+
}
|
|
1351
|
+
if (cutoffMs !== null) {
|
|
1352
|
+
entries = entries.filter((f) => {
|
|
1353
|
+
try {
|
|
1354
|
+
return fs6.statSync(path9.join(auditDir, f)).mtimeMs >= cutoffMs;
|
|
1355
|
+
} catch {
|
|
1356
|
+
return false;
|
|
1357
|
+
}
|
|
1358
|
+
});
|
|
1359
|
+
}
|
|
1360
|
+
for (const f of entries) {
|
|
1361
|
+
let text;
|
|
1362
|
+
try {
|
|
1363
|
+
text = fs6.readFileSync(path9.join(auditDir, f), "utf8");
|
|
1364
|
+
} catch {
|
|
1365
|
+
continue;
|
|
1366
|
+
}
|
|
1367
|
+
for (const line of text.split("\n")) {
|
|
1368
|
+
if (line.trim().length === 0) continue;
|
|
1369
|
+
try {
|
|
1370
|
+
const parsed = JSON.parse(line);
|
|
1371
|
+
if (!parsed.orchestration || typeof parsed.orchestration !== "object") continue;
|
|
1372
|
+
if (cutoffMs !== null && typeof parsed.ts === "string") {
|
|
1373
|
+
const t = Date.parse(parsed.ts);
|
|
1374
|
+
if (Number.isFinite(t) && t < cutoffMs) continue;
|
|
1375
|
+
}
|
|
1376
|
+
out.push(parsed.orchestration);
|
|
1377
|
+
} catch {
|
|
1378
|
+
continue;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
return out;
|
|
1383
|
+
}
|
|
1384
|
+
function buildReport3(opts) {
|
|
1385
|
+
const registrationRaw = fs6.readFileSync(REGISTRATION_FILE, "utf8");
|
|
1386
|
+
const registration = JSON.parse(registrationRaw);
|
|
1387
|
+
const scanOpts = {
|
|
1388
|
+
root: opts.root,
|
|
1389
|
+
maxAgeDays: opts.maxAgeDays,
|
|
1390
|
+
...opts.now !== void 0 ? { now: opts.now } : {}
|
|
1391
|
+
};
|
|
1392
|
+
const scan = scanTranscripts(scanOpts);
|
|
1393
|
+
const legs = computeLegs(scan.records);
|
|
1394
|
+
const finiteRatios = legs.map((l) => l.ratio).filter((r) => r !== null);
|
|
1395
|
+
const singleCall = legs.filter((l) => l.ratio === null).length;
|
|
1396
|
+
const orchestrations = readAuditOrchestrations(opts.auditDir, {
|
|
1397
|
+
maxAgeDays: opts.maxAgeDays,
|
|
1398
|
+
...opts.now !== void 0 ? { now: opts.now } : {}
|
|
1399
|
+
});
|
|
1400
|
+
const reviewerMeasured = [];
|
|
1401
|
+
const quotas = [];
|
|
1402
|
+
let askLines = 0;
|
|
1403
|
+
let askAdopted = 0;
|
|
1404
|
+
let askEscalated = 0;
|
|
1405
|
+
const returnChars = [];
|
|
1406
|
+
for (const o of orchestrations) {
|
|
1407
|
+
if (o.route_taken === "ask") {
|
|
1408
|
+
askLines += 1;
|
|
1409
|
+
if (o.outcome === "DONE") askAdopted += 1;
|
|
1410
|
+
}
|
|
1411
|
+
if (o.route_taken === "subagent" && o.escalated === true && o.origin === "dispatch-economy-2026") {
|
|
1412
|
+
askEscalated += 1;
|
|
1413
|
+
}
|
|
1414
|
+
if (isFiniteNonNegInt(o.return_channel_chars)) {
|
|
1415
|
+
returnChars.push(o.return_channel_chars);
|
|
1416
|
+
}
|
|
1417
|
+
if (isFiniteNonNegInt(o.rules_carried) && isFiniteNonNegInt(o.rules_used) && o.rules_carried > 0) {
|
|
1418
|
+
quotas.push(o.rules_used / o.rules_carried);
|
|
1419
|
+
}
|
|
1420
|
+
const isReviewer = Array.isArray(o.agent_combo) && o.agent_combo.some((t2) => typeof t2 === "string" && REVIEWER_TYPE_RE.test(t2));
|
|
1421
|
+
if (isReviewer && o.floor_provenance === "measured" && isFiniteNonNegInt(o.init_tokens) && isFiniteNonNegInt(o.work_tokens)) {
|
|
1422
|
+
reviewerMeasured.push({ init: o.init_tokens, work: o.work_tokens });
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
const workerFloor = {
|
|
1426
|
+
role: "worker",
|
|
1427
|
+
attribution: "transcript-leg (role axis not shipped \u2014 all legs report as worker)",
|
|
1428
|
+
legs: legs.length,
|
|
1429
|
+
single_call_legs: singleCall,
|
|
1430
|
+
median_init_tokens: median2(legs.map((l) => l.init_tokens)),
|
|
1431
|
+
median_ratio_finite: median2(finiteRatios)
|
|
1432
|
+
};
|
|
1433
|
+
const reviewerRatios = reviewerMeasured.filter((p) => p.work > 0).map((p) => p.init / p.work);
|
|
1434
|
+
const reviewerFloor = {
|
|
1435
|
+
role: "reviewer",
|
|
1436
|
+
attribution: "audit-line agent_combo",
|
|
1437
|
+
legs: reviewerMeasured.length,
|
|
1438
|
+
single_call_legs: reviewerMeasured.filter((p) => p.work === 0).length,
|
|
1439
|
+
median_init_tokens: median2(reviewerMeasured.map((p) => p.init)),
|
|
1440
|
+
median_ratio_finite: median2(reviewerRatios)
|
|
1441
|
+
};
|
|
1442
|
+
const t = registration.metrics.dispatch_floor.thresholds;
|
|
1443
|
+
const lowQuota = registration.metrics.rules_efficiency.thresholds.low_quota_signal;
|
|
1444
|
+
const medianQuota = median2(quotas);
|
|
1445
|
+
const medianWorkerRatio = workerFloor.median_ratio_finite;
|
|
1446
|
+
const notes = [
|
|
1447
|
+
`dedup: ${scan.totalSeen} raw assistant records \u2192 ${scan.dedupedCount} (replay inflation removed)`,
|
|
1448
|
+
"single_call_legs are floor-only legs (all init, zero work) \u2014 they are excluded from the finite-ratio median and support, never dilute, the projection-mandatory reading",
|
|
1449
|
+
"projection_mandatory_signal is a single-run reading; the registered verdict is a sustained-window call at review date (dispatch-economy-metrics.json)"
|
|
1450
|
+
];
|
|
1451
|
+
return {
|
|
1452
|
+
schema: "dispatch-economy-report/v1",
|
|
1453
|
+
registration: { registered_at: registration.registered_at, review_by: registration.review_by },
|
|
1454
|
+
window: { max_age_days: opts.maxAgeDays, transcript_records: scan.dedupedCount, legs: legs.length },
|
|
1455
|
+
dispatch_floor: {
|
|
1456
|
+
roles: [workerFloor, reviewerFloor],
|
|
1457
|
+
thresholds: t,
|
|
1458
|
+
projection_mandatory_signal: medianWorkerRatio === null ? null : medianWorkerRatio > t.projection_mandatory_ratio
|
|
1459
|
+
},
|
|
1460
|
+
rules_efficiency: {
|
|
1461
|
+
envelopes_with_pair: quotas.length,
|
|
1462
|
+
median_quota: medianQuota,
|
|
1463
|
+
threshold_low_quota: lowQuota,
|
|
1464
|
+
low_quota_signal: medianQuota === null ? null : medianQuota < lowQuota
|
|
1465
|
+
},
|
|
1466
|
+
ask_economy: {
|
|
1467
|
+
ask_lines: askLines,
|
|
1468
|
+
adopted: askAdopted,
|
|
1469
|
+
escalated: askEscalated,
|
|
1470
|
+
threshold_escalation_kill: registration.metrics.ask_economy.thresholds.escalation_kill,
|
|
1471
|
+
escalation_kill_signal: askLines === 0 ? null : askEscalated / askLines > registration.metrics.ask_economy.thresholds.escalation_kill
|
|
1472
|
+
},
|
|
1473
|
+
return_channel: {
|
|
1474
|
+
lines_with_field: returnChars.length,
|
|
1475
|
+
median_chars: median2(returnChars),
|
|
1476
|
+
envelope_cap_chars: registration.metrics.return_channel.thresholds.envelope_cap_chars,
|
|
1477
|
+
cap_breach_signal: returnChars.length === 0 ? null : (median2(returnChars) ?? 0) > registration.metrics.return_channel.thresholds.envelope_cap_chars
|
|
1478
|
+
},
|
|
1479
|
+
notes
|
|
1480
|
+
};
|
|
1481
|
+
}
|
|
1482
|
+
function fmtTokens(n) {
|
|
1483
|
+
if (n === null) return "\u2014";
|
|
1484
|
+
return n >= 1e3 ? `${(n / 1e3).toFixed(1)}k` : String(Math.round(n));
|
|
1485
|
+
}
|
|
1486
|
+
function renderText3(r) {
|
|
1487
|
+
const lines = [];
|
|
1488
|
+
lines.push("dispatch-economy report (registered: " + r.registration.registered_at + " \xB7 review by: " + r.registration.review_by + ")");
|
|
1489
|
+
lines.push(`window: ${r.window.max_age_days}d \xB7 ${r.window.transcript_records} deduped records \xB7 ${r.window.legs} legs`);
|
|
1490
|
+
lines.push("");
|
|
1491
|
+
lines.push("dispatch_floor:");
|
|
1492
|
+
for (const role of r.dispatch_floor.roles) {
|
|
1493
|
+
lines.push(
|
|
1494
|
+
` ${role.role.padEnd(8)} legs=${role.legs} (single-call: ${role.single_call_legs}) \xB7 median init=${fmtTokens(role.median_init_tokens)} \xB7 median init/work=${role.median_ratio_finite === null ? "\u2014" : role.median_ratio_finite.toFixed(2)}`
|
|
1495
|
+
);
|
|
1496
|
+
lines.push(` attribution: ${role.attribution}`);
|
|
1497
|
+
}
|
|
1498
|
+
lines.push(
|
|
1499
|
+
` projection-mandatory signal (ratio > ${r.dispatch_floor.thresholds.projection_mandatory_ratio}): ${r.dispatch_floor.projection_mandatory_signal === null ? "no data" : String(r.dispatch_floor.projection_mandatory_signal)}`
|
|
1500
|
+
);
|
|
1501
|
+
lines.push("");
|
|
1502
|
+
lines.push("rules_efficiency:");
|
|
1503
|
+
lines.push(
|
|
1504
|
+
` envelopes with pair=${r.rules_efficiency.envelopes_with_pair} \xB7 median quota=${r.rules_efficiency.median_quota === null ? "\u2014" : r.rules_efficiency.median_quota.toFixed(2)} \xB7 low-quota signal (< ${r.rules_efficiency.threshold_low_quota}): ${r.rules_efficiency.low_quota_signal === null ? "no data" : String(r.rules_efficiency.low_quota_signal)}`
|
|
1505
|
+
);
|
|
1506
|
+
lines.push("");
|
|
1507
|
+
lines.push("return_channel:");
|
|
1508
|
+
lines.push(
|
|
1509
|
+
` lines=${r.return_channel.lines_with_field} \xB7 median chars=${r.return_channel.median_chars === null ? "\u2014" : Math.round(r.return_channel.median_chars)} \xB7 cap-breach signal (> ${r.return_channel.envelope_cap_chars}): ${r.return_channel.cap_breach_signal === null ? "no data" : String(r.return_channel.cap_breach_signal)}`
|
|
1510
|
+
);
|
|
1511
|
+
lines.push("");
|
|
1512
|
+
lines.push("ask_economy:");
|
|
1513
|
+
lines.push(
|
|
1514
|
+
` ask lines=${r.ask_economy.ask_lines} \xB7 adopted=${r.ask_economy.adopted} \xB7 escalated=${r.ask_economy.escalated} \xB7 escalation-kill signal (> ${r.ask_economy.threshold_escalation_kill}): ${r.ask_economy.escalation_kill_signal === null ? "no data" : String(r.ask_economy.escalation_kill_signal)}`
|
|
1515
|
+
);
|
|
1516
|
+
lines.push("");
|
|
1517
|
+
for (const n of r.notes) lines.push(`note: ${n}`);
|
|
1518
|
+
return lines.join("\n") + "\n";
|
|
1519
|
+
}
|
|
1520
|
+
function main3(argv) {
|
|
1521
|
+
let format = "text";
|
|
1522
|
+
let root = DEFAULT_PROJECTS_ROOT;
|
|
1523
|
+
let auditDir = path9.join(process.cwd(), DEFAULT_AUDIT_DIR);
|
|
1524
|
+
let maxAgeDays = 14;
|
|
1525
|
+
for (let i = 0; i < argv.length; i++) {
|
|
1526
|
+
const a = argv[i];
|
|
1527
|
+
if (a === "--format") format = argv[++i] === "json" ? "json" : "text";
|
|
1528
|
+
else if (a === "--root") root = argv[++i] ?? root;
|
|
1529
|
+
else if (a === "--audit-dir") auditDir = argv[++i] ?? auditDir;
|
|
1530
|
+
else if (a === "--max-age-days") maxAgeDays = Number(argv[++i] ?? maxAgeDays) || maxAgeDays;
|
|
1531
|
+
}
|
|
1532
|
+
let report;
|
|
1533
|
+
try {
|
|
1534
|
+
report = buildReport3({ root, auditDir, maxAgeDays });
|
|
1535
|
+
} catch (err) {
|
|
1536
|
+
process.stderr.write(`dispatch_economy_report: ${err instanceof Error ? err.message : String(err)}
|
|
1537
|
+
`);
|
|
1538
|
+
return 2;
|
|
1539
|
+
}
|
|
1540
|
+
process.stdout.write(format === "json" ? JSON.stringify(report, null, 2) + "\n" : renderText3(report));
|
|
1541
|
+
return 0;
|
|
1542
|
+
}
|
|
1543
|
+
function _isCliEntry() {
|
|
1544
|
+
if (true) return false;
|
|
1545
|
+
if (process.argv[1] === void 0) return false;
|
|
1546
|
+
const argvUrl = pathToFileURL3(path9.resolve(process.argv[1])).href;
|
|
1547
|
+
if (import.meta.url === argvUrl) return true;
|
|
1548
|
+
try {
|
|
1549
|
+
return fs6.realpathSync(fileURLToPath4(import.meta.url)) === fs6.realpathSync(path9.resolve(process.argv[1]));
|
|
1550
|
+
} catch {
|
|
1551
|
+
return false;
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
if (_isCliEntry()) process.exit(main3(process.argv.slice(2)));
|
|
1555
|
+
|
|
145
1556
|
// src/scripts/ai_council/clients.ts
|
|
146
1557
|
var clients_exports = {};
|
|
147
1558
|
__export(clients_exports, {
|
|
@@ -200,27 +1611,28 @@ __export(clients_exports, {
|
|
|
200
1611
|
reset_cli_call_counts: () => reset_cli_call_counts
|
|
201
1612
|
});
|
|
202
1613
|
import { spawnSync } from "node:child_process";
|
|
203
|
-
import * as
|
|
204
|
-
import * as
|
|
1614
|
+
import * as fs8 from "node:fs";
|
|
1615
|
+
import * as path11 from "node:path";
|
|
205
1616
|
|
|
206
1617
|
// src/scripts/_lib/session_role.ts
|
|
207
1618
|
var SESSION_ROLE_ENV = "AGENT_CONFIG_SESSION_ROLE";
|
|
208
1619
|
|
|
209
1620
|
// src/scripts/ai_council/events_log.ts
|
|
210
1621
|
import * as crypto from "node:crypto";
|
|
211
|
-
import * as
|
|
212
|
-
import * as
|
|
213
|
-
import { fileURLToPath } from "node:url";
|
|
214
|
-
var SCHEMA_VERSION =
|
|
1622
|
+
import * as fs7 from "node:fs";
|
|
1623
|
+
import * as path10 from "node:path";
|
|
1624
|
+
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
1625
|
+
var SCHEMA_VERSION = 2;
|
|
215
1626
|
var _VALID_ACTIONS = /* @__PURE__ */ new Set([
|
|
216
1627
|
"proceed",
|
|
217
1628
|
"skip_necessity",
|
|
218
|
-
"block_quota"
|
|
1629
|
+
"block_quota",
|
|
1630
|
+
"quorum_result"
|
|
219
1631
|
]);
|
|
220
1632
|
var _KILL_SWITCH_ENV = "AGENT_CONFIG_NO_EVENTS_LOG";
|
|
221
|
-
var
|
|
222
|
-
var _REPO_ROOT =
|
|
223
|
-
var _DEFAULT_LOG_PATH =
|
|
1633
|
+
var _HERE5 = fileURLToPath5(import.meta.url);
|
|
1634
|
+
var _REPO_ROOT = path10.resolve(path10.dirname(_HERE5), "..", "..", "..");
|
|
1635
|
+
var _DEFAULT_LOG_PATH = path10.join(
|
|
224
1636
|
_REPO_ROOT,
|
|
225
1637
|
"agents",
|
|
226
1638
|
"runtime",
|
|
@@ -321,9 +1733,9 @@ function appendEvent(event, opts = {}) {
|
|
|
321
1733
|
}
|
|
322
1734
|
}
|
|
323
1735
|
const target = opts.logPath != null ? opts.logPath : _DEFAULT_LOG_PATH;
|
|
324
|
-
|
|
1736
|
+
fs7.mkdirSync(path10.dirname(target), { recursive: true });
|
|
325
1737
|
const line = _pyJsonDumpsCompact(record);
|
|
326
|
-
|
|
1738
|
+
fs7.appendFileSync(target, line + "\n", { encoding: "utf-8" });
|
|
327
1739
|
return true;
|
|
328
1740
|
}
|
|
329
1741
|
function _isoSecondsZ(d) {
|
|
@@ -483,9 +1895,21 @@ function assertCacheBreakpointOrder(ttls) {
|
|
|
483
1895
|
}
|
|
484
1896
|
}
|
|
485
1897
|
}
|
|
1898
|
+
function _servedModel(response, field = "model") {
|
|
1899
|
+
const value = _getattr(response, field, "");
|
|
1900
|
+
return typeof value === "string" ? value : "";
|
|
1901
|
+
}
|
|
486
1902
|
var CouncilResponse = class {
|
|
487
1903
|
provider;
|
|
488
1904
|
model;
|
|
1905
|
+
// The model id the provider reported serving, when it reports one. NEVER
|
|
1906
|
+
// overwrites `model`: that is the REQUESTED id, and it is what the tier
|
|
1907
|
+
// decision was made against — keeping both is what makes a silent alias or
|
|
1908
|
+
// provider substitution detectable at all. Attribution-only; no consumer
|
|
1909
|
+
// may route on it. Defaults to '' (the honest value for a transport that
|
|
1910
|
+
// reports no served id, e.g. every CLI client) so existing callers and the
|
|
1911
|
+
// persisted response JSON stay backward-compatible.
|
|
1912
|
+
model_served;
|
|
489
1913
|
text;
|
|
490
1914
|
input_tokens;
|
|
491
1915
|
output_tokens;
|
|
@@ -501,6 +1925,7 @@ var CouncilResponse = class {
|
|
|
501
1925
|
constructor(opts) {
|
|
502
1926
|
this.provider = opts.provider;
|
|
503
1927
|
this.model = opts.model;
|
|
1928
|
+
this.model_served = opts.model_served ?? "";
|
|
504
1929
|
this.text = opts.text;
|
|
505
1930
|
this.input_tokens = opts.input_tokens ?? 0;
|
|
506
1931
|
this.output_tokens = opts.output_tokens ?? 0;
|
|
@@ -526,13 +1951,13 @@ function _setMonotonicSource(fn) {
|
|
|
526
1951
|
return prev;
|
|
527
1952
|
}
|
|
528
1953
|
function _loadKey(p, prefix, installScript) {
|
|
529
|
-
if (!
|
|
1954
|
+
if (!fs8.existsSync(p)) {
|
|
530
1955
|
throw new KeyGateError(
|
|
531
1956
|
`Key not found at ${p}.
|
|
532
1957
|
Install it with: bash ${installScript}`
|
|
533
1958
|
);
|
|
534
1959
|
}
|
|
535
|
-
const st =
|
|
1960
|
+
const st = fs8.statSync(p);
|
|
536
1961
|
const mode = st.mode & 511;
|
|
537
1962
|
if (mode !== 384) {
|
|
538
1963
|
throw new KeyGateError(
|
|
@@ -540,7 +1965,7 @@ function _loadKey(p, prefix, installScript) {
|
|
|
540
1965
|
Fix: chmod 600 ${p}`
|
|
541
1966
|
);
|
|
542
1967
|
}
|
|
543
|
-
const key =
|
|
1968
|
+
const key = fs8.readFileSync(p, { encoding: "utf-8" }).trim();
|
|
544
1969
|
if (!key) {
|
|
545
1970
|
throw new KeyGateError(`${p} is empty.`);
|
|
546
1971
|
}
|
|
@@ -747,6 +2172,7 @@ var AnthropicClient = class extends ExternalAIClient {
|
|
|
747
2172
|
return new CouncilResponse({
|
|
748
2173
|
provider: this.name,
|
|
749
2174
|
model: this.model,
|
|
2175
|
+
model_served: _servedModel(response),
|
|
750
2176
|
text,
|
|
751
2177
|
input_tokens: usage ? _getattr(usage, "input_tokens", 0) : 0,
|
|
752
2178
|
output_tokens: usage ? _getattr(usage, "output_tokens", 0) : 0,
|
|
@@ -834,6 +2260,7 @@ ${user_prompt}` }
|
|
|
834
2260
|
return new CouncilResponse({
|
|
835
2261
|
provider: this.name,
|
|
836
2262
|
model: this.model,
|
|
2263
|
+
model_served: _servedModel(response),
|
|
837
2264
|
text: text || "",
|
|
838
2265
|
input_tokens: usage ? _getattr(usage, "prompt_tokens", 0) : 0,
|
|
839
2266
|
output_tokens: usage ? _getattr(usage, "completion_tokens", 0) : 0,
|
|
@@ -894,6 +2321,8 @@ ${user_prompt}`;
|
|
|
894
2321
|
return new CouncilResponse({
|
|
895
2322
|
provider: this.name,
|
|
896
2323
|
model: this.model,
|
|
2324
|
+
// Gemini names it `model_version`, not `model`.
|
|
2325
|
+
model_served: _servedModel(response, "model_version"),
|
|
897
2326
|
text,
|
|
898
2327
|
input_tokens: usage ? _getattr(usage, "prompt_token_count", 0) : 0,
|
|
899
2328
|
output_tokens: usage ? _getattr(usage, "candidates_token_count", 0) : 0,
|
|
@@ -959,6 +2388,7 @@ var _OpenAICompatibleClient = class extends ExternalAIClient {
|
|
|
959
2388
|
return new CouncilResponse({
|
|
960
2389
|
provider: this.name,
|
|
961
2390
|
model: this.model,
|
|
2391
|
+
model_served: _servedModel(response),
|
|
962
2392
|
text: text || "",
|
|
963
2393
|
input_tokens: usage ? _getattr(usage, "prompt_tokens", 0) : 0,
|
|
964
2394
|
output_tokens: usage ? _getattr(usage, "completion_tokens", 0) : 0,
|
|
@@ -998,12 +2428,12 @@ function _today_utc_iso() {
|
|
|
998
2428
|
}
|
|
999
2429
|
function load_cli_call_counts(p = null) {
|
|
1000
2430
|
const target = p !== null ? p : _cliCallsStatePath();
|
|
1001
|
-
if (!
|
|
2431
|
+
if (!fs8.existsSync(target)) {
|
|
1002
2432
|
return {};
|
|
1003
2433
|
}
|
|
1004
2434
|
let data;
|
|
1005
2435
|
try {
|
|
1006
|
-
data = JSON.parse(
|
|
2436
|
+
data = JSON.parse(fs8.readFileSync(target, { encoding: "utf-8" }));
|
|
1007
2437
|
} catch {
|
|
1008
2438
|
return {};
|
|
1009
2439
|
}
|
|
@@ -1030,8 +2460,8 @@ function record_cli_call(provider, p = null) {
|
|
|
1030
2460
|
const target = p !== null ? p : _cliCallsStatePath();
|
|
1031
2461
|
const counts = load_cli_call_counts(target);
|
|
1032
2462
|
counts[provider] = (counts[provider] ?? 0) + 1;
|
|
1033
|
-
|
|
1034
|
-
|
|
2463
|
+
fs8.mkdirSync(path11.dirname(target), { recursive: true });
|
|
2464
|
+
fs8.writeFileSync(
|
|
1035
2465
|
target,
|
|
1036
2466
|
_jsonDumpsIndent2({ date: _today_utc_iso(), counts }),
|
|
1037
2467
|
{ encoding: "utf-8" }
|
|
@@ -1046,8 +2476,8 @@ function reset_cli_call_counts(provider = null, p = null) {
|
|
|
1046
2476
|
} else {
|
|
1047
2477
|
delete counts[provider];
|
|
1048
2478
|
}
|
|
1049
|
-
|
|
1050
|
-
|
|
2479
|
+
fs8.mkdirSync(path11.dirname(target), { recursive: true });
|
|
2480
|
+
fs8.writeFileSync(
|
|
1051
2481
|
target,
|
|
1052
2482
|
_jsonDumpsIndent2({ date: _today_utc_iso(), counts }),
|
|
1053
2483
|
{ encoding: "utf-8" }
|
|
@@ -2115,7 +3545,7 @@ function _pyJsonStringAscii(s) {
|
|
|
2115
3545
|
return out + '"';
|
|
2116
3546
|
}
|
|
2117
3547
|
function _which(name) {
|
|
2118
|
-
if (name.includes(
|
|
3548
|
+
if (name.includes(path11.sep) || path11.sep !== "/" && name.includes("/")) {
|
|
2119
3549
|
return _isExecutable(name) ? name : null;
|
|
2120
3550
|
}
|
|
2121
3551
|
const pathEnv = process.env.PATH ?? "";
|
|
@@ -2123,12 +3553,12 @@ function _which(name) {
|
|
|
2123
3553
|
return null;
|
|
2124
3554
|
}
|
|
2125
3555
|
const exts = process.platform === "win32" ? (process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean) : [""];
|
|
2126
|
-
for (const dir of pathEnv.split(
|
|
3556
|
+
for (const dir of pathEnv.split(path11.delimiter)) {
|
|
2127
3557
|
if (!dir) {
|
|
2128
3558
|
continue;
|
|
2129
3559
|
}
|
|
2130
3560
|
for (const ext of exts) {
|
|
2131
|
-
const candidate =
|
|
3561
|
+
const candidate = path11.join(dir, name + ext);
|
|
2132
3562
|
if (_isExecutable(candidate)) {
|
|
2133
3563
|
return candidate;
|
|
2134
3564
|
}
|
|
@@ -2138,7 +3568,7 @@ function _which(name) {
|
|
|
2138
3568
|
}
|
|
2139
3569
|
function _isExecutable(p) {
|
|
2140
3570
|
try {
|
|
2141
|
-
const st =
|
|
3571
|
+
const st = fs8.statSync(p);
|
|
2142
3572
|
if (!st.isFile()) {
|
|
2143
3573
|
return false;
|
|
2144
3574
|
}
|
|
@@ -2165,7 +3595,7 @@ function _defaultStdin() {
|
|
|
2165
3595
|
function ensure() {
|
|
2166
3596
|
if (buffer === null) {
|
|
2167
3597
|
try {
|
|
2168
|
-
buffer =
|
|
3598
|
+
buffer = fs8.readFileSync(0, { encoding: "utf-8" });
|
|
2169
3599
|
} catch {
|
|
2170
3600
|
buffer = "";
|
|
2171
3601
|
}
|
|
@@ -2207,14 +3637,14 @@ function _defaultStdin() {
|
|
|
2207
3637
|
|
|
2208
3638
|
// src/scripts/_lib/environment_detector.ts
|
|
2209
3639
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
2210
|
-
import * as
|
|
3640
|
+
import * as fs9 from "node:fs";
|
|
2211
3641
|
import * as os from "node:os";
|
|
2212
|
-
import * as
|
|
3642
|
+
import * as path12 from "node:path";
|
|
2213
3643
|
|
|
2214
3644
|
// src/install/toolDetection.ts
|
|
2215
|
-
import { existsSync as
|
|
2216
|
-
import { homedir } from "node:os";
|
|
2217
|
-
import { delimiter as delimiter2, join as
|
|
3645
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
3646
|
+
import { homedir as homedir3 } from "node:os";
|
|
3647
|
+
import { delimiter as delimiter2, join as join12 } from "node:path";
|
|
2218
3648
|
var TOOL_SIGNALS = {
|
|
2219
3649
|
"claude-code": { bins: ["claude"], homePaths: [".claude", ".claude.json", ".config/claude"] },
|
|
2220
3650
|
"claude-desktop": { absPaths: ["/Applications/Claude.app"], homePaths: ["Library/Application Support/Claude", ".config/Claude"] },
|
|
@@ -2259,8 +3689,8 @@ function resolveBinaryPath(name, pathEnv) {
|
|
|
2259
3689
|
for (const dir of pathEnv.split(delimiter2)) {
|
|
2260
3690
|
if (dir.length === 0) continue;
|
|
2261
3691
|
for (const candidate of [name, `${name}.exe`, `${name}.cmd`]) {
|
|
2262
|
-
const full =
|
|
2263
|
-
if (
|
|
3692
|
+
const full = join12(dir, candidate);
|
|
3693
|
+
if (existsSync7(full)) return full;
|
|
2264
3694
|
}
|
|
2265
3695
|
}
|
|
2266
3696
|
return null;
|
|
@@ -2270,10 +3700,10 @@ function binOnPath(name, pathEnv) {
|
|
|
2270
3700
|
}
|
|
2271
3701
|
function isToolInstalled(signal, home, pathEnv) {
|
|
2272
3702
|
for (const rel of signal.homePaths ?? []) {
|
|
2273
|
-
if (
|
|
3703
|
+
if (existsSync7(join12(home, rel))) return true;
|
|
2274
3704
|
}
|
|
2275
3705
|
for (const abs of signal.absPaths ?? []) {
|
|
2276
|
-
if (
|
|
3706
|
+
if (existsSync7(abs)) return true;
|
|
2277
3707
|
}
|
|
2278
3708
|
for (const bin of signal.bins ?? []) {
|
|
2279
3709
|
if (binOnPath(bin, pathEnv)) return true;
|
|
@@ -2281,7 +3711,7 @@ function isToolInstalled(signal, home, pathEnv) {
|
|
|
2281
3711
|
return false;
|
|
2282
3712
|
}
|
|
2283
3713
|
function detectInstalledTools(opts = {}) {
|
|
2284
|
-
const home = opts.home ??
|
|
3714
|
+
const home = opts.home ?? homedir3();
|
|
2285
3715
|
const pathEnv = opts.pathEnv ?? process.env["PATH"] ?? "";
|
|
2286
3716
|
const out = {};
|
|
2287
3717
|
for (const [id, signal] of Object.entries(TOOL_SIGNALS)) {
|
|
@@ -2332,7 +3762,7 @@ function classifyBilling(provider, source) {
|
|
|
2332
3762
|
function codexHome(env) {
|
|
2333
3763
|
const map = env ?? process.env;
|
|
2334
3764
|
const override = (map["CODEX_HOME"] ?? "").trim();
|
|
2335
|
-
return override !== "" ? override :
|
|
3765
|
+
return override !== "" ? override : path12.join(homeOf(env), ".codex");
|
|
2336
3766
|
}
|
|
2337
3767
|
function homeOf(env) {
|
|
2338
3768
|
const map = env ?? process.env;
|
|
@@ -2357,14 +3787,14 @@ ${res.stderr ?? ""}`;
|
|
|
2357
3787
|
}
|
|
2358
3788
|
function isFile(p) {
|
|
2359
3789
|
try {
|
|
2360
|
-
return
|
|
3790
|
+
return fs9.statSync(p).isFile();
|
|
2361
3791
|
} catch {
|
|
2362
3792
|
return false;
|
|
2363
3793
|
}
|
|
2364
3794
|
}
|
|
2365
3795
|
function exists(p) {
|
|
2366
3796
|
try {
|
|
2367
|
-
return
|
|
3797
|
+
return fs9.existsSync(p);
|
|
2368
3798
|
} catch {
|
|
2369
3799
|
return false;
|
|
2370
3800
|
}
|
|
@@ -2372,7 +3802,7 @@ function exists(p) {
|
|
|
2372
3802
|
function classifyCodexAuth(authPath) {
|
|
2373
3803
|
let data;
|
|
2374
3804
|
try {
|
|
2375
|
-
data = JSON.parse(
|
|
3805
|
+
data = JSON.parse(fs9.readFileSync(authPath, "utf-8"));
|
|
2376
3806
|
} catch {
|
|
2377
3807
|
return "cli-api-key";
|
|
2378
3808
|
}
|
|
@@ -2389,18 +3819,18 @@ function cliSubscriptionEvidence(provider, home, env, claudeConfigDir) {
|
|
|
2389
3819
|
if (provider === "anthropic") {
|
|
2390
3820
|
const configDir = claudeConfigDir;
|
|
2391
3821
|
for (const rel of [".credentials.json", "credentials.json"]) {
|
|
2392
|
-
const p =
|
|
3822
|
+
const p = path12.join(configDir, rel);
|
|
2393
3823
|
if (isFile(p)) return { source: "cli-subscription", evidence: p };
|
|
2394
3824
|
}
|
|
2395
3825
|
return null;
|
|
2396
3826
|
}
|
|
2397
3827
|
if (provider === "openai") {
|
|
2398
|
-
const p =
|
|
3828
|
+
const p = path12.join(codexHome(env), "auth.json");
|
|
2399
3829
|
if (isFile(p)) return { source: classifyCodexAuth(p), evidence: p };
|
|
2400
3830
|
return null;
|
|
2401
3831
|
}
|
|
2402
3832
|
if (provider === "gemini") {
|
|
2403
|
-
const p =
|
|
3833
|
+
const p = path12.join(home, ".gemini", "oauth_creds.json");
|
|
2404
3834
|
if (isFile(p)) return { source: "cli-subscription", evidence: p };
|
|
2405
3835
|
return null;
|
|
2406
3836
|
}
|
|
@@ -2432,7 +3862,7 @@ function detectHosts(opts) {
|
|
|
2432
3862
|
function detectAuth(opts) {
|
|
2433
3863
|
const env = opts.env ?? process.env;
|
|
2434
3864
|
const home = opts.home ?? homeOf(opts.env);
|
|
2435
|
-
const claudeConfigDir = opts.home === void 0 && opts.env === void 0 ? claude_config_dir() : (env["CLAUDE_CONFIG_DIR"] ?? "").trim() ||
|
|
3865
|
+
const claudeConfigDir = opts.home === void 0 && opts.env === void 0 ? claude_config_dir() : (env["CLAUDE_CONFIG_DIR"] ?? "").trim() || path12.join(home, ".claude");
|
|
2436
3866
|
const auth = [];
|
|
2437
3867
|
const keys = [];
|
|
2438
3868
|
for (const provider of knownProviders()) {
|
|
@@ -2486,7 +3916,7 @@ function detectEnvironment(opts = {}) {
|
|
|
2486
3916
|
}
|
|
2487
3917
|
|
|
2488
3918
|
// src/scripts/_cli/detection_report.ts
|
|
2489
|
-
import * as
|
|
3919
|
+
import * as path13 from "node:path";
|
|
2490
3920
|
|
|
2491
3921
|
// src/scripts/ai_council/transport_resolver.ts
|
|
2492
3922
|
var VALID_TRANSPORT_MODES = /* @__PURE__ */ new Set([
|
|
@@ -2688,7 +4118,7 @@ function cliBinaryPresent(environment, provider, binaryOverride) {
|
|
|
2688
4118
|
const expected = PROVIDER_CLI_META[provider]?.[0];
|
|
2689
4119
|
if (expected === void 0) return false;
|
|
2690
4120
|
return environment.hosts.some(
|
|
2691
|
-
(h) => h.binary !== null && stripExe(
|
|
4121
|
+
(h) => h.binary !== null && stripExe(path13.basename(h.binary)) === expected
|
|
2692
4122
|
);
|
|
2693
4123
|
}
|
|
2694
4124
|
function stripExe(name) {
|
|
@@ -2849,9 +4279,9 @@ function absentCouncilFacts(configPath) {
|
|
|
2849
4279
|
|
|
2850
4280
|
// src/scripts/ai_team/review_gate.ts
|
|
2851
4281
|
import * as crypto2 from "node:crypto";
|
|
2852
|
-
import * as
|
|
4282
|
+
import * as fs10 from "node:fs";
|
|
2853
4283
|
import * as os2 from "node:os";
|
|
2854
|
-
import * as
|
|
4284
|
+
import * as path14 from "node:path";
|
|
2855
4285
|
|
|
2856
4286
|
// src/scripts/ai_team/config.ts
|
|
2857
4287
|
var AI_TEAM_REVIEW_GATE_DEFAULTS = Object.freeze({
|
|
@@ -2867,16 +4297,16 @@ var AI_TEAM_DEFAULTS = Object.freeze({
|
|
|
2867
4297
|
});
|
|
2868
4298
|
|
|
2869
4299
|
// src/scripts/ai_team/review_gate.ts
|
|
2870
|
-
var GATE_LEDGER_RELPATH =
|
|
4300
|
+
var GATE_LEDGER_RELPATH = path14.join("agents", "runtime", "team", "events.log");
|
|
2871
4301
|
var _CODEX_PLUGIN_DATA_DIRNAME = `${CODEX_PLUGIN_ID}-${CODEX_MARKETPLACE_NAME}`;
|
|
2872
4302
|
function _workspace_state_segment(workspace_root) {
|
|
2873
4303
|
let canonical = workspace_root;
|
|
2874
4304
|
try {
|
|
2875
|
-
canonical =
|
|
4305
|
+
canonical = fs10.realpathSync.native(workspace_root);
|
|
2876
4306
|
} catch {
|
|
2877
4307
|
canonical = workspace_root;
|
|
2878
4308
|
}
|
|
2879
|
-
const slug_source =
|
|
4309
|
+
const slug_source = path14.basename(workspace_root) || "workspace";
|
|
2880
4310
|
const slug = slug_source.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "workspace";
|
|
2881
4311
|
const hash = crypto2.createHash("sha256").update(canonical).digest("hex").slice(0, 16);
|
|
2882
4312
|
return `${slug}-${hash}`;
|
|
@@ -2886,19 +4316,19 @@ function upstream_state_dir_candidates(workspace_root) {
|
|
|
2886
4316
|
const candidates = [];
|
|
2887
4317
|
const env = (process.env["CLAUDE_PLUGIN_DATA"] ?? "").trim();
|
|
2888
4318
|
if (env !== "") {
|
|
2889
|
-
candidates.push(
|
|
4319
|
+
candidates.push(path14.join(env, "state", segment));
|
|
2890
4320
|
}
|
|
2891
4321
|
candidates.push(
|
|
2892
|
-
|
|
4322
|
+
path14.join(claude_config_dir(), "plugins", "data", _CODEX_PLUGIN_DATA_DIRNAME, "state", segment)
|
|
2893
4323
|
);
|
|
2894
|
-
candidates.push(
|
|
4324
|
+
candidates.push(path14.join(os2.tmpdir(), "codex-companion", segment));
|
|
2895
4325
|
return candidates;
|
|
2896
4326
|
}
|
|
2897
4327
|
function upstream_gate_enabled(workspace_root) {
|
|
2898
4328
|
for (const dir of upstream_state_dir_candidates(workspace_root)) {
|
|
2899
4329
|
let parsed;
|
|
2900
4330
|
try {
|
|
2901
|
-
parsed = JSON.parse(
|
|
4331
|
+
parsed = JSON.parse(fs10.readFileSync(path14.join(dir, "state.json"), "utf-8"));
|
|
2902
4332
|
} catch {
|
|
2903
4333
|
continue;
|
|
2904
4334
|
}
|
|
@@ -2947,7 +4377,7 @@ function review_gate_doctor_signal(project_root, gate_raw) {
|
|
|
2947
4377
|
}
|
|
2948
4378
|
|
|
2949
4379
|
// src/scripts/_cli/cmd_doctor.ts
|
|
2950
|
-
var
|
|
4380
|
+
var _HERE6 = fileURLToPath6(import.meta.url);
|
|
2951
4381
|
var ArgparseExit = class extends Error {
|
|
2952
4382
|
constructor(code) {
|
|
2953
4383
|
super(`argparse-exit-${code}`);
|
|
@@ -2958,13 +4388,13 @@ var ArgparseExit = class extends Error {
|
|
|
2958
4388
|
function expanduser(p) {
|
|
2959
4389
|
if (p === "~") return os3.homedir();
|
|
2960
4390
|
if (p.startsWith("~/") || p.startsWith("~\\")) {
|
|
2961
|
-
return
|
|
4391
|
+
return path15.join(os3.homedir(), p.slice(2));
|
|
2962
4392
|
}
|
|
2963
4393
|
return p;
|
|
2964
4394
|
}
|
|
2965
4395
|
function pathExists(p) {
|
|
2966
4396
|
try {
|
|
2967
|
-
|
|
4397
|
+
fs11.statSync(p);
|
|
2968
4398
|
return true;
|
|
2969
4399
|
} catch {
|
|
2970
4400
|
return false;
|
|
@@ -2972,27 +4402,27 @@ function pathExists(p) {
|
|
|
2972
4402
|
}
|
|
2973
4403
|
function isFile2(p) {
|
|
2974
4404
|
try {
|
|
2975
|
-
return
|
|
4405
|
+
return fs11.statSync(p).isFile();
|
|
2976
4406
|
} catch {
|
|
2977
4407
|
return false;
|
|
2978
4408
|
}
|
|
2979
4409
|
}
|
|
2980
4410
|
function isDir(p) {
|
|
2981
4411
|
try {
|
|
2982
|
-
return
|
|
4412
|
+
return fs11.statSync(p).isDirectory();
|
|
2983
4413
|
} catch {
|
|
2984
4414
|
return false;
|
|
2985
4415
|
}
|
|
2986
4416
|
}
|
|
2987
4417
|
function resolvePath(p) {
|
|
2988
4418
|
try {
|
|
2989
|
-
return
|
|
4419
|
+
return fs11.realpathSync(path15.resolve(p));
|
|
2990
4420
|
} catch {
|
|
2991
|
-
return
|
|
4421
|
+
return path15.resolve(p);
|
|
2992
4422
|
}
|
|
2993
4423
|
}
|
|
2994
4424
|
function readText(p) {
|
|
2995
|
-
return
|
|
4425
|
+
return fs11.readFileSync(p, "utf-8");
|
|
2996
4426
|
}
|
|
2997
4427
|
function _jsonStrAscii(s) {
|
|
2998
4428
|
let out = '"';
|
|
@@ -3080,11 +4510,11 @@ function _jsonDumpsIndentAscii(value, indent) {
|
|
|
3080
4510
|
return _dumpIndentAscii(value, indent, 0);
|
|
3081
4511
|
}
|
|
3082
4512
|
function yamlSafeLoad(text) {
|
|
3083
|
-
if (
|
|
4513
|
+
if (YAML2 === void 0 || YAML2 === null) {
|
|
3084
4514
|
return null;
|
|
3085
4515
|
}
|
|
3086
4516
|
try {
|
|
3087
|
-
return
|
|
4517
|
+
return YAML2.parse(text, { version: "1.1" });
|
|
3088
4518
|
} catch {
|
|
3089
4519
|
return void 0;
|
|
3090
4520
|
}
|
|
@@ -3103,7 +4533,7 @@ function _resolve_project_root(arg) {
|
|
|
3103
4533
|
}
|
|
3104
4534
|
var _INSTALL_MODE_MARKER_REL = "agents/.agent-state/install-mode.txt";
|
|
3105
4535
|
function _detect_install_mode(project_root) {
|
|
3106
|
-
const marker =
|
|
4536
|
+
const marker = path15.join(project_root, _INSTALL_MODE_MARKER_REL);
|
|
3107
4537
|
if (isFile2(marker)) {
|
|
3108
4538
|
let value;
|
|
3109
4539
|
try {
|
|
@@ -3115,9 +4545,9 @@ function _detect_install_mode(project_root) {
|
|
|
3115
4545
|
return [value, "marker-file"];
|
|
3116
4546
|
}
|
|
3117
4547
|
}
|
|
3118
|
-
const has_agents_md = pathExists(
|
|
4548
|
+
const has_agents_md = pathExists(path15.join(project_root, "AGENTS.md"));
|
|
3119
4549
|
const has_copilot = pathExists(
|
|
3120
|
-
|
|
4550
|
+
path15.join(project_root, ".github", "copilot-instructions.md")
|
|
3121
4551
|
);
|
|
3122
4552
|
if (has_agents_md && has_copilot) {
|
|
3123
4553
|
return ["full", "heuristic"];
|
|
@@ -3137,7 +4567,7 @@ function _settings_layer_chain(project_root) {
|
|
|
3137
4567
|
return layers;
|
|
3138
4568
|
}
|
|
3139
4569
|
function _detect_wrapper(project_root) {
|
|
3140
|
-
const wrapper =
|
|
4570
|
+
const wrapper = path15.join(project_root, "agent-config");
|
|
3141
4571
|
if (!pathExists(wrapper)) {
|
|
3142
4572
|
return { path: String(wrapper), exists: false, embedded_root: null };
|
|
3143
4573
|
}
|
|
@@ -3204,14 +4634,14 @@ function _emit_context_text(ctx) {
|
|
|
3204
4634
|
}
|
|
3205
4635
|
function _resolve_path(project_root, raw) {
|
|
3206
4636
|
let p = expanduser(raw);
|
|
3207
|
-
if (!
|
|
3208
|
-
p =
|
|
4637
|
+
if (!path15.isAbsolute(p)) {
|
|
4638
|
+
p = path15.join(project_root, p);
|
|
3209
4639
|
}
|
|
3210
4640
|
return p;
|
|
3211
4641
|
}
|
|
3212
4642
|
function _sha256(p) {
|
|
3213
4643
|
try {
|
|
3214
|
-
const data =
|
|
4644
|
+
const data = fs11.readFileSync(p);
|
|
3215
4645
|
return crypto3.createHash("sha256").update(data).digest("hex");
|
|
3216
4646
|
} catch {
|
|
3217
4647
|
return null;
|
|
@@ -3220,7 +4650,7 @@ function _sha256(p) {
|
|
|
3220
4650
|
var PACKAGE_TAG_ID = "event4u/agent-config";
|
|
3221
4651
|
var _FRONTMATTER_PACKAGE_RE = /^package:\s*(.+?)\s*$/m;
|
|
3222
4652
|
function _read_inline_package_tag(p) {
|
|
3223
|
-
if (
|
|
4653
|
+
if (path15.extname(p) !== ".md") {
|
|
3224
4654
|
return NO_FRONTMATTER;
|
|
3225
4655
|
}
|
|
3226
4656
|
let text;
|
|
@@ -3349,13 +4779,13 @@ function rglob(root) {
|
|
|
3349
4779
|
const walk = (dir) => {
|
|
3350
4780
|
let entries;
|
|
3351
4781
|
try {
|
|
3352
|
-
entries =
|
|
4782
|
+
entries = fs11.readdirSync(dir, { withFileTypes: true });
|
|
3353
4783
|
} catch {
|
|
3354
4784
|
return;
|
|
3355
4785
|
}
|
|
3356
4786
|
entries.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
3357
4787
|
for (const ent of entries) {
|
|
3358
|
-
const full =
|
|
4788
|
+
const full = path15.join(dir, ent.name);
|
|
3359
4789
|
out.push(full);
|
|
3360
4790
|
let dirLike = ent.isDirectory();
|
|
3361
4791
|
if (ent.isSymbolicLink()) {
|
|
@@ -3430,9 +4860,9 @@ function _foreign_records(project_root, foreign) {
|
|
|
3430
4860
|
return out;
|
|
3431
4861
|
}
|
|
3432
4862
|
function relativeTo(p, base) {
|
|
3433
|
-
const rel =
|
|
4863
|
+
const rel = path15.relative(base, p);
|
|
3434
4864
|
if (rel === "") return rel;
|
|
3435
|
-
if (rel.startsWith("..") ||
|
|
4865
|
+
if (rel.startsWith("..") || path15.isAbsolute(rel)) {
|
|
3436
4866
|
return null;
|
|
3437
4867
|
}
|
|
3438
4868
|
return rel;
|
|
@@ -3496,7 +4926,7 @@ var MANIFEST_REQUIRED_CHECK_IDS = /* @__PURE__ */ new Set([
|
|
|
3496
4926
|
]);
|
|
3497
4927
|
var INSTALL_MODE_MARKER_RELATIVE = "agents/.agent-state/install-mode.txt";
|
|
3498
4928
|
function _is_global_only_consumer(project_root) {
|
|
3499
|
-
return isFile2(
|
|
4929
|
+
return isFile2(path15.join(project_root, INSTALL_MODE_MARKER_RELATIVE)) || isDir(path15.join(project_root, "agents", "overrides"));
|
|
3500
4930
|
}
|
|
3501
4931
|
var REPAIR_IDS = ["wizard-state"];
|
|
3502
4932
|
var MCP_BETA_GATES = [
|
|
@@ -3516,7 +4946,7 @@ var STATUS_SYMBOLS = {
|
|
|
3516
4946
|
var MIN_PYTHON = [3, 10];
|
|
3517
4947
|
function _check_scope(project_root) {
|
|
3518
4948
|
for (const marker of ["pnpm-workspace.yaml", "lerna.json"]) {
|
|
3519
|
-
if (pathExists(
|
|
4949
|
+
if (pathExists(path15.join(project_root, marker))) {
|
|
3520
4950
|
return {
|
|
3521
4951
|
id: "scope",
|
|
3522
4952
|
status: "warn",
|
|
@@ -3525,7 +4955,7 @@ function _check_scope(project_root) {
|
|
|
3525
4955
|
};
|
|
3526
4956
|
}
|
|
3527
4957
|
}
|
|
3528
|
-
const pkg =
|
|
4958
|
+
const pkg = path15.join(project_root, "package.json");
|
|
3529
4959
|
if (pathExists(pkg)) {
|
|
3530
4960
|
try {
|
|
3531
4961
|
const data = JSON.parse(readText(pkg));
|
|
@@ -3551,7 +4981,7 @@ var _PLACEHOLDER_EMAIL_RE = /^(t@t\.t|.*@example\.(com|org)|.*@localhost)$/i;
|
|
|
3551
4981
|
var _PLACEHOLDER_NAME_RE = /^(t|test|user|nobody|x)$/i;
|
|
3552
4982
|
function _git_config_path(project_root) {
|
|
3553
4983
|
const common = git_common_dir(project_root);
|
|
3554
|
-
return common === null ? null :
|
|
4984
|
+
return common === null ? null : path15.join(common, "config");
|
|
3555
4985
|
}
|
|
3556
4986
|
function _parse_git_user(configText) {
|
|
3557
4987
|
let inUser = false;
|
|
@@ -3581,7 +5011,7 @@ function _check_git_identity(project_root) {
|
|
|
3581
5011
|
}
|
|
3582
5012
|
let ident = _parse_git_user(readText(cfgPath));
|
|
3583
5013
|
if (ident.name === null && ident.email === null) {
|
|
3584
|
-
const globalCfg =
|
|
5014
|
+
const globalCfg = path15.join(os3.homedir(), ".gitconfig");
|
|
3585
5015
|
if (pathExists(globalCfg)) {
|
|
3586
5016
|
ident = _parse_git_user(readText(globalCfg));
|
|
3587
5017
|
}
|
|
@@ -3642,7 +5072,7 @@ function _package_root() {
|
|
|
3642
5072
|
}
|
|
3643
5073
|
function _current_package_version() {
|
|
3644
5074
|
try {
|
|
3645
|
-
const data = JSON.parse(readText(
|
|
5075
|
+
const data = JSON.parse(readText(path15.join(_package_root(), "package.json")));
|
|
3646
5076
|
const v = data["version"];
|
|
3647
5077
|
if (typeof v === "string" && v.trim()) {
|
|
3648
5078
|
return v.trim();
|
|
@@ -3686,7 +5116,7 @@ function _check_lockfile_freshness(manifest) {
|
|
|
3686
5116
|
};
|
|
3687
5117
|
}
|
|
3688
5118
|
function shutilWhich(name) {
|
|
3689
|
-
if (
|
|
5119
|
+
if (path15.dirname(name) !== "." && (name.includes("/") || name.includes("\\"))) {
|
|
3690
5120
|
return isExecutableFile(name) ? name : null;
|
|
3691
5121
|
}
|
|
3692
5122
|
const pathEnv = process2.env["PATH"] || "";
|
|
@@ -3699,12 +5129,12 @@ function shutilWhich(name) {
|
|
|
3699
5129
|
if (seenDirs.has(d)) continue;
|
|
3700
5130
|
seenDirs.add(d);
|
|
3701
5131
|
for (const ext of exts) {
|
|
3702
|
-
const candidate =
|
|
5132
|
+
const candidate = path15.join(d, name + (ext === "" ? "" : ext.toLowerCase() === ext ? ext : ext));
|
|
3703
5133
|
if (isExecutableFile(candidate)) {
|
|
3704
5134
|
return candidate;
|
|
3705
5135
|
}
|
|
3706
5136
|
if (ext !== "") {
|
|
3707
|
-
const upper =
|
|
5137
|
+
const upper = path15.join(d, name + ext);
|
|
3708
5138
|
if (isExecutableFile(upper)) return upper;
|
|
3709
5139
|
}
|
|
3710
5140
|
}
|
|
@@ -3713,10 +5143,10 @@ function shutilWhich(name) {
|
|
|
3713
5143
|
}
|
|
3714
5144
|
function isExecutableFile(p) {
|
|
3715
5145
|
try {
|
|
3716
|
-
const st =
|
|
5146
|
+
const st = fs11.statSync(p);
|
|
3717
5147
|
if (!st.isFile()) return false;
|
|
3718
5148
|
if (process2.platform === "win32") return true;
|
|
3719
|
-
|
|
5149
|
+
fs11.accessSync(p, fs11.constants.X_OK);
|
|
3720
5150
|
return true;
|
|
3721
5151
|
} catch {
|
|
3722
5152
|
return false;
|
|
@@ -3780,7 +5210,7 @@ function _check_claude_plugin() {
|
|
|
3780
5210
|
remedy: ""
|
|
3781
5211
|
};
|
|
3782
5212
|
}
|
|
3783
|
-
const projection =
|
|
5213
|
+
const projection = path15.join(os3.homedir(), ".claude", "skills");
|
|
3784
5214
|
const projection_present = isDir(projection);
|
|
3785
5215
|
if (projection_present) {
|
|
3786
5216
|
return {
|
|
@@ -3817,8 +5247,8 @@ function _check_claude_command_wrappers() {
|
|
|
3817
5247
|
remedy: ""
|
|
3818
5248
|
};
|
|
3819
5249
|
}
|
|
3820
|
-
const anchor =
|
|
3821
|
-
const commands_dir =
|
|
5250
|
+
const anchor = path15.join(os3.homedir(), ".claude");
|
|
5251
|
+
const commands_dir = path15.join(anchor, "commands");
|
|
3822
5252
|
if (!isDir(commands_dir)) {
|
|
3823
5253
|
return {
|
|
3824
5254
|
id: "claude-command-wrappers",
|
|
@@ -3827,8 +5257,8 @@ function _check_claude_command_wrappers() {
|
|
|
3827
5257
|
remedy: ""
|
|
3828
5258
|
};
|
|
3829
5259
|
}
|
|
3830
|
-
const flat_probe =
|
|
3831
|
-
const wrapper_probe =
|
|
5260
|
+
const flat_probe = fs11.existsSync(path15.join(commands_dir, "commit.md"));
|
|
5261
|
+
const wrapper_probe = fs11.existsSync(path15.join(anchor, "skills", "commit", "SKILL.md"));
|
|
3832
5262
|
if (wrapper_probe) {
|
|
3833
5263
|
return {
|
|
3834
5264
|
id: "claude-command-wrappers",
|
|
@@ -3853,7 +5283,7 @@ function _check_claude_command_wrappers() {
|
|
|
3853
5283
|
};
|
|
3854
5284
|
}
|
|
3855
5285
|
function _check_surface_state() {
|
|
3856
|
-
const matrix_path =
|
|
5286
|
+
const matrix_path = path15.join(_package_root(), "src", "config", "surface-matrix.yml");
|
|
3857
5287
|
if (!isFile2(matrix_path)) {
|
|
3858
5288
|
return {
|
|
3859
5289
|
id: "surface-state",
|
|
@@ -3864,7 +5294,7 @@ function _check_surface_state() {
|
|
|
3864
5294
|
}
|
|
3865
5295
|
let tools = {};
|
|
3866
5296
|
try {
|
|
3867
|
-
const raw =
|
|
5297
|
+
const raw = YAML2.parse(readText(matrix_path), { version: "1.1" });
|
|
3868
5298
|
const t = raw["tools"];
|
|
3869
5299
|
if (t && typeof t === "object" && !Array.isArray(t)) {
|
|
3870
5300
|
tools = t;
|
|
@@ -3877,7 +5307,7 @@ function _check_surface_state() {
|
|
|
3877
5307
|
remedy: "agent-config upgrade (reinstalls the package data files)"
|
|
3878
5308
|
};
|
|
3879
5309
|
}
|
|
3880
|
-
const _expand = (p) => p.startsWith("~/") ?
|
|
5310
|
+
const _expand = (p) => p.startsWith("~/") ? path15.join(os3.homedir(), p.slice(2)) : path15.join(_package_root(), p);
|
|
3881
5311
|
const violations = [];
|
|
3882
5312
|
const remedies = [];
|
|
3883
5313
|
let checked = 0;
|
|
@@ -3919,7 +5349,7 @@ function _check_surface_state() {
|
|
|
3919
5349
|
}
|
|
3920
5350
|
function pathExistsAny(p) {
|
|
3921
5351
|
try {
|
|
3922
|
-
|
|
5352
|
+
fs11.statSync(p);
|
|
3923
5353
|
return true;
|
|
3924
5354
|
} catch {
|
|
3925
5355
|
return false;
|
|
@@ -3935,13 +5365,13 @@ function _check_hook_wiring() {
|
|
|
3935
5365
|
remedy: ""
|
|
3936
5366
|
};
|
|
3937
5367
|
}
|
|
3938
|
-
const settings_path =
|
|
5368
|
+
const settings_path = path15.join(os3.homedir(), ".claude", "settings.json");
|
|
3939
5369
|
let missing;
|
|
3940
5370
|
try {
|
|
3941
5371
|
const matrix = build_claude_hook_matrix(
|
|
3942
|
-
|
|
5372
|
+
path15.join(_package_root(), "src", "scripts", "hook_manifest.yaml")
|
|
3943
5373
|
);
|
|
3944
|
-
const settings = pathExists(settings_path) ? JSON.parse(
|
|
5374
|
+
const settings = pathExists(settings_path) ? JSON.parse(fs11.readFileSync(settings_path, "utf8")) : {};
|
|
3945
5375
|
const hooks = (settings["hooks"] ?? {}) || {};
|
|
3946
5376
|
missing = Object.keys(matrix).filter((ev) => {
|
|
3947
5377
|
const groups = hooks[ev];
|
|
@@ -4016,7 +5446,7 @@ function _check_mcp_mode(project_root) {
|
|
|
4016
5446
|
];
|
|
4017
5447
|
const found = [];
|
|
4018
5448
|
for (const [rel, label] of candidates) {
|
|
4019
|
-
const p =
|
|
5449
|
+
const p = path15.join(project_root, rel);
|
|
4020
5450
|
if (!pathExists(p)) {
|
|
4021
5451
|
continue;
|
|
4022
5452
|
}
|
|
@@ -4048,7 +5478,7 @@ function _check_mcp_mode(project_root) {
|
|
|
4048
5478
|
};
|
|
4049
5479
|
}
|
|
4050
5480
|
function _check_offline_readiness() {
|
|
4051
|
-
const script =
|
|
5481
|
+
const script = path15.join(_package_root(), "src", "scripts", "hermetic-install.sh");
|
|
4052
5482
|
if (!pathExists(script)) {
|
|
4053
5483
|
return {
|
|
4054
5484
|
id: "offline-readiness",
|
|
@@ -4106,7 +5536,7 @@ function _check_stale_orphans() {
|
|
|
4106
5536
|
(a, b) => a < b ? -1 : a > b ? 1 : 0
|
|
4107
5537
|
);
|
|
4108
5538
|
for (const root_name of ownedSorted) {
|
|
4109
|
-
const root =
|
|
5539
|
+
const root = path15.join(anchor, root_name);
|
|
4110
5540
|
if (!isDir(root)) {
|
|
4111
5541
|
continue;
|
|
4112
5542
|
}
|
|
@@ -4121,7 +5551,7 @@ function _check_stale_orphans() {
|
|
|
4121
5551
|
if (rel === null) {
|
|
4122
5552
|
continue;
|
|
4123
5553
|
}
|
|
4124
|
-
const relPosix = rel.split(
|
|
5554
|
+
const relPosix = rel.split(path15.sep).join("/");
|
|
4125
5555
|
if (recorded_set.has(relPosix)) {
|
|
4126
5556
|
continue;
|
|
4127
5557
|
}
|
|
@@ -4176,14 +5606,14 @@ function _check_rule_scope_drift(project_root) {
|
|
|
4176
5606
|
let rules_dir = null;
|
|
4177
5607
|
let found = 0;
|
|
4178
5608
|
for (const rel of _RULE_PROJECTION_DIRS) {
|
|
4179
|
-
const cand =
|
|
5609
|
+
const cand = path15.join(project_root, rel);
|
|
4180
5610
|
if (!isDir(cand)) {
|
|
4181
5611
|
continue;
|
|
4182
5612
|
}
|
|
4183
5613
|
let count = 0;
|
|
4184
5614
|
try {
|
|
4185
|
-
for (const name of
|
|
4186
|
-
if (name.endsWith(".md") && isFile2(
|
|
5615
|
+
for (const name of fs11.readdirSync(cand)) {
|
|
5616
|
+
if (name.endsWith(".md") && isFile2(path15.join(cand, name))) {
|
|
4187
5617
|
count += 1;
|
|
4188
5618
|
}
|
|
4189
5619
|
}
|
|
@@ -4237,14 +5667,14 @@ function _check_rule_scope_drift(project_root) {
|
|
|
4237
5667
|
};
|
|
4238
5668
|
}
|
|
4239
5669
|
function _check_duplicate_scope_rules(project_root, userRulesDirOverride) {
|
|
4240
|
-
const user_rules_dir = userRulesDirOverride ??
|
|
5670
|
+
const user_rules_dir = userRulesDirOverride ?? path15.join(os3.homedir(), ".claude", "rules");
|
|
4241
5671
|
let project_rules_dir = null;
|
|
4242
5672
|
if (_is_source_repo(project_root)) {
|
|
4243
|
-
const cand =
|
|
5673
|
+
const cand = path15.join(project_root, "dist", "agent-src", "rules");
|
|
4244
5674
|
if (isDir(cand)) project_rules_dir = cand;
|
|
4245
5675
|
} else {
|
|
4246
5676
|
for (const rel of _RULE_PROJECTION_DIRS) {
|
|
4247
|
-
const cand =
|
|
5677
|
+
const cand = path15.join(project_root, rel);
|
|
4248
5678
|
if (isDir(cand)) {
|
|
4249
5679
|
project_rules_dir = cand;
|
|
4250
5680
|
break;
|
|
@@ -4313,7 +5743,7 @@ function _check_mcp_beta_readiness(project_root) {
|
|
|
4313
5743
|
}
|
|
4314
5744
|
const pending = [];
|
|
4315
5745
|
for (const [gate_id, rel] of MCP_BETA_GATES) {
|
|
4316
|
-
if (!pathExists(
|
|
5746
|
+
if (!pathExists(path15.join(project_root, rel))) {
|
|
4317
5747
|
pending.push(`${gate_id} (${rel})`);
|
|
4318
5748
|
}
|
|
4319
5749
|
}
|
|
@@ -4334,7 +5764,7 @@ function _check_mcp_beta_readiness(project_root) {
|
|
|
4334
5764
|
}
|
|
4335
5765
|
function _check_tier_usage_readiness(project_root) {
|
|
4336
5766
|
const settings_file = project_settings_path(project_root);
|
|
4337
|
-
let log_path =
|
|
5767
|
+
let log_path = path15.join(project_root, ".agent-tier-usage.jsonl");
|
|
4338
5768
|
let enabled = false;
|
|
4339
5769
|
if (isFile2(settings_file)) {
|
|
4340
5770
|
let raw;
|
|
@@ -4353,7 +5783,7 @@ function _check_tier_usage_readiness(project_root) {
|
|
|
4353
5783
|
const outputRaw = tu["output"];
|
|
4354
5784
|
const output = typeof outputRaw === "object" && outputRaw !== null && !Array.isArray(outputRaw) ? outputRaw : {};
|
|
4355
5785
|
if (typeof output["path"] === "string" && output["path"].trim()) {
|
|
4356
|
-
log_path =
|
|
5786
|
+
log_path = path15.join(project_root, output["path"].trim());
|
|
4357
5787
|
}
|
|
4358
5788
|
const val = tu["enabled"];
|
|
4359
5789
|
if (typeof val === "boolean") {
|
|
@@ -4378,7 +5808,7 @@ function _check_tier_usage_readiness(project_root) {
|
|
|
4378
5808
|
return {
|
|
4379
5809
|
id: "tier-usage-readiness",
|
|
4380
5810
|
status: "warn",
|
|
4381
|
-
message: `tier-usage telemetry on but ${
|
|
5811
|
+
message: `tier-usage telemetry on but ${path15.basename(log_path)} not yet written \u2014 no signal accumulated`,
|
|
4382
5812
|
remedy: "run any tracked command to seed the log; the dispatcher writes one record per invocation"
|
|
4383
5813
|
};
|
|
4384
5814
|
}
|
|
@@ -4393,7 +5823,7 @@ function _check_tier_usage_readiness(project_root) {
|
|
|
4393
5823
|
return {
|
|
4394
5824
|
id: "tier-usage-readiness",
|
|
4395
5825
|
status: "fail",
|
|
4396
|
-
message: `cannot read ${
|
|
5826
|
+
message: `cannot read ${path15.basename(log_path)}: ${osErrorStr(exc)}`,
|
|
4397
5827
|
remedy: "fix permissions on the tier-usage log"
|
|
4398
5828
|
};
|
|
4399
5829
|
}
|
|
@@ -4424,7 +5854,7 @@ function _check_tier_usage_readiness(project_root) {
|
|
|
4424
5854
|
return {
|
|
4425
5855
|
id: "tier-usage-readiness",
|
|
4426
5856
|
status: "fail",
|
|
4427
|
-
message: `${total} record(s) in ${
|
|
5857
|
+
message: `${total} record(s) in ${path15.basename(log_path)} but 0 passed the privacy floor \u2014 report would refuse to render`,
|
|
4428
5858
|
remedy: "inspect the log; the dispatcher is writing records the contract forbids (paths, argv, message bodies)"
|
|
4429
5859
|
};
|
|
4430
5860
|
}
|
|
@@ -4432,19 +5862,19 @@ function _check_tier_usage_readiness(project_root) {
|
|
|
4432
5862
|
return {
|
|
4433
5863
|
id: "tier-usage-readiness",
|
|
4434
5864
|
status: "warn",
|
|
4435
|
-
message: `${
|
|
5865
|
+
message: `${path15.basename(log_path)} present but empty \u2014 no signal yet`,
|
|
4436
5866
|
remedy: "run any tracked command to seed the log"
|
|
4437
5867
|
};
|
|
4438
5868
|
}
|
|
4439
5869
|
return {
|
|
4440
5870
|
id: "tier-usage-readiness",
|
|
4441
5871
|
status: "ok",
|
|
4442
|
-
message: `${valid} record(s) past the privacy floor in ${
|
|
5872
|
+
message: `${valid} record(s) past the privacy floor in ${path15.basename(log_path)} \u2014 retiering signal available`,
|
|
4443
5873
|
remedy: ""
|
|
4444
5874
|
};
|
|
4445
5875
|
}
|
|
4446
5876
|
function readText0(p) {
|
|
4447
|
-
return
|
|
5877
|
+
return fs11.readFileSync(p, "utf-8");
|
|
4448
5878
|
}
|
|
4449
5879
|
function osErrorStr(exc) {
|
|
4450
5880
|
if (exc && typeof exc === "object" && "message" in exc) {
|
|
@@ -4617,7 +6047,7 @@ function _epoch_seconds(value) {
|
|
|
4617
6047
|
function _codex_auth_expiry(auth_path) {
|
|
4618
6048
|
let data;
|
|
4619
6049
|
try {
|
|
4620
|
-
data = JSON.parse(
|
|
6050
|
+
data = JSON.parse(fs11.readFileSync(auth_path, "utf-8"));
|
|
4621
6051
|
} catch {
|
|
4622
6052
|
return null;
|
|
4623
6053
|
}
|
|
@@ -4763,7 +6193,7 @@ function _check_team(project_root) {
|
|
|
4763
6193
|
if (binary_missing) {
|
|
4764
6194
|
remedies.push("install the codex CLI: `npm install -g @openai/codex`");
|
|
4765
6195
|
}
|
|
4766
|
-
const auth_path =
|
|
6196
|
+
const auth_path = path15.join(_codex_home(), "auth.json");
|
|
4767
6197
|
const authed = pathExists(auth_path);
|
|
4768
6198
|
let auth_str;
|
|
4769
6199
|
if (!authed) {
|
|
@@ -4851,7 +6281,7 @@ function _check_unsupported_combos(manifest) {
|
|
|
4851
6281
|
};
|
|
4852
6282
|
}
|
|
4853
6283
|
function _wizard_state_path() {
|
|
4854
|
-
return
|
|
6284
|
+
return path15.join(event4u_root(), "state", "wizard-state.json");
|
|
4855
6285
|
}
|
|
4856
6286
|
function _check_wizard_state() {
|
|
4857
6287
|
const state_pth = _wizard_state_path();
|
|
@@ -4931,7 +6361,7 @@ function _check_wizard_state() {
|
|
|
4931
6361
|
};
|
|
4932
6362
|
}
|
|
4933
6363
|
function _check_settings_review_pending() {
|
|
4934
|
-
const delta_pth =
|
|
6364
|
+
const delta_pth = path15.join(event4u_root(), "state", "settings-delta.json");
|
|
4935
6365
|
if (!pathExists(delta_pth)) {
|
|
4936
6366
|
return {
|
|
4937
6367
|
id: "settings-review-pending",
|
|
@@ -4957,7 +6387,7 @@ function _check_settings_review_pending() {
|
|
|
4957
6387
|
}
|
|
4958
6388
|
function _check_memory_merge_union(project_root) {
|
|
4959
6389
|
const remedy = "run: npx tsx src/scripts/sync_gitattributes.ts (or `agent-config refresh --project`)";
|
|
4960
|
-
const target =
|
|
6390
|
+
const target = path15.join(project_root, DEFAULT_GITATTRIBUTES);
|
|
4961
6391
|
if (!pathExists(target)) {
|
|
4962
6392
|
return {
|
|
4963
6393
|
id: "memory-merge-union",
|
|
@@ -5284,13 +6714,15 @@ function _emit_text(project_root, missing, modified, foreign, tag_drift) {
|
|
|
5284
6714
|
}
|
|
5285
6715
|
var PROG = "agent-config doctor";
|
|
5286
6716
|
var USAGE = `usage: ${PROG} [-h] [--project PROJECT] [--json] [--ci] [--check ID]
|
|
5287
|
-
[--trace-root] [--context] [--
|
|
6717
|
+
[--trace-root] [--context] [--anatomy]
|
|
6718
|
+
[--repair ID]
|
|
5288
6719
|
`;
|
|
5289
6720
|
var _STORE_TRUE_FLAGS = {
|
|
5290
6721
|
"--json": "json",
|
|
5291
6722
|
"--ci": "ci",
|
|
5292
6723
|
"--trace-root": "trace_root",
|
|
5293
|
-
"--context": "context"
|
|
6724
|
+
"--context": "context",
|
|
6725
|
+
"--anatomy": "anatomy"
|
|
5294
6726
|
};
|
|
5295
6727
|
var _VALUE_FLAGS = {
|
|
5296
6728
|
"--project": "project",
|
|
@@ -5303,7 +6735,7 @@ function _argError(msg) {
|
|
|
5303
6735
|
`);
|
|
5304
6736
|
throw new ArgparseExit(2);
|
|
5305
6737
|
}
|
|
5306
|
-
function
|
|
6738
|
+
function _parse2(argv) {
|
|
5307
6739
|
const opts = {
|
|
5308
6740
|
project: null,
|
|
5309
6741
|
json: false,
|
|
@@ -5311,6 +6743,7 @@ function _parse(argv) {
|
|
|
5311
6743
|
check: null,
|
|
5312
6744
|
trace_root: false,
|
|
5313
6745
|
context: false,
|
|
6746
|
+
anatomy: false,
|
|
5314
6747
|
repair: null
|
|
5315
6748
|
};
|
|
5316
6749
|
const positionals = [];
|
|
@@ -5427,6 +6860,42 @@ function _run_context(opts) {
|
|
|
5427
6860
|
}
|
|
5428
6861
|
return 0;
|
|
5429
6862
|
}
|
|
6863
|
+
function _run_anatomy(opts) {
|
|
6864
|
+
const census = preamble_byte_census_exports;
|
|
6865
|
+
const economy = dispatch_economy_report_exports;
|
|
6866
|
+
const byteCensus = census.buildReport(census.parseArgs([]));
|
|
6867
|
+
let economyReport = null;
|
|
6868
|
+
let economyError = null;
|
|
6869
|
+
try {
|
|
6870
|
+
economyReport = economy.buildReport({
|
|
6871
|
+
root: economy.DEFAULT_PROJECTS_ROOT,
|
|
6872
|
+
auditDir: path15.join(process2.cwd(), economy.DEFAULT_AUDIT_DIR),
|
|
6873
|
+
maxAgeDays: 14
|
|
6874
|
+
});
|
|
6875
|
+
} catch (err) {
|
|
6876
|
+
economyError = err instanceof Error ? err.message : String(err);
|
|
6877
|
+
}
|
|
6878
|
+
if (opts.json) {
|
|
6879
|
+
print(
|
|
6880
|
+
_jsonDumpsIndentAscii(
|
|
6881
|
+
{
|
|
6882
|
+
preamble_byte_census: byteCensus,
|
|
6883
|
+
dispatch_economy: economyReport,
|
|
6884
|
+
dispatch_economy_unavailable: economyError
|
|
6885
|
+
},
|
|
6886
|
+
2
|
|
6887
|
+
)
|
|
6888
|
+
);
|
|
6889
|
+
return 0;
|
|
6890
|
+
}
|
|
6891
|
+
print("\u2500\u2500 injection anatomy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
6892
|
+
print(census.renderText(byteCensus));
|
|
6893
|
+
print("");
|
|
6894
|
+
print(
|
|
6895
|
+
economyReport !== null ? economy.renderText(economyReport) : `dispatch-economy report unavailable: ${economyError}`
|
|
6896
|
+
);
|
|
6897
|
+
return 0;
|
|
6898
|
+
}
|
|
5430
6899
|
function _run_repair(opts) {
|
|
5431
6900
|
const target = opts.repair;
|
|
5432
6901
|
if (target === "wizard-state") {
|
|
@@ -5439,7 +6908,7 @@ function _run_repair(opts) {
|
|
|
5439
6908
|
};
|
|
5440
6909
|
if (exists2) {
|
|
5441
6910
|
try {
|
|
5442
|
-
|
|
6911
|
+
fs11.unlinkSync(state_pth);
|
|
5443
6912
|
} catch (exc) {
|
|
5444
6913
|
payload["action"] = "error";
|
|
5445
6914
|
payload["error"] = osErrorStr(exc);
|
|
@@ -5465,8 +6934,8 @@ function _run_repair(opts) {
|
|
|
5465
6934
|
eprint(`\u274C doctor: unknown repair target ${pyRepr(target)}`);
|
|
5466
6935
|
return 2;
|
|
5467
6936
|
}
|
|
5468
|
-
function
|
|
5469
|
-
const opts =
|
|
6937
|
+
function main4(argv = null) {
|
|
6938
|
+
const opts = _parse2(argv !== null ? Array.from(argv) : process2.argv.slice(2));
|
|
5470
6939
|
if (opts.ci) {
|
|
5471
6940
|
opts.json = true;
|
|
5472
6941
|
}
|
|
@@ -5479,6 +6948,9 @@ function main(argv = null) {
|
|
|
5479
6948
|
if (opts.context) {
|
|
5480
6949
|
return _run_context(opts);
|
|
5481
6950
|
}
|
|
6951
|
+
if (opts.anatomy) {
|
|
6952
|
+
return _run_anatomy(opts);
|
|
6953
|
+
}
|
|
5482
6954
|
let project_root;
|
|
5483
6955
|
let origin;
|
|
5484
6956
|
try {
|
|
@@ -5530,25 +7002,25 @@ function main(argv = null) {
|
|
|
5530
7002
|
}
|
|
5531
7003
|
return drift_present ? 1 : 0;
|
|
5532
7004
|
}
|
|
5533
|
-
function
|
|
7005
|
+
function _isCliEntry2() {
|
|
5534
7006
|
if (process2.argv[1] === void 0) {
|
|
5535
7007
|
return false;
|
|
5536
7008
|
}
|
|
5537
|
-
const argvUrl =
|
|
7009
|
+
const argvUrl = pathToFileURL4(path15.resolve(process2.argv[1])).href;
|
|
5538
7010
|
if (import.meta.url === argvUrl) {
|
|
5539
7011
|
return true;
|
|
5540
7012
|
}
|
|
5541
7013
|
try {
|
|
5542
|
-
const here =
|
|
5543
|
-
const argv =
|
|
7014
|
+
const here = fs11.realpathSync(fileURLToPath6(import.meta.url));
|
|
7015
|
+
const argv = fs11.realpathSync(path15.resolve(process2.argv[1]));
|
|
5544
7016
|
return here === argv;
|
|
5545
7017
|
} catch {
|
|
5546
7018
|
return false;
|
|
5547
7019
|
}
|
|
5548
7020
|
}
|
|
5549
|
-
if (
|
|
7021
|
+
if (_isCliEntry2() || process2.argv[1] === _HERE6) {
|
|
5550
7022
|
try {
|
|
5551
|
-
process2.exitCode =
|
|
7023
|
+
process2.exitCode = main4(process2.argv.slice(2));
|
|
5552
7024
|
} catch (e) {
|
|
5553
7025
|
if (e instanceof ArgparseExit) {
|
|
5554
7026
|
process2.exitCode = e.code;
|
|
@@ -5559,6 +7031,11 @@ if (_isCliEntry() || process2.argv[1] === _HERE2) {
|
|
|
5559
7031
|
}
|
|
5560
7032
|
|
|
5561
7033
|
export {
|
|
7034
|
+
comparePair,
|
|
7035
|
+
splitFrontmatter,
|
|
7036
|
+
proseEqual,
|
|
7037
|
+
frontmatterPaths,
|
|
7038
|
+
censusRuleDir,
|
|
5562
7039
|
ArgparseExit,
|
|
5563
7040
|
_jsonDumpsIndentAscii,
|
|
5564
7041
|
NO_FRONTMATTER,
|
|
@@ -5619,9 +7096,9 @@ export {
|
|
|
5619
7096
|
_emit_json,
|
|
5620
7097
|
_emit_checks_text,
|
|
5621
7098
|
_emit_text,
|
|
5622
|
-
_parse,
|
|
7099
|
+
_parse2 as _parse,
|
|
5623
7100
|
_run_trace_root,
|
|
5624
7101
|
_run_context,
|
|
5625
7102
|
_run_repair,
|
|
5626
|
-
main
|
|
7103
|
+
main4 as main
|
|
5627
7104
|
};
|