harnessed 4.38.0 → 4.39.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/dist/cli.mjs +86 -6
- 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/workflows/capabilities.yaml +110 -110
- package/workflows/defaults.yaml +17 -7
- package/workflows/discuss/phase/workflow.yaml +0 -1
- package/workflows/discuss/strategic/workflow.yaml +0 -2
- package/workflows/discuss/subtask/workflow.yaml +0 -1
- package/workflows/judgments/stage-routing.yaml +10 -0
- package/workflows/plan/architecture/workflow.yaml +0 -1
- package/workflows/plan/phase/workflow.yaml +0 -1
- package/workflows/research/workflow.yaml +0 -6
- package/workflows/retro/workflow.yaml +0 -1
- package/workflows/task/clarify/workflow.yaml +0 -1
- package/workflows/task/code/workflow.yaml +0 -1
- package/workflows/task/deliver/workflow.yaml +0 -1
- package/workflows/task/test/workflow.yaml +0 -1
- package/workflows/verify/auto/workflow.yaml +10 -1
- package/workflows/verify/code-review/workflow.yaml +0 -1
- package/workflows/verify/paranoid/workflow.yaml +0 -1
- package/workflows/verify/progress/workflow.yaml +0 -1
- package/workflows/verify/second-opinion/SKILL.md +89 -0
- package/workflows/verify/second-opinion/SKILL.zh-Hans.md +88 -0
- package/workflows/verify/second-opinion/workflow.yaml +50 -0
- package/workflows/verify/simplify/workflow.yaml +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -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.39.0",
|
|
42
42
|
description: "AI coding harness package manager + composition orchestrator",
|
|
43
43
|
type: "module",
|
|
44
44
|
license: "Apache-2.0",
|
|
@@ -6382,6 +6382,13 @@ function buildDefaultGateContext(task, stage) {
|
|
|
6382
6382
|
// `harnessed gates --context-file`, and through `harnessed run`'s awaited
|
|
6383
6383
|
// probe overlay.
|
|
6384
6384
|
chrome_devtools_available: true,
|
|
6385
|
+
// Phase 54 T3 — seeded FALSE, the opposite of the line above and for the
|
|
6386
|
+
// same reason read the other way: this builder is synchronous and cannot
|
|
6387
|
+
// shell out to git, so the honest default is the direction where being
|
|
6388
|
+
// wrong costs least. Unknown must not ADD a review step — a gate that
|
|
6389
|
+
// fires when it cannot justify itself becomes noise, and noise gets
|
|
6390
|
+
// ignored. The measured value arrives via `harnessed facts`.
|
|
6391
|
+
requires_second_opinion: false,
|
|
6385
6392
|
phase: {
|
|
6386
6393
|
stage,
|
|
6387
6394
|
// T2.1 OQ2(c) — withdrawn: gated stage-routing.verify-paranoid-critical,
|
|
@@ -11383,6 +11390,41 @@ function deriveGitFacts(run) {
|
|
|
11383
11390
|
files_touched: sawNames && files.size > 0 ? files.size : null
|
|
11384
11391
|
};
|
|
11385
11392
|
}
|
|
11393
|
+
var NEWLINE_RE = new RegExp(String.fromCharCode(13) + "?" + String.fromCharCode(10));
|
|
11394
|
+
var ORCHESTRATION_SURFACE = [
|
|
11395
|
+
"workflows/judgments/",
|
|
11396
|
+
"workflows/capabilities.yaml",
|
|
11397
|
+
"workflows/role-prompts",
|
|
11398
|
+
"workflows/disciplines/",
|
|
11399
|
+
"workflows/defaults.yaml",
|
|
11400
|
+
"src/workflow/schema/phaseFactContext.ts",
|
|
11401
|
+
"src/workflow/judgmentResolver.ts",
|
|
11402
|
+
"src/workflow/exprBuilder.ts",
|
|
11403
|
+
"src/cli/facts.ts",
|
|
11404
|
+
"src/checkpoint/ledger.ts"
|
|
11405
|
+
];
|
|
11406
|
+
function onOrchestrationSurface(path) {
|
|
11407
|
+
const p7 = path.split(String.fromCharCode(92)).join("/").trim();
|
|
11408
|
+
if (p7 === "") return false;
|
|
11409
|
+
if (/^workflows\/.+\/SKILL(\.[A-Za-z-]+)?\.md$/.test(p7)) return true;
|
|
11410
|
+
return ORCHESTRATION_SURFACE.some((s) => s.endsWith("/") ? p7.startsWith(s) : p7 === s);
|
|
11411
|
+
}
|
|
11412
|
+
function deriveSecondOpinion(run) {
|
|
11413
|
+
const tagOut = run(["describe", "--tags", "--abbrev=0"]);
|
|
11414
|
+
const tag = tagOut === null ? null : tagOut.trim();
|
|
11415
|
+
if (!tag) {
|
|
11416
|
+
return {
|
|
11417
|
+
fires: false,
|
|
11418
|
+
reason: "no release tag found (git describe --tags failed or the repo has no tags)"
|
|
11419
|
+
};
|
|
11420
|
+
}
|
|
11421
|
+
const diff = run(["diff", "--name-only", tag]);
|
|
11422
|
+
if (diff === null) {
|
|
11423
|
+
return { fires: false, reason: `git diff --name-only ${tag} failed` };
|
|
11424
|
+
}
|
|
11425
|
+
const fires = diff.split(NEWLINE_RE).some(onOrchestrationSurface);
|
|
11426
|
+
return { fires, reason: null };
|
|
11427
|
+
}
|
|
11386
11428
|
function defaultGitRun(args) {
|
|
11387
11429
|
try {
|
|
11388
11430
|
return execFileSync("git", args, {
|
|
@@ -11491,6 +11533,9 @@ function buildFactsEnvelope(master, gatedNames, derived) {
|
|
|
11491
11533
|
usage: `Fill every null in \`facts\` with your honest judgement (leave a fact null to accept harnessed's default), write that object to a file, then run: harnessed gates ${master} --task "<locked spec>" --context-file <path>. The output of this command can be passed back verbatim \u2014 the envelope is unwrapped automatically.`
|
|
11492
11534
|
};
|
|
11493
11535
|
}
|
|
11536
|
+
function secondOpinionFromGit() {
|
|
11537
|
+
return deriveSecondOpinion(defaultGitRun);
|
|
11538
|
+
}
|
|
11494
11539
|
async function runFactsPlan(master, raw, deps = defaultRunDeps, gitRun = defaultGitRun, probeCdt = () => probeChromeDevtools()) {
|
|
11495
11540
|
if (!VALID_MASTERS2.has(master)) {
|
|
11496
11541
|
deps.error(
|
|
@@ -11518,6 +11563,7 @@ async function runFactsPlan(master, raw, deps = defaultRunDeps, gitRun = default
|
|
|
11518
11563
|
return;
|
|
11519
11564
|
}
|
|
11520
11565
|
const git = deriveGitFacts(gitRun);
|
|
11566
|
+
const secondOpinion = deriveSecondOpinion(gitRun);
|
|
11521
11567
|
const cdt = await probeCdt();
|
|
11522
11568
|
const derived = {
|
|
11523
11569
|
// `harnessed gates` seeds phase.stage from the master argument, so facts MUST
|
|
@@ -11542,6 +11588,14 @@ async function runFactsPlan(master, raw, deps = defaultRunDeps, gitRun = default
|
|
|
11542
11588
|
chrome_devtools_available: {
|
|
11543
11589
|
value: chromeDevtoolsAvailable(cdt),
|
|
11544
11590
|
source: chromeDevtoolsFactSource(cdt)
|
|
11591
|
+
},
|
|
11592
|
+
// Phase 54 T3 — root-flat, sister chrome_devtools_available above. `source`
|
|
11593
|
+
// doubles as the UNAVAILABLE REASON: when the criterion cannot be computed
|
|
11594
|
+
// the value is false AND the reason says why, so a repo that can never
|
|
11595
|
+
// answer is visibly unavailable rather than quietly never firing.
|
|
11596
|
+
requires_second_opinion: {
|
|
11597
|
+
value: secondOpinion.fires,
|
|
11598
|
+
source: secondOpinion.reason === null ? "git diff --name-only <last release tag> \u2229 orchestration surface (judgments/capabilities/facts/resolver/ledger/disciplines/SKILL.md)" : `criterion unavailable \u2014 ${secondOpinion.reason}`
|
|
11545
11599
|
}
|
|
11546
11600
|
};
|
|
11547
11601
|
const envelope = buildFactsEnvelope(master, gated, derived);
|
|
@@ -12977,7 +13031,7 @@ function isRalphLoopOptIn(phase) {
|
|
|
12977
13031
|
if (fb?.max_iterations_exceeded !== void 0) return true;
|
|
12978
13032
|
return false;
|
|
12979
13033
|
}
|
|
12980
|
-
function resolveMaxIterations(phase, gateContext) {
|
|
13034
|
+
function resolveMaxIterations(phase, gateContext, fromDefaults) {
|
|
12981
13035
|
const fromCli = typeof gateContext.maxIterations === "number" ? gateContext.maxIterations : void 0;
|
|
12982
13036
|
let fromYaml;
|
|
12983
13037
|
if (phase && typeof phase === "object") {
|
|
@@ -12988,7 +13042,8 @@ function resolveMaxIterations(phase, gateContext) {
|
|
|
12988
13042
|
if (Number.isFinite(n) && n > 0) fromYaml = n;
|
|
12989
13043
|
}
|
|
12990
13044
|
}
|
|
12991
|
-
const
|
|
13045
|
+
const fromTable = typeof fromDefaults === "number" && Number.isFinite(fromDefaults) && fromDefaults > 0 ? fromDefaults : void 0;
|
|
13046
|
+
const chosen = fromCli ?? fromYaml ?? fromTable ?? RALPH_DEFAULT_MAX_ITER;
|
|
12992
13047
|
return Math.min(Math.max(1, chosen), RALPH_HARD_UPPER_LIMIT);
|
|
12993
13048
|
}
|
|
12994
13049
|
var _dispatchSkillStub = {
|
|
@@ -13050,11 +13105,31 @@ var _dispatchSkillStub = {
|
|
|
13050
13105
|
};
|
|
13051
13106
|
}
|
|
13052
13107
|
};
|
|
13108
|
+
function loadMaxIterTable(packageRoot) {
|
|
13109
|
+
try {
|
|
13110
|
+
const doc = parse(
|
|
13111
|
+
readFileSync(join(packageRoot, "workflows", "defaults.yaml"), "utf8")
|
|
13112
|
+
);
|
|
13113
|
+
const out = {};
|
|
13114
|
+
for (const [wf, phases] of Object.entries(doc?.ralph_max_iterations ?? {})) {
|
|
13115
|
+
if (!phases || typeof phases !== "object") continue;
|
|
13116
|
+
const row = {};
|
|
13117
|
+
for (const [id, v] of Object.entries(phases)) {
|
|
13118
|
+
if (typeof v === "number" && Number.isFinite(v) && v > 0) row[id] = v;
|
|
13119
|
+
}
|
|
13120
|
+
out[wf] = row;
|
|
13121
|
+
}
|
|
13122
|
+
return out;
|
|
13123
|
+
} catch {
|
|
13124
|
+
return {};
|
|
13125
|
+
}
|
|
13126
|
+
}
|
|
13053
13127
|
async function runWorkflow(yamlPath, vars, opts = {}) {
|
|
13054
13128
|
const parsed = loadPhases(yamlPath, vars);
|
|
13055
13129
|
const yamlDir = dirname(resolve(yamlPath));
|
|
13056
13130
|
const inferredRoot = resolve(yamlDir, "..", "..");
|
|
13057
13131
|
const packageRoot = opts.packageRoot ?? inferredRoot;
|
|
13132
|
+
const maxIterTable = loadMaxIterTable(packageRoot);
|
|
13058
13133
|
const gateContext = { ...opts.gateContext ?? {} };
|
|
13059
13134
|
let rolePrompts = {};
|
|
13060
13135
|
try {
|
|
@@ -13133,7 +13208,7 @@ async function runWorkflow(yamlPath, vars, opts = {}) {
|
|
|
13133
13208
|
}
|
|
13134
13209
|
}
|
|
13135
13210
|
const skillName = "skills" in ph && ph.skills?.[0] || ph.id;
|
|
13136
|
-
const maxIter = resolveMaxIterations(ph, gateContext);
|
|
13211
|
+
const maxIter = resolveMaxIterations(ph, gateContext, maxIterTable[workflowName]?.[ph.id]);
|
|
13137
13212
|
const fallback = "fallback" in ph && ph.fallback?.max_iterations_exceeded ? ph.fallback.max_iterations_exceeded : void 0;
|
|
13138
13213
|
const r = await _dispatchSkillStub.fn(skillName, ph, {
|
|
13139
13214
|
maxIter,
|
|
@@ -13712,6 +13787,11 @@ function registerRun(program2) {
|
|
|
13712
13787
|
// overlay the MEASURED value (never throws; unknown still resolves true —
|
|
13713
13788
|
// see src/cli/lib/probe-chrome-devtools.ts).
|
|
13714
13789
|
chrome_devtools_available: await isChromeDevtoolsAvailable(),
|
|
13790
|
+
// Phase 54 T3 — same treatment, opposite default: the synchronous builder
|
|
13791
|
+
// seeds `false` (unknown must not add work), so overlay the MEASURED value
|
|
13792
|
+
// here. Never throws — an unavailable criterion resolves false and the
|
|
13793
|
+
// reason surfaces through `harnessed facts` and the per-turn breadcrumb.
|
|
13794
|
+
requires_second_opinion: secondOpinionFromGit().fires,
|
|
13715
13795
|
...raw.model ? { modelOverride: raw.model } : {},
|
|
13716
13796
|
...raw.maxIterations ? { maxIterations: raw.maxIterations } : {},
|
|
13717
13797
|
...raw.staged ? { staged: true } : {},
|
|
@@ -14213,7 +14293,7 @@ var V3_4_3_SIGNATURE_MASTER_RX = /\*\*Preferred path\*\*[\s\S]*dispatch to the p
|
|
|
14213
14293
|
function shouldOverwriteFile(content) {
|
|
14214
14294
|
return HARNESSED_MARKER_RX2.test(content) || V3_4_3_SIGNATURE_SUB_RX.test(content) || V3_4_3_SIGNATURE_MASTER_RX.test(content);
|
|
14215
14295
|
}
|
|
14216
|
-
async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabilities, installedPlugins, installedUserSkills, writer, fileExists2 = existsSync,
|
|
14296
|
+
async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabilities, installedPlugins, installedUserSkills, writer, fileExists2 = existsSync, readFileSync24 = (p7) => readFileSync(p7, "utf8")) {
|
|
14217
14297
|
const results = [];
|
|
14218
14298
|
const aggregatedWarnings = /* @__PURE__ */ new Set();
|
|
14219
14299
|
for (const name of slashNames) {
|
|
@@ -14232,7 +14312,7 @@ async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabiliti
|
|
|
14232
14312
|
if (fileExists2(path)) {
|
|
14233
14313
|
let existing = "";
|
|
14234
14314
|
try {
|
|
14235
|
-
existing =
|
|
14315
|
+
existing = readFileSync24(path);
|
|
14236
14316
|
} catch {
|
|
14237
14317
|
existing = "";
|
|
14238
14318
|
}
|