coding-agent-harness 1.0.5 → 1.0.6
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/CONTRIBUTING.md +2 -2
- package/README.md +63 -3
- package/README.zh-CN.md +52 -3
- package/SKILL.md +43 -43
- package/dist/build-dist.mjs +189 -0
- package/dist/check-dist-observation.mjs +428 -0
- package/dist/check-harness.mjs +489 -0
- package/dist/check-import-graph.mjs +511 -0
- package/dist/check-runtime-emit.mjs +304 -0
- package/dist/check-type-boundaries.mjs +139 -0
- package/dist/commands/dashboard-command.mjs +80 -0
- package/dist/commands/migration-command.mjs +152 -0
- package/dist/commands/preset-command.mjs +91 -0
- package/dist/commands/task-command.mjs +324 -0
- package/dist/harness.mjs +304 -0
- package/dist/lib/capability-registry.mjs +643 -0
- package/dist/lib/check-module-parallel.mjs +227 -0
- package/dist/lib/check-profiles.mjs +414 -0
- package/dist/lib/check-task-contracts.mjs +54 -0
- package/dist/lib/core-shared.mjs +254 -0
- package/dist/lib/dashboard-data.mjs +608 -0
- package/dist/lib/dashboard-workbench.mjs +334 -0
- package/dist/lib/dashboard-writer.mjs +200 -0
- package/dist/lib/git-status-summary.mjs +45 -0
- package/dist/lib/governance-index-generator.mjs +236 -0
- package/dist/lib/governance-sync.mjs +617 -0
- package/dist/lib/governance-table-boundary.mjs +161 -0
- package/{scripts → dist}/lib/harness-core.mjs +2 -0
- package/dist/lib/harness-paths.mjs +338 -0
- package/dist/lib/lesson-maintenance.mjs +139 -0
- package/dist/lib/markdown-utils.mjs +193 -0
- package/dist/lib/migration-planner.mjs +439 -0
- package/dist/lib/migration-support.mjs +317 -0
- package/dist/lib/phase-kind.mjs +46 -0
- package/dist/lib/preset-audit-contracts.mjs +40 -0
- package/dist/lib/preset-engine.mjs +516 -0
- package/dist/lib/preset-registry.mjs +831 -0
- package/dist/lib/preset-resource-contracts.mjs +83 -0
- package/dist/lib/review-confirm-git-gate.mjs +244 -0
- package/dist/lib/status-builder.mjs +87 -0
- package/{scripts → dist}/lib/status-dashboard-renderer.mjs +44 -46
- package/dist/lib/structure-migration.mjs +404 -0
- package/dist/lib/subagent-authorization-audit.mjs +198 -0
- package/dist/lib/task-audit-metadata.mjs +376 -0
- package/dist/lib/task-audit-migration.mjs +355 -0
- package/dist/lib/task-completion-consistency.mjs +29 -0
- package/dist/lib/task-index.mjs +133 -0
- package/dist/lib/task-lesson-candidates.mjs +239 -0
- package/dist/lib/task-lesson-sedimentation.mjs +300 -0
- package/dist/lib/task-lifecycle/create-task-helpers.mjs +84 -0
- package/dist/lib/task-lifecycle/phase-sync.mjs +82 -0
- package/dist/lib/task-lifecycle/review-confirm.mjs +93 -0
- package/dist/lib/task-lifecycle/review-gates.mjs +62 -0
- package/dist/lib/task-lifecycle/review-submission.mjs +52 -0
- package/dist/lib/task-lifecycle/scaffold-provenance.mjs +54 -0
- package/dist/lib/task-lifecycle/template-files.mjs +52 -0
- package/dist/lib/task-lifecycle/text-utils.mjs +26 -0
- package/dist/lib/task-lifecycle.mjs +611 -0
- package/dist/lib/task-metadata.mjs +116 -0
- package/dist/lib/task-review-model.mjs +474 -0
- package/dist/lib/task-scanner.mjs +439 -0
- package/dist/lib/task-tombstone-commands.mjs +125 -0
- package/dist/postinstall.mjs +14 -0
- package/dist/run-built-tests.mjs +84 -0
- package/docs-release/README.md +1 -0
- package/docs-release/architecture/overview.md +12 -12
- package/docs-release/architecture/overview.zh-CN.md +12 -12
- package/docs-release/architecture/system-explainer/01-system-overview.md +15 -14
- package/docs-release/architecture/system-explainer/02-module-dependency.md +8 -8
- package/docs-release/architecture/system-explainer/03-task-lifecycle.md +3 -3
- package/docs-release/architecture/system-explainer/04-check-and-governance.md +9 -7
- package/docs-release/architecture/system-explainer/05-data-flow.md +5 -5
- package/docs-release/architecture/system-explainer/06-preset-and-migration.md +1 -4
- package/docs-release/architecture/system-explainer/en-US/01-system-overview.md +15 -14
- package/docs-release/architecture/system-explainer/en-US/02-module-dependency.md +8 -8
- package/docs-release/architecture/system-explainer/en-US/03-task-lifecycle.md +3 -3
- package/docs-release/architecture/system-explainer/en-US/04-check-and-governance.md +10 -8
- package/docs-release/architecture/system-explainer/en-US/05-data-flow.md +5 -5
- package/docs-release/architecture/system-explainer/en-US/06-preset-and-migration.md +1 -4
- package/docs-release/guides/agent-installation.en-US.md +14 -8
- package/docs-release/guides/agent-installation.md +14 -8
- package/docs-release/guides/contributing.md +3 -3
- package/docs-release/guides/contributing.zh-CN.md +3 -3
- package/docs-release/guides/document-audience-and-surfaces.en-US.md +10 -10
- package/docs-release/guides/document-audience-and-surfaces.md +10 -10
- package/docs-release/guides/legacy-migration-agent-prompt.md +25 -2
- package/docs-release/guides/legacy-migration-agent-prompt.zh-CN.md +25 -2
- package/docs-release/guides/migration-playbook.en-US.md +63 -1
- package/docs-release/guides/migration-playbook.md +59 -1
- package/docs-release/guides/parent-control-repository-pattern.en-US.md +25 -25
- package/docs-release/guides/parent-control-repository-pattern.md +25 -25
- package/docs-release/guides/preset-development.md +2 -2
- package/docs-release/guides/repository-operating-models.en-US.md +21 -21
- package/docs-release/guides/repository-operating-models.md +21 -21
- package/docs-release/guides/task-state-machine.en-US.md +5 -5
- package/docs-release/guides/task-state-machine.md +5 -5
- package/docs-release/guides/typescript-runtime-migration-closeout.md +96 -0
- package/examples/minimal-project/AGENTS.md +2 -2
- package/examples/minimal-project/coding-agent-harness/harness.yaml +14 -0
- package/examples/minimal-project/coding-agent-harness/planning/tasks/demo-task/progress.md +11 -0
- package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/review.md +1 -1
- package/package.json +20 -12
- package/presets/legacy-migration/preset.yaml +5 -5
- package/presets/legacy-migration/templates/execution_strategy.append.md +1 -1
- package/presets/lesson-sedimentation/preset.yaml +3 -3
- package/presets/module/preset.yaml +2 -2
- package/presets/module/templates/execution_strategy.append.md +1 -1
- package/presets/module/templates/task_plan.append.md +3 -3
- package/presets/standard-task/preset.yaml +2 -2
- package/references/adversarial-review-standard.md +2 -2
- package/references/agents-md-pattern.md +14 -14
- package/references/cadence-ledger.md +1 -1
- package/references/ci-cd-standard.md +1 -1
- package/references/delivery-operating-model-standard.md +4 -4
- package/references/docs-directory-standard.md +65 -159
- package/references/external-source-intake-standard.md +10 -10
- package/references/harness-ledger.md +5 -5
- package/references/legacy-12-phase-bootstrap.md +2 -2
- package/references/lessons-governance.md +15 -15
- package/references/long-running-task-standard.md +6 -6
- package/references/module-parallel-standard.md +34 -34
- package/references/planning-loop.md +6 -6
- package/references/project-onboarding-audit.md +4 -4
- package/references/regression-system.md +2 -2
- package/references/repo-governance-standard.md +4 -4
- package/references/review-routing-standard.md +1 -1
- package/references/ssot-governance.md +19 -19
- package/references/taskr-gap-analysis.md +5 -5
- package/references/walkthrough-closeout.md +14 -14
- package/references/worktree-parallel.md +3 -3
- package/skills/preset-creator/references/complex-task-skeleton/task_plan.md +1 -1
- package/skills/preset-creator/references/preset-package-skeleton.md +5 -5
- package/templates/AGENTS.md.template +26 -26
- package/templates/architecture/README.md +4 -4
- package/templates/architecture/service-catalog.md +2 -2
- package/templates/architecture/services/service-template.md +1 -1
- package/templates/dashboard/assets/app-src/20-overview.js +11 -5
- package/templates/dashboard/assets/app-src/40-modules.js +1 -1
- package/templates/dashboard/assets/app.js +12 -6
- package/templates/dashboard/assets/i18n.js +4 -2
- package/templates/development/README.md +10 -10
- package/templates/development/cross-repo-debugging.md +3 -3
- package/templates/development/external-context/service-template.md +2 -2
- package/templates/development/external-source-packs/README.md +4 -4
- package/templates/integrations/README.md +4 -4
- package/templates/integrations/api-contract.md +2 -2
- package/templates/integrations/event-contract.md +2 -2
- package/templates/integrations/third-party/vendor-template.md +2 -2
- package/templates/integrations/webhook-contract.md +2 -2
- package/templates/ledger/Harness-Ledger.md +1 -1
- package/templates/planning/INDEX.md +1 -0
- package/templates/planning/module_session_prompt.md +1 -1
- package/templates/planning/task_plan.md +1 -1
- package/templates/planning/walkthrough.md +47 -0
- package/templates/reference/docs-library-standard.md +8 -8
- package/templates/reference/external-source-intake-standard.md +15 -15
- package/templates/reference/repo-governance-standard.md +1 -1
- package/templates/ssot/Module-Registry.md +1 -1
- package/templates/walkthrough/walkthrough-template.md +2 -2
- package/templates-zh-CN/AGENTS.md.template +26 -26
- package/templates-zh-CN/CLAUDE.md.template +1 -1
- package/templates-zh-CN/architecture/README.md +4 -4
- package/templates-zh-CN/architecture/service-catalog.md +2 -2
- package/templates-zh-CN/architecture/services/service-template.md +1 -1
- package/templates-zh-CN/development/README.md +10 -10
- package/templates-zh-CN/development/cross-repo-debugging.md +3 -3
- package/templates-zh-CN/development/external-context/service-template.md +2 -2
- package/templates-zh-CN/development/external-source-packs/README.md +4 -4
- package/templates-zh-CN/integrations/README.md +4 -4
- package/templates-zh-CN/integrations/api-contract.md +2 -2
- package/templates-zh-CN/integrations/event-contract.md +2 -2
- package/templates-zh-CN/integrations/third-party/vendor-template.md +2 -2
- package/templates-zh-CN/integrations/webhook-contract.md +2 -2
- package/templates-zh-CN/ledger/Harness-Ledger.md +1 -1
- package/templates-zh-CN/lessons/lesson-arch-process-change.md +1 -1
- package/templates-zh-CN/lessons/lesson-new-doc.md +3 -3
- package/templates-zh-CN/lessons/lesson-ref-change.md +4 -4
- package/templates-zh-CN/planning/module_session_prompt.md +11 -11
- package/templates-zh-CN/planning/walkthrough.md +47 -0
- package/templates-zh-CN/reference/adversarial-review-standard.md +2 -2
- package/templates-zh-CN/reference/delivery-operating-model-standard.md +3 -3
- package/templates-zh-CN/reference/docs-library-standard.md +28 -28
- package/templates-zh-CN/reference/execution-workflow-standard.md +1 -1
- package/templates-zh-CN/reference/external-source-intake-standard.md +16 -16
- package/templates-zh-CN/reference/harness-ledger-standard.md +6 -6
- package/templates-zh-CN/reference/regression-ssot-governance.md +2 -2
- package/templates-zh-CN/reference/repo-governance-standard.md +1 -1
- package/templates-zh-CN/reference/review-routing-standard.md +1 -1
- package/templates-zh-CN/reference/walkthrough-standard.md +7 -7
- package/templates-zh-CN/reference/worktree-standard.md +1 -1
- package/templates-zh-CN/regression/Cadence-Ledger.md +2 -2
- package/templates-zh-CN/ssot/Delivery-SSoT.md +3 -3
- package/templates-zh-CN/ssot/Module-Registry.md +3 -3
- package/templates-zh-CN/ssot/Regression-SSoT.md +2 -2
- package/templates-zh-CN/walkthrough/walkthrough-template.md +5 -5
- package/tsconfig.dist.json +16 -0
- package/tsconfig.json +25 -0
- package/tsconfig.runtime.json +24 -0
- package/examples/minimal-project/.harness-capabilities.json +0 -8
- package/examples/minimal-project/docs/09-PLANNING/TASKS/demo-task/progress.md +0 -11
- package/scripts/check-harness.mjs +0 -508
- package/scripts/commands/dashboard-command.mjs +0 -67
- package/scripts/commands/migration-command.mjs +0 -126
- package/scripts/commands/preset-command.mjs +0 -73
- package/scripts/commands/task-command.mjs +0 -328
- package/scripts/harness.mjs +0 -291
- package/scripts/lib/capability-registry.mjs +0 -587
- package/scripts/lib/check-module-parallel.mjs +0 -230
- package/scripts/lib/check-profiles.mjs +0 -372
- package/scripts/lib/check-task-contracts.mjs +0 -55
- package/scripts/lib/core-shared.mjs +0 -249
- package/scripts/lib/dashboard-data.mjs +0 -520
- package/scripts/lib/dashboard-workbench.mjs +0 -336
- package/scripts/lib/dashboard-writer.mjs +0 -202
- package/scripts/lib/git-status-summary.mjs +0 -46
- package/scripts/lib/governance-index-generator.mjs +0 -174
- package/scripts/lib/governance-sync.mjs +0 -611
- package/scripts/lib/governance-table-boundary.mjs +0 -175
- package/scripts/lib/lesson-maintenance.mjs +0 -152
- package/scripts/lib/markdown-utils.mjs +0 -191
- package/scripts/lib/migration-planner.mjs +0 -476
- package/scripts/lib/migration-support.mjs +0 -312
- package/scripts/lib/phase-kind.mjs +0 -50
- package/scripts/lib/preset-audit-contracts.mjs +0 -37
- package/scripts/lib/preset-engine.mjs +0 -494
- package/scripts/lib/preset-registry.mjs +0 -776
- package/scripts/lib/preset-resource-contracts.mjs +0 -83
- package/scripts/lib/review-confirm-git-gate.mjs +0 -248
- package/scripts/lib/status-builder.mjs +0 -88
- package/scripts/lib/subagent-authorization-audit.mjs +0 -196
- package/scripts/lib/task-audit-metadata.mjs +0 -385
- package/scripts/lib/task-audit-migration.mjs +0 -350
- package/scripts/lib/task-completion-consistency.mjs +0 -26
- package/scripts/lib/task-index.mjs +0 -93
- package/scripts/lib/task-lesson-candidates.mjs +0 -242
- package/scripts/lib/task-lesson-sedimentation.mjs +0 -326
- package/scripts/lib/task-lifecycle/create-task-helpers.mjs +0 -67
- package/scripts/lib/task-lifecycle/phase-sync.mjs +0 -88
- package/scripts/lib/task-lifecycle/review-confirm.mjs +0 -112
- package/scripts/lib/task-lifecycle/review-gates.mjs +0 -73
- package/scripts/lib/task-lifecycle/review-submission.mjs +0 -63
- package/scripts/lib/task-lifecycle/scaffold-provenance.mjs +0 -49
- package/scripts/lib/task-lifecycle/template-files.mjs +0 -53
- package/scripts/lib/task-lifecycle/text-utils.mjs +0 -24
- package/scripts/lib/task-lifecycle.mjs +0 -616
- package/scripts/lib/task-metadata.mjs +0 -118
- package/scripts/lib/task-review-model.mjs +0 -455
- package/scripts/lib/task-scanner.mjs +0 -503
- package/scripts/lib/task-tombstone-commands.mjs +0 -140
- package/scripts/postinstall.mjs +0 -14
- package/templates/walkthrough/Closeout-SSoT.md +0 -43
- package/templates-zh-CN/walkthrough/Closeout-SSoT.md +0 -42
- /package/examples/minimal-project/{docs → coding-agent-harness/governance/generated}/Harness-Ledger.md +0 -0
- /package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/INDEX.md +0 -0
- /package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/brief.md +0 -0
- /package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/execution_strategy.md +0 -0
- /package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/findings.md +0 -0
- /package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/lesson_candidates.md +0 -0
- /package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/task_plan.md +0 -0
- /package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/visual_map.md +0 -0
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
normalizeTarget,
|
|
5
|
-
readBundledTemplate,
|
|
6
|
-
todayDate,
|
|
7
|
-
toPosix,
|
|
8
|
-
} from "./core-shared.mjs";
|
|
9
|
-
import { splitMarkdownRow } from "./markdown-utils.mjs";
|
|
10
|
-
import { collectTasks } from "./task-scanner.mjs";
|
|
11
|
-
import {
|
|
12
|
-
beginGovernanceSync,
|
|
13
|
-
commitGovernanceSync,
|
|
14
|
-
moduleGeneratedIndexSurfaces,
|
|
15
|
-
releaseGovernanceSync,
|
|
16
|
-
} from "./governance-sync.mjs";
|
|
17
|
-
import { markdownCell } from "./task-lifecycle/text-utils.mjs";
|
|
18
|
-
|
|
19
|
-
export function rebuildGovernanceIndexes(targetInput, { dryRun = false, archive = false, apply = false } = {}) {
|
|
20
|
-
const target = normalizeTarget(targetInput);
|
|
21
|
-
const effectiveApply = Boolean(apply && !dryRun);
|
|
22
|
-
const context = beginGovernanceSync(target, { operation: "governance rebuild", dryRun: !effectiveApply });
|
|
23
|
-
try {
|
|
24
|
-
const tasks = collectTasks(target)
|
|
25
|
-
.filter((task) => task.deletionState !== "deleted")
|
|
26
|
-
.sort((a, b) => String(a.id).localeCompare(String(b.id)));
|
|
27
|
-
const surfaces = [...governanceSurfaces(target, tasks), ...moduleGeneratedIndexSurfaces(target, tasks)];
|
|
28
|
-
const archiveDir = archive ? uniqueArchiveDir(target) : "";
|
|
29
|
-
const changes = surfaces.map((surface) => ({
|
|
30
|
-
surface: surface.surface,
|
|
31
|
-
destination: surface.relative,
|
|
32
|
-
action: surface.archiveOnly
|
|
33
|
-
? apply ? "archive-legacy-governance-table" : "would-archive-legacy-governance-table"
|
|
34
|
-
: apply ? "rebuild-governance-index" : "would-rebuild-governance-index",
|
|
35
|
-
generatedRows: surface.rows.length,
|
|
36
|
-
archive: archive ? `${archiveDir}/${surface.relative}` : "",
|
|
37
|
-
}));
|
|
38
|
-
|
|
39
|
-
if (!effectiveApply) {
|
|
40
|
-
return { dryRun: true, archive, applied: false, archiveDir, changes };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const allowed = [];
|
|
44
|
-
for (const surface of surfaces) {
|
|
45
|
-
if (archive && fs.existsSync(surface.absolute)) {
|
|
46
|
-
const archivePath = path.join(target.projectRoot, archiveDir, surface.relative);
|
|
47
|
-
fs.mkdirSync(path.dirname(archivePath), { recursive: true });
|
|
48
|
-
fs.copyFileSync(surface.absolute, archivePath);
|
|
49
|
-
allowed.push(toPosix(path.relative(target.projectRoot, archivePath)));
|
|
50
|
-
}
|
|
51
|
-
if (surface.archiveOnly) {
|
|
52
|
-
if (archive && fs.existsSync(surface.absolute)) {
|
|
53
|
-
fs.rmSync(surface.absolute);
|
|
54
|
-
allowed.push(surface.relative);
|
|
55
|
-
}
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
fs.mkdirSync(path.dirname(surface.absolute), { recursive: true });
|
|
59
|
-
fs.writeFileSync(surface.absolute, surface.content);
|
|
60
|
-
allowed.push(surface.relative);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const commit = commitGovernanceSync(context, allowed, { message: "chore(harness): rebuild generated governance indexes" });
|
|
64
|
-
return { dryRun: false, archive, applied: true, archiveDir, changes, commit };
|
|
65
|
-
} finally {
|
|
66
|
-
releaseGovernanceSync(context);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function governanceSurfaces(target, tasks) {
|
|
71
|
-
return [
|
|
72
|
-
{
|
|
73
|
-
surface: "harness-ledger",
|
|
74
|
-
absolute: path.join(target.docsRoot, "Harness-Ledger.md"),
|
|
75
|
-
relative: toPosix(path.relative(target.projectRoot, path.join(target.docsRoot, "Harness-Ledger.md"))),
|
|
76
|
-
rows: tasks.map(ledgerRow),
|
|
77
|
-
content: replaceTableRows(readBundledTemplate("templates/ledger/Harness-Ledger.md"), /^ID$/i, tasks.map(ledgerRow)),
|
|
78
|
-
},
|
|
79
|
-
...legacyFeatureSurfaces(target),
|
|
80
|
-
];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function legacyFeatureSurfaces(target) {
|
|
84
|
-
return [
|
|
85
|
-
["legacy-feature-ssot", path.join(target.docsRoot, "09-PLANNING/Feature-SSoT.md")],
|
|
86
|
-
["legacy-private-feature-ssot", path.join(target.docsRoot, "09-PLANNING/Private-Feature-SSoT.md")],
|
|
87
|
-
].filter(([, absolute]) => fs.existsSync(absolute)).map(([surface, absolute]) => ({
|
|
88
|
-
surface,
|
|
89
|
-
absolute,
|
|
90
|
-
relative: toPosix(path.relative(target.projectRoot, absolute)),
|
|
91
|
-
rows: [],
|
|
92
|
-
content: "",
|
|
93
|
-
archiveOnly: true,
|
|
94
|
-
}));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function replaceTableRows(content, headerPattern, rows) {
|
|
98
|
-
const lines = String(content || "").split(/\r?\n/);
|
|
99
|
-
for (let index = 0; index < lines.length - 1; index += 1) {
|
|
100
|
-
if (!lines[index].trim().startsWith("|")) continue;
|
|
101
|
-
const header = splitMarkdownRow(lines[index]);
|
|
102
|
-
if (!header.some((cell) => headerPattern.test(cell))) continue;
|
|
103
|
-
const separator = splitMarkdownRow(lines[index + 1]);
|
|
104
|
-
if (!separator.every((cell) => /^:?-{3,}:?$/.test(cell))) continue;
|
|
105
|
-
let end = index + 2;
|
|
106
|
-
while (end < lines.length && lines[end].trim().startsWith("|")) end += 1;
|
|
107
|
-
const fitted = rows.map((row) => fitRow(row, header.length));
|
|
108
|
-
lines.splice(index + 2, end - index - 2, ...fitted.map((row) => `| ${row.join(" | ")} |`));
|
|
109
|
-
return `${lines.join("\n").trimEnd()}\n`;
|
|
110
|
-
}
|
|
111
|
-
return `${String(content || "").trimEnd()}\n\n${rows.map((row) => `| ${row.join(" | ")} |`).join("\n")}\n`;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function fitRow(row, length) {
|
|
115
|
-
const next = row.map((cell) => markdownCell(cell));
|
|
116
|
-
while (next.length < length) next.push("");
|
|
117
|
-
return next.slice(0, length);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function ledgerRow(task) {
|
|
121
|
-
const plan = stripTarget(task.taskPlanPath || `${stripTarget(task.path)}/task_plan.md`);
|
|
122
|
-
const scope = task.module ? "module" : "task";
|
|
123
|
-
const moduleKey = task.module || "none";
|
|
124
|
-
return [
|
|
125
|
-
taskLedgerId(task),
|
|
126
|
-
scope,
|
|
127
|
-
moduleKey,
|
|
128
|
-
task.title || task.shortId || task.id,
|
|
129
|
-
mapLedgerState(task.state),
|
|
130
|
-
Array.isArray(task.taskQueues) && task.taskQueues.length ? task.taskQueues.join(",") : "none",
|
|
131
|
-
plan,
|
|
132
|
-
task.reviewStatus === "confirmed" ? stripTarget(task.reviewPath) : (task.reviewStatus || "pending"),
|
|
133
|
-
task.lessonCandidateDecisionComplete ? "checked" : (task.lessonCandidateStatus || "pending"),
|
|
134
|
-
task.walkthroughPath ? stripTarget(task.walkthroughPath) : (task.closeoutStatus || "pending"),
|
|
135
|
-
residual(task),
|
|
136
|
-
todayDate(),
|
|
137
|
-
];
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function residual(task) {
|
|
141
|
-
if (Array.isArray(task.stateConflicts) && task.stateConflicts.length) return `state-conflicts:${task.stateConflicts.length}`;
|
|
142
|
-
if (Array.isArray(task.materialIssues) && task.materialIssues.length) return `material-issues:${task.materialIssues.length}`;
|
|
143
|
-
return "none";
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function taskLedgerId(task) {
|
|
147
|
-
return `HL-${taskSlug(task)}`;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function taskSlug(task) {
|
|
151
|
-
return String(task.shortId || task.id || "task").replace(/^TASKS\//, "").replace(/^MODULES\//, "").replace(/[^A-Za-z0-9-]+/g, "-").slice(0, 72);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function stripTarget(value) {
|
|
155
|
-
return String(value || "").replace(/^TARGET:/, "");
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function mapLedgerState(state) {
|
|
159
|
-
if (state === "in_progress") return "active";
|
|
160
|
-
if (state === "review") return "review";
|
|
161
|
-
if (state === "done") return "closed";
|
|
162
|
-
if (state === "blocked") return "blocked";
|
|
163
|
-
return "planned";
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function uniqueArchiveDir(target) {
|
|
167
|
-
const stamp = new Date().toISOString().replace(/[-:]/g, "").replace(".", "-");
|
|
168
|
-
const base = `docs/01-GOVERNANCE/archive/generated-governance-tables/${stamp}`;
|
|
169
|
-
for (let index = 0; index < 100; index += 1) {
|
|
170
|
-
const candidate = index === 0 ? base : `${base}-${String(index).padStart(2, "0")}`;
|
|
171
|
-
if (!fs.existsSync(path.join(target.projectRoot, candidate))) return candidate;
|
|
172
|
-
}
|
|
173
|
-
throw new Error("Unable to allocate a unique governance table archive directory");
|
|
174
|
-
}
|