cue-ai 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cue.js +1090 -492
- package/package.json +1 -1
- package/src/commands/_index.ts +4 -0
- package/src/commands/community-eval.test.ts +99 -0
- package/src/commands/community-eval.ts +155 -0
- package/src/lib/community-eval/result.test.ts +27 -0
- package/src/lib/community-eval/result.ts +80 -0
- package/src/lib/community-eval/runner.test.ts +133 -0
- package/src/lib/community-eval/runner.ts +309 -0
- package/web/README.md +2 -2
package/dist/cue.js
CHANGED
|
@@ -60283,14 +60283,604 @@ var init_benchmark = __esm(() => {
|
|
|
60283
60283
|
import_yaml18 = __toESM(require_dist(), 1);
|
|
60284
60284
|
});
|
|
60285
60285
|
|
|
60286
|
+
// src/lib/community-eval/result.ts
|
|
60287
|
+
function invalid() {
|
|
60288
|
+
throw new Error("BENCHMARK_INVALID_REPORT");
|
|
60289
|
+
}
|
|
60290
|
+
function exactRecord(value, keys) {
|
|
60291
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).length !== keys.length || !keys.every((key2) => Object.hasOwn(value, key2)))
|
|
60292
|
+
invalid();
|
|
60293
|
+
return value;
|
|
60294
|
+
}
|
|
60295
|
+
function integer(value, min, max) {
|
|
60296
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= min && value <= max ? value : invalid();
|
|
60297
|
+
}
|
|
60298
|
+
function version(value) {
|
|
60299
|
+
return typeof value === "string" && /^\d{1,4}\.\d{1,4}\.\d{1,4}$/.test(value) ? value : invalid();
|
|
60300
|
+
}
|
|
60301
|
+
function isCommunityModel(value) {
|
|
60302
|
+
return COMMUNITY_MODELS.some((model) => model === value);
|
|
60303
|
+
}
|
|
60304
|
+
function parseArm(value, available) {
|
|
60305
|
+
const arm = exactRecord(value, ["score", "durationMs", "inputTokens", "cachedInputTokens", "outputTokens", "codegraphUsed"]);
|
|
60306
|
+
const { inputTokens: input, cachedInputTokens: cached, outputTokens: output, codegraphUsed } = arm;
|
|
60307
|
+
if (typeof codegraphUsed !== "boolean" || !available && codegraphUsed)
|
|
60308
|
+
invalid();
|
|
60309
|
+
const missing = input === null && cached === null && output === null;
|
|
60310
|
+
const inputTokens = missing ? null : integer(input, 0, 1e7);
|
|
60311
|
+
return {
|
|
60312
|
+
score: integer(arm.score, 0, COMMUNITY_SCORE_MAX),
|
|
60313
|
+
durationMs: integer(arm.durationMs, 1, 300000),
|
|
60314
|
+
inputTokens,
|
|
60315
|
+
cachedInputTokens: missing ? null : integer(cached, 0, inputTokens),
|
|
60316
|
+
outputTokens: missing ? null : integer(output, 0, 1e7),
|
|
60317
|
+
codegraphUsed
|
|
60318
|
+
};
|
|
60319
|
+
}
|
|
60320
|
+
function parseCommunityReport(value) {
|
|
60321
|
+
const report = exactRecord(value, ["version", "benchmark", "model", "codexVersion", "codegraphVersion", "pairs"]);
|
|
60322
|
+
if (report.version !== 1 || report.benchmark !== COMMUNITY_BENCHMARK || !isCommunityModel(report.model) || !Array.isArray(report.pairs) || report.pairs.length !== COMMUNITY_PAIR_COUNT)
|
|
60323
|
+
invalid();
|
|
60324
|
+
return {
|
|
60325
|
+
version: 1,
|
|
60326
|
+
benchmark: COMMUNITY_BENCHMARK,
|
|
60327
|
+
model: report.model,
|
|
60328
|
+
codexVersion: version(report.codexVersion),
|
|
60329
|
+
codegraphVersion: version(report.codegraphVersion),
|
|
60330
|
+
pairs: Array.from(report.pairs, (value2) => {
|
|
60331
|
+
const pair = exactRecord(value2, ["off", "on"]);
|
|
60332
|
+
return { off: parseArm(pair.off, false), on: parseArm(pair.on, true) };
|
|
60333
|
+
})
|
|
60334
|
+
};
|
|
60335
|
+
}
|
|
60336
|
+
var COMMUNITY_MODELS, COMMUNITY_BENCHMARK = "codegraph-v1", COMMUNITY_REPORT_BYTES = 4096, COMMUNITY_PAIR_COUNT = 2, COMMUNITY_SCORE_MAX = 3;
|
|
60337
|
+
var init_result = __esm(() => {
|
|
60338
|
+
COMMUNITY_MODELS = ["gpt-5.4", "gpt-5.6-sol"];
|
|
60339
|
+
});
|
|
60340
|
+
|
|
60341
|
+
// src/lib/community-eval/runner.ts
|
|
60342
|
+
var exports_runner = {};
|
|
60343
|
+
__export(exports_runner, {
|
|
60344
|
+
runCommunityEval: () => runCommunityEval
|
|
60345
|
+
});
|
|
60346
|
+
import { spawnSync as spawnSync33 } from "node:child_process";
|
|
60347
|
+
import { existsSync as existsSync109, mkdirSync as mkdirSync47, mkdtempSync as mkdtempSync7, realpathSync as realpathSync5, rmSync as rmSync14, symlinkSync, writeFileSync as writeFileSync54 } from "node:fs";
|
|
60348
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
60349
|
+
import { dirname as dirname46, join as join149, resolve as resolve34 } from "node:path";
|
|
60350
|
+
function fail(code) {
|
|
60351
|
+
throw new Error(`BENCHMARK_${code}`);
|
|
60352
|
+
}
|
|
60353
|
+
function locateTools() {
|
|
60354
|
+
const codexPath = findRealAgentBin("codex");
|
|
60355
|
+
if (!codexPath)
|
|
60356
|
+
return fail("CODEX_NOT_INSTALLED");
|
|
60357
|
+
const codegraphPath = findRealAgentBin("codegraph");
|
|
60358
|
+
if (!codegraphPath)
|
|
60359
|
+
return fail("CODEGRAPH_NOT_INSTALLED");
|
|
60360
|
+
const architecture = process.arch;
|
|
60361
|
+
if (architecture !== "x64" && architecture !== "arm64")
|
|
60362
|
+
return fail("UNSUPPORTED_PLATFORM");
|
|
60363
|
+
let codex2 = realpathSync5(codexPath);
|
|
60364
|
+
try {
|
|
60365
|
+
const pkg = createRequire2(codex2).resolve(`@openai/codex-linux-${architecture}/package.json`);
|
|
60366
|
+
const triple = architecture === "x64" ? "x86_64" : "aarch64";
|
|
60367
|
+
codex2 = realpathSync5(join149(dirname46(pkg), "vendor", `${triple}-unknown-linux-musl`, "bin", "codex"));
|
|
60368
|
+
} catch {}
|
|
60369
|
+
let codegraph = realpathSync5(codegraphPath);
|
|
60370
|
+
try {
|
|
60371
|
+
codegraph = realpathSync5(createRequire2(codegraph).resolve(`@colbymchenry/codegraph-linux-${architecture}/bin/codegraph`));
|
|
60372
|
+
} catch {}
|
|
60373
|
+
const codegraphRoot = dirname46(dirname46(codegraph));
|
|
60374
|
+
if (!existsSync109(join149(codegraphRoot, "node")) || !existsSync109(join149(codegraphRoot, "lib", "dist", "bin", "codegraph.js"))) {
|
|
60375
|
+
return fail("CODEGRAPH_BUNDLE_REQUIRED");
|
|
60376
|
+
}
|
|
60377
|
+
return { codex: codex2, codegraph, codegraphRoot };
|
|
60378
|
+
}
|
|
60379
|
+
function writeFixture(where) {
|
|
60380
|
+
for (const [file, content] of Object.entries(FIXTURE)) {
|
|
60381
|
+
const path = join149(where, file);
|
|
60382
|
+
mkdirSync47(dirname46(path), { recursive: true });
|
|
60383
|
+
writeFileSync54(path, `${content}
|
|
60384
|
+
`);
|
|
60385
|
+
}
|
|
60386
|
+
}
|
|
60387
|
+
function permissions(roots) {
|
|
60388
|
+
const rootEntries = Object.entries({ ":minimal": "read", ...roots }).map(([path, mode]) => `${JSON.stringify(path)}=${JSON.stringify(mode)}`);
|
|
60389
|
+
return [
|
|
60390
|
+
"-c",
|
|
60391
|
+
`permissions.${PROFILE}.filesystem={${rootEntries.join(",")}}`,
|
|
60392
|
+
"-c",
|
|
60393
|
+
`permissions.${PROFILE}.network.enabled=false`
|
|
60394
|
+
];
|
|
60395
|
+
}
|
|
60396
|
+
function sandboxArgs(cwd, rules, command2) {
|
|
60397
|
+
return ["sandbox", "-C", cwd, "-P", PROFILE, ...rules, "--", ...command2];
|
|
60398
|
+
}
|
|
60399
|
+
function readTokens(usage5) {
|
|
60400
|
+
const tokens = (key2) => {
|
|
60401
|
+
const value = usage5?.[key2];
|
|
60402
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && value <= 1e7 ? value : null;
|
|
60403
|
+
};
|
|
60404
|
+
const inputTokens = tokens("input_tokens");
|
|
60405
|
+
const cachedInputTokens = tokens("cached_input_tokens");
|
|
60406
|
+
const outputTokens = tokens("output_tokens");
|
|
60407
|
+
return inputTokens !== null && cachedInputTokens !== null && outputTokens !== null && cachedInputTokens <= inputTokens ? { inputTokens, cachedInputTokens, outputTokens } : { inputTokens: null, cachedInputTokens: null, outputTokens: null };
|
|
60408
|
+
}
|
|
60409
|
+
function record2(value) {
|
|
60410
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
60411
|
+
}
|
|
60412
|
+
function grade2(message) {
|
|
60413
|
+
try {
|
|
60414
|
+
const answers = message ? record2(JSON.parse(message)) : undefined;
|
|
60415
|
+
return ANSWER_KEYS.filter((key2) => {
|
|
60416
|
+
const answer = answers?.[key2];
|
|
60417
|
+
return typeof answer === "string" && answer.trim() === ANSWERS[key2];
|
|
60418
|
+
}).length;
|
|
60419
|
+
} catch {
|
|
60420
|
+
return 0;
|
|
60421
|
+
}
|
|
60422
|
+
}
|
|
60423
|
+
function readArm(stdout2, durationMs, on) {
|
|
60424
|
+
let lastMessage;
|
|
60425
|
+
let completed = false;
|
|
60426
|
+
let codegraphUsed = false;
|
|
60427
|
+
let usage5;
|
|
60428
|
+
try {
|
|
60429
|
+
for (const line of stdout2.trim().split(`
|
|
60430
|
+
`)) {
|
|
60431
|
+
const event = record2(JSON.parse(line));
|
|
60432
|
+
if (!event || event.type === "turn.failed")
|
|
60433
|
+
return fail("CODEX_FAILED");
|
|
60434
|
+
if (event.type === "turn.completed") {
|
|
60435
|
+
if (completed)
|
|
60436
|
+
return fail("CODEX_FAILED");
|
|
60437
|
+
completed = true;
|
|
60438
|
+
usage5 = record2(event.usage);
|
|
60439
|
+
}
|
|
60440
|
+
if (event.type !== "item.completed")
|
|
60441
|
+
continue;
|
|
60442
|
+
const item = record2(event.item);
|
|
60443
|
+
if (item?.type === "agent_message" && typeof item.text === "string")
|
|
60444
|
+
lastMessage = item.text;
|
|
60445
|
+
if (item?.type === "mcp_tool_call") {
|
|
60446
|
+
if (!on || item.server !== "codegraph" || item.tool !== TOOL)
|
|
60447
|
+
return fail("CODEX_FAILED");
|
|
60448
|
+
if (item.status === "completed" && !item.error)
|
|
60449
|
+
codegraphUsed = true;
|
|
60450
|
+
}
|
|
60451
|
+
}
|
|
60452
|
+
if (!completed)
|
|
60453
|
+
return fail("CODEX_FAILED");
|
|
60454
|
+
return { score: grade2(lastMessage), durationMs, ...readTokens(usage5), codegraphUsed };
|
|
60455
|
+
} catch {
|
|
60456
|
+
return fail("CODEX_FAILED");
|
|
60457
|
+
}
|
|
60458
|
+
}
|
|
60459
|
+
async function runCommunityEval(model, options = {}) {
|
|
60460
|
+
if (!isCommunityModel(model))
|
|
60461
|
+
return fail("UNSUPPORTED_MODEL");
|
|
60462
|
+
if ((options.platform ?? process.platform) !== "linux")
|
|
60463
|
+
return fail("UNSUPPORTED_PLATFORM");
|
|
60464
|
+
const hasSystemConfig = options.hasSystemConfig ?? (() => SYSTEM_CONFIGS.some((file) => existsSync109(join149("/etc/codex", file))));
|
|
60465
|
+
if (hasSystemConfig())
|
|
60466
|
+
return fail("SYSTEM_CONFIG_UNSUPPORTED");
|
|
60467
|
+
const tools = options.tools ?? locateTools();
|
|
60468
|
+
const { command: command2 = runCommand, now = () => performance.now() } = options;
|
|
60469
|
+
const { codex: codex2, codegraph, codegraphRoot } = tools;
|
|
60470
|
+
const scratch = realpathSync5(mkdtempSync7("/tmp/cue-benchmark-"));
|
|
60471
|
+
try {
|
|
60472
|
+
const fixture = join149(scratch, "fixture");
|
|
60473
|
+
const index = join149(scratch, "index");
|
|
60474
|
+
const sandboxHome = join149(scratch, "home");
|
|
60475
|
+
const clientHome = join149(scratch, "client");
|
|
60476
|
+
const schema = join149(scratch, "answer-schema.json");
|
|
60477
|
+
const authHome = resolve34(options.authHome ?? canonicalCodexHome());
|
|
60478
|
+
mkdirSync47(sandboxHome);
|
|
60479
|
+
mkdirSync47(clientHome);
|
|
60480
|
+
writeFixture(fixture);
|
|
60481
|
+
writeFixture(index);
|
|
60482
|
+
writeFileSync54(schema, JSON.stringify({
|
|
60483
|
+
type: "object",
|
|
60484
|
+
properties: Object.fromEntries(ANSWER_KEYS.map((key2) => [key2, { type: "string" }])),
|
|
60485
|
+
required: ANSWER_KEYS,
|
|
60486
|
+
additionalProperties: false
|
|
60487
|
+
}));
|
|
60488
|
+
const sandboxEnv = {
|
|
60489
|
+
PATH: SYSTEM_PATH,
|
|
60490
|
+
HOME: sandboxHome,
|
|
60491
|
+
CODEX_HOME: sandboxHome,
|
|
60492
|
+
LANG: "C.UTF-8",
|
|
60493
|
+
CODEGRAPH_TELEMETRY: "0",
|
|
60494
|
+
CODEGRAPH_NO_DOWNLOAD: "1"
|
|
60495
|
+
};
|
|
60496
|
+
const isolated = { cwd: fixture, env: sandboxEnv };
|
|
60497
|
+
const client = { cwd: fixture, env: { PATH: SYSTEM_PATH, HOME: sandboxHome, CODEX_HOME: clientHome, LANG: "C.UTF-8" } };
|
|
60498
|
+
const codexVersion = command2(codex2, ["--version"], isolated);
|
|
60499
|
+
if (!codexVersion.ok || codexVersion.stdout.trim() !== `codex-cli ${CODEX_VERSION}`)
|
|
60500
|
+
return fail("UNSUPPORTED_CODEX");
|
|
60501
|
+
const graphVersion = command2(codegraph, ["--version"], isolated);
|
|
60502
|
+
const codegraphVersion = /^(?:codegraph )?(\d{1,4}\.\d{1,4}\.\d{1,4})$/.exec(graphVersion.stdout.trim())?.[1];
|
|
60503
|
+
if (!graphVersion.ok || !codegraphVersion)
|
|
60504
|
+
return fail("UNSUPPORTED_CODEGRAPH");
|
|
60505
|
+
const shellRules = permissions({ [codex2]: "read", [fixture]: "read" });
|
|
60506
|
+
const probe = [
|
|
60507
|
+
"/bin/sh",
|
|
60508
|
+
"-c",
|
|
60509
|
+
'test -r src/http/quotes.ts && ! test -r "$1" && ! test -r "$2" && ! test -r "$3"',
|
|
60510
|
+
"cue-probe",
|
|
60511
|
+
join149(index, "src/http/quotes.ts"),
|
|
60512
|
+
authHome,
|
|
60513
|
+
process.cwd()
|
|
60514
|
+
];
|
|
60515
|
+
if (!command2(codex2, sandboxArgs(fixture, shellRules, probe), isolated).ok)
|
|
60516
|
+
return fail("SANDBOX_UNAVAILABLE");
|
|
60517
|
+
const initRules = permissions({ [codex2]: "read", [codegraphRoot]: "read", [index]: "write" });
|
|
60518
|
+
const init = [codegraph, "init", "--yes", index];
|
|
60519
|
+
if (!command2(codex2, sandboxArgs(index, initRules, init), isolated).ok)
|
|
60520
|
+
return fail("INDEX_FAILED");
|
|
60521
|
+
symlinkSync(join149(authHome, "auth.json"), join149(clientHome, "auth.json"));
|
|
60522
|
+
const auth = ["-c", 'cli_auth_credentials_store="file"'];
|
|
60523
|
+
const status2 = command2(codex2, ["login", "status", ...auth], client);
|
|
60524
|
+
if (!status2.ok || !/^Logged in using ChatGPT\s*$/m.test(status2.stderr))
|
|
60525
|
+
return fail("CHATGPT_LOGIN_REQUIRED");
|
|
60526
|
+
const serveRules = permissions({
|
|
60527
|
+
[codex2]: "read",
|
|
60528
|
+
[codegraphRoot]: "read",
|
|
60529
|
+
[index]: "read",
|
|
60530
|
+
[join149(index, ".codegraph")]: "write"
|
|
60531
|
+
});
|
|
60532
|
+
const serve = sandboxArgs(index, serveRules, [codegraph, "serve", "--mcp", "--path", index, "--no-watch"]);
|
|
60533
|
+
const mcp = [
|
|
60534
|
+
`command=${JSON.stringify(codex2)}`,
|
|
60535
|
+
`args=${JSON.stringify(serve)}`,
|
|
60536
|
+
`cwd=${JSON.stringify(index)}`,
|
|
60537
|
+
`env={${Object.entries(sandboxEnv).map(([name, value]) => `${name}=${JSON.stringify(value)}`).join(",")}}`,
|
|
60538
|
+
`enabled_tools=["${TOOL}"]`,
|
|
60539
|
+
"required=true"
|
|
60540
|
+
].join(",");
|
|
60541
|
+
const commonArgs = [
|
|
60542
|
+
"exec",
|
|
60543
|
+
"--ignore-user-config",
|
|
60544
|
+
"--ignore-rules",
|
|
60545
|
+
"--ephemeral",
|
|
60546
|
+
"--skip-git-repo-check",
|
|
60547
|
+
"--json",
|
|
60548
|
+
"--model",
|
|
60549
|
+
model,
|
|
60550
|
+
"--output-schema",
|
|
60551
|
+
schema,
|
|
60552
|
+
"-C",
|
|
60553
|
+
fixture,
|
|
60554
|
+
...auth,
|
|
60555
|
+
"-c",
|
|
60556
|
+
'model_provider="openai"',
|
|
60557
|
+
"-c",
|
|
60558
|
+
'model_reasoning_effort="low"',
|
|
60559
|
+
"-c",
|
|
60560
|
+
`default_permissions="${PROFILE}"`,
|
|
60561
|
+
...shellRules,
|
|
60562
|
+
"-c",
|
|
60563
|
+
'approval_policy="never"',
|
|
60564
|
+
"-c",
|
|
60565
|
+
"allow_login_shell=false",
|
|
60566
|
+
"-c",
|
|
60567
|
+
'shell_environment_policy.inherit="none"',
|
|
60568
|
+
"-c",
|
|
60569
|
+
"project_doc_max_bytes=0",
|
|
60570
|
+
"-c",
|
|
60571
|
+
"features.hooks=false",
|
|
60572
|
+
"-c",
|
|
60573
|
+
"features.plugins=false",
|
|
60574
|
+
"-c",
|
|
60575
|
+
"features.apps=false",
|
|
60576
|
+
"-c",
|
|
60577
|
+
"features.multi_agent_v2=false",
|
|
60578
|
+
"-c",
|
|
60579
|
+
'web_search="disabled"',
|
|
60580
|
+
"-c",
|
|
60581
|
+
"features.memories=false",
|
|
60582
|
+
"-c",
|
|
60583
|
+
"features.shell_snapshot=false",
|
|
60584
|
+
"-c",
|
|
60585
|
+
"features.shell_snapshot_v2=false",
|
|
60586
|
+
"-c",
|
|
60587
|
+
"analytics.enabled=false",
|
|
60588
|
+
"-c",
|
|
60589
|
+
`log_dir=${JSON.stringify(sandboxHome)}`
|
|
60590
|
+
];
|
|
60591
|
+
const runArm = (on) => {
|
|
60592
|
+
const start = now();
|
|
60593
|
+
const output = command2(codex2, [
|
|
60594
|
+
...commonArgs,
|
|
60595
|
+
"-c",
|
|
60596
|
+
on ? `mcp_servers={codegraph={${mcp}}}` : "mcp_servers={}",
|
|
60597
|
+
"--",
|
|
60598
|
+
PROMPT
|
|
60599
|
+
], client);
|
|
60600
|
+
if (!output.ok)
|
|
60601
|
+
return fail("CODEX_FAILED");
|
|
60602
|
+
return readArm(output.stdout, Math.max(1, Math.round(now() - start)), on);
|
|
60603
|
+
};
|
|
60604
|
+
const offFirst = runArm(false);
|
|
60605
|
+
const onSecond = runArm(true);
|
|
60606
|
+
const onFirst = runArm(true);
|
|
60607
|
+
const offSecond = runArm(false);
|
|
60608
|
+
return parseCommunityReport({
|
|
60609
|
+
version: 1,
|
|
60610
|
+
benchmark: COMMUNITY_BENCHMARK,
|
|
60611
|
+
model,
|
|
60612
|
+
codexVersion: CODEX_VERSION,
|
|
60613
|
+
codegraphVersion,
|
|
60614
|
+
pairs: [{ off: offFirst, on: onSecond }, { off: offSecond, on: onFirst }]
|
|
60615
|
+
});
|
|
60616
|
+
} finally {
|
|
60617
|
+
rmSync14(scratch, { recursive: true, force: true });
|
|
60618
|
+
}
|
|
60619
|
+
}
|
|
60620
|
+
var CODEX_VERSION = "0.172.0", PROFILE = "cue-benchmark", TIMEOUT_MS = 120000, SYSTEM_PATH = "/usr/local/bin:/usr/bin:/bin", TOOL = "codegraph_explore", SYSTEM_CONFIGS, FIXTURE, QUESTIONS, ANSWERS, ANSWER_KEYS, PROMPT, runCommand = (bin, args, { cwd, env, stdin: stdin2 }) => {
|
|
60621
|
+
const result = spawnSync33(bin, args, {
|
|
60622
|
+
cwd,
|
|
60623
|
+
env,
|
|
60624
|
+
input: stdin2,
|
|
60625
|
+
encoding: "utf8",
|
|
60626
|
+
timeout: TIMEOUT_MS,
|
|
60627
|
+
maxBuffer: 2 * 1024 * 1024,
|
|
60628
|
+
killSignal: "SIGKILL",
|
|
60629
|
+
stdio: [stdin2 === undefined ? "ignore" : "pipe", "pipe", "pipe"]
|
|
60630
|
+
});
|
|
60631
|
+
return { ok: result.status === 0, stdout: result.stdout ?? "", stderr: result.stderr ?? "" };
|
|
60632
|
+
};
|
|
60633
|
+
var init_runner = __esm(() => {
|
|
60634
|
+
init_claude_binary();
|
|
60635
|
+
init_codex_config();
|
|
60636
|
+
init_result();
|
|
60637
|
+
SYSTEM_CONFIGS = ["config.toml", "requirements.toml", "managed_config.toml"];
|
|
60638
|
+
FIXTURE = {
|
|
60639
|
+
"src/http/quotes.ts": `import { normalizeQuoteInput } from "./quote-input";
|
|
60640
|
+
import { createQuote } from "../pricing/quote";
|
|
60641
|
+
export function handleQuote(body: unknown) {
|
|
60642
|
+
return createQuote(normalizeQuoteInput(body));
|
|
60643
|
+
}`,
|
|
60644
|
+
"src/http/quote-input.ts": `export function normalizeQuoteInput(body: unknown) {
|
|
60645
|
+
if (!body || typeof body !== "object" || !("subtotal" in body) || !("month" in body))
|
|
60646
|
+
throw new Error("Invalid quote");
|
|
60647
|
+
const { subtotal, month } = body;
|
|
60648
|
+
if (typeof subtotal !== "number" || typeof month !== "number") throw new Error("Invalid quote");
|
|
60649
|
+
return { subtotal, month };
|
|
60650
|
+
}`,
|
|
60651
|
+
"src/pricing/quote.ts": `import { seasonalCredit } from "./campaign";
|
|
60652
|
+
import { standardFee } from "./fees";
|
|
60653
|
+
export function createQuote({ subtotal, month }: { subtotal: number; month: number }) {
|
|
60654
|
+
return { total: subtotal + standardFee(subtotal) - seasonalCredit(subtotal, month) };
|
|
60655
|
+
}`,
|
|
60656
|
+
"src/pricing/campaign.ts": `export function seasonalCredit(subtotal: number, month: number) {
|
|
60657
|
+
return month === 7 ? subtotal * 0.1 : 0;
|
|
60658
|
+
}`,
|
|
60659
|
+
"src/pricing/fees.ts": `export function standardFee(subtotal: number) {
|
|
60660
|
+
return subtotal < 30 ? 4 : 0;
|
|
60661
|
+
}`
|
|
60662
|
+
};
|
|
60663
|
+
QUESTIONS = [
|
|
60664
|
+
"entry: Which repository-relative file defines createQuote, the pricing function used by handleQuote?",
|
|
60665
|
+
"rule: What is the exact function name that calculates the seasonal credit used by createQuote?",
|
|
60666
|
+
"boundary: Which repository-relative file defines the function that validates the unknown request body before pricing?"
|
|
60667
|
+
];
|
|
60668
|
+
ANSWERS = {
|
|
60669
|
+
entry: "src/pricing/quote.ts",
|
|
60670
|
+
rule: "seasonalCredit",
|
|
60671
|
+
boundary: "src/http/quote-input.ts"
|
|
60672
|
+
};
|
|
60673
|
+
ANSWER_KEYS = Object.keys(ANSWERS);
|
|
60674
|
+
PROMPT = [
|
|
60675
|
+
"Answer these questions about this small TypeScript repository. Inspect the repository with the available tools.",
|
|
60676
|
+
...QUESTIONS,
|
|
60677
|
+
"Return just the JSON object with the three requested strings. Use bare repository-relative paths."
|
|
60678
|
+
].join(`
|
|
60679
|
+
`);
|
|
60680
|
+
});
|
|
60681
|
+
|
|
60682
|
+
// src/commands/community-eval.ts
|
|
60683
|
+
var exports_community_eval = {};
|
|
60684
|
+
__export(exports_community_eval, {
|
|
60685
|
+
run: () => run77
|
|
60686
|
+
});
|
|
60687
|
+
import { closeSync as closeSync4, constants as constants5, fstatSync as fstatSync3, lstatSync as lstatSync6, openSync as openSync4, readSync as readSync4, unlinkSync as unlinkSync6, writeFileSync as writeFileSync55 } from "node:fs";
|
|
60688
|
+
function readReport(path) {
|
|
60689
|
+
const fd = openSync4(path, constants5.O_RDONLY | constants5.O_NONBLOCK);
|
|
60690
|
+
try {
|
|
60691
|
+
const file = fstatSync3(fd);
|
|
60692
|
+
if (!file.isFile() || file.size > COMMUNITY_REPORT_BYTES)
|
|
60693
|
+
throw new Error("Invalid report file");
|
|
60694
|
+
const data = Buffer.alloc(COMMUNITY_REPORT_BYTES + 1);
|
|
60695
|
+
const size = readSync4(fd, data, 0, data.length, 0);
|
|
60696
|
+
if (size > COMMUNITY_REPORT_BYTES)
|
|
60697
|
+
throw new Error("Report file is too large");
|
|
60698
|
+
return parseCommunityReport(JSON.parse(data.toString("utf8", 0, size)));
|
|
60699
|
+
} finally {
|
|
60700
|
+
closeSync4(fd);
|
|
60701
|
+
}
|
|
60702
|
+
}
|
|
60703
|
+
async function measure(args, io) {
|
|
60704
|
+
let model;
|
|
60705
|
+
let out;
|
|
60706
|
+
let yes = false;
|
|
60707
|
+
for (let i = 0;i < args.length; i++) {
|
|
60708
|
+
const arg = args[i];
|
|
60709
|
+
if (arg === "--yes" && !yes)
|
|
60710
|
+
yes = true;
|
|
60711
|
+
else if (arg === "--model" && model === undefined && args[i + 1] && !args[i + 1]?.startsWith("-"))
|
|
60712
|
+
model = args[++i];
|
|
60713
|
+
else if (arg === "--out" && out === undefined && args[i + 1] && !args[i + 1]?.startsWith("-"))
|
|
60714
|
+
out = args[++i];
|
|
60715
|
+
else {
|
|
60716
|
+
io.stderr(usage5);
|
|
60717
|
+
return 2;
|
|
60718
|
+
}
|
|
60719
|
+
}
|
|
60720
|
+
if (!isCommunityModel(model)) {
|
|
60721
|
+
io.stderr(usage5);
|
|
60722
|
+
return 2;
|
|
60723
|
+
}
|
|
60724
|
+
out ??= "cue-codegraph-v1.json";
|
|
60725
|
+
io.stdout(`Plan: ${COMMUNITY_PAIR_COUNT * 2} Codex runs with ${model} using your Codex login. Runs make model requests and may consume subscription quota. Synthetic code only; no Cuecards upload.
|
|
60726
|
+
`);
|
|
60727
|
+
if (!yes) {
|
|
60728
|
+
io.stdout(`Re-run with --yes to start.
|
|
60729
|
+
`);
|
|
60730
|
+
return 0;
|
|
60731
|
+
}
|
|
60732
|
+
let fd;
|
|
60733
|
+
try {
|
|
60734
|
+
fd = openSync4(out, "wx", 384);
|
|
60735
|
+
} catch {
|
|
60736
|
+
io.stderr(`BENCHMARK_OUTPUT_UNAVAILABLE: choose a writable, unused --out path.
|
|
60737
|
+
`);
|
|
60738
|
+
return 1;
|
|
60739
|
+
}
|
|
60740
|
+
let report;
|
|
60741
|
+
let saved = false;
|
|
60742
|
+
try {
|
|
60743
|
+
try {
|
|
60744
|
+
report = parseCommunityReport(await io.measure(model));
|
|
60745
|
+
if (report.model !== model)
|
|
60746
|
+
throw new Error("Model mismatch");
|
|
60747
|
+
} catch (error) {
|
|
60748
|
+
const code = error instanceof Error && /^BENCHMARK_[A-Z_]{1,40}$/.test(error.message) ? error.message : "BENCHMARK_RUN_FAILED";
|
|
60749
|
+
io.stderr(`${code}: no report saved. Check your Codex login, supported Codex and CodeGraph versions, and sandbox availability.
|
|
60750
|
+
`);
|
|
60751
|
+
return 1;
|
|
60752
|
+
}
|
|
60753
|
+
try {
|
|
60754
|
+
writeFileSync55(fd, JSON.stringify(report, null, 2) + `
|
|
60755
|
+
`);
|
|
60756
|
+
saved = true;
|
|
60757
|
+
} catch {
|
|
60758
|
+
io.stderr(`BENCHMARK_SAVE_FAILED: check the output filesystem.
|
|
60759
|
+
`);
|
|
60760
|
+
return 1;
|
|
60761
|
+
}
|
|
60762
|
+
} finally {
|
|
60763
|
+
try {
|
|
60764
|
+
if (!saved) {
|
|
60765
|
+
const reserved = fstatSync3(fd);
|
|
60766
|
+
const current = lstatSync6(out, { throwIfNoEntry: false });
|
|
60767
|
+
if (current?.ino === reserved.ino && current.dev === reserved.dev)
|
|
60768
|
+
unlinkSync6(out);
|
|
60769
|
+
}
|
|
60770
|
+
} catch {} finally {
|
|
60771
|
+
closeSync4(fd);
|
|
60772
|
+
}
|
|
60773
|
+
}
|
|
60774
|
+
io.stdout(`Saved local report: ${out}
|
|
60775
|
+
Preview optional contribution with cue community-eval submit <report.json>.
|
|
60776
|
+
`);
|
|
60777
|
+
const maxScore = COMMUNITY_SCORE_MAX * report.pairs.length;
|
|
60778
|
+
const offScore = report.pairs.reduce((total, pair) => total + pair.off.score, 0);
|
|
60779
|
+
const onScore = report.pairs.reduce((total, pair) => total + pair.on.score, 0);
|
|
60780
|
+
io.stdout(`Correct answers: without CodeGraph ${offScore}/${maxScore}, with CodeGraph ${onScore}/${maxScore}
|
|
60781
|
+
`);
|
|
60782
|
+
return 0;
|
|
60783
|
+
}
|
|
60784
|
+
async function submit(args, io) {
|
|
60785
|
+
const [path, confirm2] = args;
|
|
60786
|
+
if (!path || path.startsWith("-") || args.length > 2 || confirm2 !== undefined && confirm2 !== "--yes") {
|
|
60787
|
+
io.stderr(usage5);
|
|
60788
|
+
return 2;
|
|
60789
|
+
}
|
|
60790
|
+
let report;
|
|
60791
|
+
try {
|
|
60792
|
+
report = readReport(path);
|
|
60793
|
+
} catch {
|
|
60794
|
+
io.stderr(`BENCHMARK_INVALID_REPORT: expected one bounded, complete benchmark report.
|
|
60795
|
+
`);
|
|
60796
|
+
return 1;
|
|
60797
|
+
}
|
|
60798
|
+
io.stdout(`Destination: ${endpoint}
|
|
60799
|
+
The server uses your Cuecards account to prevent duplicate submissions. No individual reports are public.
|
|
60800
|
+
${JSON.stringify(report, null, 2)}
|
|
60801
|
+
`);
|
|
60802
|
+
if (confirm2 !== "--yes") {
|
|
60803
|
+
io.stdout(`Nothing sent. Re-run with --yes to submit.
|
|
60804
|
+
`);
|
|
60805
|
+
return 0;
|
|
60806
|
+
}
|
|
60807
|
+
let accepted;
|
|
60808
|
+
try {
|
|
60809
|
+
const credentials = io.credentials();
|
|
60810
|
+
if (!credentials || new URL(credentials.apiUrl).origin !== DEFAULT_API_URL) {
|
|
60811
|
+
io.stderr(`BENCHMARK_LOGIN_REQUIRED: sign in to the official Cuecards service before sharing.
|
|
60812
|
+
`);
|
|
60813
|
+
return 1;
|
|
60814
|
+
}
|
|
60815
|
+
const response = await io.request(endpoint, {
|
|
60816
|
+
method: "POST",
|
|
60817
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${credentials.token}` },
|
|
60818
|
+
body: JSON.stringify(report),
|
|
60819
|
+
redirect: "error",
|
|
60820
|
+
signal: AbortSignal.timeout(15000)
|
|
60821
|
+
});
|
|
60822
|
+
if (!response.ok)
|
|
60823
|
+
throw new Error("Collector rejected report");
|
|
60824
|
+
const result = await response.json();
|
|
60825
|
+
if (result?.ok !== true || typeof result.data?.accepted !== "boolean")
|
|
60826
|
+
throw new Error("Invalid collector response");
|
|
60827
|
+
accepted = result.data.accepted;
|
|
60828
|
+
} catch {
|
|
60829
|
+
io.stderr(`BENCHMARK_SUBMIT_FAILED: contribution was not confirmed; the local report remains.
|
|
60830
|
+
`);
|
|
60831
|
+
return 1;
|
|
60832
|
+
}
|
|
60833
|
+
io.stdout(accepted ? `Contribution accepted.
|
|
60834
|
+
` : `Already contributed; only the first report counts.
|
|
60835
|
+
`);
|
|
60836
|
+
return 0;
|
|
60837
|
+
}
|
|
60838
|
+
async function run77(args, io = defaults) {
|
|
60839
|
+
const [sub, ...rest] = args;
|
|
60840
|
+
if (sub === "run")
|
|
60841
|
+
return measure(rest, io);
|
|
60842
|
+
if (sub === "submit")
|
|
60843
|
+
return submit(rest, io);
|
|
60844
|
+
if (!sub || sub === "--help" || sub === "-h") {
|
|
60845
|
+
io.stdout(usage5);
|
|
60846
|
+
return 0;
|
|
60847
|
+
}
|
|
60848
|
+
io.stderr(usage5);
|
|
60849
|
+
return 2;
|
|
60850
|
+
}
|
|
60851
|
+
var endpoint, usage5, defaults;
|
|
60852
|
+
var init_community_eval = __esm(() => {
|
|
60853
|
+
init_cue_credentials();
|
|
60854
|
+
init_result();
|
|
60855
|
+
endpoint = DEFAULT_API_URL + "/api/v1/benchmarks";
|
|
60856
|
+
usage5 = [
|
|
60857
|
+
"cue community-eval run --model <" + COMMUNITY_MODELS.join("|") + "> [--out report.json] [--yes]",
|
|
60858
|
+
"cue community-eval submit <report.json> [--yes]",
|
|
60859
|
+
"Without --yes, each command previews its action; no models are called and no data is sent."
|
|
60860
|
+
].join(`
|
|
60861
|
+
`) + `
|
|
60862
|
+
`;
|
|
60863
|
+
defaults = {
|
|
60864
|
+
measure: async (model) => (await Promise.resolve().then(() => (init_runner(), exports_runner))).runCommunityEval(model),
|
|
60865
|
+
credentials: loadCredentials,
|
|
60866
|
+
request: (url, init) => fetch(url, init),
|
|
60867
|
+
stdout: (text3) => {
|
|
60868
|
+
process.stdout.write(text3);
|
|
60869
|
+
},
|
|
60870
|
+
stderr: (text3) => {
|
|
60871
|
+
process.stderr.write(text3);
|
|
60872
|
+
}
|
|
60873
|
+
};
|
|
60874
|
+
});
|
|
60875
|
+
|
|
60286
60876
|
// src/commands/brief.ts
|
|
60287
60877
|
var exports_brief = {};
|
|
60288
60878
|
__export(exports_brief, {
|
|
60289
|
-
run: () =>
|
|
60879
|
+
run: () => run78
|
|
60290
60880
|
});
|
|
60291
60881
|
import { mkdir as mkdir9, readFile as readFile22, writeFile as writeFile12 } from "node:fs/promises";
|
|
60292
|
-
import { dirname as
|
|
60293
|
-
async function
|
|
60882
|
+
import { dirname as dirname47, join as join150 } from "node:path";
|
|
60883
|
+
async function run78(args) {
|
|
60294
60884
|
if (args.includes("-h") || args.includes("--help")) {
|
|
60295
60885
|
process.stdout.write(HELP2);
|
|
60296
60886
|
return 0;
|
|
@@ -60326,14 +60916,14 @@ async function run77(args) {
|
|
|
60326
60916
|
return 0;
|
|
60327
60917
|
}
|
|
60328
60918
|
const rendered = renderBrief(brief, { includeNotes: false });
|
|
60329
|
-
const target =
|
|
60919
|
+
const target = join150(cwd, BRIEF_FILE);
|
|
60330
60920
|
let existing = null;
|
|
60331
60921
|
try {
|
|
60332
60922
|
existing = await readFile22(target, "utf8");
|
|
60333
60923
|
} catch {}
|
|
60334
60924
|
const merged = mergeBriefFile(existing, rendered);
|
|
60335
60925
|
try {
|
|
60336
|
-
await mkdir9(
|
|
60926
|
+
await mkdir9(dirname47(target), { recursive: true });
|
|
60337
60927
|
await writeFile12(target, merged);
|
|
60338
60928
|
} catch (err) {
|
|
60339
60929
|
process.stderr.write(`cue brief: could not write ${target}: ${err.message}
|
|
@@ -60361,10 +60951,10 @@ var init_brief = __esm(() => {
|
|
|
60361
60951
|
// src/commands/tree.ts
|
|
60362
60952
|
var exports_tree = {};
|
|
60363
60953
|
__export(exports_tree, {
|
|
60364
|
-
run: () =>
|
|
60954
|
+
run: () => run79
|
|
60365
60955
|
});
|
|
60366
|
-
import { resolve as
|
|
60367
|
-
async function
|
|
60956
|
+
import { resolve as resolve35 } from "node:path";
|
|
60957
|
+
async function run79(args) {
|
|
60368
60958
|
const json = args.includes("--json");
|
|
60369
60959
|
let profileName2 = args.find((a) => !a.startsWith("-"));
|
|
60370
60960
|
if (!profileName2) {
|
|
@@ -60378,11 +60968,11 @@ async function run78(args) {
|
|
|
60378
60968
|
const profile = await loadProfile(profileName2);
|
|
60379
60969
|
const chain = profile.inheritanceChain;
|
|
60380
60970
|
const kitty = await detectKittyTerminal();
|
|
60381
|
-
const profilesRoot3 =
|
|
60971
|
+
const profilesRoot3 = resolve35(new URL(import.meta.url).pathname, "..", "..", "..", "profiles");
|
|
60382
60972
|
let nextImageId = 1;
|
|
60383
60973
|
function getIcon(p2, name) {
|
|
60384
60974
|
if (kitty && p2.iconImage && nextImageId <= 255) {
|
|
60385
|
-
const imgPath =
|
|
60975
|
+
const imgPath = resolve35(profilesRoot3, name, p2.iconImage);
|
|
60386
60976
|
const id = nextImageId++;
|
|
60387
60977
|
transmitKittyImage(imgPath, id, 2, 1);
|
|
60388
60978
|
return kittyPlaceholderLabel(id, 2, 1);
|
|
@@ -60465,14 +61055,14 @@ var init_tree = __esm(() => {
|
|
|
60465
61055
|
// src/commands/sources.ts
|
|
60466
61056
|
var exports_sources = {};
|
|
60467
61057
|
__export(exports_sources, {
|
|
60468
|
-
run: () =>
|
|
61058
|
+
run: () => run80
|
|
60469
61059
|
});
|
|
60470
|
-
import { readFileSync as readFileSync100, existsSync as
|
|
60471
|
-
import { spawnSync as
|
|
60472
|
-
import { join as
|
|
61060
|
+
import { readFileSync as readFileSync100, existsSync as existsSync110, readdirSync as readdirSync54 } from "node:fs";
|
|
61061
|
+
import { spawnSync as spawnSync34 } from "node:child_process";
|
|
61062
|
+
import { join as join151 } from "node:path";
|
|
60473
61063
|
import { homedir as homedir58 } from "node:os";
|
|
60474
61064
|
function loadSkillsLock() {
|
|
60475
|
-
if (!
|
|
61065
|
+
if (!existsSync110(SKILLS_LOCK))
|
|
60476
61066
|
return { version: 1, skills: {} };
|
|
60477
61067
|
try {
|
|
60478
61068
|
return JSON.parse(readFileSync100(SKILLS_LOCK, "utf8"));
|
|
@@ -60490,14 +61080,14 @@ function cmdList6(json) {
|
|
|
60490
61080
|
for (const [repo, count] of [...repoMap.entries()].sort((a, b2) => b2[1] - a[1])) {
|
|
60491
61081
|
results.push({ repo, url: `https://github.com/${repo}`, skillCount: count, type: "npx" });
|
|
60492
61082
|
}
|
|
60493
|
-
const localSkillsRoot =
|
|
60494
|
-
if (
|
|
61083
|
+
const localSkillsRoot = join151(repoRoot(), "resources", "skills", "skills");
|
|
61084
|
+
if (existsSync110(localSkillsRoot)) {
|
|
60495
61085
|
let count = 0;
|
|
60496
61086
|
try {
|
|
60497
61087
|
for (const cat of readdirSync54(localSkillsRoot)) {
|
|
60498
|
-
const catPath =
|
|
61088
|
+
const catPath = join151(localSkillsRoot, cat);
|
|
60499
61089
|
try {
|
|
60500
|
-
count += readdirSync54(catPath).filter((f2) =>
|
|
61090
|
+
count += readdirSync54(catPath).filter((f2) => existsSync110(join151(catPath, f2, "SKILL.md"))).length;
|
|
60501
61091
|
} catch {}
|
|
60502
61092
|
}
|
|
60503
61093
|
} catch {}
|
|
@@ -60594,7 +61184,7 @@ async function cmdSearch4(query, json) {
|
|
|
60594
61184
|
process.stdout.write(`\uD83D\uDD0D Searching GitHub for skill repos: "${query}"...
|
|
60595
61185
|
|
|
60596
61186
|
`);
|
|
60597
|
-
const npxRes =
|
|
61187
|
+
const npxRes = spawnSync34("npx", ["skills", "find", query], { encoding: "utf8", timeout: 30000 });
|
|
60598
61188
|
if (npxRes.status === 0 && npxRes.stdout.trim()) {
|
|
60599
61189
|
process.stdout.write(npxRes.stdout);
|
|
60600
61190
|
process.stdout.write(`
|
|
@@ -60602,7 +61192,7 @@ Install with: npx skills add <owner/repo> -a claude-code -y
|
|
|
60602
61192
|
`);
|
|
60603
61193
|
return 0;
|
|
60604
61194
|
}
|
|
60605
|
-
const smithRes =
|
|
61195
|
+
const smithRes = spawnSync34("smithery", ["skill", "search", query], { encoding: "utf8", timeout: 15000 });
|
|
60606
61196
|
if (smithRes.status === 0 && smithRes.stdout.trim()) {
|
|
60607
61197
|
process.stdout.write(smithRes.stdout);
|
|
60608
61198
|
return 0;
|
|
@@ -60620,7 +61210,7 @@ Try browsing:
|
|
|
60620
61210
|
`);
|
|
60621
61211
|
return 0;
|
|
60622
61212
|
}
|
|
60623
|
-
async function
|
|
61213
|
+
async function run80(args) {
|
|
60624
61214
|
const json = args.includes("--json");
|
|
60625
61215
|
const rest = args.filter((a) => !a.startsWith("-"));
|
|
60626
61216
|
if (rest[0] === "search") {
|
|
@@ -60638,19 +61228,19 @@ var SKILLS_LOCK;
|
|
|
60638
61228
|
var init_sources = __esm(() => {
|
|
60639
61229
|
init_profile_loader();
|
|
60640
61230
|
init_repo_root();
|
|
60641
|
-
SKILLS_LOCK =
|
|
61231
|
+
SKILLS_LOCK = join151(homedir58(), "skills-lock.json");
|
|
60642
61232
|
});
|
|
60643
61233
|
|
|
60644
61234
|
// src/commands/playground.ts
|
|
60645
61235
|
var exports_playground = {};
|
|
60646
61236
|
__export(exports_playground, {
|
|
60647
|
-
run: () =>
|
|
61237
|
+
run: () => run81
|
|
60648
61238
|
});
|
|
60649
|
-
import { mkdtempSync as
|
|
60650
|
-
import { join as
|
|
61239
|
+
import { mkdtempSync as mkdtempSync8, rmSync as rmSync15, mkdirSync as mkdirSync48, writeFileSync as writeFileSync56, existsSync as existsSync111 } from "node:fs";
|
|
61240
|
+
import { join as join152 } from "node:path";
|
|
60651
61241
|
import { execSync as execSync2, spawn as spawn9 } from "node:child_process";
|
|
60652
61242
|
import { tmpdir as tmpdir7 } from "node:os";
|
|
60653
|
-
async function
|
|
61243
|
+
async function run81(args) {
|
|
60654
61244
|
if (args.includes("-h") || args.includes("--help") || !args[0] || args[0].startsWith("-")) {
|
|
60655
61245
|
process.stdout.write(`cue playground — try a skill in isolation
|
|
60656
61246
|
|
|
@@ -60669,15 +61259,15 @@ Example:
|
|
|
60669
61259
|
const skillId = args[0];
|
|
60670
61260
|
const profileIdx = args.indexOf("--profile");
|
|
60671
61261
|
const baseProfile = profileIdx >= 0 ? args[profileIdx + 1] ?? "core" : "core";
|
|
60672
|
-
const skillPath =
|
|
60673
|
-
if (!
|
|
61262
|
+
const skillPath = join152(SKILLS_ROOT23, skillId, "SKILL.md");
|
|
61263
|
+
if (!existsSync111(skillPath)) {
|
|
60674
61264
|
process.stderr.write(`Skill "${skillId}" not found at ${skillPath}
|
|
60675
61265
|
`);
|
|
60676
61266
|
return 1;
|
|
60677
61267
|
}
|
|
60678
|
-
const tmpDir =
|
|
60679
|
-
const claudeDir =
|
|
60680
|
-
|
|
61268
|
+
const tmpDir = mkdtempSync8(join152(tmpdir7(), "cue-playground-"));
|
|
61269
|
+
const claudeDir = join152(tmpDir, "claude");
|
|
61270
|
+
mkdirSync48(claudeDir, { recursive: true });
|
|
60681
61271
|
const { readFileSync: readFileSync101 } = await import("node:fs");
|
|
60682
61272
|
let claudeMd = `# Playground: ${skillId}
|
|
60683
61273
|
|
|
@@ -60687,7 +61277,7 @@ Base profile: ${baseProfile}
|
|
|
60687
61277
|
try {
|
|
60688
61278
|
const profile = await loadProfile(baseProfile);
|
|
60689
61279
|
for (const s of profile.skills.local) {
|
|
60690
|
-
const sp =
|
|
61280
|
+
const sp = join152(SKILLS_ROOT23, s.id, "SKILL.md");
|
|
60691
61281
|
try {
|
|
60692
61282
|
claudeMd += readFileSync101(sp, "utf8") + `
|
|
60693
61283
|
|
|
@@ -60698,9 +61288,9 @@ Base profile: ${baseProfile}
|
|
|
60698
61288
|
}
|
|
60699
61289
|
} catch {}
|
|
60700
61290
|
claudeMd += readFileSync101(skillPath, "utf8");
|
|
60701
|
-
|
|
60702
|
-
|
|
60703
|
-
|
|
61291
|
+
writeFileSync56(join152(claudeDir, "CLAUDE.md"), claudeMd);
|
|
61292
|
+
writeFileSync56(join152(claudeDir, "settings.json"), JSON.stringify({ permissions: {} }, null, 2));
|
|
61293
|
+
writeFileSync56(join152(tmpDir, ".cue-hash"), "playground");
|
|
60704
61294
|
process.stdout.write(`\uD83C\uDFAE Playground: ${skillId} (base: ${baseProfile})
|
|
60705
61295
|
`);
|
|
60706
61296
|
process.stdout.write(` Runtime: ${claudeDir}
|
|
@@ -60725,10 +61315,10 @@ Base profile: ${baseProfile}
|
|
|
60725
61315
|
};
|
|
60726
61316
|
process.on("SIGINT", cleanupAndExit);
|
|
60727
61317
|
process.on("SIGTERM", cleanupAndExit);
|
|
60728
|
-
return new Promise((
|
|
61318
|
+
return new Promise((resolve36) => {
|
|
60729
61319
|
child.on("close", (code) => {
|
|
60730
61320
|
cleanup(tmpDir);
|
|
60731
|
-
|
|
61321
|
+
resolve36(code ?? 0);
|
|
60732
61322
|
});
|
|
60733
61323
|
});
|
|
60734
61324
|
}
|
|
@@ -60736,34 +61326,34 @@ function findClaude() {
|
|
|
60736
61326
|
try {
|
|
60737
61327
|
return execSync2("which claude", { encoding: "utf8" }).trim() || null;
|
|
60738
61328
|
} catch {
|
|
60739
|
-
const paths = ["/usr/local/bin/claude",
|
|
61329
|
+
const paths = ["/usr/local/bin/claude", join152(process.env.HOME ?? "", ".local/bin/claude")];
|
|
60740
61330
|
for (const p2 of paths)
|
|
60741
|
-
if (
|
|
61331
|
+
if (existsSync111(p2))
|
|
60742
61332
|
return p2;
|
|
60743
61333
|
return null;
|
|
60744
61334
|
}
|
|
60745
61335
|
}
|
|
60746
61336
|
function cleanup(dir) {
|
|
60747
61337
|
try {
|
|
60748
|
-
|
|
61338
|
+
rmSync15(dir, { recursive: true, force: true });
|
|
60749
61339
|
} catch {}
|
|
60750
61340
|
}
|
|
60751
61341
|
var SKILLS_ROOT23;
|
|
60752
61342
|
var init_playground = __esm(() => {
|
|
60753
61343
|
init_profile_loader();
|
|
60754
61344
|
init_repo_root();
|
|
60755
|
-
SKILLS_ROOT23 =
|
|
61345
|
+
SKILLS_ROOT23 = join152(repoRoot(), "resources", "skills", "skills");
|
|
60756
61346
|
});
|
|
60757
61347
|
|
|
60758
61348
|
// src/commands/workspace.ts
|
|
60759
61349
|
var exports_workspace = {};
|
|
60760
61350
|
__export(exports_workspace, {
|
|
60761
|
-
run: () =>
|
|
61351
|
+
run: () => run82
|
|
60762
61352
|
});
|
|
60763
|
-
import { existsSync as
|
|
60764
|
-
import { join as
|
|
61353
|
+
import { existsSync as existsSync112, readFileSync as readFileSync101, writeFileSync as writeFileSync57, appendFileSync as appendFileSync5 } from "node:fs";
|
|
61354
|
+
import { join as join153 } from "node:path";
|
|
60765
61355
|
import { homedir as homedir59 } from "node:os";
|
|
60766
|
-
async function
|
|
61356
|
+
async function run82(args) {
|
|
60767
61357
|
if (args.includes("-h") || args.includes("--help")) {
|
|
60768
61358
|
process.stdout.write(`cue workspace — select a workspace within the active profile
|
|
60769
61359
|
|
|
@@ -60787,7 +61377,7 @@ and injects context (industry, market, language) into the persona.
|
|
|
60787
61377
|
}
|
|
60788
61378
|
let profileName2;
|
|
60789
61379
|
try {
|
|
60790
|
-
const result = await resolveProfileForCwd({ cwd: process.cwd(), homeDir: homedir59(), configDir:
|
|
61380
|
+
const result = await resolveProfileForCwd({ cwd: process.cwd(), homeDir: homedir59(), configDir: join153(homedir59(), ".config", "cue") });
|
|
60791
61381
|
if (result.source !== "none")
|
|
60792
61382
|
profileName2 = result.profile;
|
|
60793
61383
|
} catch {}
|
|
@@ -60943,22 +61533,22 @@ Voice: ...`
|
|
|
60943
61533
|
saveWorkspace(profileName2, newId, ws);
|
|
60944
61534
|
R2.success(`Added workspace "${newId}"`);
|
|
60945
61535
|
if (apiKeyValue && apiKeyValue.trim()) {
|
|
60946
|
-
const envCuePath =
|
|
61536
|
+
const envCuePath = join153(homedir59(), ".env.cue");
|
|
60947
61537
|
const line = `export ${apiKeyVar}="${apiKeyValue}"
|
|
60948
61538
|
`;
|
|
60949
|
-
if (
|
|
61539
|
+
if (existsSync112(envCuePath)) {
|
|
60950
61540
|
const existing = readFileSync101(envCuePath, "utf8");
|
|
60951
61541
|
if (!existing.includes(`export ${apiKeyVar}=`)) {
|
|
60952
61542
|
appendFileSync5(envCuePath, line);
|
|
60953
61543
|
}
|
|
60954
61544
|
} else {
|
|
60955
|
-
|
|
61545
|
+
writeFileSync57(envCuePath, line, { mode: 384 });
|
|
60956
61546
|
}
|
|
60957
61547
|
R2.success(`Saved ${apiKeyVar} to ~/.env.cue`);
|
|
60958
|
-
const bashrcPath =
|
|
61548
|
+
const bashrcPath = join153(homedir59(), ".bashrc");
|
|
60959
61549
|
const sourceLine = "[ -f ~/.env.cue ] && source ~/.env.cue";
|
|
60960
61550
|
let alreadySourced = false;
|
|
60961
|
-
if (
|
|
61551
|
+
if (existsSync112(bashrcPath)) {
|
|
60962
61552
|
alreadySourced = readFileSync101(bashrcPath, "utf8").includes(sourceLine);
|
|
60963
61553
|
}
|
|
60964
61554
|
if (!alreadySourced) {
|
|
@@ -61216,30 +61806,30 @@ var init_workspace = __esm(() => {
|
|
|
61216
61806
|
// src/commands/evolve.ts
|
|
61217
61807
|
var exports_evolve = {};
|
|
61218
61808
|
__export(exports_evolve, {
|
|
61219
|
-
run: () =>
|
|
61809
|
+
run: () => run83,
|
|
61220
61810
|
lineText: () => lineText
|
|
61221
61811
|
});
|
|
61222
|
-
import { spawnSync as
|
|
61812
|
+
import { spawnSync as spawnSync35 } from "node:child_process";
|
|
61223
61813
|
import {
|
|
61224
61814
|
readFileSync as readFileSync102,
|
|
61225
|
-
existsSync as
|
|
61226
|
-
writeFileSync as
|
|
61227
|
-
mkdirSync as
|
|
61815
|
+
existsSync as existsSync113,
|
|
61816
|
+
writeFileSync as writeFileSync58,
|
|
61817
|
+
mkdirSync as mkdirSync49,
|
|
61228
61818
|
readdirSync as readdirSync55,
|
|
61229
61819
|
statSync as statSync31,
|
|
61230
61820
|
appendFileSync as appendFileSync6
|
|
61231
61821
|
} from "node:fs";
|
|
61232
|
-
import { join as
|
|
61822
|
+
import { join as join154, resolve as resolve36, dirname as dirname48 } from "node:path";
|
|
61233
61823
|
import { homedir as homedir60 } from "node:os";
|
|
61234
61824
|
import { fileURLToPath as fileURLToPath13 } from "node:url";
|
|
61235
61825
|
function findSessionFiles(maxAge) {
|
|
61236
61826
|
const files = [];
|
|
61237
61827
|
const cutoff = Date.now() - maxAge;
|
|
61238
|
-
if (!
|
|
61828
|
+
if (!existsSync113(SESSIONS_ROOT))
|
|
61239
61829
|
return files;
|
|
61240
61830
|
function walk3(dir) {
|
|
61241
61831
|
for (const entry of readdirSync55(dir, { withFileTypes: true })) {
|
|
61242
|
-
const p2 =
|
|
61832
|
+
const p2 = join154(dir, entry.name);
|
|
61243
61833
|
if (entry.isDirectory())
|
|
61244
61834
|
walk3(p2);
|
|
61245
61835
|
else if (entry.name.endsWith(".jsonl")) {
|
|
@@ -61314,7 +61904,7 @@ function checkSkillUsage(lines, skills) {
|
|
|
61314
61904
|
return { used, unused };
|
|
61315
61905
|
}
|
|
61316
61906
|
function ghSearchSkills(query) {
|
|
61317
|
-
const res =
|
|
61907
|
+
const res = spawnSync35("gh", [
|
|
61318
61908
|
"api",
|
|
61319
61909
|
"search/repositories",
|
|
61320
61910
|
"--method",
|
|
@@ -61358,9 +61948,9 @@ async function generateProposal(profileName2) {
|
|
|
61358
61948
|
};
|
|
61359
61949
|
}
|
|
61360
61950
|
async function applyProposal(profileName2, proposal) {
|
|
61361
|
-
const profilesDir4 =
|
|
61362
|
-
const yamlPath =
|
|
61363
|
-
if (!
|
|
61951
|
+
const profilesDir4 = resolve36(dirname48(fileURLToPath13(import.meta.url)), "..", "..", "profiles");
|
|
61952
|
+
const yamlPath = join154(profilesDir4, profileName2, "profile.yaml");
|
|
61953
|
+
if (!existsSync113(yamlPath)) {
|
|
61364
61954
|
process.stderr.write(`❌ Profile YAML not found: ${yamlPath}
|
|
61365
61955
|
`);
|
|
61366
61956
|
return;
|
|
@@ -61376,18 +61966,18 @@ async function applyProposal(profileName2, proposal) {
|
|
|
61376
61966
|
content = content.replace(new RegExp(`\\s*-\\s*${skill.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*\\n?`), `
|
|
61377
61967
|
`);
|
|
61378
61968
|
}
|
|
61379
|
-
|
|
61380
|
-
const evoLog =
|
|
61969
|
+
writeFileSync58(yamlPath, content);
|
|
61970
|
+
const evoLog = join154(configDir(), "evolution-log.jsonl");
|
|
61381
61971
|
const entry = { ts: new Date().toISOString(), profile: profileName2, added: proposal.add, removed: proposal.remove, gaps: proposal.gaps };
|
|
61382
|
-
|
|
61972
|
+
mkdirSync49(dirname48(evoLog), { recursive: true });
|
|
61383
61973
|
appendFileSync6(evoLog, JSON.stringify(entry) + `
|
|
61384
61974
|
`);
|
|
61385
61975
|
process.stdout.write(`✅ Applied: +${proposal.add.length} skills, -${proposal.remove.length} skills
|
|
61386
61976
|
`);
|
|
61387
61977
|
}
|
|
61388
61978
|
function showHistory() {
|
|
61389
|
-
const evoLog =
|
|
61390
|
-
if (!
|
|
61979
|
+
const evoLog = join154(configDir(), "evolution-log.jsonl");
|
|
61980
|
+
if (!existsSync113(evoLog)) {
|
|
61391
61981
|
process.stdout.write(`No evolution history yet.
|
|
61392
61982
|
`);
|
|
61393
61983
|
return;
|
|
@@ -61402,7 +61992,7 @@ function showHistory() {
|
|
|
61402
61992
|
} catch {}
|
|
61403
61993
|
}
|
|
61404
61994
|
}
|
|
61405
|
-
async function
|
|
61995
|
+
async function run83(args) {
|
|
61406
61996
|
const showHelp = args.includes("--help") || args.includes("-h");
|
|
61407
61997
|
if (showHelp) {
|
|
61408
61998
|
process.stdout.write(`Usage: cue evolve [--apply] [--history] [profile]
|
|
@@ -61473,7 +62063,7 @@ var init_evolve = __esm(() => {
|
|
|
61473
62063
|
init_config_paths();
|
|
61474
62064
|
init_profile_loader();
|
|
61475
62065
|
init_cwd_resolver();
|
|
61476
|
-
SESSIONS_ROOT =
|
|
62066
|
+
SESSIONS_ROOT = join154(homedir60(), ".claude", "projects");
|
|
61477
62067
|
DAYS_7 = 7 * 24 * 60 * 60 * 1000;
|
|
61478
62068
|
DAYS_30 = 30 * 24 * 60 * 60 * 1000;
|
|
61479
62069
|
});
|
|
@@ -61481,11 +62071,11 @@ var init_evolve = __esm(() => {
|
|
|
61481
62071
|
// src/commands/migrate-symlinks.ts
|
|
61482
62072
|
var exports_migrate_symlinks = {};
|
|
61483
62073
|
__export(exports_migrate_symlinks, {
|
|
61484
|
-
run: () =>
|
|
62074
|
+
run: () => run84,
|
|
61485
62075
|
migrateSymlinks: () => migrateSymlinks
|
|
61486
62076
|
});
|
|
61487
62077
|
import { readdir as readdir10, readlink as readlink2, lstat as lstat2, unlink as unlink2, symlink as symlink3 } from "node:fs/promises";
|
|
61488
|
-
import { join as
|
|
62078
|
+
import { join as join155 } from "node:path";
|
|
61489
62079
|
import { homedir as homedir61 } from "node:os";
|
|
61490
62080
|
function resolveMappings(opts) {
|
|
61491
62081
|
if (opts.mappings && opts.mappings.length > 0)
|
|
@@ -61511,7 +62101,7 @@ async function walk3(dir, mappings, dryRun, s) {
|
|
|
61511
62101
|
return;
|
|
61512
62102
|
}
|
|
61513
62103
|
for (const name of entries) {
|
|
61514
|
-
const path =
|
|
62104
|
+
const path = join155(dir, name);
|
|
61515
62105
|
let st3;
|
|
61516
62106
|
try {
|
|
61517
62107
|
st3 = await lstat2(path);
|
|
@@ -61550,7 +62140,7 @@ function parseMap(arg) {
|
|
|
61550
62140
|
return null;
|
|
61551
62141
|
return { from: arg.slice(0, eq), to: arg.slice(eq + 1) };
|
|
61552
62142
|
}
|
|
61553
|
-
async function
|
|
62143
|
+
async function run84(args) {
|
|
61554
62144
|
let from = "";
|
|
61555
62145
|
let to = "";
|
|
61556
62146
|
let dryRun = true;
|
|
@@ -61585,8 +62175,8 @@ async function run83(args) {
|
|
|
61585
62175
|
return 1;
|
|
61586
62176
|
}
|
|
61587
62177
|
const defaultRoots = roots.length > 0 ? roots : [
|
|
61588
|
-
|
|
61589
|
-
|
|
62178
|
+
join155(homedir61(), ".codex", "skills"),
|
|
62179
|
+
join155(homedir61(), ".claude-accounts")
|
|
61590
62180
|
];
|
|
61591
62181
|
const summary = await migrateSymlinks({ mappings, roots: defaultRoots, dryRun });
|
|
61592
62182
|
process.stdout.write(JSON.stringify(summary, null, 2) + `
|
|
@@ -61598,26 +62188,26 @@ var init_migrate_symlinks = () => {};
|
|
|
61598
62188
|
// src/commands/feedback.ts
|
|
61599
62189
|
var exports_feedback = {};
|
|
61600
62190
|
__export(exports_feedback, {
|
|
61601
|
-
run: () =>
|
|
62191
|
+
run: () => run85
|
|
61602
62192
|
});
|
|
61603
|
-
import { existsSync as
|
|
61604
|
-
import { dirname as
|
|
62193
|
+
import { existsSync as existsSync114, mkdirSync as mkdirSync50, readFileSync as readFileSync103, writeFileSync as writeFileSync59, appendFileSync as appendFileSync7 } from "node:fs";
|
|
62194
|
+
import { dirname as dirname49, join as join156 } from "node:path";
|
|
61605
62195
|
import { homedir as homedir62 } from "node:os";
|
|
61606
|
-
import { spawnSync as
|
|
62196
|
+
import { spawnSync as spawnSync36 } from "node:child_process";
|
|
61607
62197
|
import { createInterface as createInterface4 } from "node:readline/promises";
|
|
61608
62198
|
function genId() {
|
|
61609
62199
|
return Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
|
|
61610
62200
|
}
|
|
61611
62201
|
function getCueVersion() {
|
|
61612
62202
|
try {
|
|
61613
|
-
const pkg = JSON.parse(readFileSync103(
|
|
62203
|
+
const pkg = JSON.parse(readFileSync103(join156(import.meta.dirname ?? __dirname, "..", "..", "package.json"), "utf8"));
|
|
61614
62204
|
return pkg.version ?? "unknown";
|
|
61615
62205
|
} catch {
|
|
61616
62206
|
return "unknown";
|
|
61617
62207
|
}
|
|
61618
62208
|
}
|
|
61619
62209
|
function loadEntries() {
|
|
61620
|
-
if (!
|
|
62210
|
+
if (!existsSync114(LOG_PATH))
|
|
61621
62211
|
return [];
|
|
61622
62212
|
return readFileSync103(LOG_PATH, "utf8").split(`
|
|
61623
62213
|
`).filter((l) => l.trim()).map((l) => {
|
|
@@ -61629,7 +62219,7 @@ function loadEntries() {
|
|
|
61629
62219
|
}).filter((e2) => !!e2);
|
|
61630
62220
|
}
|
|
61631
62221
|
function saveEntry(entry) {
|
|
61632
|
-
|
|
62222
|
+
mkdirSync50(dirname49(LOG_PATH), { recursive: true });
|
|
61633
62223
|
appendFileSync7(LOG_PATH, JSON.stringify(entry) + `
|
|
61634
62224
|
`);
|
|
61635
62225
|
}
|
|
@@ -61730,7 +62320,7 @@ ${body}
|
|
|
61730
62320
|
`);
|
|
61731
62321
|
return 0;
|
|
61732
62322
|
}
|
|
61733
|
-
const res =
|
|
62323
|
+
const res = spawnSync36("gh", [
|
|
61734
62324
|
"issue",
|
|
61735
62325
|
"create",
|
|
61736
62326
|
"--repo",
|
|
@@ -61750,7 +62340,7 @@ ${body}
|
|
|
61750
62340
|
const url = res.stdout.trim();
|
|
61751
62341
|
entry.shared_issue_url = url;
|
|
61752
62342
|
const all = loadEntries().map((e2) => e2.id === entry.id ? entry : e2);
|
|
61753
|
-
|
|
62343
|
+
writeFileSync59(LOG_PATH, all.map((e2) => JSON.stringify(e2)).join(`
|
|
61754
62344
|
`) + `
|
|
61755
62345
|
`);
|
|
61756
62346
|
process.stdout.write(` ${green8("✓ Shared:")} ${url}
|
|
@@ -61758,9 +62348,9 @@ ${body}
|
|
|
61758
62348
|
return 0;
|
|
61759
62349
|
}
|
|
61760
62350
|
function hasGh() {
|
|
61761
|
-
return
|
|
62351
|
+
return spawnSync36("gh", ["--version"], { stdio: "ignore", timeout: 1000 }).status === 0;
|
|
61762
62352
|
}
|
|
61763
|
-
async function
|
|
62353
|
+
async function run85(args) {
|
|
61764
62354
|
if (args.includes("-h") || args.includes("--help")) {
|
|
61765
62355
|
process.stdout.write(`cue feedback — share what's working and what isn't
|
|
61766
62356
|
|
|
@@ -61829,7 +62419,7 @@ Examples:
|
|
|
61829
62419
|
}
|
|
61830
62420
|
var __dirname = "/home/runner/work/cuecards/cuecards/src/commands", LOG_PATH, bold11 = (s) => `\x1B[1m${s}\x1B[0m`, dim12 = (s) => `\x1B[2m${s}\x1B[0m`, cyan = (s) => `\x1B[36m${s}\x1B[0m`, green8 = (s) => `\x1B[32m${s}\x1B[0m`;
|
|
61831
62421
|
var init_feedback = __esm(() => {
|
|
61832
|
-
LOG_PATH =
|
|
62422
|
+
LOG_PATH = join156(process.env.XDG_CONFIG_HOME ?? join156(homedir62(), ".config"), "cue", "feedback.log");
|
|
61833
62423
|
});
|
|
61834
62424
|
|
|
61835
62425
|
// src/commands/submit-profile.ts
|
|
@@ -61838,10 +62428,10 @@ __export(exports_submit_profile, {
|
|
|
61838
62428
|
runCmd: () => runCmd,
|
|
61839
62429
|
run: () => runCmd
|
|
61840
62430
|
});
|
|
61841
|
-
import { existsSync as
|
|
62431
|
+
import { existsSync as existsSync115, mkdtempSync as mkdtempSync9, mkdirSync as mkdirSync51, copyFileSync as copyFileSync5, readFileSync as readFileSync104 } from "node:fs";
|
|
61842
62432
|
import { tmpdir as tmpdir8, homedir as homedir63 } from "node:os";
|
|
61843
|
-
import { join as
|
|
61844
|
-
import { spawnSync as
|
|
62433
|
+
import { join as join157, resolve as resolve37 } from "node:path";
|
|
62434
|
+
import { spawnSync as spawnSync37 } from "node:child_process";
|
|
61845
62435
|
function readProfileMeta(path) {
|
|
61846
62436
|
const content = readFileSync104(path, "utf8");
|
|
61847
62437
|
const parsed = import_yaml19.parse(content);
|
|
@@ -61856,8 +62446,8 @@ function readProfileMeta(path) {
|
|
|
61856
62446
|
throw new Error(`profile name "${name}" must be kebab-case ([a-z][a-z0-9-]{1,63})`);
|
|
61857
62447
|
return { name, description, icon, inherits };
|
|
61858
62448
|
}
|
|
61859
|
-
function
|
|
61860
|
-
const res =
|
|
62449
|
+
function run86(cmd, args, opts = {}) {
|
|
62450
|
+
const res = spawnSync37(cmd, args, {
|
|
61861
62451
|
cwd: opts.cwd,
|
|
61862
62452
|
encoding: "utf8",
|
|
61863
62453
|
stdio: opts.inherit ? "inherit" : ["ignore", "pipe", "pipe"],
|
|
@@ -61870,10 +62460,10 @@ function run85(cmd, args, opts = {}) {
|
|
|
61870
62460
|
};
|
|
61871
62461
|
}
|
|
61872
62462
|
function hasGh2() {
|
|
61873
|
-
return
|
|
62463
|
+
return run86("gh", ["--version"]).ok;
|
|
61874
62464
|
}
|
|
61875
62465
|
function ghUser() {
|
|
61876
|
-
const r =
|
|
62466
|
+
const r = run86("gh", ["api", "user", "--jq", ".login"]);
|
|
61877
62467
|
return r.ok ? r.out : null;
|
|
61878
62468
|
}
|
|
61879
62469
|
function printLintReport(result) {
|
|
@@ -61915,7 +62505,7 @@ Examples:
|
|
|
61915
62505
|
`);
|
|
61916
62506
|
return 1;
|
|
61917
62507
|
}
|
|
61918
|
-
if (!
|
|
62508
|
+
if (!existsSync115(path)) {
|
|
61919
62509
|
process.stderr.write(`File not found: ${path}
|
|
61920
62510
|
`);
|
|
61921
62511
|
return 1;
|
|
@@ -61934,16 +62524,16 @@ Examples:
|
|
|
61934
62524
|
process.stdout.write(`
|
|
61935
62525
|
${bold12("Profile:")} ${meta.name} ${dim13(meta.description)}
|
|
61936
62526
|
`);
|
|
61937
|
-
const stagingRoot =
|
|
61938
|
-
const profilesDir4 =
|
|
61939
|
-
|
|
61940
|
-
copyFileSync5(
|
|
62527
|
+
const stagingRoot = mkdtempSync9(join157(tmpdir8(), "cue-submit-"));
|
|
62528
|
+
const profilesDir4 = join157(stagingRoot, "profiles", meta.name);
|
|
62529
|
+
mkdirSync51(profilesDir4, { recursive: true });
|
|
62530
|
+
copyFileSync5(resolve37(path), join157(profilesDir4, "profile.yaml"));
|
|
61941
62531
|
process.stdout.write(` ${dim13("Staged to:")} ${profilesDir4}
|
|
61942
62532
|
`);
|
|
61943
62533
|
process.stdout.write(`
|
|
61944
62534
|
${bold12("Lint report:")}
|
|
61945
62535
|
`);
|
|
61946
|
-
const lintResult = await lintProfile(meta.name, { profilesDir:
|
|
62536
|
+
const lintResult = await lintProfile(meta.name, { profilesDir: join157(stagingRoot, "profiles") }).catch((e2) => {
|
|
61947
62537
|
process.stderr.write(red7(`✗ Lint failed: `) + e2.message + `
|
|
61948
62538
|
`);
|
|
61949
62539
|
return null;
|
|
@@ -62037,13 +62627,13 @@ ${prBody.split(`
|
|
|
62037
62627
|
`);
|
|
62038
62628
|
return 0;
|
|
62039
62629
|
}
|
|
62040
|
-
const forkDir =
|
|
62041
|
-
|
|
62042
|
-
if (!
|
|
62630
|
+
const forkDir = join157(homedir63(), ".cache", "cue", "submit-fork");
|
|
62631
|
+
mkdirSync51(join157(homedir63(), ".cache", "cue"), { recursive: true });
|
|
62632
|
+
if (!existsSync115(join157(forkDir, ".git"))) {
|
|
62043
62633
|
process.stdout.write(`
|
|
62044
62634
|
${bold12("Forking")} ${UPSTREAM_REPO}...
|
|
62045
62635
|
`);
|
|
62046
|
-
const fork =
|
|
62636
|
+
const fork = run86("gh", ["repo", "fork", UPSTREAM_REPO, "--clone", forkDir, "--remote=true"], { inherit: true });
|
|
62047
62637
|
if (!fork.ok) {
|
|
62048
62638
|
process.stderr.write(red7(`✗ Fork failed
|
|
62049
62639
|
`));
|
|
@@ -62052,18 +62642,18 @@ ${prBody.split(`
|
|
|
62052
62642
|
} else {
|
|
62053
62643
|
process.stdout.write(` ${dim13(`Reusing existing fork at ${forkDir}`)}
|
|
62054
62644
|
`);
|
|
62055
|
-
|
|
62056
|
-
|
|
62057
|
-
|
|
62645
|
+
run86("git", ["fetch", "upstream", "main"], { cwd: forkDir });
|
|
62646
|
+
run86("git", ["checkout", "main"], { cwd: forkDir });
|
|
62647
|
+
run86("git", ["reset", "--hard", "upstream/main"], { cwd: forkDir });
|
|
62058
62648
|
}
|
|
62059
62649
|
process.stdout.write(` ${bold12("Creating branch:")} ${branch}
|
|
62060
62650
|
`);
|
|
62061
|
-
|
|
62062
|
-
const destDir =
|
|
62063
|
-
|
|
62064
|
-
copyFileSync5(
|
|
62065
|
-
|
|
62066
|
-
const commit =
|
|
62651
|
+
run86("git", ["checkout", "-b", branch], { cwd: forkDir });
|
|
62652
|
+
const destDir = join157(forkDir, "profiles", meta.name);
|
|
62653
|
+
mkdirSync51(destDir, { recursive: true });
|
|
62654
|
+
copyFileSync5(resolve37(path), join157(destDir, "profile.yaml"));
|
|
62655
|
+
run86("git", ["add", "profiles/" + meta.name + "/profile.yaml"], { cwd: forkDir });
|
|
62656
|
+
const commit = run86("git", ["commit", "-m", `feat: add ${meta.name} profile`], { cwd: forkDir });
|
|
62067
62657
|
if (!commit.ok) {
|
|
62068
62658
|
process.stderr.write(red7("✗ Commit failed: ") + commit.err + `
|
|
62069
62659
|
`);
|
|
@@ -62071,7 +62661,7 @@ ${prBody.split(`
|
|
|
62071
62661
|
}
|
|
62072
62662
|
process.stdout.write(` ${bold12("Pushing branch...")}
|
|
62073
62663
|
`);
|
|
62074
|
-
const push =
|
|
62664
|
+
const push = run86("git", ["push", "-u", "origin", branch], { cwd: forkDir, inherit: true });
|
|
62075
62665
|
if (!push.ok) {
|
|
62076
62666
|
process.stderr.write(red7(`✗ Push failed
|
|
62077
62667
|
`));
|
|
@@ -62079,7 +62669,7 @@ ${prBody.split(`
|
|
|
62079
62669
|
}
|
|
62080
62670
|
process.stdout.write(` ${bold12("Opening PR...")}
|
|
62081
62671
|
`);
|
|
62082
|
-
const pr =
|
|
62672
|
+
const pr = run86("gh", [
|
|
62083
62673
|
"pr",
|
|
62084
62674
|
"create",
|
|
62085
62675
|
"--repo",
|
|
@@ -62110,35 +62700,35 @@ var init_submit_profile = __esm(() => {
|
|
|
62110
62700
|
|
|
62111
62701
|
// src/lib/telemetry-ingest.ts
|
|
62112
62702
|
import {
|
|
62113
|
-
closeSync as
|
|
62114
|
-
existsSync as
|
|
62115
|
-
openSync as
|
|
62703
|
+
closeSync as closeSync5,
|
|
62704
|
+
existsSync as existsSync116,
|
|
62705
|
+
openSync as openSync5,
|
|
62116
62706
|
readFileSync as readFileSync105,
|
|
62117
|
-
readSync as
|
|
62707
|
+
readSync as readSync5,
|
|
62118
62708
|
readdirSync as readdirSync56,
|
|
62119
62709
|
renameSync as renameSync12,
|
|
62120
62710
|
statSync as statSync32,
|
|
62121
|
-
writeFileSync as
|
|
62711
|
+
writeFileSync as writeFileSync60
|
|
62122
62712
|
} from "node:fs";
|
|
62123
62713
|
import { homedir as homedir64 } from "node:os";
|
|
62124
|
-
import { join as
|
|
62714
|
+
import { join as join158 } from "node:path";
|
|
62125
62715
|
function looksLikeAgentPrompt(text3) {
|
|
62126
62716
|
const head = text3.trimStart().slice(0, 200);
|
|
62127
62717
|
return SUB_AGENT_PROMPT_PATTERNS.some((re2) => re2.test(head));
|
|
62128
62718
|
}
|
|
62129
62719
|
function recentTranscripts2(projectsDir, sinceDays) {
|
|
62130
|
-
if (!
|
|
62720
|
+
if (!existsSync116(projectsDir))
|
|
62131
62721
|
return [];
|
|
62132
62722
|
const cutoff = Date.now() - sinceDays * 24 * 3600 * 1000;
|
|
62133
62723
|
const out = [];
|
|
62134
62724
|
try {
|
|
62135
62725
|
for (const proj of readdirSync56(projectsDir)) {
|
|
62136
|
-
const projDir =
|
|
62726
|
+
const projDir = join158(projectsDir, proj);
|
|
62137
62727
|
try {
|
|
62138
62728
|
for (const f2 of readdirSync56(projDir)) {
|
|
62139
62729
|
if (!f2.endsWith(".jsonl"))
|
|
62140
62730
|
continue;
|
|
62141
|
-
const full =
|
|
62731
|
+
const full = join158(projDir, f2);
|
|
62142
62732
|
try {
|
|
62143
62733
|
const st3 = statSync32(full);
|
|
62144
62734
|
if (st3.mtimeMs >= cutoff)
|
|
@@ -62152,7 +62742,7 @@ function recentTranscripts2(projectsDir, sinceDays) {
|
|
|
62152
62742
|
return out.map((x3) => x3.path);
|
|
62153
62743
|
}
|
|
62154
62744
|
function loadSeen(path) {
|
|
62155
|
-
if (!
|
|
62745
|
+
if (!existsSync116(path))
|
|
62156
62746
|
return { invocations: new Set, misses: new Set };
|
|
62157
62747
|
try {
|
|
62158
62748
|
const raw = JSON.parse(readFileSync105(path, "utf8"));
|
|
@@ -62166,7 +62756,7 @@ function loadSeen(path) {
|
|
|
62166
62756
|
}
|
|
62167
62757
|
function saveSeen(path, seen) {
|
|
62168
62758
|
const tmp = `${path}.tmp.${process.pid}`;
|
|
62169
|
-
|
|
62759
|
+
writeFileSync60(tmp, JSON.stringify({
|
|
62170
62760
|
invocations: [...seen.invocations],
|
|
62171
62761
|
misses: [...seen.misses]
|
|
62172
62762
|
}, null, 2) + `
|
|
@@ -62260,11 +62850,11 @@ function ingestTranscript(path, triggers, seen) {
|
|
|
62260
62850
|
const st3 = statSync32(path);
|
|
62261
62851
|
if (st3.size > MAX_BYTES_PER_TRANSCRIPT) {
|
|
62262
62852
|
const buf = Buffer.alloc(MAX_BYTES_PER_TRANSCRIPT);
|
|
62263
|
-
const fd =
|
|
62853
|
+
const fd = openSync5(path, "r");
|
|
62264
62854
|
try {
|
|
62265
|
-
|
|
62855
|
+
readSync5(fd, buf, 0, MAX_BYTES_PER_TRANSCRIPT, st3.size - MAX_BYTES_PER_TRANSCRIPT);
|
|
62266
62856
|
} finally {
|
|
62267
|
-
|
|
62857
|
+
closeSync5(fd);
|
|
62268
62858
|
}
|
|
62269
62859
|
contentRaw = buf.toString("utf8");
|
|
62270
62860
|
const nl = contentRaw.indexOf(`
|
|
@@ -62360,7 +62950,7 @@ async function ingest(opts = {}) {
|
|
|
62360
62950
|
if (!isEnabled2()) {
|
|
62361
62951
|
return { transcriptsScanned: 0, newInvocations: 0, newMisses: 0, skippedDuplicates: 0 };
|
|
62362
62952
|
}
|
|
62363
|
-
const projectsDir = opts.projectsDir ??
|
|
62953
|
+
const projectsDir = opts.projectsDir ?? join158(homedir64(), ".claude", "projects");
|
|
62364
62954
|
const sinceDays = opts.sinceDays ?? 7;
|
|
62365
62955
|
const transcripts = recentTranscripts2(projectsDir, sinceDays);
|
|
62366
62956
|
const seenPath = opts.seenTrackerOverride ?? seenTrackerPath();
|
|
@@ -62502,9 +63092,9 @@ var init_telemetry_report = __esm(() => {
|
|
|
62502
63092
|
// src/commands/telemetry.ts
|
|
62503
63093
|
var exports_telemetry = {};
|
|
62504
63094
|
__export(exports_telemetry, {
|
|
62505
|
-
run: () =>
|
|
63095
|
+
run: () => run87
|
|
62506
63096
|
});
|
|
62507
|
-
import { join as
|
|
63097
|
+
import { join as join159 } from "node:path";
|
|
62508
63098
|
import { homedir as homedir65 } from "node:os";
|
|
62509
63099
|
function formatBytes(n) {
|
|
62510
63100
|
if (n < 1024)
|
|
@@ -62621,7 +63211,7 @@ function parseDuration(raw, fallbackDays) {
|
|
|
62621
63211
|
}
|
|
62622
63212
|
async function buildAllProfileTriggers() {
|
|
62623
63213
|
const triggers = new Map;
|
|
62624
|
-
const skillsRoot6 =
|
|
63214
|
+
const skillsRoot6 = join159(process.env.CUE_REPO_ROOT ?? process.env.SOUL_REPO_ROOT ?? process.cwd(), "resources", "skills", "skills");
|
|
62625
63215
|
let profileNames = [];
|
|
62626
63216
|
try {
|
|
62627
63217
|
profileNames = await listProfiles();
|
|
@@ -62639,7 +63229,7 @@ async function buildAllProfileTriggers() {
|
|
|
62639
63229
|
if (ref.id.includes("*"))
|
|
62640
63230
|
continue;
|
|
62641
63231
|
const slugParts = ref.id.split("/");
|
|
62642
|
-
const dir =
|
|
63232
|
+
const dir = join159(skillsRoot6, ...slugParts);
|
|
62643
63233
|
let parsed;
|
|
62644
63234
|
try {
|
|
62645
63235
|
parsed = await parseSkillFromDir(ref.id, dir);
|
|
@@ -62671,7 +63261,7 @@ async function ingestCmd(args) {
|
|
|
62671
63261
|
process.stdout.write(`${dim14(`Loaded ${triggers.size} skills with trigger phrases for miss detection.`)}
|
|
62672
63262
|
`);
|
|
62673
63263
|
}
|
|
62674
|
-
const projectsDir =
|
|
63264
|
+
const projectsDir = join159(homedir65(), ".claude", "projects");
|
|
62675
63265
|
const stats = await ingest({ projectsDir, sinceDays, triggers });
|
|
62676
63266
|
if (asJson) {
|
|
62677
63267
|
process.stdout.write(JSON.stringify(stats, null, 2) + `
|
|
@@ -62688,7 +63278,7 @@ async function ingestCmd(args) {
|
|
|
62688
63278
|
}
|
|
62689
63279
|
async function declaredSkillNamesForProfile(profileName2) {
|
|
62690
63280
|
const names = new Set;
|
|
62691
|
-
const skillsRoot6 =
|
|
63281
|
+
const skillsRoot6 = join159(process.env.CUE_REPO_ROOT ?? process.env.SOUL_REPO_ROOT ?? process.cwd(), "resources", "skills", "skills");
|
|
62692
63282
|
let profileNames;
|
|
62693
63283
|
if (profileName2) {
|
|
62694
63284
|
profileNames = [profileName2];
|
|
@@ -62710,7 +63300,7 @@ async function declaredSkillNamesForProfile(profileName2) {
|
|
|
62710
63300
|
if (ref.id.includes("*"))
|
|
62711
63301
|
continue;
|
|
62712
63302
|
const slugParts = ref.id.split("/");
|
|
62713
|
-
const dir =
|
|
63303
|
+
const dir = join159(skillsRoot6, ...slugParts);
|
|
62714
63304
|
try {
|
|
62715
63305
|
const parsed = await parseSkillFromDir(ref.id, dir);
|
|
62716
63306
|
if (!parsed.missing)
|
|
@@ -62937,7 +63527,7 @@ function printUsage() {
|
|
|
62937
63527
|
`) + `
|
|
62938
63528
|
`);
|
|
62939
63529
|
}
|
|
62940
|
-
async function
|
|
63530
|
+
async function run87(args) {
|
|
62941
63531
|
const sub = args[0];
|
|
62942
63532
|
const rest = args.slice(1);
|
|
62943
63533
|
switch (sub) {
|
|
@@ -62986,7 +63576,7 @@ var init_telemetry = __esm(() => {
|
|
|
62986
63576
|
// src/commands/suggest-pairs.ts
|
|
62987
63577
|
var exports_suggest_pairs = {};
|
|
62988
63578
|
__export(exports_suggest_pairs, {
|
|
62989
|
-
run: () =>
|
|
63579
|
+
run: () => run88,
|
|
62990
63580
|
renderTable: () => renderTable,
|
|
62991
63581
|
parseArgs: () => parseArgs9,
|
|
62992
63582
|
buildRows: () => buildRows
|
|
@@ -63075,7 +63665,7 @@ function renderTable(rows) {
|
|
|
63075
63665
|
return lines.join(`
|
|
63076
63666
|
`);
|
|
63077
63667
|
}
|
|
63078
|
-
async function
|
|
63668
|
+
async function run88(argv) {
|
|
63079
63669
|
const args = parseArgs9(argv);
|
|
63080
63670
|
if (args.help) {
|
|
63081
63671
|
process.stdout.write([
|
|
@@ -63114,14 +63704,14 @@ var init_suggest_pairs = __esm(() => {
|
|
|
63114
63704
|
// src/commands/gates.ts
|
|
63115
63705
|
var exports_gates = {};
|
|
63116
63706
|
__export(exports_gates, {
|
|
63117
|
-
run: () =>
|
|
63707
|
+
run: () => run89,
|
|
63118
63708
|
readGateStatus: () => readGateStatus,
|
|
63119
63709
|
readAllGateStatus: () => readAllGateStatus,
|
|
63120
63710
|
parseArgs: () => parseArgs10
|
|
63121
63711
|
});
|
|
63122
|
-
import { spawnSync as
|
|
63123
|
-
import { existsSync as
|
|
63124
|
-
import { join as
|
|
63712
|
+
import { spawnSync as spawnSync38 } from "node:child_process";
|
|
63713
|
+
import { existsSync as existsSync117, readFileSync as readFileSync106 } from "node:fs";
|
|
63714
|
+
import { join as join160, resolve as resolve38 } from "node:path";
|
|
63125
63715
|
import { fileURLToPath as fileURLToPath14 } from "node:url";
|
|
63126
63716
|
function parseArgs10(argv) {
|
|
63127
63717
|
const out = {
|
|
@@ -63171,8 +63761,8 @@ function helpText3() {
|
|
|
63171
63761
|
function resolveActiveProfile2(explicit) {
|
|
63172
63762
|
if (explicit)
|
|
63173
63763
|
return explicit;
|
|
63174
|
-
const pin =
|
|
63175
|
-
if (
|
|
63764
|
+
const pin = join160(process.cwd(), ".cue.profile");
|
|
63765
|
+
if (existsSync117(pin)) {
|
|
63176
63766
|
try {
|
|
63177
63767
|
const txt = readFileSync106(pin, "utf8").trim().split(`
|
|
63178
63768
|
`)[0]?.trim();
|
|
@@ -63186,7 +63776,7 @@ function resolveActiveProfile2(explicit) {
|
|
|
63186
63776
|
}
|
|
63187
63777
|
function gateSourcePath(ref) {
|
|
63188
63778
|
const fname = ref.endsWith(".sh") ? ref : `${ref}.sh`;
|
|
63189
|
-
return
|
|
63779
|
+
return join160(GATES_RESOURCE_DIR, fname);
|
|
63190
63780
|
}
|
|
63191
63781
|
async function gatesForProfile(profileSelector) {
|
|
63192
63782
|
const parts = profileSelector.split("+").map((s) => s.trim()).filter(Boolean);
|
|
@@ -63222,7 +63812,7 @@ async function runList2(args) {
|
|
|
63222
63812
|
`);
|
|
63223
63813
|
for (const g of gates) {
|
|
63224
63814
|
const src = gateSourcePath(g);
|
|
63225
|
-
const ok =
|
|
63815
|
+
const ok = existsSync117(src);
|
|
63226
63816
|
const marker = ok ? " ✓" : " ✗";
|
|
63227
63817
|
const note = ok ? "" : " (missing — `cue doctor` will flag)";
|
|
63228
63818
|
process.stdout.write(`${marker} ${g}${note}
|
|
@@ -63246,7 +63836,7 @@ async function runRun(args) {
|
|
|
63246
63836
|
let anyFailed = false;
|
|
63247
63837
|
for (const g of gates) {
|
|
63248
63838
|
const src = gateSourcePath(g);
|
|
63249
|
-
if (!
|
|
63839
|
+
if (!existsSync117(src)) {
|
|
63250
63840
|
process.stderr.write(`✗ ${g} (source missing at ${src})
|
|
63251
63841
|
`);
|
|
63252
63842
|
anyFailed = true;
|
|
@@ -63257,7 +63847,7 @@ async function runRun(args) {
|
|
|
63257
63847
|
process.stdout.write(`
|
|
63258
63848
|
→ ${g}
|
|
63259
63849
|
`);
|
|
63260
|
-
const res =
|
|
63850
|
+
const res = spawnSync38("bash", [src], {
|
|
63261
63851
|
stdio: ["ignore", "inherit", "inherit"],
|
|
63262
63852
|
env: { ...process.env }
|
|
63263
63853
|
});
|
|
@@ -63292,11 +63882,11 @@ function fmtRelative(iso) {
|
|
|
63292
63882
|
return `${day}d ago`;
|
|
63293
63883
|
return iso.slice(0, 10);
|
|
63294
63884
|
}
|
|
63295
|
-
function printRun(
|
|
63296
|
-
const overallGlyph =
|
|
63297
|
-
process.stdout.write(`${overallGlyph} ${
|
|
63885
|
+
function printRun(run89) {
|
|
63886
|
+
const overallGlyph = run89.overall === "pass" ? "✓" : run89.overall === "fail" ? "✗" : "·";
|
|
63887
|
+
process.stdout.write(`${overallGlyph} ${run89.profile} ${run89.overall.toUpperCase()} (${fmtRelative(run89.ts)})
|
|
63298
63888
|
`);
|
|
63299
|
-
for (const r of
|
|
63889
|
+
for (const r of run89.results) {
|
|
63300
63890
|
const g = r.ok ? " ✓" : " ✗";
|
|
63301
63891
|
process.stdout.write(`${g} ${r.name}${r.ok ? "" : ` (exit ${r.exit})`}
|
|
63302
63892
|
`);
|
|
@@ -63324,8 +63914,8 @@ async function runStatus(args) {
|
|
|
63324
63914
|
`);
|
|
63325
63915
|
return 0;
|
|
63326
63916
|
}
|
|
63327
|
-
for (const
|
|
63328
|
-
printRun(
|
|
63917
|
+
for (const run90 of all) {
|
|
63918
|
+
printRun(run90);
|
|
63329
63919
|
process.stdout.write(`
|
|
63330
63920
|
`);
|
|
63331
63921
|
}
|
|
@@ -63337,21 +63927,21 @@ async function runStatus(args) {
|
|
|
63337
63927
|
`);
|
|
63338
63928
|
return 1;
|
|
63339
63929
|
}
|
|
63340
|
-
const
|
|
63930
|
+
const run89 = readGateStatus(profile);
|
|
63341
63931
|
if (args.json) {
|
|
63342
|
-
process.stdout.write(JSON.stringify(
|
|
63932
|
+
process.stdout.write(JSON.stringify(run89, null, 2) + `
|
|
63343
63933
|
`);
|
|
63344
63934
|
return 0;
|
|
63345
63935
|
}
|
|
63346
|
-
if (!
|
|
63936
|
+
if (!run89) {
|
|
63347
63937
|
process.stdout.write(`No gate runs recorded for "${profile}" yet. End a Claude session with this profile active and the Stop hook will populate this.
|
|
63348
63938
|
`);
|
|
63349
63939
|
return 0;
|
|
63350
63940
|
}
|
|
63351
|
-
printRun(
|
|
63941
|
+
printRun(run89);
|
|
63352
63942
|
return 0;
|
|
63353
63943
|
}
|
|
63354
|
-
async function
|
|
63944
|
+
async function run89(argv) {
|
|
63355
63945
|
try {
|
|
63356
63946
|
ensureGateStatusDir();
|
|
63357
63947
|
} catch {}
|
|
@@ -63374,18 +63964,18 @@ var init_gates = __esm(() => {
|
|
|
63374
63964
|
init_profile_loader();
|
|
63375
63965
|
init_gate_status();
|
|
63376
63966
|
init_gate_status();
|
|
63377
|
-
REPO_ROOT8 =
|
|
63378
|
-
GATES_RESOURCE_DIR =
|
|
63967
|
+
REPO_ROOT8 = resolve38(fileURLToPath14(import.meta.url), "..", "..", "..");
|
|
63968
|
+
GATES_RESOURCE_DIR = join160(REPO_ROOT8, "resources", "quality-gates");
|
|
63379
63969
|
});
|
|
63380
63970
|
|
|
63381
63971
|
// src/commands/skill-report.ts
|
|
63382
63972
|
var exports_skill_report2 = {};
|
|
63383
63973
|
__export(exports_skill_report2, {
|
|
63384
|
-
run: () =>
|
|
63974
|
+
run: () => run90,
|
|
63385
63975
|
parseArgs: () => parseArgs11
|
|
63386
63976
|
});
|
|
63387
|
-
import { existsSync as
|
|
63388
|
-
import { join as
|
|
63977
|
+
import { existsSync as existsSync118, readFileSync as readFileSync107, statSync as statSync33 } from "node:fs";
|
|
63978
|
+
import { join as join161, resolve as resolve39 } from "node:path";
|
|
63389
63979
|
function parseArgs11(argv) {
|
|
63390
63980
|
const out = {
|
|
63391
63981
|
profile: null,
|
|
@@ -63431,8 +64021,8 @@ function helpText4() {
|
|
|
63431
64021
|
function resolveActiveProfile3(explicit) {
|
|
63432
64022
|
if (explicit)
|
|
63433
64023
|
return explicit;
|
|
63434
|
-
const pin =
|
|
63435
|
-
if (
|
|
64024
|
+
const pin = join161(process.cwd(), ".cue.profile");
|
|
64025
|
+
if (existsSync118(pin)) {
|
|
63436
64026
|
try {
|
|
63437
64027
|
const txt = readFileSync107(pin, "utf8").trim().split(`
|
|
63438
64028
|
`)[0]?.trim();
|
|
@@ -63443,8 +64033,8 @@ function resolveActiveProfile3(explicit) {
|
|
|
63443
64033
|
return process.env.CUE_PROFILE ?? null;
|
|
63444
64034
|
}
|
|
63445
64035
|
function skillBytes(id) {
|
|
63446
|
-
const direct =
|
|
63447
|
-
if (
|
|
64036
|
+
const direct = join161(SKILLS_ROOT24, id, "SKILL.md");
|
|
64037
|
+
if (existsSync118(direct)) {
|
|
63448
64038
|
try {
|
|
63449
64039
|
return statSync33(direct).size;
|
|
63450
64040
|
} catch {
|
|
@@ -63529,7 +64119,7 @@ function renderRows(profileName2, rows, windowDays, now) {
|
|
|
63529
64119
|
return out.join(`
|
|
63530
64120
|
`);
|
|
63531
64121
|
}
|
|
63532
|
-
async function
|
|
64122
|
+
async function run90(argv) {
|
|
63533
64123
|
const args = parseArgs11(argv);
|
|
63534
64124
|
if (args.help) {
|
|
63535
64125
|
process.stdout.write(helpText4());
|
|
@@ -63595,19 +64185,19 @@ var init_skill_report2 = __esm(() => {
|
|
|
63595
64185
|
init_profile_loader();
|
|
63596
64186
|
init_skill_report();
|
|
63597
64187
|
init_telemetry_consent();
|
|
63598
|
-
REPO_ROOT9 =
|
|
63599
|
-
SKILLS_ROOT24 =
|
|
64188
|
+
REPO_ROOT9 = resolve39(new URL(import.meta.url).pathname, "..", "..", "..");
|
|
64189
|
+
SKILLS_ROOT24 = join161(REPO_ROOT9, "resources", "skills", "skills");
|
|
63600
64190
|
});
|
|
63601
64191
|
|
|
63602
64192
|
// src/commands/prune.ts
|
|
63603
64193
|
var exports_prune = {};
|
|
63604
64194
|
__export(exports_prune, {
|
|
63605
|
-
run: () =>
|
|
64195
|
+
run: () => run91,
|
|
63606
64196
|
parseArgs: () => parseArgs12,
|
|
63607
64197
|
dropSkillsFromYaml: () => dropSkillsFromYaml
|
|
63608
64198
|
});
|
|
63609
|
-
import { copyFileSync as copyFileSync6, existsSync as
|
|
63610
|
-
import { join as
|
|
64199
|
+
import { copyFileSync as copyFileSync6, existsSync as existsSync119, readFileSync as readFileSync108, statSync as statSync34, writeFileSync as writeFileSync61 } from "node:fs";
|
|
64200
|
+
import { join as join162, resolve as resolve40 } from "node:path";
|
|
63611
64201
|
function parseArgs12(argv) {
|
|
63612
64202
|
const out = {
|
|
63613
64203
|
dead: false,
|
|
@@ -63656,8 +64246,8 @@ function helpText5() {
|
|
|
63656
64246
|
function resolveActiveProfile4(explicit) {
|
|
63657
64247
|
if (explicit)
|
|
63658
64248
|
return explicit;
|
|
63659
|
-
const pin =
|
|
63660
|
-
if (
|
|
64249
|
+
const pin = join162(process.cwd(), ".cue.profile");
|
|
64250
|
+
if (existsSync119(pin)) {
|
|
63661
64251
|
try {
|
|
63662
64252
|
const txt = readFileSync108(pin, "utf8").trim().split(`
|
|
63663
64253
|
`)[0]?.trim();
|
|
@@ -63740,7 +64330,7 @@ function dropSkillsFromYaml(source, toRemove) {
|
|
|
63740
64330
|
return { rewritten: out.join(`
|
|
63741
64331
|
`), removed };
|
|
63742
64332
|
}
|
|
63743
|
-
async function
|
|
64333
|
+
async function run91(argv) {
|
|
63744
64334
|
const args = parseArgs12(argv);
|
|
63745
64335
|
if (args.help || !args.dead) {
|
|
63746
64336
|
process.stdout.write(helpText5());
|
|
@@ -63779,8 +64369,8 @@ async function run90(argv) {
|
|
|
63779
64369
|
let knownBytes = 0;
|
|
63780
64370
|
let knownCount = 0;
|
|
63781
64371
|
for (const z3 of zombies2) {
|
|
63782
|
-
const path =
|
|
63783
|
-
if (
|
|
64372
|
+
const path = join162(SKILLS_ROOT25, z3, "SKILL.md");
|
|
64373
|
+
if (existsSync119(path)) {
|
|
63784
64374
|
try {
|
|
63785
64375
|
knownBytes += statSync34(path).size;
|
|
63786
64376
|
knownCount++;
|
|
@@ -63788,8 +64378,8 @@ async function run90(argv) {
|
|
|
63788
64378
|
}
|
|
63789
64379
|
}
|
|
63790
64380
|
const estTokens = knownCount === zombies2.length ? Math.round(knownBytes / 4) : estimateTokenSavings(zombies2.length);
|
|
63791
|
-
const yamlPath =
|
|
63792
|
-
if (!
|
|
64381
|
+
const yamlPath = join162(PROFILES_DIR15, profileName2, "profile.yaml");
|
|
64382
|
+
if (!existsSync119(yamlPath)) {
|
|
63793
64383
|
process.stderr.write(`cue prune: ${yamlPath} doesn't exist
|
|
63794
64384
|
`);
|
|
63795
64385
|
return 1;
|
|
@@ -63828,7 +64418,7 @@ Dry-run: would remove ${edit.removed} line(s) from ${yamlPath}.
|
|
|
63828
64418
|
`);
|
|
63829
64419
|
return 1;
|
|
63830
64420
|
}
|
|
63831
|
-
|
|
64421
|
+
writeFileSync61(yamlPath, edit.rewritten);
|
|
63832
64422
|
process.stdout.write(`
|
|
63833
64423
|
✓ Removed ${edit.removed} line(s) from ${yamlPath}.
|
|
63834
64424
|
` + ` Backup: ${backup}
|
|
@@ -63840,9 +64430,9 @@ var init_prune = __esm(() => {
|
|
|
63840
64430
|
init_profile_loader();
|
|
63841
64431
|
init_skill_report();
|
|
63842
64432
|
init_telemetry_consent();
|
|
63843
|
-
REPO_ROOT10 =
|
|
63844
|
-
PROFILES_DIR15 = process.env.CUE_PROFILES_DIR ??
|
|
63845
|
-
SKILLS_ROOT25 =
|
|
64433
|
+
REPO_ROOT10 = resolve40(new URL(import.meta.url).pathname, "..", "..", "..");
|
|
64434
|
+
PROFILES_DIR15 = process.env.CUE_PROFILES_DIR ?? join162(REPO_ROOT10, "profiles");
|
|
64435
|
+
SKILLS_ROOT25 = join162(REPO_ROOT10, "resources", "skills", "skills");
|
|
63846
64436
|
});
|
|
63847
64437
|
|
|
63848
64438
|
// src/lib/trigger-gaps.ts
|
|
@@ -63903,13 +64493,13 @@ var DEFAULT_MIN_TRIGGER_LENGTH = 4, DEFAULT_WEAK_TRIGGER_MAX_PROMPT_CHARS = 80;
|
|
|
63903
64493
|
// src/commands/trigger-gaps.ts
|
|
63904
64494
|
var exports_trigger_gaps = {};
|
|
63905
64495
|
__export(exports_trigger_gaps, {
|
|
63906
|
-
run: () =>
|
|
64496
|
+
run: () => run92,
|
|
63907
64497
|
parseArgs: () => parseArgs13,
|
|
63908
64498
|
collectUserPrompts: () => collectUserPrompts
|
|
63909
64499
|
});
|
|
63910
|
-
import { existsSync as
|
|
64500
|
+
import { existsSync as existsSync120, readdirSync as readdirSync57, readFileSync as readFileSync109, statSync as statSync35 } from "node:fs";
|
|
63911
64501
|
import { homedir as homedir66 } from "node:os";
|
|
63912
|
-
import { join as
|
|
64502
|
+
import { join as join163, resolve as resolve41 } from "node:path";
|
|
63913
64503
|
function parseArgs13(argv) {
|
|
63914
64504
|
const out = {
|
|
63915
64505
|
profile: null,
|
|
@@ -63957,8 +64547,8 @@ function helpText6() {
|
|
|
63957
64547
|
function resolveActiveProfile5(explicit) {
|
|
63958
64548
|
if (explicit)
|
|
63959
64549
|
return explicit;
|
|
63960
|
-
const pin =
|
|
63961
|
-
if (
|
|
64550
|
+
const pin = join163(process.cwd(), ".cue.profile");
|
|
64551
|
+
if (existsSync120(pin)) {
|
|
63962
64552
|
try {
|
|
63963
64553
|
const txt = readFileSync109(pin, "utf8").trim().split(`
|
|
63964
64554
|
`)[0]?.trim();
|
|
@@ -63971,7 +64561,7 @@ function resolveActiveProfile5(explicit) {
|
|
|
63971
64561
|
function collectUserPrompts(sinceDays, root = PROJECTS_ROOT, opts = {}) {
|
|
63972
64562
|
const maxBytes = opts.maxBytes ?? 32 * 1024 * 1024;
|
|
63973
64563
|
const maxPrompts = opts.maxPrompts ?? 20000;
|
|
63974
|
-
if (!
|
|
64564
|
+
if (!existsSync120(root))
|
|
63975
64565
|
return [];
|
|
63976
64566
|
const cutoff = Date.now() - sinceDays * 24 * 60 * 60 * 1000;
|
|
63977
64567
|
const candidates = [];
|
|
@@ -63982,7 +64572,7 @@ function collectUserPrompts(sinceDays, root = PROJECTS_ROOT, opts = {}) {
|
|
|
63982
64572
|
return [];
|
|
63983
64573
|
}
|
|
63984
64574
|
for (const dir of dirs) {
|
|
63985
|
-
const dirPath =
|
|
64575
|
+
const dirPath = join163(root, dir);
|
|
63986
64576
|
let stat8;
|
|
63987
64577
|
try {
|
|
63988
64578
|
stat8 = statSync35(dirPath);
|
|
@@ -63998,7 +64588,7 @@ function collectUserPrompts(sinceDays, root = PROJECTS_ROOT, opts = {}) {
|
|
|
63998
64588
|
continue;
|
|
63999
64589
|
}
|
|
64000
64590
|
for (const f2 of files) {
|
|
64001
|
-
const fp =
|
|
64591
|
+
const fp = join163(dirPath, f2);
|
|
64002
64592
|
try {
|
|
64003
64593
|
const st3 = statSync35(fp);
|
|
64004
64594
|
if (st3.mtimeMs < cutoff)
|
|
@@ -64070,7 +64660,7 @@ function renderRows2(profileName2, rows, sinceDays) {
|
|
|
64070
64660
|
return out.join(`
|
|
64071
64661
|
`);
|
|
64072
64662
|
}
|
|
64073
|
-
async function
|
|
64663
|
+
async function run92(argv) {
|
|
64074
64664
|
const args = parseArgs13(argv);
|
|
64075
64665
|
if (args.help) {
|
|
64076
64666
|
process.stdout.write(helpText6());
|
|
@@ -64103,9 +64693,9 @@ async function run91(argv) {
|
|
|
64103
64693
|
} catch {}
|
|
64104
64694
|
}
|
|
64105
64695
|
const userPrompts = collectUserPrompts(args.sinceDays);
|
|
64106
|
-
const
|
|
64696
|
+
const usage6 = computeSkillUsage(loaded, { windowDays: args.sinceDays });
|
|
64107
64697
|
const hits = new Map;
|
|
64108
|
-
for (const u of
|
|
64698
|
+
for (const u of usage6)
|
|
64109
64699
|
hits.set(u.id, u.hits);
|
|
64110
64700
|
const rows = computeTriggerGaps({
|
|
64111
64701
|
skills,
|
|
@@ -64139,15 +64729,15 @@ var init_trigger_gaps = __esm(() => {
|
|
|
64139
64729
|
init_resolver_local();
|
|
64140
64730
|
init_skill_report();
|
|
64141
64731
|
init_telemetry_consent();
|
|
64142
|
-
REPO_ROOT11 =
|
|
64143
|
-
PROJECTS_ROOT =
|
|
64732
|
+
REPO_ROOT11 = resolve41(new URL(import.meta.url).pathname, "..", "..", "..");
|
|
64733
|
+
PROJECTS_ROOT = join163(homedir66(), ".claude", "projects");
|
|
64144
64734
|
});
|
|
64145
64735
|
|
|
64146
64736
|
// src/lib/local-inventory.ts
|
|
64147
64737
|
import { readdir as readdir11, readFile as readFile23, realpath as realpath3, stat as stat8 } from "node:fs/promises";
|
|
64148
64738
|
import { createHash as createHash16 } from "node:crypto";
|
|
64149
64739
|
import { homedir as homedir67 } from "node:os";
|
|
64150
|
-
import { basename as basename14, join as
|
|
64740
|
+
import { basename as basename14, join as join164, resolve as resolve42 } from "node:path";
|
|
64151
64741
|
function fileId(kind, path) {
|
|
64152
64742
|
return `${kind}:${createHash16("sha256").update(path).digest("hex")}`;
|
|
64153
64743
|
}
|
|
@@ -64195,7 +64785,7 @@ async function scanLocalInventory(options) {
|
|
|
64195
64785
|
const sources = [];
|
|
64196
64786
|
const mcpFiles = [...options.mcpFiles];
|
|
64197
64787
|
const missingState = (err) => err.code === "ENOENT" ? "missing" : "unreadable";
|
|
64198
|
-
for (const root of new Set(options.skillRoots.map((x3) =>
|
|
64788
|
+
for (const root of new Set(options.skillRoots.map((x3) => resolve42(x3)))) {
|
|
64199
64789
|
const source = { path: root, state: "scanned" };
|
|
64200
64790
|
sources.push(source);
|
|
64201
64791
|
const visited = new Set;
|
|
@@ -64212,9 +64802,9 @@ async function scanLocalInventory(options) {
|
|
|
64212
64802
|
visited.add(canonical);
|
|
64213
64803
|
const entries = await readdir11(dir, { withFileTypes: true });
|
|
64214
64804
|
if (entries.some((e2) => e2.name === ".mcp.json" && e2.isFile()))
|
|
64215
|
-
mcpFiles.push(
|
|
64805
|
+
mcpFiles.push(join164(dir, ".mcp.json"));
|
|
64216
64806
|
if (entries.some((e2) => e2.name === "SKILL.md")) {
|
|
64217
|
-
const file = await realpath3(
|
|
64807
|
+
const file = await realpath3(join164(dir, "SKILL.md"));
|
|
64218
64808
|
const id = fileId("skill", file);
|
|
64219
64809
|
const existing = items.get(id);
|
|
64220
64810
|
if (existing) {
|
|
@@ -64234,7 +64824,7 @@ async function scanLocalInventory(options) {
|
|
|
64234
64824
|
if (["node_modules", ".git", ".omx", "dist", "coverage"].includes(entry.name))
|
|
64235
64825
|
continue;
|
|
64236
64826
|
if (entry.isDirectory() || entry.isSymbolicLink())
|
|
64237
|
-
await walk4(
|
|
64827
|
+
await walk4(join164(dir, entry.name), depth + 1);
|
|
64238
64828
|
}
|
|
64239
64829
|
} catch (err) {
|
|
64240
64830
|
source.state = dir === root ? missingState(err) : "partial";
|
|
@@ -64242,7 +64832,7 @@ async function scanLocalInventory(options) {
|
|
|
64242
64832
|
}
|
|
64243
64833
|
await walk4(root, 0);
|
|
64244
64834
|
}
|
|
64245
|
-
for (const file of new Set(mcpFiles.map((x3) =>
|
|
64835
|
+
for (const file of new Set(mcpFiles.map((x3) => resolve42(x3)))) {
|
|
64246
64836
|
const source = { path: file, state: "scanned" };
|
|
64247
64837
|
sources.push(source);
|
|
64248
64838
|
try {
|
|
@@ -64330,22 +64920,22 @@ async function collectLocalInventory() {
|
|
|
64330
64920
|
const home = homedir67();
|
|
64331
64921
|
const cwd = process.cwd();
|
|
64332
64922
|
const codex2 = canonicalCodexHome();
|
|
64333
|
-
const claude = process.env.CUE_CLAUDE_HOME ??
|
|
64334
|
-
const agentHomes = [...new Set([codex2,
|
|
64923
|
+
const claude = process.env.CUE_CLAUDE_HOME ?? join164(home, ".claude");
|
|
64924
|
+
const agentHomes = [...new Set([codex2, join164(home, ".codex"), claude, process.env.CODEX_HOME, process.env.CLAUDE_CONFIG_DIR].filter((x3) => !!x3))];
|
|
64335
64925
|
try {
|
|
64336
|
-
for (const entry of await readdir11(
|
|
64926
|
+
for (const entry of await readdir11(join164(configDir(), "runtime"), { withFileTypes: true })) {
|
|
64337
64927
|
if (entry.isDirectory())
|
|
64338
64928
|
for (const agent of ["codex", "claude"])
|
|
64339
|
-
agentHomes.push(
|
|
64929
|
+
agentHomes.push(join164(configDir(), "runtime", entry.name, agent));
|
|
64340
64930
|
}
|
|
64341
64931
|
} catch {}
|
|
64342
|
-
const skillRoots = [
|
|
64343
|
-
const mcpFiles = [
|
|
64932
|
+
const skillRoots = [join164(repoRoot(), "resources/skills/skills"), join164(cacheDir(), "npx"), join164(home, ".agents/skills"), join164(cwd, ".agents/skills"), join164(cwd, ".claude/skills"), join164(cwd, ".codex/skills")];
|
|
64933
|
+
const mcpFiles = [join164(home, ".claude.json"), join164(cwd, ".mcp.json"), join164(home, ".cursor/mcp.json"), join164(cwd, ".cursor/mcp.json")];
|
|
64344
64934
|
for (const dir of new Set(agentHomes)) {
|
|
64345
|
-
skillRoots.push(
|
|
64346
|
-
mcpFiles.push(
|
|
64935
|
+
skillRoots.push(join164(dir, "skills"), join164(dir, "plugins/cache"));
|
|
64936
|
+
mcpFiles.push(join164(dir, "config.toml"), join164(dir, ".mcp.json"), join164(dir, "settings.json"));
|
|
64347
64937
|
}
|
|
64348
|
-
const catalogFiles = ["claude.sanitized.json", "claude_runtime.sanitized.json", "codex.sanitized.json"].map((file) =>
|
|
64938
|
+
const catalogFiles = ["claude.sanitized.json", "claude_runtime.sanitized.json", "codex.sanitized.json"].map((file) => join164(repoRoot(), "resources/mcps/configs", file));
|
|
64349
64939
|
mcpFiles.push(...catalogFiles);
|
|
64350
64940
|
const resolveSkill = createLocalSkillResolver();
|
|
64351
64941
|
let allSkillIds;
|
|
@@ -64364,12 +64954,12 @@ async function collectLocalInventory() {
|
|
|
64364
64954
|
}
|
|
64365
64955
|
const skills = await Promise.all(localRefs.map(async (ref) => {
|
|
64366
64956
|
try {
|
|
64367
|
-
return { ref, path:
|
|
64957
|
+
return { ref, path: join164(await resolveSkill(ref), "SKILL.md") };
|
|
64368
64958
|
} catch {
|
|
64369
64959
|
return { ref };
|
|
64370
64960
|
}
|
|
64371
64961
|
}));
|
|
64372
|
-
const remote = p2.skills.npx.flatMap((ref) => ref.skills.map((skill) => ({ ref: `${ref.repo}/${skill}`, path:
|
|
64962
|
+
const remote = p2.skills.npx.flatMap((ref) => ref.skills.map((skill) => ({ ref: `${ref.repo}/${skill}`, path: join164(cacheSkillPath({}, cacheKey(ref.repo, ref.pin), skill), "SKILL.md") })));
|
|
64373
64963
|
profiles.push({ name, path, description: p2.description, skills: [...skills, ...remote], mcps: p2.mcps.map((m2) => m2.id) });
|
|
64374
64964
|
} catch {
|
|
64375
64965
|
profiles.push({ name, path, description: "Profile could not be loaded", error: true, skills: [], mcps: [] });
|
|
@@ -64389,11 +64979,11 @@ var init_local_inventory = __esm(() => {
|
|
|
64389
64979
|
});
|
|
64390
64980
|
|
|
64391
64981
|
// src/lib/plugin-discovery.ts
|
|
64392
|
-
import { existsSync as
|
|
64982
|
+
import { existsSync as existsSync121, readdirSync as readdirSync58, readFileSync as readFileSync110 } from "node:fs";
|
|
64393
64983
|
import { homedir as homedir68 } from "node:os";
|
|
64394
|
-
import { join as
|
|
64984
|
+
import { join as join165 } from "node:path";
|
|
64395
64985
|
function claudeHome() {
|
|
64396
|
-
return process.env.CUE_CLAUDE_HOME ??
|
|
64986
|
+
return process.env.CUE_CLAUDE_HOME ?? join165(homedir68(), ".claude");
|
|
64397
64987
|
}
|
|
64398
64988
|
function readJson(path) {
|
|
64399
64989
|
try {
|
|
@@ -64403,23 +64993,23 @@ function readJson(path) {
|
|
|
64403
64993
|
}
|
|
64404
64994
|
}
|
|
64405
64995
|
function countSkills(installPath) {
|
|
64406
|
-
const skillsDir =
|
|
64407
|
-
if (!
|
|
64996
|
+
const skillsDir = join165(installPath, "skills");
|
|
64997
|
+
if (!existsSync121(skillsDir))
|
|
64408
64998
|
return 0;
|
|
64409
64999
|
try {
|
|
64410
|
-
return readdirSync58(skillsDir, { withFileTypes: true }).filter((d) => d.isDirectory() &&
|
|
65000
|
+
return readdirSync58(skillsDir, { withFileTypes: true }).filter((d) => d.isDirectory() && existsSync121(join165(skillsDir, d.name, "SKILL.md"))).length;
|
|
64411
65001
|
} catch {
|
|
64412
65002
|
return 0;
|
|
64413
65003
|
}
|
|
64414
65004
|
}
|
|
64415
65005
|
function manifestDescription(installPath) {
|
|
64416
|
-
const m2 = readJson(
|
|
65006
|
+
const m2 = readJson(join165(installPath, ".claude-plugin", "plugin.json"));
|
|
64417
65007
|
return (m2?.description ?? "").slice(0, 200);
|
|
64418
65008
|
}
|
|
64419
65009
|
function discoverInstalledPlugins2() {
|
|
64420
65010
|
const home = claudeHome();
|
|
64421
|
-
const installed = readJson(
|
|
64422
|
-
const settings = readJson(
|
|
65011
|
+
const installed = readJson(join165(home, "plugins", "installed_plugins.json"));
|
|
65012
|
+
const settings = readJson(join165(home, "settings.json"));
|
|
64423
65013
|
const enabledMap = settings?.enabledPlugins ?? {};
|
|
64424
65014
|
const installedMap = installed?.plugins ?? {};
|
|
64425
65015
|
const ids = new Set([
|
|
@@ -64433,7 +65023,7 @@ function discoverInstalledPlugins2() {
|
|
|
64433
65023
|
const marketplace = at3 > 0 ? id.slice(at3 + 1) : "";
|
|
64434
65024
|
const entry = installedMap[id]?.[0];
|
|
64435
65025
|
const installPath = entry?.installPath ?? null;
|
|
64436
|
-
const onDisk = installPath != null &&
|
|
65026
|
+
const onDisk = installPath != null && existsSync121(installPath);
|
|
64437
65027
|
out.push({
|
|
64438
65028
|
id,
|
|
64439
65029
|
name,
|
|
@@ -64452,10 +65042,10 @@ function discoverInstalledPlugins2() {
|
|
|
64452
65042
|
var init_plugin_discovery = () => {};
|
|
64453
65043
|
|
|
64454
65044
|
// src/lib/workflow-store.ts
|
|
64455
|
-
import { existsSync as
|
|
64456
|
-
import { join as
|
|
65045
|
+
import { existsSync as existsSync122, mkdirSync as mkdirSync52, readdirSync as readdirSync59, readFileSync as readFileSync111, writeFileSync as writeFileSync62 } from "node:fs";
|
|
65046
|
+
import { join as join166, resolve as resolve43 } from "node:path";
|
|
64457
65047
|
function workflowsDir() {
|
|
64458
|
-
return process.env.CUE_WORKFLOWS_DIR ??
|
|
65048
|
+
return process.env.CUE_WORKFLOWS_DIR ?? join166(REPO_ROOT12, "resources", "workflows");
|
|
64459
65049
|
}
|
|
64460
65050
|
function assertValidName(name) {
|
|
64461
65051
|
if (!NAME_RE.test(name) || name.includes("..") || name.length > 64) {
|
|
@@ -64471,13 +65061,13 @@ function readJson2(path) {
|
|
|
64471
65061
|
}
|
|
64472
65062
|
function listWorkflows() {
|
|
64473
65063
|
const dir = workflowsDir();
|
|
64474
|
-
if (!
|
|
65064
|
+
if (!existsSync122(dir))
|
|
64475
65065
|
return [];
|
|
64476
65066
|
const out = [];
|
|
64477
65067
|
for (const f2 of readdirSync59(dir)) {
|
|
64478
65068
|
if (!f2.endsWith(".json"))
|
|
64479
65069
|
continue;
|
|
64480
|
-
const wf = readJson2(
|
|
65070
|
+
const wf = readJson2(join166(dir, f2));
|
|
64481
65071
|
if (!wf || typeof wf.name !== "string")
|
|
64482
65072
|
continue;
|
|
64483
65073
|
out.push({
|
|
@@ -64493,7 +65083,7 @@ function listWorkflows() {
|
|
|
64493
65083
|
}
|
|
64494
65084
|
function loadWorkflow(name) {
|
|
64495
65085
|
assertValidName(name);
|
|
64496
|
-
return readJson2(
|
|
65086
|
+
return readJson2(join166(workflowsDir(), `${name}.json`));
|
|
64497
65087
|
}
|
|
64498
65088
|
function saveWorkflow(input, nowIso) {
|
|
64499
65089
|
const wf = input;
|
|
@@ -64507,8 +65097,8 @@ function saveWorkflow(input, nowIso) {
|
|
|
64507
65097
|
if (!Array.isArray(wf.edges))
|
|
64508
65098
|
throw new WorkflowError("workflow.edges must be an array");
|
|
64509
65099
|
const dir = workflowsDir();
|
|
64510
|
-
if (!
|
|
64511
|
-
|
|
65100
|
+
if (!existsSync122(dir))
|
|
65101
|
+
mkdirSync52(dir, { recursive: true });
|
|
64512
65102
|
const existing = loadWorkflow(wf.name);
|
|
64513
65103
|
const doc = {
|
|
64514
65104
|
version: 1,
|
|
@@ -64520,24 +65110,24 @@ function saveWorkflow(input, nowIso) {
|
|
|
64520
65110
|
createdAt: existing?.createdAt ?? nowIso,
|
|
64521
65111
|
updatedAt: nowIso
|
|
64522
65112
|
};
|
|
64523
|
-
|
|
65113
|
+
writeFileSync62(join166(dir, `${wf.name}.json`), JSON.stringify(doc, null, 2) + `
|
|
64524
65114
|
`);
|
|
64525
65115
|
return doc;
|
|
64526
65116
|
}
|
|
64527
65117
|
var REPO_ROOT12, WorkflowError, NAME_RE;
|
|
64528
65118
|
var init_workflow_store = __esm(() => {
|
|
64529
|
-
REPO_ROOT12 =
|
|
65119
|
+
REPO_ROOT12 = resolve43(new URL(import.meta.url).pathname, "..", "..", "..");
|
|
64530
65120
|
WorkflowError = class WorkflowError extends Error {
|
|
64531
65121
|
};
|
|
64532
65122
|
NAME_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
64533
65123
|
});
|
|
64534
65124
|
|
|
64535
65125
|
// src/lib/active-sessions.ts
|
|
64536
|
-
import { existsSync as
|
|
65126
|
+
import { existsSync as existsSync123, readdirSync as readdirSync60, readFileSync as readFileSync112, readlinkSync as readlinkSync2 } from "node:fs";
|
|
64537
65127
|
import { homedir as homedir69 } from "node:os";
|
|
64538
|
-
import { join as
|
|
65128
|
+
import { join as join167 } from "node:path";
|
|
64539
65129
|
function supportsProcScan() {
|
|
64540
|
-
return process.platform === "linux" &&
|
|
65130
|
+
return process.platform === "linux" && existsSync123("/proc/self/environ");
|
|
64541
65131
|
}
|
|
64542
65132
|
function readEnviron(pid) {
|
|
64543
65133
|
try {
|
|
@@ -64594,7 +65184,7 @@ function profileFromCwdPin(cwd) {
|
|
|
64594
65184
|
if (!cwd)
|
|
64595
65185
|
return null;
|
|
64596
65186
|
try {
|
|
64597
|
-
const raw = readFileSync112(
|
|
65187
|
+
const raw = readFileSync112(join167(cwd, ".cue.profile"), "utf8");
|
|
64598
65188
|
const first = raw.split(`
|
|
64599
65189
|
`)[0]?.trim();
|
|
64600
65190
|
return first && first.length > 0 ? first : null;
|
|
@@ -64707,18 +65297,18 @@ var init_active_sessions = __esm(() => {
|
|
|
64707
65297
|
// src/lib/mcp-catalog.ts
|
|
64708
65298
|
import { readFileSync as readFileSync113 } from "node:fs";
|
|
64709
65299
|
import { readFile as readFile24, writeFile as writeFile13, access as access4 } from "node:fs/promises";
|
|
64710
|
-
import { resolve as
|
|
65300
|
+
import { resolve as resolve44, join as join168 } from "node:path";
|
|
64711
65301
|
function configsDir() {
|
|
64712
|
-
return
|
|
65302
|
+
return join168(repoRoot(), "resources", "mcps", "configs");
|
|
64713
65303
|
}
|
|
64714
65304
|
function docsDir() {
|
|
64715
|
-
return
|
|
65305
|
+
return join168(repoRoot(), "resources", "mcps", "mcps");
|
|
64716
65306
|
}
|
|
64717
65307
|
function loadAllMcpIds2() {
|
|
64718
65308
|
const ids = new Set;
|
|
64719
65309
|
for (const file of CONFIG_FILES) {
|
|
64720
65310
|
try {
|
|
64721
|
-
const raw = JSON.parse(readFileSync113(
|
|
65311
|
+
const raw = JSON.parse(readFileSync113(join168(configsDir(), file), "utf8"));
|
|
64722
65312
|
if (raw.servers)
|
|
64723
65313
|
for (const id of Object.keys(raw.servers))
|
|
64724
65314
|
ids.add(id);
|
|
@@ -64729,7 +65319,7 @@ function loadAllMcpIds2() {
|
|
|
64729
65319
|
function loadServerConfig(id) {
|
|
64730
65320
|
for (const file of CONFIG_FILES) {
|
|
64731
65321
|
try {
|
|
64732
|
-
const raw = JSON.parse(readFileSync113(
|
|
65322
|
+
const raw = JSON.parse(readFileSync113(join168(configsDir(), file), "utf8"));
|
|
64733
65323
|
if (raw.servers?.[id])
|
|
64734
65324
|
return raw.servers[id];
|
|
64735
65325
|
} catch {}
|
|
@@ -64738,7 +65328,7 @@ function loadServerConfig(id) {
|
|
|
64738
65328
|
}
|
|
64739
65329
|
function getMcpDescription2(id) {
|
|
64740
65330
|
try {
|
|
64741
|
-
const readme = readFileSync113(
|
|
65331
|
+
const readme = readFileSync113(join168(docsDir(), id, "README.md"), "utf8");
|
|
64742
65332
|
const firstLine = readme.split(`
|
|
64743
65333
|
`).find((l) => l.trim() && !l.startsWith("#"));
|
|
64744
65334
|
return firstLine?.trim().slice(0, 140) ?? "";
|
|
@@ -64787,8 +65377,8 @@ async function addMcpToProfile(id, profileName2) {
|
|
|
64787
65377
|
throw new Error(`invalid-profile: "${profileName2}"`);
|
|
64788
65378
|
}
|
|
64789
65379
|
const dir = profilesDir();
|
|
64790
|
-
const yamlPath =
|
|
64791
|
-
if (!
|
|
65380
|
+
const yamlPath = join168(dir, profileName2, "profile.yaml");
|
|
65381
|
+
if (!resolve44(yamlPath).startsWith(resolve44(dir))) {
|
|
64792
65382
|
throw new Error(`invalid-profile: "${profileName2}"`);
|
|
64793
65383
|
}
|
|
64794
65384
|
try {
|
|
@@ -64835,13 +65425,13 @@ var init_mcp_catalog = __esm(() => {
|
|
|
64835
65425
|
|
|
64836
65426
|
// src/lib/market-install.ts
|
|
64837
65427
|
import { readFile as readFile25, writeFile as writeFile14, access as access5 } from "node:fs/promises";
|
|
64838
|
-
import { resolve as
|
|
65428
|
+
import { resolve as resolve45, dirname as dirname50, join as join169 } from "node:path";
|
|
64839
65429
|
import { fileURLToPath as fileURLToPath15 } from "node:url";
|
|
64840
65430
|
function repoRoot6() {
|
|
64841
|
-
return process.env.CUE_REPO_ROOT ?? process.env.SOUL_REPO_ROOT ??
|
|
65431
|
+
return process.env.CUE_REPO_ROOT ?? process.env.SOUL_REPO_ROOT ?? resolve45(dirname50(fileURLToPath15(import.meta.url)), "..", "..");
|
|
64842
65432
|
}
|
|
64843
65433
|
function profilesDir4() {
|
|
64844
|
-
return process.env.CUE_PROFILES_DIR ??
|
|
65434
|
+
return process.env.CUE_PROFILES_DIR ?? join169(repoRoot6(), "profiles");
|
|
64845
65435
|
}
|
|
64846
65436
|
function escapeRe2(s) {
|
|
64847
65437
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -64851,8 +65441,8 @@ async function profileYamlPath3(profile) {
|
|
|
64851
65441
|
throw new Error(`invalid-profile: "${profile}"`);
|
|
64852
65442
|
}
|
|
64853
65443
|
const dir = profilesDir4();
|
|
64854
|
-
const yamlPath =
|
|
64855
|
-
if (!
|
|
65444
|
+
const yamlPath = join169(dir, profile, "profile.yaml");
|
|
65445
|
+
if (!resolve45(yamlPath).startsWith(resolve45(dir))) {
|
|
64856
65446
|
throw new Error(`invalid-profile: "${profile}"`);
|
|
64857
65447
|
}
|
|
64858
65448
|
try {
|
|
@@ -65025,13 +65615,13 @@ var init_market_install = __esm(() => {
|
|
|
65025
65615
|
|
|
65026
65616
|
// src/lib/skill-clis.ts
|
|
65027
65617
|
import { readFileSync as readFileSync114 } from "node:fs";
|
|
65028
|
-
import { resolve as
|
|
65618
|
+
import { resolve as resolve46, dirname as dirname51, join as join170 } from "node:path";
|
|
65029
65619
|
import { fileURLToPath as fileURLToPath16 } from "node:url";
|
|
65030
65620
|
function repoRoot7() {
|
|
65031
|
-
return process.env.CUE_REPO_ROOT ?? process.env.SOUL_REPO_ROOT ??
|
|
65621
|
+
return process.env.CUE_REPO_ROOT ?? process.env.SOUL_REPO_ROOT ?? resolve46(dirname51(fileURLToPath16(import.meta.url)), "..", "..");
|
|
65032
65622
|
}
|
|
65033
65623
|
function recipesPath() {
|
|
65034
|
-
return
|
|
65624
|
+
return join170(repoRoot7(), "resources", "cli-recipes.json");
|
|
65035
65625
|
}
|
|
65036
65626
|
function splitFrontmatter2(content) {
|
|
65037
65627
|
const lines = content.split(`
|
|
@@ -65426,9 +66016,9 @@ function parsePlaybook(slug, content) {
|
|
|
65426
66016
|
}
|
|
65427
66017
|
|
|
65428
66018
|
// src/lib/permissions.ts
|
|
65429
|
-
import { existsSync as
|
|
66019
|
+
import { existsSync as existsSync124, readFileSync as readFileSync115 } from "node:fs";
|
|
65430
66020
|
import { homedir as homedir70 } from "node:os";
|
|
65431
|
-
import { join as
|
|
66021
|
+
import { join as join171 } from "node:path";
|
|
65432
66022
|
function parseRuleString(raw) {
|
|
65433
66023
|
const m2 = raw.match(/^\s*([^(]+?)\s*\((.*)\)\s*$/);
|
|
65434
66024
|
if (m2)
|
|
@@ -65467,7 +66057,7 @@ function buildPermissions(blocks) {
|
|
|
65467
66057
|
return { rules, counts, defaultMode };
|
|
65468
66058
|
}
|
|
65469
66059
|
function claudeUserDir() {
|
|
65470
|
-
return process.env.CUE_CLAUDE_HOME ??
|
|
66060
|
+
return process.env.CUE_CLAUDE_HOME ?? join171(homedir70(), ".claude");
|
|
65471
66061
|
}
|
|
65472
66062
|
function readPermsFile(path) {
|
|
65473
66063
|
try {
|
|
@@ -65479,16 +66069,16 @@ function readPermsFile(path) {
|
|
|
65479
66069
|
}
|
|
65480
66070
|
function collectPermissions() {
|
|
65481
66071
|
const userDir = claudeUserDir();
|
|
65482
|
-
const proj =
|
|
66072
|
+
const proj = join171(process.cwd(), ".claude");
|
|
65483
66073
|
const files = [
|
|
65484
66074
|
{ label: "managed", path: "/etc/claude-code/managed-settings.json", present: false },
|
|
65485
|
-
{ label: "project · local", path:
|
|
65486
|
-
{ label: "project", path:
|
|
65487
|
-
{ label: "user · local", path:
|
|
65488
|
-
{ label: "user", path:
|
|
66075
|
+
{ label: "project · local", path: join171(proj, "settings.local.json"), present: false },
|
|
66076
|
+
{ label: "project", path: join171(proj, "settings.json"), present: false },
|
|
66077
|
+
{ label: "user · local", path: join171(userDir, "settings.local.json"), present: false },
|
|
66078
|
+
{ label: "user", path: join171(userDir, "settings.json"), present: false }
|
|
65489
66079
|
];
|
|
65490
66080
|
const blocks = files.map((f2) => {
|
|
65491
|
-
f2.present =
|
|
66081
|
+
f2.present = existsSync124(f2.path);
|
|
65492
66082
|
return { label: f2.label, perms: f2.present ? readPermsFile(f2.path) : null };
|
|
65493
66083
|
});
|
|
65494
66084
|
const { rules, counts, defaultMode } = buildPermissions(blocks);
|
|
@@ -65627,14 +66217,14 @@ function computeVersionInfo(current, doc) {
|
|
|
65627
66217
|
}
|
|
65628
66218
|
|
|
65629
66219
|
// src/lib/dashboard-env-reader.ts
|
|
65630
|
-
import { existsSync as
|
|
66220
|
+
import { existsSync as existsSync125, readFileSync as readFileSync116 } from "node:fs";
|
|
65631
66221
|
import { homedir as homedir71 } from "node:os";
|
|
65632
|
-
import { join as
|
|
66222
|
+
import { join as join172 } from "node:path";
|
|
65633
66223
|
function loadEnvFolderDefs(opts) {
|
|
65634
66224
|
const dir = opts?.configDirOverride ?? configDir();
|
|
65635
|
-
const exists2 = opts?.existsFn ??
|
|
66225
|
+
const exists2 = opts?.existsFn ?? existsSync125;
|
|
65636
66226
|
const read = opts?.readFn ?? ((p2) => readFileSync116(p2, "utf8"));
|
|
65637
|
-
const cfgPath =
|
|
66227
|
+
const cfgPath = join172(dir, "env-folders.json");
|
|
65638
66228
|
try {
|
|
65639
66229
|
if (exists2(cfgPath)) {
|
|
65640
66230
|
const parsed = JSON.parse(read(cfgPath));
|
|
@@ -65680,7 +66270,7 @@ function parseEnvText(raw, revealKey) {
|
|
|
65680
66270
|
}
|
|
65681
66271
|
return out;
|
|
65682
66272
|
}
|
|
65683
|
-
var DEFAULT_ENV_FOLDER_DEFS, expandHome = (p2) => p2.startsWith("~/") ?
|
|
66273
|
+
var DEFAULT_ENV_FOLDER_DEFS, expandHome = (p2) => p2.startsWith("~/") ? join172(homedir71(), p2.slice(2)) : p2, ENV_FOLDER_DEFS, ENV_SECRET_RE;
|
|
65684
66274
|
var init_dashboard_env_reader = __esm(() => {
|
|
65685
66275
|
init_config_paths();
|
|
65686
66276
|
DEFAULT_ENV_FOLDER_DEFS = [
|
|
@@ -65697,12 +66287,12 @@ var init_dashboard_env_reader = __esm(() => {
|
|
|
65697
66287
|
|
|
65698
66288
|
// src/lib/dashboard-static-assets.ts
|
|
65699
66289
|
import { readFile as readFile26, stat as statAsync } from "node:fs/promises";
|
|
65700
|
-
import { join as
|
|
66290
|
+
import { join as join173, resolve as resolve47 } from "node:path";
|
|
65701
66291
|
function mergeProfilesDir() {
|
|
65702
|
-
return process.env.CUE_PROFILES_DIR ??
|
|
66292
|
+
return process.env.CUE_PROFILES_DIR ?? join173(REPO_ROOT13, "profiles");
|
|
65703
66293
|
}
|
|
65704
66294
|
function pluginLogosDir() {
|
|
65705
|
-
return process.env.CUE_PLUGIN_LOGOS_DIR ??
|
|
66295
|
+
return process.env.CUE_PLUGIN_LOGOS_DIR ?? join173(REPO_ROOT13, "resources", "plugin-logos");
|
|
65706
66296
|
}
|
|
65707
66297
|
function contentTypeFor(path) {
|
|
65708
66298
|
if (path.endsWith(".html"))
|
|
@@ -65736,8 +66326,8 @@ async function serveProfileIcon(rawName) {
|
|
|
65736
66326
|
return new Response("no icon", { status: 404 });
|
|
65737
66327
|
}
|
|
65738
66328
|
const dir = mergeProfilesDir();
|
|
65739
|
-
const file =
|
|
65740
|
-
if (!file.startsWith(
|
|
66329
|
+
const file = resolve47(join173(dir, name, iconImage));
|
|
66330
|
+
if (!file.startsWith(resolve47(dir)))
|
|
65741
66331
|
return new Response("forbidden", { status: 403 });
|
|
65742
66332
|
try {
|
|
65743
66333
|
const st3 = await statAsync(file);
|
|
@@ -65761,8 +66351,8 @@ async function servePluginIcon(rawId) {
|
|
|
65761
66351
|
const iconImage = (await loadProfile(name)).iconImage;
|
|
65762
66352
|
if (iconImage && !iconImage.includes("/") && !iconImage.includes("\\") && !iconImage.includes("..")) {
|
|
65763
66353
|
const pdir = mergeProfilesDir();
|
|
65764
|
-
const pfile =
|
|
65765
|
-
if (pfile.startsWith(
|
|
66354
|
+
const pfile = resolve47(join173(pdir, name, iconImage));
|
|
66355
|
+
if (pfile.startsWith(resolve47(pdir))) {
|
|
65766
66356
|
try {
|
|
65767
66357
|
const st3 = await statAsync(pfile);
|
|
65768
66358
|
if (st3.isFile()) {
|
|
@@ -65775,8 +66365,8 @@ async function servePluginIcon(rawId) {
|
|
|
65775
66365
|
}
|
|
65776
66366
|
} catch {}
|
|
65777
66367
|
const gdir = pluginLogosDir();
|
|
65778
|
-
const gfile =
|
|
65779
|
-
if (!gfile.startsWith(
|
|
66368
|
+
const gfile = resolve47(join173(gdir, name + ".png"));
|
|
66369
|
+
if (!gfile.startsWith(resolve47(gdir)))
|
|
65780
66370
|
return new Response("forbidden", { status: 403 });
|
|
65781
66371
|
try {
|
|
65782
66372
|
const st3 = await statAsync(gfile);
|
|
@@ -65791,20 +66381,20 @@ async function servePluginIcon(rawId) {
|
|
|
65791
66381
|
var REPO_ROOT13;
|
|
65792
66382
|
var init_dashboard_static_assets = __esm(() => {
|
|
65793
66383
|
init_profile_loader();
|
|
65794
|
-
REPO_ROOT13 =
|
|
66384
|
+
REPO_ROOT13 = resolve47(new URL(import.meta.url).pathname, "..", "..", "..");
|
|
65795
66385
|
});
|
|
65796
66386
|
|
|
65797
66387
|
// src/lib/dashboard-server.ts
|
|
65798
|
-
import { existsSync as
|
|
66388
|
+
import { existsSync as existsSync126, readFileSync as readFileSync117, readdirSync as readdirSync61, statSync as statSync36 } from "node:fs";
|
|
65799
66389
|
import { readFile as readFile27, stat as statAsync2 } from "node:fs/promises";
|
|
65800
66390
|
import { homedir as homedir72 } from "node:os";
|
|
65801
|
-
import { join as
|
|
66391
|
+
import { join as join174, resolve as resolve48, sep as sep12 } from "node:path";
|
|
65802
66392
|
import { fileURLToPath as fileURLToPath17 } from "node:url";
|
|
65803
66393
|
function resolveProfileQuery(explicit) {
|
|
65804
66394
|
if (explicit)
|
|
65805
66395
|
return explicit;
|
|
65806
|
-
const pin =
|
|
65807
|
-
if (
|
|
66396
|
+
const pin = join174(process.cwd(), ".cue.profile");
|
|
66397
|
+
if (existsSync126(pin)) {
|
|
65808
66398
|
try {
|
|
65809
66399
|
const txt = readFileSync117(pin, "utf8").trim().split(`
|
|
65810
66400
|
`)[0]?.trim();
|
|
@@ -65892,12 +66482,12 @@ async function handleStatus2() {
|
|
|
65892
66482
|
}
|
|
65893
66483
|
async function handleProfiles() {
|
|
65894
66484
|
const names = await listProfiles();
|
|
65895
|
-
const runtimeRoot =
|
|
66485
|
+
const runtimeRoot = join174(configDir(), "runtime");
|
|
65896
66486
|
const rows = names.map((name) => {
|
|
65897
|
-
const claudeMd =
|
|
66487
|
+
const claudeMd = join174(runtimeRoot, name, "claude", "CLAUDE.md");
|
|
65898
66488
|
let sizeBytes = null;
|
|
65899
66489
|
try {
|
|
65900
|
-
if (
|
|
66490
|
+
if (existsSync126(claudeMd))
|
|
65901
66491
|
sizeBytes = statSync36(claudeMd).size;
|
|
65902
66492
|
} catch {}
|
|
65903
66493
|
return { name, claudeMdBytes: sizeBytes };
|
|
@@ -65905,10 +66495,10 @@ async function handleProfiles() {
|
|
|
65905
66495
|
return { ok: true, data: rows };
|
|
65906
66496
|
}
|
|
65907
66497
|
function playbooksDir() {
|
|
65908
|
-
return process.env.CUE_PLAYBOOKS_DIR ??
|
|
66498
|
+
return process.env.CUE_PLAYBOOKS_DIR ?? join174(REPO_ROOT14, "resources", "playbooks");
|
|
65909
66499
|
}
|
|
65910
66500
|
function commandsDir() {
|
|
65911
|
-
return process.env.CUE_COMMANDS_DIR ??
|
|
66501
|
+
return process.env.CUE_COMMANDS_DIR ?? join174(REPO_ROOT14, "resources", "commands");
|
|
65912
66502
|
}
|
|
65913
66503
|
async function handleProfilesFull() {
|
|
65914
66504
|
const names = await listProfiles();
|
|
@@ -65918,7 +66508,7 @@ async function handleProfilesFull() {
|
|
|
65918
66508
|
return {
|
|
65919
66509
|
name,
|
|
65920
66510
|
icon: p2.icon ?? null,
|
|
65921
|
-
iconImage: p2.iconImage &&
|
|
66511
|
+
iconImage: p2.iconImage && existsSync126(join174(mergeProfilesDir(), name, p2.iconImage)) ? p2.iconImage : null,
|
|
65922
66512
|
description: p2.description,
|
|
65923
66513
|
skills: p2.skills.local.length,
|
|
65924
66514
|
npx: p2.skills.npx.length,
|
|
@@ -65972,7 +66562,7 @@ async function handleProfileDetail(params) {
|
|
|
65972
66562
|
const slug = id.slice(id.lastIndexOf("/") + 1);
|
|
65973
66563
|
try {
|
|
65974
66564
|
const dir = await resolveLocalSkill(id);
|
|
65975
|
-
const path =
|
|
66565
|
+
const path = join174(dir, "SKILL.md");
|
|
65976
66566
|
const content = await readFile27(path, "utf8");
|
|
65977
66567
|
const sizeK = +((await statAsync2(path)).size / 1024).toFixed(1);
|
|
65978
66568
|
const parsed = parseSkillFromContent(id, content, slug);
|
|
@@ -66013,7 +66603,7 @@ Provided on demand via \`npx ${ref.repo}\`. The body is fetched at activation ti
|
|
|
66013
66603
|
if (!/^[A-Za-z0-9._-]+$/.test(slug))
|
|
66014
66604
|
return null;
|
|
66015
66605
|
try {
|
|
66016
|
-
const content = await readFile27(
|
|
66606
|
+
const content = await readFile27(join174(pbDir, `${slug}.md`), "utf8");
|
|
66017
66607
|
return parsePlaybook(slug, content);
|
|
66018
66608
|
} catch {
|
|
66019
66609
|
return null;
|
|
@@ -66034,8 +66624,8 @@ Provided on demand via \`npx ${ref.repo}\`. The body is fetched at activation ti
|
|
|
66034
66624
|
return { name: name2, ref, desc: "", argHint: null, body: stubCommandBody(name2), sizeK: 0, missing: true };
|
|
66035
66625
|
}
|
|
66036
66626
|
try {
|
|
66037
|
-
const path =
|
|
66038
|
-
if (!
|
|
66627
|
+
const path = join174(cmdDir, `${ref}.md`);
|
|
66628
|
+
if (!resolve48(path).startsWith(resolve48(cmdDir) + sep12)) {
|
|
66039
66629
|
return { name: name2, ref, desc: "", argHint: null, body: stubCommandBody(name2), sizeK: 0, missing: true };
|
|
66040
66630
|
}
|
|
66041
66631
|
const content = await readFile27(path, "utf8");
|
|
@@ -66071,8 +66661,8 @@ Provided on demand via \`npx ${ref.repo}\`. The body is fetched at activation ti
|
|
|
66071
66661
|
}
|
|
66072
66662
|
function claudeDirForSource(source, profileName2) {
|
|
66073
66663
|
if (source === "global")
|
|
66074
|
-
return
|
|
66075
|
-
return profileName2 ?
|
|
66664
|
+
return join174(homedir72(), ".claude");
|
|
66665
|
+
return profileName2 ? join174(configDir(), "runtime", profileName2, "claude") : null;
|
|
66076
66666
|
}
|
|
66077
66667
|
function resolveHookScript(command2, source, profileName2) {
|
|
66078
66668
|
const m2 = command2.match(/(\S+\.(?:sh|bash|zsh|js|mjs|cjs|ts|py|rb|pl))\b/);
|
|
@@ -66084,7 +66674,7 @@ function resolveHookScript(command2, source, profileName2) {
|
|
|
66084
66674
|
return null;
|
|
66085
66675
|
if (!p2.startsWith("/"))
|
|
66086
66676
|
return null;
|
|
66087
|
-
return
|
|
66677
|
+
return resolve48(p2);
|
|
66088
66678
|
}
|
|
66089
66679
|
function hookLanguage(path) {
|
|
66090
66680
|
const ext = path.slice(path.lastIndexOf(".") + 1).toLowerCase();
|
|
@@ -66103,7 +66693,7 @@ function hookLanguage(path) {
|
|
|
66103
66693
|
return map[ext] ?? ext ?? "text";
|
|
66104
66694
|
}
|
|
66105
66695
|
function readHooksFile(path, source, profileName2) {
|
|
66106
|
-
if (!
|
|
66696
|
+
if (!existsSync126(path))
|
|
66107
66697
|
return [];
|
|
66108
66698
|
let parsed;
|
|
66109
66699
|
try {
|
|
@@ -66145,8 +66735,8 @@ async function resolveHooksProfile(profileParam) {
|
|
|
66145
66735
|
return resolveActiveProfile();
|
|
66146
66736
|
}
|
|
66147
66737
|
function enumerateHooks(profileName2) {
|
|
66148
|
-
const globalPath =
|
|
66149
|
-
const runtimePath = profileName2 ?
|
|
66738
|
+
const globalPath = join174(homedir72(), ".claude", "settings.json");
|
|
66739
|
+
const runtimePath = profileName2 ? join174(configDir(), "runtime", profileName2, "claude", "settings.json") : null;
|
|
66150
66740
|
const flat = [
|
|
66151
66741
|
...readHooksFile(globalPath, "global", null),
|
|
66152
66742
|
...runtimePath ? readHooksFile(runtimePath, "profile", profileName2) : []
|
|
@@ -66188,10 +66778,10 @@ async function handleHookSource(params) {
|
|
|
66188
66778
|
return { ok: false, error: "missing-path" };
|
|
66189
66779
|
const name = await resolveHooksProfile(params.get("profile"));
|
|
66190
66780
|
const allow = new Set(enumerateHooks(name).map((h2) => h2.scriptPath).filter((p2) => !!p2));
|
|
66191
|
-
const abs =
|
|
66781
|
+
const abs = resolve48(requested);
|
|
66192
66782
|
if (!allow.has(abs))
|
|
66193
66783
|
return { ok: false, error: "not-a-hook-script" };
|
|
66194
|
-
if (!
|
|
66784
|
+
if (!existsSync126(abs) || !statSync36(abs).isFile())
|
|
66195
66785
|
return { ok: false, error: "not-found" };
|
|
66196
66786
|
if (statSync36(abs).size > HOOK_SOURCE_MAX_BYTES)
|
|
66197
66787
|
return { ok: false, error: "too-large" };
|
|
@@ -66245,8 +66835,8 @@ async function handleMergeSave(body) {
|
|
|
66245
66835
|
try {
|
|
66246
66836
|
const preview = await mergeProfiles(names, { name, optimize: body?.actions, budget: body?.budget });
|
|
66247
66837
|
const yaml = renderMerged(preview, mode);
|
|
66248
|
-
const existingPath =
|
|
66249
|
-
const previousYaml =
|
|
66838
|
+
const existingPath = join174(mergeProfilesDir(), name, "profile.yaml");
|
|
66839
|
+
const previousYaml = existsSync126(existingPath) ? readFileSync117(existingPath, "utf8") : null;
|
|
66250
66840
|
const path = await writeMergedProfile(name, yaml, { force: body?.force });
|
|
66251
66841
|
return { ok: true, data: { path, mode, created: previousYaml === null, yaml, previousYaml } };
|
|
66252
66842
|
} catch (err) {
|
|
@@ -66265,7 +66855,7 @@ async function handleMcpCatalog() {
|
|
|
66265
66855
|
for (const name of await listProfiles()) {
|
|
66266
66856
|
try {
|
|
66267
66857
|
const p2 = await loadProfile(name);
|
|
66268
|
-
const iconImage = p2.iconImage &&
|
|
66858
|
+
const iconImage = p2.iconImage && existsSync126(join174(profilesDir5, name, p2.iconImage)) ? p2.iconImage : null;
|
|
66269
66859
|
for (const m2 of p2.mcps) {
|
|
66270
66860
|
const list = usedBy.get(m2.id) ?? [];
|
|
66271
66861
|
list.push({ name, icon: p2.icon ?? null, iconImage });
|
|
@@ -66348,9 +66938,9 @@ async function handleTriggerGaps(params) {
|
|
|
66348
66938
|
}
|
|
66349
66939
|
}))).filter((s) => s !== null);
|
|
66350
66940
|
const userPrompts = collectUserPrompts(sinceDays);
|
|
66351
|
-
const
|
|
66941
|
+
const usage6 = computeSkillUsage(profile, { windowDays: sinceDays });
|
|
66352
66942
|
const hits = new Map;
|
|
66353
|
-
for (const u of
|
|
66943
|
+
for (const u of usage6)
|
|
66354
66944
|
hits.set(u.id, u.hits);
|
|
66355
66945
|
const rows = computeTriggerGaps({ skills, userPrompts, hits });
|
|
66356
66946
|
const data = { profile: name, windowDays: sinceDays, promptsScanned: userPrompts.length, rows };
|
|
@@ -66468,7 +67058,7 @@ async function handleDiscoveredPlugins() {
|
|
|
66468
67058
|
}
|
|
66469
67059
|
function localVersion() {
|
|
66470
67060
|
try {
|
|
66471
|
-
const pkg = JSON.parse(readFileSync117(
|
|
67061
|
+
const pkg = JSON.parse(readFileSync117(join174(REPO_ROOT14, "package.json"), "utf8"));
|
|
66472
67062
|
return pkg.version ?? "0.0.0";
|
|
66473
67063
|
} catch {
|
|
66474
67064
|
return "0.0.0";
|
|
@@ -66490,11 +67080,11 @@ async function handleVersion() {
|
|
|
66490
67080
|
return { ok: true, data };
|
|
66491
67081
|
}
|
|
66492
67082
|
function registryIndexPath() {
|
|
66493
|
-
return
|
|
67083
|
+
return join174(REPO_ROOT14, "docs", "registry", "index.json");
|
|
66494
67084
|
}
|
|
66495
67085
|
async function loadMarketRegistry() {
|
|
66496
67086
|
const path = registryIndexPath();
|
|
66497
|
-
if (
|
|
67087
|
+
if (existsSync126(path)) {
|
|
66498
67088
|
try {
|
|
66499
67089
|
return JSON.parse(readFileSync117(path, "utf8"));
|
|
66500
67090
|
} catch {}
|
|
@@ -66573,7 +67163,7 @@ function playbookMarketItems() {
|
|
|
66573
67163
|
if (!/^[A-Za-z0-9._-]+$/.test(slug))
|
|
66574
67164
|
continue;
|
|
66575
67165
|
try {
|
|
66576
|
-
const content = readFileSync117(
|
|
67166
|
+
const content = readFileSync117(join174(dir, file), "utf8");
|
|
66577
67167
|
const pb = parsePlaybook(slug, content);
|
|
66578
67168
|
items.push({
|
|
66579
67169
|
id: `workflow:${slug}`,
|
|
@@ -66646,7 +67236,7 @@ function localMcpMarketItems(registryMcpIds) {
|
|
|
66646
67236
|
function cliMarketItems() {
|
|
66647
67237
|
let recipes;
|
|
66648
67238
|
try {
|
|
66649
|
-
recipes = JSON.parse(readFileSync117(
|
|
67239
|
+
recipes = JSON.parse(readFileSync117(join174(REPO_ROOT14, "resources", "cli-recipes.json"), "utf8"));
|
|
66650
67240
|
} catch {
|
|
66651
67241
|
return [];
|
|
66652
67242
|
}
|
|
@@ -66799,7 +67389,7 @@ async function handleWorkflowSave(body) {
|
|
|
66799
67389
|
}
|
|
66800
67390
|
async function handleEnvFolders() {
|
|
66801
67391
|
const folders = await Promise.all(ENV_FOLDER_DEFS.map(async (f2) => {
|
|
66802
|
-
const abs =
|
|
67392
|
+
const abs = join174(expandHome(f2.path), ".env");
|
|
66803
67393
|
let count = 0;
|
|
66804
67394
|
try {
|
|
66805
67395
|
const raw = await readFile27(abs, "utf8");
|
|
@@ -66815,7 +67405,7 @@ async function handleEnv(params) {
|
|
|
66815
67405
|
const def = ENV_FOLDER_DEFS.find((f2) => f2.path === folder);
|
|
66816
67406
|
if (!def)
|
|
66817
67407
|
return { ok: false, error: "unknown-folder" };
|
|
66818
|
-
const abs =
|
|
67408
|
+
const abs = join174(expandHome(def.path), ".env");
|
|
66819
67409
|
let raw;
|
|
66820
67410
|
try {
|
|
66821
67411
|
raw = await readFile27(abs, "utf8");
|
|
@@ -66918,20 +67508,20 @@ function createHandler() {
|
|
|
66918
67508
|
return Response.json({ ok: false, error: err.message }, { status: 500 });
|
|
66919
67509
|
}
|
|
66920
67510
|
}
|
|
66921
|
-
if (
|
|
67511
|
+
if (existsSync126(WEB_DIST)) {
|
|
66922
67512
|
const requested = url.pathname === "/" ? "/index.html" : url.pathname;
|
|
66923
|
-
const file =
|
|
66924
|
-
const resolved2 =
|
|
67513
|
+
const file = join174(WEB_DIST, requested);
|
|
67514
|
+
const resolved2 = resolve48(file);
|
|
66925
67515
|
if (!resolved2.startsWith(WEB_DIST)) {
|
|
66926
67516
|
return new Response("forbidden", { status: 403 });
|
|
66927
67517
|
}
|
|
66928
|
-
if (
|
|
67518
|
+
if (existsSync126(resolved2) && statSync36(resolved2).isFile()) {
|
|
66929
67519
|
return new Response(readFileSync117(resolved2), {
|
|
66930
67520
|
headers: { "Content-Type": contentTypeFor(resolved2) }
|
|
66931
67521
|
});
|
|
66932
67522
|
}
|
|
66933
|
-
const indexHtml =
|
|
66934
|
-
if (
|
|
67523
|
+
const indexHtml = join174(WEB_DIST, "index.html");
|
|
67524
|
+
if (existsSync126(indexHtml)) {
|
|
66935
67525
|
return new Response(readFileSync117(indexHtml), {
|
|
66936
67526
|
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
66937
67527
|
});
|
|
@@ -66947,7 +67537,7 @@ function createHandler() {
|
|
|
66947
67537
|
};
|
|
66948
67538
|
}
|
|
66949
67539
|
function webDistExists() {
|
|
66950
|
-
return
|
|
67540
|
+
return existsSync126(WEB_DIST);
|
|
66951
67541
|
}
|
|
66952
67542
|
var REPO_ROOT14, WEB_DIST, profileDetailCache, PROFILE_DETAIL_TTL_MS = 60000, HOOK_SOURCE_MAX_BYTES, mcpCatalogCache = null, MCP_CATALOG_TTL_MS = 60000, triggerGapsCache, TRIGGER_GAPS_TTL_MS = 90000, SSE_HEADERS, STREAM_TICK_MS = 3000, STREAM_HEARTBEAT_MS = 20000, NPM_LATEST_URL = "https://registry.npmjs.org/cue-ai/latest", VERSION_TTL_MS, versionCache = null, REGISTRY_URL3 = "https://opencue.github.io/cue/registry/index.json", marketCache = null, MARKET_TTL_MS = 60000, MARKET_ADD_KINDS, ROUTES, POST_ROUTES;
|
|
66953
67543
|
var init_dashboard_server = __esm(() => {
|
|
@@ -66976,8 +67566,8 @@ var init_dashboard_server = __esm(() => {
|
|
|
66976
67566
|
init_trigger_gaps();
|
|
66977
67567
|
init_dashboard_env_reader();
|
|
66978
67568
|
init_dashboard_static_assets();
|
|
66979
|
-
REPO_ROOT14 =
|
|
66980
|
-
WEB_DIST =
|
|
67569
|
+
REPO_ROOT14 = resolve48(fileURLToPath17(import.meta.url), "..", "..", "..");
|
|
67570
|
+
WEB_DIST = join174(REPO_ROOT14, "web", "dist");
|
|
66981
67571
|
profileDetailCache = new Map;
|
|
66982
67572
|
HOOK_SOURCE_MAX_BYTES = 256 * 1024;
|
|
66983
67573
|
triggerGapsCache = new Map;
|
|
@@ -67025,16 +67615,16 @@ var init_dashboard_server = __esm(() => {
|
|
|
67025
67615
|
// src/commands/dashboard.ts
|
|
67026
67616
|
var exports_dashboard = {};
|
|
67027
67617
|
__export(exports_dashboard, {
|
|
67028
|
-
run: () =>
|
|
67618
|
+
run: () => run93,
|
|
67029
67619
|
parseArgs: () => parseArgs14
|
|
67030
67620
|
});
|
|
67031
67621
|
import { spawn as spawn10 } from "node:child_process";
|
|
67032
67622
|
import { createServer } from "node:http";
|
|
67033
67623
|
function readBody(req) {
|
|
67034
|
-
return new Promise((
|
|
67624
|
+
return new Promise((resolve49, reject) => {
|
|
67035
67625
|
const chunks = [];
|
|
67036
67626
|
req.on("data", (c) => chunks.push(c));
|
|
67037
|
-
req.on("end", () =>
|
|
67627
|
+
req.on("end", () => resolve49(Buffer.concat(chunks)));
|
|
67038
67628
|
req.on("error", reject);
|
|
67039
67629
|
});
|
|
67040
67630
|
}
|
|
@@ -67146,7 +67736,7 @@ function helpText7() {
|
|
|
67146
67736
|
].join(`
|
|
67147
67737
|
`);
|
|
67148
67738
|
}
|
|
67149
|
-
async function
|
|
67739
|
+
async function run93(argv) {
|
|
67150
67740
|
const args = parseArgs14(argv);
|
|
67151
67741
|
if (args.help) {
|
|
67152
67742
|
process.stdout.write(helpText7());
|
|
@@ -67168,9 +67758,9 @@ async function run92(argv) {
|
|
|
67168
67758
|
})();
|
|
67169
67759
|
});
|
|
67170
67760
|
try {
|
|
67171
|
-
await new Promise((
|
|
67761
|
+
await new Promise((resolve49, reject) => {
|
|
67172
67762
|
server.once("error", reject);
|
|
67173
|
-
server.listen(args.port, args.host,
|
|
67763
|
+
server.listen(args.port, args.host, resolve49);
|
|
67174
67764
|
});
|
|
67175
67765
|
} catch (err) {
|
|
67176
67766
|
process.stderr.write(`cue dashboard: failed to bind ${url}: ${err.message}
|
|
@@ -67200,7 +67790,7 @@ var init_dashboard = __esm(() => {
|
|
|
67200
67790
|
// src/commands/dash.ts
|
|
67201
67791
|
var exports_dash = {};
|
|
67202
67792
|
__export(exports_dash, {
|
|
67203
|
-
run: () =>
|
|
67793
|
+
run: () => run94,
|
|
67204
67794
|
parseDashArgs: () => parseDashArgs,
|
|
67205
67795
|
dashUrl: () => dashUrl,
|
|
67206
67796
|
dashFetch: () => dashFetch,
|
|
@@ -67287,11 +67877,11 @@ function helpText8() {
|
|
|
67287
67877
|
`);
|
|
67288
67878
|
}
|
|
67289
67879
|
function writeOut(s) {
|
|
67290
|
-
return new Promise((
|
|
67291
|
-
process.stdout.write(s, () =>
|
|
67880
|
+
return new Promise((resolve49) => {
|
|
67881
|
+
process.stdout.write(s, () => resolve49());
|
|
67292
67882
|
});
|
|
67293
67883
|
}
|
|
67294
|
-
async function
|
|
67884
|
+
async function run94(argv) {
|
|
67295
67885
|
const a = parseDashArgs(argv);
|
|
67296
67886
|
if (a.help || !a.sub) {
|
|
67297
67887
|
process.stdout.write(helpText8());
|
|
@@ -67389,7 +67979,7 @@ function toParams(obj) {
|
|
|
67389
67979
|
async function dispatch(req) {
|
|
67390
67980
|
const isNotification = req.id === undefined;
|
|
67391
67981
|
const respond = (result) => isNotification ? null : { jsonrpc: "2.0", id: req.id ?? null, result };
|
|
67392
|
-
const
|
|
67982
|
+
const fail2 = (code, message, data) => isNotification ? null : { jsonrpc: "2.0", id: req.id ?? null, error: { code, message, data } };
|
|
67393
67983
|
switch (req.method) {
|
|
67394
67984
|
case "initialize":
|
|
67395
67985
|
return respond({
|
|
@@ -67414,7 +68004,7 @@ async function dispatch(req) {
|
|
|
67414
68004
|
const args = params.arguments ?? {};
|
|
67415
68005
|
const tool = TOOLS.find((t) => t.name === name);
|
|
67416
68006
|
if (!tool)
|
|
67417
|
-
return
|
|
68007
|
+
return fail2(-32601, `Unknown tool: ${name}`);
|
|
67418
68008
|
try {
|
|
67419
68009
|
const result = await tool.handler(args);
|
|
67420
68010
|
return respond({
|
|
@@ -67422,13 +68012,13 @@ async function dispatch(req) {
|
|
|
67422
68012
|
isError: !result.ok
|
|
67423
68013
|
});
|
|
67424
68014
|
} catch (err) {
|
|
67425
|
-
return
|
|
68015
|
+
return fail2(-32603, `Tool ${name} threw: ${err.message}`);
|
|
67426
68016
|
}
|
|
67427
68017
|
}
|
|
67428
68018
|
case "ping":
|
|
67429
68019
|
return respond({});
|
|
67430
68020
|
default:
|
|
67431
|
-
return
|
|
68021
|
+
return fail2(-32601, `Method not found: ${req.method}`);
|
|
67432
68022
|
}
|
|
67433
68023
|
}
|
|
67434
68024
|
async function runStdioServer() {
|
|
@@ -67561,7 +68151,7 @@ var init_mcp_server = __esm(() => {
|
|
|
67561
68151
|
// src/commands/mcp.ts
|
|
67562
68152
|
var exports_mcp = {};
|
|
67563
68153
|
__export(exports_mcp, {
|
|
67564
|
-
run: () =>
|
|
68154
|
+
run: () => run95,
|
|
67565
68155
|
parseArgs: () => parseArgs15
|
|
67566
68156
|
});
|
|
67567
68157
|
function parseArgs15(argv) {
|
|
@@ -67692,7 +68282,7 @@ async function runTest2(args) {
|
|
|
67692
68282
|
}
|
|
67693
68283
|
return result.isError ? 1 : 0;
|
|
67694
68284
|
}
|
|
67695
|
-
async function
|
|
68285
|
+
async function run95(argv) {
|
|
67696
68286
|
const args = parseArgs15(argv);
|
|
67697
68287
|
if (args.help) {
|
|
67698
68288
|
process.stdout.write(helpText9());
|
|
@@ -67718,12 +68308,12 @@ var init_mcp = __esm(() => {
|
|
|
67718
68308
|
// src/commands/mem.ts
|
|
67719
68309
|
var exports_mem = {};
|
|
67720
68310
|
__export(exports_mem, {
|
|
67721
|
-
run: () =>
|
|
68311
|
+
run: () => run96
|
|
67722
68312
|
});
|
|
67723
|
-
import { copyFileSync as copyFileSync7, existsSync as
|
|
68313
|
+
import { copyFileSync as copyFileSync7, existsSync as existsSync127, mkdirSync as mkdirSync53, readdirSync as readdirSync62, readFileSync as readFileSync118, rmSync as rmSync16, statSync as statSync37 } from "node:fs";
|
|
67724
68314
|
import { homedir as homedir73 } from "node:os";
|
|
67725
|
-
import { join as
|
|
67726
|
-
async function
|
|
68315
|
+
import { join as join175 } from "node:path";
|
|
68316
|
+
async function run96(args) {
|
|
67727
68317
|
if (args.includes("-h") || args.includes("--help")) {
|
|
67728
68318
|
printHelp9();
|
|
67729
68319
|
return 0;
|
|
@@ -67753,8 +68343,8 @@ async function runStatus2() {
|
|
|
67753
68343
|
const names = new Set(await safeListProfiles());
|
|
67754
68344
|
for (const n of Object.keys(registry.slots))
|
|
67755
68345
|
names.add(n);
|
|
67756
|
-
const profilesRoot3 =
|
|
67757
|
-
if (
|
|
68346
|
+
const profilesRoot3 = join175(home, ".claude-mem", "profiles");
|
|
68347
|
+
if (existsSync127(profilesRoot3)) {
|
|
67758
68348
|
for (const entry of readdirSync62(profilesRoot3, { withFileTypes: true })) {
|
|
67759
68349
|
if (entry.isDirectory())
|
|
67760
68350
|
names.add(entry.name);
|
|
@@ -67776,8 +68366,8 @@ claude-mem per-profile stores
|
|
|
67776
68366
|
const dir = claudeMemDataDir(name, home);
|
|
67777
68367
|
const slot = registry.slots[name];
|
|
67778
68368
|
const ports = slot === undefined ? null : portsForSlot(slot);
|
|
67779
|
-
const dbPath =
|
|
67780
|
-
const onDisk =
|
|
68369
|
+
const dbPath = join175(dir, "claude-mem.db");
|
|
68370
|
+
const onDisk = existsSync127(dbPath);
|
|
67781
68371
|
if (!onDisk && ports === null)
|
|
67782
68372
|
continue;
|
|
67783
68373
|
shown++;
|
|
@@ -67859,29 +68449,29 @@ async function runSeed(rest) {
|
|
|
67859
68449
|
return 1;
|
|
67860
68450
|
}
|
|
67861
68451
|
const known = await safeListProfiles();
|
|
67862
|
-
const hasRuntime =
|
|
68452
|
+
const hasRuntime = existsSync127(join175(configDir(), "runtime", name));
|
|
67863
68453
|
if (known.length > 0 && !known.includes(name) && !hasRuntime) {
|
|
67864
68454
|
process.stderr.write(`cue mem seed: no profile or runtime named "${name}" (run \`cue list\`)
|
|
67865
68455
|
`);
|
|
67866
68456
|
return 1;
|
|
67867
68457
|
}
|
|
67868
68458
|
const home = homedir73();
|
|
67869
|
-
const source = fromArg ??
|
|
67870
|
-
const sourceDb =
|
|
67871
|
-
if (!
|
|
68459
|
+
const source = fromArg ?? join175(home, ".claude-mem");
|
|
68460
|
+
const sourceDb = join175(source, "claude-mem.db");
|
|
68461
|
+
if (!existsSync127(sourceDb)) {
|
|
67872
68462
|
process.stderr.write(`cue mem seed: no claude-mem.db at ${source}
|
|
67873
68463
|
`);
|
|
67874
68464
|
return 1;
|
|
67875
68465
|
}
|
|
67876
68466
|
const target = claudeMemDataDir(name, home);
|
|
67877
|
-
const targetDb =
|
|
67878
|
-
if (
|
|
68467
|
+
const targetDb = join175(target, "claude-mem.db");
|
|
68468
|
+
if (existsSync127(targetDb) && !force) {
|
|
67879
68469
|
process.stderr.write(`cue mem seed: ${name} already has a store at ${target}
|
|
67880
68470
|
` + ` Refusing to overwrite. Re-run with --force to replace it.
|
|
67881
68471
|
`);
|
|
67882
68472
|
return 1;
|
|
67883
68473
|
}
|
|
67884
|
-
|
|
68474
|
+
mkdirSync53(target, { recursive: true });
|
|
67885
68475
|
const snapshot = snapshotDb(sourceDb, targetDb);
|
|
67886
68476
|
if (snapshot.ok) {
|
|
67887
68477
|
process.stdout.write(`Seeded ${name} ← ${source}
|
|
@@ -67892,10 +68482,10 @@ async function runSeed(rest) {
|
|
|
67892
68482
|
let copied = 0;
|
|
67893
68483
|
let bytes = 0;
|
|
67894
68484
|
for (const file of DB_FILES) {
|
|
67895
|
-
const src =
|
|
67896
|
-
if (!
|
|
68485
|
+
const src = join175(source, file);
|
|
68486
|
+
if (!existsSync127(src))
|
|
67897
68487
|
continue;
|
|
67898
|
-
copyFileSync7(src,
|
|
68488
|
+
copyFileSync7(src, join175(target, file));
|
|
67899
68489
|
copied++;
|
|
67900
68490
|
bytes += statSync37(src).size;
|
|
67901
68491
|
}
|
|
@@ -67911,8 +68501,8 @@ function snapshotDb(srcDb, destDb) {
|
|
|
67911
68501
|
const { Database } = __require("bun:sqlite");
|
|
67912
68502
|
const db = new Database(srcDb, { readonly: true });
|
|
67913
68503
|
try {
|
|
67914
|
-
if (
|
|
67915
|
-
|
|
68504
|
+
if (existsSync127(destDb))
|
|
68505
|
+
rmSync16(destDb, { force: true });
|
|
67916
68506
|
db.exec(`VACUUM INTO '${destDb.replace(/'/g, "''")}'`);
|
|
67917
68507
|
} finally {
|
|
67918
68508
|
db.close();
|
|
@@ -67925,7 +68515,7 @@ function snapshotDb(srcDb, destDb) {
|
|
|
67925
68515
|
function readRegistry(home) {
|
|
67926
68516
|
const path = registryPath(home);
|
|
67927
68517
|
try {
|
|
67928
|
-
if (!
|
|
68518
|
+
if (!existsSync127(path))
|
|
67929
68519
|
return { version: 1, slots: {} };
|
|
67930
68520
|
const raw = JSON.parse(readFileSync118(path, "utf8"));
|
|
67931
68521
|
if (!raw || typeof raw.slots !== "object" || raw.slots === null) {
|
|
@@ -67944,8 +68534,8 @@ async function safeListProfiles() {
|
|
|
67944
68534
|
}
|
|
67945
68535
|
}
|
|
67946
68536
|
function workerState(dataDir) {
|
|
67947
|
-
const pidFile =
|
|
67948
|
-
if (!
|
|
68537
|
+
const pidFile = join175(dataDir, "worker.pid");
|
|
68538
|
+
if (!existsSync127(pidFile))
|
|
67949
68539
|
return "stopped";
|
|
67950
68540
|
try {
|
|
67951
68541
|
const raw = readFileSync118(pidFile, "utf8").trim();
|
|
@@ -68235,11 +68825,11 @@ var init__index = __esm(() => {
|
|
|
68235
68825
|
load: async () => ({
|
|
68236
68826
|
run: async (args) => {
|
|
68237
68827
|
if (args.includes("--docker")) {
|
|
68238
|
-
const { run:
|
|
68239
|
-
return
|
|
68828
|
+
const { run: run98 } = await Promise.resolve().then(() => (init_export_docker(), exports_export_docker));
|
|
68829
|
+
return run98(args.filter((a) => a !== "--docker"));
|
|
68240
68830
|
}
|
|
68241
|
-
const { run:
|
|
68242
|
-
return
|
|
68831
|
+
const { run: run97 } = await Promise.resolve().then(() => (init_import_profile(), exports_import_profile));
|
|
68832
|
+
return run97(["export", ...args]);
|
|
68243
68833
|
}
|
|
68244
68834
|
})
|
|
68245
68835
|
},
|
|
@@ -68323,6 +68913,10 @@ var init__index = __esm(() => {
|
|
|
68323
68913
|
summary: "Measure profile efficiency: tokens, skill usage, cost",
|
|
68324
68914
|
load: () => Promise.resolve().then(() => (init_benchmark(), exports_benchmark))
|
|
68325
68915
|
},
|
|
68916
|
+
"community-eval": {
|
|
68917
|
+
summary: "Run and optionally share a synthetic CodeGraph A/B benchmark",
|
|
68918
|
+
load: () => Promise.resolve().then(() => (init_community_eval(), exports_community_eval))
|
|
68919
|
+
},
|
|
68326
68920
|
brief: {
|
|
68327
68921
|
summary: "Show this directory's verified facts as handed to the agent; --write persists them",
|
|
68328
68922
|
load: () => Promise.resolve().then(() => (init_brief(), exports_brief))
|
|
@@ -68356,12 +68950,12 @@ var init__index = __esm(() => {
|
|
|
68356
68950
|
load: async () => ({
|
|
68357
68951
|
run: async () => {
|
|
68358
68952
|
const { maybePromptStar: maybePromptStar2 } = await Promise.resolve().then(() => (init_star_prompt(), exports_star_prompt));
|
|
68359
|
-
const { existsSync:
|
|
68360
|
-
const { join:
|
|
68953
|
+
const { existsSync: existsSync128, unlinkSync: unlinkSync7 } = await import("node:fs");
|
|
68954
|
+
const { join: join176 } = await import("node:path");
|
|
68361
68955
|
const { configDir: configDir2 } = await Promise.resolve().then(() => (init_config_paths(), exports_config_paths));
|
|
68362
|
-
const flag =
|
|
68363
|
-
if (
|
|
68364
|
-
|
|
68956
|
+
const flag = join176(configDir2(), ".star-prompted");
|
|
68957
|
+
if (existsSync128(flag))
|
|
68958
|
+
unlinkSync7(flag);
|
|
68365
68959
|
await maybePromptStar2();
|
|
68366
68960
|
return 0;
|
|
68367
68961
|
}
|
|
@@ -68425,7 +69019,7 @@ var init__index = __esm(() => {
|
|
|
68425
69019
|
// src/commands/completions.ts
|
|
68426
69020
|
var exports_completions = {};
|
|
68427
69021
|
__export(exports_completions, {
|
|
68428
|
-
run: () =>
|
|
69022
|
+
run: () => run97,
|
|
68429
69023
|
completionScript: () => completionScript
|
|
68430
69024
|
});
|
|
68431
69025
|
function bashCompletion() {
|
|
@@ -68510,7 +69104,7 @@ _cue "$@"
|
|
|
68510
69104
|
function completionScript(shell) {
|
|
68511
69105
|
return shell === "zsh" ? zshCompletion() : bashCompletion();
|
|
68512
69106
|
}
|
|
68513
|
-
async function
|
|
69107
|
+
async function run97(args) {
|
|
68514
69108
|
const shell = args[0] ?? (process.env.SHELL?.includes("zsh") ? "zsh" : "bash");
|
|
68515
69109
|
if (shell === "zsh") {
|
|
68516
69110
|
process.stdout.write(zshCompletion());
|
|
@@ -68556,16 +69150,16 @@ __export(exports_shell, {
|
|
|
68556
69150
|
shimInstalled: () => shimInstalled,
|
|
68557
69151
|
runUninstall: () => runUninstall,
|
|
68558
69152
|
runInstall: () => runInstall,
|
|
68559
|
-
run: () =>
|
|
69153
|
+
run: () => run98,
|
|
68560
69154
|
resolveHookShell: () => resolveHookShell,
|
|
68561
69155
|
resolveCueInvocation: () => resolveCueInvocation
|
|
68562
69156
|
});
|
|
68563
|
-
import { existsSync as
|
|
68564
|
-
import { spawnSync as
|
|
68565
|
-
import { join as
|
|
69157
|
+
import { existsSync as existsSync128, readFileSync as readFileSync119, statSync as statSync38, accessSync as accessSync2, constants as constants6 } from "node:fs";
|
|
69158
|
+
import { spawnSync as spawnSync39 } from "node:child_process";
|
|
69159
|
+
import { join as join176, dirname as dirname52, win32 as win325 } from "node:path";
|
|
68566
69160
|
import { homedir as homedir74 } from "node:os";
|
|
68567
69161
|
function isCueShimFile(path, agent) {
|
|
68568
|
-
if (!
|
|
69162
|
+
if (!existsSync128(path))
|
|
68569
69163
|
return false;
|
|
68570
69164
|
if (statSync38(path).size >= MAX_SHIM_BYTES)
|
|
68571
69165
|
return false;
|
|
@@ -68576,7 +69170,7 @@ function isExecutableFile(p2, platform2 = process.platform) {
|
|
|
68576
69170
|
if (!statSync38(p2).isFile())
|
|
68577
69171
|
return false;
|
|
68578
69172
|
if (platform2 !== "win32")
|
|
68579
|
-
accessSync2(p2,
|
|
69173
|
+
accessSync2(p2, constants6.X_OK);
|
|
68580
69174
|
return true;
|
|
68581
69175
|
} catch {
|
|
68582
69176
|
return false;
|
|
@@ -68686,7 +69280,7 @@ function resolveTrustedPowerShellExecutables() {
|
|
|
68686
69280
|
function updateWindowsUserPath(dir, action) {
|
|
68687
69281
|
const env = { ...process.env, CUE_SHIM_DIR: dir };
|
|
68688
69282
|
for (const command2 of resolveTrustedPowerShellExecutables()) {
|
|
68689
|
-
const result =
|
|
69283
|
+
const result = spawnSync39(command2, ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", windowsPathScript(action)], { env, stdio: "ignore", windowsHide: true });
|
|
68690
69284
|
if (result.status === 0)
|
|
68691
69285
|
return true;
|
|
68692
69286
|
}
|
|
@@ -68699,7 +69293,7 @@ function readWindowsPathDirs() {
|
|
|
68699
69293
|
"[Console]::Out.Write([Environment]::ExpandEnvironmentVariables(($p-join ';')))"
|
|
68700
69294
|
].join("; ");
|
|
68701
69295
|
for (const command2 of resolveTrustedPowerShellExecutables()) {
|
|
68702
|
-
const result =
|
|
69296
|
+
const result = spawnSync39(command2, ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", script], {
|
|
68703
69297
|
encoding: "utf8",
|
|
68704
69298
|
stdio: ["ignore", "pipe", "ignore"],
|
|
68705
69299
|
windowsHide: true
|
|
@@ -68717,24 +69311,24 @@ function windowsPathGuidance(dir) {
|
|
|
68717
69311
|
async function ensureRcPath(a) {
|
|
68718
69312
|
if (a.writeRc === false)
|
|
68719
69313
|
return false;
|
|
68720
|
-
const { mkdirSync:
|
|
69314
|
+
const { mkdirSync: mkdirSync54, writeFileSync: writeFileSync63, appendFileSync: appendFileSync8 } = await import("node:fs");
|
|
68721
69315
|
if (a.shell === "fish") {
|
|
68722
69316
|
const target = fishDropInPath(a.homeDir);
|
|
68723
|
-
if (
|
|
69317
|
+
if (existsSync128(target)) {
|
|
68724
69318
|
if (readFileSync119(target, "utf8").includes(a.dir))
|
|
68725
69319
|
return true;
|
|
68726
69320
|
a.err(`⚠️ ${target} exists and doesn't reference ${a.dir} — leaving it alone.
|
|
68727
69321
|
`);
|
|
68728
69322
|
return false;
|
|
68729
69323
|
}
|
|
68730
|
-
|
|
68731
|
-
|
|
69324
|
+
mkdirSync54(dirname52(target), { recursive: true });
|
|
69325
|
+
writeFileSync63(target, fishDropIn(a.dir));
|
|
68732
69326
|
a.out(`✅ PATH configured → ${target}
|
|
68733
69327
|
`);
|
|
68734
69328
|
return true;
|
|
68735
69329
|
}
|
|
68736
|
-
const rcPath =
|
|
68737
|
-
if (
|
|
69330
|
+
const rcPath = join176(a.home, a.shell === "zsh" ? ".zshrc" : ".bashrc");
|
|
69331
|
+
if (existsSync128(rcPath) && readFileSync119(rcPath, "utf8").includes(a.dir))
|
|
68738
69332
|
return true;
|
|
68739
69333
|
const approved = a.yes === true || (a.confirm ? await a.confirm(`Append the cue PATH line to ${rcPath}?`) : false);
|
|
68740
69334
|
if (!approved)
|
|
@@ -68750,7 +69344,7 @@ ${a.line}
|
|
|
68750
69344
|
function shimInstalled(homeDir, agent = "claude", platform2 = process.platform) {
|
|
68751
69345
|
const candidates = [
|
|
68752
69346
|
shimPath(shimDir(homeDir), agent, platform2),
|
|
68753
|
-
...platform2 === "win32" ? [] : [
|
|
69347
|
+
...platform2 === "win32" ? [] : [join176(homeDir ?? homedir74(), ".local", "bin", agent)]
|
|
68754
69348
|
];
|
|
68755
69349
|
for (const candidate of candidates) {
|
|
68756
69350
|
try {
|
|
@@ -68766,13 +69360,13 @@ function resolveCueInvocation(opts = {}) {
|
|
|
68766
69360
|
const pathDirs = opts.pathDirs ?? (process.env.PATH ?? "").split(separator).filter(Boolean);
|
|
68767
69361
|
for (const dir of pathDirs) {
|
|
68768
69362
|
for (const name of commandCandidates2("cue", platform2)) {
|
|
68769
|
-
if (dir && isExecutableFile(
|
|
69363
|
+
if (dir && isExecutableFile(join176(dir, name), platform2))
|
|
68770
69364
|
return "cue";
|
|
68771
69365
|
}
|
|
68772
69366
|
}
|
|
68773
|
-
const root = opts.repoRoot ?? process.env.CUE_REPO_ROOT ??
|
|
68774
|
-
for (const candidate of [
|
|
68775
|
-
if (
|
|
69367
|
+
const root = opts.repoRoot ?? process.env.CUE_REPO_ROOT ?? join176(homedir74(), "Documents", "cue");
|
|
69368
|
+
for (const candidate of [join176(root, "bin", "cue.mjs"), join176(root, "bin", "cue")]) {
|
|
69369
|
+
if (existsSync128(candidate)) {
|
|
68776
69370
|
return platform2 === "win32" ? `"${process.execPath}" "${candidate}"` : `"${candidate}"`;
|
|
68777
69371
|
}
|
|
68778
69372
|
}
|
|
@@ -68790,7 +69384,7 @@ async function runInstall(opts = {}) {
|
|
|
68790
69384
|
const persistedPathDirs = platform2 === "win32" ? (opts.readWindowsPathDirs ?? readWindowsPathDirs)() : [];
|
|
68791
69385
|
const pathDirs = [...processPathDirs, ...persistedPathDirs].filter(Boolean);
|
|
68792
69386
|
const agents = opts.agents ?? SHIM_AGENTS;
|
|
68793
|
-
const { mkdirSync:
|
|
69387
|
+
const { mkdirSync: mkdirSync54, writeFileSync: writeFileSync63, chmodSync: chmodSync2, unlinkSync: unlinkSync7 } = await import("node:fs");
|
|
68794
69388
|
const injected = {
|
|
68795
69389
|
claude: opts.realClaude,
|
|
68796
69390
|
codex: opts.realCodex
|
|
@@ -68808,21 +69402,21 @@ async function runInstall(opts = {}) {
|
|
|
68808
69402
|
`);
|
|
68809
69403
|
return 1;
|
|
68810
69404
|
}
|
|
68811
|
-
|
|
69405
|
+
mkdirSync54(dir, { recursive: true });
|
|
68812
69406
|
const cueInvoke = resolveCueInvocation({ pathDirs, platform: platform2 });
|
|
68813
69407
|
for (const agent of real.keys()) {
|
|
68814
69408
|
const target = shimPath(dir, agent, platform2);
|
|
68815
|
-
|
|
69409
|
+
writeFileSync63(target, shimContent(cueInvoke, agent, platform2));
|
|
68816
69410
|
if (platform2 !== "win32")
|
|
68817
69411
|
chmodSync2(target, 493);
|
|
68818
69412
|
out(`✅ Installed ${agent} shim → ${target}
|
|
68819
69413
|
`);
|
|
68820
69414
|
}
|
|
68821
69415
|
for (const agent of platform2 === "win32" ? [] : real.keys()) {
|
|
68822
|
-
const legacy =
|
|
69416
|
+
const legacy = join176(home, ".local", "bin", agent);
|
|
68823
69417
|
try {
|
|
68824
69418
|
if (isCueShimFile(legacy, agent)) {
|
|
68825
|
-
|
|
69419
|
+
unlinkSync7(legacy);
|
|
68826
69420
|
out(`\uD83E\uDDF9 Removed legacy cue shim → ${legacy}
|
|
68827
69421
|
`);
|
|
68828
69422
|
}
|
|
@@ -68867,7 +69461,7 @@ async function runInstall(opts = {}) {
|
|
|
68867
69461
|
}
|
|
68868
69462
|
} else if (position === "after") {
|
|
68869
69463
|
err(`
|
|
68870
|
-
⚠️ ${
|
|
69464
|
+
⚠️ ${dirname52(firstReal)} precedes ${dir} on PATH — the real binary shadows the shim.
|
|
68871
69465
|
`);
|
|
68872
69466
|
err(` Move ${dir} earlier on PATH, then open a new terminal.
|
|
68873
69467
|
`);
|
|
@@ -68880,11 +69474,11 @@ async function runUninstall(opts = {}) {
|
|
|
68880
69474
|
const home = opts.homeDir ?? homedir74();
|
|
68881
69475
|
const platform2 = opts.platform ?? process.platform;
|
|
68882
69476
|
const dir = shimDir(opts.homeDir);
|
|
68883
|
-
const { unlinkSync:
|
|
69477
|
+
const { unlinkSync: unlinkSync7 } = await import("node:fs");
|
|
68884
69478
|
for (const agent of SHIM_AGENTS) {
|
|
68885
69479
|
const target = shimPath(dir, agent, platform2);
|
|
68886
|
-
if (
|
|
68887
|
-
|
|
69480
|
+
if (existsSync128(target)) {
|
|
69481
|
+
unlinkSync7(target);
|
|
68888
69482
|
out(`\uD83D\uDDD1️ Removed ${target}
|
|
68889
69483
|
`);
|
|
68890
69484
|
}
|
|
@@ -68901,15 +69495,15 @@ async function runUninstall(opts = {}) {
|
|
|
68901
69495
|
} else {
|
|
68902
69496
|
const fishTarget = fishDropInPath(opts.homeDir);
|
|
68903
69497
|
try {
|
|
68904
|
-
if (
|
|
68905
|
-
|
|
69498
|
+
if (existsSync128(fishTarget) && readFileSync119(fishTarget, "utf8").includes(FISH_DROPIN_MARKER)) {
|
|
69499
|
+
unlinkSync7(fishTarget);
|
|
68906
69500
|
out(`\uD83D\uDDD1️ Removed ${fishTarget}
|
|
68907
69501
|
`);
|
|
68908
69502
|
}
|
|
68909
69503
|
} catch {}
|
|
68910
69504
|
}
|
|
68911
69505
|
for (const agent of platform2 === "win32" ? [] : SHIM_AGENTS) {
|
|
68912
|
-
const legacy =
|
|
69506
|
+
const legacy = join176(home, ".local", "bin", agent);
|
|
68913
69507
|
try {
|
|
68914
69508
|
if (isCueShimFile(legacy, agent)) {
|
|
68915
69509
|
err(`⚠️ A legacy cue shim remains at ${legacy} — remove it by hand to fully deactivate.
|
|
@@ -68924,7 +69518,7 @@ bash/zsh: remove the cue PATH line from your rc if you added one.
|
|
|
68924
69518
|
}
|
|
68925
69519
|
return 0;
|
|
68926
69520
|
}
|
|
68927
|
-
async function
|
|
69521
|
+
async function run98(args) {
|
|
68928
69522
|
const sub = args[0];
|
|
68929
69523
|
if (sub === "hook") {
|
|
68930
69524
|
const shell = resolveHookShell(args[1]);
|
|
@@ -68972,21 +69566,21 @@ Add the shell hook to auto-switch profiles on cd:
|
|
|
68972
69566
|
return 1;
|
|
68973
69567
|
}
|
|
68974
69568
|
async function installCompletions() {
|
|
68975
|
-
const { mkdirSync:
|
|
69569
|
+
const { mkdirSync: mkdirSync54, writeFileSync: writeFileSync63 } = await import("node:fs");
|
|
68976
69570
|
const shell = process.env.SHELL ?? "/bin/bash";
|
|
68977
69571
|
const { completionScript: completionScript2 } = await Promise.resolve().then(() => (init_completions(), exports_completions));
|
|
68978
69572
|
if (shell.includes("zsh")) {
|
|
68979
|
-
const compDir =
|
|
68980
|
-
|
|
68981
|
-
|
|
69573
|
+
const compDir = join176(homedir74(), ".zsh", "completions");
|
|
69574
|
+
mkdirSync54(compDir, { recursive: true });
|
|
69575
|
+
writeFileSync63(join176(compDir, "_cue"), completionScript2("zsh"));
|
|
68982
69576
|
process.stdout.write(`✅ Installed zsh completions → ${compDir}/_cue
|
|
68983
69577
|
`);
|
|
68984
69578
|
process.stdout.write(` Add to .zshrc: fpath=(~/.zsh/completions $fpath); autoload -Uz compinit && compinit
|
|
68985
69579
|
`);
|
|
68986
69580
|
} else if (shell.includes("bash")) {
|
|
68987
|
-
const compDir =
|
|
68988
|
-
|
|
68989
|
-
|
|
69581
|
+
const compDir = join176(homedir74(), ".local", "share", "bash-completion", "completions");
|
|
69582
|
+
mkdirSync54(compDir, { recursive: true });
|
|
69583
|
+
writeFileSync63(join176(compDir, "cue"), completionScript2("bash"));
|
|
68990
69584
|
process.stdout.write(`✅ Installed bash completions → ${compDir}/cue
|
|
68991
69585
|
`);
|
|
68992
69586
|
}
|
|
@@ -69000,22 +69594,22 @@ var init_shell = __esm(() => {
|
|
|
69000
69594
|
// src/commands/doctor.ts
|
|
69001
69595
|
var exports_doctor = {};
|
|
69002
69596
|
__export(exports_doctor, {
|
|
69003
|
-
run: () =>
|
|
69597
|
+
run: () => run99,
|
|
69004
69598
|
missingMcpIssue: () => missingMcpIssue,
|
|
69005
69599
|
checkCodexHooks: () => checkCodexHooks,
|
|
69006
69600
|
checkActivation: () => checkActivation,
|
|
69007
69601
|
applyRuntimeFix: () => applyRuntimeFix,
|
|
69008
69602
|
applyFix: () => applyFix
|
|
69009
69603
|
});
|
|
69010
|
-
import { readFileSync as readFileSync120, existsSync as
|
|
69604
|
+
import { readFileSync as readFileSync120, existsSync as existsSync129, lstatSync as lstatSync7, readlinkSync as readlinkSync3, readdirSync as readdirSync63 } from "node:fs";
|
|
69011
69605
|
import { readFile as readFile28, writeFile as writeFile15, rm as rm7 } from "node:fs/promises";
|
|
69012
|
-
import { resolve as
|
|
69013
|
-
import { spawnSync as
|
|
69606
|
+
import { resolve as resolve49, dirname as dirname53, join as join177 } from "node:path";
|
|
69607
|
+
import { spawnSync as spawnSync40 } from "node:child_process";
|
|
69014
69608
|
function loadAllMcpIds3() {
|
|
69015
69609
|
const ids = new Set;
|
|
69016
69610
|
for (const file of ["claude.sanitized.json", "claude_runtime.sanitized.json", "codex.sanitized.json"]) {
|
|
69017
69611
|
try {
|
|
69018
|
-
const raw = JSON.parse(readFileSync120(
|
|
69612
|
+
const raw = JSON.parse(readFileSync120(join177(MCP_CONFIGS_DIR4, file), "utf8"));
|
|
69019
69613
|
if (raw.servers)
|
|
69020
69614
|
for (const id of Object.keys(raw.servers))
|
|
69021
69615
|
ids.add(id);
|
|
@@ -69024,7 +69618,7 @@ function loadAllMcpIds3() {
|
|
|
69024
69618
|
return ids;
|
|
69025
69619
|
}
|
|
69026
69620
|
function checkCodexHooks(profile, runtimeDir, desired = {}) {
|
|
69027
|
-
if (!
|
|
69621
|
+
if (!existsSync129(runtimeDir))
|
|
69028
69622
|
return [];
|
|
69029
69623
|
const issues = [];
|
|
69030
69624
|
const issue = (message, severity = "warning") => {
|
|
@@ -69032,25 +69626,25 @@ function checkCodexHooks(profile, runtimeDir, desired = {}) {
|
|
|
69032
69626
|
};
|
|
69033
69627
|
try {
|
|
69034
69628
|
const readOptional = (name) => {
|
|
69035
|
-
const path =
|
|
69036
|
-
return
|
|
69629
|
+
const path = join177(runtimeDir, name);
|
|
69630
|
+
return existsSync129(path) ? readFileSync120(path, "utf8") : undefined;
|
|
69037
69631
|
};
|
|
69038
69632
|
const config = readOptional("config.toml") ?? "";
|
|
69039
69633
|
const raw = readOptional("hooks.json");
|
|
69040
69634
|
const owned = readOptional(".cue-hooks.json");
|
|
69041
69635
|
const inline = parseBaseCodexConfig(config).top.hooks !== undefined || /^\s*\[\[?\s*hooks\s*\.\s*(?!state(?:\s*\.|\s*\]))[A-Za-z]/m.test(config);
|
|
69042
69636
|
if (raw !== undefined && inline)
|
|
69043
|
-
issue(`Codex hooks load from both ${
|
|
69637
|
+
issue(`Codex hooks load from both ${join177(runtimeDir, "config.toml")} and hooks.json; keep event definitions in hooks.json (approval state may stay in TOML)`);
|
|
69044
69638
|
const reconciled = reconcileCodexHooks(raw, owned, desired);
|
|
69045
69639
|
const current = raw === undefined ? {} : JSON.parse(raw).hooks ?? {};
|
|
69046
69640
|
if (JSON.stringify(current) !== JSON.stringify(reconciled.document.hooks)) {
|
|
69047
|
-
issue(`Codex hook registrations are missing or stale in ${
|
|
69641
|
+
issue(`Codex hook registrations are missing or stale in ${join177(runtimeDir, "hooks.json")}; rebuild this profile. Ownership: .cue-hooks.json; unrelated entries are preserved`);
|
|
69048
69642
|
} else {
|
|
69049
69643
|
const wanted = reconcileCodexHooks(undefined, undefined, desired).owned.hooks;
|
|
69050
69644
|
const tracked = reconciled.owned.hooks;
|
|
69051
69645
|
const untracked = Object.entries(wanted).some(([event, entries]) => entries.length > (tracked[event]?.length ?? 0));
|
|
69052
69646
|
if (untracked)
|
|
69053
|
-
issue(`Codex profile hooks in ${
|
|
69647
|
+
issue(`Codex profile hooks in ${join177(runtimeDir, "hooks.json")} are untracked legacy/shared entries; preserved rather than claimed. Ownership: .cue-hooks.json; inspect sources with Codex /hooks`);
|
|
69054
69648
|
}
|
|
69055
69649
|
} catch (error) {
|
|
69056
69650
|
issue(`Cannot inspect Codex hook sources in ${runtimeDir}: ${error instanceof Error ? error.message : String(error)}`, "error");
|
|
@@ -69060,7 +69654,7 @@ function checkCodexHooks(profile, runtimeDir, desired = {}) {
|
|
|
69060
69654
|
function missingMcpIssue(profile, id, registeredIds, sourcesDir = MCP_SOURCES_DIR) {
|
|
69061
69655
|
if (registeredIds.has(id))
|
|
69062
69656
|
return null;
|
|
69063
|
-
const hasLocalSource = /^[A-Za-z0-9._-]+$/.test(id) &&
|
|
69657
|
+
const hasLocalSource = /^[A-Za-z0-9._-]+$/.test(id) && existsSync129(join177(sourcesDir, id));
|
|
69064
69658
|
if (hasLocalSource) {
|
|
69065
69659
|
return {
|
|
69066
69660
|
code: "D2",
|
|
@@ -69143,13 +69737,13 @@ async function checkProfile(profileName2, allSkillIds, allMcpIds, incompleteSkil
|
|
|
69143
69737
|
});
|
|
69144
69738
|
}
|
|
69145
69739
|
for (const agent of ["claude", "codex"]) {
|
|
69146
|
-
const hashFile =
|
|
69147
|
-
if (
|
|
69740
|
+
const hashFile = join177(RUNTIME_ROOT4, profileName2, agent, ".cue-hash");
|
|
69741
|
+
if (existsSync129(hashFile)) {
|
|
69148
69742
|
try {
|
|
69149
|
-
const hashStat =
|
|
69150
|
-
const yamlPath =
|
|
69151
|
-
if (
|
|
69152
|
-
const yamlStat =
|
|
69743
|
+
const hashStat = lstatSync7(hashFile);
|
|
69744
|
+
const yamlPath = join177(PROFILES_DIR16, profileName2, "profile.yaml");
|
|
69745
|
+
if (existsSync129(yamlPath)) {
|
|
69746
|
+
const yamlStat = lstatSync7(yamlPath);
|
|
69153
69747
|
if (yamlStat.mtimeMs > hashStat.mtimeMs) {
|
|
69154
69748
|
issues.push({
|
|
69155
69749
|
code: "D5",
|
|
@@ -69157,7 +69751,7 @@ async function checkProfile(profileName2, allSkillIds, allMcpIds, incompleteSkil
|
|
|
69157
69751
|
profile: profileName2,
|
|
69158
69752
|
message: `Runtime for ${agent} may be stale (profile.yaml newer than hash)`,
|
|
69159
69753
|
fix: `Remove stale .cue-hash; next launch will rebuild`,
|
|
69160
|
-
runtimeDir:
|
|
69754
|
+
runtimeDir: dirname53(hashFile),
|
|
69161
69755
|
path: hashFile
|
|
69162
69756
|
});
|
|
69163
69757
|
}
|
|
@@ -69166,19 +69760,19 @@ async function checkProfile(profileName2, allSkillIds, allMcpIds, incompleteSkil
|
|
|
69166
69760
|
}
|
|
69167
69761
|
}
|
|
69168
69762
|
for (const agent of ["claude", "codex"]) {
|
|
69169
|
-
const runtimeDir =
|
|
69170
|
-
if (!
|
|
69763
|
+
const runtimeDir = join177(RUNTIME_ROOT4, profileName2, agent);
|
|
69764
|
+
if (!existsSync129(runtimeDir))
|
|
69171
69765
|
continue;
|
|
69172
69766
|
try {
|
|
69173
69767
|
const entries = readdirSync63(runtimeDir);
|
|
69174
69768
|
for (const entry of entries) {
|
|
69175
|
-
const entryPath =
|
|
69769
|
+
const entryPath = join177(runtimeDir, entry);
|
|
69176
69770
|
try {
|
|
69177
|
-
const st3 =
|
|
69771
|
+
const st3 = lstatSync7(entryPath);
|
|
69178
69772
|
if (st3.isSymbolicLink()) {
|
|
69179
69773
|
const target = readlinkSync3(entryPath);
|
|
69180
|
-
const resolvedTarget =
|
|
69181
|
-
if (!
|
|
69774
|
+
const resolvedTarget = resolve49(dirname53(entryPath), target);
|
|
69775
|
+
if (!existsSync129(resolvedTarget)) {
|
|
69182
69776
|
issues.push({
|
|
69183
69777
|
code: "D6",
|
|
69184
69778
|
severity: "error",
|
|
@@ -69194,7 +69788,7 @@ async function checkProfile(profileName2, allSkillIds, allMcpIds, incompleteSkil
|
|
|
69194
69788
|
}
|
|
69195
69789
|
} catch {}
|
|
69196
69790
|
}
|
|
69197
|
-
issues.push(...checkCodexHooks(profileName2,
|
|
69791
|
+
issues.push(...checkCodexHooks(profileName2, join177(RUNTIME_ROOT4, runtimePathKey(profileName2), "codex"), profile.codex?.hooks ?? profile.codexConfig?.hooks));
|
|
69198
69792
|
const profileSkillSlugs = new Set(profileSkillIds2.map((id) => id.split("/").pop()));
|
|
69199
69793
|
for (const skill of incompleteSkills) {
|
|
69200
69794
|
const slug = skill.id.split("/").pop();
|
|
@@ -69211,8 +69805,8 @@ async function checkProfile(profileName2, allSkillIds, allMcpIds, incompleteSkil
|
|
|
69211
69805
|
const declaredGates = profile.qualityGates ?? [];
|
|
69212
69806
|
for (const ref of declaredGates) {
|
|
69213
69807
|
const fname = ref.endsWith(".sh") ? ref : `${ref}.sh`;
|
|
69214
|
-
const gatePath =
|
|
69215
|
-
if (!
|
|
69808
|
+
const gatePath = join177(QUALITY_GATES_DIR, fname);
|
|
69809
|
+
if (!existsSync129(gatePath)) {
|
|
69216
69810
|
issues.push({
|
|
69217
69811
|
code: "D8",
|
|
69218
69812
|
severity: "warning",
|
|
@@ -69264,7 +69858,7 @@ function checkActivation(opts = {}) {
|
|
|
69264
69858
|
code: "D9",
|
|
69265
69859
|
severity: "error",
|
|
69266
69860
|
profile: PROF,
|
|
69267
|
-
message: `Real binary dir ${
|
|
69861
|
+
message: `Real binary dir ${resolve49(realBin, "..")} precedes ${dir} on PATH — the shim is shadowed`,
|
|
69268
69862
|
fix: `Reorder PATH so ${dir} comes before the real claude/codex`
|
|
69269
69863
|
});
|
|
69270
69864
|
}
|
|
@@ -69283,7 +69877,7 @@ function formatAgo(ms) {
|
|
|
69283
69877
|
}
|
|
69284
69878
|
async function applyRuntimeFix(issue, runtimeRoot = RUNTIME_ROOT4) {
|
|
69285
69879
|
if (issue.code === "D5") {
|
|
69286
|
-
const hashPath = issue.path ??
|
|
69880
|
+
const hashPath = issue.path ?? join177(runtimeRoot, issue.profile, "claude", ".cue-hash");
|
|
69287
69881
|
try {
|
|
69288
69882
|
await rm7(hashPath, { force: true });
|
|
69289
69883
|
return true;
|
|
@@ -69295,12 +69889,12 @@ async function applyRuntimeFix(issue, runtimeRoot = RUNTIME_ROOT4) {
|
|
|
69295
69889
|
if (!issue.path)
|
|
69296
69890
|
return false;
|
|
69297
69891
|
try {
|
|
69298
|
-
const st3 =
|
|
69892
|
+
const st3 = lstatSync7(issue.path);
|
|
69299
69893
|
if (!st3.isSymbolicLink())
|
|
69300
69894
|
return false;
|
|
69301
69895
|
await rm7(issue.path, { recursive: true, force: true });
|
|
69302
|
-
const runtimeDir = issue.runtimeDir ??
|
|
69303
|
-
await rm7(
|
|
69896
|
+
const runtimeDir = issue.runtimeDir ?? dirname53(issue.path);
|
|
69897
|
+
await rm7(join177(runtimeDir, ".cue-hash"), { force: true });
|
|
69304
69898
|
return true;
|
|
69305
69899
|
} catch {
|
|
69306
69900
|
return false;
|
|
@@ -69311,7 +69905,7 @@ async function applyRuntimeFix(issue, runtimeRoot = RUNTIME_ROOT4) {
|
|
|
69311
69905
|
async function applyFix(issue, profilesDir5 = PROFILES_DIR16) {
|
|
69312
69906
|
if (issue.manual)
|
|
69313
69907
|
return false;
|
|
69314
|
-
const yamlPath =
|
|
69908
|
+
const yamlPath = join177(profilesDir5, issue.profile, "profile.yaml");
|
|
69315
69909
|
switch (issue.code) {
|
|
69316
69910
|
case "D1": {
|
|
69317
69911
|
const id = issue.id ?? issue.message.match(/Skill "([^"]+)"/)[1];
|
|
@@ -69382,8 +69976,8 @@ mcps:
|
|
|
69382
69976
|
if (!idMatch)
|
|
69383
69977
|
return false;
|
|
69384
69978
|
const skillId = idMatch[1];
|
|
69385
|
-
const skillDir =
|
|
69386
|
-
if (!
|
|
69979
|
+
const skillDir = join177(SKILLS_ROOT26, skillId);
|
|
69980
|
+
if (!existsSync129(skillDir))
|
|
69387
69981
|
return false;
|
|
69388
69982
|
const source = readSourceFile(skillDir);
|
|
69389
69983
|
if (!source)
|
|
@@ -69409,7 +70003,7 @@ mcps:
|
|
|
69409
70003
|
return false;
|
|
69410
70004
|
}
|
|
69411
70005
|
}
|
|
69412
|
-
async function
|
|
70006
|
+
async function run99(args) {
|
|
69413
70007
|
if (args.includes("-h") || args.includes("--help")) {
|
|
69414
70008
|
process.stdout.write(`cue doctor — detect and fix profile drift
|
|
69415
70009
|
|
|
@@ -69582,8 +70176,8 @@ async function runCliDoctor(profileName2, json) {
|
|
|
69582
70176
|
`);
|
|
69583
70177
|
return 1;
|
|
69584
70178
|
}
|
|
69585
|
-
const SKILLS_ROOT_PATH =
|
|
69586
|
-
const HOME_SKILLS_PATH =
|
|
70179
|
+
const SKILLS_ROOT_PATH = join177(repoRoot(), "resources", "skills", "skills");
|
|
70180
|
+
const HOME_SKILLS_PATH = join177(process.env.HOME ?? "~", ".claude", "skills");
|
|
69587
70181
|
let profile;
|
|
69588
70182
|
try {
|
|
69589
70183
|
profile = await loadProfile(profileName2);
|
|
@@ -69674,10 +70268,10 @@ async function runCliDoctor(profileName2, json) {
|
|
|
69674
70268
|
const slug = id.split("/").pop() ?? id;
|
|
69675
70269
|
let content = "";
|
|
69676
70270
|
const paths = [
|
|
69677
|
-
|
|
70271
|
+
join177(HOME_SKILLS_PATH, slug, "SKILL.md"),
|
|
69678
70272
|
...(() => {
|
|
69679
70273
|
try {
|
|
69680
|
-
return readdirSync63(SKILLS_ROOT_PATH).map((cat) =>
|
|
70274
|
+
return readdirSync63(SKILLS_ROOT_PATH).map((cat) => join177(SKILLS_ROOT_PATH, cat, slug, "SKILL.md"));
|
|
69681
70275
|
} catch {
|
|
69682
70276
|
return [];
|
|
69683
70277
|
}
|
|
@@ -69707,7 +70301,7 @@ async function runCliDoctor(profileName2, json) {
|
|
|
69707
70301
|
}
|
|
69708
70302
|
const results = [];
|
|
69709
70303
|
for (const [cli, skills] of [...cliNeeded.entries()].sort((a, b2) => b2[1].length - a[1].length)) {
|
|
69710
|
-
const check =
|
|
70304
|
+
const check = spawnSync40("which", [cli], { encoding: "utf8", timeout: 2000 });
|
|
69711
70305
|
const installed2 = check.status === 0;
|
|
69712
70306
|
results.push({ cli, installed: installed2, skills: skills.length, hint: installed2 ? undefined : INSTALL_HINTS[cli] });
|
|
69713
70307
|
}
|
|
@@ -69762,12 +70356,12 @@ var init_doctor = __esm(() => {
|
|
|
69762
70356
|
init_codex_config();
|
|
69763
70357
|
init_runtime_materializer();
|
|
69764
70358
|
init_config_paths();
|
|
69765
|
-
PROFILES_DIR16 = process.env.CUE_PROFILES_DIR ??
|
|
69766
|
-
SKILLS_ROOT26 =
|
|
69767
|
-
MCP_CONFIGS_DIR4 =
|
|
69768
|
-
MCP_SOURCES_DIR =
|
|
69769
|
-
QUALITY_GATES_DIR =
|
|
69770
|
-
RUNTIME_ROOT4 =
|
|
70359
|
+
PROFILES_DIR16 = process.env.CUE_PROFILES_DIR ?? join177(repoRoot(), "profiles");
|
|
70360
|
+
SKILLS_ROOT26 = join177(repoRoot(), "resources", "skills", "skills");
|
|
70361
|
+
MCP_CONFIGS_DIR4 = join177(repoRoot(), "resources", "mcps", "configs");
|
|
70362
|
+
MCP_SOURCES_DIR = join177(repoRoot(), "resources", "mcps", "mcps");
|
|
70363
|
+
QUALITY_GATES_DIR = join177(repoRoot(), "resources", "quality-gates");
|
|
70364
|
+
RUNTIME_ROOT4 = join177(configDir(), "runtime");
|
|
69771
70365
|
INSTALL_HINTS = {
|
|
69772
70366
|
python: "apt install python3 / brew install python",
|
|
69773
70367
|
pip: "apt install python3-pip / comes with python",
|
|
@@ -69799,20 +70393,20 @@ __export(exports_config_paths2, {
|
|
|
69799
70393
|
cacheDir: () => cacheDir3
|
|
69800
70394
|
});
|
|
69801
70395
|
import { homedir as homedir75 } from "node:os";
|
|
69802
|
-
import { join as
|
|
70396
|
+
import { join as join179 } from "node:path";
|
|
69803
70397
|
function configDir2() {
|
|
69804
70398
|
const xdg = process.env.XDG_CONFIG_HOME;
|
|
69805
|
-
return
|
|
70399
|
+
return join179(xdg && xdg.length > 0 ? xdg : join179(homedir75(), ".config"), "cue");
|
|
69806
70400
|
}
|
|
69807
70401
|
function cacheDir3() {
|
|
69808
70402
|
const xdg = process.env.XDG_CACHE_HOME;
|
|
69809
|
-
return
|
|
70403
|
+
return join179(xdg && xdg.length > 0 ? xdg : join179(homedir75(), ".cache"), "cue");
|
|
69810
70404
|
}
|
|
69811
70405
|
var init_config_paths2 = () => {};
|
|
69812
70406
|
|
|
69813
70407
|
// src/index.ts
|
|
69814
70408
|
import { readFileSync as readFileSync121 } from "fs";
|
|
69815
|
-
import { resolve as
|
|
70409
|
+
import { resolve as resolve51 } from "path";
|
|
69816
70410
|
|
|
69817
70411
|
// src/commands/_index.ts
|
|
69818
70412
|
var COMMANDS2 = {
|
|
@@ -70053,11 +70647,11 @@ var COMMANDS2 = {
|
|
|
70053
70647
|
load: async () => ({
|
|
70054
70648
|
run: async (args) => {
|
|
70055
70649
|
if (args.includes("--docker")) {
|
|
70056
|
-
const { run:
|
|
70057
|
-
return
|
|
70650
|
+
const { run: run101 } = await Promise.resolve().then(() => (init_export_docker(), exports_export_docker));
|
|
70651
|
+
return run101(args.filter((a) => a !== "--docker"));
|
|
70058
70652
|
}
|
|
70059
|
-
const { run:
|
|
70060
|
-
return
|
|
70653
|
+
const { run: run100 } = await Promise.resolve().then(() => (init_import_profile(), exports_import_profile));
|
|
70654
|
+
return run100(["export", ...args]);
|
|
70061
70655
|
}
|
|
70062
70656
|
})
|
|
70063
70657
|
},
|
|
@@ -70141,6 +70735,10 @@ var COMMANDS2 = {
|
|
|
70141
70735
|
summary: "Measure profile efficiency: tokens, skill usage, cost",
|
|
70142
70736
|
load: () => Promise.resolve().then(() => (init_benchmark(), exports_benchmark))
|
|
70143
70737
|
},
|
|
70738
|
+
"community-eval": {
|
|
70739
|
+
summary: "Run and optionally share a synthetic CodeGraph A/B benchmark",
|
|
70740
|
+
load: () => Promise.resolve().then(() => (init_community_eval(), exports_community_eval))
|
|
70741
|
+
},
|
|
70144
70742
|
brief: {
|
|
70145
70743
|
summary: "Show this directory's verified facts as handed to the agent; --write persists them",
|
|
70146
70744
|
load: () => Promise.resolve().then(() => (init_brief(), exports_brief))
|
|
@@ -70174,12 +70772,12 @@ var COMMANDS2 = {
|
|
|
70174
70772
|
load: async () => ({
|
|
70175
70773
|
run: async () => {
|
|
70176
70774
|
const { maybePromptStar: maybePromptStar2 } = await Promise.resolve().then(() => (init_star_prompt(), exports_star_prompt));
|
|
70177
|
-
const { existsSync:
|
|
70178
|
-
const { join:
|
|
70775
|
+
const { existsSync: existsSync130, unlinkSync: unlinkSync7 } = await import("node:fs");
|
|
70776
|
+
const { join: join178 } = await import("node:path");
|
|
70179
70777
|
const { configDir: configDir2 } = await Promise.resolve().then(() => (init_config_paths(), exports_config_paths));
|
|
70180
|
-
const flag =
|
|
70181
|
-
if (
|
|
70182
|
-
|
|
70778
|
+
const flag = join178(configDir2(), ".star-prompted");
|
|
70779
|
+
if (existsSync130(flag))
|
|
70780
|
+
unlinkSync7(flag);
|
|
70183
70781
|
await maybePromptStar2();
|
|
70184
70782
|
return 0;
|
|
70185
70783
|
}
|
|
@@ -70240,7 +70838,7 @@ var COMMANDS2 = {
|
|
|
70240
70838
|
};
|
|
70241
70839
|
|
|
70242
70840
|
// src/lib/command-runner.ts
|
|
70243
|
-
async function
|
|
70841
|
+
async function runCommand2(name, args, command2) {
|
|
70244
70842
|
try {
|
|
70245
70843
|
const mod = await command2.load();
|
|
70246
70844
|
return await mod.run(args);
|
|
@@ -70253,9 +70851,9 @@ async function runCommand(name, args, command2) {
|
|
|
70253
70851
|
}
|
|
70254
70852
|
|
|
70255
70853
|
// src/lib/repo-root.ts
|
|
70256
|
-
import { dirname as
|
|
70854
|
+
import { dirname as dirname54, join as join178, resolve as resolve50 } from "node:path";
|
|
70257
70855
|
import { fileURLToPath as fileURLToPath18 } from "node:url";
|
|
70258
|
-
var FALLBACK_REPO_ROOT3 =
|
|
70856
|
+
var FALLBACK_REPO_ROOT3 = resolve50(dirname54(fileURLToPath18(import.meta.url)), "..", "..");
|
|
70259
70857
|
function repoRoot8() {
|
|
70260
70858
|
return process.env.CUE_REPO_ROOT ?? process.env.SOUL_REPO_ROOT ?? FALLBACK_REPO_ROOT3;
|
|
70261
70859
|
}
|
|
@@ -70266,7 +70864,7 @@ function readVersion() {
|
|
|
70266
70864
|
if (_version !== null)
|
|
70267
70865
|
return _version;
|
|
70268
70866
|
try {
|
|
70269
|
-
const pkg = JSON.parse(readFileSync121(
|
|
70867
|
+
const pkg = JSON.parse(readFileSync121(resolve51(repoRoot8(), "package.json"), "utf8"));
|
|
70270
70868
|
_version = pkg.version ?? "0.0.0";
|
|
70271
70869
|
return _version;
|
|
70272
70870
|
} catch {
|
|
@@ -70343,12 +70941,12 @@ function similarity(a, b2) {
|
|
|
70343
70941
|
return 2 * matches / (a.length - 1 + b2.length - 1);
|
|
70344
70942
|
}
|
|
70345
70943
|
async function checkForUpdate(currentVersion) {
|
|
70346
|
-
const { existsSync:
|
|
70347
|
-
const { join:
|
|
70944
|
+
const { existsSync: existsSync130, readFileSync: rf, writeFileSync: wf, mkdirSync: mkdirSync54 } = await import("fs");
|
|
70945
|
+
const { join: join180 } = await import("path");
|
|
70348
70946
|
const { configDir: configDir3 } = await Promise.resolve().then(() => (init_config_paths2(), exports_config_paths2));
|
|
70349
70947
|
const cfgDir = configDir3();
|
|
70350
|
-
const checkFile =
|
|
70351
|
-
if (
|
|
70948
|
+
const checkFile = join180(cfgDir, ".last-update-check");
|
|
70949
|
+
if (existsSync130(checkFile)) {
|
|
70352
70950
|
const last = parseInt(rf(checkFile, "utf8").trim(), 10) || 0;
|
|
70353
70951
|
if (Date.now() - last < 86400000)
|
|
70354
70952
|
return;
|
|
@@ -70360,7 +70958,7 @@ async function checkForUpdate(currentVersion) {
|
|
|
70360
70958
|
const latest = data.version;
|
|
70361
70959
|
if (!latest)
|
|
70362
70960
|
return;
|
|
70363
|
-
|
|
70961
|
+
mkdirSync54(cfgDir, { recursive: true });
|
|
70364
70962
|
wf(checkFile, String(Date.now()));
|
|
70365
70963
|
if (latest === currentVersion)
|
|
70366
70964
|
return;
|
|
@@ -70377,21 +70975,21 @@ async function checkForUpdate(currentVersion) {
|
|
|
70377
70975
|
if (process.stdin.isTTY && process.stdout.isTTY) {
|
|
70378
70976
|
const readline = await import("readline");
|
|
70379
70977
|
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
70380
|
-
const answer = await new Promise((
|
|
70978
|
+
const answer = await new Promise((resolve52) => {
|
|
70381
70979
|
rl.question(" Install now? [y/N] ", (a) => {
|
|
70382
70980
|
rl.close();
|
|
70383
|
-
|
|
70981
|
+
resolve52(a);
|
|
70384
70982
|
});
|
|
70385
70983
|
setTimeout(() => {
|
|
70386
70984
|
rl.close();
|
|
70387
|
-
|
|
70985
|
+
resolve52("n");
|
|
70388
70986
|
}, 5000);
|
|
70389
70987
|
});
|
|
70390
70988
|
if (answer.toLowerCase() === "y" || answer.toLowerCase() === "yes") {
|
|
70391
70989
|
process.stderr.write(` \uD83D\uDCE6 Updating...
|
|
70392
70990
|
`);
|
|
70393
|
-
const { spawnSync:
|
|
70394
|
-
const result =
|
|
70991
|
+
const { spawnSync: spawnSync41 } = await import("child_process");
|
|
70992
|
+
const result = spawnSync41("npm", ["install", "-g", "cue-ai"], { encoding: "utf8", timeout: 60000, stdio: ["ignore", "pipe", "pipe"] });
|
|
70395
70993
|
if (result.status === 0) {
|
|
70396
70994
|
process.stderr.write(` \u2705 Updated to ${latest}
|
|
70397
70995
|
|
|
@@ -70412,7 +71010,7 @@ async function main(argv) {
|
|
|
70412
71010
|
if (!skipUpdateCheck)
|
|
70413
71011
|
checkForUpdate(readVersion()).catch(() => {});
|
|
70414
71012
|
if (args.length === 0) {
|
|
70415
|
-
return
|
|
71013
|
+
return runCommand2("status", [], COMMANDS2.status);
|
|
70416
71014
|
}
|
|
70417
71015
|
if (args[0] === "-h" || args[0] === "--help" || args[0] === "help") {
|
|
70418
71016
|
printHelp10(args.includes("--all"));
|
|
@@ -70444,7 +71042,7 @@ Run "cue --help" for all commands.
|
|
|
70444
71042
|
`);
|
|
70445
71043
|
return 1;
|
|
70446
71044
|
}
|
|
70447
|
-
return
|
|
71045
|
+
return runCommand2(name, args.slice(1), cmd);
|
|
70448
71046
|
}
|
|
70449
71047
|
main(process.argv).then((code) => {
|
|
70450
71048
|
process.exitCode = code;
|