co-maintainer 0.6.5 → 0.6.7

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.
@@ -13,7 +13,7 @@ import { validateSkill } from "../knowledge/validate.js";
13
13
  import { readConfig, reposDir, resolvedAiToken, writeRepoConfig, } from "../config.js";
14
14
  import { readState, writeState } from "../store/skill_state.js";
15
15
  import { cacheSet } from "../store/cache_db.js";
16
- import { log, timed, withLogSink } from "../util/log.js";
16
+ import { log, timed, withCliLogsToStderr, withLogSink } from "../util/log.js";
17
17
  import { printRunSummary, summaryFromMetrics } from "../util/run_summary.js";
18
18
  import { enqueue, registerHandler } from "./jobs.js";
19
19
  import { resolveConcurrency } from "./concurrency.js";
@@ -24,6 +24,7 @@ import { mkdir, readTextFile, remove } from "../util/runtime.js";
24
24
  import { addResponseCost, emptyTally } from "../util/cost.js";
25
25
  import { costLabel } from "../util/run_summary.js";
26
26
  import { formatError } from "../cli/error.js";
27
+ import { buildSetupJson } from "../cli/command_json.js";
27
28
  export function emptyAiMetrics() {
28
29
  return { calls: 0, tokensIn: 0, tokensOut: 0, ...emptyTally() };
29
30
  }
@@ -144,7 +145,12 @@ export async function runInitOrRemake(options) {
144
145
  if (openedAppDb)
145
146
  await openAppDb();
146
147
  try {
147
- await initOrRemake(options);
148
+ // With `--json` stdout carries the one document, so progress moves to
149
+ // stderr.
150
+ if (options.json)
151
+ await withCliLogsToStderr(() => initOrRemake(options));
152
+ else
153
+ await initOrRemake(options);
148
154
  }
149
155
  finally {
150
156
  if (openedAppDb)
@@ -301,7 +307,29 @@ async function initOrRemake(options) {
301
307
  ? `updated ${result.changed.join(", ")}`
302
308
  : "already current"}`);
303
309
  log("done", `${facts.length} facts · ${source.pullRequests.length} pull requests · ${source.commits.length} commits`);
304
- printRunSummary(summaryFromMetrics(aiMetrics, performance.now() - operationStarted));
310
+ const summary = summaryFromMetrics(aiMetrics, performance.now() - operationStarted);
311
+ printRunSummary(summary);
312
+ if (options.json) {
313
+ console.log(buildSetupJson({
314
+ command: options.command === "remake" ? "sync" : "init",
315
+ repo: options.repo,
316
+ skillPath: path,
317
+ changed: result.changed,
318
+ facts: facts.length,
319
+ pullRequests: source.pullRequests.length,
320
+ commits: source.commits.length,
321
+ reviewGuide: reviewDocuments
322
+ ? reviewDocuments.detailed
323
+ ? "detailed"
324
+ : "single"
325
+ : "skipped",
326
+ validation: {
327
+ errors: finalValidation.errors,
328
+ warnings: finalValidation.warnings,
329
+ },
330
+ summary,
331
+ }));
332
+ }
305
333
  if (options.logTime) {
306
334
  log("time", `AI total · calls=${aiMetrics.calls} · input=${aiMetrics.tokensIn} tokens · output=${aiMetrics.tokensOut} tokens · cost=${costLabel(aiMetrics)}`);
307
335
  log("time", `total init/sync · ${((performance.now() - operationStarted) / 1000).toFixed(2)}s`);
@@ -54,6 +54,9 @@ export type Options = {
54
54
  /** `probe --run`: after printing the plan, run the recommended init in the
55
55
  * same process. */
56
56
  run?: boolean;
57
+ /** `probe`, `init` and `sync --json`: one JSON document on stdout, progress
58
+ * on stderr, and no prompts. */
59
+ json?: boolean;
57
60
  /** How a review decides a blocking finding. `model` keeps the
58
61
  * 0.4.13 behavior, `severity` uses a fixed P0/P1 threshold. */
59
62
  reviewBlocking?: "model" | "severity";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "co-maintainer",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "description": "An imitator of yours, A PR review tool like co-maintainer.",
5
5
  "keywords": [
6
6
  "ai",