@leiyi-works/dsh-session-tmpdir 0.10.14 → 0.10.16

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.
Files changed (4) hide show
  1. package/README.md +12 -1
  2. package/client.js +0 -1
  3. package/index.js +10 -10
  4. 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` 给用户**固定问法**的选择题(标题「保存位置」、问题「这份要长期保存吗?」,只给 **A 不长期保存** / **B 长期保存** 两个选项;A 的 description 必须用 `task_tmpdir` 返回的真实绝对路径(含真实会话标题,如「保存到临时目录 D:\DSH工作区\_tmp\<实际标题>,随会话删除后 7 天清理」);B 的 description 用本会话工作目录的真实绝对路径(如「保存到 D:\DSH工作区」);两处都不出现占位符和反引号;v0.10.7 起禁止自创/替换/增删选项、禁止把路径写进标签;选 B 时模型自行起目录名、不再跟用户确认;弹窗前先在对话里说明这份是什么文件/内容;其他位置由用户直接在输入框里写路径);
72
+ 2. 模型调用 `ask_user_question` 给用户**固定问法**的选择题(标题「保存位置」、问题「这份要长期保存吗?」,只给 **A 长期保存** / **B 不长期保存** 两个选项;A 的 description 用本会话工作目录的真实绝对路径(如「保存到 D:\DSH工作区」);B 的 description 必须用 `task_tmpdir` 返回的真实绝对路径(含真实会话标题,如「保存到临时目录 D:\DSH工作区\_tmp\<实际标题>,随会话删除后 7 天清理」);两处都不出现占位符和反引号;v0.10.7 起禁止自创/替换/增删选项、禁止把路径写进标签;选 A 时模型自行起目录名、不再跟用户确认;弹窗前先在对话里说明这份是什么文件/内容;其他位置由用户直接在输入框里写路径);
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
 
@@ -320,3 +320,14 @@ v0.10.3 变更(2026-11-16):
320
320
  - 注入新增要求:弹窗前先在对话消息里用一句话说明这份是什么文件/内容(弹窗里仍不写文件名,保持固定格式)。
321
321
  - 客户端样式追加:`[data-question-key] [class*="_description"]{font-size:12px;line-height:18px}`,让灰色的选项小字比正文(14px)明显小一档。
322
322
  - 文案与样式改动,guard 判定、审批、清理逻辑未改。
323
+
324
+ ## v0.10.15 变更(2026-11-19):标题不再加粗(按用户要求定稿)
325
+
326
+ - 客户端样式去掉 `h2[id^="question-"]` 的 `font-weight:600`,问题标题恢复常规字重(500);只保留选项正文加粗(600)与灰色小字 12px。
327
+ - 文案与 guard 逻辑未改。
328
+
329
+ ## v0.10.16 变更(2026-11-19):选项 1/2 对调(长期保存在前)
330
+
331
+ - 按用户要求把问询卡片里的两个选项顺序对调:第 1 项改为「长期保存」(description 仍是本会话工作目录的真实绝对路径),第 2 项改为「不长期保存」(description 仍是 `task_tmpdir` 返回的临时目录真实绝对路径 + 随会话删除后 N 天清理)。
332
+ - 选项标签与说明文案本身不动,只调换先后;`compact` 注入的固定问法、`full` 注入的 A/B 两项及其说明、guard 的 5 处拦截提示全部按新顺序改写。
333
+ - 只改提示文案顺序;guard 判定、审批、清理逻辑未改。
package/client.js CHANGED
@@ -275,7 +275,6 @@ window.__ModuleLoader__.load({
275
275
  const style = document.createElement('style')
276
276
  style.id = STYLE_ID
277
277
  style.textContent = [
278
- '[data-question-key] h2[id^="question-"]{font-weight:600 !important}',
279
278
  '[data-question-key] [class*="_optionLabel"]{font-weight:600 !important}',
280
279
  '[data-question-key] [class*="_description"]{font-size:12px !important;line-height:18px !important}',
281
280
  ].join('')
package/index.js CHANGED
@@ -317,7 +317,7 @@ export function buildPromptText(cfg) {
317
317
  '',
318
318
  `- 临时产物一律写到 <会话工作目录>/${rootDirName}/<会话标题>/,不要放在工作区根目录;先调用 \`task_tmpdir\` 拿准确路径(会话改名会跟着改,别写死)。`,
