@polka-codes/cli 0.9.10 → 0.9.12

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 +118 -113
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -39790,7 +39790,7 @@ var {
39790
39790
  Help
39791
39791
  } = import__.default;
39792
39792
  // package.json
39793
- var version = "0.9.10";
39793
+ var version = "0.9.12";
39794
39794
 
39795
39795
  // ../../node_modules/@inquirer/core/dist/esm/lib/key.js
39796
39796
  var isUpKey = (key) => key.name === "up" || key.name === "k" || key.ctrl && key.name === "p";
@@ -77185,6 +77185,7 @@ You are the **Architect** agent, responsible for:
77185
77185
  4. **Accuracy** - Ensure conclusions are verifiable.
77186
77186
  5. **Clarity** - Present information in a structured format.
77187
77187
  6. **Minimal Queries** - Ask questions only when truly needed.
77188
+ 7. **Completion** - Only use the \`attemptCompletion\` tool if the user's request has been fully satisfied and no coding tasks need to be delegated to the Coder agent.
77188
77189
 
77189
77190
  ## Steps
77190
77191
  1. **Analyze Task** - Capture goals, constraints, and success criteria.
@@ -77198,7 +77199,7 @@ You are the **Architect** agent, responsible for:
77198
77199
  6. **Handover/Delegate**
77199
77200
  - If the plan consists of a single self-contained step, hand it over as one task.
77200
77201
  - If multiple steps are required, break them into numbered tasks to delegate to the **Coder** agent.
77201
- - Provide all necessary context, implementation plan, file references, and clarifications for successful execution.
77202
+ - When handing over or delegating, you MUST provide the full implementation plan. Include all necessary context, file references, and clarifications for successful execution.
77202
77203
 
77203
77204
  ${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
77204
77205
  ${capabilities(toolNamePrefix)}
@@ -84994,6 +84995,7 @@ function createOpenAI(options = {}) {
84994
84995
  return provider2;
84995
84996
  }
84996
84997
  var openai = createOpenAI();
84998
+
84997
84999
  // ../../node_modules/@openrouter/ai-sdk-provider/dist/index.mjs
84998
85000
  var __defProp3 = Object.defineProperty;
84999
85001
  var __defProps = Object.defineProperties;
@@ -96901,7 +96903,7 @@ function toJSONSchema3(input, _params) {
96901
96903
  gen2.process(schema);
96902
96904
  }
96903
96905
  const schemas5 = {};
96904
- const external4 = {
96906
+ const external3 = {
96905
96907
  registry: input,
96906
96908
  uri: _params?.uri,
96907
96909
  defs
@@ -96910,7 +96912,7 @@ function toJSONSchema3(input, _params) {
96910
96912
  const [key2, schema] = entry;
96911
96913
  schemas5[key2] = gen2.emit(schema, {
96912
96914
  ..._params,
96913
- external: external4
96915
+ external: external3
96914
96916
  });
96915
96917
  }
96916
96918
  if (Object.keys(defs).length > 0) {
@@ -109587,7 +109589,9 @@ class Runner {
109587
109589
  ret += `
