cc-codeconductor 1.6.1 → 1.7.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.md +22 -7
- package/dist/core/compilation/compile-checker.d.ts +3 -2
- package/dist/core/goal/goal-state.d.ts +1 -0
- package/dist/core/orchestrator/runtime-orchestrator.d.ts +1 -0
- package/dist/core/queue/lock.d.ts +3 -0
- package/dist/core/verification/rdd-receipt.d.ts +6 -0
- package/dist/core/verification/verification-runner.d.ts +11 -2
- package/dist/index.js +1217 -596
- package/dist/library.js +391 -140
- package/dist/validation/schemas.d.ts +65 -26
- package/docs/generated/cli.md +8 -0
- package/package.json +1 -1
- package/presets/agy/AGENTS.md +1 -1
- package/presets/agy/scripts/invoke-hook.cjs +43 -24
- package/presets/agy/skills/backlog/SKILL.md +1 -1
- package/presets/agy/skills/cc-spec-mutation/SKILL.md +1 -1
- package/presets/agy/skills/cc-tdd-cycle/SKILL.md +1 -1
- package/presets/agy/skills/evaluation/SKILL.md +1 -1
- package/presets/agy/skills/openspec/SKILL.md +10 -6
- package/presets/agy/skills/testing-tdd/SKILL.md +3 -3
- package/presets/agy/workflows/cc-api-contract.md +1 -1
- package/presets/agy/workflows/cc-ask.md +2 -2
- package/presets/agy/workflows/cc-db-migration.md +1 -1
- package/presets/agy/workflows/cc-feature.md +1 -1
- package/presets/agy/workflows/cc-fix.md +1 -1
- package/presets/agy/workflows/cc-iterative.md +1 -1
- package/presets/agy/workflows/cc-odd.md +2 -2
- package/presets/agy/workflows/cc-openspec.md +1 -1
- package/presets/agy/workflows/cc-spec-mutation.md +2 -2
- package/presets/agy/workflows/cc-tdd-cycle.md +2 -2
- package/presets/claude/CLAUDE.md +1 -1
- package/presets/claude/commands/cc/api-contract.md +1 -1
- package/presets/claude/commands/cc/ask.md +2 -2
- package/presets/claude/commands/cc/db-migration.md +1 -1
- package/presets/claude/commands/cc/feature.md +1 -1
- package/presets/claude/commands/cc/fix.md +1 -1
- package/presets/claude/commands/cc/iterative.md +1 -1
- package/presets/claude/commands/cc/odd.md +2 -2
- package/presets/claude/commands/cc/openspec.md +5 -5
- package/presets/claude/commands/cc/spec-mutation.md +2 -2
- package/presets/claude/commands/cc/tdd-cycle.md +3 -3
- package/presets/claude/settings.json +6 -101
- package/presets/claude/skills/backlog/SKILL.md +1 -1
- package/presets/claude/skills/evaluation/SKILL.md +1 -1
- package/presets/claude/skills/openspec/SKILL.md +10 -6
- package/presets/claude/skills/testing-tdd/SKILL.md +3 -3
- package/presets/codex/AGENTS.md +1 -1
- package/presets/codex/commands/cc-ask.md +2 -2
- package/presets/codex/skills/backlog/SKILL.md +1 -1
- package/presets/codex/skills/cc-api-contract/SKILL.md +1 -1
- package/presets/codex/skills/cc-db-migration/SKILL.md +1 -1
- package/presets/codex/skills/cc-feature/SKILL.md +1 -1
- package/presets/codex/skills/cc-fix/SKILL.md +1 -1
- package/presets/codex/skills/cc-iterative/SKILL.md +1 -1
- package/presets/codex/skills/cc-odd/SKILL.md +2 -2
- package/presets/codex/skills/cc-openspec/SKILL.md +10 -8
- package/presets/codex/skills/cc-spec-mutation/SKILL.md +2 -2
- package/presets/codex/skills/cc-tdd-cycle/SKILL.md +2 -2
- package/presets/codex/skills/django-testing/SKILL.md +1 -1
- package/presets/codex/skills/evaluation/SKILL.md +1 -1
- package/presets/codex/skills/openspec/SKILL.md +10 -6
- package/presets/codex/skills/python-django-stack/SKILL.md +1 -1
- package/presets/codex/skills/testing-tdd/SKILL.md +3 -3
- package/presets/cursor/AGENTS.md +1 -1
- package/presets/cursor/commands/cc/api-contract.md +1 -1
- package/presets/cursor/commands/cc/ask.md +2 -2
- package/presets/cursor/commands/cc/db-migration.md +1 -1
- package/presets/cursor/commands/cc/feature.md +1 -1
- package/presets/cursor/commands/cc/fix.md +1 -1
- package/presets/cursor/commands/cc/iterative.md +1 -1
- package/presets/cursor/commands/cc/odd.md +2 -2
- package/presets/cursor/commands/cc/openspec.md +10 -8
- package/presets/cursor/commands/cc/spec-mutation.md +2 -2
- package/presets/cursor/commands/cc/tdd-cycle.md +2 -2
- package/presets/cursor/skills/backlog/SKILL.md +1 -1
- package/presets/cursor/skills/evaluation/SKILL.md +1 -1
- package/presets/cursor/skills/openspec/SKILL.md +10 -6
- package/presets/cursor/skills/testing-tdd/SKILL.md +3 -3
- package/presets/gemini/GEMINI.md +1 -1
- package/presets/gemini/commands/cc/api-contract.toml +1 -1
- package/presets/gemini/commands/cc/ask.toml +2 -2
- package/presets/gemini/commands/cc/db-migration.toml +1 -1
- package/presets/gemini/commands/cc/feature.toml +1 -1
- package/presets/gemini/commands/cc/fix.toml +1 -1
- package/presets/gemini/commands/cc/iterative.toml +1 -1
- package/presets/gemini/commands/cc/odd.toml +2 -2
- package/presets/gemini/commands/cc/openspec.toml +10 -8
- package/presets/gemini/commands/cc/spec-mutation.toml +2 -2
- package/presets/gemini/commands/cc/tdd-cycle.toml +2 -2
- package/presets/muse/AGENTS.md +1 -1
- package/presets/opencode/agents/implementer.md +1 -1
- package/presets/opencode/agents/tester.md +1 -1
- package/presets/opencode/commands/cc-api-contract.md +1 -1
- package/presets/opencode/commands/cc-ask.md +2 -2
- package/presets/opencode/commands/cc-db-migration.md +1 -1
- package/presets/opencode/commands/cc-feature.md +1 -1
- package/presets/opencode/commands/cc-fix.md +1 -1
- package/presets/opencode/commands/cc-iterative.md +1 -1
- package/presets/opencode/commands/cc-odd.md +2 -2
- package/presets/opencode/commands/cc-openspec.md +2 -2
- package/presets/opencode/commands/cc-spec-mutation.md +2 -2
- package/presets/opencode/commands/cc-tdd-cycle.md +2 -2
- package/presets/opencode/prompts/v1.0.0/implementer.md +1 -1
- package/presets/opencode/prompts/v1.0.0/tester.md +1 -1
- package/presets/opencode/skills/backlog/SKILL.md +1 -1
- package/presets/opencode/skills/django-testing/SKILL.md +1 -0
- package/presets/opencode/skills/evaluation/SKILL.md +1 -1
- package/presets/opencode/skills/openspec/SKILL.md +10 -6
- package/presets/opencode/skills/python-django-stack/SKILL.md +1 -0
- package/presets/opencode/skills/python-fastapi-stack/SKILL.md +1 -0
- package/presets/opencode/skills/spring-boot-kotlin/SKILL.md +1 -0
- package/presets/opencode/skills/sqlalchemy/SKILL.md +1 -0
- package/presets/opencode/skills/testing-tdd/SKILL.md +3 -3
- package/presets/pi/AGENTS.md +1 -1
- package/presets/shared/invoke-hook.cjs +43 -24
- package/src/presets/manifests/claude.yml +1 -1
- package/src/presets/shared-skills.yml +30 -0
- package/src/presets/targets/pi.yml +1 -1
package/dist/index.js
CHANGED
|
@@ -72,7 +72,7 @@ var package_default;
|
|
|
72
72
|
var init_package = __esm(() => {
|
|
73
73
|
package_default = {
|
|
74
74
|
name: "cc-codeconductor",
|
|
75
|
-
version: "1.
|
|
75
|
+
version: "1.7.0",
|
|
76
76
|
description: "A multi-agent orchestration framework for AI-assisted software engineering workflows.",
|
|
77
77
|
keywords: [
|
|
78
78
|
"ai",
|
|
@@ -4179,6 +4179,27 @@ function formatUsage(usage, bin = resolveCliBin()) {
|
|
|
4179
4179
|
}
|
|
4180
4180
|
var init_cli_bin = () => {};
|
|
4181
4181
|
|
|
4182
|
+
// src/core/presets/package-paths.ts
|
|
4183
|
+
var exports_package_paths = {};
|
|
4184
|
+
__export(exports_package_paths, {
|
|
4185
|
+
PACKAGE_ROOT: () => PACKAGE_ROOT,
|
|
4186
|
+
POLICY_PATH: () => POLICY_PATH,
|
|
4187
|
+
ROOT_PRESETS_DIR: () => ROOT_PRESETS_DIR,
|
|
4188
|
+
SKILLS_REGISTRY_PATH: () => SKILLS_REGISTRY_PATH,
|
|
4189
|
+
SRC_PRESETS_DIR: () => SRC_PRESETS_DIR
|
|
4190
|
+
});
|
|
4191
|
+
import { dirname, resolve, sep } from "node:path";
|
|
4192
|
+
import { fileURLToPath } from "node:url";
|
|
4193
|
+
var moduleDir, PACKAGE_ROOT, SRC_PRESETS_DIR, ROOT_PRESETS_DIR, POLICY_PATH, SKILLS_REGISTRY_PATH;
|
|
4194
|
+
var init_package_paths = __esm(() => {
|
|
4195
|
+
moduleDir = dirname(fileURLToPath(import.meta.url));
|
|
4196
|
+
PACKAGE_ROOT = moduleDir.endsWith(`${sep}dist`) ? resolve(moduleDir, "..") : resolve(moduleDir, "..", "..", "..");
|
|
4197
|
+
SRC_PRESETS_DIR = resolve(PACKAGE_ROOT, "src", "presets");
|
|
4198
|
+
ROOT_PRESETS_DIR = resolve(PACKAGE_ROOT, "presets");
|
|
4199
|
+
POLICY_PATH = resolve(PACKAGE_ROOT, "policy.yml");
|
|
4200
|
+
SKILLS_REGISTRY_PATH = resolve(PACKAGE_ROOT, "skills-registry.json");
|
|
4201
|
+
});
|
|
4202
|
+
|
|
4182
4203
|
// node_modules/yaml/dist/nodes/identity.js
|
|
4183
4204
|
var require_identity = __commonJS(function(exports) {
|
|
4184
4205
|
var ALIAS = Symbol.for("yaml.alias");
|
|
@@ -7857,10 +7878,10 @@ var require_resolve_block_map = __commonJS(function(exports) {
|
|
|
7857
7878
|
let offset = bm.offset;
|
|
7858
7879
|
let commentEnd = null;
|
|
7859
7880
|
for (const collItem of bm.items) {
|
|
7860
|
-
const { start, key, sep, value } = collItem;
|
|
7881
|
+
const { start, key, sep: sep2, value } = collItem;
|
|
7861
7882
|
const keyProps = resolveProps.resolveProps(start, {
|
|
7862
7883
|
indicator: "explicit-key-ind",
|
|
7863
|
-
next: key ??
|
|
7884
|
+
next: key ?? sep2?.[0],
|
|
7864
7885
|
offset,
|
|
7865
7886
|
onError,
|
|
7866
7887
|
parentIndent: bm.indent,
|
|
@@ -7874,7 +7895,7 @@ var require_resolve_block_map = __commonJS(function(exports) {
|
|
|
7874
7895
|
else if ("indent" in key && key.indent !== bm.indent)
|
|
7875
7896
|
onError(offset, "BAD_INDENT", startColMsg);
|
|
7876
7897
|
}
|
|
7877
|
-
if (!keyProps.anchor && !keyProps.tag && !
|
|
7898
|
+
if (!keyProps.anchor && !keyProps.tag && !sep2) {
|
|
7878
7899
|
commentEnd = keyProps.end;
|
|
7879
7900
|
if (keyProps.comment) {
|
|
7880
7901
|
if (map.comment)
|
|
@@ -7899,7 +7920,7 @@ var require_resolve_block_map = __commonJS(function(exports) {
|
|
|
7899
7920
|
ctx.atKey = false;
|
|
7900
7921
|
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
|
|
7901
7922
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
7902
|
-
const valueProps = resolveProps.resolveProps(
|
|
7923
|
+
const valueProps = resolveProps.resolveProps(sep2 ?? [], {
|
|
7903
7924
|
indicator: "map-value-ind",
|
|
7904
7925
|
next: value,
|
|
7905
7926
|
offset: keyNode.range[2],
|
|
@@ -7915,7 +7936,7 @@ var require_resolve_block_map = __commonJS(function(exports) {
|
|
|
7915
7936
|
if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
|
|
7916
7937
|
onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
|
|
7917
7938
|
}
|
|
7918
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset,
|
|
7939
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep2, null, valueProps, onError);
|
|
7919
7940
|
if (ctx.schema.compat)
|
|
7920
7941
|
utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
|
|
7921
7942
|
offset = valueNode.range[2];
|
|
@@ -8001,7 +8022,7 @@ var require_resolve_end = __commonJS(function(exports) {
|
|
|
8001
8022
|
let comment = "";
|
|
8002
8023
|
if (end) {
|
|
8003
8024
|
let hasSpace = false;
|
|
8004
|
-
let
|
|
8025
|
+
let sep2 = "";
|
|
8005
8026
|
for (const token of end) {
|
|
8006
8027
|
const { source, type } = token;
|
|
8007
8028
|
switch (type) {
|
|
@@ -8015,13 +8036,13 @@ var require_resolve_end = __commonJS(function(exports) {
|
|
|
8015
8036
|
if (!comment)
|
|
8016
8037
|
comment = cb;
|
|
8017
8038
|
else
|
|
8018
|
-
comment +=
|
|
8019
|
-
|
|
8039
|
+
comment += sep2 + cb;
|
|
8040
|
+
sep2 = "";
|
|
8020
8041
|
break;
|
|
8021
8042
|
}
|
|
8022
8043
|
case "newline":
|
|
8023
8044
|
if (comment)
|
|
8024
|
-
|
|
8045
|
+
sep2 += source;
|
|
8025
8046
|
hasSpace = true;
|
|
8026
8047
|
break;
|
|
8027
8048
|
default:
|
|
@@ -8061,18 +8082,18 @@ var require_resolve_flow_collection = __commonJS(function(exports) {
|
|
|
8061
8082
|
let offset = fc.offset + fc.start.source.length;
|
|
8062
8083
|
for (let i = 0;i < fc.items.length; ++i) {
|
|
8063
8084
|
const collItem = fc.items[i];
|
|
8064
|
-
const { start, key, sep, value } = collItem;
|
|
8085
|
+
const { start, key, sep: sep2, value } = collItem;
|
|
8065
8086
|
const props = resolveProps.resolveProps(start, {
|
|
8066
8087
|
flow: fcName,
|
|
8067
8088
|
indicator: "explicit-key-ind",
|
|
8068
|
-
next: key ??
|
|
8089
|
+
next: key ?? sep2?.[0],
|
|
8069
8090
|
offset,
|
|
8070
8091
|
onError,
|
|
8071
8092
|
parentIndent: fc.indent,
|
|
8072
8093
|
startOnNewline: false
|
|
8073
8094
|
});
|
|
8074
8095
|
if (!props.found) {
|
|
8075
|
-
if (!props.anchor && !props.tag && !
|
|
8096
|
+
if (!props.anchor && !props.tag && !sep2 && !value) {
|
|
8076
8097
|
if (i === 0 && props.comma)
|
|
8077
8098
|
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
|
|
8078
8099
|
else if (i < fc.items.length - 1)
|
|
@@ -8124,8 +8145,8 @@ var require_resolve_flow_collection = __commonJS(function(exports) {
|
|
|
8124
8145
|
}
|
|
8125
8146
|
}
|
|
8126
8147
|
}
|
|
8127
|
-
if (!isMap && !
|
|
8128
|
-
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end,
|
|
8148
|
+
if (!isMap && !sep2 && !props.found) {
|
|
8149
|
+
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep2, null, props, onError);
|
|
8129
8150
|
coll.items.push(valueNode);
|
|
8130
8151
|
offset = valueNode.range[2];
|
|
8131
8152
|
if (isBlock(value))
|
|
@@ -8137,7 +8158,7 @@ var require_resolve_flow_collection = __commonJS(function(exports) {
|
|
|
8137
8158
|
if (isBlock(key))
|
|
8138
8159
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
8139
8160
|
ctx.atKey = false;
|
|
8140
|
-
const valueProps = resolveProps.resolveProps(
|
|
8161
|
+
const valueProps = resolveProps.resolveProps(sep2 ?? [], {
|
|
8141
8162
|
flow: fcName,
|
|
8142
8163
|
indicator: "map-value-ind",
|
|
8143
8164
|
next: value,
|
|
@@ -8148,8 +8169,8 @@ var require_resolve_flow_collection = __commonJS(function(exports) {
|
|
|
8148
8169
|
});
|
|
8149
8170
|
if (valueProps.found) {
|
|
8150
8171
|
if (!isMap && !props.found && ctx.options.strict) {
|
|
8151
|
-
if (
|
|
8152
|
-
for (const st of
|
|
8172
|
+
if (sep2)
|
|
8173
|
+
for (const st of sep2) {
|
|
8153
8174
|
if (st === valueProps.found)
|
|
8154
8175
|
break;
|
|
8155
8176
|
if (st.type === "newline") {
|
|
@@ -8166,7 +8187,7 @@ var require_resolve_flow_collection = __commonJS(function(exports) {
|
|
|
8166
8187
|
else
|
|
8167
8188
|
onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
|
|
8168
8189
|
}
|
|
8169
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end,
|
|
8190
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep2, null, valueProps, onError) : null;
|
|
8170
8191
|
if (valueNode) {
|
|
8171
8192
|
if (isBlock(value))
|
|
8172
8193
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
@@ -8343,7 +8364,7 @@ var require_resolve_block_scalar = __commonJS(function(exports) {
|
|
|
8343
8364
|
chompStart = i + 1;
|
|
8344
8365
|
}
|
|
8345
8366
|
let value = "";
|
|
8346
|
-
let
|
|
8367
|
+
let sep2 = "";
|
|
8347
8368
|
let prevMoreIndented = false;
|
|
8348
8369
|
for (let i = 0;i < contentStart; ++i)
|
|
8349
8370
|
value += lines[i][0].slice(trimIndent) + `
|
|
@@ -8361,33 +8382,33 @@ var require_resolve_block_scalar = __commonJS(function(exports) {
|
|
|
8361
8382
|
indent = "";
|
|
8362
8383
|
}
|
|
8363
8384
|
if (type === Scalar.Scalar.BLOCK_LITERAL) {
|
|
8364
|
-
value +=
|
|
8365
|
-
|
|
8385
|
+
value += sep2 + indent.slice(trimIndent) + content;
|
|
8386
|
+
sep2 = `
|
|
8366
8387
|
`;
|
|
8367
8388
|
} else if (indent.length > trimIndent || content[0] === "\t") {
|
|
8368
|
-
if (
|
|
8369
|
-
|
|
8389
|
+
if (sep2 === " ")
|
|
8390
|
+
sep2 = `
|
|
8370
8391
|
`;
|
|
8371
|
-
else if (!prevMoreIndented &&
|
|
8392
|
+
else if (!prevMoreIndented && sep2 === `
|
|
8372
8393
|
`)
|
|
8373
|
-
|
|
8394
|
+
sep2 = `
|
|
8374
8395
|
|
|
8375
8396
|
`;
|
|
8376
|
-
value +=
|
|
8377
|
-
|
|
8397
|
+
value += sep2 + indent.slice(trimIndent) + content;
|
|
8398
|
+
sep2 = `
|
|
8378
8399
|
`;
|
|
8379
8400
|
prevMoreIndented = true;
|
|
8380
8401
|
} else if (content === "") {
|
|
8381
|
-
if (
|
|
8402
|
+
if (sep2 === `
|
|
8382
8403
|
`)
|
|
8383
8404
|
value += `
|
|
8384
8405
|
`;
|
|
8385
8406
|
else
|
|
8386
|
-
|
|
8407
|
+
sep2 = `
|
|
8387
8408
|
`;
|
|
8388
8409
|
} else {
|
|
8389
|
-
value +=
|
|
8390
|
-
|
|
8410
|
+
value += sep2 + content;
|
|
8411
|
+
sep2 = " ";
|
|
8391
8412
|
prevMoreIndented = false;
|
|
8392
8413
|
}
|
|
8393
8414
|
}
|
|
@@ -8568,27 +8589,27 @@ var require_resolve_flow_scalar = __commonJS(function(exports) {
|
|
|
8568
8589
|
if (!match)
|
|
8569
8590
|
return source;
|
|
8570
8591
|
let res = match[1];
|
|
8571
|
-
let
|
|
8592
|
+
let sep2 = " ";
|
|
8572
8593
|
let pos = first.lastIndex;
|
|
8573
8594
|
line.lastIndex = pos;
|
|
8574
8595
|
while (match = line.exec(source)) {
|
|
8575
8596
|
if (match[1] === "") {
|
|
8576
|
-
if (
|
|
8597
|
+
if (sep2 === `
|
|
8577
8598
|
`)
|
|
8578
|
-
res +=
|
|
8599
|
+
res += sep2;
|
|
8579
8600
|
else
|
|
8580
|
-
|
|
8601
|
+
sep2 = `
|
|
8581
8602
|
`;
|
|
8582
8603
|
} else {
|
|
8583
|
-
res +=
|
|
8584
|
-
|
|
8604
|
+
res += sep2 + match[1];
|
|
8605
|
+
sep2 = " ";
|
|
8585
8606
|
}
|
|
8586
8607
|
pos = line.lastIndex;
|
|
8587
8608
|
}
|
|
8588
8609
|
const last = /[ \t]*(.*)/sy;
|
|
8589
8610
|
last.lastIndex = pos;
|
|
8590
8611
|
match = last.exec(source);
|
|
8591
|
-
return res +
|
|
8612
|
+
return res + sep2 + (match?.[1] ?? "");
|
|
8592
8613
|
}
|
|
8593
8614
|
function doubleQuotedValue(source, onError) {
|
|
8594
8615
|
let res = "";
|
|
@@ -9369,14 +9390,14 @@ var require_cst_stringify = __commonJS(function(exports) {
|
|
|
9369
9390
|
}
|
|
9370
9391
|
}
|
|
9371
9392
|
}
|
|
9372
|
-
function stringifyItem({ start, key, sep, value }) {
|
|
9393
|
+
function stringifyItem({ start, key, sep: sep2, value }) {
|
|
9373
9394
|
let res = "";
|
|
9374
9395
|
for (const st of start)
|
|
9375
9396
|
res += st.source;
|
|
9376
9397
|
if (key)
|
|
9377
9398
|
res += stringifyToken(key);
|
|
9378
|
-
if (
|
|
9379
|
-
for (const st of
|
|
9399
|
+
if (sep2)
|
|
9400
|
+
for (const st of sep2)
|
|
9380
9401
|
res += st.source;
|
|
9381
9402
|
if (value)
|
|
9382
9403
|
res += stringifyToken(value);
|
|
@@ -10524,18 +10545,18 @@ var require_parser = __commonJS(function(exports) {
|
|
|
10524
10545
|
if (this.type === "map-value-ind") {
|
|
10525
10546
|
const prev = getPrevProps(this.peek(2));
|
|
10526
10547
|
const start = getFirstKeyStartProps(prev);
|
|
10527
|
-
let
|
|
10548
|
+
let sep2;
|
|
10528
10549
|
if (scalar.end) {
|
|
10529
|
-
|
|
10530
|
-
|
|
10550
|
+
sep2 = scalar.end;
|
|
10551
|
+
sep2.push(this.sourceToken);
|
|
10531
10552
|
delete scalar.end;
|
|
10532
10553
|
} else
|
|
10533
|
-
|
|
10554
|
+
sep2 = [this.sourceToken];
|
|
10534
10555
|
const map = {
|
|
10535
10556
|
type: "block-map",
|
|
10536
10557
|
offset: scalar.offset,
|
|
10537
10558
|
indent: scalar.indent,
|
|
10538
|
-
items: [{ start, key: scalar, sep }]
|
|
10559
|
+
items: [{ start, key: scalar, sep: sep2 }]
|
|
10539
10560
|
};
|
|
10540
10561
|
this.onKeyLine = true;
|
|
10541
10562
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -10689,15 +10710,15 @@ var require_parser = __commonJS(function(exports) {
|
|
|
10689
10710
|
} else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
|
|
10690
10711
|
const start2 = getFirstKeyStartProps(it.start);
|
|
10691
10712
|
const key = it.key;
|
|
10692
|
-
const
|
|
10693
|
-
|
|
10713
|
+
const sep2 = it.sep;
|
|
10714
|
+
sep2.push(this.sourceToken);
|
|
10694
10715
|
delete it.key;
|
|
10695
10716
|
delete it.sep;
|
|
10696
10717
|
this.stack.push({
|
|
10697
10718
|
type: "block-map",
|
|
10698
10719
|
offset: this.offset,
|
|
10699
10720
|
indent: this.indent,
|
|
10700
|
-
items: [{ start: start2, key, sep }]
|
|
10721
|
+
items: [{ start: start2, key, sep: sep2 }]
|
|
10701
10722
|
});
|
|
10702
10723
|
} else if (start.length > 0) {
|
|
10703
10724
|
it.sep = it.sep.concat(start, this.sourceToken);
|
|
@@ -10891,13 +10912,13 @@ var require_parser = __commonJS(function(exports) {
|
|
|
10891
10912
|
const prev = getPrevProps(parent);
|
|
10892
10913
|
const start = getFirstKeyStartProps(prev);
|
|
10893
10914
|
fixFlowSeqItems(fc);
|
|
10894
|
-
const
|
|
10895
|
-
|
|
10915
|
+
const sep2 = fc.end.splice(1, fc.end.length);
|
|
10916
|
+
sep2.push(this.sourceToken);
|
|
10896
10917
|
const map = {
|
|
10897
10918
|
type: "block-map",
|
|
10898
10919
|
offset: fc.offset,
|
|
10899
10920
|
indent: fc.indent,
|
|
10900
|
-
items: [{ start, key: fc, sep }]
|
|
10921
|
+
items: [{ start, key: fc, sep: sep2 }]
|
|
10901
10922
|
};
|
|
10902
10923
|
this.onKeyLine = true;
|
|
10903
10924
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -11278,6 +11299,7 @@ __export(exports_schemas, {
|
|
|
11278
11299
|
TaskOutcomeSchema: () => TaskOutcomeSchema,
|
|
11279
11300
|
TaskOutcomeSourceSchema: () => TaskOutcomeSourceSchema,
|
|
11280
11301
|
TaskOutcomeStatusSchema: () => TaskOutcomeStatusSchema,
|
|
11302
|
+
TddValidationRecordSchema: () => TddValidationRecordSchema,
|
|
11281
11303
|
TechnicalPlanOutputSchema: () => TechnicalPlanOutputSchema,
|
|
11282
11304
|
TokenUsageSchema: () => TokenUsageSchema,
|
|
11283
11305
|
ToolProviderNamesSchema: () => ToolProviderNamesSchema,
|
|
@@ -11449,7 +11471,7 @@ function validateProductEvent(data) {
|
|
|
11449
11471
|
function validateSkillsRegistry(data) {
|
|
11450
11472
|
return SkillsRegistrySchema.parse(data);
|
|
11451
11473
|
}
|
|
11452
|
-
var CouncilAgentSpecSchema, CouncilSpecSchema, ProjectProfileSchema, CompileCheckConfigSchema, LoopConfigSchema, CodeConductorConfigSchema, RunnerTargetSchema, InstallStrategySchema, ContainedRelativePathSchema, ManifestEntrySchema, InstallManifestSchema, ToolProviderNamesSchema, PermissionProviderNamesSchema, ModelConfigSchema, SkillFrontmatterSchema, CommandFrontmatterSchema, TargetCapabilitiesSchema, ContractTargetSchema, ContractFormatSchema, AgentContractSchema, CouncilFindingSchema, CouncilVerdictInputSchema, ConsensusConfigSchema, CouncilVerdictSchema, ClaudeAgentFileSchema, OpenCodeAgentFileSchema, SentryStackFrameSchema, SentryWebhookSchema, MemoryPointerSchema, MemoryIndexSchema, GoalTaskSchema, GoalGraphSchema, ConfidenceLevelSchema, ProductNodeTypeSchema, GraphRelationSchema, KnowledgeEntitySchema, DecisionSchema, EvidenceSchema, CanonicalTaskCardStatusSchema, CanonicalTaskCardSchema, ProductGraphNodeSchema, ProductGraphEdgeSchema, ProductGraphSchema, ProductMetaSchema, ProductEventTypeSchema, ProductEventSchema, OperationalStateSchema, StrategicMemorySchema, ImpactReportSchema, BusinessReviewOutputSchema, VerificationReportSchema, BacklogStatusSchema, BacklogTypeSchema, BacklogPrioritySchema, BacklogGlobalSchema, BacklogItemSchema, BacklogDocumentSchema, OpenspecTaskCardPhaseSchema, OpenspecTaskCardStatusSchema, OpenspecTaskCardSchema, OpenspecStateSchema, SpecAnalyzeFindingSchema, SpecAnalyzeReportSchema, WorkflowCommandSchema, CcepOutputFormatSchema, CommandEnvelopeSchema, WorkflowPhaseSchema, WorkflowRiskRuleSchema, WorkflowProfileSchema, ExecutionContextSchema, PlannerOutputSchema, AgentArtifactSchema, AgentOutputSchema, ImplementerTestsSchema, ImplementerOutputSchema, ReviewAxisSchema, ReviewFindingSchema, ReviewerOutputSchema, TechnicalPlanOutputSchema, FixIntakeOutputSchema, ScorecardVerdictSchema, ScorecardCriterionIdSchema, ScorecardCriterionSchema, ScorecardRecordSchema, TaskOutcomeSourceSchema, TaskOutcomeStatusSchema, DeliveryRouteSchema, TokenUsageSchema, DeliveryTelemetrySchema, DeliveryLedgerTaskSchema, DeliveryLedgerSchema, HandoffEnvelopeSchema, RepoRelativePathSchema, DeliveryLedgerRequestSchema, TaskOutcomeSchema, HarnessComponentIdSchema, HarnessComponentLayerSchema, HarnessToggleKindSchema, HarnessCatalogEntrySchema, HarnessCatalogSchema, HarnessOverlaySchema, HarnessExperimentSchema, HarnessSuiteTaskSchema, HarnessSuiteSchema, EvaluationIndexSchema, ExecutionProfileNameSchema, ExecutionProfileSchema, SkillsRegistrySchema;
|
|
11474
|
+
var CouncilAgentSpecSchema, CouncilSpecSchema, ProjectProfileSchema, CompileCheckConfigSchema, LoopConfigSchema, CodeConductorConfigSchema, RunnerTargetSchema, InstallStrategySchema, ContainedRelativePathSchema, ManifestEntrySchema, InstallManifestSchema, ToolProviderNamesSchema, PermissionProviderNamesSchema, ModelConfigSchema, SkillFrontmatterSchema, CommandFrontmatterSchema, TargetCapabilitiesSchema, ContractTargetSchema, ContractFormatSchema, AgentContractSchema, CouncilFindingSchema, CouncilVerdictInputSchema, ConsensusConfigSchema, CouncilVerdictSchema, ClaudeAgentFileSchema, OpenCodeAgentFileSchema, SentryStackFrameSchema, SentryWebhookSchema, MemoryPointerSchema, MemoryIndexSchema, GoalTaskSchema, GoalGraphSchema, ConfidenceLevelSchema, ProductNodeTypeSchema, GraphRelationSchema, KnowledgeEntitySchema, DecisionSchema, EvidenceSchema, TddValidationRecordSchema, CanonicalTaskCardStatusSchema, CanonicalTaskCardSchema, ProductGraphNodeSchema, ProductGraphEdgeSchema, ProductGraphSchema, ProductMetaSchema, ProductEventTypeSchema, ProductEventSchema, OperationalStateSchema, StrategicMemorySchema, ImpactReportSchema, BusinessReviewOutputSchema, VerificationReportSchema, BacklogStatusSchema, BacklogTypeSchema, BacklogPrioritySchema, BacklogGlobalSchema, BacklogItemSchema, BacklogDocumentSchema, OpenspecTaskCardPhaseSchema, OpenspecTaskCardStatusSchema, OpenspecTaskCardSchema, OpenspecStateSchema, SpecAnalyzeFindingSchema, SpecAnalyzeReportSchema, WorkflowCommandSchema, CcepOutputFormatSchema, CommandEnvelopeSchema, WorkflowPhaseSchema, WorkflowRiskRuleSchema, WorkflowProfileSchema, ExecutionContextSchema, PlannerOutputSchema, AgentArtifactSchema, AgentOutputSchema, ImplementerTestsSchema, ImplementerOutputSchema, ReviewAxisSchema, ReviewFindingSchema, ReviewerOutputSchema, TechnicalPlanOutputSchema, FixIntakeOutputSchema, ScorecardVerdictSchema, ScorecardCriterionIdSchema, ScorecardCriterionSchema, ScorecardRecordSchema, TaskOutcomeSourceSchema, TaskOutcomeStatusSchema, DeliveryRouteSchema, TokenUsageSchema, DeliveryTelemetrySchema, DeliveryLedgerTaskSchema, DeliveryLedgerSchema, HandoffEnvelopeSchema, RepoRelativePathSchema, DeliveryLedgerRequestSchema, TaskOutcomeSchema, HarnessComponentIdSchema, HarnessComponentLayerSchema, HarnessToggleKindSchema, HarnessCatalogEntrySchema, HarnessCatalogSchema, HarnessOverlaySchema, HarnessExperimentSchema, HarnessSuiteTaskSchema, HarnessSuiteSchema, EvaluationIndexSchema, ExecutionProfileNameSchema, ExecutionProfileSchema, SkillsRegistrySchema;
|
|
11453
11475
|
var init_schemas = __esm(() => {
|
|
11454
11476
|
init_zod();
|
|
11455
11477
|
init_runner_target();
|
|
@@ -11694,6 +11716,7 @@ var init_schemas = __esm(() => {
|
|
|
11694
11716
|
title: exports_external.string(),
|
|
11695
11717
|
type: exports_external.enum(["feature", "fix", "refactor", "test", "docs"]),
|
|
11696
11718
|
risk: exports_external.enum(["low", "medium", "high"]),
|
|
11719
|
+
priority: exports_external.enum(["P0", "P1", "P2", "P3"]).optional(),
|
|
11697
11720
|
status: exports_external.enum(["pending", "in-progress", "done", "blocked"]),
|
|
11698
11721
|
depends_on: exports_external.array(exports_external.string()).optional().default([]),
|
|
11699
11722
|
acceptance_criteria: exports_external.array(exports_external.string()),
|
|
@@ -11766,6 +11789,13 @@ var init_schemas = __esm(() => {
|
|
|
11766
11789
|
summary: exports_external.string().optional(),
|
|
11767
11790
|
data: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
|
|
11768
11791
|
});
|
|
11792
|
+
TddValidationRecordSchema = exports_external.object({
|
|
11793
|
+
taskId: exports_external.string().min(1),
|
|
11794
|
+
evidenceId: exports_external.string().min(1),
|
|
11795
|
+
receiptNonce: exports_external.string().regex(/^[0-9a-f]{32}$/),
|
|
11796
|
+
manifestHash: exports_external.string().regex(/^[0-9a-f]{64}$/),
|
|
11797
|
+
validatedAt: exports_external.string().datetime()
|
|
11798
|
+
}).strict();
|
|
11769
11799
|
CanonicalTaskCardStatusSchema = exports_external.enum([
|
|
11770
11800
|
"draft",
|
|
11771
11801
|
"ready",
|
|
@@ -11830,6 +11860,7 @@ var init_schemas = __esm(() => {
|
|
|
11830
11860
|
ProductEventTypeSchema = exports_external.enum([
|
|
11831
11861
|
"task.started",
|
|
11832
11862
|
"task.completed",
|
|
11863
|
+
"lock.recovered",
|
|
11833
11864
|
"decision.recorded",
|
|
11834
11865
|
"evidence.added",
|
|
11835
11866
|
"ingest.completed",
|
|
@@ -11966,7 +11997,8 @@ var init_schemas = __esm(() => {
|
|
|
11966
11997
|
lastScanHash: exports_external.string().optional(),
|
|
11967
11998
|
lastScanAt: exports_external.string().optional(),
|
|
11968
11999
|
changePaths: exports_external.record(exports_external.string(), exports_external.string()).optional().default({}),
|
|
11969
|
-
itemSnapshots: exports_external.record(exports_external.string(), exports_external.string()).optional().default({})
|
|
12000
|
+
itemSnapshots: exports_external.record(exports_external.string(), exports_external.string()).optional().default({}),
|
|
12001
|
+
itemBaseCommits: exports_external.record(exports_external.string(), exports_external.string()).optional()
|
|
11970
12002
|
});
|
|
11971
12003
|
SpecAnalyzeFindingSchema = exports_external.object({
|
|
11972
12004
|
severity: exports_external.enum(["CRITICAL", "HIGH", "MEDIUM", "LOW"]),
|
|
@@ -12202,7 +12234,8 @@ var init_schemas = __esm(() => {
|
|
|
12202
12234
|
id: ScorecardCriterionIdSchema,
|
|
12203
12235
|
label: exports_external.string(),
|
|
12204
12236
|
weight: exports_external.number().min(0).max(1),
|
|
12205
|
-
score: exports_external.number().int().min(0).max(3),
|
|
12237
|
+
score: exports_external.number().int().min(0).max(3).nullable(),
|
|
12238
|
+
unmeasured: exports_external.boolean().optional(),
|
|
12206
12239
|
notes: exports_external.string().optional(),
|
|
12207
12240
|
autoSuggested: exports_external.boolean().optional()
|
|
12208
12241
|
});
|
|
@@ -12428,10 +12461,10 @@ var init_schemas = __esm(() => {
|
|
|
12428
12461
|
|
|
12429
12462
|
// src/core/config/config-loader.ts
|
|
12430
12463
|
import { readFile } from "node:fs/promises";
|
|
12431
|
-
import { resolve } from "node:path";
|
|
12464
|
+
import { resolve as resolve2 } from "node:path";
|
|
12432
12465
|
async function loadConfig(projectRoot) {
|
|
12433
12466
|
try {
|
|
12434
|
-
const configPath =
|
|
12467
|
+
const configPath = resolve2(projectRoot, CONFIG_FILE);
|
|
12435
12468
|
const content = await readFile(configPath, "utf-8");
|
|
12436
12469
|
const data = $parse(content);
|
|
12437
12470
|
if (!data) {
|
|
@@ -12451,7 +12484,7 @@ async function loadConfig(projectRoot) {
|
|
|
12451
12484
|
}
|
|
12452
12485
|
async function configExists(projectRoot) {
|
|
12453
12486
|
try {
|
|
12454
|
-
const configPath =
|
|
12487
|
+
const configPath = resolve2(projectRoot, CONFIG_FILE);
|
|
12455
12488
|
await readFile(configPath, "utf-8");
|
|
12456
12489
|
return true;
|
|
12457
12490
|
} catch {
|
|
@@ -12465,27 +12498,6 @@ var init_config_loader = __esm(() => {
|
|
|
12465
12498
|
init_schemas();
|
|
12466
12499
|
});
|
|
12467
12500
|
|
|
12468
|
-
// src/core/presets/package-paths.ts
|
|
12469
|
-
var exports_package_paths = {};
|
|
12470
|
-
__export(exports_package_paths, {
|
|
12471
|
-
PACKAGE_ROOT: () => PACKAGE_ROOT,
|
|
12472
|
-
POLICY_PATH: () => POLICY_PATH,
|
|
12473
|
-
ROOT_PRESETS_DIR: () => ROOT_PRESETS_DIR,
|
|
12474
|
-
SKILLS_REGISTRY_PATH: () => SKILLS_REGISTRY_PATH,
|
|
12475
|
-
SRC_PRESETS_DIR: () => SRC_PRESETS_DIR
|
|
12476
|
-
});
|
|
12477
|
-
import { dirname, resolve as resolve2, sep } from "node:path";
|
|
12478
|
-
import { fileURLToPath } from "node:url";
|
|
12479
|
-
var moduleDir, PACKAGE_ROOT, SRC_PRESETS_DIR, ROOT_PRESETS_DIR, POLICY_PATH, SKILLS_REGISTRY_PATH;
|
|
12480
|
-
var init_package_paths = __esm(() => {
|
|
12481
|
-
moduleDir = dirname(fileURLToPath(import.meta.url));
|
|
12482
|
-
PACKAGE_ROOT = moduleDir.endsWith(`${sep}dist`) ? resolve2(moduleDir, "..") : resolve2(moduleDir, "..", "..", "..");
|
|
12483
|
-
SRC_PRESETS_DIR = resolve2(PACKAGE_ROOT, "src", "presets");
|
|
12484
|
-
ROOT_PRESETS_DIR = resolve2(PACKAGE_ROOT, "presets");
|
|
12485
|
-
POLICY_PATH = resolve2(PACKAGE_ROOT, "policy.yml");
|
|
12486
|
-
SKILLS_REGISTRY_PATH = resolve2(PACKAGE_ROOT, "skills-registry.json");
|
|
12487
|
-
});
|
|
12488
|
-
|
|
12489
12501
|
// src/core/security/target-compatibility.ts
|
|
12490
12502
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
12491
12503
|
async function loadTargetSecurityCompatibility() {
|
|
@@ -13131,6 +13143,7 @@ var init_complementary_detector = __esm(() => {
|
|
|
13131
13143
|
import { lstat as lstat2, readdir, readFile as readFile4, stat } from "node:fs/promises";
|
|
13132
13144
|
import { homedir as homedir2 } from "node:os";
|
|
13133
13145
|
import { join as join4, relative as relative2, resolve as resolve4 } from "node:path";
|
|
13146
|
+
import { isDeepStrictEqual } from "node:util";
|
|
13134
13147
|
function isMaintainerReservedDest(baseDir, destPath) {
|
|
13135
13148
|
const rel = relative2(baseDir, destPath).replace(/\\/g, "/");
|
|
13136
13149
|
if (MAINTAINER_RESERVED_EXACT.has(rel))
|
|
@@ -13187,7 +13200,12 @@ function mergeDeep(target, source) {
|
|
|
13187
13200
|
const srcVal = source[key];
|
|
13188
13201
|
const tgtVal = target[key];
|
|
13189
13202
|
if (Array.isArray(srcVal) && Array.isArray(tgtVal)) {
|
|
13190
|
-
|
|
13203
|
+
const values = [...tgtVal];
|
|
13204
|
+
for (const value of srcVal) {
|
|
13205
|
+
if (!values.some((existing) => isDeepStrictEqual(existing, value)))
|
|
13206
|
+
values.push(value);
|
|
13207
|
+
}
|
|
13208
|
+
result[key] = values;
|
|
13191
13209
|
} else if (srcVal && typeof srcVal === "object" && !Array.isArray(srcVal) && tgtVal && typeof tgtVal === "object" && !Array.isArray(tgtVal)) {
|
|
13192
13210
|
result[key] = mergeDeep(tgtVal, srcVal);
|
|
13193
13211
|
} else {
|
|
@@ -13454,6 +13472,7 @@ async function applySingleFile(srcPath, destPath, strategy, force, dryRun, isTem
|
|
|
13454
13472
|
incomingContent = await injectMcpServers(incomingContent, destPath);
|
|
13455
13473
|
let finalContent = incomingContent;
|
|
13456
13474
|
let action = "written";
|
|
13475
|
+
const warnings = [];
|
|
13457
13476
|
if (strategy === "append") {
|
|
13458
13477
|
let existing = "";
|
|
13459
13478
|
try {
|
|
@@ -13471,9 +13490,30 @@ async function applySingleFile(srcPath, destPath, strategy, force, dryRun, isTem
|
|
|
13471
13490
|
let existing = {};
|
|
13472
13491
|
try {
|
|
13473
13492
|
existing = JSON.parse(await readFile4(destPath, "utf-8"));
|
|
13474
|
-
|
|
13493
|
+
if (!existing || typeof existing !== "object" || Array.isArray(existing)) {
|
|
13494
|
+
throw new Error("Existing JSON must be an object");
|
|
13495
|
+
}
|
|
13496
|
+
} catch (error) {
|
|
13497
|
+
if (error.code !== "ENOENT") {
|
|
13498
|
+
return { src: srcPath, dest: destPath, action: "error", error: `Cannot merge existing JSON: ${error}` };
|
|
13499
|
+
}
|
|
13500
|
+
}
|
|
13475
13501
|
try {
|
|
13476
13502
|
const incoming = JSON.parse(incomingContent);
|
|
13503
|
+
if (!incoming || typeof incoming !== "object" || Array.isArray(incoming)) {
|
|
13504
|
+
throw new Error("Incoming JSON must be an object");
|
|
13505
|
+
}
|
|
13506
|
+
if (srcPath.replace(/\\/g, "/").endsWith("/claude/settings.json")) {
|
|
13507
|
+
const permissions = existing.permissions;
|
|
13508
|
+
const allow = permissions?.allow;
|
|
13509
|
+
if (Array.isArray(allow)) {
|
|
13510
|
+
for (const rule of allow) {
|
|
13511
|
+
if (typeof rule === "string" && /^(?:Bash\([^)]*\*[^)]*\)|WebFetch(?:\([^)]*\*[^)]*\))?)$/.test(rule)) {
|
|
13512
|
+
warnings.push(`${destPath}: preserved user permission ${rule}; review this broad permission.`);
|
|
13513
|
+
}
|
|
13514
|
+
}
|
|
13515
|
+
}
|
|
13516
|
+
}
|
|
13477
13517
|
finalContent = JSON.stringify(mergeDeep(existing, incoming), null, 2);
|
|
13478
13518
|
} catch (e) {
|
|
13479
13519
|
return { src: srcPath, dest: destPath, action: "error", error: `JSON merge failed: ${e}` };
|
|
@@ -13497,7 +13537,7 @@ async function applySingleFile(srcPath, destPath, strategy, force, dryRun, isTem
|
|
|
13497
13537
|
}
|
|
13498
13538
|
}
|
|
13499
13539
|
if (dryRun) {
|
|
13500
|
-
return { src: srcPath, dest: destPath, action, dryRun: true, renderedContent: finalContent };
|
|
13540
|
+
return { src: srcPath, dest: destPath, action, dryRun: true, renderedContent: finalContent, ...warnings.length ? { warnings } : {} };
|
|
13501
13541
|
}
|
|
13502
13542
|
if (baseDir === undefined) {
|
|
13503
13543
|
return {
|
|
@@ -13511,7 +13551,7 @@ async function applySingleFile(srcPath, destPath, strategy, force, dryRun, isTem
|
|
|
13511
13551
|
await writeContainedFile(baseDir, relative2(baseDir, destPath), finalContent, {
|
|
13512
13552
|
force: true
|
|
13513
13553
|
});
|
|
13514
|
-
return { src: srcPath, dest: destPath, action, renderedContent: finalContent };
|
|
13554
|
+
return { src: srcPath, dest: destPath, action, renderedContent: finalContent, ...warnings.length ? { warnings } : {} };
|
|
13515
13555
|
} catch (e) {
|
|
13516
13556
|
return { src: srcPath, dest: destPath, action: "error", error: String(e) };
|
|
13517
13557
|
}
|
|
@@ -14926,6 +14966,7 @@ __export(exports_doctor_command, {
|
|
|
14926
14966
|
});
|
|
14927
14967
|
import { join as join6 } from "node:path";
|
|
14928
14968
|
import { homedir as homedir4 } from "node:os";
|
|
14969
|
+
import { spawnSync } from "node:child_process";
|
|
14929
14970
|
async function doctorCommand(options) {
|
|
14930
14971
|
const { projectRoot, output } = options;
|
|
14931
14972
|
const checks = [];
|
|
@@ -14974,6 +15015,22 @@ async function doctorCommand(options) {
|
|
|
14974
15015
|
}
|
|
14975
15016
|
};
|
|
14976
15017
|
}
|
|
15018
|
+
const hookProbe = spawnSync(process.execPath, [join6(ROOT_PRESETS_DIR, "shared", "invoke-hook.cjs"), "--check"], {
|
|
15019
|
+
cwd: projectRoot,
|
|
15020
|
+
input: "",
|
|
15021
|
+
encoding: "utf8",
|
|
15022
|
+
timeout: 12000,
|
|
15023
|
+
env: { ...process.env, PROJECT_ROOT: projectRoot }
|
|
15024
|
+
});
|
|
15025
|
+
let hookOperational = false;
|
|
15026
|
+
try {
|
|
15027
|
+
hookOperational = hookProbe.status === 0 && JSON.parse(hookProbe.stdout).operational === true;
|
|
15028
|
+
} catch {}
|
|
15029
|
+
checks.push({
|
|
15030
|
+
name: "hook-runner",
|
|
15031
|
+
status: hookOperational ? "pass" : "warn",
|
|
15032
|
+
message: hookOperational ? "CodeConductor hook runner is operational." : "Hook guard unavailable. Install cc-codeconductor locally; CC_DEV=1 is reserved for trusted development. CC_HOOK_FAIL_CLOSED=1 denies pre-tool when unavailable."
|
|
15033
|
+
});
|
|
14977
15034
|
const runnerDirs = [".opencode", ".claude", ".codex"];
|
|
14978
15035
|
for (const dir of runnerDirs) {
|
|
14979
15036
|
try {
|
|
@@ -15283,6 +15340,7 @@ async function doctorCommand(options) {
|
|
|
15283
15340
|
}
|
|
15284
15341
|
}
|
|
15285
15342
|
var init_doctor_command = __esm(() => {
|
|
15343
|
+
init_package_paths();
|
|
15286
15344
|
init_config_loader();
|
|
15287
15345
|
init_target_compatibility();
|
|
15288
15346
|
init_update_checker();
|
|
@@ -17370,6 +17428,7 @@ async function installPresetCommand(options) {
|
|
|
17370
17428
|
const results = await copyFromManifest(manifest, PRESETS_DIR, baseDir, isGlobal, dryRun, force, modelConfig, locale);
|
|
17371
17429
|
for (const r of results) {
|
|
17372
17430
|
allFileResults.push({ target: t, ...r });
|
|
17431
|
+
postInstallWarnings.push(...r.warnings ?? []);
|
|
17373
17432
|
}
|
|
17374
17433
|
if (!dryRun) {
|
|
17375
17434
|
postInstallWarnings.push(...await verifyRenderedFiles(manifest, baseDir, results));
|
|
@@ -20614,15 +20673,233 @@ var init_product_planner = __esm(() => {
|
|
|
20614
20673
|
};
|
|
20615
20674
|
});
|
|
20616
20675
|
|
|
20676
|
+
// src/core/memory/episodic-store.ts
|
|
20677
|
+
import { appendFile, mkdir as mkdir10, readFile as readFile18 } from "node:fs/promises";
|
|
20678
|
+
import { resolve as resolve19 } from "node:path";
|
|
20679
|
+
async function appendEvent(projectRoot, event) {
|
|
20680
|
+
try {
|
|
20681
|
+
const full = ProductEventSchema.parse({
|
|
20682
|
+
...event,
|
|
20683
|
+
id: event.id ?? `evt-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
|
|
20684
|
+
});
|
|
20685
|
+
const path = eventsPath(projectRoot);
|
|
20686
|
+
await mkdir10(resolve19(projectRoot, ".codeconductor"), { recursive: true });
|
|
20687
|
+
await appendFile(path, JSON.stringify(full) + `
|
|
20688
|
+
`, "utf-8");
|
|
20689
|
+
return ok(full);
|
|
20690
|
+
} catch (e) {
|
|
20691
|
+
return err(e instanceof Error ? e : new Error(String(e)));
|
|
20692
|
+
}
|
|
20693
|
+
}
|
|
20694
|
+
async function listEvents(projectRoot, since, type) {
|
|
20695
|
+
try {
|
|
20696
|
+
const content = await readFile18(eventsPath(projectRoot), "utf-8");
|
|
20697
|
+
const events = [];
|
|
20698
|
+
for (const line of content.split(`
|
|
20699
|
+
`)) {
|
|
20700
|
+
if (!line.trim())
|
|
20701
|
+
continue;
|
|
20702
|
+
const parsed = ProductEventSchema.parse(JSON.parse(line));
|
|
20703
|
+
if (since && parsed.timestamp < since)
|
|
20704
|
+
continue;
|
|
20705
|
+
if (type && parsed.type !== type)
|
|
20706
|
+
continue;
|
|
20707
|
+
events.push(parsed);
|
|
20708
|
+
}
|
|
20709
|
+
return ok(events);
|
|
20710
|
+
} catch (e) {
|
|
20711
|
+
if (e.code === "ENOENT") {
|
|
20712
|
+
return ok([]);
|
|
20713
|
+
}
|
|
20714
|
+
return err(e instanceof Error ? e : new Error(String(e)));
|
|
20715
|
+
}
|
|
20716
|
+
}
|
|
20717
|
+
var init_episodic_store = __esm(() => {
|
|
20718
|
+
init_schemas();
|
|
20719
|
+
init_paths();
|
|
20720
|
+
});
|
|
20721
|
+
|
|
20722
|
+
// src/core/queue/lock.ts
|
|
20723
|
+
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
20724
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
20725
|
+
import { mkdir as mkdir11, open as open2, readFile as readFile19, unlink as unlink2 } from "node:fs/promises";
|
|
20726
|
+
import { hostname } from "node:os";
|
|
20727
|
+
import { resolve as resolve20 } from "node:path";
|
|
20728
|
+
async function readOwner(path) {
|
|
20729
|
+
const owner = JSON.parse(await readFile19(path, "utf8"));
|
|
20730
|
+
if (!Number.isInteger(owner.pid) || owner.pid <= 0 || typeof owner.hostname !== "string" || typeof owner.token !== "string" || !owner.token || !Number.isFinite(Date.parse(owner.timestamp))) {
|
|
20731
|
+
throw new Error("Invalid queue lock metadata");
|
|
20732
|
+
}
|
|
20733
|
+
return owner;
|
|
20734
|
+
}
|
|
20735
|
+
function isOrphan(owner) {
|
|
20736
|
+
if (owner.hostname !== hostname() || Date.now() - Date.parse(owner.timestamp) < STALE_MS)
|
|
20737
|
+
return false;
|
|
20738
|
+
try {
|
|
20739
|
+
process.kill(owner.pid, 0);
|
|
20740
|
+
return false;
|
|
20741
|
+
} catch (e) {
|
|
20742
|
+
return e.code === "ESRCH";
|
|
20743
|
+
}
|
|
20744
|
+
}
|
|
20745
|
+
async function removeOwned(path, token) {
|
|
20746
|
+
try {
|
|
20747
|
+
if ((await readOwner(path)).token === token)
|
|
20748
|
+
await unlink2(path);
|
|
20749
|
+
} catch (e) {
|
|
20750
|
+
if (e.code !== "ENOENT")
|
|
20751
|
+
throw e;
|
|
20752
|
+
}
|
|
20753
|
+
}
|
|
20754
|
+
async function electRecovery(dir, token, owner) {
|
|
20755
|
+
const registry = resolve20(dir, "recoveries");
|
|
20756
|
+
await mkdir11(registry, { recursive: true });
|
|
20757
|
+
const seen = new Set;
|
|
20758
|
+
while (!seen.has(token)) {
|
|
20759
|
+
seen.add(token);
|
|
20760
|
+
const path = resolve20(registry, `${createHash3("sha256").update(token).digest("hex")}.json`);
|
|
20761
|
+
try {
|
|
20762
|
+
const file = await open2(path, "wx");
|
|
20763
|
+
try {
|
|
20764
|
+
await file.writeFile(JSON.stringify(owner));
|
|
20765
|
+
} finally {
|
|
20766
|
+
await file.close();
|
|
20767
|
+
}
|
|
20768
|
+
return true;
|
|
20769
|
+
} catch (e) {
|
|
20770
|
+
if (e.code !== "EEXIST")
|
|
20771
|
+
throw e;
|
|
20772
|
+
}
|
|
20773
|
+
const elected = await readOwner(path);
|
|
20774
|
+
if (elected.token === owner.token)
|
|
20775
|
+
return true;
|
|
20776
|
+
if (!isOrphan(elected))
|
|
20777
|
+
return false;
|
|
20778
|
+
token = elected.token;
|
|
20779
|
+
}
|
|
20780
|
+
throw new Error("Invalid queue lock recovery chain");
|
|
20781
|
+
}
|
|
20782
|
+
async function withQueueLock(projectRoot, action) {
|
|
20783
|
+
const root = resolve20(projectRoot);
|
|
20784
|
+
const held = heldLocks.getStore();
|
|
20785
|
+
if (held?.has(root))
|
|
20786
|
+
return action();
|
|
20787
|
+
const dir = resolve20(projectRoot, ".codeconductor/queue");
|
|
20788
|
+
const path = resolve20(dir, ".lock");
|
|
20789
|
+
const recoveryPath = resolve20(dir, ".lock.recovery");
|
|
20790
|
+
const owner = {
|
|
20791
|
+
pid: process.pid,
|
|
20792
|
+
hostname: hostname(),
|
|
20793
|
+
timestamp: new Date().toISOString(),
|
|
20794
|
+
token: randomUUID()
|
|
20795
|
+
};
|
|
20796
|
+
let acquired = false;
|
|
20797
|
+
try {
|
|
20798
|
+
await mkdir11(dir, { recursive: true });
|
|
20799
|
+
for (let attempt = 0;attempt < 40; attempt++) {
|
|
20800
|
+
try {
|
|
20801
|
+
const recoveryOwner = await readOwner(recoveryPath);
|
|
20802
|
+
if (isOrphan(recoveryOwner) && await electRecovery(dir, recoveryOwner.token, owner)) {
|
|
20803
|
+
await removeOwned(recoveryPath, recoveryOwner.token);
|
|
20804
|
+
continue;
|
|
20805
|
+
}
|
|
20806
|
+
} catch (e) {
|
|
20807
|
+
if (e instanceof SyntaxError || e instanceof Error && e.message === "Invalid queue lock metadata") {
|
|
20808
|
+
await new Promise((resolveWait) => setTimeout(resolveWait, 25));
|
|
20809
|
+
continue;
|
|
20810
|
+
}
|
|
20811
|
+
if (e.code !== "ENOENT")
|
|
20812
|
+
throw e;
|
|
20813
|
+
try {
|
|
20814
|
+
const file = await open2(path, "wx");
|
|
20815
|
+
try {
|
|
20816
|
+
await file.writeFile(JSON.stringify(owner));
|
|
20817
|
+
} finally {
|
|
20818
|
+
await file.close();
|
|
20819
|
+
}
|
|
20820
|
+
acquired = true;
|
|
20821
|
+
break;
|
|
20822
|
+
} catch (e2) {
|
|
20823
|
+
if (e2.code !== "EEXIST")
|
|
20824
|
+
throw e2;
|
|
20825
|
+
}
|
|
20826
|
+
try {
|
|
20827
|
+
const existing = await readOwner(path);
|
|
20828
|
+
if (isOrphan(existing) && await electRecovery(dir, existing.token, owner)) {
|
|
20829
|
+
const current = await readOwner(path);
|
|
20830
|
+
if (current.token === existing.token && isOrphan(current)) {
|
|
20831
|
+
await unlink2(path);
|
|
20832
|
+
const recovered = await appendEvent(projectRoot, {
|
|
20833
|
+
type: "lock.recovered",
|
|
20834
|
+
timestamp: new Date().toISOString(),
|
|
20835
|
+
payload: { owner: current }
|
|
20836
|
+
});
|
|
20837
|
+
if (!recovered.success)
|
|
20838
|
+
return recovered;
|
|
20839
|
+
}
|
|
20840
|
+
continue;
|
|
20841
|
+
}
|
|
20842
|
+
} catch (e2) {
|
|
20843
|
+
if (!(e2 instanceof SyntaxError) && !(e2 instanceof Error && e2.message === "Invalid queue lock metadata") && !["ENOENT", "EEXIST"].includes(e2.code ?? ""))
|
|
20844
|
+
throw e2;
|
|
20845
|
+
}
|
|
20846
|
+
}
|
|
20847
|
+
await new Promise((resolveWait) => setTimeout(resolveWait, 25));
|
|
20848
|
+
}
|
|
20849
|
+
if (!acquired)
|
|
20850
|
+
return err(new Error("Queue lock is held by another process; retry after it finishes"));
|
|
20851
|
+
return await heldLocks.run(new Set([...held ?? [], root]), action);
|
|
20852
|
+
} catch (e) {
|
|
20853
|
+
return err(e instanceof Error ? e : new Error(String(e)));
|
|
20854
|
+
} finally {
|
|
20855
|
+
if (acquired) {
|
|
20856
|
+
try {
|
|
20857
|
+
await removeOwned(path, owner.token);
|
|
20858
|
+
} catch (e) {
|
|
20859
|
+
return err(e instanceof Error ? e : new Error(String(e)));
|
|
20860
|
+
}
|
|
20861
|
+
}
|
|
20862
|
+
}
|
|
20863
|
+
}
|
|
20864
|
+
var STALE_MS, heldLocks;
|
|
20865
|
+
var init_lock = __esm(() => {
|
|
20866
|
+
init_episodic_store();
|
|
20867
|
+
STALE_MS = 5 * 60 * 1000;
|
|
20868
|
+
heldLocks = new AsyncLocalStorage;
|
|
20869
|
+
});
|
|
20870
|
+
|
|
20617
20871
|
// src/core/goal/goal-state.ts
|
|
20618
20872
|
var exports_goal_state = {};
|
|
20619
20873
|
__export(exports_goal_state, {
|
|
20620
20874
|
loadGoal: () => loadGoal,
|
|
20621
20875
|
markTaskBlocked: () => markTaskBlocked,
|
|
20876
|
+
propagateBlockedTasks: () => propagateBlockedTasks,
|
|
20622
20877
|
writeGoal: () => writeGoal
|
|
20623
20878
|
});
|
|
20624
|
-
import {
|
|
20625
|
-
import {
|
|
20879
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
20880
|
+
import { mkdir as mkdir12, readFile as readFile20, rename as rename3, unlink as unlink3, writeFile as writeFile10 } from "node:fs/promises";
|
|
20881
|
+
import { resolve as resolve21 } from "node:path";
|
|
20882
|
+
function propagateBlockedTasks(graph) {
|
|
20883
|
+
const blocked = new Set(graph.tasks.filter((task) => task.status === "blocked").map((task) => task.id));
|
|
20884
|
+
let changed = false;
|
|
20885
|
+
let progressed;
|
|
20886
|
+
do {
|
|
20887
|
+
progressed = false;
|
|
20888
|
+
for (const task of graph.tasks) {
|
|
20889
|
+
if (task.status !== "pending")
|
|
20890
|
+
continue;
|
|
20891
|
+
const dependency = (task.depends_on ?? []).find((id) => blocked.has(id));
|
|
20892
|
+
if (!dependency)
|
|
20893
|
+
continue;
|
|
20894
|
+
task.status = "blocked";
|
|
20895
|
+
task.blocked_reason = `Blocked by dependency "${dependency}"`;
|
|
20896
|
+
blocked.add(task.id);
|
|
20897
|
+
progressed = true;
|
|
20898
|
+
changed = true;
|
|
20899
|
+
}
|
|
20900
|
+
} while (progressed);
|
|
20901
|
+
return changed;
|
|
20902
|
+
}
|
|
20626
20903
|
function validateGoalGraph2(graph) {
|
|
20627
20904
|
const ids = new Set(graph.tasks.map((t) => t.id));
|
|
20628
20905
|
if (ids.size !== graph.tasks.length) {
|
|
@@ -20637,14 +20914,20 @@ function validateGoalGraph2(graph) {
|
|
|
20637
20914
|
}
|
|
20638
20915
|
const visited = new Set;
|
|
20639
20916
|
const inStack = new Set;
|
|
20917
|
+
const path = [];
|
|
20918
|
+
let cycle = [];
|
|
20919
|
+
const tasksById = new Map(graph.tasks.map((task) => [task.id, task]));
|
|
20640
20920
|
function dfs(taskId) {
|
|
20641
|
-
if (inStack.has(taskId))
|
|
20921
|
+
if (inStack.has(taskId)) {
|
|
20922
|
+
cycle = [...path.slice(path.indexOf(taskId)), taskId];
|
|
20642
20923
|
return true;
|
|
20924
|
+
}
|
|
20643
20925
|
if (visited.has(taskId))
|
|
20644
20926
|
return false;
|
|
20645
20927
|
visited.add(taskId);
|
|
20646
20928
|
inStack.add(taskId);
|
|
20647
|
-
|
|
20929
|
+
path.push(taskId);
|
|
20930
|
+
const task = tasksById.get(taskId);
|
|
20648
20931
|
if (task) {
|
|
20649
20932
|
for (const dep of task.depends_on ?? []) {
|
|
20650
20933
|
if (dfs(dep))
|
|
@@ -20652,29 +20935,43 @@ function validateGoalGraph2(graph) {
|
|
|
20652
20935
|
}
|
|
20653
20936
|
}
|
|
20654
20937
|
inStack.delete(taskId);
|
|
20938
|
+
path.pop();
|
|
20655
20939
|
return false;
|
|
20656
20940
|
}
|
|
20657
20941
|
for (const task of graph.tasks) {
|
|
20658
20942
|
if (dfs(task.id)) {
|
|
20659
|
-
return err(new Error(`Cycle detected
|
|
20943
|
+
return err(new Error(`Cycle detected: ${cycle.join(" -> ")}`));
|
|
20660
20944
|
}
|
|
20661
20945
|
}
|
|
20662
20946
|
return ok(graph);
|
|
20663
20947
|
}
|
|
20664
20948
|
async function writeGoal(projectRoot, graph) {
|
|
20949
|
+
return withQueueLock(projectRoot, () => writeGoalUnlocked(projectRoot, graph));
|
|
20950
|
+
}
|
|
20951
|
+
async function writeGoalUnlocked(projectRoot, graph) {
|
|
20665
20952
|
const validation = validateGoalGraph2(graph);
|
|
20666
20953
|
if (!validation.success)
|
|
20667
20954
|
return validation;
|
|
20668
|
-
const dir =
|
|
20669
|
-
|
|
20670
|
-
|
|
20671
|
-
|
|
20672
|
-
|
|
20955
|
+
const dir = resolve21(projectRoot, ".codeconductor");
|
|
20956
|
+
const temporary = resolve21(dir, `current-goal.${process.pid}.${randomUUID2()}.tmp`);
|
|
20957
|
+
try {
|
|
20958
|
+
await mkdir12(dir, { recursive: true });
|
|
20959
|
+
await writeFile10(temporary, $stringify(graph), { encoding: "utf-8", flag: "wx" });
|
|
20960
|
+
await rename3(temporary, resolve21(dir, "current-goal.yml"));
|
|
20961
|
+
return ok(undefined);
|
|
20962
|
+
} catch (e) {
|
|
20963
|
+
return err(e instanceof Error ? e : new Error(String(e)));
|
|
20964
|
+
} finally {
|
|
20965
|
+
await unlink3(temporary).catch((e) => {
|
|
20966
|
+
if (e.code !== "ENOENT")
|
|
20967
|
+
throw e;
|
|
20968
|
+
});
|
|
20969
|
+
}
|
|
20673
20970
|
}
|
|
20674
20971
|
async function loadGoal(projectRoot) {
|
|
20675
20972
|
try {
|
|
20676
|
-
const filePath =
|
|
20677
|
-
const content = await
|
|
20973
|
+
const filePath = resolve21(projectRoot, GOAL_FILE);
|
|
20974
|
+
const content = await readFile20(filePath, "utf-8");
|
|
20678
20975
|
const data = $parse(content);
|
|
20679
20976
|
const validated = GoalGraphSchema.parse(data);
|
|
20680
20977
|
return validateGoalGraph2(validated);
|
|
@@ -20683,6 +20980,9 @@ async function loadGoal(projectRoot) {
|
|
|
20683
20980
|
}
|
|
20684
20981
|
}
|
|
20685
20982
|
async function markTaskBlocked(projectRoot, taskId, reason) {
|
|
20983
|
+
return withQueueLock(projectRoot, () => markTaskBlockedUnlocked(projectRoot, taskId, reason));
|
|
20984
|
+
}
|
|
20985
|
+
async function markTaskBlockedUnlocked(projectRoot, taskId, reason) {
|
|
20686
20986
|
const loadResult = await loadGoal(projectRoot);
|
|
20687
20987
|
if (!loadResult.success)
|
|
20688
20988
|
return loadResult;
|
|
@@ -20693,12 +20993,14 @@ async function markTaskBlocked(projectRoot, taskId, reason) {
|
|
|
20693
20993
|
}
|
|
20694
20994
|
task.status = "blocked";
|
|
20695
20995
|
task.blocked_reason = reason;
|
|
20996
|
+
propagateBlockedTasks(graph);
|
|
20696
20997
|
return writeGoal(projectRoot, graph);
|
|
20697
20998
|
}
|
|
20698
20999
|
var GOAL_FILE = ".codeconductor/current-goal.yml";
|
|
20699
21000
|
var init_goal_state = __esm(() => {
|
|
20700
21001
|
init_dist();
|
|
20701
21002
|
init_schemas();
|
|
21003
|
+
init_lock();
|
|
20702
21004
|
});
|
|
20703
21005
|
|
|
20704
21006
|
// src/commands/goal.command.ts
|
|
@@ -20836,8 +21138,8 @@ var init_goal_command = __esm(() => {
|
|
|
20836
21138
|
});
|
|
20837
21139
|
|
|
20838
21140
|
// src/core/openspec/backlog-parser.ts
|
|
20839
|
-
import { readFile as
|
|
20840
|
-
import { resolve as
|
|
21141
|
+
import { readFile as readFile21 } from "node:fs/promises";
|
|
21142
|
+
import { resolve as resolve22 } from "node:path";
|
|
20841
21143
|
function parseBool(value) {
|
|
20842
21144
|
const v = value.trim().toLowerCase();
|
|
20843
21145
|
return v === "yes" || v === "true";
|
|
@@ -21011,8 +21313,8 @@ function parseBacklogMarkdown(content) {
|
|
|
21011
21313
|
}
|
|
21012
21314
|
async function loadBacklog(projectRoot) {
|
|
21013
21315
|
try {
|
|
21014
|
-
const filePath =
|
|
21015
|
-
const content = await
|
|
21316
|
+
const filePath = resolve22(projectRoot, BACKLOG_FILE);
|
|
21317
|
+
const content = await readFile21(filePath, "utf-8");
|
|
21016
21318
|
return parseBacklogMarkdown(content);
|
|
21017
21319
|
} catch (e) {
|
|
21018
21320
|
return err(e instanceof Error ? e : new Error(String(e)));
|
|
@@ -21061,11 +21363,11 @@ function slugify(text) {
|
|
|
21061
21363
|
}
|
|
21062
21364
|
|
|
21063
21365
|
// src/core/knowledge/source-parsers.ts
|
|
21064
|
-
import { readFile as
|
|
21366
|
+
import { readFile as readFile22 } from "node:fs/promises";
|
|
21065
21367
|
import { basename as basename6, join as join17, relative as relative7, sep as sep6 } from "node:path";
|
|
21066
21368
|
async function parseAdrFile(filePath) {
|
|
21067
21369
|
try {
|
|
21068
|
-
const content = await
|
|
21370
|
+
const content = await readFile22(filePath, "utf-8");
|
|
21069
21371
|
const base = basename6(filePath);
|
|
21070
21372
|
const idMatch = base.match(/adr-(\d+)/i);
|
|
21071
21373
|
const id = idMatch ? `adr-${idMatch[1]}` : slugify(base);
|
|
@@ -21114,7 +21416,7 @@ function adrToEntities(adr, source) {
|
|
|
21114
21416
|
}
|
|
21115
21417
|
async function parseReadmeEntities(projectRoot, productName) {
|
|
21116
21418
|
try {
|
|
21117
|
-
const content = await
|
|
21419
|
+
const content = await readFile22(join17(projectRoot, "README.md"), "utf-8");
|
|
21118
21420
|
const firstPara = content.split(`
|
|
21119
21421
|
|
|
21120
21422
|
`).find((p) => p.trim() && !p.startsWith("#") && !p.startsWith(">")) ?? "";
|
|
@@ -21135,7 +21437,7 @@ async function parseReadmeEntities(projectRoot, productName) {
|
|
|
21135
21437
|
}
|
|
21136
21438
|
async function parseGraphifyEntities(projectRoot) {
|
|
21137
21439
|
try {
|
|
21138
|
-
const raw = await
|
|
21440
|
+
const raw = await readFile22(join17(projectRoot, "graphify-out", "graph.json"), "utf-8");
|
|
21139
21441
|
const graph = JSON.parse(raw);
|
|
21140
21442
|
const entities = [];
|
|
21141
21443
|
for (const node2 of graph.nodes ?? []) {
|
|
@@ -21190,57 +21492,11 @@ async function scanSrcComponents(projectRoot) {
|
|
|
21190
21492
|
}
|
|
21191
21493
|
var init_source_parsers = () => {};
|
|
21192
21494
|
|
|
21193
|
-
// src/core/memory/episodic-store.ts
|
|
21194
|
-
import { appendFile, mkdir as mkdir11, readFile as readFile21 } from "node:fs/promises";
|
|
21195
|
-
import { resolve as resolve21 } from "node:path";
|
|
21196
|
-
async function appendEvent(projectRoot, event) {
|
|
21197
|
-
try {
|
|
21198
|
-
const full = ProductEventSchema.parse({
|
|
21199
|
-
...event,
|
|
21200
|
-
id: event.id ?? `evt-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
|
|
21201
|
-
});
|
|
21202
|
-
const path = eventsPath(projectRoot);
|
|
21203
|
-
await mkdir11(resolve21(projectRoot, ".codeconductor"), { recursive: true });
|
|
21204
|
-
await appendFile(path, JSON.stringify(full) + `
|
|
21205
|
-
`, "utf-8");
|
|
21206
|
-
return ok(full);
|
|
21207
|
-
} catch (e) {
|
|
21208
|
-
return err(e instanceof Error ? e : new Error(String(e)));
|
|
21209
|
-
}
|
|
21210
|
-
}
|
|
21211
|
-
async function listEvents(projectRoot, since, type) {
|
|
21212
|
-
try {
|
|
21213
|
-
const content = await readFile21(eventsPath(projectRoot), "utf-8");
|
|
21214
|
-
const events = [];
|
|
21215
|
-
for (const line of content.split(`
|
|
21216
|
-
`)) {
|
|
21217
|
-
if (!line.trim())
|
|
21218
|
-
continue;
|
|
21219
|
-
const parsed = ProductEventSchema.parse(JSON.parse(line));
|
|
21220
|
-
if (since && parsed.timestamp < since)
|
|
21221
|
-
continue;
|
|
21222
|
-
if (type && parsed.type !== type)
|
|
21223
|
-
continue;
|
|
21224
|
-
events.push(parsed);
|
|
21225
|
-
}
|
|
21226
|
-
return ok(events);
|
|
21227
|
-
} catch (e) {
|
|
21228
|
-
if (e.code === "ENOENT") {
|
|
21229
|
-
return ok([]);
|
|
21230
|
-
}
|
|
21231
|
-
return err(e instanceof Error ? e : new Error(String(e)));
|
|
21232
|
-
}
|
|
21233
|
-
}
|
|
21234
|
-
var init_episodic_store = __esm(() => {
|
|
21235
|
-
init_schemas();
|
|
21236
|
-
init_paths();
|
|
21237
|
-
});
|
|
21238
|
-
|
|
21239
21495
|
// src/core/knowledge/ingest-pipeline.ts
|
|
21240
|
-
import { createHash as
|
|
21241
|
-
import { readFile as
|
|
21496
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
21497
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
21242
21498
|
import { join as join18, relative as relative8, sep as sep7 } from "node:path";
|
|
21243
|
-
import { mkdir as
|
|
21499
|
+
import { mkdir as mkdir13, writeFile as writeFile11 } from "node:fs/promises";
|
|
21244
21500
|
async function mapLimit(items, limit, fn) {
|
|
21245
21501
|
if (items.length === 0)
|
|
21246
21502
|
return [];
|
|
@@ -21260,8 +21516,8 @@ async function mapLimit(items, limit, fn) {
|
|
|
21260
21516
|
}
|
|
21261
21517
|
async function hashFile(path) {
|
|
21262
21518
|
try {
|
|
21263
|
-
const content = await
|
|
21264
|
-
return
|
|
21519
|
+
const content = await readFile23(path, "utf-8");
|
|
21520
|
+
return createHash4("sha256").update(content).digest("hex").slice(0, 16);
|
|
21265
21521
|
} catch {
|
|
21266
21522
|
return null;
|
|
21267
21523
|
}
|
|
@@ -21287,7 +21543,7 @@ async function collectDeferRisks(projectRoot) {
|
|
|
21287
21543
|
await walk(join18(projectRoot, "src"));
|
|
21288
21544
|
const perFile = await mapLimit(files, WALK_READ_CONCURRENCY, async (full) => {
|
|
21289
21545
|
const entities = [];
|
|
21290
|
-
const content = await
|
|
21546
|
+
const content = await readFile23(full, "utf-8");
|
|
21291
21547
|
const rel = relative8(projectRoot, full).split(sep7).join("/");
|
|
21292
21548
|
const deferRe = new RegExp(DEFER_REGEX_SOURCE, "gm");
|
|
21293
21549
|
let match;
|
|
@@ -21454,7 +21710,7 @@ async function runIngest(projectRoot, productName) {
|
|
|
21454
21710
|
lastIngestAt: new Date().toISOString(),
|
|
21455
21711
|
sourceHashes
|
|
21456
21712
|
};
|
|
21457
|
-
await
|
|
21713
|
+
await mkdir13(join18(projectRoot, ".codeconductor"), { recursive: true });
|
|
21458
21714
|
await writeFile11(productMetaPath(projectRoot), JSON.stringify(ProductMetaSchema.parse(meta), null, 2), "utf-8");
|
|
21459
21715
|
await appendEvent(projectRoot, {
|
|
21460
21716
|
type: "ingest.completed",
|
|
@@ -21536,11 +21792,11 @@ var init_ingest_command = __esm(() => {
|
|
|
21536
21792
|
});
|
|
21537
21793
|
|
|
21538
21794
|
// src/core/memory/operational-state.ts
|
|
21539
|
-
import { mkdir as
|
|
21540
|
-
import { resolve as
|
|
21795
|
+
import { mkdir as mkdir14, readFile as readFile24, writeFile as writeFile12 } from "node:fs/promises";
|
|
21796
|
+
import { resolve as resolve23 } from "node:path";
|
|
21541
21797
|
async function loadOperationalState(projectRoot) {
|
|
21542
21798
|
try {
|
|
21543
|
-
const raw = await
|
|
21799
|
+
const raw = await readFile24(operationalStatePath(projectRoot), "utf-8");
|
|
21544
21800
|
return ok(OperationalStateSchema.parse(JSON.parse(raw)));
|
|
21545
21801
|
} catch (e) {
|
|
21546
21802
|
if (e.code === "ENOENT") {
|
|
@@ -21562,7 +21818,7 @@ async function saveOperationalState(projectRoot, state) {
|
|
|
21562
21818
|
updatedAt: new Date().toISOString()
|
|
21563
21819
|
});
|
|
21564
21820
|
const path = operationalStatePath(projectRoot);
|
|
21565
|
-
await
|
|
21821
|
+
await mkdir14(resolve23(projectRoot, ".codeconductor"), { recursive: true });
|
|
21566
21822
|
await writeFile12(path, JSON.stringify(validated, null, 2), "utf-8");
|
|
21567
21823
|
return ok(undefined);
|
|
21568
21824
|
} catch (e) {
|
|
@@ -21597,11 +21853,11 @@ var init_operational_state = __esm(() => {
|
|
|
21597
21853
|
});
|
|
21598
21854
|
|
|
21599
21855
|
// src/core/memory/strategic-memory.ts
|
|
21600
|
-
import { mkdir as
|
|
21601
|
-
import { resolve as
|
|
21856
|
+
import { mkdir as mkdir15, readFile as readFile25, writeFile as writeFile13 } from "node:fs/promises";
|
|
21857
|
+
import { resolve as resolve24 } from "node:path";
|
|
21602
21858
|
async function loadStrategicMemory(projectRoot) {
|
|
21603
21859
|
try {
|
|
21604
|
-
const raw = await
|
|
21860
|
+
const raw = await readFile25(strategicPath(projectRoot), "utf-8");
|
|
21605
21861
|
return ok(StrategicMemorySchema.parse(JSON.parse(raw)));
|
|
21606
21862
|
} catch (e) {
|
|
21607
21863
|
if (e.code === "ENOENT") {
|
|
@@ -21622,7 +21878,7 @@ async function saveStrategicMemory(projectRoot, memory) {
|
|
|
21622
21878
|
updatedAt: new Date().toISOString()
|
|
21623
21879
|
});
|
|
21624
21880
|
const path = strategicPath(projectRoot);
|
|
21625
|
-
await
|
|
21881
|
+
await mkdir15(resolve24(projectRoot, ".codeconductor"), { recursive: true });
|
|
21626
21882
|
await writeFile13(path, JSON.stringify(validated, null, 2), "utf-8");
|
|
21627
21883
|
return ok(undefined);
|
|
21628
21884
|
} catch (e) {
|
|
@@ -21635,8 +21891,8 @@ var init_strategic_memory = __esm(() => {
|
|
|
21635
21891
|
});
|
|
21636
21892
|
|
|
21637
21893
|
// src/core/memory/memory-index.ts
|
|
21638
|
-
import { mkdir as
|
|
21639
|
-
import { resolve as
|
|
21894
|
+
import { mkdir as mkdir16, readFile as readFile26, writeFile as writeFile14 } from "node:fs/promises";
|
|
21895
|
+
import { resolve as resolve25 } from "node:path";
|
|
21640
21896
|
function parseMarkdown(content) {
|
|
21641
21897
|
const startIdx = content.indexOf(SENTINEL_START);
|
|
21642
21898
|
const endIdx = content.indexOf(SENTINEL_END);
|
|
@@ -21655,8 +21911,8 @@ function parseMarkdown(content) {
|
|
|
21655
21911
|
}
|
|
21656
21912
|
async function loadMemoryIndex(projectRoot) {
|
|
21657
21913
|
try {
|
|
21658
|
-
const filePath =
|
|
21659
|
-
const content = await
|
|
21914
|
+
const filePath = resolve25(projectRoot, MEMORY_FILE);
|
|
21915
|
+
const content = await readFile26(filePath, "utf-8");
|
|
21660
21916
|
const parsed = parseMarkdown(content);
|
|
21661
21917
|
if (!parsed) {
|
|
21662
21918
|
return err(new Error("Failed to parse memory index from memory.md"));
|
|
@@ -21673,24 +21929,24 @@ var init_memory_index = __esm(() => {
|
|
|
21673
21929
|
});
|
|
21674
21930
|
|
|
21675
21931
|
// src/core/evaluation/outcome-store.ts
|
|
21676
|
-
import { appendFile as appendFile2, mkdir as
|
|
21677
|
-
import { resolve as
|
|
21932
|
+
import { appendFile as appendFile2, mkdir as mkdir17, readFile as readFile27, readdir as readdir6, writeFile as writeFile15 } from "node:fs/promises";
|
|
21933
|
+
import { resolve as resolve26 } from "node:path";
|
|
21678
21934
|
async function ensureEvaluationDir(projectRoot) {
|
|
21679
|
-
const dir =
|
|
21680
|
-
await
|
|
21681
|
-
await
|
|
21935
|
+
const dir = resolve26(projectRoot, EVAL_DIR);
|
|
21936
|
+
await mkdir17(dir, { recursive: true });
|
|
21937
|
+
await mkdir17(resolve26(dir, SCORECARDS_DIR), { recursive: true });
|
|
21682
21938
|
return dir;
|
|
21683
21939
|
}
|
|
21684
21940
|
async function appendOutcome(projectRoot, outcome) {
|
|
21685
21941
|
try {
|
|
21686
21942
|
const dir = await ensureEvaluationDir(projectRoot);
|
|
21687
21943
|
const validated = TaskOutcomeSchema.parse(outcome);
|
|
21688
|
-
await appendFile2(
|
|
21944
|
+
await appendFile2(resolve26(dir, OUTCOMES_FILE), JSON.stringify(validated) + `
|
|
21689
21945
|
`, "utf-8");
|
|
21690
|
-
const indexPath =
|
|
21946
|
+
const indexPath = resolve26(dir, INDEX_FILE);
|
|
21691
21947
|
let index = { version: 1, lastOutcomeId: validated.id };
|
|
21692
21948
|
try {
|
|
21693
|
-
const raw = await
|
|
21949
|
+
const raw = await readFile27(indexPath, "utf-8");
|
|
21694
21950
|
index = EvaluationIndexSchema.parse(JSON.parse(raw));
|
|
21695
21951
|
index.lastOutcomeId = validated.id;
|
|
21696
21952
|
} catch {}
|
|
@@ -21702,8 +21958,8 @@ async function appendOutcome(projectRoot, outcome) {
|
|
|
21702
21958
|
}
|
|
21703
21959
|
async function listOutcomes(projectRoot, filter = {}) {
|
|
21704
21960
|
try {
|
|
21705
|
-
const path =
|
|
21706
|
-
const content = await
|
|
21961
|
+
const path = resolve26(projectRoot, EVAL_DIR, OUTCOMES_FILE);
|
|
21962
|
+
const content = await readFile27(path, "utf-8");
|
|
21707
21963
|
const lines = content.split(`
|
|
21708
21964
|
`).filter((l) => l.trim().length > 0);
|
|
21709
21965
|
const outcomes = [];
|
|
@@ -21741,7 +21997,7 @@ async function saveScorecard(projectRoot, record) {
|
|
|
21741
21997
|
try {
|
|
21742
21998
|
const dir = await ensureEvaluationDir(projectRoot);
|
|
21743
21999
|
const validated = ScorecardRecordSchema.parse(record);
|
|
21744
|
-
const filePath =
|
|
22000
|
+
const filePath = resolve26(dir, SCORECARDS_DIR, `${validated.id}.json`);
|
|
21745
22001
|
await writeFile15(filePath, JSON.stringify(validated, null, 2), "utf-8");
|
|
21746
22002
|
return ok(filePath);
|
|
21747
22003
|
} catch (e) {
|
|
@@ -21750,7 +22006,7 @@ async function saveScorecard(projectRoot, record) {
|
|
|
21750
22006
|
}
|
|
21751
22007
|
async function listScorecards(projectRoot, filter = {}) {
|
|
21752
22008
|
try {
|
|
21753
|
-
const dir =
|
|
22009
|
+
const dir = resolve26(projectRoot, EVAL_DIR, SCORECARDS_DIR);
|
|
21754
22010
|
let files;
|
|
21755
22011
|
try {
|
|
21756
22012
|
files = await readdir6(dir);
|
|
@@ -21763,7 +22019,7 @@ async function listScorecards(projectRoot, filter = {}) {
|
|
|
21763
22019
|
for (const file of files) {
|
|
21764
22020
|
if (!file.endsWith(".json"))
|
|
21765
22021
|
continue;
|
|
21766
|
-
const parsed = ScorecardRecordSchema.parse(JSON.parse(await
|
|
22022
|
+
const parsed = ScorecardRecordSchema.parse(JSON.parse(await readFile27(resolve26(dir, file), "utf-8")));
|
|
21767
22023
|
if (filter.backlogId && parsed.backlogId !== filter.backlogId)
|
|
21768
22024
|
continue;
|
|
21769
22025
|
if (filter.verdict && parsed.verdict !== filter.verdict)
|
|
@@ -21785,8 +22041,8 @@ async function hasPassingScorecard(projectRoot, backlogId) {
|
|
|
21785
22041
|
}
|
|
21786
22042
|
async function loadScorecard(projectRoot, id) {
|
|
21787
22043
|
try {
|
|
21788
|
-
const filePath =
|
|
21789
|
-
const content = await
|
|
22044
|
+
const filePath = resolve26(projectRoot, EVAL_DIR, SCORECARDS_DIR, `${id}.json`);
|
|
22045
|
+
const content = await readFile27(filePath, "utf-8");
|
|
21790
22046
|
return ok(ScorecardRecordSchema.parse(JSON.parse(content)));
|
|
21791
22047
|
} catch (e) {
|
|
21792
22048
|
return err(e instanceof Error ? e : new Error(String(e)));
|
|
@@ -21878,11 +22134,11 @@ var init_outcome_store = __esm(() => {
|
|
|
21878
22134
|
});
|
|
21879
22135
|
|
|
21880
22136
|
// src/core/feedback/feedback-ingestor.ts
|
|
21881
|
-
import { readFile as
|
|
22137
|
+
import { readFile as readFile28 } from "node:fs/promises";
|
|
21882
22138
|
import { join as join19 } from "node:path";
|
|
21883
22139
|
async function parseChangelogLearnings(projectRoot) {
|
|
21884
22140
|
try {
|
|
21885
|
-
const content = await
|
|
22141
|
+
const content = await readFile28(join19(projectRoot, "CHANGELOG.md"), "utf-8");
|
|
21886
22142
|
const unreleased = content.match(/## \[Unreleased\]([\s\S]*?)(?=## \[|\n## )/i);
|
|
21887
22143
|
if (!unreleased)
|
|
21888
22144
|
return [];
|
|
@@ -22226,6 +22482,7 @@ var init_product_command = __esm(() => {
|
|
|
22226
22482
|
});
|
|
22227
22483
|
|
|
22228
22484
|
// src/core/compilation/compile-checker.ts
|
|
22485
|
+
import { spawn } from "node:child_process";
|
|
22229
22486
|
function tokenizeCommand(cmd) {
|
|
22230
22487
|
const tokens = [];
|
|
22231
22488
|
let current = "";
|
|
@@ -22271,6 +22528,12 @@ function isAllowlistedCompileCommand(command) {
|
|
|
22271
22528
|
return false;
|
|
22272
22529
|
return ALLOWLISTED_ARGV_PREFIXES.some((prefix) => parts.length >= prefix.length && prefix.every((token, i) => parts[i] === token));
|
|
22273
22530
|
}
|
|
22531
|
+
function isAllowlistedTestCommand(command) {
|
|
22532
|
+
if (!isAllowlistedCompileCommand(command))
|
|
22533
|
+
return false;
|
|
22534
|
+
const parts = Array.isArray(command) ? command : tokenizeCommand(command);
|
|
22535
|
+
return parts.some((token) => token === "test" || token.startsWith("test:"));
|
|
22536
|
+
}
|
|
22274
22537
|
function minimalChildEnv() {
|
|
22275
22538
|
const env = {
|
|
22276
22539
|
PATH: process.env.PATH ?? "",
|
|
@@ -22376,40 +22639,37 @@ async function runCompileCheck(options) {
|
|
|
22376
22639
|
const startTime = performance.now();
|
|
22377
22640
|
let timedOut = false;
|
|
22378
22641
|
const parts = Array.isArray(command) ? command : tokenizeCommand(command);
|
|
22642
|
+
const failure = (stderr) => ({
|
|
22643
|
+
success: false,
|
|
22644
|
+
exitCode: -1,
|
|
22645
|
+
stdout: "",
|
|
22646
|
+
stderr,
|
|
22647
|
+
errors: [],
|
|
22648
|
+
durationMs: performance.now() - startTime,
|
|
22649
|
+
timedOut: false
|
|
22650
|
+
});
|
|
22379
22651
|
let proc;
|
|
22380
22652
|
try {
|
|
22381
|
-
proc =
|
|
22653
|
+
proc = spawn(parts[0], parts.slice(1), {
|
|
22382
22654
|
cwd,
|
|
22383
|
-
|
|
22384
|
-
stderr: "pipe",
|
|
22655
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
22385
22656
|
env: minimalChildEnv(),
|
|
22386
22657
|
detached: process.platform !== "win32"
|
|
22387
22658
|
});
|
|
22388
22659
|
} catch (err2) {
|
|
22389
|
-
|
|
22390
|
-
|
|
22391
|
-
|
|
22392
|
-
|
|
22393
|
-
|
|
22394
|
-
|
|
22395
|
-
|
|
22396
|
-
|
|
22397
|
-
|
|
22398
|
-
|
|
22399
|
-
}
|
|
22400
|
-
const collectOutput = (async () => {
|
|
22401
|
-
const stdoutStream = proc.stdout;
|
|
22402
|
-
const stderrStream = proc.stderr;
|
|
22403
|
-
const [stdout, stderr] = await Promise.all([
|
|
22404
|
-
new Response(stdoutStream).text(),
|
|
22405
|
-
new Response(stderrStream).text()
|
|
22406
|
-
]);
|
|
22407
|
-
return { stdout, stderr, exitCode: await proc.exited };
|
|
22408
|
-
})();
|
|
22409
|
-
collectOutput.catch(() => {});
|
|
22660
|
+
return failure(String(err2));
|
|
22661
|
+
}
|
|
22662
|
+
const collectOutput = new Promise((resolvePromise) => {
|
|
22663
|
+
let stdout = "";
|
|
22664
|
+
let stderr = "";
|
|
22665
|
+
proc.stdout.setEncoding("utf-8").on("data", (chunk) => stdout += chunk);
|
|
22666
|
+
proc.stderr.setEncoding("utf-8").on("data", (chunk) => stderr += chunk);
|
|
22667
|
+
proc.on("error", (err2) => resolvePromise({ stdout: "", stderr: String(err2), exitCode: -1 }));
|
|
22668
|
+
proc.on("close", (code) => resolvePromise({ stdout, stderr, exitCode: code ?? -1 }));
|
|
22669
|
+
});
|
|
22410
22670
|
let timeoutId;
|
|
22411
|
-
const timeout = new Promise((
|
|
22412
|
-
timeoutId = setTimeout(() =>
|
|
22671
|
+
const timeout = new Promise((resolvePromise) => {
|
|
22672
|
+
timeoutId = setTimeout(() => resolvePromise("timeout"), timeoutMs);
|
|
22413
22673
|
});
|
|
22414
22674
|
try {
|
|
22415
22675
|
const outcome = await Promise.race([collectOutput, timeout]);
|
|
@@ -22417,8 +22677,7 @@ async function runCompileCheck(options) {
|
|
|
22417
22677
|
timedOut = true;
|
|
22418
22678
|
try {
|
|
22419
22679
|
if (process.platform === "win32") {
|
|
22420
|
-
|
|
22421
|
-
await taskkill.exited;
|
|
22680
|
+
spawn("taskkill", ["/PID", String(proc.pid), "/T", "/F"], { stdio: "ignore" }).on("error", () => proc.kill("SIGKILL"));
|
|
22422
22681
|
} else {
|
|
22423
22682
|
process.kill(-proc.pid, "SIGKILL");
|
|
22424
22683
|
}
|
|
@@ -22427,7 +22686,6 @@ async function runCompileCheck(options) {
|
|
|
22427
22686
|
proc.kill("SIGKILL");
|
|
22428
22687
|
} catch {}
|
|
22429
22688
|
}
|
|
22430
|
-
await proc.exited;
|
|
22431
22689
|
return {
|
|
22432
22690
|
success: false,
|
|
22433
22691
|
exitCode: proc.exitCode ?? -1,
|
|
@@ -22448,15 +22706,7 @@ async function runCompileCheck(options) {
|
|
|
22448
22706
|
timedOut
|
|
22449
22707
|
};
|
|
22450
22708
|
} catch (err2) {
|
|
22451
|
-
return {
|
|
22452
|
-
success: false,
|
|
22453
|
-
exitCode: -1,
|
|
22454
|
-
stdout: "",
|
|
22455
|
-
stderr: String(err2),
|
|
22456
|
-
errors: [],
|
|
22457
|
-
durationMs: performance.now() - startTime,
|
|
22458
|
-
timedOut
|
|
22459
|
-
};
|
|
22709
|
+
return { ...failure(String(err2)), timedOut };
|
|
22460
22710
|
} finally {
|
|
22461
22711
|
clearTimeout(timeoutId);
|
|
22462
22712
|
}
|
|
@@ -22483,18 +22733,19 @@ __export(exports_rdd_receipt, {
|
|
|
22483
22733
|
captureReceipt: () => captureReceipt,
|
|
22484
22734
|
collectReceiptPaths: () => collectReceiptPaths,
|
|
22485
22735
|
isRddReceipt: () => isRddReceipt,
|
|
22736
|
+
isRegisteredReceipt: () => isRegisteredReceipt,
|
|
22486
22737
|
verifyReceipt: () => verifyReceipt,
|
|
22487
22738
|
verifyReceiptLock: () => verifyReceiptLock
|
|
22488
22739
|
});
|
|
22489
|
-
import { createHash as
|
|
22490
|
-
import { mkdir as
|
|
22491
|
-
import { join as join20, relative as relative9, resolve as
|
|
22740
|
+
import { createHash as createHash5, randomBytes } from "node:crypto";
|
|
22741
|
+
import { mkdir as mkdir18, readdir as readdir7, readFile as readFile29, writeFile as writeFile17 } from "node:fs/promises";
|
|
22742
|
+
import { join as join20, relative as relative9, resolve as resolve27, sep as sep8 } from "node:path";
|
|
22492
22743
|
function sha2562(content) {
|
|
22493
|
-
return
|
|
22744
|
+
return createHash5("sha256").update(content).digest("hex");
|
|
22494
22745
|
}
|
|
22495
22746
|
function canonicalPath(projectRoot, input) {
|
|
22496
|
-
const root =
|
|
22497
|
-
const absolute =
|
|
22747
|
+
const root = resolve27(projectRoot);
|
|
22748
|
+
const absolute = resolve27(root, input);
|
|
22498
22749
|
if (absolute !== root && !absolute.startsWith(`${root}${sep8}`)) {
|
|
22499
22750
|
throw new Error(`RDD receipt path "${input}" is outside the project root`);
|
|
22500
22751
|
}
|
|
@@ -22512,7 +22763,7 @@ async function fingerprint(projectRoot, paths) {
|
|
|
22512
22763
|
}
|
|
22513
22764
|
const result = [];
|
|
22514
22765
|
for (const [path, absolute] of [...deduplicated.entries()].sort(([left], [right]) => left.localeCompare(right))) {
|
|
22515
|
-
result.push({ path, hash: sha2562(await
|
|
22766
|
+
result.push({ path, hash: sha2562(await readFile29(absolute)) });
|
|
22516
22767
|
}
|
|
22517
22768
|
return result;
|
|
22518
22769
|
}
|
|
@@ -22521,7 +22772,7 @@ function manifestHash(paths) {
|
|
|
22521
22772
|
`));
|
|
22522
22773
|
}
|
|
22523
22774
|
function receiptRegistryDir(projectRoot) {
|
|
22524
|
-
return join20(
|
|
22775
|
+
return join20(resolve27(projectRoot), ".codeconductor", "rdd-receipts");
|
|
22525
22776
|
}
|
|
22526
22777
|
function isWellFormedNonce(nonce) {
|
|
22527
22778
|
return typeof nonce === "string" && /^[0-9a-f]{32}$/.test(nonce);
|
|
@@ -22530,7 +22781,7 @@ async function isRegisteredReceipt(projectRoot, receipt) {
|
|
|
22530
22781
|
if (!isWellFormedNonce(receipt.nonce))
|
|
22531
22782
|
return false;
|
|
22532
22783
|
try {
|
|
22533
|
-
const raw = await
|
|
22784
|
+
const raw = await readFile29(join20(receiptRegistryDir(projectRoot), `${receipt.nonce}.json`), "utf-8");
|
|
22534
22785
|
const entry = JSON.parse(raw);
|
|
22535
22786
|
return entry.manifestHash === receipt.manifestHash;
|
|
22536
22787
|
} catch {
|
|
@@ -22566,13 +22817,13 @@ async function captureReceipt(projectRoot, input) {
|
|
|
22566
22817
|
nonce
|
|
22567
22818
|
};
|
|
22568
22819
|
const directory = receiptRegistryDir(projectRoot);
|
|
22569
|
-
await
|
|
22820
|
+
await mkdir18(directory, { recursive: true });
|
|
22570
22821
|
const entry = { manifestHash: hashed, taskId: input.taskId, capturedAt };
|
|
22571
22822
|
await writeFile17(join20(directory, `${nonce}.json`), JSON.stringify(entry, null, 2), "utf-8");
|
|
22572
22823
|
return receipt;
|
|
22573
22824
|
}
|
|
22574
22825
|
async function collectReceiptPaths(projectRoot) {
|
|
22575
|
-
const root =
|
|
22826
|
+
const root = resolve27(projectRoot);
|
|
22576
22827
|
const paths = [];
|
|
22577
22828
|
async function visit2(current) {
|
|
22578
22829
|
const entries = await readdir7(current, { withFileTypes: true });
|
|
@@ -22599,7 +22850,7 @@ async function verifyReceipt(projectRoot, receipt) {
|
|
|
22599
22850
|
for (const path of pathsToCheck) {
|
|
22600
22851
|
try {
|
|
22601
22852
|
const canonical = canonicalPath(projectRoot, path);
|
|
22602
|
-
const hash = sha2562(await
|
|
22853
|
+
const hash = sha2562(await readFile29(canonical.absolute));
|
|
22603
22854
|
const currentEntry = { path: canonical.relative, hash };
|
|
22604
22855
|
current.push(currentEntry);
|
|
22605
22856
|
currentByPath.set(currentEntry.path, currentEntry);
|
|
@@ -22625,7 +22876,7 @@ async function verifyReceipt(projectRoot, receipt) {
|
|
|
22625
22876
|
async function verifyReceiptLock(projectRoot, lockPath) {
|
|
22626
22877
|
let parsed;
|
|
22627
22878
|
try {
|
|
22628
|
-
parsed = JSON.parse(await
|
|
22879
|
+
parsed = JSON.parse(await readFile29(resolve27(projectRoot, lockPath), "utf-8"));
|
|
22629
22880
|
} catch {
|
|
22630
22881
|
return { valid: false, changedPaths: [] };
|
|
22631
22882
|
}
|
|
@@ -22648,9 +22899,9 @@ var init_rdd_receipt = __esm(() => {
|
|
|
22648
22899
|
|
|
22649
22900
|
// src/core/verification/verification-runner.ts
|
|
22650
22901
|
import { existsSync as existsSync3 } from "node:fs";
|
|
22651
|
-
import { readFile as
|
|
22652
|
-
import { dirname as dirname10, join as join21, resolve as
|
|
22653
|
-
import { mkdir as
|
|
22902
|
+
import { readFile as readFile30 } from "node:fs/promises";
|
|
22903
|
+
import { dirname as dirname10, join as join21, resolve as resolve28 } from "node:path";
|
|
22904
|
+
import { mkdir as mkdir19, readdir as readdir8, writeFile as writeFile18 } from "node:fs/promises";
|
|
22654
22905
|
function isPassingEvidence(ev) {
|
|
22655
22906
|
switch (ev.type) {
|
|
22656
22907
|
case "verification":
|
|
@@ -22676,8 +22927,8 @@ async function isCurrentPassingEvidence(projectRoot, ev) {
|
|
|
22676
22927
|
return (await verifyReceipt(projectRoot, receipt)).valid;
|
|
22677
22928
|
}
|
|
22678
22929
|
function evidenceFilePath(evDir, id) {
|
|
22679
|
-
const path =
|
|
22680
|
-
if (dirname10(path) !==
|
|
22930
|
+
const path = resolve28(evDir, `${id.replace(/[^A-Za-z0-9_-]/g, "_")}.json`);
|
|
22931
|
+
if (dirname10(path) !== resolve28(evDir)) {
|
|
22681
22932
|
return err(new Error(`Refusing to write evidence for "${id}" outside ${evDir}`));
|
|
22682
22933
|
}
|
|
22683
22934
|
return ok(path);
|
|
@@ -22688,7 +22939,7 @@ async function persistEvidence(projectRoot, evidence) {
|
|
|
22688
22939
|
if (!evidencePath.success)
|
|
22689
22940
|
return evidencePath;
|
|
22690
22941
|
try {
|
|
22691
|
-
await
|
|
22942
|
+
await mkdir19(evDir, { recursive: true });
|
|
22692
22943
|
await writeFile18(evidencePath.data, JSON.stringify(evidence, null, 2), "utf-8");
|
|
22693
22944
|
} catch (e) {
|
|
22694
22945
|
return err(e instanceof Error ? e : new Error(String(e)));
|
|
@@ -22711,7 +22962,7 @@ async function collectTaskEvidence(projectRoot, taskId) {
|
|
|
22711
22962
|
if (!file.endsWith(".json"))
|
|
22712
22963
|
continue;
|
|
22713
22964
|
try {
|
|
22714
|
-
const raw = await
|
|
22965
|
+
const raw = await readFile30(join21(evDir, file), "utf-8");
|
|
22715
22966
|
const ev = EvidenceSchema.parse(JSON.parse(raw));
|
|
22716
22967
|
if (ev.relatedTask === taskId)
|
|
22717
22968
|
records.push(ev);
|
|
@@ -22891,14 +23142,79 @@ async function gateTaskCompletion(projectRoot, taskId, evidenceRequired, evidenc
|
|
|
22891
23142
|
}
|
|
22892
23143
|
return ok(true);
|
|
22893
23144
|
}
|
|
22894
|
-
async function
|
|
23145
|
+
async function captureTddSuiteEvidence(projectRoot, taskId, options) {
|
|
23146
|
+
if (!options.allowCompileCheck && !isAllowlistedTestCommand(options.command)) {
|
|
23147
|
+
return err(new Error("TDD suite command is not on the test allowlist. Re-run with --allow-compile-check to trust it."));
|
|
23148
|
+
}
|
|
23149
|
+
const paths = await collectReceiptPaths(projectRoot);
|
|
23150
|
+
const before = await captureReceipt(projectRoot, {
|
|
23151
|
+
taskId,
|
|
23152
|
+
phase: options.phase ?? "verification",
|
|
23153
|
+
paths,
|
|
23154
|
+
command: options.command,
|
|
23155
|
+
outcome: "failed",
|
|
23156
|
+
coverage: "project"
|
|
23157
|
+
});
|
|
23158
|
+
const result = await runCompileCheck({
|
|
23159
|
+
command: options.command,
|
|
23160
|
+
cwd: projectRoot
|
|
23161
|
+
});
|
|
23162
|
+
const suitePassed = result.success && !result.timedOut && result.exitCode === 0;
|
|
23163
|
+
const suiteFailed = !result.timedOut && result.exitCode > 0;
|
|
23164
|
+
const receipt = { ...before, outcome: suitePassed ? "passed" : "failed" };
|
|
23165
|
+
const receiptResult = await verifyReceipt(projectRoot, receipt);
|
|
23166
|
+
if (!receiptResult.valid) {
|
|
23167
|
+
return err(new Error(`RDD candidate changed while the TDD suite ran: ${receiptResult.changedPaths.join(", ")}`));
|
|
23168
|
+
}
|
|
23169
|
+
const evidence = {
|
|
23170
|
+
id: `ev-tdd-${taskId}-${Date.now()}`,
|
|
23171
|
+
source: TDD_EVIDENCE_SOURCE,
|
|
23172
|
+
type: "tdd",
|
|
23173
|
+
timestamp: new Date().toISOString(),
|
|
23174
|
+
relatedTask: taskId,
|
|
23175
|
+
confidence: suitePassed || suiteFailed ? 0.9 : 0.3,
|
|
23176
|
+
summary: suitePassed ? "TDD suite passed" : suiteFailed ? "TDD suite failed" : "TDD suite inconclusive",
|
|
23177
|
+
data: {
|
|
23178
|
+
capturedBy: TDD_CAPTURED_BY,
|
|
23179
|
+
suiteFailed,
|
|
23180
|
+
suitePassed,
|
|
23181
|
+
exitCode: result.exitCode,
|
|
23182
|
+
timedOut: result.timedOut,
|
|
23183
|
+
command: options.command,
|
|
23184
|
+
rddReceipt: receipt
|
|
23185
|
+
}
|
|
23186
|
+
};
|
|
23187
|
+
const persisted = await persistEvidence(projectRoot, evidence);
|
|
23188
|
+
if (!persisted.success)
|
|
23189
|
+
return persisted;
|
|
23190
|
+
const event = await appendEvent(projectRoot, {
|
|
23191
|
+
type: "verification.completed",
|
|
23192
|
+
timestamp: new Date().toISOString(),
|
|
23193
|
+
payload: {
|
|
23194
|
+
taskId,
|
|
23195
|
+
tdd: true,
|
|
23196
|
+
suiteFailed,
|
|
23197
|
+
suitePassed,
|
|
23198
|
+
evidenceId: evidence.id
|
|
23199
|
+
}
|
|
23200
|
+
});
|
|
23201
|
+
if (!event.success)
|
|
23202
|
+
return event;
|
|
23203
|
+
return ok({
|
|
23204
|
+
evidenceId: evidence.id,
|
|
23205
|
+
suiteFailed,
|
|
23206
|
+
suitePassed,
|
|
23207
|
+
receipt
|
|
23208
|
+
});
|
|
23209
|
+
}
|
|
23210
|
+
async function readRunnerTddEvidence(projectRoot, taskId, evidenceId) {
|
|
22895
23211
|
const evDir = evidenceDir(projectRoot);
|
|
22896
23212
|
const path = evidenceFilePath(evDir, evidenceId);
|
|
22897
23213
|
if (!path.success)
|
|
22898
23214
|
return path;
|
|
22899
23215
|
let raw;
|
|
22900
23216
|
try {
|
|
22901
|
-
raw = await
|
|
23217
|
+
raw = await readFile30(path.data, "utf-8");
|
|
22902
23218
|
} catch (e) {
|
|
22903
23219
|
return err(e instanceof Error ? e : new Error(String(e)));
|
|
22904
23220
|
}
|
|
@@ -22927,24 +23243,83 @@ async function loadTddSuiteEvidence(projectRoot, taskId, evidenceId) {
|
|
|
22927
23243
|
if (receipt.taskId !== taskId) {
|
|
22928
23244
|
return err(new Error(`Evidence "${evidenceId}" receipt belongs to another task`));
|
|
22929
23245
|
}
|
|
22930
|
-
|
|
23246
|
+
return ok({ capturedBy, suiteFailed, suitePassed, receipt });
|
|
23247
|
+
}
|
|
23248
|
+
async function loadTddSuiteEvidence(projectRoot, taskId, evidenceId) {
|
|
23249
|
+
const read = await readRunnerTddEvidence(projectRoot, taskId, evidenceId);
|
|
23250
|
+
if (!read.success)
|
|
23251
|
+
return read;
|
|
23252
|
+
const verified = await verifyReceipt(projectRoot, read.data.receipt);
|
|
22931
23253
|
if (!verified.valid) {
|
|
22932
23254
|
return err(new Error(`Evidence "${evidenceId}" RDD receipt is stale: ${verified.changedPaths.join(", ")}`));
|
|
22933
23255
|
}
|
|
22934
|
-
return
|
|
23256
|
+
return read;
|
|
22935
23257
|
}
|
|
22936
|
-
async function
|
|
23258
|
+
async function listRunnerTddRecords(projectRoot, taskId) {
|
|
22937
23259
|
const collected = await collectTaskEvidence(projectRoot, taskId);
|
|
22938
23260
|
if (!collected.success)
|
|
22939
|
-
return
|
|
22940
|
-
|
|
22941
|
-
|
|
23261
|
+
return [];
|
|
23262
|
+
return collected.data.records.filter((ev) => ev.type === "tdd" && ev.source === TDD_EVIDENCE_SOURCE && ev.data?.capturedBy === TDD_CAPTURED_BY);
|
|
23263
|
+
}
|
|
23264
|
+
function tddValidationFilePath(projectRoot, taskId) {
|
|
23265
|
+
return evidenceFilePath(join21(resolve28(projectRoot), ".codeconductor", "tdd-validations"), taskId);
|
|
23266
|
+
}
|
|
23267
|
+
async function loadTddValidation(projectRoot, taskId) {
|
|
23268
|
+
const path = tddValidationFilePath(projectRoot, taskId);
|
|
23269
|
+
if (!path.success)
|
|
23270
|
+
return;
|
|
23271
|
+
try {
|
|
23272
|
+
const record = TddValidationRecordSchema.parse(JSON.parse(await readFile30(path.data, "utf-8")));
|
|
23273
|
+
return record.taskId === taskId ? record : undefined;
|
|
23274
|
+
} catch {
|
|
23275
|
+
return;
|
|
23276
|
+
}
|
|
23277
|
+
}
|
|
23278
|
+
async function recordRedValidation(projectRoot, taskId) {
|
|
23279
|
+
let best;
|
|
23280
|
+
for (const ev of await listRunnerTddRecords(projectRoot, taskId)) {
|
|
23281
|
+
const loaded = await loadTddSuiteEvidence(projectRoot, taskId, ev.id);
|
|
23282
|
+
if (!loaded.success || !isRedSuite(loaded.data) || loaded.data.receipt.outcome !== "failed")
|
|
22942
23283
|
continue;
|
|
23284
|
+
const { receipt } = loaded.data;
|
|
23285
|
+
if (!best || receipt.capturedAt > best.receipt.capturedAt || receipt.capturedAt === best.receipt.capturedAt && ev.id > best.id) {
|
|
23286
|
+
best = { id: ev.id, receipt };
|
|
23287
|
+
}
|
|
23288
|
+
}
|
|
23289
|
+
if (!best || !best.receipt.nonce) {
|
|
23290
|
+
return err(new Error(`Task ${taskId} has no fresh RED verification-runner TDD evidence`));
|
|
23291
|
+
}
|
|
23292
|
+
const record = TddValidationRecordSchema.parse({
|
|
23293
|
+
taskId,
|
|
23294
|
+
evidenceId: best.id,
|
|
23295
|
+
receiptNonce: best.receipt.nonce,
|
|
23296
|
+
manifestHash: best.receipt.manifestHash,
|
|
23297
|
+
validatedAt: new Date().toISOString()
|
|
23298
|
+
});
|
|
23299
|
+
const path = tddValidationFilePath(projectRoot, taskId);
|
|
23300
|
+
if (!path.success)
|
|
23301
|
+
return path;
|
|
23302
|
+
try {
|
|
23303
|
+
await mkdir19(dirname10(path.data), { recursive: true });
|
|
23304
|
+
await writeFile18(path.data, JSON.stringify(record, null, 2), "utf-8");
|
|
23305
|
+
} catch (e) {
|
|
23306
|
+
return err(e instanceof Error ? e : new Error(String(e)));
|
|
23307
|
+
}
|
|
23308
|
+
return ok(record);
|
|
23309
|
+
}
|
|
23310
|
+
async function hasTddRunnerEvidence(projectRoot, taskId, expectedPhase) {
|
|
23311
|
+
const validation = expectedPhase === "red" ? await loadTddValidation(projectRoot, taskId) : undefined;
|
|
23312
|
+
for (const ev of await listRunnerTddRecords(projectRoot, taskId)) {
|
|
23313
|
+
if (expectedPhase === "red" && validation?.evidenceId === ev.id) {
|
|
23314
|
+
const read = await readRunnerTddEvidence(projectRoot, taskId, ev.id);
|
|
23315
|
+
if (read.success && isRedSuite(read.data) && read.data.receipt.outcome === "failed" && read.data.receipt.nonce === validation.receiptNonce && read.data.receipt.manifestHash === validation.manifestHash && await isRegisteredReceipt(projectRoot, read.data.receipt)) {
|
|
23316
|
+
return true;
|
|
23317
|
+
}
|
|
22943
23318
|
}
|
|
22944
23319
|
const loaded = await loadTddSuiteEvidence(projectRoot, taskId, ev.id);
|
|
22945
23320
|
if (!loaded.success)
|
|
22946
23321
|
continue;
|
|
22947
|
-
if (expectedPhase === "red" && (
|
|
23322
|
+
if (expectedPhase === "red" && !isRedSuite(loaded.data))
|
|
22948
23323
|
continue;
|
|
22949
23324
|
if (expectedPhase === "green" && (!loaded.data.suitePassed || loaded.data.suiteFailed))
|
|
22950
23325
|
continue;
|
|
@@ -22952,7 +23327,7 @@ async function hasTddRunnerEvidence(projectRoot, taskId, expectedPhase) {
|
|
|
22952
23327
|
}
|
|
22953
23328
|
return false;
|
|
22954
23329
|
}
|
|
22955
|
-
var TDD_EVIDENCE_SOURCE = "cc verify", TDD_CAPTURED_BY = "verification-runner";
|
|
23330
|
+
var TDD_EVIDENCE_SOURCE = "cc verify", TDD_CAPTURED_BY = "verification-runner", isRedSuite = (e) => e.suiteFailed && !e.suitePassed;
|
|
22956
23331
|
var init_verification_runner = __esm(() => {
|
|
22957
23332
|
init_schemas();
|
|
22958
23333
|
init_config_loader();
|
|
@@ -22964,22 +23339,23 @@ var init_verification_runner = __esm(() => {
|
|
|
22964
23339
|
|
|
22965
23340
|
// src/core/orchestrator/runtime-orchestrator.ts
|
|
22966
23341
|
async function rollbackTaskStatus(projectRoot, graph, task, previousStatus, previousState, cause) {
|
|
22967
|
-
|
|
22968
|
-
|
|
22969
|
-
|
|
22970
|
-
|
|
23342
|
+
return withQueueLock(projectRoot, async () => {
|
|
23343
|
+
task.status = previousStatus;
|
|
23344
|
+
const write = await writeGoal(projectRoot, graph);
|
|
23345
|
+
const restored = write.success ? await saveOperationalState(projectRoot, previousState) : write;
|
|
23346
|
+
return restored.success ? err(cause) : err(new Error(`${cause.message} (rollback failed: ${restored.error.message})`));
|
|
23347
|
+
});
|
|
22971
23348
|
}
|
|
22972
23349
|
function getReadyTasks(graph) {
|
|
23350
|
+
propagateBlockedTasks(graph);
|
|
22973
23351
|
const done = new Set(graph.tasks.filter((t) => t.status === "done").map((t) => t.id));
|
|
22974
|
-
const
|
|
23352
|
+
const order = new Map(graph.tasks.map((task, index) => [task.id, index]));
|
|
22975
23353
|
return graph.tasks.filter((task) => {
|
|
22976
23354
|
if (task.status !== "pending")
|
|
22977
23355
|
return false;
|
|
22978
|
-
if (blocked.has(task.id))
|
|
22979
|
-
return false;
|
|
22980
23356
|
const deps = task.depends_on ?? [];
|
|
22981
23357
|
return deps.every((d) => done.has(d));
|
|
22982
|
-
});
|
|
23358
|
+
}).sort((a, b) => (a.priority ?? "P2").localeCompare(b.priority ?? "P2") || order.get(a.id) - order.get(b.id) || a.id.localeCompare(b.id));
|
|
22983
23359
|
}
|
|
22984
23360
|
function goalTaskToCanonicalCard(task, objective) {
|
|
22985
23361
|
return {
|
|
@@ -23024,9 +23400,29 @@ function buildTaskEnvelope(card, projectRoot, projectName) {
|
|
|
23024
23400
|
};
|
|
23025
23401
|
}
|
|
23026
23402
|
async function getNextTask(projectRoot, projectName) {
|
|
23403
|
+
return withQueueLock(projectRoot, () => getNextTaskUnlocked(projectRoot, projectName));
|
|
23404
|
+
}
|
|
23405
|
+
async function claimNextTask(projectRoot, projectName) {
|
|
23406
|
+
return withQueueLock(projectRoot, async () => {
|
|
23407
|
+
const next = await getNextTaskUnlocked(projectRoot, projectName);
|
|
23408
|
+
if (!next.success)
|
|
23409
|
+
return next;
|
|
23410
|
+
const started = await startTaskUnlocked(projectRoot, next.data.task.id, next.data.task.agentType);
|
|
23411
|
+
return started.success ? next : started;
|
|
23412
|
+
});
|
|
23413
|
+
}
|
|
23414
|
+
async function completeTask(projectRoot, taskId, evidenceIds) {
|
|
23415
|
+
return withQueueLock(projectRoot, () => completeTaskUnlocked(projectRoot, taskId, evidenceIds));
|
|
23416
|
+
}
|
|
23417
|
+
async function getNextTaskUnlocked(projectRoot, projectName) {
|
|
23027
23418
|
const goalResult = await loadGoal(projectRoot);
|
|
23028
23419
|
if (!goalResult.success)
|
|
23029
23420
|
return goalResult;
|
|
23421
|
+
if (propagateBlockedTasks(goalResult.data)) {
|
|
23422
|
+
const write = await writeGoal(projectRoot, goalResult.data);
|
|
23423
|
+
if (!write.success)
|
|
23424
|
+
return write;
|
|
23425
|
+
}
|
|
23030
23426
|
const graphResult = await loadGraph(projectRoot);
|
|
23031
23427
|
const productGraph = graphResult.success ? graphResult.data : undefined;
|
|
23032
23428
|
const enriched = enrichGoalWithProduct(goalResult.data, productGraph);
|
|
@@ -23044,7 +23440,7 @@ async function getNextTask(projectRoot, projectName) {
|
|
|
23044
23440
|
readyCount: ready.length
|
|
23045
23441
|
});
|
|
23046
23442
|
}
|
|
23047
|
-
async function
|
|
23443
|
+
async function startTaskUnlocked(projectRoot, taskId, agent) {
|
|
23048
23444
|
const goalResult = await loadGoal(projectRoot);
|
|
23049
23445
|
if (!goalResult.success)
|
|
23050
23446
|
return goalResult;
|
|
@@ -23054,6 +23450,10 @@ async function startTask(projectRoot, taskId, agent) {
|
|
|
23054
23450
|
if (task.status !== "pending") {
|
|
23055
23451
|
return err(new Error(`Task ${taskId} is ${task.status}, expected pending`));
|
|
23056
23452
|
}
|
|
23453
|
+
const done = new Set(goalResult.data.tasks.filter((t) => t.status === "done").map((t) => t.id));
|
|
23454
|
+
const unmet = (task.depends_on ?? []).filter((id) => !done.has(id));
|
|
23455
|
+
if (unmet.length > 0)
|
|
23456
|
+
return err(new Error(`Task ${taskId} has unmet dependencies: ${unmet.join(", ")}`));
|
|
23057
23457
|
const stateBefore = await loadOperationalState(projectRoot);
|
|
23058
23458
|
if (!stateBefore.success)
|
|
23059
23459
|
return stateBefore;
|
|
@@ -23077,7 +23477,7 @@ async function startTask(projectRoot, taskId, agent) {
|
|
|
23077
23477
|
}
|
|
23078
23478
|
return ok(undefined);
|
|
23079
23479
|
}
|
|
23080
|
-
async function
|
|
23480
|
+
async function completeTaskUnlocked(projectRoot, taskId, evidenceIds) {
|
|
23081
23481
|
const goalResult = await loadGoal(projectRoot);
|
|
23082
23482
|
if (!goalResult.success)
|
|
23083
23483
|
return goalResult;
|
|
@@ -23143,6 +23543,7 @@ function formatGoalStatus(graph) {
|
|
|
23143
23543
|
var init_runtime_orchestrator = __esm(() => {
|
|
23144
23544
|
init_product_planner();
|
|
23145
23545
|
init_goal_state();
|
|
23546
|
+
init_lock();
|
|
23146
23547
|
init_graph_store();
|
|
23147
23548
|
init_episodic_store();
|
|
23148
23549
|
init_operational_state();
|
|
@@ -23717,14 +24118,10 @@ async function handleStatus(projectRoot, output) {
|
|
|
23717
24118
|
}
|
|
23718
24119
|
async function handleNext(projectRoot, output) {
|
|
23719
24120
|
const projectName = await getProjectName(projectRoot);
|
|
23720
|
-
const next = await
|
|
24121
|
+
const next = await claimNextTask(projectRoot, projectName);
|
|
23721
24122
|
if (!next.success) {
|
|
23722
24123
|
return { code: 1, data: { success: false, command: "orchestrate", errors: [next.error.message] } };
|
|
23723
24124
|
}
|
|
23724
|
-
const started = await startTask(projectRoot, next.data.task.id, next.data.task.agentType);
|
|
23725
|
-
if (!started.success) {
|
|
23726
|
-
return { code: 1, data: { success: false, command: "orchestrate", errors: [started.error.message] } };
|
|
23727
|
-
}
|
|
23728
24125
|
if (output === "json") {
|
|
23729
24126
|
return {
|
|
23730
24127
|
code: 0,
|
|
@@ -24082,6 +24479,54 @@ var init_verify_command = __esm(() => {
|
|
|
24082
24479
|
init_verification_runner();
|
|
24083
24480
|
});
|
|
24084
24481
|
|
|
24482
|
+
// src/commands/tdd.command.ts
|
|
24483
|
+
var exports_tdd_command = {};
|
|
24484
|
+
__export(exports_tdd_command, {
|
|
24485
|
+
tddCommand: () => tddCommand
|
|
24486
|
+
});
|
|
24487
|
+
function fail(errors3) {
|
|
24488
|
+
return { code: 1, data: { success: false, command: "tdd", errors: errors3 } };
|
|
24489
|
+
}
|
|
24490
|
+
async function tddCommand(options) {
|
|
24491
|
+
const { subcommand, projectRoot, taskId, phase, command } = options;
|
|
24492
|
+
if (subcommand !== "capture") {
|
|
24493
|
+
return fail([`Unknown subcommand: ${subcommand}. ${USAGE}`]);
|
|
24494
|
+
}
|
|
24495
|
+
if (!taskId || !command || phase !== "red" && phase !== "green") {
|
|
24496
|
+
return fail([USAGE]);
|
|
24497
|
+
}
|
|
24498
|
+
const captured = await captureTddSuiteEvidence(projectRoot, taskId, {
|
|
24499
|
+
command,
|
|
24500
|
+
phase,
|
|
24501
|
+
allowCompileCheck: options.allowCompileCheck === true
|
|
24502
|
+
});
|
|
24503
|
+
if (!captured.success)
|
|
24504
|
+
return fail([captured.error.message]);
|
|
24505
|
+
const { evidenceId, suiteFailed, suitePassed } = captured.data;
|
|
24506
|
+
const matches = phase === "red" ? suiteFailed : suitePassed;
|
|
24507
|
+
return {
|
|
24508
|
+
code: matches ? 0 : 1,
|
|
24509
|
+
data: {
|
|
24510
|
+
success: matches,
|
|
24511
|
+
command: "tdd capture",
|
|
24512
|
+
taskId,
|
|
24513
|
+
phase,
|
|
24514
|
+
evidenceId,
|
|
24515
|
+
suiteFailed,
|
|
24516
|
+
suitePassed,
|
|
24517
|
+
...matches ? {} : {
|
|
24518
|
+
errors: [
|
|
24519
|
+
phase === "red" ? "RED requires a failing suite, but the suite passed: the test proves nothing." : "GREEN requires a passing suite, but the suite failed."
|
|
24520
|
+
]
|
|
24521
|
+
}
|
|
24522
|
+
}
|
|
24523
|
+
};
|
|
24524
|
+
}
|
|
24525
|
+
var USAGE = 'Usage: tdd capture --task <cardId> --phase red|green --command "<test command>" [--allow-compile-check]';
|
|
24526
|
+
var init_tdd_command = __esm(() => {
|
|
24527
|
+
init_verification_runner();
|
|
24528
|
+
});
|
|
24529
|
+
|
|
24085
24530
|
// src/commands/rdd.command.ts
|
|
24086
24531
|
var exports_rdd_command = {};
|
|
24087
24532
|
__export(exports_rdd_command, {
|
|
@@ -24090,18 +24535,18 @@ __export(exports_rdd_command, {
|
|
|
24090
24535
|
});
|
|
24091
24536
|
import { execFile as execFile4 } from "node:child_process";
|
|
24092
24537
|
import { existsSync as existsSync4 } from "node:fs";
|
|
24093
|
-
import { mkdir as
|
|
24094
|
-
import { dirname as dirname11, resolve as
|
|
24538
|
+
import { mkdir as mkdir20, readFile as readFile31, readdir as readdir9, rename as rename4, writeFile as writeFile19, chmod } from "node:fs/promises";
|
|
24539
|
+
import { dirname as dirname11, resolve as resolve29 } from "node:path";
|
|
24095
24540
|
import { promisify as promisify4 } from "node:util";
|
|
24096
24541
|
function receiptPath(projectRoot, id) {
|
|
24097
|
-
const directory =
|
|
24098
|
-
const path =
|
|
24542
|
+
const directory = resolve29(evidenceDir(projectRoot));
|
|
24543
|
+
const path = resolve29(directory, `${id.replace(/[^A-Za-z0-9_-]/g, "_")}.json`);
|
|
24099
24544
|
if (dirname11(path) !== directory)
|
|
24100
24545
|
throw new Error(`Invalid RDD receipt id: ${id}`);
|
|
24101
24546
|
return path;
|
|
24102
24547
|
}
|
|
24103
24548
|
async function loadReceipt(projectRoot, id) {
|
|
24104
|
-
const raw = await
|
|
24549
|
+
const raw = await readFile31(receiptPath(projectRoot, id), "utf-8");
|
|
24105
24550
|
const evidence = EvidenceSchema.parse(JSON.parse(raw));
|
|
24106
24551
|
if (evidence.type !== "rdd")
|
|
24107
24552
|
throw new Error(`Evidence "${id}" is not an RDD receipt`);
|
|
@@ -24143,16 +24588,16 @@ async function installHooks(projectRoot) {
|
|
|
24143
24588
|
cwd: projectRoot,
|
|
24144
24589
|
encoding: "utf8"
|
|
24145
24590
|
});
|
|
24146
|
-
const hooksDir =
|
|
24147
|
-
await
|
|
24591
|
+
const hooksDir = resolve29(projectRoot, stdout.trim());
|
|
24592
|
+
await mkdir20(hooksDir, { recursive: true });
|
|
24148
24593
|
const installed = [];
|
|
24149
24594
|
const skipped = [];
|
|
24150
24595
|
for (const hook of ["pre-commit", "pre-push"]) {
|
|
24151
|
-
const path =
|
|
24152
|
-
const backup =
|
|
24596
|
+
const path = resolve29(hooksDir, hook);
|
|
24597
|
+
const backup = resolve29(hooksDir, `${hook}.rdd-original`);
|
|
24153
24598
|
const marker = "# codeconductor-rdd-hook";
|
|
24154
24599
|
if (existsSync4(path)) {
|
|
24155
|
-
const existing = await
|
|
24600
|
+
const existing = await readFile31(path, "utf8");
|
|
24156
24601
|
if (existing.includes(marker)) {
|
|
24157
24602
|
skipped.push(hook);
|
|
24158
24603
|
continue;
|
|
@@ -24160,7 +24605,7 @@ async function installHooks(projectRoot) {
|
|
|
24160
24605
|
if (existsSync4(backup)) {
|
|
24161
24606
|
throw new Error(`Cannot preserve ${hook}: ${backup} already exists`);
|
|
24162
24607
|
}
|
|
24163
|
-
await
|
|
24608
|
+
await rename4(path, backup);
|
|
24164
24609
|
}
|
|
24165
24610
|
const script = `#!/bin/sh
|
|
24166
24611
|
${marker}
|
|
@@ -24203,7 +24648,7 @@ async function rddCommand(options) {
|
|
|
24203
24648
|
data: { rddReceipt: receipt }
|
|
24204
24649
|
};
|
|
24205
24650
|
const directory = evidenceDir(options.projectRoot);
|
|
24206
|
-
await
|
|
24651
|
+
await mkdir20(directory, { recursive: true });
|
|
24207
24652
|
await writeFile19(receiptPath(options.projectRoot, id), JSON.stringify(evidence, null, 2), "utf-8");
|
|
24208
24653
|
return { code: 0, data: { success: true, receiptId: id, receipt } };
|
|
24209
24654
|
}
|
|
@@ -24715,10 +25160,10 @@ var init_workflow_profile_loader = __esm(() => {
|
|
|
24715
25160
|
});
|
|
24716
25161
|
|
|
24717
25162
|
// src/core/evaluation/harness-catalog.ts
|
|
24718
|
-
import { createHash as
|
|
25163
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
24719
25164
|
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
|
|
24720
|
-
import { copyFile as copyFile2, mkdir as
|
|
24721
|
-
import { dirname as dirname12, join as join23, resolve as
|
|
25165
|
+
import { copyFile as copyFile2, mkdir as mkdir21, readFile as readFile32, readdir as readdir10, rm as rm4, writeFile as writeFile20 } from "node:fs/promises";
|
|
25166
|
+
import { dirname as dirname12, join as join23, resolve as resolve30 } from "node:path";
|
|
24722
25167
|
function catalogIds(catalog = DEFAULT_HARNESS_CATALOG) {
|
|
24723
25168
|
return catalog.components.map((c) => c.id);
|
|
24724
25169
|
}
|
|
@@ -24768,23 +25213,23 @@ function harnessFingerprint(disabled, contractVersion, ccepProfile = "feature",
|
|
|
24768
25213
|
contractVersion,
|
|
24769
25214
|
ccepProfile
|
|
24770
25215
|
};
|
|
24771
|
-
return
|
|
25216
|
+
return createHash6("sha256").update(JSON.stringify(payload)).digest("hex").slice(0, 16);
|
|
24772
25217
|
}
|
|
24773
25218
|
async function loadHarnessCatalog(projectRoot) {
|
|
24774
|
-
const overridePath =
|
|
25219
|
+
const overridePath = resolve30(projectRoot, EVAL_DIR2, CATALOG_FILE);
|
|
24775
25220
|
try {
|
|
24776
|
-
const raw = await
|
|
25221
|
+
const raw = await readFile32(overridePath, "utf-8");
|
|
24777
25222
|
return HarnessCatalogSchema.parse($parse(raw));
|
|
24778
25223
|
} catch {
|
|
24779
25224
|
return DEFAULT_HARNESS_CATALOG;
|
|
24780
25225
|
}
|
|
24781
25226
|
}
|
|
24782
25227
|
function activeOverlayPath(projectRoot) {
|
|
24783
|
-
return
|
|
25228
|
+
return resolve30(projectRoot, EVAL_DIR2, ACTIVE_OVERLAY_FILE);
|
|
24784
25229
|
}
|
|
24785
25230
|
async function readActiveOverlay(projectRoot) {
|
|
24786
25231
|
try {
|
|
24787
|
-
const raw = await
|
|
25232
|
+
const raw = await readFile32(activeOverlayPath(projectRoot), "utf-8");
|
|
24788
25233
|
return HarnessOverlaySchema.parse($parse(raw));
|
|
24789
25234
|
} catch {
|
|
24790
25235
|
return null;
|
|
@@ -24838,19 +25283,19 @@ function applyCatalogToProfile(profile, disabled) {
|
|
|
24838
25283
|
return next;
|
|
24839
25284
|
}
|
|
24840
25285
|
async function restoreOverlayBackup(projectRoot) {
|
|
24841
|
-
const backupRoot =
|
|
25286
|
+
const backupRoot = resolve30(projectRoot, EVAL_DIR2, OVERLAY_BACKUP_DIR);
|
|
24842
25287
|
if (!existsSync6(backupRoot))
|
|
24843
25288
|
return;
|
|
24844
25289
|
const configBackup = join23(backupRoot, "config.yml");
|
|
24845
|
-
const configDest =
|
|
25290
|
+
const configDest = resolve30(projectRoot, ".codeconductor", "config.yml");
|
|
24846
25291
|
if (existsSync6(configBackup)) {
|
|
24847
|
-
await
|
|
25292
|
+
await mkdir21(dirname12(configDest), { recursive: true });
|
|
24848
25293
|
await copyFile2(configBackup, configDest);
|
|
24849
25294
|
}
|
|
24850
25295
|
const workflowsBackup = join23(backupRoot, "workflows");
|
|
24851
|
-
const workflowsDest =
|
|
25296
|
+
const workflowsDest = resolve30(projectRoot, ".codeconductor", "workflows");
|
|
24852
25297
|
if (existsSync6(workflowsBackup)) {
|
|
24853
|
-
await
|
|
25298
|
+
await mkdir21(workflowsDest, { recursive: true });
|
|
24854
25299
|
const files = await readdir10(workflowsBackup);
|
|
24855
25300
|
for (const file of files) {
|
|
24856
25301
|
await copyFile2(join23(workflowsBackup, file), join23(workflowsDest, file));
|
|
@@ -24865,18 +25310,18 @@ async function restoreOverlayBackup(projectRoot) {
|
|
|
24865
25310
|
}
|
|
24866
25311
|
}
|
|
24867
25312
|
async function snapshotForBackup(projectRoot) {
|
|
24868
|
-
const backupRoot =
|
|
25313
|
+
const backupRoot = resolve30(projectRoot, EVAL_DIR2, OVERLAY_BACKUP_DIR);
|
|
24869
25314
|
if (existsSync6(backupRoot))
|
|
24870
25315
|
return;
|
|
24871
|
-
await
|
|
24872
|
-
const configPath =
|
|
25316
|
+
await mkdir21(backupRoot, { recursive: true });
|
|
25317
|
+
const configPath = resolve30(projectRoot, ".codeconductor", "config.yml");
|
|
24873
25318
|
if (existsSync6(configPath)) {
|
|
24874
25319
|
await copyFile2(configPath, join23(backupRoot, "config.yml"));
|
|
24875
25320
|
}
|
|
24876
|
-
const workflowsDir =
|
|
25321
|
+
const workflowsDir = resolve30(projectRoot, ".codeconductor", "workflows");
|
|
24877
25322
|
if (existsSync6(workflowsDir)) {
|
|
24878
25323
|
const dest = join23(backupRoot, "workflows");
|
|
24879
|
-
await
|
|
25324
|
+
await mkdir21(dest, { recursive: true });
|
|
24880
25325
|
const files = await readdir10(workflowsDir);
|
|
24881
25326
|
for (const file of files) {
|
|
24882
25327
|
if (file.endsWith(".yml")) {
|
|
@@ -24895,9 +25340,9 @@ async function applyHarnessOverlay(projectRoot, disabled, options = {}) {
|
|
|
24895
25340
|
await restoreOverlayBackup(projectRoot);
|
|
24896
25341
|
await snapshotForBackup(projectRoot);
|
|
24897
25342
|
}
|
|
24898
|
-
const workflowsDir =
|
|
24899
|
-
await
|
|
24900
|
-
await
|
|
25343
|
+
const workflowsDir = resolve30(projectRoot, ".codeconductor", "workflows");
|
|
25344
|
+
await mkdir21(workflowsDir, { recursive: true });
|
|
25345
|
+
await mkdir21(resolve30(projectRoot, EVAL_DIR2), { recursive: true });
|
|
24901
25346
|
for (const command of WORKFLOW_OVERLAY_COMMANDS) {
|
|
24902
25347
|
const base = loadWorkflowProfile(command);
|
|
24903
25348
|
const next = applyCatalogToProfile(base, disabled);
|
|
@@ -25040,9 +25485,9 @@ var init_harness_catalog = __esm(() => {
|
|
|
25040
25485
|
});
|
|
25041
25486
|
|
|
25042
25487
|
// src/core/openspec/openspec-state.ts
|
|
25043
|
-
import { createHash as
|
|
25044
|
-
import { mkdir as
|
|
25045
|
-
import { resolve as
|
|
25488
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
25489
|
+
import { mkdir as mkdir22, readFile as readFile33, rename as rename5, writeFile as writeFile21 } from "node:fs/promises";
|
|
25490
|
+
import { resolve as resolve31 } from "node:path";
|
|
25046
25491
|
function canTransition(from, to) {
|
|
25047
25492
|
return ALLOWED_TRANSITIONS[from]?.includes(to) ?? false;
|
|
25048
25493
|
}
|
|
@@ -25064,12 +25509,12 @@ function applyBacklogTransition(content, itemId, from, to, progress) {
|
|
|
25064
25509
|
async function writeFileAtomic(path, content) {
|
|
25065
25510
|
const tmp = `${path}.${process.pid}.${Date.now()}.tmp`;
|
|
25066
25511
|
await writeFile21(tmp, content, "utf-8");
|
|
25067
|
-
await
|
|
25512
|
+
await rename5(tmp, path);
|
|
25068
25513
|
}
|
|
25069
25514
|
async function loadOpenspecState(projectRoot) {
|
|
25070
25515
|
try {
|
|
25071
|
-
const filePath =
|
|
25072
|
-
const content = await
|
|
25516
|
+
const filePath = resolve31(projectRoot, STATE_FILE);
|
|
25517
|
+
const content = await readFile33(filePath, "utf-8");
|
|
25073
25518
|
const data = JSON.parse(content);
|
|
25074
25519
|
return ok(OpenspecStateSchema.parse(data));
|
|
25075
25520
|
} catch (e) {
|
|
@@ -25086,10 +25531,10 @@ async function loadOpenspecState(projectRoot) {
|
|
|
25086
25531
|
}
|
|
25087
25532
|
async function writeOpenspecState(projectRoot, state) {
|
|
25088
25533
|
try {
|
|
25089
|
-
const dir =
|
|
25090
|
-
await
|
|
25534
|
+
const dir = resolve31(projectRoot, ".codeconductor");
|
|
25535
|
+
await mkdir22(dir, { recursive: true });
|
|
25091
25536
|
const validated = OpenspecStateSchema.parse(state);
|
|
25092
|
-
await writeFileAtomic(
|
|
25537
|
+
await writeFileAtomic(resolve31(dir, "openspec-state.json"), JSON.stringify(validated, null, 2));
|
|
25093
25538
|
return ok(undefined);
|
|
25094
25539
|
} catch (e) {
|
|
25095
25540
|
return err(e instanceof Error ? e : new Error(String(e)));
|
|
@@ -25111,7 +25556,7 @@ function getNextTaskCard(state) {
|
|
|
25111
25556
|
return null;
|
|
25112
25557
|
}
|
|
25113
25558
|
function hashContent(content) {
|
|
25114
|
-
return
|
|
25559
|
+
return createHash7("sha256").update(content).digest("hex").slice(0, 16);
|
|
25115
25560
|
}
|
|
25116
25561
|
function serializeItemSnapshot(item) {
|
|
25117
25562
|
return JSON.stringify({
|
|
@@ -25161,7 +25606,12 @@ function archiveItemInMarkdown(content, itemId) {
|
|
|
25161
25606
|
break;
|
|
25162
25607
|
}
|
|
25163
25608
|
}
|
|
25164
|
-
|
|
25609
|
+
let inAcceptance = false;
|
|
25610
|
+
const block = lines.slice(itemStart, itemEnd).map((l) => {
|
|
25611
|
+
if (/^-\s+\w+:/.test(l))
|
|
25612
|
+
inAcceptance = /^-\s+Acceptance:/i.test(l);
|
|
25613
|
+
return inAcceptance ? l.replace(/^(\s*-\s+)\[ \]/, "$1[x]") : l;
|
|
25614
|
+
});
|
|
25165
25615
|
const statusLine = block.findIndex((l) => l.match(/^-\s+Status:/i));
|
|
25166
25616
|
if (statusLine >= 0)
|
|
25167
25617
|
block[statusLine] = "- Status: DONE";
|
|
@@ -25194,7 +25644,7 @@ var init_openspec_state = __esm(() => {
|
|
|
25194
25644
|
|
|
25195
25645
|
// src/core/ccep/context-resolver.ts
|
|
25196
25646
|
import { existsSync as existsSync7 } from "node:fs";
|
|
25197
|
-
import { readFile as
|
|
25647
|
+
import { readFile as readFile34 } from "node:fs/promises";
|
|
25198
25648
|
import { join as join24 } from "node:path";
|
|
25199
25649
|
async function loadProductKnowledge(projectRoot) {
|
|
25200
25650
|
if (isProductGraphDisabled(projectRoot)) {
|
|
@@ -25205,7 +25655,7 @@ async function loadProductKnowledge(projectRoot) {
|
|
|
25205
25655
|
return {};
|
|
25206
25656
|
}
|
|
25207
25657
|
try {
|
|
25208
|
-
const raw = await
|
|
25658
|
+
const raw = await readFile34(graphPath, "utf-8");
|
|
25209
25659
|
const graph = ProductGraphSchema.parse(JSON.parse(raw));
|
|
25210
25660
|
return {
|
|
25211
25661
|
productName: graph.productName,
|
|
@@ -26651,11 +27101,11 @@ var init_backlog_scanner = __esm(() => {
|
|
|
26651
27101
|
});
|
|
26652
27102
|
|
|
26653
27103
|
// src/core/openspec/backlog-session.ts
|
|
26654
|
-
import { readFile as
|
|
26655
|
-
import { resolve as
|
|
27104
|
+
import { readFile as readFile35 } from "node:fs/promises";
|
|
27105
|
+
import { resolve as resolve32 } from "node:path";
|
|
26656
27106
|
async function loadBacklogSession(projectRoot) {
|
|
26657
27107
|
try {
|
|
26658
|
-
const raw = await
|
|
27108
|
+
const raw = await readFile35(resolve32(projectRoot, BACKLOG_FILENAME), "utf-8");
|
|
26659
27109
|
const parsed = parseBacklogMarkdown(raw);
|
|
26660
27110
|
if (!parsed.success)
|
|
26661
27111
|
return parsed;
|
|
@@ -26879,8 +27329,8 @@ var init_backlog_planner = __esm(() => {
|
|
|
26879
27329
|
});
|
|
26880
27330
|
|
|
26881
27331
|
// src/core/openspec/openspec-generator.ts
|
|
26882
|
-
import { access as access7, mkdir as
|
|
26883
|
-
import { basename as basename8, resolve as
|
|
27332
|
+
import { access as access7, mkdir as mkdir23, readFile as readFile36, rename as rename6, writeFile as writeFile22 } from "node:fs/promises";
|
|
27333
|
+
import { basename as basename8, resolve as resolve33 } from "node:path";
|
|
26884
27334
|
function pad3(n) {
|
|
26885
27335
|
return String(n).padStart(3, "0");
|
|
26886
27336
|
}
|
|
@@ -26966,36 +27416,53 @@ ${blocks.join(`
|
|
|
26966
27416
|
`)}
|
|
26967
27417
|
`;
|
|
26968
27418
|
}
|
|
26969
|
-
async function
|
|
26970
|
-
|
|
26971
|
-
|
|
27419
|
+
async function syncTaskCardCheckbox(projectRoot, changePath, cardId, done) {
|
|
27420
|
+
const file = resolve33(projectRoot, changePath, "tasks.md");
|
|
27421
|
+
let content;
|
|
27422
|
+
try {
|
|
27423
|
+
content = await readFile36(file, "utf-8");
|
|
27424
|
+
} catch (e) {
|
|
27425
|
+
if (e.code === "ENOENT")
|
|
27426
|
+
return;
|
|
27427
|
+
throw e;
|
|
27428
|
+
}
|
|
27429
|
+
const suffix = `(${cardId})`;
|
|
27430
|
+
const updated = content.split(`
|
|
27431
|
+
`).map((line) => /^\s*-\s*\[[ xX]\]/.test(line) && line.trimEnd().endsWith(suffix) ? line.replace(/\[[ xX]\]/, done ? "[x]" : "[ ]") : line).join(`
|
|
27432
|
+
`);
|
|
27433
|
+
if (updated !== content)
|
|
27434
|
+
await writeFile22(file, updated, "utf-8");
|
|
26972
27435
|
}
|
|
26973
27436
|
function tasksContent(cards, options = {}) {
|
|
26974
27437
|
const criteria = options.acceptanceCriteria ?? [];
|
|
27438
|
+
const tag = (phase) => {
|
|
27439
|
+
const card = cards.find((c) => c.phase === phase);
|
|
27440
|
+
return card ? ` (${card.id})` : "";
|
|
27441
|
+
};
|
|
26975
27442
|
const lines = [
|
|
26976
27443
|
"# Implementation Tasks",
|
|
26977
27444
|
"",
|
|
26978
27445
|
"## Setup",
|
|
26979
27446
|
"",
|
|
26980
|
-
|
|
27447
|
+
`- [ ] Confirm scope and OpenSpec change folder${tag("discover")}`,
|
|
26981
27448
|
"",
|
|
26982
27449
|
"## Foundational",
|
|
26983
27450
|
"",
|
|
26984
|
-
|
|
27451
|
+
`- [ ] Read existing conventions in scope${tag("discover")}`,
|
|
26985
27452
|
"",
|
|
26986
27453
|
"## Requirements",
|
|
26987
27454
|
""
|
|
26988
27455
|
];
|
|
26989
27456
|
if (criteria.length === 0) {
|
|
26990
|
-
lines.push(
|
|
27457
|
+
lines.push(`- [ ] Implementation tasks (generated after plan)${tag("implement")}`);
|
|
26991
27458
|
} else {
|
|
26992
27459
|
for (const [index, criterion] of criteria.entries()) {
|
|
26993
27460
|
const n = pad3(index + 1);
|
|
26994
27461
|
if (options.tddRequired) {
|
|
26995
|
-
lines.push(`- [ ] Write failing test for FR-${n} (${criterion})`);
|
|
27462
|
+
lines.push(`- [ ] Write failing test for FR-${n} (${criterion})${tag("test")}`);
|
|
26996
27463
|
}
|
|
26997
|
-
lines.push(`- [ ] Implement FR-${n} (${criterion})`);
|
|
26998
|
-
lines.push(`- [ ] Verify SC-${n}`);
|
|
27464
|
+
lines.push(`- [ ] Implement FR-${n} (${criterion})${tag("implement")}`);
|
|
27465
|
+
lines.push(`- [ ] Verify SC-${n}${tag("review")}`);
|
|
26999
27466
|
}
|
|
27000
27467
|
}
|
|
27001
27468
|
const phaseCards = cards.filter((c) => c.phase === "implement" || c.phase === "test");
|
|
@@ -27007,25 +27474,25 @@ function tasksContent(cards, options = {}) {
|
|
|
27007
27474
|
if (phaseCards.length === 0) {
|
|
27008
27475
|
lines.push("- [ ] Implementation tasks (generated after plan)");
|
|
27009
27476
|
}
|
|
27010
|
-
lines.push("", "## Polish", "",
|
|
27477
|
+
lines.push("", "## Polish", "", `- [ ] Run openspec analyze and scorecard create --from-diff${tag("review")}`);
|
|
27011
27478
|
return lines.join(`
|
|
27012
27479
|
`);
|
|
27013
27480
|
}
|
|
27014
27481
|
async function generateOpenspecChange(projectRoot, item, taskCards, options = {}) {
|
|
27015
27482
|
const slug = buildChangeSlug(item);
|
|
27016
|
-
const changeDir =
|
|
27017
|
-
await
|
|
27483
|
+
const changeDir = resolve33(projectRoot, "openspec", "changes", slug);
|
|
27484
|
+
await mkdir23(resolve33(changeDir, "specs"), { recursive: true });
|
|
27018
27485
|
const taskOpts = {
|
|
27019
27486
|
tddRequired: options.tddRequired,
|
|
27020
27487
|
acceptanceCriteria: options.acceptanceCriteria ?? item.acceptanceCriteria
|
|
27021
27488
|
};
|
|
27022
|
-
await writeFile22(
|
|
27023
|
-
await writeFile22(
|
|
27024
|
-
await writeFile22(
|
|
27489
|
+
await writeFile22(resolve33(changeDir, "proposal.md"), proposalContent(item), "utf-8");
|
|
27490
|
+
await writeFile22(resolve33(changeDir, "design.md"), designContent(item), "utf-8");
|
|
27491
|
+
await writeFile22(resolve33(changeDir, "tasks.md"), tasksContent(taskCards, taskOpts), "utf-8");
|
|
27025
27492
|
const capability = capabilitySlug(item.title);
|
|
27026
|
-
await
|
|
27027
|
-
await writeFile22(
|
|
27028
|
-
await writeFile22(
|
|
27493
|
+
await mkdir23(resolve33(changeDir, "specs", capability), { recursive: true });
|
|
27494
|
+
await writeFile22(resolve33(changeDir, "specs", capability, "spec.md"), specDelta(item), "utf-8");
|
|
27495
|
+
await writeFile22(resolve33(changeDir, "change.yaml"), `version: 1
|
|
27029
27496
|
backlogId: ${item.id}
|
|
27030
27497
|
profile: standard
|
|
27031
27498
|
capabilities:
|
|
@@ -27034,11 +27501,11 @@ capabilities:
|
|
|
27034
27501
|
return `openspec/changes/${slug}`;
|
|
27035
27502
|
}
|
|
27036
27503
|
async function archiveChangeFolder(projectRoot, changePath) {
|
|
27037
|
-
const src =
|
|
27504
|
+
const src = resolve33(projectRoot, changePath);
|
|
27038
27505
|
const slug = basename8(changePath);
|
|
27039
|
-
const destDir =
|
|
27040
|
-
await
|
|
27041
|
-
const dest =
|
|
27506
|
+
const destDir = resolve33(projectRoot, "openspec", "changes", "archive");
|
|
27507
|
+
await mkdir23(destDir, { recursive: true });
|
|
27508
|
+
const dest = resolve33(destDir, slug);
|
|
27042
27509
|
try {
|
|
27043
27510
|
await access7(dest);
|
|
27044
27511
|
throw new Error(`Archive destination already exists: openspec/changes/archive/${slug}`);
|
|
@@ -27047,16 +27514,16 @@ async function archiveChangeFolder(projectRoot, changePath) {
|
|
|
27047
27514
|
throw error;
|
|
27048
27515
|
}
|
|
27049
27516
|
}
|
|
27050
|
-
await
|
|
27517
|
+
await rename6(src, dest);
|
|
27051
27518
|
return `openspec/changes/archive/${slug}`;
|
|
27052
27519
|
}
|
|
27053
27520
|
async function ensureOpenspecConfig(projectRoot) {
|
|
27054
|
-
const configPath =
|
|
27521
|
+
const configPath = resolve33(projectRoot, "openspec", "config.yaml");
|
|
27055
27522
|
try {
|
|
27056
27523
|
const { access: access8 } = await import("node:fs/promises");
|
|
27057
27524
|
await access8(configPath);
|
|
27058
27525
|
} catch {
|
|
27059
|
-
await
|
|
27526
|
+
await mkdir23(resolve33(projectRoot, "openspec"), { recursive: true });
|
|
27060
27527
|
const stub = `# OpenSpec project config (CodeConductor native compatible)
|
|
27061
27528
|
schema: spec-driven
|
|
27062
27529
|
`;
|
|
@@ -27069,8 +27536,31 @@ var init_openspec_generator = __esm(() => {
|
|
|
27069
27536
|
});
|
|
27070
27537
|
|
|
27071
27538
|
// src/core/openspec/spec-files.ts
|
|
27072
|
-
import { readFile as
|
|
27073
|
-
import { join as join25 } from "node:path";
|
|
27539
|
+
import { readFile as readFile37, readdir as readdir11 } from "node:fs/promises";
|
|
27540
|
+
import { basename as basename9, dirname as dirname13, join as join25 } from "node:path";
|
|
27541
|
+
function requirementId(name, capability) {
|
|
27542
|
+
const frId = name.match(/\bFR-\d{3}\b/)?.[0];
|
|
27543
|
+
if (frId)
|
|
27544
|
+
return frId;
|
|
27545
|
+
return `req:${capability}/${specNameSlug(name)}`;
|
|
27546
|
+
}
|
|
27547
|
+
function specNameSlug(name) {
|
|
27548
|
+
return name.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
27549
|
+
}
|
|
27550
|
+
function specCapability(path) {
|
|
27551
|
+
return basename9(path) === "spec.md" ? basename9(dirname13(path)) : basename9(path, ".md");
|
|
27552
|
+
}
|
|
27553
|
+
function hasMalformedRenames(markdown) {
|
|
27554
|
+
const sections = [...markdown.matchAll(/^## (ADDED|MODIFIED|REMOVED|RENAMED) Requirements\s*$/gm)];
|
|
27555
|
+
return sections.some((section, index) => {
|
|
27556
|
+
if (section[1] !== "RENAMED")
|
|
27557
|
+
return false;
|
|
27558
|
+
const text = markdown.slice((section.index ?? 0) + section[0].length, sections[index + 1]?.index ?? markdown.length).split(/^## /m, 1)[0] ?? "";
|
|
27559
|
+
const renamed = requirementBlocks(`## RENAMED Requirements
|
|
27560
|
+
${text}`).filter((block) => block.renamedFrom);
|
|
27561
|
+
return renamed.length === 0 || renamed.some((block) => block.id?.endsWith("/") || block.renamedFrom?.endsWith("/")) || (text.match(/^- (?:FROM|TO):/gm)?.length ?? 0) !== renamed.length * 2;
|
|
27562
|
+
});
|
|
27563
|
+
}
|
|
27074
27564
|
async function walkMarkdownFiles(dir) {
|
|
27075
27565
|
let entries;
|
|
27076
27566
|
try {
|
|
@@ -27093,18 +27583,46 @@ async function readMarkdownFiles(dir) {
|
|
|
27093
27583
|
const files = await walkMarkdownFiles(dir);
|
|
27094
27584
|
const out = [];
|
|
27095
27585
|
for (const path of files) {
|
|
27096
|
-
out.push({ path, content: await
|
|
27586
|
+
out.push({ path, content: await readFile37(path, "utf-8") });
|
|
27097
27587
|
}
|
|
27098
27588
|
return out;
|
|
27099
27589
|
}
|
|
27100
|
-
function requirementBlocks(markdown) {
|
|
27590
|
+
function requirementBlocks(markdown, capability) {
|
|
27101
27591
|
const starts = [...markdown.matchAll(/^### Requirement:.*$/gm)];
|
|
27102
|
-
|
|
27592
|
+
const sections = [...markdown.matchAll(/^## (ADDED|MODIFIED|REMOVED|RENAMED) Requirements\s*$/gm)];
|
|
27593
|
+
const headings = [...markdown.matchAll(/^## (.*)$/gm)];
|
|
27594
|
+
const blocks = starts.map((match, index) => {
|
|
27103
27595
|
const start = match.index ?? 0;
|
|
27104
|
-
const
|
|
27596
|
+
const heading = [...headings].reverse().find((entry) => (entry.index ?? 0) < start);
|
|
27597
|
+
const operation = heading?.[1]?.trim().match(/^(ADDED|MODIFIED|REMOVED|RENAMED) Requirements$/)?.[1];
|
|
27598
|
+
const nextSection = markdown.slice(start).search(/^## /m);
|
|
27599
|
+
const end = Math.min(starts[index + 1]?.index ?? markdown.length, nextSection < 0 ? markdown.length : start + nextSection);
|
|
27105
27600
|
const block = markdown.slice(start, end).trim();
|
|
27106
|
-
|
|
27601
|
+
const name = match[0].replace(/^### Requirement:\s*/, "").trim();
|
|
27602
|
+
return {
|
|
27603
|
+
id: block.match(REQUIREMENT_HEADING)?.[1] ?? requirementId(name, capability ?? "spec"),
|
|
27604
|
+
markdown: block,
|
|
27605
|
+
name,
|
|
27606
|
+
deltaOperation: operation
|
|
27607
|
+
};
|
|
27107
27608
|
});
|
|
27609
|
+
for (const [index, section] of sections.entries()) {
|
|
27610
|
+
if (section[1] !== "RENAMED")
|
|
27611
|
+
continue;
|
|
27612
|
+
const text = markdown.slice((section.index ?? 0) + section[0].length, sections[index + 1]?.index ?? markdown.length).split(/^## /m, 1)[0] ?? "";
|
|
27613
|
+
const pairs = [...text.matchAll(/^- FROM:\s*`?### Requirement:\s*(.*?)`?\s*\r?\n- TO:\s*`?### Requirement:\s*(.*?)`?\s*$/gm)];
|
|
27614
|
+
for (const pair of pairs) {
|
|
27615
|
+
const name = pair[2] ?? "";
|
|
27616
|
+
blocks.push({
|
|
27617
|
+
id: requirementId(name, capability ?? "spec"),
|
|
27618
|
+
markdown: pair[0],
|
|
27619
|
+
name,
|
|
27620
|
+
deltaOperation: "RENAMED",
|
|
27621
|
+
renamedFrom: requirementId(pair[1] ?? "", capability ?? "spec")
|
|
27622
|
+
});
|
|
27623
|
+
}
|
|
27624
|
+
}
|
|
27625
|
+
return blocks;
|
|
27108
27626
|
}
|
|
27109
27627
|
var REQUIREMENT_HEADING;
|
|
27110
27628
|
var init_spec_files = __esm(() => {
|
|
@@ -27112,8 +27630,8 @@ var init_spec_files = __esm(() => {
|
|
|
27112
27630
|
});
|
|
27113
27631
|
|
|
27114
27632
|
// src/core/openspec/spec-quality.ts
|
|
27115
|
-
import { readFile as
|
|
27116
|
-
import { join as join26, relative as relative10, resolve as
|
|
27633
|
+
import { readFile as readFile38 } from "node:fs/promises";
|
|
27634
|
+
import { join as join26, relative as relative10, resolve as resolve34 } from "node:path";
|
|
27117
27635
|
function uniqueIds(matches) {
|
|
27118
27636
|
return [...new Set(matches ?? [])];
|
|
27119
27637
|
}
|
|
@@ -27121,10 +27639,15 @@ function assessSpecMarkdown(content, path) {
|
|
|
27121
27639
|
const issues = [];
|
|
27122
27640
|
const clarifications = content.match(NEEDS_CLARIFICATION) ?? [];
|
|
27123
27641
|
const needsClarificationCount = clarifications.length;
|
|
27124
|
-
const
|
|
27642
|
+
const blocks = requirementBlocks(content, specCapability(path));
|
|
27643
|
+
const frIds = [...new Set(blocks.map((block) => block.id).filter((id) => /^FR-\d{3}$/.test(id ?? "")))];
|
|
27125
27644
|
const scIds = uniqueIds(content.match(SC_ID));
|
|
27126
27645
|
const usAcIds = uniqueIds(content.match(US_AC));
|
|
27127
|
-
const
|
|
27646
|
+
const legacy = blocks.some((block) => /^FR-\d{3}$/.test(block.id ?? "") && block.deltaOperation !== "REMOVED" && block.deltaOperation !== "RENAMED");
|
|
27647
|
+
const hasTraceIds = !legacy || scIds.length > 0 || usAcIds.length > 0;
|
|
27648
|
+
if (hasMalformedRenames(content)) {
|
|
27649
|
+
issues.push({ code: "MALFORMED_RENAME", message: "RENAMED requires paired FROM/TO requirement headings", path, severity: "error" });
|
|
27650
|
+
}
|
|
27128
27651
|
if (PLACEHOLDER.test(content)) {
|
|
27129
27652
|
issues.push({
|
|
27130
27653
|
code: "PLACEHOLDER",
|
|
@@ -27149,7 +27672,6 @@ function assessSpecMarkdown(content, path) {
|
|
|
27149
27672
|
severity: "error"
|
|
27150
27673
|
});
|
|
27151
27674
|
}
|
|
27152
|
-
const blocks = requirementBlocks(content);
|
|
27153
27675
|
if (blocks.length === 0) {
|
|
27154
27676
|
issues.push({
|
|
27155
27677
|
code: "MISSING_REQUIREMENT",
|
|
@@ -27158,8 +27680,15 @@ function assessSpecMarkdown(content, path) {
|
|
|
27158
27680
|
severity: "error"
|
|
27159
27681
|
});
|
|
27160
27682
|
}
|
|
27683
|
+
const officialScenarios = [];
|
|
27161
27684
|
for (const block of blocks) {
|
|
27685
|
+
if (!block.name?.trim() || block.id?.endsWith("/")) {
|
|
27686
|
+
issues.push({ code: "INVALID_REQUIREMENT_NAME", message: "Requirement names MUST produce a nonempty stable ID", path, severity: "error" });
|
|
27687
|
+
}
|
|
27688
|
+
if (block.deltaOperation === "REMOVED" || block.deltaOperation === "RENAMED")
|
|
27689
|
+
continue;
|
|
27162
27690
|
const text = block.markdown;
|
|
27691
|
+
const legacyBlock = /^FR-\d{3}$/.test(block.id ?? "");
|
|
27163
27692
|
const heading = text.split(`
|
|
27164
27693
|
`, 1)[0] ?? "";
|
|
27165
27694
|
if (!RFC2119.test(text)) {
|
|
@@ -27170,7 +27699,17 @@ function assessSpecMarkdown(content, path) {
|
|
|
27170
27699
|
severity: "error"
|
|
27171
27700
|
});
|
|
27172
27701
|
}
|
|
27173
|
-
|
|
27702
|
+
const scenarios = [...text.matchAll(/^#### Scenario:\s*(.+)$/gm)];
|
|
27703
|
+
if (!legacyBlock) {
|
|
27704
|
+
for (const [index, scenario] of scenarios.entries()) {
|
|
27705
|
+
const body = text.slice(scenario.index, scenarios[index + 1]?.index ?? text.length);
|
|
27706
|
+
officialScenarios.push({ id: `${block.id}#${specNameSlug(scenario[1] ?? "")}`, text: scenario[1] ?? "" });
|
|
27707
|
+
if (!/\bWHEN\b[\s\S]*?\bTHEN\b/i.test(body)) {
|
|
27708
|
+
issues.push({ code: "MISSING_GWT", message: `Scenario "${scenario[1]}" MUST include WHEN/THEN steps`, path, severity: "error" });
|
|
27709
|
+
}
|
|
27710
|
+
}
|
|
27711
|
+
}
|
|
27712
|
+
if (legacyBlock ? !GWT.test(text) : scenarios.length === 0) {
|
|
27174
27713
|
issues.push({
|
|
27175
27714
|
code: "MISSING_GWT",
|
|
27176
27715
|
message: `Requirement "${heading}" MUST include a Given/When/Then scenario`,
|
|
@@ -27187,8 +27726,14 @@ function assessSpecMarkdown(content, path) {
|
|
|
27187
27726
|
severity: "warning"
|
|
27188
27727
|
});
|
|
27189
27728
|
}
|
|
27190
|
-
const requirements =
|
|
27191
|
-
|
|
27729
|
+
const requirements = [
|
|
27730
|
+
...frIds.map((id) => ({ id, text: id })),
|
|
27731
|
+
...blocks.filter((block) => block.id?.startsWith("req:")).map((block) => ({ id: block.id, text: block.name ?? "" }))
|
|
27732
|
+
];
|
|
27733
|
+
const successCriteria = [
|
|
27734
|
+
...[...scIds, ...usAcIds].map((id) => ({ id, text: id })),
|
|
27735
|
+
...officialScenarios
|
|
27736
|
+
];
|
|
27192
27737
|
const errors3 = issues.filter((i) => i.severity === "error");
|
|
27193
27738
|
return {
|
|
27194
27739
|
valid: errors3.length === 0,
|
|
@@ -27224,8 +27769,8 @@ function mergeSpecQualityReports(reports) {
|
|
|
27224
27769
|
};
|
|
27225
27770
|
}
|
|
27226
27771
|
async function assessChangeFolder(projectRoot, changePath) {
|
|
27227
|
-
const root =
|
|
27228
|
-
const changeRoot =
|
|
27772
|
+
const root = resolve34(projectRoot);
|
|
27773
|
+
const changeRoot = resolve34(root, changePath);
|
|
27229
27774
|
if (!changeRoot.startsWith(root)) {
|
|
27230
27775
|
return {
|
|
27231
27776
|
valid: false,
|
|
@@ -27248,13 +27793,13 @@ async function assessChangeFolder(projectRoot, changePath) {
|
|
|
27248
27793
|
const extra = ["proposal.md", "design.md"].map((name) => join26(changeRoot, name));
|
|
27249
27794
|
const reports = [];
|
|
27250
27795
|
for (const file of specFiles) {
|
|
27251
|
-
const content = await
|
|
27796
|
+
const content = await readFile38(file, "utf-8");
|
|
27252
27797
|
reports.push(assessSpecMarkdown(content, relative10(root, file).replace(/\\/g, "/")));
|
|
27253
27798
|
}
|
|
27254
27799
|
for (const file of extra) {
|
|
27255
27800
|
let content;
|
|
27256
27801
|
try {
|
|
27257
|
-
content = await
|
|
27802
|
+
content = await readFile38(file, "utf-8");
|
|
27258
27803
|
} catch {
|
|
27259
27804
|
continue;
|
|
27260
27805
|
}
|
|
@@ -27296,11 +27841,10 @@ async function assessChangeFolder(projectRoot, changePath) {
|
|
|
27296
27841
|
}
|
|
27297
27842
|
return mergeSpecQualityReports(reports);
|
|
27298
27843
|
}
|
|
27299
|
-
var RFC2119,
|
|
27844
|
+
var RFC2119, SC_ID, US_AC, GWT, NEEDS_CLARIFICATION, PLACEHOLDER, HOW_LEAK, MAX_CLARIFICATIONS = 3;
|
|
27300
27845
|
var init_spec_quality = __esm(() => {
|
|
27301
27846
|
init_spec_files();
|
|
27302
27847
|
RFC2119 = /\b(MUST(?: NOT)?|SHALL(?: NOT)?|SHOULD(?: NOT)?|MAY)\b/;
|
|
27303
|
-
FR_ID = /\bFR-\d{3}\b/g;
|
|
27304
27848
|
SC_ID = /\bSC-\d{3}\b/g;
|
|
27305
27849
|
US_AC = /\b(?:US|AC)#?\d+\b/g;
|
|
27306
27850
|
GWT = /\bGIVEN\b[\s\S]*?\bWHEN\b[\s\S]*?\bTHEN\b/i;
|
|
@@ -27310,8 +27854,8 @@ var init_spec_quality = __esm(() => {
|
|
|
27310
27854
|
});
|
|
27311
27855
|
|
|
27312
27856
|
// src/core/openspec/spec-analyzer.ts
|
|
27313
|
-
import { readFile as
|
|
27314
|
-
import { join as join27, resolve as
|
|
27857
|
+
import { readFile as readFile39 } from "node:fs/promises";
|
|
27858
|
+
import { join as join27, resolve as resolve35 } from "node:path";
|
|
27315
27859
|
function unique(ids) {
|
|
27316
27860
|
return [...new Set(ids)];
|
|
27317
27861
|
}
|
|
@@ -27321,7 +27865,10 @@ function coverage(mapped, total) {
|
|
|
27321
27865
|
return Math.round(mapped / total * 1000) / 10;
|
|
27322
27866
|
}
|
|
27323
27867
|
function mentionsId(haystack, id) {
|
|
27324
|
-
|
|
27868
|
+
if (!id.startsWith("req:"))
|
|
27869
|
+
return haystack.includes(id);
|
|
27870
|
+
const escaped = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
27871
|
+
return new RegExp(`(?<![\\w:/#-])${escaped}(?![\\w/-])`).test(haystack);
|
|
27325
27872
|
}
|
|
27326
27873
|
function testSection(tasksMarkdown) {
|
|
27327
27874
|
const lines = tasksMarkdown.split(`
|
|
@@ -27335,14 +27882,8 @@ function testSection(tasksMarkdown) {
|
|
|
27335
27882
|
return kept.join(`
|
|
27336
27883
|
`);
|
|
27337
27884
|
}
|
|
27338
|
-
async function readDeltaSpecs(specDir) {
|
|
27339
|
-
const files = await readMarkdownFiles(specDir);
|
|
27340
|
-
return files.map((f) => f.content).filter(Boolean).join(`
|
|
27341
|
-
|
|
27342
|
-
`);
|
|
27343
|
-
}
|
|
27344
27885
|
function analyzeSpecArtifacts(input) {
|
|
27345
|
-
const quality = assessSpecMarkdown(input.specMarkdown, `${input.changePath}/specs`);
|
|
27886
|
+
const quality = input.specFiles?.length ? mergeSpecQualityReports(input.specFiles.map((file) => assessSpecMarkdown(file.content, file.path))) : assessSpecMarkdown(input.specMarkdown, input.specPath ?? `${input.changePath}/specs`);
|
|
27346
27887
|
const frIds = unique(quality.requirements.map((r) => r.id));
|
|
27347
27888
|
const scIds = unique(quality.successCriteria.map((s) => s.id));
|
|
27348
27889
|
const tasks = input.tasksMarkdown;
|
|
@@ -27412,23 +27953,27 @@ function analyzeSpecArtifacts(input) {
|
|
|
27412
27953
|
};
|
|
27413
27954
|
}
|
|
27414
27955
|
async function analyzeChangeFolder(projectRoot, changePath, options) {
|
|
27415
|
-
const changeRoot =
|
|
27416
|
-
const
|
|
27956
|
+
const changeRoot = resolve35(projectRoot, changePath);
|
|
27957
|
+
const specFiles = await readMarkdownFiles(join27(changeRoot, "specs"));
|
|
27958
|
+
const specMarkdown = specFiles.map((file) => file.content).join(`
|
|
27959
|
+
|
|
27960
|
+
`);
|
|
27417
27961
|
let tasksMarkdown = "";
|
|
27418
27962
|
try {
|
|
27419
|
-
tasksMarkdown = await
|
|
27963
|
+
tasksMarkdown = await readFile39(join27(changeRoot, "tasks.md"), "utf-8");
|
|
27420
27964
|
} catch {
|
|
27421
27965
|
tasksMarkdown = "";
|
|
27422
27966
|
}
|
|
27423
27967
|
let designMarkdown;
|
|
27424
27968
|
try {
|
|
27425
|
-
designMarkdown = await
|
|
27969
|
+
designMarkdown = await readFile39(join27(changeRoot, "design.md"), "utf-8");
|
|
27426
27970
|
} catch {
|
|
27427
27971
|
designMarkdown = undefined;
|
|
27428
27972
|
}
|
|
27429
27973
|
return analyzeSpecArtifacts({
|
|
27430
27974
|
changePath,
|
|
27431
27975
|
specMarkdown,
|
|
27976
|
+
specFiles,
|
|
27432
27977
|
tasksMarkdown,
|
|
27433
27978
|
designMarkdown,
|
|
27434
27979
|
policyText: options.policyText,
|
|
@@ -27442,32 +27987,41 @@ var init_spec_analyzer = __esm(() => {
|
|
|
27442
27987
|
});
|
|
27443
27988
|
|
|
27444
27989
|
// src/core/openspec/spec-sync.ts
|
|
27445
|
-
import { mkdir as
|
|
27446
|
-
import { join as join28, relative as relative11, resolve as
|
|
27447
|
-
function deltaRequirements(markdown) {
|
|
27448
|
-
|
|
27449
|
-
|
|
27450
|
-
|
|
27451
|
-
|
|
27452
|
-
|
|
27453
|
-
|
|
27454
|
-
|
|
27455
|
-
|
|
27456
|
-
|
|
27457
|
-
|
|
27458
|
-
});
|
|
27459
|
-
}
|
|
27460
|
-
function upsertRequirements(existing, deltas, source) {
|
|
27461
|
-
const requirements = requirementBlocks(existing).filter((requirement) => requirement.id !== null);
|
|
27990
|
+
import { mkdir as mkdir24, readFile as readFile40 } from "node:fs/promises";
|
|
27991
|
+
import { join as join28, relative as relative11, resolve as resolve36 } from "node:path";
|
|
27992
|
+
function deltaRequirements(markdown, capability) {
|
|
27993
|
+
return requirementBlocks(markdown, capability).filter((requirement) => requirement.id !== null && requirement.deltaOperation !== undefined).map((requirement) => ({
|
|
27994
|
+
id: requirement.id,
|
|
27995
|
+
markdown: requirement.markdown,
|
|
27996
|
+
operation: requirement.deltaOperation,
|
|
27997
|
+
name: requirement.name,
|
|
27998
|
+
renamedFrom: requirement.renamedFrom
|
|
27999
|
+
})).sort((a, b) => Number(b.operation === "RENAMED") - Number(a.operation === "RENAMED"));
|
|
28000
|
+
}
|
|
28001
|
+
function upsertRequirements(existing, deltas, source, capability) {
|
|
28002
|
+
const requirements = requirementBlocks(existing, capability).filter((requirement) => requirement.id !== null);
|
|
27462
28003
|
const byId = new Map(requirements.map((requirement) => [requirement.id, requirement]));
|
|
27463
28004
|
if (byId.size !== requirements.length) {
|
|
27464
28005
|
return { ok: false, error: `${source}: durable spec has duplicate requirement IDs` };
|
|
27465
28006
|
}
|
|
27466
28007
|
const seen = new Set;
|
|
28008
|
+
let next = existing.trimEnd();
|
|
27467
28009
|
for (const delta of deltas) {
|
|
27468
|
-
if (
|
|
27469
|
-
|
|
28010
|
+
if (delta.operation === "RENAMED") {
|
|
28011
|
+
const current2 = byId.get(delta.renamedFrom ?? "");
|
|
28012
|
+
if (!current2)
|
|
28013
|
+
return { ok: false, error: `${source}: RENAMED source ${delta.renamedFrom} does not exist` };
|
|
28014
|
+
if (delta.id !== delta.renamedFrom && byId.has(delta.id)) {
|
|
28015
|
+
return { ok: false, error: `${source}: RENAMED destination ${delta.id} already exists` };
|
|
28016
|
+
}
|
|
28017
|
+
const renamed = current2.markdown.replace(/^### Requirement:.*$/m, () => `### Requirement: ${delta.name}`);
|
|
28018
|
+
next = next.replace(current2.markdown, () => renamed);
|
|
28019
|
+
byId.delete(delta.renamedFrom ?? "");
|
|
28020
|
+
byId.set(delta.id, { ...current2, id: delta.id, markdown: renamed });
|
|
28021
|
+
continue;
|
|
27470
28022
|
}
|
|
28023
|
+
if (seen.has(delta.id))
|
|
28024
|
+
return { ok: false, error: `${source}: duplicate delta requirement ${delta.id}` };
|
|
27471
28025
|
seen.add(delta.id);
|
|
27472
28026
|
const current = byId.get(delta.id);
|
|
27473
28027
|
if (delta.operation === "ADDED" && current) {
|
|
@@ -27476,10 +28030,6 @@ function upsertRequirements(existing, deltas, source) {
|
|
|
27476
28030
|
if ((delta.operation === "MODIFIED" || delta.operation === "REMOVED") && !current) {
|
|
27477
28031
|
return { ok: false, error: `${source}: ${delta.operation} requirement ${delta.id} does not exist` };
|
|
27478
28032
|
}
|
|
27479
|
-
}
|
|
27480
|
-
let next = existing.trimEnd();
|
|
27481
|
-
for (const delta of deltas) {
|
|
27482
|
-
const current = byId.get(delta.id);
|
|
27483
28033
|
if (delta.operation === "ADDED") {
|
|
27484
28034
|
next = `${next}
|
|
27485
28035
|
|
|
@@ -27503,8 +28053,8 @@ ${delta.markdown}`;
|
|
|
27503
28053
|
` };
|
|
27504
28054
|
}
|
|
27505
28055
|
async function syncChangeSpecs(projectRoot, changePath) {
|
|
27506
|
-
const root =
|
|
27507
|
-
const changeRoot =
|
|
28056
|
+
const root = resolve36(projectRoot);
|
|
28057
|
+
const changeRoot = resolve36(root, changePath);
|
|
27508
28058
|
const changeSpecs = join28(changeRoot, "specs");
|
|
27509
28059
|
if (changeRoot !== root && !changeRoot.startsWith(`${root}/`)) {
|
|
27510
28060
|
return { success: false, syncedPaths: [], errors: ["Change path escapes project root"] };
|
|
@@ -27515,8 +28065,14 @@ async function syncChangeSpecs(projectRoot, changePath) {
|
|
|
27515
28065
|
}
|
|
27516
28066
|
const writes = [];
|
|
27517
28067
|
for (const file of files) {
|
|
27518
|
-
const delta = await
|
|
27519
|
-
|
|
28068
|
+
const delta = await readFile40(file, "utf-8");
|
|
28069
|
+
if (hasMalformedRenames(delta)) {
|
|
28070
|
+
return { success: false, syncedPaths: [], errors: [`${relative11(root, file)}: RENAMED requires paired FROM/TO requirement headings`] };
|
|
28071
|
+
}
|
|
28072
|
+
const requirements = deltaRequirements(delta, specCapability(file));
|
|
28073
|
+
if (requirements.some((requirement) => !requirement.name?.trim() || requirement.id.endsWith("/"))) {
|
|
28074
|
+
return { success: false, syncedPaths: [], errors: [`${relative11(root, file)}: requirement names must produce a nonempty stable ID`] };
|
|
28075
|
+
}
|
|
27520
28076
|
if (requirements.length === 0) {
|
|
27521
28077
|
return {
|
|
27522
28078
|
success: false,
|
|
@@ -27529,15 +28085,15 @@ async function syncChangeSpecs(projectRoot, changePath) {
|
|
|
27529
28085
|
let existing = `# ${relativeSpec.replace(/\\/g, "/")}
|
|
27530
28086
|
`;
|
|
27531
28087
|
try {
|
|
27532
|
-
existing = await
|
|
28088
|
+
existing = await readFile40(target, "utf-8");
|
|
27533
28089
|
} catch {}
|
|
27534
|
-
const merged = upsertRequirements(existing, requirements, relative11(root, file));
|
|
28090
|
+
const merged = upsertRequirements(existing, requirements, relative11(root, file), specCapability(file));
|
|
27535
28091
|
if (!merged.ok)
|
|
27536
28092
|
return { success: false, syncedPaths: [], errors: [merged.error] };
|
|
27537
28093
|
writes.push({ path: target, content: merged.content });
|
|
27538
28094
|
}
|
|
27539
28095
|
for (const write of writes) {
|
|
27540
|
-
await
|
|
28096
|
+
await mkdir24(resolve36(write.path, ".."), { recursive: true });
|
|
27541
28097
|
await writeFileAtomic(write.path, write.content);
|
|
27542
28098
|
}
|
|
27543
28099
|
return {
|
|
@@ -27546,16 +28102,14 @@ async function syncChangeSpecs(projectRoot, changePath) {
|
|
|
27546
28102
|
errors: []
|
|
27547
28103
|
};
|
|
27548
28104
|
}
|
|
27549
|
-
var SECTION_HEADING;
|
|
27550
28105
|
var init_spec_sync = __esm(() => {
|
|
27551
28106
|
init_openspec_state();
|
|
27552
28107
|
init_spec_files();
|
|
27553
|
-
SECTION_HEADING = /^## (ADDED|MODIFIED|REMOVED) Requirements\s*$/gm;
|
|
27554
28108
|
});
|
|
27555
28109
|
|
|
27556
28110
|
// src/core/openspec/artifact-progress.ts
|
|
27557
|
-
import { access as access8, readdir as readdir12, readFile as
|
|
27558
|
-
import { join as join29, resolve as
|
|
28111
|
+
import { access as access8, readdir as readdir12, readFile as readFile41 } from "node:fs/promises";
|
|
28112
|
+
import { join as join29, resolve as resolve37 } from "node:path";
|
|
27559
28113
|
function countCheckboxes(markdown) {
|
|
27560
28114
|
let total = 0;
|
|
27561
28115
|
let complete = 0;
|
|
@@ -27595,8 +28149,8 @@ async function hasMarkdown(dir) {
|
|
|
27595
28149
|
return false;
|
|
27596
28150
|
}
|
|
27597
28151
|
async function readArtifactProgress(projectRoot, changePath) {
|
|
27598
|
-
const root =
|
|
27599
|
-
const changeRoot =
|
|
28152
|
+
const root = resolve37(projectRoot);
|
|
28153
|
+
const changeRoot = resolve37(root, changePath);
|
|
27600
28154
|
if (changeRoot !== root && !changeRoot.startsWith(`${root}/`)) {
|
|
27601
28155
|
return ABSENT;
|
|
27602
28156
|
}
|
|
@@ -27609,7 +28163,7 @@ async function readArtifactProgress(projectRoot, changePath) {
|
|
|
27609
28163
|
let checkboxes = { total: 0, complete: 0, remaining: 0 };
|
|
27610
28164
|
if (tasks) {
|
|
27611
28165
|
try {
|
|
27612
|
-
checkboxes = countCheckboxes(await
|
|
28166
|
+
checkboxes = countCheckboxes(await readFile41(join29(changeRoot, "tasks.md"), "utf-8"));
|
|
27613
28167
|
} catch {
|
|
27614
28168
|
checkboxes = { total: 0, complete: 0, remaining: 0 };
|
|
27615
28169
|
}
|
|
@@ -27642,10 +28196,11 @@ var exports_openspec_command = {};
|
|
|
27642
28196
|
__export(exports_openspec_command, {
|
|
27643
28197
|
openspecCommand: () => openspecCommand
|
|
27644
28198
|
});
|
|
27645
|
-
import { readFile as
|
|
27646
|
-
import {
|
|
28199
|
+
import { readFile as readFile42 } from "node:fs/promises";
|
|
28200
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
28201
|
+
import { resolve as resolve38 } from "node:path";
|
|
27647
28202
|
async function openspecCommand(options) {
|
|
27648
|
-
const { subcommand, itemId, projectRoot, output, reason } = options;
|
|
28203
|
+
const { subcommand, itemId, projectRoot, output, reason, allowUnchecked } = options;
|
|
27649
28204
|
switch (subcommand) {
|
|
27650
28205
|
case "validate":
|
|
27651
28206
|
return handleValidate(projectRoot);
|
|
@@ -27668,7 +28223,7 @@ async function openspecCommand(options) {
|
|
|
27668
28223
|
case "unblock":
|
|
27669
28224
|
return handleUnblock(projectRoot, itemId);
|
|
27670
28225
|
case "archive":
|
|
27671
|
-
return handleArchive(projectRoot, itemId);
|
|
28226
|
+
return handleArchive(projectRoot, itemId, allowUnchecked);
|
|
27672
28227
|
case "sync":
|
|
27673
28228
|
return handleSync(projectRoot, itemId);
|
|
27674
28229
|
case "verify":
|
|
@@ -27686,14 +28241,14 @@ async function openspecCommand(options) {
|
|
|
27686
28241
|
};
|
|
27687
28242
|
}
|
|
27688
28243
|
}
|
|
27689
|
-
function
|
|
28244
|
+
function fail2(command, errors3, extra = {}) {
|
|
27690
28245
|
return {
|
|
27691
28246
|
code: 1,
|
|
27692
28247
|
data: { success: false, command, errors: errors3, ...extra }
|
|
27693
28248
|
};
|
|
27694
28249
|
}
|
|
27695
28250
|
async function persistBacklog(projectRoot, content) {
|
|
27696
|
-
await writeFileAtomic(
|
|
28251
|
+
await writeFileAtomic(resolve38(projectRoot, BACKLOG_FILENAME), content);
|
|
27697
28252
|
}
|
|
27698
28253
|
async function persistState(projectRoot, state) {
|
|
27699
28254
|
const written = await writeOpenspecState(projectRoot, state);
|
|
@@ -27721,12 +28276,12 @@ function resolveActiveChange(state, command, itemId) {
|
|
|
27721
28276
|
if (!targetId) {
|
|
27722
28277
|
return {
|
|
27723
28278
|
ok: false,
|
|
27724
|
-
response:
|
|
28279
|
+
response: fail2(command, ["No active change. Run openspec plan or pass an item id."])
|
|
27725
28280
|
};
|
|
27726
28281
|
}
|
|
27727
28282
|
const changePath = state.changePaths[targetId];
|
|
27728
28283
|
if (!changePath || changePath.includes("/archive/")) {
|
|
27729
|
-
return { ok: false, response:
|
|
28284
|
+
return { ok: false, response: fail2(command, [`No active change folder for ${targetId}`]) };
|
|
27730
28285
|
}
|
|
27731
28286
|
return { ok: true, targetId, changePath };
|
|
27732
28287
|
}
|
|
@@ -27734,7 +28289,7 @@ async function collectAnalyzeReport(projectRoot, session, targetId, changePath)
|
|
|
27734
28289
|
const tddRequired = session.doc.global.tddRequired;
|
|
27735
28290
|
const policyParts = [];
|
|
27736
28291
|
try {
|
|
27737
|
-
policyParts.push(await
|
|
28292
|
+
policyParts.push(await readFile42(resolve38(projectRoot, "AGENTS.md"), "utf-8"));
|
|
27738
28293
|
} catch {}
|
|
27739
28294
|
policyParts.push(session.raw);
|
|
27740
28295
|
const cards = itemCards(session.state, targetId);
|
|
@@ -27876,7 +28431,7 @@ async function handleScan(projectRoot) {
|
|
|
27876
28431
|
};
|
|
27877
28432
|
const written = await persistState(projectRoot, state);
|
|
27878
28433
|
if (!written.ok) {
|
|
27879
|
-
return
|
|
28434
|
+
return fail2("openspec scan", [written.error]);
|
|
27880
28435
|
}
|
|
27881
28436
|
return {
|
|
27882
28437
|
code: 0,
|
|
@@ -27911,7 +28466,7 @@ async function handlePlan(projectRoot, itemId) {
|
|
|
27911
28466
|
}
|
|
27912
28467
|
const existingState = session.state;
|
|
27913
28468
|
if (item.status !== "PLANNED" && !canTransition(item.status, "PLANNED")) {
|
|
27914
|
-
return
|
|
28469
|
+
return fail2("openspec plan", [
|
|
27915
28470
|
`Illegal backlog transition for ${item.id}: ${item.status} → PLANNED.`
|
|
27916
28471
|
]);
|
|
27917
28472
|
}
|
|
@@ -27938,11 +28493,11 @@ async function handlePlan(projectRoot, itemId) {
|
|
|
27938
28493
|
};
|
|
27939
28494
|
const written = await persistState(projectRoot, newState);
|
|
27940
28495
|
if (!written.ok) {
|
|
27941
|
-
return
|
|
28496
|
+
return fail2("openspec plan", [written.error]);
|
|
27942
28497
|
}
|
|
27943
28498
|
const transition = applyBacklogTransition(session.raw, item.id, item.status, "PLANNED", item.progress);
|
|
27944
28499
|
if (!transition.success) {
|
|
27945
|
-
return
|
|
28500
|
+
return fail2("openspec plan", [transition.error.message]);
|
|
27946
28501
|
}
|
|
27947
28502
|
await persistBacklog(projectRoot, transition.data);
|
|
27948
28503
|
return {
|
|
@@ -27963,7 +28518,7 @@ async function handleAnalyze(projectRoot, itemId) {
|
|
|
27963
28518
|
const command = "openspec analyze";
|
|
27964
28519
|
const sessionResult = await loadBacklogSession(projectRoot);
|
|
27965
28520
|
if (!sessionResult.success)
|
|
27966
|
-
return
|
|
28521
|
+
return fail2(command, [sessionResult.error.message]);
|
|
27967
28522
|
const session = sessionResult.data;
|
|
27968
28523
|
const resolved = resolveActiveChange(session.state, command, itemId);
|
|
27969
28524
|
if (!resolved.ok)
|
|
@@ -28002,7 +28557,7 @@ async function handleSync(projectRoot, itemId) {
|
|
|
28002
28557
|
return resolved.response;
|
|
28003
28558
|
const synced = await syncChangeSpecs(projectRoot, resolved.changePath);
|
|
28004
28559
|
if (!synced.success) {
|
|
28005
|
-
return
|
|
28560
|
+
return fail2(command, [
|
|
28006
28561
|
`Spec sync failed for ${resolved.targetId}: ${synced.errors.join("; ")}`
|
|
28007
28562
|
]);
|
|
28008
28563
|
}
|
|
@@ -28028,7 +28583,7 @@ async function handleVerify(projectRoot, itemId) {
|
|
|
28028
28583
|
const command = "openspec verify";
|
|
28029
28584
|
const sessionResult = await loadBacklogSession(projectRoot);
|
|
28030
28585
|
if (!sessionResult.success)
|
|
28031
|
-
return
|
|
28586
|
+
return fail2(command, [sessionResult.error.message]);
|
|
28032
28587
|
const session = sessionResult.data;
|
|
28033
28588
|
const resolved = resolveActiveChange(session.state, command, itemId);
|
|
28034
28589
|
if (!resolved.ok)
|
|
@@ -28092,7 +28647,7 @@ async function handleVerify(projectRoot, itemId) {
|
|
|
28092
28647
|
dimension: "Coherence"
|
|
28093
28648
|
});
|
|
28094
28649
|
}
|
|
28095
|
-
const archiveReady = !issues.some((i) => i.severity === "CRITICAL") && cards.length > 0 && doneCount === cards.length && missingArtifacts(progress.artifacts).length === 0 && scorecardOk;
|
|
28650
|
+
const archiveReady = !issues.some((i) => i.severity === "CRITICAL") && cards.length > 0 && doneCount === cards.length && missingArtifacts(progress.artifacts).length === 0 && progress.checkboxes.remaining === 0 && scorecardOk;
|
|
28096
28651
|
return {
|
|
28097
28652
|
code: 0,
|
|
28098
28653
|
data: {
|
|
@@ -28163,44 +28718,38 @@ async function handleNext2(projectRoot) {
|
|
|
28163
28718
|
}
|
|
28164
28719
|
const next = getNextTaskCard(stateResult.data);
|
|
28165
28720
|
if (!next) {
|
|
28721
|
+
const doing = stateResult.data.taskCards.find((c) => c.status === "doing");
|
|
28166
28722
|
return {
|
|
28167
28723
|
code: 0,
|
|
28168
28724
|
data: {
|
|
28169
28725
|
success: true,
|
|
28170
28726
|
command: "openspec next",
|
|
28171
28727
|
taskCard: null,
|
|
28172
|
-
|
|
28728
|
+
...doing ? { inProgressCardId: doing.id } : {},
|
|
28729
|
+
message: doing ? `${doing.id} is in progress. Finish it with: openspec done ${doing.id}` : "No pending task cards. Run openspec plan first."
|
|
28173
28730
|
}
|
|
28174
28731
|
};
|
|
28175
28732
|
}
|
|
28176
|
-
let loop = undefined;
|
|
28177
|
-
if (shouldRunAgentLoop(undefined, next.agent, next.phase)) {
|
|
28178
|
-
loop = await runLoopForProject(projectRoot, {
|
|
28179
|
-
taskTitle: next.title,
|
|
28180
|
-
originalTask: next.prompt
|
|
28181
|
-
});
|
|
28182
|
-
}
|
|
28183
28733
|
return {
|
|
28184
|
-
code:
|
|
28734
|
+
code: 0,
|
|
28185
28735
|
data: {
|
|
28186
|
-
success:
|
|
28736
|
+
success: true,
|
|
28187
28737
|
command: "openspec next",
|
|
28188
|
-
taskCard: next
|
|
28189
|
-
...loop ? { loop } : {}
|
|
28738
|
+
taskCard: next
|
|
28190
28739
|
}
|
|
28191
28740
|
};
|
|
28192
28741
|
}
|
|
28193
28742
|
async function loadStateOrFail(projectRoot, command) {
|
|
28194
28743
|
const stateResult = await loadOpenspecState(projectRoot);
|
|
28195
28744
|
if (!stateResult.success) {
|
|
28196
|
-
return { ok: false, response:
|
|
28745
|
+
return { ok: false, response: fail2(command, [stateResult.error.message]) };
|
|
28197
28746
|
}
|
|
28198
28747
|
return { ok: true, state: stateResult.data };
|
|
28199
28748
|
}
|
|
28200
28749
|
function findItemOrFail(session, itemId, command) {
|
|
28201
28750
|
const item = session.doc.items.find((i) => i.id === itemId) ?? session.doc.archive.find((i) => i.id === itemId);
|
|
28202
28751
|
if (!item) {
|
|
28203
|
-
return { ok: false, response:
|
|
28752
|
+
return { ok: false, response: fail2(command, [`Backlog item ${itemId} not found`]) };
|
|
28204
28753
|
}
|
|
28205
28754
|
return {
|
|
28206
28755
|
ok: true,
|
|
@@ -28211,32 +28760,45 @@ function findItemOrFail(session, itemId, command) {
|
|
|
28211
28760
|
async function handleStart(projectRoot, cardId) {
|
|
28212
28761
|
const command = "openspec start";
|
|
28213
28762
|
if (!cardId) {
|
|
28214
|
-
return
|
|
28763
|
+
return fail2(command, ["Missing card id. Usage: openspec start <cardId>"]);
|
|
28215
28764
|
}
|
|
28216
28765
|
const sessionResult = await loadBacklogSession(projectRoot);
|
|
28217
28766
|
if (!sessionResult.success)
|
|
28218
|
-
return
|
|
28767
|
+
return fail2(command, [sessionResult.error.message]);
|
|
28219
28768
|
const session = sessionResult.data;
|
|
28220
28769
|
const card = findCard(session.state, cardId);
|
|
28221
28770
|
if (!card) {
|
|
28222
|
-
return
|
|
28771
|
+
return fail2(command, [`Task card ${cardId} not found`]);
|
|
28223
28772
|
}
|
|
28224
28773
|
if (card.status !== "pending" && card.status !== "doing") {
|
|
28225
|
-
return
|
|
28774
|
+
return fail2(command, [`Card ${cardId} cannot start from status ${card.status}`]);
|
|
28226
28775
|
}
|
|
28227
28776
|
const itemLoaded = findItemOrFail(session, card.backlogId, command);
|
|
28228
28777
|
if (!itemLoaded.ok)
|
|
28229
28778
|
return itemLoaded.response;
|
|
28230
28779
|
let state = session.state;
|
|
28231
|
-
|
|
28780
|
+
let baseWarning;
|
|
28781
|
+
if (!state.itemBaseCommits?.[card.backlogId]) {
|
|
28782
|
+
try {
|
|
28783
|
+
const base = execFileSync2("git", ["rev-parse", "--verify", "HEAD"], {
|
|
28784
|
+
cwd: projectRoot,
|
|
28785
|
+
encoding: "utf8",
|
|
28786
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
28787
|
+
}).trim();
|
|
28788
|
+
state = { ...state, itemBaseCommits: { ...state.itemBaseCommits, [card.backlogId]: base } };
|
|
28789
|
+
} catch {
|
|
28790
|
+
baseWarning = "Item base unavailable: could not resolve git HEAD.";
|
|
28791
|
+
}
|
|
28792
|
+
}
|
|
28793
|
+
if (card.status === "pending" || state !== session.state) {
|
|
28232
28794
|
state = setTaskCardStatus(state, cardId, "doing");
|
|
28233
28795
|
const written = await persistState(projectRoot, state);
|
|
28234
28796
|
if (!written.ok)
|
|
28235
|
-
return
|
|
28797
|
+
return fail2(command, [written.error]);
|
|
28236
28798
|
}
|
|
28237
28799
|
const transition = await transitionItem(projectRoot, itemLoaded.item, "IN_PROGRESS", itemLoaded.item.progress, session.raw);
|
|
28238
28800
|
if (!transition.ok)
|
|
28239
|
-
return
|
|
28801
|
+
return fail2(command, [transition.error]);
|
|
28240
28802
|
return {
|
|
28241
28803
|
code: 0,
|
|
28242
28804
|
data: {
|
|
@@ -28245,22 +28807,23 @@ async function handleStart(projectRoot, cardId) {
|
|
|
28245
28807
|
cardId,
|
|
28246
28808
|
cardStatus: "doing",
|
|
28247
28809
|
itemId: itemLoaded.item.id,
|
|
28248
|
-
itemStatus: "IN_PROGRESS"
|
|
28810
|
+
itemStatus: "IN_PROGRESS",
|
|
28811
|
+
...baseWarning ? { warnings: [baseWarning] } : {}
|
|
28249
28812
|
}
|
|
28250
28813
|
};
|
|
28251
28814
|
}
|
|
28252
28815
|
async function handleDone(projectRoot, cardId) {
|
|
28253
28816
|
const command = "openspec done";
|
|
28254
28817
|
if (!cardId) {
|
|
28255
|
-
return
|
|
28818
|
+
return fail2(command, ["Missing card id. Usage: openspec done <cardId>"]);
|
|
28256
28819
|
}
|
|
28257
28820
|
const sessionResult = await loadBacklogSession(projectRoot);
|
|
28258
28821
|
if (!sessionResult.success)
|
|
28259
|
-
return
|
|
28822
|
+
return fail2(command, [sessionResult.error.message]);
|
|
28260
28823
|
const session = sessionResult.data;
|
|
28261
28824
|
const card = findCard(session.state, cardId);
|
|
28262
28825
|
if (!card) {
|
|
28263
|
-
return
|
|
28826
|
+
return fail2(command, [`Task card ${cardId} not found`]);
|
|
28264
28827
|
}
|
|
28265
28828
|
if (card.status === "done") {
|
|
28266
28829
|
return {
|
|
@@ -28269,7 +28832,7 @@ async function handleDone(projectRoot, cardId) {
|
|
|
28269
28832
|
};
|
|
28270
28833
|
}
|
|
28271
28834
|
if (card.status !== "doing") {
|
|
28272
|
-
return
|
|
28835
|
+
return fail2(command, [`Card ${cardId} must be doing before done (got ${card.status})`]);
|
|
28273
28836
|
}
|
|
28274
28837
|
const itemLoaded = findItemOrFail(session, card.backlogId, command);
|
|
28275
28838
|
if (!itemLoaded.ok)
|
|
@@ -28277,11 +28840,13 @@ async function handleDone(projectRoot, cardId) {
|
|
|
28277
28840
|
const tddRequired = session.doc.global.tddRequired;
|
|
28278
28841
|
if (tddRequired && (card.phase === "test" || card.phase === "implement")) {
|
|
28279
28842
|
const expectedPhase = card.phase === "test" ? "red" : "green";
|
|
28280
|
-
const
|
|
28281
|
-
if (
|
|
28282
|
-
|
|
28283
|
-
|
|
28284
|
-
|
|
28843
|
+
const message = `Card ${cardId} (${card.phase}) requires current ${expectedPhase.toUpperCase()} verification-runner TDD evidence. Run: tdd capture --task ${cardId} --phase ${expectedPhase} --command "<test command>", then openspec done.`;
|
|
28844
|
+
if (card.phase === "test") {
|
|
28845
|
+
const recorded = await recordRedValidation(projectRoot, cardId);
|
|
28846
|
+
if (!recorded.success)
|
|
28847
|
+
return fail2(command, [`${message} ${recorded.error.message}`]);
|
|
28848
|
+
} else if (!await hasTddRunnerEvidence(projectRoot, cardId, expectedPhase)) {
|
|
28849
|
+
return fail2(command, [message]);
|
|
28285
28850
|
}
|
|
28286
28851
|
}
|
|
28287
28852
|
const state = setTaskCardStatus(session.state, cardId, "done");
|
|
@@ -28291,18 +28856,14 @@ async function handleDone(projectRoot, cardId) {
|
|
|
28291
28856
|
const allDone = cards.length > 0 && doneCount === cards.length;
|
|
28292
28857
|
const written = await persistState(projectRoot, state);
|
|
28293
28858
|
if (!written.ok)
|
|
28294
|
-
return
|
|
28859
|
+
return fail2(command, [written.error]);
|
|
28295
28860
|
const changePath = state.changePaths[card.backlogId];
|
|
28296
|
-
if (changePath)
|
|
28297
|
-
await
|
|
28298
|
-
tddRequired,
|
|
28299
|
-
acceptanceCriteria: itemLoaded.item.acceptanceCriteria
|
|
28300
|
-
});
|
|
28301
|
-
}
|
|
28861
|
+
if (changePath)
|
|
28862
|
+
await syncTaskCardCheckbox(projectRoot, changePath, cardId, true);
|
|
28302
28863
|
const nextStatus = allDone ? "REVIEW" : "IN_PROGRESS";
|
|
28303
28864
|
const transition = await transitionItem(projectRoot, itemLoaded.item, nextStatus, progress, session.raw);
|
|
28304
28865
|
if (!transition.ok)
|
|
28305
|
-
return
|
|
28866
|
+
return fail2(command, [transition.error]);
|
|
28306
28867
|
return {
|
|
28307
28868
|
code: 0,
|
|
28308
28869
|
data: {
|
|
@@ -28320,18 +28881,18 @@ async function handleDone(projectRoot, cardId) {
|
|
|
28320
28881
|
async function handleBlock(projectRoot, cardId, reason) {
|
|
28321
28882
|
const command = "openspec block";
|
|
28322
28883
|
if (!cardId) {
|
|
28323
|
-
return
|
|
28884
|
+
return fail2(command, ["Missing card id. Usage: openspec block <cardId> --reason <text>"]);
|
|
28324
28885
|
}
|
|
28325
28886
|
if (!reason || !reason.trim()) {
|
|
28326
|
-
return
|
|
28887
|
+
return fail2(command, ["--reason is required"]);
|
|
28327
28888
|
}
|
|
28328
28889
|
const sessionResult = await loadBacklogSession(projectRoot);
|
|
28329
28890
|
if (!sessionResult.success)
|
|
28330
|
-
return
|
|
28891
|
+
return fail2(command, [sessionResult.error.message]);
|
|
28331
28892
|
const session = sessionResult.data;
|
|
28332
28893
|
const card = findCard(session.state, cardId);
|
|
28333
28894
|
if (!card) {
|
|
28334
|
-
return
|
|
28895
|
+
return fail2(command, [`Task card ${cardId} not found`]);
|
|
28335
28896
|
}
|
|
28336
28897
|
const itemLoaded = findItemOrFail(session, card.backlogId, command);
|
|
28337
28898
|
if (!itemLoaded.ok)
|
|
@@ -28339,10 +28900,10 @@ async function handleBlock(projectRoot, cardId, reason) {
|
|
|
28339
28900
|
const state = setTaskCardStatus(session.state, cardId, "blocked");
|
|
28340
28901
|
const written = await persistState(projectRoot, state);
|
|
28341
28902
|
if (!written.ok)
|
|
28342
|
-
return
|
|
28903
|
+
return fail2(command, [written.error]);
|
|
28343
28904
|
const transition = await transitionItem(projectRoot, itemLoaded.item, "BLOCKED", undefined, session.raw);
|
|
28344
28905
|
if (!transition.ok)
|
|
28345
|
-
return
|
|
28906
|
+
return fail2(command, [transition.error]);
|
|
28346
28907
|
return {
|
|
28347
28908
|
code: 0,
|
|
28348
28909
|
data: {
|
|
@@ -28359,41 +28920,37 @@ async function handleBlock(projectRoot, cardId, reason) {
|
|
|
28359
28920
|
async function handleUnblock(projectRoot, cardId) {
|
|
28360
28921
|
const command = "openspec unblock";
|
|
28361
28922
|
if (!cardId) {
|
|
28362
|
-
return
|
|
28923
|
+
return fail2(command, ["Missing card id. Usage: openspec unblock <cardId>"]);
|
|
28363
28924
|
}
|
|
28364
28925
|
const sessionResult = await loadBacklogSession(projectRoot);
|
|
28365
28926
|
if (!sessionResult.success)
|
|
28366
|
-
return
|
|
28927
|
+
return fail2(command, [sessionResult.error.message]);
|
|
28367
28928
|
const session = sessionResult.data;
|
|
28368
28929
|
const card = findCard(session.state, cardId);
|
|
28369
28930
|
if (!card) {
|
|
28370
|
-
return
|
|
28931
|
+
return fail2(command, [`Task card ${cardId} not found`]);
|
|
28371
28932
|
}
|
|
28372
28933
|
if (card.status !== "blocked") {
|
|
28373
|
-
return
|
|
28934
|
+
return fail2(command, [`Card ${cardId} must be blocked before unblock (got ${card.status})`]);
|
|
28374
28935
|
}
|
|
28375
28936
|
const itemLoaded = findItemOrFail(session, card.backlogId, command);
|
|
28376
28937
|
if (!itemLoaded.ok)
|
|
28377
28938
|
return itemLoaded.response;
|
|
28378
28939
|
if (itemLoaded.item.status !== "BLOCKED") {
|
|
28379
|
-
return
|
|
28940
|
+
return fail2(command, [
|
|
28380
28941
|
`Backlog item ${itemLoaded.item.id} must be BLOCKED before unblock (got ${itemLoaded.item.status})`
|
|
28381
28942
|
]);
|
|
28382
28943
|
}
|
|
28383
28944
|
const state = setTaskCardStatus(session.state, cardId, "pending");
|
|
28384
28945
|
const written = await persistState(projectRoot, state);
|
|
28385
28946
|
if (!written.ok)
|
|
28386
|
-
return
|
|
28947
|
+
return fail2(command, [written.error]);
|
|
28387
28948
|
const changePath = state.changePaths[card.backlogId];
|
|
28388
|
-
if (changePath)
|
|
28389
|
-
await
|
|
28390
|
-
tddRequired: session.doc.global.tddRequired,
|
|
28391
|
-
acceptanceCriteria: itemLoaded.item.acceptanceCriteria
|
|
28392
|
-
});
|
|
28393
|
-
}
|
|
28949
|
+
if (changePath)
|
|
28950
|
+
await syncTaskCardCheckbox(projectRoot, changePath, cardId, false);
|
|
28394
28951
|
const transition = await transitionItem(projectRoot, itemLoaded.item, "READY", undefined, session.raw);
|
|
28395
28952
|
if (!transition.ok)
|
|
28396
|
-
return
|
|
28953
|
+
return fail2(command, [transition.error]);
|
|
28397
28954
|
return {
|
|
28398
28955
|
code: 0,
|
|
28399
28956
|
data: {
|
|
@@ -28407,38 +28964,38 @@ async function handleUnblock(projectRoot, cardId) {
|
|
|
28407
28964
|
}
|
|
28408
28965
|
};
|
|
28409
28966
|
}
|
|
28410
|
-
async function handleArchive(projectRoot, itemId) {
|
|
28967
|
+
async function handleArchive(projectRoot, itemId, allowUnchecked = false) {
|
|
28411
28968
|
const command = "openspec archive";
|
|
28412
28969
|
if (!itemId) {
|
|
28413
|
-
return
|
|
28970
|
+
return fail2(command, ["Missing item id. Usage: openspec archive <itemId>"]);
|
|
28414
28971
|
}
|
|
28415
28972
|
const sessionResult = await loadBacklogSession(projectRoot);
|
|
28416
28973
|
if (!sessionResult.success)
|
|
28417
|
-
return
|
|
28974
|
+
return fail2(command, [sessionResult.error.message]);
|
|
28418
28975
|
const session = sessionResult.data;
|
|
28419
28976
|
const itemLoaded = findItemOrFail(session, itemId, command);
|
|
28420
28977
|
if (!itemLoaded.ok)
|
|
28421
28978
|
return itemLoaded.response;
|
|
28422
28979
|
const cards = itemCards(session.state, itemId);
|
|
28423
28980
|
if (cards.length === 0) {
|
|
28424
|
-
return
|
|
28981
|
+
return fail2(command, [`No task cards found for ${itemId}. Run openspec plan first.`]);
|
|
28425
28982
|
}
|
|
28426
28983
|
const unfinished = cards.filter((c) => c.status !== "done");
|
|
28427
28984
|
if (unfinished.length > 0) {
|
|
28428
|
-
return
|
|
28985
|
+
return fail2(command, [
|
|
28429
28986
|
`Cannot archive ${itemId}: ${unfinished.length} card(s) are not done (${unfinished.map((c) => c.id).join(", ")})`
|
|
28430
28987
|
]);
|
|
28431
28988
|
}
|
|
28432
28989
|
if (itemLoaded.reviewRequired) {
|
|
28433
28990
|
const reviewCard = cards.find((c) => c.phase === "review");
|
|
28434
28991
|
if (!reviewCard || reviewCard.status !== "done") {
|
|
28435
|
-
return
|
|
28992
|
+
return fail2(command, [
|
|
28436
28993
|
`Cannot archive ${itemId}: global.reviewRequired needs the review phase card done`
|
|
28437
28994
|
]);
|
|
28438
28995
|
}
|
|
28439
28996
|
const passed = await hasPassingScorecard(projectRoot, itemId);
|
|
28440
28997
|
if (!passed) {
|
|
28441
|
-
return
|
|
28998
|
+
return fail2(command, [
|
|
28442
28999
|
`Cannot archive ${itemId}: global.reviewRequired needs a PASS scorecard for this backlog id`
|
|
28443
29000
|
]);
|
|
28444
29001
|
}
|
|
@@ -28450,28 +29007,34 @@ async function handleArchive(projectRoot, itemId) {
|
|
|
28450
29007
|
const progress = await readArtifactProgress(projectRoot, changePath);
|
|
28451
29008
|
const missing = missingArtifacts(progress.artifacts);
|
|
28452
29009
|
if (missing.length > 0) {
|
|
28453
|
-
return
|
|
29010
|
+
return fail2(command, [
|
|
28454
29011
|
`Cannot archive ${itemId}: change folder is missing ${missing.join(", ")}. Re-run openspec plan ${itemId} or restore them.`
|
|
28455
29012
|
]);
|
|
28456
29013
|
}
|
|
28457
29014
|
const { report } = await collectAnalyzeReport(projectRoot, session, itemId, changePath);
|
|
28458
29015
|
const critical = report.findings.filter((f) => f.severity === "CRITICAL");
|
|
28459
29016
|
if (critical.length > 0) {
|
|
28460
|
-
return
|
|
29017
|
+
return fail2(command, [
|
|
28461
29018
|
`Cannot archive ${itemId}: analyze reports ${critical.length} CRITICAL finding(s): ${critical.map((f) => f.code).join(", ")}. Resolve them first.`
|
|
28462
29019
|
]);
|
|
28463
29020
|
}
|
|
28464
29021
|
if (progress.checkboxes.remaining > 0) {
|
|
28465
|
-
|
|
29022
|
+
const unchecked = `${progress.checkboxes.remaining} of ${progress.checkboxes.total} tasks.md checkboxes are unchecked (only [x]/[X] counts as done)`;
|
|
29023
|
+
if (!allowUnchecked) {
|
|
29024
|
+
return fail2(command, [
|
|
29025
|
+
`Cannot archive ${itemId}: ${unchecked}. Tick them as the work completes, or pass --allow-unchecked to archive anyway.`
|
|
29026
|
+
]);
|
|
29027
|
+
}
|
|
29028
|
+
warnings.push(`${unchecked}; archived with --allow-unchecked.`);
|
|
28466
29029
|
}
|
|
28467
29030
|
const synced = await syncChangeSpecs(projectRoot, changePath);
|
|
28468
29031
|
if (!synced.success) {
|
|
28469
|
-
return
|
|
29032
|
+
return fail2(command, [`Cannot archive ${itemId}: spec sync failed: ${synced.errors.join("; ")}`]);
|
|
28470
29033
|
}
|
|
28471
29034
|
try {
|
|
28472
29035
|
archivedPath = await archiveChangeFolder(projectRoot, changePath);
|
|
28473
29036
|
} catch (e) {
|
|
28474
|
-
return
|
|
29037
|
+
return fail2(command, [
|
|
28475
29038
|
`Backlog archived but change folder move failed: ${e instanceof Error ? e.message : String(e)}`
|
|
28476
29039
|
]);
|
|
28477
29040
|
}
|
|
@@ -28480,7 +29043,7 @@ async function handleArchive(projectRoot, itemId) {
|
|
|
28480
29043
|
if (itemLoaded.item.status !== "DONE") {
|
|
28481
29044
|
const toDone = await transitionItem(projectRoot, itemLoaded.item, "DONE", 100, content);
|
|
28482
29045
|
if (!toDone.ok)
|
|
28483
|
-
return
|
|
29046
|
+
return fail2(command, [toDone.error]);
|
|
28484
29047
|
content = toDone.content;
|
|
28485
29048
|
}
|
|
28486
29049
|
const archived = archiveItemInMarkdown(content, itemId);
|
|
@@ -28492,7 +29055,7 @@ async function handleArchive(projectRoot, itemId) {
|
|
|
28492
29055
|
};
|
|
28493
29056
|
const written = await persistState(projectRoot, nextState);
|
|
28494
29057
|
if (!written.ok)
|
|
28495
|
-
return
|
|
29058
|
+
return fail2(command, [written.error]);
|
|
28496
29059
|
return {
|
|
28497
29060
|
code: 0,
|
|
28498
29061
|
data: {
|
|
@@ -28519,7 +29082,6 @@ var init_openspec_command = __esm(() => {
|
|
|
28519
29082
|
init_outcome_store();
|
|
28520
29083
|
init_openspec_state();
|
|
28521
29084
|
init_backlog_parser();
|
|
28522
|
-
init_loop_engine();
|
|
28523
29085
|
});
|
|
28524
29086
|
|
|
28525
29087
|
// src/core/ccep/context-assembly.ts
|
|
@@ -28570,25 +29132,25 @@ var init_handoff_envelope = __esm(() => {
|
|
|
28570
29132
|
});
|
|
28571
29133
|
|
|
28572
29134
|
// src/core/delivery/delivery-ledger.ts
|
|
28573
|
-
import { createHash as
|
|
28574
|
-
import { mkdir as
|
|
28575
|
-
import { resolve as
|
|
29135
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
29136
|
+
import { mkdir as mkdir25, readFile as readFile43, writeFile as writeFile23 } from "node:fs/promises";
|
|
29137
|
+
import { resolve as resolve39, sep as sep9 } from "node:path";
|
|
28576
29138
|
function ledgerPath(projectRoot, id) {
|
|
28577
29139
|
if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(id))
|
|
28578
29140
|
throw new Error("Invalid delivery ledger id");
|
|
28579
|
-
return
|
|
29141
|
+
return resolve39(projectRoot, DELIVERY_DIR, `${id}.md`);
|
|
28580
29142
|
}
|
|
28581
29143
|
async function fingerprintWorkspace(projectRoot, paths) {
|
|
28582
|
-
const root =
|
|
29144
|
+
const root = resolve39(projectRoot);
|
|
28583
29145
|
const fingerprints = {};
|
|
28584
29146
|
for (const path of paths) {
|
|
28585
|
-
const candidate =
|
|
29147
|
+
const candidate = resolve39(root, path);
|
|
28586
29148
|
if (candidate !== root && !candidate.startsWith(`${root}${sep9}`)) {
|
|
28587
29149
|
fingerprints[path] = "outside-root";
|
|
28588
29150
|
continue;
|
|
28589
29151
|
}
|
|
28590
29152
|
try {
|
|
28591
|
-
fingerprints[path] =
|
|
29153
|
+
fingerprints[path] = createHash8("sha256").update(await readFile43(candidate)).digest("hex");
|
|
28592
29154
|
} catch {
|
|
28593
29155
|
fingerprints[path] = "missing";
|
|
28594
29156
|
}
|
|
@@ -28611,7 +29173,7 @@ function parseLedger(content) {
|
|
|
28611
29173
|
return DeliveryLedgerSchema.parse($parse(match[1]));
|
|
28612
29174
|
}
|
|
28613
29175
|
async function loadDeliveryLedger(projectRoot, id) {
|
|
28614
|
-
return parseLedger(await
|
|
29176
|
+
return parseLedger(await readFile43(ledgerPath(projectRoot, id), "utf-8"));
|
|
28615
29177
|
}
|
|
28616
29178
|
async function createDeliveryLedger(projectRoot, input) {
|
|
28617
29179
|
const request = DeliveryLedgerRequestSchema.parse(input);
|
|
@@ -28636,7 +29198,7 @@ async function createDeliveryLedger(projectRoot, input) {
|
|
|
28636
29198
|
createdAt: now,
|
|
28637
29199
|
updatedAt: now
|
|
28638
29200
|
});
|
|
28639
|
-
await
|
|
29201
|
+
await mkdir25(resolve39(projectRoot, DELIVERY_DIR), { recursive: true });
|
|
28640
29202
|
try {
|
|
28641
29203
|
await writeFile23(path, render(ledger), { encoding: "utf-8", flag: "wx" });
|
|
28642
29204
|
return { created: true, ledger };
|
|
@@ -28968,10 +29530,10 @@ __export(exports_hook_command, {
|
|
|
28968
29530
|
parseHookFormat: () => parseHookFormat,
|
|
28969
29531
|
readStdinText: () => readStdinText
|
|
28970
29532
|
});
|
|
28971
|
-
import { spawnSync } from "node:child_process";
|
|
29533
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
28972
29534
|
import { existsSync as existsSync8, readFileSync as readFileSync6 } from "node:fs";
|
|
28973
29535
|
import { createRequire as createRequire2 } from "node:module";
|
|
28974
|
-
import { dirname as
|
|
29536
|
+
import { dirname as dirname14, resolve as resolve40 } from "node:path";
|
|
28975
29537
|
function parseHookFormat(raw) {
|
|
28976
29538
|
return raw === "agy" || raw === "claude" || raw === "muse" ? raw : undefined;
|
|
28977
29539
|
}
|
|
@@ -29003,15 +29565,15 @@ function resolvePreToolInput(options, stdinText, format) {
|
|
|
29003
29565
|
};
|
|
29004
29566
|
}
|
|
29005
29567
|
async function sessionLines(projectRoot) {
|
|
29006
|
-
const backlogPath =
|
|
29007
|
-
const profilePath =
|
|
29568
|
+
const backlogPath = resolve40(projectRoot, "BACKLOG.md");
|
|
29569
|
+
const profilePath = resolve40(projectRoot, ".codeconductor", "evaluation", "execution-profile.yml");
|
|
29008
29570
|
return [
|
|
29009
29571
|
"[CodeConductor] Session start",
|
|
29010
29572
|
"Skills: openspec, backlog, evaluation, testing-tdd — invoke via /cc-* then CLI.",
|
|
29011
|
-
existsSync8(backlogPath) ? "BACKLOG.md present — run:
|
|
29012
|
-
existsSync8(profilePath) ? "Scorecard profile on disk — run:
|
|
29013
|
-
"Hooks:
|
|
29014
|
-
"Eval suites:
|
|
29573
|
+
existsSync8(backlogPath) ? "BACKLOG.md present — run: npx cc-codeconductor openspec status" : "No BACKLOG.md — author with /cc-backlog if you need an item queue.",
|
|
29574
|
+
existsSync8(profilePath) ? "Scorecard profile on disk — run: npx cc-codeconductor scorecard models" : "Scorecard: npx cc-codeconductor scorecard create --task <id> --from-diff",
|
|
29575
|
+
"Hooks: npx cc-codeconductor hook pre-tool | post-tool | session-start",
|
|
29576
|
+
"Eval suites: npx cc-codeconductor scorecard suite-run --suite workflow-gates"
|
|
29015
29577
|
];
|
|
29016
29578
|
}
|
|
29017
29579
|
async function hookCommand(options) {
|
|
@@ -29059,21 +29621,21 @@ async function hookCommand(options) {
|
|
|
29059
29621
|
function formatWrittenFile(filePath, projectRoot) {
|
|
29060
29622
|
if (!filePath)
|
|
29061
29623
|
return;
|
|
29062
|
-
filePath =
|
|
29624
|
+
filePath = resolve40(projectRoot, filePath);
|
|
29063
29625
|
if (!existsSync8(filePath))
|
|
29064
29626
|
return;
|
|
29065
29627
|
const prettier = /\.(ts|tsx|js|jsx|mjs|cjs|json|jsonc|md|mdx|css|scss|html|astro|ya?ml)$/i;
|
|
29066
29628
|
const eslint = /\.(ts|tsx|js|jsx|mjs|cjs)$/i;
|
|
29067
29629
|
const python = /\.py$/i;
|
|
29068
29630
|
const opts = { cwd: projectRoot, stdio: "ignore", windowsHide: true, timeout: 5000 };
|
|
29069
|
-
const require2 = createRequire2(
|
|
29631
|
+
const require2 = createRequire2(resolve40(projectRoot, "package.json"));
|
|
29070
29632
|
function runNodeTool(name, args) {
|
|
29071
29633
|
try {
|
|
29072
29634
|
const manifestPath = require2.resolve(`${name}/package.json`);
|
|
29073
29635
|
const manifest = JSON.parse(readFileSync6(manifestPath, "utf8"));
|
|
29074
29636
|
const bin = typeof manifest.bin === "string" ? manifest.bin : manifest.bin?.[name];
|
|
29075
29637
|
if (typeof bin === "string")
|
|
29076
|
-
|
|
29638
|
+
spawnSync2(process.execPath, [resolve40(dirname14(manifestPath), bin), ...args], opts);
|
|
29077
29639
|
} catch {}
|
|
29078
29640
|
}
|
|
29079
29641
|
if (prettier.test(filePath)) {
|
|
@@ -29083,8 +29645,8 @@ function formatWrittenFile(filePath, projectRoot) {
|
|
|
29083
29645
|
runNodeTool("eslint", ["--fix", filePath]);
|
|
29084
29646
|
}
|
|
29085
29647
|
if (python.test(filePath)) {
|
|
29086
|
-
|
|
29087
|
-
|
|
29648
|
+
spawnSync2("ruff", ["format", filePath], opts);
|
|
29649
|
+
spawnSync2("ruff", ["check", "--fix", filePath], opts);
|
|
29088
29650
|
}
|
|
29089
29651
|
}
|
|
29090
29652
|
var init_hook_command = __esm(() => {
|
|
@@ -29114,35 +29676,41 @@ function createDefaultCriteria(overrides = {}) {
|
|
|
29114
29676
|
id: def.id,
|
|
29115
29677
|
label: def.label,
|
|
29116
29678
|
weight: def.weight,
|
|
29117
|
-
score: o
|
|
29679
|
+
score: o ? o.score : 2,
|
|
29118
29680
|
notes: o?.notes,
|
|
29119
|
-
autoSuggested: o?.autoSuggested
|
|
29681
|
+
autoSuggested: o?.autoSuggested,
|
|
29682
|
+
unmeasured: o?.unmeasured
|
|
29120
29683
|
};
|
|
29121
29684
|
});
|
|
29122
29685
|
}
|
|
29123
29686
|
function computeWeightedScore(criteria) {
|
|
29124
29687
|
let total = 0;
|
|
29125
29688
|
for (const c of criteria) {
|
|
29126
|
-
total += c.score * c.weight;
|
|
29689
|
+
total += (c.score ?? 0) * c.weight;
|
|
29127
29690
|
}
|
|
29128
29691
|
return Math.round(total * 1000) / 1000;
|
|
29129
29692
|
}
|
|
29130
29693
|
function computeVerdict(criteria, weightedScore) {
|
|
29131
29694
|
const byId = new Map(criteria.map((c) => [c.id, c.score]));
|
|
29132
|
-
const acceptance = byId.get("acceptance")
|
|
29133
|
-
const minimalDiff = byId.get("minimal_diff")
|
|
29134
|
-
const regressions = byId.get("regressions")
|
|
29695
|
+
const acceptance = byId.has("acceptance") ? byId.get("acceptance") : 0;
|
|
29696
|
+
const minimalDiff = byId.has("minimal_diff") ? byId.get("minimal_diff") : 0;
|
|
29697
|
+
const regressions = byId.has("regressions") ? byId.get("regressions") : 0;
|
|
29135
29698
|
if (acceptance === 0 || minimalDiff === 0 || regressions === 0) {
|
|
29136
29699
|
return "REJECT";
|
|
29137
29700
|
}
|
|
29138
29701
|
if (weightedScore < 1.5) {
|
|
29139
29702
|
return "REJECT";
|
|
29140
29703
|
}
|
|
29704
|
+
if (pendingCriteria(criteria).length > 0)
|
|
29705
|
+
return "REVISE";
|
|
29141
29706
|
if (weightedScore >= PASS_THRESHOLD && !criteria.some((c) => c.score === 0)) {
|
|
29142
29707
|
return "PASS";
|
|
29143
29708
|
}
|
|
29144
29709
|
return "REVISE";
|
|
29145
29710
|
}
|
|
29711
|
+
function pendingCriteria(criteria) {
|
|
29712
|
+
return criteria.filter((c) => c.score === null || c.unmeasured && (c.autoSuggested !== false || !c.notes?.trim())).map((c) => c.id);
|
|
29713
|
+
}
|
|
29146
29714
|
function buildScorecardRecord(params) {
|
|
29147
29715
|
const weightedScore = computeWeightedScore(params.criteria);
|
|
29148
29716
|
const verdict = computeVerdict(params.criteria, weightedScore);
|
|
@@ -29487,7 +30055,7 @@ function ccGainToScorecardImpact(result) {
|
|
|
29487
30055
|
}
|
|
29488
30056
|
|
|
29489
30057
|
// src/core/evaluation/scorecard-signals.ts
|
|
29490
|
-
import { execFileSync as
|
|
30058
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
29491
30059
|
function parseScopeFiles(scope) {
|
|
29492
30060
|
return scope.split(/[,;]/).map((entry) => entry.trim().replace(/[.;:]$/, "").replace(/^`|`$/g, "")).filter(Boolean);
|
|
29493
30061
|
}
|
|
@@ -29497,6 +30065,18 @@ function isGeneratedBuildCache(path) {
|
|
|
29497
30065
|
function collectScorecardSignals(projectRoot, scopeFiles, extra) {
|
|
29498
30066
|
const findings = [];
|
|
29499
30067
|
const overrides = {};
|
|
30068
|
+
overrides.tests = {
|
|
30069
|
+
score: null,
|
|
30070
|
+
unmeasured: true,
|
|
30071
|
+
autoSuggested: true,
|
|
30072
|
+
notes: "Unmeasured: no verification-runner evidence supplied"
|
|
30073
|
+
};
|
|
30074
|
+
overrides.cc_gain = {
|
|
30075
|
+
score: null,
|
|
30076
|
+
unmeasured: true,
|
|
30077
|
+
autoSuggested: true,
|
|
30078
|
+
notes: "Unmeasured: no diff available for complexity audit"
|
|
30079
|
+
};
|
|
29500
30080
|
const scopeViolationCount = extra?.scopeViolationCount;
|
|
29501
30081
|
if (scopeViolationCount && scopeViolationCount > 0) {
|
|
29502
30082
|
overrides.minimal_diff = {
|
|
@@ -29517,13 +30097,21 @@ function collectScorecardSignals(projectRoot, scopeFiles, extra) {
|
|
|
29517
30097
|
}
|
|
29518
30098
|
let diff = "";
|
|
29519
30099
|
try {
|
|
29520
|
-
diff =
|
|
30100
|
+
diff = execFileSync3("git", ["diff", extra?.baseCommit ?? "HEAD", "--"], {
|
|
29521
30101
|
cwd: projectRoot,
|
|
29522
30102
|
encoding: "utf-8",
|
|
29523
30103
|
stdio: ["ignore", "pipe", "ignore"]
|
|
29524
30104
|
});
|
|
29525
30105
|
} catch {
|
|
29526
30106
|
findings.push("Could not read git diff; scope audit skipped.");
|
|
30107
|
+
if (!overrides.minimal_diff) {
|
|
30108
|
+
overrides.minimal_diff = {
|
|
30109
|
+
score: null,
|
|
30110
|
+
unmeasured: true,
|
|
30111
|
+
autoSuggested: true,
|
|
30112
|
+
notes: "Unmeasured: git diff unavailable"
|
|
30113
|
+
};
|
|
30114
|
+
}
|
|
29527
30115
|
return { criteriaOverrides: overrides, findings, scopeViolationCount, hashMismatch };
|
|
29528
30116
|
}
|
|
29529
30117
|
if (!diff.trim()) {
|
|
@@ -29599,8 +30187,14 @@ function applyAnalyzeSignals(hints, analyze) {
|
|
|
29599
30187
|
autoSuggested: true
|
|
29600
30188
|
};
|
|
29601
30189
|
findings.push("Tests auto-suggested 0: missing verification-runner evidence.");
|
|
30190
|
+
} else if (analyze.hasTddEvidence === true && !hints.hashMismatch) {
|
|
30191
|
+
criteriaOverrides.tests = {
|
|
30192
|
+
score: 2,
|
|
30193
|
+
notes: "Verification-runner RED/GREEN evidence verified",
|
|
30194
|
+
autoSuggested: true
|
|
30195
|
+
};
|
|
29602
30196
|
}
|
|
29603
|
-
return { criteriaOverrides, findings };
|
|
30197
|
+
return { ...hints, criteriaOverrides, findings };
|
|
29604
30198
|
}
|
|
29605
30199
|
function criteriaFromSignals(hints) {
|
|
29606
30200
|
return createDefaultCriteria(hints.criteriaOverrides);
|
|
@@ -29612,24 +30206,24 @@ var init_scorecard_signals = __esm(() => {
|
|
|
29612
30206
|
|
|
29613
30207
|
// src/core/evaluation/harness-experiment.ts
|
|
29614
30208
|
import { existsSync as existsSync9 } from "node:fs";
|
|
29615
|
-
import { cp, mkdir as
|
|
29616
|
-
import { dirname as
|
|
30209
|
+
import { cp, mkdir as mkdir26, readFile as readFile44, readdir as readdir13, writeFile as writeFile24 } from "node:fs/promises";
|
|
30210
|
+
import { dirname as dirname15, join as join30, resolve as resolve41 } from "node:path";
|
|
29617
30211
|
function experimentDir(projectRoot, experimentId) {
|
|
29618
|
-
return
|
|
30212
|
+
return resolve41(projectRoot, EVAL_DIR2, EXPERIMENTS_DIR, experimentId);
|
|
29619
30213
|
}
|
|
29620
30214
|
function experimentYamlPath(projectRoot, experimentId) {
|
|
29621
30215
|
return join30(experimentDir(projectRoot, experimentId), "experiment.yml");
|
|
29622
30216
|
}
|
|
29623
30217
|
async function loadHarnessSuite(projectRoot, suiteId, suitePath) {
|
|
29624
30218
|
const candidates = suitePath ? [suitePath] : [
|
|
29625
|
-
|
|
29626
|
-
|
|
30219
|
+
resolve41(projectRoot, "eval", "suites", suiteId, "suite.yml"),
|
|
30220
|
+
resolve41(projectRoot, EVAL_DIR2, "suites", suiteId, "suite.yml")
|
|
29627
30221
|
];
|
|
29628
30222
|
for (const path of candidates) {
|
|
29629
30223
|
if (!existsSync9(path))
|
|
29630
30224
|
continue;
|
|
29631
30225
|
try {
|
|
29632
|
-
const suite = HarnessSuiteSchema.parse($parse(await
|
|
30226
|
+
const suite = HarnessSuiteSchema.parse($parse(await readFile44(path, "utf-8")));
|
|
29633
30227
|
return ok({ ...suite, path });
|
|
29634
30228
|
} catch (e) {
|
|
29635
30229
|
return err(e instanceof Error ? e : new Error(String(e)));
|
|
@@ -29639,7 +30233,7 @@ async function loadHarnessSuite(projectRoot, suiteId, suitePath) {
|
|
|
29639
30233
|
}
|
|
29640
30234
|
async function loadExperiment(projectRoot, experimentId) {
|
|
29641
30235
|
try {
|
|
29642
|
-
const raw = await
|
|
30236
|
+
const raw = await readFile44(experimentYamlPath(projectRoot, experimentId), "utf-8");
|
|
29643
30237
|
return ok(HarnessExperimentSchema.parse($parse(raw)));
|
|
29644
30238
|
} catch (e) {
|
|
29645
30239
|
if (e.code === "ENOENT") {
|
|
@@ -29649,7 +30243,7 @@ async function loadExperiment(projectRoot, experimentId) {
|
|
|
29649
30243
|
}
|
|
29650
30244
|
}
|
|
29651
30245
|
async function listExperiments(projectRoot) {
|
|
29652
|
-
const root =
|
|
30246
|
+
const root = resolve41(projectRoot, EVAL_DIR2, EXPERIMENTS_DIR);
|
|
29653
30247
|
if (!existsSync9(root))
|
|
29654
30248
|
return [];
|
|
29655
30249
|
const ids = await readdir13(root);
|
|
@@ -29691,8 +30285,8 @@ function formatTaskCard(task, experimentId, variantId) {
|
|
|
29691
30285
|
"When done:",
|
|
29692
30286
|
"",
|
|
29693
30287
|
"```",
|
|
29694
|
-
`
|
|
29695
|
-
`
|
|
30288
|
+
`npx cc-codeconductor scorecard create --task ${task.id} --from-diff`,
|
|
30289
|
+
`npx cc-codeconductor scorecard record --task ${task.id} --verdict PASS|REVISE|REJECT --score <n> --experiment ${experimentId} --variant ${variantId} --suite-task ${task.id}`,
|
|
29696
30290
|
"```",
|
|
29697
30291
|
task.testCommand ? `
|
|
29698
30292
|
Fixture test command: \`${task.testCommand}\`
|
|
@@ -29716,7 +30310,7 @@ function formatExperimentMarkdown(experiment) {
|
|
|
29716
30310
|
"Compare with:",
|
|
29717
30311
|
"",
|
|
29718
30312
|
"```",
|
|
29719
|
-
`
|
|
30313
|
+
`npx cc-codeconductor scorecard ablation --experiment ${experiment.id}`,
|
|
29720
30314
|
"```",
|
|
29721
30315
|
""
|
|
29722
30316
|
].join(`
|
|
@@ -29728,8 +30322,8 @@ function generateExperimentId(suiteId, now = new Date) {
|
|
|
29728
30322
|
return `abl-${date}-${suiteId}-${rand}`;
|
|
29729
30323
|
}
|
|
29730
30324
|
async function copyFixture(suitePath, fixtureDir, dest) {
|
|
29731
|
-
const source = fixtureDir ?
|
|
29732
|
-
await
|
|
30325
|
+
const source = fixtureDir ? resolve41(dirname15(suitePath), fixtureDir) : join30(dirname15(suitePath), "fixture");
|
|
30326
|
+
await mkdir26(dest, { recursive: true });
|
|
29733
30327
|
if (existsSync9(source)) {
|
|
29734
30328
|
await cp(source, dest, { recursive: true });
|
|
29735
30329
|
}
|
|
@@ -29751,7 +30345,7 @@ async function startHarnessExperiment(projectRoot, options) {
|
|
|
29751
30345
|
suitePath: suite.data.path
|
|
29752
30346
|
};
|
|
29753
30347
|
const root = experimentDir(projectRoot, experimentId);
|
|
29754
|
-
await
|
|
30348
|
+
await mkdir26(root, { recursive: true });
|
|
29755
30349
|
await writeFile24(experimentYamlPath(projectRoot, experimentId), $stringify(experiment), "utf-8");
|
|
29756
30350
|
await writeFile24(join30(root, "EXPERIMENT.md"), formatExperimentMarkdown(experiment), "utf-8");
|
|
29757
30351
|
for (const task of suite.data.tasks) {
|
|
@@ -29801,9 +30395,9 @@ var init_harness_experiment = __esm(() => {
|
|
|
29801
30395
|
});
|
|
29802
30396
|
|
|
29803
30397
|
// src/core/evaluation/suite-run.ts
|
|
29804
|
-
import { spawnSync as
|
|
30398
|
+
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
29805
30399
|
import { existsSync as existsSync10 } from "node:fs";
|
|
29806
|
-
import { resolve as
|
|
30400
|
+
import { resolve as resolve42 } from "node:path";
|
|
29807
30401
|
async function runHarnessSuiteTasks(projectRoot, suiteId, suitePath) {
|
|
29808
30402
|
const suite = await loadHarnessSuite(projectRoot, suiteId, suitePath);
|
|
29809
30403
|
if (!suite.success) {
|
|
@@ -29863,9 +30457,9 @@ function runTaskCommand(projectRoot, task) {
|
|
|
29863
30457
|
if (parts.length === 0) {
|
|
29864
30458
|
return { ok: false, detail: "Empty testCommand" };
|
|
29865
30459
|
}
|
|
29866
|
-
const bin = parts[0] === "bun" && existsSync10(
|
|
30460
|
+
const bin = parts[0] === "bun" && existsSync10(resolve42(projectRoot, "src/cli/main.ts")) ? "bun" : parts[0];
|
|
29867
30461
|
const args = parts[0] === "bun" ? parts.slice(1) : parts.slice(1);
|
|
29868
|
-
const result =
|
|
30462
|
+
const result = spawnSync3(bin, args, {
|
|
29869
30463
|
cwd: projectRoot,
|
|
29870
30464
|
encoding: "utf8",
|
|
29871
30465
|
windowsHide: true,
|
|
@@ -29914,11 +30508,11 @@ var init_suite_run = __esm(() => {
|
|
|
29914
30508
|
});
|
|
29915
30509
|
|
|
29916
30510
|
// src/core/evaluation/execution-profile.ts
|
|
29917
|
-
import { readFile as
|
|
29918
|
-
import { resolve as
|
|
30511
|
+
import { readFile as readFile45 } from "node:fs/promises";
|
|
30512
|
+
import { resolve as resolve43 } from "node:path";
|
|
29919
30513
|
async function loadExecutionProfile(projectRoot, defaultTarget = "opencode") {
|
|
29920
30514
|
try {
|
|
29921
|
-
const content = await
|
|
30515
|
+
const content = await readFile45(resolve43(projectRoot, PROFILE_FILE), "utf-8");
|
|
29922
30516
|
const data = $parse(content);
|
|
29923
30517
|
return ExecutionProfileSchema.parse(data);
|
|
29924
30518
|
} catch {
|
|
@@ -29998,8 +30592,8 @@ var init_execution_profile = __esm(() => {
|
|
|
29998
30592
|
});
|
|
29999
30593
|
|
|
30000
30594
|
// src/core/evaluation/prompt-diff.ts
|
|
30001
|
-
import { readFile as
|
|
30002
|
-
import { join as join31, resolve as
|
|
30595
|
+
import { readFile as readFile46, readdir as readdir14 } from "node:fs/promises";
|
|
30596
|
+
import { join as join31, resolve as resolve44 } from "node:path";
|
|
30003
30597
|
function normalizeVersion(v) {
|
|
30004
30598
|
return v.startsWith("v") ? v : `v${v}`;
|
|
30005
30599
|
}
|
|
@@ -30048,7 +30642,7 @@ async function diffPromptVersions(fromVersion, toVersion, options = {}) {
|
|
|
30048
30642
|
const fromV = normalizeVersion(fromVersion);
|
|
30049
30643
|
const toV = normalizeVersion(toVersion);
|
|
30050
30644
|
const searchRoots = [
|
|
30051
|
-
|
|
30645
|
+
resolve44(options.projectRoot ?? PACKAGE_ROOT, ".agents", "prompts"),
|
|
30052
30646
|
join31(ROOT_PRESETS_DIR, target, "prompts"),
|
|
30053
30647
|
join31(ROOT_PRESETS_DIR, "opencode", "prompts")
|
|
30054
30648
|
];
|
|
@@ -30058,7 +30652,7 @@ async function diffPromptVersions(fromVersion, toVersion, options = {}) {
|
|
|
30058
30652
|
const f = join31(root, fromV);
|
|
30059
30653
|
const t = join31(root, toV);
|
|
30060
30654
|
try {
|
|
30061
|
-
await
|
|
30655
|
+
await readFile46(join31(f, "orchestrator.md"), "utf-8");
|
|
30062
30656
|
fromDir = f;
|
|
30063
30657
|
toDir = t;
|
|
30064
30658
|
break;
|
|
@@ -30069,7 +30663,7 @@ async function diffPromptVersions(fromVersion, toVersion, options = {}) {
|
|
|
30069
30663
|
toDir = join31(ROOT_PRESETS_DIR, "opencode", "prompts", toV);
|
|
30070
30664
|
} else {
|
|
30071
30665
|
try {
|
|
30072
|
-
await
|
|
30666
|
+
await readFile46(join31(toDir, "orchestrator.md"), "utf-8");
|
|
30073
30667
|
} catch {
|
|
30074
30668
|
toDir = join31(ROOT_PRESETS_DIR, "opencode", "prompts", toV);
|
|
30075
30669
|
}
|
|
@@ -30089,12 +30683,12 @@ async function diffPromptVersions(fromVersion, toVersion, options = {}) {
|
|
|
30089
30683
|
let oldText = "";
|
|
30090
30684
|
let newText = "";
|
|
30091
30685
|
try {
|
|
30092
|
-
oldText = await
|
|
30686
|
+
oldText = await readFile46(join31(fromDir, name), "utf-8");
|
|
30093
30687
|
} catch {
|
|
30094
30688
|
oldText = "";
|
|
30095
30689
|
}
|
|
30096
30690
|
try {
|
|
30097
|
-
newText = await
|
|
30691
|
+
newText = await readFile46(join31(toDir, name), "utf-8");
|
|
30098
30692
|
} catch {
|
|
30099
30693
|
newText = "";
|
|
30100
30694
|
}
|
|
@@ -30133,13 +30727,13 @@ var init_prompt_diff = __esm(() => {
|
|
|
30133
30727
|
});
|
|
30134
30728
|
|
|
30135
30729
|
// src/core/evaluation/regression-checklist.ts
|
|
30136
|
-
import { execFileSync as
|
|
30137
|
-
import { mkdir as
|
|
30138
|
-
import { dirname as
|
|
30730
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
30731
|
+
import { mkdir as mkdir27, readFile as readFile47, writeFile as writeFile25 } from "node:fs/promises";
|
|
30732
|
+
import { dirname as dirname16, resolve as resolve45 } from "node:path";
|
|
30139
30733
|
async function loadRegressionChecklist() {
|
|
30140
30734
|
try {
|
|
30141
|
-
const path =
|
|
30142
|
-
const content = await
|
|
30735
|
+
const path = resolve45(ROOT_PRESETS_DIR, "templates", "regression-checklist.yml");
|
|
30736
|
+
const content = await readFile47(path, "utf-8");
|
|
30143
30737
|
const data = $parse(content);
|
|
30144
30738
|
return data.checks ?? [];
|
|
30145
30739
|
} catch {
|
|
@@ -30153,7 +30747,7 @@ function runCheckCommand(cmd, cwd) {
|
|
|
30153
30747
|
if (!file)
|
|
30154
30748
|
return { passed: false, message: "Empty command" };
|
|
30155
30749
|
try {
|
|
30156
|
-
|
|
30750
|
+
execFileSync4(file, args, {
|
|
30157
30751
|
cwd,
|
|
30158
30752
|
encoding: "utf-8",
|
|
30159
30753
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -30194,8 +30788,8 @@ async function runRegressionChecklist(projectRoot, options = {}) {
|
|
|
30194
30788
|
checks,
|
|
30195
30789
|
timestamp: new Date().toISOString()
|
|
30196
30790
|
};
|
|
30197
|
-
const outPath =
|
|
30198
|
-
await
|
|
30791
|
+
const outPath = resolve45(projectRoot, ".codeconductor/evaluation/regression-last.json");
|
|
30792
|
+
await mkdir27(dirname16(outPath), { recursive: true });
|
|
30199
30793
|
await writeFile25(outPath, JSON.stringify(report, null, 2), "utf-8");
|
|
30200
30794
|
return ok(report);
|
|
30201
30795
|
} catch (e) {
|
|
@@ -30239,7 +30833,7 @@ var init_model_comparison = __esm(() => {
|
|
|
30239
30833
|
|
|
30240
30834
|
// src/core/evaluation/cost-quality-matrix.ts
|
|
30241
30835
|
import { writeFile as writeFile26 } from "node:fs/promises";
|
|
30242
|
-
import { resolve as
|
|
30836
|
+
import { resolve as resolve46 } from "node:path";
|
|
30243
30837
|
async function buildCostQualityMatrix(projectRoot, outcomes) {
|
|
30244
30838
|
const agg = aggregateOutcomes(outcomes);
|
|
30245
30839
|
const rows = Object.entries(agg.byModel).map(([model, entry]) => {
|
|
@@ -30259,7 +30853,7 @@ async function buildCostQualityMatrix(projectRoot, outcomes) {
|
|
|
30259
30853
|
rows
|
|
30260
30854
|
};
|
|
30261
30855
|
const dir = await ensureEvaluationDir(projectRoot);
|
|
30262
|
-
await writeFile26(
|
|
30856
|
+
await writeFile26(resolve46(dir, "matrix.yml"), $stringify(matrix), "utf-8");
|
|
30263
30857
|
return matrix;
|
|
30264
30858
|
}
|
|
30265
30859
|
function formatMatrixMarkdown(matrix) {
|
|
@@ -30283,8 +30877,8 @@ var init_cost_quality_matrix = __esm(() => {
|
|
|
30283
30877
|
});
|
|
30284
30878
|
|
|
30285
30879
|
// src/core/evaluation/ablation-report.ts
|
|
30286
|
-
import { mkdir as
|
|
30287
|
-
import { resolve as
|
|
30880
|
+
import { mkdir as mkdir28, writeFile as writeFile27 } from "node:fs/promises";
|
|
30881
|
+
import { resolve as resolve47 } from "node:path";
|
|
30288
30882
|
function isPass(o) {
|
|
30289
30883
|
return o.verdict === "PASS" || o.status === "pass";
|
|
30290
30884
|
}
|
|
@@ -30330,6 +30924,8 @@ async function averageCriteria(projectRoot, outcomes) {
|
|
|
30330
30924
|
if (!loaded.success)
|
|
30331
30925
|
continue;
|
|
30332
30926
|
for (const c of loaded.data.criteria) {
|
|
30927
|
+
if (c.score === null)
|
|
30928
|
+
continue;
|
|
30333
30929
|
if (!buckets[c.id])
|
|
30334
30930
|
buckets[c.id] = [];
|
|
30335
30931
|
buckets[c.id].push(c.score);
|
|
@@ -30390,7 +30986,11 @@ async function buildAblationReport(projectRoot, outcomes, experimentId) {
|
|
|
30390
30986
|
...Object.keys(treatment.criteria ?? {})
|
|
30391
30987
|
]);
|
|
30392
30988
|
for (const cid of criterionIds) {
|
|
30393
|
-
|
|
30989
|
+
const baselineScore = baseline.criteria?.[cid];
|
|
30990
|
+
const treatmentScore = treatment.criteria?.[cid];
|
|
30991
|
+
if (baselineScore !== undefined && treatmentScore !== undefined) {
|
|
30992
|
+
deltaCriteria[cid] = treatmentScore - baselineScore;
|
|
30993
|
+
}
|
|
30394
30994
|
}
|
|
30395
30995
|
rows.push({
|
|
30396
30996
|
component: id,
|
|
@@ -30452,9 +31052,9 @@ function formatAblationMarkdown(report) {
|
|
|
30452
31052
|
`);
|
|
30453
31053
|
}
|
|
30454
31054
|
async function persistAblationReport(projectRoot, markdown) {
|
|
30455
|
-
const dir =
|
|
30456
|
-
await
|
|
30457
|
-
const path =
|
|
31055
|
+
const dir = resolve47(projectRoot, EVAL_DIR2);
|
|
31056
|
+
await mkdir28(dir, { recursive: true });
|
|
31057
|
+
const path = resolve47(dir, "ablation-last.md");
|
|
30458
31058
|
await writeFile27(path, markdown, "utf-8");
|
|
30459
31059
|
return path;
|
|
30460
31060
|
}
|
|
@@ -30469,8 +31069,8 @@ var exports_scorecard_command = {};
|
|
|
30469
31069
|
__export(exports_scorecard_command, {
|
|
30470
31070
|
scorecardCommand: () => scorecardCommand
|
|
30471
31071
|
});
|
|
30472
|
-
import { readFile as
|
|
30473
|
-
import { resolve as
|
|
31072
|
+
import { readFile as readFile48 } from "node:fs/promises";
|
|
31073
|
+
import { resolve as resolve48 } from "node:path";
|
|
30474
31074
|
function contractVersion() {
|
|
30475
31075
|
return package_default.version;
|
|
30476
31076
|
}
|
|
@@ -30534,19 +31134,22 @@ async function handleCreate(projectRoot, options) {
|
|
|
30534
31134
|
scopeFiles = parseScopeFiles(item.scope);
|
|
30535
31135
|
}
|
|
30536
31136
|
}
|
|
30537
|
-
let hints = collectScorecardSignals(projectRoot, scopeFiles);
|
|
30538
31137
|
const state = await loadOpenspecState(projectRoot);
|
|
30539
31138
|
const backlogId = options.taskId?.startsWith("BC-") ? options.taskId : undefined;
|
|
31139
|
+
const baseCommit = backlogId && state.success ? state.data.itemBaseCommits?.[backlogId] : undefined;
|
|
31140
|
+
let hints = collectScorecardSignals(projectRoot, scopeFiles, { baseCommit });
|
|
30540
31141
|
const changePath = backlogId && state.success ? state.data.changePaths[backlogId] : undefined;
|
|
30541
31142
|
if (changePath && !changePath.includes("/archive/")) {
|
|
30542
31143
|
const tddRequired = backlog.success ? backlog.data.global.tddRequired : false;
|
|
30543
31144
|
const cards = state.success ? state.data.taskCards.filter((c) => c.backlogId === backlogId) : [];
|
|
30544
31145
|
let hasEvidence;
|
|
30545
|
-
|
|
30546
|
-
|
|
30547
|
-
|
|
30548
|
-
|
|
30549
|
-
|
|
31146
|
+
const tddCards = cards.filter((c) => c.phase === "test" || c.phase === "implement");
|
|
31147
|
+
if (tddCards.length > 0) {
|
|
31148
|
+
hasEvidence = true;
|
|
31149
|
+
for (const card of tddCards) {
|
|
31150
|
+
const expectedPhase = card.phase === "test" ? "red" : "green";
|
|
31151
|
+
if (!await hasTddRunnerEvidence(projectRoot, card.id, expectedPhase)) {
|
|
31152
|
+
hasEvidence = false;
|
|
30550
31153
|
break;
|
|
30551
31154
|
}
|
|
30552
31155
|
}
|
|
@@ -30565,6 +31168,10 @@ async function handleCreate(projectRoot, options) {
|
|
|
30565
31168
|
criteria = criteriaFromSignals(hints);
|
|
30566
31169
|
findings = hints.findings;
|
|
30567
31170
|
}
|
|
31171
|
+
const pending = pendingCriteria(criteria);
|
|
31172
|
+
if (pending.length > 0) {
|
|
31173
|
+
findings.push(`Unmeasured criteria requiring manual scores with notes: ${pending.join(", ")}`);
|
|
31174
|
+
}
|
|
30568
31175
|
const id = generateEvalId("sc");
|
|
30569
31176
|
const configResult = await loadConfig(projectRoot);
|
|
30570
31177
|
const target = configResult.success ? configResult.data.defaults.target : "opencode";
|
|
@@ -30758,12 +31365,12 @@ async function handleCompareModels(projectRoot, options) {
|
|
|
30758
31365
|
outcomes = outcomes.filter((o) => options.modelsFilter.includes(o.model));
|
|
30759
31366
|
}
|
|
30760
31367
|
const markdown = generateModelComparisonMarkdown(outcomes, options.modelsFilter);
|
|
30761
|
-
const templatePath =
|
|
31368
|
+
const templatePath = resolve48(projectRoot, ".codeconductor/evaluation/model-comparison-last.md");
|
|
30762
31369
|
try {
|
|
30763
|
-
await
|
|
31370
|
+
await readFile48(templatePath);
|
|
30764
31371
|
} catch {}
|
|
30765
|
-
const { writeFile: writeFile28, mkdir:
|
|
30766
|
-
await
|
|
31372
|
+
const { writeFile: writeFile28, mkdir: mkdir29 } = await import("node:fs/promises");
|
|
31373
|
+
await mkdir29(resolve48(projectRoot, ".codeconductor/evaluation"), { recursive: true });
|
|
30767
31374
|
await writeFile28(templatePath, markdown, "utf-8");
|
|
30768
31375
|
return {
|
|
30769
31376
|
code: 0,
|
|
@@ -30973,9 +31580,9 @@ function getDomain(url) {
|
|
|
30973
31580
|
function originOf(url) {
|
|
30974
31581
|
try {
|
|
30975
31582
|
const parsed = new URL(url);
|
|
30976
|
-
const
|
|
31583
|
+
const hostname2 = parsed.hostname.toLowerCase().replace(/\.$/, "");
|
|
30977
31584
|
const port = parsed.port !== "" ? parsed.port : parsed.protocol === "https:" ? "443" : "80";
|
|
30978
|
-
return `${parsed.protocol}//${
|
|
31585
|
+
return `${parsed.protocol}//${hostname2}:${port}`;
|
|
30979
31586
|
} catch {
|
|
30980
31587
|
return;
|
|
30981
31588
|
}
|
|
@@ -32633,6 +33240,7 @@ var COMMANDS = [
|
|
|
32633
33240
|
{ name: "orchestrate", group: "workflow", summary: "Run goal execution orchestration.", usage: ["cc-codeconductor orchestrate <subcommand>"] },
|
|
32634
33241
|
{ name: "impact", group: "workflow", summary: "Analyze change impact.", usage: ["cc-codeconductor impact [--files <paths>]"] },
|
|
32635
33242
|
{ name: "verify", group: "workflow", summary: "Verify task completion with evidence.", usage: ["cc-codeconductor verify --task <id>"] },
|
|
33243
|
+
{ name: "tdd", group: "workflow", summary: "Capture runner-verified RED/GREEN TDD evidence.", usage: ['cc-codeconductor tdd capture --task <cardId> --phase red|green --command "<test command>"'] },
|
|
32636
33244
|
{ name: "rdd", group: "workflow", summary: "Capture and validate Receipt-Driven Development evidence.", usage: ["cc-codeconductor rdd capture --task <id> [--phase red|green|review]", "cc-codeconductor rdd verify --receipt <id>", "cc-codeconductor rdd status [--task <id>]", "cc-codeconductor rdd git-check", "cc-codeconductor rdd install-hooks"] },
|
|
32637
33245
|
{ name: "seo", group: "tool", summary: "Audit SEO and generate llms.txt.", usage: ["cc-codeconductor seo audit --url <url>"] },
|
|
32638
33246
|
{ name: "debt-harvest", aliases: ["harvest"], group: "tool", summary: "Scan source files for deferred debt.", usage: ["cc-codeconductor debt-harvest"] }
|
|
@@ -33208,6 +33816,18 @@ async function routeCommand(args, projectRoot) {
|
|
|
33208
33816
|
allowCompileCheck: options["allow-compile-check"] === true || options["allow-compile-check"] === "true"
|
|
33209
33817
|
});
|
|
33210
33818
|
}
|
|
33819
|
+
case "tdd": {
|
|
33820
|
+
const { tddCommand: tddCommand2 } = await Promise.resolve().then(() => (init_tdd_command(), exports_tdd_command));
|
|
33821
|
+
return tddCommand2({
|
|
33822
|
+
subcommand: subcommand ?? "",
|
|
33823
|
+
projectRoot,
|
|
33824
|
+
output: flags.output,
|
|
33825
|
+
taskId: options.task ?? args.rest?.[0],
|
|
33826
|
+
phase: options.phase,
|
|
33827
|
+
command: options.command,
|
|
33828
|
+
allowCompileCheck: options["allow-compile-check"] === true || options["allow-compile-check"] === "true"
|
|
33829
|
+
});
|
|
33830
|
+
}
|
|
33211
33831
|
case "rdd": {
|
|
33212
33832
|
const validSubs = ["capture", "verify", "status", "git-check", "install-hooks"];
|
|
33213
33833
|
if (!subcommand || !validSubs.includes(subcommand)) {
|
|
@@ -33294,6 +33914,7 @@ async function routeCommand(args, projectRoot) {
|
|
|
33294
33914
|
subcommand: openspecSub,
|
|
33295
33915
|
itemId,
|
|
33296
33916
|
reason: typeof options.reason === "string" ? options.reason : undefined,
|
|
33917
|
+
allowUnchecked: options["allow-unchecked"] === true || options["allow-unchecked"] === "true",
|
|
33297
33918
|
projectRoot,
|
|
33298
33919
|
output: flags.output
|
|
33299
33920
|
});
|