@polka-codes/runner 0.9.49 → 0.9.50
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/index.js +40 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23569,7 +23569,7 @@ var {
|
|
|
23569
23569
|
Help
|
|
23570
23570
|
} = import__.default;
|
|
23571
23571
|
// package.json
|
|
23572
|
-
var version = "0.9.
|
|
23572
|
+
var version = "0.9.50";
|
|
23573
23573
|
|
|
23574
23574
|
// src/runner.ts
|
|
23575
23575
|
import { execSync } from "node:child_process";
|
|
@@ -36535,7 +36535,6 @@ var TodoItemSchema = exports_external.object({
|
|
|
36535
36535
|
id: exports_external.string(),
|
|
36536
36536
|
title: exports_external.string(),
|
|
36537
36537
|
description: exports_external.string(),
|
|
36538
|
-
relevantFileList: exports_external.array(exports_external.string()),
|
|
36539
36538
|
status: TodoStatus
|
|
36540
36539
|
});
|
|
36541
36540
|
var UpdateTodoItemInputSchema = exports_external.object({
|
|
@@ -36544,7 +36543,6 @@ var UpdateTodoItemInputSchema = exports_external.object({
|
|
|
36544
36543
|
parentId: exports_external.string().nullish(),
|
|
36545
36544
|
title: exports_external.string().nullish(),
|
|
36546
36545
|
description: exports_external.string().nullish(),
|
|
36547
|
-
relevantFileList: exports_external.array(exports_external.string()).nullish(),
|
|
36548
36546
|
status: TodoStatus.nullish()
|
|
36549
36547
|
}).superRefine((data, ctx) => {
|
|
36550
36548
|
if (data.operation === "add") {
|
|
@@ -40210,13 +40208,23 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
|
40210
40208
|
}
|
|
40211
40209
|
|
|
40212
40210
|
// ../cli-shared/src/provider.ts
|
|
40211
|
+
class InMemoryStore {
|
|
40212
|
+
#data;
|
|
40213
|
+
async read() {
|
|
40214
|
+
return this.#data;
|
|
40215
|
+
}
|
|
40216
|
+
async write(data) {
|
|
40217
|
+
this.#data = data;
|
|
40218
|
+
}
|
|
40219
|
+
}
|
|
40213
40220
|
var getProvider = (options = {}) => {
|
|
40214
40221
|
const ig = import_ignore2.default().add(options.excludeFiles ?? []);
|
|
40215
|
-
const memoryStore =
|
|
40216
|
-
const
|
|
40222
|
+
const memoryStore = options.memoryStore ?? new InMemoryStore;
|
|
40223
|
+
const todoItemStore = options.todoItemStore ?? new InMemoryStore;
|
|
40217
40224
|
const defaultMemoryTopic = ":default:";
|
|
40218
40225
|
const provider2 = {
|
|
40219
40226
|
listTodoItems: async (id, status) => {
|
|
40227
|
+
const todoItems = await todoItemStore.read() ?? [];
|
|
40220
40228
|
let items;
|
|
40221
40229
|
if (!id) {
|
|
40222
40230
|
items = todoItems.filter((i) => !i.id.includes("."));
|
|
@@ -40245,6 +40253,7 @@ var getProvider = (options = {}) => {
|
|
|
40245
40253
|
return items;
|
|
40246
40254
|
},
|
|
40247
40255
|
getTodoItem: async (id) => {
|
|
40256
|
+
const todoItems = await todoItemStore.read() ?? [];
|
|
40248
40257
|
const item = todoItems.find((i) => i.id === id);
|
|
40249
40258
|
if (!item) {
|
|
40250
40259
|
throw new Error(`To-do item with id ${id} not found`);
|
|
@@ -40253,8 +40262,9 @@ var getProvider = (options = {}) => {
|
|
|
40253
40262
|
return { ...item, subItems };
|
|
40254
40263
|
},
|
|
40255
40264
|
updateTodoItem: async (input) => {
|
|
40265
|
+
const todoItems = await todoItemStore.read() ?? [];
|
|
40256
40266
|
if (input.operation === "add") {
|
|
40257
|
-
const { parentId, title, description,
|
|
40267
|
+
const { parentId, title, description, status } = input;
|
|
40258
40268
|
if (!title) {
|
|
40259
40269
|
throw new Error("Title is required for add operation");
|
|
40260
40270
|
}
|
|
@@ -40265,19 +40275,27 @@ var getProvider = (options = {}) => {
|
|
|
40265
40275
|
throw new Error(`Parent to-do item with id ${parentId} not found`);
|
|
40266
40276
|
}
|
|
40267
40277
|
const childItems = todoItems.filter((i) => i.id.startsWith(`${parentId}.`) && i.id.split(".").length === parentId.split(".").length + 1);
|
|
40268
|
-
|
|
40278
|
+
const maxId = childItems.reduce((max, item) => {
|
|
40279
|
+
const parts = item.id.split(".");
|
|
40280
|
+
const lastPart = parseInt(parts[parts.length - 1], 10);
|
|
40281
|
+
return Math.max(max, lastPart);
|
|
40282
|
+
}, 0);
|
|
40283
|
+
newId = `${parentId}.${maxId + 1}`;
|
|
40269
40284
|
} else {
|
|
40270
40285
|
const rootItems = todoItems.filter((i) => !i.id.includes("."));
|
|
40271
|
-
|
|
40286
|
+
const maxId = rootItems.reduce((max, item) => {
|
|
40287
|
+
const idNum = parseInt(item.id, 10);
|
|
40288
|
+
return Math.max(max, idNum);
|
|
40289
|
+
}, 0);
|
|
40290
|
+
newId = `${maxId + 1}`;
|
|
40272
40291
|
}
|
|
40273
40292
|
const newItem = {
|
|
40274
40293
|
id: newId,
|
|
40275
40294
|
title,
|
|
40276
40295
|
description: description ?? "",
|
|
40277
|
-
|
|
40278
|
-
status: "open"
|
|
40296
|
+
status: status ?? "open"
|
|
40279
40297
|
};
|
|
40280
|
-
|
|
40298
|
+
await todoItemStore.write([...todoItems, newItem]);
|
|
40281
40299
|
return { id: newId };
|
|
40282
40300
|
} else {
|
|
40283
40301
|
const { id } = input;
|
|
@@ -40294,40 +40312,43 @@ var getProvider = (options = {}) => {
|
|
|
40294
40312
|
if (input.description != null) {
|
|
40295
40313
|
item.description = input.description ?? "";
|
|
40296
40314
|
}
|
|
40297
|
-
if (input.relevantFileList != null) {
|
|
40298
|
-
item.relevantFileList = input.relevantFileList;
|
|
40299
|
-
}
|
|
40300
40315
|
if (input.status != null) {
|
|
40301
40316
|
item.status = input.status;
|
|
40302
40317
|
}
|
|
40318
|
+
await todoItemStore.write(todoItems);
|
|
40303
40319
|
return { id };
|
|
40304
40320
|
}
|
|
40305
40321
|
},
|
|
40306
40322
|
listMemoryTopics: async () => {
|
|
40307
|
-
|
|
40323
|
+
const memory = await memoryStore.read() ?? {};
|
|
40324
|
+
return Object.keys(memory);
|
|
40308
40325
|
},
|
|
40309
40326
|
readMemory: async (topic = defaultMemoryTopic) => {
|
|
40310
|
-
|
|
40327
|
+
const memory = await memoryStore.read() ?? {};
|
|
40328
|
+
return memory[topic];
|
|
40311
40329
|
},
|
|
40312
40330
|
updateMemory: async (operation, topic, content) => {
|
|
40313
40331
|
const memoryTopic = topic ?? defaultMemoryTopic;
|
|
40332
|
+
const memory = await memoryStore.read() ?? {};
|
|
40314
40333
|
switch (operation) {
|
|
40315
40334
|
case "append":
|
|
40316
40335
|
if (content === undefined) {
|
|
40317
40336
|
throw new Error("Content is required for append operation.");
|
|
40318
40337
|
}
|
|
40319
|
-
|
|
40338
|
+
memory[memoryTopic] = `${memory[memoryTopic] || ""}
|
|
40339
|
+
${content}`;
|
|
40320
40340
|
break;
|
|
40321
40341
|
case "replace":
|
|
40322
40342
|
if (content === undefined) {
|
|
40323
40343
|
throw new Error("Content is required for replace operation.");
|
|
40324
40344
|
}
|
|
40325
|
-
|
|
40345
|
+
memory[memoryTopic] = content;
|
|
40326
40346
|
break;
|
|
40327
40347
|
case "remove":
|
|
40328
|
-
delete
|
|
40348
|
+
delete memory[memoryTopic];
|
|
40329
40349
|
break;
|
|
40330
40350
|
}
|
|
40351
|
+
await memoryStore.write(memory);
|
|
40331
40352
|
},
|
|
40332
40353
|
readFile: async (path, includeIgnored) => {
|
|
40333
40354
|
if (!includeIgnored && ig.ignores(path)) {
|