@xiaoso/dsh-tool-plus 0.1.9 → 0.1.10-beta.1

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 (40) hide show
  1. package/README.en.md +12 -5
  2. package/README.md +11 -4
  3. package/THIRD_PARTY_NOTICES.md +36 -0
  4. package/lib/client.js +272 -181
  5. package/lib/index.mjs +875 -1081
  6. package/lib/{scrapers-mhvFrvjH.mjs → scrapers-DODCPcZW.mjs} +1 -1
  7. package/lib/types/client/BashPlusCard.d.ts +6 -6
  8. package/lib/types/client/ToolPlusSection.d.ts +3 -3
  9. package/lib/types/client/forms.d.ts +6 -6
  10. package/lib/types/client/index.d.ts +25 -12
  11. package/lib/types/client/locales.d.ts +1 -1
  12. package/lib/types/client/preset-panel.d.ts +54 -42
  13. package/lib/types/config/settings.d.ts +202 -21
  14. package/lib/types/host/browser-probe-rpc.d.ts +2 -1
  15. package/lib/types/host/preset-host.d.ts +103 -0
  16. package/lib/types/host/preset-rpc.d.ts +37 -72
  17. package/lib/types/presets/compare.d.ts +14 -37
  18. package/lib/types/presets/conflicts.d.ts +59 -0
  19. package/lib/types/presets/delta.d.ts +23 -18
  20. package/lib/types/presets/plan.d.ts +55 -0
  21. package/lib/types/presets/rows.d.ts +84 -0
  22. package/lib/types/presets/status.d.ts +56 -47
  23. package/lib/types/tools/bash/background.d.ts +20 -5
  24. package/lib/types/tools/bash/streaming-output.d.ts +4 -2
  25. package/lib/types/tools/shared/browser-rpc-channel.d.ts +84 -42
  26. package/lib/types/web/client/labels.d.ts +1 -1
  27. package/lib/types/web/client/row-utils.d.ts +26 -1
  28. package/lib/{utils-eiUz9n8I.mjs → utils-D80w8vry.mjs} +1 -1
  29. package/package.json +61 -46
  30. package/presets/tool-plus-ptc.patch.yml +164 -0
  31. package/presets/tool-plus-standard.patch.yml +158 -0
  32. package/lib/types/presets/install.d.ts +0 -44
  33. package/lib/types/presets/paths.d.ts +0 -41
  34. package/lib/types/presets/rewrite.d.ts +0 -86
  35. package/presets/install-presets.mjs +0 -143
  36. package/presets/package.json +0 -42
  37. package/presets/tool-plus-ptc/agent.cordis.yml +0 -284
  38. package/presets/tool-plus-ptc/preset.yml +0 -3
  39. package/presets/tool-plus-standard/agent.cordis.yml +0 -269
  40. package/presets/tool-plus-standard/preset.yml +0 -3
