@goodtek/vibeops 1.1.2 → 2.0.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/CHANGELOG.md +24 -0
- package/README.md +28 -12
- package/dist/bootstrap/installer.js +1 -1
- package/dist/cli.js +58 -8
- package/dist/commands/init.js +3 -3
- package/dist/commands/llm.js +3 -3
- package/dist/commands/status.js +1 -0
- package/dist/commands/task-add.js +2 -2
- package/dist/commands/task-merge.js +134 -0
- package/dist/commands/task-release.js +103 -0
- package/dist/commands/{task-done.js → task-ship.js} +28 -63
- package/dist/commands/task-sync.js +183 -0
- package/dist/lib/git.js +7 -0
- package/dist/lib/paths.js +1 -1
- package/dist/lib/pr-create.js +63 -0
- package/dist/lib/resolve-task.js +1 -1
- package/dist/lib/task-context.js +22 -7
- package/dist/lib/task-git-commit.js +32 -0
- package/dist/lib/task-lifecycle-target.js +41 -0
- package/dist/lib/task-scaffold.js +1 -1
- package/dist/lib/{task-done-llm.js → task-ship-llm.js} +9 -6
- package/dist/lib/task.js +7 -0
- package/package.json +1 -1
- package/templates/clients/claude/CLAUDE.md +5 -27
- package/templates/clients/cursor/.cursor/rules/02-git-safety.mdc +5 -5
- package/templates/clients/cursor/.cursor/rules/03-docs-before-ship.mdc +13 -0
- package/templates/core/AGENTS.md +16 -34
- package/templates/core/docs/logs/README.md +1 -1
- package/templates/core/docs/project/03-architecture.md +1 -1
- package/templates/core/docs/project/05-current-state.md +1 -1
- package/templates/core/docs/project/06-decisions.md +1 -1
- package/templates/skills-shared/implement-task/SKILL.md +7 -16
- package/templates/clients/cursor/.cursor/rules/03-docs-on-done.mdc +0 -13
|
@@ -1,76 +1,45 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import { readText } from "../lib/filesystem.js";
|
|
3
|
+
import { requireGitConfig } from "../lib/git-config.js";
|
|
3
4
|
import { bold, cyan, dim, green, log, yellow } from "../lib/logger.js";
|
|
4
5
|
import { projectPaths } from "../lib/paths.js";
|
|
5
6
|
import { resolveTask, taskNotFoundMessage } from "../lib/resolve-task.js";
|
|
6
|
-
import { applyTaskDoneMemory, fallbackResultSections, llmCompleteTaskDone, writeTaskResultSections, } from "../lib/task-done-llm.js";
|
|
7
7
|
import { relPath } from "../lib/task-context.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { hasNonEmptySection, markGitContextDone, parseTaskFilename, readGitContext, readTaskFile, updateInlineStatus, } from "../lib/task.js";
|
|
8
|
+
import { commitDirtyWorkingTree, docsCommitMessageFor, featCommitMessageFor, pushBranch, } from "../lib/task-git-commit.js";
|
|
9
|
+
import { applyTaskShipMemory, fallbackResultSections, llmCompleteTaskShip, writeTaskResultSections, } from "../lib/task-ship-llm.js";
|
|
11
10
|
import { finishTaskWithPullRequest } from "../lib/task-push-pr.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return `feat(${taskId.toLowerCase()}): ${slug}`;
|
|
15
|
-
}
|
|
16
|
-
function closureCommitMessageFor(taskId) {
|
|
17
|
-
return `docs(${taskId.toLowerCase()}): close task metadata`;
|
|
18
|
-
}
|
|
19
|
-
async function tryCommitDirty(cwd, message, dryRun) {
|
|
20
|
-
const git = await readGitInfo(cwd);
|
|
21
|
-
if (!git.isRepo || git.dirty !== true)
|
|
22
|
-
return false;
|
|
23
|
-
const { committable, excluded } = partitionPathsForAutoCommit(await listWorkingTreeRelPaths(cwd), { unmerged: [] });
|
|
24
|
-
if (committable.length === 0)
|
|
25
|
-
return false;
|
|
26
|
-
if (excluded.length > 0) {
|
|
27
|
-
log.warn(`Skipping ${excluded.length} build artifact path(s) from auto-commit.`);
|
|
28
|
-
}
|
|
29
|
-
if (dryRun) {
|
|
30
|
-
log.info(dim(` would commit ${committable.length} path(s)`));
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
await gitAddPaths(cwd, committable);
|
|
34
|
-
await runGit(cwd, ["commit", "-q", "-m", message]);
|
|
35
|
-
log.ok(`Committed: ${message}`);
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* After push/MR: write Status Done + Git Context closure, commit, push so the remote
|
|
40
|
-
* branch matches local TASK metadata (canonical two-phase close).
|
|
41
|
-
*/
|
|
42
|
-
async function commitClosureMetadataAndPush(opts) {
|
|
11
|
+
import { hasNonEmptySection, parseTaskFilename, readGitContext, readTaskFile, updateInlineStatus, } from "../lib/task.js";
|
|
12
|
+
async function commitShipMetadataAndPush(opts) {
|
|
43
13
|
if (opts.dryRun) {
|
|
44
|
-
log.info(dim(" would set Status →
|
|
45
|
-
log.info(dim(" would commit
|
|
14
|
+
log.info(dim(" would set Status → Review"));
|
|
15
|
+
log.info(dim(" would commit ship metadata"));
|
|
46
16
|
if (opts.push !== null) {
|
|
47
|
-
log.info(dim(` would git push ${opts.push.remote} ${opts.push.branch} (
|
|
17
|
+
log.info(dim(` would git push ${opts.push.remote} ${opts.push.branch} (review metadata)`));
|
|
48
18
|
}
|
|
49
19
|
return true;
|
|
50
20
|
}
|
|
51
|
-
await updateInlineStatus(opts.taskFile, "
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const committed = await tryCommitDirty(opts.cwd, closureCommitMessageFor(opts.taskId), false);
|
|
21
|
+
await updateInlineStatus(opts.taskFile, "review");
|
|
22
|
+
log.ok("Status → Review");
|
|
23
|
+
const committed = await commitDirtyWorkingTree(opts.cwd, docsCommitMessageFor(opts.taskId, "ready for review"), false);
|
|
55
24
|
if (!committed) {
|
|
56
|
-
log.warn("No file changes for
|
|
25
|
+
log.warn("No file changes for review metadata commit — check TASK Status on the remote branch.");
|
|
57
26
|
return true;
|
|
58
27
|
}
|
|
59
28
|
if (opts.push === null)
|
|
60
29
|
return true;
|
|
61
30
|
try {
|
|
62
|
-
await
|
|
63
|
-
log.ok(`Pushed
|
|
31
|
+
await pushBranch(opts.cwd, opts.push.remote, opts.push.branch, false);
|
|
32
|
+
log.ok(`Pushed review metadata → ${opts.push.remote}/${opts.push.branch}`);
|
|
64
33
|
return true;
|
|
65
34
|
}
|
|
66
35
|
catch (e) {
|
|
67
36
|
const msg = e instanceof Error ? e.message : String(e);
|
|
68
|
-
log.error(`
|
|
37
|
+
log.error(`Review metadata push failed: ${msg}`);
|
|
69
38
|
log.info(dim(`Fix auth/remote, then: git push ${opts.push.remote} ${opts.push.branch}`));
|
|
70
39
|
return false;
|
|
71
40
|
}
|
|
72
41
|
}
|
|
73
|
-
export async function
|
|
42
|
+
export async function taskShipCommand(taskRef, options = {}) {
|
|
74
43
|
const cwd = resolve(options.cwd ?? process.cwd());
|
|
75
44
|
const paths = projectPaths(cwd);
|
|
76
45
|
const dryRun = options.dryRun === true;
|
|
@@ -84,7 +53,7 @@ export async function taskDoneCommand(taskRef, options = {}) {
|
|
|
84
53
|
const meta = await readTaskFile(taskFile);
|
|
85
54
|
const body = await readText(taskFile);
|
|
86
55
|
const relFile = relPath(cwd, taskFile);
|
|
87
|
-
log.info(bold(`vibeops task
|
|
56
|
+
log.info(bold(`vibeops task ship ${taskId}`));
|
|
88
57
|
log.info(` ${dim("file")} ${relFile}`);
|
|
89
58
|
log.blank();
|
|
90
59
|
let resultOk = hasNonEmptySection(body, "Result");
|
|
@@ -95,7 +64,7 @@ export async function taskDoneCommand(taskRef, options = {}) {
|
|
|
95
64
|
log.info(dim(" would call LLM and patch docs/project/*"));
|
|
96
65
|
}
|
|
97
66
|
else {
|
|
98
|
-
const patch = await
|
|
67
|
+
const patch = await llmCompleteTaskShip({
|
|
99
68
|
cwd,
|
|
100
69
|
taskId,
|
|
101
70
|
taskTitle: meta.title,
|
|
@@ -105,7 +74,7 @@ export async function taskDoneCommand(taskRef, options = {}) {
|
|
|
105
74
|
if (patch !== null) {
|
|
106
75
|
await writeTaskResultSections(taskFile, patch.result, patch.testResult);
|
|
107
76
|
log.ok(`Result / Test Result updated (${patch.provider})`);
|
|
108
|
-
const memory = await
|
|
77
|
+
const memory = await applyTaskShipMemory(cwd, patch);
|
|
109
78
|
for (const p of memory.updated)
|
|
110
79
|
log.ok(`Updated ${p}`);
|
|
111
80
|
for (const p of memory.skipped)
|
|
@@ -136,7 +105,7 @@ export async function taskDoneCommand(taskRef, options = {}) {
|
|
|
136
105
|
log.info(" · LLM fill Result / Test Result + patch docs/project/*");
|
|
137
106
|
}
|
|
138
107
|
log.info(" · commit implementation, push task branch, open MR/PR (unless --no-pr)");
|
|
139
|
-
log.info(" · Status →
|
|
108
|
+
log.info(" · Status → Review; commit metadata; push again");
|
|
140
109
|
await finishTaskWithPullRequest({
|
|
141
110
|
cwd,
|
|
142
111
|
taskFile,
|
|
@@ -144,10 +113,8 @@ export async function taskDoneCommand(taskRef, options = {}) {
|
|
|
144
113
|
skipPr: options.noPr === true,
|
|
145
114
|
});
|
|
146
115
|
const gitCtxDry = await readGitContext(taskFile);
|
|
147
|
-
const gitCfgDry = gitCtxDry !== null
|
|
148
|
-
|
|
149
|
-
: null;
|
|
150
|
-
await commitClosureMetadataAndPush({
|
|
116
|
+
const gitCfgDry = gitCtxDry !== null ? await requireGitConfig(cwd).catch(() => null) : null;
|
|
117
|
+
await commitShipMetadataAndPush({
|
|
151
118
|
cwd,
|
|
152
119
|
taskFile,
|
|
153
120
|
taskId,
|
|
@@ -159,8 +126,7 @@ export async function taskDoneCommand(taskRef, options = {}) {
|
|
|
159
126
|
return;
|
|
160
127
|
}
|
|
161
128
|
const parts = parseTaskFilename(taskFile);
|
|
162
|
-
|
|
163
|
-
await tryCommitDirty(cwd, commitMsg, false);
|
|
129
|
+
await commitDirtyWorkingTree(cwd, featCommitMessageFor(parts.id, meta.title), false);
|
|
164
130
|
const gitCtx = await readGitContext(taskFile);
|
|
165
131
|
if (gitCtx !== null) {
|
|
166
132
|
const prResult = await finishTaskWithPullRequest({
|
|
@@ -169,13 +135,12 @@ export async function taskDoneCommand(taskRef, options = {}) {
|
|
|
169
135
|
skipPr: options.noPr === true,
|
|
170
136
|
});
|
|
171
137
|
if (!prResult.ok) {
|
|
172
|
-
log.error("TASK left In Progress — fix push/MR, then rerun task
|
|
138
|
+
log.error("TASK left In Progress — fix push/MR, then rerun task ship.");
|
|
173
139
|
process.exitCode = 1;
|
|
174
140
|
return;
|
|
175
141
|
}
|
|
176
142
|
if (prResult.mergeRequestUrl) {
|
|
177
143
|
log.info(` ${dim("MR/PR")} ${prResult.mergeRequestUrl}`);
|
|
178
|
-
log.info(dim("Merge on GitHub/GitLab — CI deploys after merge."));
|
|
179
144
|
}
|
|
180
145
|
}
|
|
181
146
|
else {
|
|
@@ -193,18 +158,18 @@ export async function taskDoneCommand(taskRef, options = {}) {
|
|
|
193
158
|
log.warn(e.message);
|
|
194
159
|
}
|
|
195
160
|
}
|
|
196
|
-
const
|
|
161
|
+
const shipped = await commitShipMetadataAndPush({
|
|
197
162
|
cwd,
|
|
198
163
|
taskFile,
|
|
199
164
|
taskId: parts.id,
|
|
200
165
|
dryRun: false,
|
|
201
166
|
push: pushTarget,
|
|
202
167
|
});
|
|
203
|
-
if (!
|
|
204
|
-
log.error("
|
|
168
|
+
if (!shipped) {
|
|
169
|
+
log.error("Review metadata push failed — fix manually, then run task merge.");
|
|
205
170
|
process.exitCode = 1;
|
|
206
171
|
return;
|
|
207
172
|
}
|
|
208
173
|
log.blank();
|
|
209
|
-
log.info(`Next: ${cyan("vibeops task
|
|
174
|
+
log.info(`Next: ${cyan("vibeops task merge")} (or merge in the host UI), then ${cyan("vibeops task sync")}`);
|
|
210
175
|
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { GitConfigError, requireGitConfig } from "../lib/git-config.js";
|
|
3
|
+
import { detectGitHost, mergeRequestLabel } from "../lib/git-host.js";
|
|
4
|
+
import { gitBranchExists, gitDeleteBranch, gitDeleteRemoteBranch, gitFetchRemote, gitPullFastForwardOnly, gitRemoteBranchExists, gitRemoteUrl, gitSwitchToBranch, readGitInfo, } from "../lib/git.js";
|
|
5
|
+
import { bold, cyan, dim, log, yellow } from "../lib/logger.js";
|
|
6
|
+
import { getMergeRequestState, probeMergeRequestCli } from "../lib/pr-create.js";
|
|
7
|
+
import { projectPaths } from "../lib/paths.js";
|
|
8
|
+
import { taskNotFoundMessage } from "../lib/resolve-task.js";
|
|
9
|
+
import { relPath } from "../lib/task-context.js";
|
|
10
|
+
import { commitDirtyWorkingTree, docsCommitMessageFor, pushBranch, } from "../lib/task-git-commit.js";
|
|
11
|
+
import { resolveLifecycleTarget } from "../lib/task-lifecycle-target.js";
|
|
12
|
+
import { markGitContextDone, readGitContext, readTaskFile, updateInlineStatus, } from "../lib/task.js";
|
|
13
|
+
function isProtectedBranch(name, integration, production) {
|
|
14
|
+
return name === integration || name === production || name === "main" || name === "master";
|
|
15
|
+
}
|
|
16
|
+
export async function taskSyncCommand(taskRef, options = {}) {
|
|
17
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
18
|
+
const dryRun = options.dryRun === true;
|
|
19
|
+
const paths = projectPaths(cwd);
|
|
20
|
+
let gitCfg;
|
|
21
|
+
try {
|
|
22
|
+
gitCfg = await requireGitConfig(cwd);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
if (e instanceof GitConfigError) {
|
|
26
|
+
log.error(e.message);
|
|
27
|
+
process.exitCode = 1;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
throw e;
|
|
31
|
+
}
|
|
32
|
+
const target = await resolveLifecycleTarget(paths, cwd, taskRef);
|
|
33
|
+
if (target === null) {
|
|
34
|
+
if (taskRef?.trim()) {
|
|
35
|
+
log.error(taskNotFoundMessage(taskRef));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
log.error("No TASK to sync. Pass TASK-NNN, checkout a task/* branch, or run task ship first.");
|
|
39
|
+
}
|
|
40
|
+
process.exitCode = 1;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const { integrationBranch, productionBranch, remote } = gitCfg;
|
|
44
|
+
const { taskId, taskBranch, taskFile } = target;
|
|
45
|
+
const ctx = await readGitContext(taskFile);
|
|
46
|
+
if (isProtectedBranch(taskBranch, integrationBranch, productionBranch)) {
|
|
47
|
+
log.error(`Refusing to delete protected branch: ${taskBranch}`);
|
|
48
|
+
process.exitCode = 1;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
log.info(bold(`vibeops task sync ${taskId}`));
|
|
52
|
+
log.info(` ${dim("task branch")} ${cyan(taskBranch)}`);
|
|
53
|
+
log.info(` ${dim("integration")} ${integrationBranch}`);
|
|
54
|
+
log.info(` ${dim("file")} ${relPath(cwd, taskFile)}`);
|
|
55
|
+
log.blank();
|
|
56
|
+
const meta = await readTaskFile(taskFile);
|
|
57
|
+
if (ctx?.mergeRequestUrl && !dryRun) {
|
|
58
|
+
const remoteUrl = await gitRemoteUrl(cwd, remote);
|
|
59
|
+
const host = remoteUrl !== null && detectGitHost(remoteUrl) !== null
|
|
60
|
+
? detectGitHost(remoteUrl)
|
|
61
|
+
: gitCfg.host;
|
|
62
|
+
if (await probeMergeRequestCli(host)) {
|
|
63
|
+
const state = await getMergeRequestState(cwd, host, ctx.mergeRequestUrl);
|
|
64
|
+
const label = mergeRequestLabel(host);
|
|
65
|
+
if (state === "open") {
|
|
66
|
+
log.warn(`${yellow(label)} still open — merge with task merge or the host UI before sync.`);
|
|
67
|
+
}
|
|
68
|
+
else if (state === "merged") {
|
|
69
|
+
log.ok(`${label} merged.`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else if (meta.status === "review") {
|
|
74
|
+
log.warn(`${yellow("Status")} is Review — merge the MR first, then rerun task sync.`);
|
|
75
|
+
}
|
|
76
|
+
if (dryRun) {
|
|
77
|
+
log.info(bold("dry-run — would:"));
|
|
78
|
+
log.info(` · git fetch ${remote} --prune`);
|
|
79
|
+
log.info(` · git switch ${integrationBranch}`);
|
|
80
|
+
log.info(` · git pull --ff-only ${remote} ${integrationBranch}`);
|
|
81
|
+
if (meta.status !== "done") {
|
|
82
|
+
log.info(" · Status → Done on integration branch; commit; push");
|
|
83
|
+
}
|
|
84
|
+
log.info(` · git branch ${options.force === true ? "-D" : "-d"} ${taskBranch}`);
|
|
85
|
+
if (options.noRemoteDelete !== true) {
|
|
86
|
+
log.info(` · git push ${remote} --delete ${taskBranch} (if exists)`);
|
|
87
|
+
}
|
|
88
|
+
log.blank();
|
|
89
|
+
log.info(`Next: ${cyan("vibeops task add")}`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const git = await readGitInfo(cwd);
|
|
93
|
+
if (!git.isRepo) {
|
|
94
|
+
log.error("Not a git repository.");
|
|
95
|
+
process.exitCode = 1;
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (git.branch === taskBranch) {
|
|
99
|
+
log.info(dim(`On ${taskBranch} — switching to ${integrationBranch} first.`));
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
await gitFetchRemote(cwd, remote);
|
|
103
|
+
log.ok(`Fetched ${remote} (--prune)`);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
107
|
+
log.warn(`git fetch failed (${msg}). Continuing with local refs.`);
|
|
108
|
+
}
|
|
109
|
+
const switched = await gitSwitchToBranch(cwd, integrationBranch, remote);
|
|
110
|
+
if (!switched) {
|
|
111
|
+
log.error(`Integration branch "${integrationBranch}" not found locally or on ${remote}.`);
|
|
112
|
+
process.exitCode = 1;
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
log.ok(`On ${integrationBranch}`);
|
|
116
|
+
if (await gitRemoteBranchExists(cwd, remote, integrationBranch)) {
|
|
117
|
+
try {
|
|
118
|
+
await gitPullFastForwardOnly(cwd, remote, integrationBranch);
|
|
119
|
+
log.ok(`Up to date with ${remote}/${integrationBranch} (--ff-only)`);
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
123
|
+
log.error(`Could not fast-forward ${integrationBranch}: ${msg}. Resolve locally, then rerun.`);
|
|
124
|
+
process.exitCode = 1;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
log.warn(`No ${remote}/${integrationBranch} — skipped pull.`);
|
|
130
|
+
}
|
|
131
|
+
const metaOnIntegration = await readTaskFile(taskFile);
|
|
132
|
+
if (metaOnIntegration.status !== "done") {
|
|
133
|
+
await updateInlineStatus(taskFile, "done");
|
|
134
|
+
await markGitContextDone(taskFile);
|
|
135
|
+
log.ok("Status → Done");
|
|
136
|
+
const committed = await commitDirtyWorkingTree(cwd, docsCommitMessageFor(taskId, "mark done"), false);
|
|
137
|
+
if (committed) {
|
|
138
|
+
try {
|
|
139
|
+
await pushBranch(cwd, remote, integrationBranch, false);
|
|
140
|
+
log.ok(`Pushed done metadata → ${remote}/${integrationBranch}`);
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
144
|
+
log.warn(`Could not push done metadata: ${msg}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (await gitBranchExists(cwd, taskBranch)) {
|
|
149
|
+
try {
|
|
150
|
+
await gitDeleteBranch(cwd, taskBranch, { force: options.force === true });
|
|
151
|
+
log.ok(`Deleted local branch ${taskBranch}`);
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
155
|
+
log.error(`Could not delete local ${taskBranch}: ${msg}`);
|
|
156
|
+
log.info(dim("Merge the MR into the integration branch first, or rerun with --force (discards unmerged branch)."));
|
|
157
|
+
process.exitCode = 1;
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
log.info(dim(`Local branch ${taskBranch} not found — skipped.`));
|
|
163
|
+
}
|
|
164
|
+
if (options.noRemoteDelete !== true && (await gitRemoteBranchExists(cwd, remote, taskBranch))) {
|
|
165
|
+
try {
|
|
166
|
+
await gitDeleteRemoteBranch(cwd, remote, taskBranch);
|
|
167
|
+
log.ok(`Deleted ${remote}/${taskBranch}`);
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
171
|
+
log.warn(`Could not delete remote ${taskBranch}: ${msg}`);
|
|
172
|
+
log.info(dim(`Delete manually: git push ${remote} --delete ${taskBranch}`));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else if (options.noRemoteDelete === true) {
|
|
176
|
+
log.info(dim("Remote branch delete skipped (--no-remote-delete)."));
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
log.info(dim(`No ${remote}/${taskBranch} — skipped remote delete.`));
|
|
180
|
+
}
|
|
181
|
+
log.blank();
|
|
182
|
+
log.info(`Next: ${cyan("vibeops task add")}`);
|
|
183
|
+
}
|
package/dist/lib/git.js
CHANGED
|
@@ -495,6 +495,13 @@ export async function gitFetch(cwd, remote, ref) {
|
|
|
495
495
|
args.push(ref);
|
|
496
496
|
await runGit(cwd, args);
|
|
497
497
|
}
|
|
498
|
+
/** Fetch all refs from `remote` and prune deleted remote-tracking branches. */
|
|
499
|
+
export async function gitFetchRemote(cwd, remote) {
|
|
500
|
+
await runGit(cwd, ["fetch", remote, "--prune"]);
|
|
501
|
+
}
|
|
502
|
+
export async function gitDeleteRemoteBranch(cwd, remote, branch) {
|
|
503
|
+
await runGit(cwd, ["push", remote, "--delete", branch]);
|
|
504
|
+
}
|
|
498
505
|
export async function gitPullFastForwardOnly(cwd, remote, branch) {
|
|
499
506
|
await runGit(cwd, ["pull", "--ff-only", remote, branch]);
|
|
500
507
|
}
|
package/dist/lib/paths.js
CHANGED
|
@@ -22,7 +22,7 @@ export function projectPaths(root) {
|
|
|
22
22
|
gitignore: join(abs, ".gitignore"),
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
/** Project memory files updated by `vibeops task
|
|
25
|
+
/** Project memory files updated by `vibeops task ship`. */
|
|
26
26
|
export const PROJECT_MEMORY_FILES = {
|
|
27
27
|
currentState: "docs/project/05-current-state.md",
|
|
28
28
|
architecture: "docs/project/03-architecture.md",
|
package/dist/lib/pr-create.js
CHANGED
|
@@ -64,3 +64,66 @@ export async function probeMergeRequestCli(host) {
|
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
function prRefFromUrl(url) {
|
|
68
|
+
const trimmed = url.trim();
|
|
69
|
+
const pullMatch = /\/pull\/(\d+)/i.exec(trimmed);
|
|
70
|
+
if (pullMatch)
|
|
71
|
+
return pullMatch[1];
|
|
72
|
+
const mrMatch = /\/merge_requests\/(\d+)/i.exec(trimmed);
|
|
73
|
+
if (mrMatch)
|
|
74
|
+
return mrMatch[1];
|
|
75
|
+
if (/^\d+$/.test(trimmed))
|
|
76
|
+
return trimmed;
|
|
77
|
+
return trimmed;
|
|
78
|
+
}
|
|
79
|
+
export async function getMergeRequestState(cwd, host, url) {
|
|
80
|
+
const ref = prRefFromUrl(url);
|
|
81
|
+
try {
|
|
82
|
+
if (host === "gitlab") {
|
|
83
|
+
const { stdout } = await execFileAsync("glab", ["mr", "view", ref, "--output", "json", "state"], { cwd, maxBuffer: 1024 * 1024 });
|
|
84
|
+
const state = stdout.trim().toLowerCase();
|
|
85
|
+
if (state === "merged")
|
|
86
|
+
return "merged";
|
|
87
|
+
if (state === "opened" || state === "open")
|
|
88
|
+
return "open";
|
|
89
|
+
if (state === "closed")
|
|
90
|
+
return "closed";
|
|
91
|
+
return "unknown";
|
|
92
|
+
}
|
|
93
|
+
const { stdout } = await execFileAsync("gh", ["pr", "view", ref, "--json", "state", "-q", ".state"], { cwd, maxBuffer: 1024 * 1024 });
|
|
94
|
+
const state = stdout.trim().toUpperCase();
|
|
95
|
+
if (state === "MERGED")
|
|
96
|
+
return "merged";
|
|
97
|
+
if (state === "OPEN")
|
|
98
|
+
return "open";
|
|
99
|
+
if (state === "CLOSED")
|
|
100
|
+
return "closed";
|
|
101
|
+
return "unknown";
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return "unknown";
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export async function mergeMergeRequest(opts) {
|
|
108
|
+
const ref = prRefFromUrl(opts.url);
|
|
109
|
+
const method = opts.method ?? "squash";
|
|
110
|
+
const label = mergeRequestLabel(opts.host);
|
|
111
|
+
if (opts.dryRun === true) {
|
|
112
|
+
if (opts.host === "gitlab") {
|
|
113
|
+
log.info(`would ${label} merge ${ref} (glab mr merge)`);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
log.info(`would gh pr merge ${ref} --${method}`);
|
|
117
|
+
}
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (opts.host === "gitlab") {
|
|
121
|
+
await execFileAsync("glab", ["mr", "merge", ref], {
|
|
122
|
+
cwd: opts.cwd,
|
|
123
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
124
|
+
});
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const args = ["pr", "merge", ref, `--${method}`];
|
|
128
|
+
await execFileAsync("gh", args, { cwd: opts.cwd, maxBuffer: 4 * 1024 * 1024 });
|
|
129
|
+
}
|
package/dist/lib/resolve-task.js
CHANGED
|
@@ -30,5 +30,5 @@ export function taskNotFoundMessage(taskRef) {
|
|
|
30
30
|
if (taskRef?.trim()) {
|
|
31
31
|
return `TASK not found: ${normalizeTaskRef(taskRef)}. Check docs/tasks/.`;
|
|
32
32
|
}
|
|
33
|
-
return "No open TASK found. Run `vibeops task add` or pass `vibeops task
|
|
33
|
+
return "No open TASK found. Run `vibeops task add` or pass `vibeops task ship TASK-NNN`.";
|
|
34
34
|
}
|
package/dist/lib/task-context.js
CHANGED
|
@@ -2,12 +2,15 @@ import { relative } from "node:path";
|
|
|
2
2
|
import { gitBranchExists, readGitInfo } from "./git.js";
|
|
3
3
|
import { readGitContext } from "./task.js";
|
|
4
4
|
import { isOnTaskBranch, loadActionableTasks, pickActiveTask, pickInProgressTask, } from "./task.js";
|
|
5
|
-
/** TASK that blocks `task add` — in progress or open on current task branch. */
|
|
5
|
+
/** TASK that blocks `task add` — in progress, in review, or open on current task branch. */
|
|
6
6
|
export async function findBlockingTask(paths, cwd) {
|
|
7
7
|
const tasks = await loadActionableTasks(paths.docsTasks);
|
|
8
8
|
const inProgress = pickInProgressTask(tasks);
|
|
9
9
|
if (inProgress !== null)
|
|
10
10
|
return inProgress;
|
|
11
|
+
const review = tasks.find((t) => t.status === "review");
|
|
12
|
+
if (review !== undefined)
|
|
13
|
+
return review;
|
|
11
14
|
const git = await readGitInfo(cwd);
|
|
12
15
|
if (git.isRepo && typeof git.branch === "string" && git.branch.startsWith("task/")) {
|
|
13
16
|
for (const t of tasks) {
|
|
@@ -32,12 +35,16 @@ export function computeNextHint(input) {
|
|
|
32
35
|
return "init";
|
|
33
36
|
if (input.focus === null)
|
|
34
37
|
return "task-add";
|
|
35
|
-
if (input.focus.status === "done")
|
|
36
|
-
return "task-add";
|
|
38
|
+
if (input.focus.status === "done") {
|
|
39
|
+
return input.onTaskBranch === true ? "task-sync" : "task-add";
|
|
40
|
+
}
|
|
41
|
+
if (input.focus.status === "review") {
|
|
42
|
+
return input.hasMergeRequest ? "task-merge" : "task-ship";
|
|
43
|
+
}
|
|
37
44
|
if (!input.resultFilled || !input.testFilled) {
|
|
38
45
|
return input.onTaskBranch === true ? "cursor-implement" : "cursor-plan";
|
|
39
46
|
}
|
|
40
|
-
return "task-
|
|
47
|
+
return input.hasMergeRequest ? "task-merge" : "task-ship";
|
|
41
48
|
}
|
|
42
49
|
export function hintToText(hint, cwd, task) {
|
|
43
50
|
switch (hint) {
|
|
@@ -45,15 +52,23 @@ export function hintToText(hint, cwd, task) {
|
|
|
45
52
|
return "Run `vibeops init` in this directory.";
|
|
46
53
|
case "task-add":
|
|
47
54
|
return "Run `vibeops task add` to start the next slice.";
|
|
48
|
-
case "task-
|
|
49
|
-
return task ? `Run \`vibeops task
|
|
55
|
+
case "task-ship":
|
|
56
|
+
return task ? `Run \`vibeops task ship ${task.id}\`.` : "Run `vibeops task ship`.";
|
|
57
|
+
case "task-merge":
|
|
58
|
+
return task
|
|
59
|
+
? `Run \`vibeops task merge ${task.id}\`, then task sync.`
|
|
60
|
+
: "Run `vibeops task merge` after the MR is ready.";
|
|
61
|
+
case "task-sync":
|
|
62
|
+
return task
|
|
63
|
+
? `MR merged? Run \`vibeops task sync ${task.id}\`, then task add.`
|
|
64
|
+
: "Run `vibeops task sync` after merging the MR.";
|
|
50
65
|
case "cursor-plan":
|
|
51
66
|
return task
|
|
52
67
|
? `In Cursor Ask: @${relPath(cwd, task.filePath)} — refine Scope / AC.`
|
|
53
68
|
: "Open the TASK file in Cursor Ask.";
|
|
54
69
|
case "cursor-implement":
|
|
55
70
|
return task
|
|
56
|
-
? `In Cursor Agent: @${relPath(cwd, task.filePath)} — implement, then task
|
|
71
|
+
? `In Cursor Agent: @${relPath(cwd, task.filePath)} — implement, then task ship.`
|
|
57
72
|
: "Implement per the TASK file in Cursor.";
|
|
58
73
|
}
|
|
59
74
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { dim, log } from "./logger.js";
|
|
2
|
+
import { gitAddPaths, gitPush, listWorkingTreeRelPaths, partitionPathsForAutoCommit, readGitInfo, runGit, } from "./git.js";
|
|
3
|
+
export function featCommitMessageFor(taskId, title) {
|
|
4
|
+
const slug = title.replace(/^TASK-\d+\s*[:\-]\s*/i, "").trim() || taskId;
|
|
5
|
+
return `feat(${taskId.toLowerCase()}): ${slug}`;
|
|
6
|
+
}
|
|
7
|
+
export function docsCommitMessageFor(taskId, suffix) {
|
|
8
|
+
return `docs(${taskId.toLowerCase()}): ${suffix}`;
|
|
9
|
+
}
|
|
10
|
+
/** Commit all committable dirty paths; returns whether a commit was created. */
|
|
11
|
+
export async function commitDirtyWorkingTree(cwd, message, dryRun) {
|
|
12
|
+
const git = await readGitInfo(cwd);
|
|
13
|
+
if (!git.isRepo || git.dirty !== true)
|
|
14
|
+
return false;
|
|
15
|
+
const { committable, excluded } = partitionPathsForAutoCommit(await listWorkingTreeRelPaths(cwd), { unmerged: [] });
|
|
16
|
+
if (committable.length === 0)
|
|
17
|
+
return false;
|
|
18
|
+
if (excluded.length > 0) {
|
|
19
|
+
log.warn(`Skipping ${excluded.length} build artifact path(s) from auto-commit.`);
|
|
20
|
+
}
|
|
21
|
+
if (dryRun) {
|
|
22
|
+
log.info(dim(` would commit ${committable.length} path(s): ${message}`));
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
await gitAddPaths(cwd, committable);
|
|
26
|
+
await runGit(cwd, ["commit", "-q", "-m", message]);
|
|
27
|
+
log.ok(`Committed: ${message}`);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
export async function pushBranch(cwd, remote, branch, setUpstream) {
|
|
31
|
+
await gitPush(cwd, remote, branch, setUpstream);
|
|
32
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { readGitInfo } from "./git.js";
|
|
2
|
+
import { isOnTaskBranch, loadActionableTasks, pickLatestReviewTask, readGitContext, } from "./task.js";
|
|
3
|
+
import { resolveTask } from "./resolve-task.js";
|
|
4
|
+
/** Resolve TASK + task branch for ship / merge / sync. */
|
|
5
|
+
export async function resolveLifecycleTarget(paths, cwd, taskRef) {
|
|
6
|
+
const trimmed = taskRef?.trim();
|
|
7
|
+
if (trimmed !== undefined && trimmed.length > 0) {
|
|
8
|
+
const resolved = await resolveTask(paths, cwd, trimmed);
|
|
9
|
+
if (resolved === null)
|
|
10
|
+
return null;
|
|
11
|
+
const ctx = await readGitContext(resolved.taskFile);
|
|
12
|
+
if (ctx === null)
|
|
13
|
+
return null;
|
|
14
|
+
return {
|
|
15
|
+
taskId: resolved.taskId,
|
|
16
|
+
taskBranch: ctx.taskBranch,
|
|
17
|
+
taskFile: resolved.taskFile,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const git = await readGitInfo(cwd);
|
|
21
|
+
if (git.isRepo && typeof git.branch === "string" && git.branch.startsWith("task/")) {
|
|
22
|
+
const tasks = await loadActionableTasks(paths.docsTasks);
|
|
23
|
+
for (const t of tasks) {
|
|
24
|
+
const ctx = await readGitContext(t.filePath);
|
|
25
|
+
if (isOnTaskBranch(git.branch, ctx)) {
|
|
26
|
+
return { taskId: t.id, taskBranch: git.branch, taskFile: t.filePath };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const review = pickLatestReviewTask(await loadActionableTasks(paths.docsTasks));
|
|
31
|
+
if (review === null)
|
|
32
|
+
return null;
|
|
33
|
+
const ctx = await readGitContext(review.filePath);
|
|
34
|
+
if (ctx === null)
|
|
35
|
+
return null;
|
|
36
|
+
return {
|
|
37
|
+
taskId: review.id,
|
|
38
|
+
taskBranch: ctx.taskBranch,
|
|
39
|
+
taskFile: review.filePath,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -45,7 +45,7 @@ ${draft.idea.trim()}
|
|
|
45
45
|
## Acceptance Criteria
|
|
46
46
|
|
|
47
47
|
1. Goal and Scope are met and verifiable via Test Plan.
|
|
48
|
-
2. Result and Test Result are filled before \`vibeops task
|
|
48
|
+
2. Result and Test Result are filled before \`vibeops task ship\`.
|
|
49
49
|
|
|
50
50
|
## Test Plan
|
|
51
51
|
|