109588
109590
  <file_content path="${file4}">${fileContent}</file_content>`;
109589
109591
  } catch (error120) {
109590
- console.warn(`Failed to read file: ${file4}`, error120);
109592
+ if (options.verbose > 0) {
109593
+ console.log(`Failed to read file: ${file4}`, error120);
109594
+ }
109591
109595
  unreadableFiles.push(file4);
109592
109596
  }
109593
109597
  }
@@ -110348,7 +110352,6 @@ function ora(options) {
110348
110352
 
110349
110353
  // src/commands/commit.ts
110350
110354
  var commitCommand = new Command("commit").description("Create a commit with AI-generated message").option("-a, --all", "Stage all files before committing").argument("[message]", "Optional context for the commit message generation").action(async (message, localOptions, command) => {
110351
- const spinner = ora("Gathering information...").start();
110352
110355
  const options = command.parent?.opts() ?? {};
110353
110356
  const { providerConfig, config: config6 } = parseOptions(options);
110354
110357
  const commandConfig = providerConfig.getConfigForCommand("commit");
@@ -110358,6 +110361,7 @@ var commitCommand = new Command("commit").description("Create a commit with AI-g
110358
110361
  }
110359
110362
  console.log("Provider:", commandConfig.provider);
110360
110363
  console.log("Model:", commandConfig.model);
110364
+ const spinner = ora("Gathering information...").start();
110361
110365
  const usage = new UsageMeter(import_lodash6.merge(prices_default, config6.prices ?? {}));
110362
110366
  try {
110363
110367
  const status = execSync("git status --porcelain").toString();
@@ -110384,10 +110388,6 @@ var commitCommand = new Command("commit").description("Create a commit with AI-g
110384
110388
  const diff = execSync("git diff --cached -U50").toString();
110385
110389
  spinner.text = "Generating commit message...";
110386
110390
  const llm = getModel(commandConfig);
110387
- const _schema = exports_external2.object({
110388
- reasoning: exports_external2.string().describe("Reasoning if any"),
110389
- message: exports_external2.string().describe("The generated commit message")
110390
- });
110391
110391
  const commitMessage = await generateGitCommitMessage(llm, { diff, context: message }, usage);
110392
110392
  usage.printUsage();
110393
110393
  spinner.succeed("Commit message generated");
@@ -110748,6 +110748,89 @@ var prCommand = new Command("pr").description("Create a GitHub pull request").ar
110748
110748
  import { execSync as execSync3 } from "node:child_process";
110749
110749
  import { Console } from "node:console";
110750
110750
  var import_lodash9 = __toESM(require_lodash(), 1);
110751
+
110752
+ // src/commands/task.ts
110753
+ var readStdin = async (timeoutMs = 30000) => {
110754
+ if (process.stdin.isTTY) {
110755
+ return "";
110756
+ }
110757
+ return new Promise((resolve3, reject) => {
110758
+ let input = "";
110759
+ const cleanup = () => {
110760
+ if (timeoutId)
110761
+ clearTimeout(timeoutId);
110762
+ process.stdin.removeAllListeners();
110763
+ process.stdin.resume();
110764
+ };
110765
+ const timeoutId = setTimeout(() => {
110766
+ cleanup();
110767
+ reject(new Error("Stdin read timeout"));
110768
+ }, timeoutMs);
110769
+ process.stdin.on("data", (chunk) => {
110770
+ input += chunk.toString();
110771
+ });
110772
+ process.stdin.on("end", () => {
110773
+ cleanup();
110774
+ if (!input) {
110775
+ reject(new Error("Empty stdin input"));
110776
+ return;
110777
+ }
110778
+ resolve3(input);
110779
+ });
110780
+ process.stdin.on("error", (err) => {
110781
+ cleanup();
110782
+ reject(err);
110783
+ });
110784
+ });
110785
+ };
110786
+ async function runTask(taskArg, _options, command) {
110787
+ let task = taskArg;
110788
+ if (!task) {
110789
+ try {
110790
+ const stdinInput = await readStdin();
110791
+ if (stdinInput) {
110792
+ task = stdinInput;
110793
+ } else {
110794
+ runChat(command.opts());
110795
+ return;
110796
+ }
110797
+ } catch (error120) {
110798
+ console.error("Error reading stdin:", error120);
110799
+ process.exit(1);
110800
+ }
110801
+ }
110802
+ const { config: config6, providerConfig, verbose, maxMessageCount, budget, agent } = parseOptions(command.opts());
110803
+ const { provider: provider3, model, parameters } = providerConfig.getConfigForAgent(agent) ?? {};
110804
+ if (!provider3 || !model) {
110805
+ console.error("Provider and model must be configured");
110806
+ process.exit(1);
110807
+ }
110808
+ console.log("Provider:", provider3);
110809
+ console.log("Model:", model);
110810
+ for (const [key2, value] of Object.entries(parameters ?? {})) {
110811
+ console.log(`${key2}:`, value);
110812
+ }
110813
+ const runner = new Runner({
110814
+ providerConfig,
110815
+ config: config6,
110816
+ maxMessageCount,
110817
+ budget,
110818
+ interactive: process.stdin.isTTY,
110819
+ verbose
110820
+ });
110821
+ const sigintHandler = () => {
110822
+ runner.abort();
110823
+ console.log();
110824
+ runner.printUsage();
110825
+ process.exit(0);
110826
+ };
110827
+ process.on("SIGINT", sigintHandler);
110828
+ await runner.startTask(task, agent);
110829
+ process.off("SIGINT", sigintHandler);
110830
+ runner.printUsage();
110831
+ }
110832
+
110833
+ // src/commands/review.ts
110751
110834
  function parseGitStatus(statusOutput) {
110752
110835
  const statusLines = statusOutput.split(`
