@polka-codes/cli 0.9.90 → 0.9.91

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 CHANGED
@@ -75769,6 +75769,7 @@ import { randomUUID } from "node:crypto";
75769
75769
  import { existsSync as existsSync4 } from "node:fs";
75770
75770
  import { mkdir as mkdir2, readFile as readFile4, rename as rename2, writeFile as writeFile2 } from "node:fs/promises";
75771
75771
  import { dirname as dirname3, resolve as resolve5 } from "node:path";
75772
+ import { fileURLToPath } from "node:url";
75772
75773
 
75773
75774
  class FileLock {
75774
75775
  lockfilePath;
@@ -75875,7 +75876,24 @@ async function getSqlJs() {
75875
75876
  if (SqlJsInitPromise) {
75876
75877
  return SqlJsInitPromise;
75877
75878
  }
75878
- SqlJsInitPromise = import_sql.default({});
75879
+ const moduleDir = dirname3(fileURLToPath(import.meta.url));
75880
+ const candidates = [
75881
+ resolve5(moduleDir, "sql-wasm.wasm"),
75882
+ resolve5(moduleDir, "..", "dist", "sql-wasm.wasm"),
75883
+ resolve5(moduleDir, "..", "node_modules", "sql.js", "dist", "sql-wasm.wasm"),
75884
+ resolve5(moduleDir, "..", "..", "..", "node_modules", "sql.js", "dist", "sql-wasm.wasm"),
75885
+ resolve5(process.cwd(), "node_modules", "sql.js", "dist", "sql-wasm.wasm")
75886
+ ];
75887
+ SqlJsInitPromise = import_sql.default({
75888
+ locateFile: (file2) => {
75889
+ for (const candidate of candidates) {
75890
+ if (existsSync4(candidate)) {
75891
+ return candidate;
75892
+ }
75893
+ }
75894
+ return file2;
75895
+ }
75896
+ });
75879
75897
  SqlJs = await SqlJsInitPromise;
75880
75898
  return SqlJs;
75881
75899
  }
@@ -77730,15 +77748,15 @@ ${value}
77730
77748
  }
77731
77749
  function getReviewInstructions(params) {
77732
77750
  if (params.targetCommit) {
77733
- return `Review the changes in commit '${params.targetCommit}'. The gitDiff tool is NOT available for past commits. Use readFile to inspect the file contents and identify issues in the modified files listed in <file_status>.`;
77751
+ return `Review the changes in commit '${params.targetCommit}'. Use the gitDiff tool with the file parameter to inspect what changed in each file. Focus your review on the actual changes shown in the diff.`;
77734
77752
  }
77735
77753
  if (params.commitRange) {
77736
- return `Review the pull request. Use the gitDiff tool with commit range '${params.commitRange}' to inspect the actual code changes.`;
77754
+ return `Review the pull request or commit range '${params.commitRange}'. Use the gitDiff tool with the file parameter to inspect the actual code changes.`;
77737
77755
  }
77738
77756
  if (params.staged) {
77739
- return "Review the staged changes. Use the gitDiff tool with staged: true to inspect the actual code changes.";
77757
+ return "Review the staged changes. Use the gitDiff tool with the file parameter and staged: true to inspect the actual code changes.";
77740
77758
  }
77741
- return "Review the unstaged changes. Use the gitDiff tool to inspect the actual code changes.";
77759
+ return "Review the unstaged changes. Use the gitDiff tool with the file parameter to inspect the actual code changes.";
77742
77760
  }
