@polka-codes/core 0.8.4 → 0.8.6
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 +37 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1010,6 +1010,14 @@ var getStringArray = (args, name, defaultValue) => {
|
|
|
1010
1010
|
if (ret === "") {
|
|
1011
1011
|
return [];
|
|
1012
1012
|
}
|
|
1013
|
+
if (Array.isArray(ret)) {
|
|
1014
|
+
for (const item of ret) {
|
|
1015
|
+
if (typeof item !== "string") {
|
|
1016
|
+
throw new Error(`Invalid argument type: ${name} ${item}`);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
return ret;
|
|
1020
|
+
}
|
|
1013
1021
|
if (typeof ret !== "string") {
|
|
1014
1022
|
throw new Error(`Invalid argument type: ${name} ${ret}`);
|
|
1015
1023
|
}
|
|
@@ -3245,7 +3253,7 @@ You have access to two tools for working with files: **${toolNamePrefix}write_to
|
|
|
3245
3253
|
|
|
3246
3254
|
## Important Considerations
|
|
3247
3255
|
|
|
3248
|
-
- Using ${toolNamePrefix}write_to_file requires providing the file
|
|
3256
|
+
- Using ${toolNamePrefix}write_to_file requires providing the file's complete final content.
|
|
3249
3257
|
- 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.
|
|
3250
3258
|
- While ${toolNamePrefix}write_to_file should not be your default choice, don't hesitate to use it when the situation truly calls for it.
|
|
3251
3259
|
|
|
@@ -3258,12 +3266,12 @@ You have access to two tools for working with files: **${toolNamePrefix}write_to
|
|
|
3258
3266
|
## When to Use
|
|
3259
3267
|
|
|
3260
3268
|
- Small, localized changes like updating a few lines, function implementations, changing variable names, modifying a section of text, etc.
|
|
3261
|
-
- Targeted improvements where only specific portions of the file
|
|
3269
|
+
- Targeted improvements where only specific portions of the file's content needs to be altered.
|
|
3262
3270
|
- Especially useful for long files where much of the file will remain unchanged.
|
|
3263
3271
|
|
|
3264
3272
|
## Advantages
|
|
3265
3273
|
|
|
3266
|
-
- More efficient for minor edits, since you don
|
|
3274
|
+
- More efficient for minor edits, since you don't need to supply the entire file content.
|
|
3267
3275
|
- Reduces the chance of errors that can occur when overwriting large files.
|
|
3268
3276
|
|
|
3269
3277
|
# Choosing the Appropriate Tool
|
|
@@ -3289,41 +3297,39 @@ var rules = (toolNamePrefix) => `
|
|
|
3289
3297
|
|
|
3290
3298
|
RULES
|
|
3291
3299
|
|
|
3292
|
-
-
|
|
3293
|
-
-
|
|
3294
|
-
|
|
3295
|
-
-
|
|
3296
|
-
- Before using
|
|
3297
|
-
-
|
|
3298
|
-
-
|
|
3299
|
-
-
|
|
3300
|
-
-
|
|
3301
|
-
-
|
|
3302
|
-
-
|
|
3303
|
-
-
|
|
3304
|
-
-
|
|
3305
|
-
-
|
|
3306
|
-
-
|
|
3307
|
-
-
|
|
3308
|
-
- 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.
|
|
3309
|
-
- 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.
|
|
3310
|
-
- 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.
|
|
3311
|
-
- 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.
|
|
3312
|
-
- 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.
|
|
3313
|
-
- Keep the inline docs up to date if needed.
|
|
3300
|
+
- Work only with relative paths; you may \`cd\` into child directories but never use \`cd ..\`, root, or absolute paths.
|
|
3301
|
+
- When generating code, tests, or other comment-capable files, prepend a comment describing the file's purpose plus \u201Cgenerated by polka.codes\u201D.
|
|
3302
|
+
For text files (e.g. README.md), append a footer with the same notice.
|
|
3303
|
+
- Never describe what changed inside code comments; comments must focus on purpose or usage only.
|
|
3304
|
+
- 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.
|
|
3305
|
+
- 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.
|
|
3306
|
+
- Prefer ${toolNamePrefix}replace_in_file for focused edits; choose ${toolNamePrefix}write_to_file for new files or complete rewrites.
|
|
3307
|
+
- 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.
|
|
3308
|
+
- SEARCH blocks in ${toolNamePrefix}replace_in_file must match whole lines. If multiple blocks are needed, list them in file order.
|
|
3309
|
+
- Do not guess unseen content. Read existing files first unless creating new ones.
|
|
3310
|
+
- Follow existing style, lint, and naming conventions. Ensure all changes compile and pass tests where applicable.
|
|
3311
|
+
- ALWAYS wait for the user's confirmation after each tool call before starting the next step.
|
|
3312
|
+
- The agent must never invoke more than 5 tools in a single response.
|
|
3313
|
+
- Do not end ${toolNamePrefix}attempt_completion output with questions or conversational prompts.
|
|
3314
|
+
- Avoid filler words like \u201CGreat\u201D, \u201CCertainly\u201D, \u201COkay\u201D, \u201CSure\u201D at the start of responses; be direct and technical.
|
|
3315
|
+
- Keep inline documentation current as you edit.
|
|
3314
3316
|
`;
|
|
3315
3317
|
var objectives = (toolNamePrefix) => `
|
|
3316
3318
|
====
|
|
3317
3319
|
|
|
3318
3320
|
OBJECTIVE
|
|
3319
3321
|
|
|
3320
|
-
You
|
|
3322
|
+
You solve the user's task by working in small, verifiable steps.
|
|
3321
3323
|
|
|
3322
|
-
1.
|
|
3323
|
-
2.
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3324
|
+
1. **Plan** - Parse the task, list clear goals, and order them logically.
|
|
3325
|
+
2. **Think** - Wrap private reasoning in <thinking></thinking>.
|
|
3326
|
+
\u2022 Review project context.
|
|
3327
|
+
\u2022 Select the single best tool for the next goal.
|
|
3328
|
+
\u2022 Ensure every required parameter is available or can be inferred.
|
|
3329
|
+
3. **Act** - Invoke one tool per step. Wait for the system's response (and user confirmation where required) before continuing.
|
|
3330
|
+
4. **Iterate** - Repeat Plan \u2192 Think \u2192 Act until all goals are complete.
|
|
3331
|
+
5. **Complete** - Use ${toolNamePrefix}attempt_completion to deliver the final result. Do not invite further discussion unless the user explicitly requests changes.
|
|
3332
|
+
`;
|
|
3327
3333
|
var fullSystemPrompt4 = (info, tools, toolNamePrefix, instructions, scripts) => `
|
|
3328
3334
|
${basePrompt2}
|
|
3329
3335
|
${toolUsePrompt(tools, toolNamePrefix)}
|