@ygrishajev/jig 1.1.0 → 1.2.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.
Files changed (36) hide show
  1. package/README.md +16 -0
  2. package/dist/adapters/git/remote-ref.js +125 -0
  3. package/dist/adapters/git/run-code.js +66 -0
  4. package/dist/adapters/git/run-history.js +79 -0
  5. package/dist/adapters/run-store/composite-run-store.js +68 -14
  6. package/dist/adapters/run-store/git-remote-run-store.js +34 -129
  7. package/dist/app/run-jig.js +28 -7
  8. package/dist/app/run-stores.js +4 -3
  9. package/dist/cli/main.js +3 -15
  10. package/dist/domain/apply-outcome.js +30 -13
  11. package/dist/domain/diagnostics.js +104 -0
  12. package/dist/domain/errors.js +8 -0
  13. package/dist/domain/final-check.js +21 -1
  14. package/dist/domain/run-id.js +4 -1
  15. package/dist/domain/run-state.js +43 -1
  16. package/dist/domain/slice.js +8 -2
  17. package/dist/integrations/github/cli.js +20 -0
  18. package/dist/integrations/github/command.js +68 -0
  19. package/dist/integrations/github/errors.js +19 -0
  20. package/dist/integrations/github/findings-comment.js +53 -0
  21. package/dist/integrations/github/github-port.js +1 -0
  22. package/dist/integrations/github/implement-issue.js +281 -0
  23. package/dist/integrations/github/octokit-github.js +101 -0
  24. package/dist/integrations/github/orchestration-state.js +132 -0
  25. package/dist/integrations/github/orchestration-store.js +109 -0
  26. package/dist/integrations/github/repository-identity.js +27 -0
  27. package/dist/integrations/github/request-snapshot.js +3 -0
  28. package/dist/integrations/github/run-branch-publication.js +102 -0
  29. package/dist/ports/run-code.js +1 -0
  30. package/dist/prompts/design-review.js +2 -0
  31. package/dist/prompts/planning.js +5 -1
  32. package/dist/prompts/pull-request.js +4 -1
  33. package/dist/prompts/slice.js +11 -0
  34. package/dist/steps/pull-request-description.js +1 -1
  35. package/dist/steps/slice.js +1 -0
  36. package/package.json +5 -4