110753
110836
  `).filter((line) => line);
@@ -110868,9 +110951,9 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
110868
110951
  };
110869
110952
  try {
110870
110953
  if (options.pr) {
110871
- await reviewPR(options.pr, spinner, sharedAiOptions, options.json);
110954
+ await reviewPR(options.pr, spinner, sharedAiOptions, options.json, command);
110872
110955
  } else {
110873
- await reviewLocal(spinner, sharedAiOptions, options.json);
110956
+ await reviewLocal(spinner, sharedAiOptions, options.json, command);
110874
110957
  }
110875
110958
  } catch (error120) {
110876
110959
  spinner.fail(`Error reviewing: ${error120 instanceof Error ? error120.message : String(error120)}`);
@@ -110881,7 +110964,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
110881
110964
  usage.printUsage();
110882
110965
  }
110883
110966
  });
110884
- async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput) {
110967
+ async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput, command) {
110885
110968
  const prNumberMatch = prIdentifier.match(/\d+$/);
110886
110969
  if (!prNumberMatch) {
110887
110970
  spinner.fail("Invalid PR number or URL.");
@@ -110928,13 +111011,9 @@ async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput) {
110928
111011
  changedFiles
110929
111012
  });
110930
111013
  spinner.succeed("Review generated successfully");
110931
- if (isJsonOutput) {
110932
- console.log(JSON.stringify(result, null, 2));
110933
- } else {
110934
- console.log(formatReviewForConsole(result));
110935
- }
111014
+ await handleReviewResult(result, isJsonOutput, command);
110936
111015
  }
110937
- async function reviewLocal(spinner, sharedAiOptions, isJsonOutput) {
111016
+ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput, command) {
110938
111017
  const gitStatus = execSync3("git status --porcelain=v1", { encoding: "utf-8" });
110939
111018
  const statusLines = gitStatus.split(`
110940
111019
  `).filter((line) => line);
@@ -110950,11 +111029,7 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput) {
110950
111029
  changedFiles: stagedFiles
110951
111030
  });
110952
111031
  spinner.succeed("Review generated successfully");
110953
- if (isJsonOutput) {
110954
- console.log(JSON.stringify(result2, null, 2));
110955
- } else {
110956
- console.log(formatReviewForConsole(result2));
110957
- }
111032
+ await handleReviewResult(result2, isJsonOutput, command);
110958
111033
  return;
110959
111034
  }
110960
111035
  if (hasUnstagedChanges) {
@@ -110966,11 +111041,7 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput) {
110966
111041
  changedFiles: unstagedFiles
110967
111042
  });
110968
111043
  spinner.succeed("Review generated successfully");
110969
- if (isJsonOutput) {
110970
- console.log(JSON.stringify(result2, null, 2));
110971
- } else {
110972
- console.log(formatReviewForConsole(result2));
110973
- }
111044
+ await handleReviewResult(result2, isJsonOutput, command);
110974
111045
  return;
110975
111046
  }
110976
111047
  spinner.text = "No local changes detected. Falling back to branch diff...";
@@ -111004,10 +111075,25 @@ async function reviewLocal(spinner, sharedAiOptions, isJsonOutput) {
111004
111075
  changedFiles: branchChangedFiles
111005
111076
  });
111006
111077
  spinner.succeed("Review generated successfully");
111078
+ await handleReviewResult(result, isJsonOutput, command);
111079
+ }
111080
+ async function handleReviewResult(result, isJsonOutput, command) {
111007
111081
  if (isJsonOutput) {
111008
111082
  console.log(JSON.stringify(result, null, 2));
111009
- } else {
111010
- console.log(formatReviewForConsole(result));
111083
+ return;
111084
+ }
111085
+ const formatted = formatReviewForConsole(result);
111086
+ console.log(formatted);
111087
+ if (process.stdin.isTTY && result.specificReviews.length > 0) {
111088
+ const shouldRunTask = await esm_default2({
111089
+ message: "Do you wish polka-codes to address the review results?"
111090
+ });
111091
+ if (shouldRunTask) {
111092
+ const taskInstruction = `please address the review result:
111093
+
111094
+ ${formatted}`;
111095
+ await runTask(taskInstruction, {}, command);
111096
+ }
111011
111097
  }
111012
111098
  }
111013
111099
  function formatReviewForConsole(output) {
@@ -111021,7 +111107,7 @@ ${output.overview}`;
111021
111107
  `;
111022
111108
  for (const item of output.specificReviews) {
111023
111109
  formatted += `
