@jayyuen66/dsh-plugin-shared 0.1.9 → 0.2.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 (39) hide show
  1. package/README.md +73 -66
  2. package/README.zh-CN.md +98 -91
  3. package/config/tsconfig.client.base.json +1 -1
  4. package/dist/build/build-client.js +2 -2
  5. package/dist/build/build-host.js +1 -1
  6. package/dist/build/canonicalize-region-paths-DowoRhQK.js +1 -0
  7. package/dist/canonicalize-region-paths.js +1 -1
  8. package/dist/card-ui.js +105 -0
  9. package/dist/config/oxlint.base.js +1 -1
  10. package/dist/config/vitest.base.js +1 -1
  11. package/dist/jsonl.js +3 -3
  12. package/dist/project-key.js +1 -1
  13. package/dist/types/build-artifacts.d.ts +11 -11
  14. package/dist/types/build-client.d.ts +20 -20
  15. package/dist/types/build-host.d.ts +4 -4
  16. package/dist/types/build-types.d.ts +4 -4
  17. package/dist/types/canonicalize-region-paths.d.ts +1 -1
  18. package/dist/types/card-apply.d.ts +9 -9
  19. package/dist/types/card-ui/field.d.ts +33 -0
  20. package/dist/types/card-ui/hint.d.ts +11 -0
  21. package/dist/types/card-ui/inputs.d.ts +33 -0
  22. package/dist/types/card-ui/layout.d.ts +19 -0
  23. package/dist/types/card-ui/save-bar.d.ts +16 -0
  24. package/dist/types/card-ui/select.d.ts +15 -0
  25. package/dist/types/card-ui/styles.d.ts +2 -0
  26. package/dist/types/card-ui.d.ts +10 -0
  27. package/dist/types/config/oxlint.base.d.ts +118 -38
  28. package/dist/types/config/vitest.base.d.ts +3 -3
  29. package/dist/types/errors.d.ts +6 -6
  30. package/dist/types/job-outcome.d.ts +12 -12
  31. package/dist/types/jsonl.d.ts +6 -6
  32. package/dist/types/lesson-bus.d.ts +2 -2
  33. package/dist/types/locale.d.ts +9 -9
  34. package/dist/types/project-key.d.ts +6 -5
  35. package/dist/types/record.d.ts +16 -16
  36. package/dist/types/text.d.ts +4 -4
  37. package/dist/types/tool-events.d.ts +50 -21
  38. package/package.json +41 -22
  39. package/dist/build/canonicalize-region-paths-BxladpX3.js +0 -1
@@ -1,29 +1,58 @@
1
1
  import type { SessionEvent } from "@deepseek-ai/dsh-session";
2
+ import type { ToolCallId } from "@deepseek-ai/dsh-llm/brand";
3
+ import type { ContentBlock } from "@deepseek-ai/dsh-llm/types";
4
+ import type { JsonValue } from "@deepseek-ai/dsh-util-values";
2
5
  export type { SessionEvent } from "@deepseek-ai/dsh-session";
3
- export type { PtcDispatchEventData, PtcDispatchStartEventData } from "@deepseek-ai/dsh-tools/types";
6
+ /** 一枚 PTC 子调度**开始**时记下的载荷。字段与宿主声明逐位同形,理由见文件头。 */
7
+ export interface PtcDispatchStartEventData {
8
+ rootCallId: ToolCallId;
9
+ parentCallId: ToolCallId;
10
+ subCallId: ToolCallId;
11
+ name: string;
12
+ arguments: unknown;
13
+ }
14
+ /** 一枚 PTC 子调度**结算**时记下的载荷:结算面沿用 `tool/result` 自己的词表。 */
15
+ export interface PtcDispatchEventData extends PtcDispatchStartEventData {
16
+ isError: boolean;
17
+ content: ContentBlock[];
18
+ /** 可重放的工具侧呈现元数据,与模型可见内容分开记账。 */
19
+ meta?: JsonValue;
20
+ /** 可选的失败身份与原始用户可见细节,不在模型可见内容里。 */
21
+ error?: {
22
+ name: string;
23
+ code: string;
24
+ reason?: string;
25
+ };
26
+ }
27
+ declare module "@deepseek-ai/dsh-session/types" {
28
+ interface SessionEventMap {
29
+ "tool/ptc-dispatch-start": PtcDispatchStartEventData;
30
+ "tool/ptc-dispatch": PtcDispatchEventData;
31
+ }
32
+ }
4
33
  /**
5
- * 一条 tool/call 的记账记录。
34
+ * 一条 tool/call 的记录。
6
35
  *
7
- * 字段一律 `readonly`:台账一旦入表就只作证据读,账目被就地改写会让证据链失去意义。
36
+ * 字段一律 `readonly`:记录一旦入表就只作证据读,记录被就地改写会让证据链失去意义。
8
37
  */
