harnessed 4.15.0 → 4.15.2
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/cli.mjs +340 -57
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { existsSync, mkdirSync, renameSync, writeFileSync, readFileSync, readdirSync } from 'fs';
|
|
2
|
+
import { existsSync, mkdirSync, renameSync, writeFileSync, readFileSync, readdirSync, statSync } from 'fs';
|
|
3
3
|
import { homedir } from 'os';
|
|
4
|
-
import { join, dirname, resolve, sep, relative } from 'path';
|
|
4
|
+
import { join, dirname, resolve, sep, win32, relative } from 'path';
|
|
5
5
|
import { Type } from '@sinclair/typebox';
|
|
6
6
|
import { readFile, readdir, unlink, writeFile, stat, rm, cp, mkdir, rename, access, appendFile } from 'fs/promises';
|
|
7
7
|
import { Value } from '@sinclair/typebox/value';
|
|
@@ -38,7 +38,7 @@ var init_package = __esm({
|
|
|
38
38
|
"package.json"() {
|
|
39
39
|
package_default = {
|
|
40
40
|
name: "harnessed",
|
|
41
|
-
version: "4.15.
|
|
41
|
+
version: "4.15.2",
|
|
42
42
|
description: "AI coding harness package manager + composition orchestrator",
|
|
43
43
|
type: "module",
|
|
44
44
|
license: "Apache-2.0",
|
|
@@ -4411,6 +4411,117 @@ var init_breakLoop = __esm({
|
|
|
4411
4411
|
LOOP_THRESHOLD = 3;
|
|
4412
4412
|
}
|
|
4413
4413
|
});
|
|
4414
|
+
function realProbe(p6) {
|
|
4415
|
+
try {
|
|
4416
|
+
if (typeof spawnSync !== "function") return null;
|
|
4417
|
+
const r = spawnSync(p6, ["-c", "echo harnessed-bash-ok"], { encoding: "utf8", timeout: 5e3 });
|
|
4418
|
+
if (!r || r.error) return null;
|
|
4419
|
+
return r.status === 0;
|
|
4420
|
+
} catch {
|
|
4421
|
+
return null;
|
|
4422
|
+
}
|
|
4423
|
+
}
|
|
4424
|
+
function realWhere(name) {
|
|
4425
|
+
try {
|
|
4426
|
+
if (typeof spawnSync !== "function") return [];
|
|
4427
|
+
const r = spawnSync("where", [name], { encoding: "utf8" });
|
|
4428
|
+
if (!r || r.status !== 0) return [];
|
|
4429
|
+
return (r.stdout ?? "").split(/\r?\n/).map((s) => s.trim()).filter((s) => s.length > 0);
|
|
4430
|
+
} catch {
|
|
4431
|
+
return [];
|
|
4432
|
+
}
|
|
4433
|
+
}
|
|
4434
|
+
function realExists(p6) {
|
|
4435
|
+
try {
|
|
4436
|
+
return existsSync(p6);
|
|
4437
|
+
} catch {
|
|
4438
|
+
return false;
|
|
4439
|
+
}
|
|
4440
|
+
}
|
|
4441
|
+
function defaultDeps() {
|
|
4442
|
+
return {
|
|
4443
|
+
platform: process.platform,
|
|
4444
|
+
env: process.env,
|
|
4445
|
+
where: realWhere,
|
|
4446
|
+
exists: realExists,
|
|
4447
|
+
probe: realProbe
|
|
4448
|
+
};
|
|
4449
|
+
}
|
|
4450
|
+
function resolveBash(deps) {
|
|
4451
|
+
if (cache2) return cache2;
|
|
4452
|
+
cache2 = compute({ ...defaultDeps(), ...deps });
|
|
4453
|
+
return cache2;
|
|
4454
|
+
}
|
|
4455
|
+
function compute(d) {
|
|
4456
|
+
if (d.platform !== "win32") {
|
|
4457
|
+
return { path: null, source: "path", reason: "not-applicable" };
|
|
4458
|
+
}
|
|
4459
|
+
const envBash = d.env.HARNESSED_BASH;
|
|
4460
|
+
if (envBash && envBash.trim().length > 0) {
|
|
4461
|
+
return { path: envBash.trim(), source: "env" };
|
|
4462
|
+
}
|
|
4463
|
+
const pathLines = d.where("bash");
|
|
4464
|
+
const first = pathLines[0];
|
|
4465
|
+
const wslOnPath = first && WSL_STUB_RE.test(first) ? first : void 0;
|
|
4466
|
+
const usable = (p6) => !WSL_STUB_RE.test(p6) && d.probe(p6) !== false;
|
|
4467
|
+
if (first && usable(first)) {
|
|
4468
|
+
return { path: first, source: "path" };
|
|
4469
|
+
}
|
|
4470
|
+
const gitFirst = d.where("git")[0];
|
|
4471
|
+
if (gitFirst && /git\.exe$/i.test(gitFirst)) {
|
|
4472
|
+
const root = dirname8(dirname8(gitFirst));
|
|
4473
|
+
for (const cand of [join17(root, "bin", "bash.exe"), join17(root, "usr", "bin", "bash.exe")]) {
|
|
4474
|
+
if (d.exists(cand) && usable(cand)) return { path: cand, source: "git-derived", wslOnPath };
|
|
4475
|
+
}
|
|
4476
|
+
}
|
|
4477
|
+
const bases = [
|
|
4478
|
+
d.env.ProgramFiles,
|
|
4479
|
+
d.env.ProgramW6432,
|
|
4480
|
+
d.env["ProgramFiles(x86)"],
|
|
4481
|
+
d.env.LOCALAPPDATA ? join17(d.env.LOCALAPPDATA, "Programs") : void 0
|
|
4482
|
+
];
|
|
4483
|
+
for (const base of bases) {
|
|
4484
|
+
if (!base) continue;
|
|
4485
|
+
for (const cand of [
|
|
4486
|
+
join17(base, "Git", "bin", "bash.exe"),
|
|
4487
|
+
join17(base, "Git", "usr", "bin", "bash.exe")
|
|
4488
|
+
]) {
|
|
4489
|
+
if (d.exists(cand) && usable(cand))
|
|
4490
|
+
return { path: cand, source: "standard-location", wslOnPath };
|
|
4491
|
+
}
|
|
4492
|
+
}
|
|
4493
|
+
const laterUsable = pathLines.slice(1).find((l) => usable(l));
|
|
4494
|
+
if (laterUsable) return { path: laterUsable, source: "path", wslOnPath };
|
|
4495
|
+
if (pathLines.length > 0) {
|
|
4496
|
+
return { path: null, source: "path", reason: "wsl-only", wslOnPath: wslOnPath ?? first };
|
|
4497
|
+
}
|
|
4498
|
+
return { path: "bash", source: "path-fallback" };
|
|
4499
|
+
}
|
|
4500
|
+
var dirname8, join17, WSL_STUB_RE, cache2;
|
|
4501
|
+
var init_resolveBash = __esm({
|
|
4502
|
+
"src/installers/lib/resolveBash.ts"() {
|
|
4503
|
+
({ dirname: dirname8, join: join17 } = win32);
|
|
4504
|
+
WSL_STUB_RE = /[\\/](windows[\\/](system32|sysnative|syswow64)|microsoft[\\/]windowsapps)[\\/]bash\.exe$/i;
|
|
4505
|
+
cache2 = null;
|
|
4506
|
+
}
|
|
4507
|
+
});
|
|
4508
|
+
|
|
4509
|
+
// src/installers/lib/verifyMessage.ts
|
|
4510
|
+
function sanitizeOutputTail(raw, cap = 160) {
|
|
4511
|
+
const firstNonEmpty = raw.split(/\r?\n/).find((l) => l.trim().length > 0) ?? "";
|
|
4512
|
+
const printable = firstNonEmpty.replace(/[^\x20-\x7E]/g, "").trim();
|
|
4513
|
+
return printable.length > 0 ? printable.slice(0, cap) : "(unreadable output)";
|
|
4514
|
+
}
|
|
4515
|
+
function formatVerifyFail(cmd, exitCode, expected, stdout2, stderr) {
|
|
4516
|
+
const cmdPart = cmd.length > 80 ? `${cmd.slice(0, 80)}\u2026` : cmd;
|
|
4517
|
+
const rawTail = stderr.trim() || stdout2.trim();
|
|
4518
|
+
const tail = rawTail.length > 0 ? sanitizeOutputTail(rawTail) : "(no output)";
|
|
4519
|
+
return `verify failed (exit ${exitCode} \u2260 expected ${expected}): \`${cmdPart}\` \u2014 ${tail}`;
|
|
4520
|
+
}
|
|
4521
|
+
var init_verifyMessage = __esm({
|
|
4522
|
+
"src/installers/lib/verifyMessage.ts"() {
|
|
4523
|
+
}
|
|
4524
|
+
});
|
|
4414
4525
|
function checkNodeVersion() {
|
|
4415
4526
|
const v = process.versions.node;
|
|
4416
4527
|
const major = Number.parseInt(v.split(".")[0] ?? "0", 10);
|
|
@@ -4424,7 +4535,7 @@ function checkNodeVersion() {
|
|
|
4424
4535
|
async function checkMcpScope() {
|
|
4425
4536
|
if (detectPlatform().id !== "claude") {
|
|
4426
4537
|
return {
|
|
4427
|
-
name: "mcp scope
|
|
4538
|
+
name: "mcp scope",
|
|
4428
4539
|
status: "pass",
|
|
4429
4540
|
message: "skipped (claude-only check)"
|
|
4430
4541
|
};
|
|
@@ -4437,25 +4548,23 @@ async function checkMcpScope() {
|
|
|
4437
4548
|
projectExists = true;
|
|
4438
4549
|
} catch {
|
|
4439
4550
|
}
|
|
4440
|
-
let
|
|
4551
|
+
let userCount = 0;
|
|
4441
4552
|
try {
|
|
4442
4553
|
const raw = await readFile(userClaude, "utf8");
|
|
4443
4554
|
const parsed = JSON.parse(raw);
|
|
4444
|
-
|
|
4555
|
+
userCount = parsed.mcpServers ? Object.keys(parsed.mcpServers).length : 0;
|
|
4445
4556
|
} catch {
|
|
4446
4557
|
}
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
};
|
|
4454
|
-
}
|
|
4558
|
+
const parts = [];
|
|
4559
|
+
if (userCount > 0)
|
|
4560
|
+
parts.push(
|
|
4561
|
+
`${userCount} user-scope server(s) (~/.claude.json \u2014 harnessed default since v3.0.2)`
|
|
4562
|
+
);
|
|
4563
|
+
if (projectExists) parts.push("project .mcp.json present");
|
|
4455
4564
|
return {
|
|
4456
|
-
name: "mcp scope
|
|
4565
|
+
name: "mcp scope",
|
|
4457
4566
|
status: "pass",
|
|
4458
|
-
message:
|
|
4567
|
+
message: parts.length > 0 ? parts.join("; ") : "no MCP servers installed"
|
|
4459
4568
|
};
|
|
4460
4569
|
}
|
|
4461
4570
|
function checkJq() {
|
|
@@ -4469,15 +4578,32 @@ function checkJq() {
|
|
|
4469
4578
|
};
|
|
4470
4579
|
}
|
|
4471
4580
|
const fix = process.platform === "win32" ? "winget install jqlang.jq (or: scoop install jq)" : process.platform === "darwin" ? "brew install jq" : "apt-get install jq (or: dnf install jq)";
|
|
4472
|
-
|
|
4581
|
+
const installCmd = process.platform === "win32" ? "winget install jqlang.jq" : process.platform === "darwin" ? "brew install jq" : "apt-get install -y jq";
|
|
4582
|
+
return {
|
|
4583
|
+
name: "jq present",
|
|
4584
|
+
status: "warn",
|
|
4585
|
+
message: "jq not found in PATH (optional \u2014 needed by `harnessed audit-log --filter` and the ralph-loop plugin on Windows)",
|
|
4586
|
+
fix,
|
|
4587
|
+
install_commands: [installCmd]
|
|
4588
|
+
};
|
|
4589
|
+
}
|
|
4590
|
+
function sanitizeToolOutput(raw, cap = 60) {
|
|
4591
|
+
return sanitizeOutputTail(raw, cap);
|
|
4473
4592
|
}
|
|
4474
4593
|
function checkWinBash() {
|
|
4475
4594
|
if (process.platform !== "win32") {
|
|
4476
4595
|
return { name: "bash flavor (win)", status: "pass", message: "skipped (non-Windows)" };
|
|
4477
4596
|
}
|
|
4478
|
-
const
|
|
4479
|
-
|
|
4480
|
-
|
|
4597
|
+
const r = resolveBash();
|
|
4598
|
+
if (r.path === null) {
|
|
4599
|
+
return {
|
|
4600
|
+
name: "bash flavor (win)",
|
|
4601
|
+
status: "fail",
|
|
4602
|
+
message: `only the WSL stub is on PATH (${sanitizeToolOutput(r.wslOnPath ?? "")}) \u2014 harnessed verify/install cmds cannot run`,
|
|
4603
|
+
fix: "install Git for Windows (https://git-scm.com/download/win), reorder PATH so Git Bash precedes WSL bash.exe, or set HARNESSED_BASH to a Git Bash path"
|
|
4604
|
+
};
|
|
4605
|
+
}
|
|
4606
|
+
if (r.source === "path-fallback") {
|
|
4481
4607
|
return {
|
|
4482
4608
|
name: "bash flavor (win)",
|
|
4483
4609
|
status: "fail",
|
|
@@ -4485,21 +4611,25 @@ function checkWinBash() {
|
|
|
4485
4611
|
fix: "install Git for Windows (Git Bash) and ensure it is on PATH"
|
|
4486
4612
|
};
|
|
4487
4613
|
}
|
|
4488
|
-
|
|
4489
|
-
const distro = (probe.stdout ?? "").trim();
|
|
4490
|
-
if (distro.length > 0) {
|
|
4614
|
+
if (r.wslOnPath) {
|
|
4491
4615
|
return {
|
|
4492
4616
|
name: "bash flavor (win)",
|
|
4493
|
-
status: "
|
|
4494
|
-
message: `
|
|
4617
|
+
status: "warn",
|
|
4618
|
+
message: `PATH-first bash is the WSL stub (${sanitizeToolOutput(r.wslOnPath)}); harnessed resolved Git Bash at ${r.path} \u2014 but OTHER tools (e.g. ralph-loop plugin forks) may still hit WSL`,
|
|
4495
4619
|
fix: "reorder PATH so Git Bash precedes WSL bash.exe (Settings \u2192 System \u2192 Environment Variables)"
|
|
4496
4620
|
};
|
|
4497
4621
|
}
|
|
4498
|
-
return {
|
|
4622
|
+
return {
|
|
4623
|
+
name: "bash flavor (win)",
|
|
4624
|
+
status: "pass",
|
|
4625
|
+
message: `${r.path} (Git Bash / native, via ${r.source})`
|
|
4626
|
+
};
|
|
4499
4627
|
}
|
|
4500
4628
|
var init_check_builtin = __esm({
|
|
4501
4629
|
"src/cli/lib/check-builtin.ts"() {
|
|
4502
4630
|
init_platform();
|
|
4631
|
+
init_resolveBash();
|
|
4632
|
+
init_verifyMessage();
|
|
4503
4633
|
}
|
|
4504
4634
|
});
|
|
4505
4635
|
|
|
@@ -4513,7 +4643,23 @@ function probeOne(cmd) {
|
|
|
4513
4643
|
const r = spawnSync(finder, [cmd], { encoding: "utf8" });
|
|
4514
4644
|
return r.status === 0 && (r.stdout?.trim().length ?? 0) > 0;
|
|
4515
4645
|
}
|
|
4516
|
-
function
|
|
4646
|
+
function gstackSkillsDirInstalled(exists) {
|
|
4647
|
+
for (const dir of harnessSkillsDirs()) {
|
|
4648
|
+
const root = join(dir, "gstack");
|
|
4649
|
+
if (exists(join(root, "office-hours", "SKILL.md")) || exists(join(root, "skills", "office-hours.md"))) {
|
|
4650
|
+
return root;
|
|
4651
|
+
}
|
|
4652
|
+
}
|
|
4653
|
+
return null;
|
|
4654
|
+
}
|
|
4655
|
+
function probeGstackPrefix(deps) {
|
|
4656
|
+
const exists = deps?.exists ?? ((p6) => {
|
|
4657
|
+
try {
|
|
4658
|
+
return existsSync(p6);
|
|
4659
|
+
} catch {
|
|
4660
|
+
return false;
|
|
4661
|
+
}
|
|
4662
|
+
});
|
|
4517
4663
|
const hasGstack = probeOne("gstack-office-hours");
|
|
4518
4664
|
const hasBare = probeOne("office-hours");
|
|
4519
4665
|
if (hasGstack && !hasBare) {
|
|
@@ -4529,14 +4675,23 @@ function probeGstackPrefix() {
|
|
|
4529
4675
|
fix: `edit .harnessed/config.json manually: '{"gstack_prefix":"gstack-"}' OR '{"gstack_prefix":""}'`
|
|
4530
4676
|
};
|
|
4531
4677
|
}
|
|
4678
|
+
const skillsRoot = gstackSkillsDirInstalled(exists);
|
|
4679
|
+
if (skillsRoot !== null) {
|
|
4680
|
+
return {
|
|
4681
|
+
status: "pass",
|
|
4682
|
+
prefix: "",
|
|
4683
|
+
detail: `gstack skills dir found (${skillsRoot})`
|
|
4684
|
+
};
|
|
4685
|
+
}
|
|
4532
4686
|
return {
|
|
4533
4687
|
status: "fail",
|
|
4534
|
-
detail: "neither gstack-office-hours nor office-hours found in PATH",
|
|
4535
|
-
fix: "install gstack: `
|
|
4688
|
+
detail: "neither gstack-office-hours nor office-hours found in PATH, and no gstack skills dir",
|
|
4689
|
+
fix: "install gstack: run `harnessed setup` (git-clones gstack into ~/.claude/skills/gstack) \u2014 see https://github.com/garrytan/gstack"
|
|
4536
4690
|
};
|
|
4537
4691
|
}
|
|
4538
4692
|
var init_probe_gstack = __esm({
|
|
4539
4693
|
"src/cli/lib/probe-gstack.ts"() {
|
|
4694
|
+
init_platform();
|
|
4540
4695
|
}
|
|
4541
4696
|
});
|
|
4542
4697
|
var AliasEntryV1, AliasesV1;
|
|
@@ -5465,10 +5620,65 @@ var init_ccHookAdd2 = __esm({
|
|
|
5465
5620
|
};
|
|
5466
5621
|
}
|
|
5467
5622
|
});
|
|
5623
|
+
function evalClause(clause, home) {
|
|
5624
|
+
const m = clause.match(CLAUSE_RE);
|
|
5625
|
+
if (!m?.[1] || !m[2]) return null;
|
|
5626
|
+
const flag = m[1];
|
|
5627
|
+
let p6 = m[2];
|
|
5628
|
+
if (UNSAFE_PATH_RE.test(p6)) return null;
|
|
5629
|
+
if (p6 === "~") p6 = home;
|
|
5630
|
+
else if (p6.startsWith("~/")) p6 = `${home}/${p6.slice(2)}`;
|
|
5631
|
+
else if (p6.startsWith("~")) return null;
|
|
5632
|
+
try {
|
|
5633
|
+
const st = statSync(p6);
|
|
5634
|
+
if (flag === "f") return st.isFile();
|
|
5635
|
+
if (flag === "d") return st.isDirectory();
|
|
5636
|
+
return true;
|
|
5637
|
+
} catch {
|
|
5638
|
+
return false;
|
|
5639
|
+
}
|
|
5640
|
+
}
|
|
5641
|
+
function evalTestChain(cmd, home = homedir()) {
|
|
5642
|
+
const trimmed = cmd.trim();
|
|
5643
|
+
if (trimmed.length === 0 || !trimmed.startsWith("test ")) return null;
|
|
5644
|
+
const parts = trimmed.split(/\s*(\|\||&&)\s*/);
|
|
5645
|
+
if (parts.length % 2 === 0) return null;
|
|
5646
|
+
let acc = null;
|
|
5647
|
+
let pendingOp = null;
|
|
5648
|
+
for (let i = 0; i < parts.length; i++) {
|
|
5649
|
+
const part = parts[i] ?? "";
|
|
5650
|
+
if (i % 2 === 1) {
|
|
5651
|
+
pendingOp = part;
|
|
5652
|
+
continue;
|
|
5653
|
+
}
|
|
5654
|
+
const v = evalClause(part, home);
|
|
5655
|
+
if (v === null) return null;
|
|
5656
|
+
if (acc === null) {
|
|
5657
|
+
acc = v;
|
|
5658
|
+
} else if (pendingOp === "||") {
|
|
5659
|
+
acc = acc || v;
|
|
5660
|
+
} else {
|
|
5661
|
+
acc = acc && v;
|
|
5662
|
+
}
|
|
5663
|
+
}
|
|
5664
|
+
return acc;
|
|
5665
|
+
}
|
|
5666
|
+
var CLAUSE_RE, UNSAFE_PATH_RE;
|
|
5667
|
+
var init_nativeTest = __esm({
|
|
5668
|
+
"src/installers/lib/nativeTest.ts"() {
|
|
5669
|
+
CLAUSE_RE = /^test\s+-(f|d|e)\s+(\S+)$/;
|
|
5670
|
+
UNSAFE_PATH_RE = /[|&;<>()*?"'`$={}[\]]/;
|
|
5671
|
+
}
|
|
5672
|
+
});
|
|
5468
5673
|
function expandTildeForWindows(cmd) {
|
|
5469
5674
|
const home = homedir().replace(/\\/g, "/");
|
|
5470
5675
|
return cmd.replace(/(^|[\s"'`(])~\//g, `$1${home}/`);
|
|
5471
5676
|
}
|
|
5677
|
+
function needsPosixShell(cmd) {
|
|
5678
|
+
if (POSIX_SYNTAX_RE.test(cmd)) return true;
|
|
5679
|
+
const firstToken = cmd.trim().split(/\s+/)[0]?.toLowerCase() ?? "";
|
|
5680
|
+
return POSIX_FIRST_TOKENS.has(firstToken);
|
|
5681
|
+
}
|
|
5472
5682
|
async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
5473
5683
|
const violation = checkCmdString(cmd);
|
|
5474
5684
|
if (violation) {
|
|
@@ -5485,6 +5695,11 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
|
5485
5695
|
}
|
|
5486
5696
|
};
|
|
5487
5697
|
}
|
|
5698
|
+
const joinedCmd = args.length > 0 ? `${cmd} ${args.join(" ")}` : cmd;
|
|
5699
|
+
const nativeResult = evalTestChain(joinedCmd);
|
|
5700
|
+
if (nativeResult !== null) {
|
|
5701
|
+
return { ok: true, exitCode: nativeResult ? 0 : 1, stdout: "", stderr: "" };
|
|
5702
|
+
}
|
|
5488
5703
|
const installCfg = ctx.manifest.spec.install;
|
|
5489
5704
|
const effectiveTimeoutMs = timeoutMs ?? DEFAULT_INSTALL_TIMEOUT_MS;
|
|
5490
5705
|
const env = { ...process.env, ...installCfg.env ?? {} };
|
|
@@ -5493,10 +5708,24 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
|
5493
5708
|
let triedBash = false;
|
|
5494
5709
|
const stdio = ["ignore", "pipe", "pipe"];
|
|
5495
5710
|
if (process.platform === "win32") {
|
|
5496
|
-
if (opts?.posixShell) {
|
|
5497
|
-
const
|
|
5711
|
+
if (opts?.posixShell && needsPosixShell(joinedCmd)) {
|
|
5712
|
+
const bash = resolveBash();
|
|
5713
|
+
if (bash.path === null) {
|
|
5714
|
+
return {
|
|
5715
|
+
ok: false,
|
|
5716
|
+
phase: "spawn",
|
|
5717
|
+
error: {
|
|
5718
|
+
file: ctx.manifest.metadata.name,
|
|
5719
|
+
path: "/spec/install/cmd",
|
|
5720
|
+
message: `the only \`bash\` on PATH is the WSL stub (${bash.wslOnPath ?? "C:\\Windows\\System32\\bash.exe"}) \u2014 it cannot run harnessed verify/install commands (WSL '~' is the Linux home, and distro-less stubs exit 1). Install Git for Windows (https://git-scm.com/download/win), reorder PATH so Git Bash precedes WSL bash.exe, or set HARNESSED_BASH to a Git Bash path, then re-run \`harnessed setup\`.`,
|
|
5721
|
+
line: null,
|
|
5722
|
+
column: null,
|
|
5723
|
+
keyword: "bash-missing"
|
|
5724
|
+
}
|
|
5725
|
+
};
|
|
5726
|
+
}
|
|
5498
5727
|
triedBash = true;
|
|
5499
|
-
child = spawn(
|
|
5728
|
+
child = spawn(bash.path, ["-c", joinedCmd], { cwd, env, windowsHide: true, stdio });
|
|
5500
5729
|
} else {
|
|
5501
5730
|
const expandedCmd = expandTildeForWindows(cmd);
|
|
5502
5731
|
const expandedArgs = args.map(expandTildeForWindows);
|
|
@@ -5508,8 +5737,7 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
|
5508
5737
|
});
|
|
5509
5738
|
}
|
|
5510
5739
|
} else {
|
|
5511
|
-
|
|
5512
|
-
child = spawn("/bin/sh", ["-c", joined], { cwd, env, stdio });
|
|
5740
|
+
child = spawn("/bin/sh", ["-c", joinedCmd], { cwd, env, stdio });
|
|
5513
5741
|
}
|
|
5514
5742
|
let stdout2 = "";
|
|
5515
5743
|
let stderr = "";
|
|
@@ -5528,7 +5756,11 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
|
5528
5756
|
error: {
|
|
5529
5757
|
file: ctx.manifest.metadata.name,
|
|
5530
5758
|
path: "/spec/install/cmd",
|
|
5531
|
-
|
|
5759
|
+
// v4.15.1 — fall back to stdout when stderr is empty (WSL stubs and
|
|
5760
|
+
// some CLIs write their error text to stdout; a bare trailing colon
|
|
5761
|
+
// read as "no reason" in user dogfood). v4.15.2 — sanitized (CP936
|
|
5762
|
+
// mojibake was embedded verbatim in the ctx7 dogfood error).
|
|
5763
|
+
message: `spawn timed out after ${effectiveTimeoutMs}ms (cmd: ${cmd}); partial output: ${(stderr || stdout2).trim() ? sanitizeOutputTail(stderr || stdout2, 200) : "(no output)"}`,
|
|
5532
5764
|
line: null,
|
|
5533
5765
|
column: null,
|
|
5534
5766
|
keyword: "spawn-timeout"
|
|
@@ -5557,10 +5789,38 @@ async function spawnCmd(ctx, cmd, args, timeoutMs, opts) {
|
|
|
5557
5789
|
});
|
|
5558
5790
|
});
|
|
5559
5791
|
}
|
|
5560
|
-
var DEFAULT_VERIFY_TIMEOUT_MS, DEFAULT_INSTALL_TIMEOUT_MS;
|
|
5792
|
+
var POSIX_SYNTAX_RE, POSIX_FIRST_TOKENS, DEFAULT_VERIFY_TIMEOUT_MS, DEFAULT_INSTALL_TIMEOUT_MS;
|
|
5561
5793
|
var init_spawn = __esm({
|
|
5562
5794
|
"src/installers/lib/spawn.ts"() {
|
|
5563
5795
|
init_security();
|
|
5796
|
+
init_nativeTest();
|
|
5797
|
+
init_resolveBash();
|
|
5798
|
+
init_verifyMessage();
|
|
5799
|
+
POSIX_SYNTAX_RE = /[|;<>`$~[\]{}()*?!]|&&/;
|
|
5800
|
+
POSIX_FIRST_TOKENS = /* @__PURE__ */ new Set([
|
|
5801
|
+
"test",
|
|
5802
|
+
"grep",
|
|
5803
|
+
"rm",
|
|
5804
|
+
"cp",
|
|
5805
|
+
"mv",
|
|
5806
|
+
"mkdir",
|
|
5807
|
+
"ls",
|
|
5808
|
+
"cat",
|
|
5809
|
+
"cd",
|
|
5810
|
+
"sh",
|
|
5811
|
+
"bash",
|
|
5812
|
+
"command",
|
|
5813
|
+
"find",
|
|
5814
|
+
"sed",
|
|
5815
|
+
"awk",
|
|
5816
|
+
"touch",
|
|
5817
|
+
"ln",
|
|
5818
|
+
"chmod",
|
|
5819
|
+
"head",
|
|
5820
|
+
"tail",
|
|
5821
|
+
"which",
|
|
5822
|
+
"echo"
|
|
5823
|
+
]);
|
|
5564
5824
|
DEFAULT_VERIFY_TIMEOUT_MS = 15e3;
|
|
5565
5825
|
DEFAULT_INSTALL_TIMEOUT_MS = 3e5;
|
|
5566
5826
|
}
|
|
@@ -5975,6 +6235,7 @@ var init_gitCloneWithSetup2 = __esm({
|
|
|
5975
6235
|
init_preflight();
|
|
5976
6236
|
init_spawn();
|
|
5977
6237
|
init_state2();
|
|
6238
|
+
init_verifyMessage();
|
|
5978
6239
|
installGitCloneWithSetup = async (ctx) => {
|
|
5979
6240
|
const install = ctx.manifest.spec.install;
|
|
5980
6241
|
if (install.method !== "git-clone-with-setup") {
|
|
@@ -6108,7 +6369,8 @@ var init_gitCloneWithSetup2 = __esm({
|
|
|
6108
6369
|
error: err(
|
|
6109
6370
|
ctx,
|
|
6110
6371
|
"/spec/verify/cmd",
|
|
6111
|
-
|
|
6372
|
+
// v4.15.1 — unified verify-fail format (cmd + output tail; no dangling colon).
|
|
6373
|
+
formatVerifyFail(ctx.manifest.spec.verify.cmd, vr.exitCode, expected, vr.stdout, vr.stderr),
|
|
6112
6374
|
"verify-failed"
|
|
6113
6375
|
)
|
|
6114
6376
|
};
|
|
@@ -6487,6 +6749,7 @@ var init_npmCli2 = __esm({
|
|
|
6487
6749
|
init_preflight();
|
|
6488
6750
|
init_spawn();
|
|
6489
6751
|
init_state2();
|
|
6752
|
+
init_verifyMessage();
|
|
6490
6753
|
installNpmCli = async (ctx) => {
|
|
6491
6754
|
const install = ctx.manifest.spec.install;
|
|
6492
6755
|
if (install.method !== "npm-cli") {
|
|
@@ -6514,9 +6777,11 @@ var init_npmCli2 = __esm({
|
|
|
6514
6777
|
let level = detectLevel(install.cmd);
|
|
6515
6778
|
let cmd = install.cmd;
|
|
6516
6779
|
const plan = { files: [] };
|
|
6517
|
-
if (!ctx.opts.quiet)
|
|
6518
|
-
|
|
6519
|
-
|
|
6780
|
+
if (!ctx.opts.quiet) {
|
|
6781
|
+
process.stdout.write(renderDiff(plan, ctx));
|
|
6782
|
+
if (level === "L4")
|
|
6783
|
+
process.stdout.write(" (L4 system install \u2014 global PATH change; see cmd above)\n");
|
|
6784
|
+
}
|
|
6520
6785
|
const conf = await confirmAt(level, { ...ctx});
|
|
6521
6786
|
if (!conf.proceed) {
|
|
6522
6787
|
if (level === "L4" && conf.reason === "flag-missing" && !ctx.opts.nonInteractive) {
|
|
@@ -6572,7 +6837,8 @@ var init_npmCli2 = __esm({
|
|
|
6572
6837
|
error: err(
|
|
6573
6838
|
ctx,
|
|
6574
6839
|
"/spec/verify/cmd",
|
|
6575
|
-
|
|
6840
|
+
// v4.15.1 — unified verify-fail format (cmd + output tail; no dangling colon).
|
|
6841
|
+
formatVerifyFail(ctx.manifest.spec.verify.cmd, vr.exitCode, expected, vr.stdout, vr.stderr),
|
|
6576
6842
|
"verify-failed"
|
|
6577
6843
|
)
|
|
6578
6844
|
};
|
|
@@ -6594,6 +6860,7 @@ var init_npxSkillInstaller2 = __esm({
|
|
|
6594
6860
|
init_preflight();
|
|
6595
6861
|
init_spawn();
|
|
6596
6862
|
init_state2();
|
|
6863
|
+
init_verifyMessage();
|
|
6597
6864
|
installNpxSkillInstaller = async (ctx) => {
|
|
6598
6865
|
const install = ctx.manifest.spec.install;
|
|
6599
6866
|
if (install.method !== "npx-skill-installer") {
|
|
@@ -6711,7 +6978,8 @@ var init_npxSkillInstaller2 = __esm({
|
|
|
6711
6978
|
error: err(
|
|
6712
6979
|
ctx,
|
|
6713
6980
|
"/spec/verify/cmd",
|
|
6714
|
-
|
|
6981
|
+
// v4.15.1 — unified verify-fail format (cmd + output tail; no dangling colon).
|
|
6982
|
+
formatVerifyFail(ctx.manifest.spec.verify.cmd, vr.exitCode, expected, vr.stdout, vr.stderr),
|
|
6715
6983
|
"verify-failed"
|
|
6716
6984
|
)
|
|
6717
6985
|
};
|
|
@@ -6965,7 +7233,7 @@ var release_preflight_exports = {};
|
|
|
6965
7233
|
__export(release_preflight_exports, {
|
|
6966
7234
|
anyFailed: () => anyFailed,
|
|
6967
7235
|
collectPreflight: () => collectPreflight,
|
|
6968
|
-
defaultDeps: () =>
|
|
7236
|
+
defaultDeps: () => defaultDeps2
|
|
6969
7237
|
});
|
|
6970
7238
|
function unreleasedSection(changelog) {
|
|
6971
7239
|
const start = changelog.indexOf("## [Unreleased]");
|
|
@@ -7020,7 +7288,7 @@ function collectPreflight(deps) {
|
|
|
7020
7288
|
function anyFailed(checks) {
|
|
7021
7289
|
return checks.some((c) => c.status === "fail");
|
|
7022
7290
|
}
|
|
7023
|
-
function
|
|
7291
|
+
function defaultDeps2(cwd) {
|
|
7024
7292
|
let changelog = "";
|
|
7025
7293
|
let version = "";
|
|
7026
7294
|
try {
|
|
@@ -8686,8 +8954,8 @@ function registerReleasePreflight(program2) {
|
|
|
8686
8954
|
program2.command("release-preflight").description(
|
|
8687
8955
|
"Read-only release-readiness gate (CHANGELOG / version / git-clean / tag). Exits 1 if not ready."
|
|
8688
8956
|
).action(async () => {
|
|
8689
|
-
const { collectPreflight: collectPreflight2, anyFailed: anyFailed2, defaultDeps:
|
|
8690
|
-
const checks = collectPreflight2(
|
|
8957
|
+
const { collectPreflight: collectPreflight2, anyFailed: anyFailed2, defaultDeps: defaultDeps3 } = await Promise.resolve().then(() => (init_release_preflight(), release_preflight_exports));
|
|
8958
|
+
const checks = collectPreflight2(defaultDeps3(process.cwd()));
|
|
8691
8959
|
console.log("\n release preflight (read-only \u2014 nothing is pushed/published):\n");
|
|
8692
8960
|
for (const c of checks) {
|
|
8693
8961
|
const mark = c.status === "pass" ? "\u2713" : c.status === "warn" ? "\u26A0" : "\u2717";
|
|
@@ -9432,7 +9700,8 @@ async function reclassifyForceUpdateFailures(firstPass, forcePass, probe) {
|
|
|
9432
9700
|
const failed = [];
|
|
9433
9701
|
const keptExisting = [];
|
|
9434
9702
|
for (const entry of forcePass.failed) {
|
|
9435
|
-
const
|
|
9703
|
+
const m = entry.match(/^([^:]+):\s*(.*)$/s);
|
|
9704
|
+
const name = (m?.[1] ?? entry).trim();
|
|
9436
9705
|
if (priorlyInstalled.has(name)) {
|
|
9437
9706
|
let present = false;
|
|
9438
9707
|
try {
|
|
@@ -9441,7 +9710,7 @@ async function reclassifyForceUpdateFailures(firstPass, forcePass, probe) {
|
|
|
9441
9710
|
present = false;
|
|
9442
9711
|
}
|
|
9443
9712
|
if (present) {
|
|
9444
|
-
keptExisting.push(name);
|
|
9713
|
+
keptExisting.push({ name, reason: m?.[2]?.trim() ?? "" });
|
|
9445
9714
|
continue;
|
|
9446
9715
|
}
|
|
9447
9716
|
}
|
|
@@ -9571,25 +9840,31 @@ function printGrouped(b, prefix = "") {
|
|
|
9571
9840
|
for (const s of b.skipped)
|
|
9572
9841
|
push(groupOf(s.name), { status: "skipped", name: s.name, note: s.reason });
|
|
9573
9842
|
for (const n of b.alreadyInstalled) push(groupOf(n), { status: "already-installed", name: n });
|
|
9574
|
-
for (const
|
|
9575
|
-
|
|
9843
|
+
for (const k of b.keptExisting ?? []) {
|
|
9844
|
+
const why = k.reason ? `refresh failed: ${k.reason.slice(0, 90)}` : "refresh failed";
|
|
9845
|
+
push(groupOf(k.name), {
|
|
9576
9846
|
status: "kept-existing",
|
|
9577
|
-
name:
|
|
9578
|
-
note:
|
|
9847
|
+
name: k.name,
|
|
9848
|
+
note: `${why} \u2014 prior version retained`
|
|
9579
9849
|
});
|
|
9850
|
+
}
|
|
9580
9851
|
for (const g of GROUP_ORDER) {
|
|
9581
9852
|
const entries = buckets[g];
|
|
9582
9853
|
if (!entries || entries.length === 0) continue;
|
|
9583
9854
|
console.log(`
|
|
9584
9855
|
${prefix}${GROUP_LABELS[g] ?? g} (${entries.length})`);
|
|
9585
9856
|
const nameW = Math.max(...entries.map((e) => e.name.length), "component".length);
|
|
9586
|
-
|
|
9587
|
-
for (const e of entries) {
|
|
9857
|
+
const rows = entries.map((e) => {
|
|
9588
9858
|
const note2 = e.note && e.note.length > NOTE_MAX ? `${e.note.slice(0, NOTE_MAX)}\u2026` : e.note;
|
|
9589
9859
|
const line = ` ${GLYPHS[e.status] ?? " "} ${e.status.padEnd(18)} ${e.name.padEnd(nameW)}${note2 ? ` ${note2}` : ""}`;
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9860
|
+
return { status: e.status, line };
|
|
9861
|
+
});
|
|
9862
|
+
const sepW = Math.max(...rows.map((r) => r.line.length)) - 4;
|
|
9863
|
+
console.log(` ${"\u2014".repeat(sepW)}`);
|
|
9864
|
+
for (const r of rows) {
|
|
9865
|
+
if (r.status === "failed") console.error(r.line);
|
|
9866
|
+
else if (r.status === "kept-existing") console.warn(r.line);
|
|
9867
|
+
else console.log(r.line);
|
|
9593
9868
|
}
|
|
9594
9869
|
}
|
|
9595
9870
|
}
|
|
@@ -9727,6 +10002,8 @@ installing ${manifestPaths.length} upstream components (MCP serialized, rest par
|
|
|
9727
10002
|
initialValue: false
|
|
9728
10003
|
});
|
|
9729
10004
|
if (!isCancel6(ans) && ans === true) {
|
|
10005
|
+
console.log(`
|
|
10006
|
+
force-updating ${b.alreadyInstalled.length} plugin(s)...`);
|
|
9730
10007
|
const b2 = await runStepBInstall(manifestPaths, {
|
|
9731
10008
|
updateInstalled: true,
|
|
9732
10009
|
quiet: true,
|
|
@@ -9758,6 +10035,12 @@ Force-update pass complete: ${b2.installed.length} installed / ${b2.keptExisting
|
|
|
9758
10035
|
await runL4Rescue2(manifestPaths, b.skipped);
|
|
9759
10036
|
}
|
|
9760
10037
|
}
|
|
10038
|
+
if (b.failed.length > 0) {
|
|
10039
|
+
console.error(
|
|
10040
|
+
`
|
|
10041
|
+
${b.failed.length} component(s) failed \u2014 see the notes in the tables above; re-run \`harnessed setup\` to retry, or run \`harnessed doctor\` for environment diagnostics.`
|
|
10042
|
+
);
|
|
10043
|
+
}
|
|
9761
10044
|
console.log(
|
|
9762
10045
|
t("setup.complete", {
|
|
9763
10046
|
skills: skillsInstalled,
|