@polka-codes/cli 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.
- package/dist/index.js +229 -85
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31550,7 +31550,7 @@ var {
|
|
|
31550
31550
|
Help
|
|
31551
31551
|
} = import__.default;
|
|
31552
31552
|
// package.json
|
|
31553
|
-
var version = "0.8.
|
|
31553
|
+
var version = "0.8.5";
|
|
31554
31554
|
|
|
31555
31555
|
// ../core/src/AiService/AiServiceBase.ts
|
|
31556
31556
|
class AiServiceBase {
|
|
@@ -40930,10 +40930,16 @@ ${search}`);
|
|
|
40930
40930
|
};
|
|
40931
40931
|
// ../core/src/tools/utils/getArg.ts
|
|
40932
40932
|
var getString = (args2, name2, defaultValue) => {
|
|
40933
|
+
if (typeof args2 !== "object" || Array.isArray(args2)) {
|
|
40934
|
+
throw new Error(`Invalid argument type: ${name2} ${args2}`);
|
|
40935
|
+
}
|
|
40933
40936
|
const ret = args2[name2] ?? defaultValue;
|
|
40934
40937
|
if (ret === undefined) {
|
|
40935
40938
|
throw new Error(`Missing required argument: ${name2}`);
|
|
40936
40939
|
}
|
|
40940
|
+
if (typeof ret !== "string") {
|
|
40941
|
+
throw new Error(`Invalid argument type: ${name2} ${ret}`);
|
|
40942
|
+
}
|
|
40937
40943
|
return ret;
|
|
40938
40944
|
};
|
|
40939
40945
|
var getStringArray = (args2, name2, defaultValue) => {
|
|
@@ -40947,6 +40953,9 @@ var getStringArray = (args2, name2, defaultValue) => {
|
|
|
40947
40953
|
if (ret === "") {
|
|
40948
40954
|
return [];
|
|
40949
40955
|
}
|
|
40956
|
+
if (typeof ret !== "string") {
|
|
40957
|
+
throw new Error(`Invalid argument type: ${name2} ${ret}`);
|
|
40958
|
+
}
|
|
40950
40959
|
return ret.split(",").map((s2) => s2.trim());
|
|
40951
40960
|
};
|
|
40952
40961
|
var getBoolean = (args2, name2, defaultValue) => {
|
|
@@ -40957,13 +40966,16 @@ var getBoolean = (args2, name2, defaultValue) => {
|
|
|
40957
40966
|
}
|
|
40958
40967
|
return defaultValue;
|
|
40959
40968
|
}
|
|
40969
|
+
if (typeof ret !== "string") {
|
|
40970
|
+
throw new Error(`Invalid argument type: ${name2} ${ret}`);
|
|
40971
|
+
}
|
|
40960
40972
|
switch (ret.toLowerCase()) {
|
|
40961
40973
|
case "true":
|
|
40962
40974
|
return true;
|
|
40963
40975
|
case "false":
|
|
40964
40976
|
return false;
|
|
40965
40977
|
default:
|
|
40966
|
-
throw new Error(`Invalid argument value: ${name2}`);
|
|
40978
|
+
throw new Error(`Invalid argument value: ${name2} ${ret}`);
|
|
40967
40979
|
}
|
|
40968
40980
|
};
|
|
40969
40981
|
var getInt = (args2, name2, defaultValue) => {
|
|
@@ -40974,50 +40986,104 @@ var getInt = (args2, name2, defaultValue) => {
|
|
|
40974
40986
|
}
|
|
40975
40987
|
return defaultValue;
|
|
40976
40988
|
}
|
|
40989
|
+
if (typeof ret !== "string") {
|
|
40990
|
+
throw new Error(`Invalid argument type: ${name2} ${ret}`);
|
|
40991
|
+
}
|
|
40977
40992
|
const parsed = Number.parseInt(ret);
|
|
40978
40993
|
if (Number.isNaN(parsed)) {
|
|
40979
|
-
throw new Error(`Invalid argument value: ${name2}`);
|
|
40994
|
+
throw new Error(`Invalid argument value: ${name2} ${ret}`);
|
|
40980
40995
|
}
|
|
40981
40996
|
return parsed;
|
|
40982
40997
|
};
|
|
40998
|
+
var getArray = (args2, name2, defaultValue) => {
|
|
40999
|
+
if (typeof args2 !== "object" || Array.isArray(args2)) {
|
|
41000
|
+
throw new Error(`Invalid argument type: ${name2} ${args2}`);
|
|
41001
|
+
}
|
|
41002
|
+
const ret = args2[name2];
|
|
41003
|
+
if (ret === undefined) {
|
|
41004
|
+
if (defaultValue === undefined) {
|
|
41005
|
+
throw new Error(`Missing required argument: ${name2}`);
|
|
41006
|
+
}
|
|
41007
|
+
return defaultValue;
|
|
41008
|
+
}
|
|
41009
|
+
if (Array.isArray(ret)) {
|
|
41010
|
+
return ret;
|
|
41011
|
+
}
|
|
41012
|
+
return [ret];
|
|
41013
|
+
};
|
|
40983
41014
|
// ../core/src/tools/askFollowupQuestion.ts
|
|
40984
41015
|
var toolInfo = {
|
|
40985
41016
|
name: "ask_followup_question",
|
|
40986
|
-
description: "
|
|
41017
|
+
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.",
|
|
40987
41018
|
parameters: [
|
|
40988
41019
|
{
|
|
40989
|
-
name: "
|
|
40990
|
-
description: "
|
|
41020
|
+
name: "questions",
|
|
41021
|
+
description: "One or more follow-up questions you need answered before you can continue.",
|
|
40991
41022
|
required: true,
|
|
40992
|
-
|
|
40993
|
-
|
|
40994
|
-
|
|
40995
|
-
|
|
40996
|
-
|
|
40997
|
-
|
|
40998
|
-
|
|
41023
|
+
allowMultiple: true,
|
|
41024
|
+
children: [
|
|
41025
|
+
{
|
|
41026
|
+
name: "prompt",
|
|
41027
|
+
description: "The text of the question.",
|
|
41028
|
+
required: true,
|
|
41029
|
+
usageValue: "question text here"
|
|
41030
|
+
},
|
|
41031
|
+
{
|
|
41032
|
+
name: "options",
|
|
41033
|
+
description: "Ordered list of suggested answers (omit if none).",
|
|
41034
|
+
required: false,
|
|
41035
|
+
allowMultiple: true,
|
|
41036
|
+
usageValue: "suggested answer here"
|
|
41037
|
+
}
|
|
41038
|
+
]
|
|
40999
41039
|
}
|
|
41000
41040
|
],
|
|
41001
41041
|
examples: [
|
|
41002
41042
|
{
|
|
41003
|
-
description: "
|
|
41043
|
+
description: "Single clarifying question (no options)",
|
|
41004
41044
|
parameters: [
|
|
41005
41045
|
{
|
|
41006
|
-
name: "
|
|
41007
|
-
value: "What is the
|
|
41046
|
+
name: "questions",
|
|
41047
|
+
value: { prompt: "What is the target deployment environment?" }
|
|
41008
41048
|
}
|
|
41009
41049
|
]
|
|
41010
41050
|
},
|
|
41011
41051
|
{
|
|
41012
|
-
description: "
|
|
41052
|
+
description: "Single question with multiple-choice options",
|
|
41013
41053
|
parameters: [
|
|
41014
41054
|
{
|
|
41015
|
-
name: "
|
|
41016
|
-
value:
|
|
41017
|
-
|
|
41055
|
+
name: "questions",
|
|
41056
|
+
value: {
|
|
41057
|
+
prompt: "Which frontend framework are you using?",
|
|
41058
|
+
options: ["React", "Angular", "Vue", "Svelte"]
|
|
41059
|
+
}
|
|
41060
|
+
}
|
|
41061
|
+
]
|
|
41062
|
+
},
|
|
41063
|
+
{
|
|
41064
|
+
description: "Two related questions in one call",
|
|
41065
|
+
parameters: [
|
|
41018
41066
|
{
|
|
41019
|
-
name: "
|
|
41020
|
-
value:
|
|
41067
|
+
name: "questions",
|
|
41068
|
+
value: [
|
|
41069
|
+
{ prompt: "What type of application are you building?" },
|
|
41070
|
+
{
|
|
41071
|
+
prompt: "Preferred programming language?",
|
|
41072
|
+
options: ["JavaScript", "TypeScript", "Python", "Java"]
|
|
41073
|
+
}
|
|
41074
|
+
]
|
|
41075
|
+
}
|
|
41076
|
+
]
|
|
41077
|
+
},
|
|
41078
|
+
{
|
|
41079
|
+
description: "Binary (yes/no) confirmation",
|
|
41080
|
+
parameters: [
|
|
41081
|
+
{
|
|
41082
|
+
name: "questions",
|
|
41083
|
+
value: {
|
|
41084
|
+
prompt: "Is it acceptable to refactor existing tests to improve performance?",
|
|
41085
|
+
options: ["Yes", "No"]
|
|
41086
|
+
}
|
|
41021
41087
|
}
|
|
41022
41088
|
]
|
|
41023
41089
|
}
|
|
@@ -41031,13 +41097,26 @@ var handler = async (provider, args2) => {
|
|
|
41031
41097
|
message: "Not possible to ask followup question. Abort."
|
|
41032
41098
|
};
|
|
41033
41099
|
}
|
|
41034
|
-
const
|
|
41035
|
-
|
|
41036
|
-
|
|
41100
|
+
const questions = getArray(args2, "questions");
|
|
41101
|
+
if (!questions || questions.length === 0) {
|
|
41102
|
+
return {
|
|
41103
|
+
type: "Error" /* Error */,
|
|
41104
|
+
message: "No questions provided"
|
|
41105
|
+
};
|
|
41106
|
+
}
|
|
41107
|
+
const answers = [];
|
|
41108
|
+
for (const question of questions) {
|
|
41109
|
+
const prompt = getString(question, "prompt");
|
|
41110
|
+
const options = getArray(question, "options", []);
|
|
41111
|
+
const answer = await provider.askFollowupQuestion(prompt, options);
|
|
41112
|
+
answers.push(`<ask_followup_question_answer question="${prompt}">
|
|
41113
|
+
${answer}
|
|
41114
|
+
</ask_followup_question_answer>`);
|
|
41115
|
+
}
|
|
41037
41116
|
return {
|
|
41038
41117
|
type: "Reply" /* Reply */,
|
|
41039
|
-
message:
|
|
41040
|
-
|
|
41118
|
+
message: answers.join(`
|
|
41119
|
+
`)
|
|
41041
41120
|
};
|
|
41042
41121
|
};
|
|
41043
41122
|
var isAvailable = (provider) => {
|
|
@@ -41174,33 +41253,27 @@ var delegate_default = {
|
|
|
41174
41253
|
// ../core/src/tools/executeCommand.ts
|
|
41175
41254
|
var toolInfo4 = {
|
|
41176
41255
|
name: "execute_command",
|
|
41177
|
-
description:
|
|
41256
|
+
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.",
|
|
41178
41257
|
parameters: [
|
|
41179
41258
|
{
|
|
41180
41259
|
name: "command",
|
|
41181
|
-
description: "The
|
|
41260
|
+
description: "The exact command to run (valid for the current OS). It must be correctly formatted and free of harmful instructions.",
|
|
41182
41261
|
required: true,
|
|
41183
|
-
usageValue: "
|
|
41262
|
+
usageValue: "your-command-here"
|
|
41184
41263
|
},
|
|
41185
41264
|
{
|
|
41186
41265
|
name: "requires_approval",
|
|
41187
|
-
description:
|
|
41266
|
+
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).",
|
|
41188
41267
|
required: false,
|
|
41189
|
-
usageValue: "true
|
|
41268
|
+
usageValue: "true | false"
|
|
41190
41269
|
}
|
|
41191
41270
|
],
|
|
41192
41271
|
examples: [
|
|
41193
41272
|
{
|
|
41194
|
-
description: "
|
|
41273
|
+
description: "Make a build",
|
|
41195
41274
|
parameters: [
|
|
41196
|
-
{
|
|
41197
|
-
|
|
41198
|
-
value: "npm run dev"
|
|
41199
|
-
},
|
|
41200
|
-
{
|
|
41201
|
-
name: "requires_approval",
|
|
41202
|
-
value: "false"
|
|
41203
|
-
}
|
|
41275
|
+
{ name: "command", value: "npm run build" },
|
|
41276
|
+
{ name: "requires_approval", value: "false" }
|
|
41204
41277
|
]
|
|
41205
41278
|
}
|
|
41206
41279
|
],
|
|
@@ -42162,6 +42235,23 @@ var getAvailableTools = ({
|
|
|
42162
42235
|
};
|
|
42163
42236
|
|
|
42164
42237
|
// ../core/src/Agent/parseAssistantMessage.ts
|
|
42238
|
+
function parseNestedParameters(content, parameterPrefix) {
|
|
42239
|
+
const result = {};
|
|
42240
|
+
const nestedParamRegex = new RegExp(`<${parameterPrefix}([^>]+)>([\\s\\S]*?)<\\/${parameterPrefix}\\1>`, "gs");
|
|
42241
|
+
while (true) {
|
|
42242
|
+
const match = nestedParamRegex.exec(content);
|
|
42243
|
+
if (match === null)
|
|
42244
|
+
break;
|
|
42245
|
+
const paramName = match[1];
|
|
42246
|
+
const paramContent = match[2].trim();
|
|
42247
|
+
if (paramContent.includes(`<${parameterPrefix}`)) {
|
|
42248
|
+
result[paramName] = parseNestedParameters(paramContent, parameterPrefix);
|
|
42249
|
+
} else {
|
|
42250
|
+
result[paramName] = paramContent;
|
|
42251
|
+
}
|
|
42252
|
+
}
|
|
42253
|
+
return result;
|
|
42254
|
+
}
|
|
42165
42255
|
function parseAssistantMessage(assistantMessage, tools, toolNamePrefix) {
|
|
42166
42256
|
const parameterPrefix = `${toolNamePrefix}parameter_`;
|
|
42167
42257
|
const results = [];
|
|
@@ -42190,10 +42280,25 @@ function parseAssistantMessage(assistantMessage, tools, toolNamePrefix) {
|
|
|
42190
42280
|
for (const param of tool.parameters) {
|
|
42191
42281
|
const paramName = `${parameterPrefix}${param.name}`;
|
|
42192
42282
|
const escapedParamName = paramName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
42193
|
-
const
|
|
42194
|
-
const
|
|
42195
|
-
|
|
42196
|
-
|
|
42283
|
+
const paramRegex = new RegExp(`<${escapedParamName}>([\\s\\S]*?)<\\/${escapedParamName}>`, "gs");
|
|
42284
|
+
const paramMatches = [];
|
|
42285
|
+
while (true) {
|
|
42286
|
+
const paramMatch = paramRegex.exec(fullTagContent);
|
|
42287
|
+
if (paramMatch === null)
|
|
42288
|
+
break;
|
|
42289
|
+
paramMatches.push(paramMatch[1].trim());
|
|
42290
|
+
}
|
|
42291
|
+
if (paramMatches.length > 0) {
|
|
42292
|
+
if (paramMatches.length === 1) {
|
|
42293
|
+
const paramContent = paramMatches[0];
|
|
42294
|
+
if (paramContent.includes(`<${parameterPrefix}`)) {
|
|
42295
|
+
params[param.name] = parseNestedParameters(paramContent, parameterPrefix);
|
|
42296
|
+
} else {
|
|
42297
|
+
params[param.name] = paramContent;
|
|
42298
|
+
}
|
|
42299
|
+
} else {
|
|
42300
|
+
params[param.name] = paramMatches;
|
|
42301
|
+
}
|
|
42197
42302
|
}
|
|
42198
42303
|
}
|
|
42199
42304
|
results.push({
|
|
@@ -42225,6 +42330,20 @@ function parseAssistantMessage(assistantMessage, tools, toolNamePrefix) {
|
|
|
42225
42330
|
}
|
|
42226
42331
|
|
|
42227
42332
|
// ../core/src/Agent/prompts.ts
|
|
42333
|
+
var renderParameterValue = (key, value, parameterPrefix) => {
|
|
42334
|
+
if (typeof value === "string") {
|
|
42335
|
+
return `<${parameterPrefix}${key}>${value}</${parameterPrefix}${key}>`;
|
|
42336
|
+
}
|
|
42337
|
+
if (Array.isArray(value)) {
|
|
42338
|
+
return value.map((v2) => renderParameterValue(key, v2, parameterPrefix)).join(`
|
|
42339
|
+
`);
|
|
42340
|
+
}
|
|
42341
|
+
const inner = Object.entries(value).map(([key2, v2]) => renderParameterValue(key2, v2, parameterPrefix)).join(`
|
|
42342
|
+
`);
|
|
42343
|
+
return `<${parameterPrefix}${key}>
|
|
42344
|
+
${inner}
|
|
42345
|
+
</${parameterPrefix}${key}>`;
|
|
42346
|
+
};
|
|
42228
42347
|
var toolInfoPrompt = (tool, toolNamePrefix, parameterPrefix) => `
|
|
42229
42348
|
## ${toolNamePrefix}${tool.name}
|
|
42230
42349
|
|
|
@@ -42239,11 +42358,11 @@ Usage:
|
|
|
42239
42358
|
${tool.parameters.map((param) => `<${parameterPrefix}${param.name}>${param.usageValue}</${parameterPrefix}${param.name}>`).join(`
|
|
42240
42359
|
`)}
|
|
42241
42360
|
</${toolNamePrefix}${tool.name}>`;
|
|
42242
|
-
var toolInfoExamplesPrompt = (
|
|
42243
|
-
## Example
|
|
42361
|
+
var toolInfoExamplesPrompt = (tool, example, toolNamePrefix, parameterPrefix) => `
|
|
42362
|
+
## Example: ${example.description}
|
|
42244
42363
|
|
|
42245
42364
|
<${toolNamePrefix}${tool.name}>
|
|
42246
|
-
${example.parameters.map((param) =>
|
|
42365
|
+
${example.parameters.map((param) => `${renderParameterValue(param.name, param.value, parameterPrefix)}`).join(`
|
|
42247
42366
|
`)}
|
|
42248
42367
|
</${toolNamePrefix}${tool.name}>
|
|
42249
42368
|
`;
|
|
@@ -42252,7 +42371,6 @@ var toolUsePrompt = (tools, toolNamePrefix) => {
|
|
|
42252
42371
|
return "";
|
|
42253
42372
|
}
|
|
42254
42373
|
const parameterPrefix = `${toolNamePrefix}parameter_`;
|
|
42255
|
-
let exampleIndex = 0;
|
|
42256
42374
|
return `
|
|
42257
42375
|
====
|
|
42258
42376
|
|
|
@@ -42270,11 +42388,39 @@ Tool use is formatted using XML-style tags. The tool name is enclosed in opening
|
|
|
42270
42388
|
...
|
|
42271
42389
|
</${toolNamePrefix}tool_name>
|
|
42272
42390
|
|
|
42273
|
-
|
|
42391
|
+
## Array Parameters
|
|
42392
|
+
|
|
42393
|
+
To create an array of values for a parameter, repeat the parameter tag multiple times:
|
|
42394
|
+
|
|
42395
|
+
<${toolNamePrefix}process_file>
|
|
42396
|
+
<${parameterPrefix}path>test.ts</${parameterPrefix}path>
|
|
42397
|
+
<${parameterPrefix}path>main.ts</${parameterPrefix}path>
|
|
42398
|
+
</${toolNamePrefix}process_file>
|
|
42274
42399
|
|
|
42275
|
-
|
|
42276
|
-
|
|
42277
|
-
|
|
42400
|
+
## Nested Object Parameters
|
|
42401
|
+
|
|
42402
|
+
To create nested objects, nest parameter tags within other parameter tags:
|
|
42403
|
+
|
|
42404
|
+
<${toolNamePrefix}example_tool>
|
|
42405
|
+
<${parameterPrefix}key>
|
|
42406
|
+
<${parameterPrefix}key2>value</${parameterPrefix}key2>
|
|
42407
|
+
<${parameterPrefix}key3>value2</${parameterPrefix}key3>
|
|
42408
|
+
</${parameterPrefix}key>
|
|
42409
|
+
</${toolNamePrefix}example_tool>
|
|
42410
|
+
|
|
42411
|
+
You can also combine array parameters with nested objects:
|
|
42412
|
+
|
|
42413
|
+
<${toolNamePrefix}example_tool>
|
|
42414
|
+
<${parameterPrefix}key>
|
|
42415
|
+
<${parameterPrefix}key2>value</${parameterPrefix}key2>
|
|
42416
|
+
<${parameterPrefix}key3>value2</${parameterPrefix}key3>
|
|
42417
|
+
</${parameterPrefix}key>
|
|
42418
|
+
<${parameterPrefix}key>
|
|
42419
|
+
<${parameterPrefix}key2>value3</${parameterPrefix}key2>
|
|
42420
|
+
<${parameterPrefix}key3>value4</${parameterPrefix}key3>
|
|
42421
|
+
<${parameterPrefix}key3>value5</${parameterPrefix}key3>
|
|
42422
|
+
</${parameterPrefix}key>
|
|
42423
|
+
</${toolNamePrefix}example_tool>
|
|
42278
42424
|
|
|
42279
42425
|
Always adhere to this format for the tool use to ensure proper parsing and execution.
|
|
42280
42426
|
|
|
@@ -42288,7 +42434,7 @@ ${tools.map((tool) => toolInfoPrompt(tool, toolNamePrefix, parameterPrefix)).joi
|
|
|
42288
42434
|
${tools.map((tool) => {
|
|
42289
42435
|
let promp = "";
|
|
42290
42436
|
for (const example of tool.examples ?? []) {
|
|
42291
|
-
promp += toolInfoExamplesPrompt(
|
|
42437
|
+
promp += toolInfoExamplesPrompt(tool, example, toolNamePrefix, parameterPrefix);
|
|
42292
42438
|
}
|
|
42293
42439
|
return promp;
|
|
42294
42440
|
}).join("")}
|
|
@@ -43008,7 +43154,7 @@ You have access to two tools for working with files: **${toolNamePrefix}write_to
|
|
|
43008
43154
|
|
|
43009
43155
|
## Important Considerations
|
|
43010
43156
|
|
|
43011
|
-
- Using ${toolNamePrefix}write_to_file requires providing the file
|
|
43157
|
+
- Using ${toolNamePrefix}write_to_file requires providing the file's complete final content.
|
|
43012
43158
|
- 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.
|
|
43013
43159
|
- While ${toolNamePrefix}write_to_file should not be your default choice, don't hesitate to use it when the situation truly calls for it.
|
|
43014
43160
|
|
|
@@ -43021,12 +43167,12 @@ You have access to two tools for working with files: **${toolNamePrefix}write_to
|
|
|
43021
43167
|
## When to Use
|
|
43022
43168
|
|
|
43023
43169
|
- Small, localized changes like updating a few lines, function implementations, changing variable names, modifying a section of text, etc.
|
|
43024
|
-
- Targeted improvements where only specific portions of the file
|
|
43170
|
+
- Targeted improvements where only specific portions of the file's content needs to be altered.
|
|
43025
43171
|
- Especially useful for long files where much of the file will remain unchanged.
|
|
43026
43172
|
|
|
43027
43173
|
## Advantages
|
|
43028
43174
|
|
|
43029
|
-
- More efficient for minor edits, since you don
|
|
43175
|
+
- More efficient for minor edits, since you don't need to supply the entire file content.
|
|
43030
43176
|
- Reduces the chance of errors that can occur when overwriting large files.
|
|
43031
43177
|
|
|
43032
43178
|
# Choosing the Appropriate Tool
|
|
@@ -43052,41 +43198,39 @@ var rules = (toolNamePrefix) => `
|
|
|
43052
43198
|
|
|
43053
43199
|
RULES
|
|
43054
43200
|
|
|
43055
|
-
-
|
|
43056
|
-
-
|
|
43057
|
-
|
|
43058
|
-
-
|
|
43059
|
-
- Before using
|
|
43060
|
-
-
|
|
43061
|
-
-
|
|
43062
|
-
-
|
|
43063
|
-
-
|
|
43064
|
-
-
|
|
43065
|
-
-
|
|
43066
|
-
-
|
|
43067
|
-
-
|
|
43068
|
-
-
|
|
43069
|
-
-
|
|
43070
|
-
-
|
|
43071
|
-
- 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.
|
|
43072
|
-
- 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.
|
|
43073
|
-
- 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.
|
|
43074
|
-
- 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.
|
|
43075
|
-
- 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.
|
|
43076
|
-
- Keep the inline docs up to date if needed.
|
|
43201
|
+
- Work only with relative paths; you may \`cd\` into child directories but never use \`cd ..\`, root, or absolute paths.
|
|
43202
|
+
- When generating code, tests, or other comment-capable files, prepend a comment describing the file's purpose plus “generated by polka.codes”.
|
|
43203
|
+
For text files (e.g. README.md), append a footer with the same notice.
|
|
43204
|
+
- Never describe what changed inside code comments; comments must focus on purpose or usage only.
|
|
43205
|
+
- 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.
|
|
43206
|
+
- 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.
|
|
43207
|
+
- Prefer ${toolNamePrefix}replace_in_file for focused edits; choose ${toolNamePrefix}write_to_file for new files or complete rewrites.
|
|
43208
|
+
- 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.
|
|
43209
|
+
- SEARCH blocks in ${toolNamePrefix}replace_in_file must match whole lines. If multiple blocks are needed, list them in file order.
|
|
43210
|
+
- Do not guess unseen content. Read existing files first unless creating new ones.
|
|
43211
|
+
- Follow existing style, lint, and naming conventions. Ensure all changes compile and pass tests where applicable.
|
|
43212
|
+
- ALWAYS wait for the user's confirmation after each tool call before starting the next step.
|
|
43213
|
+
- The agent must never invoke more than 5 tools in a single response.
|
|
43214
|
+
- Do not end ${toolNamePrefix}attempt_completion output with questions or conversational prompts.
|
|
43215
|
+
- Avoid filler words like “Great”, “Certainly”, “Okay”, “Sure” at the start of responses; be direct and technical.
|
|
43216
|
+
- Keep inline documentation current as you edit.
|
|
43077
43217
|
`;
|
|
43078
43218
|
var objectives = (toolNamePrefix) => `
|
|
43079
43219
|
====
|
|
43080
43220
|
|
|
43081
43221
|
OBJECTIVE
|
|
43082
43222
|
|
|
43083
|
-
You
|
|
43223
|
+
You solve the user's task by working in small, verifiable steps.
|
|
43084
43224
|
|
|
43085
|
-
1.
|
|
43086
|
-
2.
|
|
43087
|
-
|
|
43088
|
-
|
|
43089
|
-
|
|
43225
|
+
1. **Plan** - Parse the task, list clear goals, and order them logically.
|
|
43226
|
+
2. **Think** - Wrap private reasoning in <thinking></thinking>.
|
|
43227
|
+
• Review project context.
|
|
43228
|
+
• Select the single best tool for the next goal.
|
|
43229
|
+
• Ensure every required parameter is available or can be inferred.
|
|
43230
|
+
3. **Act** - Invoke one tool per step. Wait for the system's response (and user confirmation where required) before continuing.
|
|
43231
|
+
4. **Iterate** - Repeat Plan → Think → Act until all goals are complete.
|
|
43232
|
+
5. **Complete** - Use ${toolNamePrefix}attempt_completion to deliver the final result. Do not invite further discussion unless the user explicitly requests changes.
|
|
43233
|
+
`;
|
|
43090
43234
|
var fullSystemPrompt4 = (info2, tools, toolNamePrefix, instructions, scripts) => `
|
|
43091
43235
|
${basePrompt2}
|
|
43092
43236
|
${toolUsePrompt(tools, toolNamePrefix)}
|