9
38
  export interface ToolCallRecord {
10
39
  /**
11
- * 调用名(edit/write/str_replace_editor/read/grep/…)——本模块的**分桶键**,必选。
40
+ * 调用名(edit/write/str_replace_editor/read/grep/…)——本模块的**分组键**,必选。
12
41
  *
13
42
  * 官方把它声明成必选 `string`(`tool/call` 见 packages/core/session/src/types.ts:361,
14
43
  * PtcDispatchStartEventData.name 见 packages/core/tools/src/types.ts:15),但运行期拦不住
15
- * (依据见 usableName)。所以可空性在**扫描层**就处理掉了,不带到类型面:callRecordOf 遇到
16
- * 缺可用 name 的调用类事件整条跳过,与 hasObjectData 同一口径。
44
+ * (依据见 usableName)。所以可空性在**扫描层**就处理掉了,不带到类型声明:callRecordOf 遇到
45
+ * 缺可用 name 的调用类事件整条跳过,与 hasObjectData 同一规则。
17
46
  *
18
47
  * 为什么不把过滤留给消费方:下游分类全建立在 name 上——editPathOf 的 str_replace_editor
19
- * 只读判定、门禁侧的 EDIT_TOOLS 与 refSearchTools 名单——而 editPathOf 的兜底分支会把任何
20
- * 非 str_replace_editor 的调用一律判成 write。无名调用一旦进了台账,只要它的 arguments
48
+ * 只读判定、检查侧的 EDIT_TOOLS 与 refSearchTools 名单——而 editPathOf 的回退分支会把任何
49
+ * 非 str_replace_editor 的调用一律判成 write。无名调用一旦进了记录,只要它的 arguments
21
50
  * 里有 file_path 就算成写操作。现在是靠三个消费方各自记得先判一次才没出事——那是同一条
22
51
  * 不变式的三份手抄,漏一份就出事。
23
52
  *
24
- * 与 callId 的差别是**为什么一个必选、一个可空**:callId 由 usableCallId 兜底,且它有
25
- * nc:<seq> 兜底席位(消费方的 noCallId 桶专门收那种行),缺了不影响归类;name 一旦缺了
26
- * 就没法分桶、没有兜底席位,只能在入口滤掉。
53
+ * 与 callId 的差别是**为什么一个必选、一个可空**:callId 由 usableCallId 回退,且它有
54
+ * `nc:<seq>` 回退值(消费方的 noCallId 组专门收那种行),缺了不影响归类;name 一旦缺了
55
+ * 就没法分组、没有回退值,只能在入口滤掉。
27
56
  */
28
57
  readonly name: string;
29
58
  /** callId:tool/result 串联键;缺失时由调用方按 seq 造 `nc:` 键。 */
@@ -32,8 +61,8 @@ export interface ToolCallRecord {
32
61
  readonly arguments: Record<string, unknown>;
33
62
  /**
34
63
  * arguments 原始值无法解析为对象(JSON 字符串非法、或非字符串非对象)。
35
- * 调用方据此保留各自语义——有的把坏参判成"这次编辑不记账",有的仍记账但路径留空。
36
- * 共享层只标记不决策:把两档策略统一掉,等于在其中一侧悄悄改掉门禁的松紧。
64
+ * 调用方据此保留各自语义——有的把无效参数判成"这次编辑不入记录",有的仍记录但路径留空。
65
+ * 共享层只标记不决策:把两档策略统一掉,等于在其中一侧悄悄改掉检查的宽严。
37
66
  */
38
67
  readonly badArguments: boolean;
39
68
  /**
@@ -48,24 +77,24 @@ export interface ToolResultRecord {
48
77
  readonly isError: boolean;
49
78
  readonly seq: number;
50
79
  }
51
- /** 一条事件产出的记账行(call 与 result 互斥;非记账事件两位都是 undefined)。 */
80
+ /** 一条事件产出的记录行(call 与 result 互斥;非记录事件两位都是 undefined)。 */
52
81
  export interface ToolEventRows {
53
82
  readonly call: ToolCallRecord | undefined;
54
83
  readonly result: ToolResultRecord | undefined;
55
84
  }
56
85
  /**
57
- * **单条事件**的记账行(`scanToolEvents` 的一步,也是它唯一的实现处)。
86
+ * **单条事件**的记录行(`scanToolEvents` 的一步,也是它唯一的实现处)。
58
87
  *
59
- * 之所以导出:有的消费方要把同一套台账折成投影单元(增量折叠),折叠与"注册表缺席时的全量
60
- * 扫描"必须逐字同源——两处各写一遍字段读取,就会在两行上给出不同的证据链(那是安全门禁的
88
+ * 之所以导出:有的消费方要把同一套记录折成投影单元(增量折叠),折叠与"注册表缺席时的全量
89
+ * 扫描"必须逐字同源——两处各写一遍字段读取,就会在两行上给出不同的证据链(那是安全检查的
61
90
  * fail-open)。折叠侧传 `event.seq`,扫描侧传数组下标,两者在官方 `seq = log.length` 的连号
62
- * 契约下是同一个值。
91
+ * 约定下是同一个值。
63
92
  */
64
93
  export declare function toolEventRowsOf(event: SessionEvent, index: number): ToolEventRows;
65
94
  /**
66
95
  * 扫描事件流 → tool/call 与 tool/result 两张表。
67
- * 只收集形状可用的事件,其余静默跳过——调用方(门禁/证据链)以空表安全降级,不因零星
68
- * 坏事件抛错。数组空洞(类型面不可表示、重放数据里却可能出现)同样跳过。
96
+ * 只收集形状可用的事件,其余静默跳过——调用方(检查/证据链)以空表安全回退,不因零星
97
+ * 坏事件抛错。数组空洞(类型声明不可表示、重放数据里却可能出现)同样跳过。
69
98
  * seq 取事件在入参数组里的下标(与折叠侧按 seq 归因的语义同一个值)。
70
99
  */
71
100
  export declare function scanToolEvents(events: readonly SessionEvent[]): {
@@ -76,7 +105,7 @@ export declare function scanToolEvents(events: readonly SessionEvent[]): {
76
105
  * {@link editPathOf} 的返回值。按 `kind` 判别联合。
77
106
  *
78
107
  * 只有两支:**`write` / `read-view`**。取不到路径时仍返回所属那一支、只把 `path` 置为
79
- * `undefined`——判据是工具名与 `command`,与路径取不取得到无关;再多一枚 `skip` 只会逼
108
+ * `undefined`——判断依据是工具名与 `command`,与路径取不取得到无关;再多一个 `skip` 只会逼
80
109
  * 调用方写出永不执行的分支。路径有没有由 `path === undefined` 表达。
81
110
  */
82
111
  export type EditTarget = {
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@jayyuen66/dsh-plugin-shared",
3
- "version": "0.1.9",
4
- "description": "dsh 自研插件的共享工具库:tool 事件流记账扫描 + 卡片 apply/差异骨架 + 官方作业结局映射 + 项目键派生 + 代理对安全截断。作为库包被 import,不由用户启用",
3
+ "version": "0.2.1",
4
+ "description": "dsh 自研插件的共享工具库:tool 事件流记账扫描 + 卡片 apply/差异骨架 + 统一设置卡 UI 组件 + 官方作业结局映射 + 项目键派生 + 代理对安全截断。作为库包被 import,不由用户启用",
5
5
  "keywords": [
6
6
  "cordis",
7
7
  "dsh",
8
8
  "plugin",
9
+ "settings-card",
9
10
  "tool-events"
10
11
  ],
11
12
  "homepage": "https://github.com/JayYuen666/dsh-plugin-shared#readme",
@@ -45,6 +46,10 @@
45
46
  "types": "./dist/types/card-diff.d.ts",
46
47
  "default": "./dist/card-diff.js"
47
48
  },
49
+ "./lib/card-ui": {
50
+ "types": "./dist/types/card-ui.d.ts",
51
+ "default": "./dist/card-ui.js"
52
+ },
48
53
  "./lib/project-key": {
49
54
  "types": "./dist/types/project-key.d.ts",
50
55
  "default": "./dist/project-key.js"
@@ -114,36 +119,47 @@
114
119
  "registry": "https://registry.npmjs.org"
115
120
  },
116
121
  "devDependencies": {
117
- "@deepseek-ai/cordis": "4.0.5",
118
- "@deepseek-ai/dsh-brand": "0.2.1-rc.3",
119
- "@deepseek-ai/dsh-client-locale": "0.2.1-rc.3",
120
- "@deepseek-ai/dsh-jobs": "0.2.1-rc.3",
121
- "@deepseek-ai/dsh-llm": "0.2.1-rc.3",
122
- "@deepseek-ai/dsh-output-retention": "0.2.1-rc.3",
123
- "@deepseek-ai/dsh-scope": "0.2.1-rc.3",
124
- "@deepseek-ai/dsh-session": "0.2.1-rc.3",
125
- "@deepseek-ai/dsh-shell": "0.2.1-rc.3",
126
- "@deepseek-ai/dsh-tools": "0.2.1-rc.3",
127
- "@types/node": "26.6.5",
122
+ "@deepseek-ai/cordis": "4.0.6-alpha.1",
123
+ "@deepseek-ai/dsh-brand": "0.2.2-alpha.2",
124
+ "@deepseek-ai/dsh-client-locale": "0.2.2-alpha.2",
125
+ "@deepseek-ai/dsh-jobs": "0.2.2-alpha.2",
126
+ "@deepseek-ai/dsh-llm": "0.2.2-alpha.2",
127
+ "@deepseek-ai/dsh-output-retention": "0.2.2-alpha.2",
128
+ "@deepseek-ai/dsh-scope": "0.2.2-alpha.2",
129
+ "@deepseek-ai/dsh-session": "0.2.2-alpha.2",
130
+ "@deepseek-ai/dsh-shell": "0.2.2-alpha.2",
131
+ "@deepseek-ai/dsh-tool-executor-ptc": "0.2.2-alpha.2",
132
+ "@deepseek-ai/dsh-tools": "0.2.2-alpha.2",
133
+ "@deepseek-ai/dsh-util-values": "0.2.2-alpha.2",
134
+ "@e18e/eslint-plugin": "0.8.1",
135
+ "@types/node": "26.6.6",
136
+ "@types/react": "19.3.0",
137
+ "@types/react-dom": "19.3.0",
128
138
  "@vitest/coverage-v8": "5.0.5",
139
+ "eslint-plugin-regexp": "3.3.2",
129
140
  "eslint-plugin-sonarjs": "4.2.2",
130
- "oxfmt": "0.74.0",
131
- "oxlint": "1.89.0",
141
+ "eslint-plugin-zod": "5.2.2",
142
+ "happy-dom": "21.0.4",
143
+ "oxfmt": "0.75.0",
144
+ "oxlint": "1.90.0",
132
145
  "oxlint-tsgolint": "7.0.2005",
146
+ "react": "^19.3.0",
147
+ "react-dom": "^19.3.1",
133
148
  "rolldown": "1.2.15",
134
149
  "typescript": "7.0.2",
135
150
  "vite": "8.3.5",
136
151
  "vitest": "5.0.5"
137
152
  },
138
153
  "peerDependencies": {
139
- "@deepseek-ai/cordis": "4.0.5",
154
+ "@deepseek-ai/cordis": "^4.0.5||^4.0.6-alpha.1",
140
155
  "@deepseek-ai/dsh": "^0.2.1-rc.3",
141
- "@deepseek-ai/dsh-client-locale": "0.2.1-rc.3",
142
- "@deepseek-ai/dsh-jobs": "0.2.1-rc.3",
143
- "@deepseek-ai/dsh-output-retention": "0.2.1-rc.3",
144
- "@deepseek-ai/dsh-session": "0.2.1-rc.3",
145
- "@deepseek-ai/dsh-shell": "0.2.1-rc.3",
146
- "@deepseek-ai/dsh-tools": "0.2.1-rc.3"
156
+ "@deepseek-ai/dsh-client-locale": "^0.2.1-rc.3",
157
+ "@deepseek-ai/dsh-jobs": "^0.2.1-rc.3",
158
+ "@deepseek-ai/dsh-output-retention": "^0.2.1-rc.3",
159
+ "@deepseek-ai/dsh-session": "^0.2.1-rc.3",
160
+ "@deepseek-ai/dsh-shell": "^0.2.1-rc.3",
161
+ "@deepseek-ai/dsh-tools": "^0.2.1-rc.3",
162
+ "react": "^19.3.0"
147
163
  },
148
164
  "peerDependenciesMeta": {
149
165
  "@deepseek-ai/cordis": {
@@ -169,6 +185,9 @@
169
185
  },
170
186
  "@deepseek-ai/dsh-tools": {
171
187
  "optional": true
188
+ },
189
+ "react": {
190
+ "optional": true
172
191
  }
173
192
  },
174
193
  "icon": "icon.svg",
@@ -1 +0,0 @@
1
- const e=/^\/\/#region .*$/gmu,t=/^[^\s'"`]+$/u,n=/^(?:\.\.?\/)+/u,r=/[/\\]+/u;function i(e){let t=e.replace(/[/\\]+$/u,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n===-1?t:t.slice(n+1)}function a(e){let t=e.replace(/[/\\]+$/u,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n===-1?t:t.slice(0,n)}function o(e){let t=i(e);return[i(a(e)),t].filter(e=>e.length>0)}function s(e,t){let n=e;for(let e of t)n.startsWith(`${e}/`)&&(n=n.slice(e.length+1));return n}function c(e){return e.split(r)}function l(e){let t=[...e];for(;t.length>1&&t.at(-1)===``;)t.pop();return t}function u(e){return e.startsWith(`/`)||e.startsWith(`\\`)||/^[A-Za-z]:[\\/]/u.test(e)}function d(e,t){let n=u(e);if(n!==u(t))return null;let r=l(c(e)),i=l(c(t));if(n&&r[0]!==i[0])return null;let a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)a+=1;return[...Array.from({length:r.length-a},()=>`..`),...i.slice(a)]}function f(e){if(e===null||e.length===0)return``;let t=0;for(;t<e.length&&e[t]===`..`;)t+=1;return t===e.length?``:e.slice(t).join(`/`)}function p(e,t){return{own:f(d(e,t)),parent:f(d(e,a(t)))}}function m(e,t){return t.own.length>0&&e.startsWith(`${t.own}/`)?e.slice(t.own.length+1):t.parent.length>0&&e.startsWith(`${t.parent}/`)?e.slice(t.parent.length+1):e}function h(e,r,i){let a=e.slice(10);if(!t.test(a))return e;let o=a.replace(n,``);return`//#region ${i===null?s(o,r):m(o,i)}`}function g(t,n,r){let i=o(n);if(r===void 0)return i.length===0?t:t.replaceAll(e,e=>h(e,i,null));let a=p(r,n);return t.replaceAll(e,e=>h(e,i,a))}export{g as t};