@polka-codes/cli-shared 0.8.25 → 0.8.27
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 +69 -57
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37654,14 +37654,18 @@ var handler8 = async (provider, args) => {
|
|
|
37654
37654
|
if (result.status === "no_diff_applied") {
|
|
37655
37655
|
return {
|
|
37656
37656
|
type: "Error" /* Error */,
|
|
37657
|
-
message: `<replace_in_file_result path="${path}" status="failed" message="Unable to apply changes"
|
|
37657
|
+
message: `<replace_in_file_result path="${path}" status="failed" message="Unable to apply changes">
|
|
37658
|
+
<file_content path="${path}">${fileContent}</file_content>
|
|
37659
|
+
</replace_in_file_result>`
|
|
37658
37660
|
};
|
|
37659
37661
|
}
|
|
37660
37662
|
await provider.writeFile(path, result.content);
|
|
37661
37663
|
if (result.status === "some_diff_applied") {
|
|
37662
37664
|
return {
|
|
37663
37665
|
type: "Reply" /* Reply */,
|
|
37664
|
-
message: `<replace_in_file_result path="${path}" status="some_diff_applied" applied_count="${result.appliedCount}" total_count="${result.totalCount}"
|
|
37666
|
+
message: `<replace_in_file_result path="${path}" status="some_diff_applied" applied_count="${result.appliedCount}" total_count="${result.totalCount}">
|
|
37667
|
+
<file_content path="${path}">${result.content}</file_content>
|
|
37668
|
+
</replace_in_file_result>`
|
|
37665
37669
|
};
|
|
37666
37670
|
}
|
|
37667
37671
|
return {
|
|
@@ -38809,12 +38813,27 @@ ${instance.prompt}`;
|
|
|
38809
38813
|
}
|
|
38810
38814
|
}
|
|
38811
38815
|
let currentAssistantMessage = "";
|
|
38812
|
-
const retryCount = 5;
|
|
38816
|
+
const retryCount = this.config.retryCount ?? 5;
|
|
38817
|
+
const requestTimeoutSeconds = this.config.requestTimeoutSeconds ?? 10;
|
|
38813
38818
|
for (let i2 = 0;i2 < retryCount; i2++) {
|
|
38814
38819
|
currentAssistantMessage = "";
|
|
38820
|
+
let timeout;
|
|
38821
|
+
const resetTimeout = () => {
|
|
38822
|
+
if (timeout) {
|
|
38823
|
+
clearTimeout(timeout);
|
|
38824
|
+
}
|
|
38825
|
+
if (requestTimeoutSeconds > 0) {
|
|
38826
|
+
timeout = setTimeout(() => {
|
|
38827
|
+
console.debug(`No data received for ${requestTimeoutSeconds} seconds. Aborting request.`);
|
|
38828
|
+
this.ai.abort();
|
|
38829
|
+
}, requestTimeoutSeconds * 1000);
|
|
38830
|
+
}
|
|
38831
|
+
};
|
|
38815
38832
|
const stream = this.ai.send(this.config.systemPrompt, this.#messages);
|
|
38816
38833
|
try {
|
|
38834
|
+
resetTimeout();
|
|
38817
38835
|
for await (const chunk of stream) {
|
|
38836
|
+
resetTimeout();
|
|
38818
38837
|
switch (chunk.type) {
|
|
38819
38838
|
case "usage":
|
|
38820
38839
|
await this.#callback({ kind: "Usage" /* Usage */, agent: this });
|
|
@@ -38833,6 +38852,10 @@ ${instance.prompt}`;
|
|
|
38833
38852
|
break;
|
|
38834
38853
|
}
|
|
38835
38854
|
console.error("Error in stream:", error);
|
|
38855
|
+
} finally {
|
|
38856
|
+
if (timeout) {
|
|
38857
|
+
clearTimeout(timeout);
|
|
38858
|
+
}
|
|
38836
38859
|
}
|
|
38837
38860
|
if (currentAssistantMessage) {
|
|
38838
38861
|
break;
|
|
@@ -43228,7 +43251,9 @@ var agentSchema = providerModelSchema.extend({
|
|
|
43228
43251
|
initialContext: z2.object({
|
|
43229
43252
|
maxFileCount: z2.number().int().positive().optional(),
|
|
43230
43253
|
excludes: z2.array(z2.string()).optional()
|
|
43231
|
-
}).optional()
|
|
43254
|
+
}).optional(),
|
|
43255
|
+
retryCount: z2.number().int().min(0).optional(),
|
|
43256
|
+
requestTimeoutSeconds: z2.number().int().positive().optional()
|
|
43232
43257
|
});
|
|
43233
43258
|
var configSchema = z2.object({
|
|
43234
43259
|
agent: z2.string().optional(),
|
|
@@ -43248,6 +43273,8 @@ var configSchema = z2.object({
|
|
|
43248
43273
|
defaultParameters: z2.record(z2.string(), z2.any()).optional(),
|
|
43249
43274
|
maxMessageCount: z2.number().int().positive().optional(),
|
|
43250
43275
|
budget: z2.number().positive().optional(),
|
|
43276
|
+
retryCount: z2.number().int().min(0).optional(),
|
|
43277
|
+
requestTimeoutSeconds: z2.number().int().positive().optional(),
|
|
43251
43278
|
scripts: z2.record(z2.string(), z2.string().or(z2.object({
|
|
43252
43279
|
command: z2.string(),
|
|
43253
43280
|
description: z2.string()
|
|
@@ -43530,64 +43557,49 @@ ${output}`);
|
|
|
43530
43557
|
};
|
|
43531
43558
|
|
|
43532
43559
|
// ../core/src/AiTool/generateProjectConfig.ts
|
|
43533
|
-
var prompt4 = `
|
|
43534
|
-
|
|
43535
|
-
|
|
43536
|
-
|
|
43537
|
-
|
|
43538
|
-
|
|
43539
|
-
-
|
|
43540
|
-
-
|
|
43541
|
-
|
|
43542
|
-
|
|
43543
|
-
-
|
|
43544
|
-
|
|
43545
|
-
|
|
43546
|
-
|
|
43547
|
-
|
|
43548
|
-
|
|
43549
|
-
|
|
43550
|
-
|
|
43551
|
-
|
|
43552
|
-
|
|
43553
|
-
<
|
|
43554
|
-
|
|
43555
|
-
|
|
43556
|
-
|
|
43557
|
-
|
|
43558
|
-
|
|
43559
|
-
|
|
43560
|
-
|
|
43561
|
-
|
|
43562
|
-
|
|
43563
|
-
rules:
|
|
43564
|
-
- "Use \`bun\` as package manager"
|
|
43565
|
-
- "Write tests using bun:test with snapshots"
|
|
43566
|
-
- "Follow Biome code style"
|
|
43567
|
-
|
|
43568
|
-
excludeFiles:
|
|
43569
|
-
# Sensitive files
|
|
43560
|
+
var prompt4 = `
|
|
43561
|
+
Role: Analyzer agent
|
|
43562
|
+
Goal: Produce a valid polkacodes YAML configuration for the project.
|
|
43563
|
+
|
|
43564
|
+
Workflow
|
|
43565
|
+
1. Scan project files with tool_read_file and identify:
|
|
43566
|
+
- Package/build tool (npm, bun, pnpm, etc.)
|
|
43567
|
+
- Test framework and patterns (snapshot tests, coverage, etc.)
|
|
43568
|
+
- Formatter / linter and their rules
|
|
43569
|
+
- Folder structure and naming conventions
|
|
43570
|
+
- CI / development workflows
|
|
43571
|
+
|
|
43572
|
+
2. Build a YAML config with three root keys:
|
|
43573
|
+
|
|
43574
|
+
\`\`\`yaml
|
|
43575
|
+
scripts: # derive from package.json and CI
|
|
43576
|
+
format: # code formatter
|
|
43577
|
+
command: "<formatter cmd>"
|
|
43578
|
+
description: "Format code"
|
|
43579
|
+
check: # linter / type checker
|
|
43580
|
+
command: "<linter cmd>"
|
|
43581
|
+
description: "Static checks"
|
|
43582
|
+
test: # test runner
|
|
43583
|
+
command: "<test cmd>"
|
|
43584
|
+
description: "Run tests"
|
|
43585
|
+
# add any other meaningful project scripts
|
|
43586
|
+
|
|
43587
|
+
rules: # bullet list of key conventions/tools
|
|
43588
|
+
|
|
43589
|
+
excludeFiles: # only files likely to hold secrets
|
|
43570
43590
|
- ".env"
|
|
43571
43591
|
- ".env.*"
|
|
43572
43592
|
- ".npmrc"
|
|
43593
|
+
# do NOT list build artifacts, lockfiles, or paths already in .gitignore
|
|
43594
|
+
\`\`\`
|
|
43595
|
+
|
|
43596
|
+
3. Return the YAML exactly once, wrapped like:
|
|
43597
|
+
|
|
43598
|
+
<tool_attempt_completion>
|
|
43599
|
+
<tool_parameter_result>
|
|
43600
|
+
# YAML (2-space indents, double-quoted commands)
|
|
43573
43601
|
</tool_parameter_result>
|
|
43574
43602
|
</tool_attempt_completion>
|
|
43575
|
-
|
|
43576
|
-
Focus on:
|
|
43577
|
-
- Package manager and dependency management
|
|
43578
|
-
- Testing frameworks and patterns
|
|
43579
|
-
- Code style and linting rules
|
|
43580
|
-
- File organization and naming conventions
|
|
43581
|
-
- Build and development workflows
|
|
43582
|
-
- Sensitive files that should not be committed:
|
|
43583
|
-
- Environment files (.env*)
|
|
43584
|
-
- Configuration files with potential secrets
|
|
43585
|
-
- Generated files to exclude:
|
|
43586
|
-
- Lock files from package managers
|
|
43587
|
-
- Build artifacts and outputs
|
|
43588
|
-
- Generated file that are not ignored by .gitignore
|
|
43589
|
-
|
|
43590
|
-
The configuration should accurately reflect the project's structure, tools, and conventions.
|
|
43591
43603
|
`;
|
|
43592
43604
|
var generateProjectConfig_default = {
|
|
43593
43605
|
name: "generateProjectConfig",
|