319
319
  `- 长期文件(可复用脚本/记录/交付成品)写到 \`${rootDirName}/\` 以外前必须先问用户,且只能用下面的固定问法;用户同意后 \`longterm_approve\` 登记再写;${allowOverwrite ? '覆盖已存在的文件不用问;' : '覆盖已存在文件也要问;'}临时产物不要问用户。`,
320
- `- 固定问法(禁止自创/替换/增删选项,禁止把位置写进选项标签):标题「保存位置」+ 问题「这份要长期保存吗?」+ 选项 A「不长期保存」+ 选项 B「长期保存」。A 的 description 必须先调用 \`task_tmpdir\` 拿本会话临时目录的真实绝对路径(含真实会话标题),写成「保存到临时目录 <该绝对路径>,随会话删除后 ${orphanCleanupDays} 天清理」,不要出现 <会话标题> 占位符、不要用反引号;B 的 description 写「保存到 <本会话工作目录的真实绝对路径>」(路径取运行时上下文里的工作目录,不要留占位符、不要用反引号)。其它位置由用户在输入框自己写,不另列成选项。`,
320
+ `- 固定问法(禁止自创/替换/增删选项,禁止把位置写进选项标签):标题「保存位置」+ 问题「这份要长期保存吗?」+ 选项 A「长期保存」+ 选项 B「不长期保存」。A 的 description 写「保存到 <本会话工作目录的真实绝对路径>」(路径取运行时上下文里的工作目录,不要留占位符、不要用反引号);B 的 description 必须先调用 \`task_tmpdir\` 拿本会话临时目录的真实绝对路径(含真实会话标题),写成「保存到临时目录 <该绝对路径>,随会话删除后 ${orphanCleanupDays} 天清理」,不要出现 <会话标题> 占位符、不要用反引号。其它位置由用户在输入框自己写,不另列成选项。`,
321
321
  `- 弹窗前先在对话消息里说明这份是什么文件/内容(一句话即可,弹窗里不写文件名)。`,
322
322
  `- 未登记就写到 \`${rootDirName}/\` 以外会被 guard 直接拒绝(write/edit、shell、代码执行、publish 等所有写通道);被拒就改用 task_tmpdir 的路径,不要换写法绕过。白名单见左侧「临时目录」面板。`,
323
323
  ].join('\n')
