@jayyuen66/dsh-dir-prep-organize 0.1.4 → 0.1.6

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 (81) hide show
  1. package/CHANGELOG.md +117 -0
  2. package/LICENSE +1 -1
  3. package/README.md +209 -104
  4. package/README.zh-CN.md +209 -102
  5. package/agents/academic/academic-statistician.md +143 -0
  6. package/agents/design/design-inclusive-visuals-specialist.md +4 -3
  7. package/agents/design/design-ui-designer.md +6 -3
  8. package/agents/design/design-ux-architect.md +20 -7
  9. package/agents/design/design-whimsy-injector.md +23 -1
  10. package/agents/engineering/engineering-autonomous-optimization-architect.md +31 -22
  11. package/agents/engineering/engineering-backend-architect.md +43 -54
  12. package/agents/engineering/engineering-data-engineer.md +21 -6
  13. package/agents/engineering/engineering-database-optimizer.md +22 -10
  14. package/agents/engineering/engineering-devops-automator.md +12 -3
  15. package/agents/engineering/engineering-email-intelligence-engineer.md +41 -4
  16. package/agents/engineering/engineering-embedded-firmware-engineer.md +27 -5
  17. package/agents/engineering/engineering-feishu-integration-developer.md +10 -2
  18. package/agents/engineering/engineering-frontend-developer.md +24 -18
  19. package/agents/engineering/engineering-git-workflow-master.md +16 -4
  20. package/agents/engineering/engineering-incident-response-commander.md +3 -3
  21. package/agents/engineering/engineering-prompt-engineer.md +7 -2
  22. package/agents/engineering/engineering-rapid-prototyper.md +7 -3
  23. package/agents/engineering/engineering-security-engineer.md +2 -0
  24. package/agents/engineering/engineering-solidity-smart-contract-engineer.md +1 -1
  25. package/agents/engineering/engineering-technical-writer.md +4 -4
  26. package/agents/engineering/engineering-threat-detection-engineer.md +2 -0
  27. package/agents/engineering/engineering-voice-ai-integration-engineer.md +39 -16
  28. package/agents/engineering/engineering-wechat-mini-program-developer.md +7 -2
  29. package/agents/game-development/blender/blender-addon-engineer.md +12 -3
  30. package/agents/game-development/economy-designer.md +155 -0
  31. package/agents/game-development/godot/godot-gameplay-scripter.md +4 -0
  32. package/agents/game-development/godot/godot-multiplayer-engineer.md +6 -2
  33. package/agents/game-development/godot/godot-shader-developer.md +4 -3
  34. package/agents/game-development/roblox-studio/roblox-experience-designer.md +7 -6
  35. package/agents/game-development/roblox-studio/roblox-systems-scripter.md +7 -0
  36. package/agents/game-development/technical-artist.md +4 -0
  37. package/agents/game-development/unity/unity-multiplayer-engineer.md +67 -0
  38. package/agents/game-development/unreal-engine/unreal-multiplayer-architect.md +82 -31
  39. package/agents/game-development/unreal-engine/unreal-systems-engineer.md +13 -1
  40. package/agents/marketing/marketing-agentic-search-optimizer.md +50 -87
  41. package/agents/marketing/marketing-carousel-growth-engine.md +49 -35
  42. package/agents/marketing/marketing-private-domain-operator.md +2 -2
  43. package/agents/marketing/marketing-seo-specialist.md +22 -0
  44. package/agents/product/product-behavioral-nudge-engine.md +3 -0
  45. package/agents/project-management/project-management-jira-workflow-steward.md +5 -2
  46. package/agents/security/security-appsec-engineer.md +75 -43
  47. package/agents/security/security-threat-detection-engineer.md +6 -0
  48. package/agents/security/security-threat-intelligence-analyst.md +32 -15
  49. package/agents/specialized/accounts-payable-agent.md +39 -45
  50. package/agents/specialized/grant-writer.md +2 -2
  51. package/agents/specialized/healthcare-aging-parent-care-companion.md +396 -0
  52. package/agents/specialized/identity-graph-operator.md +24 -3
  53. package/agents/specialized/lsp-index-engineer.md +17 -15
  54. package/agents/specialized/recruitment-specialist.md +17 -11
  55. package/agents/specialized/specialized-developer-advocate.md +4 -4
  56. package/agents/specialized/specialized-fedramp-rmf-compliance.md +379 -0
  57. package/agents/specialized/specialized-focus-music-architect.md +176 -0
  58. package/agents/specialized/specialized-french-consulting-market.md +17 -15
  59. package/agents/specialized/specialized-model-qa.md +78 -34
  60. package/agents/specialized/specialized-salesforce-architect.md +17 -15
  61. package/agents/specialized/specialized-workflow-architect.md +2 -2
  62. package/agents/supply-chain/supply-chain-strategist.md +12 -3
  63. package/agents/support/support-analytics-reporter.md +48 -30
  64. package/agents/support/support-finance-tracker.md +36 -18
  65. package/agents/support/support-infrastructure-maintainer.md +2 -2
  66. package/agents/support/support-support-responder.md +43 -26
  67. package/agents/testing/testing-api-tester.md +37 -27
  68. package/agents/testing/testing-performance-benchmarker.md +82 -47
  69. package/agents/testing/testing-test-results-analyzer.md +37 -18
  70. package/agents/testing/testing-tool-evaluator.md +30 -10
  71. package/client.js +209 -141
  72. package/cordis.patch.yml +4 -23
  73. package/host.js +98 -68
  74. package/package.json +53 -44
  75. package/templates.data.mjs +9 -10
  76. package/types/host.d.ts +29 -21
  77. package/types/src/client-timeouts.d.ts +4 -4
  78. package/types/src/host-messages.d.ts +5 -3
  79. package/types/src/remote.d.ts +12 -3
  80. package/types/src/templates.d.ts +3 -3
  81. package/types/src/ui-messages.d.ts +22 -14
