co-maintainer 0.6.8 → 0.6.10

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 (75) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/src/ai/fake.d.ts +10 -1
  3. package/dist/src/ai/fake.js +39 -4
  4. package/dist/src/cli/args.js +2 -0
  5. package/dist/src/cli/command_json.d.ts +6 -0
  6. package/dist/src/cli/command_json.js +1 -0
  7. package/dist/src/cli/commands/probe.js +25 -0
  8. package/dist/src/cli/commands/registry.js +11 -0
  9. package/dist/src/cli/commands/review.js +5 -1
  10. package/dist/src/cli/commands/serve.js +10 -0
  11. package/dist/src/cli/commands/set.js +23 -2
  12. package/dist/src/cli/review_args.d.ts +9 -0
  13. package/dist/src/cli/review_args.js +36 -1
  14. package/dist/src/cli/review_github.js +6 -2
  15. package/dist/src/cli/review_result.js +6 -5
  16. package/dist/src/github/app.d.ts +4 -0
  17. package/dist/src/github/app.js +10 -1
  18. package/dist/src/github/permissions.js +40 -0
  19. package/dist/src/local/git_ops.js +3 -2
  20. package/dist/src/local/git_revision.d.ts +5 -2
  21. package/dist/src/local/git_revision.js +17 -10
  22. package/dist/src/pr/checkout.js +14 -5
  23. package/dist/src/pr/codegraph_tools.js +5 -3
  24. package/dist/src/pr/reviewer.d.ts +2 -0
  25. package/dist/src/pr/reviewer.js +1 -1
  26. package/dist/src/remote/client.js +14 -4
  27. package/dist/src/remote/push_client.d.ts +7 -0
  28. package/dist/src/remote/push_client.js +287 -0
  29. package/dist/src/remote/server/body.d.ts +11 -0
  30. package/dist/src/remote/server/body.js +14 -5
  31. package/dist/src/remote/server/routes.d.ts +1 -0
  32. package/dist/src/remote/server/routes.js +61 -4
  33. package/dist/src/remote/server/sync.js +11 -3
  34. package/dist/src/remote/validate.js +17 -0
  35. package/dist/src/server/api/repos.js +13 -2
  36. package/dist/src/server/app.js +5 -6
  37. package/dist/src/server/http.js +5 -0
  38. package/dist/src/server/pages/layout.js +1 -0
  39. package/dist/src/server/pages/repo.d.ts +3 -1
  40. package/dist/src/server/pages/repo.js +4 -1
  41. package/dist/src/server/pages/repo_pushes.d.ts +7 -0
  42. package/dist/src/server/pages/repo_pushes.js +144 -0
  43. package/dist/src/server/pages/repo_settings.js +45 -1
  44. package/dist/src/server/pages/router.js +34 -5
  45. package/dist/src/server/pages/settings.js +1 -1
  46. package/dist/src/server/webhook/index.js +24 -7
  47. package/dist/src/services/dashboard.d.ts +46 -0
  48. package/dist/src/services/dashboard.js +24 -0
  49. package/dist/src/services/jobs.js +18 -3
  50. package/dist/src/services/push_review.d.ts +51 -0
  51. package/dist/src/services/push_review.js +878 -0
  52. package/dist/src/services/setup.js +21 -0
  53. package/dist/src/services/watch_comments.d.ts +10 -0
  54. package/dist/src/services/watch_comments.js +179 -0
  55. package/dist/src/services/watch_issues.d.ts +70 -0
  56. package/dist/src/services/watch_issues.js +266 -0
  57. package/dist/src/services/watch_notes.d.ts +8 -0
  58. package/dist/src/services/watch_notes.js +80 -0
  59. package/dist/src/services/watch_status.d.ts +25 -0
  60. package/dist/src/services/watch_status.js +101 -0
  61. package/dist/src/services/webhook.js +107 -3
  62. package/dist/src/store/migrations.js +63 -0
  63. package/dist/src/store/repos.d.ts +1 -1
  64. package/dist/src/store/rows.d.ts +6 -0
  65. package/dist/src/store/sessions.d.ts +3 -0
  66. package/dist/src/store/sessions.js +5 -0
  67. package/dist/src/store/watch.d.ts +108 -0
  68. package/dist/src/store/watch.js +186 -0
  69. package/dist/src/types.d.ts +2 -0
  70. package/dist/src/util/repo_name.d.ts +2 -0
  71. package/dist/src/util/repo_name.js +56 -0
  72. package/dist/src/util/runtime.js +7 -0
  73. package/dist/src/util/sanitize.d.ts +6 -0
  74. package/dist/src/util/sanitize.js +10 -0
  75. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ /** The spelling to use for `name` (`owner/repo`). */