@@ -338,11 +338,11 @@ export function buildPromptText(cfg) {
338
338
  'Before asking, state in the conversation message what file/content this is (one short sentence; the popup itself must not name the file).',
339
339
  '- header: 保存位置',
340
340
  '- question: 这份要长期保存吗?',
341
- '- A. 不长期保存',
342
- '- B. 长期保存',
343
- `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: write the REAL absolute path of this session's working directory: 保存到 <that absolute path> — resolve it from the runtime context (Current working directory), no placeholder, no backticks. 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.`,
341
+ '- A. 长期保存',
342
+ '- B. 不长期保存',
343
+ `Use exactly these two labels; put the explanation in each option's \`description\` instead. A: write the REAL absolute path of this session's working directory: 保存到 <that absolute path> — resolve it from the runtime context (Current working directory), no placeholder, no backticks. B: 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. 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.`,
344
344
  'Do not create anything until the user answers.',
345
- 'Picking B: pick a clear file path under the workspace root, call `longterm_approve` with it (mode=file by default), then write it.',
345
+ 'Picking A: pick a clear file path under the workspace root, call `longterm_approve` with it (mode=file by default), then write it.',
346
346
  '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.',
347
347
  'After the user agrees, call `longterm_approve` with that file path, then write it; add mode=dir only when the user explicitly wants the whole directory writable.',
348
348
  `If the user declines, says temporary, or the content is scratch: call \`task_tmpdir\` and write under \`${rootDirName}/<会话标题>/\`. Never invent a workspace-root file or folder instead.`,
@@ -539,7 +539,7 @@ export function longtermGuardReason(targetPath, cwd, options = {}) {
539
539
  if (allowRootFiles.some((entry) => entry.toLowerCase() === name.toLowerCase())) return undefined
540
540
  if (globMatch(name, allowRootPatterns)) return undefined
541
541
  return (
542
- `工作区根目录不能新建/修改条目(${name})。若这份内容需要长期保存:先用 ask_user_question 征求用户意见(固定问法:A「不长期保存」/ B「长期保存」,其它位置让用户写在输入框),` +
542
+ `工作区根目录不能新建/修改条目(${name})。若这份内容需要长期保存:先用 ask_user_question 征求用户意见(固定问法:A「长期保存」/ B「不长期保存」,其它位置让用户写在输入框),` +
543
543
  `用户同意后用 longterm_approve 登记用户指定的目录再写;用户不同意或属于临时产物 → 用 task_tmpdir 写到 ` +
544
544
  `${rootDirName}/<会话标题>/。`
545
545
  )
@@ -548,7 +548,7 @@ export function longtermGuardReason(targetPath, cwd, options = {}) {
548
548
  if (!first) return undefined
549
549
  if (globMatch(first, allowRootPatterns)) return undefined
550
550
  return (
551
- `「${first}」不在本次会话已批准的长期落点里。若这份内容需要长期保存:先用 ask_user_question 征求用户意见(固定问法:A「不长期保存」/ B「长期保存」,其它位置让用户写在输入框),` +
551
+ `「${first}」不在本次会话已批准的长期落点里。若这份内容需要长期保存:先用 ask_user_question 征求用户意见(固定问法:A「长期保存」/ B「不长期保存」,其它位置让用户写在输入框),` +
552
552
  `用户同意后调用 longterm_approve 登记用户指定的目录再写;用户不同意或属于临时产物 → 用 task_tmpdir 写到 ` +
553
553
  `${rootDirName}/<会话标题>/。`
554
554
  )
@@ -696,13 +696,13 @@ export function longtermCommandGuardReason(command, workspaceRoot, options = {})
696
696
  const first = firstSegmentUnder(base, abs)
697
697
  if (samePath(dirname(abs), base)) {
698
698
  return (
699
- `命令会新建工作区根目录条目「${basename(abs)}」(${abs})。若需要长期保存:先用 ask_user_question 征求用户意见(固定问法:A「不长期保存」/ B「长期保存」,其它位置让用户写在输入框),` +
699
+ `命令会新建工作区根目录条目「${basename(abs)}」(${abs})。若需要长期保存:先用 ask_user_question 征求用户意见(固定问法:A「长期保存」/ B「不长期保存」,其它位置让用户写在输入框),` +
700
700
  `同意后 longterm_approve 登记目录再执行;临时产物请写到 ${rootDirName}/<会话标题>/(先 task_tmpdir 取路径)。`
701
701
  )
702
702
  }
703
703
  return (
704
704
  `命令会新建工作区里的「${first || basename(abs)}」(${abs}),它不在本次会话已批准的长期落点里。` +
705
- `若需要长期保存:先用 ask_user_question 征求用户意见(固定问法:A「不长期保存」/ B「长期保存」,其它位置让用户写在输入框),同意后 longterm_approve 登记目录再执行;` +
705
+ `若需要长期保存:先用 ask_user_question 征求用户意见(固定问法:A「长期保存」/ B「不长期保存」,其它位置让用户写在输入框),同意后 longterm_approve 登记目录再执行;` +
706
706
  `临时产物请写到 ${rootDirName}/<会话标题>/(先 task_tmpdir 取路径)。`
707
707
  )
708
708
  }
@@ -899,7 +899,7 @@ export function outsideWriteDenialReason(abs, options = {}) {
899
899
  const { rootDirName = DEFAULT_ROOT, action = '写入' } = options
900
900
  return (
901
901
  `「${basename(abs)}」在工作区之外(${abs}),属于长期保存位置:${action}前必须先征求用户意见——` +
902
- `用 ask_user_question 问用户(固定问法:A「不长期保存」/ B「长期保存」,其它位置让用户写在输入框);用户同意后用 longterm_approve 登记该目录再${action};` +
902
+ `用 ask_user_question 问用户(固定问法:A「长期保存」/ B「不长期保存」,其它位置让用户写在输入框);用户同意后用 longterm_approve 登记该目录再${action};` +
903
903
  `用户不同意或属于临时产物 → 用 task_tmpdir 写到 ${rootDirName}/<会话标题>/。`
904
904
  )
905
905
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leiyi-works/dsh-session-tmpdir",
3
- "version": "0.10.14",
3
+ "version": "0.10.16",
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": {