@polka-codes/core 0.8.3 → 0.8.5

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.
@@ -774,64 +774,122 @@ export declare class DeepSeekService extends AiServiceBase {
774
774
  declare const _default: {
775
775
  handler: ToolHandler<{
776
776
  readonly name: "ask_followup_question";
777
- readonly description: "Whenever you need extra details or clarification to complete the task, pose a direct question to the user. Use this tool sparingly to avoid excessive back-and-forth. If helpful, offer multiple-choice options or examples to guide the user’s response.";
777
+ readonly description: "Call this when vital details are missing. Pose each follow-up as one direct, unambiguous question. If it speeds the reply, add up to five short, mutually-exclusive answer options. Group any related questions in the same call to avoid a back-and-forth chain.";
778
778
  readonly parameters: [{
779
- readonly name: "question";
780
- readonly description: "The question to ask the user. This should be a clear, specific question that addresses the information you need.";
779
+ readonly name: "questions";
780
+ readonly description: "One or more follow-up questions you need answered before you can continue.";
781
781
  readonly required: true;
782
- readonly usageValue: "Your question here";
783
- }, {
784
- readonly name: "options";
785
- readonly description: "A comma separated list of possible answers to the question. Ordered by preference. If not provided, the user will be prompted to provide an answer.";
786
- readonly required: false;
787
- readonly usageValue: "A comma separated list of possible answers (optional)";
782
+ readonly allowMultiple: true;
783
+ readonly children: [{
784
+ readonly name: "prompt";
785
+ readonly description: "The text of the question.";
786
+ readonly required: true;
787
+ readonly usageValue: "question text here";
788
+ }, {
789
+ readonly name: "options";
790
+ readonly description: "Ordered list of suggested answers (omit if none).";
791
+ readonly required: false;
792
+ readonly allowMultiple: true;
793
+ readonly usageValue: "suggested answer here";
794
+ }];
788
795
  }];
789
796
  readonly examples: [{
790
- readonly description: "Request to ask a question";
797
+ readonly description: "Single clarifying question (no options)";
791
798
  readonly parameters: [{
792
- readonly name: "question";
793
- readonly value: "What is the name of the project?";
799
+ readonly name: "questions";
800
+ readonly value: {
801
+ readonly prompt: "What is the target deployment environment?";
802
+ };
794
803
  }];
795
804
  }, {
796
- readonly description: "Request to ask a question with options";
805
+ readonly description: "Single question with multiple-choice options";
797
806
  readonly parameters: [{
798
- readonly name: "question";
799
- readonly value: "What framework do you use?";
800
- }, {
801
- readonly name: "options";
802
- readonly value: "React,Angular,Vue,Svelte";
807
+ readonly name: "questions";
808
+ readonly value: {
809
+ readonly prompt: "Which frontend framework are you using?";
810
+ readonly options: ["React", "Angular", "Vue", "Svelte"];
811
+ };
812
+ }];
813
+ }, {
814
+ readonly description: "Two related questions in one call";
815
+ readonly parameters: [{
816
+ readonly name: "questions";
817
+ readonly value: [{
818
+ readonly prompt: "What type of application are you building?";
819
+ }, {
820
+ readonly prompt: "Preferred programming language?";
821
+ readonly options: ["JavaScript", "TypeScript", "Python", "Java"];
822
+ }];
823
+ }];
824
+ }, {
825
+ readonly description: "Binary (yes/no) confirmation";
826
+ readonly parameters: [{
827
+ readonly name: "questions";
828
+ readonly value: {
829
+ readonly prompt: "Is it acceptable to refactor existing tests to improve performance?";
830
+ readonly options: ["Yes", "No"];
831
+ };
803
832
  }];
804
833
  }];
805
834
  readonly permissionLevel: PermissionLevel.None;
806
835
  }, InteractionProvider>;
807
836
  isAvailable: (provider: InteractionProvider) => boolean;
808
837
  name: "ask_followup_question";
809
- description: "Whenever you need extra details or clarification to complete the task, pose a direct question to the user. Use this tool sparingly to avoid excessive back-and-forth. If helpful, offer multiple-choice options or examples to guide the user’s response.";
838
+ description: "Call this when vital details are missing. Pose each follow-up as one direct, unambiguous question. If it speeds the reply, add up to five short, mutually-exclusive answer options. Group any related questions in the same call to avoid a back-and-forth chain.";
810
839
  parameters: [{
811
- readonly name: "question";
812
- readonly description: "The question to ask the user. This should be a clear, specific question that addresses the information you need.";
840
+ readonly name: "questions";
841
+ readonly description: "One or more follow-up questions you need answered before you can continue.";
813
842
  readonly required: true;
814
- readonly usageValue: "Your question here";
815
- }, {
816
- readonly name: "options";
817
- readonly description: "A comma separated list of possible answers to the question. Ordered by preference. If not provided, the user will be prompted to provide an answer.";
818
- readonly required: false;
819
- readonly usageValue: "A comma separated list of possible answers (optional)";
843
+ readonly allowMultiple: true;
844
+ readonly children: [{
845
+ readonly name: "prompt";
846
+ readonly description: "The text of the question.";
847
+ readonly required: true;
848
+ readonly usageValue: "question text here";
849
+ }, {
850
+ readonly name: "options";
851
+ readonly description: "Ordered list of suggested answers (omit if none).";
852
+ readonly required: false;
853
+ readonly allowMultiple: true;
854
+ readonly usageValue: "suggested answer here";
855
+ }];
820
856
  }];
821
857
  examples: [{
822
- readonly description: "Request to ask a question";
858
+ readonly description: "Single clarifying question (no options)";
823
859
  readonly parameters: [{
824
- readonly name: "question";
825
- readonly value: "What is the name of the project?";
860
+ readonly name: "questions";
861
+ readonly value: {
862
+ readonly prompt: "What is the target deployment environment?";
863
+ };
826
864
  }];
827
865
  }, {
828
- readonly description: "Request to ask a question with options";
866
+ readonly description: "Single question with multiple-choice options";
829
867
  readonly parameters: [{
830
- readonly name: "question";
831
- readonly value: "What framework do you use?";
832
- }, {
833
- readonly name: "options";
834
- readonly value: "React,Angular,Vue,Svelte";
868
+ readonly name: "questions";
869
+ readonly value: {
870
+ readonly prompt: "Which frontend framework are you using?";
871
+ readonly options: ["React", "Angular", "Vue", "Svelte"];
872
+ };
873
+ }];
874
+ }, {
875
+ readonly description: "Two related questions in one call";
876
+ readonly parameters: [{
877
+ readonly name: "questions";
878
+ readonly value: [{
879
+ readonly prompt: "What type of application are you building?";
880
+ }, {
881
+ readonly prompt: "Preferred programming language?";
882
+ readonly options: ["JavaScript", "TypeScript", "Python", "Java"];
883
+ }];
884
+ }];
885
+ }, {
886
+ readonly description: "Binary (yes/no) confirmation";
887
+ readonly parameters: [{
888
+ readonly name: "questions";
889
+ readonly value: {
890
+ readonly prompt: "Is it acceptable to refactor existing tests to improve performance?";
891
+ readonly options: ["Yes", "No"];
892
+ };
835
893
  }];
836
894
  }];
837
895
  permissionLevel: PermissionLevel.None;
@@ -1354,23 +1412,23 @@ export { _default_3 as delegate_alias_2 }
1354
1412
  declare const _default_4: {
1355
1413
  handler: ToolHandler<{
1356
1414
  readonly name: "execute_command";
1357
- readonly description: "Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will also be executed in the project root directory regardless of executed commands in previous tool uses.";
1415
+ readonly description: "Run a single CLI command. The command is always executed in the project-root working directory (regardless of earlier commands). Prefer one-off shell commands over wrapper scripts for flexibility. After an `execute_command` call, no other tool calls are allowed in the same assistant response.";
1358
1416
  readonly parameters: [{
1359
1417
  readonly name: "command";
1360
- readonly description: "The CLI command to execute. This should be valid for the current operating system. Ensure the command is properly formatted and does not contain any harmful instructions.";
1418
+ readonly description: "The exact command to run (valid for the current OS). It must be correctly formatted and free of harmful instructions.";
1361
1419
  readonly required: true;
1362
- readonly usageValue: "Your command here";
1420
+ readonly usageValue: "your-command-here";
1363
1421
  }, {
1364
1422
  readonly name: "requires_approval";
1365
- readonly description: "A boolean indicating whether this command requires explicit user approval before execution in case the user has auto-approve mode enabled. Set to 'true' for potentially impactful operations like installing/uninstalling packages, deleting/overwriting files, system configuration changes, network operations, or any commands that could have unintended side effects. Set to 'false' for safe operations like reading files/directories, running development servers, building projects, and other non-destructive operations.";
1423
+ readonly description: "Set to `true` for commands that install/uninstall software, modify or delete files, change system settings, perform network operations, or have other side effects. Use `false` for safe, read-only, or purely local development actions (e.g., listing files, make a build, running tests).";
1366
1424
  readonly required: false;
1367
- readonly usageValue: "true or false";
1425
+ readonly usageValue: "true | false";
1368
1426
  }];
1369
1427
  readonly examples: [{
1370
- readonly description: "Request to execute a command";
1428
+ readonly description: "Make a build";
1371
1429
  readonly parameters: [{
1372
1430
  readonly name: "command";
1373
- readonly value: "npm run dev";
1431
+ readonly value: "npm run build";
1374
1432
  }, {
1375
1433
  readonly name: "requires_approval";
1376
1434
  readonly value: "false";
@@ -1380,23 +1438,23 @@ declare const _default_4: {
1380
1438
  }, CommandProvider>;
1381
1439
  isAvailable: (provider: CommandProvider) => boolean;
1382
1440
  name: "execute_command";
1383
- description: "Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will also be executed in the project root directory regardless of executed commands in previous tool uses.";
1441
+ description: "Run a single CLI command. The command is always executed in the project-root working directory (regardless of earlier commands). Prefer one-off shell commands over wrapper scripts for flexibility. After an `execute_command` call, no other tool calls are allowed in the same assistant response.";
1384
1442
  parameters: [{
1385
1443
  readonly name: "command";
1386
- readonly description: "The CLI command to execute. This should be valid for the current operating system. Ensure the command is properly formatted and does not contain any harmful instructions.";
1444
+ readonly description: "The exact command to run (valid for the current OS). It must be correctly formatted and free of harmful instructions.";
1387
1445
  readonly required: true;
1388
- readonly usageValue: "Your command here";
1446
+ readonly usageValue: "your-command-here";
1389
1447
  }, {
1390
1448
  readonly name: "requires_approval";
1391
- readonly description: "A boolean indicating whether this command requires explicit user approval before execution in case the user has auto-approve mode enabled. Set to 'true' for potentially impactful operations like installing/uninstalling packages, deleting/overwriting files, system configuration changes, network operations, or any commands that could have unintended side effects. Set to 'false' for safe operations like reading files/directories, running development servers, building projects, and other non-destructive operations.";
1449
+ readonly description: "Set to `true` for commands that install/uninstall software, modify or delete files, change system settings, perform network operations, or have other side effects. Use `false` for safe, read-only, or purely local development actions (e.g., listing files, make a build, running tests).";
1392
1450
  readonly required: false;
1393
- readonly usageValue: "true or false";
1451
+ readonly usageValue: "true | false";
1394
1452
  }];
1395
1453
  examples: [{
1396
- readonly description: "Request to execute a command";
1454
+ readonly description: "Make a build";
1397
1455
  readonly parameters: [{
1398
1456
  readonly name: "command";
1399
- readonly value: "npm run dev";
1457
+ readonly value: "npm run build";
1400
1458
  }, {
1401
1459
  readonly name: "requires_approval";
1402
1460
  readonly value: "false";
@@ -1861,6 +1919,11 @@ declare const generateProjectConfig: (agent: MultiAgent, params: unknown) => Pro
1861
1919
  export { generateProjectConfig }
1862
1920
  export { generateProjectConfig as generateProjectConfig_alias_1 }
1863
1921
 
1922
+ declare const getArray: <T extends string>(args: Partial<Record<T, ToolParameterValue>> | ToolParameterValue, name: T, defaultValue?: ToolParameterValue[]) => ToolParameterValue[];
1923
+ export { getArray }
1924
+ export { getArray as getArray_alias_1 }
1925
+ export { getArray as getArray_alias_2 }
1926
+
1864
1927
  /**
1865
1928
  * Get the available tools based on the provider and agent availability
1866
1929
  * @param provider The provider to use.
@@ -1880,7 +1943,7 @@ declare const getAvailableTools: ({ provider, allTools, hasAgent, permissionLeve
1880
1943
  export { getAvailableTools }
1881
1944
  export { getAvailableTools as getAvailableTools_alias_1 }
1882
1945
 
1883
- declare const getBoolean: <T extends string>(args: Partial<Record<T, string>>, name: T, defaultValue?: boolean) => boolean;
1946
+ declare const getBoolean: <T extends string>(args: Partial<Record<T, ToolParameterValue>>, name: T, defaultValue?: boolean) => boolean;
1884
1947
  export { getBoolean }
1885
1948
  export { getBoolean as getBoolean_alias_1 }
1886
1949
  export { getBoolean as getBoolean_alias_2 }
@@ -1890,7 +1953,7 @@ export { GetInput }
1890
1953
  export { GetInput as GetInput_alias_1 }
1891
1954
  export { GetInput as GetInput_alias_2 }
1892
1955
 
1893
- declare const getInt: <T extends string>(args: Partial<Record<T, string>>, name: T, defaultValue?: number) => number;
1956
+ declare const getInt: <T extends string>(args: Partial<Record<T, ToolParameterValue>>, name: T, defaultValue?: number) => number;
1894
1957
  export { getInt }
1895
1958
  export { getInt as getInt_alias_1 }
1896
1959
  export { getInt as getInt_alias_2 }
@@ -1900,12 +1963,12 @@ export { GetOutput }
1900
1963
  export { GetOutput as GetOutput_alias_1 }
1901
1964
  export { GetOutput as GetOutput_alias_2 }
1902
1965
 
1903
- declare const getString: <T extends string>(args: Partial<Partial<Record<T, string>>>, name: T, defaultValue?: string) => string;
1966
+ declare const getString: <T extends string>(args: Partial<Record<T, string>> | ToolParameterValue, name: T, defaultValue?: string) => string;
1904
1967
  export { getString }
1905
1968
  export { getString as getString_alias_1 }
1906
1969
  export { getString as getString_alias_2 }
1907
1970
 
1908
- declare const getStringArray: <T extends string>(args: Partial<Record<T, string>>, name: T, defaultValue?: string[]) => string[];
1971
+ declare const getStringArray: <T extends string>(args: Partial<Record<T, ToolParameterValue>>, name: T, defaultValue?: string[]) => string[];
1909
1972
  export { getStringArray }
1910
1973
  export { getStringArray as getStringArray_alias_1 }
1911
1974
  export { getStringArray as getStringArray_alias_2 }
@@ -2229,6 +2292,34 @@ declare type Output = {
2229
2292
  * // {type: "tool_use", name: "search", params: {query: "cats"}},
2230
2293
  * // {type: "text", content: "Here are the results"}
2231
2294
  * // ]
2295
+ *
2296
+ * // Array mode (multiple occurrences of the same parameter)
2297
+ * parseAssistantMessage(
2298
+ * `<tool_read_file>
2299
+ * <tool_parameter_path>test.ts</tool_parameter_path>
2300
+ * <tool_parameter_path>main.ts</tool_parameter_path>
2301
+ * </tool_read_file>`,
2302
+ * tools,
2303
+ * "tool_"
2304
+ * )
2305
+ * // Returns: [
2306
+ * // {type: "tool_use", name: "read_file", params: {path: ["test.ts", "main.ts"]}}
2307
+ * // ]
2308
+ *
2309
+ * // Nested objects
2310
+ * parseAssistantMessage(
2311
+ * `<tool_example>
2312
+ * <tool_parameter_key>
2313
+ * <tool_parameter_key2>value</tool_parameter_key2>
2314
+ * <tool_parameter_key3>value2</tool_parameter_key3>
2315
+ * </tool_parameter_key>
2316
+ * </tool_example>`,
2317
+ * tools,
2318
+ * "tool_"
2319
+ * )
2320
+ * // Returns: [
2321
+ * // {type: "tool_use", name: "example", params: {key: {key2: "value", key3: "value2"}}}
2322
+ * // ]
2232
2323
  */
2233
2324
  declare function parseAssistantMessage(assistantMessage: string, tools: ToolInfo[], toolNamePrefix: string): AssistantMessageContent[];
2234
2325
  export { parseAssistantMessage }
@@ -2467,13 +2558,13 @@ declare type ToolExample = {
2467
2558
  description: string;
2468
2559
  parameters: {
2469
2560
  name: string;
2470
- value: string;
2561
+ value: ToolParameterValue;
2471
2562
  }[];
2472
2563
  };
2473
2564
  export { ToolExample }
2474
2565
  export { ToolExample as ToolExample_alias_1 }
2475
2566
 
2476
- declare type ToolHandler<T extends ToolInfo, P> = (provider: P, args: Partial<Record<T['parameters'][number]['name'], string>>) => Promise<ToolResponse>;
2567
+ declare type ToolHandler<T extends ToolInfo, P> = (provider: P, args: Partial<Record<T['parameters'][number]['name'], ToolParameterValue>>) => Promise<ToolResponse>;
2477
2568
  export { ToolHandler }
2478
2569
  export { ToolHandler as ToolHandler_alias_1 }
2479
2570
 
@@ -2489,32 +2580,61 @@ export { ToolInfo as ToolInfo_alias_1 }
2489
2580
 
2490
2581
  export declare const toolInfo: {
2491
2582
  readonly name: "ask_followup_question";
2492
- readonly description: "Whenever you need extra details or clarification to complete the task, pose a direct question to the user. Use this tool sparingly to avoid excessive back-and-forth. If helpful, offer multiple-choice options or examples to guide the user’s response.";
2583
+ readonly description: "Call this when vital details are missing. Pose each follow-up as one direct, unambiguous question. If it speeds the reply, add up to five short, mutually-exclusive answer options. Group any related questions in the same call to avoid a back-and-forth chain.";
2493
2584
  readonly parameters: [{
2494
- readonly name: "question";
2495
- readonly description: "The question to ask the user. This should be a clear, specific question that addresses the information you need.";
2585
+ readonly name: "questions";
2586
+ readonly description: "One or more follow-up questions you need answered before you can continue.";
2496
2587
  readonly required: true;
2497
- readonly usageValue: "Your question here";
2498
- }, {
2499
- readonly name: "options";
2500
- readonly description: "A comma separated list of possible answers to the question. Ordered by preference. If not provided, the user will be prompted to provide an answer.";
2501
- readonly required: false;
2502
- readonly usageValue: "A comma separated list of possible answers (optional)";
2588
+ readonly allowMultiple: true;
2589
+ readonly children: [{
2590
+ readonly name: "prompt";
2591
+ readonly description: "The text of the question.";
2592
+ readonly required: true;
2593
+ readonly usageValue: "question text here";
2594
+ }, {
2595
+ readonly name: "options";
2596
+ readonly description: "Ordered list of suggested answers (omit if none).";
2597
+ readonly required: false;
2598
+ readonly allowMultiple: true;
2599
+ readonly usageValue: "suggested answer here";
2600
+ }];
2503
2601
  }];
2504
2602
  readonly examples: [{
2505
- readonly description: "Request to ask a question";
2603
+ readonly description: "Single clarifying question (no options)";
2506
2604
  readonly parameters: [{
2507
- readonly name: "question";
2508
- readonly value: "What is the name of the project?";
2605
+ readonly name: "questions";
2606
+ readonly value: {
2607
+ readonly prompt: "What is the target deployment environment?";
2608
+ };
2509
2609
  }];
2510
2610
  }, {
2511
- readonly description: "Request to ask a question with options";
2611
+ readonly description: "Single question with multiple-choice options";
2512
2612
  readonly parameters: [{
2513
- readonly name: "question";
2514
- readonly value: "What framework do you use?";
2515
- }, {
2516
- readonly name: "options";
2517
- readonly value: "React,Angular,Vue,Svelte";
2613
+ readonly name: "questions";
2614
+ readonly value: {
2615
+ readonly prompt: "Which frontend framework are you using?";
2616
+ readonly options: ["React", "Angular", "Vue", "Svelte"];
2617
+ };
2618
+ }];
2619
+ }, {
2620
+ readonly description: "Two related questions in one call";
2621
+ readonly parameters: [{
2622
+ readonly name: "questions";
2623
+ readonly value: [{
2624
+ readonly prompt: "What type of application are you building?";
2625
+ }, {
2626
+ readonly prompt: "Preferred programming language?";
2627
+ readonly options: ["JavaScript", "TypeScript", "Python", "Java"];
2628
+ }];
2629
+ }];
2630
+ }, {
2631
+ readonly description: "Binary (yes/no) confirmation";
2632
+ readonly parameters: [{
2633
+ readonly name: "questions";
2634
+ readonly value: {
2635
+ readonly prompt: "Is it acceptable to refactor existing tests to improve performance?";
2636
+ readonly options: ["Yes", "No"];
2637
+ };
2518
2638
  }];
2519
2639
  }];
2520
2640
  readonly permissionLevel: PermissionLevel.None;
@@ -2736,23 +2856,23 @@ export declare const toolInfo_alias_2: {
2736
2856
 
2737
2857
  export declare const toolInfo_alias_3: {
2738
2858
  readonly name: "execute_command";
2739
- readonly description: "Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will also be executed in the project root directory regardless of executed commands in previous tool uses.";
2859
+ readonly description: "Run a single CLI command. The command is always executed in the project-root working directory (regardless of earlier commands). Prefer one-off shell commands over wrapper scripts for flexibility. After an `execute_command` call, no other tool calls are allowed in the same assistant response.";
2740
2860
  readonly parameters: [{
2741
2861
  readonly name: "command";
2742
- readonly description: "The CLI command to execute. This should be valid for the current operating system. Ensure the command is properly formatted and does not contain any harmful instructions.";
2862
+ readonly description: "The exact command to run (valid for the current OS). It must be correctly formatted and free of harmful instructions.";
2743
2863
  readonly required: true;
2744
- readonly usageValue: "Your command here";
2864
+ readonly usageValue: "your-command-here";
2745
2865
  }, {
2746
2866
  readonly name: "requires_approval";
2747
- readonly description: "A boolean indicating whether this command requires explicit user approval before execution in case the user has auto-approve mode enabled. Set to 'true' for potentially impactful operations like installing/uninstalling packages, deleting/overwriting files, system configuration changes, network operations, or any commands that could have unintended side effects. Set to 'false' for safe operations like reading files/directories, running development servers, building projects, and other non-destructive operations.";
2867
+ readonly description: "Set to `true` for commands that install/uninstall software, modify or delete files, change system settings, perform network operations, or have other side effects. Use `false` for safe, read-only, or purely local development actions (e.g., listing files, make a build, running tests).";
2748
2868
  readonly required: false;
2749
- readonly usageValue: "true or false";
2869
+ readonly usageValue: "true | false";
2750
2870
  }];
2751
2871
  readonly examples: [{
2752
- readonly description: "Request to execute a command";
2872
+ readonly description: "Make a build";
2753
2873
  readonly parameters: [{
2754
2874
  readonly name: "command";
2755
- readonly value: "npm run dev";
2875
+ readonly value: "npm run build";
2756
2876
  }, {
2757
2877
  readonly name: "requires_approval";
2758
2878
  readonly value: "false";
@@ -2930,11 +3050,19 @@ declare type ToolParameter = {
2930
3050
  name: string;
2931
3051
  description: string;
2932
3052
  required: boolean;
2933
- usageValue: string;
3053
+ usageValue?: string;
3054
+ allowMultiple?: boolean;
3055
+ children?: ToolParameter[];
2934
3056
  };
2935
3057
  export { ToolParameter }
2936
3058
  export { ToolParameter as ToolParameter_alias_1 }
2937
3059
 
3060
+ declare type ToolParameterValue = string | {
3061
+ [key: string]: ToolParameterValue;
3062
+ } | ToolParameterValue[];
3063
+ export { ToolParameterValue }
3064
+ export { ToolParameterValue as ToolParameterValue_alias_1 }
3065
+
2938
3066
  declare type ToolProvider = FilesystemProvider & CommandProvider & InteractionProvider;
2939
3067
  export { ToolProvider }
2940
3068
  export { ToolProvider as ToolProvider_alias_1 }
@@ -3039,7 +3167,7 @@ export { ToolResponseType as ToolResponseType_alias_1 }
3039
3167
  declare interface ToolUse {
3040
3168
  type: 'tool_use';
3041
3169
  name: string;
3042
- params: Record<string, string>;
3170
+ params: Record<string, any>;
3043
3171
  }
3044
3172
  export { ToolUse }
3045
3173
  export { ToolUse as ToolUse_alias_1 }
package/dist/index.d.ts CHANGED
@@ -100,6 +100,7 @@ export { AiToolDefinition } from './_tsup-dts-rollup.js';
100
100
  export { GetInput } from './_tsup-dts-rollup.js';
101
101
  export { GetOutput } from './_tsup-dts-rollup.js';
102
102
  export { ToolParameter } from './_tsup-dts-rollup.js';
103
+ export { ToolParameterValue } from './_tsup-dts-rollup.js';
103
104
  export { ToolExample } from './_tsup-dts-rollup.js';
104
105
  export { PermissionLevel } from './_tsup-dts-rollup.js';
105
106
  export { ToolInfo } from './_tsup-dts-rollup.js';
@@ -123,3 +124,4 @@ export { getString } from './_tsup-dts-rollup.js';
123
124
  export { getStringArray } from './_tsup-dts-rollup.js';
124
125
  export { getBoolean } from './_tsup-dts-rollup.js';
125
126
  export { getInt } from './_tsup-dts-rollup.js';
127
+ export { getArray } from './_tsup-dts-rollup.js';
package/dist/index.js CHANGED
@@ -987,10 +987,16 @@ ${search}`);
987
987
 
988
988
  // src/tools/utils/getArg.ts
989
989
  var getString = (args, name, defaultValue) => {
990
+ if (typeof args !== "object" || Array.isArray(args)) {
991
+ throw new Error(`Invalid argument type: ${name} ${args}`);
992
+ }
990
993
  const ret = args[name] ?? defaultValue;
991
994
  if (ret === void 0) {
992
995
  throw new Error(`Missing required argument: ${name}`);
993
996
  }
997
+ if (typeof ret !== "string") {
998
+ throw new Error(`Invalid argument type: ${name} ${ret}`);
999
+ }
994
1000
  return ret;
995
1001
  };
996
1002
  var getStringArray = (args, name, defaultValue) => {
@@ -1004,6 +1010,9 @@ var getStringArray = (args, name, defaultValue) => {
1004
1010
  if (ret === "") {
1005
1011
  return [];
1006
1012
  }
1013
+ if (typeof ret !== "string") {
1014
+ throw new Error(`Invalid argument type: ${name} ${ret}`);
1015
+ }
1007
1016
  return ret.split(",").map((s) => s.trim());
1008
1017
  };
1009
1018
  var getBoolean = (args, name, defaultValue) => {
@@ -1014,13 +1023,16 @@ var getBoolean = (args, name, defaultValue) => {
1014
1023
  }
1015
1024
  return defaultValue;
1016
1025
  }
1026
+ if (typeof ret !== "string") {
1027
+ throw new Error(`Invalid argument type: ${name} ${ret}`);
1028
+ }
1017
1029
  switch (ret.toLowerCase()) {
1018
1030
  case "true":
1019
1031
  return true;
1020
1032
  case "false":
1021
1033
  return false;
1022
1034
  default:
1023
- throw new Error(`Invalid argument value: ${name}`);
1035
+ throw new Error(`Invalid argument value: ${name} ${ret}`);
1024
1036
  }
1025
1037
  };
1026
1038
  var getInt = (args, name, defaultValue) => {
@@ -1031,51 +1043,105 @@ var getInt = (args, name, defaultValue) => {
1031
1043
  }
1032
1044
  return defaultValue;
1033
1045
  }
1046
+ if (typeof ret !== "string") {
1047
+ throw new Error(`Invalid argument type: ${name} ${ret}`);
1048
+ }
1034
1049
  const parsed = Number.parseInt(ret);
1035
1050
  if (Number.isNaN(parsed)) {
1036
- throw new Error(`Invalid argument value: ${name}`);
1051
+ throw new Error(`Invalid argument value: ${name} ${ret}`);
1037
1052
  }
1038
1053
  return parsed;
1039
1054
  };
1055
+ var getArray = (args, name, defaultValue) => {
1056
+ if (typeof args !== "object" || Array.isArray(args)) {
1057
+ throw new Error(`Invalid argument type: ${name} ${args}`);
1058
+ }
1059
+ const ret = args[name];
1060
+ if (ret === void 0) {
1061
+ if (defaultValue === void 0) {
1062
+ throw new Error(`Missing required argument: ${name}`);
1063
+ }
1064
+ return defaultValue;
1065
+ }
1066
+ if (Array.isArray(ret)) {
1067
+ return ret;
1068
+ }
1069
+ return [ret];
1070
+ };
1040
1071
 
1041
1072
  // src/tools/askFollowupQuestion.ts
1042
1073
  var toolInfo = {
1043
1074
  name: "ask_followup_question",
1044
- description: "Whenever you need extra details or clarification to complete the task, pose a direct question to the user. Use this tool sparingly to avoid excessive back-and-forth. If helpful, offer multiple-choice options or examples to guide the user\u2019s response.",
1075
+ description: "Call this when vital details are missing. Pose each follow-up as one direct, unambiguous question. If it speeds the reply, add up to five short, mutually-exclusive answer options. Group any related questions in the same call to avoid a back-and-forth chain.",
1045
1076
  parameters: [
1046
1077
  {
1047
- name: "question",
1048
- description: "The question to ask the user. This should be a clear, specific question that addresses the information you need.",
1078
+ name: "questions",
1079
+ description: "One or more follow-up questions you need answered before you can continue.",
1049
1080
  required: true,
1050
- usageValue: "Your question here"
1051
- },
1052
- {
1053
- name: "options",
1054
- description: "A comma separated list of possible answers to the question. Ordered by preference. If not provided, the user will be prompted to provide an answer.",
1055
- required: false,
1056
- usageValue: "A comma separated list of possible answers (optional)"
1081
+ allowMultiple: true,
1082
+ children: [
1083
+ {
1084
+ name: "prompt",
1085
+ description: "The text of the question.",
1086
+ required: true,
1087
+ usageValue: "question text here"
1088
+ },
1089
+ {
1090
+ name: "options",
1091
+ description: "Ordered list of suggested answers (omit if none).",
1092
+ required: false,
1093
+ allowMultiple: true,
1094
+ usageValue: "suggested answer here"
1095
+ }
1096
+ ]
1057
1097
  }
1058
1098
  ],
1059
1099
  examples: [
1060
1100
  {
1061
- description: "Request to ask a question",
1101
+ description: "Single clarifying question (no options)",
1062
1102
  parameters: [
1063
1103
  {
1064
- name: "question",
1065
- value: "What is the name of the project?"
1104
+ name: "questions",
1105
+ value: { prompt: "What is the target deployment environment?" }
1066
1106
  }
1067
1107
  ]
1068
1108
  },
1069
1109
  {
1070
- description: "Request to ask a question with options",
1110
+ description: "Single question with multiple-choice options",
1071
1111
  parameters: [
1072
1112
  {
1073
- name: "question",
1074
- value: "What framework do you use?"
1075
- },
1113
+ name: "questions",
1114
+ value: {
1115
+ prompt: "Which frontend framework are you using?",
1116
+ options: ["React", "Angular", "Vue", "Svelte"]
1117
+ }
1118
+ }
1119
+ ]
1120
+ },
1121
+ {
1122
+ description: "Two related questions in one call",
1123
+ parameters: [
1076
1124
  {
1077
- name: "options",
1078
- value: "React,Angular,Vue,Svelte"
1125
+ name: "questions",
1126
+ value: [
1127
+ { prompt: "What type of application are you building?" },
1128
+ {
1129
+ prompt: "Preferred programming language?",
1130
+ options: ["JavaScript", "TypeScript", "Python", "Java"]
1131
+ }
1132
+ ]
1133
+ }
1134
+ ]
1135
+ },
1136
+ {
1137
+ description: "Binary (yes/no) confirmation",
1138
+ parameters: [
1139
+ {
1140
+ name: "questions",
1141
+ value: {
1142
+ prompt: "Is it acceptable to refactor existing tests to improve performance?",
1143
+ options: ["Yes", "No"]
1144
+ }
1079
1145
  }
1080
1146
  ]
1081
1147
  }
@@ -1089,13 +1155,25 @@ var handler = async (provider, args) => {
1089
1155
  message: "Not possible to ask followup question. Abort."
1090
1156
  };
1091
1157
  }
1092
- const question = getString(args, "question");
1093
- const options = getStringArray(args, "options", []);
1094
- const answer = await provider.askFollowupQuestion(question, options);
1158
+ const questions = getArray(args, "questions");
1159
+ if (!questions || questions.length === 0) {
1160
+ return {
1161
+ type: "Error" /* Error */,
1162
+ message: "No questions provided"
1163
+ };
1164
+ }
1165
+ const answers = [];
1166
+ for (const question of questions) {
1167
+ const prompt6 = getString(question, "prompt");
1168
+ const options = getArray(question, "options", []);
1169
+ const answer = await provider.askFollowupQuestion(prompt6, options);
1170
+ answers.push(`<ask_followup_question_answer question="${prompt6}">
1171
+ ${answer}
1172
+ </ask_followup_question_answer>`);
1173
+ }
1095
1174
  return {
1096
1175
  type: "Reply" /* Reply */,
1097
- message: `<ask_followup_question_question>${question}</ask_followup_question_question>
1098
- <ask_followup_question_answer>${answer}</ask_followup_question_answer>`
1176
+ message: answers.join("\n")
1099
1177
  };
1100
1178
  };
1101
1179
  var isAvailable = (provider) => {
@@ -1236,33 +1314,27 @@ var delegate_default = {
1236
1314
  // src/tools/executeCommand.ts
1237
1315
  var toolInfo4 = {
1238
1316
  name: "execute_command",
1239
- description: `Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will also be executed in the project root directory regardless of executed commands in previous tool uses.`,
1317
+ description: "Run a single CLI command. The command is always executed in the project-root working directory (regardless of earlier commands). Prefer one-off shell commands over wrapper scripts for flexibility. After an `execute_command` call, no other tool calls are allowed in the same assistant response.",
1240
1318
  parameters: [
1241
1319
  {
1242
1320
  name: "command",
1243
- description: "The CLI command to execute. This should be valid for the current operating system. Ensure the command is properly formatted and does not contain any harmful instructions.",
1321
+ description: "The exact command to run (valid for the current OS). It must be correctly formatted and free of harmful instructions.",
1244
1322
  required: true,
1245
- usageValue: "Your command here"
1323
+ usageValue: "your-command-here"
1246
1324
  },
1247
1325
  {
1248
1326
  name: "requires_approval",
1249
- description: `A boolean indicating whether this command requires explicit user approval before execution in case the user has auto-approve mode enabled. Set to 'true' for potentially impactful operations like installing/uninstalling packages, deleting/overwriting files, system configuration changes, network operations, or any commands that could have unintended side effects. Set to 'false' for safe operations like reading files/directories, running development servers, building projects, and other non-destructive operations.`,
1327
+ description: "Set to `true` for commands that install/uninstall software, modify or delete files, change system settings, perform network operations, or have other side effects. Use `false` for safe, read-only, or purely local development actions (e.g., listing files, make a build, running tests).",
1250
1328
  required: false,
1251
- usageValue: "true or false"
1329
+ usageValue: "true | false"
1252
1330
  }
1253
1331
  ],
1254
1332
  examples: [
1255
1333
  {
1256
- description: "Request to execute a command",
1334
+ description: "Make a build",
1257
1335
  parameters: [
1258
- {
1259
- name: "command",
1260
- value: "npm run dev"
1261
- },
1262
- {
1263
- name: "requires_approval",
1264
- value: "false"
1265
- }
1336
+ { name: "command", value: "npm run build" },
1337
+ { name: "requires_approval", value: "false" }
1266
1338
  ]
1267
1339
  }
1268
1340
  ],
@@ -2230,6 +2302,22 @@ var getAvailableTools = ({
2230
2302
  };
2231
2303
 
2232
2304
  // src/Agent/parseAssistantMessage.ts
2305
+ function parseNestedParameters(content, parameterPrefix) {
2306
+ const result = {};
2307
+ const nestedParamRegex = new RegExp(`<${parameterPrefix}([^>]+)>([\\s\\S]*?)<\\/${parameterPrefix}\\1>`, "gs");
2308
+ while (true) {
2309
+ const match = nestedParamRegex.exec(content);
2310
+ if (match === null) break;
2311
+ const paramName = match[1];
2312
+ const paramContent = match[2].trim();
2313
+ if (paramContent.includes(`<${parameterPrefix}`)) {
2314
+ result[paramName] = parseNestedParameters(paramContent, parameterPrefix);
2315
+ } else {
2316
+ result[paramName] = paramContent;
2317
+ }
2318
+ }
2319
+ return result;
2320
+ }
2233
2321
  function parseAssistantMessage(assistantMessage, tools, toolNamePrefix) {
2234
2322
  const parameterPrefix = `${toolNamePrefix}parameter_`;
2235
2323
  const results = [];
@@ -2257,10 +2345,24 @@ function parseAssistantMessage(assistantMessage, tools, toolNamePrefix) {
2257
2345
  for (const param of tool.parameters) {
2258
2346
  const paramName = `${parameterPrefix}${param.name}`;
2259
2347
  const escapedParamName = paramName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2260
- const paramPattern = `<${escapedParamName}>([\\s\\S]*?)<\\/${escapedParamName}>`;
2261
- const paramMatch = fullTagContent.match(new RegExp(paramPattern, "s"));
2262
- if (paramMatch) {
2263
- params[param.name] = paramMatch[1].trim();
2348
+ const paramRegex = new RegExp(`<${escapedParamName}>([\\s\\S]*?)<\\/${escapedParamName}>`, "gs");
2349
+ const paramMatches = [];
2350
+ while (true) {
2351
+ const paramMatch = paramRegex.exec(fullTagContent);
2352
+ if (paramMatch === null) break;
2353
+ paramMatches.push(paramMatch[1].trim());
2354
+ }
2355
+ if (paramMatches.length > 0) {
2356
+ if (paramMatches.length === 1) {
2357
+ const paramContent = paramMatches[0];
2358
+ if (paramContent.includes(`<${parameterPrefix}`)) {
2359
+ params[param.name] = parseNestedParameters(paramContent, parameterPrefix);
2360
+ } else {
2361
+ params[param.name] = paramContent;
2362
+ }
2363
+ } else {
2364
+ params[param.name] = paramMatches;
2365
+ }
2264
2366
  }
2265
2367
  }
2266
2368
  results.push({
@@ -2292,6 +2394,18 @@ function parseAssistantMessage(assistantMessage, tools, toolNamePrefix) {
2292
2394
  }
2293
2395
 
2294
2396
  // src/Agent/prompts.ts
2397
+ var renderParameterValue = (key, value, parameterPrefix) => {
2398
+ if (typeof value === "string") {
2399
+ return `<${parameterPrefix}${key}>${value}</${parameterPrefix}${key}>`;
2400
+ }
2401
+ if (Array.isArray(value)) {
2402
+ return value.map((v) => renderParameterValue(key, v, parameterPrefix)).join("\n");
2403
+ }
2404
+ const inner = Object.entries(value).map(([key2, v]) => renderParameterValue(key2, v, parameterPrefix)).join("\n");
2405
+ return `<${parameterPrefix}${key}>
2406
+ ${inner}
2407
+ </${parameterPrefix}${key}>`;
2408
+ };
2295
2409
  var toolInfoPrompt = (tool, toolNamePrefix, parameterPrefix) => `
2296
2410
  ## ${toolNamePrefix}${tool.name}
2297
2411
 
@@ -2304,11 +2418,11 @@ Usage:
2304
2418
  <${toolNamePrefix}${tool.name}>
2305
2419
  ${tool.parameters.map((param) => `<${parameterPrefix}${param.name}>${param.usageValue}</${parameterPrefix}${param.name}>`).join("\n")}
2306
2420
  </${toolNamePrefix}${tool.name}>`;
2307
- var toolInfoExamplesPrompt = (idx, tool, example, toolNamePrefix, parameterPrefix) => `
2308
- ## Example ${idx + 1}: ${example.description}
2421
+ var toolInfoExamplesPrompt = (tool, example, toolNamePrefix, parameterPrefix) => `
2422
+ ## Example: ${example.description}
2309
2423
 
2310
2424
  <${toolNamePrefix}${tool.name}>
2311
- ${example.parameters.map((param) => `<${parameterPrefix}${param.name}>${param.value}</${parameterPrefix}${param.name}>`).join("\n")}
2425
+ ${example.parameters.map((param) => `${renderParameterValue(param.name, param.value, parameterPrefix)}`).join("\n")}
2312
2426
  </${toolNamePrefix}${tool.name}>
2313
2427
  `;
2314
2428
  var toolUsePrompt = (tools, toolNamePrefix) => {
@@ -2316,7 +2430,6 @@ var toolUsePrompt = (tools, toolNamePrefix) => {
2316
2430
  return "";
2317
2431
  }
2318
2432
  const parameterPrefix = `${toolNamePrefix}parameter_`;
2319
- let exampleIndex = 0;
2320
2433
  return `
2321
2434
  ====
2322
2435
 
@@ -2334,11 +2447,39 @@ Tool use is formatted using XML-style tags. The tool name is enclosed in opening
2334
2447
  ...
2335
2448
  </${toolNamePrefix}tool_name>
2336
2449
 
2337
- For example:
2450
+ ## Array Parameters
2451
+
2452
+ To create an array of values for a parameter, repeat the parameter tag multiple times:
2453
+
2454
+ <${toolNamePrefix}process_file>
2455
+ <${parameterPrefix}path>test.ts</${parameterPrefix}path>
2456
+ <${parameterPrefix}path>main.ts</${parameterPrefix}path>
2457
+ </${toolNamePrefix}process_file>
2458
+
2459
+ ## Nested Object Parameters
2338
2460
 
2339
- <${toolNamePrefix}read_file>
2340
- <${parameterPrefix}path>src/main.js</${parameterPrefix}path>
2341
- </${toolNamePrefix}read_file>
2461
+ To create nested objects, nest parameter tags within other parameter tags:
2462
+
2463
+ <${toolNamePrefix}example_tool>
2464
+ <${parameterPrefix}key>
2465
+ <${parameterPrefix}key2>value</${parameterPrefix}key2>
2466
+ <${parameterPrefix}key3>value2</${parameterPrefix}key3>
2467
+ </${parameterPrefix}key>
2468
+ </${toolNamePrefix}example_tool>
2469
+
2470
+ You can also combine array parameters with nested objects:
2471
+
2472
+ <${toolNamePrefix}example_tool>
2473
+ <${parameterPrefix}key>
2474
+ <${parameterPrefix}key2>value</${parameterPrefix}key2>
2475
+ <${parameterPrefix}key3>value2</${parameterPrefix}key3>
2476
+ </${parameterPrefix}key>
2477
+ <${parameterPrefix}key>
2478
+ <${parameterPrefix}key2>value3</${parameterPrefix}key2>
2479
+ <${parameterPrefix}key3>value4</${parameterPrefix}key3>
2480
+ <${parameterPrefix}key3>value5</${parameterPrefix}key3>
2481
+ </${parameterPrefix}key>
2482
+ </${toolNamePrefix}example_tool>
2342
2483
 
2343
2484
  Always adhere to this format for the tool use to ensure proper parsing and execution.
2344
2485
 
@@ -2351,7 +2492,7 @@ ${tools.map((tool) => toolInfoPrompt(tool, toolNamePrefix, parameterPrefix)).joi
2351
2492
  ${tools.map((tool) => {
2352
2493
  let promp = "";
2353
2494
  for (const example of tool.examples ?? []) {
2354
- promp += toolInfoExamplesPrompt(exampleIndex++, tool, example, toolNamePrefix, parameterPrefix);
2495
+ promp += toolInfoExamplesPrompt(tool, example, toolNamePrefix, parameterPrefix);
2355
2496
  }
2356
2497
  return promp;
2357
2498
  }).join("")}
@@ -3104,7 +3245,7 @@ You have access to two tools for working with files: **${toolNamePrefix}write_to
3104
3245
 
3105
3246
  ## Important Considerations
3106
3247
 
3107
- - Using ${toolNamePrefix}write_to_file requires providing the file\u2019s complete final content.
3248
+ - Using ${toolNamePrefix}write_to_file requires providing the file's complete final content.
3108
3249
  - If you only need to make small changes to an existing file, consider using ${toolNamePrefix}replace_in_file instead to avoid unnecessarily rewriting the entire file.
3109
3250
  - While ${toolNamePrefix}write_to_file should not be your default choice, don't hesitate to use it when the situation truly calls for it.
3110
3251
 
@@ -3117,12 +3258,12 @@ You have access to two tools for working with files: **${toolNamePrefix}write_to
3117
3258
  ## When to Use
3118
3259
 
3119
3260
  - Small, localized changes like updating a few lines, function implementations, changing variable names, modifying a section of text, etc.
3120
- - Targeted improvements where only specific portions of the file\u2019s content needs to be altered.
3261
+ - Targeted improvements where only specific portions of the file's content needs to be altered.
3121
3262
  - Especially useful for long files where much of the file will remain unchanged.
3122
3263
 
3123
3264
  ## Advantages
3124
3265
 
3125
- - More efficient for minor edits, since you don\u2019t need to supply the entire file content.
3266
+ - More efficient for minor edits, since you don't need to supply the entire file content.
3126
3267
  - Reduces the chance of errors that can occur when overwriting large files.
3127
3268
 
3128
3269
  # Choosing the Appropriate Tool
@@ -3148,41 +3289,39 @@ var rules = (toolNamePrefix) => `
3148
3289
 
3149
3290
  RULES
3150
3291
 
3151
- - You may use \`cd\` to enter any child directory within the current working directory. For example, \`cd myChildDir\`. But you may never move to a parent directory or any directory outside your current path. For example, do not use \`cd ..\`, \`cd /\`, or any absolute path.
3152
- - Always work with relative path names, and never use absolute paths.
3153
- - When generating code or test or any file that support comments, add a comment on top of the file with a description of the file's purpose and a note that this file is generated by "polka.codes".
3154
- - When generate text file such as README.md, add a footer indicating this file is generated by "polka.codes".
3155
- - Before using the ${toolNamePrefix}execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory, and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command). For example, if you needed to run \`npm install\` in a project that's not in the current working directory, you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`. However, you can only cd into child directory, but never parent directory or root directory or home directory.
3156
- - When using the ${toolNamePrefix}search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the ${toolNamePrefix}search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use ${toolNamePrefix}read_file to examine the full context of interesting matches before using ${toolNamePrefix}replace_in_file to make informed changes.
3157
- - When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when creating files, as the ${toolNamePrefix}write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
3158
- - Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
3159
- - When making changes to code, always consider the context in which the code is being used. Ensure that your changes are compatible with the existing codebase and that they follow the project's coding standards and best practices.
3160
- - **Adhere to any established coding style, linting rules, or naming conventions if they are known or can be inferred from the existing codebase, to maintain consistency.**
3161
- - When you want to modify a file, use the ${toolNamePrefix}replace_in_file or ${toolNamePrefix}write_to_file tool directly with the desired changes. You do not need to display the changes before using the tool.
3162
- - **Do not guess or hallucinate file content that has not been explicitly provided or read. Always read an existing file with \`${toolNamePrefix}read_file\` (or rely on content the user directly provided) before modifying it, unless you are creating a brand-new file.**
3163
- - Do not ask for more information than necessary. Use the tools provided to accomplish the user's request efficiently and effectively. When you've completed your task, you must use the ${toolNamePrefix}attempt_completion tool to present the result to the user.
3164
- - The user may provide a file's contents directly in their message, in which case you shouldn't use the ${toolNamePrefix}read_file tool to get the file contents again since you already have it.
3165
- - Your goal is to try to accomplish the user's task, NOT engage in a back and forth conversation.
3166
- - NEVER end ${toolNamePrefix}attempt_completion result with a question or request to engage in further conversation! Formulate the end of your result in a way that is final and does not require further input from the user.
3167
- - You are STRICTLY FORBIDDEN from starting your messages with "Great", "Certainly", "Okay", "Sure". You should NOT be conversational in your responses, but rather direct and to the point. For example you should NOT say "Great, I've updated the CSS" but instead something like "I've updated the CSS". It is important you be clear and technical in your messages.
3168
- - When presented with images, utilize your vision capabilities to thoroughly examine them and extract meaningful information. Incorporate these insights into your thought process as you accomplish the user's task.
3169
- - When using the ${toolNamePrefix}replace_in_file tool, you must include complete lines in your SEARCH blocks, not partial lines. The system requires exact line matches and cannot match partial lines. For example, if you want to match a line containing "const x = 5;", your SEARCH block must include the entire line, not just "x = 5" or other fragments.
3170
- - When using the ${toolNamePrefix}replace_in_file tool, if you use multiple SEARCH/REPLACE blocks, list them in the order they appear in the file. For example if you need to make changes to both line 10 and line 50, first include the SEARCH/REPLACE block for line 10, followed by the SEARCH/REPLACE block for line 50.
3171
- - It is critical you wait for the user's response after each tool use, in order to confirm the success of the tool use. For example, if asked to make a todo app, you would create a file, wait for the user's response it was created successfully, then create another file if needed, wait for the user's response it was created successfully, etc.
3172
- - Keep the inline docs up to date if needed.
3292
+ - Work only with relative paths; you may \`cd\` into child directories but never use \`cd ..\`, root, or absolute paths.
3293
+ - When generating code, tests, or other comment-capable files, prepend a comment describing the file's purpose plus \u201Cgenerated by polka.codes\u201D.
3294
+ For text files (e.g. README.md), append a footer with the same notice.
3295
+ - Never describe what changed inside code comments; comments must focus on purpose or usage only.
3296
+ - Before using ${toolNamePrefix}execute_command, consider SYSTEM INFORMATION to ensure commands suit the user's OS. If a command must run in a subdirectory, prepend a single \`cd childDir &&\` segment.
3297
+ - Use ${toolNamePrefix}search_files for broad analysis, then ${toolNamePrefix}read_file to inspect context, and finally ${toolNamePrefix}replace_in_file or ${toolNamePrefix}write_to_file to modify.
3298
+ - Prefer ${toolNamePrefix}replace_in_file for focused edits; choose ${toolNamePrefix}write_to_file for new files or complete rewrites.
3299
+ - When creating a new file, look for existing files with similar content or patterns; if found, read them and use their structure or conventions as a reference.
3300
+ - SEARCH blocks in ${toolNamePrefix}replace_in_file must match whole lines. If multiple blocks are needed, list them in file order.
3301
+ - Do not guess unseen content. Read existing files first unless creating new ones.
3302
+ - Follow existing style, lint, and naming conventions. Ensure all changes compile and pass tests where applicable.
3303
+ - ALWAYS wait for the user's confirmation after each tool call before starting the next step.
3304
+ - The agent must never invoke more than 5 tools in a single response.
3305
+ - Do not end ${toolNamePrefix}attempt_completion output with questions or conversational prompts.
3306
+ - Avoid filler words like \u201CGreat\u201D, \u201CCertainly\u201D, \u201COkay\u201D, \u201CSure\u201D at the start of responses; be direct and technical.
3307
+ - Keep inline documentation current as you edit.
3173
3308
  `;
3174
3309
  var objectives = (toolNamePrefix) => `
3175
3310
  ====
3176
3311
 
3177
3312
  OBJECTIVE
3178
3313
 
3179
- You accomplish a given task iteratively, breaking it down into clear steps and working through them methodically.
3314
+ You solve the user's task by working in small, verifiable steps.
3180
3315
 
3181
- 1. Analyze the user's task and set clear, achievable goals to accomplish it. Prioritize these goals in a logical order.
3182
- 2. Work through these goals sequentially, utilizing available tools one at a time as necessary. Each goal should correspond to a distinct step in your problem-solving process. You will be informed on the work completed and what's remaining as you go.
3183
- 3. Remember, you have extensive capabilities with access to a wide range of tools that can be used in powerful and clever ways as necessary to accomplish each goal. Before calling a tool, do some analysis within <thinking></thinking> tags. First, analyze the file structure provided in environment_details to gain context and insights for proceeding effectively. Then, think about which of the provided tools is the most relevant tool to accomplish the user's task. Next, go through each of the required parameters of the relevant tool and determine if the user has directly provided or given enough information to infer a value. When deciding if the parameter can be inferred, carefully consider all the context to see if it supports a specific value. If all of the required parameters are present or can be reasonably inferred, close the thinking tag and proceed with the tool use.
3184
- 4. Once you've completed the user's task, you must use the ${toolNamePrefix}attempt_completion tool to present the result of the task to the user.
3185
- 5. The user may provide feedback, which you can use to make improvements and try again. But DO NOT continue in pointless back and forth conversations, i.e. don't end your responses with questions or offers for further assistance.`;
3316
+ 1. **Plan** - Parse the task, list clear goals, and order them logically.
3317
+ 2. **Think** - Wrap private reasoning in <thinking></thinking>.
3318
+ \u2022 Review project context.
3319
+ \u2022 Select the single best tool for the next goal.
3320
+ \u2022 Ensure every required parameter is available or can be inferred.
3321
+ 3. **Act** - Invoke one tool per step. Wait for the system's response (and user confirmation where required) before continuing.
3322
+ 4. **Iterate** - Repeat Plan \u2192 Think \u2192 Act until all goals are complete.
3323
+ 5. **Complete** - Use ${toolNamePrefix}attempt_completion to deliver the final result. Do not invite further discussion unless the user explicitly requests changes.
3324
+ `;
3186
3325
  var fullSystemPrompt4 = (info, tools, toolNamePrefix, instructions, scripts) => `
3187
3326
  ${basePrompt2}
3188
3327
  ${toolUsePrompt(tools, toolNamePrefix)}
@@ -3997,6 +4136,7 @@ export {
3997
4136
  generateGitCommitMessage,
3998
4137
  generateGithubPullRequestDetails,
3999
4138
  generateProjectConfig,
4139
+ getArray,
4000
4140
  getAvailableTools,
4001
4141
  getBoolean,
4002
4142
  getInt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/core",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",