@on-par/factory-core 0.9.28-next.13 → 0.9.28-next.15

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 (64) hide show
  1. package/dist/config/index.d.ts +1 -0
  2. package/dist/config/index.d.ts.map +1 -1
  3. package/dist/config/index.js +7 -1
  4. package/dist/config/index.js.map +1 -1
  5. package/dist/internal.d.ts +1 -0
  6. package/dist/internal.d.ts.map +1 -1
  7. package/dist/internal.js +1 -0
  8. package/dist/internal.js.map +1 -1
  9. package/dist/phases/ship-approval.d.ts +17 -0
  10. package/dist/phases/ship-approval.d.ts.map +1 -0
  11. package/dist/phases/ship-approval.js +21 -0
  12. package/dist/phases/ship-approval.js.map +1 -0
  13. package/dist/phases/ship-branch-push.d.ts +17 -0
  14. package/dist/phases/ship-branch-push.d.ts.map +1 -0
  15. package/dist/phases/ship-branch-push.js +77 -0
  16. package/dist/phases/ship-branch-push.js.map +1 -0
  17. package/dist/phases/ship-evidence-comment.d.ts +12 -0
  18. package/dist/phases/ship-evidence-comment.d.ts.map +1 -0
  19. package/dist/phases/ship-evidence-comment.js +30 -0
  20. package/dist/phases/ship-evidence-comment.js.map +1 -0
  21. package/dist/phases/ship-existing-pr.d.ts +11 -0
  22. package/dist/phases/ship-existing-pr.d.ts.map +1 -0
  23. package/dist/phases/ship-existing-pr.js +36 -0
  24. package/dist/phases/ship-existing-pr.js.map +1 -0
  25. package/dist/phases/ship-finish.d.ts +15 -0
  26. package/dist/phases/ship-finish.d.ts.map +1 -0
  27. package/dist/phases/ship-finish.js +69 -0
  28. package/dist/phases/ship-finish.js.map +1 -0
  29. package/dist/phases/ship-git-detail.d.ts +31 -0
  30. package/dist/phases/ship-git-detail.d.ts.map +1 -0
  31. package/dist/phases/ship-git-detail.js +71 -0
  32. package/dist/phases/ship-git-detail.js.map +1 -0
  33. package/dist/phases/ship-git-remote.d.ts +51 -0
  34. package/dist/phases/ship-git-remote.d.ts.map +1 -0
  35. package/dist/phases/ship-git-remote.js +70 -0
  36. package/dist/phases/ship-git-remote.js.map +1 -0
  37. package/dist/phases/ship-git.d.ts +4 -79
  38. package/dist/phases/ship-git.d.ts.map +1 -1
  39. package/dist/phases/ship-git.js +2 -135
  40. package/dist/phases/ship-git.js.map +1 -1
  41. package/dist/phases/ship-open-pr.d.ts +19 -0
  42. package/dist/phases/ship-open-pr.d.ts.map +1 -0
  43. package/dist/phases/ship-open-pr.js +71 -0
  44. package/dist/phases/ship-open-pr.js.map +1 -0
  45. package/dist/phases/ship-options.d.ts +76 -0
  46. package/dist/phases/ship-options.d.ts.map +1 -0
  47. package/dist/phases/ship-options.js +4 -0
  48. package/dist/phases/ship-options.js.map +1 -0
  49. package/dist/phases/ship-reentry.d.ts +20 -0
  50. package/dist/phases/ship-reentry.d.ts.map +1 -0
  51. package/dist/phases/ship-reentry.js +47 -0
  52. package/dist/phases/ship-reentry.js.map +1 -0
  53. package/dist/phases/ship.d.ts +4 -76
  54. package/dist/phases/ship.d.ts.map +1 -1
  55. package/dist/phases/ship.js +30 -295
  56. package/dist/phases/ship.js.map +1 -1
  57. package/dist/queue/lane-discovery-interval.d.ts +6 -0
  58. package/dist/queue/lane-discovery-interval.d.ts.map +1 -0
  59. package/dist/queue/lane-discovery-interval.js +9 -0
  60. package/dist/queue/lane-discovery-interval.js.map +1 -0
  61. package/dist/reports/pr-body.d.ts.map +1 -1
  62. package/dist/reports/pr-body.js +18 -8
  63. package/dist/reports/pr-body.js.map +1 -1
  64. package/package.json +5 -5
