zen-code 4.0.0 → 4.2.0

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 (27) hide show
  1. package/dist/{MultiLineTextInput-DjNvaZzA.mjs → MultiLineTextInput-e7hD79Wp.mjs} +2 -2
  2. package/dist/{_commonjsHelpers-ByX85dGu.mjs → _commonjsHelpers-DQNKXVTB.mjs} +2 -2
  3. package/dist/app-DWJrZDvr.mjs +12316 -0
  4. package/dist/{checkpoint-1sAx_j1E-vdL63_qZ.mjs → checkpoint-1sAx_j1E-C7OZFRPe.mjs} +2 -2
  5. package/dist/{checkpoint-DxiUsHMy-DSc-mf5U.mjs → checkpoint-DxiUsHMy-LKqXeDEy.mjs} +2 -2
  6. package/dist/{devtools-DpL9Fl6d.mjs → devtools-CzaVuYnh.mjs} +1 -1
  7. package/dist/{graphBuilder-ulTm2bmI.mjs → graphBuilder-B3T9KyfH.mjs} +11869 -11311
  8. package/dist/{id-BHzJB_zk.mjs → id-DAEnqc1v.mjs} +5 -5
  9. package/dist/{index-BrsJ_rEy.mjs → index-B9w1j1Jz.mjs} +5 -5
  10. package/dist/{index-hjtoWC6i.mjs → index-D7W7mYQR.mjs} +3 -3
  11. package/dist/{memories-C_p4qG-9.mjs → memories-D7PFLLlR.mjs} +1 -1
  12. package/dist/nonInteractive.mjs +21 -22
  13. package/dist/{queue-D6tEGCGs-dshzv8m6.mjs → queue-D6tEGCGs-C8z6cY9y.mjs} +1 -1
  14. package/dist/{shallow-BJVbNSyQ.mjs → shallow-ChkcFpXh.mjs} +3 -3
  15. package/dist/subTasks-PsCKmIx0.mjs +210 -0
  16. package/dist/tasks-Dmf3N6e4.mjs +237 -0
  17. package/dist/zen-code.mjs +2 -2
  18. package/dist/zen-init.mjs +1 -526
  19. package/dist/zen-keyboard.mjs +1 -1
  20. package/package.json +2 -2
  21. package/dist/FileSystemConfigStore-Bog5vylu.mjs +0 -47
  22. package/dist/app-QzdcE86p.mjs +0 -11834
  23. package/dist/ask_agents-bHg8fyUp.mjs +0 -67
  24. package/dist/get_allowed_models-DWso18Ri.mjs +0 -253
  25. package/dist/index-BG-c4_r3.mjs +0 -449
  26. package/dist/subagents-DnvCjtPv.mjs +0 -95
  27. package/dist/tasks-DhCRIevp.mjs +0 -113
