pi-auto-unattended 0.7.0 → 0.8.0
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 +12 -0
- package/README.md +2 -2
- package/extensions/pi-auto.ts +53 -10
- package/lib.sh +32 -4
- package/package.json +1 -1
- package/pi-auto +1 -1
- package/test/lib.test.sh +34 -0
- package/test/pi-auto.test.mjs +36 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 0.8.0 (2026-12-05)
|
|
4
|
+
|
|
5
|
+
- 修语义偏差(用户 2026-12-05):「off = 服务今天不会再拉起本目录」把 agent 的开关说成了**目录**级,
|
|
6
|
+
而它实际关的是**本会话**。现在:
|
|
7
|
+
- `retired/<slug>.json` 记 `scope:"session"` + `sessionId` + `pid` + `boot` + `promptHash`,
|
|
8
|
+
文案改为「本会话已收工:不再续轮。服务今天不再为这份需求拉起本目录(改 `projects[].prompt`、
|
|
9
|
+
写今日补充、预约到点或 `pi-auto on` 才会重新拉起)」。
|
|
10
|
+
- 新增工单指纹 `jobFingerprint` = `sha1(projects[].prompt + "\n" + 作用域内 today.prompt)`(TS 与
|
|
11
|
+
`lib.sh:pi_job_fingerprint` 同口径、两边各自有测试):**指纹变了 ⇒ 当天的收工标记作废**
|
|
12
|
+
(`pi_retired_today` 返回「未收工」),服务可以重新拉起 —— 这样「agent 关掉自己」不会把目录整天锁死。
|
|
13
|
+
- legacy 标记(没有 `promptHash` 的旧文件)按已收工处理,升级不会把旧标记当成新活。
|
|
14
|
+
- 回归:`node --test` 31 → 32 条、`test/lib.test.sh` 新增 4 条(指纹一致/legacy/需求变更/今日补充变更)。
|
|
3
15
|
## 0.7.0 (2026-12-05)
|
|
4
16
|
|
|
5
17
|
- 新增**交接线**(用户口径:全天候 agent = 一个 agent 做完本轮把活交给下一轮):`agent_before_settle`
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ extensions/pi-auto.ts ──> state/auto/*.json (不 import bash/服务代
|
|
|
19
19
|
服务/CLI ──写文件──> pi-mailbox inbox ──读/注入──> 会话
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
- 扩展与服务只通过文件契约通信:`session-<pid>.json`(开关/轮次)、`retired/<slug>.json
|
|
22
|
+
- 扩展与服务只通过文件契约通信:`session-<pid>.json`(开关/轮次)、`retired/<slug>.json`(本会话当天收工 + 工单指纹)、
|
|
23
23
|
`audit.log`(审计)。
|
|
24
24
|
- 进上下文的话**只有一条通道**:`pi-mailbox`。本仓不实现 `send-keys`,也不自己调 `sendUserMessage`。
|
|
25
25
|
- 代理探测仍是单向依赖 `~/bin/lib-proxy.sh`;没有反向调用。
|
|
@@ -272,7 +272,7 @@ systemd --user pi-auto.service
|
|
|
272
272
|
- 无人值守会话(`PI_AUTO_SESSION_ID` / 兼容 `PI_BOOT_SESSION_ID` / `PI_RUN_DIR`)默认 **on**;
|
|
273
273
|
用户手开会话默认 **off**(不许静默自己续轮)。
|
|
274
274
|
- `on`:本轮结束后在 `agent_before_settle` 追加一条续轮草稿并 `continue: true`,**无轮次上限**。
|
|
275
|
-
- `off`:唯一收工信号。写 `retired/<slug>.json`
|
|
275
|
+
- `off`:唯一收工信号。写 `retired/<slug>.json` 后停;服务当天不再为同一份需求拉起该目录。
|
|
276
276
|
- `aborted`(Escape/断流)或 `error`(上游重试耗尽):不做硬续轮,而是延迟 15s/30s/1m/2m/5m
|
|
277
277
|
往自己的 mailbox inbox 写一条轻推;`completed` 轮会重置退避计数。
|
|
278
278
|
- 子代理/async runner 进程(`PI_SUBAGENT_*`、`PI_ASYNC_NATIVE_RUNNER`)直接不参与。
|
package/extensions/pi-auto.ts
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
*
|
|
13
13
|
* 状态(`<agentDir>/state/auto/`,`PI_AUTO_STATE_DIR` 可覆盖):
|
|
14
14
|
* session-<pid>.json { pid,cwd,slug,sessionId,boot,keepAlive,rounds,outcome,phase,updatedAt,... }
|
|
15
|
-
* retired/<slug>.json { date,reason }
|
|
15
|
+
* retired/<slug>.json { date,reason,scope,sessionId,pid,boot,promptHash }
|
|
16
|
+
* 本会话已收工 + 哪个工单收的(指纹变了 ⇒ 服务可重新拉起)
|
|
16
17
|
* audit.log 一行一条 JSON
|
|
17
18
|
*/
|
|
18
19
|
import crypto from "node:crypto";
|
|
@@ -108,10 +109,38 @@ export function retiredFile(cwd: string): string {
|
|
|
108
109
|
return path.join(retiredRoot(), `${slugFor(cwd)}.json`);
|
|
109
110
|
}
|
|
110
111
|
|
|
112
|
+
/**
|
|
113
|
+
* 「这份工单」的指纹 = sha1(projects[].prompt + "\n" + 作用域命中的 today.prompt)。
|
|
114
|
+
* 与 lib.sh:pi_job_fingerprint 同口径。收工标记记的是**哪个工单收的工**,
|
|
115
|
+
* 不是「这个目录今天不许再动」——需求变了就该重新拉起(2026-12-05 用户口径)。
|
|
116
|
+
*/
|
|
117
|
+
export function jobFingerprint(cwd: string, now = new Date()): string {
|
|
118
|
+
const dir = resolveDir(cwd);
|
|
119
|
+
let prompt = "";
|
|
120
|
+
let today = "";
|
|
121
|
+
try {
|
|
122
|
+
const plan = readPlan();
|
|
123
|
+
const proj = plan.projects.find((p) => p.dir && resolveDir(p.dir) === dir);
|
|
124
|
+
prompt = proj?.prompt ?? "";
|
|
125
|
+
if (plan.today.date === localDate(now) && (!plan.today.dir || resolveDir(plan.today.dir) === dir)) {
|
|
126
|
+
today = plan.today.prompt ?? "";
|
|
127
|
+
}
|
|
128
|
+
} catch {
|
|
129
|
+
/* plan 读不到就按空指纹算(等价于 legacy 行为) */
|
|
130
|
+
}
|
|
131
|
+
return crypto.createHash("sha1").update(`${prompt}\n${today}`).digest("hex");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 今天是否已为**这份工单**收工。legacy(没有 promptHash 的旧文件)按「已收工」处理,
|
|
136
|
+
* 避免升级后把旧的收工标记当成新活。
|
|
137
|
+
*/
|
|
111
138
|
export function retiredToday(cwd: string, now = new Date()): boolean {
|
|
112
139
|
try {
|
|
113
|
-
const data = JSON.parse(fs.readFileSync(retiredFile(cwd), "utf8")) as { date?: string };
|
|
114
|
-
|
|
140
|
+
const data = JSON.parse(fs.readFileSync(retiredFile(cwd), "utf8")) as { date?: string; promptHash?: string };
|
|
141
|
+
if (data.date !== localDate(now)) return false;
|
|
142
|
+
if (!data.promptHash) return true;
|
|
143
|
+
return data.promptHash === jobFingerprint(cwd, now);
|
|
115
144
|
} catch {
|
|
116
145
|
return false;
|
|
117
146
|
}
|
|
@@ -122,11 +151,21 @@ function localDate(d: Date): string {
|
|
|
122
151
|
return new Date(d.getTime() - off).toISOString().slice(0, 10);
|
|
123
152
|
}
|
|
124
153
|
|
|
125
|
-
|
|
154
|
+
/** 收工 = 本会话停;顺带记下「哪份工单、哪个会话」收的,服务据此决定还要不要为同样的需求再拉起。 */
|
|
155
|
+
export function retire(cwd: string, reason: string, extra: { sessionId?: string; pid?: number; boot?: boolean } = {}): void {
|
|
126
156
|
try {
|
|
127
157
|
fs.mkdirSync(retiredRoot(), { recursive: true });
|
|
128
158
|
const file = retiredFile(cwd);
|
|
129
|
-
|
|
159
|
+
const payload = {
|
|
160
|
+
date: localDate(new Date()),
|
|
161
|
+
reason,
|
|
162
|
+
scope: "session",
|
|
163
|
+
sessionId: extra.sessionId ?? "",
|
|
164
|
+
pid: extra.pid ?? process.pid,
|
|
165
|
+
boot: extra.boot ?? false,
|
|
166
|
+
promptHash: jobFingerprint(cwd),
|
|
167
|
+
};
|
|
168
|
+
fs.writeFileSync(file, `${JSON.stringify(payload, null, 2)}\n`);
|
|
130
169
|
} catch {
|
|
131
170
|
/* 收工标记写不进去不影响会话退出 */
|
|
132
171
|
}
|
|
@@ -925,7 +964,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
925
964
|
const setKeepAlive = (ctx: ExtensionContext, enabled: boolean, by: "agent" | "command" | "retired", note?: string): AutoState => {
|
|
926
965
|
const next = touch(ctx, { keepAlive: enabled });
|
|
927
966
|
if (enabled) unretire(next.cwd);
|
|
928
|
-
else if (next.boot)
|
|
967
|
+
else if (next.boot) {
|
|
968
|
+
retire(next.cwd, note?.trim() || by, { sessionId: next.sessionId, pid: next.pid, boot: next.boot });
|
|
969
|
+
}
|
|
929
970
|
audit({ kind: enabled ? "on" : "off", by, cwd: next.cwd, note: note ?? null, rounds: next.rounds });
|
|
930
971
|
return next;
|
|
931
972
|
};
|
|
@@ -953,11 +994,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
953
994
|
label: "无人值守续轮开关",
|
|
954
995
|
description:
|
|
955
996
|
"pi-auto 的续轮开关:on = 本轮结束后自动接着推下一轮(无轮次上限,直到你自己 off);" +
|
|
956
|
-
"off =
|
|
997
|
+
"off = 本会话收工(不再自动续轮;服务当天不再为这份需求拉起本目录,需求/今日补充/预约变了才重新拉起);status = 看当前开关/轮次。",
|
|
957
998
|
promptSnippet: "无人值守续轮开关(pi-auto):要接着干就 on,收工就 off",
|
|
958
999
|
promptGuidelines: [
|
|
959
1000
|
"还有自己能做的活 → `auto_switch({action:\"on\"})`(无人值守会话默认已开);",
|
|
960
|
-
"收工或只剩人工/审批/环境门 → `auto_switch({action:\"off\", note:\"原因\"})
|
|
1001
|
+
"收工或只剩人工/审批/环境门 → `auto_switch({action:\"off\", note:\"原因\"})`:这是唯一的收工信号(关的是**本会话**,服务当天不再为同一份需求拉起本目录);",
|
|
961
1002
|
"等 CI/子代理/分钟级 ⇒ `auto_timer({after:\"25m\"})`;等一条长命令 ⇒ `auto_bg({command:…})`(都是调完就结束本轮,不要 `bash sleep`);",
|
|
962
1003
|
],
|
|
963
1004
|
parameters: {
|
|
@@ -980,7 +1021,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
980
1021
|
type: "text" as const,
|
|
981
1022
|
text:
|
|
982
1023
|
`pi-auto:keepAlive=${next.keepAlive}(轮次 ${next.rounds})。` +
|
|
983
|
-
(next.keepAlive ? "本轮结束后自动续下一轮;收工时记得 off。" : "
|
|
1024
|
+
(next.keepAlive ? "本轮结束后自动续下一轮;收工时记得 off。" : "本会话已收工:不再续轮。服务今天不再为这份需求拉起本目录(改 projects[].prompt、写今日补充、预约到点或 `pi-auto on` 才会重新拉起)。"),
|
|
984
1025
|
},
|
|
985
1026
|
],
|
|
986
1027
|
details: { state: next },
|
|
@@ -1694,7 +1735,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
1694
1735
|
if (!state) return;
|
|
1695
1736
|
audit({ kind: "session-end", cwd: state.cwd, rounds: state.rounds, keepAlive: state.keepAlive, reason: event.reason });
|
|
1696
1737
|
if (!state.keepAlive) {
|
|
1697
|
-
if (state.boot)
|
|
1738
|
+
if (state.boot) {
|
|
1739
|
+
retire(state.cwd, `session_shutdown:${event.reason}`, { sessionId: state.sessionId, pid: state.pid, boot: state.boot });
|
|
1740
|
+
}
|
|
1698
1741
|
try {
|
|
1699
1742
|
fs.rmSync(statePath(state.pid), { force: true });
|
|
1700
1743
|
} catch {
|
package/lib.sh
CHANGED
|
@@ -163,12 +163,40 @@ pi_sid_current() {
|
|
|
163
163
|
# 由扩展在 auto_switch off / 正常退出时写,由本库读;服务据此当天不再拉起。
|
|
164
164
|
pi_retired_file() { printf '%s/%s.json' "$PI_AUTO_RETIRED_DIR" "$(pi_slug_for "$1")"; }
|
|
165
165
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
# 「这份工单」的指纹 = sha1(projects[].prompt + "\n" + 作用域命中的 today.prompt)。
|
|
167
|
+
# 与 extensions/pi-auto.ts:jobFingerprint 同口径。收工标记记的是**哪个工单收的工**:
|
|
168
|
+
# 需求/今日补充一变,指纹就变 ⇒ 同一目录当天还能被重新拉起(2026-12-05 用户口径:
|
|
169
|
+
# agent 关掉的是**本会话**,不是「这个目录今天不许再动」)。
|
|
170
|
+
pi_plan_project_prompt() { # <目录>
|
|
171
|
+
local dir="${1:-}"
|
|
172
|
+
pi_plan_has || return 0
|
|
173
|
+
jq -r --arg home "$HOME" --arg d "$dir" '
|
|
174
|
+
[ .projects[]? | select((.dir // "") != "")
|
|
175
|
+
| (.dir as $x | (if ($x | startswith("~")) then ($home + ($x | sub("^~"; ""))) else $x end)) as $abs
|
|
176
|
+
| select($abs == $d) | (.prompt // "") ] | (first // "")' "$PI_AUTO_PLAN_FILE" 2>/dev/null | head -1
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
pi_job_fingerprint() { # <目录>
|
|
180
|
+
local dir prompt today
|
|
181
|
+
dir="$(realpath -m -- "${1:-$PWD}" 2>/dev/null || printf '%s' "${1:-$PWD}")"
|
|
182
|
+
prompt="$(pi_plan_project_prompt "$dir")"
|
|
183
|
+
today="$(pi_plan_today_for "$dir")"
|
|
184
|
+
pi_plan_hash "$prompt
|
|
185
|
+
$today"
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
pi_retired_today() { # <目录>;返回 0 = 这份工单今天已收工
|
|
189
|
+
local f dir d ph
|
|
190
|
+
dir="$(realpath -m -- "${1:-$PWD}" 2>/dev/null || printf '%s' "${1:-$PWD}")"
|
|
191
|
+
f="$(pi_retired_file "$dir")"
|
|
169
192
|
[ -f "$f" ] || return 1
|
|
170
193
|
d="$(jq -r '.date // empty' "$f" 2>/dev/null)"
|
|
171
|
-
[ "$d" = "$(date +%F)" ]
|
|
194
|
+
[ "$d" = "$(date +%F)" ] || return 1
|
|
195
|
+
ph="$(jq -r '.promptHash // empty' "$f" 2>/dev/null)"
|
|
196
|
+
[ -n "$ph" ] || return 0 # legacy(升级前的收工标记)按已收工处理,避免被当成新活
|
|
197
|
+
[ "$ph" = "$(pi_job_fingerprint "$dir")" ] && return 0
|
|
198
|
+
pi_log "收工标记已过期(工单指纹变了):$dir ⇒ 视为未收工,可重新拉起"
|
|
199
|
+
return 1
|
|
172
200
|
}
|
|
173
201
|
|
|
174
202
|
pi_retired_set() { # <目录> <原因>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-auto-unattended",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Unattended Pi sessions: tool-side extensions (auto_switch keep-alive, auto_schedule timed runs, auto_today project-scoped daily brief, auto_timer/auto_bg wait-without-blocking, context-threshold handoff at idle) plus a pi-auto CLI and systemd daemon that keeps one agent alive per selected folder and nudges them through pi-mailbox.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
package/pi-auto
CHANGED
|
@@ -78,7 +78,7 @@ ensure_one() { # <目录> <常驻需求> [force] [一次性请求]
|
|
|
78
78
|
pi_state_init "$session" "$PI_AUTO_DIR" "$PI_AUTO_TAG"
|
|
79
79
|
|
|
80
80
|
if [ "$force" != "1" ] && pi_retired_today "$PI_AUTO_DIR"; then
|
|
81
|
-
pi_log "跳过 $session
|
|
81
|
+
pi_log "跳过 $session:这份需求今天已收工(改 projects[].prompt / 写今日补充 / 预约到点 / pi-auto on 都会重新拉起)"
|
|
82
82
|
return 0
|
|
83
83
|
fi
|
|
84
84
|
|
package/test/lib.test.sh
CHANGED
|
@@ -145,4 +145,38 @@ jq '.projects += [{"dir":"'"$HOME"'/expired","enabled":true,"prompt":"","until":
|
|
|
145
145
|
# 锁用后不留痕迹
|
|
146
146
|
[ ! -e "$PI_AUTO_PLAN_FILE.lockdir" ] || fail "plan.json 锁未释放"
|
|
147
147
|
|
|
148
|
+
|
|
149
|
+
# 收工标记绑定「这份工单」:指纹变了(projects[].prompt 或作用域内 today.prompt 变)⇒ 视为未收工
|
|
150
|
+
mkdir -p "$HOME/job"
|
|
151
|
+
cat >"$PI_AUTO_PLAN_FILE" <<JSON
|
|
152
|
+
{"version":2,"today":{"date":"$(date +%F)","dir":"","prompt":"今日补充A","hash":"x","deliveredTo":[]},
|
|
153
|
+
"projects":[{"dir":"$HOME/job","enabled":true,"prompt":"需求A"}],"schedules":[]}
|
|
154
|
+
JSON
|
|
155
|
+
fp="$(pi_job_fingerprint "$HOME/job")"
|
|
156
|
+
[ "${#fp}" = 40 ] || fail "job 指纹应是 sha1"
|
|
157
|
+
pi_retired_write() { # <promptHash|空>
|
|
158
|
+
mkdir -p "$PI_AUTO_RETIRED_DIR"
|
|
159
|
+
jq -n --arg d "$(date +%F)" --arg h "$1" --arg s "pi-auto-job-1" '{date:$d,reason:"agent off",scope:"session",sessionId:$s,pid:123,boot:true,promptHash:$h}' \
|
|
160
|
+
>"$(pi_retired_file "$HOME/job")"
|
|
161
|
+
}
|
|
162
|
+
pi_retired_write "$fp"
|
|
163
|
+
pi_retired_today "$HOME/job" || fail "指纹一致 ⇒ 应判已收工"
|
|
164
|
+
# legacy(没有 promptHash)仍按已收工处理
|
|
165
|
+
pi_retired_write ""
|
|
166
|
+
pi_retired_today "$HOME/job" || fail "legacy 收工标记应仍算已收工"
|
|
167
|
+
# 需求变了 ⇒ 视为未收工(同一目录当天要能重新拉起)
|
|
168
|
+
pi_retired_write "$fp"
|
|
169
|
+
jq '.projects[0].prompt="需求B"' "$PI_AUTO_PLAN_FILE" >"$PI_AUTO_PLAN_FILE.t" && mv "$PI_AUTO_PLAN_FILE.t" "$PI_AUTO_PLAN_FILE"
|
|
170
|
+
if pi_retired_today "$HOME/job"; then fail "projects[].prompt 变了仍判已收工"; fi
|
|
171
|
+
# 今日补充变了同样唤醒
|
|
172
|
+
cat >"$PI_AUTO_PLAN_FILE" <<JSON
|
|
173
|
+
{"version":2,"today":{"date":"$(date +%F)","dir":"$HOME/job","prompt":"今日补充A","hash":"x","deliveredTo":[]},
|
|
174
|
+
"projects":[{"dir":"$HOME/job","enabled":true,"prompt":"需求A"}],"schedules":[]}
|
|
175
|
+
JSON
|
|
176
|
+
pi_retired_write "$(pi_job_fingerprint "$HOME/job")"
|
|
177
|
+
pi_retired_today "$HOME/job" || fail "补充未变 ⇒ 已收工"
|
|
178
|
+
jq '.today.prompt="今日补充B"' "$PI_AUTO_PLAN_FILE" >"$PI_AUTO_PLAN_FILE.t" && mv "$PI_AUTO_PLAN_FILE.t" "$PI_AUTO_PLAN_FILE"
|
|
179
|
+
if pi_retired_today "$HOME/job"; then fail "今日补充变了仍判已收工"; fi
|
|
180
|
+
rm -f "$(pi_retired_file "$HOME/job")"
|
|
181
|
+
|
|
148
182
|
echo "lib.sh gate: OK"
|
package/test/pi-auto.test.mjs
CHANGED
|
@@ -29,10 +29,12 @@ import register, {
|
|
|
29
29
|
retire,
|
|
30
30
|
retiredFile,
|
|
31
31
|
retiredToday,
|
|
32
|
+
jobFingerprint,
|
|
32
33
|
slugFor,
|
|
33
34
|
statePath,
|
|
34
35
|
timersPath,
|
|
35
36
|
todayHash,
|
|
37
|
+
updatePlan,
|
|
36
38
|
writeTimers,
|
|
37
39
|
} from "../extensions/pi-auto.ts";
|
|
38
40
|
|
|
@@ -817,3 +819,37 @@ test("交接(reason=new)不丢计时器;真退出才清;死 pid 的孤
|
|
|
817
819
|
host.cleanup();
|
|
818
820
|
}
|
|
819
821
|
});
|
|
822
|
+
|
|
823
|
+
test("收工标记绑的是会话+工单(不是目录):写 sessionId/scope/promptHash,需求变了当天还能重新拉起", async () => {
|
|
824
|
+
const host = createHost({ boot: true });
|
|
825
|
+
try {
|
|
826
|
+
await host.boot();
|
|
827
|
+
updatePlan((p) => {
|
|
828
|
+
p.projects = [{ dir: host.ctx.cwd, enabled: true, prompt: "需求A" }];
|
|
829
|
+
});
|
|
830
|
+
assert.match(jobFingerprint(host.ctx.cwd), /^[0-9a-f]{40}$/);
|
|
831
|
+
const off = await host.callTool("auto_switch", { action: "off", note: "做完了" });
|
|
832
|
+
assert.match(off.content[0].text, /本会话已收工/);
|
|
833
|
+
assert.match(off.content[0].text, /不再为这份需求拉起本目录/);
|
|
834
|
+
|
|
835
|
+
const raw = JSON.parse(readFileSync(retiredFile(host.ctx.cwd), "utf8"));
|
|
836
|
+
assert.equal(raw.scope, "session");
|
|
837
|
+
assert.equal(raw.sessionId, "sess-1");
|
|
838
|
+
assert.equal(raw.reason, "做完了");
|
|
839
|
+
assert.equal(raw.boot, true);
|
|
840
|
+
assert.match(raw.promptHash, /^[0-9a-f]{40}$/);
|
|
841
|
+
assert.equal(retiredToday(host.ctx.cwd), true);
|
|
842
|
+
|
|
843
|
+
// 同一目录换了工单 ⇒ 今天的收工标记不再算数(服务可以重新拉起)
|
|
844
|
+
updatePlan((p) => {
|
|
845
|
+
p.projects[0].prompt = "需求B";
|
|
846
|
+
});
|
|
847
|
+
assert.equal(retiredToday(host.ctx.cwd), false);
|
|
848
|
+
|
|
849
|
+
// legacy 标记(升级前写的、没有 promptHash)仍按已收工处理
|
|
850
|
+
writeFileSync(retiredFile(host.ctx.cwd), JSON.stringify({ date: new Date().toISOString().slice(0, 10), reason: "old" }));
|
|
851
|
+
assert.equal(retiredToday(host.ctx.cwd), true);
|
|
852
|
+
} finally {
|
|
853
|
+
host.cleanup();
|
|
854
|
+
}
|
|
855
|
+
});
|