coding-agent-harness 1.0.4 → 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/CHANGELOG.md +7 -0
- package/CONTRIBUTING.md +2 -2
- package/LICENSE +661 -21
- package/LICENSE-EXCEPTION.md +37 -0
- package/README.md +96 -4
- package/README.zh-CN.md +75 -4
- package/SKILL.md +52 -51
- 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 +3 -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 +48 -47
- 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 +13 -13
- package/docs-release/architecture/overview.zh-CN.md +13 -13
- package/docs-release/architecture/system-explainer/01-system-overview.md +218 -0
- package/docs-release/architecture/system-explainer/02-module-dependency.md +257 -0
- package/docs-release/architecture/system-explainer/03-task-lifecycle.md +304 -0
- package/docs-release/architecture/system-explainer/04-check-and-governance.md +241 -0
- package/docs-release/architecture/system-explainer/05-data-flow.md +276 -0
- package/docs-release/architecture/system-explainer/06-preset-and-migration.md +300 -0
- package/docs-release/architecture/system-explainer/README.md +67 -0
- package/docs-release/architecture/system-explainer/en-US/01-system-overview.md +227 -0
- package/docs-release/architecture/system-explainer/en-US/02-module-dependency.md +263 -0
- package/docs-release/architecture/system-explainer/en-US/03-task-lifecycle.md +319 -0
- package/docs-release/architecture/system-explainer/en-US/04-check-and-governance.md +252 -0
- package/docs-release/architecture/system-explainer/en-US/05-data-flow.md +290 -0
- package/docs-release/architecture/system-explainer/en-US/06-preset-and-migration.md +320 -0
- package/docs-release/architecture/system-explainer/en-US/README.md +70 -0
- package/docs-release/guides/agent-installation.en-US.md +22 -15
- package/docs-release/guides/agent-installation.md +23 -15
- 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 +28 -4
- 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 +35 -18
- package/docs-release/guides/task-state-machine.md +35 -18
- 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/INDEX.md +60 -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 +22 -13
- 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 +6 -6
- 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/brief.md +11 -0
- 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 +31 -29
- 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/00-state.js +12 -0
- package/templates/dashboard/assets/app-src/10-router.js +3 -0
- package/templates/dashboard/assets/app-src/20-overview.js +13 -3
- package/templates/dashboard/assets/app-src/35-task-detail.js +46 -6
- package/templates/dashboard/assets/app-src/40-modules.js +1 -1
- package/templates/dashboard/assets/app-src/55-presets.js +375 -0
- package/templates/dashboard/assets/app-src/60-shared.js +3 -1
- package/templates/dashboard/assets/app-src/90-bindings.js +131 -0
- package/templates/dashboard/assets/app.css +583 -0
- package/templates/dashboard/assets/app.css.manifest.json +1 -0
- package/templates/dashboard/assets/app.js +585 -11
- package/templates/dashboard/assets/app.manifest.json +1 -0
- package/templates/dashboard/assets/css-src/00-foundation.css +4 -0
- package/templates/dashboard/assets/css-src/40-detail-modules-migration.css +62 -0
- package/templates/dashboard/assets/css-src/45-presets.css +516 -0
- package/templates/dashboard/assets/i18n.js +144 -4
- 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 +88 -0
- package/templates/planning/brief.md +1 -1
- package/templates/planning/module_session_prompt.md +2 -1
- package/templates/planning/review.md +0 -18
- package/templates/planning/task_plan.md +5 -44
- package/templates/planning/visual_map.md +13 -9
- package/templates/planning/visual_map.simple.md +52 -0
- package/templates/planning/walkthrough.md +47 -0
- package/templates/reference/docs-library-standard.md +8 -8
- package/templates/reference/execution-workflow-standard.md +29 -2
- 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 +31 -29
- 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/INDEX.md +87 -0
- package/templates-zh-CN/planning/brief.md +1 -1
- package/templates-zh-CN/planning/module_session_prompt.md +12 -11
- package/templates-zh-CN/planning/review.md +0 -18
- package/templates-zh-CN/planning/task_plan.md +3 -63
- package/templates-zh-CN/planning/visual_map.md +14 -7
- package/templates-zh-CN/planning/visual_map.simple.md +48 -0
- 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 +32 -7
- 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 -96
- package/scripts/commands/preset-command.mjs +0 -73
- package/scripts/commands/task-command.mjs +0 -327
- package/scripts/harness.mjs +0 -287
- package/scripts/lib/capability-registry.mjs +0 -591
- package/scripts/lib/check-module-parallel.mjs +0 -237
- package/scripts/lib/check-profiles.mjs +0 -418
- package/scripts/lib/check-task-contracts.mjs +0 -47
- package/scripts/lib/core-shared.mjs +0 -196
- package/scripts/lib/dashboard-data.mjs +0 -412
- package/scripts/lib/dashboard-workbench.mjs +0 -257
- package/scripts/lib/dashboard-writer.mjs +0 -198
- 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 -514
- package/scripts/lib/governance-table-boundary.mjs +0 -175
- package/scripts/lib/lesson-maintenance.mjs +0 -152
- package/scripts/lib/markdown-utils.mjs +0 -158
- package/scripts/lib/migration-planner.mjs +0 -478
- package/scripts/lib/migration-support.mjs +0 -312
- package/scripts/lib/preset-audit-contracts.mjs +0 -37
- package/scripts/lib/preset-engine.mjs +0 -497
- package/scripts/lib/preset-registry.mjs +0 -627
- package/scripts/lib/preset-resource-contracts.mjs +0 -83
- package/scripts/lib/review-confirm-git-gate.mjs +0 -248
- package/scripts/lib/subagent-authorization-audit.mjs +0 -196
- package/scripts/lib/task-completion-consistency.mjs +0 -16
- 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/review-confirm.mjs +0 -101
- package/scripts/lib/task-lifecycle/review-gates.mjs +0 -70
- package/scripts/lib/task-lifecycle/text-utils.mjs +0 -24
- package/scripts/lib/task-lifecycle.mjs +0 -649
- package/scripts/lib/task-review-model.mjs +0 -469
- package/scripts/lib/task-scanner.mjs +0 -576
- 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/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,576 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
allowedTaskStates,
|
|
5
|
-
allowedTaskBudgets,
|
|
6
|
-
visualMapFile,
|
|
7
|
-
legacyVisualRoadmapFile,
|
|
8
|
-
lessonCandidatesFile,
|
|
9
|
-
longRunningTaskContractFile,
|
|
10
|
-
taskContractMarker,
|
|
11
|
-
toPosix,
|
|
12
|
-
readFileSafe,
|
|
13
|
-
walkFiles,
|
|
14
|
-
titleFromMarkdown,
|
|
15
|
-
} from "./core-shared.mjs";
|
|
16
|
-
import {
|
|
17
|
-
tableAfterHeading,
|
|
18
|
-
firstColumn,
|
|
19
|
-
splitList,
|
|
20
|
-
splitDependencies,
|
|
21
|
-
} from "./markdown-utils.mjs";
|
|
22
|
-
import {
|
|
23
|
-
isLessonCandidateDecisionComplete,
|
|
24
|
-
parseLessonCandidateStatus,
|
|
25
|
-
validateLessonCandidateDetailArtifacts,
|
|
26
|
-
} from "./task-lesson-candidates.mjs";
|
|
27
|
-
import {
|
|
28
|
-
assessMaterialsReadiness,
|
|
29
|
-
collectReviewRisks,
|
|
30
|
-
collectStateConflicts,
|
|
31
|
-
deriveLifecycleState,
|
|
32
|
-
deriveReviewQueueState,
|
|
33
|
-
deriveTaskQueues,
|
|
34
|
-
isBlockingReviewRisk,
|
|
35
|
-
parseAgentReviewSubmission,
|
|
36
|
-
parseReviewConfirmation,
|
|
37
|
-
parseTaskIdentity,
|
|
38
|
-
parseTaskTombstone,
|
|
39
|
-
requiresReviewMaterials,
|
|
40
|
-
taskReviewStatus,
|
|
41
|
-
taskScannerVersion,
|
|
42
|
-
} from "./task-review-model.mjs";
|
|
43
|
-
export {
|
|
44
|
-
collectReviewRisks,
|
|
45
|
-
deriveLifecycleState,
|
|
46
|
-
deriveReviewQueueState,
|
|
47
|
-
isBlockingReviewRisk,
|
|
48
|
-
parseAgentReviewSubmission,
|
|
49
|
-
parseReviewConfirmation,
|
|
50
|
-
parseTaskIdentity,
|
|
51
|
-
parseTaskTombstone,
|
|
52
|
-
requiresReviewMaterials,
|
|
53
|
-
taskReviewStatus,
|
|
54
|
-
taskScannerVersion,
|
|
55
|
-
} from "./task-review-model.mjs";
|
|
56
|
-
export {
|
|
57
|
-
allowedLessonCandidateRowStatuses,
|
|
58
|
-
allowedLessonCandidateTaskStatuses,
|
|
59
|
-
isLessonCandidateDecisionComplete,
|
|
60
|
-
parseLessonCandidateStatus,
|
|
61
|
-
reviewCompleteLessonCandidateStatuses,
|
|
62
|
-
} from "./task-lesson-candidates.mjs";
|
|
63
|
-
|
|
64
|
-
export function parseTaskState(progressContent) {
|
|
65
|
-
return parseTaskStateInfo(progressContent).state;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function parseTaskBudget(taskPlanContent) {
|
|
69
|
-
const match =
|
|
70
|
-
String(taskPlanContent || "").match(/^Selected budget\s*[::]\s*([^\n]+)/im) ||
|
|
71
|
-
String(taskPlanContent || "").match(/^选择预算\s*[::]\s*([^\n]+)/im);
|
|
72
|
-
if (!match) return "standard";
|
|
73
|
-
const raw = match[1].replace(/`/g, "").trim().toLowerCase();
|
|
74
|
-
const normalized = raw.replaceAll("_", "-").replace(/\s+/g, "-");
|
|
75
|
-
if (allowedTaskBudgets.has(normalized)) return normalized;
|
|
76
|
-
if (["long-running", "longrunning", "module-parallel"].includes(normalized)) return "complex";
|
|
77
|
-
return "standard";
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function parseMetadataLine(content, labels) {
|
|
81
|
-
const escaped = labels.map((label) => label.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
82
|
-
const match = String(content || "").match(new RegExp(`^(?:${escaped})\\s*[::]\\s*([^\\n]+)`, "im"));
|
|
83
|
-
return match ? match[1].replace(/`/g, "").trim() : "";
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function normalizeMetadataValue(value, fallback = "") {
|
|
87
|
-
const normalized = String(value || "")
|
|
88
|
-
.replace(/`/g, "")
|
|
89
|
-
.trim()
|
|
90
|
-
.toLowerCase()
|
|
91
|
-
.replaceAll("_", "-")
|
|
92
|
-
.replace(/\s+/g, "-");
|
|
93
|
-
return normalized || fallback;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function parseTaskMetadata(taskPlanContent) {
|
|
97
|
-
const content = String(taskPlanContent || "");
|
|
98
|
-
const kind = normalizeMetadataValue(parseMetadataLine(content, ["Task Kind", "任务类型"]), "general");
|
|
99
|
-
const preset = normalizeMetadataValue(parseMetadataLine(content, ["Task Preset", "Preset", "任务预设"]), "none");
|
|
100
|
-
const presetVersion = parseMetadataLine(content, ["Preset Version", "预设版本"]);
|
|
101
|
-
const migrationTargetLevel = normalizeMetadataValue(
|
|
102
|
-
parseMetadataLine(content, ["Migration Target Level", "Target Level", "迁移目标等级", "目标等级"]),
|
|
103
|
-
"",
|
|
104
|
-
);
|
|
105
|
-
const migrationAchievedLevel = normalizeMetadataValue(
|
|
106
|
-
parseMetadataLine(content, ["Migration Achieved Level", "Achieved Level", "迁移实际完成等级", "实际完成等级"]),
|
|
107
|
-
"",
|
|
108
|
-
);
|
|
109
|
-
const evidenceBundle = parseMetadataLine(content, ["Evidence Bundle", "证据包"]);
|
|
110
|
-
return {
|
|
111
|
-
kind,
|
|
112
|
-
preset,
|
|
113
|
-
presetVersion,
|
|
114
|
-
migrationTargetLevel,
|
|
115
|
-
migrationAchievedLevel,
|
|
116
|
-
evidenceBundle,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function parseTaskContractInfo(taskPlanContent) {
|
|
121
|
-
const content = String(taskPlanContent || "");
|
|
122
|
-
const explicit =
|
|
123
|
-
content.match(/^Task Contract\s*[::]\s*`?([^`\n]+)`?\s*$/im) ||
|
|
124
|
-
content.match(/^任务合同\s*[::]\s*`?([^`\n]+)`?\s*$/im);
|
|
125
|
-
const version = explicit ? explicit[1].trim() : "";
|
|
126
|
-
return {
|
|
127
|
-
version,
|
|
128
|
-
generated: version === "harness-task/v1" || content.includes(taskContractMarker),
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export function parseTaskStateInfo(progressContent) {
|
|
133
|
-
const match = progressContent.match(/^##\s*(?:Current Status|Status|状态)\s*[::]?\s*(?:\n\s*)?([^\n]+)/im);
|
|
134
|
-
if (!match) return inferLegacyTaskState(progressContent);
|
|
135
|
-
const raw = match[1].replace(/`/g, "").trim();
|
|
136
|
-
if (!raw || raw.includes("|") || /^[-*]\s+/.test(raw)) return inferLegacyTaskState(progressContent);
|
|
137
|
-
const aliases = new Map([
|
|
138
|
-
["进行中", "in_progress"],
|
|
139
|
-
["已完成", "done"],
|
|
140
|
-
["未开始", "not_started"],
|
|
141
|
-
["计划中", "planned"],
|
|
142
|
-
["审查中", "review"],
|
|
143
|
-
["已阻塞", "blocked"],
|
|
144
|
-
["pending", "planned"],
|
|
145
|
-
]);
|
|
146
|
-
const normalized = aliases.get(raw) || raw.toLowerCase().replaceAll("-", "_").replaceAll(" ", "_");
|
|
147
|
-
return allowedTaskStates.has(normalized)
|
|
148
|
-
? { state: normalized, source: "explicit", raw }
|
|
149
|
-
: { state: "unknown", source: "invalid", raw };
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function inferLegacyTaskState(progressContent) {
|
|
153
|
-
const { header, rows } = tableAfterHeading(progressContent, /^(Status|状态)$/i);
|
|
154
|
-
const statusIndex = firstColumn(header, ["Status", "状态"]);
|
|
155
|
-
if (statusIndex < 0 || rows.length === 0) return { state: "unknown", source: "missing", raw: "" };
|
|
156
|
-
const states = rows.map((row) => normalizeLegacyState(row[statusIndex])).filter(Boolean);
|
|
157
|
-
if (states.includes("blocked")) return { state: "blocked", source: "legacy-table", raw: "blocked" };
|
|
158
|
-
if (states.includes("in_progress")) return { state: "in_progress", source: "legacy-table", raw: "in_progress" };
|
|
159
|
-
if (states.includes("review")) return { state: "review", source: "legacy-table", raw: "review" };
|
|
160
|
-
if (states.length > 0 && states.every((state) => state === "done")) return { state: "done", source: "legacy-table", raw: "done" };
|
|
161
|
-
if (states.some((state) => ["planned", "not_started"].includes(state))) return { state: "planned", source: "legacy-table", raw: "planned" };
|
|
162
|
-
return { state: "unknown", source: "missing", raw: "" };
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function normalizeLegacyState(value) {
|
|
166
|
-
const raw = String(value || "").replace(/`/g, "").trim().toLowerCase();
|
|
167
|
-
if (!raw || /^(none|n\/a|na|-|—|–|无)$/.test(raw)) return "";
|
|
168
|
-
if (/block|阻塞|blocked/.test(raw)) return "blocked";
|
|
169
|
-
if (/in[-_\s]?progress|doing|active|进行中|当前|working/.test(raw)) return "in_progress";
|
|
170
|
-
if (/review|审查|审核|验证中/.test(raw)) return "review";
|
|
171
|
-
if (/done|complete|completed|merged|closed|完成|已完成/.test(raw)) return "done";
|
|
172
|
-
if (/pending|planned|todo|not[-_\s]?started|未开始|计划/.test(raw)) return "planned";
|
|
173
|
-
return "";
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export function parsePhases(taskPlanContent) {
|
|
177
|
-
const { header, rows } = tableAfterHeading(taskPlanContent, /^Phase ID$/i);
|
|
178
|
-
if (rows.length === 0) return [];
|
|
179
|
-
const indexes = {
|
|
180
|
-
id: firstColumn(header, ["Phase ID", "阶段 ID"]),
|
|
181
|
-
dependsOn: firstColumn(header, ["Depends On", "依赖"]),
|
|
182
|
-
state: firstColumn(header, ["State", "状态"]),
|
|
183
|
-
completion: firstColumn(header, ["Completion", "完成度"]),
|
|
184
|
-
output: firstColumn(header, ["Output", "产出"]),
|
|
185
|
-
requiredEvidence: firstColumn(header, ["Required Evidence", "必要证据"]),
|
|
186
|
-
evidenceStatus: firstColumn(header, ["Evidence Status", "证据状态"]),
|
|
187
|
-
blockingRisk: firstColumn(header, ["Blocking Risk", "阻塞风险"]),
|
|
188
|
-
owner: firstColumn(header, ["Owner / Handoff", "负责人 / 交接"]),
|
|
189
|
-
};
|
|
190
|
-
return rows.map((row) => ({
|
|
191
|
-
id: row[indexes.id] || "",
|
|
192
|
-
dependsOn: splitDependencies(row[indexes.dependsOn] || ""),
|
|
193
|
-
state: row[indexes.state] || "planned",
|
|
194
|
-
completion: Number.parseInt(String(row[indexes.completion] || "0").replace("%", ""), 10) || 0,
|
|
195
|
-
output: row[indexes.output] || "",
|
|
196
|
-
requiredEvidence: splitList(row[indexes.requiredEvidence] || ""),
|
|
197
|
-
evidenceStatus: row[indexes.evidenceStatus] || "missing",
|
|
198
|
-
blockingRisk: row[indexes.blockingRisk] || "",
|
|
199
|
-
owner: row[indexes.owner] || "",
|
|
200
|
-
}));
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export function readTaskContractFile(taskDir, fileName, legacyContent = "") {
|
|
204
|
-
const filePath = path.join(taskDir, fileName);
|
|
205
|
-
const content = readFileSafe(filePath);
|
|
206
|
-
if (content.trim()) return { path: filePath, content, source: "standalone" };
|
|
207
|
-
return { path: filePath, content: legacyContent, source: legacyContent.trim() ? "legacy" : "missing" };
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
export function readVisualMapContractFile(taskDir, legacyContent = "") {
|
|
211
|
-
const canonicalPath = path.join(taskDir, visualMapFile);
|
|
212
|
-
const canonical = readFileSafe(canonicalPath);
|
|
213
|
-
if (canonical.trim()) return { path: canonicalPath, content: canonical, source: "canonical", status: "present" };
|
|
214
|
-
const legacyPath = path.join(taskDir, legacyVisualRoadmapFile);
|
|
215
|
-
const legacy = readFileSafe(legacyPath);
|
|
216
|
-
if (legacy.trim()) return { path: legacyPath, content: legacy, source: "legacy", status: "legacy-only" };
|
|
217
|
-
return {
|
|
218
|
-
path: canonicalPath,
|
|
219
|
-
content: legacyContent,
|
|
220
|
-
source: legacyContent.trim() ? "legacy" : "missing",
|
|
221
|
-
status: legacyContent.trim() ? "legacy-only" : "missing",
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export function isActiveTaskState(state) {
|
|
226
|
-
return ["active", "planned", "not_started", "in_progress", "review", "blocked", "reopened", "current-evidence"].includes(state);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export function listTaskPlanPaths(target) {
|
|
230
|
-
const taskRoots = [
|
|
231
|
-
path.join(target.docsRoot, "09-PLANNING/TASKS"),
|
|
232
|
-
path.join(target.docsRoot, "09-PLANNING/MODULES"),
|
|
233
|
-
];
|
|
234
|
-
return taskRoots
|
|
235
|
-
.flatMap(walkFiles)
|
|
236
|
-
.filter((file) => file.endsWith("task_plan.md"))
|
|
237
|
-
.filter((file) => !file.includes(`${path.sep}_task-template${path.sep}`))
|
|
238
|
-
.filter((file) => !file.includes(`${path.sep}_optional-structures${path.sep}`))
|
|
239
|
-
.filter((file) => !file.includes(`${path.sep}_archive${path.sep}`));
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
export function taskIdForDirectory(target, taskDir) {
|
|
243
|
-
return toPosix(path.relative(path.join(target.docsRoot, "09-PLANNING"), taskDir));
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
export function inferTaskClassification({ id, title, relative, explicitModule, legacyCandidate = false }) {
|
|
247
|
-
if (explicitModule) {
|
|
248
|
-
return {
|
|
249
|
-
module: explicitModule,
|
|
250
|
-
source: "explicit",
|
|
251
|
-
bucket: "module",
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
const text = `${id} ${title} ${relative}`.toLowerCase();
|
|
255
|
-
const rules = [
|
|
256
|
-
["dashboard", /dashboard|visibility|cockpit|console|ui|frontend|view|页面|看板|驾驶舱/],
|
|
257
|
-
["migration", /migration|migrate|adoption|legacy|safe-adoption|迁移|历史|兼容/],
|
|
258
|
-
["task-lifecycle", /task|phase|lifecycle|planning|计划|任务|阶段/],
|
|
259
|
-
["review-quality", /review|finding|evidence|qa|test|regression|审查|证据|回归|测试/],
|
|
260
|
-
["release-docs", /docs-release|readme|guide|install|playbook|文档|安装|指南/],
|
|
261
|
-
["repo-governance", /git|ci|source-package|private|boundary|repo|branch|pr|仓库|边界/],
|
|
262
|
-
["automation-cli", /cli|command|script|harness\.mjs|自动化|命令/],
|
|
263
|
-
];
|
|
264
|
-
const match = rules.find(([, pattern]) => pattern.test(text));
|
|
265
|
-
return {
|
|
266
|
-
module: match ? match[0] : legacyCandidate ? "legacy-unclassified" : "unclassified",
|
|
267
|
-
source: match ? "inferred" : "fallback",
|
|
268
|
-
bucket: legacyCandidate ? "legacy" : "current",
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
export function assessBriefQuality(content, { source = "missing" } = {}) {
|
|
273
|
-
const text = String(content || "").trim();
|
|
274
|
-
const issues = [];
|
|
275
|
-
if (source !== "standalone") issues.push("missing-standalone-brief");
|
|
276
|
-
if (text.length < 120) issues.push("too-short");
|
|
277
|
-
if (!/^##\s+/m.test(text)) issues.push("missing-sections");
|
|
278
|
-
if (/\[(?:outcome|scope|risk|evidence|next|目标|范围|风险|证据|下一步)[^\]]*\]/i.test(text)) issues.push("unfilled-placeholder");
|
|
279
|
-
return { status: issues.length ? "fail" : "pass", issues };
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
export function explicitVisualMapStatus(briefContent) {
|
|
283
|
-
const match = String(briefContent || "").match(/^Visual Map Status:\s*(present|not-needed|missing|legacy-only)\s*$/im);
|
|
284
|
-
return match ? match[1] : "";
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
export function taskMigrationClassification(state, visualMapStatus) {
|
|
288
|
-
if (state === "unknown") return "unknown-needs-human";
|
|
289
|
-
if (isActiveTaskState(state)) return "active";
|
|
290
|
-
if (visualMapStatus === "present" || visualMapStatus === "legacy-only") return "historical-with-diagram";
|
|
291
|
-
return "historical-no-map-needed";
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
export function requiresCanonicalVisualMap(task) {
|
|
295
|
-
return ["active", "reopened", "current-evidence", "historical-with-diagram"].includes(task.migrationClassification);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
export function taskCutoverCounters(tasks) {
|
|
299
|
-
const legacyVisualOnlyCount = tasks.filter((task) => task.visualMapStatus === "legacy-only").length;
|
|
300
|
-
const unknownClassificationCount = tasks.filter((task) => task.migrationClassification === "unknown-needs-human").length;
|
|
301
|
-
const weakBriefCount = tasks.filter((task) => task.briefQuality?.status !== "pass").length;
|
|
302
|
-
const visualMapRequiredCount = tasks.filter(requiresCanonicalVisualMap).length;
|
|
303
|
-
const missingCanonicalVisualMapCount = tasks.filter((task) => requiresCanonicalVisualMap(task) && task.visualMapSource !== "canonical").length;
|
|
304
|
-
return {
|
|
305
|
-
legacyVisualOnlyCount,
|
|
306
|
-
unknownClassificationCount,
|
|
307
|
-
weakBriefCount,
|
|
308
|
-
visualMapRequiredCount,
|
|
309
|
-
missingCanonicalVisualMapCount,
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
export function collectTasks(target) {
|
|
314
|
-
return listTaskPlanPaths(target).map((taskPlanPath) => {
|
|
315
|
-
const taskDir = path.dirname(taskPlanPath);
|
|
316
|
-
const taskPlan = readFileSafe(taskPlanPath);
|
|
317
|
-
const brief = readTaskContractFile(taskDir, "brief.md", "");
|
|
318
|
-
const executionStrategyPath = path.join(taskDir, "execution_strategy.md");
|
|
319
|
-
const progressPath = path.join(taskDir, "progress.md");
|
|
320
|
-
const reviewPath = path.join(taskDir, "review.md");
|
|
321
|
-
const findingsPath = path.join(taskDir, "findings.md");
|
|
322
|
-
const lessonCandidatesPath = path.join(taskDir, lessonCandidatesFile);
|
|
323
|
-
const longRunningContractPath = path.join(taskDir, longRunningTaskContractFile);
|
|
324
|
-
const visualMap = readVisualMapContractFile(taskDir, taskPlan);
|
|
325
|
-
const progress = readFileSafe(progressPath);
|
|
326
|
-
const review = readFileSafe(reviewPath);
|
|
327
|
-
const parsedLessonCandidates = parseLessonCandidateStatus(readFileSafe(lessonCandidatesPath));
|
|
328
|
-
const lessonDetailIssues = validateLessonCandidateDetailArtifacts(target, taskDir, parsedLessonCandidates);
|
|
329
|
-
const lessonCandidates = lessonDetailIssues.length
|
|
330
|
-
? { ...parsedLessonCandidates, issues: [...parsedLessonCandidates.issues, ...lessonDetailIssues] }
|
|
331
|
-
: parsedLessonCandidates;
|
|
332
|
-
const phases = parsePhases(visualMap.content);
|
|
333
|
-
const completion =
|
|
334
|
-
phases.length > 0
|
|
335
|
-
? Math.round(
|
|
336
|
-
phases.filter((phase) => phase.state !== "skipped").reduce((sum, phase) => sum + phase.completion, 0) /
|
|
337
|
-
Math.max(1, phases.filter((phase) => phase.state !== "skipped").length),
|
|
338
|
-
)
|
|
339
|
-
: 0;
|
|
340
|
-
const relative = toPosix(path.relative(target.projectRoot, taskDir));
|
|
341
|
-
const id = taskIdForDirectory(target, taskDir);
|
|
342
|
-
const identity = parseTaskIdentity(taskPlan, id);
|
|
343
|
-
const tombstone = parseTaskTombstone(taskPlan);
|
|
344
|
-
const title = titleFromMarkdown(brief.content || taskPlan, path.basename(taskDir));
|
|
345
|
-
const stateInfo = parseTaskStateInfo(progress);
|
|
346
|
-
const budget = parseTaskBudget(taskPlan);
|
|
347
|
-
const metadata = parseTaskMetadata(taskPlan);
|
|
348
|
-
const taskContract = parseTaskContractInfo(taskPlan);
|
|
349
|
-
const explicitModule = id.startsWith("MODULES/") ? id.split("/")[1] : null;
|
|
350
|
-
const legacyCandidate = brief.source !== "standalone" || visualMap.status === "legacy-only" || !fs.existsSync(executionStrategyPath);
|
|
351
|
-
const classification = inferTaskClassification({ id, title, relative, explicitModule, legacyCandidate });
|
|
352
|
-
const briefVisualStatus = explicitVisualMapStatus(brief.content);
|
|
353
|
-
const visualMapStatus = briefVisualStatus === "not-needed" && visualMap.status === "missing" ? "not-needed" : visualMap.status;
|
|
354
|
-
const risks = collectReviewRisks(review);
|
|
355
|
-
const reviewSubmission = parseAgentReviewSubmission(review, { taskKey: identity.taskKey });
|
|
356
|
-
const reviewConfirmation = parseReviewConfirmation(review, {
|
|
357
|
-
taskKey: identity.taskKey,
|
|
358
|
-
projectRoot: target.projectRoot,
|
|
359
|
-
taskDir,
|
|
360
|
-
reviewPath,
|
|
361
|
-
progressPath,
|
|
362
|
-
});
|
|
363
|
-
const reviewStatus = taskReviewStatus({ reviewContent: review, risks, confirmation: reviewConfirmation, submission: reviewSubmission });
|
|
364
|
-
const closeoutInfo = taskCloseoutInfo(target, taskPlanPath);
|
|
365
|
-
const lifecycleState = deriveLifecycleState({ state: stateInfo.state, reviewStatus, closeoutStatus: closeoutInfo.status });
|
|
366
|
-
const materialReadiness = assessMaterialsReadiness({
|
|
367
|
-
budget,
|
|
368
|
-
taskDir,
|
|
369
|
-
taskPlan,
|
|
370
|
-
brief,
|
|
371
|
-
visualMap,
|
|
372
|
-
reviewSubmission,
|
|
373
|
-
lessonCandidates,
|
|
374
|
-
phases,
|
|
375
|
-
longRunningContractPath,
|
|
376
|
-
reviewSurfaceRequired: requiresReviewMaterials({
|
|
377
|
-
state: stateInfo.state,
|
|
378
|
-
lifecycleState,
|
|
379
|
-
closeoutStatus: closeoutInfo.status,
|
|
380
|
-
}),
|
|
381
|
-
});
|
|
382
|
-
const stateConflicts = collectStateConflicts({ state: stateInfo.state, reviewStatus, closeoutStatus: closeoutInfo.status, lifecycleState });
|
|
383
|
-
const reviewQueueState = deriveReviewQueueState({
|
|
384
|
-
state: stateInfo.state,
|
|
385
|
-
lifecycleState,
|
|
386
|
-
reviewStatus,
|
|
387
|
-
closeoutStatus: closeoutInfo.status,
|
|
388
|
-
budget,
|
|
389
|
-
walkthroughPath: closeoutInfo.walkthroughPath,
|
|
390
|
-
lessonCandidateDecisionComplete: isLessonCandidateDecisionComplete(lessonCandidates),
|
|
391
|
-
materialsReady: materialReadiness.ready,
|
|
392
|
-
deletionState: tombstone.deletionState,
|
|
393
|
-
});
|
|
394
|
-
const queueModel = deriveTaskQueues({
|
|
395
|
-
id,
|
|
396
|
-
title,
|
|
397
|
-
state: stateInfo.state,
|
|
398
|
-
budget,
|
|
399
|
-
reviewStatus,
|
|
400
|
-
reviewSubmission,
|
|
401
|
-
reviewConfirmation,
|
|
402
|
-
reviewQueueState,
|
|
403
|
-
materialIssues: materialReadiness.issues,
|
|
404
|
-
risks,
|
|
405
|
-
stateConflicts,
|
|
406
|
-
lessonCandidates,
|
|
407
|
-
closeoutStatus: closeoutInfo.status,
|
|
408
|
-
tombstone,
|
|
409
|
-
taskDir,
|
|
410
|
-
target,
|
|
411
|
-
});
|
|
412
|
-
return {
|
|
413
|
-
id,
|
|
414
|
-
taskKey: identity.taskKey,
|
|
415
|
-
currentPath: `TARGET:${relative}`,
|
|
416
|
-
originalPath: `TARGET:${relative}`,
|
|
417
|
-
aliases: [],
|
|
418
|
-
identitySource: identity.identitySource,
|
|
419
|
-
shortId: path.basename(taskDir),
|
|
420
|
-
title,
|
|
421
|
-
path: `TARGET:${relative}`,
|
|
422
|
-
taskPlanPath: `TARGET:${toPosix(path.relative(target.projectRoot, taskPlanPath))}`,
|
|
423
|
-
executionStrategyPath: `TARGET:${toPosix(path.relative(target.projectRoot, executionStrategyPath))}`,
|
|
424
|
-
progressPath: `TARGET:${toPosix(path.relative(target.projectRoot, progressPath))}`,
|
|
425
|
-
reviewPath: `TARGET:${toPosix(path.relative(target.projectRoot, reviewPath))}`,
|
|
426
|
-
findingsPath: `TARGET:${toPosix(path.relative(target.projectRoot, findingsPath))}`,
|
|
427
|
-
module: explicitModule,
|
|
428
|
-
inferredModule: classification.module,
|
|
429
|
-
classificationSource: classification.source,
|
|
430
|
-
classificationBucket: classification.bucket,
|
|
431
|
-
briefSource: brief.source,
|
|
432
|
-
briefPath: `TARGET:${toPosix(path.relative(target.projectRoot, brief.path))}`,
|
|
433
|
-
visualMapSource: visualMap.source,
|
|
434
|
-
visualMapStatus,
|
|
435
|
-
visualMapPath: `TARGET:${toPosix(path.relative(target.projectRoot, visualMap.path))}`,
|
|
436
|
-
legacyVisualRoadmapPresent: fs.existsSync(path.join(taskDir, legacyVisualRoadmapFile)),
|
|
437
|
-
briefQuality: assessBriefQuality(brief.content, { source: brief.source }),
|
|
438
|
-
migrationClassification: taskMigrationClassification(stateInfo.state, visualMapStatus),
|
|
439
|
-
roadmapSource: visualMap.source,
|
|
440
|
-
state: stateInfo.state,
|
|
441
|
-
budget,
|
|
442
|
-
taskContractVersion: taskContract.version,
|
|
443
|
-
taskContractGenerated: taskContract.generated,
|
|
444
|
-
stateSource: stateInfo.source,
|
|
445
|
-
stateRaw: stateInfo.raw,
|
|
446
|
-
taskKind: metadata.kind,
|
|
447
|
-
taskPreset: metadata.preset,
|
|
448
|
-
presetVersion: metadata.presetVersion,
|
|
449
|
-
migrationTargetLevel: metadata.migrationTargetLevel,
|
|
450
|
-
migrationAchievedLevel: metadata.migrationAchievedLevel,
|
|
451
|
-
evidenceBundle: formatEvidenceBundle(metadata.evidenceBundle),
|
|
452
|
-
migrationSnapshot: collectMigrationSnapshot(target, metadata),
|
|
453
|
-
lifecycleState,
|
|
454
|
-
reviewStatus,
|
|
455
|
-
reviewSubmitted: Boolean(reviewSubmission?.submitted),
|
|
456
|
-
reviewSubmission,
|
|
457
|
-
reviewQueueState,
|
|
458
|
-
reviewConfirmation,
|
|
459
|
-
materialsReady: materialReadiness.ready,
|
|
460
|
-
materialIssues: materialReadiness.issues,
|
|
461
|
-
taskQueues: queueModel.taskQueues,
|
|
462
|
-
queueReasons: queueModel.queueReasons,
|
|
463
|
-
repairPrompt: queueModel.repairPrompt,
|
|
464
|
-
closeoutStatus: closeoutInfo.status,
|
|
465
|
-
walkthroughPath: closeoutInfo.walkthroughPath ? `TARGET:${closeoutInfo.walkthroughPath}` : "",
|
|
466
|
-
lessonCandidatePath: fs.existsSync(lessonCandidatesPath)
|
|
467
|
-
? `TARGET:${toPosix(path.relative(target.projectRoot, lessonCandidatesPath))}`
|
|
468
|
-
: "",
|
|
469
|
-
lessonCandidateStatus: lessonCandidates.status,
|
|
470
|
-
lessonCandidateReviewDecision: lessonCandidates.reviewDecision,
|
|
471
|
-
lessonCandidatePromotionState: lessonCandidates.promotionState,
|
|
472
|
-
lessonCandidateCloseoutToken: lessonCandidates.closeoutToken,
|
|
473
|
-
lessonCandidateRowCount: lessonCandidates.rows.length,
|
|
474
|
-
lessonCandidateRows: lessonCandidates.rows,
|
|
475
|
-
lessonCandidateOpenCount: lessonCandidates.openCount,
|
|
476
|
-
lessonCandidateIssues: lessonCandidates.issues,
|
|
477
|
-
lessonCandidateDecisionComplete: isLessonCandidateDecisionComplete(lessonCandidates),
|
|
478
|
-
longRunningContractPath: fs.existsSync(longRunningContractPath)
|
|
479
|
-
? `TARGET:${toPosix(path.relative(target.projectRoot, longRunningContractPath))}`
|
|
480
|
-
: "",
|
|
481
|
-
longRunningContractStatus: fs.existsSync(longRunningContractPath) ? "present" : "missing",
|
|
482
|
-
deletionState: tombstone.deletionState,
|
|
483
|
-
supersededBy: tombstone.supersededBy,
|
|
484
|
-
supersedes: tombstone.supersedes,
|
|
485
|
-
deleteReason: tombstone.deleteReason,
|
|
486
|
-
hiddenByDefault: tombstone.hiddenByDefault,
|
|
487
|
-
reopenEligible: tombstone.reopenEligible,
|
|
488
|
-
archiveEligible: tombstone.archiveEligible,
|
|
489
|
-
tombstoneSourcePath: tombstone.tombstoneSourcePath
|
|
490
|
-
? `TARGET:${toPosix(path.relative(target.projectRoot, path.join(taskDir, "task_plan.md")))}#Task Tombstone`
|
|
491
|
-
: "",
|
|
492
|
-
stateConflicts,
|
|
493
|
-
completion,
|
|
494
|
-
phases,
|
|
495
|
-
risks,
|
|
496
|
-
evidence: collectEvidence(progress),
|
|
497
|
-
handoffs: collectHandoffs(progress, title),
|
|
498
|
-
dependencies: [],
|
|
499
|
-
};
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
function collectMigrationSnapshot(target, metadata) {
|
|
504
|
-
if (metadata.preset !== "legacy-migration") return null;
|
|
505
|
-
const evidenceBundle = String(metadata.evidenceBundle || "").replace(/^TARGET:/, "").replace(/^\/+/, "");
|
|
506
|
-
const bundlePath = evidenceBundle ? path.join(target.projectRoot, evidenceBundle) : "";
|
|
507
|
-
const sessionPath = bundlePath ? path.join(bundlePath, "session.json") : "";
|
|
508
|
-
let session = null;
|
|
509
|
-
try {
|
|
510
|
-
session = sessionPath && fs.existsSync(sessionPath) ? JSON.parse(fs.readFileSync(sessionPath, "utf8")) : null;
|
|
511
|
-
} catch {
|
|
512
|
-
session = null;
|
|
513
|
-
}
|
|
514
|
-
const summary = session?.plan?.summary || {};
|
|
515
|
-
return {
|
|
516
|
-
targetLevel: metadata.migrationTargetLevel || "",
|
|
517
|
-
achievedLevel: metadata.migrationAchievedLevel || "",
|
|
518
|
-
evidenceBundle: evidenceBundle ? `TARGET:${evidenceBundle}` : "",
|
|
519
|
-
evidencePresent: Boolean(bundlePath && fs.existsSync(bundlePath)),
|
|
520
|
-
sessionPresent: Boolean(session),
|
|
521
|
-
sessionResult: session?.result || "",
|
|
522
|
-
normalStatus: session?.checks?.normal?.status || "",
|
|
523
|
-
strictStatus: session?.checks?.strict?.status || "",
|
|
524
|
-
strictDeferred: Boolean(session?.strictDeferred),
|
|
525
|
-
warnings: Number(summary.warnings || 0),
|
|
526
|
-
taskActions: Number(summary.taskActions || 0),
|
|
527
|
-
reviewSchemaGaps: Number(summary.reviewSchemaGaps || 0),
|
|
528
|
-
legacyReferenceGaps: Number(summary.legacyReferenceGaps || 0),
|
|
529
|
-
legacyResiduals: Number(summary.legacyResiduals || 0),
|
|
530
|
-
fullCutoverEligible: summary.fullCutoverEligible === true,
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
function formatEvidenceBundle(value) {
|
|
535
|
-
const normalized = String(value || "").replace(/^TARGET:/, "").replace(/^\/+/, "");
|
|
536
|
-
return normalized ? `TARGET:${normalized}` : "";
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
function taskCloseoutInfo(target, taskPlanPath) {
|
|
540
|
-
const closeout = readFileSafe(path.join(target.docsRoot, "10-WALKTHROUGH/Closeout-SSoT.md"));
|
|
541
|
-
if (!closeout.trim()) return { status: "missing", walkthroughPath: "" };
|
|
542
|
-
const docsRelative = `docs/${toPosix(path.relative(target.docsRoot, taskPlanPath))}`;
|
|
543
|
-
const projectRelative = toPosix(path.relative(target.projectRoot, taskPlanPath));
|
|
544
|
-
const line = closeout
|
|
545
|
-
.split(/\r?\n/)
|
|
546
|
-
.find((entry) => entry.includes(docsRelative) || entry.includes(projectRelative));
|
|
547
|
-
if (!line) return { status: "missing", walkthroughPath: "" };
|
|
548
|
-
const walkthroughPath = extractWalkthroughPath(target, line);
|
|
549
|
-
const status = /\b(closed|complete|completed|done|skipped-with-reason|skipped|已关闭|已完成|跳过)\b/i.test(line) ? "closed" : "pending";
|
|
550
|
-
return { status, walkthroughPath };
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
function extractWalkthroughPath(target, closeoutLine) {
|
|
554
|
-
const matches = [...String(closeoutLine || "").matchAll(/`?((?:docs\/)?10-WALKTHROUGH\/[^`|\s]+\.md)`?/g)];
|
|
555
|
-
const match = matches.find((entry) => !entry[1].endsWith("Closeout-SSoT.md") && !entry[1].includes("/_"));
|
|
556
|
-
if (!match) return "";
|
|
557
|
-
const projectRelative = match[1].startsWith("docs/") ? match[1] : `docs/${match[1]}`;
|
|
558
|
-
if (!fs.existsSync(path.join(target.projectRoot, projectRelative))) return "";
|
|
559
|
-
return projectRelative;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
function collectHandoffs(progressContent, taskId) {
|
|
563
|
-
if (!/Coordinator Handoff/i.test(progressContent) || !/pending-coordinator-pass/i.test(progressContent)) return [];
|
|
564
|
-
return [{ id: `H-${taskId}`, from: "worker", to: "coordinator", state: "pending", summary: "Coordinator handoff pending" }];
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
function collectEvidence(progressContent) {
|
|
568
|
-
const matches = [...progressContent.matchAll(/\b(command|diff|fixture|screenshot|review|report):((?:PUBLIC|PRIVATE|TARGET|EXTERNAL|URL):[^:\s|]+):([^\n|]+)/g)];
|
|
569
|
-
return matches.map((match, index) => ({
|
|
570
|
-
id: `E-${String(index + 1).padStart(3, "0")}`,
|
|
571
|
-
type: match[1],
|
|
572
|
-
path: match[2],
|
|
573
|
-
status: "present",
|
|
574
|
-
summary: match[3].trim(),
|
|
575
|
-
}));
|
|
576
|
-
}
|