@polka-codes/cli 0.9.93 → 0.9.95
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 +196 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42709,6 +42709,10 @@ ${error48}`);
|
|
|
42709
42709
|
const config3 = readConfig(path);
|
|
42710
42710
|
configs.push(config3);
|
|
42711
42711
|
} catch (error48) {
|
|
42712
|
+
const errorCode = error48?.code;
|
|
42713
|
+
if (errorCode === "ENOENT") {
|
|
42714
|
+
continue;
|
|
42715
|
+
}
|
|
42712
42716
|
console.error(`Error loading config file: ${path}
|
|
42713
42717
|
${error48}`);
|
|
42714
42718
|
throw error48;
|
|
@@ -94126,7 +94130,7 @@ function createGitReadBinaryFile(commit2) {
|
|
|
94126
94130
|
};
|
|
94127
94131
|
}
|
|
94128
94132
|
const isWindows2 = process.platform === "win32";
|
|
94129
|
-
const command = isWindows2 ? `cmd /c "git show ${quotedCommit}:${quotedUrl} | base64 -w 0
|
|
94133
|
+
const command = isWindows2 ? `cmd /c "git show ${quotedCommit}:${quotedUrl} | base64 -w 0"` : `sh -c "git show ${quotedCommit}:${quotedUrl} | base64"`;
|
|
94130
94134
|
const result = await provider3.executeCommand(command, false);
|
|
94131
94135
|
if (result.exitCode === 0) {
|
|
94132
94136
|
const base64Data = result.stdout.replace(/\n/g, "");
|
|
@@ -112340,7 +112344,7 @@ var {
|
|
|
112340
112344
|
Help
|
|
112341
112345
|
} = import__.default;
|
|
112342
112346
|
// package.json
|
|
112343
|
-
var version = "0.9.
|
|
112347
|
+
var version = "0.9.95";
|
|
112344
112348
|
|
|
112345
112349
|
// src/commands/agent.ts
|
|
112346
112350
|
init_src();
|
|
@@ -120272,6 +120276,15 @@ async function executeWorkflow(workflow3, input2, commandName, logger, providerO
|
|
|
120272
120276
|
}
|
|
120273
120277
|
}
|
|
120274
120278
|
function createPolkaCodesServerTools(logger) {
|
|
120279
|
+
function escapeRegexPattern(pattern) {
|
|
120280
|
+
return pattern.replace(/[.+*?^${}()|[\]\\]/g, "\\$&");
|
|
120281
|
+
}
|
|
120282
|
+
function createWildcardRegex(pattern) {
|
|
120283
|
+
const withWildcardsPlaceholders = pattern.replace(/\*/g, "\x00STAR\x00").replace(/\?/g, "\x00QUEST\x00");
|
|
120284
|
+
const escaped = escapeRegexPattern(withWildcardsPlaceholders);
|
|
120285
|
+
const withWildcards = escaped.replace(/\0STAR\0/g, ".*").replace(/\0QUEST\0/g, ".");
|
|
120286
|
+
return new RegExp(`^${withWildcards}$`);
|
|
120287
|
+
}
|
|
120275
120288
|
return [
|
|
120276
120289
|
{
|
|
120277
120290
|
name: "code",
|
|
@@ -120595,33 +120608,92 @@ between different operations.
|
|
|
120595
120608
|
|
|
120596
120609
|
Parameters:
|
|
120597
120610
|
- operation (required): The operation to perform. Use "append" to add content, "replace" to overwrite all content, or "remove" to delete the topic.
|
|
120598
|
-
-
|
|
120599
|
-
-
|
|
120611
|
+
- topics (optional): Array of topic names for batch operations. Content can be an array (one per topic) or a single string (broadcast to all topics).
|
|
120612
|
+
- topic (optional): Single memory topic to update. Defaults to ":default:".
|
|
120613
|
+
- content (optional): The content to store (required for "append" and "replace" operations). For batch operations with topics, provide an array of the same length or a single string to broadcast.
|
|
120614
|
+
|
|
120615
|
+
Supports wildcards in topic name for remove operation:
|
|
120616
|
+
- Use "*" to remove all topics (e.g., topic ":plan:*")
|
|
120617
|
+
- Use pattern matching like ":plan:*" to remove all topics starting with ":plan:"
|
|
120600
120618
|
|
|
120601
120619
|
Returns a message confirming the operation performed.`,
|
|
120602
120620
|
inputSchema: exports_external.object({
|
|
120603
|
-
operation: exports_external.enum(["append", "replace", "remove"]).describe("The operation: append (add content), replace (overwrite), or remove (delete topic)"),
|
|
120604
|
-
topic: exports_external.string().optional().describe('
|
|
120605
|
-
|
|
120621
|
+
operation: exports_external.enum(["append", "replace", "remove"]).describe("The operation: append (add content), replace (overwrite), or remove (delete topic(s))"),
|
|
120622
|
+
topic: exports_external.string().optional().describe('Single memory topic to update (defaults to ":default:")'),
|
|
120623
|
+
topics: exports_external.array(exports_external.string()).min(1).optional().describe("Array of topics for batch operations"),
|
|
120624
|
+
content: exports_external.union([exports_external.string(), exports_external.array(exports_external.string())]).optional().describe("Content to store (string or array for batch). Required for append/replace, omitted for remove")
|
|
120625
|
+
}).refine((data) => {
|
|
120626
|
+
if (data.topics && data.content) {
|
|
120627
|
+
if (Array.isArray(data.content)) {
|
|
120628
|
+
return data.content.length === data.topics.length;
|
|
120629
|
+
}
|
|
120630
|
+
return true;
|
|
120631
|
+
}
|
|
120632
|
+
if (!data.topics && data.content !== undefined && Array.isArray(data.content)) {
|
|
120633
|
+
return false;
|
|
120634
|
+
}
|
|
120635
|
+
return true;
|
|
120636
|
+
}, {
|
|
120637
|
+
message: "For single topic mode, content must be a string. For batch mode with topics array, content can be an array (same length) or a string (broadcast to all topics)"
|
|
120606
120638
|
}),
|
|
120607
120639
|
handler: async (args, toolContext) => {
|
|
120608
120640
|
const {
|
|
120609
120641
|
operation,
|
|
120610
|
-
topic
|
|
120611
|
-
|
|
120642
|
+
topic: singleTopic,
|
|
120643
|
+
topics,
|
|
120644
|
+
content: contentInput
|
|
120612
120645
|
} = args;
|
|
120613
|
-
toolContext.logger.info(`MCP: Memory operation "${operation}" on topic "${
|
|
120646
|
+
toolContext.logger.info(`MCP: Memory operation "${operation}" on ${topics ? `${topics.length} topics` : `topic "${singleTopic}"`}`);
|
|
120614
120647
|
const memoryStore = await getMemoryStore(toolContext.logger);
|
|
120615
120648
|
if (!memoryStore) {
|
|
120616
120649
|
return "Error: Memory store is not enabled. Configure it in your .polkacodes.yml with memory.enabled: true";
|
|
120617
120650
|
}
|
|
120618
120651
|
try {
|
|
120619
|
-
if (
|
|
120652
|
+
if (topics) {
|
|
120653
|
+
if (operation === "remove" && contentInput !== undefined) {
|
|
120654
|
+
return 'Error: Content must not be provided for "remove" operation';
|
|
120655
|
+
}
|
|
120656
|
+
if ((operation === "append" || operation === "replace") && contentInput === undefined) {
|
|
120657
|
+
return 'Error: Content is required for "append" and "replace" operations';
|
|
120658
|
+
}
|
|
120659
|
+
const contents = Array.isArray(contentInput) ? contentInput : topics.map(() => contentInput);
|
|
120660
|
+
const operations = topics.map((topic2, index) => ({
|
|
120661
|
+
operation,
|
|
120662
|
+
name: topic2,
|
|
120663
|
+
content: operation === "remove" ? undefined : contents[index]
|
|
120664
|
+
}));
|
|
120665
|
+
await memoryStore.store.batchUpdateMemory(operations);
|
|
120666
|
+
return `Batch operation "${operation}" completed on ${topics.length} topics:
|
|
120667
|
+
${topics.join(`
|
|
120668
|
+
`)}`;
|
|
120669
|
+
}
|
|
120670
|
+
const topic = singleTopic || ":default:";
|
|
120671
|
+
if (operation === "remove" && (topic.includes("*") || topic.includes("?"))) {
|
|
120672
|
+
const allEntries = await memoryStore.store.queryMemory({ scope: "auto" }, { operation: "select" });
|
|
120673
|
+
if (!Array.isArray(allEntries)) {
|
|
120674
|
+
return "Error: Unable to query memory entries";
|
|
120675
|
+
}
|
|
120676
|
+
const regex2 = createWildcardRegex(topic);
|
|
120677
|
+
const matchingTopics = allEntries.filter((e2) => regex2.test(e2.name)).map((e2) => e2.name);
|
|
120678
|
+
if (matchingTopics.length === 0) {
|
|
120679
|
+
return `No topics found matching pattern "${topic}"`;
|
|
120680
|
+
}
|
|
120681
|
+
const operations = matchingTopics.map((matchingTopic) => ({
|
|
120682
|
+
operation: "remove",
|
|
120683
|
+
name: matchingTopic
|
|
120684
|
+
}));
|
|
120685
|
+
await memoryStore.store.batchUpdateMemory(operations);
|
|
120686
|
+
return `Removed ${matchingTopics.length} topic(s) matching pattern "${topic}":
|
|
120687
|
+
${matchingTopics.join(`
|
|
120688
|
+
`)}`;
|
|
120689
|
+
}
|
|
120690
|
+
if ((operation === "append" || operation === "replace") && contentInput === undefined) {
|
|
120620
120691
|
return 'Error: Content is required for "append" and "replace" operations';
|
|
120621
120692
|
}
|
|
120622
|
-
if (operation === "remove" &&
|
|
120693
|
+
if (operation === "remove" && contentInput !== undefined) {
|
|
120623
120694
|
return 'Error: Content must not be provided for "remove" operation';
|
|
120624
120695
|
}
|
|
120696
|
+
const content = typeof contentInput === "string" ? contentInput : undefined;
|
|
120625
120697
|
await memoryStore.store.updateMemory(operation, topic, content);
|
|
120626
120698
|
const messages = {
|
|
120627
120699
|
append: `Content appended to memory topic "${topic}"`,
|
|
@@ -120639,22 +120711,127 @@ Returns a message confirming the operation performed.`,
|
|
|
120639
120711
|
description: `List all available memory topics.
|
|
120640
120712
|
|
|
120641
120713
|
Use this to see what information has been stored and which topics are
|
|
120642
|
-
available to read from. Returns a list of topic names that have content
|
|
120643
|
-
|
|
120644
|
-
|
|
120645
|
-
|
|
120714
|
+
available to read from. Returns a list of topic names that have content.
|
|
120715
|
+
|
|
120716
|
+
Parameters:
|
|
120717
|
+
- pattern (optional): Filter topics by wildcard pattern (e.g., ":plan:*" for all plan topics)
|
|
120718
|
+
- scope (optional): Filter by scope ("auto", "project", or "global")`,
|
|
120719
|
+
inputSchema: exports_external.object({
|
|
120720
|
+
pattern: exports_external.string().optional().describe('Filter topics by wildcard pattern (e.g., ":plan:*")'),
|
|
120721
|
+
scope: exports_external.enum(["auto", "project", "global"]).optional().describe('Filter by scope (defaults to "auto")')
|
|
120722
|
+
}),
|
|
120723
|
+
handler: async (args, toolContext) => {
|
|
120724
|
+
const { pattern, scope } = args;
|
|
120725
|
+
toolContext.logger.info(`MCP: Listing memory topics${pattern ? ` with pattern "${pattern}"` : ""}`);
|
|
120646
120726
|
const memoryStore = await getMemoryStore(toolContext.logger);
|
|
120647
120727
|
if (!memoryStore) {
|
|
120648
120728
|
return "Error: Memory store is not enabled. Configure it in your .polkacodes.yml with memory.enabled: true";
|
|
120649
120729
|
}
|
|
120650
120730
|
try {
|
|
120651
|
-
const
|
|
120731
|
+
const query = {};
|
|
120732
|
+
query.scope = scope ?? "auto";
|
|
120733
|
+
const entries = await memoryStore.store.queryMemory(query, { operation: "select" });
|
|
120652
120734
|
if (!entries || !Array.isArray(entries) || entries.length === 0) {
|
|
120653
120735
|
return "No memory topics found.";
|
|
120654
120736
|
}
|
|
120655
|
-
|
|
120656
|
-
|
|
120737
|
+
let topics = [...new Set(entries.map((e2) => e2.name))];
|
|
120738
|
+
if (pattern) {
|
|
120739
|
+
const regex2 = createWildcardRegex(pattern);
|
|
120740
|
+
topics = topics.filter((t2) => regex2.test(t2));
|
|
120741
|
+
}
|
|
120742
|
+
if (topics.length === 0) {
|
|
120743
|
+
return pattern ? `No memory topics found matching pattern "${pattern}"` : "No memory topics found.";
|
|
120744
|
+
}
|
|
120745
|
+
return `Memory topics (${topics.length}):
|
|
120657
120746
|
${topics.join(`
|
|
120747
|
+
`)}`;
|
|
120748
|
+
} catch (error48) {
|
|
120749
|
+
return `Error: ${error48 instanceof Error ? error48.message : String(error48)}`;
|
|
120750
|
+
}
|
|
120751
|
+
}
|
|
120752
|
+
},
|
|
120753
|
+
{
|
|
120754
|
+
name: "memory_query",
|
|
120755
|
+
description: `Query memory with advanced filters.
|
|
120756
|
+
|
|
120757
|
+
Use this to search memory entries by content, metadata, or other criteria.
|
|
120758
|
+
Returns detailed entry information with metadata.
|
|
120759
|
+
|
|
120760
|
+
Parameters:
|
|
120761
|
+
- search (optional): Search text to find in content
|
|
120762
|
+
- type (optional): Filter by entry type (note, todo, plan, etc.)
|
|
120763
|
+
- status (optional): Filter by status (open, completed, closed, etc.)
|
|
120764
|
+
- priority (optional): Filter by priority (null, low, medium, high)
|
|
120765
|
+
- tags (optional): Filter by tags
|
|
120766
|
+
- scope (optional): Filter by scope ("auto", "project", or "global")
|
|
120767
|
+
- operation (optional): Query operation - "select" returns entries, "count" returns count
|
|
120768
|
+
|
|
120769
|
+
Returns matching entries with full metadata.`,
|
|
120770
|
+
inputSchema: exports_external.object({
|
|
120771
|
+
search: exports_external.string().optional().describe("Search text to find in content"),
|
|
120772
|
+
type: exports_external.string().optional().describe("Filter by entry type (note, todo, plan, etc.)"),
|
|
120773
|
+
status: exports_external.string().optional().describe("Filter by status (open, completed, closed, etc.)"),
|
|
120774
|
+
priority: exports_external.string().optional().describe("Filter by priority (null, low, medium, high)"),
|
|
120775
|
+
tags: exports_external.string().optional().describe("Filter by tags"),
|
|
120776
|
+
scope: exports_external.enum(["auto", "project", "global"]).optional().describe('Filter by scope (defaults to "auto")'),
|
|
120777
|
+
operation: exports_external.enum(["select", "count"]).optional().describe('Query operation (defaults to "select")')
|
|
120778
|
+
}),
|
|
120779
|
+
handler: async (args, toolContext) => {
|
|
120780
|
+
const {
|
|
120781
|
+
search,
|
|
120782
|
+
type,
|
|
120783
|
+
status,
|
|
120784
|
+
priority,
|
|
120785
|
+
tags,
|
|
120786
|
+
scope,
|
|
120787
|
+
operation = "select"
|
|
120788
|
+
} = args;
|
|
120789
|
+
toolContext.logger.info(`MCP: Querying memory - operation: "${operation}"`);
|
|
120790
|
+
const memoryStore = await getMemoryStore(toolContext.logger);
|
|
120791
|
+
if (!memoryStore) {
|
|
120792
|
+
return "Error: Memory store is not enabled. Configure it in your .polkacodes.yml with memory.enabled: true";
|
|
120793
|
+
}
|
|
120794
|
+
try {
|
|
120795
|
+
const memoryQuery = {};
|
|
120796
|
+
memoryQuery.scope = scope ?? "auto";
|
|
120797
|
+
if (search)
|
|
120798
|
+
memoryQuery.search = search;
|
|
120799
|
+
if (type)
|
|
120800
|
+
memoryQuery.type = type;
|
|
120801
|
+
if (status)
|
|
120802
|
+
memoryQuery.status = status;
|
|
120803
|
+
if (priority)
|
|
120804
|
+
memoryQuery.priority = priority;
|
|
120805
|
+
if (tags)
|
|
120806
|
+
memoryQuery.tags = tags;
|
|
120807
|
+
const result = await memoryStore.store.queryMemory(memoryQuery, { operation });
|
|
120808
|
+
if (operation === "count") {
|
|
120809
|
+
return `Found ${typeof result === "number" ? result : 0} matching entries`;
|
|
120810
|
+
}
|
|
120811
|
+
if (!Array.isArray(result) || result.length === 0) {
|
|
120812
|
+
return "No matching entries found.";
|
|
120813
|
+
}
|
|
120814
|
+
const formatted = result.map((entry) => {
|
|
120815
|
+
const lines = [];
|
|
120816
|
+
lines.push(`Topic: ${entry.name}`);
|
|
120817
|
+
if (entry.entry_type)
|
|
120818
|
+
lines.push(` Type: ${entry.entry_type}`);
|
|
120819
|
+
if (entry.status)
|
|
120820
|
+
lines.push(` Status: ${entry.status}`);
|
|
120821
|
+
if (entry.priority)
|
|
120822
|
+
lines.push(` Priority: ${entry.priority}`);
|
|
120823
|
+
if (entry.tags)
|
|
120824
|
+
lines.push(` Tags: ${entry.tags}`);
|
|
120825
|
+
if (entry.created_at)
|
|
120826
|
+
lines.push(` Created: ${new Date(entry.created_at).toISOString()}`);
|
|
120827
|
+
lines.push(` Content: ${entry.content?.substring(0, 100)}${entry.content && entry.content.length > 100 ? "..." : ""}`);
|
|
120828
|
+
return lines.join(`
|
|
120829
|
+
`);
|
|
120830
|
+
});
|
|
120831
|
+
return `Found ${result.length} entries:
|
|
120832
|
+
|
|
120833
|
+
${formatted.join(`
|
|
120834
|
+
|
|
120658
120835
|
`)}`;
|
|
120659
120836
|
} catch (error48) {
|
|
120660
120837
|
return `Error: ${error48 instanceof Error ? error48.message : String(error48)}`;
|