@polka-codes/cli 0.9.94 → 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 +198 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42709,11 +42709,13 @@ ${error48}`);
|
|
|
42709
42709
|
const config3 = readConfig(path);
|
|
42710
42710
|
configs.push(config3);
|
|
42711
42711
|
} catch (error48) {
|
|
42712
|
-
|
|
42713
|
-
|
|
42714
|
-
|
|
42715
|
-
throw error48;
|
|
42712
|
+
const errorCode = error48?.code;
|
|
42713
|
+
if (errorCode === "ENOENT") {
|
|
42714
|
+
continue;
|
|
42716
42715
|
}
|
|
42716
|
+
console.error(`Error loading config file: ${path}
|
|
42717
|
+
${error48}`);
|
|
42718
|
+
throw error48;
|
|
42717
42719
|
}
|
|
42718
42720
|
}
|
|
42719
42721
|
} else {
|
|
@@ -94128,7 +94130,7 @@ function createGitReadBinaryFile(commit2) {
|
|
|
94128
94130
|
};
|
|
94129
94131
|
}
|
|
94130
94132
|
const isWindows2 = process.platform === "win32";
|
|
94131
|
-
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"`;
|
|
94132
94134
|
const result = await provider3.executeCommand(command, false);
|
|
94133
94135
|
if (result.exitCode === 0) {
|
|
94134
94136
|
const base64Data = result.stdout.replace(/\n/g, "");
|
|
@@ -112342,7 +112344,7 @@ var {
|
|
|
112342
112344
|
Help
|
|
112343
112345
|
} = import__.default;
|
|
112344
112346
|
// package.json
|
|
112345
|
-
var version = "0.9.
|
|
112347
|
+
var version = "0.9.95";
|
|
112346
112348
|
|
|
112347
112349
|
// src/commands/agent.ts
|
|
112348
112350
|
init_src();
|
|
@@ -120274,6 +120276,15 @@ async function executeWorkflow(workflow3, input2, commandName, logger, providerO
|
|
|
120274
120276
|
}
|
|
120275
120277
|
}
|
|
120276
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
|
+
}
|
|
120277
120288
|
return [
|
|
120278
120289
|
{
|
|
120279
120290
|
name: "code",
|
|
@@ -120597,33 +120608,92 @@ between different operations.
|
|
|
120597
120608
|
|
|
120598
120609
|
Parameters:
|
|
120599
120610
|
- operation (required): The operation to perform. Use "append" to add content, "replace" to overwrite all content, or "remove" to delete the topic.
|
|
120600
|
-
-
|
|
120601
|
-
-
|
|
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:"
|
|
120602
120618
|
|
|
120603
120619
|
Returns a message confirming the operation performed.`,
|
|
120604
120620
|
inputSchema: exports_external.object({
|
|
120605
|
-
operation: exports_external.enum(["append", "replace", "remove"]).describe("The operation: append (add content), replace (overwrite), or remove (delete topic)"),
|
|
120606
|
-
topic: exports_external.string().optional().describe('
|
|
120607
|
-
|
|
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)"
|
|
120608
120638
|
}),
|
|
120609
120639
|
handler: async (args, toolContext) => {
|
|
120610
120640
|
const {
|
|
120611
120641
|
operation,
|
|
120612
|
-
topic
|
|
120613
|
-
|
|
120642
|
+
topic: singleTopic,
|
|
120643
|
+
topics,
|
|
120644
|
+
content: contentInput
|
|
120614
120645
|
} = args;
|
|
120615
|
-
toolContext.logger.info(`MCP: Memory operation "${operation}" on topic "${
|
|
120646
|
+
toolContext.logger.info(`MCP: Memory operation "${operation}" on ${topics ? `${topics.length} topics` : `topic "${singleTopic}"`}`);
|
|
120616
120647
|
const memoryStore = await getMemoryStore(toolContext.logger);
|
|
120617
120648
|
if (!memoryStore) {
|
|
120618
120649
|
return "Error: Memory store is not enabled. Configure it in your .polkacodes.yml with memory.enabled: true";
|
|
120619
120650
|
}
|
|
120620
120651
|
try {
|
|
120621
|
-
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) {
|
|
120622
120691
|
return 'Error: Content is required for "append" and "replace" operations';
|
|
120623
120692
|
}
|
|
120624
|
-
if (operation === "remove" &&
|
|
120693
|
+
if (operation === "remove" && contentInput !== undefined) {
|
|
120625
120694
|
return 'Error: Content must not be provided for "remove" operation';
|
|
120626
120695
|
}
|
|
120696
|
+
const content = typeof contentInput === "string" ? contentInput : undefined;
|
|
120627
120697
|
await memoryStore.store.updateMemory(operation, topic, content);
|
|
120628
120698
|
const messages = {
|
|
120629
120699
|
append: `Content appended to memory topic "${topic}"`,
|
|
@@ -120641,22 +120711,127 @@ Returns a message confirming the operation performed.`,
|
|
|
120641
120711
|
description: `List all available memory topics.
|
|
120642
120712
|
|
|
120643
120713
|
Use this to see what information has been stored and which topics are
|
|
120644
|
-
available to read from. Returns a list of topic names that have content
|
|
120645
|
-
|
|
120646
|
-
|
|
120647
|
-
|
|
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}"` : ""}`);
|
|
120648
120726
|
const memoryStore = await getMemoryStore(toolContext.logger);
|
|
120649
120727
|
if (!memoryStore) {
|
|
120650
120728
|
return "Error: Memory store is not enabled. Configure it in your .polkacodes.yml with memory.enabled: true";
|
|
120651
120729
|
}
|
|
120652
120730
|
try {
|
|
120653
|
-
const
|
|
120731
|
+
const query = {};
|
|
120732
|
+
query.scope = scope ?? "auto";
|
|
120733
|
+
const entries = await memoryStore.store.queryMemory(query, { operation: "select" });
|
|
120654
120734
|
if (!entries || !Array.isArray(entries) || entries.length === 0) {
|
|
120655
120735
|
return "No memory topics found.";
|
|
120656
120736
|
}
|
|
120657
|
-
|
|
120658
|
-
|
|
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}):
|
|
120659
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
|
+
|
|
120660
120835
|
`)}`;
|
|
120661
120836
|
} catch (error48) {
|
|
120662
120837
|
return `Error: ${error48 instanceof Error ? error48.message : String(error48)}`;
|