@goodtek/vibeops 3.1.4 → 3.1.6
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/CHANGELOG.md +18 -0
- package/README.md +3 -1
- package/dist/commands/task-add.js +10 -1
- package/dist/commands/task-merge.js +6 -0
- package/dist/commands/task-release.js +34 -11
- package/dist/commands/task-ship.js +10 -8
- package/dist/lib/merge-base-freshness.js +55 -0
- package/dist/lib/pr-create.js +15 -0
- package/dist/lib/task-git-commit.js +9 -4
- package/dist/lib/task.js +43 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,24 @@ All notable changes to VibeOps are documented here.
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
## 3.1.6 - 2026-10-17
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **`task release` failed when the release PR was already open.** It now reuses the open integration → production PR; a failing lookup refuses. The dry-run now says the merge waits for the PR's own CI runs (it already did since 3.1.2) and shows `requiredChecks` as an extra by-name list (TASK-030).
|
|
12
|
+
- **An unreadable Git Context was skipped quietly.** `task ship` printed "push/MR skipped" and exited 0; it now exits 1 before committing or pushing and names the problem (e.g. ``line 160 is `## ## Git Context` ``). `task add` no longer "resumes" an In Progress TASK whose Git Context is damaged — that wrote a second section and blocked new TASKs in every worktree (TASK-030).
|
|
13
|
+
|
|
14
|
+
## 3.1.5 - 2026-10-16
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **`task merge` merged stale branches.** It now refuses unless the head commit the gate approved contains the current `<remote>/<base>` (`git merge-base --is-ancestor` after fetching both); the error says how many commits behind and how to update. Observed in a consumer repo: a branch rebuilt with `git reset --soft` on a stale `origin/develop` was squash-merged after `develop` had moved and silently reverted other TASKs' work. Fetch errors refuse. `task release` is unchanged (D-008, TASK-029).
|
|
19
|
+
- **`task ship -m` joined multi-line messages** into one line, so a `Co-Authored-By:` trailer ended up in the subject. Only the subject is TASK-scoped now; the body and trailers are kept (TASK-029).
|
|
20
|
+
|
|
21
|
+
### Security
|
|
22
|
+
|
|
23
|
+
- `js-yaml` 3.14.2 → 3.15.2 (via `gray-matter`; GHSA-52cp-r559-cp3m, GHSA-5p4m-2wfm-xmqj, GHSA-2883-xcg3-v3hh, GHSA-h67p-54hq-rp68). Dev: `tsx` ^4.23.15 → `esbuild` 0.28.2 (GHSA-g7r4-m6w7-qqqr). `sprintf-js` (GHSA-hp3w-g68c-fv3c) has no fixed release; it is only used by `js-yaml`'s command-line tool, which vibeops does not run (TASK-027).
|
|
24
|
+
|
|
7
25
|
## 3.1.4 - 2026-10-16
|
|
8
26
|
|
|
9
27
|
### Changed
|
package/README.md
CHANGED
|
@@ -158,7 +158,7 @@ vibeops llm use auto # auto | codex-oauth | cursor-agent | openai
|
|
|
158
158
|
- **`task merge`**: merge MR/PR into integration (TASK md unchanged) — **only when every check is green** (see [Merge gate](#merge-gate)).
|
|
159
159
|
- **`task sync`**: verify merge → leave the task branch (switch to integration, or detach at `<remote>/<integration>` when another worktree owns it) → fast-forward local integration where safe → delete local + remote `task/*` branch (TASK md unchanged).
|
|
160
160
|
- **`pull`**: fetch + switch to integration branch + `git pull --ff-only` (one command). Refuses (exit 1) when another worktree has the integration branch checked out — run it there.
|
|
161
|
-
- **`task release`**: integration → production PR + merge (skipped on trunk policy).
|
|
161
|
+
- **`task release`**: integration → production PR + merge (skipped on trunk policy). Reuses the open release PR when there is one; the merge waits for that PR's own CI like `task merge`.
|
|
162
162
|
- **`status`**: Now / Next card — focus stage, checklist, PR, and the next command to run.
|
|
163
163
|
- No force-push to shared branches.
|
|
164
164
|
|
|
@@ -223,6 +223,8 @@ Before calling `gh pr merge` / `glab mr merge`:
|
|
|
223
223
|
- **No checks at all → refuse** unless `allowNoChecks: true`. "No checks" means: empty rollup, no GitHub Actions run and no expected workflow for the head commit (GitLab: no pipeline). For CI outside GitHub Actions (commit statuses / check apps), the empty list is re-polled for `emptyRollupGraceSeconds` first; list such checks in `requiredChecks` so the gate waits for them by name.
|
|
224
224
|
- **Waiting** polls the host (`gh pr view` + the Actions REST API) every `pollIntervalSeconds` (default 10 s, the default of `gh pr checks --watch`) until the state changes, bounded by `waitTimeoutSeconds` (default 900 s). Host read errors back off exponentially with jitter (capped at 60 s, GitHub's guidance for rate-limited clients).
|
|
225
225
|
- **The merge is pinned to the checked commit:** right before merging the gate re-reads the PR head; if it moved, the new head is evaluated from scratch. The merge itself uses `gh pr merge --match-head-commit <sha>` (requires **gh ≥ 2.13.0**) / `glab mr merge --auto-merge=false --sha <sha>` (verified with glab 1.106), so a push between the last check and the merge makes the host refuse. A GitLab `405` re-runs the gate and retries once with the same flags.
|
|
226
|
+
- **Unreadable Git Context stops `task ship` / `task add`:** a TASK file whose `## Git Context` cannot be read (e.g. an edit left `## ## Git Context`) makes `task ship` exit 1 before committing or pushing, naming the line; `task add` refuses to "resume" such a TASK (it would write a second section) and names the file and line.
|
|
227
|
+
- **`task merge` refuses a stale base:** the head commit the gate approved must contain the current `<remote>/<base>` (`git merge-base --is-ancestor`, after fetching the base branch and the head commit). A head that does not — the base moved since the branch was pushed, or the branch was rebuilt on an old base (e.g. `git reset --soft <stale origin/develop>` + commit) — can silently revert work merged into the base since, and a squash merge lands that revert. Bring the branch up to date (`git fetch` + `git merge <remote>/<base>`, test, `task ship`), wait for CI, then rerun `task merge`. A fetch failure refuses (fail closed). `task release` does not apply this check (with merge-commit releases the production branch is normally not an ancestor of the integration branch).
|
|
226
228
|
|
|
227
229
|
### Configuration (`.vibeops.json` → `merge`)
|
|
228
230
|
|
|
@@ -12,7 +12,7 @@ import { findBlockingTask, relPath } from "../lib/task-context.js";
|
|
|
12
12
|
import { allocateTaskId, TaskIdAllocationError } from "../lib/task-id-allocation.js";
|
|
13
13
|
import { readTaskLockConfig, TaskLockConfigError, TaskLockHeldError, withTaskLock, } from "../lib/task-lock.js";
|
|
14
14
|
import { isIncompleteTaskStart, startTaskBranch } from "../lib/task-start.js";
|
|
15
|
-
import { branchNameForTaskFile, loadActionableTasks, readGitContext } from "../lib/task.js";
|
|
15
|
+
import { branchNameForTaskFile, damagedGitContext, loadActionableTasks, readGitContext, } from "../lib/task.js";
|
|
16
16
|
async function loadGitConfigOrNull(root, dryRun) {
|
|
17
17
|
try {
|
|
18
18
|
return await requireGitConfig(root);
|
|
@@ -98,6 +98,15 @@ export async function taskAddCommand(opts = {}) {
|
|
|
98
98
|
const blocking = await findBlockingTask(paths, root);
|
|
99
99
|
// Resume: In Progress file exists but task branch / Git Context was never finished.
|
|
100
100
|
if (blocking !== null && gitCfg !== null) {
|
|
101
|
+
// A damaged Git Context is not an unfinished add: resuming would write a second section.
|
|
102
|
+
const damaged = await damagedGitContext(blocking.filePath);
|
|
103
|
+
if (damaged !== null) {
|
|
104
|
+
log.error(`${bold(blocking.id)} is In Progress but its Git Context cannot be read: ${damaged}.`);
|
|
105
|
+
log.info(` ${dim("file")} ${relPath(root, blocking.filePath)}`);
|
|
106
|
+
log.info(dim("No TASK was created. Fix the TASK file (then ship it), and rerun task add."));
|
|
107
|
+
process.exitCode = 1;
|
|
108
|
+
return "done";
|
|
109
|
+
}
|
|
101
110
|
const incomplete = await isIncompleteTaskStart(root, blocking.filePath);
|
|
102
111
|
if (incomplete) {
|
|
103
112
|
log.warn(`${yellow("Incomplete")} — ${bold(blocking.id)} exists but the task branch was not created.`);
|
|
@@ -22,6 +22,9 @@ function resolveMergeMethod(opts) {
|
|
|
22
22
|
}
|
|
23
23
|
function mergeFailureHint(error) {
|
|
24
24
|
if (error instanceof MergeGateError) {
|
|
25
|
+
if (error.problems.some((p) => p.startsWith("stale base:"))) {
|
|
26
|
+
return "Not merged. Bring the task branch up to date with its base (see above), push, wait for CI, then rerun `vibeops task merge`.";
|
|
27
|
+
}
|
|
25
28
|
return "Not merged. Fix the failing checks (re-run `vibeops task ship` to push a fix and re-run CI), then rerun `vibeops task merge`.";
|
|
26
29
|
}
|
|
27
30
|
return "Merge in the host UI if branch protection blocks CLI merge.";
|
|
@@ -105,6 +108,7 @@ export async function taskMergeCommand(taskRef, options = {}) {
|
|
|
105
108
|
method,
|
|
106
109
|
requiredChecks,
|
|
107
110
|
gate,
|
|
111
|
+
requireBaseInHead: { remote: gitCfg.remote, baseBranch: ctx.baseBranch },
|
|
108
112
|
dryRun: true,
|
|
109
113
|
});
|
|
110
114
|
log.blank();
|
|
@@ -138,6 +142,7 @@ export async function taskMergeCommand(taskRef, options = {}) {
|
|
|
138
142
|
waitForCi: true,
|
|
139
143
|
requiredChecks,
|
|
140
144
|
gate,
|
|
145
|
+
requireBaseInHead: { remote: gitCfg.remote, baseBranch: ctx.baseBranch },
|
|
141
146
|
});
|
|
142
147
|
const verified = await assertMergeRequestMerged({
|
|
143
148
|
cwd,
|
|
@@ -176,6 +181,7 @@ export async function taskMergeCommand(taskRef, options = {}) {
|
|
|
176
181
|
waitForCi: true,
|
|
177
182
|
requiredChecks,
|
|
178
183
|
gate,
|
|
184
|
+
requireBaseInHead: { remote: gitCfg.remote, baseBranch: ctx.baseBranch },
|
|
179
185
|
});
|
|
180
186
|
const verified = await assertMergeRequestMerged({
|
|
181
187
|
cwd,
|
|
@@ -5,7 +5,7 @@ import { formatHostCliHint, formatHostCliMissingMessage } from "../lib/git-host-
|
|
|
5
5
|
import { detectGitHost, mergeRequestLabel } from "../lib/git-host.js";
|
|
6
6
|
import { gitRemoteUrl } from "../lib/git.js";
|
|
7
7
|
import { bold, dim, log } from "../lib/logger.js";
|
|
8
|
-
import { createMergeRequest, getMergeRequestState, MergeGateError, mergeMergeRequest, probeMergeRequestCli, } from "../lib/pr-create.js";
|
|
8
|
+
import { createMergeRequest, findMergeRequestByBranches, getMergeRequestState, MergeGateError, mergeMergeRequest, probeMergeRequestCli, } from "../lib/pr-create.js";
|
|
9
9
|
import { assertMergeRequestMerged } from "../lib/task-merge-verify.js";
|
|
10
10
|
function resolveReleaseMergeMethod(opts) {
|
|
11
11
|
if (opts.rebase === true)
|
|
@@ -65,9 +65,10 @@ export async function taskReleaseCommand(options = {}) {
|
|
|
65
65
|
if (dryRun) {
|
|
66
66
|
log.info(bold("dry-run — would:"));
|
|
67
67
|
log.info(` · ${label}: ${integrationBranch} → ${productionBranch}`);
|
|
68
|
+
log.info(` · reuse the open ${label} ${integrationBranch} → ${productionBranch} if there is one`);
|
|
68
69
|
if (options.noMerge !== true) {
|
|
69
|
-
log.info(` · merge ${label} (${resolveReleaseMergeMethod(options)}) only when
|
|
70
|
-
log.info(` · required checks: ${requiredChecks.length > 0 ? requiredChecks.join(", ") : "
|
|
70
|
+
log.info(` · merge ${label} (${resolveReleaseMergeMethod(options)}) only when every check on its head commit is green — waits for the ${label}'s own CI runs`);
|
|
71
|
+
log.info(` · required checks (by name, in addition): ${requiredChecks.length > 0 ? requiredChecks.join(", ") : "none configured"}`);
|
|
71
72
|
if (mergeCfg.allowNoChecks) {
|
|
72
73
|
log.info(" · allowNoChecks: true (a release PR with no checks would merge)");
|
|
73
74
|
}
|
|
@@ -84,24 +85,46 @@ export async function taskReleaseCommand(options = {}) {
|
|
|
84
85
|
return;
|
|
85
86
|
}
|
|
86
87
|
let releaseUrl;
|
|
88
|
+
let open;
|
|
87
89
|
try {
|
|
88
|
-
|
|
90
|
+
open = await findMergeRequestByBranches({
|
|
89
91
|
cwd,
|
|
90
92
|
host,
|
|
91
|
-
baseBranch: productionBranch,
|
|
92
93
|
headBranch: integrationBranch,
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
baseBranch: productionBranch,
|
|
95
|
+
state: "open",
|
|
95
96
|
});
|
|
96
|
-
releaseUrl = url;
|
|
97
|
-
log.ok(`${label}: ${url}`);
|
|
98
97
|
}
|
|
99
98
|
catch (e) {
|
|
100
|
-
const msg = e instanceof Error ? e.message : String(e);
|
|
101
|
-
log.error(`Could not
|
|
99
|
+
const msg = e instanceof Error ? e.message.split("\n")[0] : String(e);
|
|
100
|
+
log.error(`Could not look up an open release ${label}: ${msg}`);
|
|
102
101
|
process.exitCode = 1;
|
|
103
102
|
return;
|
|
104
103
|
}
|
|
104
|
+
if (open !== null) {
|
|
105
|
+
releaseUrl = open.url;
|
|
106
|
+
log.ok(`${label} already open — reusing: ${releaseUrl}`);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
try {
|
|
110
|
+
const { url } = await createMergeRequest({
|
|
111
|
+
cwd,
|
|
112
|
+
host,
|
|
113
|
+
baseBranch: productionBranch,
|
|
114
|
+
headBranch: integrationBranch,
|
|
115
|
+
title,
|
|
116
|
+
body,
|
|
117
|
+
});
|
|
118
|
+
releaseUrl = url;
|
|
119
|
+
log.ok(`${label}: ${url}`);
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
123
|
+
log.error(`Could not create release ${label}: ${msg}`);
|
|
124
|
+
process.exitCode = 1;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
105
128
|
if (options.noMerge === true) {
|
|
106
129
|
log.info(dim("Merge skipped (--no-merge)."));
|
|
107
130
|
return;
|
|
@@ -14,7 +14,7 @@ import { runPostMergeNewCycle } from "../lib/task-new-cycle.js";
|
|
|
14
14
|
import { applyTaskShipMemory, fallbackResultSections, llmCompleteTaskShip, writeTaskResultSections, } from "../lib/task-ship-llm.js";
|
|
15
15
|
import { detectShipPrState, prRefLabel, resolveShipAction, } from "../lib/task-ship-state.js";
|
|
16
16
|
import { finishTaskWithPullRequest } from "../lib/task-push-pr.js";
|
|
17
|
-
import { hasNonEmptySection, parseTaskFilename, readGitContext, readTaskFile, updateInlineStatus, } from "../lib/task.js";
|
|
17
|
+
import { hasNonEmptySection, parseTaskFilename, gitContextProblem, readGitContext, readTaskFile, updateInlineStatus, } from "../lib/task.js";
|
|
18
18
|
import { assertTaskIdFreeOnRemote } from "../lib/task-id-allocation.js";
|
|
19
19
|
function describePushFailure(message) {
|
|
20
20
|
const lower = message.toLowerCase();
|
|
@@ -111,6 +111,13 @@ async function runFirstShip(ctx) {
|
|
|
111
111
|
process.exitCode = 1;
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
|
+
const gitCtx = await readGitContext(taskFile);
|
|
115
|
+
if (gitCtx === null) {
|
|
116
|
+
log.error(`No Git Context in ${relPath(cwd, taskFile)}: ${await gitContextProblem(taskFile)}. Nothing was committed or pushed.`);
|
|
117
|
+
log.info(dim("`vibeops task add` writes this section with the task branch; restore it, then rerun task ship."));
|
|
118
|
+
process.exitCode = 1;
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
114
121
|
if (dryRun) {
|
|
115
122
|
log.info(bold("dry-run — would:"));
|
|
116
123
|
if (!resultOk || !testOk) {
|
|
@@ -128,8 +135,7 @@ async function runFirstShip(ctx) {
|
|
|
128
135
|
});
|
|
129
136
|
return;
|
|
130
137
|
}
|
|
131
|
-
|
|
132
|
-
if (gitCtx !== null && !(await ensureOnTaskBranch(cwd, gitCtx, dryRun))) {
|
|
138
|
+
if (!(await ensureOnTaskBranch(cwd, gitCtx, dryRun))) {
|
|
133
139
|
process.exitCode = 1;
|
|
134
140
|
return;
|
|
135
141
|
}
|
|
@@ -150,10 +156,6 @@ async function runFirstShip(ctx) {
|
|
|
150
156
|
});
|
|
151
157
|
await commitDirtyWorkingTree(cwd, message, false);
|
|
152
158
|
}
|
|
153
|
-
if (gitCtx === null) {
|
|
154
|
-
log.info(dim("No Git Context — push/MR skipped."));
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
159
|
await commitShipMetadata({ cwd, taskFile, taskId: parts.id, dryRun: false });
|
|
158
160
|
const prResult = await finishTaskWithPullRequest({
|
|
159
161
|
cwd,
|
|
@@ -183,7 +185,7 @@ async function runUpdateOpenPr(ctx) {
|
|
|
183
185
|
const { cwd, taskId, taskFile, meta, body, prCtx, dryRun, nonInteractive, options } = ctx;
|
|
184
186
|
const gitCtx = await readGitContext(taskFile);
|
|
185
187
|
if (gitCtx === null) {
|
|
186
|
-
log.error(
|
|
188
|
+
log.error(`No Git Context — cannot update the open PR: ${await gitContextProblem(taskFile)}.`);
|
|
187
189
|
process.exitCode = 1;
|
|
188
190
|
return;
|
|
189
191
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { gitIsAncestor, runGit } from "./git.js";
|
|
2
|
+
/**
|
|
3
|
+
* The MR/PR head must contain the current tip of its base branch.
|
|
4
|
+
*
|
|
5
|
+
* A head that does not (base moved, or the branch was rebuilt on a stale base,
|
|
6
|
+
* e.g. `git reset --soft <old base>` + commit) can silently revert work merged
|
|
7
|
+
* into the base since; a squash merge then lands that revert. Fetches the base
|
|
8
|
+
* branch and the head commit first; any fetch / read failure fails closed.
|
|
9
|
+
*/
|
|
10
|
+
export async function checkBaseInHead(opts) {
|
|
11
|
+
const { cwd, remote, baseBranch, headSha } = opts;
|
|
12
|
+
const baseRef = `refs/remotes/${remote}/${baseBranch}`;
|
|
13
|
+
try {
|
|
14
|
+
await runGit(cwd, ["fetch", "--no-tags", remote, `+refs/heads/${baseBranch}:${baseRef}`]);
|
|
15
|
+
if (!(await commitExists(cwd, headSha))) {
|
|
16
|
+
await runGit(cwd, ["fetch", "--no-tags", remote, headSha]);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
const msg = e instanceof Error ? e.message.split("\n")[0] : String(e);
|
|
21
|
+
return {
|
|
22
|
+
ok: false,
|
|
23
|
+
problem: `could not fetch ${remote}/${baseBranch} and head ${short(headSha)} to check the base is current (${msg})`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (await gitIsAncestor(cwd, baseRef, headSha))
|
|
27
|
+
return { ok: true };
|
|
28
|
+
let behind = "";
|
|
29
|
+
try {
|
|
30
|
+
const { stdout } = await runGit(cwd, ["rev-list", "--count", `${headSha}..${baseRef}`]);
|
|
31
|
+
behind = ` (${stdout.trim()} commit(s) behind)`;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// count is informational only
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
ok: false,
|
|
38
|
+
problem: `stale base: head ${short(headSha)} does not contain ${remote}/${baseBranch}${behind}. ` +
|
|
39
|
+
`Merging it can silently revert work merged into ${baseBranch} since. ` +
|
|
40
|
+
`Update the task branch (git fetch ${remote} && git merge ${remote}/${baseBranch}, resolve, test), ` +
|
|
41
|
+
`push it (vibeops task ship), wait for CI, then rerun vibeops task merge.`,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async function commitExists(cwd, sha) {
|
|
45
|
+
try {
|
|
46
|
+
await runGit(cwd, ["cat-file", "-e", `${sha}^{commit}`]);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function short(sha) {
|
|
54
|
+
return sha.slice(0, 7);
|
|
55
|
+
}
|
package/dist/lib/pr-create.js
CHANGED
|
@@ -5,6 +5,7 @@ import { classifyRollup, evaluateCheckGate, formatCheckGateProblems, } from "./c
|
|
|
5
5
|
import { isMergeRequestReadyToMerge, isPipelineActive, pipelineGateState, pipelineStatusFromHost, } from "./merge-request-readiness.js";
|
|
6
6
|
import { evaluateActionsRuns, listExpectedPullRequestWorkflows, listWorkflowRunsForSha, parseGitHubPullUrl, } from "./github-actions-gate.js";
|
|
7
7
|
import { dim, log } from "./logger.js";
|
|
8
|
+
import { checkBaseInHead } from "./merge-base-freshness.js";
|
|
8
9
|
import { MERGE_GATE_DEFAULTS, mergeGateTiming } from "./merge-config.js";
|
|
9
10
|
const execFileAsync = promisify(execFile);
|
|
10
11
|
async function ghPrCreate(opts) {
|
|
@@ -607,6 +608,10 @@ export async function mergeMergeRequest(opts) {
|
|
|
607
608
|
? ` + required: ${opts.requiredChecks.join(", ")}`
|
|
608
609
|
: "";
|
|
609
610
|
log.info(`would check ${label} status checks (all green${required}) before merging`);
|
|
611
|
+
if (opts.requireBaseInHead !== undefined) {
|
|
612
|
+
const { remote, baseBranch } = opts.requireBaseInHead;
|
|
613
|
+
log.info(`would refuse unless the head commit contains ${remote}/${baseBranch} (stale base)`);
|
|
614
|
+
}
|
|
610
615
|
if (opts.host === "gitlab") {
|
|
611
616
|
log.info(`would ${label} merge ${ref} (glab ${gitLabMergeArgs(ref, method, "<head sha>").join(" ")})`);
|
|
612
617
|
}
|
|
@@ -629,6 +634,16 @@ export async function mergeMergeRequest(opts) {
|
|
|
629
634
|
// Strict read already guarantees this; never merge unpinned.
|
|
630
635
|
throw new MergeGateError(label, ["host did not report the head commit SHA"]);
|
|
631
636
|
}
|
|
637
|
+
if (opts.requireBaseInHead !== undefined) {
|
|
638
|
+
const fresh = await checkBaseInHead({
|
|
639
|
+
cwd: opts.cwd,
|
|
640
|
+
remote: opts.requireBaseInHead.remote,
|
|
641
|
+
baseBranch: gate.details.baseBranch ?? opts.requireBaseInHead.baseBranch,
|
|
642
|
+
headSha: gate.details.headSha,
|
|
643
|
+
});
|
|
644
|
+
if (!fresh.ok)
|
|
645
|
+
throw new MergeGateError(label, [fresh.problem]);
|
|
646
|
+
}
|
|
632
647
|
return gate.details;
|
|
633
648
|
};
|
|
634
649
|
const details = await runGate();
|
|
@@ -16,20 +16,25 @@ const CONVENTIONAL_COMMIT_RE = /^([a-z]+)(?:\(([^)]*)\))?(!)?:\s*(.+)$/is;
|
|
|
16
16
|
* - `"fix(login): handle null"` → `fix(task-001): handle null` (scope rewritten)
|
|
17
17
|
* - `"handle null"` → `feat(task-001): handle null` (defaultType)
|
|
18
18
|
* - already-scoped correct messages are returned unchanged.
|
|
19
|
+
* - only the subject (first line) is scoped; a body and trailers after it
|
|
20
|
+
* (e.g. `Co-Authored-By:`) are kept line by line.
|
|
19
21
|
*/
|
|
20
22
|
export function taskScopedCommitMessage(taskId, rawMessage, defaultType = "feat") {
|
|
21
23
|
const scope = taskId.toLowerCase();
|
|
22
|
-
const
|
|
24
|
+
const lines = rawMessage.replace(/\r\n?/g, "\n").trim().split("\n");
|
|
25
|
+
const msg = (lines[0] ?? "").replace(/\s+/g, " ").trim();
|
|
26
|
+
const body = lines.slice(1).map((l) => l.trimEnd()).join("\n").replace(/^\n+/, "");
|
|
27
|
+
const withBody = (subject) => (body.length > 0 ? `${subject}\n\n${body}` : subject);
|
|
23
28
|
if (msg.length === 0)
|
|
24
|
-
return `${defaultType}(${scope}): ${taskId}
|
|
29
|
+
return withBody(`${defaultType}(${scope}): ${taskId}`);
|
|
25
30
|
const m = CONVENTIONAL_COMMIT_RE.exec(msg);
|
|
26
31
|
if (m) {
|
|
27
32
|
const type = m[1].toLowerCase();
|
|
28
33
|
const bang = m[3] ?? "";
|
|
29
34
|
const subject = m[4].trim();
|
|
30
|
-
return `${type}(${scope})${bang}: ${subject}
|
|
35
|
+
return withBody(`${type}(${scope})${bang}: ${subject}`);
|
|
31
36
|
}
|
|
32
|
-
return `${defaultType}(${scope}): ${msg}
|
|
37
|
+
return withBody(`${defaultType}(${scope}): ${msg}`);
|
|
33
38
|
}
|
|
34
39
|
/**
|
|
35
40
|
* Commit all committable dirty paths (staged and unstaged, including deletions
|
package/dist/lib/task.js
CHANGED
|
@@ -221,6 +221,25 @@ function locateSection(text, title, level = 2) {
|
|
|
221
221
|
}
|
|
222
222
|
return null;
|
|
223
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* A line that looks like the `## <title>` heading but is not one (e.g. `## ## Git Context`
|
|
226
|
+
* or `#Git Context`), when no well-formed heading exists. 1-based line number, or `null`.
|
|
227
|
+
*/
|
|
228
|
+
export function findMalformedSectionHeading(text, title, level = 2) {
|
|
229
|
+
if (locateSection(text, title, level) !== null)
|
|
230
|
+
return null;
|
|
231
|
+
const want = title.toLowerCase();
|
|
232
|
+
const lines = text.split("\n");
|
|
233
|
+
for (let i = 0; i < lines.length; i++) {
|
|
234
|
+
const line = lines[i];
|
|
235
|
+
if (!/^\s*#/.test(line))
|
|
236
|
+
continue;
|
|
237
|
+
const name = line.replace(/^[\s#]+/, "").replace(/[\s#]+$/, "").toLowerCase();
|
|
238
|
+
if (name === want)
|
|
239
|
+
return { line: i + 1, text: line.trim() };
|
|
240
|
+
}
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
224
243
|
export function readSection(body, title) {
|
|
225
244
|
const block = locateSection(body, title);
|
|
226
245
|
if (block === null)
|
|
@@ -420,6 +439,30 @@ export async function upsertGitContext(filePath, ctx) {
|
|
|
420
439
|
await writeText(filePath, updated);
|
|
421
440
|
}
|
|
422
441
|
}
|
|
442
|
+
/**
|
|
443
|
+
* The Git Context exists but cannot be read (malformed heading, or the section lacks
|
|
444
|
+
* its fields): the problem text, else `null` (readable, or no section at all).
|
|
445
|
+
*/
|
|
446
|
+
export async function damagedGitContext(filePath) {
|
|
447
|
+
if ((await readGitContext(filePath)) !== null)
|
|
448
|
+
return null;
|
|
449
|
+
const raw = await readText(filePath);
|
|
450
|
+
const malformed = findMalformedSectionHeading(raw, "Git Context") !== null;
|
|
451
|
+
const unparsable = readSection(raw, "Git Context").length > 0;
|
|
452
|
+
return malformed || unparsable ? gitContextProblem(filePath) : null;
|
|
453
|
+
}
|
|
454
|
+
/** Why {@link readGitContext} returned `null` for this file — for error messages. */
|
|
455
|
+
export async function gitContextProblem(filePath) {
|
|
456
|
+
const raw = await readText(filePath);
|
|
457
|
+
const bad = findMalformedSectionHeading(raw, "Git Context");
|
|
458
|
+
if (bad !== null) {
|
|
459
|
+
return `line ${bad.line} is \`${bad.text}\`, not \`## Git Context\` — fix that heading`;
|
|
460
|
+
}
|
|
461
|
+
if (readSection(raw, "Git Context").length === 0) {
|
|
462
|
+
return "the file has no `## Git Context` section";
|
|
463
|
+
}
|
|
464
|
+
return "`## Git Context` lacks Base Branch / Base Commit / Task Branch / Started At";
|
|
465
|
+
}
|
|
423
466
|
const GIT_CTX_RE = {
|
|
424
467
|
baseBranch: /^-\s+Base Branch:\s*`([^`]+)`/m,
|
|
425
468
|
baseCommit: /^-\s+Base Commit:\s*`([^`]+)`/m,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodtek/vibeops",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6",
|
|
4
4
|
"description": "Minimal CLI rails for Cursor-based TASK-driven vibe coding.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@9.15.9",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@eslint/js": "10.0.1",
|
|
64
64
|
"@types/node": "^20.14.0",
|
|
65
65
|
"eslint": "10.11.0",
|
|
66
|
-
"tsx": "^4.
|
|
66
|
+
"tsx": "^4.23.15",
|
|
67
67
|
"typescript": "^5.5.4",
|
|
68
68
|
"typescript-eslint": "8.71.0"
|
|
69
69
|
}
|