@peterxiaoyang/superspec 0.1.59 → 0.1.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/transition.js +42 -0
- package/package.json +1 -1
package/dist/transition.js
CHANGED
|
@@ -1075,6 +1075,46 @@ function canReopenToPropose(from) {
|
|
|
1075
1075
|
return from === "propose_ready" || from === "apply" || from === "apply_done" ||
|
|
1076
1076
|
from === "review" || from === "accepted";
|
|
1077
1077
|
}
|
|
1078
|
+
/**
|
|
1079
|
+
* 普通 reopen --to propose 成功后附带一次非阻断提示:本次回退本可用 --self-test-fix 完成。
|
|
1080
|
+
* 刻意不按 reason 关键词分类(主会话自由文本不可靠),也刻意不在 apply 状态提示
|
|
1081
|
+
* (apply 内直接修任务即可,无需 reopen)。提示门禁与 self-test-fix 分支保持同一套:
|
|
1082
|
+
* pending 为空、无活跃尝试、contract 模式需要完成事件、无未处理的代码审查问题;
|
|
1083
|
+
* 条件不满足时不提示,避免建议一条必然被 skip 的命令。提示不改变任何转换结果。
|
|
1084
|
+
*/
|
|
1085
|
+
function selfTestFixAdvisory(change, changeRoot, snapshot, events, opts) {
|
|
1086
|
+
if (opts.reviewFix || opts.reviewFinding || opts.selfTestFix)
|
|
1087
|
+
return null;
|
|
1088
|
+
if (!["apply_done", "review", "accepted"].includes(snapshot.state))
|
|
1089
|
+
return null;
|
|
1090
|
+
if (applyPlanningMaterialsChanged(changeRoot, events))
|
|
1091
|
+
return null;
|
|
1092
|
+
const status = pendingTaskStatusForApply(changeRoot, events);
|
|
1093
|
+
if (status.pending.length > 0)
|
|
1094
|
+
return null;
|
|
1095
|
+
if (snapshot.active_task_attempts.some(attempt => attempt.state === "active"))
|
|
1096
|
+
return null;
|
|
1097
|
+
const tasksContent = readFileSync(join(changeRoot, "tasks.md"), "utf8");
|
|
1098
|
+
let parentTaskId = null;
|
|
1099
|
+
if (status.mode === "contract") {
|
|
1100
|
+
parentTaskId = status.completedByEvent[0]
|
|
1101
|
+
?? parseTasksMd(tasksContent).find(task => hasHistoricalTaskCompletion(events, task.taskId))?.taskId
|
|
1102
|
+
?? null;
|
|
1103
|
+
}
|
|
1104
|
+
else {
|
|
1105
|
+
parentTaskId = parseTasksMd(tasksContent).find(task => task.done)?.taskId ?? null;
|
|
1106
|
+
}
|
|
1107
|
+
if (!parentTaskId)
|
|
1108
|
+
return null;
|
|
1109
|
+
const failedReview = latestCodeReviewFailedStatus(events);
|
|
1110
|
+
if (failedReview?.unresolved.length)
|
|
1111
|
+
return null;
|
|
1112
|
+
return [
|
|
1113
|
+
`提示(猜测,可能不适用):本次 reopen 已回退到 propose。若本意只是不改变已批准行为和方案,这一步本可避免——`,
|
|
1114
|
+
`在 apply_done/review/accepted 状态应执行 superspec transition reopen --change "${change}" --to apply --self-test-fix "${parentTaskId}" --reason "<本次原因>"。`,
|
|
1115
|
+
`当前已在 propose,请继续计划更新流程。`,
|
|
1116
|
+
].join("");
|
|
1117
|
+
}
|
|
1078
1118
|
export function reopen(projectRoot, change, changeRoot, to, reason, opts = {}) {
|
|
1079
1119
|
return commitTransition(projectRoot, change, changeRoot, {
|
|
1080
1120
|
name: "reopen", idempotencyInputs: {
|
|
@@ -1249,6 +1289,7 @@ export function reopen(projectRoot, change, changeRoot, to, reason, opts = {}) {
|
|
|
1249
1289
|
jobs: snapshot.open_jobs,
|
|
1250
1290
|
};
|
|
1251
1291
|
}
|
|
1292
|
+
const selfTestFixAdvisoryText = selfTestFixAdvisory(change, changeRoot, snapshot, events, opts);
|
|
1252
1293
|
const currentBaseline = proposalDocsBaseline(changeRoot);
|
|
1253
1294
|
const acceptedBaseline = snapshot.state === "accepted" ? latestAcceptedProposalBaseline(events) : null;
|
|
1254
1295
|
// 旧版 accepted 事件的基线可能缺少后来纳入 Propose gate 的材料。保留其已冻结
|
|
@@ -1277,6 +1318,7 @@ export function reopen(projectRoot, change, changeRoot, to, reason, opts = {}) {
|
|
|
1277
1318
|
planning_validation_version: 2,
|
|
1278
1319
|
planning_validation_profile: planningValidationProfileForNewRound(projectRoot),
|
|
1279
1320
|
},
|
|
1321
|
+
...(selfTestFixAdvisoryText ? { details: { advisory: selfTestFixAdvisoryText } } : {}),
|
|
1280
1322
|
extraEvents: planningReopenExtraEvents(snapshot, "propose", reason.trim()),
|
|
1281
1323
|
};
|
|
1282
1324
|
}
|