@polka-codes/cli 0.8.20 → 0.8.21
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 +145 -249
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -38447,7 +38447,7 @@ var {
|
|
|
38447
38447
|
Help
|
|
38448
38448
|
} = import__.default;
|
|
38449
38449
|
// package.json
|
|
38450
|
-
var version = "0.8.
|
|
38450
|
+
var version = "0.8.21";
|
|
38451
38451
|
|
|
38452
38452
|
// ../core/src/AiService/AiServiceBase.ts
|
|
38453
38453
|
class AiServiceBase {
|
|
@@ -47758,39 +47758,6 @@ __export(exports_allTools, {
|
|
|
47758
47758
|
askFollowupQuestion: () => askFollowupQuestion_default
|
|
47759
47759
|
});
|
|
47760
47760
|
|
|
47761
|
-
// ../core/src/tools/utils/editFile.ts
|
|
47762
|
-
var START_OF_FILE = "<<<START_OF_FILE>>>";
|
|
47763
|
-
var END_OF_FILE = "<<<END_OF_FILE>>>";
|
|
47764
|
-
var editFile = async (fileContent, operations) => {
|
|
47765
|
-
if (!operations || operations.length === 0) {
|
|
47766
|
-
throw new Error("At least one edit operation is required");
|
|
47767
|
-
}
|
|
47768
|
-
let updatedContent = fileContent;
|
|
47769
|
-
for (const operation of operations) {
|
|
47770
|
-
updatedContent = await applyEditOperation(updatedContent, operation);
|
|
47771
|
-
}
|
|
47772
|
-
return updatedContent;
|
|
47773
|
-
};
|
|
47774
|
-
async function applyEditOperation(fileContent, operation) {
|
|
47775
|
-
const { search, replace } = operation;
|
|
47776
|
-
if (search === START_OF_FILE && replace === END_OF_FILE) {
|
|
47777
|
-
throw new Error("Cannot search for START_OF_FILE and replace with END_OF_FILE");
|
|
47778
|
-
}
|
|
47779
|
-
if (search === END_OF_FILE && replace === START_OF_FILE) {
|
|
47780
|
-
throw new Error("Cannot search for END_OF_FILE and replace with START_OF_FILE");
|
|
47781
|
-
}
|
|
47782
|
-
if (search === START_OF_FILE) {
|
|
47783
|
-
return replace + fileContent;
|
|
47784
|
-
}
|
|
47785
|
-
if (search === END_OF_FILE) {
|
|
47786
|
-
return fileContent + replace;
|
|
47787
|
-
}
|
|
47788
|
-
const index = fileContent.indexOf(search);
|
|
47789
|
-
if (index === -1) {
|
|
47790
|
-
throw new Error(`Could not find text: ${search}`);
|
|
47791
|
-
}
|
|
47792
|
-
return fileContent.slice(0, index) + replace + fileContent.slice(index + search.length);
|
|
47793
|
-
}
|
|
47794
47761
|
// ../core/src/tools/utils/getArg.ts
|
|
47795
47762
|
var getString = (args, name, defaultValue) => {
|
|
47796
47763
|
if (typeof args !== "object" || Array.isArray(args)) {
|
|
@@ -48397,29 +48364,29 @@ var toolInfo7 = {
|
|
|
48397
48364
|
{
|
|
48398
48365
|
name: "diff",
|
|
48399
48366
|
description: `One or more SEARCH/REPLACE blocks following this exact format:
|
|
48400
|
-
|
|
48401
|
-
|
|
48402
|
-
|
|
48403
|
-
|
|
48404
|
-
|
|
48405
|
-
|
|
48406
|
-
|
|
48407
|
-
|
|
48408
|
-
|
|
48409
|
-
|
|
48410
|
-
|
|
48411
|
-
|
|
48412
|
-
|
|
48413
|
-
|
|
48414
|
-
|
|
48415
|
-
|
|
48416
|
-
|
|
48417
|
-
|
|
48418
|
-
|
|
48419
|
-
|
|
48420
|
-
|
|
48421
|
-
|
|
48422
|
-
|
|
48367
|
+
\`\`\`
|
|
48368
|
+
<<<<<<< SEARCH
|
|
48369
|
+
[exact content to find]
|
|
48370
|
+
=======
|
|
48371
|
+
[new content to replace with]
|
|
48372
|
+
>>>>>>> REPLACE
|
|
48373
|
+
\`\`\`
|
|
48374
|
+
Critical rules:
|
|
48375
|
+
1. SEARCH content must match the associated file section to find EXACTLY:
|
|
48376
|
+
* Match character-for-character including whitespace, indentation, line endings
|
|
48377
|
+
* Include all comments, docstrings, etc.
|
|
48378
|
+
2. SEARCH/REPLACE blocks will ONLY replace the first match occurrence.
|
|
48379
|
+
* Including multiple unique SEARCH/REPLACE blocks if you need to make multiple changes.
|
|
48380
|
+
* Include *just* enough lines in each SEARCH section to uniquely match each set of lines that need to change.
|
|
48381
|
+
* When using multiple SEARCH/REPLACE blocks, list them in the order they appear in the file.
|
|
48382
|
+
3. Keep SEARCH/REPLACE blocks concise:
|
|
48383
|
+
* Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.
|
|
48384
|
+
* Include just the changing lines, and a few surrounding lines if needed for uniqueness.
|
|
48385
|
+
* Do not include long runs of unchanging lines in SEARCH/REPLACE blocks.
|
|
48386
|
+
* Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
|
|
48387
|
+
4. Special operations:
|
|
48388
|
+
* To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
|
|
48389
|
+
* To delete code: Use empty REPLACE section`,
|
|
48423
48390
|
required: true,
|
|
48424
48391
|
usageValue: "Search and replace blocks here"
|
|
48425
48392
|
}
|
|
@@ -48462,6 +48429,73 @@ function handleSubmit() {
|
|
|
48462
48429
|
return (
|
|
48463
48430
|
<div>
|
|
48464
48431
|
>>>>>>> REPLACE
|
|
48432
|
+
`
|
|
48433
|
+
}
|
|
48434
|
+
]
|
|
48435
|
+
},
|
|
48436
|
+
{
|
|
48437
|
+
description: "Request to perform a simple, single-line replacement",
|
|
48438
|
+
parameters: [
|
|
48439
|
+
{
|
|
48440
|
+
name: "path",
|
|
48441
|
+
value: "src/config.js"
|
|
48442
|
+
},
|
|
48443
|
+
{
|
|
48444
|
+
name: "diff",
|
|
48445
|
+
value: `
|
|
48446
|
+
<<<<<<< SEARCH
|
|
48447
|
+
const API_URL = 'https://api.example.com';
|
|
48448
|
+
=======
|
|
48449
|
+
const API_URL = 'https://api.staging.example.com';
|
|
48450
|
+
>>>>>>> REPLACE
|
|
48451
|
+
`
|
|
48452
|
+
}
|
|
48453
|
+
]
|
|
48454
|
+
},
|
|
48455
|
+
{
|
|
48456
|
+
description: "Request to add a new function to a file",
|
|
48457
|
+
parameters: [
|
|
48458
|
+
{
|
|
48459
|
+
name: "path",
|
|
48460
|
+
value: "src/utils.js"
|
|
48461
|
+
},
|
|
48462
|
+
{
|
|
48463
|
+
name: "diff",
|
|
48464
|
+
value: `
|
|
48465
|
+
<<<<<<< SEARCH
|
|
48466
|
+
function helperA() {
|
|
48467
|
+
// ...
|
|
48468
|
+
}
|
|
48469
|
+
=======
|
|
48470
|
+
function helperA() {
|
|
48471
|
+
// ...
|
|
48472
|
+
}
|
|
48473
|
+
|
|
48474
|
+
function newHelper() {
|
|
48475
|
+
// implementation
|
|
48476
|
+
}
|
|
48477
|
+
>>>>>>> REPLACE
|
|
48478
|
+
`
|
|
48479
|
+
}
|
|
48480
|
+
]
|
|
48481
|
+
},
|
|
48482
|
+
{
|
|
48483
|
+
description: "Request to delete a block of code from a file",
|
|
48484
|
+
parameters: [
|
|
48485
|
+
{
|
|
48486
|
+
name: "path",
|
|
48487
|
+
value: "src/app.js"
|
|
48488
|
+
},
|
|
48489
|
+
{
|
|
48490
|
+
name: "diff",
|
|
48491
|
+
value: `
|
|
48492
|
+
<<<<<<< SEARCH
|
|
48493
|
+
function oldFeature() {
|
|
48494
|
+
// This is no longer needed
|
|
48495
|
+
}
|
|
48496
|
+
|
|
48497
|
+
=======
|
|
48498
|
+
>>>>>>> REPLACE
|
|
48465
48499
|
`
|
|
48466
48500
|
}
|
|
48467
48501
|
]
|
|
@@ -49086,167 +49120,6 @@ var renameFile_default = {
|
|
|
49086
49120
|
handler: handler13,
|
|
49087
49121
|
isAvailable: isAvailable13
|
|
49088
49122
|
};
|
|
49089
|
-
// ../core/src/tools/editFile.ts
|
|
49090
|
-
var toolInfo14 = {
|
|
49091
|
-
name: "edit_file",
|
|
49092
|
-
description: "Request to edit file contents using search/replace operations. Supports multiple edit operations in a single call.",
|
|
49093
|
-
parameters: [
|
|
49094
|
-
{
|
|
49095
|
-
name: "path",
|
|
49096
|
-
description: "The path of the file to edit",
|
|
49097
|
-
required: true,
|
|
49098
|
-
usageValue: "File path here"
|
|
49099
|
-
},
|
|
49100
|
-
{
|
|
49101
|
-
name: "operations",
|
|
49102
|
-
description: "Edit operation with search and replace parameters",
|
|
49103
|
-
required: true,
|
|
49104
|
-
allowMultiple: true,
|
|
49105
|
-
children: [
|
|
49106
|
-
{
|
|
49107
|
-
name: "search",
|
|
49108
|
-
description: `Text to search for and replace (use ${START_OF_FILE} to insert at file start, ${END_OF_FILE} to insert at file end)`,
|
|
49109
|
-
required: true,
|
|
49110
|
-
usageValue: "Text to find and replace"
|
|
49111
|
-
},
|
|
49112
|
-
{
|
|
49113
|
-
name: "replace",
|
|
49114
|
-
description: "Text to replace the search text with",
|
|
49115
|
-
required: true,
|
|
49116
|
-
usageValue: "Replacement text"
|
|
49117
|
-
}
|
|
49118
|
-
],
|
|
49119
|
-
usageValue: "operations here"
|
|
49120
|
-
}
|
|
49121
|
-
],
|
|
49122
|
-
examples: [
|
|
49123
|
-
{
|
|
49124
|
-
description: "Replace specific text",
|
|
49125
|
-
parameters: [
|
|
49126
|
-
{
|
|
49127
|
-
name: "path",
|
|
49128
|
-
value: "src/main.ts"
|
|
49129
|
-
},
|
|
49130
|
-
{
|
|
49131
|
-
name: "operations",
|
|
49132
|
-
value: {
|
|
49133
|
-
search: `function oldFunction() {
|
|
49134
|
-
return 42;
|
|
49135
|
-
}`,
|
|
49136
|
-
replace: `function newFunction() {
|
|
49137
|
-
return "new implementation";
|
|
49138
|
-
}`
|
|
49139
|
-
}
|
|
49140
|
-
}
|
|
49141
|
-
]
|
|
49142
|
-
},
|
|
49143
|
-
{
|
|
49144
|
-
description: "Insert at start of file",
|
|
49145
|
-
parameters: [
|
|
49146
|
-
{
|
|
49147
|
-
name: "path",
|
|
49148
|
-
value: "src/header.ts"
|
|
49149
|
-
},
|
|
49150
|
-
{
|
|
49151
|
-
name: "operations",
|
|
49152
|
-
value: {
|
|
49153
|
-
search: START_OF_FILE,
|
|
49154
|
-
replace: `// File header comment
|
|
49155
|
-
`
|
|
49156
|
-
}
|
|
49157
|
-
}
|
|
49158
|
-
]
|
|
49159
|
-
},
|
|
49160
|
-
{
|
|
49161
|
-
description: "Multiple operations in one call",
|
|
49162
|
-
parameters: [
|
|
49163
|
-
{
|
|
49164
|
-
name: "path",
|
|
49165
|
-
value: "src/utils.ts"
|
|
49166
|
-
},
|
|
49167
|
-
{
|
|
49168
|
-
name: "operations",
|
|
49169
|
-
value: [
|
|
49170
|
-
{
|
|
49171
|
-
search: 'import React from "react"',
|
|
49172
|
-
replace: 'import React, { useState } from "react"'
|
|
49173
|
-
},
|
|
49174
|
-
{
|
|
49175
|
-
search: `function Component() {
|
|
49176
|
-
return (`,
|
|
49177
|
-
replace: `function Component() {
|
|
49178
|
-
const [state, setState] = useState(false);
|
|
49179
|
-
return (`
|
|
49180
|
-
}
|
|
49181
|
-
]
|
|
49182
|
-
}
|
|
49183
|
-
]
|
|
49184
|
-
},
|
|
49185
|
-
{
|
|
49186
|
-
description: "Append content at end of file",
|
|
49187
|
-
parameters: [
|
|
49188
|
-
{
|
|
49189
|
-
name: "path",
|
|
49190
|
-
value: "src/footer.ts"
|
|
49191
|
-
},
|
|
49192
|
-
{
|
|
49193
|
-
name: "operations",
|
|
49194
|
-
value: {
|
|
49195
|
-
search: END_OF_FILE,
|
|
49196
|
-
replace: `
|
|
49197
|
-
// End of file appended comment
|
|
49198
|
-
`
|
|
49199
|
-
}
|
|
49200
|
-
}
|
|
49201
|
-
]
|
|
49202
|
-
}
|
|
49203
|
-
],
|
|
49204
|
-
permissionLevel: 2 /* Write */
|
|
49205
|
-
};
|
|
49206
|
-
var handler14 = async (provider, args) => {
|
|
49207
|
-
if (!provider.readFile || !provider.writeFile) {
|
|
49208
|
-
return {
|
|
49209
|
-
type: "Error" /* Error */,
|
|
49210
|
-
message: "Not possible to edit file. Abort."
|
|
49211
|
-
};
|
|
49212
|
-
}
|
|
49213
|
-
const path = getString(args, "path");
|
|
49214
|
-
const operations = getArray(args, "operations");
|
|
49215
|
-
if (!operations || operations.length === 0) {
|
|
49216
|
-
return {
|
|
49217
|
-
type: "Error" /* Error */,
|
|
49218
|
-
message: `<error><edit_file_path>${path}</edit_file_path><error_message>At least one edit operation is required</error_message></error>`
|
|
49219
|
-
};
|
|
49220
|
-
}
|
|
49221
|
-
const fileContent = await provider.readFile(path);
|
|
49222
|
-
if (fileContent == null) {
|
|
49223
|
-
return {
|
|
49224
|
-
type: "Error" /* Error */,
|
|
49225
|
-
message: `<error><edit_file_path>${path}</edit_file_path><error_message>File not found</error_message></error>`
|
|
49226
|
-
};
|
|
49227
|
-
}
|
|
49228
|
-
try {
|
|
49229
|
-
const result = await editFile(fileContent, operations);
|
|
49230
|
-
await provider.writeFile(path, result);
|
|
49231
|
-
return {
|
|
49232
|
-
type: "Reply" /* Reply */,
|
|
49233
|
-
message: `<edit_file_path>${path}</edit_file_path>`
|
|
49234
|
-
};
|
|
49235
|
-
} catch (error) {
|
|
49236
|
-
return {
|
|
49237
|
-
type: "Error" /* Error */,
|
|
49238
|
-
message: `<error><edit_file_path>${path}</edit_file_path><error_message>${error instanceof Error ? error.message : String(error)}</error_message></error>`
|
|
49239
|
-
};
|
|
49240
|
-
}
|
|
49241
|
-
};
|
|
49242
|
-
var isAvailable14 = (provider) => {
|
|
49243
|
-
return !!provider.readFile && !!provider.writeFile;
|
|
49244
|
-
};
|
|
49245
|
-
var editFile_default = {
|
|
49246
|
-
...toolInfo14,
|
|
49247
|
-
handler: handler14,
|
|
49248
|
-
isAvailable: isAvailable14
|
|
49249
|
-
};
|
|
49250
49123
|
// ../core/src/getAvailableTools.ts
|
|
49251
49124
|
var getAvailableTools = ({
|
|
49252
49125
|
provider: provider2,
|
|
@@ -49471,6 +49344,8 @@ Tool use is formatted using XML-style tags. The tool name is enclosed in opening
|
|
|
49471
49344
|
...
|
|
49472
49345
|
</${toolNamePrefix}tool_name>
|
|
49473
49346
|
|
|
49347
|
+
**It is crucial that all tags are correctly nested and closed.**
|
|
49348
|
+
|
|
49474
49349
|
## Array Parameters
|
|
49475
49350
|
|
|
49476
49351
|
To create an array of values for a parameter, repeat the parameter tag multiple times:
|
|
@@ -49505,7 +49380,7 @@ You can also combine array parameters with nested objects:
|
|
|
49505
49380
|
</${parameterPrefix}key>
|
|
49506
49381
|
</${toolNamePrefix}example_tool>
|
|
49507
49382
|
|
|
49508
|
-
Always adhere to this format
|
|
49383
|
+
Always adhere to this format, ensuring every opening tag has a matching closing tag, to ensure proper parsing and execution.
|
|
49509
49384
|
|
|
49510
49385
|
NEVER surround tool use with triple backticks (\`\`\`).
|
|
49511
49386
|
|
|
@@ -49844,8 +49719,8 @@ ${instance.prompt}`;
|
|
|
49844
49719
|
}
|
|
49845
49720
|
async#invokeTool(name, args) {
|
|
49846
49721
|
try {
|
|
49847
|
-
const
|
|
49848
|
-
if (!
|
|
49722
|
+
const handler14 = this.handlers[name]?.handler;
|
|
49723
|
+
if (!handler14) {
|
|
49849
49724
|
return {
|
|
49850
49725
|
type: "Error" /* Error */,
|
|
49851
49726
|
message: responsePrompts.errorInvokeTool(name, "Tool not found"),
|
|
@@ -49864,7 +49739,7 @@ ${instance.prompt}`;
|
|
|
49864
49739
|
if (resp) {
|
|
49865
49740
|
return resp;
|
|
49866
49741
|
}
|
|
49867
|
-
return await
|
|
49742
|
+
return await handler14(this.config.provider, args);
|
|
49868
49743
|
} catch (error) {
|
|
49869
49744
|
return {
|
|
49870
49745
|
type: "Error" /* Error */,
|
|
@@ -50203,7 +50078,7 @@ var editingFilesPrompt = (toolNamePrefix) => `
|
|
|
50203
50078
|
|
|
50204
50079
|
EDITING FILES
|
|
50205
50080
|
|
|
50206
|
-
You have two file-manipulation tools: **${toolNamePrefix}write_to_file** (full overwrite) and **${toolNamePrefix}
|
|
50081
|
+
You have two file-manipulation tools: **${toolNamePrefix}write_to_file** (full overwrite) and **${toolNamePrefix}replace_in_file** (targeted anchor-based edits). Choose the smallest safe operation for every change.
|
|
50207
50082
|
|
|
50208
50083
|
# ${toolNamePrefix}write_to_file
|
|
50209
50084
|
|
|
@@ -50215,16 +50090,16 @@ You have two file-manipulation tools: **${toolNamePrefix}write_to_file** (full o
|
|
|
50215
50090
|
|
|
50216
50091
|
- Initial file creation, such as when scaffolding a new project.
|
|
50217
50092
|
- Overwriting large boilerplate files where you want to replace the entire content at once.
|
|
50218
|
-
- When the complexity or number of changes would make ${toolNamePrefix}
|
|
50093
|
+
- When the complexity or number of changes would make ${toolNamePrefix}replace_in_file unwieldy or error-prone.
|
|
50219
50094
|
- When you need to completely restructure a file's content or change its fundamental organization.
|
|
50220
50095
|
|
|
50221
50096
|
## Important Considerations
|
|
50222
50097
|
|
|
50223
50098
|
- Using ${toolNamePrefix}write_to_file requires providing the file's complete final content.
|
|
50224
|
-
- If you only need to make small changes to an existing file, consider using ${toolNamePrefix}
|
|
50099
|
+
- 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.
|
|
50225
50100
|
- While ${toolNamePrefix}write_to_file should not be your default choice, don't hesitate to use it when the situation truly calls for it.
|
|
50226
50101
|
|
|
50227
|
-
# ${toolNamePrefix}
|
|
50102
|
+
# ${toolNamePrefix}replace_in_file
|
|
50228
50103
|
|
|
50229
50104
|
## Purpose
|
|
50230
50105
|
|
|
@@ -50243,10 +50118,10 @@ You have two file-manipulation tools: **${toolNamePrefix}write_to_file** (full o
|
|
|
50243
50118
|
|
|
50244
50119
|
# Choosing the Appropriate Tool
|
|
50245
50120
|
|
|
50246
|
-
- **Default to ${toolNamePrefix}
|
|
50121
|
+
- **Default to ${toolNamePrefix}replace_in_file** for most changes. It keeps diffs small and reduces risk.
|
|
50247
50122
|
- **Use ${toolNamePrefix}write_to_file** when:
|
|
50248
50123
|
- Creating new files
|
|
50249
|
-
- The changes are so extensive that using ${toolNamePrefix}
|
|
50124
|
+
- The changes are so extensive that using ${toolNamePrefix}replace_in_file would be more complex or risky
|
|
50250
50125
|
- You need to completely reorganize or restructure a file
|
|
50251
50126
|
- The file is relatively small and the changes affect most of its content
|
|
50252
50127
|
- You're generating boilerplate or template files
|
|
@@ -50254,9 +50129,9 @@ You have two file-manipulation tools: **${toolNamePrefix}write_to_file** (full o
|
|
|
50254
50129
|
# Workflow Tips
|
|
50255
50130
|
|
|
50256
50131
|
1. Before editing, assess the scope of your changes and decide which tool to use.
|
|
50257
|
-
2. For targeted edits, apply ${toolNamePrefix}
|
|
50132
|
+
2. For targeted edits, apply ${toolNamePrefix}replace_in_file with carefully crafted before/after text anchors. If you need multiple changes, you can stack multiple operations within a single ${toolNamePrefix}replace_in_file call.
|
|
50258
50133
|
3. For major overhauls or initial file creation, rely on ${toolNamePrefix}write_to_file.
|
|
50259
|
-
4. Once the file has been edited with either ${toolNamePrefix}write_to_file or ${toolNamePrefix}
|
|
50134
|
+
4. Once the file has been edited with either ${toolNamePrefix}write_to_file or ${toolNamePrefix}replace_in_file, the system will provide you with the final state of the modified file. Use this updated content as the reference point for any subsequent operations, since it reflects any auto-formatting or user-applied changes.
|
|
50260
50135
|
|
|
50261
50136
|
Picking the right tool keeps edits minimal, safe, and easy to review.
|
|
50262
50137
|
`;
|
|
@@ -50270,10 +50145,10 @@ RULES
|
|
|
50270
50145
|
For text files (e.g. README.md), append a footer with the same notice.
|
|
50271
50146
|
- Never describe what changed inside code comments; comments must focus on purpose or usage only.
|
|
50272
50147
|
- 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.
|
|
50273
|
-
- Use ${toolNamePrefix}search_files for broad analysis, then ${toolNamePrefix}read_file to inspect context, and finally ${toolNamePrefix}
|
|
50274
|
-
- Prefer ${toolNamePrefix}
|
|
50148
|
+
- 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.
|
|
50149
|
+
- Prefer ${toolNamePrefix}replace_in_file for focused edits; choose ${toolNamePrefix}write_to_file for new files or complete rewrites.
|
|
50275
50150
|
- 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.
|
|
50276
|
-
- Use before/after text anchors in ${toolNamePrefix}
|
|
50151
|
+
- Use before/after text anchors in ${toolNamePrefix}replace_in_file to target changes. If multiple operations are needed, list them in file order.
|
|
50277
50152
|
- Do not guess unseen content. Read existing files first unless creating new ones.
|
|
50278
50153
|
- Follow existing style, lint, and naming conventions. Ensure all changes compile and pass tests where applicable.
|
|
50279
50154
|
- ALWAYS wait for the user's confirmation after each tool call before starting the next step.
|
|
@@ -59768,15 +59643,15 @@ function useKeypress(userHandler) {
|
|
|
59768
59643
|
signal.current = userHandler;
|
|
59769
59644
|
useEffect((rl) => {
|
|
59770
59645
|
let ignore = false;
|
|
59771
|
-
const
|
|
59646
|
+
const handler14 = withUpdates((_input, event) => {
|
|
59772
59647
|
if (ignore)
|
|
59773
59648
|
return;
|
|
59774
59649
|
signal.current(event, rl);
|
|
59775
59650
|
});
|
|
59776
|
-
rl.input.on("keypress",
|
|
59651
|
+
rl.input.on("keypress", handler14);
|
|
59777
59652
|
return () => {
|
|
59778
59653
|
ignore = true;
|
|
59779
|
-
rl.input.removeListener("keypress",
|
|
59654
|
+
rl.input.removeListener("keypress", handler14);
|
|
59780
59655
|
};
|
|
59781
59656
|
}, []);
|
|
59782
59657
|
}
|
|
@@ -59958,16 +59833,16 @@ class Emitter {
|
|
|
59958
59833
|
|
|
59959
59834
|
class SignalExitBase {
|
|
59960
59835
|
}
|
|
59961
|
-
var signalExitWrap = (
|
|
59836
|
+
var signalExitWrap = (handler14) => {
|
|
59962
59837
|
return {
|
|
59963
59838
|
onExit(cb, opts) {
|
|
59964
|
-
return
|
|
59839
|
+
return handler14.onExit(cb, opts);
|
|
59965
59840
|
},
|
|
59966
59841
|
load() {
|
|
59967
|
-
return
|
|
59842
|
+
return handler14.load();
|
|
59968
59843
|
},
|
|
59969
59844
|
unload() {
|
|
59970
|
-
return
|
|
59845
|
+
return handler14.unload();
|
|
59971
59846
|
}
|
|
59972
59847
|
};
|
|
59973
59848
|
};
|
|
@@ -60575,6 +60450,24 @@ ${theme.style.description(selectedChoice.description)}` : ``;
|
|
|
60575
60450
|
return `${[prefix, message, helpTipTop].filter(Boolean).join(" ")}
|
|
60576
60451
|
${page}${helpTipBottom}${choiceDescription}${import_ansi_escapes3.default.cursorHide}`;
|
|
60577
60452
|
});
|
|
60453
|
+
// ../cli-shared/src/utils/checkRipgrep.ts
|
|
60454
|
+
import { spawnSync } from "node:child_process";
|
|
60455
|
+
var rgAvailability = {
|
|
60456
|
+
isAvailable: null
|
|
60457
|
+
};
|
|
60458
|
+
function checkRipgrep() {
|
|
60459
|
+
if (rgAvailability.isAvailable !== null) {
|
|
60460
|
+
return rgAvailability.isAvailable;
|
|
60461
|
+
}
|
|
60462
|
+
const rg = spawnSync("rg", ["--version"]);
|
|
60463
|
+
if (rg.error || rg.status !== 0) {
|
|
60464
|
+
rgAvailability.isAvailable = false;
|
|
60465
|
+
return false;
|
|
60466
|
+
}
|
|
60467
|
+
rgAvailability.isAvailable = true;
|
|
60468
|
+
return true;
|
|
60469
|
+
}
|
|
60470
|
+
|
|
60578
60471
|
// ../cli-shared/src/utils/listFiles.ts
|
|
60579
60472
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
60580
60473
|
import { promises as fs2 } from "node:fs";
|
|
@@ -60672,7 +60565,6 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles) {
|
|
|
60672
60565
|
|
|
60673
60566
|
// ../cli-shared/src/utils/searchFiles.ts
|
|
60674
60567
|
import { spawn } from "node:child_process";
|
|
60675
|
-
import { rgPath } from "@vscode/ripgrep";
|
|
60676
60568
|
async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
60677
60569
|
const args = [
|
|
60678
60570
|
"--line-number",
|
|
@@ -60697,7 +60589,7 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
|
60697
60589
|
args.push(regex, path);
|
|
60698
60590
|
return new Promise((resolve2, reject) => {
|
|
60699
60591
|
const results = [];
|
|
60700
|
-
const rg = spawn(
|
|
60592
|
+
const rg = spawn("rg", args, {
|
|
60701
60593
|
cwd,
|
|
60702
60594
|
stdio: ["ignore", "pipe", "pipe"]
|
|
60703
60595
|
});
|
|
@@ -60755,9 +60647,6 @@ var getProvider = (agentName, config2, options = {}) => {
|
|
|
60755
60647
|
listFiles: async (path, recursive, maxCount) => {
|
|
60756
60648
|
return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles);
|
|
60757
60649
|
},
|
|
60758
|
-
searchFiles: async (path, regex, filePattern) => {
|
|
60759
|
-
return await searchFiles(path, regex, filePattern, process.cwd(), options.excludeFiles);
|
|
60760
|
-
},
|
|
60761
60650
|
executeCommand: (command, needApprove) => {
|
|
60762
60651
|
return new Promise((resolve2, reject) => {
|
|
60763
60652
|
options.command?.onStarted(command);
|
|
@@ -60813,6 +60702,13 @@ var getProvider = (agentName, config2, options = {}) => {
|
|
|
60813
60702
|
return;
|
|
60814
60703
|
}
|
|
60815
60704
|
};
|
|
60705
|
+
if (checkRipgrep()) {
|
|
60706
|
+
provider2.searchFiles = async (path, regex, filePattern) => {
|
|
60707
|
+
return await searchFiles(path, regex, filePattern, process.cwd(), options.excludeFiles);
|
|
60708
|
+
};
|
|
60709
|
+
} else {
|
|
60710
|
+
console.error("Error: ripgrep (rg) is not installed. Search file tool is disabled. Please install it from https://github.com/BurntSushi/ripgrep#installation");
|
|
60711
|
+
}
|
|
60816
60712
|
return provider2;
|
|
60817
60713
|
};
|
|
60818
60714
|
// ../../node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
@@ -61854,7 +61750,7 @@ var runChat = async (opts, command) => {
|
|
|
61854
61750
|
};
|
|
61855
61751
|
|
|
61856
61752
|
// src/commands/commit.ts
|
|
61857
|
-
import { execSync, spawnSync } from "node:child_process";
|
|
61753
|
+
import { execSync, spawnSync as spawnSync2 } from "node:child_process";
|
|
61858
61754
|
|
|
61859
61755
|
// ../../node_modules/ora/index.js
|
|
61860
61756
|
import process10 from "node:process";
|
|
@@ -62511,7 +62407,7 @@ var commitCommand = new Command("commit").description("Create a commit with AI-g
|
|
|
62511
62407
|
Commit message:
|
|
62512
62408
|
${result.response}`);
|
|
62513
62409
|
try {
|
|
62514
|
-
|
|
62410
|
+
spawnSync2("git", ["commit", "-m", result.response], { stdio: "inherit" });
|
|
62515
62411
|
} catch {
|
|
62516
62412
|
console.error("Error: Commit failed");
|
|
62517
62413
|
process.exit(1);
|
|
@@ -66627,7 +66523,7 @@ ${newConfig.provider.toUpperCase()}_API_KEY=${newConfig.apiKey}`;
|
|
|
66627
66523
|
});
|
|
66628
66524
|
|
|
66629
66525
|
// src/commands/pr.ts
|
|
66630
|
-
import { execSync as execSync2, spawnSync as
|
|
66526
|
+
import { execSync as execSync2, spawnSync as spawnSync3 } from "node:child_process";
|
|
66631
66527
|
var prCommand = new Command("pr").description("Create a GitHub pull request").argument("[message]", "Optional context for the commit message generation").action(async (message, _options, command) => {
|
|
66632
66528
|
const options = command.parent?.opts() ?? {};
|
|
66633
66529
|
const { providerConfig, config: config3 } = parseOptions(options);
|
|
@@ -66687,7 +66583,7 @@ var prCommand = new Command("pr").description("Create a GitHub pull request").ar
|
|
|
66687
66583
|
console.log("Title:", prDetails.response.title);
|
|
66688
66584
|
console.log(prDetails.response.description);
|
|
66689
66585
|
await new Promise((resolve2) => setTimeout(resolve2, 10));
|
|
66690
|
-
|
|
66586
|
+
spawnSync3("gh", ["pr", "create", "--title", prDetails.response.title.trim(), "--body", prDetails.response.description.trim()], {
|
|
66691
66587
|
stdio: "inherit"
|
|
66692
66588
|
});
|
|
66693
66589
|
usage.printUsage();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polka-codes/cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.21",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"author": "github@polka.codes",
|
|
6
6
|
"type": "module",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "bun build src/index.ts --outdir dist --target node
|
|
17
|
+
"build": "bun build src/index.ts --outdir dist --target node"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@inquirer/prompts": "^7.2.3",
|