@polka-codes/core 0.8.6 → 0.8.8

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.
@@ -780,6 +780,7 @@ declare const _default: {
780
780
  readonly description: "One or more follow-up questions you need answered before you can continue.";
781
781
  readonly required: true;
782
782
  readonly allowMultiple: true;
783
+ readonly usageValue: "questions here";
783
784
  readonly children: [{
784
785
  readonly name: "prompt";
785
786
  readonly description: "The text of the question.";
@@ -841,6 +842,7 @@ declare const _default: {
841
842
  readonly description: "One or more follow-up questions you need answered before you can continue.";
842
843
  readonly required: true;
843
844
  readonly allowMultiple: true;
845
+ readonly usageValue: "questions here";
844
846
  readonly children: [{
845
847
  readonly name: "prompt";
846
848
  readonly description: "The text of the question.";
@@ -2586,6 +2588,7 @@ export declare const toolInfo: {
2586
2588
  readonly description: "One or more follow-up questions you need answered before you can continue.";
2587
2589
  readonly required: true;
2588
2590
  readonly allowMultiple: true;
2591
+ readonly usageValue: "questions here";
2589
2592
  readonly children: [{
2590
2593
  readonly name: "prompt";
2591
2594
  readonly description: "The text of the question.";
package/dist/index.js CHANGED
@@ -1087,6 +1087,7 @@ var toolInfo = {
1087
1087
  description: "One or more follow-up questions you need answered before you can continue.",
1088
1088
  required: true,
1089
1089
  allowMultiple: true,
1090
+ usageValue: "questions here",
1090
1091
  children: [
1091
1092
  {
1092
1093
  name: "prompt",
@@ -2310,16 +2311,46 @@ var getAvailableTools = ({
2310
2311
  };
2311
2312
 
2312
2313
  // src/Agent/parseAssistantMessage.ts
2313
- function parseNestedParameters(content, parameterPrefix) {
2314
+ function parseNestedParameters(content, parameterPrefix, childrenParams) {
2314
2315
  const result = {};
2315
2316
  const nestedParamRegex = new RegExp(`<${parameterPrefix}([^>]+)>([\\s\\S]*?)<\\/${parameterPrefix}\\1>`, "gs");
2317
+ const arrayParams = /* @__PURE__ */ new Set();
2318
+ if (childrenParams) {
2319
+ for (const param of childrenParams) {
2320
+ if (param.allowMultiple) {
2321
+ arrayParams.add(param.name);
2322
+ }
2323
+ }
2324
+ }
2316
2325
  while (true) {
2317
2326
  const match = nestedParamRegex.exec(content);
2318
2327
  if (match === null) break;
2319
2328
  const paramName = match[1];
2320
2329
  const paramContent = match[2].trim();
2321
- if (paramContent.includes(`<${parameterPrefix}`)) {
2322
- result[paramName] = parseNestedParameters(paramContent, parameterPrefix);
2330
+ const childParam = childrenParams?.find((p) => p.name === paramName);
2331
+ if (paramContent.includes(`<${parameterPrefix}`) && childParam?.children) {
2332
+ const nestedResult = parseNestedParameters(paramContent, parameterPrefix, childParam.children);
2333
+ if (arrayParams.has(paramName)) {
2334
+ if (!result[paramName]) {
2335
+ result[paramName] = [];
2336
+ }
2337
+ if (Array.isArray(result[paramName])) {
2338
+ result[paramName].push(nestedResult);
2339
+ } else {
2340
+ result[paramName] = [nestedResult];
2341
+ }
2342
+ } else {
2343
+ result[paramName] = nestedResult;
2344
+ }
2345
+ } else if (arrayParams.has(paramName)) {
2346
+ if (!result[paramName]) {
2347
+ result[paramName] = [];
2348
+ }
2349
+ if (Array.isArray(result[paramName])) {
2350
+ result[paramName].push(paramContent);
2351
+ } else {
2352
+ result[paramName] = [paramContent];
2353
+ }
2323
2354
  } else {
2324
2355
  result[paramName] = paramContent;
2325
2356
  }
@@ -2361,15 +2392,29 @@ function parseAssistantMessage(assistantMessage, tools, toolNamePrefix) {
2361
2392
  paramMatches.push(paramMatch[1].trim());
2362
2393
  }
2363
2394
  if (paramMatches.length > 0) {
2364
- if (paramMatches.length === 1) {
2395
+ if (paramMatches.length === 1 && !param.allowMultiple) {
2365
2396
  const paramContent = paramMatches[0];
2366
- if (paramContent.includes(`<${parameterPrefix}`)) {
2367
- params[param.name] = parseNestedParameters(paramContent, parameterPrefix);
2397
+ if (paramContent.includes(`<${parameterPrefix}`) && param.children) {
2398
+ params[param.name] = parseNestedParameters(paramContent, parameterPrefix, param.children);
2368
2399
  } else {
2369
2400
  params[param.name] = paramContent;
2370
2401
  }
2371
2402
  } else {
2372
- params[param.name] = paramMatches;
2403
+ if (param.allowMultiple) {
2404
+ params[param.name] = paramMatches.map((paramContent) => {
2405
+ if (paramContent.includes(`<${parameterPrefix}`) && param.children) {
2406
+ return parseNestedParameters(paramContent, parameterPrefix, param.children);
2407
+ }
2408
+ return paramContent;
2409
+ });
2410
+ } else {
2411
+ const paramContent = paramMatches[0];
2412
+ if (paramContent.includes(`<${parameterPrefix}`) && param.children) {
2413
+ params[param.name] = parseNestedParameters(paramContent, parameterPrefix, param.children);
2414
+ } else {
2415
+ params[param.name] = paramContent;
2416
+ }
2417
+ }
2373
2418
  }
2374
2419
  }
2375
2420
  }
@@ -2420,11 +2465,16 @@ var toolInfoPrompt = (tool, toolNamePrefix, parameterPrefix) => `
2420
2465
  Description: ${tool.description}
2421
2466
 
2422
2467
  Parameters:
2423
- ${tool.parameters.map((param) => `- ${parameterPrefix}${param.name}: (${param.required ? "required" : "optional"}) ${param.description}`).join("\n")}
2468
+ ${tool.parameters.map(
2469
+ (param) => `- ${parameterPrefix}${param.name}: (${param.required ? "required" : "optional"})${param.allowMultiple ? " (multiple allowed)" : ""} ${param.description}`
2470
+ ).join("\n")}
2424
2471
 
2425
2472
  Usage:
2426
2473
  <${toolNamePrefix}${tool.name}>
2427
- ${tool.parameters.map((param) => `<${parameterPrefix}${param.name}>${param.usageValue}</${parameterPrefix}${param.name}>`).join("\n")}
2474
+ ${tool.parameters.map(
2475
+ (param) => param.allowMultiple ? `<${parameterPrefix}${param.name}>${param.usageValue}</${parameterPrefix}${param.name}>
2476
+ <${parameterPrefix}${param.name}>${param.usageValue}</${parameterPrefix}${param.name}>` : `<${parameterPrefix}${param.name}>${param.usageValue}</${parameterPrefix}${param.name}>`
2477
+ ).join("\n")}
2428
2478
  </${toolNamePrefix}${tool.name}>`;
2429
2479
  var toolInfoExamplesPrompt = (tool, example, toolNamePrefix, parameterPrefix) => `
2430
2480
  ## Example: ${example.description}
@@ -2972,42 +3022,35 @@ var fullSystemPrompt2 = (info, tools, toolNamePrefix, instructions, scripts) =>
2972
3022
  ## Role
2973
3023
  You are the **Architect** agent, responsible for:
2974
3024
  1. **Task Analysis** - Understand requirements.
2975
- 2. **File Identification** - Find and select relevant files.
2976
- 3. **File Reading** - Use the provided tools to gather information from these files.
2977
- 4. **Implementation Plan** - Draft a detailed, unambiguous, *code-free* plan (pseudocode or interface stubs allowed).
2978
- 5. **Review & Improve** - Evaluate and refine the plan.
3025
+ 2. **File Identification** - Select relevant files.
3026
+ 3. **File Reading** - Use provided tools to gather information.
3027
+ 4. **Implementation Plan** - Draft a *code-free* plan (pseudocode/interface stubs permitted).
3028
+ 5. **Review & Improve** - Refine the plan.
2979
3029
  6. **Handover/Delegate** - Provide the final plan, context, and files to the **Coder** agent.
2980
3030
 
2981
- > **Note**: The **Architect** agent must **never** modify project files directly. Your sole deliverable is the implementation plan; the **Coder** agent will perform all code changes.
3031
+ > **Never** modify project files directly. Only produce the implementation plan; the **Coder** agent performs all code changes.
2982
3032
 
2983
3033
  ## Rules
2984
- 1. **Consistency** - Always align with the user's instructions and project objectives.
2985
- 2. **Relevance** - Consult only files essential to the task.
2986
- 3. **Conciseness** - Communicate succinctly; avoid repetition.
2987
- 4. **Accuracy** - Ensure findings and conclusions are correct and verifiable.
2988
- 5. **Clarity** - Present information in a structured, easy-to-follow format.
2989
- 6. **Minimal Queries** - Ask clarifying questions only when essential; avoid redundant questioning.
3034
+ 1. **Consistency** - Align with user objectives.
3035
+ 2. **Relevance** - Consult only essential files.
3036
+ 3. **Conciseness** - Be succinct; avoid repetition.
3037
+ 4. **Accuracy** - Ensure conclusions are verifiable.
3038
+ 5. **Clarity** - Present information in a structured format.
3039
+ 6. **Minimal Queries** - Ask questions only when truly needed.
2990
3040
 
2991
3041
  ## Steps
2992
- 1. **Analyze Task**
2993
- - Capture requirements, constraints, and objectives.
2994
-
2995
- 2. **Identify Relevant Files**
2996
- - List the specific files needed and justify each selection.
2997
-
2998
- 3. **Read Files via Tools**
2999
- - Extract key information with provided tools and summarize insights.
3000
-
3001
- 4. **Create Implementation Plan**
3002
- - Produce a **detailed, step-by-step plan** that:
3003
- - Describes tasks, resources, and dependencies.
3004
- - Uses pseudocode or interface declarations *only*\u2014no concrete code.
3005
- - Is explicit enough for the **Coder** agent to implement without further clarification.
3006
-
3007
- 5. **Handover/Delegate**
3042
+ 1. **Analyze Task** - Capture goals, constraints, and success criteria.
3043
+ 2. **Identify Relevant Files** - List files and justify each choice.
3044
+ 3. **Read Files via Tools** - Summarize key insights.
3045
+ 4. **Create Implementation Plan** - Provide a detailed, step-by-step breakdown:
3046
+ * Tasks, resources, and dependencies.
3047
+ * Pseudocode or interface declarations only\u2014no concrete code.
3048
+ * Sufficient detail for the **Coder** to implement without follow-ups.
3049
+ 5. **Review & Improve** - Confirm the plan is unambiguous and complete.
3050
+ 6. **Handover/Delegate**
3008
3051
  - If the plan consists of a single self-contained step, hand it over as one task.
3009
- - If multiple steps are required, break them into numbered tasks for the **Coder** agent.
3010
- - Provide all necessary context, file references, and clarifications for successful execution.
3052
+ - If multiple steps are required, break them into numbered tasks to delegate to the **Coder** agent.
3053
+ - Provide all necessary context, implementation plan, file references, and clarifications for successful execution.
3011
3054
 
3012
3055
  ${toolUsePrompt(tools, toolNamePrefix)}
3013
3056
  ${capabilities(toolNamePrefix)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/core",
3
- "version": "0.8.6",
3
+ "version": "0.8.8",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",