111024
- **${item.file}:${item.lines}**
111110
+ - ${item.file}#${item.lines}
111025
111111
 
111026
111112
  ${item.review}
111027
111113
  `;
@@ -111044,87 +111130,6 @@ function printChangedFiles(changedFiles, spinner, isJsonOutput) {
111044
111130
  spinner.start();
111045
111131
  }
111046
111132
 
111047
- // src/commands/task.ts
111048
- var readStdin = async (timeoutMs = 30000) => {
111049
- if (process.stdin.isTTY) {
111050
- return "";
111051
- }
111052
- return new Promise((resolve3, reject) => {
111053
- let input = "";
111054
- const cleanup = () => {
111055
- if (timeoutId)
111056
- clearTimeout(timeoutId);
111057
- process.stdin.removeAllListeners();
111058
- process.stdin.resume();
111059
- };
111060
- const timeoutId = setTimeout(() => {
111061
- cleanup();
111062
- reject(new Error("Stdin read timeout"));
111063
- }, timeoutMs);
111064
- process.stdin.on("data", (chunk) => {
111065
- input += chunk.toString();
111066
- });
111067
- process.stdin.on("end", () => {
111068
- cleanup();
111069
- if (!input) {
111070
- reject(new Error("Empty stdin input"));
111071
- return;
111072
- }
111073
- resolve3(input);
111074
- });
111075
- process.stdin.on("error", (err) => {
111076
- cleanup();
111077
- reject(err);
111078
- });
111079
- });
111080
- };
111081
- async function runTask(taskArg, _options, command) {
111082
- let task = taskArg;
111083
- if (!task) {
111084
- try {
111085
- const stdinInput = await readStdin();
111086
- if (stdinInput) {
111087
- task = stdinInput;
111088
- } else {
111089
- runChat(command.opts());
111090
- return;
111091
- }
111092
- } catch (error120) {
111093
- console.error("Error reading stdin:", error120);
111094
- process.exit(1);
111095
- }
111096
- }
111097
- const { config: config6, providerConfig, verbose, maxMessageCount, budget, agent } = parseOptions(command.opts());
111098
- const { provider: provider3, model, parameters } = providerConfig.getConfigForAgent(agent) ?? {};
111099
- if (!provider3 || !model) {
111100
- console.error("Provider and model must be configured");
111101
- process.exit(1);
111102
- }
111103
- console.log("Provider:", provider3);
111104
- console.log("Model:", model);
111105
- for (const [key2, value] of Object.entries(parameters ?? {})) {
111106
- console.log(`${key2}:`, value);
111107
- }
111108
- const runner = new Runner({
111109
- providerConfig,
111110
- config: config6,
111111
- maxMessageCount,
111112
- budget,
111113
- interactive: process.stdin.isTTY,
111114
- verbose
111115
- });
111116
- const sigintHandler = () => {
111117
- runner.abort();
111118
- console.log();
111119
- runner.printUsage();
111120
- process.exit(0);
111121
- };
111122
- process.on("SIGINT", sigintHandler);
111123
- await runner.startTask(task, agent);
111124
- process.off("SIGINT", sigintHandler);
111125
- runner.printUsage();
111126
- }
111127
-
111128
111133
  // src/index.ts
111129
111134
  var program2 = new Command;
111130
111135
  program2.name("polka").description("Polka Codes CLI").version(version);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.9.10",
3
+ "version": "0.9.12",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",