harnessed 4.47.0 → 4.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-en.md +65 -65
- package/README.md +65 -65
- package/dist/cli.mjs +877 -701
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -6,11 +6,11 @@ import { Type } from '@sinclair/typebox';
|
|
|
6
6
|
import { readFile, readdir, stat, rm, unlink, writeFile, cp, mkdir, access, rename, appendFile, copyFile, chmod, mkdtemp } from 'fs/promises';
|
|
7
7
|
import { Value } from '@sinclair/typebox/value';
|
|
8
8
|
import lockfile from 'proper-lockfile';
|
|
9
|
+
import { pathToFileURL, fileURLToPath } from 'url';
|
|
9
10
|
import { LineCounter, parseDocument, parse, isSeq, isScalar, stringify } from 'yaml';
|
|
10
11
|
import { Ajv } from 'ajv';
|
|
11
12
|
import * as ajvFormatsNs from 'ajv-formats';
|
|
12
13
|
import { execFileSync, spawnSync, spawn, execFile, exec } from 'child_process';
|
|
13
|
-
import { pathToFileURL, fileURLToPath } from 'url';
|
|
14
14
|
import { createHash, verify, createPublicKey } from 'crypto';
|
|
15
15
|
import { promisify } from 'util';
|
|
16
16
|
import * as p from '@clack/prompts';
|
|
@@ -38,7 +38,7 @@ var init_package = __esm({
|
|
|
38
38
|
"package.json"() {
|
|
39
39
|
package_default = {
|
|
40
40
|
name: "harnessed",
|
|
41
|
-
version: "4.
|
|
41
|
+
version: "4.48.0",
|
|
42
42
|
description: "AI coding harness package manager + composition orchestrator",
|
|
43
43
|
type: "module",
|
|
44
44
|
license: "Apache-2.0",
|
|
@@ -1224,71 +1224,727 @@ var init_forwardStep = __esm({
|
|
|
1224
1224
|
}
|
|
1225
1225
|
});
|
|
1226
1226
|
|
|
1227
|
-
//
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1227
|
+
// messages/en.json
|
|
1228
|
+
var en_default;
|
|
1229
|
+
var init_en = __esm({
|
|
1230
|
+
"messages/en.json"() {
|
|
1231
|
+
en_default = {
|
|
1232
|
+
"setup.workflows_not_found": "error: workflows directory not found at {{path}}",
|
|
1233
|
+
"setup.nothing_to_install": "setup: no workflow directories with SKILL.md found \u2014 nothing to install",
|
|
1234
|
+
"setup.dry_run.header": "[dry-run] setup would install {{count}} workflow(s) to {{path}}:",
|
|
1235
|
+
"setup.dry_run.run_hint": " run without --dry-run to execute",
|
|
1236
|
+
"setup.copy_failed": " error: failed to copy {{name}}: {{message}}",
|
|
1237
|
+
"setup.step_a_complete": "Step A: {{count}} workflows installed to {{path}}",
|
|
1238
|
+
"setup.step_a_render.complete": " generated {{count}}/{{total}} command files",
|
|
1239
|
+
"setup.step_a_render.warnings_header": " [A.5] warnings \u2014 some capability cmds could not be fully resolved:",
|
|
1240
|
+
"setup.step_c.created": " [C] created {{path}} + enabled Agent Teams",
|
|
1241
|
+
"setup.step_c.already_enabled": " [C] Agent Teams already enabled ({{path}})",
|
|
1242
|
+
"setup.step_c.enabled_backup": " [C] enabled Agent Teams in {{path}} (backup saved \u2192 {{backupPath}})",
|
|
1243
|
+
"setup.step_c.skipped": " [C] Agent Teams enable skipped: {{message}}",
|
|
1244
|
+
"setup.step_d.created": " [D] created {{path}} + wrote env.HARNESSED_USER_LANG={{lang}}",
|
|
1245
|
+
"setup.step_d.already_set": " [D] env.HARNESSED_USER_LANG={{lang}} already set in {{path}} \u2014 respecting user override",
|
|
1246
|
+
"setup.step_d.enabled_backup": " [D] wrote env.HARNESSED_USER_LANG={{lang}} in {{path}} (backup saved \u2192 {{backupPath}})",
|
|
1247
|
+
"setup.step_d.skipped": " [D] User language write skipped: {{message}}",
|
|
1248
|
+
"setup.step_b_complete": "Upstream components: {{installed}} installed / {{already}} already-installed / {{skipped}} skipped / {{failed}} failed [{{seconds}}s]",
|
|
1249
|
+
"setup.complete": "setup complete \u2014 {{skills}} workflows + {{manifests}} base manifests configured",
|
|
1250
|
+
"setup.mcp_hint": "Run /mcp in Claude Code to verify MCP server connections.",
|
|
1251
|
+
"setup.mcp_hint_codex": "Run codex mcp list to verify MCP server connections.",
|
|
1252
|
+
"setup.search_key_hint.header": "\n\u26A0 Search MCP API keys missing \u2014 the server(s) below are installed but will fail at query time until the key is configured:",
|
|
1253
|
+
"setup.search_key_hint.line": ' {{server}}: set {{envVar}} \u2014 add it to the ~/.claude/settings.json "env" block (e.g. {"env": {"{{envVar}}": "<your-key>"}}) or export {{envVar}} in your shell',
|
|
1254
|
+
"setup.optional_offer.ecc_note": " ecc (bonus tier): installing it unlocks finer-grained scenario orchestration (per-language review/build expert routing etc.); the trade-off is ~20k+ tokens/session of static listing overhead \u2014 inherent to ECC's own scale (281 skills / 94 commands / 67 agents), not introduced by harnessed.",
|
|
1255
|
+
"setup.bundled_summary": "\nharnessed workflows bundled at <packageRoot>/workflows/ (share-only, read-only)",
|
|
1256
|
+
"setup.bundled_location": "",
|
|
1257
|
+
"setup.doctor_hint": "\nRun harnessed doctor to verify your environment.",
|
|
1258
|
+
"agent_teams.missing_header": "\n\u26A0\uFE0F Agent Teams not enabled \u2014 parallelism upgrade path unavailable",
|
|
1259
|
+
"agent_teams.missing_fix": " fix: claude config set env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS 1",
|
|
1260
|
+
"agent_teams.missing_explanation": " harnessed task parallelism uses Subagent or Agent Teams (CC 2.1.178+)",
|
|
1261
|
+
"agent_teams.missing_nonblocking": " non-blocking \u2014 auto-degrades to subagent fan-out\n",
|
|
1262
|
+
"install.manifest_not_found": "error: manifest '{{name}}' not found",
|
|
1263
|
+
"install.manifest_not_found.fix": " fix: ensure manifests/tools/{{name}}.yaml, manifests/skill-packs/{{name}}.yaml, or manifests/optional/{{name}}.yaml exists",
|
|
1264
|
+
"install.audit_hint": " fix: run 'harnessed audit' to inspect manifest issues",
|
|
1265
|
+
"install.success": "installed {{name}}",
|
|
1266
|
+
"install.success_with_version": "installed {{name}}@{{version}}",
|
|
1267
|
+
"install.already_installed": "already-installed {{name}} (idempotent check hit; nothing to do)",
|
|
1268
|
+
"install.already_installed_with_version": "already-installed {{name}}@{{version}} (idempotent check hit; nothing to do)",
|
|
1269
|
+
"install.aborted": "aborted: {{reason}}",
|
|
1270
|
+
"uninstall.dry_run.preview": "[dry-run] would uninstall '{{name}}' via method '{{method}}'",
|
|
1271
|
+
"uninstall.dry_run.run_hint": " run without --dry-run to execute",
|
|
1272
|
+
"uninstall.confirm.prompt": "Uninstall '{{name}}'? This cannot be undone.",
|
|
1273
|
+
"uninstall.cancelled": "aborted: user cancelled",
|
|
1274
|
+
"uninstall.completed": "uninstalled {{name}}",
|
|
1275
|
+
"uninstall.unified.nothing": "nothing to do \u2014 no harnessed artifacts found",
|
|
1276
|
+
"uninstall.unified.header": "harnessed uninstall will remove the following:",
|
|
1277
|
+
"uninstall.unified.commands": " Commands: {{count}} harnessed-generated slash command file(s) in ~/.claude/commands/",
|
|
1278
|
+
"uninstall.unified.agent_roles": " Agent roles: {{count}} harnessed-generated codex agent role file(s) in ~/.codex/agents/",
|
|
1279
|
+
"uninstall.unified.skills": " Skills: {{count}} workflow skill directory(ies) in ~/.claude/skills/",
|
|
1280
|
+
"uninstall.unified.settings": " Settings: harnessed env vars (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS, HARNESSED_USER_LANG) from ~/.claude/settings.json",
|
|
1281
|
+
"uninstall.unified.hooks": " Hooks: {{count}} harnessed Stop/UserPromptSubmit hook(s) in ~/.claude/settings.json",
|
|
1282
|
+
"uninstall.unified.state_dir": " State directory: ~/.claude/harnessed/ (includes backups, audit log, state, lock)",
|
|
1283
|
+
"uninstall.unified.upstream_note": "\nUpstream components (npm packages, MCP servers, CC plugins, git-cloned repos, npx skills) are NOT affected.",
|
|
1284
|
+
"uninstall.unified.dry_run_hint": "\n(dry-run \u2014 re-run without --dry-run to actually remove)",
|
|
1285
|
+
"uninstall.unified.confirm": "Remove harnessed's own files? Upstream components (npm packages, MCP servers, CC plugins, etc.) will NOT be affected. This cannot be undone.",
|
|
1286
|
+
"uninstall.unified.removing": "removing harnessed files...",
|
|
1287
|
+
"uninstall.unified.removed_commands": " removed {{count}} command file(s)",
|
|
1288
|
+
"uninstall.unified.removed_agent_roles": " removed {{count}} codex agent role file(s)",
|
|
1289
|
+
"uninstall.unified.removed_skills": " removed {{count}} skill directory(ies)",
|
|
1290
|
+
"uninstall.unified.removed_settings": " removed harnessed env vars from ~/.claude/settings.json",
|
|
1291
|
+
"uninstall.unified.removed_hooks": " removed {{count}} harnessed hook(s) from ~/.claude/settings.json",
|
|
1292
|
+
"uninstall.unified.removed_state_dir": " removed ~/.claude/harnessed/",
|
|
1293
|
+
"uninstall.unified.partial_failure": "\n{{count}} item(s) could not be removed (permission denied or already gone):",
|
|
1294
|
+
"uninstall.unified.complete": "uninstall complete \u2014 harnessed's own files have been removed",
|
|
1295
|
+
"uninstall.unified.cli_hint_header": "\nto remove the harnessed CLI itself (the step above did not \u2014 it only cleared setup files):",
|
|
1296
|
+
"uninstall.unified.cli_hint_binary": " binary: delete {{path}}\n then remove {{dir}} from your PATH",
|
|
1297
|
+
"uninstall.unified.cli_hint_npm": " npm: npm uninstall -g harnessed",
|
|
1298
|
+
"uninstall.unified.cli_hint_other": " installed both ways? remove the other too \u2014 npm: 'npm uninstall -g harnessed' / binary: delete the exe + its bin dir from PATH",
|
|
1299
|
+
"gc.invalid_duration": "error: invalid --older-than '{{value}}'",
|
|
1300
|
+
"gc.invalid_duration.fix": " fix: use format <N>{d|h|m|w} e.g. 30d / 24h / 60m / 4w",
|
|
1301
|
+
"gc.no_backups": "no backups found ({{root}} absent) \u2014 nothing to gc",
|
|
1302
|
+
"gc.no_old_snapshots": "no snapshots older than {{cutoff}} (kept {{keptCount}} most-recent)",
|
|
1303
|
+
"gc.summary_will_delete": "would delete {{count}} snapshot(s), ~{{sizeKb}} KB total:",
|
|
1304
|
+
"gc.summary_deleting": "deleting {{count}} snapshot(s), ~{{sizeKb}} KB total:",
|
|
1305
|
+
"gc.dry_run_rerun_hint": "\n(dry-run \u2014 re-run without --dry-run to actually delete)",
|
|
1306
|
+
"doctor.summary.fail": "\nsome checks failed (see fix hints above)",
|
|
1307
|
+
"doctor.summary.warn": "\nall checks ok (with warnings \u2014 see hints above)",
|
|
1308
|
+
"doctor.summary.pass": "\nall checks passed",
|
|
1309
|
+
"doctor.host_scope": "host: {{host}} \u2014 {{applied}} of {{total}} checks apply\n",
|
|
1310
|
+
"doctor.matrix.legend": "\nn/a = the check is not declared for that host in the registry, so it was not run",
|
|
1311
|
+
"check_docs.clean": "documentation discipline: no violations",
|
|
1312
|
+
"check_docs.state_line_limit": "STATE.md is {{lines}} lines > the {{limit}}-line digest limit \u2014 archive older phase narrative to RETROSPECTIVE.md (override for one run: HARNESSED_ALLOW_LONG_STATE=1)",
|
|
1313
|
+
"check_docs.state_key_decisions": "{{count}} '\u5173\u952E\u51B3\u8BAE ship \u603B\u7ED3' section(s) > {{limit}} \u2014 keep only the current one; move the rest to RETROSPECTIVE.md",
|
|
1314
|
+
"check_docs.state_errata": "historical commentary '{{excerpt}}' belongs in RETROSPECTIVE.md, not in the STATE digest",
|
|
1315
|
+
"check_docs.roadmap_narrative": "closing narrative inlined in an overview doc ({{signals}}) \u2014 ROADMAP carries one line + a pointer per phase; narrative goes to SUMMARY / VERIFICATION",
|
|
1316
|
+
"check_docs.summary_halt": "\ndocumentation discipline: {{halt}} blocking + {{warn}} advisory violation(s)",
|
|
1317
|
+
"check_docs.summary_warn": "\ndocumentation discipline: {{warn}} advisory violation(s) (non-blocking)",
|
|
1318
|
+
"backup.no_backups": "no backups found ({{root}} absent)",
|
|
1319
|
+
"backup.no_backups_empty": "no backups found ({{root}} empty)",
|
|
1320
|
+
"backup.total_snapshots": "\n{{count}} snapshot(s) total",
|
|
1321
|
+
"rollback.metadata_unreadable": "error: cannot read {{path}}: {{message}}",
|
|
1322
|
+
"rollback.metadata_unreadable.fix": " fix: run 'harnessed backup list' to see available timestamps",
|
|
1323
|
+
"rollback.checksum_mismatch": "error: backup checksum mismatch for {{target}} (expected {{expected}}, got {{actual}})",
|
|
1324
|
+
"rollback.restored": "restored {{count}} file(s) from {{timestamp}}",
|
|
1325
|
+
"status.no_installs": "no installs recorded ({{path}} absent or empty)",
|
|
1326
|
+
"status.summary_installs": "\n{{count}} install(s) recorded",
|
|
1327
|
+
"status.lock_held": "\nlock: held (since {{since}}){{staleSuffix}}",
|
|
1328
|
+
"status.lock_held.stale_suffix": " \u2014 STALE",
|
|
1329
|
+
"status.lock_release_hint": " to release: wait for process to finish or delete {{path}}",
|
|
1330
|
+
"status.lock_free": "\nlock: free",
|
|
1331
|
+
"here.no_workflow": "no active workflow for this repo ({{path}} has no entry for cwd)",
|
|
1332
|
+
"here.no_workflow.hint": " to start: run a stage (e.g. `harnessed gates discuss`) or `harnessed run <workflow>`",
|
|
1333
|
+
"audit_log.no_records_file": "no audit records found ({{path}} does not exist)",
|
|
1334
|
+
"audit_log.no_records_empty": "no audit records found (audit.log is empty)",
|
|
1335
|
+
"audit_log.jq_missing": "\u2717 jq not found in PATH \u2014 run: harnessed doctor",
|
|
1336
|
+
"audit_log.tail_invalid": "\u2717 --tail must be a positive integer",
|
|
1337
|
+
"audit_log.head_invalid": "\u2717 --head must be a positive integer",
|
|
1338
|
+
"execute_task.require_task": "error: --task <text> is required",
|
|
1339
|
+
"execute_task.load_phases_failed": "error: failed to load workflows/{{workflow}}/phases.yaml \u2014 {{message}}",
|
|
1340
|
+
"execute_task.precommit_skipped": "\u26A0\uFE0F before-commit pre-flight skipped ({{message}}); subagent will biome-check at commit time.",
|
|
1341
|
+
"research.require_query": "error: --query <text> is required",
|
|
1342
|
+
"manifest_add.non_interactive_warn": "[ee-5-gate] WARN: --non-interactive skips 5-question prompt (D-03 dry-run-only). plan-phase hard reject still applies.",
|
|
1343
|
+
"manifest_add.dry_run_preview": "[manifest-add] dry-run preview for upstream: {{upstream}} \u2192 {{path}}",
|
|
1344
|
+
"manifest_add.empty_answer": "error: EE-5 gate requires non-empty answer",
|
|
1345
|
+
"manifest_add.gate_passed_wrote": "[manifest-add] EE-5 gate passed; wrote {{path}}",
|
|
1346
|
+
"manifest_add.gate_passed_dry_run": "[manifest-add] EE-5 gate passed (dry-run); would write {{path}}",
|
|
1347
|
+
"resume.fail": "\u2717 {{error}}",
|
|
1348
|
+
"resume.corrupt": "\u2717 {{error}}\n path: {{path}}"
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
1351
|
+
});
|
|
1352
|
+
function mapToSupported(raw) {
|
|
1353
|
+
if (!raw) return "en";
|
|
1354
|
+
if (/^zh([^a-z]|$)/i.test(raw)) return "zh-Hans";
|
|
1355
|
+
return "en";
|
|
1234
1356
|
}
|
|
1235
|
-
function
|
|
1236
|
-
const
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1357
|
+
function detectLocale() {
|
|
1358
|
+
const raw = process.env.HARNESSED_LANG || process.env.LC_ALL || process.env.LANG || process.env.LANGUAGE || safeIntlLocale();
|
|
1359
|
+
return mapToSupported(raw);
|
|
1360
|
+
}
|
|
1361
|
+
function safeIntlLocale() {
|
|
1362
|
+
try {
|
|
1363
|
+
return Intl.DateTimeFormat().resolvedOptions().locale;
|
|
1364
|
+
} catch {
|
|
1365
|
+
return void 0;
|
|
1242
1366
|
}
|
|
1243
|
-
if (!node || typeof node !== "object") return { line: null, column: null };
|
|
1244
|
-
const range = node.range;
|
|
1245
|
-
if (!range) return { line: null, column: null };
|
|
1246
|
-
const offset = range[0];
|
|
1247
|
-
const pos = lineCounter.linePos(offset);
|
|
1248
|
-
return { line: pos.line, column: pos.col };
|
|
1249
1367
|
}
|
|
1250
|
-
function
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1368
|
+
function wireMessagesDir(provider) {
|
|
1369
|
+
wiredMessagesDirProvider = provider;
|
|
1370
|
+
}
|
|
1371
|
+
function messagesDir() {
|
|
1372
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
1373
|
+
const candidates = [];
|
|
1374
|
+
if (wiredMessagesDirProvider) {
|
|
1375
|
+
try {
|
|
1376
|
+
candidates.push(wiredMessagesDirProvider());
|
|
1377
|
+
} catch {
|
|
1378
|
+
}
|
|
1257
1379
|
}
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1380
|
+
candidates.push(resolve(here, "..", "..", "messages"), resolve(here, "..", "messages"));
|
|
1381
|
+
for (const c of candidates) {
|
|
1382
|
+
try {
|
|
1383
|
+
readFileSync(join(c, "en.json"), "utf8");
|
|
1384
|
+
return c;
|
|
1385
|
+
} catch {
|
|
1386
|
+
}
|
|
1265
1387
|
}
|
|
1266
|
-
return
|
|
1267
|
-
file,
|
|
1268
|
-
path,
|
|
1269
|
-
message: err2.message ?? "unknown error",
|
|
1270
|
-
line,
|
|
1271
|
-
column,
|
|
1272
|
-
keyword: err2.keyword
|
|
1273
|
-
};
|
|
1388
|
+
return resolve(process.cwd(), "messages");
|
|
1274
1389
|
}
|
|
1275
|
-
function
|
|
1276
|
-
return
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
}
|
|
1390
|
+
function loadLocale(locale) {
|
|
1391
|
+
if (cache[locale]) return cache[locale];
|
|
1392
|
+
const path = join(messagesDir(), `${locale}.json`);
|
|
1393
|
+
try {
|
|
1394
|
+
const raw = readFileSync(path, "utf8");
|
|
1395
|
+
cache[locale] = JSON.parse(raw);
|
|
1396
|
+
} catch {
|
|
1397
|
+
cache[locale] = locale === "en" ? en_default : {};
|
|
1398
|
+
}
|
|
1399
|
+
return cache[locale];
|
|
1284
1400
|
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1401
|
+
function setLocale(locale) {
|
|
1402
|
+
if (!locale) return;
|
|
1403
|
+
const mapped = mapToSupported(locale);
|
|
1404
|
+
if (SUPPORTED.has(mapped)) currentLocale = mapped;
|
|
1405
|
+
}
|
|
1406
|
+
function getLocale() {
|
|
1407
|
+
if (currentLocale === null) currentLocale = detectLocale();
|
|
1408
|
+
return currentLocale;
|
|
1409
|
+
}
|
|
1410
|
+
function t(key, params) {
|
|
1411
|
+
const locale = getLocale();
|
|
1412
|
+
const primary = loadLocale(locale);
|
|
1413
|
+
let template = primary[key];
|
|
1414
|
+
if (template === void 0 && locale !== "en") {
|
|
1415
|
+
template = loadLocale("en")[key];
|
|
1416
|
+
}
|
|
1417
|
+
if (template === void 0) template = key;
|
|
1418
|
+
if (!params) return template;
|
|
1419
|
+
return template.replace(/\{\{(\w+)\}\}/g, (_match, name) => {
|
|
1420
|
+
const v = params[name];
|
|
1421
|
+
return v === void 0 ? `{{${name}}}` : String(v);
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1424
|
+
var SUPPORTED, currentLocale, cache, wiredMessagesDirProvider;
|
|
1425
|
+
var init_i18n = __esm({
|
|
1426
|
+
"src/i18n/index.ts"() {
|
|
1427
|
+
init_en();
|
|
1428
|
+
SUPPORTED = /* @__PURE__ */ new Set(["en", "zh-Hans"]);
|
|
1429
|
+
currentLocale = null;
|
|
1430
|
+
cache = {};
|
|
1431
|
+
wiredMessagesDirProvider = null;
|
|
1287
1432
|
}
|
|
1288
1433
|
});
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1434
|
+
function getPackageRoot() {
|
|
1435
|
+
const thisFile = fileURLToPath(import.meta.url);
|
|
1436
|
+
const thisDir = dirname(thisFile);
|
|
1437
|
+
if (thisDir.endsWith("dist") || thisDir.replace(/\\/g, "/").endsWith("/dist")) {
|
|
1438
|
+
return resolve(thisDir, "..");
|
|
1439
|
+
}
|
|
1440
|
+
return resolve(thisDir, "..", "..");
|
|
1441
|
+
}
|
|
1442
|
+
var init_packagePath = __esm({
|
|
1443
|
+
"src/platform/packagePath.ts"() {
|
|
1444
|
+
}
|
|
1445
|
+
});
|
|
1446
|
+
|
|
1447
|
+
// src/platform/assetsRoot.ts
|
|
1448
|
+
var assetsRoot_exports = {};
|
|
1449
|
+
__export(assetsRoot_exports, {
|
|
1450
|
+
compiledAssetsDir: () => compiledAssetsDir,
|
|
1451
|
+
computeAssetsRoot: () => computeAssetsRoot,
|
|
1452
|
+
getAssetsRoot: () => getAssetsRoot,
|
|
1453
|
+
isCompiledModuleUrl: () => isCompiledModuleUrl,
|
|
1454
|
+
isCompiledRuntime: () => isCompiledRuntime
|
|
1455
|
+
});
|
|
1456
|
+
function isCompiledRuntime(url = import.meta.url) {
|
|
1457
|
+
return isCompiledModuleUrl(url);
|
|
1458
|
+
}
|
|
1459
|
+
function isCompiledModuleUrl(url) {
|
|
1460
|
+
let s = url;
|
|
1461
|
+
try {
|
|
1462
|
+
s = decodeURIComponent(url);
|
|
1463
|
+
} catch {
|
|
1464
|
+
}
|
|
1465
|
+
const normalized2 = s.replace(/\\/g, "/").toLowerCase();
|
|
1466
|
+
return BUNFS_MARKERS.some((m) => normalized2.includes(m));
|
|
1467
|
+
}
|
|
1468
|
+
function computeAssetsRoot(d) {
|
|
1469
|
+
const override = d.env.HARNESSED_ASSETS_OVERRIDE;
|
|
1470
|
+
if (override && override.trim().length > 0) {
|
|
1471
|
+
return { root: override.trim(), source: "override", compiledAssetsMissing: false };
|
|
1472
|
+
}
|
|
1473
|
+
if (isCompiledModuleUrl(d.moduleUrl)) {
|
|
1474
|
+
const root = join(d.stateRoot(), "assets", d.version);
|
|
1475
|
+
const present = d.exists(join(root, "workflows"));
|
|
1476
|
+
return { root, source: "compiled", compiledAssetsMissing: !present };
|
|
1477
|
+
}
|
|
1478
|
+
return { root: d.packageRoot, source: "package", compiledAssetsMissing: false };
|
|
1479
|
+
}
|
|
1480
|
+
function compiledAssetsDir(version) {
|
|
1481
|
+
return join(detectPlatform().stateRoot, "assets", version);
|
|
1482
|
+
}
|
|
1483
|
+
function realDeps() {
|
|
1484
|
+
return {
|
|
1485
|
+
env: process.env,
|
|
1486
|
+
moduleUrl: import.meta.url,
|
|
1487
|
+
exists: (p8) => {
|
|
1488
|
+
try {
|
|
1489
|
+
return existsSync(p8);
|
|
1490
|
+
} catch {
|
|
1491
|
+
return false;
|
|
1492
|
+
}
|
|
1493
|
+
},
|
|
1494
|
+
stateRoot: () => detectPlatform().stateRoot,
|
|
1495
|
+
packageRoot: getPackageRoot(),
|
|
1496
|
+
version: package_default.version
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
function getAssetsRoot() {
|
|
1500
|
+
const r = computeAssetsRoot(realDeps());
|
|
1501
|
+
if (r.source === "compiled" && r.compiledAssetsMissing && !warnedMissing) {
|
|
1502
|
+
warnedMissing = true;
|
|
1503
|
+
console.error(
|
|
1504
|
+
`warning: compiled harnessed binary but bundled assets are not unpacked at ${r.root} \u2014 asset-dependent commands (setup / run / prompt / install) will fail. Reinstall the binary, or use the npm distribution (npm i -g harnessed). (asset unpack pipeline lands in a later release \u2014 B1 seam)`
|
|
1505
|
+
);
|
|
1506
|
+
}
|
|
1507
|
+
return r.root;
|
|
1508
|
+
}
|
|
1509
|
+
var BUNFS_MARKERS, warnedMissing;
|
|
1510
|
+
var init_assetsRoot = __esm({
|
|
1511
|
+
"src/platform/assetsRoot.ts"() {
|
|
1512
|
+
init_package();
|
|
1513
|
+
init_packagePath();
|
|
1514
|
+
init_platform();
|
|
1515
|
+
BUNFS_MARKERS = ["/$bunfs/", "/~bun/"];
|
|
1516
|
+
warnedMissing = false;
|
|
1517
|
+
}
|
|
1518
|
+
});
|
|
1519
|
+
function resolveLocaleYaml(dir, baseName, locale = getLocale()) {
|
|
1520
|
+
if (locale !== "en") {
|
|
1521
|
+
const sibling = join(dir, `${baseName}.${locale}.yaml`);
|
|
1522
|
+
if (existsSync(sibling)) return sibling;
|
|
1523
|
+
}
|
|
1524
|
+
return join(dir, `${baseName}.yaml`);
|
|
1525
|
+
}
|
|
1526
|
+
var init_localeYaml = __esm({
|
|
1527
|
+
"src/i18n/localeYaml.ts"() {
|
|
1528
|
+
init_i18n();
|
|
1529
|
+
}
|
|
1530
|
+
});
|
|
1531
|
+
async function loadRolePrompts(workflowsDir, locale = getLocale()) {
|
|
1532
|
+
const path = resolveLocaleYaml(workflowsDir, "role-prompts", locale);
|
|
1533
|
+
let raw;
|
|
1534
|
+
try {
|
|
1535
|
+
raw = await readFile(path, "utf8");
|
|
1536
|
+
} catch {
|
|
1537
|
+
return {};
|
|
1538
|
+
}
|
|
1539
|
+
const doc = parse(raw);
|
|
1540
|
+
return doc?.prompts ?? {};
|
|
1541
|
+
}
|
|
1542
|
+
function mapRolePromptText(rp, render) {
|
|
1543
|
+
const s = (v) => typeof v === "string" ? render(v) : v;
|
|
1544
|
+
return {
|
|
1545
|
+
...rp,
|
|
1546
|
+
specialist: s(rp.specialist),
|
|
1547
|
+
responsibility: s(rp.responsibility),
|
|
1548
|
+
checklist: Array.isArray(rp.checklist) ? rp.checklist.map((c) => s(c)) : rp.checklist,
|
|
1549
|
+
severity: s(rp.severity)
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
function mapRolePromptsText(prompts, render) {
|
|
1553
|
+
const out = {};
|
|
1554
|
+
for (const [name, rp] of Object.entries(prompts)) out[name] = mapRolePromptText(rp, render);
|
|
1555
|
+
return out;
|
|
1556
|
+
}
|
|
1557
|
+
var init_rolePrompts = __esm({
|
|
1558
|
+
"src/workflow/rolePrompts.ts"() {
|
|
1559
|
+
init_i18n();
|
|
1560
|
+
init_localeYaml();
|
|
1561
|
+
}
|
|
1562
|
+
});
|
|
1563
|
+
async function scanWorkflowsNested(workflowsDir, entries) {
|
|
1564
|
+
const workflows = [];
|
|
1565
|
+
for (const entry of entries.sort()) {
|
|
1566
|
+
if (NON_WORKFLOW_DIRS.has(entry)) continue;
|
|
1567
|
+
const src = join(workflowsDir, entry);
|
|
1568
|
+
let s;
|
|
1569
|
+
try {
|
|
1570
|
+
s = await stat(src);
|
|
1571
|
+
} catch {
|
|
1572
|
+
continue;
|
|
1573
|
+
}
|
|
1574
|
+
if (!s.isDirectory()) continue;
|
|
1575
|
+
let hasFlatSkill = false;
|
|
1576
|
+
try {
|
|
1577
|
+
await stat(join(src, "SKILL.md"));
|
|
1578
|
+
hasFlatSkill = true;
|
|
1579
|
+
} catch {
|
|
1580
|
+
hasFlatSkill = false;
|
|
1581
|
+
}
|
|
1582
|
+
if (hasFlatSkill) {
|
|
1583
|
+
if (FLAT_LEGACY_KEEP.has(entry)) {
|
|
1584
|
+
workflows.push({ name: entry, relPath: entry, isMaster: FLAT_TOP_LEVEL_MASTERS.has(entry) });
|
|
1585
|
+
continue;
|
|
1586
|
+
}
|
|
1587
|
+
workflows.push({ name: entry, relPath: entry, isMaster: false });
|
|
1588
|
+
continue;
|
|
1589
|
+
}
|
|
1590
|
+
let subEntries;
|
|
1591
|
+
try {
|
|
1592
|
+
subEntries = await readdir(src);
|
|
1593
|
+
} catch {
|
|
1594
|
+
continue;
|
|
1595
|
+
}
|
|
1596
|
+
for (const sub of subEntries.sort()) {
|
|
1597
|
+
const subDir = join(src, sub);
|
|
1598
|
+
let ss;
|
|
1599
|
+
try {
|
|
1600
|
+
ss = await stat(subDir);
|
|
1601
|
+
} catch {
|
|
1602
|
+
continue;
|
|
1603
|
+
}
|
|
1604
|
+
if (!ss.isDirectory()) continue;
|
|
1605
|
+
try {
|
|
1606
|
+
await stat(join(subDir, "SKILL.md"));
|
|
1607
|
+
} catch {
|
|
1608
|
+
continue;
|
|
1609
|
+
}
|
|
1610
|
+
const name = sub === "auto" ? entry : `${entry}-${sub}`;
|
|
1611
|
+
workflows.push({ name, relPath: `${entry}/${sub}`, isMaster: sub === "auto" });
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
return { workflows };
|
|
1615
|
+
}
|
|
1616
|
+
var FLAT_LEGACY_KEEP, FLAT_TOP_LEVEL_MASTERS, NON_WORKFLOW_DIRS;
|
|
1617
|
+
var init_scan_nested = __esm({
|
|
1618
|
+
"src/workflow/scan-nested.ts"() {
|
|
1619
|
+
FLAT_LEGACY_KEEP = /* @__PURE__ */ new Set(["research", "retro", "auto"]);
|
|
1620
|
+
FLAT_TOP_LEVEL_MASTERS = /* @__PURE__ */ new Set(["auto"]);
|
|
1621
|
+
NON_WORKFLOW_DIRS = /* @__PURE__ */ new Set(["disciplines", "judgments"]);
|
|
1622
|
+
}
|
|
1623
|
+
});
|
|
1624
|
+
function toHostId(id) {
|
|
1625
|
+
return id === "codex" ? "codex" : "claude";
|
|
1626
|
+
}
|
|
1627
|
+
async function loadHostPrimitives(opts) {
|
|
1628
|
+
const path = resolveLocaleYaml(opts.workflowsDir, YAML_BASE, opts.locale ?? getLocale());
|
|
1629
|
+
let raw;
|
|
1630
|
+
try {
|
|
1631
|
+
raw = await readFile(path, "utf8");
|
|
1632
|
+
} catch {
|
|
1633
|
+
return {};
|
|
1634
|
+
}
|
|
1635
|
+
const doc = parse(raw);
|
|
1636
|
+
return doc?.primitives ?? {};
|
|
1637
|
+
}
|
|
1638
|
+
async function loadHostMapNotes(opts) {
|
|
1639
|
+
const path = resolveLocaleYaml(opts.workflowsDir, YAML_BASE, opts.locale ?? getLocale());
|
|
1640
|
+
let raw;
|
|
1641
|
+
try {
|
|
1642
|
+
raw = await readFile(path, "utf8");
|
|
1643
|
+
} catch {
|
|
1644
|
+
return [];
|
|
1645
|
+
}
|
|
1646
|
+
const doc = parse(raw);
|
|
1647
|
+
const notes = doc?.host_map_notes?.[opts.host];
|
|
1648
|
+
return Array.isArray(notes) ? notes.filter((n) => typeof n === "string") : [];
|
|
1649
|
+
}
|
|
1650
|
+
function loadHostPrimitivesCached(opts) {
|
|
1651
|
+
const locale = opts.locale ?? getLocale();
|
|
1652
|
+
const key = `${opts.workflowsDir}|${locale}`;
|
|
1653
|
+
const hit = _tableCache.get(key);
|
|
1654
|
+
if (hit) return hit;
|
|
1655
|
+
const p8 = loadHostPrimitives({ workflowsDir: opts.workflowsDir, locale });
|
|
1656
|
+
_tableCache.set(key, p8);
|
|
1657
|
+
return p8;
|
|
1658
|
+
}
|
|
1659
|
+
function templateRe() {
|
|
1660
|
+
return new RegExp(HOST_PRIMITIVE_TEMPLATE.source, "g");
|
|
1661
|
+
}
|
|
1662
|
+
function lineOf(body, offset) {
|
|
1663
|
+
let line = 1;
|
|
1664
|
+
for (let i = 0; i < offset && i < body.length; i++) if (body[i] === "\n") line++;
|
|
1665
|
+
return line;
|
|
1666
|
+
}
|
|
1667
|
+
function renderHostPrimitives(body, opts) {
|
|
1668
|
+
const { host, table } = opts;
|
|
1669
|
+
return body.replace(
|
|
1670
|
+
templateRe(),
|
|
1671
|
+
(match, primitive, variant, offset) => {
|
|
1672
|
+
const name = variant ?? DEFAULT_VARIANT;
|
|
1673
|
+
const where = `'${match}' at line ${lineOf(body, offset)} (offset ${offset})`;
|
|
1674
|
+
const variants = table[primitive];
|
|
1675
|
+
if (!variants) {
|
|
1676
|
+
throw new Error(
|
|
1677
|
+
`unknown host primitive 'host.${primitive}' \u2014 ${where}; not defined in host-primitives.yaml`
|
|
1678
|
+
);
|
|
1679
|
+
}
|
|
1680
|
+
const entry = variants[name];
|
|
1681
|
+
if (!entry) {
|
|
1682
|
+
throw new Error(
|
|
1683
|
+
`unknown variant '${name}' for host primitive '${primitive}' \u2014 ${where}; defined variants: ${Object.keys(variants).sort().join(", ") || "(none)"}`
|
|
1684
|
+
);
|
|
1685
|
+
}
|
|
1686
|
+
const text = entry[host];
|
|
1687
|
+
if (text === void 0) {
|
|
1688
|
+
throw new Error(
|
|
1689
|
+
`host primitive '${primitive}.${name}' has no text for host '${host}' \u2014 ${where}; defined hosts: ${Object.keys(entry).sort().join(", ") || "(none)"}`
|
|
1690
|
+
);
|
|
1691
|
+
}
|
|
1692
|
+
return text;
|
|
1693
|
+
}
|
|
1694
|
+
);
|
|
1695
|
+
}
|
|
1696
|
+
function cell(text) {
|
|
1697
|
+
return text.replaceAll("|", "\\|");
|
|
1698
|
+
}
|
|
1699
|
+
function code(text) {
|
|
1700
|
+
return text.includes("`") ? text : `\`${text}\``;
|
|
1701
|
+
}
|
|
1702
|
+
function hostMapRows(table) {
|
|
1703
|
+
const rows = [];
|
|
1704
|
+
for (const primitive of Object.keys(table).sort()) {
|
|
1705
|
+
const entry = table[primitive]?.[DEFAULT_VARIANT];
|
|
1706
|
+
const claude = entry?.claude;
|
|
1707
|
+
const codex = entry?.codex;
|
|
1708
|
+
if (claude === void 0 || codex === void 0) continue;
|
|
1709
|
+
if (claude.includes("\n") || codex.includes("\n")) continue;
|
|
1710
|
+
if (claude.length > TERM_MAX_LEN || codex.length > TERM_MAX_LEN) continue;
|
|
1711
|
+
rows.push({ primitive, claude, codex });
|
|
1712
|
+
}
|
|
1713
|
+
return rows;
|
|
1714
|
+
}
|
|
1715
|
+
function buildHostMapSection(opts) {
|
|
1716
|
+
const { host, table } = opts;
|
|
1717
|
+
if (host === "claude") return "";
|
|
1718
|
+
const rows = hostMapRows(table);
|
|
1719
|
+
const notes = opts.notes ?? [];
|
|
1720
|
+
if (rows.length === 0 && notes.length === 0) return "";
|
|
1721
|
+
const skillsDir = table.skills_dir?.[DEFAULT_VARIANT]?.[host];
|
|
1722
|
+
const where = skillsDir ? ` and installed it under ${code(skillsDir)}` : "";
|
|
1723
|
+
const lines = [
|
|
1724
|
+
HOST_MAP_START,
|
|
1725
|
+
`## Host map \u2014 ${host}`,
|
|
1726
|
+
"",
|
|
1727
|
+
`harnessed rendered this artifact for the **${host}** harness${where}. The workflow prose was authored against Claude Code, so where a step names a tool it names the ${host} one. Use the table to decode any instruction that still reads as Claude-Code-shaped; do not substitute the Claude Code names back.`
|
|
1728
|
+
];
|
|
1729
|
+
if (rows.length > 0) {
|
|
1730
|
+
lines.push(
|
|
1731
|
+
"",
|
|
1732
|
+
`| primitive | Claude Code | ${host} |`,
|
|
1733
|
+
"| --- | --- | --- |",
|
|
1734
|
+
...rows.map(
|
|
1735
|
+
(r) => `| \`${r.primitive}\` | ${cell(code(r.claude))} | ${cell(code(r.codex))} |`
|
|
1736
|
+
)
|
|
1737
|
+
);
|
|
1738
|
+
}
|
|
1739
|
+
if (notes.length > 0) {
|
|
1740
|
+
lines.push("", "Caveats \u2014 these hold for the whole artifact:", "");
|
|
1741
|
+
for (const n of notes) lines.push(`- ${n}`);
|
|
1742
|
+
}
|
|
1743
|
+
lines.push(HOST_MAP_END);
|
|
1744
|
+
return lines.join("\n");
|
|
1745
|
+
}
|
|
1746
|
+
function regionRe() {
|
|
1747
|
+
const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1748
|
+
return new RegExp(`${esc(HOST_MAP_START)}[\\s\\S]*?${esc(HOST_MAP_END)}\\n*`, "g");
|
|
1749
|
+
}
|
|
1750
|
+
function insertHostMapSection(body, section) {
|
|
1751
|
+
if (section === "") return body;
|
|
1752
|
+
const stripped = body.replace(regionRe(), "");
|
|
1753
|
+
const fm = FRONTMATTER_RX.exec(stripped);
|
|
1754
|
+
const offset = fm ? fm[0].length : 0;
|
|
1755
|
+
const before = stripped.slice(0, offset);
|
|
1756
|
+
const after = stripped.slice(offset).replace(/^\n+/, "");
|
|
1757
|
+
const lead = offset === 0 ? "" : "\n";
|
|
1758
|
+
return `${before}${lead}${section}
|
|
1759
|
+
|
|
1760
|
+
${after}`;
|
|
1761
|
+
}
|
|
1762
|
+
var DEFAULT_VARIANT, YAML_BASE, _tableCache, HOST_PRIMITIVE_TEMPLATE, HOST_MAP_START, HOST_MAP_END, TERM_MAX_LEN, FRONTMATTER_RX;
|
|
1763
|
+
var init_hostPrimitives = __esm({
|
|
1764
|
+
"src/cli/lib/hostPrimitives.ts"() {
|
|
1765
|
+
init_i18n();
|
|
1766
|
+
init_localeYaml();
|
|
1767
|
+
DEFAULT_VARIANT = "default";
|
|
1768
|
+
YAML_BASE = "host-primitives";
|
|
1769
|
+
_tableCache = /* @__PURE__ */ new Map();
|
|
1770
|
+
HOST_PRIMITIVE_TEMPLATE = /\{\{\s*host\.([A-Za-z0-9_-]+)(?:\.([A-Za-z0-9_-]+))?\s*\}\}/g;
|
|
1771
|
+
HOST_MAP_START = "<!-- harnessed:host-map:start -->";
|
|
1772
|
+
HOST_MAP_END = "<!-- harnessed:host-map:end -->";
|
|
1773
|
+
TERM_MAX_LEN = 64;
|
|
1774
|
+
FRONTMATTER_RX = /^---[ \t]*\r?\n[\s\S]*?\r?\n---[ \t]*(\r?\n|$)/;
|
|
1775
|
+
}
|
|
1776
|
+
});
|
|
1777
|
+
|
|
1778
|
+
// src/cli/lib/agentsMd.ts
|
|
1779
|
+
var agentsMd_exports = {};
|
|
1780
|
+
__export(agentsMd_exports, {
|
|
1781
|
+
AGENTS_MD_END: () => AGENTS_MD_END,
|
|
1782
|
+
AGENTS_MD_START: () => AGENTS_MD_START,
|
|
1783
|
+
agentsMdPath: () => agentsMdPath,
|
|
1784
|
+
buildAgentsMdSection: () => buildAgentsMdSection,
|
|
1785
|
+
insertAgentsMdSection: () => insertAgentsMdSection,
|
|
1786
|
+
resolveCommandNames: () => resolveCommandNames,
|
|
1787
|
+
runAgentsMd: () => runAgentsMd,
|
|
1788
|
+
stripAgentsMdSection: () => stripAgentsMdSection
|
|
1789
|
+
});
|
|
1790
|
+
function agentsMdPath() {
|
|
1791
|
+
return join(detectPlatform().homeDir, "AGENTS.md");
|
|
1792
|
+
}
|
|
1793
|
+
function buildAgentsMdSection(opts) {
|
|
1794
|
+
const { commands, commandsDir, table } = opts;
|
|
1795
|
+
const hostMap = buildHostMapSection({ host: "codex", table, notes: opts.notes });
|
|
1796
|
+
const lines = [
|
|
1797
|
+
AGENTS_MD_START,
|
|
1798
|
+
"",
|
|
1799
|
+
"## harnessed",
|
|
1800
|
+
"",
|
|
1801
|
+
"This block is GENERATED by `harnessed agents-md`. Edits inside the markers are",
|
|
1802
|
+
"overwritten on the next run; put anything hand-written OUTSIDE them.",
|
|
1803
|
+
"",
|
|
1804
|
+
`harnessed installs its slash commands as prompt files under \`${commandsDir}\`.`,
|
|
1805
|
+
"Invoke one by name to enter the orchestration engine:",
|
|
1806
|
+
"",
|
|
1807
|
+
...commands.length > 0 ? commands.map((c) => `- \`/${c}\``) : ["- (none installed \u2014 run `harnessed setup`)"],
|
|
1808
|
+
"",
|
|
1809
|
+
"Each command file carries its own description in frontmatter; read it there rather",
|
|
1810
|
+
"than guessing from the name.",
|
|
1811
|
+
""
|
|
1812
|
+
];
|
|
1813
|
+
if (hostMap !== "") lines.push(hostMap.trimEnd(), "");
|
|
1814
|
+
lines.push(AGENTS_MD_END, "");
|
|
1815
|
+
return lines.join("\n");
|
|
1816
|
+
}
|
|
1817
|
+
function stripAgentsMdSection(body) {
|
|
1818
|
+
const a = body.indexOf(AGENTS_MD_START);
|
|
1819
|
+
if (a === -1) return body;
|
|
1820
|
+
const b = body.indexOf(AGENTS_MD_END, a);
|
|
1821
|
+
if (b === -1) return body;
|
|
1822
|
+
const head = body.slice(0, a);
|
|
1823
|
+
const tail = body.slice(b + AGENTS_MD_END.length);
|
|
1824
|
+
return `${head.replace(/\n+$/, "\n")}${tail.replace(/^\n+/, "")}`;
|
|
1825
|
+
}
|
|
1826
|
+
function insertAgentsMdSection(body, section) {
|
|
1827
|
+
const base = stripAgentsMdSection(body);
|
|
1828
|
+
if (section === "") return base;
|
|
1829
|
+
const sep3 = base === "" || base.endsWith("\n\n") ? "" : base.endsWith("\n") ? "\n" : "\n\n";
|
|
1830
|
+
return `${base}${sep3}${section}`;
|
|
1831
|
+
}
|
|
1832
|
+
async function resolveCommandNames(workflowsDir) {
|
|
1833
|
+
const { readdir: readdir19 } = await import('fs/promises');
|
|
1834
|
+
const entries = await readdir19(workflowsDir);
|
|
1835
|
+
const { workflows } = await scanWorkflowsNested(workflowsDir, entries);
|
|
1836
|
+
const prompts = await loadRolePrompts(workflowsDir);
|
|
1837
|
+
return workflows.map((w) => w.name).filter((n) => prompts[n] !== void 0).sort();
|
|
1838
|
+
}
|
|
1839
|
+
async function runAgentsMd(opts) {
|
|
1840
|
+
const path = agentsMdPath();
|
|
1841
|
+
const read2 = opts.deps?.readFile ?? ((p8) => readFile(p8, "utf8"));
|
|
1842
|
+
const write = opts.deps?.writeFile ?? ((p8, c) => writeFile(p8, c, "utf8"));
|
|
1843
|
+
let current = "";
|
|
1844
|
+
let existed = true;
|
|
1845
|
+
try {
|
|
1846
|
+
current = await read2(path);
|
|
1847
|
+
} catch {
|
|
1848
|
+
existed = false;
|
|
1849
|
+
}
|
|
1850
|
+
if (opts.remove === true) {
|
|
1851
|
+
if (!existed) return { status: "absent", path };
|
|
1852
|
+
const next2 = stripAgentsMdSection(current);
|
|
1853
|
+
if (next2 === current) return { status: "unchanged", path };
|
|
1854
|
+
if (opts.dryRun !== true) await write(path, next2);
|
|
1855
|
+
return { status: "removed", path };
|
|
1856
|
+
}
|
|
1857
|
+
const locale = opts.locale ?? "en";
|
|
1858
|
+
const section = buildAgentsMdSection({
|
|
1859
|
+
commands: await resolveCommandNames(opts.workflowsDir),
|
|
1860
|
+
commandsDir: detectPlatform().commandsDir,
|
|
1861
|
+
table: await loadHostPrimitives({ workflowsDir: opts.workflowsDir, locale }),
|
|
1862
|
+
notes: await loadHostMapNotes({ workflowsDir: opts.workflowsDir, locale, host: "codex" })
|
|
1863
|
+
});
|
|
1864
|
+
const next = insertAgentsMdSection(current, section);
|
|
1865
|
+
if (existed && next === current) return { status: "unchanged", path };
|
|
1866
|
+
const action = !existed ? "create" : current.includes(AGENTS_MD_START) ? "replace" : "append";
|
|
1867
|
+
if (opts.dryRun === true) return { status: "preview", path, action, section };
|
|
1868
|
+
await write(path, next);
|
|
1869
|
+
return { status: "written", path, action };
|
|
1870
|
+
}
|
|
1871
|
+
var AGENTS_MD_START, AGENTS_MD_END;
|
|
1872
|
+
var init_agentsMd = __esm({
|
|
1873
|
+
"src/cli/lib/agentsMd.ts"() {
|
|
1874
|
+
init_platform();
|
|
1875
|
+
init_rolePrompts();
|
|
1876
|
+
init_scan_nested();
|
|
1877
|
+
init_hostPrimitives();
|
|
1878
|
+
AGENTS_MD_START = "<!-- harnessed:agents-md:start -->";
|
|
1879
|
+
AGENTS_MD_END = "<!-- harnessed:agents-md:end -->";
|
|
1880
|
+
}
|
|
1881
|
+
});
|
|
1882
|
+
|
|
1883
|
+
// src/manifest/errors.ts
|
|
1884
|
+
function instancePathToKeyPath(instancePath) {
|
|
1885
|
+
if (!instancePath || instancePath === "/") return [];
|
|
1886
|
+
return instancePath.split("/").filter(Boolean).map((seg) => {
|
|
1887
|
+
const n = Number(seg);
|
|
1888
|
+
return Number.isInteger(n) && String(n) === seg ? n : seg;
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
function locateLineFromDoc(doc, lineCounter, instancePath) {
|
|
1892
|
+
const path = instancePathToKeyPath(instancePath);
|
|
1893
|
+
let node;
|
|
1894
|
+
if (path.length === 0) {
|
|
1895
|
+
node = doc.contents;
|
|
1896
|
+
} else {
|
|
1897
|
+
node = doc.getIn(path, true);
|
|
1898
|
+
}
|
|
1899
|
+
if (!node || typeof node !== "object") return { line: null, column: null };
|
|
1900
|
+
const range = node.range;
|
|
1901
|
+
if (!range) return { line: null, column: null };
|
|
1902
|
+
const offset = range[0];
|
|
1903
|
+
const pos = lineCounter.linePos(offset);
|
|
1904
|
+
return { line: pos.line, column: pos.col };
|
|
1905
|
+
}
|
|
1906
|
+
function ajvErrorToFriendly(err2, file, doc, lineCounter) {
|
|
1907
|
+
let path = err2.instancePath || "/";
|
|
1908
|
+
const params = err2.params;
|
|
1909
|
+
if (err2.keyword === "additionalProperties" && params && typeof params.additionalProperty === "string") {
|
|
1910
|
+
path = `${path}/${params.additionalProperty}`;
|
|
1911
|
+
} else if (err2.keyword === "required" && params && typeof params.missingProperty === "string") {
|
|
1912
|
+
path = `${path}/${params.missingProperty}`;
|
|
1913
|
+
}
|
|
1914
|
+
let line = null;
|
|
1915
|
+
let column = null;
|
|
1916
|
+
if (doc && lineCounter) {
|
|
1917
|
+
const lookupPath = err2.keyword === "required" ? err2.instancePath || "/" : path;
|
|
1918
|
+
const loc = locateLineFromDoc(doc, lineCounter, lookupPath);
|
|
1919
|
+
line = loc.line;
|
|
1920
|
+
column = loc.column;
|
|
1921
|
+
}
|
|
1922
|
+
return {
|
|
1923
|
+
file,
|
|
1924
|
+
path,
|
|
1925
|
+
message: err2.message ?? "unknown error",
|
|
1926
|
+
line,
|
|
1927
|
+
column,
|
|
1928
|
+
keyword: err2.keyword
|
|
1929
|
+
};
|
|
1930
|
+
}
|
|
1931
|
+
function yamlParseErrorToFriendly(err2, file) {
|
|
1932
|
+
return {
|
|
1933
|
+
file,
|
|
1934
|
+
path: "/",
|
|
1935
|
+
message: err2.message,
|
|
1936
|
+
line: err2.linePos?.[0]?.line ?? null,
|
|
1937
|
+
column: err2.linePos?.[0]?.col ?? null,
|
|
1938
|
+
keyword: "yaml-parse"
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1941
|
+
var init_errors = __esm({
|
|
1942
|
+
"src/manifest/errors.ts"() {
|
|
1943
|
+
}
|
|
1944
|
+
});
|
|
1945
|
+
var ApiVersion, Kind, SpdxLicense, LicenseSource, Upstream, MetadataSchema;
|
|
1946
|
+
var init_metadata = __esm({
|
|
1947
|
+
"src/manifest/schema/metadata.ts"() {
|
|
1292
1948
|
ApiVersion = Type.Literal("harnessed/v1");
|
|
1293
1949
|
Kind = Type.Literal("Manifest");
|
|
1294
1950
|
SpdxLicense = Type.Union([
|
|
@@ -1748,7 +2404,7 @@ var init_schema2 = __esm({
|
|
|
1748
2404
|
};
|
|
1749
2405
|
}
|
|
1750
2406
|
});
|
|
1751
|
-
function
|
|
2407
|
+
function lineOf2(node, lineCounter) {
|
|
1752
2408
|
if (!node?.range) return null;
|
|
1753
2409
|
const offset = node.range[0];
|
|
1754
2410
|
return lineCounter.linePos(offset).line;
|
|
@@ -1770,7 +2426,7 @@ function checkScalarCmd(doc, lineCounter, path, filename) {
|
|
|
1770
2426
|
file: filename,
|
|
1771
2427
|
path: `/${path.join("/")}`,
|
|
1772
2428
|
message: `shell escape detected: '${pat.label}' (${pat.hint}) at ${path.join(".")} \u2014 v0.1 forbids dynamic shell evaluation; v0.2 will use \`requires_secret\` + \`\${secret:KEY}\` for env placeholders`,
|
|
1773
|
-
line:
|
|
2429
|
+
line: lineOf2(node, lineCounter),
|
|
1774
2430
|
column: null,
|
|
1775
2431
|
keyword: "security"
|
|
1776
2432
|
};
|
|
@@ -1810,7 +2466,7 @@ function checkSecurityViolations(doc, filename, lineCounter) {
|
|
|
1810
2466
|
file: filename,
|
|
1811
2467
|
path: `/spec/uninstall/cleanup_paths/${idx}`,
|
|
1812
2468
|
message: `shell escape detected: '${pat.label}' (${pat.hint}) at spec.uninstall.cleanup_paths[${idx}] \u2014 v0.1 forbids dynamic shell evaluation`,
|
|
1813
|
-
line:
|
|
2469
|
+
line: lineOf2(item, lineCounter),
|
|
1814
2470
|
column: null,
|
|
1815
2471
|
keyword: "security"
|
|
1816
2472
|
});
|
|
@@ -1911,278 +2567,70 @@ var init_validate = __esm({
|
|
|
1911
2567
|
strictSchema: true,
|
|
1912
2568
|
strictTypes: true,
|
|
1913
2569
|
strictRequired: true,
|
|
1914
|
-
allErrors: true,
|
|
1915
|
-
discriminator: true,
|
|
1916
|
-
allowUnionTypes: false
|
|
1917
|
-
})
|
|
1918
|
-
);
|
|
1919
|
-
_compiled = null;
|
|
1920
|
-
INSTALL_TYPE_METHODS = {
|
|
1921
|
-
npm: ["npm-cli"],
|
|
1922
|
-
mcp: ["mcp-stdio-add", "mcp-http-add"],
|
|
1923
|
-
git: ["git-clone-with-setup"],
|
|
1924
|
-
skill: ["cc-plugin-marketplace", "npx-skill-installer"],
|
|
1925
|
-
// 5th install_type (Phase 2.4). Missing here meant `install_type: hook` accepted
|
|
1926
|
-
// ANY method: an unconstrained bucket, not a closed one (external review L10).
|
|
1927
|
-
hook: ["cc-hook-add"]
|
|
1928
|
-
};
|
|
1929
|
-
}
|
|
1930
|
-
});
|
|
1931
|
-
|
|
1932
|
-
// src/cli/lib/origin-check.ts
|
|
1933
|
-
var origin_check_exports = {};
|
|
1934
|
-
__export(origin_check_exports, {
|
|
1935
|
-
checkOrigin: () => checkOrigin
|
|
1936
|
-
});
|
|
1937
|
-
function normalizeUrl(s) {
|
|
1938
|
-
return s.trim().replace(/^(https?:\/\/|git@github\.com:|ssh:\/\/git@github\.com\/)/, "").replace(/\.git$/, "").replace(":", "/").replace(/\/$/, "").toLowerCase();
|
|
1939
|
-
}
|
|
1940
|
-
function checkOrigin(cwd = process.cwd(), opts = {}) {
|
|
1941
|
-
const allowFork = opts.allowFork ?? true;
|
|
1942
|
-
let expected = null;
|
|
1943
|
-
try {
|
|
1944
|
-
const pkg = JSON.parse(readFileSync(join(cwd, "package.json"), "utf8"));
|
|
1945
|
-
expected = typeof pkg.repository === "string" ? pkg.repository : pkg.repository?.url ?? null;
|
|
1946
|
-
} catch {
|
|
1947
|
-
}
|
|
1948
|
-
if (!expected) {
|
|
1949
|
-
return {
|
|
1950
|
-
status: "warn",
|
|
1951
|
-
detail: "package.json has no repository.url field",
|
|
1952
|
-
fix: "add `repository` field to package.json"
|
|
1953
|
-
};
|
|
1954
|
-
}
|
|
1955
|
-
const r = spawnSync("git", ["config", "--get", "remote.origin.url"], {
|
|
1956
|
-
cwd,
|
|
1957
|
-
encoding: "utf8"
|
|
1958
|
-
});
|
|
1959
|
-
if (r.status !== 0) {
|
|
1960
|
-
return {
|
|
1961
|
-
status: "warn",
|
|
1962
|
-
detail: "no git remote origin (detached / non-clone)",
|
|
1963
|
-
fix: "git remote add origin <expected-url>"
|
|
1964
|
-
};
|
|
1965
|
-
}
|
|
1966
|
-
const actual = r.stdout.trim();
|
|
1967
|
-
if (normalizeUrl(actual) === normalizeUrl(expected)) {
|
|
1968
|
-
return { status: "pass", detail: actual };
|
|
1969
|
-
}
|
|
1970
|
-
return {
|
|
1971
|
-
status: allowFork ? "warn" : "fail",
|
|
1972
|
-
detail: `origin '${actual}' \u2260 expected '${expected}'`,
|
|
1973
|
-
fix: allowFork ? "verify intentional fork; if not, `git remote set-url origin <expected>`" : "origin URL drift \u2014 possible tamper, `git remote set-url origin <expected>` to restore"
|
|
1974
|
-
};
|
|
1975
|
-
}
|
|
1976
|
-
var init_origin_check = __esm({
|
|
1977
|
-
"src/cli/lib/origin-check.ts"() {
|
|
1978
|
-
}
|
|
1979
|
-
});
|
|
1980
|
-
|
|
1981
|
-
// messages/en.json
|
|
1982
|
-
var en_default;
|
|
1983
|
-
var init_en = __esm({
|
|
1984
|
-
"messages/en.json"() {
|
|
1985
|
-
en_default = {
|
|
1986
|
-
"setup.workflows_not_found": "error: workflows directory not found at {{path}}",
|
|
1987
|
-
"setup.nothing_to_install": "setup: no workflow directories with SKILL.md found \u2014 nothing to install",
|
|
1988
|
-
"setup.dry_run.header": "[dry-run] setup would install {{count}} workflow(s) to {{path}}:",
|
|
1989
|
-
"setup.dry_run.run_hint": " run without --dry-run to execute",
|
|
1990
|
-
"setup.copy_failed": " error: failed to copy {{name}}: {{message}}",
|
|
1991
|
-
"setup.step_a_complete": "Step A: {{count}} workflows installed to {{path}}",
|
|
1992
|
-
"setup.step_a_render.complete": " generated {{count}}/{{total}} command files",
|
|
1993
|
-
"setup.step_a_render.warnings_header": " [A.5] warnings \u2014 some capability cmds could not be fully resolved:",
|
|
1994
|
-
"setup.step_c.created": " [C] created {{path}} + enabled Agent Teams",
|
|
1995
|
-
"setup.step_c.already_enabled": " [C] Agent Teams already enabled ({{path}})",
|
|
1996
|
-
"setup.step_c.enabled_backup": " [C] enabled Agent Teams in {{path}} (backup saved \u2192 {{backupPath}})",
|
|
1997
|
-
"setup.step_c.skipped": " [C] Agent Teams enable skipped: {{message}}",
|
|
1998
|
-
"setup.step_d.created": " [D] created {{path}} + wrote env.HARNESSED_USER_LANG={{lang}}",
|
|
1999
|
-
"setup.step_d.already_set": " [D] env.HARNESSED_USER_LANG={{lang}} already set in {{path}} \u2014 respecting user override",
|
|
2000
|
-
"setup.step_d.enabled_backup": " [D] wrote env.HARNESSED_USER_LANG={{lang}} in {{path}} (backup saved \u2192 {{backupPath}})",
|
|
2001
|
-
"setup.step_d.skipped": " [D] User language write skipped: {{message}}",
|
|
2002
|
-
"setup.step_b_complete": "Upstream components: {{installed}} installed / {{already}} already-installed / {{skipped}} skipped / {{failed}} failed [{{seconds}}s]",
|
|
2003
|
-
"setup.complete": "setup complete \u2014 {{skills}} workflows + {{manifests}} base manifests configured",
|
|
2004
|
-
"setup.mcp_hint": "Run /mcp in Claude Code to verify MCP server connections.",
|
|
2005
|
-
"setup.mcp_hint_codex": "Run codex mcp list to verify MCP server connections.",
|
|
2006
|
-
"setup.search_key_hint.header": "\n\u26A0 Search MCP API keys missing \u2014 the server(s) below are installed but will fail at query time until the key is configured:",
|
|
2007
|
-
"setup.search_key_hint.line": ' {{server}}: set {{envVar}} \u2014 add it to the ~/.claude/settings.json "env" block (e.g. {"env": {"{{envVar}}": "<your-key>"}}) or export {{envVar}} in your shell',
|
|
2008
|
-
"setup.optional_offer.ecc_note": " ecc (bonus tier): installing it unlocks finer-grained scenario orchestration (per-language review/build expert routing etc.); the trade-off is ~20k+ tokens/session of static listing overhead \u2014 inherent to ECC's own scale (281 skills / 94 commands / 67 agents), not introduced by harnessed.",
|
|
2009
|
-
"setup.bundled_summary": "\nharnessed workflows bundled at <packageRoot>/workflows/ (share-only, read-only)",
|
|
2010
|
-
"setup.bundled_location": "",
|
|
2011
|
-
"setup.doctor_hint": "\nRun harnessed doctor to verify your environment.",
|
|
2012
|
-
"agent_teams.missing_header": "\n\u26A0\uFE0F Agent Teams not enabled \u2014 parallelism upgrade path unavailable",
|
|
2013
|
-
"agent_teams.missing_fix": " fix: claude config set env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS 1",
|
|
2014
|
-
"agent_teams.missing_explanation": " harnessed task parallelism uses Subagent or Agent Teams (CC 2.1.178+)",
|
|
2015
|
-
"agent_teams.missing_nonblocking": " non-blocking \u2014 auto-degrades to subagent fan-out\n",
|
|
2016
|
-
"install.manifest_not_found": "error: manifest '{{name}}' not found",
|
|
2017
|
-
"install.manifest_not_found.fix": " fix: ensure manifests/tools/{{name}}.yaml, manifests/skill-packs/{{name}}.yaml, or manifests/optional/{{name}}.yaml exists",
|
|
2018
|
-
"install.audit_hint": " fix: run 'harnessed audit' to inspect manifest issues",
|
|
2019
|
-
"install.success": "installed {{name}}",
|
|
2020
|
-
"install.success_with_version": "installed {{name}}@{{version}}",
|
|
2021
|
-
"install.already_installed": "already-installed {{name}} (idempotent check hit; nothing to do)",
|
|
2022
|
-
"install.already_installed_with_version": "already-installed {{name}}@{{version}} (idempotent check hit; nothing to do)",
|
|
2023
|
-
"install.aborted": "aborted: {{reason}}",
|
|
2024
|
-
"uninstall.dry_run.preview": "[dry-run] would uninstall '{{name}}' via method '{{method}}'",
|
|
2025
|
-
"uninstall.dry_run.run_hint": " run without --dry-run to execute",
|
|
2026
|
-
"uninstall.confirm.prompt": "Uninstall '{{name}}'? This cannot be undone.",
|
|
2027
|
-
"uninstall.cancelled": "aborted: user cancelled",
|
|
2028
|
-
"uninstall.completed": "uninstalled {{name}}",
|
|
2029
|
-
"uninstall.unified.nothing": "nothing to do \u2014 no harnessed artifacts found",
|
|
2030
|
-
"uninstall.unified.header": "harnessed uninstall will remove the following:",
|
|
2031
|
-
"uninstall.unified.commands": " Commands: {{count}} harnessed-generated slash command file(s) in ~/.claude/commands/",
|
|
2032
|
-
"uninstall.unified.agent_roles": " Agent roles: {{count}} harnessed-generated codex agent role file(s) in ~/.codex/agents/",
|
|
2033
|
-
"uninstall.unified.skills": " Skills: {{count}} workflow skill directory(ies) in ~/.claude/skills/",
|
|
2034
|
-
"uninstall.unified.settings": " Settings: harnessed env vars (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS, HARNESSED_USER_LANG) from ~/.claude/settings.json",
|
|
2035
|
-
"uninstall.unified.hooks": " Hooks: {{count}} harnessed Stop/UserPromptSubmit hook(s) in ~/.claude/settings.json",
|
|
2036
|
-
"uninstall.unified.state_dir": " State directory: ~/.claude/harnessed/ (includes backups, audit log, state, lock)",
|
|
2037
|
-
"uninstall.unified.upstream_note": "\nUpstream components (npm packages, MCP servers, CC plugins, git-cloned repos, npx skills) are NOT affected.",
|
|
2038
|
-
"uninstall.unified.dry_run_hint": "\n(dry-run \u2014 re-run without --dry-run to actually remove)",
|
|
2039
|
-
"uninstall.unified.confirm": "Remove harnessed's own files? Upstream components (npm packages, MCP servers, CC plugins, etc.) will NOT be affected. This cannot be undone.",
|
|
2040
|
-
"uninstall.unified.removing": "removing harnessed files...",
|
|
2041
|
-
"uninstall.unified.removed_commands": " removed {{count}} command file(s)",
|
|
2042
|
-
"uninstall.unified.removed_agent_roles": " removed {{count}} codex agent role file(s)",
|
|
2043
|
-
"uninstall.unified.removed_skills": " removed {{count}} skill directory(ies)",
|
|
2044
|
-
"uninstall.unified.removed_settings": " removed harnessed env vars from ~/.claude/settings.json",
|
|
2045
|
-
"uninstall.unified.removed_hooks": " removed {{count}} harnessed hook(s) from ~/.claude/settings.json",
|
|
2046
|
-
"uninstall.unified.removed_state_dir": " removed ~/.claude/harnessed/",
|
|
2047
|
-
"uninstall.unified.partial_failure": "\n{{count}} item(s) could not be removed (permission denied or already gone):",
|
|
2048
|
-
"uninstall.unified.complete": "uninstall complete \u2014 harnessed's own files have been removed",
|
|
2049
|
-
"uninstall.unified.cli_hint_header": "\nto remove the harnessed CLI itself (the step above did not \u2014 it only cleared setup files):",
|
|
2050
|
-
"uninstall.unified.cli_hint_binary": " binary: delete {{path}}\n then remove {{dir}} from your PATH",
|
|
2051
|
-
"uninstall.unified.cli_hint_npm": " npm: npm uninstall -g harnessed",
|
|
2052
|
-
"uninstall.unified.cli_hint_other": " installed both ways? remove the other too \u2014 npm: 'npm uninstall -g harnessed' / binary: delete the exe + its bin dir from PATH",
|
|
2053
|
-
"gc.invalid_duration": "error: invalid --older-than '{{value}}'",
|
|
2054
|
-
"gc.invalid_duration.fix": " fix: use format <N>{d|h|m|w} e.g. 30d / 24h / 60m / 4w",
|
|
2055
|
-
"gc.no_backups": "no backups found ({{root}} absent) \u2014 nothing to gc",
|
|
2056
|
-
"gc.no_old_snapshots": "no snapshots older than {{cutoff}} (kept {{keptCount}} most-recent)",
|
|
2057
|
-
"gc.summary_will_delete": "would delete {{count}} snapshot(s), ~{{sizeKb}} KB total:",
|
|
2058
|
-
"gc.summary_deleting": "deleting {{count}} snapshot(s), ~{{sizeKb}} KB total:",
|
|
2059
|
-
"gc.dry_run_rerun_hint": "\n(dry-run \u2014 re-run without --dry-run to actually delete)",
|
|
2060
|
-
"doctor.summary.fail": "\nsome checks failed (see fix hints above)",
|
|
2061
|
-
"doctor.summary.warn": "\nall checks ok (with warnings \u2014 see hints above)",
|
|
2062
|
-
"doctor.summary.pass": "\nall checks passed",
|
|
2063
|
-
"doctor.host_scope": "host: {{host}} \u2014 {{applied}} of {{total}} checks apply\n",
|
|
2064
|
-
"doctor.matrix.legend": "\nn/a = the check is not declared for that host in the registry, so it was not run",
|
|
2065
|
-
"check_docs.clean": "documentation discipline: no violations",
|
|
2066
|
-
"check_docs.state_line_limit": "STATE.md is {{lines}} lines > the {{limit}}-line digest limit \u2014 archive older phase narrative to RETROSPECTIVE.md (override for one run: HARNESSED_ALLOW_LONG_STATE=1)",
|
|
2067
|
-
"check_docs.state_key_decisions": "{{count}} '\u5173\u952E\u51B3\u8BAE ship \u603B\u7ED3' section(s) > {{limit}} \u2014 keep only the current one; move the rest to RETROSPECTIVE.md",
|
|
2068
|
-
"check_docs.state_errata": "historical commentary '{{excerpt}}' belongs in RETROSPECTIVE.md, not in the STATE digest",
|
|
2069
|
-
"check_docs.roadmap_narrative": "closing narrative inlined in an overview doc ({{signals}}) \u2014 ROADMAP carries one line + a pointer per phase; narrative goes to SUMMARY / VERIFICATION",
|
|
2070
|
-
"check_docs.summary_halt": "\ndocumentation discipline: {{halt}} blocking + {{warn}} advisory violation(s)",
|
|
2071
|
-
"check_docs.summary_warn": "\ndocumentation discipline: {{warn}} advisory violation(s) (non-blocking)",
|
|
2072
|
-
"backup.no_backups": "no backups found ({{root}} absent)",
|
|
2073
|
-
"backup.no_backups_empty": "no backups found ({{root}} empty)",
|
|
2074
|
-
"backup.total_snapshots": "\n{{count}} snapshot(s) total",
|
|
2075
|
-
"rollback.metadata_unreadable": "error: cannot read {{path}}: {{message}}",
|
|
2076
|
-
"rollback.metadata_unreadable.fix": " fix: run 'harnessed backup list' to see available timestamps",
|
|
2077
|
-
"rollback.checksum_mismatch": "error: backup checksum mismatch for {{target}} (expected {{expected}}, got {{actual}})",
|
|
2078
|
-
"rollback.restored": "restored {{count}} file(s) from {{timestamp}}",
|
|
2079
|
-
"status.no_installs": "no installs recorded ({{path}} absent or empty)",
|
|
2080
|
-
"status.summary_installs": "\n{{count}} install(s) recorded",
|
|
2081
|
-
"status.lock_held": "\nlock: held (since {{since}}){{staleSuffix}}",
|
|
2082
|
-
"status.lock_held.stale_suffix": " \u2014 STALE",
|
|
2083
|
-
"status.lock_release_hint": " to release: wait for process to finish or delete {{path}}",
|
|
2084
|
-
"status.lock_free": "\nlock: free",
|
|
2085
|
-
"here.no_workflow": "no active workflow for this repo ({{path}} has no entry for cwd)",
|
|
2086
|
-
"here.no_workflow.hint": " to start: run a stage (e.g. `harnessed gates discuss`) or `harnessed run <workflow>`",
|
|
2087
|
-
"audit_log.no_records_file": "no audit records found ({{path}} does not exist)",
|
|
2088
|
-
"audit_log.no_records_empty": "no audit records found (audit.log is empty)",
|
|
2089
|
-
"audit_log.jq_missing": "\u2717 jq not found in PATH \u2014 run: harnessed doctor",
|
|
2090
|
-
"audit_log.tail_invalid": "\u2717 --tail must be a positive integer",
|
|
2091
|
-
"audit_log.head_invalid": "\u2717 --head must be a positive integer",
|
|
2092
|
-
"execute_task.require_task": "error: --task <text> is required",
|
|
2093
|
-
"execute_task.load_phases_failed": "error: failed to load workflows/{{workflow}}/phases.yaml \u2014 {{message}}",
|
|
2094
|
-
"execute_task.precommit_skipped": "\u26A0\uFE0F before-commit pre-flight skipped ({{message}}); subagent will biome-check at commit time.",
|
|
2095
|
-
"research.require_query": "error: --query <text> is required",
|
|
2096
|
-
"manifest_add.non_interactive_warn": "[ee-5-gate] WARN: --non-interactive skips 5-question prompt (D-03 dry-run-only). plan-phase hard reject still applies.",
|
|
2097
|
-
"manifest_add.dry_run_preview": "[manifest-add] dry-run preview for upstream: {{upstream}} \u2192 {{path}}",
|
|
2098
|
-
"manifest_add.empty_answer": "error: EE-5 gate requires non-empty answer",
|
|
2099
|
-
"manifest_add.gate_passed_wrote": "[manifest-add] EE-5 gate passed; wrote {{path}}",
|
|
2100
|
-
"manifest_add.gate_passed_dry_run": "[manifest-add] EE-5 gate passed (dry-run); would write {{path}}",
|
|
2101
|
-
"resume.fail": "\u2717 {{error}}",
|
|
2102
|
-
"resume.corrupt": "\u2717 {{error}}\n path: {{path}}"
|
|
2103
|
-
};
|
|
2104
|
-
}
|
|
2105
|
-
});
|
|
2106
|
-
function mapToSupported(raw) {
|
|
2107
|
-
if (!raw) return "en";
|
|
2108
|
-
if (/^zh([^a-z]|$)/i.test(raw)) return "zh-Hans";
|
|
2109
|
-
return "en";
|
|
2110
|
-
}
|
|
2111
|
-
function detectLocale() {
|
|
2112
|
-
const raw = process.env.HARNESSED_LANG || process.env.LC_ALL || process.env.LANG || process.env.LANGUAGE || safeIntlLocale();
|
|
2113
|
-
return mapToSupported(raw);
|
|
2114
|
-
}
|
|
2115
|
-
function safeIntlLocale() {
|
|
2116
|
-
try {
|
|
2117
|
-
return Intl.DateTimeFormat().resolvedOptions().locale;
|
|
2118
|
-
} catch {
|
|
2119
|
-
return void 0;
|
|
2120
|
-
}
|
|
2121
|
-
}
|
|
2122
|
-
function wireMessagesDir(provider) {
|
|
2123
|
-
wiredMessagesDirProvider = provider;
|
|
2124
|
-
}
|
|
2125
|
-
function messagesDir() {
|
|
2126
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
2127
|
-
const candidates = [];
|
|
2128
|
-
if (wiredMessagesDirProvider) {
|
|
2129
|
-
try {
|
|
2130
|
-
candidates.push(wiredMessagesDirProvider());
|
|
2131
|
-
} catch {
|
|
2132
|
-
}
|
|
2133
|
-
}
|
|
2134
|
-
candidates.push(resolve(here, "..", "..", "messages"), resolve(here, "..", "messages"));
|
|
2135
|
-
for (const c of candidates) {
|
|
2136
|
-
try {
|
|
2137
|
-
readFileSync(join(c, "en.json"), "utf8");
|
|
2138
|
-
return c;
|
|
2139
|
-
} catch {
|
|
2140
|
-
}
|
|
2570
|
+
allErrors: true,
|
|
2571
|
+
discriminator: true,
|
|
2572
|
+
allowUnionTypes: false
|
|
2573
|
+
})
|
|
2574
|
+
);
|
|
2575
|
+
_compiled = null;
|
|
2576
|
+
INSTALL_TYPE_METHODS = {
|
|
2577
|
+
npm: ["npm-cli"],
|
|
2578
|
+
mcp: ["mcp-stdio-add", "mcp-http-add"],
|
|
2579
|
+
git: ["git-clone-with-setup"],
|
|
2580
|
+
skill: ["cc-plugin-marketplace", "npx-skill-installer"],
|
|
2581
|
+
// 5th install_type (Phase 2.4). Missing here meant `install_type: hook` accepted
|
|
2582
|
+
// ANY method: an unconstrained bucket, not a closed one (external review L10).
|
|
2583
|
+
hook: ["cc-hook-add"]
|
|
2584
|
+
};
|
|
2141
2585
|
}
|
|
2142
|
-
|
|
2586
|
+
});
|
|
2587
|
+
|
|
2588
|
+
// src/cli/lib/origin-check.ts
|
|
2589
|
+
var origin_check_exports = {};
|
|
2590
|
+
__export(origin_check_exports, {
|
|
2591
|
+
checkOrigin: () => checkOrigin
|
|
2592
|
+
});
|
|
2593
|
+
function normalizeUrl(s) {
|
|
2594
|
+
return s.trim().replace(/^(https?:\/\/|git@github\.com:|ssh:\/\/git@github\.com\/)/, "").replace(/\.git$/, "").replace(":", "/").replace(/\/$/, "").toLowerCase();
|
|
2143
2595
|
}
|
|
2144
|
-
function
|
|
2145
|
-
|
|
2146
|
-
|
|
2596
|
+
function checkOrigin(cwd = process.cwd(), opts = {}) {
|
|
2597
|
+
const allowFork = opts.allowFork ?? true;
|
|
2598
|
+
let expected = null;
|
|
2147
2599
|
try {
|
|
2148
|
-
const
|
|
2149
|
-
|
|
2600
|
+
const pkg = JSON.parse(readFileSync(join(cwd, "package.json"), "utf8"));
|
|
2601
|
+
expected = typeof pkg.repository === "string" ? pkg.repository : pkg.repository?.url ?? null;
|
|
2150
2602
|
} catch {
|
|
2151
|
-
cache[locale] = locale === "en" ? en_default : {};
|
|
2152
2603
|
}
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
}
|
|
2160
|
-
function getLocale() {
|
|
2161
|
-
if (currentLocale === null) currentLocale = detectLocale();
|
|
2162
|
-
return currentLocale;
|
|
2163
|
-
}
|
|
2164
|
-
function t(key, params) {
|
|
2165
|
-
const locale = getLocale();
|
|
2166
|
-
const primary = loadLocale(locale);
|
|
2167
|
-
let template = primary[key];
|
|
2168
|
-
if (template === void 0 && locale !== "en") {
|
|
2169
|
-
template = loadLocale("en")[key];
|
|
2604
|
+
if (!expected) {
|
|
2605
|
+
return {
|
|
2606
|
+
status: "warn",
|
|
2607
|
+
detail: "package.json has no repository.url field",
|
|
2608
|
+
fix: "add `repository` field to package.json"
|
|
2609
|
+
};
|
|
2170
2610
|
}
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
const v = params[name];
|
|
2175
|
-
return v === void 0 ? `{{${name}}}` : String(v);
|
|
2611
|
+
const r = spawnSync("git", ["config", "--get", "remote.origin.url"], {
|
|
2612
|
+
cwd,
|
|
2613
|
+
encoding: "utf8"
|
|
2176
2614
|
});
|
|
2615
|
+
if (r.status !== 0) {
|
|
2616
|
+
return {
|
|
2617
|
+
status: "warn",
|
|
2618
|
+
detail: "no git remote origin (detached / non-clone)",
|
|
2619
|
+
fix: "git remote add origin <expected-url>"
|
|
2620
|
+
};
|
|
2621
|
+
}
|
|
2622
|
+
const actual = r.stdout.trim();
|
|
2623
|
+
if (normalizeUrl(actual) === normalizeUrl(expected)) {
|
|
2624
|
+
return { status: "pass", detail: actual };
|
|
2625
|
+
}
|
|
2626
|
+
return {
|
|
2627
|
+
status: allowFork ? "warn" : "fail",
|
|
2628
|
+
detail: `origin '${actual}' \u2260 expected '${expected}'`,
|
|
2629
|
+
fix: allowFork ? "verify intentional fork; if not, `git remote set-url origin <expected>`" : "origin URL drift \u2014 possible tamper, `git remote set-url origin <expected>` to restore"
|
|
2630
|
+
};
|
|
2177
2631
|
}
|
|
2178
|
-
var
|
|
2179
|
-
|
|
2180
|
-
"src/i18n/index.ts"() {
|
|
2181
|
-
init_en();
|
|
2182
|
-
SUPPORTED = /* @__PURE__ */ new Set(["en", "zh-Hans"]);
|
|
2183
|
-
currentLocale = null;
|
|
2184
|
-
cache = {};
|
|
2185
|
-
wiredMessagesDirProvider = null;
|
|
2632
|
+
var init_origin_check = __esm({
|
|
2633
|
+
"src/cli/lib/origin-check.ts"() {
|
|
2186
2634
|
}
|
|
2187
2635
|
});
|
|
2188
2636
|
function getBackupRoot() {
|
|
@@ -2558,7 +3006,7 @@ function resolveWindowsBin(bin, env = process.env, isFile = (p8) => existsSync(p
|
|
|
2558
3006
|
const candidates = extname(bin) ? [""] : exts;
|
|
2559
3007
|
for (const dir of dirs) {
|
|
2560
3008
|
for (const ext of candidates) {
|
|
2561
|
-
const p8 =
|
|
3009
|
+
const p8 = join18(dir, `${bin}${ext}`);
|
|
2562
3010
|
if (isFile(p8)) return p8;
|
|
2563
3011
|
}
|
|
2564
3012
|
}
|
|
@@ -2573,10 +3021,10 @@ function planWindowsSpawn(bin, args, resolved) {
|
|
|
2573
3021
|
const line = [escapeCommand(resolved), ...args.map((a) => escapeArgument(a))].join(" ");
|
|
2574
3022
|
return { command: "cmd.exe", args: ["/d", "/s", "/c", `"${line}"`], verbatim: true };
|
|
2575
3023
|
}
|
|
2576
|
-
var extname,
|
|
3024
|
+
var extname, join18, META;
|
|
2577
3025
|
var init_winSpawn = __esm({
|
|
2578
3026
|
"src/installers/lib/winSpawn.ts"() {
|
|
2579
|
-
({ extname, join:
|
|
3027
|
+
({ extname, join: join18 } = win32);
|
|
2580
3028
|
META = /([()\][%!^"`<>&|;, *?])/g;
|
|
2581
3029
|
}
|
|
2582
3030
|
});
|
|
@@ -3272,91 +3720,6 @@ var init_evidence = __esm({
|
|
|
3272
3720
|
init_resolveYaml();
|
|
3273
3721
|
}
|
|
3274
3722
|
});
|
|
3275
|
-
function getPackageRoot() {
|
|
3276
|
-
const thisFile = fileURLToPath(import.meta.url);
|
|
3277
|
-
const thisDir = dirname(thisFile);
|
|
3278
|
-
if (thisDir.endsWith("dist") || thisDir.replace(/\\/g, "/").endsWith("/dist")) {
|
|
3279
|
-
return resolve(thisDir, "..");
|
|
3280
|
-
}
|
|
3281
|
-
return resolve(thisDir, "..", "..");
|
|
3282
|
-
}
|
|
3283
|
-
var init_packagePath = __esm({
|
|
3284
|
-
"src/platform/packagePath.ts"() {
|
|
3285
|
-
}
|
|
3286
|
-
});
|
|
3287
|
-
|
|
3288
|
-
// src/platform/assetsRoot.ts
|
|
3289
|
-
var assetsRoot_exports = {};
|
|
3290
|
-
__export(assetsRoot_exports, {
|
|
3291
|
-
compiledAssetsDir: () => compiledAssetsDir,
|
|
3292
|
-
computeAssetsRoot: () => computeAssetsRoot,
|
|
3293
|
-
getAssetsRoot: () => getAssetsRoot,
|
|
3294
|
-
isCompiledModuleUrl: () => isCompiledModuleUrl,
|
|
3295
|
-
isCompiledRuntime: () => isCompiledRuntime
|
|
3296
|
-
});
|
|
3297
|
-
function isCompiledRuntime(url = import.meta.url) {
|
|
3298
|
-
return isCompiledModuleUrl(url);
|
|
3299
|
-
}
|
|
3300
|
-
function isCompiledModuleUrl(url) {
|
|
3301
|
-
let s = url;
|
|
3302
|
-
try {
|
|
3303
|
-
s = decodeURIComponent(url);
|
|
3304
|
-
} catch {
|
|
3305
|
-
}
|
|
3306
|
-
const normalized2 = s.replace(/\\/g, "/").toLowerCase();
|
|
3307
|
-
return BUNFS_MARKERS.some((m) => normalized2.includes(m));
|
|
3308
|
-
}
|
|
3309
|
-
function computeAssetsRoot(d) {
|
|
3310
|
-
const override = d.env.HARNESSED_ASSETS_OVERRIDE;
|
|
3311
|
-
if (override && override.trim().length > 0) {
|
|
3312
|
-
return { root: override.trim(), source: "override", compiledAssetsMissing: false };
|
|
3313
|
-
}
|
|
3314
|
-
if (isCompiledModuleUrl(d.moduleUrl)) {
|
|
3315
|
-
const root = join(d.stateRoot(), "assets", d.version);
|
|
3316
|
-
const present = d.exists(join(root, "workflows"));
|
|
3317
|
-
return { root, source: "compiled", compiledAssetsMissing: !present };
|
|
3318
|
-
}
|
|
3319
|
-
return { root: d.packageRoot, source: "package", compiledAssetsMissing: false };
|
|
3320
|
-
}
|
|
3321
|
-
function compiledAssetsDir(version) {
|
|
3322
|
-
return join(detectPlatform().stateRoot, "assets", version);
|
|
3323
|
-
}
|
|
3324
|
-
function realDeps() {
|
|
3325
|
-
return {
|
|
3326
|
-
env: process.env,
|
|
3327
|
-
moduleUrl: import.meta.url,
|
|
3328
|
-
exists: (p8) => {
|
|
3329
|
-
try {
|
|
3330
|
-
return existsSync(p8);
|
|
3331
|
-
} catch {
|
|
3332
|
-
return false;
|
|
3333
|
-
}
|
|
3334
|
-
},
|
|
3335
|
-
stateRoot: () => detectPlatform().stateRoot,
|
|
3336
|
-
packageRoot: getPackageRoot(),
|
|
3337
|
-
version: package_default.version
|
|
3338
|
-
};
|
|
3339
|
-
}
|
|
3340
|
-
function getAssetsRoot() {
|
|
3341
|
-
const r = computeAssetsRoot(realDeps());
|
|
3342
|
-
if (r.source === "compiled" && r.compiledAssetsMissing && !warnedMissing) {
|
|
3343
|
-
warnedMissing = true;
|
|
3344
|
-
console.error(
|
|
3345
|
-
`warning: compiled harnessed binary but bundled assets are not unpacked at ${r.root} \u2014 asset-dependent commands (setup / run / prompt / install) will fail. Reinstall the binary, or use the npm distribution (npm i -g harnessed). (asset unpack pipeline lands in a later release \u2014 B1 seam)`
|
|
3346
|
-
);
|
|
3347
|
-
}
|
|
3348
|
-
return r.root;
|
|
3349
|
-
}
|
|
3350
|
-
var BUNFS_MARKERS, warnedMissing;
|
|
3351
|
-
var init_assetsRoot = __esm({
|
|
3352
|
-
"src/platform/assetsRoot.ts"() {
|
|
3353
|
-
init_package();
|
|
3354
|
-
init_packagePath();
|
|
3355
|
-
init_platform();
|
|
3356
|
-
BUNFS_MARKERS = ["/$bunfs/", "/~bun/"];
|
|
3357
|
-
warnedMissing = false;
|
|
3358
|
-
}
|
|
3359
|
-
});
|
|
3360
3723
|
|
|
3361
3724
|
// src/checkpoint/tddBoundary.ts
|
|
3362
3725
|
var tddBoundary_exports = {};
|
|
@@ -4728,7 +5091,7 @@ function compute(d) {
|
|
|
4728
5091
|
const gitFirst = d.where("git")[0];
|
|
4729
5092
|
if (gitFirst && /git\.exe$/i.test(gitFirst)) {
|
|
4730
5093
|
const root = dirname9(dirname9(gitFirst));
|
|
4731
|
-
for (const cand of [
|
|
5094
|
+
for (const cand of [join26(root, "bin", "bash.exe"), join26(root, "usr", "bin", "bash.exe")]) {
|
|
4732
5095
|
if (d.exists(cand) && usable(cand)) return { path: cand, source: "git-derived", wslOnPath };
|
|
4733
5096
|
}
|
|
4734
5097
|
}
|
|
@@ -4736,13 +5099,13 @@ function compute(d) {
|
|
|
4736
5099
|
d.env.ProgramFiles,
|
|
4737
5100
|
d.env.ProgramW6432,
|
|
4738
5101
|
d.env["ProgramFiles(x86)"],
|
|
4739
|
-
d.env.LOCALAPPDATA ?
|
|
5102
|
+
d.env.LOCALAPPDATA ? join26(d.env.LOCALAPPDATA, "Programs") : void 0
|
|
4740
5103
|
];
|
|
4741
5104
|
for (const base of bases) {
|
|
4742
5105
|
if (!base) continue;
|
|
4743
5106
|
for (const cand of [
|
|
4744
|
-
|
|
4745
|
-
|
|
5107
|
+
join26(base, "Git", "bin", "bash.exe"),
|
|
5108
|
+
join26(base, "Git", "usr", "bin", "bash.exe")
|
|
4746
5109
|
]) {
|
|
4747
5110
|
if (d.exists(cand) && usable(cand))
|
|
4748
5111
|
return { path: cand, source: "standard-location", wslOnPath };
|
|
@@ -4755,10 +5118,10 @@ function compute(d) {
|
|
|
4755
5118
|
}
|
|
4756
5119
|
return { path: "bash", source: "path-fallback" };
|
|
4757
5120
|
}
|
|
4758
|
-
var dirname9,
|
|
5121
|
+
var dirname9, join26, WSL_STUB_RE, cache4;
|
|
4759
5122
|
var init_resolveBash = __esm({
|
|
4760
5123
|
"src/installers/lib/resolveBash.ts"() {
|
|
4761
|
-
({ dirname: dirname9, join:
|
|
5124
|
+
({ dirname: dirname9, join: join26 } = win32);
|
|
4762
5125
|
WSL_STUB_RE = /[\\/](windows[\\/](system32|sysnative|syswow64)|microsoft[\\/]windowsapps)[\\/]bash\.exe$/i;
|
|
4763
5126
|
cache4 = null;
|
|
4764
5127
|
}
|
|
@@ -5501,93 +5864,32 @@ function checkBun(deps) {
|
|
|
5501
5864
|
message: r.stdout.split(/\r?\n/)[0]?.trim() ?? "bun found"
|
|
5502
5865
|
};
|
|
5503
5866
|
}
|
|
5504
|
-
const missing = {
|
|
5505
|
-
name: "bun present",
|
|
5506
|
-
status: "warn",
|
|
5507
|
-
message: "bun not found in PATH \u2014 gstack setup builds its browse binary with bun (gstack refresh will fail without it)"
|
|
5508
|
-
};
|
|
5509
|
-
if (platform === "win32") {
|
|
5510
|
-
return {
|
|
5511
|
-
...missing,
|
|
5512
|
-
fix: "winget install Oven-sh.Bun",
|
|
5513
|
-
install_commands: ["winget install Oven-sh.Bun"]
|
|
5514
|
-
};
|
|
5515
|
-
}
|
|
5516
|
-
if (platform === "darwin") {
|
|
5517
|
-
return {
|
|
5518
|
-
...missing,
|
|
5519
|
-
fix: "brew install oven-sh/bun/bun",
|
|
5520
|
-
install_commands: ["brew install oven-sh/bun/bun"]
|
|
5521
|
-
};
|
|
5522
|
-
}
|
|
5523
|
-
return {
|
|
5524
|
-
...missing,
|
|
5525
|
-
fix: "see https://bun.sh/docs/installation (curl -fsSL https://bun.sh/install | bash \u2014 review the script first)"
|
|
5526
|
-
};
|
|
5527
|
-
}
|
|
5528
|
-
var init_check_bun = __esm({
|
|
5529
|
-
"src/cli/lib/check-bun.ts"() {
|
|
5530
|
-
}
|
|
5531
|
-
});
|
|
5532
|
-
async function scanWorkflowsNested(workflowsDir, entries) {
|
|
5533
|
-
const workflows = [];
|
|
5534
|
-
for (const entry of entries.sort()) {
|
|
5535
|
-
if (NON_WORKFLOW_DIRS.has(entry)) continue;
|
|
5536
|
-
const src = join(workflowsDir, entry);
|
|
5537
|
-
let s;
|
|
5538
|
-
try {
|
|
5539
|
-
s = await stat(src);
|
|
5540
|
-
} catch {
|
|
5541
|
-
continue;
|
|
5542
|
-
}
|
|
5543
|
-
if (!s.isDirectory()) continue;
|
|
5544
|
-
let hasFlatSkill = false;
|
|
5545
|
-
try {
|
|
5546
|
-
await stat(join(src, "SKILL.md"));
|
|
5547
|
-
hasFlatSkill = true;
|
|
5548
|
-
} catch {
|
|
5549
|
-
hasFlatSkill = false;
|
|
5550
|
-
}
|
|
5551
|
-
if (hasFlatSkill) {
|
|
5552
|
-
if (FLAT_LEGACY_KEEP.has(entry)) {
|
|
5553
|
-
workflows.push({ name: entry, relPath: entry, isMaster: FLAT_TOP_LEVEL_MASTERS.has(entry) });
|
|
5554
|
-
continue;
|
|
5555
|
-
}
|
|
5556
|
-
workflows.push({ name: entry, relPath: entry, isMaster: false });
|
|
5557
|
-
continue;
|
|
5558
|
-
}
|
|
5559
|
-
let subEntries;
|
|
5560
|
-
try {
|
|
5561
|
-
subEntries = await readdir(src);
|
|
5562
|
-
} catch {
|
|
5563
|
-
continue;
|
|
5564
|
-
}
|
|
5565
|
-
for (const sub of subEntries.sort()) {
|
|
5566
|
-
const subDir = join(src, sub);
|
|
5567
|
-
let ss;
|
|
5568
|
-
try {
|
|
5569
|
-
ss = await stat(subDir);
|
|
5570
|
-
} catch {
|
|
5571
|
-
continue;
|
|
5572
|
-
}
|
|
5573
|
-
if (!ss.isDirectory()) continue;
|
|
5574
|
-
try {
|
|
5575
|
-
await stat(join(subDir, "SKILL.md"));
|
|
5576
|
-
} catch {
|
|
5577
|
-
continue;
|
|
5578
|
-
}
|
|
5579
|
-
const name = sub === "auto" ? entry : `${entry}-${sub}`;
|
|
5580
|
-
workflows.push({ name, relPath: `${entry}/${sub}`, isMaster: sub === "auto" });
|
|
5581
|
-
}
|
|
5867
|
+
const missing = {
|
|
5868
|
+
name: "bun present",
|
|
5869
|
+
status: "warn",
|
|
5870
|
+
message: "bun not found in PATH \u2014 gstack setup builds its browse binary with bun (gstack refresh will fail without it)"
|
|
5871
|
+
};
|
|
5872
|
+
if (platform === "win32") {
|
|
5873
|
+
return {
|
|
5874
|
+
...missing,
|
|
5875
|
+
fix: "winget install Oven-sh.Bun",
|
|
5876
|
+
install_commands: ["winget install Oven-sh.Bun"]
|
|
5877
|
+
};
|
|
5582
5878
|
}
|
|
5583
|
-
|
|
5879
|
+
if (platform === "darwin") {
|
|
5880
|
+
return {
|
|
5881
|
+
...missing,
|
|
5882
|
+
fix: "brew install oven-sh/bun/bun",
|
|
5883
|
+
install_commands: ["brew install oven-sh/bun/bun"]
|
|
5884
|
+
};
|
|
5885
|
+
}
|
|
5886
|
+
return {
|
|
5887
|
+
...missing,
|
|
5888
|
+
fix: "see https://bun.sh/docs/installation (curl -fsSL https://bun.sh/install | bash \u2014 review the script first)"
|
|
5889
|
+
};
|
|
5584
5890
|
}
|
|
5585
|
-
var
|
|
5586
|
-
|
|
5587
|
-
"src/workflow/scan-nested.ts"() {
|
|
5588
|
-
FLAT_LEGACY_KEEP = /* @__PURE__ */ new Set(["research", "retro", "auto"]);
|
|
5589
|
-
FLAT_TOP_LEVEL_MASTERS = /* @__PURE__ */ new Set(["auto"]);
|
|
5590
|
-
NON_WORKFLOW_DIRS = /* @__PURE__ */ new Set(["disciplines", "judgments"]);
|
|
5891
|
+
var init_check_bun = __esm({
|
|
5892
|
+
"src/cli/lib/check-bun.ts"() {
|
|
5591
5893
|
}
|
|
5592
5894
|
});
|
|
5593
5895
|
|
|
@@ -7727,203 +8029,6 @@ var init_doctor_registry = __esm({
|
|
|
7727
8029
|
];
|
|
7728
8030
|
}
|
|
7729
8031
|
});
|
|
7730
|
-
function resolveLocaleYaml(dir, baseName, locale = getLocale()) {
|
|
7731
|
-
if (locale !== "en") {
|
|
7732
|
-
const sibling = join(dir, `${baseName}.${locale}.yaml`);
|
|
7733
|
-
if (existsSync(sibling)) return sibling;
|
|
7734
|
-
}
|
|
7735
|
-
return join(dir, `${baseName}.yaml`);
|
|
7736
|
-
}
|
|
7737
|
-
var init_localeYaml = __esm({
|
|
7738
|
-
"src/i18n/localeYaml.ts"() {
|
|
7739
|
-
init_i18n();
|
|
7740
|
-
}
|
|
7741
|
-
});
|
|
7742
|
-
async function loadRolePrompts(workflowsDir, locale = getLocale()) {
|
|
7743
|
-
const path = resolveLocaleYaml(workflowsDir, "role-prompts", locale);
|
|
7744
|
-
let raw;
|
|
7745
|
-
try {
|
|
7746
|
-
raw = await readFile(path, "utf8");
|
|
7747
|
-
} catch {
|
|
7748
|
-
return {};
|
|
7749
|
-
}
|
|
7750
|
-
const doc = parse(raw);
|
|
7751
|
-
return doc?.prompts ?? {};
|
|
7752
|
-
}
|
|
7753
|
-
function mapRolePromptText(rp, render) {
|
|
7754
|
-
const s = (v) => typeof v === "string" ? render(v) : v;
|
|
7755
|
-
return {
|
|
7756
|
-
...rp,
|
|
7757
|
-
specialist: s(rp.specialist),
|
|
7758
|
-
responsibility: s(rp.responsibility),
|
|
7759
|
-
checklist: Array.isArray(rp.checklist) ? rp.checklist.map((c) => s(c)) : rp.checklist,
|
|
7760
|
-
severity: s(rp.severity)
|
|
7761
|
-
};
|
|
7762
|
-
}
|
|
7763
|
-
function mapRolePromptsText(prompts, render) {
|
|
7764
|
-
const out = {};
|
|
7765
|
-
for (const [name, rp] of Object.entries(prompts)) out[name] = mapRolePromptText(rp, render);
|
|
7766
|
-
return out;
|
|
7767
|
-
}
|
|
7768
|
-
var init_rolePrompts = __esm({
|
|
7769
|
-
"src/workflow/rolePrompts.ts"() {
|
|
7770
|
-
init_i18n();
|
|
7771
|
-
init_localeYaml();
|
|
7772
|
-
}
|
|
7773
|
-
});
|
|
7774
|
-
function toHostId(id) {
|
|
7775
|
-
return id === "codex" ? "codex" : "claude";
|
|
7776
|
-
}
|
|
7777
|
-
async function loadHostPrimitives(opts) {
|
|
7778
|
-
const path = resolveLocaleYaml(opts.workflowsDir, YAML_BASE, opts.locale ?? getLocale());
|
|
7779
|
-
let raw;
|
|
7780
|
-
try {
|
|
7781
|
-
raw = await readFile(path, "utf8");
|
|
7782
|
-
} catch {
|
|
7783
|
-
return {};
|
|
7784
|
-
}
|
|
7785
|
-
const doc = parse(raw);
|
|
7786
|
-
return doc?.primitives ?? {};
|
|
7787
|
-
}
|
|
7788
|
-
async function loadHostMapNotes(opts) {
|
|
7789
|
-
const path = resolveLocaleYaml(opts.workflowsDir, YAML_BASE, opts.locale ?? getLocale());
|
|
7790
|
-
let raw;
|
|
7791
|
-
try {
|
|
7792
|
-
raw = await readFile(path, "utf8");
|
|
7793
|
-
} catch {
|
|
7794
|
-
return [];
|
|
7795
|
-
}
|
|
7796
|
-
const doc = parse(raw);
|
|
7797
|
-
const notes = doc?.host_map_notes?.[opts.host];
|
|
7798
|
-
return Array.isArray(notes) ? notes.filter((n) => typeof n === "string") : [];
|
|
7799
|
-
}
|
|
7800
|
-
function loadHostPrimitivesCached(opts) {
|
|
7801
|
-
const locale = opts.locale ?? getLocale();
|
|
7802
|
-
const key = `${opts.workflowsDir}|${locale}`;
|
|
7803
|
-
const hit = _tableCache.get(key);
|
|
7804
|
-
if (hit) return hit;
|
|
7805
|
-
const p8 = loadHostPrimitives({ workflowsDir: opts.workflowsDir, locale });
|
|
7806
|
-
_tableCache.set(key, p8);
|
|
7807
|
-
return p8;
|
|
7808
|
-
}
|
|
7809
|
-
function templateRe() {
|
|
7810
|
-
return new RegExp(HOST_PRIMITIVE_TEMPLATE.source, "g");
|
|
7811
|
-
}
|
|
7812
|
-
function lineOf2(body, offset) {
|
|
7813
|
-
let line = 1;
|
|
7814
|
-
for (let i = 0; i < offset && i < body.length; i++) if (body[i] === "\n") line++;
|
|
7815
|
-
return line;
|
|
7816
|
-
}
|
|
7817
|
-
function renderHostPrimitives(body, opts) {
|
|
7818
|
-
const { host, table } = opts;
|
|
7819
|
-
return body.replace(
|
|
7820
|
-
templateRe(),
|
|
7821
|
-
(match, primitive, variant, offset) => {
|
|
7822
|
-
const name = variant ?? DEFAULT_VARIANT;
|
|
7823
|
-
const where = `'${match}' at line ${lineOf2(body, offset)} (offset ${offset})`;
|
|
7824
|
-
const variants = table[primitive];
|
|
7825
|
-
if (!variants) {
|
|
7826
|
-
throw new Error(
|
|
7827
|
-
`unknown host primitive 'host.${primitive}' \u2014 ${where}; not defined in host-primitives.yaml`
|
|
7828
|
-
);
|
|
7829
|
-
}
|
|
7830
|
-
const entry = variants[name];
|
|
7831
|
-
if (!entry) {
|
|
7832
|
-
throw new Error(
|
|
7833
|
-
`unknown variant '${name}' for host primitive '${primitive}' \u2014 ${where}; defined variants: ${Object.keys(variants).sort().join(", ") || "(none)"}`
|
|
7834
|
-
);
|
|
7835
|
-
}
|
|
7836
|
-
const text = entry[host];
|
|
7837
|
-
if (text === void 0) {
|
|
7838
|
-
throw new Error(
|
|
7839
|
-
`host primitive '${primitive}.${name}' has no text for host '${host}' \u2014 ${where}; defined hosts: ${Object.keys(entry).sort().join(", ") || "(none)"}`
|
|
7840
|
-
);
|
|
7841
|
-
}
|
|
7842
|
-
return text;
|
|
7843
|
-
}
|
|
7844
|
-
);
|
|
7845
|
-
}
|
|
7846
|
-
function cell(text) {
|
|
7847
|
-
return text.replaceAll("|", "\\|");
|
|
7848
|
-
}
|
|
7849
|
-
function code(text) {
|
|
7850
|
-
return text.includes("`") ? text : `\`${text}\``;
|
|
7851
|
-
}
|
|
7852
|
-
function hostMapRows(table) {
|
|
7853
|
-
const rows = [];
|
|
7854
|
-
for (const primitive of Object.keys(table).sort()) {
|
|
7855
|
-
const entry = table[primitive]?.[DEFAULT_VARIANT];
|
|
7856
|
-
const claude = entry?.claude;
|
|
7857
|
-
const codex = entry?.codex;
|
|
7858
|
-
if (claude === void 0 || codex === void 0) continue;
|
|
7859
|
-
if (claude.includes("\n") || codex.includes("\n")) continue;
|
|
7860
|
-
if (claude.length > TERM_MAX_LEN || codex.length > TERM_MAX_LEN) continue;
|
|
7861
|
-
rows.push({ primitive, claude, codex });
|
|
7862
|
-
}
|
|
7863
|
-
return rows;
|
|
7864
|
-
}
|
|
7865
|
-
function buildHostMapSection(opts) {
|
|
7866
|
-
const { host, table } = opts;
|
|
7867
|
-
if (host === "claude") return "";
|
|
7868
|
-
const rows = hostMapRows(table);
|
|
7869
|
-
const notes = opts.notes ?? [];
|
|
7870
|
-
if (rows.length === 0 && notes.length === 0) return "";
|
|
7871
|
-
const skillsDir = table.skills_dir?.[DEFAULT_VARIANT]?.[host];
|
|
7872
|
-
const where = skillsDir ? ` and installed it under ${code(skillsDir)}` : "";
|
|
7873
|
-
const lines = [
|
|
7874
|
-
HOST_MAP_START,
|
|
7875
|
-
`## Host map \u2014 ${host}`,
|
|
7876
|
-
"",
|
|
7877
|
-
`harnessed rendered this artifact for the **${host}** harness${where}. The workflow prose was authored against Claude Code, so where a step names a tool it names the ${host} one. Use the table to decode any instruction that still reads as Claude-Code-shaped; do not substitute the Claude Code names back.`
|
|
7878
|
-
];
|
|
7879
|
-
if (rows.length > 0) {
|
|
7880
|
-
lines.push(
|
|
7881
|
-
"",
|
|
7882
|
-
`| primitive | Claude Code | ${host} |`,
|
|
7883
|
-
"| --- | --- | --- |",
|
|
7884
|
-
...rows.map(
|
|
7885
|
-
(r) => `| \`${r.primitive}\` | ${cell(code(r.claude))} | ${cell(code(r.codex))} |`
|
|
7886
|
-
)
|
|
7887
|
-
);
|
|
7888
|
-
}
|
|
7889
|
-
if (notes.length > 0) {
|
|
7890
|
-
lines.push("", "Caveats \u2014 these hold for the whole artifact:", "");
|
|
7891
|
-
for (const n of notes) lines.push(`- ${n}`);
|
|
7892
|
-
}
|
|
7893
|
-
lines.push(HOST_MAP_END);
|
|
7894
|
-
return lines.join("\n");
|
|
7895
|
-
}
|
|
7896
|
-
function regionRe() {
|
|
7897
|
-
const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7898
|
-
return new RegExp(`${esc(HOST_MAP_START)}[\\s\\S]*?${esc(HOST_MAP_END)}\\n*`, "g");
|
|
7899
|
-
}
|
|
7900
|
-
function insertHostMapSection(body, section) {
|
|
7901
|
-
if (section === "") return body;
|
|
7902
|
-
const stripped = body.replace(regionRe(), "");
|
|
7903
|
-
const fm = FRONTMATTER_RX.exec(stripped);
|
|
7904
|
-
const offset = fm ? fm[0].length : 0;
|
|
7905
|
-
const before = stripped.slice(0, offset);
|
|
7906
|
-
const after = stripped.slice(offset).replace(/^\n+/, "");
|
|
7907
|
-
const lead = offset === 0 ? "" : "\n";
|
|
7908
|
-
return `${before}${lead}${section}
|
|
7909
|
-
|
|
7910
|
-
${after}`;
|
|
7911
|
-
}
|
|
7912
|
-
var DEFAULT_VARIANT, YAML_BASE, _tableCache, HOST_PRIMITIVE_TEMPLATE, HOST_MAP_START, HOST_MAP_END, TERM_MAX_LEN, FRONTMATTER_RX;
|
|
7913
|
-
var init_hostPrimitives = __esm({
|
|
7914
|
-
"src/cli/lib/hostPrimitives.ts"() {
|
|
7915
|
-
init_i18n();
|
|
7916
|
-
init_localeYaml();
|
|
7917
|
-
DEFAULT_VARIANT = "default";
|
|
7918
|
-
YAML_BASE = "host-primitives";
|
|
7919
|
-
_tableCache = /* @__PURE__ */ new Map();
|
|
7920
|
-
HOST_PRIMITIVE_TEMPLATE = /\{\{\s*host\.([A-Za-z0-9_-]+)(?:\.([A-Za-z0-9_-]+))?\s*\}\}/g;
|
|
7921
|
-
HOST_MAP_START = "<!-- harnessed:host-map:start -->";
|
|
7922
|
-
HOST_MAP_END = "<!-- harnessed:host-map:end -->";
|
|
7923
|
-
TERM_MAX_LEN = 64;
|
|
7924
|
-
FRONTMATTER_RX = /^---[ \t]*\r?\n[\s\S]*?\r?\n---[ \t]*(\r?\n|$)/;
|
|
7925
|
-
}
|
|
7926
|
-
});
|
|
7927
8032
|
|
|
7928
8033
|
// src/cli/lib/rolePromptHostRender.ts
|
|
7929
8034
|
var rolePromptHostRender_exports = {};
|
|
@@ -14121,6 +14226,61 @@ function registerAdvance(program2) {
|
|
|
14121
14226
|
});
|
|
14122
14227
|
}
|
|
14123
14228
|
|
|
14229
|
+
// src/cli/agents-md.ts
|
|
14230
|
+
init_i18n();
|
|
14231
|
+
init_assetsRoot();
|
|
14232
|
+
init_platform();
|
|
14233
|
+
init_agentsMd();
|
|
14234
|
+
function registerAgentsMd(program2) {
|
|
14235
|
+
program2.command("agents-md").description(
|
|
14236
|
+
"Write the harnessed block into <CODEX_HOME>/AGENTS.md (marker-delimited, idempotent) \u2014 command list + host-primitive glossary, all derived; your own prose outside the markers is untouched"
|
|
14237
|
+
).option("--dry-run", "print what would be written; touch nothing").option("--remove", "strip the harnessed block (leaves the rest of the file alone)").action(async (raw) => {
|
|
14238
|
+
const platform = detectPlatform();
|
|
14239
|
+
if (platform.id !== "codex") {
|
|
14240
|
+
console.error(
|
|
14241
|
+
`harness-mismatch: AGENTS.md is codex's session-start contract; this process resolved to '${platform.id}'. Nothing written \u2014 run this from codex, or force the host with HARNESSED_PLATFORM=codex, because a copy nobody reads is worse than no copy.`
|
|
14242
|
+
);
|
|
14243
|
+
process.exitCode = 1;
|
|
14244
|
+
return;
|
|
14245
|
+
}
|
|
14246
|
+
const locale = getLocale();
|
|
14247
|
+
try {
|
|
14248
|
+
const r = await runAgentsMd({
|
|
14249
|
+
workflowsDir: join(getAssetsRoot(), "workflows"),
|
|
14250
|
+
dryRun: raw.dryRun === true,
|
|
14251
|
+
remove: raw.remove === true,
|
|
14252
|
+
locale: locale === "zh-Hans" ? "zh-Hans" : "en"
|
|
14253
|
+
});
|
|
14254
|
+
switch (r.status) {
|
|
14255
|
+
case "preview":
|
|
14256
|
+
console.log(r.section.trimEnd());
|
|
14257
|
+
console.log(
|
|
14258
|
+
`
|
|
14259
|
+
[dry-run] would ${r.action} the block above in ${r.path}. Nothing outside the markers is touched.`
|
|
14260
|
+
);
|
|
14261
|
+
break;
|
|
14262
|
+
case "written":
|
|
14263
|
+
console.log(
|
|
14264
|
+
`${r.action === "replace" ? "refreshed" : "wrote"} the harnessed block in ${r.path}`
|
|
14265
|
+
);
|
|
14266
|
+
break;
|
|
14267
|
+
case "removed":
|
|
14268
|
+
console.log(`removed the harnessed block from ${r.path}`);
|
|
14269
|
+
break;
|
|
14270
|
+
case "unchanged":
|
|
14271
|
+
console.log(`${r.path} already up to date \u2014 nothing to do`);
|
|
14272
|
+
break;
|
|
14273
|
+
case "absent":
|
|
14274
|
+
console.log(`${r.path} does not exist \u2014 nothing to remove`);
|
|
14275
|
+
break;
|
|
14276
|
+
}
|
|
14277
|
+
} catch (e) {
|
|
14278
|
+
console.error(`agents-md failed: ${e.message}`);
|
|
14279
|
+
process.exitCode = 1;
|
|
14280
|
+
}
|
|
14281
|
+
});
|
|
14282
|
+
}
|
|
14283
|
+
|
|
14124
14284
|
// src/cli/audit.ts
|
|
14125
14285
|
init_validate();
|
|
14126
14286
|
|
|
@@ -18577,6 +18737,20 @@ async function runUnifiedUninstall(home, dryRun) {
|
|
|
18577
18737
|
failures.push(`${path}: ${e.message}`);
|
|
18578
18738
|
}
|
|
18579
18739
|
}
|
|
18740
|
+
let removedAgentsMdBlock = false;
|
|
18741
|
+
if (platform.id === "codex") {
|
|
18742
|
+
try {
|
|
18743
|
+
const { agentsMdPath: agentsMdPath2, stripAgentsMdSection: stripAgentsMdSection2 } = await Promise.resolve().then(() => (init_agentsMd(), agentsMd_exports));
|
|
18744
|
+
const p8 = agentsMdPath2();
|
|
18745
|
+
const before = await readFile(p8, "utf8");
|
|
18746
|
+
const after = stripAgentsMdSection2(before);
|
|
18747
|
+
if (after !== before) {
|
|
18748
|
+
await writeFile(p8, after, "utf8");
|
|
18749
|
+
removedAgentsMdBlock = true;
|
|
18750
|
+
}
|
|
18751
|
+
} catch {
|
|
18752
|
+
}
|
|
18753
|
+
}
|
|
18580
18754
|
let removedAgentRoles = 0;
|
|
18581
18755
|
for (const path of agentRoleFiles) {
|
|
18582
18756
|
try {
|
|
@@ -18586,6 +18760,7 @@ async function runUnifiedUninstall(home, dryRun) {
|
|
|
18586
18760
|
failures.push(`${path}: ${e.message}`);
|
|
18587
18761
|
}
|
|
18588
18762
|
}
|
|
18763
|
+
if (removedAgentsMdBlock) console.log(` AGENTS.md: harnessed block removed`);
|
|
18589
18764
|
let removedSkills = 0;
|
|
18590
18765
|
for (const dir of skillDirs) {
|
|
18591
18766
|
try {
|
|
@@ -18949,6 +19124,7 @@ registerReject(program);
|
|
|
18949
19124
|
registerCompact(program);
|
|
18950
19125
|
registerWorkflows(program);
|
|
18951
19126
|
registerExemptGateguard(program);
|
|
19127
|
+
registerAgentsMd(program);
|
|
18952
19128
|
registerLearn(program);
|
|
18953
19129
|
registerUpdate(program);
|
|
18954
19130
|
registerReleasePreflight(program);
|