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,503 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
visualMapFile,
|
|
5
|
-
legacyVisualRoadmapFile,
|
|
6
|
-
lessonCandidatesFile,
|
|
7
|
-
longRunningTaskContractFile,
|
|
8
|
-
toPosix,
|
|
9
|
-
readFileSafe,
|
|
10
|
-
readJsonSafe,
|
|
11
|
-
walkFiles,
|
|
12
|
-
titleFromMarkdown,
|
|
13
|
-
} from "./core-shared.mjs";
|
|
14
|
-
import {
|
|
15
|
-
tableAfterHeading,
|
|
16
|
-
firstColumn,
|
|
17
|
-
splitList,
|
|
18
|
-
splitDependencies,
|
|
19
|
-
} from "./markdown-utils.mjs";
|
|
20
|
-
import {
|
|
21
|
-
normalizePhaseActor,
|
|
22
|
-
normalizePhaseKind,
|
|
23
|
-
phaseCompletionAverage,
|
|
24
|
-
} from "./phase-kind.mjs";
|
|
25
|
-
import {
|
|
26
|
-
legacyAuditIssues,
|
|
27
|
-
parseTaskAuditMetadata,
|
|
28
|
-
scaffoldProvenanceSummaryFromTaskAudit,
|
|
29
|
-
taskAuditMaterialIssues,
|
|
30
|
-
} from "./task-audit-metadata.mjs";
|
|
31
|
-
import {
|
|
32
|
-
parseTaskBudget,
|
|
33
|
-
parseTaskContractInfo,
|
|
34
|
-
parseTaskMetadata,
|
|
35
|
-
parseTaskStateInfo,
|
|
36
|
-
} from "./task-metadata.mjs";
|
|
37
|
-
import {
|
|
38
|
-
isLessonCandidateDecisionComplete,
|
|
39
|
-
parseLessonCandidateStatus,
|
|
40
|
-
validateLessonCandidateDetailArtifacts,
|
|
41
|
-
} from "./task-lesson-candidates.mjs";
|
|
42
|
-
import {
|
|
43
|
-
assessMaterialsReadiness,
|
|
44
|
-
collectReviewRisks,
|
|
45
|
-
collectStateConflicts,
|
|
46
|
-
deriveLifecycleState,
|
|
47
|
-
deriveReviewQueueState,
|
|
48
|
-
deriveTaskQueues,
|
|
49
|
-
isBlockingReviewRisk,
|
|
50
|
-
parseAgentReviewSubmission,
|
|
51
|
-
parseReviewConfirmation,
|
|
52
|
-
parseTaskIdentity,
|
|
53
|
-
parseTaskTombstone,
|
|
54
|
-
requiresReviewMaterials,
|
|
55
|
-
taskReviewStatus,
|
|
56
|
-
taskScannerVersion,
|
|
57
|
-
} from "./task-review-model.mjs";
|
|
58
|
-
export {
|
|
59
|
-
parseTaskBudget,
|
|
60
|
-
parseTaskContractInfo,
|
|
61
|
-
parseTaskMetadata,
|
|
62
|
-
parseTaskState,
|
|
63
|
-
parseTaskStateInfo,
|
|
64
|
-
} from "./task-metadata.mjs";
|
|
65
|
-
export {
|
|
66
|
-
collectReviewRisks,
|
|
67
|
-
deriveLifecycleState,
|
|
68
|
-
deriveReviewQueueState,
|
|
69
|
-
isBlockingReviewRisk,
|
|
70
|
-
parseAgentReviewSubmission,
|
|
71
|
-
parseReviewConfirmation,
|
|
72
|
-
parseTaskIdentity,
|
|
73
|
-
parseTaskTombstone,
|
|
74
|
-
requiresReviewMaterials,
|
|
75
|
-
taskReviewStatus,
|
|
76
|
-
taskScannerVersion,
|
|
77
|
-
} from "./task-review-model.mjs";
|
|
78
|
-
export {
|
|
79
|
-
parseTaskAuditMetadata,
|
|
80
|
-
} from "./task-audit-metadata.mjs";
|
|
81
|
-
export {
|
|
82
|
-
allowedLessonCandidateRowStatuses,
|
|
83
|
-
allowedLessonCandidateTaskStatuses,
|
|
84
|
-
isLessonCandidateDecisionComplete,
|
|
85
|
-
parseLessonCandidateStatus,
|
|
86
|
-
reviewCompleteLessonCandidateStatuses,
|
|
87
|
-
} from "./task-lesson-candidates.mjs";
|
|
88
|
-
|
|
89
|
-
export function parsePhases(taskPlanContent) {
|
|
90
|
-
const { header, rows } = tableAfterHeading(taskPlanContent, /^Phase ID$/i);
|
|
91
|
-
if (rows.length === 0) return [];
|
|
92
|
-
const indexes = {
|
|
93
|
-
id: firstColumn(header, ["Phase ID", "阶段 ID"]),
|
|
94
|
-
kind: firstColumn(header, ["Kind", "阶段类型", "类型"]),
|
|
95
|
-
dependsOn: firstColumn(header, ["Depends On", "依赖"]),
|
|
96
|
-
state: firstColumn(header, ["State", "状态"]),
|
|
97
|
-
completion: firstColumn(header, ["Completion", "完成度"]),
|
|
98
|
-
output: firstColumn(header, ["Output", "产出"]),
|
|
99
|
-
requiredEvidence: firstColumn(header, ["Required Evidence", "必要证据"]),
|
|
100
|
-
exitCommand: firstColumn(header, ["Exit Command", "出口命令", "退出命令"]),
|
|
101
|
-
actor: firstColumn(header, ["Actor", "执行者", "角色"]),
|
|
102
|
-
evidenceStatus: firstColumn(header, ["Evidence Status", "证据状态"]),
|
|
103
|
-
blockingRisk: firstColumn(header, ["Blocking Risk", "阻塞风险"]),
|
|
104
|
-
owner: firstColumn(header, ["Owner / Handoff", "负责人 / 交接"]),
|
|
105
|
-
};
|
|
106
|
-
return rows.map((row) => ({
|
|
107
|
-
id: row[indexes.id] || "",
|
|
108
|
-
kind: normalizePhaseKind(row[indexes.kind]),
|
|
109
|
-
dependsOn: splitDependencies(row[indexes.dependsOn] || ""),
|
|
110
|
-
state: row[indexes.state] || "planned",
|
|
111
|
-
completion: Number.parseInt(String(row[indexes.completion] || "0").replace("%", ""), 10) || 0,
|
|
112
|
-
output: row[indexes.output] || "",
|
|
113
|
-
requiredEvidence: splitList(row[indexes.requiredEvidence] || ""),
|
|
114
|
-
exitCommand: row[indexes.exitCommand] || "",
|
|
115
|
-
actor: normalizePhaseActor(row[indexes.actor]),
|
|
116
|
-
evidenceStatus: row[indexes.evidenceStatus] || "missing",
|
|
117
|
-
blockingRisk: row[indexes.blockingRisk] || "",
|
|
118
|
-
owner: row[indexes.owner] || "",
|
|
119
|
-
}));
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export function readTaskContractFile(taskDir, fileName, legacyContent = "") {
|
|
123
|
-
const filePath = path.join(taskDir, fileName);
|
|
124
|
-
const content = readFileSafe(filePath);
|
|
125
|
-
if (content.trim()) return { path: filePath, content, source: "standalone" };
|
|
126
|
-
return { path: filePath, content: legacyContent, source: legacyContent.trim() ? "legacy" : "missing" };
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export function readVisualMapContractFile(taskDir, legacyContent = "") {
|
|
130
|
-
const canonicalPath = path.join(taskDir, visualMapFile);
|
|
131
|
-
const canonical = readFileSafe(canonicalPath);
|
|
132
|
-
if (canonical.trim()) return { path: canonicalPath, content: canonical, source: "canonical", status: "present" };
|
|
133
|
-
const legacyPath = path.join(taskDir, legacyVisualRoadmapFile);
|
|
134
|
-
const legacy = readFileSafe(legacyPath);
|
|
135
|
-
if (legacy.trim()) return { path: legacyPath, content: legacy, source: "legacy", status: "legacy-only" };
|
|
136
|
-
return {
|
|
137
|
-
path: canonicalPath,
|
|
138
|
-
content: legacyContent,
|
|
139
|
-
source: legacyContent.trim() ? "legacy" : "missing",
|
|
140
|
-
status: legacyContent.trim() ? "legacy-only" : "missing",
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function isActiveTaskState(state) {
|
|
145
|
-
return ["active", "planned", "not_started", "in_progress", "review", "blocked", "reopened", "current-evidence"].includes(state);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export function listTaskPlanPaths(target) {
|
|
149
|
-
const taskRoots = [
|
|
150
|
-
path.join(target.docsRoot, "09-PLANNING/TASKS"),
|
|
151
|
-
path.join(target.docsRoot, "09-PLANNING/MODULES"),
|
|
152
|
-
];
|
|
153
|
-
return taskRoots
|
|
154
|
-
.flatMap(walkFiles)
|
|
155
|
-
.filter((file) => file.endsWith("task_plan.md"))
|
|
156
|
-
.filter((file) => !file.includes(`${path.sep}_task-template${path.sep}`))
|
|
157
|
-
.filter((file) => !file.includes(`${path.sep}_optional-structures${path.sep}`))
|
|
158
|
-
.filter((file) => !file.includes(`${path.sep}_archive${path.sep}`));
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export function taskIdForDirectory(target, taskDir) {
|
|
162
|
-
return toPosix(path.relative(path.join(target.docsRoot, "09-PLANNING"), taskDir));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export function inferTaskClassification({ id, title, relative, explicitModule, legacyCandidate = false }) {
|
|
166
|
-
if (explicitModule) {
|
|
167
|
-
return {
|
|
168
|
-
module: explicitModule,
|
|
169
|
-
source: "explicit",
|
|
170
|
-
bucket: "module",
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
const text = `${id} ${title} ${relative}`.toLowerCase();
|
|
174
|
-
const rules = [
|
|
175
|
-
["dashboard", /dashboard|visibility|cockpit|console|ui|frontend|view|页面|看板|驾驶舱/],
|
|
176
|
-
["migration", /migration|migrate|adoption|legacy|safe-adoption|迁移|历史|兼容/],
|
|
177
|
-
["task-lifecycle", /task|phase|lifecycle|planning|计划|任务|阶段/],
|
|
178
|
-
["review-quality", /review|finding|evidence|qa|test|regression|审查|证据|回归|测试/],
|
|
179
|
-
["release-docs", /docs-release|readme|guide|install|playbook|文档|安装|指南/],
|
|
180
|
-
["repo-governance", /git|ci|source-package|private|boundary|repo|branch|pr|仓库|边界/],
|
|
181
|
-
["automation-cli", /cli|command|script|harness\.mjs|自动化|命令/],
|
|
182
|
-
];
|
|
183
|
-
const match = rules.find(([, pattern]) => pattern.test(text));
|
|
184
|
-
return {
|
|
185
|
-
module: match ? match[0] : legacyCandidate ? "legacy-unclassified" : "unclassified",
|
|
186
|
-
source: match ? "inferred" : "fallback",
|
|
187
|
-
bucket: legacyCandidate ? "legacy" : "current",
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export function assessBriefQuality(content, { source = "missing" } = {}) {
|
|
192
|
-
const text = String(content || "").trim();
|
|
193
|
-
const issues = [];
|
|
194
|
-
if (source !== "standalone") issues.push("missing-standalone-brief");
|
|
195
|
-
if (text.length < 120) issues.push("too-short");
|
|
196
|
-
if (!/^##\s+/m.test(text)) issues.push("missing-sections");
|
|
197
|
-
if (/\[(?:outcome|scope|risk|evidence|next|目标|范围|风险|证据|下一步)[^\]]*\]/i.test(text)) issues.push("unfilled-placeholder");
|
|
198
|
-
return { status: issues.length ? "fail" : "pass", issues };
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export function explicitVisualMapStatus(briefContent) {
|
|
202
|
-
const match = String(briefContent || "").match(/^Visual Map Status:\s*(present|not-needed|missing|legacy-only)\s*$/im);
|
|
203
|
-
return match ? match[1] : "";
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export function taskMigrationClassification(state, visualMapStatus) {
|
|
207
|
-
if (state === "unknown") return "unknown-needs-human";
|
|
208
|
-
if (isActiveTaskState(state)) return "active";
|
|
209
|
-
if (visualMapStatus === "present" || visualMapStatus === "legacy-only") return "historical-with-diagram";
|
|
210
|
-
return "historical-no-map-needed";
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export function requiresCanonicalVisualMap(task) {
|
|
214
|
-
return ["active", "reopened", "current-evidence", "historical-with-diagram"].includes(task.migrationClassification);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export function taskCutoverCounters(tasks) {
|
|
218
|
-
const legacyVisualOnlyCount = tasks.filter((task) => task.visualMapStatus === "legacy-only").length;
|
|
219
|
-
const unknownClassificationCount = tasks.filter((task) => task.migrationClassification === "unknown-needs-human").length;
|
|
220
|
-
const weakBriefCount = tasks.filter((task) => task.briefQuality?.status !== "pass").length;
|
|
221
|
-
const visualMapRequiredCount = tasks.filter(requiresCanonicalVisualMap).length;
|
|
222
|
-
const missingCanonicalVisualMapCount = tasks.filter((task) => requiresCanonicalVisualMap(task) && task.visualMapSource !== "canonical").length;
|
|
223
|
-
return {
|
|
224
|
-
legacyVisualOnlyCount,
|
|
225
|
-
unknownClassificationCount,
|
|
226
|
-
weakBriefCount,
|
|
227
|
-
visualMapRequiredCount,
|
|
228
|
-
missingCanonicalVisualMapCount,
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export function collectTasks(target, { requireGeneratedScaffoldProvenance = false, taskPlanPaths, closeoutContent } = {}) {
|
|
233
|
-
const paths = taskPlanPaths || listTaskPlanPaths(target);
|
|
234
|
-
const closeout = closeoutContent ?? readFileSafe(path.join(target.docsRoot, "10-WALKTHROUGH/Closeout-SSoT.md"));
|
|
235
|
-
return paths.map((taskPlanPath) => {
|
|
236
|
-
const taskDir = path.dirname(taskPlanPath);
|
|
237
|
-
const taskPlan = readFileSafe(taskPlanPath);
|
|
238
|
-
const brief = readTaskContractFile(taskDir, "brief.md", "");
|
|
239
|
-
const executionStrategyPath = path.join(taskDir, "execution_strategy.md");
|
|
240
|
-
const indexPath = path.join(taskDir, "INDEX.md");
|
|
241
|
-
const progressPath = path.join(taskDir, "progress.md");
|
|
242
|
-
const reviewPath = path.join(taskDir, "review.md");
|
|
243
|
-
const findingsPath = path.join(taskDir, "findings.md");
|
|
244
|
-
const lessonCandidatesPath = path.join(taskDir, lessonCandidatesFile);
|
|
245
|
-
const longRunningContractPath = path.join(taskDir, longRunningTaskContractFile);
|
|
246
|
-
const visualMap = readVisualMapContractFile(taskDir, taskPlan);
|
|
247
|
-
const progress = readFileSafe(progressPath);
|
|
248
|
-
const review = readFileSafe(reviewPath);
|
|
249
|
-
const indexContent = readFileSafe(indexPath);
|
|
250
|
-
const parsedLessonCandidates = parseLessonCandidateStatus(readFileSafe(lessonCandidatesPath));
|
|
251
|
-
const lessonDetailIssues = validateLessonCandidateDetailArtifacts(target, taskDir, parsedLessonCandidates);
|
|
252
|
-
const lessonCandidates = lessonDetailIssues.length
|
|
253
|
-
? { ...parsedLessonCandidates, issues: [...parsedLessonCandidates.issues, ...lessonDetailIssues] }
|
|
254
|
-
: parsedLessonCandidates;
|
|
255
|
-
const phases = parsePhases(visualMap.content);
|
|
256
|
-
const completion = phaseCompletionAverage(phases);
|
|
257
|
-
const relative = toPosix(path.relative(target.projectRoot, taskDir));
|
|
258
|
-
const id = taskIdForDirectory(target, taskDir);
|
|
259
|
-
const identity = parseTaskIdentity(taskPlan, id);
|
|
260
|
-
const tombstone = parseTaskTombstone(taskPlan);
|
|
261
|
-
const title = titleFromMarkdown(brief.content || taskPlan, path.basename(taskDir));
|
|
262
|
-
const stateInfo = parseTaskStateInfo(progress);
|
|
263
|
-
const budget = parseTaskBudget(taskPlan);
|
|
264
|
-
const metadata = parseTaskMetadata(taskPlan);
|
|
265
|
-
const taskContract = parseTaskContractInfo(taskPlan);
|
|
266
|
-
const taskAudit = parseTaskAuditMetadata(indexContent, {
|
|
267
|
-
required: requireGeneratedScaffoldProvenance && taskContract.generated,
|
|
268
|
-
});
|
|
269
|
-
const scaffoldProvenance = { summary: scaffoldProvenanceSummaryFromTaskAudit(taskAudit) };
|
|
270
|
-
const explicitModule = id.startsWith("MODULES/") ? id.split("/")[1] : null;
|
|
271
|
-
const legacyCandidate = brief.source !== "standalone" || visualMap.status === "legacy-only" || !fs.existsSync(executionStrategyPath);
|
|
272
|
-
const classification = inferTaskClassification({ id, title, relative, explicitModule, legacyCandidate });
|
|
273
|
-
const briefVisualStatus = explicitVisualMapStatus(brief.content);
|
|
274
|
-
const visualMapStatus = briefVisualStatus === "not-needed" && visualMap.status === "missing" ? "not-needed" : visualMap.status;
|
|
275
|
-
const risks = collectReviewRisks(review);
|
|
276
|
-
const reviewSubmission = parseAgentReviewSubmission(review, { taskKey: identity.taskKey });
|
|
277
|
-
const reviewConfirmation = parseReviewConfirmation(review, {
|
|
278
|
-
taskKey: identity.taskKey,
|
|
279
|
-
taskAudit,
|
|
280
|
-
projectRoot: target.projectRoot,
|
|
281
|
-
taskDir,
|
|
282
|
-
indexPath,
|
|
283
|
-
reviewPath,
|
|
284
|
-
progressPath,
|
|
285
|
-
});
|
|
286
|
-
const reviewStatus = taskReviewStatus({ reviewContent: review, risks, confirmation: reviewConfirmation, submission: reviewSubmission });
|
|
287
|
-
const closeoutInfo = taskCloseoutInfo(target, taskPlanPath, closeout);
|
|
288
|
-
const effectiveCloseoutStatus = budget === "simple" && stateInfo.state === "done" && completion === 100
|
|
289
|
-
? "closed"
|
|
290
|
-
: closeoutInfo.status;
|
|
291
|
-
const lifecycleState = deriveLifecycleState({ state: stateInfo.state, reviewStatus, closeoutStatus: effectiveCloseoutStatus, budget });
|
|
292
|
-
const materialReadiness = assessMaterialsReadiness({
|
|
293
|
-
budget,
|
|
294
|
-
taskDir,
|
|
295
|
-
taskPlan,
|
|
296
|
-
brief,
|
|
297
|
-
visualMap,
|
|
298
|
-
reviewSubmission,
|
|
299
|
-
lessonCandidates,
|
|
300
|
-
phases,
|
|
301
|
-
longRunningContractPath,
|
|
302
|
-
reviewSurfaceRequired: requiresReviewMaterials({
|
|
303
|
-
state: stateInfo.state,
|
|
304
|
-
lifecycleState,
|
|
305
|
-
closeoutStatus: effectiveCloseoutStatus,
|
|
306
|
-
}),
|
|
307
|
-
});
|
|
308
|
-
const materialIssues = [
|
|
309
|
-
...materialReadiness.issues,
|
|
310
|
-
...taskAuditMaterialIssues(target, taskDir, taskAudit),
|
|
311
|
-
...legacyAuditIssues(target, taskDir, { briefContent: brief.content, reviewContent: review }),
|
|
312
|
-
];
|
|
313
|
-
const stateConflicts = collectStateConflicts({ state: stateInfo.state, reviewStatus, closeoutStatus: effectiveCloseoutStatus, lifecycleState, budget });
|
|
314
|
-
const reviewQueueState = deriveReviewQueueState({
|
|
315
|
-
state: stateInfo.state,
|
|
316
|
-
lifecycleState,
|
|
317
|
-
reviewStatus,
|
|
318
|
-
closeoutStatus: effectiveCloseoutStatus,
|
|
319
|
-
budget,
|
|
320
|
-
walkthroughPath: closeoutInfo.walkthroughPath,
|
|
321
|
-
lessonCandidateDecisionComplete: isLessonCandidateDecisionComplete(lessonCandidates),
|
|
322
|
-
materialsReady: materialIssues.length === 0,
|
|
323
|
-
deletionState: tombstone.deletionState,
|
|
324
|
-
});
|
|
325
|
-
const queueModel = deriveTaskQueues({
|
|
326
|
-
id,
|
|
327
|
-
title,
|
|
328
|
-
state: stateInfo.state,
|
|
329
|
-
budget,
|
|
330
|
-
reviewStatus,
|
|
331
|
-
reviewSubmission,
|
|
332
|
-
reviewConfirmation,
|
|
333
|
-
reviewQueueState,
|
|
334
|
-
materialIssues,
|
|
335
|
-
risks,
|
|
336
|
-
stateConflicts,
|
|
337
|
-
lessonCandidates,
|
|
338
|
-
closeoutStatus: effectiveCloseoutStatus,
|
|
339
|
-
tombstone,
|
|
340
|
-
taskDir,
|
|
341
|
-
target,
|
|
342
|
-
});
|
|
343
|
-
return {
|
|
344
|
-
id,
|
|
345
|
-
taskKey: identity.taskKey,
|
|
346
|
-
currentPath: `TARGET:${relative}`,
|
|
347
|
-
originalPath: `TARGET:${relative}`,
|
|
348
|
-
aliases: [],
|
|
349
|
-
identitySource: identity.identitySource,
|
|
350
|
-
shortId: path.basename(taskDir),
|
|
351
|
-
title,
|
|
352
|
-
path: `TARGET:${relative}`,
|
|
353
|
-
taskPlanPath: `TARGET:${toPosix(path.relative(target.projectRoot, taskPlanPath))}`,
|
|
354
|
-
executionStrategyPath: `TARGET:${toPosix(path.relative(target.projectRoot, executionStrategyPath))}`,
|
|
355
|
-
progressPath: `TARGET:${toPosix(path.relative(target.projectRoot, progressPath))}`,
|
|
356
|
-
reviewPath: `TARGET:${toPosix(path.relative(target.projectRoot, reviewPath))}`,
|
|
357
|
-
findingsPath: `TARGET:${toPosix(path.relative(target.projectRoot, findingsPath))}`,
|
|
358
|
-
module: explicitModule,
|
|
359
|
-
inferredModule: classification.module,
|
|
360
|
-
classificationSource: classification.source,
|
|
361
|
-
classificationBucket: classification.bucket,
|
|
362
|
-
briefSource: brief.source,
|
|
363
|
-
briefPath: `TARGET:${toPosix(path.relative(target.projectRoot, brief.path))}`,
|
|
364
|
-
visualMapSource: visualMap.source,
|
|
365
|
-
visualMapStatus,
|
|
366
|
-
visualMapPath: `TARGET:${toPosix(path.relative(target.projectRoot, visualMap.path))}`,
|
|
367
|
-
legacyVisualRoadmapPresent: fs.existsSync(path.join(taskDir, legacyVisualRoadmapFile)),
|
|
368
|
-
briefQuality: assessBriefQuality(brief.content, { source: brief.source }),
|
|
369
|
-
migrationClassification: taskMigrationClassification(stateInfo.state, visualMapStatus),
|
|
370
|
-
roadmapSource: visualMap.source,
|
|
371
|
-
state: stateInfo.state,
|
|
372
|
-
budget,
|
|
373
|
-
taskContractVersion: taskContract.version,
|
|
374
|
-
taskContractGenerated: taskContract.generated,
|
|
375
|
-
stateSource: stateInfo.source,
|
|
376
|
-
stateRaw: stateInfo.raw,
|
|
377
|
-
taskKind: metadata.kind,
|
|
378
|
-
taskPreset: metadata.preset,
|
|
379
|
-
presetVersion: metadata.presetVersion,
|
|
380
|
-
migrationTargetLevel: metadata.migrationTargetLevel,
|
|
381
|
-
migrationAchievedLevel: metadata.migrationAchievedLevel,
|
|
382
|
-
evidenceBundle: formatEvidenceBundle(metadata.evidenceBundle),
|
|
383
|
-
migrationSnapshot: collectMigrationSnapshot(target, metadata),
|
|
384
|
-
scaffoldProvenance: scaffoldProvenance.summary,
|
|
385
|
-
taskAudit: taskAudit.summary,
|
|
386
|
-
lifecycleState,
|
|
387
|
-
reviewStatus,
|
|
388
|
-
reviewSubmitted: Boolean(reviewSubmission?.submitted),
|
|
389
|
-
reviewSubmission,
|
|
390
|
-
reviewQueueState,
|
|
391
|
-
reviewConfirmation,
|
|
392
|
-
materialsReady: materialIssues.length === 0,
|
|
393
|
-
materialIssues,
|
|
394
|
-
taskQueues: queueModel.taskQueues,
|
|
395
|
-
queueReasons: queueModel.queueReasons,
|
|
396
|
-
repairPrompt: queueModel.repairPrompt,
|
|
397
|
-
closeoutStatus: effectiveCloseoutStatus,
|
|
398
|
-
walkthroughPath: closeoutInfo.walkthroughPath ? `TARGET:${closeoutInfo.walkthroughPath}` : "",
|
|
399
|
-
lessonCandidatePath: fs.existsSync(lessonCandidatesPath)
|
|
400
|
-
? `TARGET:${toPosix(path.relative(target.projectRoot, lessonCandidatesPath))}`
|
|
401
|
-
: "",
|
|
402
|
-
lessonCandidateStatus: lessonCandidates.status,
|
|
403
|
-
lessonCandidateReviewDecision: lessonCandidates.reviewDecision,
|
|
404
|
-
lessonCandidatePromotionState: lessonCandidates.promotionState,
|
|
405
|
-
lessonCandidateCloseoutToken: lessonCandidates.closeoutToken,
|
|
406
|
-
lessonCandidateRowCount: lessonCandidates.rows.length,
|
|
407
|
-
lessonCandidateRows: lessonCandidates.rows,
|
|
408
|
-
lessonCandidateOpenCount: lessonCandidates.openCount,
|
|
409
|
-
lessonCandidateIssues: lessonCandidates.issues,
|
|
410
|
-
lessonCandidateDecisionComplete: isLessonCandidateDecisionComplete(lessonCandidates),
|
|
411
|
-
longRunningContractPath: fs.existsSync(longRunningContractPath)
|
|
412
|
-
? `TARGET:${toPosix(path.relative(target.projectRoot, longRunningContractPath))}`
|
|
413
|
-
: "",
|
|
414
|
-
longRunningContractStatus: fs.existsSync(longRunningContractPath) ? "present" : "missing",
|
|
415
|
-
deletionState: tombstone.deletionState,
|
|
416
|
-
supersededBy: tombstone.supersededBy,
|
|
417
|
-
supersedes: tombstone.supersedes,
|
|
418
|
-
deleteReason: tombstone.deleteReason,
|
|
419
|
-
hiddenByDefault: tombstone.hiddenByDefault,
|
|
420
|
-
reopenEligible: tombstone.reopenEligible,
|
|
421
|
-
archiveEligible: tombstone.archiveEligible,
|
|
422
|
-
tombstoneSourcePath: tombstone.tombstoneSourcePath
|
|
423
|
-
? `TARGET:${toPosix(path.relative(target.projectRoot, path.join(taskDir, "task_plan.md")))}#Task Tombstone`
|
|
424
|
-
: "",
|
|
425
|
-
stateConflicts,
|
|
426
|
-
completion,
|
|
427
|
-
phases,
|
|
428
|
-
risks,
|
|
429
|
-
evidence: collectEvidence(progress),
|
|
430
|
-
handoffs: collectHandoffs(progress, title),
|
|
431
|
-
dependencies: [],
|
|
432
|
-
};
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
function collectMigrationSnapshot(target, metadata) {
|
|
437
|
-
if (metadata.preset !== "legacy-migration") return null;
|
|
438
|
-
const evidenceBundle = String(metadata.evidenceBundle || "").replace(/^TARGET:/, "").replace(/^\/+/, "");
|
|
439
|
-
const bundlePath = evidenceBundle ? path.join(target.projectRoot, evidenceBundle) : "";
|
|
440
|
-
const sessionPath = bundlePath ? path.join(bundlePath, "session.json") : "";
|
|
441
|
-
const session = sessionPath && fs.existsSync(sessionPath) ? readJsonSafe(sessionPath, null) : null;
|
|
442
|
-
const summary = session?.plan?.summary || {};
|
|
443
|
-
return {
|
|
444
|
-
targetLevel: metadata.migrationTargetLevel || "",
|
|
445
|
-
achievedLevel: metadata.migrationAchievedLevel || "",
|
|
446
|
-
evidenceBundle: evidenceBundle ? `TARGET:${evidenceBundle}` : "",
|
|
447
|
-
evidencePresent: Boolean(bundlePath && fs.existsSync(bundlePath)),
|
|
448
|
-
sessionPresent: Boolean(session),
|
|
449
|
-
sessionResult: session?.result || "",
|
|
450
|
-
normalStatus: session?.checks?.normal?.status || "",
|
|
451
|
-
strictStatus: session?.checks?.strict?.status || "",
|
|
452
|
-
strictDeferred: Boolean(session?.strictDeferred),
|
|
453
|
-
warnings: Number(summary.warnings || 0),
|
|
454
|
-
taskActions: Number(summary.taskActions || 0),
|
|
455
|
-
reviewSchemaGaps: Number(summary.reviewSchemaGaps || 0),
|
|
456
|
-
legacyReferenceGaps: Number(summary.legacyReferenceGaps || 0),
|
|
457
|
-
legacyResiduals: Number(summary.legacyResiduals || 0),
|
|
458
|
-
fullCutoverEligible: summary.fullCutoverEligible === true,
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
function formatEvidenceBundle(value) {
|
|
463
|
-
const normalized = String(value || "").replace(/^TARGET:/, "").replace(/^\/+/, "");
|
|
464
|
-
return normalized ? `TARGET:${normalized}` : "";
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
function taskCloseoutInfo(target, taskPlanPath, closeout) {
|
|
468
|
-
if (!closeout.trim()) return { status: "missing", walkthroughPath: "" };
|
|
469
|
-
const docsRelative = `docs/${toPosix(path.relative(target.docsRoot, taskPlanPath))}`;
|
|
470
|
-
const projectRelative = toPosix(path.relative(target.projectRoot, taskPlanPath));
|
|
471
|
-
const line = closeout
|
|
472
|
-
.split(/\r?\n/)
|
|
473
|
-
.find((entry) => entry.includes(docsRelative) || entry.includes(projectRelative));
|
|
474
|
-
if (!line) return { status: "missing", walkthroughPath: "" };
|
|
475
|
-
const walkthroughPath = extractWalkthroughPath(target, line);
|
|
476
|
-
const status = /\b(closed|complete|completed|done|skipped-with-reason|skipped|已关闭|已完成|跳过)\b/i.test(line) ? "closed" : "pending";
|
|
477
|
-
return { status, walkthroughPath };
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
function extractWalkthroughPath(target, closeoutLine) {
|
|
481
|
-
const matches = [...String(closeoutLine || "").matchAll(/`?((?:docs\/)?10-WALKTHROUGH\/[^`|\s]+\.md)`?/g)];
|
|
482
|
-
const match = matches.find((entry) => !entry[1].endsWith("Closeout-SSoT.md") && !entry[1].includes("/_"));
|
|
483
|
-
if (!match) return "";
|
|
484
|
-
const projectRelative = match[1].startsWith("docs/") ? match[1] : `docs/${match[1]}`;
|
|
485
|
-
if (!fs.existsSync(path.join(target.projectRoot, projectRelative))) return "";
|
|
486
|
-
return projectRelative;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
function collectHandoffs(progressContent, taskId) {
|
|
490
|
-
if (!/Coordinator Handoff/i.test(progressContent) || !/pending-coordinator-pass/i.test(progressContent)) return [];
|
|
491
|
-
return [{ id: `H-${taskId}`, from: "worker", to: "coordinator", state: "pending", summary: "Coordinator handoff pending" }];
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
function collectEvidence(progressContent) {
|
|
495
|
-
const matches = [...progressContent.matchAll(/\b(command|diff|fixture|screenshot|review|report):((?:PUBLIC|PRIVATE|TARGET|EXTERNAL|URL):[^:\s|]+):([^\n|]+)/g)];
|
|
496
|
-
return matches.map((match, index) => ({
|
|
497
|
-
id: `E-${String(index + 1).padStart(3, "0")}`,
|
|
498
|
-
type: match[1],
|
|
499
|
-
path: match[2],
|
|
500
|
-
status: "present",
|
|
501
|
-
summary: match[3].trim(),
|
|
502
|
-
}));
|
|
503
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
normalizeTarget,
|
|
5
|
-
nowTimestamp,
|
|
6
|
-
readFileSafe,
|
|
7
|
-
toPosix,
|
|
8
|
-
datePrefix,
|
|
9
|
-
} from "./core-shared.mjs";
|
|
10
|
-
import { collectTasks } from "./task-scanner.mjs";
|
|
11
|
-
import {
|
|
12
|
-
beginGovernanceSync,
|
|
13
|
-
commitGovernanceSync,
|
|
14
|
-
releaseGovernanceSync,
|
|
15
|
-
} from "./governance-sync.mjs";
|
|
16
|
-
|
|
17
|
-
export function supersedeTask(targetInput, oldRef, { by = "", reason = "" } = {}) {
|
|
18
|
-
if (!by) throw new Error("task-supersede requires --by <new-task-id>");
|
|
19
|
-
const target = normalizeTarget(targetInput);
|
|
20
|
-
const oldTask = resolveTask(target, oldRef);
|
|
21
|
-
const newTask = resolveTask(target, by);
|
|
22
|
-
const governanceContext = beginGovernanceSync(target, { operation: `task-supersede ${oldTask.id}` });
|
|
23
|
-
try {
|
|
24
|
-
writeTombstone(target, oldTask, {
|
|
25
|
-
State: "superseded",
|
|
26
|
-
"Superseded By": newTask.id,
|
|
27
|
-
Reason: reason || "superseded",
|
|
28
|
-
Operator: "coordinator",
|
|
29
|
-
Timestamp: nowTimestamp(),
|
|
30
|
-
"Reopen Eligible": "yes",
|
|
31
|
-
"Archive Eligible": "no",
|
|
32
|
-
});
|
|
33
|
-
appendProgress(target, oldTask, `task-supersede: superseded by ${newTask.id}`, reason || "superseded");
|
|
34
|
-
appendSupersedes(target, newTask, oldTask.id);
|
|
35
|
-
const commit = commitGovernanceSync(contextFor(target, governanceContext), taskPaths(target, oldTask, newTask), {
|
|
36
|
-
message: `chore(harness): supersede task ${oldTask.id}`,
|
|
37
|
-
});
|
|
38
|
-
return { taskId: oldTask.id, supersededBy: newTask.id, reason: reason || "superseded", governance: { commit } };
|
|
39
|
-
} finally {
|
|
40
|
-
releaseGovernanceSync(governanceContext);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function softDeleteTask(targetInput, taskRef, { reason = "" } = {}) {
|
|
45
|
-
const target = normalizeTarget(targetInput);
|
|
46
|
-
const task = resolveTask(target, taskRef);
|
|
47
|
-
return writeDeletionState(target, task, "soft-deleted", reason || "soft-delete", "task-delete --soft");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function archiveTask(targetInput, taskRef, { reason = "" } = {}) {
|
|
51
|
-
const target = normalizeTarget(targetInput);
|
|
52
|
-
const task = resolveTask(target, taskRef);
|
|
53
|
-
return writeDeletionState(target, task, "archived", reason || "archive", "task-archive");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function reopenTask(targetInput, taskRef, { reason = "" } = {}) {
|
|
57
|
-
const target = normalizeTarget(targetInput);
|
|
58
|
-
const task = resolveTask(target, taskRef);
|
|
59
|
-
const governanceContext = beginGovernanceSync(target, { operation: `task-reopen ${task.id}` });
|
|
60
|
-
try {
|
|
61
|
-
const taskPlanPath = path.join(target.projectRoot, task.taskPlanPath.replace(/^TARGET:/, ""));
|
|
62
|
-
const content = readFileSafe(taskPlanPath);
|
|
63
|
-
const next = content.replace(/\n##\s*(?:Task Tombstone|任务墓碑)\s*$[\s\S]*?(?=^##\s+|(?![\s\S]))/im, "");
|
|
64
|
-
fs.writeFileSync(taskPlanPath, next.endsWith("\n") ? next : `${next}\n`);
|
|
65
|
-
appendProgress(target, task, "task-reopen", reason || "reopened");
|
|
66
|
-
const commit = commitGovernanceSync(governanceContext, taskPaths(target, task), {
|
|
67
|
-
message: `chore(harness): reopen task ${task.id}`,
|
|
68
|
-
});
|
|
69
|
-
return { taskId: task.id, deletionState: "active", reason: reason || "reopened", governance: { commit } };
|
|
70
|
-
} finally {
|
|
71
|
-
releaseGovernanceSync(governanceContext);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function writeDeletionState(target, task, deletionState, reason, action) {
|
|
76
|
-
const governanceContext = beginGovernanceSync(target, { operation: `${action} ${task.id}` });
|
|
77
|
-
try {
|
|
78
|
-
writeTombstone(target, task, {
|
|
79
|
-
State: deletionState,
|
|
80
|
-
Reason: reason,
|
|
81
|
-
Operator: "coordinator",
|
|
82
|
-
Timestamp: nowTimestamp(),
|
|
83
|
-
"Reopen Eligible": "yes",
|
|
84
|
-
"Archive Eligible": deletionState === "archived" ? "yes" : "no",
|
|
85
|
-
});
|
|
86
|
-
appendProgress(target, task, action, reason);
|
|
87
|
-
const commit = commitGovernanceSync(governanceContext, taskPaths(target, task), {
|
|
88
|
-
message: `chore(harness): ${action.replace(/\s+/g, " ")} ${task.id}`,
|
|
89
|
-
});
|
|
90
|
-
return { taskId: task.id, deletionState, reason, governance: { commit } };
|
|
91
|
-
} finally {
|
|
92
|
-
releaseGovernanceSync(governanceContext);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function taskPaths(target, ...tasks) {
|
|
97
|
-
return [...new Set(tasks.flatMap((task) => [task.taskPlanPath, task.progressPath]).filter(Boolean).map((item) => toPosix(item.replace(/^TARGET:/, ""))))];
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function contextFor(_target, context) {
|
|
101
|
-
return context;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function resolveTask(target, ref) {
|
|
105
|
-
const normalized = String(ref || "").trim();
|
|
106
|
-
const matches = collectTasks(target).filter((task) => {
|
|
107
|
-
const bare = datePrefix.test(task.shortId) ? task.shortId.replace(datePrefix, "") : task.shortId;
|
|
108
|
-
return task.id === normalized || task.shortId === normalized || task.id.endsWith(`/${normalized}`) || bare === normalized;
|
|
109
|
-
});
|
|
110
|
-
if (matches.length === 1) return matches[0];
|
|
111
|
-
if (matches.length > 1) throw new Error(`Ambiguous task reference: ${ref}`);
|
|
112
|
-
throw new Error(`Task not found: ${ref}`);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function writeTombstone(target, task, fields) {
|
|
116
|
-
const taskPlanPath = path.join(target.projectRoot, task.taskPlanPath.replace(/^TARGET:/, ""));
|
|
117
|
-
const content = readFileSafe(taskPlanPath).replace(/\n##\s*(?:Task Tombstone|任务墓碑)\s*$[\s\S]*?(?=^##\s+|(?![\s\S]))/im, "");
|
|
118
|
-
const block = ["", "## Task Tombstone", "", "| Field | Value |", "| --- | --- |", ...Object.entries(fields).map(([key, value]) => `| ${key} | ${escapeCell(value)} |`), ""].join("\n");
|
|
119
|
-
fs.writeFileSync(taskPlanPath, `${content.trimEnd()}\n${block}`);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function appendSupersedes(target, task, oldId) {
|
|
123
|
-
const taskPlanPath = path.join(target.projectRoot, task.taskPlanPath.replace(/^TARGET:/, ""));
|
|
124
|
-
const content = readFileSafe(taskPlanPath);
|
|
125
|
-
if (/^Supersedes\s*[::]/im.test(content)) {
|
|
126
|
-
fs.writeFileSync(taskPlanPath, content.replace(/^Supersedes\s*[::]\s*(.*)$/im, (_m, current) => `Supersedes: ${[current, oldId].filter(Boolean).join(", ")}`));
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
fs.writeFileSync(taskPlanPath, `${content.trimEnd()}\nSupersedes: ${oldId}\n`);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function appendProgress(target, task, action, reason) {
|
|
133
|
-
const progressPath = path.join(target.projectRoot, task.progressPath.replace(/^TARGET:/, ""));
|
|
134
|
-
const relative = toPosix(path.relative(target.projectRoot, progressPath));
|
|
135
|
-
fs.appendFileSync(progressPath, `\n\n## Tombstone Log\n\n- ${nowTimestamp()} ${action}: ${escapeCell(reason)} (${relative})\n`);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function escapeCell(value) {
|
|
139
|
-
return String(value || "").replace(/\r?\n/g, " ").replaceAll("|", "\\|").trim();
|
|
140
|
-
}
|
package/scripts/postinstall.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { seedBundledPresets } from "./lib/harness-core.mjs";
|
|
4
|
-
|
|
5
|
-
if (process.env.CODING_AGENT_HARNESS_SKIP_POSTINSTALL === "1") process.exit(0);
|
|
6
|
-
|
|
7
|
-
try {
|
|
8
|
-
const result = seedBundledPresets({ scope: "user" });
|
|
9
|
-
const changed = result.created + result.overwritten;
|
|
10
|
-
const summary = changed > 0 ? `${changed} bundled presets installed` : `${result.skipped} bundled presets already present`;
|
|
11
|
-
console.log(`coding-agent-harness postinstall: ${summary} at ${result.target}`);
|
|
12
|
-
} catch (error) {
|
|
13
|
-
console.warn(`coding-agent-harness postinstall: preset seed skipped (${error.message})`);
|
|
14
|
-
}
|