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

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 +377 -906
  5. package/lib/index.mjs +885 -1087
  6. package/lib/{scrapers-mhvFrvjH.mjs → scrapers-DSArdJ6N.mjs} +1 -1
  7. package/lib/types/client/ToolPlusSection.d.ts +3 -3
  8. package/lib/types/client/forms.d.ts +6 -6
  9. package/lib/types/client/index.d.ts +29 -12
  10. package/lib/types/client/locales.d.ts +1 -1
  11. package/lib/types/client/preset-panel.d.ts +54 -42
  12. package/lib/types/config/settings.d.ts +202 -21
  13. package/lib/types/host/browser-probe-rpc.d.ts +2 -1
  14. package/lib/types/host/preset-host.d.ts +103 -0
  15. package/lib/types/host/preset-rpc.d.ts +37 -72
  16. package/lib/types/presets/compare.d.ts +14 -37
  17. package/lib/types/presets/conflicts.d.ts +59 -0
  18. package/lib/types/presets/delta.d.ts +23 -18
  19. package/lib/types/presets/plan.d.ts +55 -0
  20. package/lib/types/presets/rows.d.ts +84 -0
  21. package/lib/types/presets/status.d.ts +56 -47
  22. package/lib/types/tools/bash/background.d.ts +20 -5
  23. package/lib/types/tools/bash/streaming-output.d.ts +4 -2
  24. package/lib/types/tools/shared/browser-rpc-channel.d.ts +84 -42
  25. package/lib/types/web/client/labels.d.ts +1 -1
  26. package/lib/types/web/client/row-utils.d.ts +26 -1
  27. package/lib/{utils-eiUz9n8I.mjs → utils-DA8R1_Q8.mjs} +1 -1
  28. package/package.json +166 -151
  29. package/presets/tool-plus-ptc.patch.yml +164 -0
  30. package/presets/tool-plus-standard.patch.yml +158 -0
  31. package/lib/types/client/BashPlusCard.d.ts +0 -53
  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
@@ -1,53 +0,0 @@
1
- /**
2
- * The tool-plus settings card — a collapsible disclosure card in the Plugins
3
- * settings tab styled against the app's `--dsw-alias-*` design tokens and the
4
- * official card interaction (header button with unsaved badge + rotating
5
- * chevron, smooth expand/collapse respecting reduced-motion, staged edits that
6
- * survive collapsing, one Save write, nothing rendered while the namespace is
7
- * unavailable). Copy is fully localized through the slot-injected `t` seat
8
- * (`locale: 'tool-plus'`), which re-renders on a locale switch.
9
- *
10
- * The card edits the FLAT settings surface (OMP `bash*`-style scalar keys) —
11
- * the client scope only writes scalar fields — grouped as timeouts,
12
- * backgrounding, output, completion truncation (subdivided into byte and line
13
- * settings), and behavior. Field definitions, defaults, and copy keys come
14
- * from the single-source field table (`src/config/fields.ts`), shared with
15
- * the Tool Plus settings section.
16
- * @module @xiaoso/dsh-tool-plus/client
17
- */
18
- import { type ReactNode } from 'react';
19
- import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
20
- import type { SettingsScope } from '@deepseek-ai/dsh-client-ui-settings/client';
21
- import type { OutputRetentionMode, OutputTruncateStrategy } from '../config/settings.ts';
22
- /** The flat, scalar-editable fields this card edits (mirrors the settings schema). */
23
- export interface BashPlusSettings {
24
- enableRunInBackground?: boolean;
25
- autoBackgroundMs?: number;
26
- defaultTimeoutMs?: number;
27
- maxTimeoutMs?: number;
28
- outputMaxBytes?: number;
29
- outputSinkTailBytes?: number;
30
- outputSinkHeadBytes?: number;
31
- minimizerEnabled?: boolean;
32
- interceptorEnabled?: boolean;
33
- nonInteractiveEnv?: boolean;
34
- snapshotEnabled?: boolean;
35
- useShellCommandWrapper?: boolean;
36
- maxBackgroundJobs?: number;
37
- outputTruncateStrategy?: OutputTruncateStrategy;
38
- outputTruncateTriggerBytes?: number;
39
- outputTruncateTriggerLines?: number;
40
- outputTruncateByteMode?: OutputRetentionMode;
41
- outputTruncateByteHeadBytes?: number;
42
- outputTruncateByteTailBytes?: number;
43
- outputTruncateLineMode?: OutputRetentionMode;
44
- outputTruncateLineHeadLines?: number;
45
- outputTruncateLineTailLines?: number;
46
- }
47
- /** Business face the slot registration injects: the bound scope. */
48
- export interface BashPlusCardFace {
49
- scope: SettingsScope<BashPlusSettings>;
50
- }
51
- /** Props the renderer binds: runtime seat, the `t` locale seat, and the scope face. */
52
- export type BashPlusCardProps = PropsRuntime<'settings.plugin.item'> & PropsLocale<'tool-plus'> & BashPlusCardFace;
53
- export declare function BashPlusCard(props: BashPlusCardProps): ReactNode;
@@ -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
- }