@michengai/dsh-pua 0.3.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.
Files changed (170) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +38 -0
  4. package/README.md +150 -0
  5. package/assets/pua/command-again.md +23 -0
  6. package/assets/pua/command-done-check.md +21 -0
  7. package/assets/pua/command-evidence.md +18 -0
  8. package/assets/pua/flavors.md +388 -0
  9. package/assets/pua/methodology-alibaba.md +33 -0
  10. package/assets/pua/methodology-amazon.md +42 -0
  11. package/assets/pua/methodology-apple.md +42 -0
  12. package/assets/pua/methodology-baidu.md +33 -0
  13. package/assets/pua/methodology-bytedance.md +41 -0
  14. package/assets/pua/methodology-ding.md +75 -0
  15. package/assets/pua/methodology-huawei.md +95 -0
  16. package/assets/pua/methodology-jd.md +42 -0
  17. package/assets/pua/methodology-meituan.md +41 -0
  18. package/assets/pua/methodology-microsoft.md +138 -0
  19. package/assets/pua/methodology-netflix.md +41 -0
  20. package/assets/pua/methodology-pinduoduo.md +33 -0
  21. package/assets/pua/methodology-tencent.md +41 -0
  22. package/assets/pua/methodology-tesla.md +42 -0
  23. package/assets/pua/methodology-xiaomi.md +42 -0
  24. package/assets/pua/upstream/agents/cto-p10.md +87 -0
  25. package/assets/pua/upstream/agents/pua-action-executor.md +60 -0
  26. package/assets/pua/upstream/agents/pua-policy-guardian.md +54 -0
  27. package/assets/pua/upstream/agents/pua-self-reviewer.md +62 -0
  28. package/assets/pua/upstream/agents/pua-verifier.md +61 -0
  29. package/assets/pua/upstream/agents/senior-engineer-p7.md +116 -0
  30. package/assets/pua/upstream/agents/tech-lead-p9.md +97 -0
  31. package/assets/pua/upstream/commands/again.md +23 -0
  32. package/assets/pua/upstream/commands/cancel-pua-loop.md +62 -0
  33. package/assets/pua/upstream/commands/ding.md +25 -0
  34. package/assets/pua/upstream/commands/done-check.md +21 -0
  35. package/assets/pua/upstream/commands/evidence.md +18 -0
  36. package/assets/pua/upstream/commands/flavor.md +6 -0
  37. package/assets/pua/upstream/commands/kpi.md +5 -0
  38. package/assets/pua/upstream/commands/mama.md +5 -0
  39. package/assets/pua/upstream/commands/off.md +41 -0
  40. package/assets/pua/upstream/commands/offline.md +38 -0
  41. package/assets/pua/upstream/commands/on.md +15 -0
  42. package/assets/pua/upstream/commands/p10.md +5 -0
  43. package/assets/pua/upstream/commands/p7.md +5 -0
  44. package/assets/pua/upstream/commands/p9.md +5 -0
  45. package/assets/pua/upstream/commands/pro.md +5 -0
  46. package/assets/pua/upstream/commands/pua-loop.md +5 -0
  47. package/assets/pua/upstream/commands/pua.md +44 -0
  48. package/assets/pua/upstream/commands/reap-orphans.md +68 -0
  49. package/assets/pua/upstream/commands/survey.md +9 -0
  50. package/assets/pua/upstream/commands/team-status.md +56 -0
  51. package/assets/pua/upstream/commands/teardown-all.md +80 -0
  52. package/assets/pua/upstream/commands/yes.md +5 -0
  53. package/assets/pua/upstream/hooks/checkpoint-save.sh +56 -0
  54. package/assets/pua/upstream/hooks/failure-detector.sh +266 -0
  55. package/assets/pua/upstream/hooks/flavor-helper.sh +300 -0
  56. package/assets/pua/upstream/hooks/frustration-trigger.sh +61 -0
  57. package/assets/pua/upstream/hooks/hooks.json +114 -0
  58. package/assets/pua/upstream/hooks/integrity-guard.sh +494 -0
  59. package/assets/pua/upstream/hooks/pua-loop-hook.sh +360 -0
  60. package/assets/pua/upstream/hooks/runtime-state.py +460 -0
  61. package/assets/pua/upstream/hooks/sanitize-session.sh +165 -0
  62. package/assets/pua/upstream/hooks/session-restore.sh +189 -0
  63. package/assets/pua/upstream/hooks/stop-feedback.sh +51 -0
  64. package/assets/pua/upstream/hooks/subagent-teardown.sh +56 -0
  65. package/assets/pua/upstream/skills/ding/SKILL.md +83 -0
  66. package/assets/pua/upstream/skills/ding/references/ding-reminders.md +77 -0
  67. package/assets/pua/upstream/skills/ding/references/methodology-ding.md +75 -0
  68. package/assets/pua/upstream/skills/mama/SKILL.md +117 -0
  69. package/assets/pua/upstream/skills/p10/SKILL.md +13 -0
  70. package/assets/pua/upstream/skills/p7/SKILL.md +13 -0
  71. package/assets/pua/upstream/skills/p9/SKILL.md +15 -0
  72. package/assets/pua/upstream/skills/pro/SKILL.md +69 -0
  73. package/assets/pua/upstream/skills/pua/SKILL.md +438 -0
  74. package/assets/pua/upstream/skills/pua/references/agent-team.md +110 -0
  75. package/assets/pua/upstream/skills/pua/references/de-escalation-protocol.md +134 -0
  76. package/assets/pua/upstream/skills/pua/references/ding-reminders.md +77 -0
  77. package/assets/pua/upstream/skills/pua/references/display-protocol.md +63 -0
  78. package/assets/pua/upstream/skills/pua/references/evolution-protocol.md +187 -0
  79. package/assets/pua/upstream/skills/pua/references/flavors.md +388 -0
  80. package/assets/pua/upstream/skills/pua/references/harness-governance.md +159 -0
  81. package/assets/pua/upstream/skills/pua/references/methodology-alibaba.md +33 -0
  82. package/assets/pua/upstream/skills/pua/references/methodology-amazon.md +42 -0
  83. package/assets/pua/upstream/skills/pua/references/methodology-apple.md +42 -0
  84. package/assets/pua/upstream/skills/pua/references/methodology-baidu.md +33 -0
  85. package/assets/pua/upstream/skills/pua/references/methodology-bytedance.md +41 -0
  86. package/assets/pua/upstream/skills/pua/references/methodology-ding.md +75 -0
  87. package/assets/pua/upstream/skills/pua/references/methodology-huawei.md +95 -0
  88. package/assets/pua/upstream/skills/pua/references/methodology-jd.md +42 -0
  89. package/assets/pua/upstream/skills/pua/references/methodology-meituan.md +41 -0
  90. package/assets/pua/upstream/skills/pua/references/methodology-microsoft.md +138 -0
  91. package/assets/pua/upstream/skills/pua/references/methodology-netflix.md +41 -0
  92. package/assets/pua/upstream/skills/pua/references/methodology-pinduoduo.md +33 -0
  93. package/assets/pua/upstream/skills/pua/references/methodology-router.md +81 -0
  94. package/assets/pua/upstream/skills/pua/references/methodology-tencent.md +41 -0
  95. package/assets/pua/upstream/skills/pua/references/methodology-tesla.md +42 -0
  96. package/assets/pua/upstream/skills/pua/references/methodology-xiaomi.md +42 -0
  97. package/assets/pua/upstream/skills/pua/references/p10-protocol.md +127 -0
  98. package/assets/pua/upstream/skills/pua/references/p7-protocol.md +250 -0
  99. package/assets/pua/upstream/skills/pua/references/p9-protocol.md +266 -0
  100. package/assets/pua/upstream/skills/pua/references/platform.md +126 -0
  101. package/assets/pua/upstream/skills/pua/references/runtime-contract.md +65 -0
  102. package/assets/pua/upstream/skills/pua/references/survey.md +292 -0
  103. package/assets/pua/upstream/skills/pua/references/teardown-protocol.md +195 -0
  104. package/assets/pua/upstream/skills/pua-en/SKILL.md +344 -0
  105. package/assets/pua/upstream/skills/pua-ja/SKILL.md +378 -0
  106. package/assets/pua/upstream/skills/pua-loop/SKILL.md +162 -0
  107. package/assets/pua/upstream/skills/shot/SKILL.md +449 -0
  108. package/assets/pua/upstream/skills/yes/SKILL.md +76 -0
  109. package/assets/pua/upstream.json +637 -0
  110. package/assets/screenshots/pua-global-settings.png +0 -0
  111. package/assets/screenshots/pua-session-settings.png +0 -0
  112. package/cordis.patch.yml +5 -0
  113. package/lib/args.d.ts +34 -0
  114. package/lib/args.js +149 -0
  115. package/lib/args.js.map +1 -0
  116. package/lib/client-refresh.d.ts +6 -0
  117. package/lib/client-refresh.js +41 -0
  118. package/lib/client-refresh.js.map +1 -0
  119. package/lib/client.d.ts +30 -0
  120. package/lib/client.js +68 -0
  121. package/lib/client.js.map +7 -0
  122. package/lib/command.d.ts +18 -0
  123. package/lib/command.js +118 -0
  124. package/lib/command.js.map +1 -0
  125. package/lib/configuration.d.ts +89 -0
  126. package/lib/configuration.js +31 -0
  127. package/lib/configuration.js.map +1 -0
  128. package/lib/content.d.ts +14 -0
  129. package/lib/content.js +51 -0
  130. package/lib/content.js.map +1 -0
  131. package/lib/flavors.d.ts +82 -0
  132. package/lib/flavors.js +30 -0
  133. package/lib/flavors.js.map +1 -0
  134. package/lib/hook-content.d.ts +14 -0
  135. package/lib/hook-content.js +63 -0
  136. package/lib/hook-content.js.map +1 -0
  137. package/lib/index.d.ts +21 -0
  138. package/lib/index.js +75 -0
  139. package/lib/index.js.map +1 -0
  140. package/lib/remote-contract.d.ts +148 -0
  141. package/lib/remote-contract.js +20 -0
  142. package/lib/remote-contract.js.map +1 -0
  143. package/lib/remote.d.ts +20 -0
  144. package/lib/remote.js +133 -0
  145. package/lib/remote.js.map +1 -0
  146. package/lib/review.d.ts +4 -0
  147. package/lib/review.js +72 -0
  148. package/lib/review.js.map +1 -0
  149. package/lib/runtime.d.ts +61 -0
  150. package/lib/runtime.js +519 -0
  151. package/lib/runtime.js.map +1 -0
  152. package/lib/session-compat.d.ts +3 -0
  153. package/lib/session-compat.js +9 -0
  154. package/lib/session-compat.js.map +1 -0
  155. package/lib/settings.d.ts +46 -0
  156. package/lib/settings.js +44 -0
  157. package/lib/settings.js.map +1 -0
  158. package/lib/source.d.ts +10 -0
  159. package/lib/source.js +32 -0
  160. package/lib/source.js.map +1 -0
  161. package/lib/state.d.ts +36 -0
  162. package/lib/state.js +187 -0
  163. package/lib/state.js.map +1 -0
  164. package/lib/terminal-observation.d.ts +4 -0
  165. package/lib/terminal-observation.js +12 -0
  166. package/lib/terminal-observation.js.map +1 -0
  167. package/lib/tool-order.d.ts +9 -0
  168. package/lib/tool-order.js +82 -0
  169. package/lib/tool-order.js.map +1 -0
  170. package/package.json +172 -0
