@weareikko/code-review 0.9.4 → 0.9.5

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.
@@ -2,7 +2,7 @@ import { mkdir, readFile, readdir, realpath, rename, rm, unlink, writeFile } fro
2
2
  import { dirname, join, relative, resolve, sep } from "node:path";
3
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
4
  import nodeFs, { existsSync, readFileSync } from "node:fs";
5
- import { getEnvApiKey, getModel } from "@earendil-works/pi-ai";
5
+ import { getEnvApiKey, streamSimple } from "@earendil-works/pi-ai/compat";
6
6
  import { createHash, randomUUID } from "node:crypto";
7
7
  import { homedir } from "node:os";
8
8
  import { parse } from "yaml";
@@ -11,6 +11,7 @@ import { promisify } from "node:util";
11
11
  import { tracingChannel } from "node:diagnostics_channel";
12
12
  import { performance } from "node:perf_hooks";
13
13
  import { Agent } from "@earendil-works/pi-agent-core";
14
+ import { getBuiltinModel } from "@earendil-works/pi-ai/providers/all";
14
15
  import { createReadOnlyTools } from "@earendil-works/pi-coding-agent";
15
16
  import { createTwoFilesPatch } from "diff";
16
17
  import * as git from "isomorphic-git";
@@ -1389,7 +1390,7 @@ function buildSummaryBody(summary, costFooter, options = {}) {
1389
1390
  return `${withFooter}\n\n${buildSummaryHistoryBlock(historyEntries)}`;
1390
1391
  }
1391
1392
  function buildReviewedCommitFooter(commitSha) {
1392
- return `Reviewed by ${PRODUCT_LINK} v0.9.4 for commit ${commitSha}.`;
1393
+ return `Reviewed by ${PRODUCT_LINK} v0.9.5 for commit ${commitSha}.`;
1393
1394
  }