77743
77761
  function formatReviewToolInput(params) {
77744
77762
  const fileList = params.changedFiles && params.changedFiles.length > 0 ? params.changedFiles.map((file2) => {
@@ -77777,18 +77795,20 @@ ${TOOL_USAGE_INSTRUCTION}
77777
77795
  - **Include**: Source code, config files, and template files.
77778
77796
  - **Exclude**: Lockfiles, build artifacts, test snapshots, binary/media files, data and fixtures and other generated files.
77779
77797
  3. **Inspect Changes**:
77780
- - When the \`gitDiff\` tool is available: Use it on one file at a time to see the exact changes. When reviewing pull requests, use the \`commitRange\` parameter provided in the review instructions.
77781
- - When the \`gitDiff\` tool is NOT available (reviewing past commits): Use \`readFile\` to inspect the file contents. You will not have access to the exact diff, so focus on reviewing the code for issues in the modified files listed in \`<file_status>\`.
77798
+ - The \`gitDiff\` tool is ALWAYS available for reviewing changes.
77799
+ - When reviewing pull requests or commit ranges: Use \`gitDiff\` with the file parameter to see exact changes.
77800
+ - When reviewing local changes: Use \`gitDiff\` with staged: true for staged changes, or without parameters for unstaged changes.
77801
+ - When reviewing a specific commit: Use \`gitDiff\` with the file parameter to see what changed in that commit.
77782
77802
  4. **Analyze and Review**: Analyze the code for issues. When using \`gitDiff\`, focus only on the modified lines (additions/deletions). Provide specific, actionable feedback with accurate line numbers.
77783
77803
 
77784
77804
  ## Critical Rules
77785
77805
 
77786
- - **Focus on Changes**: When using \`gitDiff\`, ONLY review the actual changes shown in the diff. Do not comment on existing, unmodified code. When \`gitDiff\` is not available, focus on the modified files listed in \`<file_status>\`.
77806
+ - **Focus on Changes**: When using \`gitDiff\`, ONLY review the actual changes shown in the diff. Do not comment on existing, unmodified code.
77787
77807
  - **Focus Scope**: Do not comment on overall project structure or architecture unless directly impacted by the changes in the diff.
77788
77808
  - **No Feature Requests**: Do not comment on missing features or functionality that are not part of this diff.
77789
- - **One File at a Time**: Review files individually using \`gitDiff\` (when available) with the specific file path, or \`readFile\` when reviewing past commits.
77790
- - **No Empty Diffs**: MUST NOT call \`gitDiff\` with an empty or omitted file parameter when the tool is available.
77791
- - **Accurate Line Numbers**: When using \`gitDiff\`, use the line numbers from the diff annotations (\`[Line N]\` for additions, \`[Line N removed]\` for deletions). When \`gitDiff\` is not available, use line numbers from \`readFile\` output.
77809
+ - **One File at a Time**: Review files individually using \`gitDiff\` with the specific file path.
77810
+ - **No Empty Diffs**: MUST NOT call \`gitDiff\` with an empty or omitted file parameter. Always specify a file path.
77811
+ - **Accurate Line Numbers**: When using \`gitDiff\`, use the line numbers from the diff annotations (\`[Line N]\` for additions, \`[Line N removed]\` for deletions).
77792
77812
  - **No Praise**: Provide only reviews for actual issues found. Do not include praise or positive feedback.
77793
77813
  - **Clear Reasoning**: For each issue, provide clear reasoning explaining why it's a problem and what the impact could be.
77794
77814
  - **Specific Advice**: Avoid generic advice. Provide concrete, actionable suggestions specific to the code being reviewed.
@@ -94005,9 +94025,9 @@ function createGitReadBinaryFile(commit2) {
94005
94025
  }
94006
94026
  };
94007
94027
  }
94008
- const result = await provider3.executeCommand(`git show ${quotedCommit}:${quotedUrl} | base64`, false);
94028
+ const result = await provider3.executeCommand(`git show ${quotedCommit}:${quotedUrl}`, false);
94009
94029
  if (result.exitCode === 0) {
94010
- const base64Data = result.stdout.replace(/\n/g, "");
94030
+ const base64Data = Buffer.from(result.stdout, "binary").toString("base64");
94011
94031
  return {
94012
94032
  success: true,
94013
94033
  message: {
@@ -94044,6 +94064,91 @@ function createGitAwareTools(commit2) {
94044
94064
  readBinaryFile: createGitReadBinaryFile(commit2)
94045
94065
  };
94046
94066
  }
94067
+ function createGitAwareDiff(commit2) {
94068
+ const toolInfo20 = {
94069
+ name: "git_diff",
94070
+ description: `Get the git diff for commit ${commit2}. Shows the exact changes introduced by this specific commit. Use this to inspect what changed in each file. Always specify a file path.`,
94071
+ parameters: exports_external.object({
94072
+ file: exports_external.string().describe("Get the diff for a specific file within the commit. This parameter is required.").meta({ usageValue: "File path here (required)" }),
94073
+ contextLines: exports_external.coerce.number().int().min(0).optional().default(5).describe("Number of context lines to include around changes.").meta({ usageValue: "Context lines count (optional)" }),
94074
+ includeLineNumbers: exports_external.preprocess((val) => {
94075
+ if (typeof val === "string") {
94076
+ const lower2 = val.toLowerCase();
94077
+ if (lower2 === "false")
94078
+ return false;
94079
+ if (lower2 === "true")
94080
+ return true;
94081
+ }
94082
+ return val;
94083
+ }, exports_external.boolean().optional().default(true)).describe("Annotate the diff with line numbers for additions and deletions.").meta({ usageValue: "true or false (optional)" })
94084
+ })
94085
+ };
94086
+ const handler20 = async (provider3, args) => {
94087
+ if (!provider3.executeCommand) {
94088
+ return {
94089
+ success: false,
94090
+ message: {
94091
+ type: "error-text",
94092
+ value: "Not possible to execute command."
94093
+ }
94094
+ };
94095
+ }
94096
+ const { file: file2, contextLines, includeLineNumbers } = toolInfo20.parameters.parse(args);
94097
+ const quotedCommit = quoteForShell(commit2);
94098
+ let command = `git show --no-color --format= -U${contextLines} ${quotedCommit}`;
94099
+ if (file2) {
94100
+ const quotedFile = quoteForShell(file2);
94101
+ command = `git show --no-color --format= -U${contextLines} ${quotedCommit} -- ${quotedFile}`;
94102
+ }
94103
+ try {
94104
+ const result = await provider3.executeCommand(command, false);
94105
+ if (result.exitCode === 0) {
94106
+ if (!result.stdout.trim()) {
94107
+ return {
94108
+ success: true,
94109
+ message: {
94110
+ type: "text",
94111
+ value: "No diff found."
94112
+ }
94113
+ };
94114
+ }
94115
+ let diffOutput = result.stdout;
94116
+ if (includeLineNumbers) {
94117
+ diffOutput = annotateDiffWithLineNumbers(diffOutput);
94118
+ }
94119
+ return {
94120
+ success: true,
94121
+ message: {
94122
+ type: "text",
94123
+ value: `<diff file="${file2 ?? "all"}">
94124
+ ${diffOutput}
94125
+ </diff>`
94126
+ }
94127
+ };
94128
+ }
94129
+ return {
94130
+ success: false,
94131
+ message: {
94132
+ type: "error-text",
94133
+ value: `\`${command}\` exited with code ${result.exitCode}:
94134
+ ${result.stderr}`
94135
+ }
94136
+ };
94137
+ } catch (error48) {
94138
+ return {
94139
+ success: false,
94140
+ message: {
94141
+ type: "error-text",
94142
+ value: error48 instanceof Error ? error48.message : String(error48)
94143
+ }
94144
+ };
94145
+ }
94146
+ };
94147
+ return {
94148
+ ...toolInfo20,
94149
+ handler: handler20
94150
+ };
94151
+ }
94047
94152
  var init_git_file_tools = __esm(() => {
94048
94153
  init_zod();
94049
94154
  });
