co-maintainer 0.7.2-beta.1 → 0.7.2

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 (159) hide show
  1. package/dist/package.json +2 -1
  2. package/dist/src/ai/anthropic.d.ts +1 -1
  3. package/dist/src/ai/anthropic.js +1 -1
  4. package/dist/src/ai/batch.d.ts +1 -1
  5. package/dist/src/ai/batch.js +3 -3
  6. package/dist/src/ai/copy_rule.d.ts +7 -0
  7. package/dist/src/ai/copy_rule.js +23 -0
  8. package/dist/src/ai/estimate.js +3 -3
  9. package/dist/src/ai/fake.js +2 -1
  10. package/dist/src/ai/mermaid.js +1 -0
  11. package/dist/src/ai/oauth/registry.d.ts +1 -1
  12. package/dist/src/ai/oauth/sign-in-with-chatgpt.d.ts +4 -4
  13. package/dist/src/ai/oauth/sign-in-with-chatgpt.js +6 -6
  14. package/dist/src/ai/openai.d.ts +3 -3
  15. package/dist/src/ai/openai.js +4 -4
  16. package/dist/src/ai/openrouter.d.ts +1 -1
  17. package/dist/src/ai/openrouter.js +1 -1
  18. package/dist/src/ai/pricing.js +1 -1
  19. package/dist/src/ai/provider.d.ts +2 -0
  20. package/dist/src/ai/provider.js +8 -2
  21. package/dist/src/ai/verify.d.ts +1 -1
  22. package/dist/src/ai/verify.js +1 -1
  23. package/dist/src/cli/args.js +1 -1
  24. package/dist/src/cli/command_json.d.ts +1 -1
  25. package/dist/src/cli/commands/config.d.ts +1 -1
  26. package/dist/src/cli/commands/config.js +1 -1
  27. package/dist/src/cli/commands/oauth.js +1 -1
  28. package/dist/src/cli/commands/probe.js +1 -1
  29. package/dist/src/cli/commands/serve.d.ts +1 -1
  30. package/dist/src/cli/commands/serve.js +1 -1
  31. package/dist/src/cli/commands/set.d.ts +1 -1
  32. package/dist/src/cli/commands/set.js +4 -4
  33. package/dist/src/cli/commands/view.js +2 -2
  34. package/dist/src/cli/error.d.ts +1 -1
  35. package/dist/src/cli/error.js +1 -1
  36. package/dist/src/cli/prompt.d.ts +2 -2
  37. package/dist/src/cli/prompt.js +3 -3
  38. package/dist/src/cli/review_args.js +2 -2
  39. package/dist/src/cli/review_result.d.ts +3 -4
  40. package/dist/src/cli/review_result.js +5 -8
  41. package/dist/src/config.d.ts +11 -11
  42. package/dist/src/config.js +3 -3
  43. package/dist/src/github/app.d.ts +1 -1
  44. package/dist/src/github/app.js +1 -1
  45. package/dist/src/github/app_manifest.d.ts +1 -1
  46. package/dist/src/github/app_manifest.js +1 -1
  47. package/dist/src/github/client.d.ts +1 -1
  48. package/dist/src/github/client.js +1 -1
  49. package/dist/src/github/gh.js +2 -2
  50. package/dist/src/github/jwt.d.ts +1 -1
  51. package/dist/src/github/jwt.js +1 -1
  52. package/dist/src/github/oauth.js +2 -2
  53. package/dist/src/knowledge/facts.js +3 -3
  54. package/dist/src/knowledge/guide.js +7 -7
  55. package/dist/src/knowledge/probe.js +1 -1
  56. package/dist/src/knowledge/skill.js +1 -1
  57. package/dist/src/knowledge/synthesis.js +7 -7
  58. package/dist/src/local/carry_over_store.d.ts +1 -1
  59. package/dist/src/local/carry_over_store.js +1 -1
  60. package/dist/src/local/codegraph_prepare.js +1 -1
  61. package/dist/src/local/git_ops.js +1 -1
  62. package/dist/src/local/review_local.js +3 -3
  63. package/dist/src/local/review_lock.d.ts +1 -1
  64. package/dist/src/pr/checkout.d.ts +3 -3
  65. package/dist/src/pr/checkout.js +7 -7
  66. package/dist/src/pr/codegraph_tool_args.d.ts +1 -1
  67. package/dist/src/pr/codegraph_tool_args.js +1 -1
  68. package/dist/src/pr/findings.js +8 -9
  69. package/dist/src/pr/findings_json.d.ts +2 -2
  70. package/dist/src/pr/findings_json.js +1 -1
  71. package/dist/src/pr/github_revision.js +1 -1
  72. package/dist/src/pr/review_copy.d.ts +2 -3
  73. package/dist/src/pr/review_copy.js +2 -3
  74. package/dist/src/pr/reviewer.d.ts +3 -3
  75. package/dist/src/pr/reviewer.js +24 -26
  76. package/dist/src/pr/scope.d.ts +8 -8
  77. package/dist/src/pr/scope.js +4 -4
  78. package/dist/src/pr/snapshot.d.ts +2 -2
  79. package/dist/src/remote/client.js +3 -3
  80. package/dist/src/remote/schema.d.ts +1 -1
  81. package/dist/src/remote/schema.js +1 -1
  82. package/dist/src/remote/server/body.d.ts +1 -1
  83. package/dist/src/remote/server/body.js +1 -1
  84. package/dist/src/remote/server/guides.js +1 -1
  85. package/dist/src/remote/validate.js +1 -1
  86. package/dist/src/review/blocking.d.ts +3 -3
  87. package/dist/src/review/blocking.js +2 -2
  88. package/dist/src/review/carry_over.d.ts +1 -1
  89. package/dist/src/review/carry_over.js +2 -2
  90. package/dist/src/review/diagram.js +7 -6
  91. package/dist/src/review/engine.d.ts +1 -1
  92. package/dist/src/review/guides.js +1 -1
  93. package/dist/src/review/system_prompt.d.ts +1 -1
  94. package/dist/src/review/system_prompt.js +1 -1
  95. package/dist/src/server/api/jobs.js +2 -2
  96. package/dist/src/server/api/repos.js +1 -1
  97. package/dist/src/server/app.js +1 -1
  98. package/dist/src/server/auth.d.ts +3 -3
  99. package/dist/src/server/auth.js +9 -4
  100. package/dist/src/server/http.js +5 -5
  101. package/dist/src/server/pages/activity.js +1 -1
  102. package/dist/src/server/pages/add_repo.js +1 -0
  103. package/dist/src/server/pages/client.d.ts +2 -2
  104. package/dist/src/server/pages/client.js +2 -2
  105. package/dist/src/server/pages/home.d.ts +1 -1
  106. package/dist/src/server/pages/home.js +1 -1
  107. package/dist/src/server/pages/icons.d.ts +1 -1
  108. package/dist/src/server/pages/icons.js +1 -1
  109. package/dist/src/server/pages/layout.d.ts +2 -2
  110. package/dist/src/server/pages/layout.js +3 -3
  111. package/dist/src/server/pages/pr.js +2 -0
  112. package/dist/src/server/pages/rate_limit_waits.js +2 -2
  113. package/dist/src/server/pages/repo_settings.js +1 -0
  114. package/dist/src/server/pages/router.js +3 -2
  115. package/dist/src/server/pages/styles.d.ts +2 -2
  116. package/dist/src/server/pages/styles.js +2 -2
  117. package/dist/src/server/pages/ui.d.ts +1 -1
  118. package/dist/src/server/pages/ui.js +2 -2
  119. package/dist/src/server/webhook/index.js +1 -1
  120. package/dist/src/services/clear.d.ts +2 -2
  121. package/dist/src/services/clear.js +2 -2
  122. package/dist/src/services/probe.js +1 -1
  123. package/dist/src/services/remote_review_abort.d.ts +1 -1
  124. package/dist/src/services/remote_review_abort.js +1 -1
  125. package/dist/src/services/remote_tokens.js +1 -1
  126. package/dist/src/services/replies.js +0 -2
  127. package/dist/src/services/review.d.ts +3 -5
  128. package/dist/src/services/review.js +8 -10
  129. package/dist/src/services/setup.d.ts +2 -2
  130. package/dist/src/services/setup.js +9 -9
  131. package/dist/src/services/watch_comments.js +1 -2
  132. package/dist/src/services/watch_notes.js +1 -3
  133. package/dist/src/store/app_db.d.ts +1 -1
  134. package/dist/src/store/app_db.js +2 -2
  135. package/dist/src/store/jobs.d.ts +2 -2
  136. package/dist/src/store/jobs.js +3 -3
  137. package/dist/src/store/migrations.d.ts +2 -2
  138. package/dist/src/store/migrations.js +18 -18
  139. package/dist/src/store/rows.d.ts +2 -2
  140. package/dist/src/store/rows.js +1 -1
  141. package/dist/src/store/sessions.d.ts +1 -1
  142. package/dist/src/store/sessions.js +2 -2
  143. package/dist/src/store/sqlite.js +2 -2
  144. package/dist/src/tools/codegraph.d.ts +1 -1
  145. package/dist/src/tools/codegraph.js +3 -3
  146. package/dist/src/tools/codegraph_exec.d.ts +1 -1
  147. package/dist/src/tools/codegraph_exec.js +1 -1
  148. package/dist/src/types.d.ts +2 -2
  149. package/dist/src/util/keyed_lock.d.ts +1 -1
  150. package/dist/src/util/keyed_lock.js +1 -1
  151. package/dist/src/util/log.js +1 -1
  152. package/dist/src/util/redact.js +2 -1
  153. package/dist/src/util/run_summary.d.ts +3 -3
  154. package/dist/src/util/run_summary.js +3 -3
  155. package/dist/src/util/runtime.d.ts +4 -4
  156. package/dist/src/util/runtime.js +5 -5
  157. package/dist/src/util/time.d.ts +1 -1
  158. package/dist/src/util/time.js +1 -1
  159. package/package.json +2 -1
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "co-maintainer",
3
- "version": "0.7.2-beta.1",
3
+ "version": "0.7.2",
4
4
  "description": "An imitator of yours, A PR review tool like co-maintainer.",