1394
1395
  function extractReviewedCommitSha(body) {
1395
1396
  return REVIEWED_COMMIT_FOOTER_PATTERN.exec(body)?.[1] ?? null;
@@ -3961,6 +3962,26 @@ var SEVERITY_RULE = {
3961
3962
  CRITICAL: "- Only report CRITICAL issues — skip WARN and INFO"
3962
3963
  };
3963
3964
  var exec = promisify(execFile);
3965
+ /**
3966
+ * Stream function for the reviewer agent.
3967
+ *
3968
+ * pi-ai >=0.82 requires an explicit stream function (earlier versions built one
3969
+ * internally from model + getApiKey); `streamSimple` is the drop-in. Critically,
3970
+ * 0.83 also moved cloudflare-ai-gateway base-URL substitution — the
3971
+ * `{CLOUDFLARE_ACCOUNT_ID}` / `{CLOUDFLARE_GATEWAY_ID}` placeholders — from a
3972
+ * direct `process.env` read to an explicit `env` on the stream options. Without
3973
+ * threading `env` through, the gateway URL keeps its literal placeholders and
3974
+ * every request fails with Cloudflare 401 2035 ("Invalid request path"). Passing
3975
+ * `env` is harmless for providers whose base URL has no placeholders.
3976
+ *
3977
+ * `stream` is injectable so the env threading can be unit-tested without a live call.
3978
+ */
3979
+ function createReviewStreamFn(stream = streamSimple) {
3980
+ return (model, context, options) => stream(model, context, {
3981
+ ...options,
3982
+ env: process.env
3983
+ });
3984
+ }
3964
3985
  function defaultCreateAgent(params) {
3965
3986
  return new Agent({
3966
3987
  initialState: {
@@ -3969,7 +3990,8 @@ function defaultCreateAgent(params) {
3969
3990
  tools: params.tools,
3970
3991
  thinkingLevel: params.thinkingLevel
3971
3992
  },
3972
- getApiKey: params.getApiKey
3993
+ getApiKey: params.getApiKey,
3994
+ streamFn: createReviewStreamFn()
3973
3995
  });
3974
3996
  }
3975
3997
  async function findGitRoot(cwd) {
@@ -4447,7 +4469,7 @@ function resolveModel(modelString, baseUrl, maxTokens) {
4447
4469
  const { provider, modelId } = splitModel(modelString);
4448
4470
  if (provider === void 0 || modelId === void 0) throw new ReviewerError(`Invalid model format "${modelString}". Expected "provider/modelId" (e.g. "anthropic/claude-sonnet-4-5").`);
4449
4471
  if (provider === "ollama") return buildOllamaModel(modelId, baseUrl || "http://localhost:11434/v1", maxTokens);
4450
- const model = getModel(provider, modelId);
4472
+ const model = getBuiltinModel(provider, modelId);
4451
4473
  if (!model) throw new ReviewerError(`Unknown model "${modelString}".`, { hint: `Check that "${provider}" is a valid provider and "${modelId}" is a registered model ID.` });
4452
4474
  if (baseUrl || maxTokens > 0) return {
4453
4475
  ...model,
@@ -5616,7 +5638,7 @@ async function loadDefaultRuntime() {
5616
5638
  const [sdkNode, resources, semconv] = modules;
5617
5639
  const serviceResource = resources.resourceFromAttributes({
5618
5640
  [semconv.ATTR_SERVICE_NAME ?? "service.name"]: SERVICE_NAME,
5619
- [semconv.ATTR_SERVICE_VERSION ?? "service.version"]: "0.9.4"
5641
+ [semconv.ATTR_SERVICE_VERSION ?? "service.version"]: "0.9.5"
5620
5642
  });
5621
5643
  applyOtelExporterDefaults(process.env);
5622
5644
  const sdk = new sdkNode.NodeSDK({ resource: resources.defaultResource().merge(serviceResource) });
@@ -6088,7 +6110,7 @@ function boldCommentTitle(body) {
6088
6110
  */
6089
6111
  function buildCommentBody(body, commitSha, confidence) {
6090
6112
  const confidenceLine = `_Confidence: ${confidence}._`;
6091
- const footer = `<sub>Reviewed by ${PRODUCT_LINK} v0.9.4 for commit ${commitSha}.</sub>`;
6113
+ const footer = `<sub>Reviewed by ${PRODUCT_LINK} v0.9.5 for commit ${commitSha}.</sub>`;
6092
6114
  return `${boldCommentTitle(body.trim())}\n\n${confidenceLine}\n\n---\n\n${footer}`;
6093
6115
  }
6094
6116
  function buildPayload(comment, body, refs, resolved) {
@@ -7195,10 +7217,10 @@ async function main(argv = process.argv.slice(2)) {
7195
7217
  return;
7196
7218
  }
7197
7219
  if (argv.includes("--version") || argv.includes("-v")) {
7198
- console.log("0.9.4");
7220
+ console.log("0.9.5");
7199
7221
  return;
7200
7222
  }
7201
- process.stderr.write(`[code-review] @weareikko/code-review v0.9.4\n`);
7223
+ process.stderr.write(`[code-review] @weareikko/code-review v0.9.5\n`);
7202
7224
  assertNodeVersion();
7203
7225
  applyCodeReviewEnvPrefix();
7204
7226
  applyDefaultCacheRetention();
@@ -7221,4 +7243,4 @@ if (isDirectRun()) main().catch((error) => {
7221
7243
  //#endregion
7222
7244
  export { resolveNpmSkillDir as $, SUMMARY_MARKER as A, findExistingSummaryNoteId as B, normalizeSeverity as C, SUMMARY_HISTORY_ENTRY_START as D, SUMMARY_HISTORY_ENTRY_END as E, buildSummaryHistoryEntries as F, extractDiffHunkContext as G, stripSummaryMarker as H, extractReviewedCommitSha as I, normalizeBody as J, extractExistingFingerprints as K, extractSummaryHistoryEntries as L, buildReviewedCommitFooter as M, buildSizeNoticeBlock as N, SUMMARY_HISTORY_LIMIT as O, buildSummaryBody as P, parseSkillSpec as Q, findExistingReviewedCommitSha as R, traceDiagnosticPhase as S, SUMMARY_HISTORY_END as T, upsertSummaryNote as U, stripSummaryHistory as V, appendFingerprintMarkers as W, gitSkillCacheKey as X, sha256 as Y, loadNamedSkill as Z, DIAGNOSTIC_CHANNEL_PREFIX as _, main as a, diagnosticChannels as b, buildGeneratedComments as c, startOtelBridge as d, resolveSkillCacheDir as et, filterDiff as f, DIAGNOSTIC_CHANNEL_NAMES as g, parseReviewMarkdownWithWarnings as h, formatUsageLine as i, buildArchivedSummaryEntry as j, SUMMARY_HISTORY_START as k, buildPayload as l, parseReviewMarkdown as m, formatPerModelUsage as n, run as o, runReview as p, fingerprints as q, formatSkillsFooter as r, withHttpStamping as s, countPostedBySeverity as t, isOtelEnabled as u, createDiagnosticContext as v, toGitLabReviewSeverity as w, traceDiagnostic as x, createDiagnosticRunId as y, findExistingSummaryNote as z };
7223
7245
 
7224
- //# sourceMappingURL=cli-C3kNr0rX.js.map
7246
+ //# sourceMappingURL=cli-tIo5jQvJ.js.map