@akagilnc/pi-workflow-roles 0.1.4403 → 0.1.4419
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 +4 -3
- package/README.zh-CN.md +5 -4
- package/THIRD_PARTY_NOTICES.md +8 -6
- package/dist/acp-host/production-host.js +249 -624
- package/dist/headless-host/production-host.js +251 -626
- package/dist/migrate-book-topology.js +23 -6
- package/dist/package-resources/method-skill.js +6 -1
- package/dist/pi/role-turn-host.js +3 -1
- package/dist/public-cli/invocation.js +83 -32
- package/dist/public-cli/main.js +240 -306
- package/dist/public-cli/option-definitions.js +23 -6
- package/dist/public-cli/post-admission.js +0 -4
- package/dist/public-cli/run-lifecycle.js +25 -4
- package/dist/public-cli/settlement.js +6 -77
- package/dist/role-activation-flags.js +1 -0
- package/extensions/role-runtime.ts +3 -5
- package/package.json +1 -1
- package/resources/836-deleted-machine-instruction-inventory.md +1 -1
- package/resources/methods/ak-cross-m-review/CONTEXT.md +48 -0
- package/resources/methods/ak-cross-m-review/LICENSE +21 -0
- package/resources/methods/ak-cross-m-review/SKILL.md +170 -0
- package/resources/methods/ak-cross-m-review/prompts/cmr-completeness.md +118 -0
- package/resources/methods/ak-cross-m-review/prompts/cmr-reviewer.md +128 -0
- package/resources/methods/ak-cross-m-review/provenance.json +41 -0
- package/souls/judge.md +1 -1
- package/souls/reviewer.md +1 -1
- package/src/archivist-record-entry.ts +1 -1
- package/src/canonical-skill-binding.ts +2 -2
- package/src/host-contracts.ts +2 -0
- package/src/package-contracts/reviewer-output.ts +4 -2
- package/src/package-resources/method-skill.ts +7 -2
- package/src/pi/role-turn-host.ts +3 -1
- package/src/public-cli/invocation.ts +108 -39
- package/src/public-cli/option-definitions.ts +23 -6
- package/src/public-cli/post-admission.ts +0 -4
- package/src/public-cli/reviewer-run.ts +39 -16
- package/src/public-cli/run-lifecycle.ts +33 -3
- package/src/public-cli/settlement.ts +8 -73
- package/src/reviewer-role.ts +27 -16
- package/src/role-activation-flags.ts +1 -0
- package/src/role-runtime-dependencies.ts +2 -4
- package/src/role-runtime.ts +9 -26
- package/src/worker-role.ts +1 -1
- package/dist/adr-path-refs.js +0 -23
- package/dist/public-cli/reviewer-dispatch-rejection.js +0 -77
- package/dist/reviewer-dispatch.js +0 -14
- package/dist/reviewer-git-snapshot.js +0 -32
- package/dist/reviewer-pinned-git.js +0 -308
- package/dist/reviewer-preflight-error.js +0 -15
- package/dist/reviewer-prompt-identity.js +0 -10
- package/resources/methods/code-review/SKILL.md +0 -92
- package/resources/methods/code-review/agents/openai.yaml +0 -3
- package/resources/methods/code-review/provenance.json +0 -26
- package/src/adr-path-refs.ts +0 -25
- package/src/public-cli/reviewer-dispatch-rejection.ts +0 -106
- package/src/reviewer-dispatch.ts +0 -39
- package/src/reviewer-git-snapshot.ts +0 -45
- package/src/reviewer-pinned-git.ts +0 -330
- package/src/reviewer-preflight-error.ts +0 -14
- package/src/reviewer-prompt-identity.ts +0 -17
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: code-review
|
|
3
|
-
description: Review the changes since a fixed point (commit, branch, tag, or merge-base) along two axes — Standards (does the code follow this repo's documented coding standards?) and Spec (does the code match what the originating issue/spec asked for?). Runs both reviews in parallel sub-agents and reports them side by side. Use when the user wants to review a branch, a PR, work-in-progress changes, or asks to "review since X".
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
Two-axis review of the diff between `HEAD` and a fixed point the user supplies:
|
|
7
|
-
|
|
8
|
-
- **Standards** — does the code conform to this repo's documented coding standards?
|
|
9
|
-
- **Spec** — does the code faithfully implement the originating issue / spec?
|
|
10
|
-
|
|
11
|
-
Both axes run as **parallel sub-agents** so they don't pollute each other's context, then this skill aggregates their findings.
|
|
12
|
-
|
|
13
|
-
This package method must remain usable without Matt setup files and must **not** modify project governance as setup. Do **not** run `/setup-matt-pocock-skills`, write `docs/agents/issue-tracker.md`, or create other project governance files to "prepare" the review.
|
|
14
|
-
|
|
15
|
-
Review is independent of product repair: keep scratch probes, fixtures, and temporary investigation artifacts distinguishable from fixed-target facts, and never turn the review into product repairs, commits, or governance edits.
|
|
16
|
-
|
|
17
|
-
## Process
|
|
18
|
-
|
|
19
|
-
### 1. Pin the fixed point
|
|
20
|
-
|
|
21
|
-
Whatever the user said is the fixed point — a commit SHA, branch name, tag, `main`, `HEAD~5`, etc. If they didn't specify one, ask for it.
|
|
22
|
-
|
|
23
|
-
Capture the diff command once: `git diff <fixed-point>...HEAD` (three-dot, so the comparison is against the merge-base). Also note the list of commits via `git log <fixed-point>..HEAD --oneline`.
|
|
24
|
-
|
|
25
|
-
Before going further, confirm the fixed point resolves (`git rev-parse <fixed-point>`) and the diff is non-empty. A bad ref or empty diff should fail here — not inside two parallel sub-agents.
|
|
26
|
-
|
|
27
|
-
### 2. Identify the spec source
|
|
28
|
-
|
|
29
|
-
Look for the originating spec, in this order:
|
|
30
|
-
|
|
31
|
-
1. Spec or issue material the caller already supplied (task text, admitted attachments, or explicit paths in the request).
|
|
32
|
-
2. Issue references in the commit messages (`#123`, `Closes #45`, GitLab `!67`, etc.) — fetch only when a working tracker is already available without setup; do not install or write tracker config.
|
|
33
|
-
3. A path the user passed as an argument.
|
|
34
|
-
4. A pre-existing spec file under `docs/`, `specs/`, or `.scratch/` matching the branch name or feature.
|
|
35
|
-
5. If nothing is found, treat Spec as not established: the **Spec** axis skips substantive requirements checking and reports "no spec available". Do not invent a spec and do not mutate the repository to create one.
|
|
36
|
-
|
|
37
|
-
### 3. Identify the standards sources
|
|
38
|
-
|
|
39
|
-
Anything in the repo that documents how code should be written, such as `CODING_STANDARDS.md` or `CONTRIBUTING.md`.
|
|
40
|
-
|
|
41
|
-
On top of whatever the repo documents, the Standards axis always carries the **smell baseline** below — a fixed set of Fowler code smells (_Refactoring_, ch.3) that applies even when a repo documents nothing. Two rules bind it:
|
|
42
|
-
|
|
43
|
-
- **The repo overrides.** A documented repo standard always wins; where it endorses something the baseline would flag, suppress the smell.
|
|
44
|
-
- **Always a judgement call.** Each smell is a labelled heuristic ("possible Feature Envy"), never a hard violation — and, like any standard here, skip anything tooling already enforces.
|
|
45
|
-
|
|
46
|
-
Each smell reads *what it is* → *how to fix*; match it against the diff:
|
|
47
|
-
|
|
48
|
-
- **Mysterious Name** — a function, variable, or type whose name doesn't reveal what it does or holds. → rename it; if no honest name comes, the design's murky.
|
|
49
|
-
- **Duplicated Code** — the same logic shape appears in more than one hunk or file in the change. → extract the shared shape, call it from both.
|
|
50
|
-
- **Feature Envy** — a method that reaches into another object's data more than its own. → move the method onto the data it envies.
|
|
51
|
-
- **Data Clumps** — the same few fields or params keep travelling together (a type wanting to be born). → bundle them into one type, pass that.
|
|
52
|
-
- **Primitive Obsession** — a primitive or string standing in for a domain concept that deserves its own type. → give the concept its own small type.
|
|
53
|
-
- **Repeated Switches** — the same `switch`/`if`-cascade on the same type recurs across the change. → replace with polymorphism, or one map both sites share.
|
|
54
|
-
- **Shotgun Surgery** — one logical change forces scattered edits across many files in the diff. → gather what changes together into one module.
|
|
55
|
-
- **Divergent Change** — one file or module is edited for several unrelated reasons. → split so each module changes for one reason.
|
|
56
|
-
- **Speculative Generality** — abstraction, parameters, or hooks added for needs the spec doesn't have. → delete it; inline back until a real need shows.
|
|
57
|
-
- **Message Chains** — long `a.b().c().d()` navigation the caller shouldn't depend on. → hide the walk behind one method on the first object.
|
|
58
|
-
- **Middle Man** — a class or function that mostly just delegates onward. → cut it, call the real target direct.
|
|
59
|
-
- **Refused Bequest** — a subclass or implementer that ignores or overrides most of what it inherits. → drop the inheritance, use composition.
|
|
60
|
-
|
|
61
|
-
### 4. Spawn both sub-agents in parallel
|
|
62
|
-
|
|
63
|
-
Send a single message with two `Agent` tool calls. Use the `general-purpose` subagent for both.
|
|
64
|
-
|
|
65
|
-
**Standards sub-agent prompt** — provide:
|
|
66
|
-
|
|
67
|
-
- The full diff command and commit list.
|
|
68
|
-
- Typed, traceable references to every standards-source file found in step 3, plus the complete Fowler smell baseline from this Skill. The sub-agent must actually read those supplied references; a path/digest-bound bundle is equivalent to inline material.
|
|
69
|
-
- The brief: "Report — per file/hunk where relevant — (a) every place the diff violates a documented standard: cite the standard (file + the rule); and (b) any baseline smell you spot: name it and quote the hunk. Distinguish hard violations from judgement calls — documented-standard breaches can be hard, but baseline smells are always judgement calls, and a documented repo standard overrides the baseline. Skip anything tooling enforces. Under 400 words."
|
|
70
|
-
|
|
71
|
-
**Spec sub-agent prompt** — provide:
|
|
72
|
-
|
|
73
|
-
- The diff command and commit list.
|
|
74
|
-
- A typed, traceable reference to the actual spec bytes. The sub-agent must read the supplied spec material before judging it; a path/digest-bound bundle is equivalent to inline material.
|
|
75
|
-
- The brief: "Report: (a) requirements the spec asked for that are missing or partial; (b) behaviour in the diff that wasn't asked for (scope creep); (c) requirements that look implemented but where the implementation looks wrong. Quote the spec line for each finding. Under 400 words."
|
|
76
|
-
|
|
77
|
-
If the spec is missing, skip the Spec sub-agent and note this in the final report.
|
|
78
|
-
|
|
79
|
-
### 5. Aggregate
|
|
80
|
-
|
|
81
|
-
Present the two reports under `## Standards` and `## Spec` headings, verbatim or lightly cleaned. Do **not** merge or rerank findings — the two axes are deliberately separate (see _Why two axes_).
|
|
82
|
-
|
|
83
|
-
End with a one-line summary: total findings per axis, and the worst issue _within each axis_ (if any). Don't pick a single winner across axes — that's the reranking the separation exists to prevent.
|
|
84
|
-
|
|
85
|
-
## Why two axes
|
|
86
|
-
|
|
87
|
-
A change can pass one axis and fail the other:
|
|
88
|
-
|
|
89
|
-
- Code that follows every standard but implements the wrong thing → **Standards pass, Spec fail.**
|
|
90
|
-
- Code that does exactly what the issue asked but breaks the project's conventions → **Spec pass, Standards fail.**
|
|
91
|
-
|
|
92
|
-
Reporting them separately stops one axis from masking the other.
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "code-review",
|
|
3
|
-
"kind": "role-method-skill",
|
|
4
|
-
"upstream": {
|
|
5
|
-
"repository": "https://github.com/mattpocock/skills",
|
|
6
|
-
"path": "skills/engineering/code-review",
|
|
7
|
-
"commit": "8b36d4fb2635b3c21998dcd8144439c9e5ba7302",
|
|
8
|
-
"tag": "v1.2.2",
|
|
9
|
-
"license": "MIT",
|
|
10
|
-
"copyright": "Copyright (c) 2026 Matt Pocock",
|
|
11
|
-
"attribution": "mattpocock/skills"
|
|
12
|
-
},
|
|
13
|
-
"packageAdaptation": "reviewer-no-setup-fixed-target-two-axis",
|
|
14
|
-
"files": {
|
|
15
|
-
"SKILL.md": {
|
|
16
|
-
"sha256": "17840093c3a69ebffa3a3bd9582f6a944fa58623df6a65481d5a1dc2a85dd913",
|
|
17
|
-
"byteLength": 7588,
|
|
18
|
-
"gitBlob": "768371d43a38fadf2657ff890cca5fc2b038b7e1"
|
|
19
|
-
},
|
|
20
|
-
"agents/openai.yaml": {
|
|
21
|
-
"sha256": "8229ca854e11dc8e6aef2131ee03f31fb1561cf905fab9ccc325180cf3331352",
|
|
22
|
-
"byteLength": 100,
|
|
23
|
-
"gitBlob": "9076774ba327f49068db9273feceda03bfe940fa"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
package/src/adr-path-refs.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared docs/adr path extraction from free text (issue body / ticket face).
|
|
3
|
-
* Single authority for reviewer Spec discovery.
|
|
4
|
-
*
|
|
5
|
-
* Shape only: segments under docs/adr/ without `..` or empty parts. Real IO
|
|
6
|
-
* confinement still lives at the read seam (ADR 0038).
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/** docs/adr paths referenced inside free text (order of first appearance). */
|
|
10
|
-
// Each segment must start with alnum so `.` / `..` traversal claims never match.
|
|
11
|
-
const ADR_PATH_IN_BODY =
|
|
12
|
-
/docs\/adr\/(?:[A-Za-z0-9][A-Za-z0-9._-]*\/)*[A-Za-z0-9][A-Za-z0-9._-]*\.md/g;
|
|
13
|
-
|
|
14
|
-
/** Extract unique docs/adr/*.md paths; preserve first-seen order. */
|
|
15
|
-
export function extractReferencedAdrPaths(text: string): readonly string[] {
|
|
16
|
-
const seen = new Set<string>();
|
|
17
|
-
const paths: string[] = [];
|
|
18
|
-
for (const match of text.matchAll(ADR_PATH_IN_BODY)) {
|
|
19
|
-
const path = match[0]!;
|
|
20
|
-
if (seen.has(path)) continue;
|
|
21
|
-
seen.add(path);
|
|
22
|
-
paths.push(path);
|
|
23
|
-
}
|
|
24
|
-
return Object.freeze(paths);
|
|
25
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Durable Reviewer-rejection child→parent page under AK_ROLE_RUN_DIR.
|
|
3
|
-
* Stays in public-cli (AK artifact owner); role-runtime imports this neighbor.
|
|
4
|
-
*/
|
|
5
|
-
import { writeFileSync } from "node:fs";
|
|
6
|
-
import { readFile, unlink } from "node:fs/promises";
|
|
7
|
-
import { join } from "node:path";
|
|
8
|
-
|
|
9
|
-
import type { RoleTurnKnownFailure } from "../host-contracts.ts";
|
|
10
|
-
import {
|
|
11
|
-
REVIEWER_PREFLIGHT_VIOLATIONS,
|
|
12
|
-
type ReviewerPreflightViolation,
|
|
13
|
-
} from "../reviewer-dispatch.ts";
|
|
14
|
-
|
|
15
|
-
const REVIEWER_DISPATCH_REJECTION_FILE = "typed-known-failure.json";
|
|
16
|
-
|
|
17
|
-
function isReviewerPreflightViolation(value: unknown): value is ReviewerPreflightViolation {
|
|
18
|
-
return (
|
|
19
|
-
typeof value === "string" &&
|
|
20
|
-
(REVIEWER_PREFLIGHT_VIOLATIONS as readonly string[]).includes(value)
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function reviewerDispatchRejectionPath(runDirectory: string): string {
|
|
25
|
-
return join(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Clear any prior attempt's Reviewer rejection page so resume/retry cannot
|
|
30
|
-
* inherit a stale knownFailure.details.
|
|
31
|
-
*/
|
|
32
|
-
export async function clearReviewerDispatchRejection(runDirectory: string): Promise<void> {
|
|
33
|
-
try {
|
|
34
|
-
await unlink(reviewerDispatchRejectionPath(runDirectory));
|
|
35
|
-
} catch (error) {
|
|
36
|
-
if (
|
|
37
|
-
error instanceof Error &&
|
|
38
|
-
"code" in error &&
|
|
39
|
-
(error as { code?: unknown }).code === "ENOENT"
|
|
40
|
-
) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Synchronous durable write for Reviewer dispatch rejection (child process exit is sync).
|
|
49
|
-
* Parent public CLI recovers via readReviewerDispatchRejection into knownFailure.
|
|
50
|
-
*/
|
|
51
|
-
export function recordReviewerDispatchRejectionSync(
|
|
52
|
-
runDirectory: string,
|
|
53
|
-
rejection: Readonly<{
|
|
54
|
-
diagnostic: string;
|
|
55
|
-
violations: readonly ReviewerPreflightViolation[];
|
|
56
|
-
}>,
|
|
57
|
-
): void {
|
|
58
|
-
writeFileSync(
|
|
59
|
-
reviewerDispatchRejectionPath(runDirectory),
|
|
60
|
-
`${JSON.stringify(rejection)}\n`,
|
|
61
|
-
"utf8",
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** Recover a child-written Reviewer dispatch rejection through a fixed mapping. */
|
|
66
|
-
export async function readReviewerDispatchRejection(
|
|
67
|
-
runDirectory: string,
|
|
68
|
-
): Promise<RoleTurnKnownFailure | undefined> {
|
|
69
|
-
let raw: string;
|
|
70
|
-
try {
|
|
71
|
-
raw = await readFile(reviewerDispatchRejectionPath(runDirectory), "utf8");
|
|
72
|
-
} catch (error) {
|
|
73
|
-
if (
|
|
74
|
-
error instanceof Error &&
|
|
75
|
-
"code" in error &&
|
|
76
|
-
(error as { code?: unknown }).code === "ENOENT"
|
|
77
|
-
) {
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
throw error;
|
|
81
|
-
}
|
|
82
|
-
const parsed: unknown = JSON.parse(raw);
|
|
83
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
84
|
-
const error = new Error("Reviewer dispatch rejection page must be a JSON object");
|
|
85
|
-
error.name = "ReviewerDispatchRejectionContractError";
|
|
86
|
-
throw error;
|
|
87
|
-
}
|
|
88
|
-
const record = parsed as Record<string, unknown>;
|
|
89
|
-
if (
|
|
90
|
-
typeof record.diagnostic !== "string" ||
|
|
91
|
-
record.diagnostic.trim() === "" ||
|
|
92
|
-
!Array.isArray(record.violations) ||
|
|
93
|
-
record.violations.length === 0 ||
|
|
94
|
-
record.violations.some((value) => !isReviewerPreflightViolation(value))
|
|
95
|
-
) {
|
|
96
|
-
const error = new Error("Reviewer dispatch rejection page has unusable required fields");
|
|
97
|
-
error.name = "ReviewerDispatchRejectionContractError";
|
|
98
|
-
throw error;
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
cause: "activation",
|
|
102
|
-
diagnostic: record.diagnostic,
|
|
103
|
-
identity: { name: "ReviewerDispatchRejectionError" },
|
|
104
|
-
details: { violations: Object.freeze([...record.violations]) },
|
|
105
|
-
};
|
|
106
|
-
}
|
package/src/reviewer-dispatch.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* #836 删 8: no code-compiled axis dispatch.
|
|
3
|
-
* Parent seat invokes packaged code-review skill; this module does not construct or run children.
|
|
4
|
-
*/
|
|
5
|
-
export {
|
|
6
|
-
branchNamesAtPinnedHead,
|
|
7
|
-
createReviewerPinnedGitReader,
|
|
8
|
-
immutableReviewerPin,
|
|
9
|
-
type ReviewerPinnedGitReader,
|
|
10
|
-
type ReviewerPinnedTarget,
|
|
11
|
-
type ReviewerRange,
|
|
12
|
-
} from "./reviewer-pinned-git.ts";
|
|
13
|
-
export { extractReferencedAdrPaths } from "./adr-path-refs.ts";
|
|
14
|
-
export { sha256Hex } from "./sha256.ts";
|
|
15
|
-
export {
|
|
16
|
-
isReviewerPromptText as isReviewerPromptIdentity,
|
|
17
|
-
sameReviewerPromptText as sameReviewerPromptIdentity,
|
|
18
|
-
type ReviewerPromptText as ReviewerPromptIdentity,
|
|
19
|
-
} from "./reviewer-prompt-identity.ts";
|
|
20
|
-
|
|
21
|
-
export type ReviewerIssueFetchResult = Readonly<{
|
|
22
|
-
number: number;
|
|
23
|
-
title?: string;
|
|
24
|
-
body?: string;
|
|
25
|
-
}>;
|
|
26
|
-
|
|
27
|
-
export type ReviewerIssueFetcher = (input: {
|
|
28
|
-
repo: string;
|
|
29
|
-
ticketNumber: number;
|
|
30
|
-
signal?: AbortSignal;
|
|
31
|
-
}) => Promise<ReviewerIssueFetchResult | undefined>;
|
|
32
|
-
|
|
33
|
-
export const REVIEWER_PREFLIGHT_VIOLATIONS = [
|
|
34
|
-
"base-invalid",
|
|
35
|
-
"range-invalid",
|
|
36
|
-
"prompt-identity-invalid",
|
|
37
|
-
"target-drift",
|
|
38
|
-
] as const;
|
|
39
|
-
export type ReviewerPreflightViolation = (typeof REVIEWER_PREFLIGHT_VIOLATIONS)[number];
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export const REVIEW_REF_PREFIXES = ["refs/heads", "refs/tags", "refs/remotes"] as const;
|
|
2
|
-
|
|
3
|
-
/** Closed identity for a ref: annotated tags retain both tag object and peeled commit. */
|
|
4
|
-
export type ReviewerRefEntry = Readonly<{
|
|
5
|
-
objectId: string;
|
|
6
|
-
peeledCommitId: string | null;
|
|
7
|
-
}>;
|
|
8
|
-
export type ReviewerRefMap = Readonly<Record<string, ReviewerRefEntry>>;
|
|
9
|
-
|
|
10
|
-
export function parseReviewerRefSnapshot(raw: string): Record<string, ReviewerRefEntry> {
|
|
11
|
-
const refs: Record<string, ReviewerRefEntry> = {};
|
|
12
|
-
for (const line of raw.split("\n")) {
|
|
13
|
-
if (!line) continue;
|
|
14
|
-
const fields = line.split("\0");
|
|
15
|
-
if (fields.length !== 5 || !fields[0] || !fields[1] || !fields[3]) {
|
|
16
|
-
throw new Error(`Malformed Git ref snapshot line: ${line}`);
|
|
17
|
-
}
|
|
18
|
-
const peeledCommitId = fields[3] === "commit"
|
|
19
|
-
? fields[1]
|
|
20
|
-
: fields[4] === "commit" && fields[2] ? fields[2] : null;
|
|
21
|
-
refs[fields[0]] = Object.freeze({
|
|
22
|
-
objectId: fields[1],
|
|
23
|
-
peeledCommitId,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return refs;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function reviewerRefSnapshotArgs(): string[] {
|
|
30
|
-
return ["for-each-ref", "--format=%(refname)%00%(objectname)%00%(*objectname)%00%(objecttype)%00%(*objecttype)", ...REVIEW_REF_PREFIXES];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function immutableReviewerRefs(refs: ReviewerRefMap): ReviewerRefMap {
|
|
34
|
-
return Object.freeze(Object.fromEntries(Object.entries(refs)
|
|
35
|
-
.sort(([a], [b]) => a.localeCompare(b))
|
|
36
|
-
.map(([name, entry]) => [name, Object.freeze({ objectId: entry.objectId, peeledCommitId: entry.peeledCommitId })])));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function sameReviewerPinnedTarget(
|
|
40
|
-
actual: Readonly<{ repositoryRoot: string; objectFormat: "sha1" | "sha256"; targetHead: string; refs?: ReviewerRefMap }>,
|
|
41
|
-
expected: Readonly<{ repositoryRoot: string; objectFormat: "sha1" | "sha256"; targetHead: string; refs?: ReviewerRefMap }>,
|
|
42
|
-
): boolean {
|
|
43
|
-
return actual.repositoryRoot === expected.repositoryRoot && actual.objectFormat === expected.objectFormat &&
|
|
44
|
-
actual.targetHead === expected.targetHead;
|
|
45
|
-
}
|