package/lib/args.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ import { type FlavorId } from './flavors.js';
2
+ import { type PuaMode } from './content.js';
3
+ import { type ConfigurationPatch } from './configuration.js';
4
+ export type Action = {
5
+ readonly kind: 'configure';
6
+ readonly patch: ConfigurationPatch;
7
+ } | {
8
+ readonly kind: 'activate' | 'review';
9
+ readonly task: string;
10
+ } | {
11
+ readonly kind: 'flavor';
12
+ readonly flavor: FlavorId | 'auto';
13
+ } | {
14
+ readonly kind: 'mode';
15
+ readonly mode: PuaMode;
16
+ readonly task: string;
17
+ } | {
18
+ readonly kind: 'loop';
19
+ readonly task: string;
20
+ readonly maxIterations: number;
21
+ readonly verify?: string;
22
+ readonly verificationTimeout?: number;
23
+ } | {
24
+ readonly kind: 'again' | 'done-check' | 'evidence' | 'kpi' | 'survey';
25
+ readonly task?: string;
26
+ } | {
27
+ readonly kind: 'on' | 'off' | 'offline' | 'status' | 'help' | 'flavors' | 'cancel-pua-loop' | 'team-status' | 'reap-orphans' | 'teardown-all';
28
+ };
29
+ /** 解析 /pua 后的文本;普通命令限 8 KiB;结构化配置保留 128 KiB 传输上限并按字段校验。 */
30
+ export declare function parseArgs(raw: string, loopDefaults?: {
31
+ maxIterations: number;
32
+ verify: string;
33
+ verificationTimeout: number;
34
+ }): Action;
package/lib/args.js ADDED
@@ -0,0 +1,149 @@
1
+ import { resolveFlavor } from './flavors.js';
2
+ import { MODES } from './content.js';
3
+ import { CONFIG_KEYS, loopStartSchema, parsePatch } from './configuration.js';
4
+ /** 解析 /pua 后的文本;普通命令限 8 KiB;结构化配置保留 128 KiB 传输上限并按字段校验。 */
5
+ export function parseArgs(raw, loopDefaults) {
6
+ if (Buffer.byteLength(raw, 'utf8') > (/^\s*(?:config|loop-json)\s/u.test(raw) ? 131072 : 8192))
7
+ throw new Error('输入超过长度限制,请缩短任务或验收命令。');
8
+ if (/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/u.test(raw))
9
+ throw new Error('输入包含不支持的控制字符。');
10
+ let input = raw.trim();
11
+ // 兼容用户从帮助中再次粘贴 /pua,但不递归吞掉任意多个前缀。
12
+ if (/^\/?pua(?::|\s|$)/i.test(input)) {
13
+ input = input.replace(/^\/?pua(?::|\s+|$)/i, '').trim();
14
+ if (!input || /^\/?pua(?::|\s|$)/i.test(input))
15
+ throw new Error('请只输入一次 /pua 前缀,例如 /pua flavor。');
16
+ }
17
+ if (!input)
18
+ return { kind: 'activate', task: '' };
19
+ const aliases = {
20
+ '换个方法': { kind: 'again' }, '再试试': { kind: 'again' },
21
+ '证据呢': { kind: 'evidence' }, '数据在哪': { kind: 'evidence' },
22
+ '没跑测试别说完成': { kind: 'done-check' }, '验收': { kind: 'done-check' },
23
+ };
24
+ if (Object.hasOwn(aliases, input))
25
+ return aliases[input];
26
+ if (/^(?:你来)?(?:审查|评估|分析)(?:一下)?(?:这个|当前)?(?:项目|仓库|代码)[。!!??]?$/u.test(input))
27
+ return { kind: 'review', task: input };
28
+ const first = /^(\S+)(?:\s+([\s\S]*))?$/.exec(input);
29
+ const command = first[1].toLowerCase();
30
+ const rest = (first[2] ?? '').trim();
31
+ if (command === 'loop-json') {
32
+ const { verify, ...value } = loopStartSchema.parse(parseJson(rest));
33
+ return { kind: 'loop', ...value, ...(verify.trim() ? { verify } : {}) };
34
+ }
35
+ if (command === 'config')
36
+ return { kind: 'configure', patch: parsePatch(parseJson(rest)) };
37
+ if (command === 'reset') {
38
+ if (rest && !CONFIG_KEYS.includes(rest))
39
+ throw new Error('未知配置项。');
40
+ return { kind: 'configure', patch: Object.fromEntries((rest ? [rest] : CONFIG_KEYS).map(key => [key, null])) };
41
+ }
42
+ if (command === '--') {
43
+ if (!rest)
44
+ throw new Error('-- 后需要任务描述。');
45
+ return { kind: 'activate', task: rest };
46
+ }
47
+ if (command.startsWith('-'))
48
+ throw new Error('不支持此选项。输入 /pua help 查看用法。');
49
+ if (command === 'flavor' || command === '味道' || command === '风味') {
50
+ if (!rest)
51
+ return { kind: 'flavors' };
52
+ if (rest === 'auto' || rest === '自动')
53
+ return { kind: 'flavor', flavor: 'auto' };
54
+ const flavor = resolveFlavor(rest);
55
+ if (!flavor)
56
+ throw new Error('未知风味。输入 /pua flavor 查看可用名称。');
57
+ return { kind: 'flavor', flavor };
58
+ }
59
+ if (command === 'review')
60
+ return { kind: 'review', task: rest || '审查当前项目' };
61
+ if (['ding', '钉味', '置身钉内', '置身钉外', '每日一包', '薛定谔的用户', '病态敏捷', '望舒行动'].includes(command))
62
+ return { kind: 'mode', mode: 'pua', task: `使用钉内/钉外味。${rest}` };
63
+ if (command === 'loop' || command === 'pua-loop')
64
+ return parseLoop(rest, loopDefaults);
65
+ if (MODES.includes(command))
66
+ return { kind: 'mode', mode: command, task: rest };
67
+ const typos = { in: 'on', onn: 'on', of: 'off', offn: 'off', flavour: 'flavor', flaver: 'flavor', falvor: 'flavor', stauts: 'status', stats: 'status', agian: 'again' };
68
+ if (Object.hasOwn(typos, command) && (!rest || command.length >= 4))
69
+ throw new Error(`可能想输入 /pua ${typos[command]}。若确实要把原文作为任务,请使用 /pua -- ${input}。`);
70
+ switch (command) {
71
+ case 'again':
72
+ case 'done-check':
73
+ case 'evidence':
74
+ case 'kpi':
75
+ case 'survey':
76
+ return rest ? { kind: command, task: rest } : { kind: command };
77
+ case 'on':
78
+ case 'off':
79
+ case 'offline':
80
+ case 'status':
81
+ case 'help':
82
+ case 'cancel-pua-loop':
83
+ case 'team-status':
84
+ case 'reap-orphans':
85
+ case 'teardown-all':
86
+ if (rest)
87
+ throw new Error(`${command} 不接受额外参数;任务以此单词开头时请使用 /pua -- 任务描述。`);
88
+ return { kind: command };
89
+ default:
90
+ return { kind: 'activate', task: input };
91
+ }
92
+ }
93
+ /** 循环配置从用户原生命令读取,模型不能通过输出修改独立验证条件。 */
94
+ function parseLoop(input, defaults) {
95
+ const tokens = [];
96
+ const lexer = /\s*(?:"((?:\\"|[^"])*)"|'([^']*)'|([^\s"']+))(?=\s|$)/gyu;
97
+ let offset = 0;
98
+ while (offset < input.trimEnd().length) {
99
+ lexer.lastIndex = offset;
100
+ const match = lexer.exec(input);
101
+ if (!match)
102
+ throw new Error('Loop 参数引号未闭合或格式无效,请将任务和完整验证命令分别放在引号中。');
103
+ tokens.push(match[1] !== undefined ? match[1].replaceAll('\\"', '"') : (match[2] ?? match[3]));
104
+ offset = lexer.lastIndex;
105
+ }
106
+ const seen = new Set();
107
+ let maxIterations = defaults?.maxIterations ?? 0;
108
+ let verify = defaults?.verify.trim() || undefined;
109
+ const task = [];
110
+ for (let i = 0; i < tokens.length; i++) {
111
+ const token = tokens[i];
112
+ if (token === '--max-iterations') {
113
+ if (seen.has(token))
114
+ throw new Error('--max-iterations 不能重复。');
115
+ seen.add(token);
116
+ const value = tokens[++i];
117
+ if (!value || !/^\d+$/.test(value) || Number(value) > 10000)
118
+ throw new Error('--max-iterations 必须为 0–10000;0 表示按原版不限轮次。');
119
+ maxIterations = Number(value);
120
+ }
121
+ else if (token === '--verify') {
122
+ if (seen.has(token))
123
+ throw new Error('--verify 不能重复。');
124
+ seen.add(token);
125
+ const value = tokens[++i];
126
+ if (value === undefined || value.startsWith('--'))
127
+ throw new Error('--verify 后需要带引号的验证命令。');
128
+ verify = value;
129
+ if (!verify.trim())
130
+ throw new Error('验证命令不能为空。');
131
+ }
132
+ else if (token.startsWith('--'))
133
+ throw new Error(`不支持循环选项:${token}`);
134
+ else
135
+ task.push(token);
136
+ }
137
+ if (!task.join(' ').trim())
138
+ throw new Error('loop 需要任务描述,例如 /pua loop "修复测试" --verify "npm test" --max-iterations 10。');
139
+ return { kind: 'loop', task: task.join(' ').trim(), maxIterations, ...(verify === undefined ? {} : { verify }), ...(defaults ? { verificationTimeout: defaults.verificationTimeout } : {}) };
140
+ }
141
+ function parseJson(text) {
142
+ try {
143
+ return JSON.parse(text);
144
+ }
145
+ catch {
146
+ throw new Error('配置 JSON 格式无效,请检查引号、逗号和括号。');
147
+ }
148
+ }
149
+ //# sourceMappingURL=args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAiB,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAgB,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAA2B,MAAM,oBAAoB,CAAC;AAWvG,2DAA2D;AAC3D,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,YAAqF;IAC1H,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,6BAA6B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AAE,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;IACxH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAC/L,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,IAAI,CAAC;QAAC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAAC,CAAC;IAChC,MAAM,CAAC;QAAC,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAAC,CAAC;AACzD,CAAC","sourcesContent":["import { resolveFlavor, type FlavorId } from './flavors.js';\nimport { MODES, type PuaMode } from './content.js';\nimport { CONFIG_KEYS, loopStartSchema, parsePatch, type ConfigurationPatch } from './configuration.js';\n\nexport type Action =\n | { readonly kind: 'configure'; readonly patch: ConfigurationPatch }\n | { readonly kind: 'activate' | 'review'; readonly task: string }\n | { readonly kind: 'flavor'; readonly flavor: FlavorId | 'auto' }\n | { readonly kind: 'mode'; readonly mode: PuaMode; readonly task: string }\n | { readonly kind: 'loop'; readonly task: string; readonly maxIterations: number; readonly verify?: string; readonly verificationTimeout?: number }\n | { readonly kind: 'again' | 'done-check' | 'evidence' | 'kpi' | 'survey'; readonly task?: string }\n | { readonly kind: 'on' | 'off' | 'offline' | 'status' | 'help' | 'flavors' | 'cancel-pua-loop' | 'team-status' | 'reap-orphans' | 'teardown-all' };\n\n/** 解析 /pua 后的文本;普通命令限 8 KiB;结构化配置保留 128 KiB 传输上限并按字段校验。 */\nexport function parseArgs(raw: string, loopDefaults?: { maxIterations: number; verify: string; verificationTimeout: number }): Action {\n if (Buffer.byteLength(raw, 'utf8') > (/^\\s*(?:config|loop-json)\\s/u.test(raw) ? 131072 : 8192)) throw new Error('输入超过长度限制,请缩短任务或验收命令。');\n if (/[\\u0000-\\u0008\\u000b\\u000c\\u000e-\\u001f\\u007f]/u.test(raw)) throw new Error('输入包含不支持的控制字符。');\n let input = raw.trim();\n // 兼容用户从帮助中再次粘贴 /pua,但不递归吞掉任意多个前缀。\n if (/^\\/?pua(?::|\\s|$)/i.test(input)) {\n input = input.replace(/^\\/?pua(?::|\\s+|$)/i, '').trim();\n if (!input || /^\\/?pua(?::|\\s|$)/i.test(input)) throw new Error('请只输入一次 /pua 前缀,例如 /pua flavor。');\n }\n if (!input) return { kind: 'activate', task: '' };\n const aliases: Record<string, Action> = {\n '换个方法': { kind: 'again' }, '再试试': { kind: 'again' },\n '证据呢': { kind: 'evidence' }, '数据在哪': { kind: 'evidence' },\n '没跑测试别说完成': { kind: 'done-check' }, '验收': { kind: 'done-check' },\n };\n if (Object.hasOwn(aliases, input)) return aliases[input]!;\n if (/^(?:你来)?(?:审查|评估|分析)(?:一下)?(?:这个|当前)?(?:项目|仓库|代码)[。!!??]?$/u.test(input)) return { kind: 'review', task: input };\n const first = /^(\\S+)(?:\\s+([\\s\\S]*))?$/.exec(input)!;\n const command = first[1]!.toLowerCase();\n const rest = (first[2] ?? '').trim();\n if (command === 'loop-json') {\n const { verify, ...value } = loopStartSchema.parse(parseJson(rest));\n return { kind: 'loop', ...value, ...(verify.trim() ? { verify } : {}) };\n }\n if (command === 'config') return { kind: 'configure', patch: parsePatch(parseJson(rest)) };\n if (command === 'reset') {\n if (rest && !CONFIG_KEYS.includes(rest as typeof CONFIG_KEYS[number])) throw new Error('未知配置项。');\n return { kind: 'configure', patch: Object.fromEntries((rest ? [rest] : CONFIG_KEYS).map(key => [key, null])) };\n }\n if (command === '--') {\n if (!rest) throw new Error('-- 后需要任务描述。');\n return { kind: 'activate', task: rest };\n }\n if (command.startsWith('-')) throw new Error('不支持此选项。输入 /pua help 查看用法。');\n if (command === 'flavor' || command === '味道' || command === '风味') {\n if (!rest) return { kind: 'flavors' };\n if (rest === 'auto' || rest === '自动') return { kind: 'flavor', flavor: 'auto' };\n const flavor = resolveFlavor(rest);\n if (!flavor) throw new Error('未知风味。输入 /pua flavor 查看可用名称。');\n return { kind: 'flavor', flavor };\n }\n if (command === 'review') return { kind: 'review', task: rest || '审查当前项目' };\n if (['ding', '钉味', '置身钉内', '置身钉外', '每日一包', '薛定谔的用户', '病态敏捷', '望舒行动'].includes(command)) return { kind: 'mode', mode: 'pua', task: `使用钉内/钉外味。${rest}` };\n if (command === 'loop' || command === 'pua-loop') return parseLoop(rest, loopDefaults);\n if (MODES.includes(command as PuaMode)) return { kind: 'mode', mode: command as PuaMode, task: rest };\n const typos: Record<string, string> = { in: 'on', onn: 'on', of: 'off', offn: 'off', flavour: 'flavor', flaver: 'flavor', falvor: 'flavor', stauts: 'status', stats: 'status', agian: 'again' };\n if (Object.hasOwn(typos, command) && (!rest || command.length >= 4)) throw new Error(`可能想输入 /pua ${typos[command]}。若确实要把原文作为任务,请使用 /pua -- ${input}。`);\n switch (command) {\n case 'again': case 'done-check': case 'evidence': case 'kpi': case 'survey':\n return rest ? { kind: command, task: rest } : { kind: command };\n case 'on': case 'off': case 'offline': case 'status': case 'help': case 'cancel-pua-loop': case 'team-status': case 'reap-orphans': case 'teardown-all':\n if (rest) throw new Error(`${command} 不接受额外参数;任务以此单词开头时请使用 /pua -- 任务描述。`);\n return { kind: command };\n default:\n return { kind: 'activate', task: input };\n }\n}\n\n/** 循环配置从用户原生命令读取,模型不能通过输出修改独立验证条件。 */\nfunction parseLoop(input: string, defaults?: { maxIterations: number; verify: string; verificationTimeout: number }): Action {\n const tokens: string[] = [];\n const lexer = /\\s*(?:\"((?:\\\\\"|[^\"])*)\"|'([^']*)'|([^\\s\"']+))(?=\\s|$)/gyu;\n let offset = 0;\n while (offset < input.trimEnd().length) {\n lexer.lastIndex = offset;\n const match = lexer.exec(input);\n if (!match) throw new Error('Loop 参数引号未闭合或格式无效,请将任务和完整验证命令分别放在引号中。');\n tokens.push(match[1] !== undefined ? match[1].replaceAll('\\\\\"', '\"') : (match[2] ?? match[3])!);\n offset = lexer.lastIndex;\n }\n const seen = new Set<string>();\n let maxIterations = defaults?.maxIterations ?? 0;\n let verify: string | undefined = defaults?.verify.trim() || undefined;\n const task: string[] = [];\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i]!;\n if (token === '--max-iterations') {\n if (seen.has(token)) throw new Error('--max-iterations 不能重复。');\n seen.add(token);\n const value = tokens[++i];\n if (!value || !/^\\d+$/.test(value) || Number(value) > 10000) throw new Error('--max-iterations 必须为 0–10000;0 表示按原版不限轮次。');\n maxIterations = Number(value);\n } else if (token === '--verify') {\n if (seen.has(token)) throw new Error('--verify 不能重复。');\n seen.add(token);\n const value = tokens[++i];\n if (value === undefined || value.startsWith('--')) throw new Error('--verify 后需要带引号的验证命令。');\n verify = value;\n if (!verify.trim()) throw new Error('验证命令不能为空。');\n } else if (token.startsWith('--')) throw new Error(`不支持循环选项:${token}`);\n else task.push(token);\n }\n if (!task.join(' ').trim()) throw new Error('loop 需要任务描述,例如 /pua loop \"修复测试\" --verify \"npm test\" --max-iterations 10。');\n return { kind: 'loop', task: task.join(' ').trim(), maxIterations, ...(verify === undefined ? {} : { verify }), ...(defaults ? { verificationTimeout: defaults.verificationTimeout } : {}) };\n}\n\nfunction parseJson(text: string): unknown {\n try { return JSON.parse(text); }\n catch { throw new Error('配置 JSON 格式无效,请检查引号、逗号和括号。'); }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { ConfigurationSnapshot, PuaRemoteApi } from './remote-contract.js';
2
+ /** 聊天入口独立读取全局可见性;新会话未就绪时快速重试,稳定后低频同步。 */
3
+ export declare function watchComposerConfiguration(remote: Pick<PuaRemoteApi, 'getGlobal' | 'getSession'>, sessionId: string, onGlobal: (enabled: boolean) => void, onSession: (snapshot: ConfigurationSnapshot) => void, onError?: (message: string) => void): {
4
+ refresh: () => void;
5
+ dispose: () => void;
6
+ };
@@ -0,0 +1,41 @@
1
+ /** 聊天入口独立读取全局可见性;新会话未就绪时快速重试,稳定后低频同步。 */
2
+ export function watchComposerConfiguration(remote, sessionId, onGlobal, onSession, onError = () => { }) {
3
+ let active = true;
4
+ let pending = false;
5
+ let retryDelay = 250;
6
+ let timer;
7
+ const refresh = () => {
8
+ if (!active || pending)
9
+ return;
10
+ clearTimeout(timer);
11
+ pending = true;
12
+ let failed = false;
13
+ // 不用 Promise.all 将可见性绑在 Agent 的加载生命周期上。
14
+ const global = Promise.resolve().then(() => remote.getGlobal()).then(result => {
15
+ if (!result.ok)
16
+ throw new Error(result.error.message);
17
+ if (active) {
18
+ onGlobal(result.value.values.enabled);
19
+ onError('');
20
+ }
21
+ }).catch(() => { failed = true; if (active)
22
+ onError('无法读取全局配置,请检查连接或打开插件配置页重试。'); });
23
+ const session = Promise.resolve().then(() => remote.getSession(sessionId)).then(result => {
24
+ if (!result.ok)
25
+ throw new Error(result.error.message);
26
+ if (active)
27
+ onSession(result.value);
28
+ }).catch(() => { failed = true; });
29
+ void Promise.all([global, session]).then(() => {
30
+ pending = false;
31
+ if (!active)
32
+ return;
33
+ const delay = failed ? retryDelay : 4000;
34
+ retryDelay = failed ? Math.min(retryDelay * 2, 4000) : 250;
35
+ timer = setTimeout(refresh, delay);
36
+ });
37
+ };
38
+ refresh();
39
+ return { refresh, dispose: () => { active = false; clearTimeout(timer); } };
40
+ }
41
+ //# sourceMappingURL=client-refresh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-refresh.js","sourceRoot":"","sources":["../src/client-refresh.ts"],"names":[],"mappings":"AAEA,yCAAyC;AACzC,MAAM,UAAU,0BAA0B,CACxC,MAAsD,EACtD,SAAiB,EACjB,QAAoC,EACpC,SAAoD,EACpD,UAAqC,GAAG,EAAE,GAAE,CAAC;IAE7C,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AC,CAAC;QACtC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YAC5C,OAAO,GAAG,KAAK,CAAC;YAChB,IAAI,CAAC,MAAM;gBAAE,OAAO;YACpB,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;YACzC,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YAC3D,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IACF,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9E,CAAC","sourcesContent":["import type { ConfigurationSnapshot, PuaRemoteApi } from './remote-contract.js';\n\n/** 聊天入口独立读取全局可见性;新会话未就绪时快速重试,稳定后低频同步。 */\nexport function watchComposerConfiguration(\n remote: Pick<PuaRemoteApi, 'getGlobal' | 'getSession'>,\n sessionId: string,\n onGlobal: (enabled: boolean) => void,\n onSession: (snapshot: ConfigurationSnapshot) => void,\n onError: (message: string) => void = () => {},\n): { refresh: () => void; dispose: () => void } {\n let active = true;\n let pending = false;\n let retryDelay = 250;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const refresh = () => {\n if (!active || pending) return;\n clearTimeout(timer);\n pending = true;\n let failed = false;\n // 不用 Promise.all 将可见性绑在 Agent 的加载生命周期上。\n const global = Promise.resolve().then(() => remote.getGlobal()).then(result => {\n if (!result.ok) throw new Error(result.error.message);\n if (active) { onGlobal(result.value.values.enabled); onError(''); }\n }).catch(() => { failed = true; if (active) onError('无法读取全局配置,请检查连接或打开插件配置页重试。'); });\n const session = Promise.resolve().then(() => remote.getSession(sessionId)).then(result => {\n if (!result.ok) throw new Error(result.error.message);\n if (active) onSession(result.value);\n }).catch(() => { failed = true; });\n void Promise.all([global, session]).then(() => {\n pending = false;\n if (!active) return;\n const delay = failed ? retryDelay : 4000;\n retryDelay = failed ? Math.min(retryDelay * 2, 4000) : 250;\n timer = setTimeout(refresh, delay);\n });\n };\n refresh();\n return { refresh, dispose: () => { active = false; clearTimeout(timer); } };\n}\n"]}
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import type { TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol';
3
+ import { type PuaRemoteApi } from './remote-contract.js';
4
+ interface ClientContext {
5
+ slots: {
6
+ inject(name: string, register: () => () => void): () => void;
7
+ register(options: {
8
+ name: string;
9
+ id?: string;
10
+ key?: string;
11
+ order?: number;
12
+ label?: string;
13
+ }, render: (props: {
14
+ sessionId?: string;
15
+ }) => React.ReactNode): () => void;
16
+ };
17
+ remote: {
18
+ $mount(contribution: TypertRemoteContribution): Promise<() => void>;
19
+ };
20
+ get(name: string): unknown;
21
+ effect(callback: () => () => void): void;
22
+ }
23
+ export declare const inject: string[];
24
+ /** 两个入口共享字段与校验;会话入口永远不调用全局写入方法。 */
25
+ export declare function ConfigurationPanel({ remote, sessionId }: {
26
+ remote: PuaRemoteApi;
27
+ sessionId?: string | undefined;
28
+ }): React.ReactElement;
29
+ export declare function apply(ctx: ClientContext): Promise<() => void>;
30
+ export {};