@vibeflow-tools/cli 0.5.1 → 0.6.1

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 (109) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +199 -81
  3. package/dist/chunk-D6KVQU62.js +7 -0
  4. package/dist/{cli/chunk-QULSJOW5.js → chunk-NRMCK2HM.js} +4 -4
  5. package/dist/cli/chunk-D6KVQU62.js +7 -0
  6. package/dist/{chunk-QULSJOW5.js → cli/chunk-NRMCK2HM.js} +4 -4
  7. package/dist/cli/{files-H2UIFEPJ.js → files-GOVXPMB5.js} +1 -1
  8. package/dist/cli/{files-MIDXKOAF.js → files-TKEFFLPI.js} +1 -1
  9. package/dist/cli/index.js +88 -27952
  10. package/dist/client/kanban-browser.js +15 -15
  11. package/dist/client/kanban.css +1 -1
  12. package/dist/{files-H2UIFEPJ.js → files-GOVXPMB5.js} +1 -1
  13. package/dist/{files-MIDXKOAF.js → files-TKEFFLPI.js} +1 -1
  14. package/dist/index.js +88 -27952
  15. package/package.json +8 -3
  16. package/dist/chunk-252RNKHM.js +0 -2
  17. package/dist/chunk-43MUGU6Z.js +0 -67
  18. package/dist/chunk-4Y62J4KR.js +0 -438
  19. package/dist/chunk-6ABTC7IA.js +0 -482
  20. package/dist/chunk-7K2VHAWF.js +0 -569
  21. package/dist/chunk-BKTZSHJS.js +0 -2
  22. package/dist/chunk-BQLZVQ4E.js +0 -2
  23. package/dist/chunk-F57OXWVU.js +0 -33
  24. package/dist/chunk-I2OSZY66.js +0 -803
  25. package/dist/chunk-IZB3AHO6.js +0 -6
  26. package/dist/chunk-JKC6MUZ4.js +0 -558
  27. package/dist/chunk-KKBXVPTJ.js +0 -2
  28. package/dist/chunk-LK3IGDR6.js +0 -438
  29. package/dist/chunk-MKOKIWTN.js +0 -569
  30. package/dist/chunk-MW4OS3IK.js +0 -438
  31. package/dist/chunk-NRPOXSY6.js +0 -568
  32. package/dist/chunk-NUM3G22J.js +0 -569
  33. package/dist/chunk-O564QSMS.js +0 -569
  34. package/dist/chunk-OAGEPYIT.js +0 -535
  35. package/dist/chunk-PHBHAIHA.js +0 -33
  36. package/dist/chunk-PK737AKV.js +0 -560
  37. package/dist/chunk-TPDIOJDI.js +0 -7
  38. package/dist/chunk-TWAAPROG.js +0 -822
  39. package/dist/chunk-XF2CNPE4.js +0 -803
  40. package/dist/cli/chunk-252RNKHM.js +0 -2
  41. package/dist/cli/chunk-43MUGU6Z.js +0 -67
  42. package/dist/cli/chunk-4Y62J4KR.js +0 -438
  43. package/dist/cli/chunk-6ABTC7IA.js +0 -482
  44. package/dist/cli/chunk-7K2VHAWF.js +0 -569
  45. package/dist/cli/chunk-BKTZSHJS.js +0 -2
  46. package/dist/cli/chunk-BQLZVQ4E.js +0 -2
  47. package/dist/cli/chunk-F57OXWVU.js +0 -33
  48. package/dist/cli/chunk-I2OSZY66.js +0 -803
  49. package/dist/cli/chunk-IZB3AHO6.js +0 -6
  50. package/dist/cli/chunk-JKC6MUZ4.js +0 -558
  51. package/dist/cli/chunk-KKBXVPTJ.js +0 -2
  52. package/dist/cli/chunk-LK3IGDR6.js +0 -438
  53. package/dist/cli/chunk-MKOKIWTN.js +0 -569
  54. package/dist/cli/chunk-MW4OS3IK.js +0 -438
  55. package/dist/cli/chunk-NRPOXSY6.js +0 -568
  56. package/dist/cli/chunk-NUM3G22J.js +0 -569
  57. package/dist/cli/chunk-O564QSMS.js +0 -569
  58. package/dist/cli/chunk-OAGEPYIT.js +0 -535
  59. package/dist/cli/chunk-PHBHAIHA.js +0 -33
  60. package/dist/cli/chunk-PK737AKV.js +0 -560
  61. package/dist/cli/chunk-TPDIOJDI.js +0 -7
  62. package/dist/cli/chunk-TWAAPROG.js +0 -822
  63. package/dist/cli/chunk-XF2CNPE4.js +0 -803
  64. package/dist/cli/files-27OYPA7W.js +0 -20
  65. package/dist/cli/files-2TK74THO.js +0 -22
  66. package/dist/cli/files-3RDDXUOS.js +0 -2
  67. package/dist/cli/files-7275M2PW.js +0 -20
  68. package/dist/cli/files-D3YPV7QT.js +0 -20
  69. package/dist/cli/files-FER4UZ4X.js +0 -22
  70. package/dist/cli/files-H4FRDKJV.js +0 -22
  71. package/dist/cli/files-IJZVMROA.js +0 -22
  72. package/dist/cli/files-IX5QZQHC.js +0 -2
  73. package/dist/cli/files-JPVPKRMX.js +0 -2
  74. package/dist/cli/files-KH3UEFN7.js +0 -20
  75. package/dist/cli/files-LTDT5ZFT.js +0 -22
  76. package/dist/cli/files-O4WJLFMU.js +0 -2
  77. package/dist/cli/files-OYO6A6MZ.js +0 -22
  78. package/dist/cli/files-R6QHQBH4.js +0 -22
  79. package/dist/cli/files-UCALOYWZ.js +0 -22
  80. package/dist/cli/files-UWZP7P6B.js +0 -2
  81. package/dist/cli/files-VIDLQM7Y.js +0 -20
  82. package/dist/cli/files-X2RDLF3W.js +0 -22
  83. package/dist/cli/files-XVDNOAZB.js +0 -22
  84. package/dist/cli/workspace-NB6BACZA.js +0 -12
  85. package/dist/cli/workspace-X2NGGGTQ.js +0 -12
  86. package/dist/cli/workspace-X4QXECQQ.js +0 -12
  87. package/dist/files-27OYPA7W.js +0 -20
  88. package/dist/files-2TK74THO.js +0 -22
  89. package/dist/files-3RDDXUOS.js +0 -2
  90. package/dist/files-7275M2PW.js +0 -20
  91. package/dist/files-D3YPV7QT.js +0 -20
  92. package/dist/files-FER4UZ4X.js +0 -22
  93. package/dist/files-H4FRDKJV.js +0 -22
  94. package/dist/files-IJZVMROA.js +0 -22
  95. package/dist/files-IX5QZQHC.js +0 -2
  96. package/dist/files-JPVPKRMX.js +0 -2
  97. package/dist/files-KH3UEFN7.js +0 -20
  98. package/dist/files-LTDT5ZFT.js +0 -22
  99. package/dist/files-O4WJLFMU.js +0 -2
  100. package/dist/files-OYO6A6MZ.js +0 -22
  101. package/dist/files-R6QHQBH4.js +0 -22
  102. package/dist/files-UCALOYWZ.js +0 -22
  103. package/dist/files-UWZP7P6B.js +0 -2
  104. package/dist/files-VIDLQM7Y.js +0 -20
  105. package/dist/files-X2RDLF3W.js +0 -22
  106. package/dist/files-XVDNOAZB.js +0 -22
  107. package/dist/workspace-NB6BACZA.js +0 -12
  108. package/dist/workspace-X2NGGGTQ.js +0 -12
  109. package/dist/workspace-X4QXECQQ.js +0 -12
