zen-code 4.2.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.
@@ -1,237 +0,0 @@
1
- import "micromatch";
2
- import "./graphBuilder-B3T9KyfH.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
- };