co-maintainer 0.6.3 → 0.6.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.
Files changed (78) hide show
  1. package/THIRD_PARTY_NOTICES +161 -0
  2. package/dist/package.json +4 -2
  3. package/dist/src/ai/batch.js +7 -0
  4. package/dist/src/cli/args.js +21 -3
  5. package/dist/src/cli/commands/registry.js +38 -3
  6. package/dist/src/cli/commands/serve.js +31 -3
  7. package/dist/src/cli/commands/set.js +54 -0
  8. package/dist/src/config.d.ts +14 -0
  9. package/dist/src/github/client.js +13 -0
  10. package/dist/src/github/permissions.js +8 -0
  11. package/dist/src/server/api/jobs.js +8 -1
  12. package/dist/src/server/api/repos.js +73 -11
  13. package/dist/src/server/api/settings.js +6 -0
  14. package/dist/src/server/app.d.ts +5 -0
  15. package/dist/src/server/app.js +7 -0
  16. package/dist/src/server/http.d.ts +3 -0
  17. package/dist/src/server/http.js +5 -0
  18. package/dist/src/server/pages/activity.js +412 -19
  19. package/dist/src/server/pages/add_repo.js +6 -1
  20. package/dist/src/server/pages/analytics.js +99 -31
  21. package/dist/src/server/pages/catalog.d.ts +1 -0
  22. package/dist/src/server/pages/catalog.js +145 -0
  23. package/dist/src/server/pages/client.d.ts +1 -1
  24. package/dist/src/server/pages/client.js +1 -1
  25. package/dist/src/server/pages/home.d.ts +14 -4
  26. package/dist/src/server/pages/home.js +83 -49
  27. package/dist/src/server/pages/icons.d.ts +3 -0
  28. package/dist/src/server/pages/icons.js +3 -0
  29. package/dist/src/server/pages/knowledge.js +10 -5
  30. package/dist/src/server/pages/layout.d.ts +19 -3
  31. package/dist/src/server/pages/layout.js +156 -33
  32. package/dist/src/server/pages/pr.js +4 -3
  33. package/dist/src/server/pages/rate_limit_waits.d.ts +5 -0
  34. package/dist/src/server/pages/rate_limit_waits.js +74 -0
  35. package/dist/src/server/pages/repo.js +100 -66
  36. package/dist/src/server/pages/repo_prs.js +4 -3
  37. package/dist/src/server/pages/repo_remote.js +4 -3
  38. package/dist/src/server/pages/repo_settings.d.ts +2 -2
  39. package/dist/src/server/pages/repo_settings.js +420 -46
  40. package/dist/src/server/pages/router.d.ts +5 -0
  41. package/dist/src/server/pages/router.js +82 -31
  42. package/dist/src/server/pages/settings.d.ts +10 -1
  43. package/dist/src/server/pages/settings.js +350 -206
  44. package/dist/src/server/pages/setup.d.ts +2 -5
  45. package/dist/src/server/pages/setup.js +21 -23
  46. package/dist/src/server/pages/styles.d.ts +1 -1
  47. package/dist/src/server/pages/styles.js +1 -1
  48. package/dist/src/server/pages/ui.d.ts +117 -0
  49. package/dist/src/server/pages/ui.js +166 -0
  50. package/dist/src/services/cli_repos.d.ts +2 -0
  51. package/dist/src/services/cli_repos.js +50 -0
  52. package/dist/src/services/concurrency.d.ts +39 -0
  53. package/dist/src/services/concurrency.js +88 -0
  54. package/dist/src/services/dashboard.d.ts +43 -1
  55. package/dist/src/services/dashboard.js +10 -2
  56. package/dist/src/services/jobs.js +5 -3
  57. package/dist/src/services/nav_counts.d.ts +8 -0
  58. package/dist/src/services/nav_counts.js +19 -0
  59. package/dist/src/services/rate_limit.d.ts +33 -0
  60. package/dist/src/services/rate_limit.js +78 -0
  61. package/dist/src/services/repo_list.d.ts +19 -0
  62. package/dist/src/services/repo_list.js +38 -0
  63. package/dist/src/services/review.d.ts +23 -1
  64. package/dist/src/services/review.js +165 -35
  65. package/dist/src/services/search.d.ts +13 -0
  66. package/dist/src/services/search.js +72 -0
  67. package/dist/src/services/setup.js +14 -4
  68. package/dist/src/services/setup_checklist.d.ts +1 -1
  69. package/dist/src/services/setup_checklist.js +26 -47
  70. package/dist/src/store/findings.d.ts +1 -1
  71. package/dist/src/store/findings.js +3 -3
  72. package/dist/src/store/migrations.js +7 -0
  73. package/dist/src/store/repos.d.ts +5 -0
  74. package/dist/src/store/repos.js +12 -0
  75. package/dist/src/store/reviews.d.ts +12 -1
  76. package/dist/src/store/reviews.js +34 -2
  77. package/dist/src/store/rows.d.ts +6 -0
  78. package/package.json +4 -2