@@ -1,449 +0,0 @@
1
- import f from "micromatch";
2
- import { z as i } from "zod";
3
- import "lowdb";
4
- import "lowdb/node";
5
- import "yaml";
6
- var o = /* @__PURE__ */ ((s) => (s.ALLOW = "allow", s.ASK = "ask", s.DENY = "deny", s))(o || {});
7
- i.object({
8
- tool: i.string(),
9
- specifier: i.string().optional(),
10
- action: i.nativeEnum(o)
11
- });
12
- i.object({
13
- allow: i.array(i.string()).optional(),
14
- ask: i.array(i.string()).optional(),
15
- deny: i.array(i.string()).optional(),
16
- defaultMode: i.nativeEnum(o).optional()
17
- });
18
- i.object({
19
- name: i.string(),
20
- args: i.record(i.string(), i.any())
21
- });
22
- class u {
23
- rules;
24
- defaultMode;
25
- patternCache = /* @__PURE__ */ new Map();
26
- constructor(t) {
27
- this.rules = t.rules, this.defaultMode = t.defaultMode || o.ASK, this.rules.sort((e, a) => {
28
- const n = { deny: 0, ask: 1, allow: 2 }, r = n[e.action] - n[a.action];
29
- if (r !== 0)
30
- return r;
31
- const l = e.specifier == null ? 1 : 0, h = a.specifier == null ? 1 : 0;
32
- return l - h;
33
- });
34
- }
35
- /**
36
- * Check if a tool call is permitted
37
- */
38
- checkPermission(t) {
39
- for (const e of this.rules)
40
- if (this.matchRule(e, t))
41
- return {
42
- allowed: e.action === "allow" || e.action === "ask",
43
- requiresApproval: e.action === "ask",
44
- matchedRule: e,
45
- reason: this.getReason(e)
46
- };
47
- return {
48
- allowed: this.defaultMode === "allow" || this.defaultMode === "ask",
49
- requiresApproval: this.defaultMode === "ask",
50
- reason: `No matching rule, using default mode: ${this.defaultMode}`
51
- };
52
- }
53
- /**
54
- * Check if a rule matches a tool call
55
- */
56
- matchRule(t, e) {
57
- if (t.tool !== e.name)
58
- return !1;
59
- if (!t.specifier)
60
- return !0;
61
- const a = this.argsToString(e.args);
62
- return e.name === "Bash" ? this.matchBashCommand(t.specifier, a) : t.specifier.endsWith(" ") && !/[*?[\\]/.test(t.specifier) ? a.startsWith(t.specifier) : this.matchGlob(t.specifier, a);
63
- }
64
- /**
65
- * Match Bash commands with shell operator awareness
66
- */
67
- matchBashCommand(t, e) {
68
- if (/[;&|]/.test(e))
69
- return !1;
70
- const n = /[<>()]/;
71
- if (n.test(e)) {
72
- const r = e.split(n)[0].trim();
73
- return this.matchBashPattern(t, r);
74
- }
75
- return this.matchBashPattern(t, e);
76
- }
77
- /**
78
- * Match Bash command patterns with support for prefix and glob matching
79
- */
80
- matchBashPattern(t, e) {
81
- return t.endsWith(" ") ? e.startsWith(t) : this.matchGlob(t, e);
82
- }
83
- /**
84
- * Glob pattern matching using micromatch with caching
85
- */
86
- matchGlob(t, e) {
87
- try {
88
- const a = t.replace(/^\.\//, ""), n = e.replace(/^\.\//, ""), r = `${t}::${e}`, l = this.patternCache.get(r);
89
- if (l !== void 0)
90
- return l;
91
- const h = f.isMatch(n, a, {
92
- nocase: !1,
93
- dot: !0
94
- });
95
- return this.cacheResult(r, h), h;
96
- } catch {
97
- return e === t;
98
- }
99
- }
100
- /**
101
- * Cache matching result with LRU-style size limit
102
- */
103
- cacheResult(t, e) {
104
- if (this.patternCache.size > 1e3) {
105
- const a = this.patternCache.keys().next().value;
106
- a && this.patternCache.delete(a);
107
- }
108
- this.patternCache.set(t, e);
109
- }
110
- /**
111
- * Convert tool arguments to string representation
112
- */
113
- argsToString(t) {
114
- return typeof t == "object" && t !== null ? "command" in t && t.command ? String(t.command) : "file_path" in t && t.file_path ? String(t.file_path) : Object.values(t).flat().join(" ") : String(t);
115
- }
116
- /**
117
- * Get human-readable reason for permission decision
118
- */
119
- getReason(t) {
120
- const e = t.action.toUpperCase(), a = t.tool, n = t.specifier ? `(${t.specifier})` : "";
121
- return `${e} rule matched: ${a}${n}`;
122
- }
123
- /**
124
- * Parse permission rule from string format
125
- * Examples:
126
- * - "Bash" -> { tool: "Bash", action: "allow" }
127
- * - "Bash(git commit )" -> { tool: "Bash", specifier: "git commit ", action: "allow" }
128
- */
129
- static parseRule(t, e) {
130
- const a = t.match(/^(\w+)(?:\((.*)\))?$/);
131
- if (!a)
132
- throw new Error(`Invalid permission rule format: ${t}`);
133
- const [, n, r] = a;
134
- return {
135
- tool: n,
136
- specifier: r,
137
- // MODIFIED: Don't trim - preserve trailing spaces which are significant for glob patterns
138
- action: e
139
- };
140
- }
141
- /**
142
- * Create matcher from configuration object
143
- */
144
- static fromConfig(t) {
145
- const e = [];
146
- for (const a of t.allow || [])
147
- e.push(u.parseRule(a, o.ALLOW));
148
- for (const a of t.ask || [])
149
- e.push(u.parseRule(a, o.ASK));
150
- for (const a of t.deny || [])
151
- e.push(u.parseRule(a, o.DENY));
152
- return new u({
153
- rules: e,
154
- defaultMode: t.defaultMode || o.ASK
155
- });
156
- }
157
- /**
158
- * Clear cache (useful for testing or config reload)
159
- */
160
- clearCache() {
161
- this.patternCache.clear();
162
- }
163
- /**
164
- * Get current cache size
165
- */
166
- getCacheSize() {
167
- return this.patternCache.size;
168
- }
169
- }
170
- class c {
171
- configStore;
172
- /** 工具名称映射 */
173
- toolNameMapper = {};
174
- constructor(t) {
175
- this.configStore = t;
176
- }
177
- // ========== 单例模式 ==========
178
- static instance = null;
179
- /**
180
- * 获取单例实例
181
- * @param configStore 配置存储实例(仅首次调用需要)
182
- */
183
- static getInstance(t) {
184
- if (!c.instance) {
185
- if (!t)
186
- throw new Error("PermissionStore not initialized. Provide configStore on first call.");
187
- c.instance = new c(t);
188
- }
189
- return c.instance;
190
- }
191
- /**
192
- * 重置单例(测试用)
193
- */
194
- static resetInstance() {
195
- c.instance = null;
196
- }
197
- // ========== 业务方法 ==========
198
- /**
199
- * 获取权限匹配器实例
200
- */
201
- async getPermissions() {
202
- const t = await this.configStore.getConfig();
203
- if (t.permissions)
204
- return u.fromConfig(t.permissions);
205
- }
206
- /**
207
- * 检查 Bash 命令权限
208
- */
209
- async checkBashPermission(t, e) {
210
- return (await this.getPermissions())?.checkPermission({
211
- name: "Bash",
212
- args: { command: t, cwd: e }
213
- });
214
- }
215
- /**
216
- * 检查读取文件权限
217
- */
218
- async checkReadPermission(t) {
219
- return (await this.getPermissions())?.checkPermission({
220
- name: "Read",
221
- args: { file_path: t }
222
- });
223
- }
224
- /**
225
- * 检查写入文件权限
226
- */
227
- async checkWritePermission(t) {
228
- return (await this.getPermissions())?.checkPermission({
229
- name: "Write",
230
- args: { file_path: t }
231
- });
232
- }
233
- }
234
- class S {
235
- configStore;
236
- skillStore;
237
- pluginStore;
238
- remoteStore;
239
- permissionStore;
240
- _initialized = !1;
241
- constructor(t, e, a, n) {
242
- this.configStore = t, this.skillStore = e, this.pluginStore = a, this.remoteStore = n, this.permissionStore = c.getInstance(t);
243
- }
244
- /**
245
- * 初始化管理器(延迟初始化)
246
- * 必须在使用其他方法前调用
247
- */
248
- async initialize() {
249
- this._initialized || ("initialize" in this.configStore && typeof this.configStore.initialize == "function" && await this.configStore.initialize(), "initialize" in this.skillStore && typeof this.skillStore.initialize == "function" && await this.skillStore.initialize(), "initialize" in this.pluginStore && typeof this.pluginStore.initialize == "function" && await this.pluginStore.initialize(), this._initialized = !0);
250
- }
251
- /**
252
- * 确保已初始化(内部使用)
253
- */
254
- async ensureInitialized() {
255
- if (!this._initialized)
256
- throw new Error("ConfigManager not initialized. Call await manager.initialize() first.");
257
- }
258
- // 配置相关
259
- async getConfig() {
260
- return await this.ensureInitialized(), await this.configStore.getConfig();
261
- }
262
- async updateConfig(t) {
263
- return await this.ensureInitialized(), await this.configStore.updateConfig(t);
264
- }
265
- // Skills 相关
266
- async listSkills() {
267
- return await this.ensureInitialized(), await this.skillStore.listSkills();
268
- }
269
- async getSkill(t) {
270
- return await this.ensureInitialized(), await this.skillStore.getSkill(t);
271
- }
272
- async saveSkill(t, e) {
273
- return await this.ensureInitialized(), await this.skillStore.saveSkill(t, e);
274
- }
275
- async deleteSkill(t) {
276
- return await this.ensureInitialized(), await this.skillStore.deleteSkill(t);
277
- }
278
- async syncSkillsFromRemote() {
279
- if (await this.ensureInitialized(), !this.remoteStore)
280
- throw new Error("Remote store not configured");
281
- return await this.skillStore.syncFromRemote(this.remoteStore);
282
- }
283
- // Plugins 相关
284
- async listPlugins() {
285
- return await this.ensureInitialized(), await this.pluginStore.listPlugins();
286
- }
287
- async getPluginConfig(t) {
288
- return await this.ensureInitialized(), await this.pluginStore.getPluginConfig(t);
289
- }
290
- async updatePluginConfig(t, e) {
291
- return await this.ensureInitialized(), await this.pluginStore.updatePluginConfig(t, e);
292
- }
293
- async installPlugin(t, e) {
294
- return await this.ensureInitialized(), await this.pluginStore.installPlugin(t, e);
295
- }
296
- async uninstallPlugin(t) {
297
- return await this.ensureInitialized(), await this.pluginStore.uninstallPlugin(t);
298
- }
299
- // Permissions 相关
300
- /**
301
- * 检查 Bash 命令权限
302
- */
303
- async checkBashPermission(t, e) {
304
- return await this.ensureInitialized(), await this.permissionStore.checkBashPermission(t, e);
305
- }
306
- /**
307
- * 检查读取文件权限
308
- */
309
- async checkReadPermission(t) {
310
- return await this.ensureInitialized(), await this.permissionStore.checkReadPermission(t);
311
- }
312
- /**
313
- * 检查写入文件权限
314
- */
315
- async checkWritePermission(t) {
316
- return await this.ensureInitialized(), await this.permissionStore.checkWritePermission(t);
317
- }
318
- /**
319
- * 获取权限匹配器(用于高级操作)
320
- */
321
- async getPermissionMatcher() {
322
- return await this.ensureInitialized(), await this.permissionStore.getPermissions();
323
- }
324
- /** fs 专用 */
325
- getConfigPath() {
326
- return this.configStore?.dbPath;
327
- }
328
- }
329
- async function w() {
330
- const { FileSystemConfigStore: s } = await import("./FileSystemConfigStore-Bog5vylu.mjs"), { FileSystemSkillStore: t } = await import("./FileSystemSkillStore-yvEvcRxB.mjs"), { FileSystemPluginStore: e } = await import("./FileSystemPluginStore-ChortK7z.mjs"), a = new s(), n = new t(), r = new e(), l = new S(a, n, r);
331
- return await l.initialize(), l;
332
- }
333
- const y = i.enum(["idea", "bug_report", "feature", "refactor"]), k = i.enum(["low", "medium", "high", "critical"]), z = i.enum(["pending", "planned", "archived"]), C = i.enum(["user_input", "ai_suggestion", "conversation_derived"]), P = i.object({
334
- id: i.string().uuid(),
335
- type: y,
336
- title: i.string().min(1).max(200),
337
- description: i.string(),
338
- priority: k.default("medium"),
339
- source: C,
340
- status: z.default("pending"),
341
- createdAt: i.string().datetime(),
342
- tags: i.array(i.string()).default([]),
343
- metadata: i.object({
344
- relatedFiles: i.array(i.string()).optional(),
345
- conversationContext: i.string().optional(),
346
- estimatedComplexity: i.enum(["simple", "medium", "complex"]).optional()
347
- }).optional()
348
- });
349
- i.object({
350
- version: i.literal("1.0"),
351
- sparks: i.array(P),
352
- lastUpdated: i.string().datetime()
353
- });
354
- const d = i.enum([
355
- "pickup",
356
- // 待领取(新任务,未被 agent 接管)
357
- "running",
358
- // 运行中(agent 正在执行)
359
- "complete",
360
- // 已完成(成功完成)
361
- "error",
362
- // 已失败(失败,暂停中)
363
- "review",
364
- // 待审核(完成,等待人工确认)
365
- "feedback"
366
- // 待反馈(agent 卡住,需要人工输入)
367
- ]), m = i.enum([
368
- "default",
369
- "planner",
370
- "reviewer",
371
- "refactor",
372
- "finder",
373
- "debugger"
374
- ]), b = i.enum(["serial", "parallel"]), g = i.lazy(
375
- () => i.object({
376
- // 基本信息
377
- id: i.string(),
378
- title: i.string().min(1).max(200),
379
- description: i.string(),
380
- // 执行控制
381
- execution: b.optional(),
382
- children: i.array(i.lazy(() => g)).optional(),
383
- // Agent 分配
384
- agentType: m.optional(),
385
- threadId: i.string().optional(),
386
- // 元数据
387
- estimatedTime: i.string().optional(),
388
- complexity: i.enum(["simple", "medium", "complex"]).optional(),
389
- dependencies: i.array(i.string()).optional(),
390
- acceptanceCriteria: i.array(i.string()).optional(),
391
- // 状态相关(运行时)
392
- status: d.optional(),
393
- startedAt: i.string().datetime().optional(),
394
- completedAt: i.string().datetime().optional(),
395
- assignedTo: m.optional(),
396
- error: i.object({
397
- message: i.string(),
398
- stack: i.string().optional(),
399
- retryCount: i.number().optional()
400
- }).optional()
401
- })
402
- ), I = i.object({
403
- taskId: i.string(),
404
- planId: i.string(),
405
- threadId: i.string(),
406
- // 关联的 LangGraph thread ID
407
- agentType: m,
408
- // 改为类型安全的 AgentType
409
- status: d,
410
- startedAt: i.string().datetime(),
411
- completedAt: i.string().datetime().optional(),
412
- output: i.string().optional(),
413
- error: i.string().optional(),
414
- changedFiles: i.array(i.string()).optional()
415
- });
416
- i.object({
417
- version: i.literal("1.0"),
418
- lastUpdated: i.string().datetime(),
419
- // 活跃的任务树
420
- activePlanId: i.string().optional(),
421
- tasks: i.record(i.string(), g),
422
- // 执行历史
423
- history: i.array(I),
424
- // 全局配置
425
- config: i.object({
426
- maxConcurrentAgents: i.number().min(1).max(10).default(3),
427
- retryLimit: i.number().min(0).max(10).default(3),
428
- autoResume: i.boolean().default(!1)
429
- })
430
- });
431
- const p = await w(), v = async () => {
432
- await p.initialize();
433
- }, R = async () => await p.getConfig(), j = async (s) => {
434
- await p.updateConfig(s);
435
- }, E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
436
- __proto__: null,
437
- configStore: p,
438
- getConfig: R,
439
- initDb: v,
440
- updateConfig: j
441
- }, Symbol.toStringTag, { value: "Module" }));
442
- export {
443
- g as T,
444
- E as a,
445
- p as c,
446
- R as g,
447
- v as i,
448
- j as u
449
- };
@@ -1,95 +0,0 @@
1
- import { HumanMessage as r, SystemMessage as u } from "langchain";
2
- import { S as l, a as g } from "./ask_agents-bHg8fyUp.mjs";
3
- const b = `
4
-
5
- ## SubAgents System
6
-
7
- You have access to a subagent system that can delegate specialized tasks to other agents.
8
-
9
- **Available SubAgents:**
10
-
11
- {subagents_list}
12
-
13
- **How to Use SubAgents (Progressive Disclosure):**
14
-
15
- SubAgents follow a **progressive disclosure** pattern - you know they exist (name + description above), but you only delegate tasks when needed:
16
-
17
- 1. **Recognize when to delegate**: Check if the user's task matches a subagent's specialization
18
- 2. **Use the ask_subagents tool**: Call the tool with the subagent's ID and a clear task description
19
- 3. **Provide context**: Use the \`data_transfer\` parameter to pass relevant information
20
- 4. **Get results**: The subagent will process the task and return results
21
-
22
- **When to Use SubAgents:**
23
- - When the user's request requires specialized knowledge or workflows
24
- - When a task is complex and can be broken down into subtasks
25
- - When you need parallel processing or different expertise areas
26
- - When a subagent provides proven patterns for specific domains
27
-
28
- **SubAgent Tool Usage:**
29
-
30
- The \`ask_subagents\` tool is available for delegation:
31
-
32
- - **subagent_id**: The ID of the subagent to delegate to
33
- - **task_description**: Clear description of what needs to be done
34
- - **task_id** (optional): Identifier for tracking, it will automatically be generated after you run a subagent.
35
- - **data_transfer** (optional): Context/data to pass to the subagent
36
-
37
- **Example Workflow:**
38
-
39
- User: "Can you have the research agent look into quantum computing developments?"
40
-
41
- 1. Check available subagents above → See "research" subagent with ID
42
- 2. Use ask_subagents tool with appropriate parameters
43
- 3. Provide clear task description and any necessary context
44
- 4. Process the results from the subagent
45
-
46
- Remember: SubAgents are tools to distribute work and leverage specialized capabilities. When in doubt, check if a subagent exists for the task!
47
- `;
48
- class p {
49
- name = "SubAgentsMiddleware";
50
- stateSchema = l;
51
- contextSchema = void 0;
52
- tools = [];
53
- constructor() {
54
- this.tools.push(
55
- g(
56
- async (e, s, t) => await this.selectSubAgent(e, s, t),
57
- { name: "ask_subagents", description: "ask subagents to help you" }
58
- )
59
- );
60
- }
61
- subAgents = /* @__PURE__ */ new Map();
62
- addSubAgents(e, s) {
63
- this.subAgents.set(e, s);
64
- }
65
- /**
66
- * Format subagents metadata for display in system prompt.
67
- */
68
- formatSubAgentsList() {
69
- if (this.subAgents.size === 0)
70
- return "(No subagents available yet. You can add subagents using the addSubAgents method)";
71
- const e = [];
72
- for (const [s, t] of this.subAgents)
73
- e.push(`- **${s}**: Subagent for specialized tasks`), e.push(` → Use ask_subagents with subagent_id: "${s}"`);
74
- return e.join(`
75
- `);
76
- }
77
- async selectSubAgent(e, s, t) {
78
- return t.messages.push(new r(s.task_description)), this.subAgents.get(s.subagent_id)(e, s, t);
79
- }
80
- async wrapModelCall(e, s) {
81
- const t = this.formatSubAgentsList(), n = b.replace("{subagents_list}", t);
82
- let a;
83
- e.systemPrompt ? a = e.systemPrompt + `
84
-
85
- ` + n : a = n;
86
- const o = new u(a), i = {
87
- ...e,
88
- systemMessage: o
89
- };
90
- return await s(i);
91
- }
92
- }
93
- export {
94
- p as SubAgentsMiddleware
95
- };
@@ -1,113 +0,0 @@
1
- import "micromatch";
2
- import "./index-BG-c4_r3.mjs";
3
- import "lowdb";
4
- import "lowdb/node";
5
- import "yaml";
6
- import { T as a } from "./graphBuilder-ulTm2bmI.mjs";
7
- class r {
8
- store = null;
9
- projectRoot;
10
- constructor(t) {
11
- this.projectRoot = t;
12
- }
13
- /**
14
- * 初始化 Store
15
- */
16
- async initialize() {
17
- this.store || (this.store = new a(this.projectRoot), await this.store.initialize());
18
- }
19
- /**
20
- * 确保 Store 已初始化
21
- */
22
- ensureInitialized() {
23
- if (!this.store)
24
- throw new Error("TasksStore not initialized. Call initialize() first.");
25
- }
26
- /**
27
- * 获取所有任务
28
- */
29
- async getAllTasks() {
30
- return this.ensureInitialized(), await this.store.getAllTasks();
31
- }
32
- /**
33
- * 根据 status 获取任务
34
- */
35
- async getTasksByStatus(t) {
36
- return this.ensureInitialized(), await this.store.getTasksByStatus(t);
37
- }
38
- /**
39
- * 获取单个任务
40
- */
41
- async getTask(t) {
42
- return this.ensureInitialized(), await this.store.getTask(t);
43
- }
44
- /**
45
- * 更新任务状态
46
- */
47
- async updateTaskStatus(t, e) {
48
- return this.ensureInitialized(), await this.store.updateTask(t, { status: e });
49
- }
50
- /**
51
- * 删除任务
52
- */
53
- async deleteTask(t) {
54
- return this.ensureInitialized(), await this.store.deleteTask(t);
55
- }
56
- /**
57
- * 批量添加任务
58
- */
59
- async addTasks(t) {
60
- this.ensureInitialized(), await this.store.addTasks(t);
61
- }
62
- /**
63
- * 获取活跃 Plan ID
64
- */
65
- async getActivePlan() {
66
- return this.ensureInitialized(), await this.store.getActivePlan();
67
- }
68
- /**
69
- * 设置活跃 Plan ID
70
- */
71
- async setActivePlan(t) {
72
- this.ensureInitialized(), await this.store.setActivePlan(t);
73
- }
74
- /**
75
- * 获取任务统计
76
- */
77
- async getTaskStats() {
78
- const t = await this.getAllTasks();
79
- return {
80
- total: t.length,
81
- pickup: t.filter((e) => e.status === "pickup").length,
82
- running: t.filter((e) => e.status === "running").length,
83
- complete: t.filter((e) => e.status === "complete").length,
84
- error: t.filter((e) => e.status === "error").length,
85
- review: t.filter((e) => e.status === "review").length,
86
- feedback: t.filter((e) => e.status === "feedback").length
87
- };
88
- }
89
- /**
90
- * 获取执行历史
91
- */
92
- async getHistory(t) {
93
- return this.ensureInitialized(), await this.store.getHistory(t);
94
- }
95
- /**
96
- * 清空所有任务(慎用)
97
- */
98
- async clearAllTasks() {
99
- this.ensureInitialized(), await this.store.clearAllTasks();
100
- }
101
- }
102
- let i = null;
103
- function k(s) {
104
- if (!i) {
105
- if (!s)
106
- throw new Error("projectRoot is required for first initialization");
107
- i = new r(s);
108
- }
109
- return i;
110
- }
111
- export {
112
- k as getTasksStore
113
- };