dsh-workplan 1.12.3 → 2.0.2
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 +99 -0
- package/README.en.md +17 -2
- package/README.md +41 -3
- package/docs/cc/ADV-FSP-FUNCTIONAL-SPEC.md +3 -1
- package/docs/cc/AVA-VULNERABILITY-ANALYSIS.md +9 -0
- package/docs/cc/SECURITY-TARGET.md +3 -1
- package/docs/collaboration.md +29 -2
- package/docs/release-notes-2.0.1.md +58 -0
- package/docs/release-notes-2.0.2.md +49 -0
- package/docs/release-record-2.0.1-20261105.md +113 -0
- package/lib/host.js +195 -2
- package/lib/lessons.js +378 -0
- package/lib/plan.js +37 -5
- package/lib/runtime.js +178 -2
- package/lib/three-phase.js +289 -0
- package/package.json +1 -1
- package/src/host.ts +202 -2
- package/src/lessons.ts +445 -0
- package/src/plan.ts +37 -4
- package/src/runtime.ts +184 -1
- package/src/three-phase.ts +344 -0
package/lib/plan.js
CHANGED
|
@@ -10,6 +10,7 @@ import { createHash, randomUUID } from 'node:crypto';
|
|
|
10
10
|
import { DEPARTMENT_CAPABILITIES, departmentCapability } from './departments.js';
|
|
11
11
|
import { MAX_TASK_ANCHOR_CHARS } from './understanding.js';
|
|
12
12
|
import { isMappingDigest, verifyMappingDigest } from './supersede-digest.js';
|
|
13
|
+
import { phaseSummaryLine, threePhasePromptLines, validatePhaseEvidence } from './three-phase.js';
|
|
13
14
|
export const PLAN_VERSION = 1;
|
|
14
15
|
/**
|
|
15
16
|
* [1.9.0] 处置终态:cancelled(用户撤销)与 superseded(责任已转移)。
|
|
@@ -84,7 +85,7 @@ export const UPDATE_MARKER_END = '<!-- DSH-WORKPLAN-UPDATE:END -->';
|
|
|
84
85
|
/** Upper bound for the run-time conversation window (single truncation point). */
|
|
85
86
|
export const MAX_CONVERSATION_CHARS = 7000;
|
|
86
87
|
/** Upper bound for one child evidence block; longer blocks are truncated. */
|
|
87
|
-
export const MAX_EVIDENCE_BLOCK_CHARS =
|
|
88
|
+
export const MAX_EVIDENCE_BLOCK_CHARS = 12000;
|
|
88
89
|
export const MAX_EVIDENCE_ACCEPTANCE = 20;
|
|
89
90
|
export const MAX_EVIDENCE_ARTIFACTS = 20;
|
|
90
91
|
export const MAX_EVIDENCE_NEEDS = 10;
|
|
@@ -1872,7 +1873,7 @@ const BLOCKED_LINE = /^\s*(BLOCKED|受阻|无法完成)\s*[::]\s*/i;
|
|
|
1872
1873
|
* the acceptance table cannot drift apart between the runtime and the replay.
|
|
1873
1874
|
* It never invents evidence and never upgrades a failed self-check to done.
|
|
1874
1875
|
*/
|
|
1875
|
-
export function adjudicateResult({ output, strict = true, expectedAcceptance = [] }) {
|
|
1876
|
+
export function adjudicateResult({ output, strict = true, expectedAcceptance = [], requirePhases = true }) {
|
|
1876
1877
|
const text = typeof output === 'string' ? output : '';
|
|
1877
1878
|
const parsed = parseEvidenceBlock(text);
|
|
1878
1879
|
if (!strict) {
|
|
@@ -2013,6 +2014,30 @@ export function adjudicateResult({ output, strict = true, expectedAcceptance = [
|
|
|
2013
2014
|
.map((item) => truncate(String(item), 120)).slice(0, 5).join(';')}。请按计划验收逐条给出证据后再回报。`,
|
|
2014
2015
|
};
|
|
2015
2016
|
}
|
|
2017
|
+
/*
|
|
2018
|
+
* [1.13.0] 完成前必须交出三阶段证据(用户 2026-11-05 的强制要求)。
|
|
2019
|
+
*
|
|
2020
|
+
* 这是「先规划后执行」从口号变成契约的唯一落点:子 Agent 只在提示词里
|
|
2021
|
+
* 被要求时,仍可以先动手、最后补一句「已规划」;只有把规划内容做成
|
|
2022
|
+
* 收尾证据的一部分并在这里校验,缺规划/缺验证的结果才不可能被记成 done。
|
|
2023
|
+
*
|
|
2024
|
+
* 兼容边界:`requirePhases:false` 保留给历史回放与明确关闭该门禁的部署;
|
|
2025
|
+
* `strict:false` 的旧语义不受影响(前面已经返回)。
|
|
2026
|
+
*/
|
|
2027
|
+
const phaseCheck = requirePhases === false
|
|
2028
|
+
? null
|
|
2029
|
+
: validatePhaseEvidence(payload.phases, expectedAcceptance);
|
|
2030
|
+
if (phaseCheck && !phaseCheck.ok) {
|
|
2031
|
+
return {
|
|
2032
|
+
status: 'blocked',
|
|
2033
|
+
verification: 'unverified',
|
|
2034
|
+
acceptance,
|
|
2035
|
+
artifacts,
|
|
2036
|
+
needs,
|
|
2037
|
+
error: `三阶段证据不完整(未按「规划→执行→验证」回报):${phaseCheck.errors.slice(0, 6).join(';')}`,
|
|
2038
|
+
phases: null,
|
|
2039
|
+
};
|
|
2040
|
+
}
|
|
2016
2041
|
return {
|
|
2017
2042
|
status: 'done',
|
|
2018
2043
|
verification: hasUnverified ? 'unverified' : 'structured',
|
|
@@ -2020,6 +2045,8 @@ export function adjudicateResult({ output, strict = true, expectedAcceptance = [
|
|
|
2020
2045
|
artifacts,
|
|
2021
2046
|
needs,
|
|
2022
2047
|
error: null,
|
|
2048
|
+
phases: phaseCheck?.phases ?? null,
|
|
2049
|
+
phaseSummary: phaseCheck?.phases ? phaseSummaryLine(phaseCheck.phases) : null,
|
|
2023
2050
|
};
|
|
2024
2051
|
}
|
|
2025
2052
|
export function buildUpdateMessage(update) {
|
|
@@ -3546,7 +3573,7 @@ export function findSubtask(plan, subtaskId) {
|
|
|
3546
3573
|
}
|
|
3547
3574
|
return null;
|
|
3548
3575
|
}
|
|
3549
|
-
export function buildChildPrompt({ plan, subtask, stage, dependencyResults, cwd, conversationContext = '', statuses = null, previousFailure = null, }) {
|
|
3576
|
+
export function buildChildPrompt({ plan, subtask, stage, dependencyResults, cwd, conversationContext = '', statuses = null, previousFailure = null, lessonsBrief = '', }) {
|
|
3550
3577
|
/*
|
|
3551
3578
|
* Every field below is read defensively.
|
|
3552
3579
|
*
|
|
@@ -3709,6 +3736,11 @@ export function buildChildPrompt({ plan, subtask, stage, dependencyResults, cwd,
|
|
|
3709
3736
|
...(resumeHint ? [resumeHint] : []),
|
|
3710
3737
|
...(pendingInstruction ? [pendingInstruction] : []),
|
|
3711
3738
|
'',
|
|
3739
|
+
...threePhasePromptLines(),
|
|
3740
|
+
...(typeof lessonsBrief === 'string' && lessonsBrief.trim() !== ''
|
|
3741
|
+
? ['', lessonsBrief.trim(), '']
|
|
3742
|
+
: []),
|
|
3743
|
+
'',
|
|
3712
3744
|
'执行要求:',
|
|
3713
3745
|
'- 只完成本子任务,不擅自扩大范围;不要派生新的 Agent。',
|
|
3714
3746
|
'- 你没有派发权限,也不能重启或安装任何服务;遇到这类步骤,必须先上报(见下方「遇阻上报」),再停止推进等待指示,不要空转。',
|
|
@@ -3728,13 +3760,13 @@ export function buildChildPrompt({ plan, subtask, stage, dependencyResults, cwd,
|
|
|
3728
3760
|
'',
|
|
3729
3761
|
'结果回传(必填):在汇报的最后附上一个结构化结果块,主 Agent 会按它逐项核对,不再只依赖自述。',
|
|
3730
3762
|
EVIDENCE_MARKER_BEGIN,
|
|
3731
|
-
'{"status":"done","blockedReason":"","acceptance":[{"criterion":"A1 把上面的验收标准原文抄在这里","result":"pass","evidence":"用命令输出、文件路径或引用证明"}],"artifacts":[{"kind":"file","ref":"相对工作目录的路径"}],"needs":[],"question":"","options":[]}',
|
|
3763
|
+
'{"status":"done","blockedReason":"","phases":{"planning":{"problemAnalysis":["要解决的问题 1(含现状/约束/未知/主要矛盾)"],"constraints":["..."],"unknowns":["..."],"approach":["第 1 步:做什么 → 产出什么 → 如何证明"]},"execution":{"steps":["实际执行的步骤"],"deviations":[]},"verification":{"allPassed":true,"checks":[{"criterion":"A1","method":"怎么验证","evidence":"命令输出/文件/引用"}],"requirementCheck":"逐条核对用户原要求的结果","retrospective":{"problems":["本次遇到的问题(现象+根因)"],"detours":["走过的弯路/返工/无效尝试;确实没有就写 []"],"resolutions":["最终是如何解决的"],"prevention":["以后如何预防再犯:遇到…先…"]}}},"acceptance":[{"criterion":"A1 把上面的验收标准原文抄在这里","result":"pass","evidence":"用命令输出、文件路径或引用证明"}],"artifacts":[{"kind":"file","ref":"相对工作目录的路径"}],"needs":[],"question":"","options":[]}',
|
|
3732
3764
|
EVIDENCE_MARKER_END,
|
|
3733
3765
|
'- status 只能是 done / blocked / partial;partial 会被当作受阻处理。',
|
|
3734
3766
|
'- acceptance 必须逐条覆盖上面的验收标准:criterion 以 A1、A2… 开头对号入座(编号不可省略);result 只能是 pass / fail / unverified。无法确认就写 unverified,不要写 pass。',
|
|
3735
3767
|
'- artifacts 写你实际产出或修改的文件(kind=file,ref 用相对路径)、链接(kind=url)或说明(kind=note)。',
|
|
3736
3768
|
'- needs 写需要其他部门配合的事项,每条写清「哪个部门 + 需要什么 + 用来做什么」;它会被登记为待处理需求,主 Agent 必须处置后计划才能交付。不要直连其他子 Agent。',
|
|
3737
3769
|
'- question/options 只在受阻上报时填写;done 时保持空字符串/空数组。',
|
|
3738
|
-
'- 整块不超过
|
|
3770
|
+
'- 整块不超过 12000 字符;不要把这段模板本身抄进结果块。',
|
|
3739
3771
|
].join('\n'));
|
|
3740
3772
|
}
|
package/lib/runtime.js
CHANGED
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
import { randomUUID } from 'node:crypto';
|
|
15
15
|
import { existsSync, realpathSync, statSync } from 'node:fs';
|
|
16
16
|
import { basename, dirname, isAbsolute, join, resolve } from 'node:path';
|
|
17
|
-
import { MAX_CONCURRENT, PlanError, aggregateInvariantViolations, applyStatus, attachPlanMeta, blockCancelledDependents, buildChildPrompt, buildCancelMessage, buildClarifyMessage, buildDegradedMessage, buildPlanMessage, buildPlannerPrompt, buildResultMessage, buildStopSteerText, createStatuses, deliveryReadiness, derivePlanSnapshot, extractJson, flattenSubtasks, isRecord, isSocialMessage, isTerminalPhase, isStatusQuestion, isVagueContinuation, makeUserMessage, markDependentsBlocked, messageText, readySubtasks, MAX_PLAN_RESUMES, PRESENT_DENY_CODES, canResumePlan, resetBlockedStatuses, parseCancelMessage, parseResultMessage, parseWorkplanMessage, planPhase, reconcilePhase, truncate, validatePlan, applyResultStatuses, adjudicateResult, activeDenyCode, MAX_CONVERSATION_CHARS, MAX_ESCALATION_OPTIONS, MAX_INSTRUCTION_CHARS, MAX_QUESTION_CHARS, parseUpdateMessage, buildUpdateMessage, normaliseHandoffs, openHandoffs, DEPARTMENTS, DEPARTMENT_IDS, MAX_HANDOFF_RESPONSE_CHARS, } from './plan.js';
|
|
17
|
+
import { MAX_CONCURRENT, PlanError, aggregateInvariantViolations, applyStatus, attachPlanMeta, blockCancelledDependents, buildChildPrompt, buildCancelMessage, buildClarifyMessage, buildDegradedMessage, buildPlanMessage, buildPlannerPrompt, buildResultMessage, buildStopSteerText, createStatuses, deliveryReadiness, derivePlanSnapshot, extractJson, flattenSubtasks, isRecord, isSocialMessage, isTerminalPhase, isStatusQuestion, isVagueContinuation, makeUserMessage, markDependentsBlocked, messageText, readySubtasks, MAX_PLAN_RESUMES, PRESENT_DENY_CODES, canResumePlan, resetBlockedStatuses, parseCancelMessage, parseResultMessage, parseWorkplanMessage, planPhase, reconcilePhase, truncate, validatePlan, applyResultStatuses, adjudicateResult, activeDenyCode, MAX_CONVERSATION_CHARS, MAX_ESCALATION_OPTIONS, MAX_INSTRUCTION_CHARS, MAX_QUESTION_CHARS, parseUpdateMessage, buildUpdateMessage, normaliseHandoffs, openHandoffs, DEPARTMENTS, DEPARTMENT_IDS, MAX_HANDOFF_RESPONSE_CHARS, findSubtask, } from './plan.js';
|
|
18
18
|
import { auditClarifyNeed, compactUnderstandingAudit, validatePlanContext } from './understanding.js';
|
|
19
|
+
import { phaseGateFromErrors, phaseSummaryLine, validatePhaseEvidence } from './three-phase.js';
|
|
20
|
+
import { lessonStats, rankLessons, readLessons, recordLesson, renderLessonsBrief, resolveLessonsFile, } from './lessons.js';
|
|
19
21
|
import { computeMappingDigest, verifyMappingDigest } from './supersede-digest.js';
|
|
20
22
|
import { supersedePlanRecord } from './supersede.js';
|
|
21
23
|
import { createProgressWatchdog, describeError } from './watchdog.js';
|
|
@@ -773,11 +775,40 @@ function settleFromOutput(record, subtask, output, guard, options) {
|
|
|
773
775
|
const checked = checkArtifacts(verdict.artifacts, options.cwd, options.artifactExists);
|
|
774
776
|
const escalated = verdict.status === 'blocked'
|
|
775
777
|
&& typeof verdict.question === 'string' && verdict.question.trim() !== '';
|
|
778
|
+
/*
|
|
779
|
+
* [2.0.0] 自我学习闭环的出口:完成且带复盘证据时,立刻写入永久记忆。
|
|
780
|
+
*
|
|
781
|
+
* 写入失败不改变本次判定(教训没记住是记忆层的问题,不能把已经做完的工作
|
|
782
|
+
* 判成未完成),但会把失败原因写进本条状态,避免「以为记住了其实没写」。
|
|
783
|
+
*/
|
|
784
|
+
let lessonNote = '';
|
|
785
|
+
if (verdict.status === 'done' && verdict.phases?.verification?.retrospective) {
|
|
786
|
+
try {
|
|
787
|
+
const saved = recordLesson({
|
|
788
|
+
file: resolveLessonsFile(),
|
|
789
|
+
planId: String(record.plan?.planId ?? ''),
|
|
790
|
+
subtaskId: subtask.id,
|
|
791
|
+
department: String(subtask.department ?? ''),
|
|
792
|
+
title: `${subtask.id} ${subtask.title}`,
|
|
793
|
+
cwd: typeof options.cwd === 'string' ? options.cwd : '',
|
|
794
|
+
retrospective: verdict.phases.verification.retrospective,
|
|
795
|
+
now: Date.now(),
|
|
796
|
+
});
|
|
797
|
+
if (saved) {
|
|
798
|
+
lessonNote = saved.mode === 'repeated'
|
|
799
|
+
? `已记住同类教训(第 ${saved.record.occurrences} 次,永久记忆)`
|
|
800
|
+
: '复盘已写入永久教训记忆';
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
catch (error) {
|
|
804
|
+
lessonNote = `复盘记忆写入失败:${truncate(error instanceof Error ? error.message : String(error), 120)}`;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
776
807
|
writeSubtaskStatus(record, subtask.id, {
|
|
777
808
|
status: verdict.status,
|
|
778
809
|
progress: 100,
|
|
779
810
|
finishedAt: Date.now(),
|
|
780
|
-
summary: truncate(output, 3000),
|
|
811
|
+
summary: truncate(lessonNote ? `${output}\n[自我学习] ${lessonNote}` : output, 3000),
|
|
781
812
|
error: verdict.error,
|
|
782
813
|
verification: verdict.verification,
|
|
783
814
|
acceptance: verdict.acceptance,
|
|
@@ -912,6 +943,24 @@ async function executeSubtask(ctx, record, stage, subtask, options) {
|
|
|
912
943
|
if (child.controller.signal.aborted) {
|
|
913
944
|
throw child.controller.signal.reason ?? abortError();
|
|
914
945
|
}
|
|
946
|
+
/*
|
|
947
|
+
* [2.0.0] 自我学习闭环的入口:把与本子任务最相关的历史教训注入提示词。
|
|
948
|
+
*
|
|
949
|
+
* 记忆读取失败不能影响本次派发(宁可不带教训,也不能因此不做任务),
|
|
950
|
+
* 所以整段用 try/catch 兜底;文件不存在时 renderLessonsBrief 返回空串。
|
|
951
|
+
*/
|
|
952
|
+
let lessonsBrief = '';
|
|
953
|
+
try {
|
|
954
|
+
lessonsBrief = renderLessonsBrief({
|
|
955
|
+
department: subtask.department,
|
|
956
|
+
title: subtask.title,
|
|
957
|
+
objective: subtask.objective,
|
|
958
|
+
cwd: options.cwd,
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
catch {
|
|
962
|
+
lessonsBrief = '';
|
|
963
|
+
}
|
|
915
964
|
activation = await ctx.subagents.startActivation({
|
|
916
965
|
provider: 'spawn',
|
|
917
966
|
label: `${subtask.department}:${subtask.id} ${subtask.title}`.slice(0, 120),
|
|
@@ -944,6 +993,7 @@ async function executeSubtask(ctx, record, stage, subtask, options) {
|
|
|
944
993
|
conversationContext,
|
|
945
994
|
statuses: record.statuses,
|
|
946
995
|
previousFailure: attempt > 1 ? lastFailure : null,
|
|
996
|
+
lessonsBrief,
|
|
947
997
|
}),
|
|
948
998
|
}],
|
|
949
999
|
parent: options.agent,
|
|
@@ -3940,6 +3990,87 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
3940
3990
|
};
|
|
3941
3991
|
}
|
|
3942
3992
|
}
|
|
3993
|
+
/**
|
|
3994
|
+
* [1.13.0] 阶段三(验证阶段)的插件核验入口(用户 2026-11-05)。
|
|
3995
|
+
*
|
|
3996
|
+
* 「按提交内容判阶段」:
|
|
3997
|
+
* - 只有 planning + execution 证据齐全,才会进入阶段三核验;
|
|
3998
|
+
* - 缺 planning/execution 的调用以 PHASE_GATE 拒绝并列出待补项 —— 这是一道
|
|
3999
|
+
* 证据门禁,不是对插件的全局禁用(「阶段一、二禁用插件」只是 2026-11-05
|
|
4000
|
+
* 当次优化会话的过程约束,2.0.2 起不再作为所有会话的产品规则);
|
|
4001
|
+
* - 阶段三核验会逐条检查:问题梳理/可执行思路是否有实质内容、执行步骤
|
|
4002
|
+
* 是否记录、验证是否全部通过、验证记录是否覆盖全部验收标准。
|
|
4003
|
+
*
|
|
4004
|
+
* 它不写状态、不替子 Agent 宣称完成:最终是否 done 仍由 `adjudicateResult`
|
|
4005
|
+
* 对同一份 phases 再判一次,避免「核验工具说通过」与「结果块没写」两套真相。
|
|
4006
|
+
*/
|
|
4007
|
+
async function verifySubtask(agent, args) {
|
|
4008
|
+
const childSession = agent?.session;
|
|
4009
|
+
if (!childSession?.id) {
|
|
4010
|
+
return { ok: false, code: 'NO_SESSION', passed: false, error: '只能在部门子会话内做阶段三核验' };
|
|
4011
|
+
}
|
|
4012
|
+
const parentId = childSession.header?.parentSession;
|
|
4013
|
+
if (!parentId) {
|
|
4014
|
+
return {
|
|
4015
|
+
ok: false,
|
|
4016
|
+
code: 'NOT_CHILD_SESSION',
|
|
4017
|
+
passed: false,
|
|
4018
|
+
error: '当前不是子会话,无法反查父计划;三阶段核验只对已派发的部门子任务开放',
|
|
4019
|
+
};
|
|
4020
|
+
}
|
|
4021
|
+
let record = state.records.get(parentId);
|
|
4022
|
+
if (!record?.plan) {
|
|
4023
|
+
const parent = ctx.sessions?.get?.(parentId);
|
|
4024
|
+
if (parent) {
|
|
4025
|
+
try {
|
|
4026
|
+
record = reconstructFromSession(parent);
|
|
4027
|
+
}
|
|
4028
|
+
catch (error) {
|
|
4029
|
+
pushRecordError({ errors: [] }, error);
|
|
4030
|
+
}
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
if (!record?.plan) {
|
|
4034
|
+
return { ok: false, code: 'NO_PLAN', passed: false, error: '父会话没有可关联的计划,无法核验' };
|
|
4035
|
+
}
|
|
4036
|
+
const row = (record.statuses ?? []).find((item) => item?.childId === childSession.id);
|
|
4037
|
+
if (!row) {
|
|
4038
|
+
return { ok: false, code: 'NO_SUBTASK', passed: false, error: '计划里找不到与本子会话关联的子任务(childId 未登记)' };
|
|
4039
|
+
}
|
|
4040
|
+
if (row.status === 'done') {
|
|
4041
|
+
return { ok: false, code: 'ALREADY_DONE', passed: false, subtaskId: row.subtaskId, error: '该子任务已标记完成,无需再次核验' };
|
|
4042
|
+
}
|
|
4043
|
+
const found = findSubtask(record.plan, row.subtaskId);
|
|
4044
|
+
const expectedAcceptance = Array.isArray(found?.subtask?.acceptance) ? found.subtask.acceptance : [];
|
|
4045
|
+
const rawPhases = isRecord(args?.phases)
|
|
4046
|
+
? args.phases
|
|
4047
|
+
: { planning: args?.planning, execution: args?.execution, verification: args?.verification };
|
|
4048
|
+
const check = validatePhaseEvidence(rawPhases, expectedAcceptance);
|
|
4049
|
+
if (!check.ok || !check.phases) {
|
|
4050
|
+
const gate = phaseGateFromErrors(check.errors);
|
|
4051
|
+
return {
|
|
4052
|
+
ok: false,
|
|
4053
|
+
passed: false,
|
|
4054
|
+
code: gate === 'phase-1-2' ? 'PHASE_GATE' : 'VERIFICATION_INCOMPLETE',
|
|
4055
|
+
phase: gate,
|
|
4056
|
+
planId: record.plan.planId,
|
|
4057
|
+
subtaskId: row.subtaskId,
|
|
4058
|
+
gaps: check.errors,
|
|
4059
|
+
error: gate === 'phase-1-2'
|
|
4060
|
+
? `阶段三核验缺少前两阶段证据:先完成「梳理问题 → 形成可执行思路」并实际执行,再提交阶段三核验。${check.errors.slice(0, 5).join(';')}`
|
|
4061
|
+
: `阶段三核验未通过:${check.errors.slice(0, 5).join(';')}`,
|
|
4062
|
+
};
|
|
4063
|
+
}
|
|
4064
|
+
return {
|
|
4065
|
+
ok: true,
|
|
4066
|
+
passed: true,
|
|
4067
|
+
phase: 'verification',
|
|
4068
|
+
planId: record.plan.planId,
|
|
4069
|
+
subtaskId: row.subtaskId,
|
|
4070
|
+
summary: phaseSummaryLine(check.phases),
|
|
4071
|
+
message: '插件核验通过:三阶段证据齐全、验证全部通过。现在把同一份 phases 写进结果块并提交。',
|
|
4072
|
+
};
|
|
4073
|
+
}
|
|
3943
4074
|
/**
|
|
3944
4075
|
* [1.11.0] 子 → 父的唯一反向通道(T4 C-09 / T6 M5)。
|
|
3945
4076
|
*
|
|
@@ -5653,6 +5784,49 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
5653
5784
|
});
|
|
5654
5785
|
}
|
|
5655
5786
|
}
|
|
5787
|
+
/**
|
|
5788
|
+
* [2.0.0] 只读的「永久教训记忆」入口。
|
|
5789
|
+
*
|
|
5790
|
+
* 用户要求这些经验必须能被复核。主 Agent 在阶段三可以用它查:记住了什么、
|
|
5791
|
+
* 哪些同类错误在重复发生、文件到底写在哪。它只读文件,不改任何计划状态。
|
|
5792
|
+
*/
|
|
5793
|
+
async function lessonsTool(_agent, args) {
|
|
5794
|
+
const parsed = isRecord(args) ? args : {};
|
|
5795
|
+
const action = String(parsed.action ?? 'list');
|
|
5796
|
+
const file = resolveLessonsFile();
|
|
5797
|
+
try {
|
|
5798
|
+
if (action === 'stats') {
|
|
5799
|
+
return { ok: true, ...lessonStats(file) };
|
|
5800
|
+
}
|
|
5801
|
+
if (action === 'search') {
|
|
5802
|
+
const query = String(parsed.query ?? '').trim();
|
|
5803
|
+
const rows = query
|
|
5804
|
+
? readLessons(file).filter((item) => `${item.title} ${item.problems.join(' ')} ${item.detours.join(' ')} ${item.prevention.join(' ')}`
|
|
5805
|
+
.toLowerCase()
|
|
5806
|
+
.includes(query.toLowerCase()))
|
|
5807
|
+
: readLessons(file);
|
|
5808
|
+
const limit = Math.min(Math.max(Number(parsed.limit) || 10, 1), 50);
|
|
5809
|
+
return { ok: true, file, total: rows.length, lessons: rows.slice(-limit).reverse() };
|
|
5810
|
+
}
|
|
5811
|
+
const department = typeof parsed.department === 'string' ? parsed.department.trim() : '';
|
|
5812
|
+
const limit = Math.min(Math.max(Number(parsed.limit) || 10, 1), 50);
|
|
5813
|
+
const lessons = department
|
|
5814
|
+
? readLessons(file).filter((item) => item.department === department)
|
|
5815
|
+
: readLessons(file);
|
|
5816
|
+
const ranked = department
|
|
5817
|
+
? rankLessons(lessons, { department, limit, now: Date.now() })
|
|
5818
|
+
: lessons.slice(-limit).reverse();
|
|
5819
|
+
return { ok: true, file, total: lessons.length, lessons: ranked };
|
|
5820
|
+
}
|
|
5821
|
+
catch (error) {
|
|
5822
|
+
return {
|
|
5823
|
+
ok: false,
|
|
5824
|
+
file,
|
|
5825
|
+
error: truncate(error instanceof Error ? error.message : String(error), 300),
|
|
5826
|
+
lessons: [],
|
|
5827
|
+
};
|
|
5828
|
+
}
|
|
5829
|
+
}
|
|
5656
5830
|
function dispose() {
|
|
5657
5831
|
// [1.10.4] 定时器不能吊住进程,也不能在记录清空后复活一个已销毁的计划。
|
|
5658
5832
|
for (const record of state.records.values())
|
|
@@ -5675,6 +5849,8 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
5675
5849
|
statusTool,
|
|
5676
5850
|
followupTool,
|
|
5677
5851
|
escalateTool,
|
|
5852
|
+
verifyTool: verifySubtask,
|
|
5853
|
+
lessonsTool,
|
|
5678
5854
|
instructTool,
|
|
5679
5855
|
handoffTool,
|
|
5680
5856
|
replanPlan,
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [1.13.0] 三阶段工作法:部门 Agent 的强制执行顺序。
|
|
3
|
+
*
|
|
4
|
+
* 用户要求(2026-11-05):每个部门人员收到分配的工作后,必须
|
|
5
|
+
* 1. 先全面、深入梳理「要解决的问题」;
|
|
6
|
+
* 2. 再全面、深入思考,整理出能完美完成自身工作的完整、可执行思路;
|
|
7
|
+
* 3. 只有前两步完成后,才按思路执行与验证。
|
|
8
|
+
* 全过程按先后顺序分为三个阶段:规划阶段 → 执行阶段 → 验证阶段。
|
|
9
|
+
* 阶段三允许用 dsh_workplan_verify 核验;缺 planning/execution 证据时返回 PHASE_GATE。
|
|
10
|
+
* 注意(2.0.2 更正):2026-11-05 的「第一、二阶段禁用插件」只是当次优化会话的
|
|
11
|
+
* 过程约束,不是对所有后续会话的产品规则;插件不全局禁用。
|
|
12
|
+
*
|
|
13
|
+
* 这个模块只做纯函数与常量,不依赖 harness 服务:
|
|
14
|
+
* - 校验子 Agent 回报的 `phases` 证据(缺一阶段就判未完成);
|
|
15
|
+
* - 生成阶段摘要(写进结果与日志);
|
|
16
|
+
* - 生成提示词段落(由 `buildChildPrompt` 拼进子 Agent 的提示词)。
|
|
17
|
+
*
|
|
18
|
+
* 为什么用「结构化证据」而不是只写一句提示:
|
|
19
|
+
* 只写提示词时,模型可以直接动手、最后补一句「我已规划」。把规划内容变成
|
|
20
|
+
* 收尾证据的一部分后,缺规划/缺验证的结果无法被记成 done,主 Agent 和
|
|
21
|
+
* 回放日志都能看到每个部门到底梳理了什么、按什么思路做、验证了什么。
|
|
22
|
+
*/
|
|
23
|
+
import { validateRetrospective } from './lessons.js';
|
|
24
|
+
/** 三阶段顺序不可颠倒;这里也是结果块里 `phases` 的键名。 */
|
|
25
|
+
export const THREE_PHASE_IDS = Object.freeze(['planning', 'execution', 'verification']);
|
|
26
|
+
export const THREE_PHASE_VERSION = 1;
|
|
27
|
+
/**
|
|
28
|
+
* 「全面、深入」无法由代码度量,但可以给一个不可忽略的下限:
|
|
29
|
+
* 问题梳理与可执行思路各至少 40 个字符,避免一个词就冒充规划。
|
|
30
|
+
*/
|
|
31
|
+
export const MIN_PLANNING_PROBLEM_CHARS = 40;
|
|
32
|
+
export const MIN_PLANNING_APPROACH_CHARS = 40;
|
|
33
|
+
export const MAX_PHASE_LIST_ITEMS = 20;
|
|
34
|
+
export const MAX_PHASE_ITEM_CHARS = 800;
|
|
35
|
+
export const MAX_PHASE_TOTAL_CHARS = 6000;
|
|
36
|
+
function isRecord(value) {
|
|
37
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
38
|
+
}
|
|
39
|
+
function readTextList(value, field, errors, options) {
|
|
40
|
+
if (value === undefined || value === null) {
|
|
41
|
+
if (options.required)
|
|
42
|
+
errors.push(`${field} 缺失`);
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
if (!Array.isArray(value)) {
|
|
46
|
+
errors.push(`${field} 必须是数组`);
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
const items = value
|
|
50
|
+
.map((item) => (typeof item === 'string' ? item.trim() : ''))
|
|
51
|
+
.filter(Boolean);
|
|
52
|
+
if (options.required && items.length < (options.minItems ?? 1)) {
|
|
53
|
+
errors.push(`${field} 至少需要 ${options.minItems ?? 1} 条非空内容`);
|
|
54
|
+
return items.slice(0, MAX_PHASE_LIST_ITEMS);
|
|
55
|
+
}
|
|
56
|
+
if (items.length > MAX_PHASE_LIST_ITEMS) {
|
|
57
|
+
errors.push(`${field} 超过 ${MAX_PHASE_LIST_ITEMS} 条上限`);
|
|
58
|
+
}
|
|
59
|
+
return items.slice(0, MAX_PHASE_LIST_ITEMS).map((item) => item.slice(0, MAX_PHASE_ITEM_CHARS));
|
|
60
|
+
}
|
|
61
|
+
function totalChars(items) {
|
|
62
|
+
return items.reduce((sum, item) => sum + item.length, 0);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Same matching rules as `src/plan.ts#acceptanceCoverage` (Q6 / U-16):
|
|
66
|
+
* stable A1…An numbering, exact full text, or a longer text containing the
|
|
67
|
+
* full criterion. A partial copy must not count as coverage.
|
|
68
|
+
*
|
|
69
|
+
* Kept local to avoid importing plan.ts (which imports this module); the
|
|
70
|
+
* rules are pinned by tests on both sides.
|
|
71
|
+
*/
|
|
72
|
+
function normaliseCriterion(value) {
|
|
73
|
+
return String(value ?? '')
|
|
74
|
+
.toLowerCase()
|
|
75
|
+
.replace(/[\s,。;、,.;::!!??"'“”‘’()()\[\]【】《》<>]/g, '')
|
|
76
|
+
.replace(/^(必须|需要|应当|应该|请|务必)/, '');
|
|
77
|
+
}
|
|
78
|
+
function missingCriteria(expected, checks) {
|
|
79
|
+
const want = (Array.isArray(expected) ? expected : []).map(normaliseCriterion);
|
|
80
|
+
const got = checks.map((check) => normaliseCriterion(check.criterion)).filter(Boolean);
|
|
81
|
+
const missing = [];
|
|
82
|
+
for (const [index, criterion] of want.entries()) {
|
|
83
|
+
if (!criterion)
|
|
84
|
+
continue;
|
|
85
|
+
const id = new RegExp(`(^|[^a-z0-9])a${index + 1}([^0-9]|$)`);
|
|
86
|
+
const covered = got.some((row) => {
|
|
87
|
+
if (row === criterion)
|
|
88
|
+
return true;
|
|
89
|
+
if (id.test(row))
|
|
90
|
+
return true;
|
|
91
|
+
if (Math.min(row.length, criterion.length) < 6)
|
|
92
|
+
return false;
|
|
93
|
+
return row.includes(criterion);
|
|
94
|
+
});
|
|
95
|
+
if (!covered)
|
|
96
|
+
missing.push(`A${index + 1}`);
|
|
97
|
+
}
|
|
98
|
+
return missing;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Parse + validate the `phases` object from a child's evidence block.
|
|
102
|
+
*
|
|
103
|
+
* `expectedAcceptance` is the plan's own acceptance table. When present, every
|
|
104
|
+
* criterion must have a verification check; a shorter list is treated as an
|
|
105
|
+
* incomplete phase-3 verification rather than "some checks are better than none".
|
|
106
|
+
*/
|
|
107
|
+
export function validatePhaseEvidence(value, expectedAcceptance = []) {
|
|
108
|
+
const errors = [];
|
|
109
|
+
let failedPhase = null;
|
|
110
|
+
const fail = (phase, message) => {
|
|
111
|
+
errors.push(message);
|
|
112
|
+
if (failedPhase === null)
|
|
113
|
+
failedPhase = phase;
|
|
114
|
+
};
|
|
115
|
+
if (!isRecord(value)) {
|
|
116
|
+
return {
|
|
117
|
+
ok: false,
|
|
118
|
+
phases: null,
|
|
119
|
+
errors: ['phases 缺失:必须提交 planning / execution / verification 三阶段证据'],
|
|
120
|
+
failedPhase: 'shape',
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const planningRaw = isRecord(value.planning) ? value.planning : null;
|
|
124
|
+
if (!planningRaw)
|
|
125
|
+
fail('planning', 'phases.planning 缺失(阶段一:先梳理问题,再形成可执行思路)');
|
|
126
|
+
const executionRaw = isRecord(value.execution) ? value.execution : null;
|
|
127
|
+
if (!executionRaw)
|
|
128
|
+
fail('execution', 'phases.execution 缺失(阶段二:按阶段一的思路执行)');
|
|
129
|
+
const verificationRaw = isRecord(value.verification) ? value.verification : null;
|
|
130
|
+
if (!verificationRaw)
|
|
131
|
+
fail('verification', 'phases.verification 缺失(阶段三:逐条验证)');
|
|
132
|
+
const planning = {
|
|
133
|
+
problemAnalysis: readTextList(planningRaw?.problemAnalysis, 'phases.planning.problemAnalysis', errors, {
|
|
134
|
+
required: !!planningRaw,
|
|
135
|
+
minItems: 1,
|
|
136
|
+
}),
|
|
137
|
+
constraints: readTextList(planningRaw?.constraints, 'phases.planning.constraints', errors, { required: false }),
|
|
138
|
+
unknowns: readTextList(planningRaw?.unknowns, 'phases.planning.unknowns', errors, { required: false }),
|
|
139
|
+
approach: readTextList(planningRaw?.approach, 'phases.planning.approach', errors, {
|
|
140
|
+
required: !!planningRaw,
|
|
141
|
+
minItems: 1,
|
|
142
|
+
}),
|
|
143
|
+
};
|
|
144
|
+
if (errors.some((item) => item.startsWith('phases.planning.problemAnalysis')))
|
|
145
|
+
failedPhase ||= 'planning';
|
|
146
|
+
if (errors.some((item) => item.startsWith('phases.planning.approach')))
|
|
147
|
+
failedPhase ||= 'planning';
|
|
148
|
+
if (planning.problemAnalysis.length > 0 && totalChars(planning.problemAnalysis) < MIN_PLANNING_PROBLEM_CHARS) {
|
|
149
|
+
fail('planning', `phases.planning.problemAnalysis 太薄(合计 ${totalChars(planning.problemAnalysis)} 字,至少 ${MIN_PLANNING_PROBLEM_CHARS} 字):要逐条写清现状、约束、未知与主要矛盾`);
|
|
150
|
+
}
|
|
151
|
+
if (planning.approach.length > 0 && totalChars(planning.approach) < MIN_PLANNING_APPROACH_CHARS) {
|
|
152
|
+
fail('planning', `phases.planning.approach 太薄(合计 ${totalChars(planning.approach)} 字,至少 ${MIN_PLANNING_APPROACH_CHARS} 字):要写出完整可执行的步骤,而不是一句目标`);
|
|
153
|
+
}
|
|
154
|
+
const execution = {
|
|
155
|
+
steps: readTextList(executionRaw?.steps, 'phases.execution.steps', errors, {
|
|
156
|
+
required: !!executionRaw,
|
|
157
|
+
minItems: 1,
|
|
158
|
+
}),
|
|
159
|
+
deviations: readTextList(executionRaw?.deviations, 'phases.execution.deviations', errors, { required: false }),
|
|
160
|
+
};
|
|
161
|
+
if (errors.some((item) => item.startsWith('phases.execution')))
|
|
162
|
+
failedPhase ||= 'execution';
|
|
163
|
+
const retroCheck = validateRetrospective(verificationRaw?.retrospective);
|
|
164
|
+
for (const error of retroCheck.errors)
|
|
165
|
+
fail('verification', error);
|
|
166
|
+
const verification = {
|
|
167
|
+
allPassed: verificationRaw?.allPassed === true,
|
|
168
|
+
checks: [],
|
|
169
|
+
requirementCheck: typeof verificationRaw?.requirementCheck === 'string'
|
|
170
|
+
? verificationRaw.requirementCheck.trim().slice(0, MAX_PHASE_ITEM_CHARS)
|
|
171
|
+
: '',
|
|
172
|
+
retrospective: retroCheck.retrospective,
|
|
173
|
+
};
|
|
174
|
+
if (verificationRaw && verificationRaw.allPassed !== true) {
|
|
175
|
+
fail('verification', 'phases.verification.allPassed 必须为 true:只要有一条验收标准未通过或未验证,就不得报 done');
|
|
176
|
+
}
|
|
177
|
+
if (!Array.isArray(verificationRaw?.checks)) {
|
|
178
|
+
if (verificationRaw)
|
|
179
|
+
fail('verification', 'phases.verification.checks 必须是数组');
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
verification.checks = verificationRaw.checks
|
|
183
|
+
.slice(0, MAX_PHASE_LIST_ITEMS)
|
|
184
|
+
.map((item, index) => {
|
|
185
|
+
if (!isRecord(item)) {
|
|
186
|
+
fail('verification', `phases.verification.checks[${index}] 必须是对象(criterion / method / evidence)`);
|
|
187
|
+
return { criterion: '', method: '', evidence: '' };
|
|
188
|
+
}
|
|
189
|
+
const check = {
|
|
190
|
+
criterion: typeof item.criterion === 'string' ? item.criterion.trim().slice(0, MAX_PHASE_ITEM_CHARS) : '',
|
|
191
|
+
method: typeof item.method === 'string' ? item.method.trim().slice(0, MAX_PHASE_ITEM_CHARS) : '',
|
|
192
|
+
evidence: typeof item.evidence === 'string' ? item.evidence.trim().slice(0, MAX_PHASE_ITEM_CHARS) : '',
|
|
193
|
+
};
|
|
194
|
+
if (!check.criterion)
|
|
195
|
+
fail('verification', `phases.verification.checks[${index}].criterion 不能为空`);
|
|
196
|
+
if (!check.method)
|
|
197
|
+
fail('verification', `phases.verification.checks[${index}].method 不能为空(用什么方式验证)`);
|
|
198
|
+
if (!check.evidence)
|
|
199
|
+
fail('verification', `phases.verification.checks[${index}].evidence 不能为空(命令输出/文件/引用)`);
|
|
200
|
+
return check;
|
|
201
|
+
});
|
|
202
|
+
if (verification.checks.length === 0) {
|
|
203
|
+
fail('verification', 'phases.verification.checks 至少需要一条逐项验证记录');
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const expected = Array.isArray(expectedAcceptance) ? expectedAcceptance.filter(Boolean) : [];
|
|
207
|
+
if (expected.length > 0 && verification.checks.length < expected.length) {
|
|
208
|
+
fail('verification', `phases.verification.checks 只验证了 ${verification.checks.length} 项,少于验收标准的 ${expected.length} 项:每条验收标准都要有验证记录`);
|
|
209
|
+
}
|
|
210
|
+
if (expected.length > 0) {
|
|
211
|
+
const missing = missingCriteria(expected, verification.checks);
|
|
212
|
+
if (missing.length > 0) {
|
|
213
|
+
fail('verification', `phases.verification.checks 未逐条覆盖验收标准:缺少 ${missing.join('、')}(可按 A1/A2 编号对号入座,或写完整原文;只写一部分不算覆盖)`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const phases = {
|
|
217
|
+
version: THREE_PHASE_VERSION,
|
|
218
|
+
planning,
|
|
219
|
+
execution,
|
|
220
|
+
verification,
|
|
221
|
+
};
|
|
222
|
+
const total = [
|
|
223
|
+
...planning.problemAnalysis,
|
|
224
|
+
...planning.constraints,
|
|
225
|
+
...planning.unknowns,
|
|
226
|
+
...planning.approach,
|
|
227
|
+
...execution.steps,
|
|
228
|
+
...execution.deviations,
|
|
229
|
+
verification.requirementCheck,
|
|
230
|
+
].reduce((sum, item) => sum + item.length, 0);
|
|
231
|
+
if (total > MAX_PHASE_TOTAL_CHARS) {
|
|
232
|
+
fail('shape', `phases 合计超过 ${MAX_PHASE_TOTAL_CHARS} 字,请压缩到可核对的事实,不要粘贴大段日志`);
|
|
233
|
+
}
|
|
234
|
+
return { ok: errors.length === 0, phases: errors.length === 0 ? phases : null, errors, failedPhase };
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Which stage a caller is allowed to be in, judged only by the evidence it sent.
|
|
238
|
+
*
|
|
239
|
+
* Used by `dsh_workplan_verify`: planning/execution gaps mean the caller is
|
|
240
|
+
* still in phase 1 or 2, where the plugin is disabled by the user's rule.
|
|
241
|
+
*/
|
|
242
|
+
export function phaseGateFromErrors(errors) {
|
|
243
|
+
return errors.some((item) => /^phases(\.| 缺失)/.test(item) && /planning|execution/.test(item))
|
|
244
|
+
? 'phase-1-2'
|
|
245
|
+
: 'verification';
|
|
246
|
+
}
|
|
247
|
+
/** One-line, model-readable summary of what the three phases contain. */
|
|
248
|
+
export function phaseSummaryLine(phases) {
|
|
249
|
+
const deviations = phases.execution.deviations.length;
|
|
250
|
+
return [
|
|
251
|
+
`阶段一 规划(问题梳理 ${phases.planning.problemAnalysis.length} 条 / 可执行思路 ${phases.planning.approach.length} 步)`,
|
|
252
|
+
`阶段二 执行(${phases.execution.steps.length} 步${deviations ? ` / 偏离 ${deviations} 处` : ''})`,
|
|
253
|
+
`阶段三 验证(${phases.verification.checks.length} 项${phases.verification.allPassed ? ',全部通过' : ',未全部通过'};`
|
|
254
|
+
+ `复盘 ${phases.verification.retrospective.problems.length} 个问题 / `
|
|
255
|
+
+ `${phases.verification.retrospective.detours.length} 条弯路 / `
|
|
256
|
+
+ `${phases.verification.retrospective.prevention.length} 条防再犯规则)`,
|
|
257
|
+
].join(';');
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Prompt paragraphs injected into every department child.
|
|
261
|
+
*
|
|
262
|
+
* Kept in this module so the wording and the validator above are one contract:
|
|
263
|
+
* changing what is demanded without changing what is checked would make the
|
|
264
|
+
* prompt lie about completion.
|
|
265
|
+
*/
|
|
266
|
+
export function threePhasePromptLines() {
|
|
267
|
+
return [
|
|
268
|
+
'三阶段工作法(用户强制要求;顺序不可颠倒,阶段一没有产出思路之前禁止动手执行):',
|
|
269
|
+
'【阶段一 · 规划阶段】',
|
|
270
|
+
' 1) 先全面、深入梳理要解决的问题:逐条写清现状与已知事实、约束条件、未知/待确认项、主要矛盾、工作边界;',
|
|
271
|
+
' 2) 再全面、深入思考,整理出能完美完成本子任务的完整、可执行思路:每一步做什么、产出什么、依赖什么、风险与对策、如何证明做对了;',
|
|
272
|
+
' 3) 自检:任何一条验收标准或用户原要求没有落在思路上,就回到第 1 步重做;思路不完整不得进入阶段二。',
|
|
273
|
+
'【阶段二 · 执行阶段】',
|
|
274
|
+
' 严格按阶段一整理出的思路执行。出现新事实需要偏离时,必须记录偏离原因、证据与调整后的做法,不得静默改道。',
|
|
275
|
+
'【阶段三 · 验证阶段】',
|
|
276
|
+
' 执行完成后逐条验证验收标准与用户原要求:每条都要有可复核的证据(命令输出/文件/引用);验证未通过不得报 done,无法确认写 unverified。',
|
|
277
|
+
'【阶段三收尾 · 自我学习复盘(强制)】',
|
|
278
|
+
' 报 done 之前必须把 phases.verification.retrospective 写全,四项缺一不可:',
|
|
279
|
+
' 1) problems:本次全过程遇到的所有问题(现象 + 根因),至少 1 条;',
|
|
280
|
+
' 2) detours:走过的弯路、返工与无效尝试(确实没有就写空数组 [],不要编造);',
|
|
281
|
+
' 3) resolutions:最终是如何解决上述问题的,至少 1 条,可与 problems 一一对应;',
|
|
282
|
+
' 4) prevention:以后如何预防再犯,至少 1 条,必须写成「遇到…先…」的可执行硬规则。',
|
|
283
|
+
' 插件会在完成判定时复核这四项,并在通过后把复盘写入永久记忆文件;下次派发同类任务时,历史教训会自动出现在提示词里。',
|
|
284
|
+
'插件使用说明(三阶段证据门禁):',
|
|
285
|
+
' - 阶段一、二:先把问题梳理、可执行思路与执行记录写全;此时不要调用 dsh_workplan_verify,它会因缺少前两阶段证据返回 PHASE_GATE 与待补项(这是证据门禁,不是禁用插件)。',
|
|
286
|
+
' - 阶段三:可以调用 dsh_workplan_verify 让插件做最终核验:提交 planning / execution / verification 三阶段证据,插件返回 passed 或仍需补齐的 gaps;未通过先修复再回报。遇阻时可用 dsh_workplan_escalate 上报,它是安全通道,不属于三阶段产物。',
|
|
287
|
+
' - 结果块里的 phases 是必填项:缺任一阶段、内容为空、或验证未全部通过,插件都会判为未完成,不能用 done 收尾。',
|
|
288
|
+
];
|
|
289
|
+
}
|
package/package.json
CHANGED