5
5
  "keywords": [
6
6
  "ai",
@@ -40,6 +40,7 @@
40
40
  "lint": "oxlint",
41
41
  "fmt": "oxfmt --write .",
42
42
  "fmt:check": "oxfmt --check .",
43
+ "punctuation": "node scripts/punctuation.ts",
43
44
  "dev": "node --watch main.ts",
44
45
  "probe": "node main.ts probe",
45
46
  "init": "node main.ts init",
@@ -26,7 +26,7 @@
26
26
  * called for the SDK's `stream()` + `finalMessage()` helper for large `max_tokens` (a single
27
27
  * review can ask for 96k). The SDK is not a dependency (kept fetch-only, the
28
28
  * same as every other provider), and a hand-rolled SSE accumulation loop is a
29
- * lot of code for a first cut. Anthropic's HTTP request timeout is the risk;
29
+ * lot of code for a first cut. Anthropic's HTTP request timeout is the risk,
30
30
  * if a real review ever hits it, add the streaming loop here. Upgrade path:
31
31
  * `stream:true` + parse `content_block_delta` events into the same
32
32
  * `parseMessagesBody` result shape.
@@ -113,7 +113,7 @@ function toAnthropicMessages(messages) {
113
113
  messages: out,
114
114
  };
115
115
  }
