@jayyuen66/dsh-plugin-shared 0.2.3 → 0.2.4
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.
- package/README.md +20 -15
- package/README.zh-CN.md +20 -15
- package/dist/build/build-client.js +1 -1
- package/dist/build/build-host.js +1 -1
- package/dist/card-ui-C1lrHILm.js +105 -0
- package/dist/card-ui.js +1 -105
- package/dist/client-entry.js +1 -0
- package/dist/client.js +994 -0
- package/dist/config/vitest.base.js +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin.js +1 -0
- package/dist/tool-events.js +1 -1
- package/dist/types/client-entry.d.ts +10 -0
- package/dist/types/tool-events.d.ts +21 -0
- package/package.json +53 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineConfig as e}from"vitest/config";const t={provider:`v8`,exclude:[`test/**`,`node_modules/**`,`**/test/**`,`**/node_modules/**`,`build-client*`,`client.js`,`agents/**`,`scripts/**`,`**/*.d.ts`,`**/*.d.mts`],reporter:[`text`,`json-summary`,`json`],reportsDirectory:`coverage`,thresholds:{lines:100,statements:100,functions:100,branches:100}};function n(n){let{coverageInclude:r,coverage:i,test:a}=n;if(r.length===0||r.some(e=>e.trim().length===0))throw Error(`coverageInclude 不能为空数组,也不能含空串:统计范围缺件后覆盖率阈值照样全部通过,缺的是测量对象不是覆盖。`);if(a&&`coverage`in a)throw Error(`test.coverage 会整块替换公共覆盖率配置(含四项 100% 阈值与排除表);覆盖率覆盖项请走 coverage 参数,逐键合并。`);return e({test:{include:[`test/**/*.{test,spec}.{ts,tsx,mts,cts}`],environment:`node`,testTimeout:2e4,coverage:{...t,...i,include:r,thresholds:{...t.thresholds,...i?.thresholds}},...a}})}export{n as definePackageConfig};
|
|
1
|
+
import{defineConfig as e}from"vitest/config";const t={provider:`v8`,exclude:[`test/**`,`node_modules/**`,`**/test/**`,`**/node_modules/**`,`build-client*`,`client.js`,`agents/**`,`scripts/**`,`**/*.d.ts`,`**/*.d.mts`],reporter:[`text`,`json-summary`,`json`],reportsDirectory:`coverage`,thresholds:{lines:100,statements:100,functions:100,branches:100}};function n(n){let{coverageInclude:r,coverage:i,test:a}=n;if(r.length===0||r.some(e=>e.trim().length===0))throw Error(`coverageInclude 不能为空数组,也不能含空串:统计范围缺件后覆盖率阈值照样全部通过,缺的是测量对象不是覆盖。`);if(a&&`coverage`in a)throw Error(`test.coverage 会整块替换公共覆盖率配置(含四项 100% 阈值与排除表);覆盖率覆盖项请走 coverage 参数,逐键合并。`);return e({resolve:{alias:{"@jayyuen66/dsh-plugin-shared/client":`@jayyuen66/dsh-plugin-shared/client-node`}},test:{include:[`test/**/*.{test,spec}.{ts,tsx,mts,cts}`],environment:`node`,testTimeout:2e4,coverage:{...t,...i,include:r,thresholds:{...t.thresholds,...i?.thresholds}},...a}})}export{n as definePackageConfig};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{applyPatchTargetsOf as e,editPathOf as t,editPathsOf as n,scanToolEvents as r,toolEventRowsOf as i}from"./tool-events.js";import{claimApply as a}from"./card-apply.js";import{diffTouched as o}from"./card-diff.js";import{deriveProjectKey as s}from"./project-key.js";import{DEFAULT_LOCALE as c,LOCALE_PREFERENCE_FIELD as l,LOCALE_SETTINGS_NAMESPACE as u,messagesFor as d,resolveLocale as f,resolveLocalePreference as p}from"./locale.js";import{settleLessonCall as m}from"./lesson-bus.js";import{truncateEnd as h,truncateStart as g}from"./text.js";import{fieldOf as _,hasMethods as v,isRecord as y}from"./record.js";import{errorText as b,isSettingsConflict as x}from"./errors.js";import{shrinkJsonlTail as S}from"./jsonl.js";import{jobOutcomeOf as C,killProc as w}from"./job-outcome.js";export{c as DEFAULT_LOCALE,l as LOCALE_PREFERENCE_FIELD,u as LOCALE_SETTINGS_NAMESPACE,e as applyPatchTargetsOf,a as claimApply,s as deriveProjectKey,o as diffTouched,t as editPathOf,n as editPathsOf,b as errorText,_ as fieldOf,v as hasMethods,y as isRecord,x as isSettingsConflict,C as jobOutcomeOf,w as killProc,d as messagesFor,f as resolveLocale,p as resolveLocalePreference,r as scanToolEvents,m as settleLessonCall,S as shrinkJsonlTail,i as toolEventRowsOf,h as truncateEnd,g as truncateStart};
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fieldOf as e,hasMethods as t,isRecord as n}from"./record.js";import{applyPatchTargetsOf as r,editPathOf as i,editPathsOf as a,scanToolEvents as o,toolEventRowsOf as s}from"./tool-events.js";import{claimApply as c}from"./card-apply.js";import{diffTouched as l}from"./card-diff.js";import{deriveProjectKey as u}from"./project-key.js";import{DEFAULT_LOCALE as d,LOCALE_PREFERENCE_FIELD as f,LOCALE_SETTINGS_NAMESPACE as p,messagesFor as m,resolveLocale as h,resolveLocalePreference as g}from"./locale.js";import{settleLessonCall as _}from"./lesson-bus.js";import{truncateEnd as v,truncateStart as y}from"./text.js";import{errorText as b,isSettingsConflict as x}from"./errors.js";import{shrinkJsonlTail as S}from"./jsonl.js";import{jobOutcomeOf as C,killProc as w}from"./job-outcome.js";import"./index.js";const T=`@jayyuen66/dsh-plugin-shared`;function E(){}export{d as DEFAULT_LOCALE,f as LOCALE_PREFERENCE_FIELD,p as LOCALE_SETTINGS_NAMESPACE,E as apply,r as applyPatchTargetsOf,c as claimApply,u as deriveProjectKey,l as diffTouched,i as editPathOf,a as editPathsOf,b as errorText,e as fieldOf,t as hasMethods,n as isRecord,x as isSettingsConflict,C as jobOutcomeOf,w as killProc,m as messagesFor,T as name,h as resolveLocale,g as resolveLocalePreference,o as scanToolEvents,_ as settleLessonCall,S as shrinkJsonlTail,s as toolEventRowsOf,v as truncateEnd,y as truncateStart};
|
package/dist/tool-events.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isRecord as e}from"./record.js";function
|
|
1
|
+
import{isRecord as e}from"./record.js";import{parsePatch as t}from"@deepseek-ai/dsh-fs-patch";function n(t){return e(t)&&t.isError===!0}function r(e){return e===!0}function i(t){return e(t.data)}function a(e){return typeof e==`string`&&e.length>0?e:void 0}function o(e){return typeof e==`string`&&e.length>0?e:void 0}function s(t){if(typeof t==`string`)try{let n=JSON.parse(t);return{arguments:e(n)?n:{},badArguments:!1}}catch{return{arguments:{},badArguments:!0}}return{arguments:e(t)?t:{},badArguments:!1}}function c(e,t){let n;if(!i(e))return n;if(e.type===`tool/call`){let r=o(e.data.name);if(r!==void 0){let i=s(e.data.arguments);n={name:r,callId:a(e.data.callId),arguments:i.arguments,badArguments:i.badArguments,seq:t}}}else if(e.type===`tool/ptc-dispatch-start`){let r=a(e.data.subCallId),i=o(e.data.name);if(r!==void 0&&i!==void 0){let a=s(e.data.arguments);n={name:i,callId:r,arguments:a.arguments,badArguments:a.badArguments,seq:t}}}return n}function l(t,o){let s;if(!i(t))return s;if(t.type===`tool/result`){let r=t.data.message,i=e(r)?r.source:void 0;s={callId:e(i)?a(i.callId):void 0,isError:n(r),seq:o}}else if(t.type===`tool/ptc-dispatch`){let e=a(t.data.subCallId);e!==void 0&&(s={callId:e,isError:r(t.data.isError),seq:o})}return s}function u(e,t){return{call:c(e,t),result:l(e,t)}}function d(t){let n=[],r=[];for(let[i,a]of t.entries())if(e(a)){let{call:e,result:t}=u(a,i);e!==void 0&&n.push(e),t!==void 0&&r.push(t)}return{calls:n,results:r}}function f(e,t){let n=e[t];return typeof n==`string`?n:void 0}function p(e){let n=e?.input;if(typeof n!=`string`||!n.includes(`*** Begin Patch`))return[];try{return t(n).map(e=>e.kind===`update`?e.moveTo===void 0?{kind:`update`,path:e.path}:{kind:`update`,path:e.path,moveTo:e.moveTo}:{kind:e.kind,path:e.path})}catch{return[]}}function m(e){let t=e.arguments;return e.name===`apply_patch`?{kind:`write`,path:p(t)[0]?.path}:e.name===`str_replace_editor`?t.command===`view`?{kind:`read-view`,path:f(t,`path`)}:{kind:`write`,path:f(t,`path`)}:{kind:`write`,path:f(t,`file_path`)}}function h(e){if(e.name===`apply_patch`){let t=p(e.arguments).flatMap(e=>e.kind===`update`&&e.moveTo!==void 0?[e.path,e.moveTo]:[e.path]);return t.filter((e,n)=>e.length>0&&t.indexOf(e)===n)}let t=m(e);return t.kind===`write`&&t.path!==void 0?[t.path]:[]}export{p as applyPatchTargetsOf,m as editPathOf,h as editPathsOf,d as scanToolEvents,u as toolEventRowsOf};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const name = "@jayyuen66/dsh-plugin-shared";
|
|
2
|
+
/** 客户端行只提供组件与工具函数;这个入口只让 Cordis 客户端把行当作插件装载。 */
|
|
3
|
+
export declare function apply(): void;
|
|
4
|
+
export { CARD_UI_CSS, CardForm, Field, FieldGrid, FieldLabel, InfoTip, ListField, NumberField, SaveBar, Section, SelectField, StatusBar, TextField, ToggleField, splitHint, } from "./card-ui.js";
|
|
5
|
+
export type { FieldBase, SelectOption } from "./card-ui.js";
|
|
6
|
+
export { diffTouched } from "./card-diff.js";
|
|
7
|
+
export { claimApply } from "./card-apply.js";
|
|
8
|
+
export { fieldOf, isRecord } from "./record.js";
|
|
9
|
+
export { errorText } from "./errors.js";
|
|
10
|
+
export type { MessagesCatalog } from "./locale.js";
|
|
@@ -115,8 +115,29 @@ export type EditTarget = {
|
|
|
115
115
|
readonly kind: "read-view";
|
|
116
116
|
readonly path: string | undefined;
|
|
117
117
|
};
|
|
118
|
+
/**
|
|
119
|
+
* 一条 `apply_patch` 补丁操作的目标。`moveTo` 只出现在 update 上;源路径与目的路径
|
|
120
|
+
* 都是文件效应,调用方需要分别记账。
|
|
121
|
+
*/
|
|
122
|
+
export interface ApplyPatchTarget {
|
|
123
|
+
readonly kind: "add" | "update" | "delete";
|
|
124
|
+
readonly path: string;
|
|
125
|
+
readonly moveTo?: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 从 `apply_patch` 的 `{ input }` 解析有序操作。解析器是官方 `dsh-fs-patch` 的同一份
|
|
129
|
+
* `parsePatch`:host 执行什么语法,这里就认什么,不另写一套会与宿主漂移的补丁文法。
|
|
130
|
+
* 非补丁输入、或宿主解析器拒绝的补丁一律交回空数组;调用方按工具名决定是否 fail-closed。
|
|
131
|
+
*/
|
|
132
|
+
export declare function applyPatchTargetsOf(args: Record<string, unknown> | undefined | null): readonly ApplyPatchTarget[];
|
|
118
133
|
/**
|
|
119
134
|
* 由 tool/call 记录推导被编辑的文件路径;str_replace_editor 的 view 只读不算写。
|
|
135
|
+
* `apply_patch` 取第一条操作路径,多目标调用请走 {@link editPathsOf}。
|
|
120
136
|
* @returns `write` = 写操作;`read-view` = 只读视图。取不到路径时 `path` 为 `undefined`。
|
|
121
137
|
*/
|
|
122
138
|
export declare function editPathOf(call: ToolCallRecord): EditTarget;
|
|
139
|
+
/**
|
|
140
|
+
* 一次 tool/call 的全部写目标(去重、保持补丁顺序)。`apply_patch` 的 move 同时交回
|
|
141
|
+
* 源路径与目的路径:前者被删除、后者被创建,两处都必须能被下游看见。
|
|
142
|
+
*/
|
|
143
|
+
export declare function editPathsOf(call: ToolCallRecord): readonly string[];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jayyuen66/dsh-plugin-shared",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "dsh 自研插件的共享工具库:tool 事件流记账扫描 + 卡片 apply/差异骨架 + 统一设置卡 UI 组件 + 官方作业结局映射 + 项目键派生 +
|
|
3
|
+
"version": "0.2.4",
|
|
4
|
+
"description": "dsh 自研插件的共享工具库:tool 事件流记账扫描 + 卡片 apply/差异骨架 + 统一设置卡 UI 组件 + 官方作业结局映射 + 项目键派生 + 代理对安全截断。宿主半由各插件 import;客户端半以 ./client 共享行由插件 patch 启用,不由用户单独停用",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cordis",
|
|
7
7
|
"dsh",
|
|
@@ -27,12 +27,22 @@
|
|
|
27
27
|
],
|
|
28
28
|
"type": "module",
|
|
29
29
|
"sideEffects": false,
|
|
30
|
-
"main": "./dist/
|
|
30
|
+
"main": "./dist/plugin.js",
|
|
31
31
|
"types": "./dist/index.d.ts",
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
34
34
|
"types": "./dist/index.d.ts",
|
|
35
|
-
"default": "./dist/
|
|
35
|
+
"default": "./dist/plugin.js"
|
|
36
|
+
},
|
|
37
|
+
"./client": {
|
|
38
|
+
"types": "./dist/types/client-entry.d.ts",
|
|
39
|
+
"node": "./dist/client-entry.js",
|
|
40
|
+
"import": "./dist/client-entry.js",
|
|
41
|
+
"default": "./dist/client.js"
|
|
42
|
+
},
|
|
43
|
+
"./client-node": {
|
|
44
|
+
"types": "./dist/types/client-entry.d.ts",
|
|
45
|
+
"default": "./dist/client-entry.js"
|
|
36
46
|
},
|
|
37
47
|
"./lib/tool-events": {
|
|
38
48
|
"types": "./dist/types/tool-events.d.ts",
|
|
@@ -118,48 +128,51 @@
|
|
|
118
128
|
"access": "public",
|
|
119
129
|
"registry": "https://registry.npmjs.org"
|
|
120
130
|
},
|
|
131
|
+
"dependencies": {
|
|
132
|
+
"@deepseek-ai/dsh-fs-patch": "0.2.2-rc.1"
|
|
133
|
+
},
|
|
121
134
|
"devDependencies": {
|
|
122
|
-
"@deepseek-ai/cordis": "4.0
|
|
123
|
-
"@deepseek-ai/dsh-brand": "0.2.2-
|
|
124
|
-
"@deepseek-ai/dsh-client-locale": "0.2.2-
|
|
125
|
-
"@deepseek-ai/dsh-jobs": "0.2.2-
|
|
126
|
-
"@deepseek-ai/dsh-llm": "0.2.2-
|
|
127
|
-
"@deepseek-ai/dsh-output-retention": "0.2.2-
|
|
128
|
-
"@deepseek-ai/dsh-scope": "0.2.2-
|
|
129
|
-
"@deepseek-ai/dsh-session": "0.2.2-
|
|
130
|
-
"@deepseek-ai/dsh-shell": "0.2.2-
|
|
131
|
-
"@deepseek-ai/dsh-tool-executor-ptc": "0.2.2-
|
|
132
|
-
"@deepseek-ai/dsh-tools": "0.2.2-
|
|
133
|
-
"@deepseek-ai/dsh-util-values": "0.2.2-
|
|
135
|
+
"@deepseek-ai/cordis": "4.1.0",
|
|
136
|
+
"@deepseek-ai/dsh-brand": "0.2.2-rc.1",
|
|
137
|
+
"@deepseek-ai/dsh-client-locale": "0.2.2-rc.1",
|
|
138
|
+
"@deepseek-ai/dsh-jobs": "0.2.2-rc.1",
|
|
139
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.1",
|
|
140
|
+
"@deepseek-ai/dsh-output-retention": "0.2.2-rc.1",
|
|
141
|
+
"@deepseek-ai/dsh-scope": "0.2.2-rc.1",
|
|
142
|
+
"@deepseek-ai/dsh-session": "0.2.2-rc.1",
|
|
143
|
+
"@deepseek-ai/dsh-shell": "0.2.2-rc.1",
|
|
144
|
+
"@deepseek-ai/dsh-tool-executor-ptc": "0.2.2-rc.1",
|
|
145
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.1",
|
|
146
|
+
"@deepseek-ai/dsh-util-values": "0.2.2-rc.1",
|
|
134
147
|
"@e18e/eslint-plugin": "0.8.1",
|
|
135
148
|
"@types/node": "26.6.6",
|
|
136
149
|
"@types/react": "19.3.0",
|
|
137
150
|
"@types/react-dom": "19.3.0",
|
|
138
|
-
"@vitest/coverage-v8": "5.0
|
|
139
|
-
"eslint-plugin-regexp": "3.3.
|
|
151
|
+
"@vitest/coverage-v8": "5.1.0",
|
|
152
|
+
"eslint-plugin-regexp": "3.3.3",
|
|
140
153
|
"eslint-plugin-sonarjs": "4.2.2",
|
|
141
154
|
"eslint-plugin-zod": "5.2.2",
|
|
142
155
|
"fast-check": "4.10.2",
|
|
143
156
|
"happy-dom": "21.0.4",
|
|
144
|
-
"oxfmt": "0.
|
|
145
|
-
"oxlint": "1.
|
|
157
|
+
"oxfmt": "0.76.0",
|
|
158
|
+
"oxlint": "1.91.0",
|
|
146
159
|
"oxlint-tsgolint": "7.0.2005",
|
|
147
160
|
"react": "^19.3.0",
|
|
148
161
|
"react-dom": "^19.3.1",
|
|
149
|
-
"rolldown": "1.2.
|
|
162
|
+
"rolldown": "1.2.16",
|
|
150
163
|
"typescript": "7.0.2",
|
|
151
|
-
"vite": "8.3.
|
|
152
|
-
"vitest": "5.0
|
|
164
|
+
"vite": "8.3.6",
|
|
165
|
+
"vitest": "5.1.0"
|
|
153
166
|
},
|
|
154
167
|
"peerDependencies": {
|
|
155
168
|
"@deepseek-ai/cordis": "^4.0.5||^4.0.6-alpha.1",
|
|
156
|
-
"@deepseek-ai/dsh": "^0.2.1-rc.
|
|
157
|
-
"@deepseek-ai/dsh-client-locale": "^0.2.1-rc.
|
|
158
|
-
"@deepseek-ai/dsh-jobs": "^0.2.1-rc.
|
|
159
|
-
"@deepseek-ai/dsh-output-retention": "^0.2.1-rc.
|
|
160
|
-
"@deepseek-ai/dsh-session": "^0.2.1-rc.
|
|
161
|
-
"@deepseek-ai/dsh-shell": "^0.2.1-rc.
|
|
162
|
-
"@deepseek-ai/dsh-tools": "^0.2.1-rc.
|
|
169
|
+
"@deepseek-ai/dsh": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
|
|
170
|
+
"@deepseek-ai/dsh-client-locale": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
|
|
171
|
+
"@deepseek-ai/dsh-jobs": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
|
|
172
|
+
"@deepseek-ai/dsh-output-retention": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
|
|
173
|
+
"@deepseek-ai/dsh-session": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
|
|
174
|
+
"@deepseek-ai/dsh-shell": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
|
|
175
|
+
"@deepseek-ai/dsh-tools": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
|
|
163
176
|
"react": "^19.3.0"
|
|
164
177
|
},
|
|
165
178
|
"peerDependenciesMeta": {
|
|
@@ -193,12 +206,19 @@
|
|
|
193
206
|
},
|
|
194
207
|
"icon": "icon.svg",
|
|
195
208
|
"engines": {
|
|
196
|
-
"dsh": "^0.2.1-rc.
|
|
197
|
-
"node": ">=
|
|
209
|
+
"dsh": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
|
|
210
|
+
"node": ">=24.9.0"
|
|
211
|
+
},
|
|
212
|
+
"dsh": {
|
|
213
|
+
"client": {
|
|
214
|
+
"platform": "web",
|
|
215
|
+
"immediately": true
|
|
216
|
+
}
|
|
198
217
|
},
|
|
199
218
|
"scripts": {
|
|
200
219
|
"prebuild": "node build-clean.mjs",
|
|
201
|
-
"build": "node build-host.mjs && node build-config.mjs && tsc -p tsconfig.build.json && tsc -p tsconfig.build.config.json && node build-types-check.mjs",
|
|
220
|
+
"build": "node build-host.mjs && node build-config.mjs && tsc -p tsconfig.build.json && tsc -p tsconfig.build.config.json && node build-types-check.mjs && node build-client.mjs",
|
|
221
|
+
"build:client": "node build-client.mjs",
|
|
202
222
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
203
223
|
"lint": "oxlint .",
|
|
204
224
|
"test": "vitest run --coverage",
|