harnessed 5.0.2 → 5.0.3
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 +84 -29
- 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
|
@@ -37,7 +37,7 @@ var init_package = __esm({
|
|
|
37
37
|
"package.json"() {
|
|
38
38
|
package_default = {
|
|
39
39
|
name: "harnessed",
|
|
40
|
-
version: "5.0.
|
|
40
|
+
version: "5.0.3",
|
|
41
41
|
description: "AI coding harness package manager + composition orchestrator",
|
|
42
42
|
type: "module",
|
|
43
43
|
license: "Apache-2.0",
|
|
@@ -5914,13 +5914,18 @@ function sanitizeOutputTail(raw, cap = 160) {
|
|
|
5914
5914
|
function sanitizeOutputTailEnd(raw, cap = 300) {
|
|
5915
5915
|
const lines = raw.split(/\r?\n/).map((l) => l.replace(/[^\x20-\x7E]/g, "").trim()).filter((l) => l.length > 0);
|
|
5916
5916
|
if (lines.length === 0) return "(unreadable output)";
|
|
5917
|
-
|
|
5917
|
+
const exception = lines.find((line) => /^(?:Error|[A-Za-z]+Error)(?:\s*\[[^\]]+\])?:/.test(line));
|
|
5918
|
+
const tailCap = exception ? Math.max(0, cap - exception.length - 3) : cap;
|
|
5919
|
+
let tail = "";
|
|
5918
5920
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5921
|
+
if (lines[i] === exception) continue;
|
|
5922
|
+
const cand = tail ? `${lines[i]} | ${tail}` : lines[i];
|
|
5923
|
+
if (cand.length > tailCap) break;
|
|
5924
|
+
tail = cand;
|
|
5922
5925
|
}
|
|
5923
|
-
|
|
5926
|
+
if (exception)
|
|
5927
|
+
return tail.length > 0 ? `${exception.slice(0, cap)} | ${tail}` : exception.slice(0, cap);
|
|
5928
|
+
return tail || `${lines[lines.length - 1].slice(0, cap)}\u2026`;
|
|
5924
5929
|
}
|
|
5925
5930
|
function formatSpawnFail(label, exitCode, stdout2, stderr) {
|
|
5926
5931
|
const rawTail = stderr.trim() || stdout2.trim();
|
|
@@ -15944,32 +15949,60 @@ var l4_rescue_exports = {};
|
|
|
15944
15949
|
__export(l4_rescue_exports, {
|
|
15945
15950
|
runL4Rescue: () => runL4Rescue
|
|
15946
15951
|
});
|
|
15947
|
-
async function runL4Rescue(manifestPaths,
|
|
15952
|
+
async function runL4Rescue(manifestPaths, input, hostContext = captureHostInstallContext(), options = {}) {
|
|
15953
|
+
const legacyInput = Array.isArray(input);
|
|
15948
15954
|
const out = { installed: [], skipped: [], failed: [] };
|
|
15949
|
-
const
|
|
15950
|
-
|
|
15955
|
+
const normalized2 = legacyInput ? { skipped: input, failed: [] } : input;
|
|
15956
|
+
const candidates = /* @__PURE__ */ new Map();
|
|
15957
|
+
for (const entry of normalized2.skipped) {
|
|
15958
|
+
if (entry.reason === "level-flag-missing") {
|
|
15959
|
+
candidates.set(entry.name, { name: entry.name, updateInstalled: false });
|
|
15960
|
+
}
|
|
15961
|
+
}
|
|
15962
|
+
for (const failure of normalized2.failed) {
|
|
15963
|
+
const name = failure.split(": ", 1)[0] ?? failure;
|
|
15964
|
+
if (normalized2.failureKeywords?.[name] === "verify-failed" && normalized2.componentTypes?.[name] === "cli-binary") {
|
|
15965
|
+
candidates.set(name, { name, updateInstalled: true });
|
|
15966
|
+
}
|
|
15967
|
+
}
|
|
15968
|
+
if (candidates.size === 0) return out;
|
|
15951
15969
|
const byName = /* @__PURE__ */ new Map();
|
|
15952
15970
|
for (const path of manifestPaths) {
|
|
15953
15971
|
try {
|
|
15954
15972
|
const v = validateManifestFile(await readFile(path, "utf8"), path);
|
|
15955
|
-
if (v.ok)
|
|
15956
|
-
byName.set(
|
|
15957
|
-
|
|
15958
|
-
|
|
15959
|
-
|
|
15973
|
+
if (v.ok) {
|
|
15974
|
+
byName.set(v.manifest.metadata.name, {
|
|
15975
|
+
path: path.replaceAll("\\", "/"),
|
|
15976
|
+
rawInstallType: v.manifest.spec.install_type,
|
|
15977
|
+
plan: resolveComponentPlan(v.manifest, hostContext, "install")
|
|
15978
|
+
});
|
|
15979
|
+
}
|
|
15960
15980
|
} catch {
|
|
15961
15981
|
}
|
|
15962
15982
|
}
|
|
15983
|
+
const targets = [...candidates.values()].filter((target) => {
|
|
15984
|
+
if (!target.updateInstalled) return true;
|
|
15985
|
+
const resolved = byName.get(target.name);
|
|
15986
|
+
if (!resolved?.path.includes("/manifests/tools/")) return false;
|
|
15987
|
+
const spec = resolved.plan.manifest.spec;
|
|
15988
|
+
return resolved.rawInstallType === "npm" && resolved.plan.status === "supported" && spec.type === "cli-npm" && spec.component_type === "cli-binary" && spec.install_type === "npm" && spec.install.method === "npm-cli" && /\bnpm\s+install\s+-g\b/.test(spec.install.cmd);
|
|
15989
|
+
});
|
|
15990
|
+
if (!legacyInput) {
|
|
15991
|
+
out.repairCandidates = targets.filter((target) => target.updateInstalled).map((target) => target.name);
|
|
15992
|
+
out.pending = targets.map((target) => target.name);
|
|
15993
|
+
}
|
|
15994
|
+
if (targets.length === 0 || options.interactive === false) return out;
|
|
15963
15995
|
console.log(
|
|
15964
15996
|
`
|
|
15965
15997
|
${targets.length} component(s) need a system-wide (L4) install \u2014 harnessed can run them now:`
|
|
15966
15998
|
);
|
|
15967
15999
|
for (const t2 of targets) {
|
|
15968
|
-
const
|
|
15969
|
-
if (!
|
|
16000
|
+
const resolved = byName.get(t2.name);
|
|
16001
|
+
if (!resolved) {
|
|
15970
16002
|
out.failed.push({ name: t2.name, reason: "manifest not found for L4 rescue" });
|
|
15971
16003
|
continue;
|
|
15972
16004
|
}
|
|
16005
|
+
const { plan } = resolved;
|
|
15973
16006
|
if (plan.status === "unsupported") {
|
|
15974
16007
|
out.skipped.push(t2.name);
|
|
15975
16008
|
console.log(` skipped ${t2.name} (${plan.reason})`);
|
|
@@ -15996,7 +16029,7 @@ ${targets.length} component(s) need a system-wide (L4) install \u2014 harnessed
|
|
|
15996
16029
|
// consent already given via the confirm above
|
|
15997
16030
|
fullDiff: false,
|
|
15998
16031
|
color: "auto",
|
|
15999
|
-
updateInstalled:
|
|
16032
|
+
updateInstalled: t2.updateInstalled,
|
|
16000
16033
|
quiet: true
|
|
16001
16034
|
};
|
|
16002
16035
|
const r = await runInstall(manifest, opts, plan.context);
|
|
@@ -20630,31 +20663,53 @@ Force-update pass complete: ${b2.installed.length} installed / ${b2.keptExisting
|
|
|
20630
20663
|
}
|
|
20631
20664
|
await enableAgentTeamsInSettings(setupContext);
|
|
20632
20665
|
await enableUserLangInSettings(raw.userLang, setupContext);
|
|
20633
|
-
|
|
20666
|
+
let pendingNonInteractiveL4Repair = false;
|
|
20667
|
+
const hasL4RepairCandidate = b.skipped.some((s) => s.reason === "level-flag-missing") || b.failed.some((failure) => {
|
|
20668
|
+
const name = failure.split(": ", 1)[0] ?? failure;
|
|
20669
|
+
return b.failureKeywords?.[name] === "verify-failed" && b.componentTypes[name] === "cli-binary";
|
|
20670
|
+
});
|
|
20671
|
+
if (!dryRun && hasL4RepairCandidate) {
|
|
20634
20672
|
const isTty = process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
20635
|
-
|
|
20636
|
-
|
|
20637
|
-
|
|
20673
|
+
const interactive = isTty && raw.nonInteractive !== true;
|
|
20674
|
+
const { runL4Rescue: runL4Rescue2 } = await Promise.resolve().then(() => (init_l4_rescue(), l4_rescue_exports));
|
|
20675
|
+
const rescue = await runL4Rescue2(
|
|
20676
|
+
manifestPaths,
|
|
20677
|
+
{
|
|
20678
|
+
skipped: b.skipped,
|
|
20679
|
+
failed: b.failed,
|
|
20680
|
+
failureKeywords: b.failureKeywords,
|
|
20681
|
+
componentTypes: b.componentTypes
|
|
20682
|
+
},
|
|
20683
|
+
setupContext,
|
|
20684
|
+
{ interactive }
|
|
20685
|
+
);
|
|
20686
|
+
pendingNonInteractiveL4Repair = !interactive && (rescue.pending?.length ?? 0) > 0;
|
|
20687
|
+
if (interactive) {
|
|
20688
|
+
const repairCandidates = new Set(rescue.repairCandidates ?? []);
|
|
20689
|
+
const resolved = /* @__PURE__ */ new Set([
|
|
20690
|
+
...rescue.installed,
|
|
20691
|
+
...rescue.failed.map((failure) => failure.name)
|
|
20692
|
+
]);
|
|
20693
|
+
b.failed = b.failed.filter((failure) => {
|
|
20694
|
+
const name = failure.split(": ", 1)[0] ?? failure;
|
|
20695
|
+
return !resolved.has(name);
|
|
20696
|
+
});
|
|
20638
20697
|
b.installed.push(...rescue.installed);
|
|
20639
20698
|
for (const failure of rescue.failed) {
|
|
20640
20699
|
const detail = `${failure.name}: ${failure.reason}`;
|
|
20641
20700
|
b.failed.push(detail);
|
|
20642
20701
|
console.error(` [L4 rescue] ${detail}`);
|
|
20643
20702
|
}
|
|
20644
|
-
const resolved = /* @__PURE__ */ new Set([
|
|
20645
|
-
...rescue.installed,
|
|
20646
|
-
...rescue.failed.map((failure) => failure.name)
|
|
20647
|
-
]);
|
|
20648
20703
|
b.skipped = b.skipped.filter(
|
|
20649
|
-
(skip) => skip.reason !== "level-flag-missing" || !resolved.has(skip.name)
|
|
20704
|
+
(skip) => skip.reason !== "level-flag-missing" || !resolved.has(skip.name) && !repairCandidates.has(skip.name)
|
|
20650
20705
|
);
|
|
20651
20706
|
}
|
|
20652
20707
|
}
|
|
20653
|
-
if (raw.system !== true && b.skipped.some(
|
|
20708
|
+
if (raw.system !== true && (pendingNonInteractiveL4Repair || b.skipped.some(
|
|
20654
20709
|
(skip) => skip.reason === "level-flag-missing" || skip.reason.startsWith("L4 system-scope")
|
|
20655
|
-
)) {
|
|
20710
|
+
))) {
|
|
20656
20711
|
console.warn(
|
|
20657
|
-
"\nL4 system-wide installs remain skipped
|
|
20712
|
+
"\nL4 system-wide installs remain skipped or need repair. Run: harnessed setup --system --non-interactive --update-installed"
|
|
20658
20713
|
);
|
|
20659
20714
|
}
|
|
20660
20715
|
let optionalFailed = 0;
|