@jayyuen66/dsh-dir-prep-organize 0.1.6 → 0.1.8
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 +48 -0
- package/LICENSE +1 -8
- package/README.md +23 -19
- package/README.zh-CN.md +23 -19
- package/THIRD_PARTY_NOTICES.md +7 -5
- package/client.js +466 -281
- package/docs/DETAIL.md +26 -0
- package/docs/DETAIL.zh.md +26 -0
- package/host.js +119 -44
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +56 -45
- package/types/host.d.ts +35 -2
- package/types/src/client-entry.d.ts +2 -3
- package/types/src/input-writeback.d.ts +32 -0
- package/types/src/templates.d.ts +22 -10
- package/types/src/ui-messages.d.ts +14 -4
|
@@ -72,12 +72,11 @@ export declare function persistError(t: Translate, persisted: Pick<PersistedView
|
|
|
72
72
|
treatEmptyAsReverted?: boolean;
|
|
73
73
|
}): string | undefined;
|
|
74
74
|
export declare function rootsPersistError(t: Translate, persisted: Pick<PersistedView, "ready" | "revision" | "allowRoots">, expected: readonly string[], action: string): string | undefined;
|
|
75
|
-
export declare function applyTemplateToDraft(current: string, template: string): string;
|
|
76
75
|
export interface KitProps {
|
|
77
76
|
t: Translate;
|
|
78
77
|
useCard: <TResult>(selector: (snap: TemplatesSnapshot) => TResult) => TResult;
|
|
79
|
-
useInput?: <TResult>(selector: (state: Pick<InputState, "draft">) => TResult) => TResult;
|
|
80
|
-
inputActions?: Pick<InputActions, "setDraft">;
|
|
78
|
+
useInput?: <TResult>(selector: (state: Pick<InputState, "draft" | "draftRev" | "phase">) => TResult) => TResult;
|
|
79
|
+
inputActions?: Pick<InputActions, "setDraft" | "captureInsertion" | "insertText">;
|
|
81
80
|
sessionId?: string;
|
|
82
81
|
}
|
|
83
82
|
export interface ClientCtx {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { InputActions, InputState } from "@deepseek-ai/dsh-client-ui-conversation/client";
|
|
2
|
+
export type InputActionsFace = Pick<InputActions, "setDraft" | "captureInsertion" | "insertText">;
|
|
3
|
+
/** 输入面的最新一帧(异步返回时读它,不读发起那次 render 的闭包)。 */
|
|
4
|
+
export interface InputSnapshot {
|
|
5
|
+
readonly sessionId: string;
|
|
6
|
+
readonly actions: InputActionsFace | undefined;
|
|
7
|
+
readonly draftRev: number;
|
|
8
|
+
readonly phase: InputState["phase"];
|
|
9
|
+
}
|
|
10
|
+
/** 一次整稿写回的凭据。 */
|
|
11
|
+
export interface WriteBackTicket {
|
|
12
|
+
readonly sessionId: string;
|
|
13
|
+
readonly draftRev: number;
|
|
14
|
+
readonly actions: InputActionsFace | undefined;
|
|
15
|
+
invalidated: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** 宿主是否给了整稿替换面(润色结果最后落到 setDraft)。 */
|
|
18
|
+
export declare function hasDraftFace(actions: InputActionsFace | undefined): actions is InputActionsFace;
|
|
19
|
+
/** 宿主是否给了版本校验插入面(模板走这一对,不整稿覆盖)。 */
|
|
20
|
+
export declare function hasInsertFace(actions: InputActionsFace | undefined): actions is InputActionsFace;
|
|
21
|
+
export interface WriteBackMessages {
|
|
22
|
+
readonly unavailable: string;
|
|
23
|
+
readonly stale: string;
|
|
24
|
+
}
|
|
25
|
+
export interface WriteBackBinding {
|
|
26
|
+
readonly begin: () => WriteBackTicket;
|
|
27
|
+
readonly finish: (ticket: WriteBackTicket) => void;
|
|
28
|
+
readonly commit: (content: string, ticket: WriteBackTicket) => void;
|
|
29
|
+
}
|
|
30
|
+
/** 提交期(`phase !== "plain"`)也算失效:发送成功后编辑器会被清空,失败时原稿要留着,
|
|
31
|
+
* 两种情况下在途的润色结果都不该再写进草稿。 */
|
|
32
|
+
export declare function useWriteBack(input: InputSnapshot, messages: WriteBackMessages): WriteBackBinding;
|
package/types/src/templates.d.ts
CHANGED
|
@@ -46,13 +46,25 @@ export declare function parseAgentFrontmatter(text: string): AgentFileInfo | und
|
|
|
46
46
|
* - 行内反引号一并剔除——沿用"正文不含反引号、插入不破坏 markdown 围栏"不变式;
|
|
47
47
|
* - 不设字符上限(用户拍板):全量保留叙述内容,避免截断影响
|
|
48
48
|
* 「以角色风格润色」的上下文完整性;模型 context 超限由模型报错提示用户自行处理;
|
|
49
|
-
* - 结果 trim;空正文(全围栏/全空白)→
|
|
49
|
+
* - 结果 trim;空正文(全围栏/全空白)→ 空串;
|
|
50
|
+
* - 围栏未闭合时**不抛**:把行号作为结果交出,由调用方决定是拒绝整份文件还是跳过它。
|
|
51
|
+
* 异常只由 `condenseRoleBody` 这一层抛(生成器要据此拒绝产出),导入读面拿到的是结果。
|
|
50
52
|
*/
|
|
53
|
+
export interface CondenseResult {
|
|
54
|
+
/** 清洗后的正文(围栏未闭合时是围栏起始行之前的那些行)。 */
|
|
55
|
+
text: string;
|
|
56
|
+
/** 未闭合围栏在正文里的行号(1 起);闭合完整时为 undefined。 */
|
|
57
|
+
unclosedFenceLine: number | undefined;
|
|
58
|
+
}
|
|
59
|
+
export declare function tryCondenseRoleBody(body: string): CondenseResult;
|
|
60
|
+
/** `tryCondenseRoleBody` 的严格形态:围栏未闭合时抛错,供生成器拒收畸形角色文件。
|
|
61
|
+
* 导入读面不用这一支——一份漏写结束围栏的文件不该让同目录其余角色全部失败。 */
|
|
51
62
|
export declare function condenseRoleBody(body: string): string;
|
|
52
63
|
/**
|
|
53
64
|
* 导入条目并入现有草稿:与既有 id 碰撞时确定性改写(追加 `-i` 直到唯一)。
|
|
54
|
-
* 返回新数组(不改输入),保证 pre-save 阶段 React key
|
|
55
|
-
*
|
|
65
|
+
* 返回新数组(不改输入),保证 pre-save 阶段 React key 唯一。sanitizeTemplateList 对**存量
|
|
66
|
+
* 快照**同样按序号补 id(缺失/空/撞名三档都管),这边要额外做的是避开草稿里已有的 id
|
|
67
|
+
* ——两个入口各管一段,不靠对方兜底。
|
|
56
68
|
*/
|
|
57
69
|
export declare function mergeImportedTemplates(existing: readonly TemplateEntry[], incoming: readonly TemplateEntry[]): TemplateEntry[];
|
|
58
70
|
/** 内置默认模板(独立开发者精选角色集,生成自插件内置 agents/ 目录)。
|
|
@@ -61,12 +73,12 @@ export declare function mergeImportedTemplates(existing: readonly TemplateEntry[
|
|
|
61
73
|
* 全量角色可经设置页「导入角色」导入(路径留空 = 导入内置 agents/ 全部;显式路径
|
|
62
74
|
* 受 host 的「cwd 内 + 内置角色目录 allowlist」策略约束)。 */
|
|
63
75
|
export { DEFAULT_TEMPLATES } from "./default-templates.generated.js";
|
|
76
|
+
/** 任意来源(settings 快照 / 设置卡草稿)→ 合法模板列表(纯函数,测试锁死)。
|
|
77
|
+
*
|
|
78
|
+
* - 非数组输入 → [](调用方自行决定是否回落 DEFAULT_TEMPLATES);
|
|
79
|
+
* - 剔除非对象条目与 name/text trim 后为空的条目;
|
|
80
|
+
* - name/text/description/group 一律 trim;emoji trim 后按码点截断至 12 个字符;
|
|
81
|
+
* - id 缺失与已收集 id 撞名都由 uniqueEntryId 按序号补成唯一(同输入同输出,可测试);
|
|
82
|
+
* - 绝不修改输入(深比较测试锁死)。 */
|
|
64
83
|
export declare function sanitizeTemplateList(raw: unknown): TemplateEntry[];
|
|
65
|
-
/** 任意来源(settings 快照 / 设置卡草稿)→ 合法的「导入允许目录」列表(纯函数)。
|
|
66
|
-
* host 的导入策略是「会话 cwd + 内置角色库 + importAllowRoots」,绝对路径默认拒绝,
|
|
67
|
-
* 这里登记的每一项都是**放一个读盘口子**,故:
|
|
68
|
-
* - 非数组 → [](未设置 = 一条都不登记,不是"全放行");
|
|
69
|
-
* - 非字符串 / trim 后为空 → 丢弃(空串在 host 侧 path.resolve 会落到进程 cwd,
|
|
70
|
-
* 绝不能让它变成一个隐式允许根);
|
|
71
|
-
* - 去重(同一目录登记两次没有额外语义,界面上也不该出现两行)。 */
|
|
72
84
|
export declare function sanitizeAllowRoots(raw: unknown): string[];
|
|
@@ -2,10 +2,9 @@ import type { TranslateNS as OfficialTranslateNS } from "@deepseek-ai/dsh-client
|
|
|
2
2
|
import type { MessagesCatalog } from "@jayyuen66/dsh-plugin-shared/lib/locale";
|
|
3
3
|
/** 本包设置卡产出的全部界面文案。 */
|
|
4
4
|
export interface UiMessages {
|
|
5
|
-
/**
|
|
6
|
-
readonly
|
|
7
|
-
|
|
8
|
-
readonly cardDescription: string;
|
|
5
|
+
/** 角色库小节标题与说明(这份列表同时喂「模板」下拉与「润色」▾)。 */
|
|
6
|
+
readonly rolesSection: string;
|
|
7
|
+
readonly rolesHint: string;
|
|
9
8
|
/** 设置源可写位为 false 时的状态条。 */
|
|
10
9
|
readonly statusReadOnly: string;
|
|
11
10
|
/** 设置源尚未就绪时的状态条。 */
|
|
@@ -72,6 +71,8 @@ export interface UiMessages {
|
|
|
72
71
|
readonly importAllDone: string;
|
|
73
72
|
/** 导入成功(显式路径)。 */
|
|
74
73
|
readonly importFromDone: string;
|
|
74
|
+
/** 回执带 truncated 标记时的追加说明(有内容因上限被跳过的总括)。 */
|
|
75
|
+
readonly importTruncated: string;
|
|
75
76
|
/** 导入路径输入框的 placeholder。 */
|
|
76
77
|
readonly importPlaceholder: string;
|
|
77
78
|
/** 导入路径输入框的 aria-label。 */
|
|
@@ -140,6 +141,9 @@ export interface UiMessages {
|
|
|
140
141
|
readonly organizeErrModelFailed: string;
|
|
141
142
|
/** 润色前置检查失败:输入框为空。 */
|
|
142
143
|
readonly organizeErrEmpty: string;
|
|
144
|
+
/** 润色请求超时(宿主端未在时限内回报)。 */
|
|
145
|
+
readonly organizeErrTimeout: string;
|
|
146
|
+
/** 没有会话 id 时「润色」不可用的 title 说明。 */
|
|
143
147
|
/** 润色链路兜底:宿主回执没带 error 字段时给 {message} 的占位原因。 */
|
|
144
148
|
readonly organizeErrUnknownReason: string;
|
|
145
149
|
/** 润色回执整体不是对象时的兜底错误。 */
|
|
@@ -158,10 +162,16 @@ export interface UiMessages {
|
|
|
158
162
|
readonly organizeRoleItem: string;
|
|
159
163
|
/** 润色成功但输入框动作缺失时抛出的错误(会闪烁在按钮上)。 */
|
|
160
164
|
readonly organizeWriteBackUnavailable: string;
|
|
165
|
+
/** 润色结果因草稿版本变化或会话切换而没有写回时的错误。 */
|
|
166
|
+
readonly organizeWriteBackStale: string;
|
|
167
|
+
/** 「润色」按钮 title(输入框处于提交期,编辑面只读)。 */
|
|
168
|
+
readonly organizeBusyTitle: string;
|
|
161
169
|
/** 「模板」按钮 title(可写时)。 */
|
|
162
170
|
readonly templatesIdleTitle: string;
|
|
163
171
|
/** 「模板」按钮 title(输入框动作缺失)。 */
|
|
164
172
|
readonly templatesBrokenTitle: string;
|
|
173
|
+
/** 「模板」按钮 title(输入框处于提交期,编辑面只读)。 */
|
|
174
|
+
readonly templatesBusyTitle: string;
|
|
165
175
|
/** 空分组名的归组名。 */
|
|
166
176
|
readonly templatesGroupCommon: string;
|
|
167
177
|
/** 「模板」按钮的 aria-label。 */
|