@@ -26,7 +26,10 @@ export declare function insertReview(row: {
26
26
  }): void;
27
27
  /** Written immediately before and after the `POST .../reviews` call, with
28
28
  * nothing else run between either write and the call. */
29
- export declare function setReviewStatus(id: string, status: ReviewRow["status"], patch?: Partial<Pick<ReviewRow, "posted_review_id" | "findings_count" | "tokens_in" | "tokens_out" | "cost" | "cost_status" | "cost_note" | "billed_to" | "duration_ms" | "check_run_id" | "posted_fallback" | "open_count" | "closed_count" | "subject_id" | "guide_built_at">>): void;
29
+ export declare function setReviewStatus(id: string, status: ReviewRow["status"], patch?: Partial<Pick<ReviewRow, "posted_review_id" | "findings_count" | "tokens_in" | "tokens_out" | "cost" | "cost_status" | "cost_note" | "billed_to" | "duration_ms" | "check_run_id" | "posted_fallback" | "open_count" | "closed_count" | "subject_id" | "guide_built_at" | "note_comment_id">>): void;
30
+ /** The failure note another attempt already left for this exact push, so a
31
+ * retry edits that note rather than opening a second one. */
32
+ export declare function findNoteCommentId(repo: string, prNumber: number, headSha: string | null): string | undefined;
30
33
  export declare function setReviewScope(id: string, scope: string, baseSha: string): void;
31
34
  export declare function getReview(id: string): ReviewRow | undefined;
32
35
  export declare function getReviewByJobId(jobId: string): ReviewRow | undefined;