@@ -0,0 +1,132 @@
1
+ import { z } from 'zod';
2
+ import { runIdSchema } from '../../domain/run-id.js';
3
+ const requestSchema = z.object({ runId: runIdSchema, text: z.string(), title: z.string() });
4
+ const receiptSchema = z.object({
5
+ number: z.number().int().positive(),
6
+ url: z.string(),
7
+ });
8
+ const refusalSchema = z.object({
9
+ runId: runIdSchema,
10
+ revision: z.string(),
11
+ paths: z.array(z.string()).min(1),
12
+ });
13
+ const ownershipSchema = z.object({ token: z.string(), expiresAt: z.number() });
14
+ /** Fields added after version 1 default to empty, so state saved before them still loads. */
15
+ export const orchestrationSchema = z.object({
16
+ version: z.literal(1),
17
+ requests: z.record(requestSchema),
18
+ receipts: z.record(receiptSchema),
19
+ comments: z.record(z.string()).default({}),
20
+ refusals: z.record(refusalSchema).default({}),
21
+ refusalComments: z.record(z.string()).default({}),
22
+ findingsComments: z.record(z.string()).default({}),
23
+ owners: z.record(ownershipSchema).default({}),
24
+ });
25
+ export function emptyOrchestration() {
26
+ return {
27
+ version: 1,
28
+ requests: {},
29
+ receipts: {},
30
+ comments: {},
31
+ refusals: {},
32
+ refusalComments: {},
33
+ findingsComments: {},
34
+ owners: {},
35
+ };
36
+ }
37
+ export function acceptedRequest(state, key) {
38
+ return state.requests[key];
39
+ }
40
+ export function acceptRequest(state, key, request) {
41
+ return state.requests[key]
42
+ ? state
43
+ : { ...state, requests: { ...state.requests, [key]: request } };
44
+ }
45
+ export function pullRequestReceipt(state, key) {
46
+ return state.receipts[key];
47
+ }
48
+ export function withPullRequest(state, key, receipt) {
49
+ if (state.receipts[key])
50
+ return state;
51
+ return { ...state, receipts: { ...state.receipts, [key]: receipt } };
52
+ }
53
+ export function withComment(state, identity, url) {
54
+ if (commentReceipt(state, identity))
55
+ return state;
56
+ return { ...state, comments: { ...state.comments, [commentKey(identity)]: url } };
57
+ }
58
+ export function commentReceipt(state, identity) {
59
+ return state.comments[commentKey(identity)];
60
+ }
61
+ function commentKey({ runId, outcome, revision }) {
62
+ return `${runId}:${outcome}:${revision}`;
63
+ }
64
+ /** The marker a status comment carries, so a comment whose receipt was lost can be found again. */
65
+ export function commentMarker(identity) {
66
+ return `<!-- jig:status:${commentKey(identity)} -->`;
67
+ }
68
+ export function withRefusal(state, key, refusal) {
69
+ const id = refusalKey(key, refusal.revision);
70
+ if (state.refusals[id])
71
+ return state;
72
+ return { ...state, refusals: { ...state.refusals, [id]: refusal } };
73
+ }
74
+ function refusalKey(key, revision) {
75
+ return `${key}@${revision}`;
76
+ }
77
+ export function refusalOf(state, key, revision) {
78
+ return state.refusals[refusalKey(key, revision)];
79
+ }
80
+ export function withRefusalComment(state, key, revision, url) {
81
+ const id = refusalKey(key, revision);
82
+ if (state.refusalComments[id])
83
+ return state;
84
+ return { ...state, refusalComments: { ...state.refusalComments, [id]: url } };
85
+ }
86
+ export function refusalCommentReceipt(state, key, revision) {
87
+ return state.refusalComments[refusalKey(key, revision)];
88
+ }
89
+ /** The marker a refusal comment carries, so a comment whose receipt was lost can be found again. */
90
+ export function refusalMarker(key, revision) {
91
+ return `<!-- jig:refusal:${refusalKey(key, revision)} -->`;
92
+ }
93
+ export function withFindingsComment(state, identity, url) {
94
+ if (findingsCommentReceipt(state, identity))
95
+ return state;
96
+ return {
97
+ ...state,
98
+ findingsComments: { ...state.findingsComments, [findingsKey(identity)]: url },
99
+ };
100
+ }
101
+ export function findingsCommentReceipt(state, identity) {
102
+ return state.findingsComments[findingsKey(identity)];
103
+ }
104
+ function findingsKey({ repository, pullRequest, ...comment }) {
105
+ return `findings:${repository.owner}/${repository.repo}#${pullRequest}:${commentKey(comment)}`;
106
+ }
107
+ /** The marker a findings comment carries, so a comment whose receipt was lost can be found again. */
108
+ export function findingsMarker(identity) {
109
+ return `<!-- jig:${findingsKey(identity)} -->`;
110
+ }
111
+ /** Takes publication of `key` for `claim` unless another owner holds an unexpired lease. */
112
+ export function claimPublication(state, key, claim, now) {
113
+ const owner = state.owners[key];
114
+ if (owner && owner.token !== claim.token && owner.expiresAt > now)
115
+ return state;
116
+ return { ...state, owners: { ...state.owners, [key]: claim } };
117
+ }
118
+ /** Extends the lease of `claim`'s owner; a lease another job has taken stays with that job. */
119
+ export function renewPublication(state, key, claim) {
120
+ if (!ownsPublication(state, key, claim.token))
121
+ return state;
122
+ return { ...state, owners: { ...state.owners, [key]: claim } };
123
+ }
124
+ export function ownsPublication(state, key, token) {
125
+ return state.owners[key]?.token === token;
126
+ }
127
+ export function releasePublication(state, key, token) {
128
+ if (!ownsPublication(state, key, token))
129
+ return state;
130
+ const { [key]: _released, ...owners } = state.owners;
131
+ return { ...state, owners };
132
+ }
@@ -0,0 +1,109 @@
1
+ import { Result } from 'better-result';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { isDeepStrictEqual } from 'node:util';
4
+ import { RemoteRef } from '../../adapters/git/remote-ref.js';
5
+ import { reportCleanup } from '../../app/report-cleanup.js';
6
+ import { messageOf, } from '../../domain/errors.js';
7
+ import { retryResult } from '../../domain/retry.js';
8
+ import { OrchestrationStateInvalid, PublicationInProgress } from './errors.js';
9
+ import { claimPublication, emptyOrchestration, orchestrationSchema, ownsPublication, releasePublication, renewPublication, } from './orchestration-state.js';
10
+ export class OrchestrationStore {
11
+ now;
12
+ refs;
13
+ constructor(repoRoot, now = Date.now) {
14
+ this.now = now;
15
+ this.refs = new RemoteRef(repoRoot);
16
+ }
17
+ /**
18
+ * Runs `use` as the only job publishing `key`, under a lease another job may take over once it
19
+ * expires. `use` renews the lease through `whileOwned` before each effect, and the lease is
20
+ * released however `use` ends, a throw included.
21
+ */
22
+ async withPublicationOwnership(key, logger, use) {
23
+ const token = randomUUID();
24
+ const claimed = await this.update((state) => claimPublication(state, key, this.leaseFor(token), this.now()));
25
+ if (claimed.isErr())
26
+ return Result.err(claimed.error);
27
+ if (!ownsPublication(claimed.value, key, token))
28
+ return Result.err(new PublicationInProgress({
29
+ message: `Another job is publishing ${key}; run the command again once it finishes.`,
30
+ }));
31
+ const whileOwned = async (step) => {
32
+ const renewed = await this.renew(key, token);
33
+ return renewed.isErr() ? Result.err(renewed.error) : step();
34
+ };
35
+ let used;
36
+ let released;
37
+ try {
38
+ used = await use(whileOwned);
39
+ }
40
+ finally {
41
+ released = await this.update((state) => releasePublication(state, key, token));
42
+ }
43
+ return reportCleanup(used, released.map(() => undefined), logger);
44
+ }
45
+ leaseFor(token) {
46
+ return { token, expiresAt: this.now() + OWNERSHIP_LEASE_MS };
47
+ }
48
+ async renew(key, token) {
49
+ const renewed = await this.update((state) => renewPublication(state, key, this.leaseFor(token)));
50
+ if (renewed.isErr())
51
+ return Result.err(renewed.error);
52
+ if (ownsPublication(renewed.value, key, token))
53
+ return Result.ok();
54
+ return Result.err(new PublicationInProgress({
55
+ message: `Another job took over publishing ${key} after this job's lease expired; this job stopped publishing.`,
56
+ }));
57
+ }
58
+ read() {
59
+ return this.load().then((result) => result.map(({ state }) => state));
60
+ }
61
+ load() {
62
+ return Result.gen(async function* () {
63
+ const listed = yield* Result.await(this.refs.list([ORCHESTRATION_REF]));
64
+ if (!listed.has(ORCHESTRATION_REF))
65
+ return Result.ok({ state: emptyOrchestration() });
66
+ yield* Result.await(this.refs.fetch([`+${ORCHESTRATION_REF}:${ORCHESTRATION_REF}`]));
67
+ const expected = await this.refs.revision(ORCHESTRATION_REF);
68
+ const contents = yield* Result.await(this.refs.required(['show', `${expected}:${ORCHESTRATION_FILE}`]));
69
+ const state = yield* Result.try({
70
+ try: () => orchestrationSchema.parse(JSON.parse(contents)),
71
+ catch: (cause) => new OrchestrationStateInvalid({
72
+ message: `Invalid GitHub orchestration state: ${messageOf(cause)}`,
73
+ }),
74
+ });
75
+ return Result.ok({ state, expected });
76
+ }, this);
77
+ }
78
+ async update(decide) {
79
+ const result = await retryResult(() => this.updateOnce(decide), {
80
+ retries: ORCHESTRATION_ATTEMPTS - 1,
81
+ delayMs: 0,
82
+ shouldRetry: (error) => error._tag === 'RunStateConflict',
83
+ });
84
+ return result.mapError((error) => error._tag === 'RunStateConflict'
85
+ ? new OrchestrationStateInvalid({
86
+ message: `Competing jobs kept updating GitHub orchestration ref ${ORCHESTRATION_REF}; try again.`,
87
+ })
88
+ : error);
89
+ }
90
+ updateOnce(decide) {
91
+ return Result.gen(async function* () {
92
+ const { state, expected } = yield* Result.await(this.load());
93
+ const next = decide(state);
94
+ if (isDeepStrictEqual(next, state))
95
+ return Result.ok(state);
96
+ const commit = yield* Result.await(this.refs.commitFile(ORCHESTRATION_REF, ORCHESTRATION_FILE, `${JSON.stringify(next, null, 2)}\n`, 'jig github: update orchestration'));
97
+ yield* Result.await(this.refs.pushLeased([{ ref: ORCHESTRATION_REF, source: commit, expected }]));
98
+ return Result.ok(next);
99
+ }, this);
100
+ }
101
+ }
102
+ /** How long a publication owner holds its lease unrenewed; a crashed job's lease lapses after this. */
103
+ export const OWNERSHIP_LEASE_MS = 15 * 60 * 1000;
104
+ /** A hidden ref outside the branch list shares orchestration across every repository job. */
105
+ const ORCHESTRATION_REF = 'refs/jig/_orchestration';
106
+ /** Every repository job reads the shared receipts from this file in the hidden ref. */
107
+ const ORCHESTRATION_FILE = 'orchestration.json';
108
+ /** Competing jobs re-read the winner's state, within a bounded contention budget. */
109
+ const ORCHESTRATION_ATTEMPTS = 5;
@@ -0,0 +1,27 @@
1
+ import { Result } from 'better-result';
2
+ import { z } from 'zod';
3
+ import { gitCommand, openRepo } from '../../adapters/git/repository.js';
4
+ import { GithubSetupInvalid } from './errors.js';
5
+ export async function repositoryIdentity(repoRoot, environment) {
6
+ const configured = environment.GITHUB_REPOSITORY;
7
+ if (configured !== undefined)
8
+ return parseRepository(configured);
9
+ const origin = await gitCommand('remote get-url', () => openRepo(repoRoot).remote(['get-url', 'origin']));
10
+ if (origin.isErr())
11
+ return Result.err(new GithubSetupInvalid({ message: 'Set GITHUB_REPOSITORY or configure a GitHub origin.' }));
12
+ const name = /^(?:https:\/\/github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([^\s]+?)\/?$/.exec(origin.value?.trim() ?? '')?.[1];
13
+ return parseRepository(name?.replace(/\.git$/, ''));
14
+ }
15
+ function parseRepository(value) {
16
+ const parsed = repositorySchema.safeParse(value);
17
+ return parsed.success
18
+ ? Result.ok(parsed.data)
19
+ : Result.err(new GithubSetupInvalid({ message: 'Repository must identify a GitHub owner/repository.' }));
20
+ }
21
+ const repositorySchema = z
22
+ .string()
23
+ .regex(/^[\w.-]+\/[\w.-]+$/)
24
+ .transform((value) => {
25
+ const [owner, repo] = value.split('/');
26
+ return { owner, repo };
27
+ });
@@ -0,0 +1,3 @@
1
+ export function requestText(issue) {
2
+ return `# ${issue.title}\n\n${issue.body}\n\nSource: ${issue.url}\n`;
3
+ }
@@ -0,0 +1,102 @@
1
+ import { Result } from 'better-result';
2
+ import { RemoteRef } from '../../adapters/git/remote-ref.js';
3
+ import { isAncestor } from '../../adapters/git/repository.js';
4
+ import { changedPaths, commitsBeyond, exactHead, hasCommit, mergeBaseWith, } from '../../adapters/git/run-history.js';
5
+ import { runBranchFor } from '../../domain/run-state.js';
6
+ import { RunBranchUnpublishable } from './errors.js';
7
+ /**
8
+ * The only way an issue run's code reaches the remote. It inspects exactly `revision`, refuses it
9
+ * when it changes a workflow, skips it when it changes nothing unless `pushUnchanged` asks for its
10
+ * commits anyway, and otherwise pushes that object ID under a lease on the remote branch. Any
11
+ * failure to inspect publishes nothing.
12
+ */
13
+ export function publishRunBranch(repoRoot, { pushUnchanged = false, ...inspected }) {
14
+ return Result.gen(async function* () {
15
+ const { runId, revision } = inspected;
16
+ const head = yield* Result.await(exactHead(repoRoot, branchRef(runId)));
17
+ if (head !== revision)
18
+ return Result.err(new RunBranchUnpublishable({
19
+ message: `Run branch ${runBranchFor(runId)} is at ${head ?? 'nothing'}, not the checkpoint ${revision} its state records; move it back to the checkpoint or start a new run.`,
20
+ }));
21
+ const inspection = yield* Result.await(inspectRunBranch(repoRoot, inspected));
22
+ if (inspection.kind === 'refused')
23
+ return Result.ok(inspection);
24
+ const { changesFiles } = inspection;
25
+ if (!changesFiles && !pushUnchanged)
26
+ return Result.ok({ kind: 'unchanged' });
27
+ yield* Result.await(pushLeased(repoRoot, new RemoteRef(repoRoot), runId, revision));
28
+ return Result.ok({ kind: 'published', changesFiles });
29
+ });
30
+ }
31
+ function branchRef(runId) {
32
+ return `refs/heads/${runBranchFor(runId)}`;
33
+ }
34
+ /**
35
+ * Publication and receipt reuse must not bypass workflow refusal: a prior receipt does not prove
36
+ * that the run's code is safe to publish.
37
+ */
38
+ export function inspectRunBranch(repoRoot, { runId, revision, defaultBranch }) {
39
+ return Result.gen(async function* () {
40
+ const defaultHead = yield* Result.await(fetchedHead(new RemoteRef(repoRoot), defaultBranch));
41
+ const forkPoint = yield* Result.await(mergeBaseWith(repoRoot, defaultHead, revision));
42
+ if (!forkPoint)
43
+ return Result.err(new RunBranchUnpublishable({
44
+ message: `Run branch ${runBranchFor(runId)} shares no history with ${defaultBranch}.`,
45
+ }));
46
+ const paths = yield* Result.await(changedPaths(repoRoot, forkPoint, revision));
47
+ const workflows = paths.filter(isWorkflowPath);
48
+ if (workflows.length > 0)
49
+ return Result.ok({ kind: 'refused', paths: workflows });
50
+ return Result.ok({ kind: 'clean', changesFiles: paths.length > 0 });
51
+ });
52
+ }
53
+ function fetchedHead(refs, branch) {
54
+ return Result.gen(async function* () {
55
+ const ref = `refs/heads/${branch}`;
56
+ const listed = yield* Result.await(refs.list([ref]));
57
+ const head = listed.get(ref);
58
+ if (!head)
59
+ return Result.err(new RunBranchUnpublishable({ message: `Default branch ${branch} is missing on origin.` }));
60
+ yield* Result.await(refs.fetch([`+${ref}:refs/remotes/origin/${branch}`]));
61
+ return Result.ok(head);
62
+ });
63
+ }
64
+ function isWorkflowPath(path) {
65
+ return path.startsWith(WORKFLOW_DIRECTORY);
66
+ }
67
+ /** GitHub runs workflows from this directory only; a pushed branch would let them run unreviewed. */
68
+ const WORKFLOW_DIRECTORY = '.github/workflows/';
69
+ /** Pushes `revision` only over what the remote branch holds now, and only as a fast-forward of it. */
70
+ function pushLeased(repoRoot, refs, runId, revision) {
71
+ return Result.gen(async function* () {
72
+ const ref = branchRef(runId);
73
+ const listed = yield* Result.await(refs.list([ref]));
74
+ const published = listed.get(ref);
75
+ if (published === revision)
76
+ return Result.ok();
77
+ if (published)
78
+ yield* Result.await(ensureFastForward(repoRoot, refs, runId, published, revision));
79
+ return refs.pushLeased([{ ref, source: revision, expected: published }]);
80
+ });
81
+ }
82
+ function ensureFastForward(repoRoot, refs, runId, published, revision) {
83
+ return Result.gen(async function* () {
84
+ if (!(yield* Result.await(hasCommit(repoRoot, published))))
85
+ yield* Result.await(refs.fetch([`+${branchRef(runId)}:refs/remotes/origin/${runBranchFor(runId)}`]));
86
+ if (yield* Result.await(isAncestor(repoRoot, published, revision)))
87
+ return Result.ok();
88
+ return Result.err(new RunBranchUnpublishable({
89
+ message: `Run branch ${runBranchFor(runId)} on origin moved to ${published}, which ${revision} does not build on; nothing was pushed.`,
90
+ }));
91
+ });
92
+ }
93
+ /**
94
+ * Whether a stuck run committed anything past where it started. A run saved before its starting
95
+ * commit was recorded has no known start, so it is never taken to have work.
96
+ */
97
+ export async function hasWorkBeyondStart(repoRoot, { startingCommit, codeRevision }) {
98
+ if (!startingCommit || !codeRevision)
99
+ return Result.ok(false);
100
+ const commits = await commitsBeyond(repoRoot, startingCommit, codeRevision);
101
+ return commits.map((beyond) => beyond.length > 0);
102
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -42,6 +42,8 @@ function documentsSection(label, docs) {
42
42
  function reviewRules() {
43
43
  return [
44
44
  'Explore the repository as much as you need to check the documents against it.',
45
+ 'Check that the design maps each requested behaviour to the module that owns it in this',
46
+ 'repository. Raise a consequential mismatch with a concrete failure scenario and evidence.',
45
47
  '',
46
48
  'Raise a finding only for a consequential decision: one that, wrong or missing, would',
47
49
  'materially change behaviour the request requires, violate a constraint of this repository',
@@ -25,7 +25,9 @@ export function featurePlanPrompt(request, repoSummary) {
25
25
  repoSummary,
26
26
  '',
27
27
  'Produce a plan: a summary of what will change, the overall approach, and the list of',
28
- 'affected areas of the codebase.',
28
+ "affected areas of the codebase. Compare the request's intended architecture with the",
29
+ 'existing module boundaries and ownership. Name any mismatch in the approach so the design',
30
+ 'step can resolve it before implementation.',
29
31
  '',
30
32
  'Respond with JSON matching: { "summary": string, "approach": string, "affectedAreas": string[] }.',
31
33
  ].join('\n');
@@ -51,6 +53,8 @@ export function designPrompt(request, repoSummary, plan) {
51
53
  'Write two markdown documents. Do not create any files — return them in your response:',
52
54
  '1. "design" with sections: Goal; Context; Chosen approach; Alternatives considered (each',
53
55
  ' with why it was rejected); Assumptions; Non-goals; Affected areas.',
56
+ ' In Context, map requested behaviour to the modules and rules that own it today.',
57
+ ' Explain any mismatch with the requested architecture in Chosen approach.',
54
58
  '2. "plan" — the overall implementation plan as numbered steps, each under a',
55
59
  ' `## Step N — <title>` heading. Steps describe the work, not slice boundaries:',
56
60
  ' related steps may belong to one slice. Keep a coherent feature or refactor together',
@@ -28,7 +28,10 @@ export function pullRequestPrompt(input) {
28
28
  ' HTML comments with real content.',
29
29
  '- Write the sections that describe the result and the motivation in plain words for',
30
30
  ' someone who has not seen the code: no file paths, identifiers or technical terms.',
31
- '- Keep "how" or approach sections to a few lines on the approach and notable decisions.',
31
+ '- Keep "how" or approach sections short. When a flow changed, show concise before/after',
32
+ ' pseudocode of the decision or sequence. Explain in plain words what the new flow does',
33
+ ' differently, when that difference matters, and why it was chosen. Base both versions',
34
+ ' on the actual code; skip pseudocode when it adds no clarity.',
32
35
  ...verificationRule(verifyCommand),
33
36
  '- The final-check section records what the whole-run final check decided: state that',
34
37
  ' record as fact too. Put everything it reports unmet in the section for deviations.',
@@ -10,6 +10,8 @@ export function implementPrompt(slice, verifyCommand) {
10
10
  ...houseRulesFirst(),
11
11
  '',
12
12
  'Make the necessary code changes in this repository to complete this slice.',
13
+ 'Preserve lint, test and verification settings. Change them only when this slice explicitly',
14
+ 'requires the change; never relax a check to make the implementation pass.',
13
15
  'Do not rebase, amend or otherwise rewrite the commits already on this branch.',
14
16
  '',
15
17
  ...checkAgainstHouseRulesLast(),
@@ -33,6 +35,10 @@ function previousFeedback(slice) {
33
35
  'A previous attempt at this slice was sent back with changes requested, by its review or by a failed check.',
34
36
  'Address this feedback specifically:',
35
37
  slice.lastFeedback,
38
+ 'If a requested change is wrong or outside this slice, check the relevant code and request',
39
+ 'before disputing it. Record the evidence in your commit message body so the reviewer can',
40
+ 'verify it from the commit history.',
41
+ 'Do not leave a supported finding unresolved because you disagree with its wording.',
36
42
  ...earlierRounds(slice),
37
43
  ];
38
44
  }
@@ -171,6 +177,11 @@ function sliceReviewSections(slice, range, protectedChanges) {
171
177
  'the most serious: each rejection costs the slice one of a few attempts, so a problem you',
172
178
  'leave for the next round may be the one it runs out on. On a later round, check the whole',
173
179
  'range again, not only what the last feedback named.',
180
+ 'For a missing edge case, name the reachable input or state, the wrong result, and why',
181
+ 'existing checks do not cover it. Do not request coverage for a speculative case that',
182
+ 'the slice cannot reach.',
183
+ "If an earlier finding was disputed, check the implementer's evidence against the code.",
184
+ 'Drop the finding when that evidence holds; otherwise explain the remaining failure case.',
174
185
  ];
175
186
  }
176
187
  function protectedChangesSection(changes) {
@@ -13,7 +13,7 @@ export const DEFAULT_PR_TEMPLATE = [
13
13
  '',
14
14
  '## How',
15
15
  '',
16
- '<!-- For reviewers: the approach and the notable decisions, a few lines. -->',
16
+ '<!-- For reviewers: show a short before/after flow in pseudocode when behaviour changed. Explain what differs, when it matters, and why. -->',
17
17
  '',
18
18
  '## Verification',
19
19
  '',
@@ -141,6 +141,7 @@ export const verifySlice = ({ settings, ports }) => {
141
141
  type: 'verificationFailed',
142
142
  feedback: verifyFailedFeedback(command, output),
143
143
  command,
144
+ output,
144
145
  observed,
145
146
  });
146
147
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ygrishajev/jig",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Agentic SDLC pipeline orchestrator",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -8,9 +8,9 @@
8
8
  "node": ">=20.17"
9
9
  },
10
10
  "bin": {
11
- "jig": "./dist/cli/main.js"
11
+ "jig": "./dist/integrations/github/cli.js"
12
12
  },
13
- "main": "./dist/cli/main.js",
13
+ "main": "./dist/integrations/github/cli.js",
14
14
  "files": [
15
15
  "dist",
16
16
  "presets"
@@ -27,7 +27,7 @@
27
27
  "validate": "node --import tsx scripts/validate.ts",
28
28
  "build": "tsc -p tsconfig.build.json",
29
29
  "install:local": "npm run build && T=$(npm pack --silent | tail -1) && trap 'rm -f \"$T\"' EXIT && env -u _VOLTA_TOOL_RECURSION \"${VOLTA_HOME:+$VOLTA_HOME/bin/}npm\" i -g \"$PWD/$T\"",
30
- "dev": "tsx src/cli/main.ts",
30
+ "dev": "tsx src/integrations/github/cli.ts",
31
31
  "lint": "eslint .",
32
32
  "lint:duplication": "jscpd",
33
33
  "format": "prettier --write .",
@@ -44,6 +44,7 @@
44
44
  "dependencies": {
45
45
  "@ai-hero/sandcastle": "^0.14.0",
46
46
  "@inquirer/prompts": "^8.7.5",
47
+ "@octokit/rest": "^22.0.1",
47
48
  "@opentelemetry/api": "^1.9.1",
48
49
  "@opentelemetry/exporter-trace-otlp-http": "^0.223.0",
49
50
  "@opentelemetry/sdk-node": "^0.223.0",