zen-code 4.1.0 → 4.3.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.
- package/dist/{MultiLineTextInput-DjNvaZzA.mjs → MultiLineTextInput-e7hD79Wp.mjs} +2 -2
- package/dist/{_commonjsHelpers-ByX85dGu.mjs → _commonjsHelpers-DQNKXVTB.mjs} +2 -2
- package/dist/app-Dy9hkwWD.mjs +14467 -0
- package/dist/{checkpoint-1sAx_j1E-22R2HLa7.mjs → checkpoint-1sAx_j1E-DhkeZ_II.mjs} +2 -2
- package/dist/{checkpoint-DxiUsHMy-CaZzTHEH.mjs → checkpoint-DxiUsHMy-_eGVKDHU.mjs} +2 -2
- package/dist/{devtools-DpL9Fl6d.mjs → devtools-CzaVuYnh.mjs} +1 -1
- package/dist/{graphBuilder-BSX1uOgk.mjs → graphBuilder-2Ioob7L7.mjs} +9161 -8606
- package/dist/{id-CW5jldpA.mjs → id-CxmtJIkV.mjs} +5 -5
- package/dist/{index-DHHejsBD.mjs → index-BtzTnQfe.mjs} +13 -13
- package/dist/{index-C37SAWjK.mjs → index-CwuY4ELx.mjs} +3 -3
- package/dist/index-DeHHUkFW.mjs +23 -0
- package/dist/{memories-FoRbTUbN.mjs → memories-Dqh58QqM.mjs} +1 -1
- package/dist/nonInteractive.mjs +18 -19
- package/dist/{queue-D6tEGCGs-CGkpBFRj.mjs → queue-D6tEGCGs-C6wkO825.mjs} +1 -1
- package/dist/{shallow-CehIJgqa.mjs → shallow-Bky_pv_P.mjs} +3 -3
- package/dist/{subTasks-DRzFBQoV.mjs → subTasks-Cklo326x.mjs} +1 -1
- package/dist/zen-code.mjs +2 -2
- package/dist/zen-init.mjs +1 -534
- package/dist/zen-keyboard.mjs +1 -1
- package/package.json +3 -2
- package/dist/FileSystemConfigStore-ezrLDNGJ.mjs +0 -91
- package/dist/app-C-NaCZSh.mjs +0 -12053
- package/dist/get_allowed_models-DWso18Ri.mjs +0 -253
- package/dist/index-DFARkGOA.mjs +0 -442
- package/dist/tasks-D5CMeC2P.mjs +0 -237
package/dist/index-DFARkGOA.mjs
DELETED
|
@@ -1,442 +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-ezrLDNGJ.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
|
-
]), p = i.enum([
|
|
368
|
-
"default",
|
|
369
|
-
"planner",
|
|
370
|
-
"reviewer",
|
|
371
|
-
"refactor",
|
|
372
|
-
"finder",
|
|
373
|
-
"debugger",
|
|
374
|
-
"architect"
|
|
375
|
-
]), I = i.enum(["serial", "parallel"]), g = i.lazy(
|
|
376
|
-
() => i.object({
|
|
377
|
-
// 基本信息
|
|
378
|
-
id: i.string(),
|
|
379
|
-
title: i.string().min(1).max(200),
|
|
380
|
-
description: i.string(),
|
|
381
|
-
// 执行控制
|
|
382
|
-
execution: I.optional(),
|
|
383
|
-
children: i.array(i.lazy(() => g)).optional(),
|
|
384
|
-
// Agent 分配
|
|
385
|
-
agentType: p.optional(),
|
|
386
|
-
threadId: i.string().optional(),
|
|
387
|
-
// 元数据
|
|
388
|
-
estimatedTime: i.string().optional(),
|
|
389
|
-
complexity: i.enum(["simple", "medium", "complex"]).optional(),
|
|
390
|
-
dependencies: i.array(i.string()).optional(),
|
|
391
|
-
acceptanceCriteria: i.array(i.string()).optional(),
|
|
392
|
-
// 状态相关(运行时)
|
|
393
|
-
status: d.optional(),
|
|
394
|
-
startedAt: i.string().datetime().optional(),
|
|
395
|
-
completedAt: i.string().datetime().optional(),
|
|
396
|
-
assignedTo: p.optional(),
|
|
397
|
-
error: i.object({
|
|
398
|
-
message: i.string(),
|
|
399
|
-
stack: i.string().optional(),
|
|
400
|
-
retryCount: i.number().optional()
|
|
401
|
-
}).optional()
|
|
402
|
-
})
|
|
403
|
-
), b = i.object({
|
|
404
|
-
taskId: i.string(),
|
|
405
|
-
planId: i.string(),
|
|
406
|
-
threadId: i.string(),
|
|
407
|
-
// 关联的 LangGraph thread ID
|
|
408
|
-
agentType: p,
|
|
409
|
-
// 改为类型安全的 AgentType
|
|
410
|
-
status: d,
|
|
411
|
-
startedAt: i.string().datetime(),
|
|
412
|
-
completedAt: i.string().datetime().optional(),
|
|
413
|
-
output: i.string().optional(),
|
|
414
|
-
error: i.string().optional(),
|
|
415
|
-
changedFiles: i.array(i.string()).optional()
|
|
416
|
-
});
|
|
417
|
-
i.object({
|
|
418
|
-
version: i.literal("1.0"),
|
|
419
|
-
lastUpdated: i.string().datetime(),
|
|
420
|
-
// 活跃的任务树
|
|
421
|
-
activePlanId: i.string().optional(),
|
|
422
|
-
tasks: i.record(i.string(), g),
|
|
423
|
-
// 执行历史
|
|
424
|
-
history: i.array(b),
|
|
425
|
-
// 全局配置
|
|
426
|
-
config: i.object({
|
|
427
|
-
maxConcurrentAgents: i.number().min(1).max(10).default(3),
|
|
428
|
-
retryLimit: i.number().min(0).max(10).default(3),
|
|
429
|
-
autoResume: i.boolean().default(!1)
|
|
430
|
-
})
|
|
431
|
-
});
|
|
432
|
-
const m = await w(), A = async () => {
|
|
433
|
-
await m.initialize();
|
|
434
|
-
}, T = async () => await m.getConfig(), B = async (s) => {
|
|
435
|
-
await m.updateConfig(s);
|
|
436
|
-
};
|
|
437
|
-
export {
|
|
438
|
-
m as configStore,
|
|
439
|
-
T as getConfig,
|
|
440
|
-
A as initDb,
|
|
441
|
-
B as updateConfig
|
|
442
|
-
};
|
package/dist/tasks-D5CMeC2P.mjs
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import "micromatch";
|
|
2
|
-
import "./index-DFARkGOA.mjs";
|
|
3
|
-
import { Low as n } from "lowdb";
|
|
4
|
-
import { JSONFile as d } from "lowdb/node";
|
|
5
|
-
import "yaml";
|
|
6
|
-
import r from "node:path";
|
|
7
|
-
class h {
|
|
8
|
-
db;
|
|
9
|
-
dbPath;
|
|
10
|
-
constructor(t) {
|
|
11
|
-
this.dbPath = r.join(t, ".claude", "task.json");
|
|
12
|
-
const a = new d(this.dbPath);
|
|
13
|
-
this.db = new n(a, this.getDefaultData());
|
|
14
|
-
}
|
|
15
|
-
getDefaultData() {
|
|
16
|
-
return {
|
|
17
|
-
version: "1.0",
|
|
18
|
-
lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
19
|
-
tasks: {},
|
|
20
|
-
history: [],
|
|
21
|
-
config: {
|
|
22
|
-
maxConcurrentAgents: 3,
|
|
23
|
-
retryLimit: 3,
|
|
24
|
-
autoResume: !1
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* 初始化数据库
|
|
30
|
-
*/
|
|
31
|
-
async initialize() {
|
|
32
|
-
const t = await import("node:fs"), a = r.dirname(this.dbPath);
|
|
33
|
-
t.existsSync(a) || t.mkdirSync(a, { recursive: !0 }), await this.db.read(), this.db.data || (this.db.data = this.getDefaultData(), await this.db.write());
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* 获取单个任务
|
|
37
|
-
*/
|
|
38
|
-
async getTask(t) {
|
|
39
|
-
return await this.db.read(), this.db.data.tasks[t];
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* 更新任务
|
|
43
|
-
*/
|
|
44
|
-
async updateTask(t, a) {
|
|
45
|
-
await this.db.read();
|
|
46
|
-
const i = this.db.data.tasks[t];
|
|
47
|
-
return i ? (this.db.data.tasks[t] = {
|
|
48
|
-
...i,
|
|
49
|
-
...a
|
|
50
|
-
}, a.status && (a.status === "running" && !i.startedAt ? this.db.data.tasks[t].startedAt = (/* @__PURE__ */ new Date()).toISOString() : ["complete", "error", "review"].includes(a.status) && !i.completedAt && (this.db.data.tasks[t].completedAt = (/* @__PURE__ */ new Date()).toISOString())), this.db.data.lastUpdated = (/* @__PURE__ */ new Date()).toISOString(), await this.db.write(), !0) : !1;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* 批量添加任务(用于 Plan 初始化)
|
|
54
|
-
*/
|
|
55
|
-
async addTasks(t) {
|
|
56
|
-
await this.db.read();
|
|
57
|
-
for (const a of t)
|
|
58
|
-
this.db.data.tasks[a.id] = a;
|
|
59
|
-
this.db.data.lastUpdated = (/* @__PURE__ */ new Date()).toISOString(), await this.db.write();
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* 根据 status 获取任务列表
|
|
63
|
-
*/
|
|
64
|
-
async getTasksByStatus(t) {
|
|
65
|
-
return await this.db.read(), Object.values(this.db.data.tasks).filter((a) => a.status === t);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* 获取所有任务
|
|
69
|
-
*/
|
|
70
|
-
async getAllTasks() {
|
|
71
|
-
return await this.db.read(), Object.values(this.db.data.tasks);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* 添加执行记录
|
|
75
|
-
*/
|
|
76
|
-
async addHistory(t) {
|
|
77
|
-
await this.db.read(), this.db.data.history.push(t), await this.db.write();
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* 获取执行历史
|
|
81
|
-
*/
|
|
82
|
-
async getHistory(t) {
|
|
83
|
-
return await this.db.read(), t ? this.db.data.history.filter((a) => a.planId === t) : this.db.data.history;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* 设置活跃 Plan ID
|
|
87
|
-
*/
|
|
88
|
-
async setActivePlan(t) {
|
|
89
|
-
await this.db.read(), this.db.data.activePlanId = t, this.db.data.lastUpdated = (/* @__PURE__ */ new Date()).toISOString(), await this.db.write();
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* 获取活跃 Plan ID
|
|
93
|
-
*/
|
|
94
|
-
async getActivePlan() {
|
|
95
|
-
return await this.db.read(), this.db.data.activePlanId;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* 更新配置
|
|
99
|
-
*/
|
|
100
|
-
async updateConfig(t) {
|
|
101
|
-
await this.db.read(), this.db.data.config = {
|
|
102
|
-
...this.db.data.config,
|
|
103
|
-
...t
|
|
104
|
-
}, this.db.data.lastUpdated = (/* @__PURE__ */ new Date()).toISOString(), await this.db.write();
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* 获取配置
|
|
108
|
-
*/
|
|
109
|
-
async getConfig() {
|
|
110
|
-
return await this.db.read(), this.db.data.config;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* 清空所有任务(慎用)
|
|
114
|
-
*/
|
|
115
|
-
async clearAllTasks() {
|
|
116
|
-
await this.db.read(), this.db.data.tasks = {}, this.db.data.activePlanId = void 0, this.db.data.lastUpdated = (/* @__PURE__ */ new Date()).toISOString(), await this.db.write();
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* 删除单个任务
|
|
120
|
-
*/
|
|
121
|
-
async deleteTask(t) {
|
|
122
|
-
return await this.db.read(), this.db.data.tasks[t] ? (delete this.db.data.tasks[t], this.db.data.lastUpdated = (/* @__PURE__ */ new Date()).toISOString(), await this.db.write(), !0) : !1;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* 获取数据库路径(用于测试)
|
|
126
|
-
*/
|
|
127
|
-
getDbPath() {
|
|
128
|
-
return this.dbPath;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
class o {
|
|
132
|
-
store = null;
|
|
133
|
-
projectRoot;
|
|
134
|
-
constructor(t) {
|
|
135
|
-
this.projectRoot = t;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* 初始化 Store
|
|
139
|
-
*/
|
|
140
|
-
async initialize() {
|
|
141
|
-
this.store || (this.store = new h(this.projectRoot), await this.store.initialize());
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* 确保 Store 已初始化
|
|
145
|
-
*/
|
|
146
|
-
ensureInitialized() {
|
|
147
|
-
if (!this.store)
|
|
148
|
-
throw new Error("TasksStore not initialized. Call initialize() first.");
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* 获取所有任务
|
|
152
|
-
*/
|
|
153
|
-
async getAllTasks() {
|
|
154
|
-
return this.ensureInitialized(), await this.store.getAllTasks();
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* 根据 status 获取任务
|
|
158
|
-
*/
|
|
159
|
-
async getTasksByStatus(t) {
|
|
160
|
-
return this.ensureInitialized(), await this.store.getTasksByStatus(t);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* 获取单个任务
|
|
164
|
-
*/
|
|
165
|
-
async getTask(t) {
|
|
166
|
-
return this.ensureInitialized(), await this.store.getTask(t);
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* 更新任务状态
|
|
170
|
-
*/
|
|
171
|
-
async updateTaskStatus(t, a) {
|
|
172
|
-
return this.ensureInitialized(), await this.store.updateTask(t, { status: a });
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* 删除任务
|
|
176
|
-
*/
|
|
177
|
-
async deleteTask(t) {
|
|
178
|
-
return this.ensureInitialized(), await this.store.deleteTask(t);
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* 批量添加任务
|
|
182
|
-
*/
|
|
183
|
-
async addTasks(t) {
|
|
184
|
-
this.ensureInitialized(), await this.store.addTasks(t);
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* 获取活跃 Plan ID
|
|
188
|
-
*/
|
|
189
|
-
async getActivePlan() {
|
|
190
|
-
return this.ensureInitialized(), await this.store.getActivePlan();
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* 设置活跃 Plan ID
|
|
194
|
-
*/
|
|
195
|
-
async setActivePlan(t) {
|
|
196
|
-
this.ensureInitialized(), await this.store.setActivePlan(t);
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* 获取任务统计
|
|
200
|
-
*/
|
|
201
|
-
async getTaskStats() {
|
|
202
|
-
const t = await this.getAllTasks();
|
|
203
|
-
return {
|
|
204
|
-
total: t.length,
|
|
205
|
-
pickup: t.filter((a) => a.status === "pickup").length,
|
|
206
|
-
running: t.filter((a) => a.status === "running").length,
|
|
207
|
-
complete: t.filter((a) => a.status === "complete").length,
|
|
208
|
-
error: t.filter((a) => a.status === "error").length,
|
|
209
|
-
review: t.filter((a) => a.status === "review").length,
|
|
210
|
-
feedback: t.filter((a) => a.status === "feedback").length
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* 获取执行历史
|
|
215
|
-
*/
|
|
216
|
-
async getHistory(t) {
|
|
217
|
-
return this.ensureInitialized(), await this.store.getHistory(t);
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* 清空所有任务(慎用)
|
|
221
|
-
*/
|
|
222
|
-
async clearAllTasks() {
|
|
223
|
-
this.ensureInitialized(), await this.store.clearAllTasks();
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
let e = null;
|
|
227
|
-
function k(s) {
|
|
228
|
-
if (!e) {
|
|
229
|
-
if (!s)
|
|
230
|
-
throw new Error("projectRoot is required for first initialization");
|
|
231
|
-
e = new o(s);
|
|
232
|
-
}
|
|
233
|
-
return e;
|
|
234
|
-
}
|
|
235
|
-
export {
|
|
236
|
-
k as getTasksStore
|
|
237
|
-
};
|