@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/client.js
CHANGED
|
@@ -19,7 +19,7 @@ function e$1(e) {
|
|
|
19
19
|
/** 视觉标记进入下拉前缀的最大字符数。 */
|
|
20
20
|
const EMOJI_MAX_LENGTH = 12;
|
|
21
21
|
/** 按 Unicode 码点截断:`String#slice` 数的是 UTF-16 码元,会把一个 emoji(代理对)或
|
|
22
|
-
* 组合字符劈成半个,落进模板后显示成空白方块。两个截断点(frontmatter
|
|
22
|
+
* 组合字符劈成半个,落进模板后显示成空白方块。两个截断点(frontmatter 解析与 `sanitizeTemplateList`)
|
|
23
23
|
* 共用这一份实现,scripts/gen-defaults-lib.mjs 有同源镜像。 */
|
|
24
24
|
function truncateCodePoints(value, max) {
|
|
25
25
|
const points = Array.from(value);
|
|
@@ -34,9 +34,9 @@ function uniqueEntryId(candidate, index, seen) {
|
|
|
34
34
|
return id;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* 导入条目并入 `existing`(设置卡上未保存的 `draft` 列表):与既有 id 碰撞时确定性改写(追加 `-i` 直到唯一)。
|
|
38
38
|
* 返回新数组(不改输入),保证 pre-save 阶段 React key 唯一。sanitizeTemplateList 对**存量
|
|
39
|
-
* 快照**同样按序号补 id
|
|
39
|
+
* 快照**同样按序号补 id(缺失/空/撞名三档都管),这边要额外做的是避开 `existing` 里已有的 id
|
|
40
40
|
* ——两个入口各管一段,不靠对方兜底。
|
|
41
41
|
*/
|
|
42
42
|
function mergeImportedTemplates(existing, incoming) {
|
|
@@ -84,7 +84,7 @@ function normalizeEntry(item, index, seen) {
|
|
|
84
84
|
}
|
|
85
85
|
return result;
|
|
86
86
|
}
|
|
87
|
-
/** 任意来源(settings 快照 /
|
|
87
|
+
/** 任意来源(settings 快照 / 设置卡未保存的 `draft`)→ 合法模板列表(纯函数,测试锁死)。
|
|
88
88
|
*
|
|
89
89
|
* - 非数组输入 → [](调用方自行决定是否回落 DEFAULT_TEMPLATES);
|
|
90
90
|
* - 剔除非对象条目与 name/text trim 后为空的条目;
|
|
@@ -101,28 +101,40 @@ function sanitizeTemplateList(raw) {
|
|
|
101
101
|
}
|
|
102
102
|
return out;
|
|
103
103
|
}
|
|
104
|
-
/** 任意来源(settings 快照 / 设置卡草稿)→ 合法的「导入允许目录」列表(纯函数)。
|
|
105
|
-
* host 的导入策略是「会话 cwd + 内置角色库 + importAllowRoots」,绝对路径默认拒绝,
|
|
106
|
-
* 这里登记的每一项都是**放一个读盘口子**,故:
|
|
107
|
-
* - 非数组 → [](未设置 = 一条都不登记,不是"全放行");
|
|
108
|
-
* - 非字符串 / trim 后为空 → 丢弃(空串在 host 侧 path.resolve 会落到进程 cwd,
|
|
109
|
-
* 绝不能让它变成一个隐式允许根);
|
|
110
|
-
* - **非绝对路径 → 丢弃**:契约是「额外允许的绝对目录」,相对项会被 host 按它自己的
|
|
111
|
-
* 进程 cwd 解析,等于登记了一条用户没写过、界面上也看不出指向哪里的允许根;
|
|
112
|
-
* - 去重(同一目录登记两次没有额外语义,界面上也不该出现两行)。 */
|
|
113
|
-
/** 绝对路径形状(与 host 侧 path.isAbsolute 同口径的宽松版:POSIX 根、win32 盘符、UNC)。
|
|
114
|
-
* client 半跑在浏览器里,没有 node:path 可用,故按形状判。 */
|
|
115
104
|
const BACKSLASH = String.fromCodePoint(92);
|
|
116
105
|
const WIN_DRIVE_LETTER = /^[A-Za-z]:$/u;
|
|
106
|
+
const TRAILING_SEPARATORS = /[/\\]+$/u;
|
|
107
|
+
/** 绝对路径的形状(比 host 侧 path.isAbsolute 宽松一档的同一套判断:POSIX 根、win32 盘符、UNC)。
|
|
108
|
+
* client 半跑在浏览器里,没有 node:path 可用,故按形状判。 */
|
|
117
109
|
function isAbsolutePath(value) {
|
|
118
110
|
const winDrive = WIN_DRIVE_LETTER.test(value.slice(0, 2)) && (value[2] === "/" || value[2] === BACKSLASH);
|
|
119
111
|
return value.startsWith("/") || winDrive || value.startsWith(BACKSLASH + BACKSLASH);
|
|
120
112
|
}
|
|
113
|
+
/** 剥末尾分隔符;剥完为空(POSIX 根 `/`)或只剩盘符(`C:`)时留原值——后者在 win32
|
|
114
|
+
* 是「该盘当前目录」的相对形式,不是根。 */
|
|
115
|
+
function normalizeRootShape(value) {
|
|
116
|
+
const stripped = value.replace(TRAILING_SEPARATORS, "");
|
|
117
|
+
if (stripped.length === 0 || WIN_DRIVE_LETTER.test(stripped)) return value;
|
|
118
|
+
return stripped;
|
|
119
|
+
}
|
|
120
|
+
/** 任意来源(settings 快照 / 设置卡未保存的 `rootsDraft`)→ 合法的「导入允许目录」列表(纯函数)。
|
|
121
|
+
* host 的导入策略是「会话 cwd + 内置角色库 + importAllowRoots」,绝对路径默认拒绝,
|
|
122
|
+
* 这里登记的每一项都是**放一个读盘口子**,故:
|
|
123
|
+
* - 非数组 → [](未设置 = 一条都不登记,不是"全放行");
|
|
124
|
+
* - 非字符串 / trim 后为空 → 丢弃(空串在 host 侧 path.resolve 会落到进程 cwd,
|
|
125
|
+
* 绝不能让它变成一个隐式允许根);
|
|
126
|
+
* - **非绝对路径 → 丢弃**:契约是「额外允许的绝对目录」,相对项会被 host 按它自己的
|
|
127
|
+
* 进程 cwd 解析,等于登记了一条用户没写过、界面上也看不出指向哪里的允许根;`~`
|
|
128
|
+
* 靠 shell 展开,host 的 path.resolve 不展开它,同归这一档;
|
|
129
|
+
* - 末尾分隔符归一后去重(`/a` 与 `/a/` 是同一棵目录树,不该在界面上摆两行);
|
|
130
|
+
* - 条数与单条长度都不设上限:静默丢一条就是「看着成功、内容没进去」;条目多撑长的
|
|
131
|
+
* 越界的回执由 host 侧的列举上限限制住。 */
|
|
121
132
|
function sanitizeAllowRoots(raw) {
|
|
122
133
|
const out = [];
|
|
123
134
|
if (Array.isArray(raw)) for (const item of raw) {
|
|
124
135
|
const root = typeof item === "string" ? item.trim() : "";
|
|
125
|
-
|
|
136
|
+
const shaped = normalizeRootShape(root);
|
|
137
|
+
if (root.length > 0 && isAbsolutePath(shaped) && !out.includes(shaped)) out.push(shaped);
|
|
126
138
|
}
|
|
127
139
|
return out;
|
|
128
140
|
}
|
|
@@ -144,8 +156,8 @@ function isUsableTimeoutMs(value) {
|
|
|
144
156
|
/**
|
|
145
157
|
* `organizeTimeoutMs` 的前端取表。
|
|
146
158
|
*
|
|
147
|
-
* 上界与 host 同为 `[1, MAX_TIMER_MS]`:host
|
|
148
|
-
*
|
|
159
|
+
* 上界与 host 同为 `[1, MAX_TIMER_MS]`:host 自己夹了上界正是为了躲开上面那个静默的夹断,
|
|
160
|
+
* 而这里是**唯一**发起润色读取方法调用的地方,它要是没夹,host 夹得再对也没用。
|
|
149
161
|
*
|
|
150
162
|
* @param value - 配置表单投影值
|
|
151
163
|
* @returns `[1, MAX_TIMER_MS]` 区间内的整数;不合法时 undefined(回落默认)
|
|
@@ -397,34 +409,7 @@ const UI_MESSAGES = {
|
|
|
397
409
|
builtinRetry: "Retry"
|
|
398
410
|
}
|
|
399
411
|
};
|
|
400
|
-
// node_modules/@jayyuen66/dsh-plugin-shared/dist/
|
|
401
|
-
function t$1(e) {
|
|
402
|
-
let t = Object.getOwnPropertyDescriptor(e, `message`);
|
|
403
|
-
return t !== void 0 && `value` in t && typeof t.value == `string` ? t.value : void 0;
|
|
404
|
-
}
|
|
405
|
-
function n$1(e, r) {
|
|
406
|
-
if (r.has(e)) return `<circular cause>`;
|
|
407
|
-
r.add(e);
|
|
408
|
-
try {
|
|
409
|
-
if (!(e instanceof Error)) {
|
|
410
|
-
if (typeof e == `object` && e) {
|
|
411
|
-
let n = t$1(e);
|
|
412
|
-
if (n !== void 0 && n !== ``) return n;
|
|
413
|
-
}
|
|
414
|
-
return String(e);
|
|
415
|
-
}
|
|
416
|
-
let i = e.message === `` ? e.name : e.message, a = typeof globalThis.AggregateError == `function` && e instanceof AggregateError && e.errors.length > 0 ? ` [${e.errors.map((e) => n$1(e, r)).join(`; `)}]` : ``, o = e.cause === void 0 || e.cause === null ? `` : n$1(e.cause, r);
|
|
417
|
-
return `${i}${a}${o === `` || o === i ? `` : `: ${o}`}`;
|
|
418
|
-
} catch {
|
|
419
|
-
return `<unrenderable value>`;
|
|
420
|
-
} finally {
|
|
421
|
-
r.delete(e);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
function r$1(e) {
|
|
425
|
-
return n$1(e, /* @__PURE__ */ new Set());
|
|
426
|
-
}
|
|
427
|
-
// node_modules/@jayyuen66/dsh-plugin-shared/dist/card-ui.js
|
|
412
|
+
// node_modules/@jayyuen66/dsh-plugin-shared/dist/card-ui-C1lrHILm.js
|
|
428
413
|
const c = `
|
|
429
414
|
.dsu-form{display:flex;flex-direction:column}
|
|
430
415
|
.dsu-section{margin-top:24px;padding-top:24px;border-top:.5px solid var(--dsw-alias-border-l1)}
|
|
@@ -529,25 +514,52 @@ function S(t) {
|
|
|
529
514
|
onClick: t.onDiscard
|
|
530
515
|
}, t.revertLabel), (0, react.createElement)(`span`, { className: t.error === null ? `dsu-status` : `dsu-status dsu-statusError` }, r));
|
|
531
516
|
}
|
|
517
|
+
// node_modules/@jayyuen66/dsh-plugin-shared/dist/errors.js
|
|
518
|
+
function t(e) {
|
|
519
|
+
let t = Object.getOwnPropertyDescriptor(e, `message`);
|
|
520
|
+
return t !== void 0 && `value` in t && typeof t.value == `string` ? t.value : void 0;
|
|
521
|
+
}
|
|
522
|
+
function n(e, r) {
|
|
523
|
+
if (r.has(e)) return `<circular cause>`;
|
|
524
|
+
r.add(e);
|
|
525
|
+
try {
|
|
526
|
+
if (!(e instanceof Error)) {
|
|
527
|
+
if (typeof e == `object` && e) {
|
|
528
|
+
let n = t(e);
|
|
529
|
+
if (n !== void 0 && n !== ``) return n;
|
|
530
|
+
}
|
|
531
|
+
return String(e);
|
|
532
|
+
}
|
|
533
|
+
let i = e.message === `` ? e.name : e.message, a = typeof globalThis.AggregateError == `function` && e instanceof AggregateError && e.errors.length > 0 ? ` [${e.errors.map((e) => n(e, r)).join(`; `)}]` : ``, o = e.cause === void 0 || e.cause === null ? `` : n(e.cause, r);
|
|
534
|
+
return `${i}${a}${o === `` || o === i ? `` : `: ${o}`}`;
|
|
535
|
+
} catch {
|
|
536
|
+
return `<unrenderable value>`;
|
|
537
|
+
} finally {
|
|
538
|
+
r.delete(e);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
function r(e) {
|
|
542
|
+
return n(e, /* @__PURE__ */ new Set());
|
|
543
|
+
}
|
|
532
544
|
// src/input-writeback.ts
|
|
533
545
|
/**
|
|
534
546
|
* 输入框异步写回的凭据与判定。
|
|
535
547
|
*
|
|
536
|
-
*
|
|
548
|
+
* 润色结果是整稿替换:发起时记下会话、`draftRev` 与输入动作对象,返回时用**最新一帧**
|
|
537
549
|
* 核对。任一项在途中变了(用户继续编辑、宿主进入提交期、会话被切换、组件重挂成
|
|
538
550
|
* 另一份 facade),结果都不许落地——宁可报「未写回」,也不能覆盖用户后来的输入。
|
|
539
551
|
* 模板走插入语义(captureInsertion + insertText),由宿主按发起的选区做版本校验。
|
|
540
552
|
*/
|
|
541
|
-
/**
|
|
553
|
+
/** 宿主是否给了整稿替换接口(润色结果最后落到 setDraft)。 */
|
|
542
554
|
function hasDraftFace(actions) {
|
|
543
555
|
return actions !== void 0 && typeof actions.setDraft === "function";
|
|
544
556
|
}
|
|
545
|
-
/**
|
|
557
|
+
/** 宿主是否给了版本校验的插入接口(模板走这一对,不整稿覆盖)。 */
|
|
546
558
|
function hasInsertFace(actions) {
|
|
547
559
|
return actions !== void 0 && typeof actions.captureInsertion === "function" && typeof actions.insertText === "function";
|
|
548
560
|
}
|
|
549
561
|
/** 提交期(`phase !== "plain"`)也算失效:发送成功后编辑器会被清空,失败时原稿要留着,
|
|
550
|
-
*
|
|
562
|
+
* 两种情况下在途的润色结果都不该再经 `setDraft` 写回输入框。 */
|
|
551
563
|
function useWriteBack(input, messages) {
|
|
552
564
|
const latest = (0, react.useRef)(input);
|
|
553
565
|
const active = (0, react.useRef)(void 0);
|
|
@@ -591,7 +603,7 @@ function useWriteBack(input, messages) {
|
|
|
591
603
|
};
|
|
592
604
|
}
|
|
593
605
|
// src/remote.ts
|
|
594
|
-
/** Typert Remote 命名空间(client
|
|
606
|
+
/** Typert Remote 命名空间(client 半只用这一枚)。
|
|
595
607
|
*
|
|
596
608
|
* 宿主半的注册键在 host.ts 的 `DIR_PREP_REMOTE_NAMESPACE`——两半各自打包、client 包
|
|
597
609
|
* 不能 import host.ts,所以这一枚字面量必然有两份。两边取值必须一致:写岔了的表现是
|
|
@@ -754,12 +766,12 @@ function buildReader(ctx, remote) {
|
|
|
754
766
|
importTemplates: async (args) => call((namespace) => namespace.importTemplates(args))
|
|
755
767
|
};
|
|
756
768
|
}
|
|
757
|
-
/**
|
|
769
|
+
/** 造读取器;当前部署没有远程通道时 undefined(卡片只显示读不到)。
|
|
758
770
|
*
|
|
759
|
-
* `get`
|
|
771
|
+
* `get` 这两处的做法和 buildReader 里查命名空间时保持一致,都显式传 `strict = false`:
|
|
760
772
|
* 不传时 cordis 默认只返回「提供者 fiber 当前 active」的实现,而设置卡可能在 fiber
|
|
761
|
-
*
|
|
762
|
-
* `get`
|
|
773
|
+
* 就绪前就挂上——那时读取方法会拿到 undefined 并显示「读不到」,看起来是插件没装。
|
|
774
|
+
* `get` 本身也可能抛(宿主版本演进之后,反射接口可能不再接受 bool),接住它只是为了把这
|
|
763
775
|
* 一栏降级成「读不到」,不让整张卡片跟着炸。 */
|
|
764
776
|
function createDirPrepReader(ctx) {
|
|
765
777
|
let remote;
|
|
@@ -774,7 +786,7 @@ function createDirPrepReader(ctx) {
|
|
|
774
786
|
const NS = "dir-prep-organize";
|
|
775
787
|
const BUNDLE_PKG = "@jayyuen66/dsh-dir-prep-organize";
|
|
776
788
|
const ERROR_FLASH_MS = 4e3;
|
|
777
|
-
/**
|
|
789
|
+
/** 除润色之外的调用的等待上限。润色那一发有自己的超时(来自设置卡的 organizeTimeoutMs)。 */
|
|
778
790
|
const REMOTE_TIMEOUT_MS = 125e3;
|
|
779
791
|
const RESET_CONFIRM_MS = 4e3;
|
|
780
792
|
const EMOJI_PLACEHOLDER = "😀";
|
|
@@ -915,7 +927,7 @@ function builtinTemplatesSnapshot() {
|
|
|
915
927
|
return builtinState;
|
|
916
928
|
}
|
|
917
929
|
let dirPrepReader;
|
|
918
|
-
/** 导出仅供单测:不经过 apply
|
|
930
|
+
/** 导出仅供单测:不经过 apply 的纯读取方法用例直接注入替身。 */
|
|
919
931
|
function setDirPrepReader(reader) {
|
|
920
932
|
dirPrepReader = reader;
|
|
921
933
|
}
|
|
@@ -938,7 +950,7 @@ var LocalizedOrganizeError = class extends Error {
|
|
|
938
950
|
this.params = params;
|
|
939
951
|
}
|
|
940
952
|
};
|
|
941
|
-
/**
|
|
953
|
+
/** 客户端的超时只影响等待:宿主侧的润色超时仍由它自己的 AbortController 收尾。 */
|
|
942
954
|
async function within(pending, timeoutMs) {
|
|
943
955
|
const gate = Promise.withResolvers();
|
|
944
956
|
const timer = setTimeout(() => {
|
|
@@ -980,7 +992,7 @@ async function loadBuiltinTemplates() {
|
|
|
980
992
|
settled = {
|
|
981
993
|
phase: "error",
|
|
982
994
|
list: [],
|
|
983
|
-
error: r
|
|
995
|
+
error: r(error)
|
|
984
996
|
};
|
|
985
997
|
} finally {
|
|
986
998
|
if (builtinGeneration === generation) builtinInflight = null;
|
|
@@ -1263,7 +1275,7 @@ async function runOrganizeClick(args) {
|
|
|
1263
1275
|
writeDraft(content);
|
|
1264
1276
|
} catch (error) {
|
|
1265
1277
|
if (seq.current !== mySeq) return;
|
|
1266
|
-
setFailed(error instanceof LocalizedOrganizeError ? t(error.messageKey, error.params) : r
|
|
1278
|
+
setFailed(error instanceof LocalizedOrganizeError ? t(error.messageKey, error.params) : r(error));
|
|
1267
1279
|
if (flashTimer.current !== null) clearTimeout(flashTimer.current);
|
|
1268
1280
|
flashTimer.current = setTimeout(() => {
|
|
1269
1281
|
setFailed(void 0);
|
|
@@ -1690,7 +1702,7 @@ function ImportPanel(props) {
|
|
|
1690
1702
|
skips: skipNote
|
|
1691
1703
|
}));
|
|
1692
1704
|
} catch (error) {
|
|
1693
|
-
setImportError(r
|
|
1705
|
+
setImportError(r(error));
|
|
1694
1706
|
} finally {
|
|
1695
1707
|
setImportBusy(false);
|
|
1696
1708
|
}
|
|
@@ -1883,7 +1895,7 @@ function createPersistActions(args) {
|
|
|
1883
1895
|
const { t, editable, dirty, rootsDirty, anythingDirty, confirmReset, templates, allowRoots, draft, rootsDraft, set, unset, readBack, setDraft, setDraftFor, setRootsDraft, setBusy, setSaveError, setConfirmReset } = args;
|
|
1884
1896
|
function reportError(err) {
|
|
1885
1897
|
console.error("[dir-prep-organize] templates settings write failed:", err);
|
|
1886
|
-
setSaveError(r
|
|
1898
|
+
setSaveError(r(err));
|
|
1887
1899
|
}
|
|
1888
1900
|
async function onSave() {
|
|
1889
1901
|
if (!editable || !anythingDirty) return;
|
|
@@ -1943,7 +1955,7 @@ function createPersistActions(args) {
|
|
|
1943
1955
|
onReset
|
|
1944
1956
|
};
|
|
1945
1957
|
}
|
|
1946
|
-
/** 卡片正文:状态提示 + 工具条 + 角色行表 +
|
|
1958
|
+
/** 卡片正文:状态提示 + 工具条 + 角色行表 + 导入区 + 允许目录区 + 保存条。 */
|
|
1947
1959
|
function createCardBody(view) {
|
|
1948
1960
|
const { t, statusHint, draft, rootsDraft, foot, editable, anythingDirty, busy, confirmReset, saveError } = view;
|
|
1949
1961
|
const { onCommit, onDelete, onAdd, onImported, onRootChange, onRootDelete, onRootAdd } = view.draftActions;
|
package/cordis.patch.yml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# 本包提供的输入框「润色」与「模板」能力由 client 半注册成 dock 条目;这份 patch 只负责
|
|
2
|
-
# 把 bundle
|
|
2
|
+
# 把 bundle 插进插件层栈。设置卡的数据走官方 Typert Remote 的 dirPrepOrganize 命名空间,
|
|
3
3
|
# 内置精选集由 host 半从 templates.data.mjs 经 defaults 方法按需下发。
|
|
4
4
|
# 架构与数据流见 README 与 host.ts / src/client-entry.ts。
|
|
5
5
|
- insert:
|
package/docs/DETAIL.zh.md
CHANGED