@@ -60,6 +63,14 @@ export declare function reviewStats(sinceIso: string, repo?: string, untilIso?:
60
63
  export declare function reviewStatsByRepo(sinceIso: string): (ReviewStats & {
61
64
  repo: string;
62
65
  })[];
66
+ export type ReviewKindBucket = "posted" | "not_posted" | "failed" | "cli";
67
+ /** Runs and cost per kind of review, for the Usage "By kind" table. A CLI
68
+ * (remote) review is its own bucket whatever its status, and every bucket is
69
+ * present, zero when nothing ran. */
70
+ export declare function reviewStatsByKind(sinceIso: string): (CostTotals & {
71
+ kind: ReviewKindBucket;
72
+ runs: number;
73
+ })[];
63
74
  export type DayStats = CostTotals & {
64
75
  day: string;
65
76
  reviews: number;
@@ -39,7 +39,8 @@ export function setReviewStatus(id, status, patch = {}) {
39
39
  check_run_id = COALESCE(?, check_run_id),
40
40
  posted_fallback = COALESCE(?, posted_fallback),
41
41
  subject_id = COALESCE(?, subject_id),
42
- guide_built_at = COALESCE(?, guide_built_at)
42
+ guide_built_at = COALESCE(?, guide_built_at),
43
+ note_comment_id = COALESCE(?, note_comment_id)
43
44
  WHERE id = ?`)
44
45
  .run(status, patch.posted_review_id ?? null, patch.findings_count ?? null, patch.open_count ?? null, patch.closed_count ?? null, patch.tokens_in ?? null, patch.tokens_out ?? null, patch.cost ?? null, patch.cost_status ?? null,
45
46
  // `cost_note` travels with `cost_status`: when the status changes to
@@ -47,7 +48,18 @@ export function setReviewStatus(id, status, patch = {}) {
47
48
  // null, which `COALESCE(?, cost_note)` cannot do since a provided
48
49
  // `null` and an omitted field bind the same way. The flag makes the
49
50
  // two cases distinguishable.
50
- patch.cost_status !== undefined, patch.cost_note ?? null, patch.billed_to ?? null, patch.duration_ms ?? null, patch.check_run_id ?? null, patch.posted_fallback ?? null, patch.subject_id ?? null, patch.guide_built_at ?? null, id);
51
+ patch.cost_status !== undefined, patch.cost_note ?? null, patch.billed_to ?? null, patch.duration_ms ?? null, patch.check_run_id ?? null, patch.posted_fallback ?? null, patch.subject_id ?? null, patch.guide_built_at ?? null, patch.note_comment_id ?? null, id);
52
+ }
53
+ /** The failure note another attempt already left for this exact push, so a
54
+ * retry edits that note rather than opening a second one. */
55
+ export function findNoteCommentId(repo, prNumber, headSha) {
56
+ if (!headSha)
57
+ return undefined;
58
+ return getAppDb()
59
+ .prepare(`SELECT note_comment_id FROM reviews
60
+ WHERE repo = ? AND pr_number = ? AND head_sha = ? AND note_comment_id IS NOT NULL
61
+ ORDER BY created_at DESC LIMIT 1`)
62
+ .get(repo, prNumber, headSha)?.note_comment_id;
51
63
  }
52
64
  export function setReviewScope(id, scope, baseSha) {
53
65
  getAppDb()
@@ -146,6 +158,26 @@ export function reviewStatsByRepo(sinceIso) {
146
158
  .all(sinceIso)
147
159
  .map((row) => ({ ...asStats(row), repo: row.repo }));
148
160
  }
161
+ /** Runs and cost per kind of review, for the Usage "By kind" table. A CLI
162
+ * (remote) review is its own bucket whatever its status, and every bucket is
163
+ * present, zero when nothing ran. */
164
+ export function reviewStatsByKind(sinceIso) {
165
+ const rows = getAppDb()
166
+ .prepare(`SELECT CASE
167
+ WHEN kind = 'remote' THEN 'cli'
168
+ WHEN status = 'failed' THEN 'failed'
169
+ WHEN status = 'not_posted' THEN 'not_posted'
170
+ ELSE 'posted' END AS kind,
171
+ COUNT(*) AS runs,
172
+ ${COST_COLUMNS}
173
+ FROM reviews WHERE created_at >= ?
174
+ GROUP BY 1`)
175
+ .all(sinceIso);
176
+ return ["posted", "not_posted", "failed", "cli"].map((kind) => {
177
+ const row = rows.find((r) => r.kind === kind);
178
+ return { ...asCostTotals(row), kind, runs: Number(row?.runs ?? 0) };
179
+ });
180
+ }
149
181
  export function reviewStatsByDay(sinceIso) {
150
182
  return getAppDb()
151
183
  .prepare(`SELECT substr(created_at, 1, 10) AS day,
@@ -27,6 +27,9 @@ export type RepoRow = {
27
27
  /** JSON: `"legacy"`, a template name, or a policy object. `null` takes the
28
28
  * server default. */
29
29
  review_policy_json: string | null;
30
+ /** `'cli'` when a CLI init built it, NULL when added from the dashboard.
31
+ * Optional so a row built by hand (a test fixture) need not name it. */
32
+ added_from?: string | null;
30
33
  };
31
34
  export type JobRow = {
32
35
  id: string;
@@ -86,6 +89,9 @@ export type ReviewRow = {
86
89
  posted_fallback: number;
87
90
  guide_built_at: string | null;
88
91
  codegraph: string | null;
92
+ /** The pull request issue comment a failed review left, so a retry edits it
93
+ * in place instead of posting a second note. */
94
+ note_comment_id: string | null;
89
95
  };
90
96
  export type FindingRow = {
91
97
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "co-maintainer",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "description": "An imitator of yours, A PR review tool like co-maintainer.",
5
5
  "keywords": [
6
6
  "ai",
@@ -24,7 +24,8 @@
24
24
  "files": [
25
25
  "dist/",
26
26
  "LICENSE",
27
- "README.md"
27
+ "README.md",
28
+ "THIRD_PARTY_NOTICES"
28
29
  ],
29
30
  "type": "module",
30
31
  "exports": {
@@ -52,6 +53,7 @@
52
53
  "bench-core-v3": "node benchmark/core_v3/run.ts",
53
54
  "swe-prbench-prepare": "node benchmark/swe-prbench/prepare_dataset.ts",
54
55
  "e2e": "node scripts/e2e.ts",
56
+ "e2e:fake": "node scripts/e2e_fake.ts",
55
57
  "review-local-e2e": "node scripts/review_local_e2e.ts",
56
58
  "docs:build": "node scripts/build_docs.ts",
57
59
  "pack:smoke": "node scripts/pack_smoke.ts",