@@ -0,0 +1,71 @@
1
+ // packages/core/src/phases/ship-open-pr.ts — SHIP draft PR creation and already-exists recovery
2
+ import { briefSummaryLine, renderPrBody, stripBriefIds } from '../reports/pr-body.js';
3
+ import { issueNumberOf } from '../work/work-key.js';
4
+ import { SHIP_BASE_BRANCH } from './ship-options.js';
5
+ import { findOpenPR, isPullAlreadyExistsError } from './ship-pr-lookup.js';
6
+ import { readRisk, readSpecBody } from './ship-spec.js';
7
+ import { renderStackOrderLine } from './stack-order.js';
8
+ export async function openOrFindPr(ctx) {
9
+ const { opts, inlineWork, stack, base, owner, repoName, walkthrough } = ctx;
10
+ const { octokit, issue, branch, checkSummary, log } = opts;
11
+ let prNumber;
12
+ // Get title from issue (skipped for a non-github work source — no such issue exists)
13
+ const title = inlineWork
14
+ ? inlineWork.title
15
+ : (await octokit.rest.issues.get({ owner, repo: repoName, issue_number: issueNumberOf(issue) })).data.title;
16
+ const slice = inlineWork ? undefined : opts.slice;
17
+ const finalSlice = !slice || slice.index >= slice.count;
18
+ // A brief is a local file reviewers cannot open, so the body describes it by its title and links the
19
+ // open PR it builds on (a --stack or --base-branch base), never its id, digest or path.
20
+ const basePr = inlineWork && base !== SHIP_BASE_BRANCH ? await findOpenPR(octokit, owner, repoName, base) : undefined;
21
+ const summaryLine = inlineWork
22
+ ? briefSummaryLine(title, basePr?.status === 'found' ? basePr.prNumber : undefined)
23
+ : slice
24
+ ? `Implements slice ${slice.index}/${slice.count} of #${issue}.`
25
+ : `Implements #${issue}.`;
26
+ const prTitle = inlineWork
27
+ ? stripBriefIds(title)
28
+ : slice
29
+ ? `${title} — slice ${slice.index}/${slice.count} (#${issue})`
30
+ : `${title} (#${issue})`;
31
+ // Create PR
32
+ try {
33
+ const { data: pr } = await octokit.rest.pulls.create({
34
+ owner,
35
+ repo: repoName,
36
+ head: branch,
37
+ base,
38
+ title: prTitle,
39
+ draft: true,
40
+ body: renderPrBody({
41
+ summaryLine,
42
+ footer: opts.footer,
43
+ stackOrder: stack ? renderStackOrderLine(stack) : undefined,
44
+ specBody: await readSpecBody(opts.specPath),
45
+ checkSummary,
46
+ reworkRounds: opts.reworkRounds,
47
+ risk: await readRisk(opts.specPath),
48
+ walkthrough: await walkthrough.walkthrough(),
49
+ typescriptLines: await walkthrough.counts(),
50
+ closes: inlineWork || !finalSlice ? undefined : issue,
51
+ partOf: !inlineWork && !finalSlice ? issue : undefined,
52
+ }),
53
+ });
54
+ prNumber = pr.number;
55
+ log('pr_opened', `opened PR #${prNumber} for committed work on ${branch} (base ${base})`);
56
+ }
57
+ catch (err) {
58
+ if (!isPullAlreadyExistsError(err))
59
+ throw err;
60
+ const existing = await findOpenPR(octokit, owner, repoName, branch);
61
+ if (existing.status !== 'found') {
62
+ const reason = `pulls.create reported an existing PR for ${branch} but re-querying did not find it (${existing.status === 'error' ? existing.detail : 'no open PR listed'})`;
63
+ log('ship', `${reason} — aborting`);
64
+ return { stop: { ok: false, reason } };
65
+ }
66
+ prNumber = existing.prNumber;
67
+ log('recovered', `PR #${prNumber} already existed for ${branch}; reusing it`);
68
+ }
69
+ return { prNumber };
70
+ }
71
+ //# sourceMappingURL=ship-open-pr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ship-open-pr.js","sourceRoot":"","sources":["../../src/phases/ship-open-pr.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAEhG,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAyB,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGxD,OAAO,EAAE,oBAAoB,EAAsB,MAAM,kBAAkB,CAAC;AAE5E,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAQlC;IACC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC;IAC5E,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC3D,IAAI,QAAgB,CAAC;IACrB,qFAAqF;IACrF,MAAM,K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AE,MAAM,CAAC,CAAC;QACpE,IAAI,QAAQ,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;YAChC,MAAM,MAAM,GAAG,4CAA4C,MAAM,qCAAqC,QAAQ,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,mBAAmB,GAAG,CAAC;YAC7K,GAAG,CAAC,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,CAAC;YACpC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;QACzC,CAAC;QACD,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;QAC7B,GAAG,CAAC,WAAW,EAAE,OAAO,QAAQ,wBAAwB,MAAM,cAAc,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,CAAC;AACtB,CAAC"}
@@ -0,0 +1,76 @@
1
+ import type { Octokit } from '@octokit/rest';
2
+ import type { ApprovalGate } from '../approvals/index.js';
3
+ import type { LifecycleBus } from '../bus/index.js';
4
+ import type { EventKind } from '../events/kinds.js';
5
+ import type { ReviewRouting } from '../review/routing.js';
6
+ import type { CheckSummary } from '../types/index.js';
7
+ import type { watchChecksWithInfraRerun } from '../utils/ci-watch.js';
8
+ import type { WorkRequest } from '../work/index.js';
9
+ import type { WorkKey } from '../work/work-key.js';
10
+ import type { CommandRunner } from './ship-git.js';
11
+ import type { PreviewGate } from './ship-preview.js';
12
+ import type { WalkthroughShipOpts } from './ship-walkthrough.js';
13
+ import type { StackPosition } from './stack-order.js';
14
+ /** Ship opens PRs against, and watches required checks of, this branch. */
15
+ export declare const SHIP_BASE_BRANCH = "main";
16
+ export interface ShipPhaseOptions {
17
+ issue: WorkKey;
18
+ repo: string;
19
+ worktree: string;
20
+ branch: string;
21
+ octokit: Octokit;
22
+ watchCI?: boolean;
23
+ /** Resolved pr.footer; undefined uses the default, empty string omits it. */
24
+ footer?: string;
25
+ /** Stop at the draft PR: skip mark-ready (#3449). */
26
+ draft?: boolean;
27
+ /** Post the evidence pack as a PR comment (pr.evidenceComment); default off. */
28
+ evidenceComment?: boolean;
29
+ log: (type: EventKind, msg: string) => void;
30
+ run?: CommandRunner;
31
+ /** Runs the gh rerun argv for the CI infra rescue (#2365); default runCommand. */
32
+ rerun?: (argv: readonly string[]) => Promise<{
33
+ ok: boolean;
34
+ }>;
35
+ approvalGate?: ApprovalGate;
36
+ checkSummary?: CheckSummary;
37
+ specPath?: string;
38
+ eventsFile?: string;
39
+ startedAt?: string;
40
+ logsDir?: string;
41
+ reworkRounds?: number;
42
+ /** PR classifier decision (#1724), rendered into the evidence pack. */
43
+ reviewRouting?: ReviewRouting;
44
+ /** Model pins that were not honored (#2511), rendered into the evidence pack. */
45
+ pinNotes?: string[];
46
+ /** The run's resolved work request; when its kind is not 'github-issue', the PR
47
+ * title/body come from it instead of fetching the (nonexistent) issue (#507). */
48
+ work?: Pick<WorkRequest, 'id' | 'kind' | 'title' | 'reference'>;
49
+ /** The ADR-0147 slice this run ships; titles the PR `slice k/n` and only the final slice closes the issue. */
50
+ slice?: {
51
+ index: number;
52
+ count: number;
53
+ };
54
+ /** Stack-mode (ADR-0161) position: the PR opens on `stack.base` and its body names the stack order. Ignored for inline work. */
55
+ stack?: StackPosition;
56
+ /** PR base for a non-stack run started from another branch (#3764); default main. */
57
+ baseBranch?: string;
58
+ /** Lane id stamped onto emitted lifecycle events; defaults to `issue-<issue>` (#591). */
59
+ laneId?: string;
60
+ /** Lifecycle bus to emit onto; defaults to the process-wide `lifecycleBus` (#591). */
61
+ bus?: LifecycleBus;
62
+ /** origin/<branch> SHA recorded at worktree creation (#1868). When set, the new-PR push
63
+ * replaces that stale head under a lease on this SHA, and fails closed if the remote moved (#1869). */
64
+ recordedRemoteSha?: string;
65
+ /** SHIP re-entry after a CI rework round (#2816): same open PR, plain push, watch the pushed SHA. */
66
+ reentry?: {
67
+ prNumber: number;
68
+ previousHeadSha?: string;
69
+ };
70
+ /** CI watch deadline (#3569); default DEFAULT_CI_DEADLINE_MS. */
71
+ ciDeadlineMs?: number;
72
+ walkthrough?: WalkthroughShipOpts['walkthrough'];
73
+ previewGate?: PreviewGate;
74
+ ciWatch?: typeof watchChecksWithInfraRerun;
75
+ }
76
+ //# sourceMappingURL=ship-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ship-options.d.ts","sourceRoot":"","sources":["../../src/phases/ship-options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,SAAS,CAAC;AAEvC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,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,EAAE,MAAM,CAAC;IAChB,sFAAsF;IACtF,GAAG,CAAC,EAAE,YAAY,CAAC;IACnB;4GACwG;IACxG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qGAAqG;IACrG,OAAO,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;IACjD,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,yBAAyB,CAAC;CAC5C"}
@@ -0,0 +1,4 @@
1
+ // packages/core/src/phases/ship-options.ts — SHIP phase options and the base branch it ships against
2
+ /** Ship opens PRs against, and watches required checks of, this branch. */
3
+ export const SHIP_BASE_BRANCH = 'main';
4
+ //# sourceMappingURL=ship-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ship-options.js","sourceRoot":"","sources":["../../src/phases/ship-options.ts"],"names":[],"mappings":"AAAA,qGAAqG;AAiBrG,2EAA2E;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { type CommandRunner } from './ship-git.js';
2
+ import type { ShipPhaseOptions } from './ship-options.js';
3
+ import type { ShipResult } from './ship-types.js';
4
+ export declare function pushReentry(ctx: {
5
+ run: CommandRunner;
6
+ worktree: string;
7
+ branch: string;
8
+ prNumber: number | undefined;
9
+ reentry: {
10
+ prNumber: number;
11
+ previousHeadSha?: string;
12
+ };
13
+ log: ShipPhaseOptions['log'];
14
+ }): Promise<{
15
+ stop: ShipResult;
16
+ } | {
17
+ watchRef: string;
18
+ headSha: string;
19
+ }>;
20
+ //# sourceMappingURL=ship-reentry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ship-reentry.d.ts","sourceRoot":"","sources":["../../src/phases/ship-reentry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAsD,MAAM,eAAe,CAAC;AACvG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,wBAAsB,WAAW,CAAC,GAAG,EAAE;IACrC,GAAG,EAAE,aAAa,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,GAAG,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC;CAC9B,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAyCxE"}
@@ -0,0 +1,47 @@
1
+ // packages/core/src/phases/ship-reentry.ts — SHIP re-entry push after a CI rework round
2
+ import { shellEscape } from '../utils/index.js';
3
+ import { describePushFailure, shortDetail, verifyRemoteHead } from './ship-git.js';
4
+ export async function pushReentry(ctx) {
5
+ const { run, worktree, branch, prNumber, reentry, log } = ctx;
6
+ if (prNumber !== reentry.prNumber) {
7
+ const reason = `re-entry expected open PR #${reentry.prNumber} for ${branch} but found ${prNumber === undefined ? 'none' : `#${prNumber}`}`;
8
+ log('ship', reason);
9
+ return { stop: { ok: false, reason } };
10
+ }
11
+ let localSha;
12
+ try {
13
+ localSha = (await run('git rev-parse HEAD', { cwd: worktree })).stdout.trim();
14
+ }
15
+ catch (err) {
16
+ const reason = `could not read local HEAD on re-entry (${shortDetail(err)})`;
17
+ log('ship', reason);
18
+ return { stop: { ok: false, prNumber, reason } };
19
+ }
20
+ if (localSha && localSha === reentry.previousHeadSha) {
21
+ const reason = `CI rework produced no new commit on ${branch}`;
22
+ log('ship', reason);
23
+ return { stop: { ok: false, prNumber, ciOutcome: 'failure', reason, headSha: localSha } };
24
+ }
25
+ try {
26
+ await run(`git push origin ${shellEscape(branch)}`, { cwd: worktree });
27
+ }
28
+ catch (err) {
29
+ const { kind, detail } = describePushFailure(err);
30
+ const reason = `re-entry push of ${branch} failed (${kind}): ${detail}`;
31
+ log('ship', reason);
32
+ return { stop: { ok: false, prNumber, reason } };
33
+ }
34
+ const remoteHead = await verifyRemoteHead(run, worktree, branch);
35
+ if (remoteHead.status !== 'match') {
36
+ const reason = remoteHead.status === 'mismatch'
37
+ ? `remote head ${remoteHead.remoteSha} does not match local HEAD ${remoteHead.localSha} for ${branch} after re-entry push`
38
+ : `could not verify the remote head for ${branch} after re-entry push (${remoteHead.detail})`;
39
+ log('ship', reason);
40
+ return { stop: { ok: false, prNumber, reason } };
41
+ }
42
+ const watchRef = remoteHead.remoteSha;
43
+ const headSha = remoteHead.remoteSha;
44
+ log('ship', `re-entry pushed ${branch} @ ${headSha}`);
45
+ return { watchRef, headSha };
46
+ }
47
+ //# sourceMappingURL=ship-reentry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ship-reentry.js","sourceRoot":"","sources":["../../src/phases/ship-reentry.ts"],"names":[],"mappings":"AAAA,wFAAwF;AAExF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAsB,mBAAmB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAIvG,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAOjC;IACC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IAC9D,IAAI,QAAQ,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,8BAA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M,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,oBAAoB,MAAM,YAAY,IAAI,MAAM,MAAM,EAAE,CAAC;QACxE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACpB,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC;IACnD,CAAC;IACD,MAAM,UAAU,GAAG,MAAM,gBAAgB,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACjE,IAAI,UAAU,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QAClC,MAAM,MAAM,GACV,UAAU,CAAC,MAAM,KAAK,UAAU;YAC9B,CAAC,CAAC,eAAe,UAAU,CAAC,SAAS,8BAA8B,UAAU,CAAC,QAAQ,QAAQ,MAAM,sBAAsB;YAC1H,CAAC,CAAC,wCAAwC,MAAM,yBAAyB,UAAU,CAAC,MAAM,GAAG,CAAC;QAClG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACpB,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC;IACnD,CAAC;IACD,MAAM,QAAQ,GAAG,UAAU,CAAC,SAAS,CAAC;IACtC,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC;IACrC,GAAG,CAAC,MAAM,EAAE,mBAAmB,MAAM,MAAM,OAAO,EAAE,CAAC,CAAC;IACtD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC/B,CAAC"}
@@ -1,79 +1,7 @@
1
- import { type WorkKey } from '../work/work-key.js';
2
- import type { Octokit } from '@octokit/rest';
3
- import type { ApprovalGate } from '../approvals/index.js';
4
- import { type LifecycleBus } from '../bus/index.js';
5
- import type { EventKind } from '../events/kinds.js';
6
- import { type WalkthroughShipOpts } from './ship-walkthrough.js';
7
- import { type StackPosition } from './stack-order.js';
8
- import type { ReviewRouting } from '../review/routing.js';
9
- import { type CommandRunner } from './ship-git.js';
10
- import { type PreviewGate } from './ship-preview.js';
11
- import type { CheckSummary } from '../types/index.js';
12
- import { type watchChecksWithInfraRerun } from '../utils/ci-watch.js';
13
- import type { WorkRequest } from '../work/index.js';
14
- import { findMergedPR, findOpenPR, isPullAlreadyExistsError } from './ship-pr-lookup.js';
1
+ import { type ShipPhaseOptions } from './ship-options.js';
2
+ import { findMergedPR, findOpenPR } from './ship-pr-lookup.js';
15
3
  import type { PrLookup, ShipResult } from './ship-types.js';
