co-maintainer 0.6.13 → 0.7.0-beta.1
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.
- package/README.md +1 -1
- package/dist/package.json +1 -1
- package/dist/src/ai/anthropic.js +2 -0
- package/dist/src/ai/batch.d.ts +3 -1
- package/dist/src/ai/batch.js +23 -2
- package/dist/src/ai/mermaid_loop.js +1 -1
- package/dist/src/ai/oauth/sign-in-with-chatgpt.js +8 -10
- package/dist/src/ai/openai.js +2 -0
- package/dist/src/ai/openrouter.js +2 -0
- package/dist/src/cli/args.js +47 -0
- package/dist/src/cli/command_json.d.ts +20 -1
- package/dist/src/cli/command_json.js +4 -0
- package/dist/src/cli/commands/config.d.ts +1 -1
- package/dist/src/cli/commands/config.js +1 -0
- package/dist/src/cli/commands/registry.js +226 -1
- package/dist/src/cli/commands/review.js +50 -9
- package/dist/src/cli/commands/serve.js +5 -0
- package/dist/src/cli/commands/set.js +70 -2
- package/dist/src/cli/commands/view.js +46 -5
- package/dist/src/cli/commands/view_sources.d.ts +11 -0
- package/dist/src/cli/commands/view_sources.js +40 -0
- package/dist/src/cli/main.js +5 -0
- package/dist/src/cli/pr_carry.d.ts +25 -0
- package/dist/src/cli/pr_carry.js +128 -0
- package/dist/src/cli/prompt.js +26 -1
- package/dist/src/cli/review_args.d.ts +8 -0
- package/dist/src/cli/review_args.js +18 -0
- package/dist/src/cli/review_carry.d.ts +32 -0
- package/dist/src/cli/review_carry.js +60 -0
- package/dist/src/cli/review_github.d.ts +16 -2
- package/dist/src/cli/review_github.js +49 -12
- package/dist/src/cli/review_intent.d.ts +25 -0
- package/dist/src/cli/review_intent.js +87 -0
- package/dist/src/cli/review_result.d.ts +53 -2
- package/dist/src/cli/review_result.js +90 -23
- package/dist/src/config.d.ts +27 -0
- package/dist/src/config.js +20 -12
- package/dist/src/extensions/command.d.ts +1 -0
- package/dist/src/extensions/command.js +355 -0
- package/dist/src/extensions/contexts.d.ts +65 -0
- package/dist/src/extensions/contexts.js +134 -0
- package/dist/src/extensions/cost.d.ts +8 -0
- package/dist/src/extensions/cost.js +6 -0
- package/dist/src/extensions/local_tracking.d.ts +7 -0
- package/dist/src/extensions/local_tracking.js +29 -0
- package/dist/src/extensions/mock.d.ts +29 -0
- package/dist/src/extensions/mock.js +67 -0
- package/dist/src/extensions/process.d.ts +43 -0
- package/dist/src/extensions/process.js +244 -0
- package/dist/src/extensions/registry.d.ts +79 -0
- package/dist/src/extensions/registry.js +240 -0
- package/dist/src/extensions/render_actions.d.ts +6 -0
- package/dist/src/extensions/render_actions.js +50 -0
- package/dist/src/extensions/render_cli.d.ts +18 -0
- package/dist/src/extensions/render_cli.js +88 -0
- package/dist/src/extensions/render_json.d.ts +51 -0
- package/dist/src/extensions/render_json.js +144 -0
- package/dist/src/extensions/render_markdown.d.ts +22 -0
- package/dist/src/extensions/render_markdown.js +96 -0
- package/dist/src/extensions/render_review.d.ts +44 -0
- package/dist/src/extensions/render_review.js +167 -0
- package/dist/src/extensions/report.d.ts +57 -0
- package/dist/src/extensions/report.js +97 -0
- package/dist/src/extensions/review_result.d.ts +2 -0
- package/dist/src/extensions/review_result.js +14 -0
- package/dist/src/extensions/run_folder.d.ts +74 -0
- package/dist/src/extensions/run_folder.js +172 -0
- package/dist/src/extensions/runner.d.ts +66 -0
- package/dist/src/extensions/runner.js +251 -0
- package/dist/src/extensions/schema.d.ts +103 -0
- package/dist/src/extensions/schema.js +539 -0
- package/dist/src/extensions/session.d.ts +56 -0
- package/dist/src/extensions/session.js +173 -0
- package/dist/src/github/collect.d.ts +7 -2
- package/dist/src/github/collect.js +66 -6
- package/dist/src/github/gh.d.ts +7 -0
- package/dist/src/github/gh.js +24 -29
- package/dist/src/knowledge/guide.js +3 -2
- package/dist/src/knowledge/instruction_files.d.ts +45 -0
- package/dist/src/knowledge/instruction_files.js +91 -0
- package/dist/src/knowledge/instructions.d.ts +78 -0
- package/dist/src/knowledge/instructions.js +280 -0
- package/dist/src/knowledge/rule_changes.d.ts +39 -0
- package/dist/src/knowledge/rule_changes.js +90 -0
- package/dist/src/knowledge/rules.d.ts +44 -0
- package/dist/src/knowledge/rules.js +82 -0
- package/dist/src/knowledge/synthesis.d.ts +1 -0
- package/dist/src/knowledge/synthesis.js +12 -5
- package/dist/src/knowledge/types.d.ts +4 -0
- package/dist/src/local/carry_over_store.d.ts +10 -0
- package/dist/src/local/carry_over_store.js +17 -0
- package/dist/src/local/review_local.js +100 -62
- package/dist/src/local/review_lock.js +15 -4
- package/dist/src/pr/diff_plan.d.ts +110 -0
- package/dist/src/pr/diff_plan.js +429 -0
- package/dist/src/pr/diff_summary.d.ts +17 -1
- package/dist/src/pr/diff_summary.js +87 -13
- package/dist/src/pr/review_diff.d.ts +47 -0
- package/dist/src/pr/review_diff.js +112 -0
- package/dist/src/pr/reviewer.d.ts +44 -19
- package/dist/src/pr/reviewer.js +114 -142
- package/dist/src/remote/client.js +67 -8
- package/dist/src/remote/http.d.ts +12 -0
- package/dist/src/remote/http.js +31 -0
- package/dist/src/remote/push_client.js +14 -3
- package/dist/src/remote/server/guides.js +12 -1
- package/dist/src/remote/server/routes.js +4 -2
- package/dist/src/remote/server/sessions.js +4 -1
- package/dist/src/remote/validate.js +11 -0
- package/dist/src/review/carry_over.d.ts +6 -1
- package/dist/src/review/carry_over.js +10 -2
- package/dist/src/review/coverage.d.ts +57 -0
- package/dist/src/review/coverage.js +186 -0
- package/dist/src/review/diagram.d.ts +73 -0
- package/dist/src/review/diagram.js +309 -0
- package/dist/src/review/engine.d.ts +2 -6
- package/dist/src/review/engine.js +1 -1
- package/dist/src/review/guides.d.ts +6 -0
- package/dist/src/review/guides.js +8 -1
- package/dist/src/review/intent.d.ts +24 -0
- package/dist/src/review/intent.js +28 -0
- package/dist/src/review/not_initialized.d.ts +13 -0
- package/dist/src/review/not_initialized.js +18 -0
- package/dist/src/review/system_prompt.d.ts +6 -0
- package/dist/src/review/system_prompt.js +13 -0
- package/dist/src/review/visible_paths.d.ts +22 -0
- package/dist/src/review/visible_paths.js +41 -0
- package/dist/src/server/pages/extensions.d.ts +5 -0
- package/dist/src/server/pages/extensions.js +72 -0
- package/dist/src/server/pages/pr.js +3 -2
- package/dist/src/services/dashboard.d.ts +8 -0
- package/dist/src/services/dashboard.js +8 -0
- package/dist/src/services/push_review.js +14 -5
- package/dist/src/services/remote_review.js +81 -26
- package/dist/src/services/replies.js +15 -8
- package/dist/src/services/review.d.ts +9 -3
- package/dist/src/services/review.js +109 -28
- package/dist/src/services/rules_build.d.ts +46 -0
- package/dist/src/services/rules_build.js +155 -0
- package/dist/src/services/setup.d.ts +31 -0
- package/dist/src/services/setup.js +120 -25
- package/dist/src/services/watch_comments.js +2 -0
- package/dist/src/store/cache_db.js +3 -0
- package/dist/src/store/extensions.d.ts +51 -0
- package/dist/src/store/extensions.js +132 -0
- package/dist/src/store/migrations.js +40 -0
- package/dist/src/types.d.ts +22 -1
- package/dist/src/util/atomic.d.ts +15 -1
- package/dist/src/util/atomic.js +59 -29
- package/dist/src/util/interrupt.d.ts +6 -0
- package/dist/src/util/interrupt.js +27 -0
- package/dist/src/util/runtime.d.ts +3 -1
- package/dist/src/util/runtime.js +2 -2
- package/dist/src/util/test_location_guard.d.ts +6 -0
- package/dist/src/util/test_location_guard.js +47 -0
- package/package.json +1 -1
package/dist/src/util/atomic.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { basename, dirname } from "node:path";
|
|
2
|
-
import { isNotFound, isWindows, mkdir, readDir, remove, rename, stat, writeTextFile, } from "../util/runtime.js";
|
|
2
|
+
import { chmod, isNotFound, isWindows, mkdir, readDir, remove, rename, stat, writeTextFile, } from "../util/runtime.js";
|
|
3
3
|
function tempName(dir, base) {
|
|
4
4
|
return `${dir}/.${base}.tmp-${crypto.randomUUID()}`;
|
|
5
5
|
}
|
|
@@ -34,26 +34,9 @@ async function pathExists(path) {
|
|
|
34
34
|
return false;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
|
|
40
|
-
if (!(await pathExists(path))) {
|
|
41
|
-
await rename(temp, path);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const backup = `${path}.atomic-backup`;
|
|
45
|
-
await remove(backup).catch(() => { });
|
|
46
|
-
await rename(path, backup);
|
|
47
|
-
try {
|
|
48
|
-
await rename(temp, path);
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
await rename(backup, path).catch(() => { });
|
|
52
|
-
throw error;
|
|
53
|
-
}
|
|
54
|
-
await remove(backup).catch(() => { });
|
|
55
|
-
}
|
|
56
|
-
/** Write then rename into place so readers never see a half-written file. */
|
|
37
|
+
/** Older releases replaced a file on Windows by moving it to a backup name
|
|
38
|
+
* first. A run killed between the two renames left only the backup, so put it
|
|
39
|
+
* back before writing. */
|
|
57
40
|
async function recoverWindowsAtomicBackup(path) {
|
|
58
41
|
if (!isWindows())
|
|
59
42
|
return;
|
|
@@ -62,17 +45,64 @@ async function recoverWindowsAtomicBackup(path) {
|
|
|
62
45
|
await rename(backup, path);
|
|
63
46
|
}
|
|
64
47
|
}
|
|
65
|
-
|
|
48
|
+
const defaultIo = {
|
|
49
|
+
writeTextFile: (path, text, mode) => writeTextFile(path, text, mode === undefined ? undefined : { mode }),
|
|
50
|
+
rename,
|
|
51
|
+
windows: isWindows(),
|
|
52
|
+
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
53
|
+
};
|
|
54
|
+
/** How long a Windows rename waits between tries when another program holds
|
|
55
|
+
* the target open. About a second in all, enough for a reader or a virus
|
|
56
|
+
* scanner to let go, short enough that a stuck file fails the command. */
|
|
57
|
+
const WINDOWS_RENAME_DELAYS_MS = [10, 20, 40, 80, 160, 320, 400];
|
|
58
|
+
function errorCode(error) {
|
|
59
|
+
return error instanceof Error && "code" in error
|
|
60
|
+
? String(error.code)
|
|
61
|
+
: undefined;
|
|
62
|
+
}
|
|
63
|
+
/** Node's rename replaces an existing file on every platform. On Windows it
|
|
64
|
+
* fails with EPERM, EBUSY or EACCES while another program has the target open
|
|
65
|
+
* without delete sharing, which a reader or a virus scanner can do for a
|
|
66
|
+
* moment. Those are retried briefly, then reported with the file's name. */
|
|
67
|
+
async function replaceWithRetry(io, temp, path) {
|
|
68
|
+
for (let attempt = 0;; attempt++) {
|
|
69
|
+
try {
|
|
70
|
+
await io.rename(temp, path);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
const code = errorCode(error);
|
|
75
|
+
const busy = code === "EPERM" || code === "EBUSY" || code === "EACCES";
|
|
76
|
+
if (!io.windows || !busy)
|
|
77
|
+
throw error;
|
|
78
|
+
const delay = WINDOWS_RENAME_DELAYS_MS[attempt];
|
|
79
|
+
if (delay === undefined) {
|
|
80
|
+
throw new Error(`Could not replace ${path}: another program keeps it open (${code}). Close it and try again.`, { cause: error });
|
|
81
|
+
}
|
|
82
|
+
await io.sleep(delay);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** Writes a temp file beside `path`, then renames it over `path`, so a reader
|
|
87
|
+
* in this or another process sees the old file or the new one, never half of
|
|
88
|
+
* one. `mode` is set on the temp file before the rename, so the real file never
|
|
89
|
+
* exists with a wider mode. The temp file is removed when any step fails. */
|
|
90
|
+
export async function writeTextFileAtomic(path, text, options = {}, io = defaultIo) {
|
|
66
91
|
await recoverWindowsAtomicBackup(path);
|
|
67
92
|
const dir = dirname(path);
|
|
68
93
|
await mkdir(dir, { recursive: true });
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
94
|
+
const temp = tempName(dir, basename(path));
|
|
95
|
+
try {
|
|
96
|
+
await io.writeTextFile(temp, text, options.mode);
|
|
97
|
+
if (options.mode !== undefined) {
|
|
98
|
+
// The mode given at creation is narrowed by the umask. chmod sets it
|
|
99
|
+
// exactly. Windows has no POSIX modes, so a failure there is expected.
|
|
100
|
+
await chmod(temp, options.mode).catch(() => { });
|
|
101
|
+
}
|
|
102
|
+
await replaceWithRetry(io, temp, path);
|
|
74
103
|
}
|
|
75
|
-
|
|
76
|
-
await
|
|
104
|
+
catch (error) {
|
|
105
|
+
await remove(temp).catch(() => { });
|
|
106
|
+
throw error;
|
|
77
107
|
}
|
|
78
108
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Starts a run that Ctrl-C can stop. Returns the controller to abort. */
|
|
2
|
+
export declare function armInterrupt(): AbortController;
|
|
3
|
+
export declare function disarmInterrupt(): void;
|
|
4
|
+
/** The signal every AI request carries, or `undefined` when no run is armed. */
|
|
5
|
+
export declare function interruptSignal(): AbortSignal | undefined;
|
|
6
|
+
export declare function interrupted(): boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Ctrl-C for a CLI run that must stop its model calls.
|
|
2
|
+
*
|
|
3
|
+
* A local review arms this while it runs. On SIGINT or SIGTERM it aborts the
|
|
4
|
+
* signal, and every AI provider passes the signal to `fetch`: the call in
|
|
5
|
+
* flight stops at once and no new call is sent. The alternative,
|
|
6
|
+
* `process.exit`, asserts in libuv on Windows while a fetch is open (see
|
|
7
|
+
* `exitWith`). When nothing is armed, as in `serve`, the signal is
|
|
8
|
+
* `undefined` and requests run exactly as before. */
|
|
9
|
+
import { setMaxListeners } from "node:events";
|
|
10
|
+
let controller;
|
|
11
|
+
/** Starts a run that Ctrl-C can stop. Returns the controller to abort. */
|
|
12
|
+
export function armInterrupt() {
|
|
13
|
+
controller = new AbortController();
|
|
14
|
+
// A sync before the review runs many calls at once, each one listening.
|
|
15
|
+
setMaxListeners(0, controller.signal);
|
|
16
|
+
return controller;
|
|
17
|
+
}
|
|
18
|
+
export function disarmInterrupt() {
|
|
19
|
+
controller = undefined;
|
|
20
|
+
}
|
|
21
|
+
/** The signal every AI request carries, or `undefined` when no run is armed. */
|
|
22
|
+
export function interruptSignal() {
|
|
23
|
+
return controller?.signal;
|
|
24
|
+
}
|
|
25
|
+
export function interrupted() {
|
|
26
|
+
return controller?.signal.aborted === true;
|
|
27
|
+
}
|
|
@@ -21,7 +21,9 @@ export declare function removeSync(path: string | URL, options?: {
|
|
|
21
21
|
export declare function statSync(path: string | URL): Stats;
|
|
22
22
|
export declare function readTextFile(path: string | URL): Promise<string>;
|
|
23
23
|
export declare function readFile(path: string | URL): Promise<Uint8Array>;
|
|
24
|
-
export declare function writeTextFile(path: string | URL, text: string
|
|
24
|
+
export declare function writeTextFile(path: string | URL, text: string, options?: {
|
|
25
|
+
mode?: number;
|
|
26
|
+
}): Promise<void>;
|
|
25
27
|
export declare function writeFile(path: string | URL, data: Uint8Array | string): Promise<void>;
|
|
26
28
|
export declare function mkdir(path: string | URL, options?: {
|
|
27
29
|
recursive?: boolean;
|
package/dist/src/util/runtime.js
CHANGED
|
@@ -76,8 +76,8 @@ export function readTextFile(path) {
|
|
|
76
76
|
export function readFile(path) {
|
|
77
77
|
return fsReadFile(path);
|
|
78
78
|
}
|
|
79
|
-
export function writeTextFile(path, text) {
|
|
80
|
-
return fsWriteFile(path, text);
|
|
79
|
+
export function writeTextFile(path, text, options) {
|
|
80
|
+
return fsWriteFile(path, text, options);
|
|
81
81
|
}
|
|
82
82
|
export function writeFile(path, data) {
|
|
83
83
|
return fsWriteFile(path, data);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Platform } from "./runtime.ts";
|
|
2
|
+
/** Throws when `dirFor` gives a directory outside the temp directory on any
|
|
3
|
+
* platform. Checking all three from one machine catches the test that moved
|
|
4
|
+
* only `XDG_CACHE_HOME`, which is isolated on Linux and shares the real
|
|
5
|
+
* `LOCALAPPDATA` on Windows. */
|
|
6
|
+
export declare function guardTestLocation(kind: "config" | "cache", dirFor: (os: Platform) => string): void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Keeps tests off the developer's real config, cache and database.
|
|
2
|
+
*
|
|
3
|
+
* Node's test runner runs each test file in its own process, at the same time.
|
|
4
|
+
* Two files that open the real cache.db lock each other out on Windows, and
|
|
5
|
+
* two suites run at once overwrite each other's rows. A test reaches the real
|
|
6
|
+
* locations by forgetting one environment variable, often one that only
|
|
7
|
+
* matters on another platform, so this check runs where the product resolves
|
|
8
|
+
* the config and cache directories, and fails the test that got there.
|
|
9
|
+
*
|
|
10
|
+
* It is on only in a process `node --test` started, or a child of one, which
|
|
11
|
+
* Node marks with NODE_TEST_CONTEXT, and only when the code runs from the
|
|
12
|
+
* TypeScript sources. The published package is compiled `.js`, so the check
|
|
13
|
+
* never runs for a user, even inside the user's own test suite. */
|
|
14
|
+
import { tmpdir } from "node:os";
|
|
15
|
+
import { resolve, sep } from "node:path";
|
|
16
|
+
import { getEnv, isWindows } from "./runtime.js";
|
|
17
|
+
const active = getEnv("NODE_TEST_CONTEXT") !== undefined && import.meta.url.endsWith(".ts");
|
|
18
|
+
const PLATFORMS = ["linux", "windows", "darwin"];
|
|
19
|
+
function insideTemp(path) {
|
|
20
|
+
const fold = (value) => (isWindows() ? value.toLowerCase() : value);
|
|
21
|
+
// A Windows-style path resolved on Linux keeps its backslashes as part of
|
|
22
|
+
// one name, which still sits under the temp directory when its home does.
|
|
23
|
+
const temp = fold(resolve(tmpdir()));
|
|
24
|
+
const target = fold(resolve(path));
|
|
25
|
+
return target === temp || target.startsWith(`${temp}${sep}`);
|
|
26
|
+
}
|
|
27
|
+
/** Throws when `dirFor` gives a directory outside the temp directory on any
|
|
28
|
+
* platform. Checking all three from one machine catches the test that moved
|
|
29
|
+
* only `XDG_CACHE_HOME`, which is isolated on Linux and shares the real
|
|
30
|
+
* `LOCALAPPDATA` on Windows. */
|
|
31
|
+
export function guardTestLocation(kind, dirFor) {
|
|
32
|
+
if (!active)
|
|
33
|
+
return;
|
|
34
|
+
for (const os of PLATFORMS) {
|
|
35
|
+
let dir;
|
|
36
|
+
try {
|
|
37
|
+
dir = dirFor(os);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// No home directory at all. The real lookup reports that itself.
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (!insideTemp(dir)) {
|
|
44
|
+
throw new Error(`A test reached the real ${kind} directory ${dir} (resolved as on ${os}). Call isolateTestFile() from src/testing/locations.ts at the top of the test file, or move HOME, USERPROFILE, XDG_CONFIG_HOME, XDG_CACHE_HOME, APPDATA and LOCALAPPDATA into a temp directory.`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|