@@ -94336,10 +94441,10 @@ var reviewWorkflow = async (input, context) => {
94336
94441
  return { overview: "No changes to review.", specificReviews: [] };
94337
94442
  }
94338
94443
  const targetCommit = extractTargetCommit(range, pr2);
94339
- const isReviewingCommit = targetCommit !== null;
94340
- const finalChangeInfo = targetCommit ? { ...changeInfo, targetCommit } : changeInfo;
94341
- const fileTools = isReviewingCommit && targetCommit ? createGitAwareTools(targetCommit) : { readFile: readFile_default, listFiles: listFiles_default, readBinaryFile: readBinaryFile_default };
94342
- const reviewTools = isReviewingCommit ? [fileTools.readFile, fileTools.readBinaryFile, fileTools.listFiles] : [readFile_default, readBinaryFile_default, searchFiles_default, listFiles_default, gitDiff_default];
94444
+ const isRange = range && range.includes("..");
94445
+ const finalChangeInfo = targetCommit && !isRange ? { ...changeInfo, targetCommit } : changeInfo;
94446
+ const fileTools = targetCommit && !isRange ? createGitAwareTools(targetCommit) : { readFile: readFile_default, listFiles: listFiles_default, readBinaryFile: readBinaryFile_default };
94447
+ const reviewTools = targetCommit && !isRange ? [fileTools.readFile, fileTools.readBinaryFile, fileTools.listFiles, createGitAwareDiff(targetCommit)] : [readFile_default, readBinaryFile_default, searchFiles_default, listFiles_default, gitDiff_default];
94343
94448
  const result = await step("review", async () => {
94344
94449
  const defaultContext = await getDefaultContext("review");
94345
94450
  const memoryContext = await tools3.getMemoryContext();
@@ -112131,7 +112236,7 @@ var {
112131
112236
  Help
112132
112237
  } = import__.default;
112133
112238
  // package.json
112134
- var version = "0.9.90";
112239
+ var version = "0.9.91";
112135
112240
 
112136
112241
  // src/commands/agent.ts
112137
112242
  init_src();
@@ -115346,7 +115451,7 @@ class TaskHistory {
115346
115451
  return r2.actualTime === 0 ? 0 : 100;
115347
115452
  }
115348
115453
  return Math.abs((r2.estimatedTime - r2.actualTime) / r2.estimatedTime) * 100;
115349
- }).filter((e2) => !isNaN(e2));
115454
+ }).filter((e2) => !Number.isNaN(e2));
115350
115455
  const avgErrorPercentage = errorPercentages.reduce((sum, e2) => sum + e2, 0) / errorPercentages.length;
115351
115456
  return {
115352
115457
  averageError: avgError,
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.9.90",
3
+ "version": "0.9.91",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",
@@ -14,7 +14,8 @@
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 && bun run build:copy-wasm",
18
+ "build:copy-wasm": "mkdir -p dist && cp ../../node_modules/sql.js/dist/sql-wasm.wasm dist/"
18
19
  },
19
20
  "dependencies": {
20
21
  "@ai-sdk/anthropic": "^2.0.57",