package/CHANGELOG.md ADDED
@@ -0,0 +1,117 @@
1
+ # Changelog
2
+
3
+ 格式遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循
4
+ [语义化版本](https://semver.org/lang/zh-CN/)。最新版本在最上。
5
+
6
+ ## 0.1.6
7
+
8
+ 这一版收口客户端交互与错误文案,并把构建、CI 与伞工作区基线统一;模板数据与 85 条内置精选不变。
9
+
10
+ ### Changed
11
+
12
+ - **宿主线抬到 `0.2.1-rc.3`**:`engines.dsh`、peer/dev 依赖、`pnpm-workspace.yaml` 的 overrides 与 README 徽标/正文同值;shared 下限随根真源投影。
13
+ - **构建编排统一进 shared 的 `lib/build-*`**:host/client/types 构建脚本只剩薄配置层,产物仍落 `dist/`。
14
+ - **润色链路的错误文案跟随界面语言**:客户端自己产生的错误(目录上下文失败、读取模型失败、输入为空、回执不可解析)改走本地化消息键,宿主回执里的原文不翻译、作为 `{message}` 原样带出。
15
+ - **超时值的非法输入回落到默认值**:`NaN`、`0`、负数与小数不再被折算成 1 ms 或负数——那会让「配错」看起来像「配了一个很小的合法值」,实际是立刻超时。
16
+ - **编辑中的草稿与写入操作互斥**:模板行、导入面板与允许根面板在保存期间禁用;保存成功后只清本次真正写下的键。
17
+ - **Remote 读面按运行期形状校验**:`ok: true` 但缺 `value` 的应答不再被当成「成功但空」;`$mount` 失败不缓存,下一次读会重试。
18
+ - **样式补兜底与可访问性**:所有 `var()` 带回落值,错误态 hover 不被基础样式覆盖,补 `:focus-visible` 与 `prefers-reduced-motion`。
19
+
20
+ ### Fixed
21
+
22
+ - **同一轮事件里的第二次点击会再发一次 LLM 请求**:`loading` 要等一次重渲染才生效,两道读状态的闸门都拦不住;改为在 `await` 之前置同步在途标记。
23
+ - **新增模板行的正文会把占位提示落盘**:占位改由 textarea 的 placeholder 承担,新行正文从空串开始。
24
+ - **角色文件的代码围栏没有结束标记时只导入半篇正文**:现在直接报错并点明起始行,不再静默截断。
25
+ - **恢复默认的二次确认文案写死 4 秒**:改为按实际确认窗口插值。
26
+
27
+ ### Added
28
+
29
+ - 润色链路的本地化错误消息(中英各一套)。
30
+ - 集成/属性/端到端测试与覆盖率门禁;`actionlint` 配置与更严的 CI 判据。
31
+
32
+ ## 0.1.5
33
+
34
+ ### Changed
35
+
36
+ - **命名与文案统一**:「整理」改为「润色」,「提示词模板」改为「模板库」,「角色视角」改为「角色风格」;中英文案、`package.json` 描述与关键字、`cordis.patch.yml` 与两份 README 同步。
37
+ - **prompt 信任序**:目录摘要、最近若干轮与角色正文改由 `buildOrganizeUser` 放进 user 消息的 `<data>` 围栏,system 只拿会话 cwd;数据行里的围栏标记先替换成 `[fence-open]` / `[fence-close]`,避免草稿自己关掉围栏。
38
+ - **客户端竞态收口**:内置快照读面加世代号,`reset` 之后晚到的应答不再写回 store;「恢复默认」与「保存」共用 busy 门禁;▾ 菜单项与主按钮同用 `loading || !canWrite`;超时下界夹到 1 ms。
39
+ - **Remote 读面**:`unwrap` 按运行期形状校验应答;`mount` 的 promise 失败后清缓存。
40
+ - **跨平台构建**:`.gitattributes` 钉 `eol=lf`;生成器用 `process.execPath` 跑 oxfmt 包内入口;构建产物改临时文件 + `rename`;核对产物里的 `BUNDLE_PKG` 与包名同源;补 `dist-size` 预算与 `.prettierignore` 第二份生成物。
41
+ - **CI 与发布**:新增三平台 × node 22/24 的 `ci.yml`、`codeql.yml`、`scorecard.yml` 与 `dependabot.yml`;`publish.yml` 改 OIDC 优先、静态 token 兜底,挂 `npm-publish` 环境、加 concurrency 与超时,action 钉 commit SHA。
42
+
43
+ ### Fixed
44
+
45
+ - 内置快照 `reset` 之后可能被恢复前那次请求的旧快照覆盖。
46
+ - 「恢复默认」与「保存」并发时最后写入者赢,没有共同门禁。
47
+ - 写不回草稿时,▾ 菜单要烧完整次 LLM 往返才在写回那步报错。
48
+ - `Math.trunc` 把 `(0,1)` 的配置值取整成 0,加完余量后可能变成 0 或负数,被当成「当场超时」。
49
+
50
+ ## 0.1.4
51
+
52
+ ### Changed
53
+
54
+ - **`DIR_PREP_NAMESPACE` 导出并成为错误文案与宿主注册的唯一来源**:写死两处会让「网关挂的是 A、报错说的是 B」这种漂移没有任何运行期信号。
55
+ - **双语 README 补 shared 版本下限**:profile 里更低的 overrides 会装到缺具名导出的副本,表现为「装得上、永远不生效」,而单仓 CI 看不到。
56
+
57
+ ## 0.1.3
58
+
59
+ ### Fixed
60
+
61
+ - **导入同 slug 碰撞时 id 改写进入死循环**(会同步阻塞宿主):改为循环内自增后缀,并加回归用例。
62
+ - **允许根包含判据只按 `/` 拆段**:win32 上合法子路径一律判越界、`..\` 漏检;改用 `path.relative` + 双分隔符拆段。
63
+ - **client 读面的模块级全局不随卸载清理**:收进 `ctx.effect` disposer,按身份比较防误清。
64
+
65
+ ### Changed
66
+
67
+ - **Typert 迁移收尾**:五条 `/_dsh/dir-prep/*` 端点改为官方 `dirPrepOrganize` Remote;HTTP handler、信任/CSRF 闸门、`guardBody` 与只为 body 上限存在的 `importBodyMaxBytes` 删除,webserver 集成测试一并删除。
68
+ - 删除 `peerDependencies.react`:宿主运行时是 18.x,devDependency 保留。
69
+ - 清理迁移遗留的 HTTP 契约文本、`invalidJsonBody` 死键、指错行的证据引用与失真计数。
70
+
71
+ ## 0.1.2
72
+
73
+ ### Fixed
74
+
75
+ - **目录导入的软链逃逸(P0,真磁盘复现)**:`escapesAllRoots` 原先只挂在单文件分支上,目录分支整批漏掉后端复判;cwd 里一条指向根外的软链就能把根外目录里的 `.md` 连同正文整批导入。两条分支现在统一在 `resolve` 之后先过这道门。
76
+ - **单文件导入没有字节上限**:`cwd/roles.md` 直接调 `fs.readText`,不看 `maxSnippetBytes`;现在按官方 `stat` 判大小,未知或超限即跳过并计入 `skipped.tooLarge`。
77
+ - **目录枚举逐个降级**:`fs.listDir` 在 `mapBounded` worker 里没有 try/catch,一个 `chmod 000` 的子目录就让整次导入归零;现在逐个降级并计入 `skipped.unreadable`。
78
+ - **导入回填按最新草稿合并**:`onImported` 闭包用点击那一刻的草稿,等待一整次网络往返期间用户改的行会被整份旧草稿覆盖;改为函数式更新。
79
+ - **fetch 超时夹到 2^31-1**:`organizeTimeoutMs + 5000` 越界时 V8 会静默夹成 1 ms,把「调大超时」反转成「立刻失败」;取值与夹位单源挪到 `src/client-timeouts.ts`。
80
+ - **「恢复默认」纳入 busy 门禁**;「整理」按钮在 `setDraft` 不可用时禁用。
81
+
82
+ ### Changed
83
+
84
+ - `@jayyuen66/dsh-plugin-shared` 从 `^0.1.4` 升到 `^0.1.5-rc`,吃进三处信任闸门修复;验证不止比版本号:`npm pack` 拉下发布产物逐条比对行为。
85
+ - 新增集成层(真磁盘 + 真 FileSystem 抽象类):上面三条 host 缺陷都是手搓桩测不出来的。
86
+
87
+ ## 0.1.2-rc
88
+
89
+ ### Changed
90
+
91
+ - **宿主包整体精确钉到 `0.2.1-alpha.2`**;`@jayyuen66/dsh-plugin-shared` 升到 `^0.1.4`,工具链随 catalog 更新。
92
+ - **`servingNonLoopback` 改由 shared 的 `isNonLoopbackBindHost` 取**:宿主把 `Config.host` 收成任意本机接口 IP 字面量、通配地址在载入即拒,旧的 `=== "0.0.0.0"` 恒为 false,局域网请求整片吃 403 而本地门禁全绿。
93
+ - **peerDependencies 补齐声明产物点名却未认领的宿主包**,写成 optional;值导入的 `dsh-brand` 与 `schemastery` 保持必选。
94
+ - 升级带来的声明行号位移逐条对表修正。
95
+
96
+ ## 0.1.1
97
+
98
+ ### Added
99
+
100
+ - `THIRD_PARTY_NOTICES.md`:内置角色库来自上游 agency-agents-zh(MIT),照录版权与许可原文;`LICENSE` 末尾加指向。
101
+ - `types/` 声明产物随包发布;源码里的显式 `.ts` 后缀在声明阶段改写成 `.js`。
102
+ - `engines.node >=22.12`、bugs/homepage/sideEffects;发布流水线补 `--provenance` 与发布后可取性校验。
103
+
104
+ ### Changed
105
+
106
+ - 内置精选模板表移出 `host.js`,独立为 `templates.data.mjs`,首次请求才 import;`host.js` 从数百 KB 降到几十 KB。
107
+ - 删除 `agents/integrations/`(面向外部工具的转换件,对 dsh 无作用);已验证精选模板逐字节不变。
108
+ - 删除与 `prepack` 重复的 `prepare`;CI 三个 action 改钉 commit SHA。
109
+
110
+ ### Fixed
111
+
112
+ - `check` 补上 `build:types`:此前校验的声明产物压根没被构建过。
113
+ - 发布清单门禁覆盖入口面、第三方声明、运行期产物、声明覆盖全部导出,以及不泄漏本机或包管理器内部路径。
114
+
115
+ ## 0.1.0
116
+
117
+ 首个发布版本。此前 1.0.0 与 0.6.x 已被 npm 永久记录,统一以 0.1.0 为首个发布号,依赖范围同步改为 `^0.1.0`;发布凭据改以 `NODE_AUTH_TOKEN` 注入 publish 那一步,token 形态校验保留且只读不写盘;lockfile 随依赖范围重解。
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 JayYuen
3
+ Copyright (c) 2026 JayYuen666
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,113 +1,218 @@
1
- # @jayyuen66/dsh-dir-prep-organize
1
+ <p align="center">
2
+ <img src="https://cdn.jsdelivr.net/gh/JayYuen666/dsh-dir-prep-organize@main/icon.svg" width="96" height="96" alt="dsh-dir-prep-organize logo" />
3
+ </p>
4
+
5
+ <h1 align="center">dsh-dir-prep-organize</h1>
6
+
7
+ <p align="center"><em>Two buttons beside the dsh chat input: rewrite the draft with the current directory in view, and drop a role template into it.</em></p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/@jayyuen66/dsh-dir-prep-organize"><img src="https://img.shields.io/npm/v/@jayyuen66/dsh-dir-prep-organize?style=flat-square&logo=npm&logoColor=white" alt="npm version" /></a>
11
+ <a href="https://www.npmjs.com/package/@jayyuen66/dsh-dir-prep-organize"><img src="https://img.shields.io/npm/dm/@jayyuen66/dsh-dir-prep-organize?style=flat-square" alt="npm downloads" /></a>
12
+ <a href="https://github.com/JayYuen666/dsh-dir-prep-organize/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/JayYuen666/dsh-dir-prep-organize/ci.yml?branch=main&style=flat-square&label=ci" alt="ci" /></a>
13
+ <img src="https://img.shields.io/badge/license-MIT-4c1?style=flat-square" alt="MIT" />
14
+ <img src="https://img.shields.io/badge/node-%3E%3D22.12-4c1?style=flat-square&logo=nodedotjs&logoColor=white" alt="node" />
15
+ <img src="https://img.shields.io/badge/dsh-%5E0.2.1--rc.3-658EFF?style=flat-square" alt="dsh" />
16
+ <a href="https://github.com/deepseek-ai/deepseek-harness"><img src="https://img.shields.io/badge/powered_by_dsh-4D6BFE?style=flat-square&logo=deepseek&logoColor=white" alt="powered by dsh" /></a>
17
+ </p>
18
+
19
+ <p align="center">
20
+ <img src="https://skillicons.dev/icons?i=typescript,react,nodejs" alt="tech stack" />
21
+ </p>
22
+
23
+ <p align="center">
24
+ <a href="https://github.com/JayYuen666"><img src="https://img.shields.io/badge/GitHub-JayYuen666-181717?style=flat-square&logo=github&logoColor=white" alt="GitHub" /></a>
25
+ <a href="mailto:cqwkkj@gmail.com"><img src="https://img.shields.io/badge/Email-cqwkkj@gmail.com-EA4335?style=flat-square&logo=gmail&logoColor=white" alt="Email" /></a>
26
+ <a href="https://twitter.com/JayYuen666"><img src="https://img.shields.io/badge/Twitter-X%2FJayYuen666-000000?style=flat-square&logo=x&logoColor=white" alt="Twitter/X" /></a>
27
+ <a href="./README.zh-CN.md"><img src="https://img.shields.io/badge/lang-简体中文-658EFF?style=flat-square" alt="简体中文" /></a>
28
+ </p>
29
+
30
+ **A [dsh](https://github.com/deepseek-ai/deepseek-harness) plugin: a split "Polish" button that hands your draft, the top level of the session directory and the recent real turns to the current default model for a rewrite, plus a "Template" dropdown of role templates. Zero model tools, zero HTTP routes of its own.**
31
+
32
+ ## <img src="https://api.iconify.design/lucide/file-text.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Contents
33
+
34
+ - [What it does](#what-it-does)
35
+ - [Install](#install)
36
+ - [Verify it is live](#verify-it-is-live)
37
+ - [What it does not provide](#what-it-does-not-provide)
38
+ - [Enabling it in dsh](#enabling-it-in-dsh)
39
+ - [The polish call](#the-polish-call)
40
+ - [Templates](#templates)
41
+ - [Settings](#settings)
42
+ - [Public interface](#public-interface)
43
+ - [Data and privacy](#data-and-privacy)
44
+ - [Known boundaries](#known-boundaries)
45
+ - [FAQ](#faq)
46
+ - [Development](#development)
47
+ - [License](#license)
48
+
49
+ ## <img src="https://api.iconify.design/lucide/shield.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> What it does
50
+
51
+ - Adds **two controls** to the right of the web chat input: a split "Polish" button (main key + caret) and a "Template" dropdown.
52
+ - The main key polishes directly; the caret key offers "polish in a role's style".
53
+ - The dropdown groups entries by their `group` field; an entry with an empty group lands in "General".
54
+ - **Polish** sends the draft, the top level of the session cwd (file names, sizes, and the full text of key text files), and the session's **real** user/assistant turns to the current default model, then replaces the draft with the rewrite.
55
+ - On failure the draft is **never** touched: the button shows an error state for 4 seconds with the reason in its tooltip.
56
+ - **Templates** insert text into the draft: a whole fill when the draft is empty, an append after one blank line otherwise.
57
+ - The built-in set is **85 curated role templates**, generated by `scripts/gen-defaults.mjs` from this package's `agents/` role library - a vendored collection of several hundred role `.md` files across more than twenty department directories. The curated 85 is the number that matters to a user; the library size is not pinned here because it changes whenever the upstream project is refreshed.
58
+ - That table **stays host-side**: the client bundle no longer inlines it. The generated file is ~640 KB and used to push `client.js` to ~711 KB.
59
+ - The browser calls the Remote `defaults` method **once, lazily** (first menu open or first settings-card visit) and reuses it in-process. Nothing is fetched at all when the user already has their own templates.
60
+ - While it has not arrived the menu shows a loading row - not the "no templates" hint. A failure surfaces the host's own reason plus a Retry button.
61
+ - The **"Template library"** card covers per-entry add/edit/delete, a two-step restore of the defaults, one-click import of the whole built-in library, import of a local `.md` or directory **by path**, and registration of extra allowed import directories. That card is **one list feeding two places**: the input-box "Template" dropdown and the "Polish" ▾ role menu.
62
+ - Templates and allowed directories are read and written through the host settings with **zero LLM calls**, and **no model tool is registered**.
63
+
64
+ ## <img src="https://api.iconify.design/lucide/package.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Install
2
65
 
3
- [English](./README.md) · [简体中文](./README.zh-CN.md)
66
+ ```sh
67
+ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
68
+ ```
69
+
70
+ Remove with `dsh plugin --profile web remove @jayyuen66/dsh-dir-prep-organize`. The package is on the public npm registry, so installation needs no credentials and no scoped-registry line.
71
+
72
+ - **Requires Node.js `>= 22.12`.** This is an ESM-only package. Use the **named** exports (`import { apply } from "@jayyuen66/dsh-dir-prep-organize"`); there is **no default export**, so `import pkg from …` fails with `does not provide an export named 'default'`. That Node floor is what makes `require()` of an ESM entry work at all, which is why `engines.node` is declared.
73
+ - **Requires host `dsh` at the `0.2.1-rc.3` line.** The requirement the host actually reads is `engines.dsh` (`^0.2.1-rc.3`), and it **decides alone**: `evaluatePluginCompatibility` returns on the `engines.dsh` branch before it ever looks at `peerDependencies`. Measured against the real host code: `0.2.0-rc.2` is **refused**, `0.2.1-rc.3` and `0.2.2` pass, `0.3.0` is refused. A refused host needs the explicit risk grant `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <exact> --accept-risk`.
74
+ - **The `@deepseek-ai/dsh-*` pins stay at `0.2.1-rc.3`** - the version this package is built and tested against. The `engines.dsh` range is a claim about which *hosts* it runs on; the pin is a fact about which host version it was *compiled* against. Mixing the two is why the publish gate checks them separately.
75
+ - **No `@deepseek-ai/*` under `dependencies`, by contract** (`test/publish-manifest.test.ts` enforces it). Consumer profiles install with `nodeLinker: hoisted` and `autoInstallPeers: false`, so a host package under `dependencies` is materialized as a **real directory** next to the copy the running host already loaded. `@deepseek-ai/dsh-tools` keys its tool-runtime scheduler with a plain `Symbol` (not `Symbol.for`), so symbol identity is per module instance: the host reads the scheduler off the profile copy, gets `undefined`, and **every native tool call throws** - while this package's build, typecheck and coverage gates stay green right up to that moment.
76
+ - **The two host packages `host.js` imports as values are required peers**: `@deepseek-ai/schemastery` (the host's fork - only it resolves the `.volatile()` fields) and `@deepseek-ai/dsh-brand`. `build-host.mjs` externalizes `dependencies` **and** `peerDependencies`, so the bare specifiers stay in the artifact; a devDependencies-only entry would let the bundler inline the official function body. `test/build-host.test.ts` pins both "specifier present" and "function body absent".
77
+ - **Every host package the emitted declarations name is declared under `peerDependencies`**, and each one reached only there is *optional* (`@deepseek-ai/cordis`, `cosmokit`, and the `dsh-agent-default-model` / client-ui / `fs` / `llm` / `session` family). Declaring them is not ceremony: under pnpm's strict layout a bare specifier in `types/host.d.ts` that no manifest table names is unresolvable on the consumer's side, while this repository's own typecheck stays green. The test reads that roster off `types/**/*.d.ts` rather than off this paragraph, so the two cannot drift apart.
78
+ - **What ships**: `host.js`, `client.js`, `templates.data.mjs`, `types/`, `cordis.patch.yml`, `agents/` and `THIRD_PARTY_NOTICES.md`. `package.json`, `README*` and `LICENSE` are attached unconditionally by the registry client.
79
+ - **The built-in table ships as its own artifact and is loaded on first use**, not at plugin load. It used to be bundled into `host.js`, so every user paid for the templates in memory even without opening the dropdown.
80
+ - **`agents/` is not authored here**: it comes from [`agency-agents-zh`](https://github.com/jnMetaCode/agency-agents-zh) (MIT). The copyright and licence notice ship in `THIRD_PARTY_NOTICES.md`, because MIT requires it in every distributed copy. Do not hand-edit files under `agents/`.
81
+
82
+ ### <img src="https://api.iconify.design/lucide/arrow-down-to-line.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Shared version floor
83
+
84
+ If your profile pins `@jayyuen66/dsh-plugin-shared` with a pnpm `overrides` entry, that pin must be at least the version this package declares. A lower pin installs a copy without the names imported at runtime, and the host then reports `N entries did not activate` together with `does not provide an export named ...` at boot - the package installs fine and never loads, and no per-repository CI run can see it.
85
+
86
+ ## <img src="https://api.iconify.design/lucide/circle-check.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Verify it is live
4
87
 
5
- ## What it does
88
+ 1. **Two controls appear** to the right of the chat input. If they do not, the bundle layer is not mounted - check `dsh --profile web --dump-config` for the `dir-prep-organize` layer.
89
+ - `--dump-config` is the only accepted "it is in the layer stack" signal, and it is **not read-only** - it rewrites that profile's root assembly file. Read layer lines from stdout **and** check stderr separately: an unmatched patch target appears only on stderr, so the exit code alone proves nothing.
90
+ - A layer line may read `# == <layer>` or `# == <layer>, patched by <path>`; accept both forms.
91
+ 2. **The dropdown fills**: open "Template" and the built-in list arrives through the Remote `defaults` method. A loading row means the call is in flight; a failure shows the host's reason plus Retry.
92
+ 3. **Polish works**: press the main key. The draft is replaced on success; on failure it is untouched and the button turns into an error state whose tooltip carries the reason.
93
+ 4. **The settings card renders**: "Template library" appears on the settings page, edits stage locally and take effect after **Save**.
6
94
 
7
- - Adds two controls to the right of the dsh web chat input: a split "Organize" button and a "Template" dropdown.
8
- - The main Organize key organizes directly, the caret key offers "organize from a role's point of view"; the Template dropdown groups entries by `group`, and an empty group falls into "General".
9
- - "Organize" hands the draft plus the top level of the session cwd (file names, sizes, full text of key text files) plus the session's recent real turns to the current default model for a rewrite.
10
- - On success the draft is replaced; on failure it stays untouched and the button shows an error state for 4 seconds (reason in its title).
11
- - Picking a template inserts it into the draft: a whole fill when the draft is empty, an append after one blank line otherwise.
12
- - The default list is 85 curated role templates generated by scripts/gen-defaults.mjs from this package's agents/ role library (21 department directories, 293 role .md files).
13
- - That table **stays host-side only**: the client bundle no longer inlines it - the generated file is 640KB and used to push `client.js` to 711KB.
14
- - The browser calls the Remote `defaults` method once, lazily - on the first menu open or settings-card visit - and reuses it in-process afterwards.
15
- - While it has not arrived the menus show a loading row rather than the existing "no templates" hint, and a failure surfaces the host's own reason plus a Retry button. Nothing is fetched at all when the user already has their own templates.
16
- - The "Prompt templates" card on the settings page covers per-entry add/edit/delete, two-step restore of defaults, one-click import of the whole built-in library, import of a local .md or directory by path, and registration of import allowed directories.
17
- - Templates and allowed directories are read and written through the host settings with zero LLM calls, and no model tool is registered.
95
+ ## <img src="https://api.iconify.design/lucide/circle-slash.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> What it does not provide
18
96
 
19
- ## Install
97
+ Worth knowing before you look for them:
20
98
 
21
- The packages are published to the public npm registry (`registry.npmjs.org`), so installation needs no credentials:
99
+ - **It registers no model tools.** The host half only injects `settings`; it never touches the tool registry. There is no `organize_text` tool to call.
100
+ - **It opens no HTTP route of its own.** The data plane is the official Typert Remote namespace `dirPrepOrganize`, registered through an injected child fiber, reached through the host `/api` gateway. Authentication, Host/DNS-rebinding/Origin checks, the signed browser-session cookie and body limits are all the gateway's - this package keeps no CSRF token and no route table.
101
+ - **It adds no CLI subcommand.**
102
+ - **It reads no environment variable** and makes no outbound request of its own.
103
+ - What it *does* consume: the host `settings` service (hard-injected), `llm.stream`, `agentDefaultModel`, and the session/filesystem services. Without `settings` the card is disabled with a warning and the dropdown falls back to the built-in curated set.
104
+
105
+ ## <img src="https://api.iconify.design/lucide/plug.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Enabling it in dsh
106
+
107
+ - Installing contributes the bundle patch layer (`dsh.bundle.patch` → `./cordis.patch.yml`), which inserts `- id: dir-prep-organize` with `name` set to the package name.
108
+ - The **client half** registers two slots plus the settings card:
109
+ - `conversation.input.right` - the polish button (id `dir-prep-organize`, order 99) and the templates dropdown (id `dir-prep-organize-templates`, order 100).
110
+ - `plugins.bundle.config` - the settings card, keyed by the **bundle package name** `@jayyuen66/dsh-dir-prep-organize`. The host dispatches `entryKey: pkg.name` (source of truth: `dsh.profile.bundles` in the profile's `package.json`), so a bare entry id never matches and the card would render nowhere.
111
+ - The settings namespace and `configForms.get()` stay the **bare entry id** `dir-prep-organize` - deliberately not the same identifier as that slot key.
112
+ - The client half is `dsh.client.platform = web` with `immediately`.
113
+ - The card follows the official locale plugin's preference for its own labels and copy; the host half reads the preference per request, so switching language needs no restart.
114
+
115
+ ## <img src="https://api.iconify.design/lucide/sparkles.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> The polish call
116
+
117
+ | Aspect | Fact |
118
+ |---|---|
119
+ | Transport | Host `llm.stream`: one **request-only** user text message (no `id`, no `source`) plus a `system` rule block |
120
+ | Model | `agentDefaultModel.currentSelection()` - provider / model / reasoningEffort. Its absence reports "No model selection is available" |
121
+ | Role style | An optional `roleText` injected into the user message's `<data>` fence (never into the system block - see the trust-order note above `buildOrganizeSystem`). It borrows terminology and tone only; it never executes the role's tasks |
122
+ | Finish reason | Anything other than `stop` - including a missing finish chunk - **fails** and never writes back to the draft |
123
+ | Timeout | `organizeTimeoutMs`, default 120000 ms, read per request via `.get()`. The client fetch timeout is that value + 5000 ms |
124
+ | Input caps | `maxSnippetBytes` (262144 = 256 KiB) per key file, `readConcurrency` (8) for reads. Directory, conversation and role text are **never truncated** |
125
+ | No truncation, on purpose | A model context-overflow error is the feedback, and the user slims the input. A payload above the endpoint body cap gets a 413 instead |
126
+
127
+ ## <img src="https://api.iconify.design/lucide/layout-template.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Templates
128
+
129
+ | Aspect | Fact |
130
+ |---|---|
131
+ | Entry shape | `{ id, name, description, text, group, emoji }`, all strings. `description` / `group` / `emoji` default to empty strings |
132
+ | Validation on save | Entries with an empty `name` or `text` are dropped; `emoji` is cut to 12 characters; a missing or colliding `id` is deterministically replaced by `tpl-<index>` |
133
+ | Built-in set | 85 curated templates generated from the `agents/` role library. The dropdown falls back to them when `templates` is unset |
134
+ | "Unset" is an empty array | Under implicit registration schemastery casts a missing array field to `[]`, so **an empty list always means "fall back to built-in"**. Only a non-empty array whose items are all invalid renders as an empty list |
135
+ | Restore defaults | Unsets `templates` back to the curated set and leaves `importAllowRoots` untouched. Two-step confirm; the second click must come within 4 seconds |
136
+ | Import | By path: a local `.md` file or a directory. `path` exactly empty imports the whole built-in library. A role file whose code fence never closes is rejected instead of silently importing half its body |
137
+
138
+ ## <img src="https://api.iconify.design/lucide/sliders-horizontal.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Settings
139
+
140
+ Namespace `dir-prep-organize` equals the settings entry id. Fields projected into the settings form are the `.volatile()` ones.
141
+
142
+ | Field | Type | Default | Card control | Notes |
143
+ |---|---|---|---|---|
144
+ | `templates` | `{id,name,description,text,group,emoji}[]` | unset | **yes** | The user's own templates. Unset falls back to the 85 built-in entries |
145
+ | `importAllowRoots` | `string[]` | `[]` | **yes** | Extra allowed roots for the import endpoint. Non-strings and whitespace-only items are dropped; duplicates removed. With nothing registered, only the session cwd and the built-in role library are allowed |
146
+ | `organizeTimeoutMs` | natural, volatile | `120000` | **no** | The LLM abort deadline in ms. Positive values are truncated and clamped to `[1, 2147483647]`; non-finite or ≤0 values fall back to `120000` instead of becoming an instant timeout. Past 2^31-1 Node's `setTimeout` prints a `TimeoutOverflowWarning` and silently uses **1 ms**, which turns "raise the timeout" into "fail instantly". The card has no control, so changing it means `settings.yaml` or the row's `config:` |
147
+ | `maxSnippetBytes` | natural, non-volatile | `262144` | **no** | Per-file cap for key-file snippets; a larger file, or one whose size is unknown, is skipped whole and counted in `skipped.tooLarge`. Import candidates use the same cap. Non-volatile means no form projection, hence no card row - deployment value only |
148
+ | `readConcurrency` | natural, non-volatile | `8` | **no** | Bounded read concurrency for snippets and directory imports. Clamped to `[1, 64]`: `0` or a negative value made the bounded map recurse forever until the host was killed by the OOM killer, and a huge value defeats the fd ceiling this field exists to hold |
149
+
150
+ Settings are persisted in `settings.yaml` under the dsh data directory.
151
+
152
+ ## <img src="https://api.iconify.design/lucide/network.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Public interface
153
+
154
+ Official Typert Remote namespace **`dirPrepOrganize`**, registered through an injected child fiber. The descriptors are hand-written, parameters go through strict shape validation, results go through `src-json`.
155
+
156
+ | Method | Input | Success payload |
157
+ |---|---|---|
158
+ | `defaults` | - | `ok` / `templates[…]` (the curated set) |
159
+ | `context` | `{ sessionId }` | `ok` / `cwd` / `truncated` / `skipped` / `entries[{name,isDir,sizeBytes,snippet}]` |
160
+ | `model` | `{ sessionId }` | `ok` / `provider` / `model` / `reasoningEffort` |
161
+ | `organize` | `{ sessionId, prompt, entriesSummary, roleText? }` | `ok` / `content` |
162
+ | `importTemplates` | `{ path, sessionId }` (`path` exactly empty = whole built-in library) | `ok` / `count` / `truncated` / `skipped` / `entries` |
163
+
164
+ - Business failures stay `ok:false` with `error`. The import path-policy branches are the exception: an out-of-bounds path or a malformed `path` field also carries `status` 403 or 400.
165
+ - Result parsing on the client keeps defensive defaults: a non-object payload or a missing `ok:true` becomes a **visible error**, never an empty list.
166
+
167
+ ## <img src="https://api.iconify.design/lucide/lock.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Data and privacy
168
+
169
+ | Aspect | Fact |
170
+ |---|---|
171
+ | Network | No outbound requests of its own: the data plane is the host gateway's RPC channel. No environment variable is read |
172
+ | On disk | The only data written is `templates` and `importAllowRoots`, in the host settings file |
173
+ | What one polish call sends | The full draft, the session cwd path, top-level directory entries **with the full text of key text files**, the real user/assistant turns (framework-injected messages and tool results are filtered out), and the optional role body |
174
+ | Which files get a snippet | Only 20 code/document extensions (ts/tsx/js/jsx/mjs/cjs/py/rs/go/java/rb/json/toml/md/sql/graphql/proto/css/scss/less). `yaml` / `env` are **not** whitelisted |
175
+ | Sensitive file names | Any file whose name matches `credentials` / `secret(s)` / `id_rsa` / `pem` / `p12` / `pfx` / `keystore` / `env` / `key(s)` / `token(s)` / `auth` / `passwd` / `password` / `account(s)` **at a separator boundary** never gets a snippet. The boundary is deliberate: a naive substring match would drop `monkey.js` and `AUTHORS.md`, while a miss would send credential text to a third-party model |
176
+ | Caps and concurrency | A single file over `maxSnippetBytes`, or with unknown size, is skipped whole - never half-summarized. Reads run with `readConcurrency` |
177
+ | Counters | Too-large / unreadable / deeper-level / non-role cases are counted in `skipped`, shown in the UI, and reflected honestly by `truncated` |
178
+ | Import endpoint | **Read-only**: no model call, no disk writes. Absolute paths are refused by default; only paths inside the session cwd, the package's `agents/` and `importAllowRoots` pass. `.` / `..` / hidden segments (such as `.ssh`) are always rejected, and an out-of-bounds path answers 403 echoing the resolved path |
179
+
180
+ ## <img src="https://api.iconify.design/lucide/triangle-alert.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Known boundaries
181
+
182
+ Registered honestly, one entry per class.
183
+
184
+ - **Nothing is truncated for you.** Directory listings, conversation text and role bodies go in whole. A context overflow is the model's error to report and yours to slim - this plugin will not silently drop half your draft.
185
+ - **The import card has no session context.** Its POST sends `sessionId` as an empty string, so an import must live inside the built-in `agents/` or a registered root, and must contain no `.` / `..` / hidden segments. The rejection names the allowed zones and echoes the resolved path.
186
+ - **Directory import reaches two levels.** The top level plus one sub-directory level; a third level is only **counted** as `deeper`, never imported.
187
+ - **A file whose name cannot be parsed from the first 20 frontmatter lines counts as `unnamed`** and is skipped rather than guessed.
188
+ - **Machine translation does not exist here.** The `agents/` role library and template bodies are user data; they are never translated, whichever interface language is active.
189
+ - **The polish path is best-effort about the model's answer.** A non-`stop` finish reason fails the whole call; a model that returns prose instead of a rewrite replaces your draft with that prose.
190
+
191
+ ## <img src="https://api.iconify.design/lucide/circle-help.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> FAQ
192
+
193
+ | Symptom | What happens |
194
+ |---|---|
195
+ | Nothing changed after pressing "Polish" | Failures never touch the draft; the button shows an error state for a few seconds with the reason in its tooltip. Usual causes: no session cwd (`sessionId` missing or session unknown), no model selection, a finish reason other than `stop`, or the `organizeTimeoutMs` deadline |
196
+ | The model reports a context overflow | Working as designed: input is deliberately not truncated, so the model error is the feedback. A payload above the endpoint body cap gets 413 instead |
197
+ | Importing local roles was refused | Absolute paths are refused by default and the card has no session context. The path must live inside the built-in `agents/` or a registered directory and contain no `.` / `..` / hidden segments |
198
+ | Fewer entries imported than expected | Read the four `skipped` counters: `deeper` (third level, counted only), `tooLarge` (over `maxSnippetBytes`), `unnamed` (no name in the first 20 frontmatter lines), `unreadable` (read failure) |
199
+ | Template edits not applied / wrong language | Edits stage locally and take effect for newly opened dropdowns after **Save**. Labels and copy follow the official locale preference; role and template **bodies** are user data and are never machine translated |
200
+
201
+ ## <img src="https://api.iconify.design/lucide/wrench.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Development
22
202
 
23
203
  ```sh
24
- dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
204
+ pnpm install
205
+ pnpm run check # typecheck → lint → client build → host build → types → tests → format
206
+ pnpm run gen:defaults # regenerate the curated set from agents/ (dev-time only)
25
207
  ```
26
208
 
27
- - Host range `>= 0.2.0-rc.2`, written to both `peerDependencies` and `engines.dsh`. Only `peerDependencies` is actually enforced: since `0.1.7-rc.1` the host evaluates it when loading plugins and disables an entry that fails (`compatibility-preflight.ts` → `deny()`), whereas `engines.dsh` has no reader at this host version.
28
- - The `@deepseek-ai/dsh-*` dependencies stay pinned at `0.2.1-rc.2`, the version this package is built and tested against. The range is a claim about which *hosts* it runs on; the pin is a fact about which host version *it* was compiled against — mixing the two is why the publish gate now checks them separately.
29
- - The client half is `dsh.client.platform = web` with `immediately`.
30
- - The publishing form is one repository per package, `repository.url` is git+https://github.com/JayYuen666/dsh-dir-prep-organize.git ; issues go to that repository's issue tracker (`bugs`).
31
- - Requires Node.js `>= 22.12`. This is an ESM-only package: use `import { apply } from "@jayyuen66/dsh-dir-prep-organize"` or `require("@jayyuen66/dsh-dir-prep-organize")`. There is **no default export** — `import pkg from …` fails with `does not provide an export named 'default'`; take the named exports instead. That Node floor is what makes `require()` of this ESM entry work at all, which is why `engines.node` is declared.
32
- - TypeScript declarations ship as `types/host.d.ts`, wired into both `types` and the `.` export condition. The `Config` schema value carries an explicit annotation so the emitted file never has to name a package a consumer cannot resolve.
33
- - The published artifact ships only `host.js`, `client.js`, `templates.data.mjs`, `types/`, `cordis.patch.yml`, `agents/` and `THIRD_PARTY_NOTICES.md` (package.json `files`). `LICENSE`, `README.md` and `package.json` are attached unconditionally by the registry client.
34
- - The built-in template table lives in its own artifact and is loaded **on first use**, not at plugin load. It used to be bundled into `host.js`, so every user paid for 85 templates in memory even without opening the dropdown - `host.js` is now roughly a tenth of its former size, and the browser already fetched this data lazily anyway.
35
- - `agents/` is not authored here: it comes from the upstream project [`agency-agents-zh`](https://github.com/jnMetaCode/agency-agents-zh) (MIT). Its copyright and licence notice ship in `THIRD_PARTY_NOTICES.md`, because MIT requires it in every distributed copy.
36
- - No `@deepseek-ai/*` goes in `dependencies`, and that is not a style preference. Consumers of this package are dsh plugins installed into a profile (`nodeLinker: hoisted`, `autoInstallPeers: false`), so any host package listed under `dependencies` is written into that profile as a **real directory**, coexisting with the copy the host process already loaded. `@deepseek-ai/dsh-tools` keys its `TOOL_RUNTIME_SCHEDULER` with a plain `Symbol` (not `Symbol.for`), so symbol identity is per module instance: the host's `dsh-agent-loop` reads a `ToolRuntime` mounted from the duplicate using its own copy's symbol, gets `undefined`, and **every native tool call throws** `Cannot read properties of undefined (reading 'prepare')` — the whole profile loses its tools. This package's build, typecheck and tests all stay green right up to that point, so `test/publish-manifest.test.ts` pins the invariant in the manifest instead.
37
- - The two host packages the shipped `host.js` imports as **values** are required (non-optional) `peerDependencies`: `@deepseek-ai/schemastery` (the host's fork — only it resolves 0.1.7 `.volatile()` fields into live references) and `@deepseek-ai/dsh-brand` (`0.2.1-rc.2`). The host provides them at runtime and a profile installs no peers, so no duplicate appears. `build-host.mjs` externalizes `dependencies` *and* `peerDependencies`, so the bare specifiers in `host.js` stay exactly as they were — that is the ruling behind `brandString`: the peer keeps the specifier external and the official function body out of the artifact, while a `devDependencies`-only entry lets rolldown inline it (`test/build-host.test.ts` pins both "specifier present" and "function body absent").
38
- - Every host package the emitted **declarations** name is declared under `peerDependencies`, and each one reached only there is *optional*: `@deepseek-ai/cordis` (`4.0.5`), `@deepseek-ai/cosmokit` (`1.8.6`, reached only through schemastery's `Dict`) and `@deepseek-ai/dsh-agent-default-model`, `-client-locale`, `-client-ui-conversation`, `-client-ui-renderer`, `-client-ui-settings`, `-client-ui-slots`, `-fs`, `-llm`, `-session` (all `0.2.1-rc.2`). Declaring them is not ceremony: under pnpm's strict layout a bare specifier in `types/host.d.ts` that no manifest table names is unresolvable, so the declaration entry simply would not typecheck on the consumer's side while this repository's own typecheck stays green — here both tables carry it. `test/publish-manifest.test.ts` reads that roster off `types/**/*.d.ts` rather than off this paragraph, so the two cannot drift apart. `@deepseek-ai/dsh` is the one peer nothing imports: it names the host, which is what `engines.dsh` says in words.
39
- - Every peer is repeated in `devDependencies` at the same exact pin; that is what lets this repository's own typecheck, build and tests resolve them. The remaining `@deepseek-ai/*` entries here are type-only in source and leave no specifier in the declarations either, so they stay in `devDependencies` alone.
40
- - What is left in `dependencies` is this package's own runtime code: `@jayyuen66/dsh-plugin-shared`.
41
-
42
-
43
- ## Shared version floor
44
-
45
- If your profile pins `@jayyuen66/dsh-plugin-shared` with a pnpm `overrides` entry, that pin must be at least the `@jayyuen66/dsh-plugin-shared` version this package declares. A lower pin installs a copy without the names this package imports at runtime, and the host then reports `N entries did not activate` with `does not provide an export named ...` when it boots -- the package installs fine and never loads, and no per-repo CI run can see it.
46
-
47
- ## Enabling it in dsh
48
-
49
- - Installing the package contributes the bundle patch layer (`dsh.bundle.patch` points at `./cordis.patch.yml`), which inserts `- id: dir-prep-organize` with `name` set to the package name.
50
- - Removal goes through `dsh plugin --profile web remove @jayyuen66/dsh-dir-prep-organize`.
51
- - The host half hard-injects settings: without it the card is disabled with a warning and the "Template" dropdown falls back to the built-in curated set. The client read surface is the official Typert Remote service `dirPrepOrganize`, registered through an injected child fiber; no `webServer` dependency is involved.
52
- - The client half registers slot `conversation.input.right` (organize id `dir-prep-organize` order 99, templates id `dir-prep-organize-templates` order 100) and the settings card slot `plugins.bundle.config`.
53
- - The card slot key = the bundle package name `@jayyuen66/dsh-dir-prep-organize`: the host dispatches `entryKey: pkg.name` (source of truth: `dsh.profile.bundles` in `~/.dsh/profiles/web/package.json`), so a bare entry id never matches and the card renders nowhere.
54
- - The settings namespace and `configForms.get()` stay the bare entry id `dir-prep-organize` - not the same identifier as that slot key.
55
-
56
- ## Tools exposed to the model
57
-
58
- | Aspect | Fact |
59
- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
60
- | Tool registration | None. The host half only `inject`s settings and never touches the host tool registry |
61
- | Organize call | Host `llm.stream`: one user text message (**request-only input** - no `id`, no `source`; see the three-evidence note at the top of `host.ts`) plus a `system` rule block; the model comes from `agentDefaultModel.currentSelection()` (provider/model/reasoningEffort) and its absence reports "No model selection is available" |
62
- | Role point of view | Optional `roleText` injected into the "Reference role" part of the system block; it only borrows terminology and tone, it never executes the role's tasks |
63
- | Limits | All three live in config and every request takes them through `limits`: `organizeTimeoutMs` defaults to 120000 ms (a volatile reference read via `.get()`), `maxSnippetBytes` to 262144 (256 KiB) and `readConcurrency` to 8 (plain values, no `.get()`); the client request timeout is `organizeTimeoutMs` + 5000 ms (125000 when the host value is absent; the other four reads use a 125000 ms constant); directory/conversation/role text are never truncated; a finish reason other than `stop` (including a missing finish chunk) fails and never writes back |
64
-
65
- ## Settings
66
-
67
- | Field | Type | Default | Notes |
68
- | ------------------- | ------------------------------------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
69
- | `templates` | `{id,name,description,text,group,emoji}[]` | unset | All-string fields; description/group/emoji default to empty strings; entries with an empty name or body are dropped on save, emoji is cut to 12 characters, a missing or colliding id is deterministically replaced by `tpl-<index>`. The dropdown falls back to the 85 built-in curated entries when unset. ⚠ under implicit registration "unset" reaches the client as an **empty array** (schemastery casts a missing array field to `[]`; omitting the default does not yield `undefined`), so an empty list always means "fall back to built-in" - only a non-empty array whose items are all invalid renders as an empty list |
70
- | `importAllowRoots` | `string[]` | `[]` | Extra allowed roots for the import endpoint, registered directory by directory; non-strings and whitespace-only items are dropped and duplicates removed; with nothing registered only the session cwd and the built-in role library are allowed |
71
- | `organizeTimeoutMs` | natural, `.volatile()` | `120000` | The LLM abort deadline in ms; the host reads it per request via `config.organizeTimeoutMs.get()`. Being volatile it is projected into this entry's form snapshot, and of the three it is the only one the client half reads (`rawOrganizeTimeoutMsOf`), used to set the organize fetch timeout to "this value + 5000 ms". ⚠ Clamped to `[1, 2147483647]`: past 2^31-1 Node's `setTimeout` prints a `TimeoutOverflowWarning` and silently uses **1 ms**, which turns "raise the timeout" into "fail instantly". ⚠ The card has **no control** for it: `src/client-entry.ts` writes only `templates` and `importAllowRoots`, so changing it means settings.yaml or the row's `config:` |
72
- | `maxSnippetBytes` | natural (non-volatile) | `262144` | Per-file cap for the key-file snippet; a larger file, or one whose size is unknown, is skipped whole and counted in `skipped.tooLarge`. Import candidates use the same cap. Non-volatile means it is not projected into the form snapshot, so there is no card row either - deployment value only (settings.yaml / row `config:`) |
73
- | `readConcurrency` | natural (non-volatile) | `8` | Bounded read concurrency for the key-file snippets and for directory imports (sub-directory listings, third-level counting, candidate reads). Same as above: no projection, no card control. ⚠ Clamped to `[1, 64]` before use: `0` or a negative value made the bounded map recurse into itself forever until the host process was killed by the OOM killer, and a huge value simply defeats the fd ceiling this field exists to hold |
74
- | Restore defaults | — | — | Unsets `templates` back to the curated set and leaves `importAllowRoots` untouched; two-step confirm, the second click must come within 4 seconds |
75
- | Storage | — | — | Settings namespace `dir-prep-organize` (0.1.7 implicit registration: the namespace is this entry's id, and the fields projected into the settings form are the `.volatile()` ones on `Config` in host.ts - `templates`, `importAllowRoots`, `organizeTimeoutMs`, of which the card writes the first two; `maxSnippetBytes` and `readConcurrency` stay plain values; the curated set stays on the host half and is served on demand, not as a host `base`), persisted in the settings.yaml under `<dsh data dir>` (`$DSH_HOME`) |
76
-
77
- ## Public interface
78
-
79
- Official Typert Remote namespace `dirPrepOrganize`, registered through an injected child fiber. Authentication and transport are enforced by the host `/api` gateway (Host/DNS-rebinding/Origin checks, signed browser-session cookie, body limits); the package opens no HTTP routes and keeps no CSRF token of its own.
80
-
81
- | Method | Input | Success payload |
82
- | ----------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------ |
83
- | `defaults` | — | `ok/templates[{id,name,description,text,group,emoji}]` (the curated set) |
84
- | `context` | `{ sessionId }` | `ok/cwd/truncated/skipped/entries[{name,isDir,sizeBytes,snippet}]` |
85
- | `model` | `{ sessionId }` | `ok/provider/model/reasoningEffort` |
86
- | `organize` | `{ sessionId, prompt, entriesSummary, roleText? }` | `ok/content` |
87
- | `importTemplates` | `{ path, sessionId }` (`path` exactly empty = whole built-in library) | `ok/count/truncated/skipped/entries` |
88
-
89
- - Business failures stay `ok:false` with `error`. The import path-policy branches are the exception: an out-of-bounds path or a malformed `path` field also carries `status` 403 or 400 for callers that surface it.
90
- - Result parsing on the client keeps its defensive defaults: a non-object payload or a missing `ok:true` becomes a visible error, never an empty list.
91
-
92
- ## Data and privacy
93
-
94
- | Aspect | Fact |
95
- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
96
- | Network calls | No outbound requests: the read surface is reached through the host gateway's RPC channel, and no environment variable is read |
97
- | Data on disk | The only data written to disk is `templates` and `importAllowRoots` in settings |
98
- | What one organize call sends | The full draft, the session cwd path, top-level directory entries with the full text of key text files, real user/assistant turns (framework-injected messages and tool results are filtered out), and the optional role body |
99
- | Snippet extensions | Only 20 code/document extensions (ts/tsx/js/jsx/mjs/cjs/py/rs/go/java/rb/json/toml/md/sql/graphql/proto/css/scss/less); yaml/env types are not whitelisted |
100
- | Sensitive file names | Any file whose name contains credential/secret/id_rsa/.pem/.p12/.pfx/keystore/.env/.key never gets a snippet |
101
- | Per-file cap and concurrency | A single file over `maxSnippetBytes` (default 256 KiB), or with unknown size, is skipped whole (no half summaries), reads run with `readConcurrency` (default 8); both are config fields and neither has a card control |
102
- | Counters and echo | Too-large/unreadable/deeper-level/non-role cases are counted in `skipped`, shown in the UI, and reflected honestly by `truncated` |
103
- | Import endpoint | Read-only: no model call, no disk writes. Absolute paths are refused by default; only paths inside the session cwd, the package's `agents/` and `importAllowRoots` pass, `.`/`..`/hidden segments (such as `.ssh`) are always rejected, and an out-of-bounds path answers 403 echoing the resolved path |
104
-
105
- ## FAQ
106
-
107
- | Symptom | What happens |
108
- | -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
109
- | Nothing changed after pressing "Organize"? | Failures never touch the draft; the button shows an error state for 4 seconds with the reason in its title. Usual causes: no session cwd (sessionId missing or session unknown), no model selection, a finish reason other than `stop`, the `organizeTimeoutMs` deadline (120 seconds by default) |
110
- | The model reports a context overflow? | Directory/conversation/role text are deliberately not truncated, so the model error is the feedback and you slim the input yourself; a payload above the configured body cap (8 MiB by default) gets 413 from the endpoint instead |
111
- | Importing local roles was refused? | Absolute paths are refused by default and the settings card has no session context (its POST sends `sessionId` as an empty string), so the path must live inside the built-in `agents/` or a registered directory and contain no `.`/`..`/hidden segments; the rejection names the allowed zones and echoes the resolved path |
112
- | Fewer entries imported than expected? | Read the four `skipped` counters: directory imports cover the top level plus one sub-directory level (a third level is only counted as `deeper`), files over `maxSnippetBytes` (256 KiB by default) count as `tooLarge`, files whose name cannot be parsed from the first 20 frontmatter lines count as `unnamed`, and read failures as `unreadable` |
113
- | Template edits not applied / wrong language? | Edits are staged locally and take effect for newly opened dropdowns after "Save"; the card, the two dock buttons next to the input (their labels and copy now live in the `ui-messages.ts` dictionary) and the host replies all follow the official locale plugin's preference (the host side reads it per request, no restart), while the agents/ role library and template bodies are user data and are never machine translated |
209
+ - **`test/gen-defaults.test.ts` is a drift lock.** It compares the generated file field by field against the role library, checks both mirror tables' key order, and requires **byte-level** identity with what the generator produces. Editing the parsing or extraction logic means editing `scripts/gen-defaults-lib.mjs` **and** re-running `pnpm run gen:defaults`; anything else shows up as a red test rather than a silently stale dropdown.
210
+ - The generator exits non-zero when a curated slug is missing or fails to parse, so a role can never disappear silently.
211
+ - The rest of the suite splits the classes of defect a stub cannot see: the host half, the client half, the Remote contract (`test/dir-prep-remote.test.ts`), the two build artifacts (`test/build-host.test.ts`, `test/build-client.test.ts`), and an integration layer.
212
+ - Coverage thresholds are 100% across four metrics, so a new branch needs a case that reaches it.
213
+
214
+ ## <img src="https://api.iconify.design/lucide/scale.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> License
215
+
216
+ MIT. Source at [github.com/JayYuen666/dsh-dir-prep-organize](https://github.com/JayYuen666/dsh-dir-prep-organize). Issues go to that repository's tracker.
217
+
218
+ `agents/` is vendored from [`agency-agents-zh`](https://github.com/jnMetaCode/agency-agents-zh) (MIT); see [`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md).