@polka-codes/cli-shared 0.8.26 → 0.8.28

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.
Files changed (2) hide show
  1. package/dist/index.js +63 -55
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -38813,12 +38813,27 @@ ${instance.prompt}`;
38813
38813
  }
38814
38814
  }
38815
38815
  let currentAssistantMessage = "";
38816
- const retryCount = 5;
38816
+ const retryCount = this.config.retryCount ?? 5;
38817
+ const requestTimeoutSeconds = this.config.requestTimeoutSeconds ?? 10;
38817
38818
  for (let i2 = 0;i2 < retryCount; i2++) {
38818
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
+ };
38819
38832
  const stream = this.ai.send(this.config.systemPrompt, this.#messages);
38820
38833
  try {
38834
+ resetTimeout();
38821
38835
  for await (const chunk of stream) {
38836
+ resetTimeout();
38822
38837
  switch (chunk.type) {
38823
38838
  case "usage":
38824
38839
  await this.#callback({ kind: "Usage" /* Usage */, agent: this });
@@ -38837,6 +38852,10 @@ ${instance.prompt}`;
38837
38852
  break;
38838
38853
  }
38839
38854
  console.error("Error in stream:", error);
38855
+ } finally {
38856
+ if (timeout) {
38857
+ clearTimeout(timeout);
38858
+ }
38840
38859
  }
38841
38860
  if (currentAssistantMessage) {
38842
38861
  break;
@@ -43232,7 +43251,9 @@ var agentSchema = providerModelSchema.extend({
43232
43251
  initialContext: z2.object({
43233
43252
  maxFileCount: z2.number().int().positive().optional(),
43234
43253
  excludes: z2.array(z2.string()).optional()
43235
- }).optional()
43254
+ }).optional(),
43255
+ retryCount: z2.number().int().min(0).optional(),
43256
+ requestTimeoutSeconds: z2.number().int().positive().optional()
43236
43257
  });
43237
43258
  var configSchema = z2.object({
43238
43259
  agent: z2.string().optional(),
@@ -43252,6 +43273,8 @@ var configSchema = z2.object({
43252
43273
  defaultParameters: z2.record(z2.string(), z2.any()).optional(),
43253
43274
  maxMessageCount: z2.number().int().positive().optional(),
43254
43275
  budget: z2.number().positive().optional(),
43276
+ retryCount: z2.number().int().min(0).optional(),
43277
+ requestTimeoutSeconds: z2.number().int().positive().optional(),
43255
43278
  scripts: z2.record(z2.string(), z2.string().or(z2.object({
43256
43279
  command: z2.string(),
43257
43280
  description: z2.string()
@@ -43534,64 +43557,49 @@ ${output}`);
43534
43557
  };
43535
43558
 
43536
43559
  // ../core/src/AiTool/generateProjectConfig.ts
43537
- var prompt4 = `You are an analyzer agent responsible for examining project files and generating appropriate polkacodes configuration. Your task is to:
43538
-
43539
- 1. Read and analyze the provided files using tool_read_file to understand:
43540
- - Build tools and package manager (e.g., bun, npm)
43541
- - Testing frameworks and patterns
43542
- - Code style tools and rules
43543
- - Project structure and conventions
43544
- - Common development workflows
43545
-
43546
- 2. Generate a YAML configuration that captures:
43547
- - scripts section based on package.json scripts and CI workflows. If applicable, generate following scripts:
43548
- - format: Format the code using a code formatter tool
43549
- - check: Check the code for errors using a linter tool
43550
- - test: Run tests using a test runner tool
43551
- - include other relevant scripts based on project conventions, tools, and patterns
43552
- - rules section based on project conventions, tools, and patterns
43553
- - excludeFiles section for sensitive files
43554
-
43555
- 3. Use tool_attempt_completion to return the final configuration in this format:
43556
-
43557
- <tool_attempt_completion>
43558
- <tool_parameter_result>
43559
- scripts:
43560
- test:
43561
- command: "bun test"
43562
- description: "Run tests with bun:test"
43563
- lint:
43564
- command: "biome check ."
43565
- description: "Check code style with Biome"
43566
-
43567
- rules:
43568
- - "Use \`bun\` as package manager"
43569
- - "Write tests using bun:test with snapshots"
43570
- - "Follow Biome code style"
43571
-
43572
- excludeFiles:
43573
- # 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
43574
43590
  - ".env"
43575
43591
  - ".env.*"
43576
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)
43577
43601
  </tool_parameter_result>
43578
43602
  </tool_attempt_completion>
43579
-
43580
- Focus on:
43581
- - Package manager and dependency management
43582
- - Testing frameworks and patterns
43583
- - Code style and linting rules
43584
- - File organization and naming conventions
43585
- - Build and development workflows
43586
- - Sensitive files that should not be committed:
43587
- - Environment files (.env*)
43588
- - Configuration files with potential secrets
43589
- - Generated files to exclude:
43590
- - Lock files from package managers
43591
- - Build artifacts and outputs
43592
- - Generated file that are not ignored by .gitignore
43593
-
43594
- The configuration should accurately reflect the project's structure, tools, and conventions.
43595
43603
  `;
43596
43604
  var generateProjectConfig_default = {
43597
43605
  name: "generateProjectConfig",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli-shared",
3
- "version": "0.8.26",
3
+ "version": "0.8.28",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",