@polka-codes/cli-shared 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 +46 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31053,7 +31053,6 @@ var TodoItemSchema = exports_external.object({
|
|
|
31053
31053
|
id: exports_external.string(),
|
|
31054
31054
|
title: exports_external.string(),
|
|
31055
31055
|
description: exports_external.string(),
|
|
31056
|
-
relevantFileList: exports_external.array(exports_external.string()),
|
|
31057
31056
|
status: TodoStatus
|
|
31058
31057
|
});
|
|
31059
31058
|
var UpdateTodoItemInputSchema = exports_external.object({
|
|
@@ -31062,7 +31061,6 @@ var UpdateTodoItemInputSchema = exports_external.object({
|
|
|
31062
31061
|
parentId: exports_external.string().nullish(),
|
|
31063
31062
|
title: exports_external.string().nullish(),
|
|
31064
31063
|
description: exports_external.string().nullish(),
|
|
31065
|
-
relevantFileList: exports_external.array(exports_external.string()).nullish(),
|
|
31066
31064
|
status: TodoStatus.nullish()
|
|
31067
31065
|
}).superRefine((data, ctx) => {
|
|
31068
31066
|
if (data.operation === "add") {
|
|
@@ -34742,13 +34740,23 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
|
34742
34740
|
}
|
|
34743
34741
|
|
|
34744
34742
|
// src/provider.ts
|
|
34743
|
+
class InMemoryStore {
|
|
34744
|
+
#data;
|
|
34745
|
+
async read() {
|
|
34746
|
+
return this.#data;
|
|
34747
|
+
}
|
|
34748
|
+
async write(data) {
|
|
34749
|
+
this.#data = data;
|
|
34750
|
+
}
|
|
34751
|
+
}
|
|
34745
34752
|
var getProvider = (options = {}) => {
|
|
34746
34753
|
const ig = import_ignore2.default().add(options.excludeFiles ?? []);
|
|
34747
|
-
const memoryStore =
|
|
34748
|
-
const
|
|
34754
|
+
const memoryStore = options.memoryStore ?? new InMemoryStore;
|
|
34755
|
+
const todoItemStore = options.todoItemStore ?? new InMemoryStore;
|
|
34749
34756
|
const defaultMemoryTopic = ":default:";
|
|
34750
34757
|
const provider2 = {
|
|
34751
34758
|
listTodoItems: async (id, status) => {
|
|
34759
|
+
const todoItems = await todoItemStore.read() ?? [];
|
|
34752
34760
|
let items;
|
|
34753
34761
|
if (!id) {
|
|
34754
34762
|
items = todoItems.filter((i) => !i.id.includes("."));
|
|
@@ -34777,6 +34785,7 @@ var getProvider = (options = {}) => {
|
|
|
34777
34785
|
return items;
|
|
34778
34786
|
},
|
|
34779
34787
|
getTodoItem: async (id) => {
|
|
34788
|
+
const todoItems = await todoItemStore.read() ?? [];
|
|
34780
34789
|
const item = todoItems.find((i) => i.id === id);
|
|
34781
34790
|
if (!item) {
|
|
34782
34791
|
throw new Error(`To-do item with id ${id} not found`);
|
|
@@ -34785,8 +34794,9 @@ var getProvider = (options = {}) => {
|
|
|
34785
34794
|
return { ...item, subItems };
|
|
34786
34795
|
},
|
|
34787
34796
|
updateTodoItem: async (input) => {
|
|
34797
|
+
const todoItems = await todoItemStore.read() ?? [];
|
|
34788
34798
|
if (input.operation === "add") {
|
|
34789
|
-
const { parentId, title, description,
|
|
34799
|
+
const { parentId, title, description, status } = input;
|
|
34790
34800
|
if (!title) {
|
|
34791
34801
|
throw new Error("Title is required for add operation");
|
|
34792
34802
|
}
|
|
@@ -34797,19 +34807,27 @@ var getProvider = (options = {}) => {
|
|
|
34797
34807
|
throw new Error(`Parent to-do item with id ${parentId} not found`);
|
|
34798
34808
|
}
|
|
34799
34809
|
const childItems = todoItems.filter((i) => i.id.startsWith(`${parentId}.`) && i.id.split(".").length === parentId.split(".").length + 1);
|
|
34800
|
-
|
|
34810
|
+
const maxId = childItems.reduce((max, item) => {
|
|
34811
|
+
const parts = item.id.split(".");
|
|
34812
|
+
const lastPart = parseInt(parts[parts.length - 1], 10);
|
|
34813
|
+
return Math.max(max, lastPart);
|
|
34814
|
+
}, 0);
|
|
34815
|
+
newId = `${parentId}.${maxId + 1}`;
|
|
34801
34816
|
} else {
|
|
34802
34817
|
const rootItems = todoItems.filter((i) => !i.id.includes("."));
|
|
34803
|
-
|
|
34818
|
+
const maxId = rootItems.reduce((max, item) => {
|
|
34819
|
+
const idNum = parseInt(item.id, 10);
|
|
34820
|
+
return Math.max(max, idNum);
|
|
34821
|
+
}, 0);
|
|
34822
|
+
newId = `${maxId + 1}`;
|
|
34804
34823
|
}
|
|
34805
34824
|
const newItem = {
|
|
34806
34825
|
id: newId,
|
|
34807
34826
|
title,
|
|
34808
34827
|
description: description ?? "",
|
|
34809
|
-
|
|
34810
|
-
status: "open"
|
|
34828
|
+
status: status ?? "open"
|
|
34811
34829
|
};
|
|
34812
|
-
|
|
34830
|
+
await todoItemStore.write([...todoItems, newItem]);
|
|
34813
34831
|
return { id: newId };
|
|
34814
34832
|
} else {
|
|
34815
34833
|
const { id } = input;
|
|
@@ -34826,40 +34844,43 @@ var getProvider = (options = {}) => {
|
|
|
34826
34844
|
if (input.description != null) {
|
|
34827
34845
|
item.description = input.description ?? "";
|
|
34828
34846
|
}
|
|
34829
|
-
if (input.relevantFileList != null) {
|
|
34830
|
-
item.relevantFileList = input.relevantFileList;
|
|
34831
|
-
}
|
|
34832
34847
|
if (input.status != null) {
|
|
34833
34848
|
item.status = input.status;
|
|
34834
34849
|
}
|
|
34850
|
+
await todoItemStore.write(todoItems);
|
|
34835
34851
|
return { id };
|
|
34836
34852
|
}
|
|
34837
34853
|
},
|
|
34838
34854
|
listMemoryTopics: async () => {
|
|
34839
|
-
|
|
34855
|
+
const memory = await memoryStore.read() ?? {};
|
|
34856
|
+
return Object.keys(memory);
|
|
34840
34857
|
},
|
|
34841
34858
|
readMemory: async (topic = defaultMemoryTopic) => {
|
|
34842
|
-
|
|
34859
|
+
const memory = await memoryStore.read() ?? {};
|
|
34860
|
+
return memory[topic];
|
|
34843
34861
|
},
|
|
34844
34862
|
updateMemory: async (operation, topic, content) => {
|
|
34845
34863
|
const memoryTopic = topic ?? defaultMemoryTopic;
|
|
34864
|
+
const memory = await memoryStore.read() ?? {};
|
|
34846
34865
|
switch (operation) {
|
|
34847
34866
|
case "append":
|
|
34848
34867
|
if (content === undefined) {
|
|
34849
34868
|
throw new Error("Content is required for append operation.");
|
|
34850
34869
|
}
|
|
34851
|
-
|
|
34870
|
+
memory[memoryTopic] = `${memory[memoryTopic] || ""}
|
|
34871
|
+
${content}`;
|
|
34852
34872
|
break;
|
|
34853
34873
|
case "replace":
|
|
34854
34874
|
if (content === undefined) {
|
|
34855
34875
|
throw new Error("Content is required for replace operation.");
|
|
34856
34876
|
}
|
|
34857
|
-
|
|
34877
|
+
memory[memoryTopic] = content;
|
|
34858
34878
|
break;
|
|
34859
34879
|
case "remove":
|
|
34860
|
-
delete
|
|
34880
|
+
delete memory[memoryTopic];
|
|
34861
34881
|
break;
|
|
34862
34882
|
}
|
|
34883
|
+
await memoryStore.write(memory);
|
|
34863
34884
|
},
|
|
34864
34885
|
readFile: async (path, includeIgnored) => {
|
|
34865
34886
|
if (!includeIgnored && ig.ignores(path)) {
|
|
@@ -35700,9 +35721,10 @@ ${event.systemPrompt}`);
|
|
|
35700
35721
|
}
|
|
35701
35722
|
case "ToolUse" /* ToolUse */: {
|
|
35702
35723
|
if (verbose > 0) {
|
|
35724
|
+
const params = verbose > 1 ? event.params : simplifyToolParameters(event.tool, event.params);
|
|
35703
35725
|
customConsole.log(source_default.yellow(`
|
|
35704
35726
|
|
|
35705
|
-
Tool use:`, event.tool),
|
|
35727
|
+
Tool use:`, event.tool), params);
|
|
35706
35728
|
}
|
|
35707
35729
|
const stats = taskToolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
35708
35730
|
stats.calls++;
|
|
@@ -35747,7 +35769,9 @@ Tool error:`, event.tool));
|
|
|
35747
35769
|
break;
|
|
35748
35770
|
}
|
|
35749
35771
|
case "Exit" /* Exit */:
|
|
35750
|
-
|
|
35772
|
+
if (verbose > 0) {
|
|
35773
|
+
customConsole.log("Exit Message:", event.exitReason.message);
|
|
35774
|
+
}
|
|
35751
35775
|
break;
|
|
35752
35776
|
}
|
|
35753
35777
|
for (const [tool2, taskStats] of taskToolCallStats.entries()) {
|
|
@@ -35801,5 +35825,6 @@ export {
|
|
|
35801
35825
|
getProvider,
|
|
35802
35826
|
getGlobalConfigPath,
|
|
35803
35827
|
configSchema,
|
|
35804
|
-
checkRipgrep
|
|
35828
|
+
checkRipgrep,
|
|
35829
|
+
InMemoryStore
|
|
35805
35830
|
};
|