16
- export { findMergedPR, findOpenPR, isPullAlreadyExistsError };
4
+ export { findMergedPR, findOpenPR };
17
5
  export type { PrLookup, ShipResult };
18
- export declare function shipPhase(opts: Parameters<typeof shipPhaseImpl>[0]): Promise<ShipResult>;
19
- declare function shipPhaseImpl(opts: {
20
- issue: WorkKey;
21
- repo: string;
22
- worktree: string;
23
- branch: string;
24
- octokit: Octokit;
25
- watchCI?: boolean;
26
- /** Resolved pr.footer; undefined uses the default, empty string omits it. */
27
- footer?: string;
28
- /** Stop at the draft PR: skip mark-ready (#3449). */
29
- draft?: boolean;
30
- /** Post the evidence pack as a PR comment (pr.evidenceComment); default off. */
31
- evidenceComment?: boolean;
32
- log: (type: EventKind, msg: string) => void;
33
- run?: CommandRunner;
34
- /** Runs the gh rerun argv for the CI infra rescue (#2365); default runCommand. */
35
- rerun?: (argv: readonly string[]) => Promise<{
36
- ok: boolean;
37
- }>;
38
- approvalGate?: ApprovalGate;
39
- checkSummary?: CheckSummary;
40
- specPath?: string;
41
- eventsFile?: string;
42
- startedAt?: string;
43
- logsDir?: string;
44
- reworkRounds?: number;
45
- /** PR classifier decision (#1724), rendered into the evidence pack. */
46
- reviewRouting?: ReviewRouting;
47
- /** Model pins that were not honored (#2511), rendered into the evidence pack. */
48
- pinNotes?: string[];
49
- /** The run's resolved work request; when its kind is not 'github-issue', the PR
50
- * title/body come from it instead of fetching the (nonexistent) issue (#507). */
51
- work?: Pick<WorkRequest, 'id' | 'kind' | 'title' | 'reference'>;
52
- /** The ADR-0147 slice this run ships; titles the PR `slice k/n` and only the final slice closes the issue. */
53
- slice?: {
54
- index: number;
55
- count: number;
56
- };
57
- /** Stack-mode (ADR-0161) position: the PR opens on `stack.base` and its body names the stack order. Ignored for inline work. */
58
- stack?: StackPosition;
59
- /** PR base for a non-stack run started from another branch (#3764); default main. */
60
- baseBranch?: string;
61
- /** Lane id stamped onto emitted lifecycle events; defaults to `issue-<issue>` (#591). */
62
- laneId?: string;
63
- /** Lifecycle bus to emit onto; defaults to the process-wide `lifecycleBus` (#591). */
64
- bus?: LifecycleBus;
65
- /** origin/<branch> SHA recorded at worktree creation (#1868). When set, the new-PR push
66
- * replaces that stale head under a lease on this SHA, and fails closed if the remote moved (#1869). */
67
- recordedRemoteSha?: string;
68
- /** SHIP re-entry after a CI rework round (#2816): same open PR, plain push, watch the pushed SHA. */
69
- reentry?: {
70
- prNumber: number;
71
- previousHeadSha?: string;
72
- };
73
- /** CI watch deadline (#3569); default DEFAULT_CI_DEADLINE_MS. */
74
- ciDeadlineMs?: number;
75
- walkthrough?: WalkthroughShipOpts['walkthrough'];
76
- previewGate?: PreviewGate;
77
- ciWatch?: typeof watchChecksWithInfraRerun;
78
- }): Promise<ShipResult>;
6
+ export declare function shipPhase(opts: ShipPhaseOptions): Promise<ShipResult>;
79
7
  //# sourceMappingURL=ship.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ship.d.ts","sourceRoot":"","sources":["../../src/phases/ship.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAIlE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,KAAK,YAAY,EAAiB,MAAM,i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