@cbartens/bkit 5.3.0 → 5.5.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/.bkit/README.md +20 -7
- package/.bkit/core/.agents/docs.md +1 -1
- package/.bkit/core/.agents/rules.md +14 -9
- package/.bkit/core/.bkit/README.md +19 -6
- package/.bkit/core/.bkit/cloud.md +77 -46
- package/.bkit/core/.bkit/comparison.md +3 -3
- package/.bkit/core/.bkit/install.md +21 -18
- package/.bkit/core/.bkit/lite.md +6 -6
- package/.bkit/core/.bkit/pipeline.md +6 -3
- package/.bkit/core/.bkit/prompts.md +14 -10
- package/.bkit/core/.bkit/providers.md +7 -7
- package/.bkit/core/.bkit/templates.md +46 -10
- package/.bkit/core/.bkit/trackers.md +92 -38
- package/.bkit/core/.bkit/workflows.md +140 -116
- package/.bkit/core/AGENTS.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-agents.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +4 -2
- package/.bkit/core/docs/templates/bkit-audit-config.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-cost.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-database.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +5 -5
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +14 -13
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-failures.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-gates.md +5 -2
- package/.bkit/core/docs/templates/bkit-audit-issues.md +25 -8
- package/.bkit/core/docs/templates/bkit-audit-llm.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-logs.md +10 -6
- package/.bkit/core/docs/templates/bkit-audit-models.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +5 -5
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-repo.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-security.md +11 -9
- package/.bkit/core/docs/templates/bkit-audit-slop.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-testing.md +6 -5
- package/.bkit/core/docs/templates/bkit-audit-usability.md +1 -1
- package/.bkit/core/engine/checks/after/auth.ts +88 -45
- package/.bkit/core/engine/checks/after/github.ts +18 -5
- package/.bkit/core/engine/checks/after/index.ts +1 -1
- package/.bkit/core/engine/checks/after/tools.ts +1 -1
- package/.bkit/core/engine/checks/before/env.ts +28 -18
- package/.bkit/core/engine/checks/before/mcp.ts +4 -2
- package/.bkit/core/engine/checks/status-holes.ts +0 -1
- package/.bkit/core/engine/checks/tips/catalogue.ts +31 -2
- package/.bkit/core/engine/checks/tips/index.ts +49 -27
- package/.bkit/core/engine/cli.ts +27 -18
- package/.bkit/core/engine/commands/ci/ci.ts +107 -0
- package/.bkit/core/engine/commands/comply.ts +25 -16
- package/.bkit/core/engine/commands/install/install.ts +11 -4
- package/.bkit/core/engine/commands/install/uninstall.ts +46 -0
- package/.bkit/core/engine/commands/land.ts +156 -0
- package/.bkit/core/engine/commands/lib.ts +10 -8
- package/.bkit/core/engine/commands/registry.ts +2 -0
- package/.bkit/core/engine/commands/tips.ts +7 -3
- package/.bkit/core/engine/commands/workflow/branches.ts +382 -282
- package/.bkit/core/engine/commands/workflow/disk.ts +556 -0
- package/.bkit/core/engine/commands/workflow/fids.ts +23 -15
- package/.bkit/core/engine/commands/workflow/issues.ts +106 -42
- package/.bkit/core/engine/commands/workflow/ledgers.ts +28 -11
- package/.bkit/core/engine/commands/workflow/locks.ts +38 -152
- package/.bkit/core/engine/commands/workflow/prs.ts +14 -3
- package/.bkit/core/engine/commands/workflow/repo.ts +6 -0
- package/.bkit/core/engine/commands/workflow/roadmap.ts +53 -54
- package/.bkit/core/engine/commands/workflow/runtime.ts +3 -2
- package/.bkit/core/engine/commands/workflow/status.ts +33 -11
- package/.bkit/core/engine/commands/workflow/steps.ts +26 -17
- package/.bkit/core/engine/commands/workflow/workflows.ts +442 -269
- package/.bkit/core/engine/commands/workflow/workstreams.ts +3 -2
- package/.bkit/core/engine/commands/workflow/worktrees.ts +11 -1
- package/.bkit/core/engine/install/manifest.ts +31 -10
- package/.bkit/core/engine/install/modules/cloud.ts +3 -1
- package/.bkit/core/engine/install/modules/core.ts +97 -4
- package/.bkit/core/engine/install/modules/opencode.ts +5 -0
- package/.bkit/core/engine/install/placeholders.ts +13 -17
- package/.bkit/core/engine/install/write.ts +37 -1
- package/.bkit/core/engine/render/trackers.ts +35 -23
- package/.bkit/core/engine/shared/egress.ts +6 -0
- package/.bkit/core/engine/shared/settings.ts +96 -1
- package/.bkit/core/engine/shared/timeouts.ts +8 -7
- package/.bkit/core/hooks/guardrails-tiers.js +1 -1
- package/.bkit/core/prompts/bkit-audit-generate.md +80 -7
- package/.bkit/core/prompts/bkit-build-challenge-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-tests.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-execute.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +1 -1
- package/.bkit/core/prompts/bkit-design-generate.md +2 -1
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +1 -1
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +4 -2
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +4 -2
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +12 -2
- package/.bkit/core/prompts/bkit-utility-update-failures.md +4 -2
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +4 -2
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +12 -5
- package/.bkit/core/prompts/bkit-utility-update-tracker.md +159 -0
- package/.bkit/core/workflows/bkit-auto.md +19 -6
- package/.bkit/core/workflows/bkit-build.md +64 -22
- package/.bkit/core/workflows/bkit-debug.md +72 -28
- package/.bkit/core/workflows/bkit-design.md +101 -37
- package/.bkit/core/workflows/bkit-plan.md +82 -31
- package/.bkit/core/workflows/bkit-ship.md +127 -108
- package/.bkit/shared/.bkit/.env.example +8 -0
- package/.bkit/shared/.claude/bkit-cloud.md +12 -12
- package/.bkit/shared/.claude/settings.json +4 -1
- package/.bkit/shared/.cursor/bkit-cloud.md +2 -2
- package/.bkit/shared/.cursor/mcp.json +11 -4
- package/.bkit/shared/.mcp.json +11 -4
- package/.bkit/shared/.opencode/opencode.json +2 -0
- package/.bkit/shared/docs/deployments.md +44 -29
- package/.bkit/shared/docs/security.md +1 -1
- package/.bkit/shared/docs/testing.md +3 -3
- package/.bkit/shared/gitignore +1 -2
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +2 -2
- package/.bkit/templates/.github/renovate.json5 +1 -1
- package/.bkit/templates/.github/workflows/bkit-ci.yml +29 -56
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +40 -12
- package/.bkit/templates/.husky/pre-commit +10 -4
- package/.bkit/templates/.husky/pre-push +69 -12
- package/.bkit/templates/.lintstagedrc.json +5 -1
- package/.bkit/templates/scripts/ci/lanes/check-tree-cache.mjs +138 -0
- package/.bkit/templates/scripts/ci/lanes/check-tree-cache.test.mjs +181 -0
- package/.bkit/templates/scripts/cleanup/bkit-disk-prune.machine.mjs +197 -0
- package/.bkit/templates/scripts/cleanup/bkit-disk-prune.mjs +164 -0
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +1 -1
- package/CHANGELOG.md +85 -1
- package/README.md +102 -100
- package/dist/checks/after/auth.js +81 -45
- package/dist/checks/after/github.js +17 -5
- package/dist/checks/after/index.js +1 -1
- package/dist/checks/after/tools.js +1 -1
- package/dist/checks/before/env.js +24 -17
- package/dist/checks/before/mcp.js +4 -2
- package/dist/checks/status-holes.js +0 -1
- package/dist/checks/tips/catalogue.js +28 -2
- package/dist/checks/tips/index.js +44 -28
- package/dist/cli.js +27 -19
- package/dist/commands/ci/ci.js +100 -0
- package/dist/commands/comply.js +20 -13
- package/dist/commands/install/install.js +10 -4
- package/dist/commands/install/uninstall.js +42 -0
- package/dist/commands/land.js +129 -0
- package/dist/commands/lib.js +9 -6
- package/dist/commands/registry.js +2 -0
- package/dist/commands/tips.js +7 -3
- package/dist/commands/workflow/branches.js +300 -243
- package/dist/commands/workflow/disk.js +452 -0
- package/dist/commands/workflow/fids.js +22 -15
- package/dist/commands/workflow/issues.js +90 -41
- package/dist/commands/workflow/ledgers.js +26 -11
- package/dist/commands/workflow/locks.js +35 -130
- package/dist/commands/workflow/prs.js +8 -3
- package/dist/commands/workflow/repo.js +5 -0
- package/dist/commands/workflow/roadmap.js +52 -57
- package/dist/commands/workflow/runtime.js +3 -2
- package/dist/commands/workflow/status.js +32 -12
- package/dist/commands/workflow/steps.js +20 -13
- package/dist/commands/workflow/workflows.js +397 -251
- package/dist/commands/workflow/workstreams.js +3 -2
- package/dist/commands/workflow/worktrees.js +11 -1
- package/dist/install/manifest.js +30 -10
- package/dist/install/modules/cloud.js +3 -1
- package/dist/install/modules/core.js +95 -5
- package/dist/install/modules/opencode.js +6 -0
- package/dist/install/placeholders.js +13 -19
- package/dist/install/write.js +26 -2
- package/dist/render/trackers.js +34 -20
- package/dist/shared/egress.js +6 -0
- package/dist/shared/settings.js +44 -0
- package/dist/shared/timeouts.js +8 -7
- package/package.json +11 -2
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
// ship's one-commit flush (`--flush`), and print the handover comment.
|
|
13
13
|
// close grade compliance, then the `workflow-done` row, the run's counter and
|
|
14
14
|
// outcome rows in `.bkit/stats.jsonl`, this workflow's telemetry report
|
|
15
|
-
// and the artifact links. `--flush` is ship's close:
|
|
16
|
-
//
|
|
15
|
+
// and the artifact links. `--flush` is ship's close: land it on dev
|
|
16
|
+
// through a throwaway origin/dev checkout, then remove the worktree.
|
|
17
17
|
// promote design / plan close: the highest versioned draft becomes the
|
|
18
18
|
// canonical doc (anchor stamped, a superseded canonical archived).
|
|
19
19
|
// links the feature docs and this workflow's logs on a ref, as markdown links.
|
|
@@ -38,13 +38,15 @@ import {
|
|
|
38
38
|
type CoverageStats,
|
|
39
39
|
} from "../../ledgers/telemetry.js";
|
|
40
40
|
import { readBkitVersion } from "../../install/version-file.js";
|
|
41
|
-
import {
|
|
41
|
+
import { readBkitConfig } from "../../shared/settings.js";
|
|
42
42
|
import { gradeCompliance } from "../comply.js";
|
|
43
|
+
import { landDir, pushToDev, type DevPush } from "../land.js";
|
|
43
44
|
import {
|
|
44
45
|
CommandError,
|
|
45
46
|
DEV,
|
|
46
47
|
EXIT,
|
|
47
48
|
git,
|
|
49
|
+
isSharedBranch,
|
|
48
50
|
parseJson,
|
|
49
51
|
repoRoot,
|
|
50
52
|
runGh,
|
|
@@ -61,16 +63,14 @@ import {
|
|
|
61
63
|
AUTO_LABEL,
|
|
62
64
|
AUTO_ROUTE_SUFFIX,
|
|
63
65
|
buildComment,
|
|
64
|
-
|
|
66
|
+
trackerState,
|
|
65
67
|
transitionLabels,
|
|
66
68
|
} from "./issues.js";
|
|
67
69
|
import { EXIT_EMPTY, commitBookkeeping, unionLedgers } from "./ledgers.js";
|
|
68
70
|
import {
|
|
69
71
|
EXIT_REMOVE_FAILED,
|
|
70
72
|
EXIT_SPLIT_BUCKET,
|
|
71
|
-
acquireDevLock,
|
|
72
73
|
acquireWorkflowLock,
|
|
73
|
-
lockRoot,
|
|
74
74
|
owns,
|
|
75
75
|
readHolder,
|
|
76
76
|
releaseLock,
|
|
@@ -89,14 +89,13 @@ import {
|
|
|
89
89
|
str,
|
|
90
90
|
} from "./status.js";
|
|
91
91
|
import { writeStepRow } from "./steps.js";
|
|
92
|
+
import { removeWorktree, type RemoveResult } from "./worktrees.js";
|
|
92
93
|
|
|
93
94
|
/** Sentinels a workflow leaves in its logs folder; either one existing means a handover is due. */
|
|
94
95
|
export const SENTINELS = [".rebase-failed", ".deferred-blocked"] as const;
|
|
95
96
|
|
|
96
97
|
/** Exit code (start --lock-held): the lock is missing or belongs to another owner. */
|
|
97
98
|
export const EXIT_LOCK_NOT_HELD = 6;
|
|
98
|
-
/** Exit code (handover --push): the handover artifact is missing or empty. */
|
|
99
|
-
export const EXIT_HANDOVER_MISSING = 8;
|
|
100
99
|
/** Exit code (handover --push): the branch has an open PR, so nothing was pushed. */
|
|
101
100
|
export const EXIT_OPEN_PR_KEPT = 9;
|
|
102
101
|
/** Exit code (handover, close --flush): a push failed. */
|
|
@@ -113,7 +112,7 @@ export const EXIT_NO_VERSION = 12;
|
|
|
113
112
|
interface Where {
|
|
114
113
|
root: string;
|
|
115
114
|
month: string;
|
|
116
|
-
/** Tree the run works in:
|
|
115
|
+
/** Tree the run works in: the current worktree's top. */
|
|
117
116
|
tree: string;
|
|
118
117
|
status: string;
|
|
119
118
|
}
|
|
@@ -127,20 +126,14 @@ function workflowName(workflow: string): string {
|
|
|
127
126
|
return workflow;
|
|
128
127
|
}
|
|
129
128
|
|
|
130
|
-
/**
|
|
131
|
-
* start and close work in the current tree (ship: its book root), the root
|
|
132
|
-
* `git rev-parse --show-toplevel` reports.
|
|
133
|
-
*/
|
|
129
|
+
/** start and close work in the current tree, the root `git rev-parse --show-toplevel` reports. */
|
|
134
130
|
function whereInTree(
|
|
135
131
|
cwd: string,
|
|
136
|
-
o: { workflow: string; fid: string; month?: string;
|
|
132
|
+
o: { workflow: string; fid: string; month?: string; file?: string },
|
|
137
133
|
): Where {
|
|
138
134
|
const root = repoRoot(cwd);
|
|
139
135
|
const month = resolveMonth(root, o.fid, o.month);
|
|
140
|
-
const tree =
|
|
141
|
-
o.workflow === "ship"
|
|
142
|
-
? lockRoot(cwd, o.workflow, o.devPushes)
|
|
143
|
-
: (git(cwd, ["rev-parse", "--show-toplevel"]) ?? root);
|
|
136
|
+
const tree = git(cwd, ["rev-parse", "--show-toplevel"]) ?? root;
|
|
144
137
|
const status = o.file ? path.resolve(cwd, o.file) : path.join(tree, statusRelPath(month, o.fid));
|
|
145
138
|
return { root, month, tree, status };
|
|
146
139
|
}
|
|
@@ -181,13 +174,12 @@ function abortRebase(tree: string, log: (m: string) => void): boolean {
|
|
|
181
174
|
|
|
182
175
|
/** The workflow-failed state: row, rebase abort, lock release, sentinels. */
|
|
183
176
|
function failState(ctx: RunContext, workflow: string, fid: string) {
|
|
184
|
-
const devPushes = ctx.flags.devPushes === true;
|
|
185
177
|
const root = repoRoot(ctx.cwd);
|
|
186
178
|
const month = resolveMonth(root, fid, str(ctx.flags.month) || undefined);
|
|
187
179
|
const file = str(ctx.flags.file) || undefined;
|
|
188
180
|
const status = file
|
|
189
181
|
? path.resolve(ctx.cwd, file)
|
|
190
|
-
: statusLocation({ cwd: ctx.cwd, workflow, fid, month
|
|
182
|
+
: statusLocation({ cwd: ctx.cwd, workflow, fid, month }).path;
|
|
191
183
|
|
|
192
184
|
// The run's own tree: the feature worktree when there is one, else this checkout.
|
|
193
185
|
// Never the main checkout behind a worktree, where a rebase would be a human's.
|
|
@@ -210,7 +202,7 @@ function failState(ctx: RunContext, workflow: string, fid: string) {
|
|
|
210
202
|
ctx.log(`${status} does not exist — no workflow-failed row written`);
|
|
211
203
|
}
|
|
212
204
|
|
|
213
|
-
const lockFile = workflowLockPath(
|
|
205
|
+
const lockFile = workflowLockPath(root, month, fid);
|
|
214
206
|
const { removeFailed, ...lock } = releaseLock(lockFile, {
|
|
215
207
|
workflow,
|
|
216
208
|
fid,
|
|
@@ -221,7 +213,7 @@ function failState(ctx: RunContext, workflow: string, fid: string) {
|
|
|
221
213
|
if (removeFailed) ctx.log(`lock removal failed: ${lockFile}`);
|
|
222
214
|
|
|
223
215
|
// Each sentinel is cleared where it was created: `.rebase-failed` in the run's
|
|
224
|
-
// tree, `.deferred-blocked` beside status.jsonl
|
|
216
|
+
// tree, `.deferred-blocked` beside status.jsonl.
|
|
225
217
|
const logDirs = new Set([path.join(tree, logDirRel(month, fid)), path.dirname(status)]);
|
|
226
218
|
const sentinels: Array<{ name: string; path: string }> = [];
|
|
227
219
|
for (const dir of logDirs) {
|
|
@@ -266,8 +258,10 @@ function failVerb(ctx: RunContext): number {
|
|
|
266
258
|
}
|
|
267
259
|
const merged = prState === "MERGED";
|
|
268
260
|
const transition = merged ? { phase: "merged" } : { failed: true };
|
|
269
|
-
const
|
|
261
|
+
const current = list(ctx.flags.label);
|
|
262
|
+
const labels = transitionLabels(current, transition).labels;
|
|
270
263
|
if (merged && !labels.includes("bkit:failed")) labels.push("bkit:failed");
|
|
264
|
+
const add = labels.filter((l) => !current.includes(l));
|
|
271
265
|
|
|
272
266
|
// The failure comment, when the step is named.
|
|
273
267
|
let comment: string | null = null;
|
|
@@ -294,8 +288,9 @@ function failVerb(ctx: RunContext): number {
|
|
|
294
288
|
handoverNeeded:
|
|
295
289
|
token !== undefined &&
|
|
296
290
|
(ctx.flags.maxExceeded === true || state.sentinels.length > 0 || state.soak),
|
|
291
|
+
add,
|
|
297
292
|
labels,
|
|
298
|
-
|
|
293
|
+
trackerState: trackerState(transition, undefined, readBkitConfig(repoRoot(ctx.cwd))),
|
|
299
294
|
prState,
|
|
300
295
|
comment,
|
|
301
296
|
});
|
|
@@ -313,101 +308,261 @@ function readText(cwd: string, rel: string): string {
|
|
|
313
308
|
// handover
|
|
314
309
|
// ---------------------------------------------------------------------------
|
|
315
310
|
|
|
311
|
+
/** Non-empty lines; a final newline ends the last line rather than starting an empty one. */
|
|
312
|
+
const textLines = (text: string) => text.split("\n").filter((l) => l.trim() !== "");
|
|
313
|
+
|
|
314
|
+
/** `rel` in `tree` differs from its HEAD copy, or is untracked: the run wrote it. */
|
|
315
|
+
const ownWrite = (tree: string, rel: string) =>
|
|
316
|
+
(git(tree, ["status", "--porcelain", "--untracked-files=all", "--", rel]) ?? "") !== "";
|
|
317
|
+
|
|
318
|
+
/** Copy each `.md` log in the run's log folder that dev lacks, or that the run rewrote. */
|
|
319
|
+
function carryLogs(src: string, dst: string, rel: string): string[] {
|
|
320
|
+
if (!fs.existsSync(path.join(src, rel))) return [];
|
|
321
|
+
fs.mkdirSync(path.join(dst, rel), { recursive: true });
|
|
322
|
+
const copied: string[] = [];
|
|
323
|
+
for (const f of fs.readdirSync(path.join(src, rel)).filter((n) => n.endsWith(".md"))) {
|
|
324
|
+
const from = path.join(src, rel, f);
|
|
325
|
+
const to = path.join(dst, rel, f);
|
|
326
|
+
const same = fs.existsSync(to) && fs.readFileSync(to).equals(fs.readFileSync(from));
|
|
327
|
+
if (same || (fs.existsSync(to) && !ownWrite(src, path.join(rel, f)))) continue;
|
|
328
|
+
fs.copyFileSync(from, to);
|
|
329
|
+
copied.push(path.join(rel, f));
|
|
330
|
+
}
|
|
331
|
+
return copied;
|
|
332
|
+
}
|
|
333
|
+
|
|
316
334
|
/**
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
* to dev under the dev lock when this runtime pushes dev, else the current branch.
|
|
335
|
+
* Carry a run's book (its feature worktree) into a dev checkout: its `.md` logs,
|
|
336
|
+
* and its ledger rows unioned line-wise (both hold rows the other does not).
|
|
320
337
|
*/
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
338
|
+
function carryBook(src: string, dst: string, month: string, fid: string): void {
|
|
339
|
+
carryLogs(src, dst, logDirRel(month, fid));
|
|
340
|
+
unionLedgers(src, dst);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** What a landing carried out of a shared checkout: whole `.md` logs, and ledger lines per file. */
|
|
344
|
+
interface Carried {
|
|
345
|
+
files: string[];
|
|
346
|
+
lines: Map<string, string[]>;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** Shared ledgers a run may append to, outside its own log folder. */
|
|
350
|
+
const SHARED_LEDGERS = [
|
|
351
|
+
":(glob)docs/*.jsonl",
|
|
352
|
+
":(glob).bkit/*.jsonl",
|
|
353
|
+
":(exclude).bkit/issues.jsonl",
|
|
354
|
+
];
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Carry ONLY the run's own record out of a dev / main / detached checkout, which
|
|
358
|
+
* other sessions and local-only commits share: the `.md` logs it wrote in its log
|
|
359
|
+
* folder; the lines of that folder's `.jsonl` files its HEAD lacks; and, from the
|
|
360
|
+
* shared ledgers, lines its HEAD lacks that are rows of `workflow` at or after
|
|
361
|
+
* the run's start (`startMs`). No start known → no shared-ledger row is carried.
|
|
362
|
+
*/
|
|
363
|
+
function carryOwnBook(
|
|
364
|
+
src: string,
|
|
365
|
+
dst: string,
|
|
366
|
+
o: { month: string; fid: string; workflow: string; startMs: number | undefined },
|
|
367
|
+
log: (line: string) => void,
|
|
368
|
+
): Carried {
|
|
328
369
|
const rel = logDirRel(o.month, o.fid);
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
370
|
+
const carried: Carried = { files: carryLogs(src, dst, rel), lines: new Map() };
|
|
371
|
+
const uncommitted = (file: string) => {
|
|
372
|
+
const head = new Set(textLines(git(src, ["show", `HEAD:${file}`]) ?? "").map((l) => l.trim()));
|
|
373
|
+
return textLines(fs.readFileSync(path.join(src, file), "utf-8")).filter(
|
|
374
|
+
(l) => !head.has(l.trim()),
|
|
375
|
+
);
|
|
376
|
+
};
|
|
377
|
+
const add = (file: string, lines: string[]) => {
|
|
378
|
+
const to = path.join(dst, file);
|
|
379
|
+
const existing = fs.existsSync(to) ? fs.readFileSync(to, "utf-8") : "";
|
|
380
|
+
const have = new Set(textLines(existing).map((l) => l.trim()));
|
|
381
|
+
const fresh = lines.filter((l) => !have.has(l.trim()));
|
|
382
|
+
if (fresh.length === 0) return;
|
|
383
|
+
fs.mkdirSync(path.dirname(to), { recursive: true });
|
|
384
|
+
const sep = existing !== "" && !existing.endsWith("\n") ? "\n" : "";
|
|
385
|
+
fs.appendFileSync(to, `${sep}${fresh.join("\n")}\n`);
|
|
386
|
+
carried.lines.set(file, fresh);
|
|
387
|
+
};
|
|
388
|
+
const listed = (specs: string[]) =>
|
|
389
|
+
(git(src, ["ls-files", "--cached", "--others", "--exclude-standard", "--", ...specs]) ?? "")
|
|
390
|
+
.split("\n")
|
|
391
|
+
.filter((f) => f !== "" && fs.existsSync(path.join(src, f)));
|
|
392
|
+
|
|
393
|
+
for (const file of listed([`:(glob)${rel}/*.jsonl`])) add(file, uncommitted(file));
|
|
394
|
+
if (o.startMs === undefined) {
|
|
395
|
+
log(`no ${o.workflow} start row for ${o.fid} — no shared-ledger row carried`);
|
|
396
|
+
return carried;
|
|
337
397
|
}
|
|
398
|
+
for (const file of listed(SHARED_LEDGERS)) {
|
|
399
|
+
const own = uncommitted(file).filter((l) => {
|
|
400
|
+
const parsed = parseJson(l);
|
|
401
|
+
const row = parsed.ok ? (parsed.value as Record<string, unknown> | null) : null;
|
|
402
|
+
return row?.workflow === o.workflow && Number(row.ts) >= o.startMs!;
|
|
403
|
+
});
|
|
404
|
+
if (own.length > 0) add(file, own);
|
|
405
|
+
}
|
|
406
|
+
return carried;
|
|
407
|
+
}
|
|
338
408
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
runGit(root, ["pull", "--ff-only", "origin", DEV]);
|
|
365
|
-
wt = root;
|
|
366
|
-
target = DEV;
|
|
367
|
-
} else {
|
|
368
|
-
ctx.log("RUNTIME_DEVPUSHES=false — the FAILED record commits on the current branch");
|
|
369
|
-
target = git(wt, ["branch", "--show-current"]) ?? "";
|
|
409
|
+
/**
|
|
410
|
+
* After a landing from a dev / main / detached checkout: hand back what was
|
|
411
|
+
* carried, so a later fast-forward of dev does not stop on it. A carried `.md`
|
|
412
|
+
* log identical to the landed copy is removed when untracked, or returns to HEAD
|
|
413
|
+
* when tracked. A carried ledger loses exactly the carried lines; it returns to
|
|
414
|
+
* HEAD when that leaves it equal, and an untracked one left empty is removed.
|
|
415
|
+
* Anything staged, or a log changed since it landed, stays and is named.
|
|
416
|
+
*/
|
|
417
|
+
function handBack(tree: string, sha: string, carried: Carried, log: (line: string) => void): void {
|
|
418
|
+
const back: string[] = [];
|
|
419
|
+
const kept: string[] = [];
|
|
420
|
+
const staged = (rel: string) => !runGit(tree, ["diff", "--cached", "--quiet", "--", rel]).ok;
|
|
421
|
+
const tracked = (rel: string) => runGit(tree, ["ls-files", "--error-unmatch", "--", rel]).ok;
|
|
422
|
+
for (const rel of carried.files) {
|
|
423
|
+
const abs = path.join(tree, rel);
|
|
424
|
+
const landed = runGit(tree, ["show", `${sha}:${rel}`]);
|
|
425
|
+
const same =
|
|
426
|
+
landed.ok && fs.existsSync(abs) && fs.readFileSync(abs, "utf-8").trim() === landed.stdout;
|
|
427
|
+
if (!same || staged(rel)) kept.push(rel);
|
|
428
|
+
else if (!tracked(rel)) {
|
|
429
|
+
fs.rmSync(abs);
|
|
430
|
+
back.push(rel);
|
|
431
|
+
} else if (runGit(tree, ["restore", "--source=HEAD", "--worktree", "--", rel]).ok)
|
|
432
|
+
back.push(rel);
|
|
433
|
+
else kept.push(rel);
|
|
370
434
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
435
|
+
for (const [rel, lines] of carried.lines) {
|
|
436
|
+
const abs = path.join(tree, rel);
|
|
437
|
+
if (!fs.existsSync(abs) || staged(rel)) {
|
|
438
|
+
kept.push(rel);
|
|
439
|
+
continue;
|
|
375
440
|
}
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
if (
|
|
391
|
-
|
|
392
|
-
|
|
441
|
+
const drop = new Map<string, number>();
|
|
442
|
+
for (const l of lines) drop.set(l.trim(), (drop.get(l.trim()) ?? 0) + 1);
|
|
443
|
+
const left = fs
|
|
444
|
+
.readFileSync(abs, "utf-8")
|
|
445
|
+
.split("\n")
|
|
446
|
+
.filter((l) => {
|
|
447
|
+
const n = drop.get(l.trim()) ?? 0;
|
|
448
|
+
if (n === 0) return true;
|
|
449
|
+
drop.set(l.trim(), n - 1);
|
|
450
|
+
return false;
|
|
451
|
+
})
|
|
452
|
+
.join("\n");
|
|
453
|
+
const head = runGit(tree, ["show", `HEAD:${rel}`]);
|
|
454
|
+
if (head.ok && left.trim() === head.stdout.trim()) {
|
|
455
|
+
if (!runGit(tree, ["restore", "--source=HEAD", "--worktree", "--", rel]).ok) {
|
|
456
|
+
kept.push(rel);
|
|
457
|
+
continue;
|
|
393
458
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
459
|
+
} else if (!tracked(rel) && left.trim() === "") fs.rmSync(abs);
|
|
460
|
+
else fs.writeFileSync(abs, left.endsWith("\n") || left === "" ? left : `${left}\n`);
|
|
461
|
+
back.push(rel);
|
|
462
|
+
}
|
|
463
|
+
if (back.length > 0) log(`handed back ${back.length} file(s) now on dev: ${back.join(", ")}`);
|
|
464
|
+
if (kept.length > 0) log(`kept in ${tree}, not all on dev: ${kept.join(", ")}`);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/** Thrown by a landing's build when the book adds nothing to dev. */
|
|
468
|
+
const NOTHING_TO_LAND = new Error("no bookkeeping delta");
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Land a failed run's record on dev: carry its book (the run's tree) into a
|
|
472
|
+
* throwaway origin/dev checkout, commit it as ONE
|
|
473
|
+
* `chore({fid}): {workflow} FAILED bkit [skip ci]` and push it. Ship's Failure
|
|
474
|
+
* Path always lands here; the other workflows land here only from a `dev` /
|
|
475
|
+
* `main` / detached checkout, where a commit in the checkout would publish code.
|
|
476
|
+
* `shared` (the book is such a checkout) → only the run's own record is carried
|
|
477
|
+
* (`carryOwnBook`), and `carried` says what, for the hand-back.
|
|
478
|
+
* Not landed → the record stays in the book, and the next run carries it.
|
|
479
|
+
*/
|
|
480
|
+
async function landFailedRecord(
|
|
481
|
+
ctx: RunContext,
|
|
482
|
+
o: { workflow: string; fid: string; month: string; book: string; shared: boolean },
|
|
483
|
+
): Promise<{
|
|
484
|
+
code: number;
|
|
485
|
+
pushed: boolean;
|
|
486
|
+
ref: string | null;
|
|
487
|
+
skipped: string | null;
|
|
488
|
+
sha?: string;
|
|
489
|
+
carried?: Carried;
|
|
490
|
+
}> {
|
|
491
|
+
const root = repoRoot(ctx.cwd);
|
|
492
|
+
const { book } = o;
|
|
493
|
+
const kept = `${o.workflow} FAILED record kept in ${book} — the next ${o.workflow} of ${o.fid} carries it`;
|
|
494
|
+
const stop = (code: number, why: string) => {
|
|
495
|
+
ctx.log(`${why} — ${kept}`);
|
|
496
|
+
return { code, pushed: false, ref: null, skipped: null };
|
|
497
|
+
};
|
|
498
|
+
// Read leniently: an unreadable row only leaves the run's start unknown.
|
|
499
|
+
const statusAbs = path.join(book, statusRelPath(o.month, o.fid));
|
|
500
|
+
const starts = (fs.existsSync(statusAbs) ? textLines(fs.readFileSync(statusAbs, "utf-8")) : [])
|
|
501
|
+
.map((l) => parseObject(l))
|
|
502
|
+
.filter((e) => e?.type === "workflow-started" && e.workflow === o.workflow)
|
|
503
|
+
.map((e) => Date.parse(String(e?.at)))
|
|
504
|
+
.filter((ms) => Number.isFinite(ms));
|
|
505
|
+
const startMs = starts.length > 0 ? Math.max(...starts) : NaN;
|
|
506
|
+
let carried: Carried | undefined;
|
|
507
|
+
let res: DevPush;
|
|
508
|
+
try {
|
|
509
|
+
res = await pushToDev({
|
|
510
|
+
root,
|
|
511
|
+
dir: landDir(root, o.fid),
|
|
512
|
+
build: (dir) => {
|
|
513
|
+
if (o.shared)
|
|
514
|
+
carried = carryOwnBook(
|
|
515
|
+
book,
|
|
516
|
+
dir,
|
|
517
|
+
{
|
|
518
|
+
month: o.month,
|
|
519
|
+
fid: o.fid,
|
|
520
|
+
workflow: o.workflow,
|
|
521
|
+
startMs: Number.isFinite(startMs) ? startMs : undefined,
|
|
522
|
+
},
|
|
523
|
+
ctx.log,
|
|
524
|
+
);
|
|
525
|
+
else carryBook(book, dir, o.month, o.fid);
|
|
526
|
+
const before = headSha(dir);
|
|
527
|
+
try {
|
|
528
|
+
commitBookkeeping(
|
|
529
|
+
{
|
|
530
|
+
root: dir,
|
|
531
|
+
month: o.month,
|
|
532
|
+
fid: o.fid,
|
|
533
|
+
scope: "full",
|
|
534
|
+
mode: "commit",
|
|
535
|
+
message: `chore(${o.fid}): ${o.workflow} FAILED bkit [skip ci]`,
|
|
536
|
+
},
|
|
537
|
+
ctx.log,
|
|
538
|
+
);
|
|
539
|
+
} catch (err) {
|
|
540
|
+
throw err instanceof CommandError && err.code === EXIT_EMPTY ? NOTHING_TO_LAND : err;
|
|
541
|
+
}
|
|
542
|
+
if (headSha(dir) === before) throw NOTHING_TO_LAND;
|
|
543
|
+
},
|
|
544
|
+
log: ctx.log,
|
|
545
|
+
});
|
|
546
|
+
} catch (err) {
|
|
547
|
+
if (err === NOTHING_TO_LAND) {
|
|
400
548
|
ctx.log("no bookkeeping delta to record — nothing committed, nothing pushed");
|
|
401
549
|
return { code: EXIT.OK, pushed: false, ref: null, skipped: "nothing-to-commit" };
|
|
402
550
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
551
|
+
return stop(EXIT_FLUSH_FAILED, `bookkeeping commit failed: ${(err as Error).message}`);
|
|
552
|
+
}
|
|
553
|
+
switch (res.kind) {
|
|
554
|
+
case "landed":
|
|
555
|
+
return { code: EXIT.OK, pushed: true, ref: DEV, skipped: null, sha: res.sha, carried };
|
|
556
|
+
case "refused":
|
|
557
|
+
return stop(EXIT_PUSH_FAILED, `dev refused the push: ${res.stderr}`);
|
|
558
|
+
case "push-failed":
|
|
559
|
+
return stop(EXIT_PUSH_FAILED, `dev push failed without a server answer: ${res.stderr}`);
|
|
560
|
+
case "exhausted":
|
|
561
|
+
return stop(EXIT_PUSH_FAILED, `dev moved before each of ${res.attempts} pushes`);
|
|
562
|
+
case "fetch-failed":
|
|
563
|
+
return stop(EXIT_FLUSH_FAILED, `fetch of dev failed: ${res.stderr}`);
|
|
564
|
+
case "setup-failed":
|
|
565
|
+
return stop(EXIT_FLUSH_FAILED, `throwaway checkout failed: ${res.stderr}`);
|
|
411
566
|
}
|
|
412
567
|
}
|
|
413
568
|
|
|
@@ -429,19 +584,24 @@ async function handoverVerb(ctx: RunContext): Promise<number> {
|
|
|
429
584
|
let ref = str(ctx.flags.ref) ?? null;
|
|
430
585
|
let pushed = false;
|
|
431
586
|
let skipped: string | null = null;
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
587
|
+
const tree =
|
|
588
|
+
worktree === undefined ? (git(ctx.cwd, ["rev-parse", "--show-toplevel"]) ?? base) : base;
|
|
589
|
+
const branch = git(tree, ["branch", "--show-current"]) ?? "";
|
|
590
|
+
// A dev / main / detached checkout is shared: only the run's own record leaves it.
|
|
591
|
+
const shared = branch === "" || isSharedBranch(branch);
|
|
592
|
+
let handed: { sha: string; carried: Carried } | undefined;
|
|
593
|
+
if (push && shared) {
|
|
594
|
+
const r = await landFailedRecord(ctx, { workflow, fid, month, book: tree, shared });
|
|
595
|
+
if (r.sha !== undefined && r.carried !== undefined) handed = { sha: r.sha, carried: r.carried };
|
|
596
|
+
code = r.code;
|
|
597
|
+
pushed = r.pushed;
|
|
598
|
+
ref = r.ref;
|
|
599
|
+
skipped = r.skipped;
|
|
600
|
+
} else if (push) {
|
|
601
|
+
runGit(tree, ["add", "-A"]);
|
|
602
|
+
const made = runGit(tree, ["commit", "-m", `docs(${fid}): ${workflow} aborted bkit [skip ci]`]);
|
|
443
603
|
if (!made.ok) ctx.log(`abort commit: ${made.stderr || made.stdout}`);
|
|
444
|
-
const r = pushBranch(
|
|
604
|
+
const r = pushBranch(tree, { mode: "abort", openPr: str(ctx.flags.openPr) }, ctx.log);
|
|
445
605
|
if (r.code === EXIT.USE_MCP) return r.code;
|
|
446
606
|
pushed = r.out.pushed;
|
|
447
607
|
ref = r.out.ref;
|
|
@@ -453,12 +613,8 @@ async function handoverVerb(ctx: RunContext): Promise<number> {
|
|
|
453
613
|
? EXIT_OPEN_PR_KEPT
|
|
454
614
|
: EXIT_PUSH_FAILED;
|
|
455
615
|
} else if (flush) {
|
|
456
|
-
const r = await
|
|
457
|
-
|
|
458
|
-
month,
|
|
459
|
-
devPushes: ctx.flags.devPushes === true,
|
|
460
|
-
worktree: worktree === undefined ? undefined : base,
|
|
461
|
-
});
|
|
616
|
+
const r = await landFailedRecord(ctx, { workflow, fid, month, book: tree, shared });
|
|
617
|
+
if (r.sha !== undefined && r.carried !== undefined) handed = { sha: r.sha, carried: r.carried };
|
|
462
618
|
code = r.code;
|
|
463
619
|
pushed = r.pushed;
|
|
464
620
|
ref = r.ref;
|
|
@@ -475,6 +631,7 @@ async function handoverVerb(ctx: RunContext): Promise<number> {
|
|
|
475
631
|
bodyFile: artifact,
|
|
476
632
|
})
|
|
477
633
|
: null;
|
|
634
|
+
if (handed !== undefined) handBack(tree, handed.sha, handed.carried, ctx.log);
|
|
478
635
|
ctx.emit({
|
|
479
636
|
handover: present ? artifact : null,
|
|
480
637
|
pushed,
|
|
@@ -675,7 +832,6 @@ export interface CloseInput {
|
|
|
675
832
|
workflow: string;
|
|
676
833
|
fid: string;
|
|
677
834
|
month?: string;
|
|
678
|
-
devPushes: boolean;
|
|
679
835
|
file?: string;
|
|
680
836
|
prNumber?: number;
|
|
681
837
|
squashSha?: string;
|
|
@@ -709,7 +865,7 @@ export function closeWorkflow(
|
|
|
709
865
|
throw new CommandError(EXIT.USAGE, `--squash-sha "${o.squashSha}" is not a commit sha`);
|
|
710
866
|
|
|
711
867
|
// Graded first, so the report below carries this run's grade.
|
|
712
|
-
const violations = gradeCompliance(where.tree, workflow, log);
|
|
868
|
+
const violations = gradeCompliance(where.tree, workflow, log, o.squashSha);
|
|
713
869
|
|
|
714
870
|
const step = `${workflow}-close-workflow`;
|
|
715
871
|
if (o.recordStep === true) {
|
|
@@ -857,128 +1013,152 @@ export function closeWorkflow(
|
|
|
857
1013
|
}
|
|
858
1014
|
|
|
859
1015
|
/**
|
|
860
|
-
*
|
|
861
|
-
*
|
|
862
|
-
* `docs({fid}): ship DONE bkit [skip ci]`, release the workflow lock, then land the
|
|
863
|
-
* commit — push dev, push `HEAD:dev`, or, when that is refused, a `ship-close/{fid}`
|
|
864
|
-
* PR merged with an empty body.
|
|
1016
|
+
* Publish a close commit dev refused through its own `ship-close/{fid}` PR,
|
|
1017
|
+
* merged with an empty body. Returns where it landed, or why it did not.
|
|
865
1018
|
*/
|
|
866
|
-
|
|
1019
|
+
function closePr(
|
|
1020
|
+
ctx: RunContext,
|
|
1021
|
+
dir: string,
|
|
1022
|
+
fid: string,
|
|
1023
|
+
subject: string,
|
|
1024
|
+
): { ref: string; via: string } | { failed: string } {
|
|
1025
|
+
const branch = `ship-close/${fid}`;
|
|
1026
|
+
const head = headSha(dir);
|
|
1027
|
+
if (!runGit(dir, ["push", "origin", `HEAD:refs/heads/${branch}`]).ok)
|
|
1028
|
+
return { failed: `close branch push failed` };
|
|
1029
|
+
const created = runGh(dir, [
|
|
1030
|
+
"pr",
|
|
1031
|
+
"create",
|
|
1032
|
+
"--base",
|
|
1033
|
+
DEV,
|
|
1034
|
+
"--head",
|
|
1035
|
+
branch,
|
|
1036
|
+
"--title",
|
|
1037
|
+
`docs(${fid}): ship DONE`,
|
|
1038
|
+
"--body",
|
|
1039
|
+
"",
|
|
1040
|
+
]);
|
|
1041
|
+
if (!created.ok) return { failed: `gh pr create failed: ${created.stderr}` };
|
|
1042
|
+
const pr = probePr(dir, { head: branch, base: DEV, state: "open" });
|
|
1043
|
+
const number = pr.kind === "ok" ? pr.pr?.number : undefined;
|
|
1044
|
+
if (number === undefined) return { failed: `close PR not found for ${branch}` };
|
|
1045
|
+
const merged = mergePr(
|
|
1046
|
+
dir,
|
|
1047
|
+
{ number: String(number), subject, matchHead: head, deleteBranch: true },
|
|
1048
|
+
ctx.log,
|
|
1049
|
+
);
|
|
1050
|
+
if (!merged.out.merged) ctx.log(`close PR #${number} opened but not merged — merge it by hand`);
|
|
1051
|
+
return { ref: branch, via: merged.out.merged ? "close-pr" : "close-pr-open" };
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
/**
|
|
1055
|
+
* Ship's close, in the run's tree (the feature worktree, or the adopted
|
|
1056
|
+
* checkout): the close rows there, then ONE `docs({fid}): ship DONE bkit [skip ci]`
|
|
1057
|
+
* commit built in a throwaway origin/dev checkout carrying the run's book and
|
|
1058
|
+
* landed on dev — a refused push publishes it through a `ship-close/{fid}` PR.
|
|
1059
|
+
* Only a close that landed (or opened its PR) releases the workflow lock; once
|
|
1060
|
+
* the close is on dev, the feature worktree and `branch` are removed. A close
|
|
1061
|
+
* that did not land keeps the lock for the Failure Path.
|
|
1062
|
+
*/
|
|
1063
|
+
async function shipClose(
|
|
1064
|
+
ctx: RunContext,
|
|
1065
|
+
o: CloseInput & { branch?: string },
|
|
1066
|
+
token: string | undefined,
|
|
1067
|
+
) {
|
|
867
1068
|
const root = repoRoot(ctx.cwd);
|
|
868
|
-
|
|
869
|
-
if (outbox === undefined) throw new CommandError(EXIT.USAGE, "--flush needs --outbox");
|
|
1069
|
+
if (o.outbox === undefined) throw new CommandError(EXIT.USAGE, "--flush needs --outbox");
|
|
870
1070
|
const month = resolveMonth(root, o.fid, o.month);
|
|
871
|
-
const
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
const fail = (why: string) => {
|
|
879
|
-
ctx.log(why);
|
|
880
|
-
return { code: EXIT_FLUSH_FAILED, out: null as Record<string, unknown> | null };
|
|
881
|
-
};
|
|
882
|
-
let closeRoot = "";
|
|
883
|
-
let landed: { ref: string; via: string } | null = null;
|
|
884
|
-
let out: Record<string, unknown> = {};
|
|
1071
|
+
const book = git(ctx.cwd, ["rev-parse", "--show-toplevel"]) ?? root;
|
|
1072
|
+
const subject = `docs(${o.fid}): ship DONE bkit [skip ci]`;
|
|
1073
|
+
const kept = `close bookkeeping kept in ${book}`;
|
|
1074
|
+
const out = closeWorkflow(book, { ...o, recordStep: true, message: undefined }, ctx.log);
|
|
1075
|
+
|
|
1076
|
+
let viaPr: { ref: string; via: string } | { failed: string } | null = null;
|
|
1077
|
+
let res: DevPush;
|
|
885
1078
|
try {
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
if (!runGit(wt, ["fetch", "origin", DEV]).ok)
|
|
903
|
-
return fail(`fetch origin dev failed — close bookkeeping left uncommitted in ${wt}`);
|
|
904
|
-
closeRoot = path.join(outbox, "close");
|
|
905
|
-
if (fs.existsSync(closeRoot)) runGit(wt, ["worktree", "remove", "--force", closeRoot]);
|
|
906
|
-
runGit(wt, ["worktree", "prune"]);
|
|
907
|
-
if (!runGit(wt, ["worktree", "add", "--detach", closeRoot, "origin/dev"]).ok)
|
|
908
|
-
return fail(`close worktree add failed — close bookkeeping left uncommitted in ${wt}`);
|
|
909
|
-
unionLedgers(wt, closeRoot);
|
|
910
|
-
}
|
|
911
|
-
commitBookkeeping(
|
|
912
|
-
{
|
|
913
|
-
root: closeRoot,
|
|
914
|
-
month,
|
|
915
|
-
fid: o.fid,
|
|
916
|
-
scope: "full",
|
|
917
|
-
mode: "commit-allow-empty",
|
|
918
|
-
message: `docs(${o.fid}): ship DONE bkit [skip ci]`,
|
|
1079
|
+
res = await pushToDev({
|
|
1080
|
+
root,
|
|
1081
|
+
dir: landDir(root, o.fid),
|
|
1082
|
+
build: (dir) => {
|
|
1083
|
+
carryBook(book, dir, month, o.fid);
|
|
1084
|
+
commitBookkeeping(
|
|
1085
|
+
{
|
|
1086
|
+
root: dir,
|
|
1087
|
+
month,
|
|
1088
|
+
fid: o.fid,
|
|
1089
|
+
scope: "full",
|
|
1090
|
+
mode: "commit-allow-empty",
|
|
1091
|
+
message: subject,
|
|
1092
|
+
},
|
|
1093
|
+
ctx.log,
|
|
1094
|
+
);
|
|
919
1095
|
},
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
);
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1096
|
+
refused: async (dir, stderr) => {
|
|
1097
|
+
ctx.log(`dev refused the close push — publishing it through a PR: ${stderr}`);
|
|
1098
|
+
viaPr = closePr(ctx, dir, o.fid, subject);
|
|
1099
|
+
},
|
|
1100
|
+
log: ctx.log,
|
|
1101
|
+
});
|
|
1102
|
+
} catch (err) {
|
|
1103
|
+
ctx.log(`close commit failed: ${(err as Error).message} — ${kept}`);
|
|
1104
|
+
return { code: EXIT_FLUSH_FAILED, out: null };
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
// A close that did not land keeps the lock: the Failure Path releases it.
|
|
1108
|
+
let landed: { ref: string; via: string } | null = null;
|
|
1109
|
+
switch (res.kind) {
|
|
1110
|
+
case "landed":
|
|
1111
|
+
landed = { ref: DEV, via: "head-push" };
|
|
1112
|
+
break;
|
|
1113
|
+
case "refused": {
|
|
1114
|
+
const pr = viaPr as { ref: string; via: string } | { failed: string } | null;
|
|
1115
|
+
if (pr === null || "failed" in pr) {
|
|
1116
|
+
ctx.log(`${pr === null ? "close PR not attempted" : pr.failed} — ${kept}`);
|
|
1117
|
+
return { code: EXIT_FLUSH_FAILED, out: null };
|
|
931
1118
|
}
|
|
932
|
-
landed =
|
|
1119
|
+
landed = pr;
|
|
1120
|
+
break;
|
|
933
1121
|
}
|
|
934
|
-
|
|
935
|
-
|
|
1122
|
+
case "push-failed":
|
|
1123
|
+
ctx.log(`dev push failed without a server answer: ${res.stderr} — ${kept}`);
|
|
1124
|
+
return { code: EXIT_PUSH_FAILED, out };
|
|
1125
|
+
case "exhausted":
|
|
1126
|
+
ctx.log(`dev moved before each of ${res.attempts} pushes — ${kept}`);
|
|
1127
|
+
return { code: EXIT_PUSH_FAILED, out };
|
|
1128
|
+
case "fetch-failed":
|
|
1129
|
+
ctx.log(`fetch of dev failed: ${res.stderr} — ${kept}`);
|
|
1130
|
+
return { code: EXIT_FLUSH_FAILED, out: null };
|
|
1131
|
+
case "setup-failed":
|
|
1132
|
+
ctx.log(`throwaway checkout failed: ${res.stderr} — ${kept}`);
|
|
1133
|
+
return { code: EXIT_FLUSH_FAILED, out: null };
|
|
936
1134
|
}
|
|
937
1135
|
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
`
|
|
956
|
-
"--body",
|
|
957
|
-
"",
|
|
958
|
-
]);
|
|
959
|
-
if (!created.ok) return fail(`gh pr create failed: ${created.stderr}`);
|
|
960
|
-
const pr = probePr(closeRoot, { head: branch, base: DEV, state: "open" });
|
|
961
|
-
const number = pr.kind === "ok" ? pr.pr?.number : undefined;
|
|
962
|
-
if (number === undefined) return fail(`close PR not found for ${branch}`);
|
|
963
|
-
const merged = mergePr(
|
|
964
|
-
closeRoot,
|
|
965
|
-
{
|
|
966
|
-
number: String(number),
|
|
967
|
-
subject: `docs(${o.fid}): ship DONE bkit [skip ci]`,
|
|
968
|
-
matchHead: head,
|
|
969
|
-
deleteBranch: true,
|
|
970
|
-
},
|
|
971
|
-
ctx.log,
|
|
1136
|
+
const released = releaseLock(workflowLockPath(root, month, o.fid), {
|
|
1137
|
+
workflow: "ship",
|
|
1138
|
+
fid: o.fid,
|
|
1139
|
+
token,
|
|
1140
|
+
});
|
|
1141
|
+
if (released.removeFailed) {
|
|
1142
|
+
ctx.log("Lock removal failed");
|
|
1143
|
+
return { code: EXIT_FLUSH_FAILED, out: null };
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
// The book is on dev only once the close landed or its PR merged.
|
|
1147
|
+
let worktree: RemoveResult | null = null;
|
|
1148
|
+
if (landed.via === "close-pr-open") {
|
|
1149
|
+
ctx.log(`close PR not merged — ${kept} until it is`);
|
|
1150
|
+
} else {
|
|
1151
|
+
if (landed.via === "close-pr" && !runGit(root, ["fetch", "origin", DEV]).ok)
|
|
1152
|
+
ctx.log(
|
|
1153
|
+
`fetch of dev after the close PR failed — origin/${DEV} is stale until the next fetch`,
|
|
972
1154
|
);
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
1155
|
+
try {
|
|
1156
|
+
worktree = removeWorktree(root, o.fid, o.branch, ctx.log);
|
|
1157
|
+
} catch (err) {
|
|
1158
|
+
ctx.log(`${(err as Error).message} — remove ${book} by hand`);
|
|
976
1159
|
}
|
|
977
|
-
const top = git(ctx.cwd, ["rev-parse", "--show-toplevel"]) ?? root;
|
|
978
|
-
runGit(top, ["worktree", "remove", "--force", closeRoot]);
|
|
979
|
-
runGit(top, ["worktree", "prune"]);
|
|
980
1160
|
}
|
|
981
|
-
return { code: EXIT.OK, out: { ...out,
|
|
1161
|
+
return { code: EXIT.OK, out: { ...out, landed, worktree } };
|
|
982
1162
|
}
|
|
983
1163
|
|
|
984
1164
|
// ---------------------------------------------------------------------------
|
|
@@ -1124,11 +1304,6 @@ const MONTH_FLAG: FlagSpec = {
|
|
|
1124
1304
|
type: "string",
|
|
1125
1305
|
help: "month bucket YYYYMM (default: the feature's bucket, else this UTC month)",
|
|
1126
1306
|
};
|
|
1127
|
-
const DEV_PUSHES_FLAG: FlagSpec = {
|
|
1128
|
-
name: "dev-pushes",
|
|
1129
|
-
type: "boolean",
|
|
1130
|
-
help: "ship only: this runtime pushes to dev (logs book in the main checkout)",
|
|
1131
|
-
};
|
|
1132
1307
|
const STATUS_FILE_FLAG: FlagSpec = {
|
|
1133
1308
|
name: "file",
|
|
1134
1309
|
type: "string",
|
|
@@ -1159,7 +1334,6 @@ export const workflowsCommand: CommandSpec = {
|
|
|
1159
1334
|
WORKFLOW_FLAG,
|
|
1160
1335
|
FID_FLAG,
|
|
1161
1336
|
MONTH_FLAG,
|
|
1162
|
-
DEV_PUSHES_FLAG,
|
|
1163
1337
|
STATUS_FILE_FLAG,
|
|
1164
1338
|
{
|
|
1165
1339
|
name: "lock-held",
|
|
@@ -1183,7 +1357,6 @@ export const workflowsCommand: CommandSpec = {
|
|
|
1183
1357
|
run: (ctx) => {
|
|
1184
1358
|
const workflow = workflowName(String(ctx.flags.workflow));
|
|
1185
1359
|
const fid = String(ctx.flags.fid);
|
|
1186
|
-
const devPushes = ctx.flags.devPushes === true;
|
|
1187
1360
|
const token = str(ctx.flags.token);
|
|
1188
1361
|
if (token !== undefined && ctx.flags.lockHeld !== true)
|
|
1189
1362
|
throw new CommandError(EXIT.USAGE, "--token applies with --lock-held only");
|
|
@@ -1191,13 +1364,12 @@ export const workflowsCommand: CommandSpec = {
|
|
|
1191
1364
|
workflow,
|
|
1192
1365
|
fid,
|
|
1193
1366
|
month: str(ctx.flags.month),
|
|
1194
|
-
devPushes,
|
|
1195
1367
|
file: str(ctx.flags.file),
|
|
1196
1368
|
});
|
|
1197
1369
|
|
|
1198
1370
|
let lock: Record<string, unknown>;
|
|
1199
1371
|
if (ctx.flags.lockHeld === true) {
|
|
1200
|
-
const file = workflowLockPath(
|
|
1372
|
+
const file = workflowLockPath(where.root, where.month, fid);
|
|
1201
1373
|
checkHeldLock(file, { workflow, fid, token });
|
|
1202
1374
|
lock = { path: file };
|
|
1203
1375
|
} else {
|
|
@@ -1207,7 +1379,6 @@ export const workflowsCommand: CommandSpec = {
|
|
|
1207
1379
|
workflow,
|
|
1208
1380
|
fid,
|
|
1209
1381
|
month: where.month,
|
|
1210
|
-
devPushes,
|
|
1211
1382
|
log: ctx.log,
|
|
1212
1383
|
}),
|
|
1213
1384
|
};
|
|
@@ -1246,7 +1417,6 @@ export const workflowsCommand: CommandSpec = {
|
|
|
1246
1417
|
WORKFLOW_FLAG,
|
|
1247
1418
|
{ ...FID_FLAG, required: false, help: "feature id (needed with --token)" },
|
|
1248
1419
|
MONTH_FLAG,
|
|
1249
|
-
DEV_PUSHES_FLAG,
|
|
1250
1420
|
STATUS_FILE_FLAG,
|
|
1251
1421
|
{
|
|
1252
1422
|
...TOKEN_FLAG,
|
|
@@ -1294,9 +1464,10 @@ export const workflowsCommand: CommandSpec = {
|
|
|
1294
1464
|
sentinels: "[{name, path}] sentinels that existed before this call removed them",
|
|
1295
1465
|
handoverNeeded:
|
|
1296
1466
|
"--max-exceeded, a sentinel existed, or a debug run in SOAK mode: write the abort handover",
|
|
1467
|
+
add: "labels in the set that the issue does not carry yet",
|
|
1297
1468
|
labels:
|
|
1298
1469
|
"the label set to write: the current labels plus bkit:failed (and bkit:merged for a merged ship PR)",
|
|
1299
|
-
|
|
1470
|
+
trackerState: "the Linear or Jira state for the failed issue (null under github, none)",
|
|
1300
1471
|
prState: "the --pr PR's state, or null",
|
|
1301
1472
|
comment: "the failure comment body (with --step-number), else null",
|
|
1302
1473
|
},
|
|
@@ -1309,7 +1480,7 @@ export const workflowsCommand: CommandSpec = {
|
|
|
1309
1480
|
},
|
|
1310
1481
|
handover: {
|
|
1311
1482
|
summary:
|
|
1312
|
-
"
|
|
1483
|
+
"Keep a failed run's record: commit and push it on the feature branch, or land its logs and ledgers on dev (--push from dev / main, ship's --flush); print the handover comment.",
|
|
1313
1484
|
flags: [
|
|
1314
1485
|
WORKFLOW_FLAG,
|
|
1315
1486
|
FID_FLAG,
|
|
@@ -1317,12 +1488,12 @@ export const workflowsCommand: CommandSpec = {
|
|
|
1317
1488
|
{
|
|
1318
1489
|
name: "push",
|
|
1319
1490
|
type: "boolean",
|
|
1320
|
-
help: "git add -A, commit `docs({fid}): {workflow} aborted bkit [skip ci]`, push --mode=abort",
|
|
1491
|
+
help: "feature branch: git add -A, commit `docs({fid}): {workflow} aborted bkit [skip ci]`, push --mode=abort; dev / main / detached: lands like --flush, the checkout untouched",
|
|
1321
1492
|
},
|
|
1322
1493
|
{
|
|
1323
1494
|
name: "flush",
|
|
1324
1495
|
type: "boolean",
|
|
1325
|
-
help: "ship:
|
|
1496
|
+
help: "ship: carry the run's logs and ledgers into a throwaway origin/dev checkout, ONE `chore({fid}): {workflow} FAILED bkit [skip ci]` commit, landed on dev",
|
|
1326
1497
|
},
|
|
1327
1498
|
{
|
|
1328
1499
|
name: "open-pr",
|
|
@@ -1330,11 +1501,10 @@ export const workflowsCommand: CommandSpec = {
|
|
|
1330
1501
|
help: "--push: the open-PR answer from MCP (a number, or none) instead of asking gh",
|
|
1331
1502
|
},
|
|
1332
1503
|
{ name: "ref", type: "string", help: "link the handover at this ref (no push / flush)" },
|
|
1333
|
-
DEV_PUSHES_FLAG,
|
|
1334
1504
|
{
|
|
1335
1505
|
name: "worktree",
|
|
1336
1506
|
type: "string",
|
|
1337
|
-
help: "
|
|
1507
|
+
help: "the run's tree: holds the handover and the logs, and is where --push commits (default: cwd's checkout)",
|
|
1338
1508
|
},
|
|
1339
1509
|
OWNER_REPO_FLAG,
|
|
1340
1510
|
],
|
|
@@ -1342,20 +1512,18 @@ export const workflowsCommand: CommandSpec = {
|
|
|
1342
1512
|
handover: "the handover artifact, or null when absent",
|
|
1343
1513
|
pushed: "the push (or flush push) ran and succeeded",
|
|
1344
1514
|
ref: "where the handover now lives, or null when nothing was pushed",
|
|
1345
|
-
skipped:
|
|
1346
|
-
"why nothing was pushed: open-pr | skip-ci | dev-lock-busy | nothing-to-commit (null otherwise)",
|
|
1515
|
+
skipped: "why nothing was pushed: open-pr | skip-ci | nothing-to-commit (null otherwise)",
|
|
1347
1516
|
comment:
|
|
1348
1517
|
"the handover comment body (null when there is no handover); links only when pushed",
|
|
1349
1518
|
},
|
|
1350
1519
|
exitCodes: {
|
|
1351
1520
|
[EXIT_SPLIT_BUCKET]: "no --month and the feature has logs in more than one month bucket",
|
|
1352
|
-
[EXIT_HANDOVER_MISSING]:
|
|
1353
|
-
"--push: the handover artifact is missing or empty (nothing committed)",
|
|
1354
1521
|
[EXIT_OPEN_PR_KEPT]:
|
|
1355
1522
|
"--push: the branch has an open PR, nothing pushed (the comment has no link)",
|
|
1356
|
-
[EXIT_PUSH_FAILED]:
|
|
1523
|
+
[EXIT_PUSH_FAILED]:
|
|
1524
|
+
"the push failed, or dev refused / kept moving under the FAILED landing (the comment has no link)",
|
|
1357
1525
|
[EXIT_FLUSH_FAILED]:
|
|
1358
|
-
"
|
|
1526
|
+
"the dev fetch, the throwaway checkout or the FAILED commit failed; the record stays in the run's tree",
|
|
1359
1527
|
},
|
|
1360
1528
|
run: handoverVerb,
|
|
1361
1529
|
},
|
|
@@ -1366,7 +1534,6 @@ export const workflowsCommand: CommandSpec = {
|
|
|
1366
1534
|
WORKFLOW_FLAG,
|
|
1367
1535
|
FID_FLAG,
|
|
1368
1536
|
MONTH_FLAG,
|
|
1369
|
-
DEV_PUSHES_FLAG,
|
|
1370
1537
|
STATUS_FILE_FLAG,
|
|
1371
1538
|
{
|
|
1372
1539
|
name: "pr-number",
|
|
@@ -1415,9 +1582,14 @@ export const workflowsCommand: CommandSpec = {
|
|
|
1415
1582
|
{
|
|
1416
1583
|
name: "flush",
|
|
1417
1584
|
type: "boolean",
|
|
1418
|
-
help: "ship:
|
|
1585
|
+
help: "ship: commit `ship DONE` in a throwaway origin/dev checkout carrying the run's book, land it on dev (refused: a ship-close PR), release the lock (--token), remove the worktree",
|
|
1419
1586
|
},
|
|
1420
1587
|
{ ...TOKEN_FLAG, help: "--flush: the workflow lock token to release" },
|
|
1588
|
+
{
|
|
1589
|
+
name: "branch",
|
|
1590
|
+
type: "string",
|
|
1591
|
+
help: "--flush: the shipped branch, deleted locally and on origin with the worktree once the close is on dev",
|
|
1592
|
+
},
|
|
1421
1593
|
],
|
|
1422
1594
|
output: {
|
|
1423
1595
|
row: "the appended workflow-done row",
|
|
@@ -1437,15 +1609,17 @@ export const workflowsCommand: CommandSpec = {
|
|
|
1437
1609
|
roadmapFoldNeeded:
|
|
1438
1610
|
"always true: append the feature row and re-render the board (not run here)",
|
|
1439
1611
|
featureStatus: "roadmap status this close moves the feature to",
|
|
1440
|
-
|
|
1441
|
-
|
|
1612
|
+
landed: "--flush: {ref, via: head-push | close-pr | close-pr-open}",
|
|
1613
|
+
worktree:
|
|
1614
|
+
"--flush: the `bkit worktrees remove` result once the close is on dev; null while the close PR is unmerged or the removal failed",
|
|
1442
1615
|
},
|
|
1443
1616
|
exitCodes: {
|
|
1444
1617
|
[EXIT_NO_STATUS]: "status.jsonl missing, unreadable, or not valid NDJSON (nothing written)",
|
|
1445
1618
|
[EXIT_SPLIT_BUCKET]: "no --month and the feature has logs in more than one month bucket",
|
|
1446
|
-
[EXIT_PUSH_FAILED]:
|
|
1619
|
+
[EXIT_PUSH_FAILED]:
|
|
1620
|
+
"--flush: dev moved before every push, or the push failed without a server answer; the lock is kept",
|
|
1447
1621
|
[EXIT_FLUSH_FAILED]:
|
|
1448
|
-
"--flush:
|
|
1622
|
+
"--flush: the dev fetch, the throwaway checkout or the close commit failed, the close PR could not be opened (the lock is kept), or the lock could not be removed",
|
|
1449
1623
|
},
|
|
1450
1624
|
run: async (ctx) => {
|
|
1451
1625
|
const f = ctx.flags;
|
|
@@ -1453,7 +1627,6 @@ export const workflowsCommand: CommandSpec = {
|
|
|
1453
1627
|
workflow: String(f.workflow),
|
|
1454
1628
|
fid: String(f.fid),
|
|
1455
1629
|
month: str(f.month),
|
|
1456
|
-
devPushes: f.devPushes === true,
|
|
1457
1630
|
file: str(f.file),
|
|
1458
1631
|
prNumber: positiveInt(f.prNumber, "pr-number"),
|
|
1459
1632
|
squashSha: str(f.squashSha),
|
|
@@ -1470,7 +1643,7 @@ export const workflowsCommand: CommandSpec = {
|
|
|
1470
1643
|
};
|
|
1471
1644
|
if (f.flush === true) {
|
|
1472
1645
|
if (input.workflow !== "ship") throw new CommandError(EXIT.USAGE, "--flush is ship only");
|
|
1473
|
-
const r = await shipClose(ctx, input, str(f.token));
|
|
1646
|
+
const r = await shipClose(ctx, { ...input, branch: str(f.branch) }, str(f.token));
|
|
1474
1647
|
if (r.out) ctx.emit(r.out);
|
|
1475
1648
|
return r.code;
|
|
1476
1649
|
}
|