2
+ export declare function canonicalRepoName(name: string): string;
@@ -0,0 +1,56 @@
1
+ /** One spelling per repository (issue #67).
2
+ *
3
+ * GitHub treats `owner/repo` without regard to case, but co-maintainer keys a
4
+ * repository by its name: the `repos` entry in config.json, the guide folder
5
+ * and the app.db row. Typed two ways, it became two repositories.
6
+ *
7
+ * A name is matched against what is already stored, ignoring case, and the
8
+ * stored spelling wins, so nothing written before changes. A repository seen
9
+ * for the first time is stored in lower case. */
10
+ import { readdirSync } from "node:fs";
11
+ import { readConfig, reposDir } from "../config.js";
12
+ import { getAppDb, isAppDbOpen } from "../store/app_db.js";
13
+ function storedInDb(lower) {
14
+ if (!isAppDbOpen())
15
+ return undefined;
16
+ try {
17
+ return getAppDb()
18
+ .prepare(`SELECT full_name FROM repos WHERE lower(full_name) = ?
19
+ ORDER BY active DESC, created_at LIMIT 1`)
20
+ .get(lower)?.full_name;
21
+ }
22
+ catch {
23
+ return undefined;
24
+ }
25
+ }
26
+ function storedInConfig(lower) {
27
+ try {
28
+ return Object.keys(readConfig().repos ?? {}).find((name) => name.toLowerCase() === lower);
29
+ }
30
+ catch {
31
+ return undefined;
32
+ }
33
+ }
34
+ function caseInsensitiveEntry(dir, name) {
35
+ try {
36
+ return readdirSync(dir).find((entry) => entry.toLowerCase() === name.toLowerCase());
37
+ }
38
+ catch {
39
+ return undefined;
40
+ }
41
+ }
42
+ function storedOnDisk(lower) {
43
+ const [owner, repo] = lower.split("/");
44
+ const ownerDir = caseInsensitiveEntry(reposDir(), owner);
45
+ if (!ownerDir)
46
+ return undefined;
47
+ const repoDir = caseInsensitiveEntry(`${reposDir()}/${ownerDir}`, repo);
48
+ return repoDir ? `${ownerDir}/${repoDir}` : undefined;
49
+ }
50
+ /** The spelling to use for `name` (`owner/repo`). */
51
+ export function canonicalRepoName(name) {
52
+ const lower = name.toLowerCase();
53
+ if (!/^[^/]+\/[^/]+$/.test(lower))
54
+ return name;
55
+ return (storedInDb(lower) ?? storedInConfig(lower) ?? storedOnDisk(lower) ?? lower);
56
+ }
@@ -14,6 +14,13 @@ import { join } from "node:path";
14
14
  export function isWindows() {
15
15
  return process.platform === "win32";
16
16
  }
17
+ // Windows only: keep the current working directory out of the executable search
18
+ // path, so a `git.cmd` / `gh.exe` committed in a reviewed repository cannot run
19
+ // in place of the real tool. Set once at module load — before any child spawn —
20
+ // and inherited by every child process we start.
21
+ if (isWindows() && !process.env.NoDefaultCurrentDirectoryInExePath) {
22
+ process.env.NoDefaultCurrentDirectoryInExePath = "1";
23
+ }
17
24
  /** The current OS in the vocabulary the config paths already used under Deno
18
25
  * (`"windows"`, not Node's `"win32"`). */
19
26
  export function currentPlatform() {
@@ -0,0 +1,6 @@
1
+ /** Strip C0/C1 control characters, keeping tab and newline. Run this over any
2
+ * string that came from the model or a remote server before it is printed to a
3
+ * terminal or a CI log, so it cannot inject ANSI/OSC escape sequences (cursor
4
+ * moves, screen clears, OSC 52 clipboard writes, OSC 8 disguised links) or a
5
+ * bare carriage return that overwrites the line. */
6
+ export declare function stripControlChars(value: string): string;
@@ -0,0 +1,10 @@
1
+ /** Strip C0/C1 control characters, keeping tab and newline. Run this over any
2
+ * string that came from the model or a remote server before it is printed to a
3
+ * terminal or a CI log, so it cannot inject ANSI/OSC escape sequences (cursor
4
+ * moves, screen clears, OSC 52 clipboard writes, OSC 8 disguised links) or a
5
+ * bare carriage return that overwrites the line. */
6
+ export function stripControlChars(value) {
7
+ // Dropped: 00-08, 0B-1F (so \r too), DEL 7F, and C1 80-9F. Kept: \t and \n.
8
+ // eslint-disable-next-line no-control-regex -- matching control chars is the point
9
+ return value.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g, "");
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "co-maintainer",
3
- "version": "0.6.8",
3
+ "version": "0.6.10",
4
4
  "description": "An imitator of yours, A PR review tool like co-maintainer.",
5
5
  "keywords": [
6
6
  "ai",