pr-shepherd 0.22.0 → 0.24.0
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/.claude-plugin/plugin.json +1 -1
- package/README.md +87 -125
- package/bin/cli/args.mjs +2 -0
- package/bin/cli/fix-formatter.mjs +3 -1
- package/bin/cli/formatters.mjs +3 -45
- package/bin/cli/handlers.mjs +22 -1
- package/bin/cli/help-command-pages.mjs +27 -2
- package/bin/cli/help-top-page.mjs +2 -0
- package/bin/cli/iterate-instructions.mjs +1 -1
- package/bin/cli/list-formatters.mjs +5 -2
- package/bin/cli/mark-files-as-viewed-flags.mjs +34 -0
- package/bin/cli/mark-files-as-viewed-formatter.mjs +52 -0
- package/bin/cli/mutate-formatter.mjs +50 -0
- package/bin/cli-parser.mjs +11 -2
- package/bin/commands/check.mjs +25 -56
- package/bin/commands/commit-suggestion-instruction.mjs +1 -1
- package/bin/commands/iterate/classify.mjs +32 -31
- package/bin/commands/iterate/fix-code.mjs +23 -19
- package/bin/commands/iterate/index.mjs +4 -1
- package/bin/commands/iterate/render.mjs +6 -3
- package/bin/commands/iterate/stall.mjs +1 -1
- package/bin/commands/mark-files-as-viewed.mjs +220 -0
- package/bin/commands/resolve-instructions.mjs +5 -2
- package/bin/commands/resolve-mutate.mjs +49 -4
- package/bin/commands/resolve.mjs +21 -78
- package/bin/commands/shepherd-journal.mjs +1 -1
- package/bin/comments/authors.mjs +32 -0
- package/bin/comments/minimize-policy.mjs +8 -4
- package/bin/comments/pending-ops.mjs +6 -0
- package/bin/comments/resolve.mjs +28 -11
- package/bin/comments/review-thread-markers.mjs +18 -0
- package/bin/comments/review-visibility.mjs +14 -0
- package/bin/comments/thread-visibility.mjs +60 -0
- package/bin/comments/visible-comments.mjs +2 -2
- package/bin/config/load.mjs +7 -0
- package/bin/config.json +14 -0
- package/bin/github/batch-parser-helpers.mjs +3 -4
- package/bin/github/batch-parsers.mjs +8 -6
- package/bin/github/client.mjs +1 -2
- package/bin/github/gql/batch-pr.gql +3 -0
- package/bin/reporters/agent.mjs +2 -0
- package/bin/state/seen-comments.mjs +40 -4
- package/bin/threads/transcript.mjs +6 -6
- package/package.json +8 -4
- package/plugins/pr-shepherd/.codex-plugin/plugin.json +1 -1
- package/plugins/pr-shepherd/skills/mark-files-as-viewed/SKILL.md +31 -0
- package/bin/checks/triage.test-support.mjs +0 -60
- package/bin/cli/iterate-lean.test-support.mjs +0 -3
- package/bin/cli-parser.clean.test-support.mjs +0 -44
- package/bin/cli-parser.commit-suggestion.test-support.mjs +0 -65
- package/bin/cli-parser.iterate-fix.test-support.mjs +0 -43
- package/bin/cli-parser.iterate-fixtures.mjs +0 -75
- package/bin/cli-parser.iterate.test-support.mjs +0 -44
- package/bin/cli-parser.test-support.mjs +0 -42
- package/bin/commands/check.test-support.mjs +0 -147
- package/bin/commands/clean.test-support.mjs +0 -47
- package/bin/commands/commit-suggestion.apply.test-support.mjs +0 -87
- package/bin/commands/commit-suggestion.test-support.mjs +0 -112
- package/bin/commands/iterate-stall.test-support.mjs +0 -24
- package/bin/commands/iterate-test-support.mjs +0 -150
- package/bin/commands/iterate.fix-code-in-progress.test-support.mjs +0 -123
- package/bin/commands/poll.test-support.mjs +0 -77
- package/bin/commands/resolve.test-support.mjs +0 -114
- package/bin/commands/shepherd-journal.test-support.mjs +0 -7
- package/bin/comments/outdated.mjs +0 -15
- package/bin/comments/resolve.test-support.mjs +0 -39
- package/bin/github/batch-parsers.test-support.mjs +0 -66
- package/bin/github/batch.test-support.mjs +0 -66
- package/bin/github/client.test-support.mjs +0 -55
- package/bin/github/http.test-support.mjs +0 -51
- package/bin/state/seen-comments.test-support.mjs +0 -19
- package/bin/suggestions/patch.test-support.mjs +0 -2
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { vi, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { _resetTokenCache } from "./http.mjs";
|
|
3
|
-
export const mockFetch = vi.fn();
|
|
4
|
-
vi.stubGlobal("fetch", mockFetch);
|
|
5
|
-
const { _mockExecFile } = vi.hoisted(() => ({ _mockExecFile: vi.fn() }));
|
|
6
|
-
export const mockExecFile = _mockExecFile;
|
|
7
|
-
vi.mock("node:child_process", () => ({
|
|
8
|
-
execFile: (cmd, args, optsOrCb, maybeCb) => {
|
|
9
|
-
const cb = typeof optsOrCb === "function" ? optsOrCb : maybeCb;
|
|
10
|
-
_mockExecFile(cmd, args)
|
|
11
|
-
.then((result) => cb(null, result))
|
|
12
|
-
.catch((err) => cb(err, { stdout: "", stderr: "" }));
|
|
13
|
-
},
|
|
14
|
-
}));
|
|
15
|
-
export function gqlOk(data) {
|
|
16
|
-
return {
|
|
17
|
-
ok: true,
|
|
18
|
-
status: 200,
|
|
19
|
-
headers: new Headers({ "content-type": "application/json" }),
|
|
20
|
-
json: () => Promise.resolve({ data }),
|
|
21
|
-
text: () => Promise.resolve(JSON.stringify({ data })),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export function restOk(data) {
|
|
25
|
-
return {
|
|
26
|
-
ok: true,
|
|
27
|
-
status: 200,
|
|
28
|
-
headers: new Headers({ "content-type": "application/json" }),
|
|
29
|
-
json: () => Promise.resolve(data),
|
|
30
|
-
text: () => Promise.resolve(JSON.stringify(data)),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export function gqlErrors(errors) {
|
|
34
|
-
return {
|
|
35
|
-
ok: true,
|
|
36
|
-
status: 200,
|
|
37
|
-
headers: new Headers({ "content-type": "application/json" }),
|
|
38
|
-
json: () => Promise.resolve({ data: null, errors }),
|
|
39
|
-
text: () => Promise.resolve(JSON.stringify({ data: null, errors })),
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export function registerClientHooks() {
|
|
43
|
-
beforeEach(() => {
|
|
44
|
-
mockFetch.mockReset();
|
|
45
|
-
mockExecFile.mockReset();
|
|
46
|
-
_resetTokenCache();
|
|
47
|
-
delete process.env["GITHUB_TOKEN"];
|
|
48
|
-
delete process.env["GITHUB_PERSONAL_ACCESS_TOKEN"];
|
|
49
|
-
process.env["GH_TOKEN"] = "test-token";
|
|
50
|
-
});
|
|
51
|
-
afterEach(() => {
|
|
52
|
-
delete process.env["GH_TOKEN"];
|
|
53
|
-
_resetTokenCache();
|
|
54
|
-
});
|
|
55
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { vi, beforeEach } from "vitest";
|
|
2
|
-
// ---------------------------------------------------------------------------
|
|
3
|
-
// Stub fetch and child_process globally before any imports.
|
|
4
|
-
// ---------------------------------------------------------------------------
|
|
5
|
-
const mockFetch = vi.fn();
|
|
6
|
-
vi.stubGlobal("fetch", mockFetch);
|
|
7
|
-
const { mockExecFile } = vi.hoisted(() => ({ mockExecFile: vi.fn() }));
|
|
8
|
-
vi.mock("node:child_process", () => ({
|
|
9
|
-
execFile: (cmd, args, optsOrCb, maybeCb) => {
|
|
10
|
-
const cb = typeof optsOrCb === "function" ? optsOrCb : maybeCb;
|
|
11
|
-
mockExecFile(cmd, args)
|
|
12
|
-
.then((result) => cb(null, result))
|
|
13
|
-
.catch((err) => cb(err, { stdout: "", stderr: "" }));
|
|
14
|
-
},
|
|
15
|
-
}));
|
|
16
|
-
import { GitHubRequestError, graphql, graphqlWithRateLimit, rest, restText, _resetTokenCache, } from "./http.mjs";
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
// Helpers
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
|
-
function jsonOk(data) {
|
|
21
|
-
return {
|
|
22
|
-
ok: true,
|
|
23
|
-
status: 200,
|
|
24
|
-
headers: new Headers({ "content-type": "application/json" }),
|
|
25
|
-
json: () => Promise.resolve(data),
|
|
26
|
-
text: () => Promise.resolve(JSON.stringify(data)),
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function gqlOk(data) {
|
|
30
|
-
return {
|
|
31
|
-
ok: true,
|
|
32
|
-
status: 200,
|
|
33
|
-
headers: new Headers({ "content-type": "application/json" }),
|
|
34
|
-
json: () => Promise.resolve({ data }),
|
|
35
|
-
text: () => Promise.resolve(JSON.stringify({ data })),
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
// ---------------------------------------------------------------------------
|
|
39
|
-
// Token resolution
|
|
40
|
-
// ---------------------------------------------------------------------------
|
|
41
|
-
export function registerHooks() {
|
|
42
|
-
beforeEach(() => {
|
|
43
|
-
mockFetch.mockReset();
|
|
44
|
-
mockExecFile.mockReset();
|
|
45
|
-
_resetTokenCache();
|
|
46
|
-
delete process.env["GH_TOKEN"];
|
|
47
|
-
delete process.env["GITHUB_TOKEN"];
|
|
48
|
-
delete process.env["GITHUB_PERSONAL_ACCESS_TOKEN"];
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
export { GitHubRequestError, _resetTokenCache, gqlOk, graphql, graphqlWithRateLimit, jsonOk, mockExecFile, mockFetch, rest, restText, };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { randomBytes, createHash } from "node:crypto";
|
|
3
|
-
import { rm } from "node:fs/promises";
|
|
4
|
-
export function idToFilename(id) {
|
|
5
|
-
return createHash("sha256").update(id, "utf8").digest("hex") + ".json";
|
|
6
|
-
}
|
|
7
|
-
export const testKey = { owner: "test-owner", repo: "test-repo", pr: 123 };
|
|
8
|
-
export const testId = "PRRT_kwDOTest123";
|
|
9
|
-
export let testStateDir;
|
|
10
|
-
export function registerHooks() {
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
testStateDir = `${process.env["TMPDIR"] ?? "/tmp"}/shepherd-seen-test-${randomBytes(4).toString("hex")}`;
|
|
13
|
-
process.env["PR_SHEPHERD_STATE_DIR"] = testStateDir;
|
|
14
|
-
});
|
|
15
|
-
afterEach(async () => {
|
|
16
|
-
delete process.env["PR_SHEPHERD_STATE_DIR"];
|
|
17
|
-
await rm(testStateDir, { recursive: true, force: true });
|
|
18
|
-
});
|
|
19
|
-
}
|