@polka-codes/cli 0.9.28 → 0.9.29

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 +27 -25
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -58608,7 +58608,7 @@ var {
58608
58608
  Help
58609
58609
  } = import__.default;
58610
58610
  // package.json
58611
- var version = "0.9.28";
58611
+ var version = "0.9.29";
58612
58612
 
58613
58613
  // src/commands/chat.ts
58614
58614
  import { readFile as readFile3 } from "node:fs/promises";
@@ -83089,8 +83089,9 @@ var makeAgentStepSpecHandler = (getModelFn) => ({
83089
83089
  return {
83090
83090
  ...step,
83091
83091
  async run(input, context, resumedState) {
83092
+ const logger = context.logger ?? console;
83092
83093
  if (context.verbose && context.verbose >= 1) {
83093
- console.log(`[agent-step] Running agent step '${step.id}' with input:`, input);
83094
+ logger.log(`[agent-step] Running agent step '${step.id}' with input:`, input);
83094
83095
  }
83095
83096
  try {
83096
83097
  const model = await getModelFn(step, context);
@@ -83112,7 +83113,7 @@ var makeAgentStepSpecHandler = (getModelFn) => ({
83112
83113
  throw new Error(`Unknown agent: ${agentName}`);
83113
83114
  }
83114
83115
  if (context.verbose && context.verbose >= 1) {
83115
- console.log(`[agent-step] Using agent: ${agentName}`);
83116
+ logger.log(`[agent-step] Using agent: ${agentName}`);
83116
83117
  }
83117
83118
  const agentOptions = {
83118
83119
  ai: model,
@@ -83132,7 +83133,7 @@ var makeAgentStepSpecHandler = (getModelFn) => ({
83132
83133
  throw new Error("No system prompt specified for the agent step.");
83133
83134
  }
83134
83135
  if (context.verbose && context.verbose >= 1) {
83135
- console.log(`[agent-step] Using generic WorkflowAgent`);
83136
+ logger.log(`[agent-step] Using generic WorkflowAgent`);
83136
83137
  }
83137
83138
  const systemPrompt = resolveTemplatedString(step.systemPrompt, input);
83138
83139
  return new WorkflowAgent("agent", model, {
@@ -83170,11 +83171,11 @@ var makeAgentStepSpecHandler = (getModelFn) => ({
83170
83171
  }
83171
83172
  }
83172
83173
  if (context.verbose && context.verbose >= 1) {
83173
- console.log(`[agent-step] Starting agent with content:`, JSON.stringify(combinedContentParts, null, 2));
83174
+ logger.log(`[agent-step] Starting agent with content:`, JSON.stringify(combinedContentParts, null, 2));
83174
83175
  }
83175
83176
  const exitReason = await agent.start(combinedContentParts);
83176
83177
  if (context.verbose && context.verbose >= 1) {
83177
- console.log(`[agent-step] Agent exited with reason:`, exitReason);
83178
+ logger.log(`[agent-step] Agent exited with reason:`, exitReason);
83178
83179
  }
83179
83180
  const handleExitReason = (reason) => {
83180
83181
  switch (reason.type) {
@@ -83296,15 +83297,16 @@ var builder = () => {
83296
83297
  };
83297
83298
  // ../core/src/workflow/runStep.ts
83298
83299
  var runStep = async (step, input, context, resumedState, allOutputs) => {
83300
+ const logger = context.logger ?? console;
83299
83301
  if (context.verbose && context.verbose >= 1) {
83300
- console.log(`[workflow] running step: ${step.id}`);
83301
- console.log(`[workflow] input: ${JSON.stringify(input, null, 2)}`);
83302
+ logger.log(`[workflow] running step: ${step.id}`);
83303
+ logger.log(`[workflow] input: ${JSON.stringify(input, null, 2)}`);
83302
83304
  }
83303
83305
  try {
83304
83306
  const validatedInput = step.inputSchema?.parse(input) ?? input;
83305
83307
  const result = await step.run({ ...validatedInput, $: allOutputs }, context, resumedState);
83306
83308
  if (context.verbose && context.verbose >= 1) {
83307
- console.log(`[workflow] step result: ${step.id}`, JSON.stringify(result, null, 2));
83309
+ logger.log(`[workflow] step result: ${step.id}`, JSON.stringify(result, null, 2));
83308
83310
  }
83309
83311
  if (result.type === "success") {
83310
83312
  const validatedOutput = step.outputSchema?.parse(result.output) ?? result.output;
@@ -83316,7 +83318,7 @@ var runStep = async (step, input, context, resumedState, allOutputs) => {
83316
83318
  return result;
83317
83319
  } catch (error43) {
83318
83320
  if (context.verbose && context.verbose >= 1) {
83319
- console.error(`[workflow] step error: ${step.id}`, error43);
83321
+ logger.error(`[workflow] step error: ${step.id}`, error43);
83320
83322
  }
83321
83323
  return { type: "error", error: error43 };
83322
83324
  }
@@ -101973,7 +101975,7 @@ function parseOptions(options, cwdArg, home = os2.homedir(), env2 = getEnv()) {
101973
101975
  import_lodash4.set(config4, ["providers", "openrouter" /* OpenRouter */, "apiKey"], env2.OPENROUTER_API_KEY);
101974
101976
  }
101975
101977
  if (env2.OPENAI_API_KEY) {
101976
- import_lodash4.set(config4, ["providers", "ollama" /* Ollama */, "apiKey"], env2.OPENAI_API_KEY);
101978
+ import_lodash4.set(config4, ["providers", "openai" /* OpenAI */, "apiKey"], env2.OPENAI_API_KEY);
101977
101979
  }
101978
101980
  const providerConfig = new ApiProviderConfig({
101979
101981
  defaultProvider,
@@ -104104,17 +104106,14 @@ function parseGitDiffNameStatus(diffOutput) {
104104
104106
  return { path, status: statusDescription };
104105
104107
  });
104106
104108
  }
104107
- function printChangedFiles(changedFiles, spinner, isJsonOutput) {
104109
+ function printChangedFiles(changedFiles, spinner, logger) {
104108
104110
  if (changedFiles.length === 0) {
104109
104111
  return;
104110
104112
  }
104111
104113
  spinner.stop();
104112
- const stream = isJsonOutput ? process.stderr : process.stdout;
104113
- const log = (message) => stream.write(`${message}
104114
- `);
104115
- log("Changed files:");
104114
+ logger.log("Changed files:");
104116
104115
  for (const file2 of changedFiles) {
104117
- log(`- ${file2.status}: ${file2.path}`);
104116
+ logger.log(`- ${file2.status}: ${file2.path}`);
104118
104117
  }
104119
104118
  spinner.start();
104120
104119
  }
@@ -104225,6 +104224,7 @@ var getChangeInfo = {
104225
104224
  type: "custom",
104226
104225
  run: async (input, context, _resumedState) => {
104227
104226
  const { pr, json: json2 } = input;
104227
+ const logger = context.logger ?? console;
104228
104228
  context.json = json2;
104229
104229
  const {
104230
104230
  ui: { spinner }
@@ -104245,7 +104245,7 @@ var getChangeInfo = {
104245
104245
  spinner.text = `Checking out PR #${prNumber}...`;
104246
104246
  execSync3(`gh pr checkout ${prNumber}`, { stdio: "pipe" });
104247
104247
  } catch (error43) {
104248
- console.error(error43);
104248
+ logger.error(error43);
104249
104249
  throw new Error(`Error checking out PR #${prNumber}. Make sure the PR number is correct and you have access to the repository.`);
104250
104250
  }
104251
104251
  spinner.text = "Fetching pull request details...";
@@ -104263,9 +104263,9 @@ var getChangeInfo = {
104263
104263
  });
104264
104264
  changedFiles = parseGitDiffNameStatus(diffNameStatus);
104265
104265
  } catch (_error) {
104266
- console.warn("Warning: Could not retrieve file changes list");
104266
+ logger.warn("Warning: Could not retrieve file changes list");
104267
104267
  }
104268
- printChangedFiles(changedFiles, spinner, json2);
104268
+ printChangedFiles(changedFiles, spinner, logger);
104269
104269
  changeInfo = {
104270
104270
  commitRange: `${prDetails.baseRefOid}...HEAD`,
104271
104271
  pullRequestTitle: prDetails.title,
@@ -104281,7 +104281,7 @@ var getChangeInfo = {
104281
104281
  if (hasLocalChanges) {
104282
104282
  const hasStagedChanges = statusLines.some((line) => line[0] !== " " && line[0] !== "?");
104283
104283
  const changedFiles = parseGitStatus(gitStatus);
104284
- printChangedFiles(changedFiles, spinner, json2);
104284
+ printChangedFiles(changedFiles, spinner, logger);
104285
104285
  changeInfo = {
104286
104286
  staged: hasStagedChanges,
104287
104287
  changedFiles
@@ -104310,9 +104310,9 @@ var getChangeInfo = {
104310
104310
  const diffNameStatus = execSync3(`git diff --name-status --no-color ${defaultBranch}...${currentBranch}`, { encoding: "utf-8" });
104311
104311
  branchChangedFiles = parseGitDiffNameStatus(diffNameStatus);
104312
104312
  } catch (_error) {
104313
- console.warn("Warning: Could not retrieve file changes list");
104313
+ logger.warn("Warning: Could not retrieve file changes list");
104314
104314
  }
104315
- printChangedFiles(branchChangedFiles, spinner, json2);
104315
+ printChangedFiles(branchChangedFiles, spinner, logger);
104316
104316
  changeInfo = {
104317
104317
  commitRange: `${defaultBranch}...${currentBranch}`,
104318
104318
  changedFiles: branchChangedFiles
@@ -104369,6 +104369,7 @@ var handleResult2 = {
104369
104369
  run: async (input, context, _resumedState) => {
104370
104370
  const { overview, specificReviews } = input;
104371
104371
  const json2 = context.json;
104372
+ const logger = context.logger ?? console;
104372
104373
  const {
104373
104374
  ui: { spinner }
104374
104375
  } = context;
@@ -104384,7 +104385,7 @@ var handleResult2 = {
104384
104385
  return { type: "success", output: { shouldRunTask: false } };
104385
104386
  }
104386
104387
  const formatted = formatReviewForConsole(reviewResult);
104387
- console.log(formatted);
104388
+ logger.log(formatted);
104388
104389
  let shouldRunTask = false;
104389
104390
  if (process.stdin.isTTY && reviewResult.specificReviews.length > 0) {
104390
104391
  try {
@@ -104587,7 +104588,8 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
104587
104588
  provider: toolProvider,
104588
104589
  parameters: parentOptions,
104589
104590
  verbose,
104590
- agentCallback: onEvent
104591
+ agentCallback: onEvent,
104592
+ logger: customConsole
104591
104593
  };
104592
104594
  const input = { json: options.json, ...options.pr && { pr: options.pr } };
104593
104595
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.9.28",
3
+ "version": "0.9.29",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",