116
- /** Haiku 4.5 does not support `output_config.effort`; sending it is a 400.
116
+ /** Haiku 4.5 does not support `output_config.effort`. Sending it is a 400.
117
117
  * Anthropic's effort accepts low/medium/high/xhigh/max, so the only level this
118
118
  * has to drop is "none": it means "reasoning off" in `AiRequest` and is not an
119
119
  * effort value Anthropic lists. */
@@ -33,7 +33,7 @@ export declare class AiBatch {
33
33
  /** Runs one unit, retrying a provider error and a response the validator
34
34
  * rejects. It never throws: a provider error that outlives its retries drops
35
35
  * the unit, and a response that still does not validate is used anyway. A run
36
- * that has already paid for extraction must still write what it has; a format
36
+ * that has already paid for extraction must still write what it has. A format
37
37
  * deviation is not worth losing the whole run over. The one exception is
38
38
  * Ctrl-C: every call then fails at once, and a run that went on without
39
39
  * them would write guides with every section dropped. */
@@ -77,7 +77,7 @@ export class AiBatch {
77
77
  const cached = this.records[id];
78
78
  if (cached?.status === "done" && cached.response) {
79
79
  // A `done` record from 0.4.x can hold output that never parsed. Treat
80
- // that as a miss and delete it so the retry below replaces it; the
80
+ // that as a miss and delete it so the retry below replaces it. The
81
81
  // corrupted record heals on its own the next time its unit runs.
82
82
  const reason = this.validate?.(request, cached.response) ?? null;
83
83
  if (reason === null) {
@@ -128,7 +128,7 @@ export class AiBatch {
128
128
  /** Runs one unit, retrying a provider error and a response the validator
129
129
  * rejects. It never throws: a provider error that outlives its retries drops
130
130
  * the unit, and a response that still does not validate is used anyway. A run
131
- * that has already paid for extraction must still write what it has; a format
131
+ * that has already paid for extraction must still write what it has. A format
132
132
  * deviation is not worth losing the whole run over. The one exception is
133
133
  * Ctrl-C: every call then fails at once, and a run that went on without
134
134
  * them would write guides with every section dropped. */
@@ -162,7 +162,7 @@ export class AiBatch {
162
162
  }
163
163
  continue;
164
164
  }
165
- log("ai", `gave up ${item.request.job} ${item.id.slice(0, 8)} after ${attempt} attempts; continuing without it`);
165
+ log("ai", `gave up ${item.request.job} ${item.id.slice(0, 8)} after ${attempt} attempts, continuing without it`);
166
166
  return;
167
167
  }
168
168
  const reason = this.validate?.(item.request, response) ?? null;
@@ -0,0 +1,7 @@
1
+ import type { AiProvider, AiRequest } from "../types.ts";
2
+ /** The punctuation rule is a brand rule, not a fix for one prompt. Every AI
3
+ * job, present or future, gets it in its system prompt from here, so a new job
4
+ * cannot forget it. The rule text lives once, in `REVIEW_COPY_RULE`. */
5
+ export declare function withCopyRuleRequest(request: AiRequest): AiRequest;
6
+ /** A provider whose every request carries the copy rule. */
7
+ export declare function withCopyRule(provider: AiProvider): AiProvider;
@@ -0,0 +1,23 @@
1
+ import { REVIEW_COPY_RULE } from "../pr/review_copy.js";
2
+ /** The punctuation rule is a brand rule, not a fix for one prompt. Every AI
3
+ * job, present or future, gets it in its system prompt from here, so a new job
4
+ * cannot forget it. The rule text lives once, in `REVIEW_COPY_RULE`. */
5
+ export function withCopyRuleRequest(request) {
6
+ if (request.system?.includes(REVIEW_COPY_RULE))
7
+ return request;
8
+ return {
9
+ ...request,
10
+ system: request.system
11
+ ? `${request.system}\n\n${REVIEW_COPY_RULE}`
12
+ : REVIEW_COPY_RULE,
13
+ };
14
+ }
15
+ /** A provider whose every request carries the copy rule. */
16
+ export function withCopyRule(provider) {
17
+ return {
18
+ get supportsTools() {
19
+ return provider.supportsTools;
20
+ },
21
+ complete: (request) => provider.complete(withCopyRuleRequest(request)),
22
+ };
23
+ }
@@ -2,9 +2,9 @@
2
2
  *
3
3
  * Three sources, in order of trust:
4
4
  *
5
- * 1. Job counts come from the same inputs the real run uses — the number of
5
+ * 1. Job counts come from the same inputs the real run uses, the number of
6
6
  * pull requests, whether the codebase is read, and the ten synthesis
7
- * sections — so the shape is exact.
7
+ * sections, so the shape is exact.
8
8
  * 2. Dollars come from the live OpenRouter price for the configured models.
9
9
  * When prices are unavailable the estimate reports tokens but no dollars
10
10
  * rather than guessing one.
@@ -12,7 +12,7 @@
12
12
  * there are enough, and from the calibration below otherwise.
13
13
  *
14
14
  * Calibration: cm-dx-lab, 4 pull requests and 8 files, 5
15
- * extract and 9 synth jobs, 151 s, $0.0014 — about 151/14 ≈ 10.8 s per job.
15
+ * extract and 9 synth jobs, 151 s, $0.0014, about 151/14 ≈ 10.8 s per job.
16
16
  * Token counts per job are near 2.4k in and 0.7k out. The text always says
17
17
  * the numbers are an estimate. */
18
18
  import { cacheValues } from "../store/cache_db.js";
@@ -1,3 +1,4 @@
1
+ import { withCopyRuleRequest } from "./copy_rule.js";
1
2
  import { getEnv, readTextFileSync } from "../util/runtime.js";
2
3
  export const FAKE_REVIEW_MARKDOWN = `## Findings
3
4
 
@@ -62,7 +63,7 @@ export class FakeAiProvider {
62
63
  await new Promise((resolve) => setTimeout(resolve, delay));
63
64
  }
64
65
  async complete(request) {
65
- await this.record(request);
66
+ await this.record(withCopyRuleRequest(request));
66
67
  return {
67
68
  text: this.jobText(request.job) ?? this.text,
68
69
  tokensIn: 10,
@@ -309,6 +309,7 @@ config:
309
309
  ---
310
310
  Use rect_* for requirement/element boxes and line_height/fontSize for
311
311
  readability. Keep risk and verification semantics in diagram data.`,
312
+ // punctuation: code, the message lists the semicolon as a forbidden character
312
313
  "usecase-beta": `Configuration:
313
314
  ---
314
315
  config:
@@ -19,7 +19,7 @@ export declare function oauthUnknownProvider(value: string | undefined): CliErro
19
19
  export type OAuthOps = {
20
20
  label: string;
21
21
  credentialsPath(): string;
22
- /** The browser flow; always starts a new sign-in. */
22
+ /** The browser flow. Always starts a new sign-in. */
23
23
  login(): Promise<Credentials>;
24
24
  logout(): Promise<boolean>;
25
25
  refresh(): Promise<Credentials>;
@@ -24,16 +24,16 @@ export declare function normalizeModel(model: string): string;
24
24
  export declare function loadCredentials(): Credentials | undefined;
25
25
  export declare function logout(): Promise<boolean>;
26
26
  type BrowserOpener = (url: string) => void;
27
- /** Tests replace the browser with a helper that completes the callback; the
27
+ /** Tests replace the browser with a helper that completes the callback. The
28
28
  * real opener shells out to the platform's open command. */
29
29
  export declare function setBrowserOpener(opener: BrowserOpener | undefined): void;
30
- /** The browser flow. Always runs, so a user can switch accounts; `logout`
30
+ /** The browser flow. Always runs, so a user can switch accounts, `logout`
31
31
  * first if the old one should not be reused. */
32
32
  export declare function login(): Promise<Credentials>;
33
33
  export declare function refresh(creds: Credentials): Promise<Credentials>;
34
34
  /** Credentials for a run: reuse the freshest token this process has seen,
35
35
  * refresh an expired one, or start the browser flow. `inflight` dedups so
36
- * `init`'s low and high providers never open two browsers; `cached` keeps a
36
+ * `init`'s low and high providers never open two browsers, `cached` keeps a
37
37
  * 401 refresh done inside `complete()` visible to later callers. */
38
38
  export declare function ensureCredentials(): Promise<Credentials>;
39
39
  export type ModelInfo = {
@@ -42,7 +42,7 @@ export type ModelInfo = {
42
42
  };
43
43
  /** For `oauth refresh|ping|list-models`, which operate on an existing login
44
44
  * and must not start a browser flow. A live token is reused, an expired one
45
- * refreshed; no login at all is a clear error. */
45
+ * refreshed. No login at all is a clear error. */
46
46
  export declare function requireCredentials(): Promise<Credentials>;
47
47
  export declare function listModels(creds: Credentials): Promise<ModelInfo[]>;
48
48
  /** The model slugs a user can pick, for prompts and error messages. */
@@ -5,7 +5,7 @@
5
5
  * dance registers a client on first use, keeps the tokens in
6
6
  * `~/.config/co-maintainer/oauth/sign-in-with-chatgpt.json` (0600), and
7
7
  * refreshes them. The Responses translation itself lives in `openai.ts` and
8
- * is shared; this file only adds the auth and the plan-usage request shape.
8
+ * is shared. This file only adds the auth and the plan-usage request shape.
9
9
  *
10
10
  * Route quirks this file exists to respect (confirmed against the live
11
11
  * route): `store:false` and `stream:true` are required, `max_output_tokens`
@@ -36,7 +36,7 @@ function loginTimeoutMs() {
36
36
  return Number.isFinite(raw) && raw > 0 ? raw : 5 * 60 * 1000;
37
37
  }
38
38
  /** `CM_SIWC_AUTH_URL` and `CM_SIWC_API_URL` point the flow at local fakes in
39
- * tests; unset means the real endpoints. `CM_SIWC_DIR` moves the credentials
39
+ * tests. Unset means the real endpoints. `CM_SIWC_DIR` moves the credentials
40
40
  * file so tests never touch the real one. */
41
41
  function authOrigin() {
42
42
  return (getEnv("CM_SIWC_AUTH_URL") ?? "https://auth.openai.com").replace(/\/$/, "");
@@ -173,7 +173,7 @@ export async function logout() {
173
173
  }
174
174
  }
175
175
  let browserOpener;
176
- /** Tests replace the browser with a helper that completes the callback; the
176
+ /** Tests replace the browser with a helper that completes the callback. The
177
177
  * real opener shells out to the platform's open command. */
178
178
  export function setBrowserOpener(opener) {
179
179
  browserOpener = opener;
@@ -343,7 +343,7 @@ function remember(creds) {
343
343
  cached = creds;
344
344
  return creds;
345
345
  }
346
- /** The browser flow. Always runs, so a user can switch accounts; `logout`
346
+ /** The browser flow. Always runs, so a user can switch accounts, `logout`
347
347
  * first if the old one should not be reused. */
348
348
  export async function login() {
349
349
  const existing = loadCredentials();
@@ -402,7 +402,7 @@ function requireInteractive() {
402
402
  let inflight;
403
403
  /** Credentials for a run: reuse the freshest token this process has seen,
404
404
  * refresh an expired one, or start the browser flow. `inflight` dedups so
405
- * `init`'s low and high providers never open two browsers; `cached` keeps a
405
+ * `init`'s low and high providers never open two browsers, `cached` keeps a
406
406
  * 401 refresh done inside `complete()` visible to later callers. */
407
407
  export function ensureCredentials() {
408
408
  if (cached && cached.expires_at - 60_000 > Date.now()) {
@@ -432,7 +432,7 @@ export function ensureCredentials() {
432
432
  }
433
433
  /** For `oauth refresh|ping|list-models`, which operate on an existing login
434
434
  * and must not start a browser flow. A live token is reused, an expired one
435
- * refreshed; no login at all is a clear error. */
435
+ * refreshed. No login at all is a clear error. */
436
436
  export async function requireCredentials() {
437
437
  const existing = loadCredentials();
438
438
  if (!existing?.refresh_token && !existing?.access_token) {
@@ -23,7 +23,7 @@
23
23
  * The full fix is `previous_response_id`, which needs a response id to
24
24
  * survive between calls, and `AiProvider.complete` is stateless for every
25
25
  * provider. Upgrade path: thread a response id through `AiResponse` if this
26
- * turns out to matter in practice; codegraph's own tool loop caps rounds low
26
+ * turns out to matter in practice. Codegraph's own tool loop caps rounds low
27
27
  * (mermaid_loop.ts's `maxToolRounds`), which limits how much is at stake.
28
28
  */
29
29
  import type { AiProvider, AiRequest, AiResponse, Json } from "../types.ts";
@@ -43,10 +43,10 @@ export type ResponsesBodyOptions = {
43
43
  export declare function responsesBody(model: string, request: AiRequest, options?: ResponsesBodyOptions): Json;
44
44
  export declare function parseResponsesBody(json: Json, model: string, provider?: AiResponse["provider"]): AiResponse;
45
45
  /** The SSE body the plan usage route always returns (`stream: true`). The
46
- * text deltas are ignored; the output items arrive as their own
46
+ * text deltas are ignored. The output items arrive as their own
47
47
  * `response.output_item.done` events, because this route's terminal
48
48
  * `response.completed` carries an empty `output` array (the standard API
49
- * fills it). The terminal response supplies `usage` and `status`; the
49
+ * fills it). The terminal response supplies `usage` and `status`. The
50
50
  * collected items supply `output`, so the shared {@link parseResponsesBody}
51
51
  * sees the same shape on both routes. A stream with no terminal response
52
52
  * throws, and one cut mid-way names `url`'s host. */
@@ -53,7 +53,7 @@ function toResponsesTool(tool) {
53
53
  };
54
54
  }
55
55
  /** A tool call and its result do not live inside a message the way Chat
56
- * Completions nests them; each is its own item in `input`. */
56
+ * Completions nests them. Each is its own item in `input`. */
57
57
  function toResponsesInput(messages) {
58
58
  const input = [];
59
59
  let instructions;
@@ -166,10 +166,10 @@ export function parseResponsesBody(json, model, provider = "openai") {
166
166
  };
167
167
  }
168
168
  /** The SSE body the plan usage route always returns (`stream: true`). The
169
- * text deltas are ignored; the output items arrive as their own
169
+ * text deltas are ignored. The output items arrive as their own
170
170
  * `response.output_item.done` events, because this route's terminal
171
171
  * `response.completed` carries an empty `output` array (the standard API
172
- * fills it). The terminal response supplies `usage` and `status`; the
172
+ * fills it). The terminal response supplies `usage` and `status`. The
173
173
  * collected items supply `output`, so the shared {@link parseResponsesBody}
174
174
  * sees the same shape on both routes. A stream with no terminal response
175
175
  * throws, and one cut mid-way names `url`'s host. */
@@ -196,7 +196,7 @@ export async function readResponsesStream(response, url) {
196
196
  if (done)
197
197
  break;
198
198
  buffer += decoder.decode(value, { stream: true });
199
- // SSE events are separated by a blank line; tolerate CRLF.
199
+ // SSE events are separated by a blank line. Tolerate CRLF.
200
200
  buffer = buffer.replace(/\r/g, "");
201
201
  let index = buffer.indexOf("\n\n");
202
202
  while (index >= 0) {
@@ -20,7 +20,7 @@ export type ChatHost = {
20
20
  export declare function openRouterHost(): ChatHost;
21
21
  /** Provider failures as actionable text. A 401 and a 400 for
22
22
  * an unknown model are preconditions the user can fix, so they are usage
23
- * errors; anything else is a runtime failure. Only the provider's own
23
+ * errors. Anything else is a runtime failure. Only the provider's own
24
24
  * `error.message` is surfaced: the raw body can carry account metadata
25
25
  * (`user_id`) that has no business in a terminal. */
26
26
  export declare function openRouterError(model: string, status: number, body: string, host?: ChatHost): CliError;
@@ -21,7 +21,7 @@ export function openRouterHost() {
21
21
  }
22
22
  /** Provider failures as actionable text. A 401 and a 400 for
23
23
  * an unknown model are preconditions the user can fix, so they are usage
24
- * errors; anything else is a runtime failure. Only the provider's own
24
+ * errors. Anything else is a runtime failure. Only the provider's own
25
25
  * `error.message` is surfaced: the raw body can carry account metadata
26
26
  * (`user_id`) that has no business in a terminal. */
27
27
  export function openRouterError(model, status, body, host = openRouterHost()) {
@@ -2,7 +2,7 @@
2
2
  *
3
3
  * `/api/v1/models` is public: no key needed. The list is large and changes
4
4
  * slowly, so it is cached for 24 hours in cache.db. A network failure is not
5
- * fatal — the estimate then reports tokens and time but no dollars, which is
5
+ * fatal, the estimate then reports tokens and time but no dollars, which is
6
6
  * still useful and never invents a price. */
7
7
  import { openRouterBase } from "./verify.js";
8
8
  import { cacheGet, cacheSet } from "../store/cache_db.js";
@@ -9,6 +9,8 @@ export declare function rejectRetiredProvider(value: string | undefined): void;
9
9
  /** The provider a run actually calls. `--experimental-siwc` overrides the
10
10
  * configured `ai` for the run, so logs and error labels name what ran. */
11
11
  export declare function aiProviderName(options: Options): string;
12
+ /** The provider for a run. Every one it returns is wrapped by
13
+ * `withCopyRule`, so no job reaches a model without the punctuation rule. */
12
14
  export declare function createAiProvider(options: Options, model: string): AiProvider | undefined;
13
15
  /** A 400 that names one optional part of the request earns one retry without
14
16
  * it: the JSON schema, which the prompt asks for anyway, or "thinking off",
@@ -3,6 +3,7 @@ import { OpenAiProvider } from "./openai.js";
3
3
  import { AnthropicProvider } from "./anthropic.js";
4
4
  import { openCodeHost } from "./opencode.js";
5
5
  import { EXPERIMENTAL_OAUTH_PROVIDER, oauthOps } from "./oauth/registry.js";
6
+ import { withCopyRule } from "./copy_rule.js";
6
7
  import { die } from "../cli/error.js";
7
8
  /** The one list of accepted `--ai` values, so a new or retired provider is
8
9
  * added or removed in a single place instead of the half dozen copies
@@ -27,8 +28,13 @@ export function rejectRetiredProvider(value) {
27
28
  export function aiProviderName(options) {
28
29
  return options.experimentalSiwc ? EXPERIMENTAL_OAUTH_PROVIDER : options.ai;
29
30
  }
31
+ /** The provider for a run. Every one it returns is wrapped by
32
+ * `withCopyRule`, so no job reaches a model without the punctuation rule. */
30
33
  export function createAiProvider(options, model) {
31
- // `--experimental-siwc` wins over `--ai` for the run; `parseArgs` refuses
34
+ return withCopyRule(createRawProvider(options, model));
35
+ }
36
+ function createRawProvider(options, model) {
37
+ // `--experimental-siwc` wins over `--ai` for the run, `parseArgs` refuses
32
38
  // the two together, so this only sees one of them set.
33
39
  if (options.experimentalSiwc) {
34
40
  return oauthOps(EXPERIMENTAL_OAUTH_PROVIDER).createProvider(model);
@@ -127,7 +133,7 @@ export function chatBody(model, request) {
127
133
  ? { tools: request.tools, tool_choice: "auto" }
128
134
  : {}),
129
135
  // A review asks for structured output. The schema is sent even
130
- // when tools are present, because most providers accept the pair; one that
136
+ // when tools are present, because most providers accept the pair. One that
131
137
  // rejects it gets a single retry without the schema (see
132
138
  // `OpenRouterProvider.complete`), and the prompt also asks for a fenced
133
139
  // JSON block, so a plain-text provider still works.
@@ -28,6 +28,6 @@ export declare function verifyOpenRouter(apiKey: string, model?: string): Promis
28
28
  export declare function verifyOpenAi(apiKey: string, model?: string): Promise<VerifyResult>;
29
29
  /** Anthropic authenticates the key and lists models at `/models`, but with its
30
30
  * own headers (`x-api-key` + `anthropic-version`) instead of a Bearer token.
31
- * Without a model the call only proves the key; with one it also confirms
31
+ * Without a model the call only proves the key. With one it also confirms
32
32
  * Anthropic serves it. */
33
33
  export declare function verifyAnthropic(apiKey: string, model?: string): Promise<VerifyResult>;
@@ -114,7 +114,7 @@ export async function verifyOpenAi(apiKey, model) {
114
114
  }
115
115
  /** Anthropic authenticates the key and lists models at `/models`, but with its
116
116
  * own headers (`x-api-key` + `anthropic-version`) instead of a Bearer token.
117
- * Without a model the call only proves the key; with one it also confirms
117
+ * Without a model the call only proves the key. With one it also confirms
118
118
  * Anthropic serves it. */
119
119
  export async function verifyAnthropic(apiKey, model) {
120
120
  const base = anthropicBase();
@@ -78,7 +78,7 @@ export async function parseArgs(args) {
78
78
  const { config, envPath } = prepareConfig(args);
79
79
  const env = (name) => getEnv(name);
80
80
  const configDefault = config.defaults ?? {};
81
- // Remembered from a prior `init`/`remake` on this exact repo — never a
81
+ // Remembered from a prior `init`/`remake` on this exact repo, never a
82
82
  // secret, so it can safely fill in everything except the API token.
83
83
  const repoConfig = config.repos?.[repoName] ?? {};
84
84
  const reviewBlocking = reviewBlockingFrom(env("CO_MAINTAINER_REVIEW_BLOCKING") ??
@@ -37,7 +37,7 @@ export type SetupJsonInput = {
37
37
  command: "init" | "sync";
38
38
  repo: string;
39
39
  skillPath: string;
40
- /** Section keys this run rewrote; empty when the guide was already current. */
40
+ /** Section keys this run rewrote. Empty when the guide was already current. */
41
41
  changed: string[];
42
42
  facts: number;
43
43
  pullRequests: number;
@@ -15,7 +15,7 @@ export type Source = "env" | "file" | "default";
15
15
  /** The env var that supplies each field, mirroring args.ts. Only the fields
16
16
  * that actually read env are listed. */
17
17
  export declare const ENV_BY_FIELD: Record<string, string[]>;
18
- /** Renders one field for people. A secret is masked; the password hash, which
18
+ /** Renders one field for people. A secret is masked. The password hash, which
19
19
  * nobody can use, only reports whether it is set. */
20
20
  export declare function displayValue(field: string, value: unknown): string;
21
21
  /** Values a field falls back to when neither env nor the file sets it, so
@@ -52,7 +52,7 @@ export const ENV_BY_FIELD = {
52
52
  remoteByokPolicy: ["CM_REMOTE_BYOK_POLICY"],
53
53
  codegraphVersion: ["CM_CODEGRAPH_VERSION"],
54
54
  };
55
- /** Renders one field for people. A secret is masked; the password hash, which
55
+ /** Renders one field for people. A secret is masked. The password hash, which
56
56
  * nobody can use, only reports whether it is set. */
57
57
  export function displayValue(field, value) {
58
58
  if (field === "dashboardPasswordHash") {
@@ -1,7 +1,7 @@
1
1
  /** `co-maintainer oauth login|logout|refresh|ping|list-models --provider=...`
2
2
  *
3
3
  * The credential side of the experimental Sign in with ChatGPT support. Only
4
- * `login` starts a browser flow; the rest operate on an existing login and
4
+ * `login` starts a browser flow. The rest operate on an existing login and
5
5
  * fail clearly when there is none. See `docs/docs/providers.md`. */
6
6
  import { die } from "../error.js";
7
7
  import { oauthOps, oauthUnknownProvider, resolveOAuthProvider, } from "../../ai/oauth/registry.js";
@@ -86,7 +86,7 @@ async function probe(options) {
86
86
  console.log(` cost: ${costLine}`);
87
87
  console.log(` basis: ${estimate.basis === "history"
88
88
  ? "this repository's recorded jobs"
89
- : "the cm-dx-lab calibration"}; an estimate, not a bill`);
89
+ : "the cm-dx-lab calibration"}, an estimate, not a bill`);
90
90
  if (commitWatch) {
91
91
  console.log(`\ncommit watch ${commitWatch.app === "on"
92
92
  ? "✓ App (push event on)"
@@ -11,7 +11,7 @@ export declare function resolveTrustProxy(args: string[], env?: (name: string) =
11
11
  * kept, and a first start generates one, returned so the caller can print it. */
12
12
  export declare function ensureDashboardPassword(args: string[], hasStoredPassword: boolean, store: PasswordStore): Promise<string | undefined>;
13
13
  /** `--disable-auth=password` / `--enable-auth=github` always win over the
14
- * config defaults `co-maintainer set` persisted; dies if the result would
14
+ * config defaults `co-maintainer set` persisted. Dies if the result would
15
15
  * leave no sign-in method active. Pure so it is testable without a server. */
16
16
  export declare function resolveAuthMethods(args: string[], config: Pick<UserConfig, "passwordAuthDisabled" | "githubAuthEnabled">): AuthMethods;
17
17
  export declare function resolveWebhookUrl(args: string[], port: number, configured?: string): string;
@@ -57,7 +57,7 @@ export async function ensureDashboardPassword(args, hasStoredPassword, store) {
57
57
  return generated;
58
58
  }
59
59
  /** `--disable-auth=password` / `--enable-auth=github` always win over the
60
- * config defaults `co-maintainer set` persisted; dies if the result would
60
+ * config defaults `co-maintainer set` persisted. Dies if the result would
61
61
  * leave no sign-in method active. Pure so it is testable without a server. */
62
62
  export function resolveAuthMethods(args, config) {
63
63
  const disableAuth = args
@@ -1,7 +1,7 @@
1
1
  /** `co-maintainer set --token=... --ai=... --low-model=... --high-model=...
2
2
  * --auth=... --github-app-id=... --github-app-private-key=... (or
3
3
  * --github-app-private-key-file=path or --github-app-private-key-path=path)
4
- * --github-webhook-secret=...` —
4
+ * --github-webhook-secret=...`,
5
5
  * persists global defaults, including secrets, to config.json so every
6
6
  * other command can skip both the flag and the interactive prompt. See
7
7
  * docs/md/configuration.md for the tradeoff. */
@@ -41,7 +41,7 @@ const secretFields = new Set([
41
41
  /** `co-maintainer set --token=... --ai=... --low-model=... --high-model=...
42
42
  * --auth=... --github-app-id=... --github-app-private-key=... (or
43
43
  * --github-app-private-key-file=path or --github-app-private-key-path=path)
44
- * --github-webhook-secret=...` —
44
+ * --github-webhook-secret=...`,
45
45
  * persists global defaults, including secrets, to config.json so every
46
46
  * other command can skip both the flag and the interactive prompt. See
47
47
  * docs/md/configuration.md for the tradeoff. */
@@ -336,8 +336,8 @@ export async function runSet(args) {
336
336
  }
337
337
  // Verify the key and model before writing, so a typo fails here instead of
338
338
  // after a review has already fetched and cloned the pull request.
339
- // A field present in the patch wins, including when its value is `undefined`
340
- // — that is an unset, and there is nothing left to verify.
339
+ // A field present in the patch wins, including when its value is `undefined`.
340
+ // That is an unset, and there is nothing left to verify.
341
341
  const before = readConfig();
342
342
  const effective = (field) => field in patch ? patch[field] : before[field];
343
343
  const effectiveAi = effective("ai");
@@ -365,7 +365,7 @@ export async function runSet(args) {
365
365
  if (result.status === "rejected")
366
366
  throw result.error;
367
367
  if (result.status === "unreachable") {
368
- console.error(`[set] could not verify the key and model (${result.reason}); saved anyway.`);
368
+ console.error(`[set] could not verify the key and model (${result.reason}). Saved anyway.`);
369
369
  }
370
370
  }
371
371
  // A changed password, allowed user, or sign-in method must not leave old
@@ -1,5 +1,5 @@
1
1
  /** `co-maintainer view`: print the guides co-maintainer already generated.
2
- * Read-only — the counterpart to `config` for the generated
2
+ * Read-only, the counterpart to `config` for the generated
3
3
  * knowledge rather than the settings.
4
4
  *
5
5
  * Two sources, one presentation: the guide directory on this machine,
@@ -8,7 +8,7 @@
8
8
  * and the every-guide headers are all rendered by the same code.
9
9
  *
10
10
  * Naming: the guide kinds are `skill`, `codebase`,
11
- * `review-guide`, `detailed-guide`; `--list` and the headers show the real
11
+ * `review-guide`, `detailed-guide`, `--list` and the headers show the real
12
12
  * file names, and a kind name is accepted too so a user never has to type
13
13
  * `PR_REVIEW_GUIDE.md` unless they want to. */
14
14
  import { readConfig, reposDir } from "../../config.js";
@@ -42,5 +42,5 @@ export declare function networkFailure(url: string, error: unknown): CliError;
42
42
  * and Node's own text is only `terminated`, which says neither. */
43
43
  export declare function connectionCut(url: string, error: unknown): CliError;
44
44
  /** Reads a response body. fetch rejects with a `TypeError` when the
45
- * connection closes mid-body; that becomes {@link connectionCut}. */
45
+ * connection closes mid-body. That becomes {@link connectionCut}. */
46
46
  export declare function readBody(url: string, response: Response): Promise<string>;
@@ -74,7 +74,7 @@ export function connectionCut(url, error) {
74
74
  return new CliError("connection_cut", `${hostOf(url)} closed the connection before the answer was complete${detail ? ` (${detail}).` : "."}`, "The request reached the provider and the answer was cut off. Run the command again.", EXIT_RUNTIME);
75
75
  }
76
76
  /** Reads a response body. fetch rejects with a `TypeError` when the
77
- * connection closes mid-body; that becomes {@link connectionCut}. */
77
+ * connection closes mid-body. That becomes {@link connectionCut}. */
78
78
  export async function readBody(url, response) {
79
79
  try {
80
80
  return await response.text();
@@ -1,4 +1,4 @@
1
- /** Free-text question; empty input yields the fallback (or ""). */
1
+ /** Free-text question. Empty input yields the fallback (or ""). */
2
2
  export declare function askLine(label: string, fallback?: string): Promise<string>;
3
- /** Yes/no question; anything but `y`/`yes` is a no. */
3
+ /** Yes/no question. Anything but `y`/`yes` is a no. */
4
4
  export declare function askConfirm(question: string): Promise<boolean>;
@@ -33,7 +33,7 @@ async function ask(question) {
33
33
  resolve(value);
34
34
  };
35
35
  // `question` rejects when stdin closes mid-prompt (Ctrl-D, a detached
36
- // pipeline, a killed parent); treat that as "no answer" too.
36
+ // pipeline, a killed parent). Treat that as "no answer" too.
37
37
  void rl.question(question).then(done, () => done(""));
38
38
  rl.once("close", () => done(""));
39
39
  process.stdin.once("end", () => done(""));
@@ -58,13 +58,13 @@ function raiseInterrupt() {
58
58
  else
59
59
  process.kill(process.pid, "SIGINT");
60
60
  }
61
- /** Free-text question; empty input yields the fallback (or ""). */
61
+ /** Free-text question. Empty input yields the fallback (or ""). */
62
62
  export async function askLine(label, fallback) {
63
63
  const suffix = fallback ? ` [${fallback}]` : "";
64
64
  const answer = await ask(`${label}${suffix}:`);
65
65
  return answer || fallback || "";
66
66
  }
67
- /** Yes/no question; anything but `y`/`yes` is a no. */
67
+ /** Yes/no question. Anything but `y`/`yes` is a no. */
68
68
  export async function askConfirm(question) {
69
69
  const answer = (await ask(`${question} [y/N]`)).toLowerCase();
70
70
  return answer === "y" || answer === "yes";
@@ -28,7 +28,7 @@ function parseTimeout(value) {
28
28
  }
29
29
  function reviewFlags(rest) {
30
30
  const text = (name) => rest.find((item) => item.startsWith(`--${name}=`))?.slice(name.length + 3);
31
- // `--remake-before-review` is the 0.4.13 spelling; both names mean the same
31
+ // `--remake-before-review` is the 0.4.13 spelling. Both names mean the same
32
32
  // thing, and only the new one is documented.
33
33
  const syncBeforeReview = rest.some((arg) => arg === "--sync-before-review" || arg === "--remake-before-review");
34
34
  const remoteByokOn = rest.includes("--remote-byok");
@@ -146,7 +146,7 @@ export async function parseReviewArgs(args) {
146
146
  die("--experimental-siwc cannot be used with --remote");
147
147
  }
148
148
  // `--remote-host` / `--remote-token` only mean something together with
149
- // `--remote`; silently dropping them is exactly the kind of surprise to avoid.
149
+ // `--remote`. Silently dropping them is exactly the kind of surprise to avoid.
150
150
  if ((flags.remoteHost || flags.remoteToken) && !flags.remote) {
151
151
  die("--remote-host and --remote-token require --remote");
152
152
  }
@@ -95,10 +95,9 @@ export declare function humanFindingsFromResolved(findings: ResolvedFinding[], m
95
95
  export declare function humanFindingsFromJson(findings: JsonReviewFinding[]): HumanFinding[];
96
96
  /** The finding heading, as the shared header prints it. A parsed heading is
97
97
  * `[P2 · non-blocking] \`path\`: \`symbol\``. The label and the location are
98
- * already printed beside it, so only the symbol survives. An older heading
99
- * that used an em dash is still accepted, so comments posted before 0.5.0
100
- * stay readable. A heading with no symbol leaves nothing: printing the label
101
- * or the path again would repeat what the line already says. */
98
+ * already printed beside it, so only the symbol survives. A heading with no
99
+ * symbol leaves nothing: printing the label or the path again would repeat
100
+ * what the line already says. */
102
101
  export declare function humanShortTitle(row: HumanFinding): string;
103
102
  export declare function sortHumanFindings(rows: HumanFinding[]): HumanFinding[];
104
103
  export type HumanReviewInput = {