@leiyi-works/dsh-session-tmpdir 0.10.6 → 0.10.8
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/README.md +15 -1
- package/index.js +11 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ v0.7 起,这条规则不再只靠 `write`/`edit`/`pwsh`/`bash` 四个工具名
|
|
|
69
69
|
## 长期文件审批流程
|
|
70
70
|
|
|
71
71
|
1. 模型判断某文件需要长期保存,且不在任务指定位置;
|
|
72
|
-
2. 模型调用 `ask_user_question`
|
|
72
|
+
2. 模型调用 `ask_user_question` 给用户**固定问法**的选择题(标题「保存位置」、问题「这份要长期保存吗?」,只给 **A 不长期保存** / **B 工作区根目录保存** 两个选项;v0.10.8 起 A 的 description 必须用 `task_tmpdir` 返回的真实绝对路径(含真实会话标题,如「临时目录 D:\DSH工作区\_tmp\<实际标题>,随会话删除后 7 天清理」),不再出现 `<会话标题>` 占位符;v0.10.7 起禁止自创/替换/增删选项、禁止把路径写进标签;选 B 时模型自行起目录名、不再跟用户确认;其他位置由用户直接在输入框里写路径);
|
|
73
73
|
3. 用户选长期 + 给路径 → 模型调 `longterm_approve({ path, reason, basis })` 登记:**默认 `mode: 'file'` 只批准这一个文件**;用户明确要"整个目录都行"时才用 `mode: 'dir'`。工作区外路径也能登记(例如鸿蒙的 `Download/<包名>/`),但不能登记磁盘根目录、用户主目录本身或层级过浅的目录;
|
|
74
74
|
4. 之后 `write`/`edit`、shell 命令、`publish` 交付、python 等代码工具才能**新建**该位置的文件;用户否定 → 模型改用 `task_tmpdir` 写 `_tmp`。**改写已存在文件不需要登记**(`allowOverwrite`)。
|
|
75
75
|
|
|
@@ -273,3 +273,17 @@ v0.10.3 变更(2026-11-16):
|
|
|
273
273
|
- 每步注入的固定说明(约 3,700 字符)改为可配置 `promptMode`,默认 `compact`(约 400 字符中文要点:`_tmp/<会话标题>/`、先调 `task_tmpdir`、长期文件先问、被 guard 拒绝就换 task_tmpdir、白名单面板)。
|
|
274
274
|
- `full` 恢复原完整说明(允许清单、白名单跨机同步细节等);`off` 完全不注入。
|
|
275
275
|
- guard 逻辑、审批流程、清理规则全部不变——`compact`/`off` 下越界写入仍会被拒绝,错误信息本身会引导改用 `task_tmpdir`。
|
|
276
|
+
|
|
277
|
+
## v0.10.7 变更(2026-11-19):标准问法回归
|
|
278
|
+
|
|
279
|
+
- 背景:v0.10.5 注入瘦身(`compact` 默认)把「选项标签逐字照抄 A/B 两项」的要求删掉后,实测模型开始自由发挥——把 A(不长期保存/临时目录)替换成「用户目录 `~/.dsh/tools/…`」,甚至把路径写进选项标签(2026-11-19「投屏小窗」会话实例,用户反馈“以前挺好”)。
|
|
280
|
+
- `compact` 注入重新写明**固定问法**:标题「保存位置」+ 问题「这份要长期保存吗?存哪?」+ A「不长期保存」(description:`_tmp/<会话标题>/`,临时目录,随会话删除后 N 天清理)+ B「工作区根目录保存」(description:长期保存到会话工作区根目录下);其它位置由用户在输入框写,不另列选项;禁止自创/替换/增删选项、禁止把路径或目录名写进标签。
|
|
281
|
+
- `full` 注入同步改为 “FIXED question”,明确 never invent options / never add a third option;`用户目录`/`指定目录`/`工作区外目录` 只能由输入框给出,不得变成选项。
|
|
282
|
+
- guard 的 5 处拦截提示(工作区根目录、未批准落点、命令守卫两处、工作区外)都带上固定两项,模型被拒后照着问即可。
|
|
283
|
+
- guard 判定、审批、清理逻辑未改。
|
|
284
|
+
|
|
285
|
+
## v0.10.8 变更(2026-11-19):弹窗文字按用户要求微调
|
|
286
|
+
|
|
287
|
+
- 问题文字去掉「存哪?」:固定为「这份要长期保存吗?」(位置由 A/B 两个选项表达)。
|
|
288
|
+
- A「不长期保存」的 description 改为**实时真实路径**:弹窗前先调 `task_tmpdir` 取本会话临时目录的绝对路径(含真实会话标题),写成「临时目录 <该路径>,随会话删除后 N 天清理」;不再出现 `<会话标题>` 占位符和反引号(GUI 会把反引号原样显示)。
|
|
289
|
+
- `full` 注入同步;guard 判定、审批、清理逻辑未改。
|
package/index.js
CHANGED
|
@@ -316,7 +316,8 @@ export function buildPromptText(cfg) {
|
|
|
316
316
|
'## Task temp folder(session-task-tmpdir)',
|
|
317
317
|
'',
|
|
318
318
|
`- 临时产物一律写到 <会话工作目录>/${rootDirName}/<会话标题>/,不要放在工作区根目录;先调用 \`task_tmpdir\` 拿准确路径(会话改名会跟着改,别写死)。`,
|
|
319
|
-
`- 长期文件(可复用脚本/记录/交付成品)写到 \`${rootDirName}/\`
|
|
319
|
+
`- 长期文件(可复用脚本/记录/交付成品)写到 \`${rootDirName}/\` 以外前必须先问用户,且只能用下面的固定问法;用户同意后 \`longterm_approve\` 登记再写;${allowOverwrite ? '覆盖已存在的文件不用问;' : '覆盖已存在文件也要问;'}临时产物不要问用户。`,
|
|
320
|
+
`- 固定问法(禁止自创/替换/增删选项,禁止把位置写进选项标签):标题「保存位置」+ 问题「这份要长期保存吗?」+ 选项 A「不长期保存」+ 选项 B「工作区根目录保存」。A 的 description 必须先调用 \`task_tmpdir\` 拿本会话临时目录的真实绝对路径(含真实会话标题),写成「临时目录 <该绝对路径>,随会话删除后 ${orphanCleanupDays} 天清理」,不要出现 <会话标题> 占位符、不要用反引号;B 的 description 固定写「长期保存到会话工作区根目录下」。其它位置由用户在输入框自己写,不另列成选项。`,
|
|
320
321
|
`- 未登记就写到 \`${rootDirName}/\` 以外会被 guard 直接拒绝(write/edit、shell、代码执行、publish 等所有写通道);被拒就改用 task_tmpdir 的路径,不要换写法绕过。白名单见左侧「临时目录」面板。`,
|
|
321
322
|
].join('\n')
|
|
322
323
|
}
|
|
@@ -332,10 +333,12 @@ export function buildPromptText(cfg) {
|
|
|
332
333
|
rootDirName +
|
|
333
334
|
'/` and must NOT trigger a question.',
|
|
334
335
|
`v0.9 rule (方案3): **creating a new file outside \`${rootDirName}/\` requires the user's approval**; **overwriting an existing file is allowed without asking**. Approval is per file by default (\`longterm_approve\` mode=file); mode=dir approves the whole directory.`,
|
|
335
|
-
`Before creating a new long-term file outside \`${rootDirName}/\`, you MUST ask the user with \`ask_user_question\`
|
|
336
|
+
`Before creating a new long-term file outside \`${rootDirName}/\`, you MUST ask the user with \`ask_user_question\` using this FIXED question — never invent options, never replace them with concrete folders, never add a third option:`,
|
|
337
|
+
'- header: 保存位置',
|
|
338
|
+
'- question: 这份要长期保存吗?',
|
|
336
339
|
'- A. 不长期保存',
|
|
337
340
|
'- B. 工作区根目录保存',
|
|
338
|
-
`
|
|
341
|
+
`Use exactly these two labels; put the explanation in each option's \`description\` instead. A: call \`task_tmpdir\` FIRST and write the REAL absolute path of this session's temp folder (it contains the actual session title): 临时目录 <that absolute path>,随会话删除后 ${orphanCleanupDays} 天清理 — never the <会话标题> placeholder, never backticks. B: 长期保存到会话工作区根目录下. Never put a path or folder name into a label. Any other location is typed by the user in the free-text answer box — that box covers 用户目录/指定目录/工作区外目录, so none of those may become options.`,
|
|
339
342
|
'Do not create anything until the user answers.',
|
|
340
343
|
'Picking B: pick a clear file path under the workspace root, call `longterm_approve` with it (mode=file by default), then write it.',
|
|
341
344
|
'Any answer other than A/B (e.g. a path the user typed in the free-text box) is a designated location: if it is missing or ambiguous, ask the user to confirm it before calling `longterm_approve` — never guess.',
|
|
@@ -534,7 +537,7 @@ export function longtermGuardReason(targetPath, cwd, options = {}) {
|
|
|
534
537
|
if (allowRootFiles.some((entry) => entry.toLowerCase() === name.toLowerCase())) return undefined
|
|
535
538
|
if (globMatch(name, allowRootPatterns)) return undefined
|
|
536
539
|
return (
|
|
537
|
-
`工作区根目录不能新建/修改条目(${name})。若这份内容需要长期保存:先用 ask_user_question
|
|
540
|
+
`工作区根目录不能新建/修改条目(${name})。若这份内容需要长期保存:先用 ask_user_question 征求用户意见(固定问法:A「不长期保存」/ B「工作区根目录保存」,其它位置让用户写在输入框),` +
|
|
538
541
|
`用户同意后用 longterm_approve 登记用户指定的目录再写;用户不同意或属于临时产物 → 用 task_tmpdir 写到 ` +
|
|
539
542
|
`${rootDirName}/<会话标题>/。`
|
|
540
543
|
)
|
|
@@ -543,7 +546,7 @@ export function longtermGuardReason(targetPath, cwd, options = {}) {
|
|
|
543
546
|
if (!first) return undefined
|
|
544
547
|
if (globMatch(first, allowRootPatterns)) return undefined
|
|
545
548
|
return (
|
|
546
|
-
`「${first}」不在本次会话已批准的长期落点里。若这份内容需要长期保存:先用 ask_user_question
|
|
549
|
+
`「${first}」不在本次会话已批准的长期落点里。若这份内容需要长期保存:先用 ask_user_question 征求用户意见(固定问法:A「不长期保存」/ B「工作区根目录保存」,其它位置让用户写在输入框),` +
|
|
547
550
|
`用户同意后调用 longterm_approve 登记用户指定的目录再写;用户不同意或属于临时产物 → 用 task_tmpdir 写到 ` +
|
|
548
551
|
`${rootDirName}/<会话标题>/。`
|
|
549
552
|
)
|
|
@@ -691,13 +694,13 @@ export function longtermCommandGuardReason(command, workspaceRoot, options = {})
|
|
|
691
694
|
const first = firstSegmentUnder(base, abs)
|
|
692
695
|
if (samePath(dirname(abs), base)) {
|
|
693
696
|
return (
|
|
694
|
-
`命令会新建工作区根目录条目「${basename(abs)}」(${abs})。若需要长期保存:先用 ask_user_question
|
|
697
|
+
`命令会新建工作区根目录条目「${basename(abs)}」(${abs})。若需要长期保存:先用 ask_user_question 征求用户意见(固定问法:A「不长期保存」/ B「工作区根目录保存」,其它位置让用户写在输入框),` +
|
|
695
698
|
`同意后 longterm_approve 登记目录再执行;临时产物请写到 ${rootDirName}/<会话标题>/(先 task_tmpdir 取路径)。`
|
|
696
699
|
)
|
|
697
700
|
}
|
|
698
701
|
return (
|
|
699
702
|
`命令会新建工作区里的「${first || basename(abs)}」(${abs}),它不在本次会话已批准的长期落点里。` +
|
|
700
|
-
`若需要长期保存:先用 ask_user_question
|
|
703
|
+
`若需要长期保存:先用 ask_user_question 征求用户意见(固定问法:A「不长期保存」/ B「工作区根目录保存」,其它位置让用户写在输入框),同意后 longterm_approve 登记目录再执行;` +
|
|
701
704
|
`临时产物请写到 ${rootDirName}/<会话标题>/(先 task_tmpdir 取路径)。`
|
|
702
705
|
)
|
|
703
706
|
}
|
|
@@ -894,7 +897,7 @@ export function outsideWriteDenialReason(abs, options = {}) {
|
|
|
894
897
|
const { rootDirName = DEFAULT_ROOT, action = '写入' } = options
|
|
895
898
|
return (
|
|
896
899
|
`「${basename(abs)}」在工作区之外(${abs}),属于长期保存位置:${action}前必须先征求用户意见——` +
|
|
897
|
-
`用 ask_user_question
|
|
900
|
+
`用 ask_user_question 问用户(固定问法:A「不长期保存」/ B「工作区根目录保存」,其它位置让用户写在输入框);用户同意后用 longterm_approve 登记该目录再${action};` +
|
|
898
901
|
`用户不同意或属于临时产物 → 用 task_tmpdir 写到 ${rootDirName}/<会话标题>/。`
|
|
899
902
|
)
|
|
900
903
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leiyi-works/dsh-session-tmpdir",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Per-session task temp folder with a long-term write guard. v0.9 (方案3): creating a new file outside _tmp requires the user's approval (per file by default, per directory with mode=dir), overwriting an existing file is allowed without asking, every write channel is guarded (write/edit, shell including ffmpeg/pandoc/Export-*/IO APIs, publish copies, code runtimes, unknown tools), and the persisted whitelist is shown in a left-sidebar panel「临时目录」 where entries can be removed. Every session also gets _tmp/<session title>/ in its working directory, cleaned 7 days after the session is deleted; the same tick reclaims the attachment store.",
|
|
6
6
|
"exports": {
|