@@ -1,569 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/core/files.ts
4
- import {
5
- readdirSync as readdirSync2,
6
- writeFileSync as writeFileSync2,
7
- readFileSync as readFileSync2,
8
- unlinkSync as unlinkSync2,
9
- statSync,
10
- mkdirSync as mkdirSync2,
11
- existsSync as existsSync3
12
- } from "fs";
13
- import { join as join3, basename, isAbsolute } from "path";
14
-
15
- // src/core/types.ts
16
- var ANNOTATION_TAGS = [
17
- "TODO",
18
- "FEATURE",
19
- "VARIANT",
20
- "KEEP",
21
- "QUESTION",
22
- "CONTEXT"
23
- ];
24
- var PROTO_DIR = ".proto";
25
- var TASKS_DIR = "tasks";
26
- var COMMENTS_DIR = "comments";
27
- var FILES_DIR = "tasks/files";
28
- var AGENTS_DIR = "agents";
29
- var SCREENSHOTS_DIR = "tasks/screenshots";
30
- var CONFIG_FILE = "config.json";
31
-
32
- // src/core/tasks.ts
33
- import {
34
- existsSync as existsSync2,
35
- readFileSync,
36
- writeFileSync,
37
- mkdirSync,
38
- readdirSync,
39
- unlinkSync,
40
- renameSync
41
- } from "fs";
42
- import { join as join2, extname } from "path";
43
- import { randomBytes } from "crypto";
44
-
45
- // src/core/tasks-legacy.ts
46
- import { existsSync } from "fs";
47
- import { join } from "path";
48
- var VALID_STATUSES = ["backlog", "todo", "in-progress", "review", "done"];
49
- function parseFrontMatter(content) {
50
- const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/);
51
- if (!match) return { frontMatter: {}, body: content.trim() };
52
- const yaml = match[1];
53
- const body = match[2].trim();
54
- const frontMatter = {};
55
- for (const line of yaml.split("\n")) {
56
- const colonIdx = line.indexOf(":");
57
- if (colonIdx === -1) continue;
58
- const key = line.slice(0, colonIdx).trim();
59
- let value = line.slice(colonIdx + 1).trim();
60
- if (value.startsWith("'") && value.endsWith("'") || value.startsWith('"') && value.endsWith('"')) {
61
- value = value.slice(1, -1);
62
- }
63
- frontMatter[key] = value;
64
- }
65
- return { frontMatter, body };
66
- }
67
- function parseTask(content) {
68
- const { frontMatter, body } = parseFrontMatter(content);
69
- if (!frontMatter.id || !frontMatter.selector) {
70
- return null;
71
- }
72
- const titleMatch = body.match(/^#\s+(.+)/m);
73
- const title = titleMatch ? titleMatch[1].trim() : "Untitled";
74
- const description = body.replace(/^#\s+.+\n*/m, "").trim();
75
- return {
76
- id: frontMatter.id,
77
- title,
78
- description,
79
- status: VALID_STATUSES.includes(frontMatter.status) ? frontMatter.status : "todo",
80
- url: frontMatter.url || void 0,
81
- selector: frontMatter.selector,
82
- cssSelector: frontMatter.cssSelector || void 0,
83
- file: frontMatter.file || void 0,
84
- line: frontMatter.line ? Number(frontMatter.line) : void 0,
85
- col: frontMatter.col ? Number(frontMatter.col) : void 0,
86
- component: frontMatter.component || void 0,
87
- type: frontMatter.type || void 0,
88
- priority: frontMatter.priority || void 0,
89
- reportBack: frontMatter.reportBack === "true" ? true : void 0,
90
- created: frontMatter.created || (/* @__PURE__ */ new Date()).toISOString(),
91
- updated: frontMatter.updated || void 0,
92
- comments: [],
93
- files: []
94
- };
95
- }
96
-
97
- // src/core/tasks.ts
98
- function generateTaskId() {
99
- return randomBytes(15).toString("hex");
100
- }
101
- function getTasksDir(projectDir) {
102
- return join2(projectDir, PROTO_DIR, TASKS_DIR);
103
- }
104
- function migrateLegacyTaskAssetFolders(projectDir) {
105
- const protoRoot = join2(projectDir, PROTO_DIR);
106
- const legacyFilesDir = join2(protoRoot, "files");
107
- const nextFilesDir = join2(protoRoot, FILES_DIR);
108
- const legacyScreenshotsDir = join2(protoRoot, "screenshots");
109
- const nextScreenshotsDir = join2(protoRoot, SCREENSHOTS_DIR);
110
- if (existsSync2(legacyFilesDir)) {
111
- mkdirSync(nextFilesDir, { recursive: true });
112
- for (const entry of readdirSync(legacyFilesDir)) {
113
- const from = join2(legacyFilesDir, entry);
114
- const to = join2(nextFilesDir, entry);
115
- if (existsSync2(to)) continue;
116
- try {
117
- renameSync(from, to);
118
- } catch {
119
- }
120
- }
121
- }
122
- if (existsSync2(legacyScreenshotsDir)) {
123
- mkdirSync(nextScreenshotsDir, { recursive: true });
124
- for (const entry of readdirSync(legacyScreenshotsDir)) {
125
- const from = join2(legacyScreenshotsDir, entry);
126
- const to = join2(nextScreenshotsDir, entry);
127
- if (existsSync2(to)) continue;
128
- try {
129
- renameSync(from, to);
130
- } catch {
131
- }
132
- }
133
- }
134
- }
135
- function ensureTaskDirs(projectDir) {
136
- migrateLegacyTaskAssetFolders(projectDir);
137
- mkdirSync(getTasksDir(projectDir), { recursive: true });
138
- mkdirSync(join2(projectDir, PROTO_DIR, SCREENSHOTS_DIR), { recursive: true });
139
- }
140
- function getDateSubdir(isoDate) {
141
- return isoDate.slice(0, 10);
142
- }
143
- function getTaskFilePath(projectDir, taskId, created) {
144
- const tasksDir = getTasksDir(projectDir);
145
- if (created) {
146
- return join2(tasksDir, getDateSubdir(created), `${taskId}.json`);
147
- }
148
- return join2(tasksDir, `${taskId}.json`);
149
- }
150
- function findTaskFilePath(projectDir, taskId) {
151
- const tasksDir = getTasksDir(projectDir);
152
- if (!existsSync2(tasksDir)) return null;
153
- for (const entry of readdirSync(tasksDir, { withFileTypes: true })) {
154
- if (entry.isDirectory()) {
155
- const candidate = join2(tasksDir, entry.name, `${taskId}.json`);
156
- if (existsSync2(candidate)) return candidate;
157
- } else if (entry.name === `${taskId}.json`) {
158
- return join2(tasksDir, entry.name);
159
- }
160
- }
161
- return null;
162
- }
163
- function normalizeTask(raw) {
164
- const normalizedType = (() => {
165
- if (typeof raw.type !== "string") return void 0;
166
- const t = raw.type.trim();
167
- if (!t || t === "[object Object]") return void 0;
168
- return t;
169
- })();
170
- return {
171
- id: String(raw.id ?? ""),
172
- title: String(raw.title ?? "Untitled"),
173
- description: String(raw.description ?? ""),
174
- status: VALID_STATUSES.includes(raw.status) ? raw.status : "todo",
175
- url: raw.url ? String(raw.url) : void 0,
176
- selector: (() => {
177
- const sel = String(raw.selector ?? "/");
178
- if (raw.file && !raw.cssSelector && sel.startsWith(String(raw.file))) {
179
- return raw.url ? String(raw.url) : "/";
180
- }
181
- return sel;
182
- })(),
183
- cssSelector: raw.cssSelector && String(raw.cssSelector) !== String(raw.selector ?? "/") ? String(raw.cssSelector) : void 0,
184
- file: raw.file ? String(raw.file) : void 0,
185
- line: raw.line != null ? Number(raw.line) : void 0,
186
- col: raw.col != null ? Number(raw.col) : void 0,
187
- component: raw.component ? String(raw.component) : void 0,
188
- type: normalizedType,
189
- priority: raw.priority ? String(raw.priority) : void 0,
190
- ...raw.reportBack === true && { reportBack: true },
191
- agent: raw.agent ? String(raw.agent) : void 0,
192
- model: raw.model ? String(raw.model) : void 0,
193
- author: raw.author ? String(raw.author) : void 0,
194
- commit: raw.commit ? String(raw.commit) : void 0,
195
- commits: Array.isArray(raw.commits) ? raw.commits.map((c) => ({
196
- sha: String(c.sha ?? ""),
197
- message: String(c.message ?? ""),
198
- timestamp: String(c.timestamp ?? (/* @__PURE__ */ new Date()).toISOString())
199
- })) : void 0,
200
- created: String(raw.created ?? (/* @__PURE__ */ new Date()).toISOString()),
201
- updated: raw.updated ? String(raw.updated) : void 0,
202
- comments: Array.isArray(raw.comments) ? raw.comments.map((c) => ({
203
- ...c,
204
- // Normalize legacy 'content' field → 'text' (some older agent comments used 'content')
205
- text: c.text ?? c.content ?? ""
206
- })) : [],
207
- files: Array.isArray(raw.files) ? raw.files.map((f) => {
208
- if (typeof f === "string") {
209
- return { name: f, addedAt: (/* @__PURE__ */ new Date()).toISOString() };
210
- }
211
- return {
212
- name: String(f.name ?? ""),
213
- addedAt: String(f.addedAt ?? (/* @__PURE__ */ new Date()).toISOString()),
214
- linkedPath: f.linkedPath ? String(f.linkedPath) : void 0,
215
- mimeType: f.mimeType ? String(f.mimeType) : void 0
216
- };
217
- }).filter((f) => f.name) : [],
218
- screenshot: raw.screenshot ? String(raw.screenshot) : void 0,
219
- htmlText: raw.htmlText ? String(raw.htmlText) : void 0
220
- };
221
- }
222
- function writeTaskJson(projectDir, task) {
223
- const dateDir = join2(getTasksDir(projectDir), getDateSubdir(task.created));
224
- mkdirSync(dateDir, { recursive: true });
225
- const filePath = join2(dateDir, `${task.id}.json`);
226
- writeFileSync(filePath, JSON.stringify(task, null, 2), "utf-8");
227
- }
228
- function createTask(projectDir, input) {
229
- const normalizedPriority = (() => {
230
- const raw = (input.priority ?? "").trim().toLowerCase();
231
- if (raw === "critical") return "Critical";
232
- if (raw === "high") return "High";
233
- if (raw === "low") return "Low";
234
- return "Medium";
235
- })();
236
- const task = {
237
- ...input,
238
- priority: normalizedPriority,
239
- id: generateTaskId(),
240
- created: (/* @__PURE__ */ new Date()).toISOString(),
241
- comments: [],
242
- files: []
243
- };
244
- writeTaskJson(projectDir, task);
245
- return task;
246
- }
247
- function readTaskFile(filePath) {
248
- try {
249
- const content = readFileSync(filePath, "utf-8");
250
- if (filePath.endsWith(".json")) {
251
- const raw = JSON.parse(content);
252
- if (!raw || typeof raw !== "object" || !("id" in raw)) return null;
253
- return normalizeTask(raw);
254
- }
255
- return parseTask(content);
256
- } catch {
257
- return null;
258
- }
259
- }
260
- function collectTaskFiles(projectDir) {
261
- const tasksDir = getTasksDir(projectDir);
262
- if (!existsSync2(tasksDir)) return [];
263
- const results = [];
264
- for (const entry of readdirSync(tasksDir, { withFileTypes: true })) {
265
- if (entry.isDirectory()) {
266
- const dateDir = join2(tasksDir, entry.name);
267
- for (const file of readdirSync(dateDir)) {
268
- if (extname(file) === ".json") {
269
- const filePath = join2(dateDir, file);
270
- const task = readTaskFile(filePath);
271
- if (task) results.push({ task, filePath });
272
- }
273
- }
274
- } else if (extname(entry.name) === ".json") {
275
- const filePath = join2(tasksDir, entry.name);
276
- const task = readTaskFile(filePath);
277
- if (task) results.push({ task, filePath });
278
- }
279
- }
280
- return results.sort((a, b) => {
281
- const aDate = a.task.updated ?? a.task.created;
282
- const bDate = b.task.updated ?? b.task.created;
283
- return new Date(bDate).getTime() - new Date(aDate).getTime();
284
- });
285
- }
286
- function listTasks(projectDir) {
287
- return collectTaskFiles(projectDir).map(({ task }) => task);
288
- }
289
- function listTasksWithPaths(projectDir) {
290
- return collectTaskFiles(projectDir).map(({ task, filePath }) => ({ ...task, filePath }));
291
- }
292
- function updateTask(projectDir, taskId, updates) {
293
- const existingPath = findTaskFilePath(projectDir, taskId);
294
- const task = existingPath ? readTaskFile(existingPath) : null;
295
- if (!task) return null;
296
- const updated = { ...task, ...updates, updated: (/* @__PURE__ */ new Date()).toISOString() };
297
- writeTaskJson(projectDir, updated);
298
- if (existingPath && existingPath !== getTaskFilePath(projectDir, taskId, updated.created)) {
299
- try {
300
- unlinkSync(existingPath);
301
- } catch {
302
- }
303
- }
304
- return updated;
305
- }
306
- function deleteTask(projectDir, taskId) {
307
- const filePath = findTaskFilePath(projectDir, taskId);
308
- if (!filePath) return false;
309
- unlinkSync(filePath);
310
- return true;
311
- }
312
- function formatTaskForAgent(task, comments, files) {
313
- return {
314
- id: task.id,
315
- status: task.status,
316
- title: task.title,
317
- description: task.description,
318
- ...task.url && { url: task.url },
319
- selector: task.selector,
320
- ...task.file && { file: task.file },
321
- ...task.line != null && { line: task.line },
322
- ...task.col != null && { col: task.col },
323
- ...task.component && { component: task.component },
324
- ...task.type && { type: task.type },
325
- ...task.priority && { priority: task.priority },
326
- ...comments && comments.length > 0 && { structuredComments: comments },
327
- ...files && files.length > 0 && { linkedFiles: files },
328
- ...task.reportBack && { reportBack: true },
329
- created: task.created
330
- };
331
- }
332
- function migrateTasksFromMd(projectDir) {
333
- const tasksDir = getTasksDir(projectDir);
334
- const commentsDir = join2(projectDir, PROTO_DIR, COMMENTS_DIR);
335
- if (!existsSync2(tasksDir)) return 0;
336
- const mdFiles = readdirSync(tasksDir).filter((f) => extname(f) === ".md");
337
- let migrated = 0;
338
- for (const mdFile of mdFiles) {
339
- const mdPath = join2(tasksDir, mdFile);
340
- try {
341
- const legacyTask = parseTask(readFileSync(mdPath, "utf-8"));
342
- if (!legacyTask) continue;
343
- if (findTaskFilePath(projectDir, legacyTask.id)) {
344
- unlinkSync(mdPath);
345
- continue;
346
- }
347
- const commentsPath = join2(commentsDir, `${legacyTask.id}.json`);
348
- let comments = [];
349
- if (existsSync2(commentsPath)) {
350
- try {
351
- const raw = JSON.parse(readFileSync(commentsPath, "utf-8"));
352
- if (Array.isArray(raw)) {
353
- comments = raw.map((c, i) => ({
354
- ...c,
355
- id: c.id || String(Date.now() + i).slice(-10)
356
- }));
357
- }
358
- } catch {
359
- }
360
- }
361
- const newTask = {
362
- ...legacyTask,
363
- comments,
364
- files: []
365
- };
366
- writeTaskJson(projectDir, newTask);
367
- unlinkSync(mdPath);
368
- migrated++;
369
- } catch {
370
- }
371
- }
372
- return migrated;
373
- }
374
-
375
- // src/core/files.ts
376
- var LINKED_MANIFEST = ".linked.json";
377
- function getFilesDir(projectDir, taskId) {
378
- return join3(projectDir, PROTO_DIR, FILES_DIR, taskId);
379
- }
380
- function ensureFilesDir(projectDir, taskId) {
381
- mkdirSync2(getFilesDir(projectDir, taskId), { recursive: true });
382
- }
383
- function readLinked(projectDir, taskId) {
384
- const manifestPath = join3(getFilesDir(projectDir, taskId), LINKED_MANIFEST);
385
- if (!existsSync3(manifestPath)) return [];
386
- try {
387
- return JSON.parse(readFileSync2(manifestPath, "utf-8"));
388
- } catch {
389
- return [];
390
- }
391
- }
392
- function getTaskFileRefs(projectDir, taskId) {
393
- const filePath = findTaskFilePath(projectDir, taskId);
394
- const task = filePath ? readTaskFile(filePath) : null;
395
- if (!task?.files || task.files.length === 0) return [];
396
- return task.files;
397
- }
398
- function setTaskFileRefs(projectDir, taskId, refs) {
399
- updateTask(projectDir, taskId, { files: refs });
400
- }
401
- function migrateLegacyLinkedRefs(projectDir, taskId) {
402
- const refs = getTaskFileRefs(projectDir, taskId);
403
- const manifestPath = join3(getFilesDir(projectDir, taskId), LINKED_MANIFEST);
404
- if (!existsSync3(manifestPath)) return refs;
405
- const legacy = readLinked(projectDir, taskId);
406
- if (legacy.length === 0) {
407
- try {
408
- unlinkSync2(manifestPath);
409
- } catch {
410
- }
411
- return refs;
412
- }
413
- const next = refs.slice();
414
- let added = false;
415
- for (const entry of legacy) {
416
- if (!next.find((f) => f.linkedPath === entry.path || f.name === entry.name && f.linkedPath)) {
417
- next.push({
418
- name: entry.name,
419
- linkedPath: entry.path,
420
- addedAt: (/* @__PURE__ */ new Date()).toISOString()
421
- });
422
- added = true;
423
- }
424
- }
425
- if (added) {
426
- setTaskFileRefs(projectDir, taskId, next);
427
- }
428
- try {
429
- unlinkSync2(manifestPath);
430
- } catch {
431
- }
432
- return next;
433
- }
434
- function listFiles(projectDir, taskId) {
435
- const dir = getFilesDir(projectDir, taskId);
436
- const refs = migrateLegacyLinkedRefs(projectDir, taskId);
437
- const byName = /* @__PURE__ */ new Map();
438
- for (const ref of refs) {
439
- if (ref.linkedPath && existsSync3(ref.linkedPath)) {
440
- const stat = statSync(ref.linkedPath);
441
- byName.set(ref.name, {
442
- name: ref.name,
443
- size: stat.size,
444
- url: `/api/tasks/${taskId}/files/${encodeURIComponent(ref.name)}`,
445
- linkedPath: ref.linkedPath,
446
- createdAt: stat.mtime.toISOString()
447
- });
448
- continue;
449
- }
450
- const uploadedPath = join3(dir, ref.name);
451
- if (existsSync3(uploadedPath)) {
452
- const stat = statSync(uploadedPath);
453
- byName.set(ref.name, {
454
- name: ref.name,
455
- size: stat.size,
456
- url: `/api/tasks/${taskId}/files/${encodeURIComponent(ref.name)}`,
457
- createdAt: stat.mtime.toISOString()
458
- });
459
- }
460
- }
461
- if (existsSync3(dir)) {
462
- for (const entry of readdirSync2(dir, { withFileTypes: true })) {
463
- if (!entry.isFile() || entry.name === LINKED_MANIFEST || byName.has(entry.name)) continue;
464
- const fullPath = join3(dir, entry.name);
465
- const stat = statSync(fullPath);
466
- byName.set(entry.name, {
467
- name: entry.name,
468
- size: stat.size,
469
- url: `/api/tasks/${taskId}/files/${encodeURIComponent(entry.name)}`,
470
- createdAt: stat.mtime.toISOString()
471
- });
472
- }
473
- }
474
- return Array.from(byName.values());
475
- }
476
- function saveFile(projectDir, taskId, filename, data) {
477
- const safe = basename(filename);
478
- ensureFilesDir(projectDir, taskId);
479
- writeFileSync2(join3(getFilesDir(projectDir, taskId), safe), data);
480
- const refs = migrateLegacyLinkedRefs(projectDir, taskId);
481
- if (!refs.find((f) => f.name === safe && !f.linkedPath)) {
482
- refs.push({ name: safe, addedAt: (/* @__PURE__ */ new Date()).toISOString() });
483
- setTaskFileRefs(projectDir, taskId, refs);
484
- }
485
- return {
486
- name: safe,
487
- size: data.length,
488
- url: `/api/tasks/${taskId}/files/${encodeURIComponent(safe)}`
489
- };
490
- }
491
- function linkFile(projectDir, taskId, absolutePath) {
492
- if (!isAbsolute(absolutePath)) return null;
493
- if (!existsSync3(absolutePath)) return null;
494
- const stat = statSync(absolutePath);
495
- if (!stat.isFile()) return null;
496
- const name = basename(absolutePath);
497
- const refs = migrateLegacyLinkedRefs(projectDir, taskId);
498
- if (!refs.find((f) => f.linkedPath === absolutePath)) {
499
- refs.push({
500
- name,
501
- linkedPath: absolutePath,
502
- addedAt: (/* @__PURE__ */ new Date()).toISOString()
503
- });
504
- setTaskFileRefs(projectDir, taskId, refs);
505
- }
506
- return {
507
- name,
508
- size: stat.size,
509
- url: `/api/tasks/${taskId}/files/${encodeURIComponent(name)}`,
510
- linkedPath: absolutePath
511
- };
512
- }
513
- function deleteFile(projectDir, taskId, filename) {
514
- const safe = basename(filename);
515
- const refs = migrateLegacyLinkedRefs(projectDir, taskId);
516
- const idx = refs.findIndex((f) => f.name === safe);
517
- if (idx !== -1) {
518
- const [removed] = refs.splice(idx, 1);
519
- setTaskFileRefs(projectDir, taskId, refs);
520
- if (removed && !removed.linkedPath) {
521
- const uploadedPath = join3(getFilesDir(projectDir, taskId), safe);
522
- if (existsSync3(uploadedPath)) unlinkSync2(uploadedPath);
523
- }
524
- return true;
525
- }
526
- const filePath = join3(getFilesDir(projectDir, taskId), safe);
527
- if (!existsSync3(filePath)) return false;
528
- unlinkSync2(filePath);
529
- return true;
530
- }
531
- function getFilePath(projectDir, taskId, filename) {
532
- const safe = basename(filename);
533
- const linkedRef = migrateLegacyLinkedRefs(projectDir, taskId).find((f) => f.name === safe && f.linkedPath);
534
- if (linkedRef?.linkedPath && existsSync3(linkedRef.linkedPath)) return linkedRef.linkedPath;
535
- const filePath = join3(getFilesDir(projectDir, taskId), safe);
536
- return existsSync3(filePath) ? filePath : null;
537
- }
538
- function getFileCount(projectDir, taskId) {
539
- return listFiles(projectDir, taskId).length;
540
- }
541
-
542
- export {
543
- ANNOTATION_TAGS,
544
- PROTO_DIR,
545
- AGENTS_DIR,
546
- SCREENSHOTS_DIR,
547
- CONFIG_FILE,
548
- generateTaskId,
549
- ensureTaskDirs,
550
- getTaskFilePath,
551
- findTaskFilePath,
552
- createTask,
553
- readTaskFile,
554
- listTasks,
555
- listTasksWithPaths,
556
- updateTask,
557
- deleteTask,
558
- formatTaskForAgent,
559
- migrateTasksFromMd,
560
- getFilesDir,
561
- ensureFilesDir,
562
- listFiles,
563
- saveFile,
564
- linkFile,
565
- deleteFile,
566
- getFilePath,
567
- getFileCount
568
- };
569
- //# sourceMappingURL=chunk-O564QSMS.js.map