@polka-codes/cli 0.9.98 → 0.9.100
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 +201 -82
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -112338,7 +112338,7 @@ var {
|
|
|
112338
112338
|
Help
|
|
112339
112339
|
} = import__.default;
|
|
112340
112340
|
// package.json
|
|
112341
|
-
var version = "0.9.
|
|
112341
|
+
var version = "0.9.100";
|
|
112342
112342
|
|
|
112343
112343
|
// src/commands/agent.ts
|
|
112344
112344
|
init_src();
|
|
@@ -117712,13 +117712,15 @@ init_prompts2();
|
|
|
117712
117712
|
|
|
117713
117713
|
// src/workflows/task.workflow.ts
|
|
117714
117714
|
init_src();
|
|
117715
|
+
init_zod();
|
|
117715
117716
|
init_workflow_utils();
|
|
117716
117717
|
var SYSTEM_PROMPT = `You are a generic AI assistant.
|
|
117717
117718
|
You are able to perform simple tasks including making simple changes, reading code, and answering user questions.
|
|
117718
117719
|
Use the available tools to perform the task.`;
|
|
117720
|
+
var TaskOutputSchema = exports_external.any().describe("A JSON value with the task result");
|
|
117719
117721
|
var taskWorkflow = async (input2, context) => {
|
|
117720
117722
|
const { logger, step } = context;
|
|
117721
|
-
const { task, additionalTools } = input2;
|
|
117723
|
+
const { task, additionalTools, jsonMode } = input2;
|
|
117722
117724
|
logger.info(`
|
|
117723
117725
|
Running generic agent...
|
|
117724
117726
|
`);
|
|
@@ -117740,33 +117742,44 @@ Running generic agent...
|
|
|
117740
117742
|
if (additionalTools?.mcpTools) {
|
|
117741
117743
|
agentTools.push(...additionalTools.mcpTools);
|
|
117742
117744
|
}
|
|
117743
|
-
await step("agent", async () => {
|
|
117745
|
+
const result = await step("agent", async () => {
|
|
117744
117746
|
const defaultContext = await getDefaultContext("task");
|
|
117745
117747
|
const userMessage = `${task}
|
|
117746
117748
|
|
|
117747
117749
|
${defaultContext}`;
|
|
117748
|
-
await agentWorkflow({
|
|
117750
|
+
return await agentWorkflow({
|
|
117749
117751
|
systemPrompt: SYSTEM_PROMPT,
|
|
117750
117752
|
userMessage: [{ role: "user", content: userMessage }],
|
|
117751
|
-
tools: agentTools
|
|
117753
|
+
tools: agentTools,
|
|
117754
|
+
outputSchema: jsonMode ? TaskOutputSchema : undefined
|
|
117752
117755
|
}, context);
|
|
117753
117756
|
});
|
|
117754
117757
|
logger.info(`
|
|
117755
117758
|
Agent finished!
|
|
117756
117759
|
`);
|
|
117757
|
-
return
|
|
117760
|
+
return result;
|
|
117758
117761
|
};
|
|
117759
117762
|
|
|
117760
117763
|
// src/workflows/meta.workflow.ts
|
|
117761
117764
|
var DecisionSchema = exports_external.object({
|
|
117762
117765
|
workflow: exports_external.enum(["code", "task"])
|
|
117763
117766
|
});
|
|
117767
|
+
var MetaOutputSchema = exports_external.object({
|
|
117768
|
+
workflow: exports_external.enum(["code", "task"]).describe("The workflow that was executed"),
|
|
117769
|
+
success: exports_external.boolean().describe("Whether the workflow completed successfully"),
|
|
117770
|
+
summary: exports_external.string().optional().describe("Summary of what was done"),
|
|
117771
|
+
error: exports_external.string().optional().describe("Error message if the workflow failed")
|
|
117772
|
+
});
|
|
117764
117773
|
var metaWorkflow = async (input2, context) => {
|
|
117765
117774
|
const { task } = input2;
|
|
117766
117775
|
const { logger } = context;
|
|
117767
117776
|
if (!task) {
|
|
117768
117777
|
logger.error("Task is not defined in the input for metaWorkflow.");
|
|
117769
|
-
return
|
|
117778
|
+
return {
|
|
117779
|
+
workflow: "task",
|
|
117780
|
+
success: false,
|
|
117781
|
+
error: "Task is not defined in the input for metaWorkflow."
|
|
117782
|
+
};
|
|
117770
117783
|
}
|
|
117771
117784
|
logger.info(`
|
|
117772
117785
|
Deciding which workflow to use for task...
|
|
@@ -117783,27 +117796,67 @@ Deciding which workflow to use for task...
|
|
|
117783
117796
|
outputSchema: DecisionSchema
|
|
117784
117797
|
}, context);
|
|
117785
117798
|
if (result.type !== "Exit" || !result.object) {
|
|
117786
|
-
|
|
117799
|
+
const errorMsg = `Could not decide which workflow to run. Agent exited with reason: ${result.type}`;
|
|
117800
|
+
logger.error(errorMsg);
|
|
117801
|
+
return {
|
|
117802
|
+
workflow: "task",
|
|
117803
|
+
success: false,
|
|
117804
|
+
error: errorMsg
|
|
117805
|
+
};
|
|
117787
117806
|
}
|
|
117788
117807
|
const decision = result.object;
|
|
117789
117808
|
if (!decision.workflow) {
|
|
117790
|
-
|
|
117809
|
+
const errorMsg = "Could not decide which workflow to run.";
|
|
117810
|
+
logger.error(errorMsg);
|
|
117811
|
+
return {
|
|
117812
|
+
workflow: "task",
|
|
117813
|
+
success: false,
|
|
117814
|
+
error: errorMsg
|
|
117815
|
+
};
|
|
117791
117816
|
}
|
|
117792
117817
|
logger.info(`
|
|
117793
117818
|
Decision: Using '${decision.workflow}' workflow.`);
|
|
117794
117819
|
switch (decision.workflow) {
|
|
117795
|
-
case "code":
|
|
117796
|
-
await codeWorkflow({ task, interactive: input2.interactive, additionalTools: input2.additionalTools }, context);
|
|
117797
|
-
|
|
117798
|
-
|
|
117799
|
-
|
|
117820
|
+
case "code": {
|
|
117821
|
+
const codeResult = await codeWorkflow({ task, interactive: input2.interactive, additionalTools: input2.additionalTools }, context);
|
|
117822
|
+
return {
|
|
117823
|
+
workflow: "code",
|
|
117824
|
+
success: codeResult.success,
|
|
117825
|
+
summary: codeResult.summaries?.join(`
|
|
117826
|
+
`),
|
|
117827
|
+
error: codeResult.success === false ? codeResult.reason : undefined
|
|
117828
|
+
};
|
|
117829
|
+
}
|
|
117830
|
+
case "task": {
|
|
117831
|
+
const taskResult = await taskWorkflow({
|
|
117800
117832
|
task,
|
|
117801
117833
|
interactive: input2.interactive,
|
|
117802
117834
|
additionalTools: input2.additionalTools
|
|
117803
117835
|
}, context);
|
|
117804
|
-
|
|
117805
|
-
|
|
117806
|
-
|
|
117836
|
+
if (taskResult.type === "Exit") {
|
|
117837
|
+
return {
|
|
117838
|
+
workflow: "task",
|
|
117839
|
+
success: true,
|
|
117840
|
+
summary: taskResult.message
|
|
117841
|
+
};
|
|
117842
|
+
} else if (taskResult.type === "Error") {
|
|
117843
|
+
return {
|
|
117844
|
+
workflow: "task",
|
|
117845
|
+
success: false,
|
|
117846
|
+
error: taskResult.error.message
|
|
117847
|
+
};
|
|
117848
|
+
} else {
|
|
117849
|
+
return {
|
|
117850
|
+
workflow: "task",
|
|
117851
|
+
success: false,
|
|
117852
|
+
error: "Usage limit exceeded"
|
|
117853
|
+
};
|
|
117854
|
+
}
|
|
117855
|
+
}
|
|
117856
|
+
default: {
|
|
117857
|
+
const errorMsg = `Unknown workflow: ${decision.workflow}`;
|
|
117858
|
+
throw new Error(errorMsg);
|
|
117859
|
+
}
|
|
117807
117860
|
}
|
|
117808
117861
|
};
|
|
117809
117862
|
|
|
@@ -117957,12 +118010,28 @@ async function fix3(options = {}) {
|
|
|
117957
118010
|
onUsageMeterCreated: onUsage
|
|
117958
118011
|
});
|
|
117959
118012
|
}
|
|
118013
|
+
async function task2(options) {
|
|
118014
|
+
const { task: taskInput, jsonMode, interactive, onUsage, ...context } = options;
|
|
118015
|
+
const verbose = context.silent ? -1 : context.verbose ?? 0;
|
|
118016
|
+
const logger = createLogger({ verbose });
|
|
118017
|
+
const workflowInput = {
|
|
118018
|
+
task: taskInput,
|
|
118019
|
+
jsonMode
|
|
118020
|
+
};
|
|
118021
|
+
return runWorkflow(taskWorkflow, workflowInput, {
|
|
118022
|
+
commandName: "task",
|
|
118023
|
+
context,
|
|
118024
|
+
logger,
|
|
118025
|
+
interactive: interactive !== false,
|
|
118026
|
+
onUsageMeterCreated: onUsage
|
|
118027
|
+
});
|
|
118028
|
+
}
|
|
117960
118029
|
async function plan3(options = {}) {
|
|
117961
|
-
const { task:
|
|
118030
|
+
const { task: task3, fileContent, planFile, files, mode, interactive, onUsage, ...context } = options;
|
|
117962
118031
|
const verbose = context.silent ? -1 : context.verbose ?? 0;
|
|
117963
118032
|
const logger = createLogger({ verbose });
|
|
117964
118033
|
const workflowInput = {
|
|
117965
|
-
task:
|
|
118034
|
+
task: task3,
|
|
117966
118035
|
fileContent,
|
|
117967
118036
|
filePath: planFile,
|
|
117968
118037
|
files,
|
|
@@ -118025,8 +118094,8 @@ var readStdin = async (timeoutMs = COMMAND_CONSTANTS.DEFAULT_STDIN_TIMEOUT_MS) =
|
|
|
118025
118094
|
});
|
|
118026
118095
|
});
|
|
118027
118096
|
};
|
|
118028
|
-
async function runCode(
|
|
118029
|
-
let taskInput =
|
|
118097
|
+
async function runCode(task3, _options, command) {
|
|
118098
|
+
let taskInput = task3;
|
|
118030
118099
|
const stdin = await readStdin();
|
|
118031
118100
|
if (stdin) {
|
|
118032
118101
|
taskInput = stdin;
|
|
@@ -118113,7 +118182,20 @@ init_lodash();
|
|
|
118113
118182
|
init_dist();
|
|
118114
118183
|
|
|
118115
118184
|
// src/builtin-commands.ts
|
|
118116
|
-
var BUILT_IN_COMMANDS = [
|
|
118185
|
+
var BUILT_IN_COMMANDS = [
|
|
118186
|
+
"code",
|
|
118187
|
+
"commit",
|
|
118188
|
+
"pr",
|
|
118189
|
+
"review",
|
|
118190
|
+
"fix",
|
|
118191
|
+
"plan",
|
|
118192
|
+
"task",
|
|
118193
|
+
"workflow",
|
|
118194
|
+
"run",
|
|
118195
|
+
"init",
|
|
118196
|
+
"meta",
|
|
118197
|
+
"skills"
|
|
118198
|
+
];
|
|
118117
118199
|
|
|
118118
118200
|
// src/configPrompt.ts
|
|
118119
118201
|
init_dist18();
|
|
@@ -119444,15 +119526,15 @@ class McpServer {
|
|
|
119444
119526
|
const taskExtra = { ...extra, taskStore: extra.taskStore };
|
|
119445
119527
|
const createTaskResult = args ? await Promise.resolve(handler20.createTask(args, taskExtra)) : await Promise.resolve(handler20.createTask(taskExtra));
|
|
119446
119528
|
const taskId = createTaskResult.task.taskId;
|
|
119447
|
-
let
|
|
119448
|
-
const pollInterval =
|
|
119449
|
-
while (
|
|
119529
|
+
let task3 = createTaskResult.task;
|
|
119530
|
+
const pollInterval = task3.pollInterval ?? 5000;
|
|
119531
|
+
while (task3.status !== "completed" && task3.status !== "failed" && task3.status !== "cancelled") {
|
|
119450
119532
|
await new Promise((resolve7) => setTimeout(resolve7, pollInterval));
|
|
119451
119533
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
119452
119534
|
if (!updatedTask) {
|
|
119453
119535
|
throw new McpError2(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
119454
119536
|
}
|
|
119455
|
-
|
|
119537
|
+
task3 = updatedTask;
|
|
119456
119538
|
}
|
|
119457
119539
|
return await extra.taskStore.getTaskResult(taskId);
|
|
119458
119540
|
}
|
|
@@ -120125,10 +120207,12 @@ init_code_workflow();
|
|
|
120125
120207
|
init_fix_workflow();
|
|
120126
120208
|
init_plan_workflow();
|
|
120127
120209
|
init_review_workflow();
|
|
120128
|
-
var memoryStoreCache =
|
|
120129
|
-
async function getMemoryStore(logger) {
|
|
120130
|
-
|
|
120131
|
-
|
|
120210
|
+
var memoryStoreCache = new Map;
|
|
120211
|
+
async function getMemoryStore(logger, projectPath) {
|
|
120212
|
+
const normalizedPath = path11.resolve(projectPath).split(path11.sep).join("/");
|
|
120213
|
+
const cached2 = memoryStoreCache.get(normalizedPath);
|
|
120214
|
+
if (cached2) {
|
|
120215
|
+
return cached2;
|
|
120132
120216
|
}
|
|
120133
120217
|
try {
|
|
120134
120218
|
const globalConfigPath = getGlobalConfigPath();
|
|
@@ -120137,20 +120221,20 @@ async function getMemoryStore(logger) {
|
|
|
120137
120221
|
if (!memoryConfig.enabled || memoryConfig.type === "memory") {
|
|
120138
120222
|
return null;
|
|
120139
120223
|
}
|
|
120140
|
-
const
|
|
120141
|
-
const scope = detectProjectScope(cwd);
|
|
120224
|
+
const scope = `project:${normalizedPath}`;
|
|
120142
120225
|
const dbPath = memoryConfig.path || DEFAULT_MEMORY_CONFIG.path;
|
|
120143
120226
|
const resolvedDbPath = path11.resolve(resolveHomePath(dbPath));
|
|
120144
120227
|
const sqliteStore = new SQLiteMemoryStore({ enabled: true, type: "sqlite", path: resolvedDbPath }, scope);
|
|
120145
120228
|
const memoryManager = new MemoryManager(sqliteStore);
|
|
120146
|
-
|
|
120229
|
+
const store = {
|
|
120147
120230
|
store: memoryManager,
|
|
120148
120231
|
close: () => {
|
|
120149
120232
|
sqliteStore.close();
|
|
120150
|
-
memoryStoreCache
|
|
120233
|
+
memoryStoreCache.delete(normalizedPath);
|
|
120151
120234
|
}
|
|
120152
120235
|
};
|
|
120153
|
-
|
|
120236
|
+
memoryStoreCache.set(normalizedPath, store);
|
|
120237
|
+
return store;
|
|
120154
120238
|
} catch (error48) {
|
|
120155
120239
|
logger.error(`Failed to initialize memory store: ${error48 instanceof Error ? error48.message : String(error48)}`);
|
|
120156
120240
|
return null;
|
|
@@ -120271,10 +120355,10 @@ Parameters:
|
|
|
120271
120355
|
...providerOverrideSchema.shape
|
|
120272
120356
|
}),
|
|
120273
120357
|
handler: async (args, toolContext) => {
|
|
120274
|
-
const { task:
|
|
120358
|
+
const { task: task3 } = args;
|
|
120275
120359
|
const providerOverride = extractProviderOverride(args);
|
|
120276
|
-
logger.info(`MCP: Executing code workflow - task: "${
|
|
120277
|
-
return await executeWorkflow(codeWorkflow, { task:
|
|
120360
|
+
logger.info(`MCP: Executing code workflow - task: "${task3}"${providerOverride?.provider ? ` with provider: ${providerOverride.provider}` : ""}`);
|
|
120361
|
+
return await executeWorkflow(codeWorkflow, { task: task3 }, "code", logger, providerOverride, toolContext.defaultProvider);
|
|
120278
120362
|
}
|
|
120279
120363
|
},
|
|
120280
120364
|
{
|
|
@@ -120357,9 +120441,9 @@ Parameters:
|
|
|
120357
120441
|
...providerOverrideSchema.shape
|
|
120358
120442
|
}),
|
|
120359
120443
|
handler: async (args, toolContext) => {
|
|
120360
|
-
const { task:
|
|
120444
|
+
const { task: task3 } = args;
|
|
120361
120445
|
const providerOverride = extractProviderOverride(args);
|
|
120362
|
-
logger.info(`MCP: Executing plan workflow - task: "${
|
|
120446
|
+
logger.info(`MCP: Executing plan workflow - task: "${task3}"${providerOverride?.provider ? ` with provider: ${providerOverride.provider}` : ""}`);
|
|
120363
120447
|
try {
|
|
120364
120448
|
const context = createExecutionContext(logger);
|
|
120365
120449
|
const finalProvider = providerOverride?.provider || toolContext.defaultProvider?.provider;
|
|
@@ -120375,7 +120459,7 @@ Parameters:
|
|
|
120375
120459
|
if (finalApiKey) {
|
|
120376
120460
|
context.apiKey = finalApiKey;
|
|
120377
120461
|
}
|
|
120378
|
-
const result = await runWorkflow(planWorkflow, { task:
|
|
120462
|
+
const result = await runWorkflow(planWorkflow, { task: task3, interactive: false }, {
|
|
120379
120463
|
commandName: "plan",
|
|
120380
120464
|
context,
|
|
120381
120465
|
logger,
|
|
@@ -120455,10 +120539,10 @@ Parameters:
|
|
|
120455
120539
|
...providerOverrideSchema.shape
|
|
120456
120540
|
}),
|
|
120457
120541
|
handler: async (args, toolContext) => {
|
|
120458
|
-
const { task:
|
|
120542
|
+
const { task: task3 } = args;
|
|
120459
120543
|
const providerOverride = extractProviderOverride(args);
|
|
120460
|
-
logger.info(`MCP: Executing fix workflow - task: "${
|
|
120461
|
-
return await executeWorkflow(fixWorkflow, { task:
|
|
120544
|
+
logger.info(`MCP: Executing fix workflow - task: "${task3}"${providerOverride?.provider ? ` with provider: ${providerOverride.provider}` : ""}`);
|
|
120545
|
+
return await executeWorkflow(fixWorkflow, { task: task3 }, "fix", logger, providerOverride, toolContext.defaultProvider);
|
|
120462
120546
|
}
|
|
120463
120547
|
},
|
|
120464
120548
|
{
|
|
@@ -120534,16 +120618,18 @@ Memory persists across tool calls, allowing you to maintain context
|
|
|
120534
120618
|
between different operations.
|
|
120535
120619
|
|
|
120536
120620
|
Parameters:
|
|
120621
|
+
- project (required): Absolute path to the project directory. This isolates memory to a specific project.
|
|
120537
120622
|
- topic (optional): The memory topic to read from. Defaults to ":default:" which stores general conversation context.
|
|
120538
120623
|
|
|
120539
120624
|
Returns the content stored in the specified topic, or a message indicating the topic is empty.`,
|
|
120540
120625
|
inputSchema: exports_external.object({
|
|
120626
|
+
project: exports_external.string().describe('Absolute path to the project directory (e.g., "/home/user/my-project")'),
|
|
120541
120627
|
topic: exports_external.string().optional().describe('The memory topic to read from (defaults to ":default:")')
|
|
120542
120628
|
}),
|
|
120543
120629
|
handler: async (args, toolContext) => {
|
|
120544
|
-
const { topic = ":default:" } = args;
|
|
120545
|
-
toolContext.logger.info(`MCP: Reading from memory topic "${topic}"`);
|
|
120546
|
-
const memoryStore = await getMemoryStore(toolContext.logger);
|
|
120630
|
+
const { project, topic = ":default:" } = args;
|
|
120631
|
+
toolContext.logger.info(`MCP: Reading from memory topic "${topic}" for project "${project}"`);
|
|
120632
|
+
const memoryStore = await getMemoryStore(toolContext.logger, project);
|
|
120547
120633
|
if (!memoryStore) {
|
|
120548
120634
|
return "Error: Memory store is not enabled. Configure it in your .polkacodes.yml with memory.enabled: true";
|
|
120549
120635
|
}
|
|
@@ -120567,6 +120653,7 @@ Memory persists across tool calls, allowing you to maintain context
|
|
|
120567
120653
|
between different operations.
|
|
120568
120654
|
|
|
120569
120655
|
Parameters:
|
|
120656
|
+
- project (required): Absolute path to the project directory. This isolates memory to a specific project.
|
|
120570
120657
|
- operation (required): The operation to perform. Use "append" to add content, "replace" to overwrite all content, or "remove" to delete the topic.
|
|
120571
120658
|
- 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).
|
|
120572
120659
|
- topic (optional): Single memory topic to update. Defaults to ":default:".
|
|
@@ -120578,6 +120665,7 @@ Supports wildcards in topic name for remove operation:
|
|
|
120578
120665
|
|
|
120579
120666
|
Returns a message confirming the operation performed.`,
|
|
120580
120667
|
inputSchema: exports_external.object({
|
|
120668
|
+
project: exports_external.string().describe('Absolute path to the project directory (e.g., "/home/user/my-project")'),
|
|
120581
120669
|
operation: exports_external.enum(["append", "replace", "remove"]).describe("The operation: append (add content), replace (overwrite), or remove (delete topic(s))"),
|
|
120582
120670
|
topic: exports_external.string().optional().describe('Single memory topic to update (defaults to ":default:")'),
|
|
120583
120671
|
topics: exports_external.array(exports_external.string()).min(1).optional().describe("Array of topics for batch operations"),
|
|
@@ -120598,13 +120686,14 @@ Returns a message confirming the operation performed.`,
|
|
|
120598
120686
|
}),
|
|
120599
120687
|
handler: async (args, toolContext) => {
|
|
120600
120688
|
const {
|
|
120689
|
+
project,
|
|
120601
120690
|
operation,
|
|
120602
120691
|
topic: singleTopic,
|
|
120603
120692
|
topics,
|
|
120604
120693
|
content: contentInput
|
|
120605
120694
|
} = args;
|
|
120606
|
-
toolContext.logger.info(`MCP: Memory operation "${operation}" on ${topics ? `${topics.length} topics` : `topic "${singleTopic}"`}`);
|
|
120607
|
-
const memoryStore = await getMemoryStore(toolContext.logger);
|
|
120695
|
+
toolContext.logger.info(`MCP: Memory operation "${operation}" on ${topics ? `${topics.length} topics` : `topic "${singleTopic}"`} for project "${project}"`);
|
|
120696
|
+
const memoryStore = await getMemoryStore(toolContext.logger, project);
|
|
120608
120697
|
if (!memoryStore) {
|
|
120609
120698
|
return "Error: Memory store is not enabled. Configure it in your .polkacodes.yml with memory.enabled: true";
|
|
120610
120699
|
}
|
|
@@ -120674,23 +120763,21 @@ Use this to see what information has been stored and which topics are
|
|
|
120674
120763
|
available to read from. Returns a list of topic names that have content.
|
|
120675
120764
|
|
|
120676
120765
|
Parameters:
|
|
120677
|
-
-
|
|
120678
|
-
-
|
|
120766
|
+
- project (required): Absolute path to the project directory. This isolates memory to a specific project.
|
|
120767
|
+
- pattern (optional): Filter topics by wildcard pattern (e.g., ":plan:*" for all plan topics)`,
|
|
120679
120768
|
inputSchema: exports_external.object({
|
|
120680
|
-
|
|
120681
|
-
|
|
120769
|
+
project: exports_external.string().describe('Absolute path to the project directory (e.g., "/home/user/my-project")'),
|
|
120770
|
+
pattern: exports_external.string().optional().describe('Filter topics by wildcard pattern (e.g., ":plan:*")')
|
|
120682
120771
|
}),
|
|
120683
120772
|
handler: async (args, toolContext) => {
|
|
120684
|
-
const {
|
|
120685
|
-
toolContext.logger.info(`MCP: Listing memory topics${pattern ? ` with pattern "${pattern}"` : ""}`);
|
|
120686
|
-
const memoryStore = await getMemoryStore(toolContext.logger);
|
|
120773
|
+
const { project, pattern } = args;
|
|
120774
|
+
toolContext.logger.info(`MCP: Listing memory topics for project "${project}"${pattern ? ` with pattern "${pattern}"` : ""}`);
|
|
120775
|
+
const memoryStore = await getMemoryStore(toolContext.logger, project);
|
|
120687
120776
|
if (!memoryStore) {
|
|
120688
120777
|
return "Error: Memory store is not enabled. Configure it in your .polkacodes.yml with memory.enabled: true";
|
|
120689
120778
|
}
|
|
120690
120779
|
try {
|
|
120691
|
-
const
|
|
120692
|
-
query.scope = scope ?? "auto";
|
|
120693
|
-
const entries = await memoryStore.store.queryMemory(query, { operation: "select" });
|
|
120780
|
+
const entries = await memoryStore.store.queryMemory({}, { operation: "select" });
|
|
120694
120781
|
if (!entries || !Array.isArray(entries) || entries.length === 0) {
|
|
120695
120782
|
return "No memory topics found.";
|
|
120696
120783
|
}
|
|
@@ -120718,42 +120805,41 @@ Use this to search memory entries by content, metadata, or other criteria.
|
|
|
120718
120805
|
Returns detailed entry information with metadata.
|
|
120719
120806
|
|
|
120720
120807
|
Parameters:
|
|
120808
|
+
- project (required): Absolute path to the project directory. This isolates memory to a specific project.
|
|
120721
120809
|
- search (optional): Search text to find in content
|
|
120722
120810
|
- type (optional): Filter by entry type (note, todo, plan, etc.)
|
|
120723
120811
|
- status (optional): Filter by status (open, completed, closed, etc.)
|
|
120724
120812
|
- priority (optional): Filter by priority (null, low, medium, high)
|
|
120725
120813
|
- tags (optional): Filter by tags
|
|
120726
|
-
- scope (optional): Filter by scope ("auto", "project", or "global")
|
|
120727
120814
|
- operation (optional): Query operation - "select" returns entries, "count" returns count
|
|
120728
120815
|
|
|
120729
120816
|
Returns matching entries with full metadata.`,
|
|
120730
120817
|
inputSchema: exports_external.object({
|
|
120818
|
+
project: exports_external.string().describe('Absolute path to the project directory (e.g., "/home/user/my-project")'),
|
|
120731
120819
|
search: exports_external.string().optional().describe("Search text to find in content"),
|
|
120732
120820
|
type: exports_external.string().optional().describe("Filter by entry type (note, todo, plan, etc.)"),
|
|
120733
120821
|
status: exports_external.string().optional().describe("Filter by status (open, completed, closed, etc.)"),
|
|
120734
120822
|
priority: exports_external.string().optional().describe("Filter by priority (null, low, medium, high)"),
|
|
120735
120823
|
tags: exports_external.string().optional().describe("Filter by tags"),
|
|
120736
|
-
scope: exports_external.enum(["auto", "project", "global"]).optional().describe('Filter by scope (defaults to "auto")'),
|
|
120737
120824
|
operation: exports_external.enum(["select", "count"]).optional().describe('Query operation (defaults to "select")')
|
|
120738
120825
|
}),
|
|
120739
120826
|
handler: async (args, toolContext) => {
|
|
120740
120827
|
const {
|
|
120828
|
+
project,
|
|
120741
120829
|
search,
|
|
120742
120830
|
type,
|
|
120743
120831
|
status,
|
|
120744
120832
|
priority,
|
|
120745
120833
|
tags,
|
|
120746
|
-
scope,
|
|
120747
120834
|
operation = "select"
|
|
120748
120835
|
} = args;
|
|
120749
|
-
toolContext.logger.info(`MCP: Querying memory - operation: "${operation}"`);
|
|
120750
|
-
const memoryStore = await getMemoryStore(toolContext.logger);
|
|
120836
|
+
toolContext.logger.info(`MCP: Querying memory for project "${project}" - operation: "${operation}"`);
|
|
120837
|
+
const memoryStore = await getMemoryStore(toolContext.logger, project);
|
|
120751
120838
|
if (!memoryStore) {
|
|
120752
120839
|
return "Error: Memory store is not enabled. Configure it in your .polkacodes.yml with memory.enabled: true";
|
|
120753
120840
|
}
|
|
120754
120841
|
try {
|
|
120755
120842
|
const memoryQuery = {};
|
|
120756
|
-
memoryQuery.scope = scope ?? "auto";
|
|
120757
120843
|
if (search)
|
|
120758
120844
|
memoryQuery.search = search;
|
|
120759
120845
|
if (type)
|
|
@@ -121416,14 +121502,14 @@ async function executeScript(script, name18, logger, args = []) {
|
|
|
121416
121502
|
}
|
|
121417
121503
|
|
|
121418
121504
|
// src/commands/meta.ts
|
|
121419
|
-
async function runMeta(
|
|
121505
|
+
async function runMeta(task3, command) {
|
|
121420
121506
|
const workflowOpts = getBaseWorkflowOptions(command);
|
|
121421
|
-
const { verbose } = workflowOpts;
|
|
121507
|
+
const { verbose, json: json2 } = workflowOpts;
|
|
121422
121508
|
const logger = createLogger({
|
|
121423
|
-
verbose
|
|
121509
|
+
verbose: json2 ? -1 : verbose
|
|
121424
121510
|
});
|
|
121425
|
-
if (
|
|
121426
|
-
const trimmedTask =
|
|
121511
|
+
if (task3) {
|
|
121512
|
+
const trimmedTask = task3.trim();
|
|
121427
121513
|
const words2 = trimmedTask.split(/\s+/);
|
|
121428
121514
|
if (words2.length === 1) {
|
|
121429
121515
|
const matched = await tryExecuteCommand(words2[0], logger);
|
|
@@ -121432,7 +121518,7 @@ async function runMeta(task2, command) {
|
|
|
121432
121518
|
}
|
|
121433
121519
|
logger.error(`Error: Unknown command '${words2[0]}'`);
|
|
121434
121520
|
logger.info("Available commands:");
|
|
121435
|
-
logger.info(" Built-in: code, commit, pr, review, fix, plan, workflow, run");
|
|
121521
|
+
logger.info(" Built-in: code, commit, pr, review, fix, plan, task, workflow, run");
|
|
121436
121522
|
const config4 = await loadConfig2();
|
|
121437
121523
|
if (config4?.scripts) {
|
|
121438
121524
|
const scriptNames = Object.keys(config4.scripts);
|
|
@@ -121452,15 +121538,19 @@ async function runMeta(task2, command) {
|
|
|
121452
121538
|
return;
|
|
121453
121539
|
}
|
|
121454
121540
|
const workflowInput2 = {
|
|
121455
|
-
task:
|
|
121541
|
+
task: task3,
|
|
121542
|
+
jsonMode: json2 === true,
|
|
121456
121543
|
...workflowOpts
|
|
121457
121544
|
};
|
|
121458
|
-
await runWorkflow(metaWorkflow, workflowInput2, {
|
|
121545
|
+
const result2 = await runWorkflow(metaWorkflow, workflowInput2, {
|
|
121459
121546
|
commandName: "meta",
|
|
121460
121547
|
context: workflowOpts,
|
|
121461
121548
|
logger,
|
|
121462
121549
|
...workflowOpts
|
|
121463
121550
|
});
|
|
121551
|
+
if (json2 && result2) {
|
|
121552
|
+
console.log(JSON.stringify(result2, null, 2));
|
|
121553
|
+
}
|
|
121464
121554
|
return;
|
|
121465
121555
|
}
|
|
121466
121556
|
const input2 = await getUserInput("What do you want to work on?");
|
|
@@ -121477,7 +121567,7 @@ async function runMeta(task2, command) {
|
|
|
121477
121567
|
}
|
|
121478
121568
|
logger.error(`Error: Unknown command '${words[0]}'`);
|
|
121479
121569
|
logger.info("Available commands:");
|
|
121480
|
-
logger.info(" Built-in: code, commit, pr, review, fix, plan, workflow, run");
|
|
121570
|
+
logger.info(" Built-in: code, commit, pr, review, fix, plan, task, workflow, run");
|
|
121481
121571
|
return;
|
|
121482
121572
|
}
|
|
121483
121573
|
if (words.length < 2) {
|
|
@@ -121488,14 +121578,18 @@ async function runMeta(task2, command) {
|
|
|
121488
121578
|
}
|
|
121489
121579
|
const workflowInput = {
|
|
121490
121580
|
task: input2,
|
|
121581
|
+
jsonMode: json2 === true,
|
|
121491
121582
|
...workflowOpts
|
|
121492
121583
|
};
|
|
121493
|
-
await runWorkflow(metaWorkflow, workflowInput, {
|
|
121584
|
+
const result = await runWorkflow(metaWorkflow, workflowInput, {
|
|
121494
121585
|
commandName: "meta",
|
|
121495
121586
|
context: workflowOpts,
|
|
121496
121587
|
logger,
|
|
121497
121588
|
...workflowOpts
|
|
121498
121589
|
});
|
|
121590
|
+
if (json2 && result) {
|
|
121591
|
+
console.log(JSON.stringify(result, null, 2));
|
|
121592
|
+
}
|
|
121499
121593
|
}
|
|
121500
121594
|
async function tryExecuteCommand(commandName, logger) {
|
|
121501
121595
|
if (BUILT_IN_COMMANDS.includes(commandName)) {
|
|
@@ -121523,8 +121617,8 @@ async function tryExecuteCommand(commandName, logger) {
|
|
|
121523
121617
|
|
|
121524
121618
|
// src/commands/plan.ts
|
|
121525
121619
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
121526
|
-
var planCommand = new Command("plan").description("Create or update a plan for a task.").argument("[task]", "The task to plan.").option("-p, --plan-file <path>", "The path to the plan file.").action(async (
|
|
121527
|
-
let taskInput =
|
|
121620
|
+
var planCommand = new Command("plan").description("Create or update a plan for a task.").argument("[task]", "The task to plan.").option("-p, --plan-file <path>", "The path to the plan file.").action(async (task3, options, command) => {
|
|
121621
|
+
let taskInput = task3;
|
|
121528
121622
|
let fileContent;
|
|
121529
121623
|
if (options.planFile) {
|
|
121530
121624
|
try {
|
|
@@ -121895,10 +121989,33 @@ skillsCommand.command("validate").description("Validate a skill's structure and
|
|
|
121895
121989
|
}
|
|
121896
121990
|
});
|
|
121897
121991
|
|
|
121992
|
+
// src/commands/task.ts
|
|
121993
|
+
async function runTask(taskInput, options, command) {
|
|
121994
|
+
const workflowOpts = getBaseWorkflowOptions(command);
|
|
121995
|
+
if (options.json) {
|
|
121996
|
+
workflowOpts.silent = true;
|
|
121997
|
+
}
|
|
121998
|
+
const result = await task2({
|
|
121999
|
+
task: taskInput ?? "",
|
|
122000
|
+
jsonMode: options.json === true,
|
|
122001
|
+
...workflowOpts
|
|
122002
|
+
});
|
|
122003
|
+
if (options.json) {
|
|
122004
|
+
if (result) {
|
|
122005
|
+
if (result.type === "Exit" && result.object) {
|
|
122006
|
+
console.log(JSON.stringify(result.object, null, 2));
|
|
122007
|
+
} else {
|
|
122008
|
+
console.log(JSON.stringify(result, null, 2));
|
|
122009
|
+
}
|
|
122010
|
+
}
|
|
122011
|
+
}
|
|
122012
|
+
}
|
|
122013
|
+
var taskCommand = new Command("task").description("Run a generic task using an AI agent.").argument("[task]", "The task to perform").option("--json", "Output result as JSON").action(runTask);
|
|
122014
|
+
|
|
121898
122015
|
// src/commands/workflow.ts
|
|
121899
122016
|
init_src();
|
|
121900
122017
|
import { readFile as readFile14 } from "node:fs/promises";
|
|
121901
|
-
async function runWorkflowCommand(
|
|
122018
|
+
async function runWorkflowCommand(task3, _options, command) {
|
|
121902
122019
|
const workflowOpts = getBaseWorkflowOptions(command);
|
|
121903
122020
|
const { verbose } = workflowOpts;
|
|
121904
122021
|
const logger = createLogger({ verbose });
|
|
@@ -121969,10 +122086,10 @@ async function runWorkflowCommand(task2, _options, command) {
|
|
|
121969
122086
|
};
|
|
121970
122087
|
const selectedWorkflow = workflowDef.workflows[workflowId];
|
|
121971
122088
|
const workflowInput = {};
|
|
121972
|
-
if (selectedWorkflow.inputs && selectedWorkflow.inputs.length > 0 &&
|
|
122089
|
+
if (selectedWorkflow.inputs && selectedWorkflow.inputs.length > 0 && task3) {
|
|
121973
122090
|
const firstInput = selectedWorkflow.inputs[0];
|
|
121974
|
-
workflowInput[firstInput.id] =
|
|
121975
|
-
logger.info(`Workflow input '${firstInput.id}': ${
|
|
122091
|
+
workflowInput[firstInput.id] = task3;
|
|
122092
|
+
logger.info(`Workflow input '${firstInput.id}': ${task3}`);
|
|
121976
122093
|
} else if (selectedWorkflow.inputs && selectedWorkflow.inputs.length > 0) {
|
|
121977
122094
|
logger.info(`Workflow expects inputs: ${selectedWorkflow.inputs.map((i2) => i2.id).join(", ")}`);
|
|
121978
122095
|
} else {
|
|
@@ -121992,7 +122109,7 @@ var workflowCommand = new Command("workflow").description("Run custom workflows.
|
|
|
121992
122109
|
globalThis.AI_SDK_LOG_WARNINGS = false;
|
|
121993
122110
|
var program2 = new Command;
|
|
121994
122111
|
program2.name("polka").description("Polka Codes CLI").version(version);
|
|
121995
|
-
program2.argument("[task]", "The task to execute").action((
|
|
122112
|
+
program2.argument("[task]", "The task to execute").action((task3, _options, command) => runMeta(task3, command));
|
|
121996
122113
|
program2.addCommand(initCommand);
|
|
121997
122114
|
program2.addCommand(agentCommand);
|
|
121998
122115
|
program2.addCommand(commitCommand);
|
|
@@ -122001,6 +122118,7 @@ program2.addCommand(reviewCommand);
|
|
|
122001
122118
|
program2.addCommand(planCommand);
|
|
122002
122119
|
program2.addCommand(codeCommand);
|
|
122003
122120
|
program2.addCommand(fixCommand);
|
|
122121
|
+
program2.addCommand(taskCommand);
|
|
122004
122122
|
program2.addCommand(runCommand);
|
|
122005
122123
|
program2.addCommand(skillsCommand);
|
|
122006
122124
|
program2.addCommand(mcpServerCommand);
|
|
@@ -122019,6 +122137,7 @@ process.on("uncaughtException", (error48) => {
|
|
|
122019
122137
|
}
|
|
122020
122138
|
});
|
|
122021
122139
|
export {
|
|
122140
|
+
task2 as task,
|
|
122022
122141
|
reviewCode,
|
|
122023
122142
|
plan3 as plan,
|
|
122024
122143
|
fix3 as fix,
|