@@ -0,0 +1,158 @@
1
+ # Agent preset `tool-plus-standard` — declared as one `@deepseek-ai/dsh-agent-preset` row.
2
+ #
3
+ # GENERATED by scripts/build-preset-patches.mjs from
4
+ # presets/baseline/standard.patch.yml (the shipped `standard` composition of the dsh
5
+ # release this plugin pins). Do not edit by hand: the generator is what keeps
6
+ # our delta honest across dsh upgrades, and tests/unit/preset-patches.spec.ts
7
+ # fails when this file and the generator disagree.
8
+ #
9
+ # Delta over the baseline:
10
+ # - tool-bash, tool-fs, tool-fs-search are removed — the host plane already serves them
11
+ # through this plugin's `cordis.patch.yml`, and mounting them again in the
12
+ # agent plane would create a per-session shadow instance
13
+ # - tool-pwsh is forced `disabled: true` (neither Tool Plus preset enables pwsh)
14
+ # - an inert `tool-plus` row documents where an agent-plane plugin row would go
15
+ # - everything else is the baseline, byte-equivalent
16
+ #
17
+ # A profile patch overriding this row BY THE ROW ID BELOW replaces the whole
18
+ # `config`, so an override must restate `id`, `name`, `description`, `order` and
19
+ # `plugins`. That is what `@xiaoso/dsh-tool-plus`'s settings panel writes.
20
+ - insert:
21
+ - id: preset-tool-plus-standard
22
+ name: '@deepseek-ai/dsh-agent-preset'
23
+ config:
24
+ id: tool-plus-standard
25
+ name: Tool Plus 标准增强版
26
+ description: 标准模式全部能力 + tool-plus 增强:文件/Shell 工具集替换为 @xiaoso/dsh-tool-plus(移植 oh-my-pi:read 单参数 file_path 内联行选择器、edit 三模式、bash/grep/glob);pwsh 默认禁用。
27
+ order: 20
28
+ plugins:
29
+ - id: persona
30
+ name: '@deepseek-ai/dsh-persona'
31
+ config:
32
+ suffix: Your working directory is {{cwd}}.
33
+ prefix: You are a coding agent powered by the {{model}} model.
34
+ - id: agent-instructions
35
+ name: '@deepseek-ai/dsh-agent-instructions'
36
+ config:
37
+ maxBytes: 65536
38
+ - id: tool-plus
39
+ name: '@xiaoso/dsh-tool-plus'
40
+ disabled: true
41
+ - id: tool-pwsh
42
+ name: '@deepseek-ai/dsh-tool-pwsh'
43
+ disabled: true
44
+ - id: tool-jobs
45
+ name: '@deepseek-ai/dsh-tool-jobs'
46
+ - id: skill-filesystem
47
+ name: '@deepseek-ai/dsh-skill-filesystem'
48
+ - id: tool-skill
49
+ name: '@deepseek-ai/dsh-tool-skill'
50
+ - id: command-goal
51
+ name: '@deepseek-ai/dsh-command-goal'
52
+ - id: tool-goal
53
+ name: '@deepseek-ai/dsh-tool-goal'
54
+ - id: planning
55
+ name: cordis:group
56
+ group: true
57
+ isolate:
58
+ planMode: true
59
+ config:
60
+ - id: plan-mode
61
+ name: '@deepseek-ai/dsh-plan-mode'
62
+ config:
63
+ section: |
64
+ You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
65
+
66
+ Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
67
+
68
+ The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
69
+
70
+ Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
71
+
72
+ Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
73
+
74
+ When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
75
+ - id: compaction
76
+ name: cordis:group
77
+ group: true
78
+ isolate:
79
+ compaction: true
80
+ toolResultPruner: true
81
+ config:
82
+ - id: compaction-basic
83
+ name: '@deepseek-ai/dsh-compaction-basic'
84
+ - id: command-compact
85
+ name: '@deepseek-ai/dsh-command-compact'
86
+ - id: tool-result-pruner
87
+ name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
88
+ config:
89
+ thresholdChars: 8192
90
+ headChars: 4096
91
+ tailChars: 1024
92
+ - id: delegation
93
+ name: cordis:group
94
+ group: true
95
+ isolate:
96
+ workflowEngine: true
97
+ config:
98
+ - id: tool-subagent-control
99
+ name: '@deepseek-ai/dsh-tool-subagent-control'
100
+ - id: tool-subagent-list-agents
101
+ name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
102
+ - id: tool-subagent
103
+ name: '@deepseek-ai/dsh-tool-subagent'
104
+ config:
105
+ provider: spawn
106
+ toolName: subagent
107
+ modelSelectionSettings: true
108
+ backgroundMode: continuable
109
+ - id: tool-subagent-fork
110
+ name: '@deepseek-ai/dsh-tool-subagent'
111
+ config:
112
+ provider: fork
113
+ toolName: subagent_fork
114
+ backgroundMode: continuable
115
+ - id: tool-subagent-codex
116
+ name: '@deepseek-ai/dsh-tool-subagent'
117
+ disabled: true
118
+ config:
119
+ provider: codex
120
+ toolName: subagent_codex
121
+ backgroundMode: one-shot
122
+ maxDepth: provider-managed
123
+ - id: tool-subagent-claude-code
124
+ name: '@deepseek-ai/dsh-tool-subagent'
125
+ disabled: true
126
+ config:
127
+ provider: claude-code
128
+ toolName: subagent_claude_code
129
+ backgroundMode: one-shot
130
+ maxDepth: provider-managed
131
+ - id: workflow-ptc
132
+ name: '@deepseek-ai/dsh-workflow-ptc'
133
+ config:
134
+ provider: spawn
135
+ - id: tool-workflow
136
+ name: '@deepseek-ai/dsh-tool-workflow'
137
+ - id: tool-ralph
138
+ name: '@deepseek-ai/dsh-tool-ralph'
139
+ disabled: true
140
+ config:
141
+ subagentProvider: spawn
142
+ maxRounds: 64
143
+ - id: tool-ask-user
144
+ name: '@deepseek-ai/dsh-tool-ask-user'
145
+ - id: tool-todo
146
+ name: '@deepseek-ai/dsh-tool-todo'
147
+ config:
148
+ allowParallelInProgress: true
149
+ - id: tool-web
150
+ name: '@deepseek-ai/dsh-tool-web'
151
+ config:
152
+ fetch: true
153
+ searchTimeoutMs: 60000
154
+ - id: present
155
+ name: '@deepseek-ai/dsh-tool-present'
156
+ - id: tool-plugin-manager
157
+ name: '@deepseek-ai/dsh-plugin-manager/tools'
158
+ disabled: true
@@ -1,44 +0,0 @@
1
- import { type PresetDeps } from './paths.ts';
2
- import { type PresetChange } from './rewrite.ts';
3
- /** 一次预设动作的结果:`changed: false` 表示一个字节都没写(含幂等与失败)。 */
4
- export interface PresetInstallResult {
5
- ok: boolean;
6
- changed: boolean;
7
- /** 失败/无变化的原因(给人看的一句话)。 */
8
- reason?: string;
9
- /** 本次落下的备份文件绝对路径(内容变化且有改写前内容时才有)。 */
10
- backupPath?: string;
11
- /** 实际改动清单(升级 = 冲突行改动;重置 = 整份覆盖,故为空)。 */
12
- changes: PresetChange[];
13
- }
14
- /**
15
- * 启动补缺:`<dshHome>/.agent-presets/<id>` 目录不存在时,从包内模板整份写入
16
- * (`mkdir -p` + 模板目录里的每个文件)。
17
- *
18
- * 目录已存在 → 一律不碰(含"目录存在但缺文件"的情形,那种只在设置页状态里
19
- * 显示)。整个流程每个 id 单独 try/catch,**永不抛**。
20
- * @param deps - 路径注入(fs 层测试用)。
21
- * @returns 新建成功的 id 列表与失败原因列表(顺序均为 {@link DEFAULT_PRESET_IDS})。
22
- */
23
- export declare function ensureDefaultPresets(deps?: PresetDeps): {
24
- created: string[];
25
- failed: Array<{
26
- id: string;
27
- reason: string;
28
- }>;
29
- };
30
- /**
31
- * 用户在设置页对某个预设执行的动作。
32
- *
33
- * - `upgrade`:只改官方冲突行(面板上叫「最小更新」);
34
- * - `reset`:用**所选模板**整份覆盖该预设(先备份)。模板由 `templateId` 指定,
35
- * 缺省才是同名模板 —— 面板总是把用户挑的那份模板传进来。
36
- *
37
- * 永不抛:任何异常收进 `ok: false` + `reason`。
38
- * @param id - 预设 id(目录名)。
39
- * @param action - `upgrade` 或 `reset`。
40
- * @param deps - 路径注入(fs 层测试用)。
41
- * @param templateId - `reset` 的模板来源(默认同名模板)。
42
- * @returns 结果(`changed: false` = 一个字节都没写)。
43
- */
44
- export declare function applyPresetAction(id: string, action: 'upgrade' | 'reset', deps?: PresetDeps, templateId?: string): PresetInstallResult;
@@ -1,41 +0,0 @@
1
- /** 用户根预设目录名(`dsh-agent-presets` 的 `USER_PRESET_DIR` 同值)。 */
2
- export declare const PRESET_DIR_NAME = ".agent-presets";
3
- /** 让一个目录成为 preset 的组合文件名。 */
4
- export declare const COMPOSITION_FILE_NAME = "agent.cordis.yml";
5
- /** 组合文件旁的可选展示元数据文件名。 */
6
- export declare const METADATA_FILE_NAME = "preset.yml";
7
- /**
8
- * 本插件随包的两个预设 id(启动补缺只认它们)。名单的单一来源是共享契约
9
- * 模块 {@link BUNDLED_PRESET_IDS},这里只做本模块语义下的别名。
10
- */
11
- export declare const DEFAULT_PRESET_IDS: readonly string[];
12
- /**
13
- * 路径解析的注入点:宿主半的每个公开函数都收它,fs 层测试据此把
14
- * `<dshHome>` 与包根指到临时目录,避免任何写死路径。
15
- */
16
- export interface PresetDeps {
17
- /** 覆盖 `<dshHome>`;缺省走 `$DSH_HOME` → `~/.dsh`。 */
18
- homeDir?: string;
19
- /** 覆盖插件包根(模板目录的父目录);缺省按 `import.meta.url` 向上探。 */
20
- packageRoot?: string;
21
- }
22
- /**
23
- * 解析 `<dshHome>`。优先级:注入的 `homeDir` → `$DSH_HOME`(trim 后非空)
24
- * → `~/.dsh`,与官方 `@deepseek-ai/dsh-home-paths` 的 `defaultDshHome()` 同规则。
25
- * @param deps - 可选的注入覆盖。
26
- * @returns 绝对路径的 harness home。
27
- */
28
- export declare function dshHomeDir(deps?: PresetDeps): string;
29
- /** 用户根预设目录:`<dshHome>/.agent-presets`(所有 profile 共享的写入根)。 */
30
- export declare function userPresetRoot(deps?: PresetDeps): string;
31
- /** 某个预设的用户根目录:`<dshHome>/.agent-presets/<id>`。 */
32
- export declare function userPresetDir(id: string, deps?: PresetDeps): string;
33
- /**
34
- * 插件包根:注入的 `packageRoot` 优先,否则按 `import.meta.url` 向上探。
35
- * 构建后入口是 `lib/index.mjs`(`..` 即包根),源码期是
36
- * `src/presets/paths.ts`(`../..` 即包根),两个候选都试、取同时含
37
- * `package.json` 与 `presets/` 的那个;都不命中时返回 `../..` 候选。
38
- */
39
- export declare function packageRootDir(deps?: PresetDeps): string;
40
- /** 包内模板目录:`<包根>/presets/<id>`。 */
41
- export declare function templateDir(id: string, deps?: PresetDeps): string;
@@ -1,86 +0,0 @@
1
- /**
2
- * preset 组合改写:纯函数,文本进文本出,零 I/O。
3
- *
4
- * 一个预设要"支持本插件的工具",只需让官方 4 个冲突行 id 处于「不存在」或
5
- * `disabled: true` 状态(插件已在宿主面全局接管这 4 个工具;预设里再挂一份
6
- * 会造成 per-session 影子实例)。本模块只做这一件事:
7
- *
8
- * - 只认**顶层**行 `- id: <target>`(`-` 在第 0 列),嵌套子行一律不碰;
9
- * - 行块已有 `disabled: true` → no-op;`disabled: false`(或任何非 `true`
10
- * 标量)→ 就地改成 `true`;没有 `disabled` → 在行块末尾追加一行
11
- * ` disabled: true`(缩进与行内其它键对齐);行块不存在 → 不动;
12
- * - 注释、空行、缩进、CRLF/LF、YAML 顺序、用户的本地调参全部逐字节保留;
13
- * - 输出与输入逐字节相同时 `changes` 为空——调用方以字节相等判定是否写盘
14
- * (preset 代际以 `agent.cordis.yml` 的 mtime 为键,白写一次就白造一代);
15
- * - 文本不构成顶层行列表 → `shape: 'unrecognized'`,一律不改写。
16
- *
17
- * `PresetChange.action` 的 `'absent'` 供 RPC 摘要层描述"这行本来就不挂",
18
- * 改写本身只报告真实发生的改动(否则"幂等时 changes 为空"不成立)。
19
- * @module @xiaoso/dsh-tool-plus/presets/rewrite
20
- */
21
- /** 默认冲突行 id:官方 standard / ptc / cordis 挂的 4 个官方工具行。 */
22
- export declare const PRESET_CONFLICT_IDS: readonly string[];
23
- /** 一次改写实际发生的一处改动。 */
24
- export interface PresetChange {
25
- /** 行 id(`- id: <id>` 的值)。 */
26
- id: string;
27
- /** `disabled` = 行块末尾追加了禁用键;`flipped` = 既有禁用键被改成 `true`。 */
28
- action: 'disabled' | 'flipped' | 'absent';
29
- }
30
- /** 改写结果:最终文本 + 实际改动清单。 */
31
- export interface PresetRewriteResult {
32
- text: string;
33
- changes: PresetChange[];
34
- }
35
- /** 只读判定:给设置页状态用。 */
36
- export interface PresetAnalysis {
37
- /** 仍挂着冲突行的 id(缺 `disabled` 或值不是 `true`),按 conflictIds 顺序。 */
38
- conflicts: string[];
39
- /** 无冲突且形状可识别。 */
40
- clean: boolean;
41
- /** `unrecognized` = 文本不构成顶层行列表,一律不处理。 */
42
- shape: 'ok' | 'unrecognized';
43
- }
44
- /**
45
- * 把官方冲突行改写成"不存在或 disabled: true"。
46
- *
47
- * `changes` 只含真实发生的改动(幂等跑第二次必为空);`shape: 'unrecognized'`
48
- * 时原文本原样返回。
49
- * @param text - `agent.cordis.yml` 的原文。
50
- * @param conflictIds - 冲突行 id,缺省 {@link PRESET_CONFLICT_IDS}。
51
- * @returns 最终文本与实际改动清单。
52
- */
53
- export declare function rewritePresetComposition(text: string, conflictIds?: readonly string[]): PresetRewriteResult;
54
- /**
55
- * 只读判定:该组合还有哪些冲突行没被禁用。
56
- * @param text - `agent.cordis.yml` 的原文。
57
- * @param conflictIds - 冲突行 id,缺省 {@link PRESET_CONFLICT_IDS}。
58
- * @returns 冲突清单、是否干净、形状结论。
59
- */
60
- export declare function analyzePresetComposition(text: string, conflictIds?: readonly string[]): PresetAnalysis;
61
- /** 一个顶层行块的只读视图:id + 它自己的键值对(供比差/展示,不用于改写)。 */
62
- export interface PresetRowView {
63
- id: string;
64
- /** 行内顶层键值对,顺序与文件一致;值为去引号、去尾随注释后的原文。 */
65
- keys: {
66
- key: string;
67
- value: string;
68
- }[];
69
- /**
70
- * 整个行块按缩进展开出的叶子(点号路径,列表项带 `[i]`),供比差用。
71
- * 只比顶层键是不够的:真实漂移常常藏在 `config.thresholdRatio` 这类嵌套键里。
72
- */
73
- leaves: {
74
- path: string;
75
- value: string;
76
- }[];
77
- }
78
- /**
79
- * 只读读出顶层行的键值对与展开叶子。形状不可识别时返回 undefined(不猜、不修)。
80
- *
81
- * 与 {@link analyzePresetComposition} 共用同一套扫描器(`splitLines` /
82
- * `detectShape` / `scanRows`):解析只有一份,差异视图与改写视图永远同源。
83
- * @param text - `agent.cordis.yml` 原文。
84
- * @returns 逐行视图,或形状不可识别时的 undefined。
85
- */
86
- export declare function readPresetRows(text: string): PresetRowView[] | undefined;
@@ -1,143 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Install the Tool Plus agent-preset templates into a DSH home.
4
- *
5
- * Everything preset-related lives in THIS one folder:
6
- *
7
- * presets/
8
- * install-presets.mjs <- this script (self-locating, no cwd dependency)
9
- * tool-plus-standard/ <- 标准增强版 preset template
10
- * tool-plus-ptc/ <- PTC 增强版 preset template
11
- *
12
- * Each template directory is copied verbatim into
13
- * `${DSH_HOME:-~/.dsh}/.agent-presets/<id>/` — the roster folder every running
14
- * DSH scans for agent presets. New/changed presets are picked up on the next
15
- * Host restart.
16
- *
17
- * RE-ENTRANT BY DESIGN (safe to run any number of times):
18
- *
19
- * target file missing -> install it
20
- * target file byte-identical -> report "up-to-date", touch nothing
21
- * target file differs (user edit) -> SKIP and keep the local edit,
22
- * unless --force restores the canonical copy
23
- * unknown extra files in target -> left alone (never destroys unrelated data)
24
- *
25
- * Exit codes: 0 = all targets installed or up-to-date;
26
- * 1 = at least one target was skipped (stale local edits exist —
27
- * rerun with --force to normalize) or a hard error occurred.
28
- *
29
- * Usage:
30
- * node presets/install-presets.mjs [--force] [--dry-run] [--home <dir>]
31
- *
32
- * --force overwrite differing target files with the packaged copies
33
- * --dry-run report what would happen; write nothing (exit code still reflects skips)
34
- * --home <dir> override the DSH home (defaults to $DSH_HOME, then ~/.dsh);
35
- * use this to try the installer against an isolated home
36
- */
37
-
38
- import { readdirSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
39
- import { homedir } from "node:os";
40
- import { dirname, join, resolve } from "node:path";
41
- import { fileURLToPath } from "node:url";
42
-
43
- const scriptDir = dirname(fileURLToPath(import.meta.url));
44
- const PRESET_ROOT = "agent-presets";
45
-
46
- /* ── argument parsing ────────────────────────────────────────────────────── */
47
-
48
- const args = process.argv.slice(2);
49
- /** @type {{ force: boolean, dryRun: boolean, home?: string }} */
50
- const options = { force: false, dryRun: false };
51
- for (let i = 0; i < args.length; i++) {
52
- const arg = args[i];
53
- if (arg === "--force") options.force = true;
54
- else if (arg === "--dry-run" || arg === "-n") options.dryRun = true;
55
- else if (arg === "--home") {
56
- const value = args[++i];
57
- if (value === undefined) fail("--home requires a directory argument");
58
- options.home = value;
59
- } else if (arg === "--help" || arg === "-h") {
60
- console.log(readFileSync(new URL(import.meta.url), "utf8").match(/\/\*\*[\s\S]*?\*\//)?.[0]
61
- ?.replace(/^\/\*\*/, "").replace(/\*\/$/, "").replace(/^\s*\* ?/gm, "").trim() ?? "");
62
- process.exit(0);
63
- } else fail(`unknown argument: ${arg}`);
64
- }
65
-
66
- function fail(message) {
67
- console.error(`install-presets: ${message}`);
68
- process.exit(1);
69
- }
70
-
71
- /* ── locate source templates and target home ─────────────────────────────── */
72
-
73
- const sources = readdirSync(scriptDir, { withFileTypes: true })
74
- .filter((entry) => entry.isDirectory())
75
- .map((entry) => join(scriptDir, entry.name))
76
- .filter((dir) => exists(join(dir, "preset.yml")) && exists(join(dir, "agent.cordis.yml")))
77
- .sort();
78
- if (sources.length === 0) fail(`no preset template directories found beside this script (${scriptDir})`);
79
-
80
- const dshHome = resolve(options.home ?? process.env.DSH_HOME ?? join(homedir(), ".dsh"));
81
- const targetRoot = join(dshHome, `.${PRESET_ROOT}`);
82
-
83
- /* ── re-entrant install: per-file copy / up-to-date / skip (+ --force) ───── */
84
-
85
- let skipped = 0;
86
- console.log(`DSH home : ${dshHome}`);
87
- console.log(`Target : ${targetRoot}${options.dryRun ? " (dry-run, nothing written)" : ""}`);
88
- console.log("");
89
-
90
- for (const sourceDir of sources) {
91
- const presetId = sourceDir.slice(scriptDir.length + 1).replaceAll("\\", "/");
92
- const targetDir = join(targetRoot, presetId);
93
- const files = readdirSync(sourceDir).sort();
94
-
95
- mkdirSync(targetDir, { recursive: true });
96
-
97
- for (const file of files) {
98
- const sourcePath = join(sourceDir, file);
99
- const targetPath = join(targetDir, file);
100
- const sourceBytes = readFileSync(sourcePath);
101
-
102
- if (exists(targetPath)) {
103
- const targetBytes = readFileSync(targetPath);
104
- if (sourceBytes.equals(targetBytes)) {
105
- report(presetId, file, "up-to-date");
106
- continue;
107
- }
108
- if (!options.force) {
109
- report(presetId, file, "SKIPPED (local edit preserved; rerun with --force)");
110
- skipped++;
111
- continue;
112
- }
113
- report(presetId, file, "restored (--force)");
114
- if (!options.dryRun) writeFileSync(targetPath, sourceBytes);
115
- continue;
116
- }
117
- report(presetId, file, "installed");
118
- if (!options.dryRun) writeFileSync(targetPath, sourceBytes);
119
- }
120
- }
121
-
122
- console.log("");
123
- if (skipped > 0) {
124
- console.log(`${skipped} file(s) skipped: local edits differ from the packaged templates.`);
125
- console.log("Rerun with --force to overwrite them with the canonical copies.");
126
- process.exit(1);
127
- }
128
- console.log("All presets installed or already up-to-date.");
129
-
130
- /* ── helpers ─────────────────────────────────────────────────────────────── */
131
-
132
- function exists(path) {
133
- try {
134
- readFileSync(path);
135
- return true;
136
- } catch {
137
- return false;
138
- }
139
- }
140
-
141
- function report(presetId, file, action) {
142
- console.log(` ${presetId}/${file}: ${action}`);
143
- }
@@ -1,42 +0,0 @@
1
- {
2
- "name": "@xiaoso/dsh-tool-plus-presets",
3
- "version": "0.1.8",
4
- "description": "RETIRED (2026-09-20): the preset templates now ship inside @xiaoso/dsh-tool-plus and are installed automatically on first start. This package no longer receives new versions. Do not install it separately.",
5
- "license": "MIT",
6
- "keywords": [
7
- "deepseek-harness",
8
- "dsh",
9
- "dsh-plugin",
10
- "agent-preset",
11
- "preset-installer",
12
- "cli",
13
- "coding-agent",
14
- "agent-tools"
15
- ],
16
- "repository": {
17
- "type": "git",
18
- "url": "git+https://github.com/xiaoso456/dsh-tool-plus.git",
19
- "directory": "presets"
20
- },
21
- "homepage": "https://github.com/xiaoso456/dsh-tool-plus#readme",
22
- "bugs": {
23
- "url": "https://github.com/xiaoso456/dsh-tool-plus/issues"
24
- },
25
- "type": "module",
26
- "private": true,
27
- "publishConfig": {
28
- "access": "public",
29
- "tag": "deprecated-do-not-publish"
30
- },
31
- "bin": {
32
- "dsh-tool-plus-presets": "./install-presets.mjs"
33
- },
34
- "files": [
35
- "install-presets.mjs",
36
- "tool-plus-standard",
37
- "tool-plus-ptc"
38
- ],
39
- "engines": {
40
- "node": ">=20"
41
- }
42
- }