@jayyuen66/dsh-dir-prep-organize 0.1.8 → 0.1.10
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/CHANGELOG.md +56 -23
- package/README.md +9 -9
- package/README.zh-CN.md +18 -18
- package/agents/company/chief-financial-officer.md +2 -2
- package/agents/marketing/marketing-agentic-search-optimizer.md +1 -1
- package/agents/sales/sales-discovery-coach.md +4 -4
- package/agents/specialized/zk-steward.md +2 -2
- package/agents/strategy/nexus-strategy.md +1 -1
- package/agents/strategy/playbooks/phase-0-discovery.md +1 -1
- package/agents/strategy/playbooks/phase-1-strategy.md +1 -1
- package/agents/strategy/playbooks/phase-2-foundation.md +1 -1
- package/agents/strategy/playbooks/phase-3-build.md +1 -1
- package/agents/strategy/playbooks/phase-4-hardening.md +1 -1
- package/agents/strategy/playbooks/phase-5-launch.md +1 -1
- package/agents/strategy/playbooks/phase-6-operate.md +1 -1
- package/client.js +75 -63
- package/cordis.patch.yml +1 -1
- package/docs/DETAIL.zh.md +1 -1
- package/host.js +52 -46
- package/package.json +50 -50
- package/templates.data.mjs +1 -1
- package/types/host.d.ts +40 -40
- package/types/src/client-entry.d.ts +2 -2
- package/types/src/client-timeouts.d.ts +2 -2
- package/types/src/host-messages.d.ts +6 -6
- package/types/src/input-writeback.d.ts +4 -4
- package/types/src/remote.d.ts +5 -5
- package/types/src/templates.d.ts +20 -8
- package/types/src/ui-messages.d.ts +9 -9
package/types/host.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare function defaultTemplatesFrom(raw: unknown): readonly TemplateEnt
|
|
|
22
22
|
* 内置精选模板表:按需载入,永不静态导入。
|
|
23
23
|
*
|
|
24
24
|
* 静态导入会让整张精选表随宿主载入插件一起进内存,而它们只有一个消费者——default-templates
|
|
25
|
-
*
|
|
25
|
+
* 读取方法,而客户端本来就是首次打开下拉时才拉这一发。两边都按需,才是同一件事的同一种做法。
|
|
26
26
|
*
|
|
27
27
|
* @param load - 载入器,缺省即真实 import 产物;单测靠它把「首读失败」那一档做成可复跑
|
|
28
28
|
* 的判据(产物 URL 一旦被成功加载就进 ESM 缓存,改磁盘内容对后续 import 无效,所以失败路径
|
|
@@ -43,11 +43,11 @@ export declare function loadDefaultTemplates(load?: () => Promise<readonly Templ
|
|
|
43
43
|
* @returns `[min, max]` 区间内的整数
|
|
44
44
|
*/
|
|
45
45
|
export declare function clampInt(value: number, min: number, max: number, fallback: number): number;
|
|
46
|
-
/** 目标的官方形状直接 re-export(`targetKey`
|
|
46
|
+
/** 目标的官方形状直接 re-export(`targetKey` 就此带官方 `FsTargetKey` 的 `brand`,不再降级成 string)。 */
|
|
47
47
|
export type { FsDirEntry, FsTarget } from "@deepseek-ai/dsh-fs";
|
|
48
48
|
/**
|
|
49
49
|
* 官方 `FileSystem`(installed @deepseek-ai/dsh-fs/lib/types/index.d.ts,cordis `Service`
|
|
50
|
-
* 子类 →
|
|
50
|
+
* 子类 → 名义比较)的方法子集投影:本包用 `resolve` / `listDir` / `readText`
|
|
51
51
|
* / `contains` / `stat`。旧镜像漏抄了官方那几位的可选 `signal?: AbortSignal`
|
|
52
52
|
* 形参(抄本里没有的形参在 TS 里是"少收一个参数",调用点不会报错,但真实宿主多一档取消
|
|
53
53
|
* 语义);投影之后它回到官方形状。
|
|
@@ -59,7 +59,7 @@ export type { FsDirEntry, FsTarget } from "@deepseek-ai/dsh-fs";
|
|
|
59
59
|
*/
|
|
60
60
|
export type FsService = Pick<FileSystem, "resolve" | "listDir" | "readText" | "contains" | "stat">;
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* 本包从会话消息历史里读到的类型 = **官方 `Message` 的键名投影**(installed
|
|
63
63
|
* @deepseek-ai/dsh-llm/lib/types/message.d.ts `MessageBase` 与各变体的 `role`),
|
|
64
64
|
* 三位各自取到"本包能凭运行时守卫负责的那一档":
|
|
65
65
|
* - `role` 就此是官方 `Message['role']` 的字面量联合(上游加/改角色即在此编译不过,
|
|
@@ -89,7 +89,7 @@ export interface DerivedMessageView {
|
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* 本包读到的会话类型 = 官方 `Session` 两位成员的**边界投影**(installed
|
|
93
93
|
* @deepseek-ai/dsh-session/lib/types/index.d.ts:`readonly header: SessionHeader`、
|
|
94
94
|
* `deriveMessages(): Message[]`)。
|
|
95
95
|
* 键名一律借自官方(`header` 借 `Session`、`cwd` 借 `SessionHeader`,installed
|
|
@@ -110,12 +110,12 @@ export interface SessionLike {
|
|
|
110
110
|
* `brandString<SessionId>`),返回值域换成上面的 `SessionLike` 投影——直接取官方返回的整枚
|
|
111
111
|
* `Session` 类会把名义类一路渗进本包(`private log`/`surfaceManager`),那三道运行时
|
|
112
112
|
* 守卫当场在编译器眼里变成死代码,而它们挡的是真实输入。返回 `undefined` 与官方一致。
|
|
113
|
-
*
|
|
113
|
+
* 做法同 danger-guard/host.ts 的 `GuardExecution`(借键名、值域换投影)。
|
|
114
114
|
*/
|
|
115
115
|
export interface SessionsService {
|
|
116
116
|
get: (id: SessionId) => SessionLike | undefined;
|
|
117
117
|
}
|
|
118
|
-
/** 活 Agent
|
|
118
|
+
/** 活 Agent 的模型选择接口(新版 `model.current()`;旧版只有 `options`)。 */
|
|
119
119
|
export interface LiveModelSelection {
|
|
120
120
|
readonly provider: string;
|
|
121
121
|
readonly model: string;
|
|
@@ -132,18 +132,18 @@ export interface LiveAgent {
|
|
|
132
132
|
readonly reasoningEffort?: ModelSelection["reasoningEffort"];
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
|
-
/** 宿主 agent
|
|
135
|
+
/** 宿主 agent 注册表的读取接口:按会话 id 取活 Agent。 */
|
|
136
136
|
export interface AgentsService {
|
|
137
137
|
get: (id: SessionId) => LiveAgent | undefined;
|
|
138
138
|
}
|
|
139
|
-
/** `ReasoningEffortId`
|
|
140
|
-
* `unique symbol` 为键)。本地重述成 `string & { effortBrand: ... }`
|
|
139
|
+
/** `ReasoningEffortId` 取官方真 `brand`(`Branded<'ReasoningEffortId'>`,以 dsh-brand 的
|
|
140
|
+
* `unique symbol` 为键)。本地重述成 `string & { effortBrand: ... }` 只是**自造的假类型品牌**:
|
|
141
141
|
* 键不同名即不同型,宿主真值塞不进来、任何带该属性的字符串反倒能通过,注释里那句
|
|
142
142
|
* 「转换点为 0」并不成立。取官方类型后模型选择与 stream 入参两侧共用同一真值。 */
|
|
143
143
|
export type { ReasoningEffortId } from "@deepseek-ai/dsh-llm";
|
|
144
144
|
/** 默认模型选择的三位形状:与官方 `ModelSelection`(`@deepseek-ai/dsh-agent` 的
|
|
145
|
-
* model-selection.d.ts)同形。`reasoningEffort`
|
|
146
|
-
* dsh-llm 的 peer
|
|
145
|
+
* model-selection.d.ts)同形。`reasoningEffort` 用官方真 `brand` 类型 `ReasoningEffortId`(上面已按
|
|
146
|
+
* dsh-llm 的 peer 声明里的 re-export),`brand` 值塞不进 stream 入参时静默丢字段的风险仍留在类型上。
|
|
147
147
|
*
|
|
148
148
|
* 为什么不直接 import/re-export 官方类型:那会在 `types/host.d.ts` 里留下裸说明符
|
|
149
149
|
* `@deepseek-ai/dsh-agent`,按本仓门禁它只能落进 peer 表,而本包运行期并不 import 它——
|
|
@@ -153,12 +153,12 @@ export interface ModelSelection {
|
|
|
153
153
|
readonly model: string;
|
|
154
154
|
readonly reasoningEffort?: ReasoningEffortId;
|
|
155
155
|
}
|
|
156
|
-
/**
|
|
156
|
+
/** 默认模型服务里本包用到的那部分:只 `currentSelection()`,不写回(`saveSelection` 归 composer)。
|
|
157
157
|
*
|
|
158
158
|
* 刻意不 `Pick<AgentDefaultModelConfig, …>`:那个声明文件 import 了它自己没声明的
|
|
159
159
|
* `@deepseek-ai/dsh-agent`,干净检出里这条链会退化成 error 类型,类型感知的 oxlint 在 CI
|
|
160
160
|
* 上整片报 `no-unsafe-*`(伞根里经 hoist 解析得开,本机门禁看不见)。返回值用本仓的
|
|
161
|
-
* 结构等价 `ModelSelection
|
|
161
|
+
* 结构等价 `ModelSelection`,与真实服务的官方类型在成员上相容。 */
|
|
162
162
|
export interface AgentDefaultModel {
|
|
163
163
|
readonly currentSelection: () => ModelSelection;
|
|
164
164
|
}
|
|
@@ -175,7 +175,7 @@ export type { FinishReason, StreamChunk } from "@deepseek-ai/dsh-llm";
|
|
|
175
175
|
* 与官方并行的形状声明;连同 `signal` 一起 `Pick`,一处来源。 */
|
|
176
176
|
export type LlmStreamOptions = Pick<GenerateOptions, "provider" | "model" | "reasoningEffort" | "messages" | "system" | "signal">;
|
|
177
177
|
/** 官方 `LlmRuntime`(`Context.llm` 的类型,installed @deepseek-ai/dsh-llm/lib/types/
|
|
178
|
-
* index.d.ts
|
|
178
|
+
* index.d.ts)的方法子集投影:本包只 `stream`。旧镜像把返回抄成
|
|
179
179
|
* `AsyncIterable<StreamChunk>`——官方那一位的真实返回域由成员自己交出,重述一次就多一处
|
|
180
180
|
* 会漂移的判决(`stream` 在 installed index.d.ts 上有数枚同名成员,本包用的是 runtime 那枚)。 */
|
|
181
181
|
export type LlmService = Pick<LlmRuntime, "stream">;
|
|
@@ -186,20 +186,20 @@ export interface DirEntry {
|
|
|
186
186
|
/** 关键文本文件首段摘要;非关键文件/目录为 undefined。 */
|
|
187
187
|
snippet: string | undefined;
|
|
188
188
|
}
|
|
189
|
-
/**
|
|
190
|
-
* 界面与 host 都显示成功)。dir context 与 import
|
|
189
|
+
/** 静默丢数据的记录("读失败即 undefined、超限即忽略"的话没有任何回执,
|
|
190
|
+
* 界面与 host 都显示成功)。dir context 与 import 两个读取方法共用此形状。 */
|
|
191
191
|
export interface SkipCounts {
|
|
192
192
|
/** 字节超限、整份跳过的文件数。 */
|
|
193
193
|
tooLarge: number;
|
|
194
194
|
/** 读取失败(含 EMFILE / 权限 / 非 UTF-8)的文件数。 */
|
|
195
195
|
unreadable: number;
|
|
196
|
-
/** 只在更深一层、被扫描深度限制造漏掉的 .md
|
|
196
|
+
/** 只在更深一层、被扫描深度限制造漏掉的 .md 数(只有导入接口用到)。 */
|
|
197
197
|
deeper: number;
|
|
198
|
-
/** 读到了但解析不出角色 name
|
|
198
|
+
/** 读到了但解析不出角色 name(非角色文件)而被跳过的文件数(只有导入接口用到)。 */
|
|
199
199
|
unnamed: number;
|
|
200
200
|
/** 真实目标落在允许根之外(符号链接指向根外文件)而被策略排除的文件数。
|
|
201
201
|
* 必须单列:它既不是读失败也不是超限,把「凭据文件被链接进工作目录」这类事
|
|
202
|
-
* 混进 unreadable
|
|
202
|
+
* 混进 unreadable,用户就看不出是被安全检查拦下的,还是目录本身坏了。 */
|
|
203
203
|
escaped: number;
|
|
204
204
|
}
|
|
205
205
|
export interface CollectResult {
|
|
@@ -210,8 +210,8 @@ export interface CollectResult {
|
|
|
210
210
|
skipped: SkipCounts;
|
|
211
211
|
error?: string;
|
|
212
212
|
}
|
|
213
|
-
/**
|
|
214
|
-
*
|
|
213
|
+
/** 这几个方法实际用的收集函数:fs 服务 → DirEntry[](含关键文件全文摘要)。
|
|
214
|
+
* 条目数不设上限(用户定下),但单文件按 MAX_SNIPPET_BYTES 整份跳过、
|
|
215
215
|
* 读取按 READ_CONCURRENCY 有界并发;跳过项计入 skipped 并让 truncated 反映事实。
|
|
216
216
|
* 回执文案取自注入的字典(纯函数不读设置)。 */
|
|
217
217
|
export interface DirScanLimits {
|
|
@@ -222,15 +222,15 @@ export interface DirScanLimits {
|
|
|
222
222
|
/** 单次收集的全部摘要的字节总量上限。 */
|
|
223
223
|
maxTotalBytes?: number;
|
|
224
224
|
}
|
|
225
|
-
/**
|
|
225
|
+
/** 这几个方法实际用的 limits 全集。 */
|
|
226
226
|
type RouteLimits = DirScanLimits & {
|
|
227
227
|
organizeTimeoutMs: number;
|
|
228
228
|
};
|
|
229
229
|
/**
|
|
230
|
-
*
|
|
230
|
+
* 部署值唯一一处统一处理:把会致命的几个数夹进安全区间,再交给读取方法。
|
|
231
231
|
*
|
|
232
232
|
* 为什么放在这里而不是各消费点:`limitsOf()` 是 context/organize/importTemplates
|
|
233
|
-
*
|
|
233
|
+
* 三个方法读 limits 的**唯一入口**,一处统一处理就不会漏掉将来新增的方法;而散在
|
|
234
234
|
* 各消费点夹,哪天新增一个调用点就等于新增一个漏洞。
|
|
235
235
|
*
|
|
236
236
|
* 夹哪两个、为什么:
|
|
@@ -241,7 +241,7 @@ type RouteLimits = DirScanLimits & {
|
|
|
241
241
|
* 「调大超时」变成「立刻失败」。
|
|
242
242
|
*
|
|
243
243
|
* 剩下 `maxSnippetBytes` **故意不夹**:schema 已经挡住 NaN/±Infinity/负数/小数,
|
|
244
|
-
* 唯一还能配出来的越界值 `0`
|
|
244
|
+
* 唯一还能配出来的越界值 `0` 有确定且已记录的行为(全跳过并计 tooLarge),那是用户
|
|
245
245
|
* 的显式意图,不该被悄悄改写。
|
|
246
246
|
*
|
|
247
247
|
* @param limits - 未经夹位的部署值
|
|
@@ -262,7 +262,7 @@ export declare function importPathError(requested: string, cwd: string | undefin
|
|
|
262
262
|
* truncated 反映"确实有东西没进来",不再硬编码 false。
|
|
263
263
|
* skipPolicy 用于内置角色库自检(AGENTS_DIR 是策略里的允许根,用户输入路径正常
|
|
264
264
|
* 不需要它;保留这个开关只为让"内置全量导入"不依赖安装位置是否命中隐藏段判断)。
|
|
265
|
-
* allowRoots = 设置 importAllowRoots
|
|
265
|
+
* allowRoots = 设置 importAllowRoots 登记的额外允许目录(由读取方法注入)。 */
|
|
266
266
|
export declare function collectAgentTemplates(fs: Pick<FsService, "resolve" | "listDir" | "readText" | "contains" | "stat">, requested: string, cwd: string | undefined, messages: HostMessages, opts?: {
|
|
267
267
|
skipPolicy?: boolean;
|
|
268
268
|
allowRoots?: readonly string[];
|
|
@@ -274,7 +274,7 @@ export interface OrganizeInput {
|
|
|
274
274
|
entriesSummary?: string;
|
|
275
275
|
/** 会话最近对话文本(user/assistant 交替,host 侧从 deriveMessages 提取)。 */
|
|
276
276
|
recentTurns?: string;
|
|
277
|
-
/**
|
|
277
|
+
/** 参考角色上下文(提炼自模板正文;可选)。提供时借用该角色的术语与风格润色 `prompt`。 */
|
|
278
278
|
roleText?: string;
|
|
279
279
|
model?: ModelSelection;
|
|
280
280
|
}
|
|
@@ -282,7 +282,7 @@ export interface OrganizeInput {
|
|
|
282
282
|
* 面向模型的 prompt 也随官方 locale 偏好切语言;zh 输出的正文逐字取自该字典。 */
|
|
283
283
|
export declare function buildOrganizeSystem(input: Omit<OrganizeInput, "prompt">, messages: HostMessages): string;
|
|
284
284
|
/**
|
|
285
|
-
* user 消息 =
|
|
285
|
+
* user 消息 = 用户草稿(`prompt`)+ 围栏起来的不可信数据块。
|
|
286
286
|
*
|
|
287
287
|
* 围栏用**成对的定界标记**而不是缩进或横线:模型侧最容易被无视的是「看起来像普通内容」
|
|
288
288
|
* 的标记,而成对标签既显眼、又便于判断边界。
|
|
@@ -300,7 +300,7 @@ export declare function buildOrganizeSystem(input: Omit<OrganizeInput, "prompt">
|
|
|
300
300
|
export declare function buildOrganizeUser(prompt: string, input: Omit<OrganizeInput, "prompt">, messages: HostMessages): string;
|
|
301
301
|
/**
|
|
302
302
|
* 会话最近真人对话提取(deriveMessages → "user:/assistant:" 文本串)。
|
|
303
|
-
*
|
|
303
|
+
* 不设条数/字符上限(用户定下不截断:上下文完整性优先,模型
|
|
304
304
|
* context 超限由模型报错提示用户自行处理)。
|
|
305
305
|
*
|
|
306
306
|
* 注入过滤(隐藏 bug 复查 实测确认:真实会话 log 里 user 角色
|
|
@@ -315,12 +315,12 @@ export declare function buildOrganizeUser(prompt: string, input: Omit<OrganizeIn
|
|
|
315
315
|
export declare function extractRecentTurns(messages: readonly DerivedMessageView[]): string;
|
|
316
316
|
/** 流式聚合 text-delta 为完整文本;终态非 stop 视为失败(失败文本取自注入字典)。 */
|
|
317
317
|
export declare function drainStreamToText(stream: AsyncIterable<StreamChunk>, messages: HostMessages): Promise<string>;
|
|
318
|
-
/**
|
|
318
|
+
/** 润色入口(读取方法调用;导出供测试注入假 stream)。失败文案与 system 提示都来自
|
|
319
319
|
* 注入的字典,本函数不读设置。 */
|
|
320
320
|
export declare function runOrganize(llm: LlmService, input: OrganizeInput, messages: HostMessages, timeoutMs?: number, callerSignal?: AbortSignal): Promise<{
|
|
321
321
|
content: string;
|
|
322
322
|
}>;
|
|
323
|
-
/** settings 命名空间与 loader 行 config 共用同一 schema
|
|
323
|
+
/** settings 命名空间与 loader 行 config 共用同一 schema(唯一来源,防漂移)。
|
|
324
324
|
* 值名退避为 configSchema:避免与同名 interface Config 触发 no-redeclare;
|
|
325
325
|
* 外部仍以 `Config` 名导入(export as),公开 API 不变。
|
|
326
326
|
* 写入校验由 dsh-settings 在持久化前按此 schema 完成;凡是要出现在卡上的字段都必须 `.volatile()`
|
|
@@ -389,15 +389,15 @@ export { configSchema as Config };
|
|
|
389
389
|
* 文档),放进来会被 toImportRoot 的 path.resolve 按**宿主进程 cwd** 解析,变成一条用户
|
|
390
390
|
* 没写过、也不知道存在着的允许根。 */
|
|
391
391
|
export declare function importAllowRootsOf(raw: unknown): string[];
|
|
392
|
-
/**
|
|
392
|
+
/** 注入的服务:settings 为硬依赖(cordis 等它就绪才 apply)。
|
|
393
393
|
* 命名空间是隐式的(= 本条目在 cordis.patch.yml 里的裸 id,可编辑字段取自
|
|
394
394
|
* 导出的 Config),所以 settings 在这里的职责是「页面策略(configure)与跨命名空间读
|
|
395
395
|
* (describe)」,而非「注册的前提」;设置页只派发「host 已 serve 的命名空间 ∩
|
|
396
396
|
* settings.plugin.item 卡」(dsh-client-ui-settings-plugins 源码语义),configure 必须
|
|
397
397
|
* 发生在 apply 期,故仍硬注入。sessions/fs/llm/agentDefaultModel 仍可选读。 */
|
|
398
398
|
export declare const inject: string[];
|
|
399
|
-
/**
|
|
400
|
-
*
|
|
399
|
+
/** 这些方法用到的依赖,抽出来便于测试:apply 用 ctx.get 的惰性 getter 调用(服务可能在
|
|
400
|
+
* 注册之后才就绪),测试可直接注入静态假服务。 */
|
|
401
401
|
export interface RouteDeps {
|
|
402
402
|
sessions?: () => SessionsService | undefined;
|
|
403
403
|
fs?: () => FsService | undefined;
|
|
@@ -421,13 +421,13 @@ export type MessagesOf = () => HostMessages;
|
|
|
421
421
|
* `agent.options`。没有活 Agent、或两处都答不全时 undefined(调用方回落默认模型)。
|
|
422
422
|
* 与 rescue 同一条规则:`current()` 交回 undefined 是「还没记录过选择」,不是读失败。 */
|
|
423
423
|
export declare function liveModelOf(deps: RouteDeps, sessionId: string | null): ModelSelection | undefined;
|
|
424
|
-
/**
|
|
424
|
+
/** 读取方法每次调用共用的部分:服务 getter 与现读文案/限额。 */
|
|
425
425
|
interface RemoteScope {
|
|
426
426
|
readonly deps: RouteDeps;
|
|
427
427
|
readonly messagesOf: MessagesOf;
|
|
428
428
|
readonly limitsOf: () => RouteLimits;
|
|
429
429
|
}
|
|
430
|
-
/**
|
|
430
|
+
/** 五个方法的纯载荷入口(服务与测试共用):不含任何传输层判定。 */
|
|
431
431
|
export declare function createRemotePayloads(deps: RouteDeps, messagesOf: MessagesOf): {
|
|
432
432
|
defaults: () => Promise<Record<string, unknown>>;
|
|
433
433
|
context: (sessionId: string | null) => Promise<Record<string, unknown>>;
|
|
@@ -453,7 +453,7 @@ interface ImportTemplatesRequest {
|
|
|
453
453
|
sessionId: string;
|
|
454
454
|
}
|
|
455
455
|
/**
|
|
456
|
-
*
|
|
456
|
+
* 设置卡的宿主侧接口(官方 Typert Remote):目录上下文、当前模型、润色、导入与内置模板。
|
|
457
457
|
* 本包不自建 HTTP 端点,认证与分派由宿主 /api 网关负责。
|
|
458
458
|
*/
|
|
459
459
|
export declare class DirPrepRemoteService extends TypertRemoteService {
|
|
@@ -465,9 +465,9 @@ export declare class DirPrepRemoteService extends TypertRemoteService {
|
|
|
465
465
|
organize(request: OrganizeRequest): Promise<Record<string, unknown>>;
|
|
466
466
|
importTemplates(request: ImportTemplatesRequest): Promise<Record<string, unknown>>;
|
|
467
467
|
}
|
|
468
|
-
/**
|
|
468
|
+
/** 注册这组远端方法(构造即注册);替身上下文没有注册口时只少掉这一栏。 */
|
|
469
469
|
export declare function installDirPrepRemote(ctx: Context, scope: RemoteScope): boolean;
|
|
470
|
-
/** host apply:登记设置页策略 + 注册官方 Remote
|
|
470
|
+
/** host apply:登记设置页策略 + 注册官方 Remote 服务(注入子上下文,卸载即撤)。
|
|
471
471
|
* 模板设置是**隐式注册**的(导出的 Config + 字段上的 .volatile()),本函数
|
|
472
472
|
* 不再向 settings 注册任何东西;配置值由 cordis 校验并填过默认后按 volatile 引用交进来
|
|
473
473
|
* (第二参数 config),读当前值一律 `.get()`。 */
|
|
@@ -46,7 +46,7 @@ export interface BuiltinState {
|
|
|
46
46
|
error: string;
|
|
47
47
|
}
|
|
48
48
|
export declare function builtinTemplatesSnapshot(): BuiltinState;
|
|
49
|
-
/** 导出仅供单测:不经过 apply
|
|
49
|
+
/** 导出仅供单测:不经过 apply 的纯读取方法用例直接注入替身。 */
|
|
50
50
|
export declare function setDirPrepReader(reader: DirPrepReader | undefined): void;
|
|
51
51
|
export declare function loadBuiltinTemplates(): Promise<BuiltinState>;
|
|
52
52
|
export declare function subscribeBuiltinTemplates(listener: () => void): () => void;
|
|
@@ -81,7 +81,7 @@ export interface KitProps {
|
|
|
81
81
|
}
|
|
82
82
|
export interface ClientCtx {
|
|
83
83
|
effect: Context["effect"];
|
|
84
|
-
/**
|
|
84
|
+
/** 官方的反射接口:远端接口经 `get("remote")` 取出来,不建立 inject 依赖(缺席只少一栏数据)。 */
|
|
85
85
|
get: Context["get"];
|
|
86
86
|
slots: Pick<SlotRegistry, "inject" | "register">;
|
|
87
87
|
configForms: {
|
|
@@ -11,8 +11,8 @@ export declare const ORGANIZE_TIMEOUT_SLACK_MS = 5000;
|
|
|
11
11
|
/**
|
|
12
12
|
* `organizeTimeoutMs` 的前端取表。
|
|
13
13
|
*
|
|
14
|
-
* 上界与 host 同为 `[1, MAX_TIMER_MS]`:host
|
|
15
|
-
*
|
|
14
|
+
* 上界与 host 同为 `[1, MAX_TIMER_MS]`:host 自己夹了上界正是为了躲开上面那个静默的夹断,
|
|
15
|
+
* 而这里是**唯一**发起润色读取方法调用的地方,它要是没夹,host 夹得再对也没用。
|
|
16
16
|
*
|
|
17
17
|
* @param value - 配置表单投影值
|
|
18
18
|
* @returns `[1, MAX_TIMER_MS]` 区间内的整数;不合法时 undefined(回落默认)
|
|
@@ -7,9 +7,9 @@ export interface HostMessages {
|
|
|
7
7
|
readonly sysRulesHeading: string;
|
|
8
8
|
/** 规则:只输出润色后的正文。 */
|
|
9
9
|
readonly sysRuleOutputOnly: string;
|
|
10
|
-
/**
|
|
10
|
+
/** 规则:不执行 `prompt` 里要求的任务。 */
|
|
11
11
|
readonly sysRuleNoExecution: string;
|
|
12
|
-
/**
|
|
12
|
+
/** 规则:`prompt` 本身是问题/待办指令时不给解答。 */
|
|
13
13
|
readonly sysRuleNoAnswer: string;
|
|
14
14
|
/** 规则:保留原意与语言,推断得来的上下文才补。 */
|
|
15
15
|
readonly sysRuleKeepIntent: string;
|
|
@@ -38,7 +38,7 @@ export interface HostMessages {
|
|
|
38
38
|
readonly cwdEmpty: string;
|
|
39
39
|
/** 目录枚举抛错的前缀整句(`{reason}`)。 */
|
|
40
40
|
readonly readDirFailed: string;
|
|
41
|
-
/**
|
|
41
|
+
/** 收集端点出错时顶上的整句(`{reason}`)。 */
|
|
42
42
|
readonly collectFailed: string;
|
|
43
43
|
/** 路径含 `.` / `..` / 隐藏段。 */
|
|
44
44
|
readonly illegalPathSegment: string;
|
|
@@ -60,7 +60,7 @@ export interface HostMessages {
|
|
|
60
60
|
readonly missingRoleName: string;
|
|
61
61
|
/** 导入过程抛错的前缀整句(`{reason}`)。 */
|
|
62
62
|
readonly importFailed: string;
|
|
63
|
-
/**
|
|
63
|
+
/** 导入端点出错时顶上的整句(`{reason}`)。 */
|
|
64
64
|
readonly importException: string;
|
|
65
65
|
/** 导入路由:path 字段不是字符串。 */
|
|
66
66
|
readonly importPathNotString: string;
|
|
@@ -72,7 +72,7 @@ export interface HostMessages {
|
|
|
72
72
|
readonly streamNotFinished: string;
|
|
73
73
|
/** 终态带 failure 信息时的 `{reason}` 形状(`{kind}`、`{message}`)。 */
|
|
74
74
|
readonly failureReason: string;
|
|
75
|
-
/**
|
|
75
|
+
/** `prompt` 为空白(trim 后为空)时的回执。 */
|
|
76
76
|
readonly emptyPrompt: string;
|
|
77
77
|
/** 没有可用的模型选择。 */
|
|
78
78
|
readonly noModelSelected: string;
|
|
@@ -90,7 +90,7 @@ export interface HostMessages {
|
|
|
90
90
|
readonly readModelFailed: string;
|
|
91
91
|
/** llm 服务未就绪。 */
|
|
92
92
|
readonly llmUnavailable: string;
|
|
93
|
-
/**
|
|
93
|
+
/** 润色端点出错时顶上的整句(`{reason}`)。 */
|
|
94
94
|
readonly organizeFailed: string;
|
|
95
95
|
}
|
|
96
96
|
export declare const HOST_MESSAGES: MessagesCatalog<HostMessages>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InputActions, InputState } from "@deepseek-ai/dsh-client-ui-conversation/client";
|
|
2
2
|
export type InputActionsFace = Pick<InputActions, "setDraft" | "captureInsertion" | "insertText">;
|
|
3
|
-
/**
|
|
3
|
+
/** 输入框状态的最新一帧(异步返回时读它,不读发起那次 render 的闭包)。 */
|
|
4
4
|
export interface InputSnapshot {
|
|
5
5
|
readonly sessionId: string;
|
|
6
6
|
readonly actions: InputActionsFace | undefined;
|
|
@@ -14,9 +14,9 @@ export interface WriteBackTicket {
|
|
|
14
14
|
readonly actions: InputActionsFace | undefined;
|
|
15
15
|
invalidated: boolean;
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
17
|
+
/** 宿主是否给了整稿替换接口(润色结果最后落到 setDraft)。 */
|
|
18
18
|
export declare function hasDraftFace(actions: InputActionsFace | undefined): actions is InputActionsFace;
|
|
19
|
-
/**
|
|
19
|
+
/** 宿主是否给了版本校验的插入接口(模板走这一对,不整稿覆盖)。 */
|
|
20
20
|
export declare function hasInsertFace(actions: InputActionsFace | undefined): actions is InputActionsFace;
|
|
21
21
|
export interface WriteBackMessages {
|
|
22
22
|
readonly unavailable: string;
|
|
@@ -28,5 +28,5 @@ export interface WriteBackBinding {
|
|
|
28
28
|
readonly commit: (content: string, ticket: WriteBackTicket) => void;
|
|
29
29
|
}
|
|
30
30
|
/** 提交期(`phase !== "plain"`)也算失效:发送成功后编辑器会被清空,失败时原稿要留着,
|
|
31
|
-
*
|
|
31
|
+
* 两种情况下在途的润色结果都不该再经 `setDraft` 写回输入框。 */
|
|
32
32
|
export declare function useWriteBack(input: InputSnapshot, messages: WriteBackMessages): WriteBackBinding;
|
package/types/src/remote.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InvocationDescriptor } from "@deepseek-ai/dsh-typert-protocol";
|
|
2
|
-
/** Typert Remote 命名空间(client
|
|
2
|
+
/** Typert Remote 命名空间(client 半只用这一枚)。
|
|
3
3
|
*
|
|
4
4
|
* 宿主半的注册键在 host.ts 的 `DIR_PREP_REMOTE_NAMESPACE`——两半各自打包、client 包
|
|
5
5
|
* 不能 import host.ts,所以这一枚字面量必然有两份。两边取值必须一致:写岔了的表现是
|
|
@@ -25,12 +25,12 @@ export interface DirPrepReader {
|
|
|
25
25
|
interface RemoteHost {
|
|
26
26
|
get?: (name: string, strict?: boolean) => unknown;
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
28
|
+
/** 造读取器;当前部署没有远程通道时 undefined(卡片只显示读不到)。
|
|
29
29
|
*
|
|
30
|
-
* `get`
|
|
30
|
+
* `get` 这两处的做法和 buildReader 里查命名空间时保持一致,都显式传 `strict = false`:
|
|
31
31
|
* 不传时 cordis 默认只返回「提供者 fiber 当前 active」的实现,而设置卡可能在 fiber
|
|
32
|
-
*
|
|
33
|
-
* `get`
|
|
32
|
+
* 就绪前就挂上——那时读取方法会拿到 undefined 并显示「读不到」,看起来是插件没装。
|
|
33
|
+
* `get` 本身也可能抛(宿主版本演进之后,反射接口可能不再接受 bool),接住它只是为了把这
|
|
34
34
|
* 一栏降级成「读不到」,不让整张卡片跟着炸。 */
|
|
35
35
|
export declare function createDirPrepReader(ctx: RemoteHost): DirPrepReader | undefined;
|
|
36
36
|
export {};
|
package/types/src/templates.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface TemplateEntry {
|
|
|
9
9
|
/** 角色视觉标记(下拉 item 前缀);空=不显示。 */
|
|
10
10
|
emoji: string;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
12
|
+
/** 角色正文提炼/「按角色风格润色」上下文:不设字符上限(用户定下,
|
|
13
13
|
* 上下文完整性优先;模型 context 超限由模型报错提示用户自行处理)。 */
|
|
14
14
|
/** 仓库目录名 → 下拉分组标签的**唯一**导出点在 `./group-labels.generated.ts`(表源 =
|
|
15
15
|
* scripts/gen-defaults-lib.mjs,键序 = 下拉分组展示序),本文件不再同名 re-export:
|
|
@@ -20,7 +20,7 @@ export interface TemplateEntry {
|
|
|
20
20
|
/** 仓库目录名 → 分组标签(groupLabelOf(engineering) === "工程";未收录回落目录名)。
|
|
21
21
|
* 必须只认**自有属性**:`AGENT_DIR_GROUP_LABELS["constructor"]` 会命中原型上的
|
|
22
22
|
* function(`?? dirName` 不触发)→ TemplateEntry.group 拿到函数、JSON.stringify
|
|
23
|
-
* 静默丢掉整个 group
|
|
23
|
+
* 静默丢掉整个 group 键(实测样例:{"id":"a"});"__proto__" 同理返回 {}。 */
|
|
24
24
|
export declare function groupLabelOf(dirName: string): string;
|
|
25
25
|
/** 角色 .md 解析结果(frontmatter 的 name/description/emoji + 去除头部围栏的正文)。 */
|
|
26
26
|
export interface AgentFileInfo {
|
|
@@ -44,11 +44,11 @@ export declare function parseAgentFrontmatter(text: string): AgentFileInfo | und
|
|
|
44
44
|
* 规则(确定性,测试锁死):
|
|
45
45
|
* - ``` 围栏行整体剔除(围栏内容多为长代码样例,对角色语境价值低);
|
|
46
46
|
* - 行内反引号一并剔除——沿用"正文不含反引号、插入不破坏 markdown 围栏"不变式;
|
|
47
|
-
* -
|
|
47
|
+
* - 不设字符上限(用户定下):全量保留叙述内容,避免截断影响
|
|
48
48
|
* 「以角色风格润色」的上下文完整性;模型 context 超限由模型报错提示用户自行处理;
|
|
49
49
|
* - 结果 trim;空正文(全围栏/全空白)→ 空串;
|
|
50
50
|
* - 围栏未闭合时**不抛**:把行号作为结果交出,由调用方决定是拒绝整份文件还是跳过它。
|
|
51
|
-
* 异常只由 `condenseRoleBody`
|
|
51
|
+
* 异常只由 `condenseRoleBody` 这一层抛(生成器要据此拒绝产出),导入读取方法拿到的是结果。
|
|
52
52
|
*/
|
|
53
53
|
export interface CondenseResult {
|
|
54
54
|
/** 清洗后的正文(围栏未闭合时是围栏起始行之前的那些行)。 */
|
|
@@ -58,12 +58,12 @@ export interface CondenseResult {
|
|
|
58
58
|
}
|
|
59
59
|
export declare function tryCondenseRoleBody(body: string): CondenseResult;
|
|
60
60
|
/** `tryCondenseRoleBody` 的严格形态:围栏未闭合时抛错,供生成器拒收畸形角色文件。
|
|
61
|
-
*
|
|
61
|
+
* 导入读取方法不用这一支——一份漏写结束围栏的文件不该让同目录其余角色全部失败。 */
|
|
62
62
|
export declare function condenseRoleBody(body: string): string;
|
|
63
63
|
/**
|
|
64
|
-
*
|
|
64
|
+
* 导入条目并入 `existing`(设置卡上未保存的 `draft` 列表):与既有 id 碰撞时确定性改写(追加 `-i` 直到唯一)。
|
|
65
65
|
* 返回新数组(不改输入),保证 pre-save 阶段 React key 唯一。sanitizeTemplateList 对**存量
|
|
66
|
-
* 快照**同样按序号补 id
|
|
66
|
+
* 快照**同样按序号补 id(缺失/空/撞名三档都管),这边要额外做的是避开 `existing` 里已有的 id
|
|
67
67
|
* ——两个入口各管一段,不靠对方兜底。
|
|
68
68
|
*/
|
|
69
69
|
export declare function mergeImportedTemplates(existing: readonly TemplateEntry[], incoming: readonly TemplateEntry[]): TemplateEntry[];
|
|
@@ -73,7 +73,7 @@ export declare function mergeImportedTemplates(existing: readonly TemplateEntry[
|
|
|
73
73
|
* 全量角色可经设置页「导入角色」导入(路径留空 = 导入内置 agents/ 全部;显式路径
|
|
74
74
|
* 受 host 的「cwd 内 + 内置角色目录 allowlist」策略约束)。 */
|
|
75
75
|
export { DEFAULT_TEMPLATES } from "./default-templates.generated.js";
|
|
76
|
-
/** 任意来源(settings 快照 /
|
|
76
|
+
/** 任意来源(settings 快照 / 设置卡未保存的 `draft`)→ 合法模板列表(纯函数,测试锁死)。
|
|
77
77
|
*
|
|
78
78
|
* - 非数组输入 → [](调用方自行决定是否回落 DEFAULT_TEMPLATES);
|
|
79
79
|
* - 剔除非对象条目与 name/text trim 后为空的条目;
|
|
@@ -81,4 +81,16 @@ export { DEFAULT_TEMPLATES } from "./default-templates.generated.js";
|
|
|
81
81
|
* - id 缺失与已收集 id 撞名都由 uniqueEntryId 按序号补成唯一(同输入同输出,可测试);
|
|
82
82
|
* - 绝不修改输入(深比较测试锁死)。 */
|
|
83
83
|
export declare function sanitizeTemplateList(raw: unknown): TemplateEntry[];
|
|
84
|
+
/** 任意来源(settings 快照 / 设置卡未保存的 `rootsDraft`)→ 合法的「导入允许目录」列表(纯函数)。
|
|
85
|
+
* host 的导入策略是「会话 cwd + 内置角色库 + importAllowRoots」,绝对路径默认拒绝,
|
|
86
|
+
* 这里登记的每一项都是**放一个读盘口子**,故:
|
|
87
|
+
* - 非数组 → [](未设置 = 一条都不登记,不是"全放行");
|
|
88
|
+
* - 非字符串 / trim 后为空 → 丢弃(空串在 host 侧 path.resolve 会落到进程 cwd,
|
|
89
|
+
* 绝不能让它变成一个隐式允许根);
|
|
90
|
+
* - **非绝对路径 → 丢弃**:契约是「额外允许的绝对目录」,相对项会被 host 按它自己的
|
|
91
|
+
* 进程 cwd 解析,等于登记了一条用户没写过、界面上也看不出指向哪里的允许根;`~`
|
|
92
|
+
* 靠 shell 展开,host 的 path.resolve 不展开它,同归这一档;
|
|
93
|
+
* - 末尾分隔符归一后去重(`/a` 与 `/a/` 是同一棵目录树,不该在界面上摆两行);
|
|
94
|
+
* - 条数与单条长度都不设上限:静默丢一条就是「看着成功、内容没进去」;条目多撑长的
|
|
95
|
+
* 越界的回执由 host 侧的列举上限限制住。 */
|
|
84
96
|
export declare function sanitizeAllowRoots(raw: unknown): string[];
|
|
@@ -19,9 +19,9 @@ export interface UiMessages {
|
|
|
19
19
|
readonly saving: string;
|
|
20
20
|
/** 保存按钮(空闲态);同时充当回执文本里的动作名。 */
|
|
21
21
|
readonly save: string;
|
|
22
|
-
/**
|
|
22
|
+
/** 撤销按钮(丢弃未保存的 `draft` 与 `rootsDraft`)。 */
|
|
23
23
|
readonly revert: string;
|
|
24
|
-
/** 恢复默认按钮 title
|
|
24
|
+
/** 恢复默认按钮 title(说明改动范围与两步确认)。 */
|
|
25
25
|
readonly resetTitle: string;
|
|
26
26
|
/** 恢复默认按钮(已进入确认态)。 */
|
|
27
27
|
readonly resetConfirm: string;
|
|
@@ -95,7 +95,7 @@ export interface UiMessages {
|
|
|
95
95
|
readonly skipUnreadable: string;
|
|
96
96
|
/** 跳过计数:非角色文件。 */
|
|
97
97
|
readonly skipUnnamed: string;
|
|
98
|
-
/**
|
|
98
|
+
/** 跳过计数:真实目标在允许根之外(符号链接逃逸),被安全检查拦下。 */
|
|
99
99
|
readonly skipEscaped: string;
|
|
100
100
|
/** 跳过计数整句的外层括号。 */
|
|
101
101
|
readonly skipSummary: string;
|
|
@@ -162,15 +162,15 @@ export interface UiMessages {
|
|
|
162
162
|
readonly organizeRoleItem: string;
|
|
163
163
|
/** 润色成功但输入框动作缺失时抛出的错误(会闪烁在按钮上)。 */
|
|
164
164
|
readonly organizeWriteBackUnavailable: string;
|
|
165
|
-
/**
|
|
165
|
+
/** 润色结果因 `draftRev` 变化或会话切换而没有写回时的错误。 */
|
|
166
166
|
readonly organizeWriteBackStale: string;
|
|
167
|
-
/** 「润色」按钮 title
|
|
167
|
+
/** 「润色」按钮 title(输入框处于提交期,输入区只读)。 */
|
|
168
168
|
readonly organizeBusyTitle: string;
|
|
169
169
|
/** 「模板」按钮 title(可写时)。 */
|
|
170
170
|
readonly templatesIdleTitle: string;
|
|
171
171
|
/** 「模板」按钮 title(输入框动作缺失)。 */
|
|
172
172
|
readonly templatesBrokenTitle: string;
|
|
173
|
-
/** 「模板」按钮 title
|
|
173
|
+
/** 「模板」按钮 title(输入框处于提交期,输入区只读)。 */
|
|
174
174
|
readonly templatesBusyTitle: string;
|
|
175
175
|
/** 空分组名的归组名。 */
|
|
176
176
|
readonly templatesGroupCommon: string;
|
|
@@ -203,16 +203,16 @@ declare module "@deepseek-ai/dsh-client-ui-slots" {
|
|
|
203
203
|
declare const LOCALE_NS_KEY: "dir-prep-organize";
|
|
204
204
|
/**
|
|
205
205
|
* 本源只以**类型**形态对外流通:`client-entry.ts` 的 `const NS: LocaleNs = "dir-prep-organize"` 把条目
|
|
206
|
-
* id
|
|
206
|
+
* id 钉在本源上(分叉即编译期红),而产物漂移检查仍要按字面量形状从 bundle 里抓 `NS`,所以那里
|
|
207
207
|
* 保留字面量、只加类型标注——值导出不必存在(用例侧同理:要断言运行时那串就写字面量)。
|
|
208
208
|
*/
|
|
209
209
|
export type LocaleNs = typeof LOCALE_NS_KEY;
|
|
210
210
|
/**
|
|
211
211
|
* 卡片取文案的函数形状:官方 `TranslateNS<N> = Translate<LocaleKeysOf<N>>`(installed
|
|
212
212
|
* `dsh-client-ui-slots/lib/types/index.d.ts`,而 `Translate<K> =
|
|
213
|
-
* (key: K, params?: Record<string, unknown>) => string
|
|
213
|
+
* (key: K, params?: Record<string, unknown>) => string`,同文件)。函数类型归官方,
|
|
214
214
|
* 键集就是上面 merge 的 `keyof UiMessages`(外加官方 `LocaleKeysOf` 一并放行的
|
|
215
|
-
* `common`
|
|
215
|
+
* `common` 命名空间键——那是宿主查不到键时的回落,运行时行为见其 `lookup`)。
|
|
216
216
|
*/
|
|
217
217
|
export type Translate = OfficialTranslateNS<typeof LOCALE_NS_KEY>;
|
|
218
218
|
export declare const UI_MESSAGES: MessagesCatalog<UiMessages>;
|