@goodtek/vibeops 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/LICENSE +21 -0
- package/README.md +444 -0
- package/dist/agent/loader.js +71 -0
- package/dist/agent/prompt.js +66 -0
- package/dist/bootstrap/installer.js +149 -0
- package/dist/bootstrap/manifest.js +15 -0
- package/dist/bootstrap/substitute.js +35 -0
- package/dist/cli.js +241 -0
- package/dist/commands/agent-list.js +32 -0
- package/dist/commands/agent-prompt.js +59 -0
- package/dist/commands/agent-show.js +26 -0
- package/dist/commands/github-init.js +554 -0
- package/dist/commands/github-status.js +164 -0
- package/dist/commands/init.js +179 -0
- package/dist/commands/notion-init.js +764 -0
- package/dist/commands/notion-sync.js +405 -0
- package/dist/commands/notion-test.js +595 -0
- package/dist/commands/plan.js +114 -0
- package/dist/commands/status.js +17 -0
- package/dist/commands/task-check.js +155 -0
- package/dist/commands/task-done.js +98 -0
- package/dist/commands/task-generate.js +206 -0
- package/dist/commands/task-pull.js +277 -0
- package/dist/commands/task-rollback.js +174 -0
- package/dist/commands/task-start.js +90 -0
- package/dist/lib/brief.js +349 -0
- package/dist/lib/config.js +158 -0
- package/dist/lib/filesystem.js +67 -0
- package/dist/lib/git.js +237 -0
- package/dist/lib/github-cli.js +247 -0
- package/dist/lib/inquirer-helpers.js +111 -0
- package/dist/lib/logger.js +42 -0
- package/dist/lib/notion-client.js +459 -0
- package/dist/lib/notion-discovery.js +671 -0
- package/dist/lib/notion-env.js +140 -0
- package/dist/lib/notion-mappers.js +148 -0
- package/dist/lib/notion-schema.js +272 -0
- package/dist/lib/notion-sync.js +337 -0
- package/dist/lib/notion-target.js +247 -0
- package/dist/lib/package-json.js +133 -0
- package/dist/lib/paths.js +26 -0
- package/dist/lib/project-docs.js +95 -0
- package/dist/lib/prompt-builder.js +125 -0
- package/dist/lib/task-generator.js +183 -0
- package/dist/lib/task-prompt.js +23 -0
- package/dist/lib/task-pull.js +354 -0
- package/dist/lib/task-scaffold.js +128 -0
- package/dist/lib/task-summary.js +276 -0
- package/dist/lib/task.js +364 -0
- package/dist/status/collector.js +103 -0
- package/dist/status/format.js +177 -0
- package/dist/types/brief.js +126 -0
- package/dist/types/config.js +17 -0
- package/dist/types/task.js +1 -0
- package/dist/version.js +8 -0
- package/package.json +61 -0
- package/templates/.cursor/rules/00-project-governance.mdc +28 -0
- package/templates/.cursor/rules/01-agent-orchestration.mdc +48 -0
- package/templates/.cursor/rules/02-task-workflow.mdc +38 -0
- package/templates/.cursor/rules/03-git-safety.mdc +30 -0
- package/templates/.cursor/rules/04-docs-update.mdc +22 -0
- package/templates/.vibeops/agents/architect.md +47 -0
- package/templates/.vibeops/agents/builder.md +38 -0
- package/templates/.vibeops/agents/docs.md +54 -0
- package/templates/.vibeops/agents/orchestrator.md +40 -0
- package/templates/.vibeops/agents/planner.md +60 -0
- package/templates/.vibeops/agents/recovery.md +49 -0
- package/templates/.vibeops/agents/reviewer.md +47 -0
- package/templates/.vibeops/agents/tester.md +43 -0
- package/templates/.vibeops/prompts/create-plan.md +33 -0
- package/templates/.vibeops/prompts/generate-tasks.md +41 -0
- package/templates/.vibeops/prompts/implement-task.md +39 -0
- package/templates/.vibeops/prompts/review-task.md +34 -0
- package/templates/.vibeops/prompts/rollback.md +32 -0
- package/templates/.vibeops/prompts/start-project.md +39 -0
- package/templates/.vibeops/workflows/notion-sync.md +53 -0
- package/templates/.vibeops/workflows/project-start.md +73 -0
- package/templates/.vibeops/workflows/rollback.md +45 -0
- package/templates/.vibeops/workflows/task-lifecycle.md +71 -0
- package/templates/AGENTS.md +98 -0
- package/templates/docs/logs/README.md +38 -0
- package/templates/docs/project/00-overview.md +27 -0
- package/templates/docs/project/01-requirements.md +30 -0
- package/templates/docs/project/02-mvp-scope.md +36 -0
- package/templates/docs/project/03-architecture.md +34 -0
- package/templates/docs/project/04-tech-stack.md +29 -0
- package/templates/docs/project/05-current-state.md +35 -0
- package/templates/docs/project/06-decisions.md +20 -0
- package/templates/docs/project/07-backlog.md +23 -0
- package/templates/docs/project/08-env.md +29 -0
- package/templates/docs/project/09-deployment.md +28 -0
- package/templates/docs/tasks/TASK-000-template.md +72 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planning + execution helpers for `vibeops task pull`.
|
|
3
|
+
*
|
|
4
|
+
* Notion is queried for TASK rows whose Status matches `--status` (default
|
|
5
|
+
* "Planned"). For each row that does NOT yet have a local TASK file we plan
|
|
6
|
+
* a new `docs/tasks/TASK-NNN-slug.md` skeleton.
|
|
7
|
+
*
|
|
8
|
+
* Rules:
|
|
9
|
+
* - Never overwrite an existing local file.
|
|
10
|
+
* - Never write any TASK body section beyond the Notion-sourced metadata.
|
|
11
|
+
* - Always include a `## Notion Page` section so `notion sync` can later
|
|
12
|
+
* update the same row in place.
|
|
13
|
+
*
|
|
14
|
+
* Mutation surface:
|
|
15
|
+
* - `executePullEntry` writes the local file and (if Docs Path on Notion
|
|
16
|
+
* was empty) optionally updates the Notion page's Docs Path. Callers in
|
|
17
|
+
* dry-run mode MUST skip this.
|
|
18
|
+
*/
|
|
19
|
+
import { readdir } from "node:fs/promises";
|
|
20
|
+
import { basename, join, posix } from "node:path";
|
|
21
|
+
import { pathExists, writeText } from "./filesystem.js";
|
|
22
|
+
import { projectPaths } from "./paths.js";
|
|
23
|
+
import { formatTaskId, highestTaskNumber, } from "./task.js";
|
|
24
|
+
import { slugify } from "./task-generator.js";
|
|
25
|
+
import { readRichText, readSelect, readStatus, readTitle, richTextEqualsFilter, richTextProperty, statusEqualsFilter, andFilter, } from "./notion-mappers.js";
|
|
26
|
+
import { renderPulledTaskMarkdown, } from "./task-summary.js";
|
|
27
|
+
export function rowFromNotionPage(page) {
|
|
28
|
+
const p = page.properties;
|
|
29
|
+
return {
|
|
30
|
+
pageId: page.id,
|
|
31
|
+
taskId: readRichText(p["Task ID"]),
|
|
32
|
+
name: readTitle(p.Name),
|
|
33
|
+
status: readStatus(p.Status),
|
|
34
|
+
mvpPhase: readSelect(p["MVP Phase"]),
|
|
35
|
+
priority: readSelect(p.Priority),
|
|
36
|
+
summary: readRichText(p.Summary),
|
|
37
|
+
docsPath: readRichText(p["Docs Path"]),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const DEFAULT_STATUS_NAMES = ["Planned"];
|
|
41
|
+
const DEFAULT_LIMIT = 20;
|
|
42
|
+
const MAX_LIMIT = 100;
|
|
43
|
+
function buildPullFilter(projectId, statusNames) {
|
|
44
|
+
const statusFilters = statusNames.map((n) => statusEqualsFilter("Status", n));
|
|
45
|
+
const statusFilter = statusFilters.length === 1
|
|
46
|
+
? statusFilters[0]
|
|
47
|
+
: { or: statusFilters };
|
|
48
|
+
return andFilter([
|
|
49
|
+
richTextEqualsFilter("Project ID", projectId),
|
|
50
|
+
statusFilter,
|
|
51
|
+
]);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Notion `Docs Path` is **trusted only when its basename matches the TASK
|
|
55
|
+
* ID**. A row whose Task ID is `TASK-099` but whose Docs Path points at
|
|
56
|
+
* `docs/tasks/TASK-012-package-polish-readme.md` is a mismatch — surfacing
|
|
57
|
+
* it as `local-file-exists` silently shadows the real TASK-099 candidate.
|
|
58
|
+
*
|
|
59
|
+
* Acceptable basenames (case sensitive — Notion is case sensitive here):
|
|
60
|
+
* - `TASK-099.md`
|
|
61
|
+
* - `TASK-099-anything.md` (the standard `TASK-NNN-slug.md` form)
|
|
62
|
+
*
|
|
63
|
+
* Anything else is a mismatch.
|
|
64
|
+
*/
|
|
65
|
+
export function docsPathMatchesTaskId(docsRelativePath, taskId) {
|
|
66
|
+
if (docsRelativePath.length === 0 || taskId.length === 0)
|
|
67
|
+
return false;
|
|
68
|
+
const base = basename(docsRelativePath);
|
|
69
|
+
return base === `${taskId}.md` || base.startsWith(`${taskId}-`);
|
|
70
|
+
}
|
|
71
|
+
/** Scan `docs/tasks` for any file whose basename starts with `TASK-NNN`. */
|
|
72
|
+
async function findLocalTaskFileForId(docsTasksDir, taskId) {
|
|
73
|
+
let entries;
|
|
74
|
+
try {
|
|
75
|
+
entries = await readdir(docsTasksDir);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
for (const name of entries) {
|
|
81
|
+
if (name === `${taskId}.md` || name.startsWith(`${taskId}-`)) {
|
|
82
|
+
return join(docsTasksDir, name);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
export async function planPull(inputs) {
|
|
88
|
+
const statusNames = inputs.statusNames ?? DEFAULT_STATUS_NAMES;
|
|
89
|
+
const limit = Math.max(1, Math.min(inputs.limit ?? DEFAULT_LIMIT, MAX_LIMIT));
|
|
90
|
+
const res = await inputs.client.queryDataSource(inputs.tasksDataSourceId, {
|
|
91
|
+
filter: buildPullFilter(inputs.projectId, statusNames),
|
|
92
|
+
pageSize: limit,
|
|
93
|
+
});
|
|
94
|
+
const paths = projectPaths(inputs.cwd);
|
|
95
|
+
const startCounter = await highestTaskNumber(paths.docsTasks);
|
|
96
|
+
let nextNumber = startCounter + 1;
|
|
97
|
+
const entries = [];
|
|
98
|
+
const skipped = [];
|
|
99
|
+
const trace = [];
|
|
100
|
+
// First pass: detect duplicate Task IDs across the Notion query result so
|
|
101
|
+
// a second row with the same id cannot quietly create a second entry. We
|
|
102
|
+
// keep the first row and skip subsequent ones with `duplicate-task-id`.
|
|
103
|
+
const seenTaskIds = new Set();
|
|
104
|
+
const duplicatePageIds = new Set();
|
|
105
|
+
for (const page of res.results) {
|
|
106
|
+
const id = rowFromNotionPage(page).taskId.trim();
|
|
107
|
+
if (id.length === 0)
|
|
108
|
+
continue;
|
|
109
|
+
if (seenTaskIds.has(id)) {
|
|
110
|
+
duplicatePageIds.add(page.id);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
seenTaskIds.add(id);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
for (const page of res.results) {
|
|
117
|
+
const row = rowFromNotionPage(page);
|
|
118
|
+
const notionDocsPath = row.docsPath.trim();
|
|
119
|
+
// (A) Task ID required — guard against blank ids before we touch local fs.
|
|
120
|
+
const taskIdRaw = row.taskId.trim();
|
|
121
|
+
if (taskIdRaw.length === 0 && notionDocsPath.length === 0) {
|
|
122
|
+
// No Task ID and no Docs Path → allocate a fresh one, treated as a
|
|
123
|
+
// legitimate "new" candidate (existing behaviour). Trace it so
|
|
124
|
+
// `--verbose` makes the allocation visible.
|
|
125
|
+
const taskId = formatTaskId(nextNumber);
|
|
126
|
+
nextNumber++;
|
|
127
|
+
const slug = slugify(row.name.length > 0 ? row.name : taskId, taskId.toLowerCase());
|
|
128
|
+
const docsRelativePath = posix.join("docs/tasks", `${taskId}-${slug}.md`);
|
|
129
|
+
const absPath = join(paths.docsTasks, `${taskId}-${slug}.md`);
|
|
130
|
+
// Even an allocated id may already be present on disk (race / manual
|
|
131
|
+
// creation). Re-check.
|
|
132
|
+
if (await pathExists(absPath)) {
|
|
133
|
+
skipped.push({
|
|
134
|
+
pageId: page.id,
|
|
135
|
+
taskId,
|
|
136
|
+
reason: "local-file-exists",
|
|
137
|
+
docsRelativePath,
|
|
138
|
+
detail: `local resolved path: ${docsRelativePath}`,
|
|
139
|
+
});
|
|
140
|
+
trace.push({
|
|
141
|
+
taskId,
|
|
142
|
+
pageId: page.id,
|
|
143
|
+
notionDocsPath,
|
|
144
|
+
localResolvedPath: docsRelativePath,
|
|
145
|
+
decision: "skip-local-file-exists",
|
|
146
|
+
reason: "Task ID was empty, allocated next id already on disk",
|
|
147
|
+
});
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
entries.push({
|
|
151
|
+
pageId: page.id,
|
|
152
|
+
taskId,
|
|
153
|
+
title: row.name.length > 0 ? row.name : taskId,
|
|
154
|
+
status: row.status,
|
|
155
|
+
mvpPhase: row.mvpPhase,
|
|
156
|
+
summary: row.summary,
|
|
157
|
+
docsRelativePath,
|
|
158
|
+
absPath,
|
|
159
|
+
notionNeedsDocsPath: true,
|
|
160
|
+
detail: "allocated Task ID (Notion row had none)",
|
|
161
|
+
});
|
|
162
|
+
trace.push({
|
|
163
|
+
taskId,
|
|
164
|
+
pageId: page.id,
|
|
165
|
+
notionDocsPath: "",
|
|
166
|
+
localResolvedPath: docsRelativePath,
|
|
167
|
+
decision: "new-file",
|
|
168
|
+
reason: "Task ID empty → allocated; no local file with that id",
|
|
169
|
+
});
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (taskIdRaw.length === 0) {
|
|
173
|
+
// Has a Docs Path but no Task ID — refuse to act. Renaming pages from
|
|
174
|
+
// empty ids is risky and not in TASK-011 scope.
|
|
175
|
+
skipped.push({
|
|
176
|
+
pageId: page.id,
|
|
177
|
+
taskId: "(none)",
|
|
178
|
+
reason: "no-task-id",
|
|
179
|
+
docsRelativePath: notionDocsPath,
|
|
180
|
+
detail: `notion docs path: ${notionDocsPath}`,
|
|
181
|
+
});
|
|
182
|
+
trace.push({
|
|
183
|
+
taskId: "(none)",
|
|
184
|
+
pageId: page.id,
|
|
185
|
+
notionDocsPath,
|
|
186
|
+
localResolvedPath: notionDocsPath,
|
|
187
|
+
decision: "skip-no-task-id",
|
|
188
|
+
reason: "Notion row has Docs Path but no Task ID",
|
|
189
|
+
});
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
const taskId = taskIdRaw;
|
|
193
|
+
// (A.2) duplicate Task ID across the considered rows.
|
|
194
|
+
if (duplicatePageIds.has(page.id)) {
|
|
195
|
+
skipped.push({
|
|
196
|
+
pageId: page.id,
|
|
197
|
+
taskId,
|
|
198
|
+
reason: "duplicate-task-id",
|
|
199
|
+
docsRelativePath: notionDocsPath,
|
|
200
|
+
detail: `another Notion row already used this Task ID in the same query`,
|
|
201
|
+
});
|
|
202
|
+
trace.push({
|
|
203
|
+
taskId,
|
|
204
|
+
pageId: page.id,
|
|
205
|
+
notionDocsPath,
|
|
206
|
+
localResolvedPath: "",
|
|
207
|
+
decision: "skip-duplicate-task-id",
|
|
208
|
+
reason: "duplicate Task ID across considered rows — kept first row only",
|
|
209
|
+
});
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
// (B) Notion Docs Path exists but does NOT match this Task ID. Refuse
|
|
213
|
+
// to create / overwrite — surface a `docs-path-mismatch` so the user
|
|
214
|
+
// can fix Notion. We deliberately do NOT auto-rename — auto-fixing
|
|
215
|
+
// Notion's Docs Path on a mismatch is reserved for a future
|
|
216
|
+
// `--fix-docs-path` opt-in.
|
|
217
|
+
if (notionDocsPath.length > 0 &&
|
|
218
|
+
!docsPathMatchesTaskId(notionDocsPath, taskId)) {
|
|
219
|
+
skipped.push({
|
|
220
|
+
pageId: page.id,
|
|
221
|
+
taskId,
|
|
222
|
+
reason: "docs-path-mismatch",
|
|
223
|
+
docsRelativePath: notionDocsPath,
|
|
224
|
+
detail: `notion docs path: ${notionDocsPath}\n` +
|
|
225
|
+
`expected basename prefix: ${taskId}- or ${taskId}.md\n` +
|
|
226
|
+
`action: fix Notion 'Docs Path' for this row (auto-fix not enabled).`,
|
|
227
|
+
});
|
|
228
|
+
trace.push({
|
|
229
|
+
taskId,
|
|
230
|
+
pageId: page.id,
|
|
231
|
+
notionDocsPath,
|
|
232
|
+
localResolvedPath: notionDocsPath,
|
|
233
|
+
decision: "skip-docs-path-mismatch",
|
|
234
|
+
reason: `Notion Docs Path basename does not match ${taskId}- prefix`,
|
|
235
|
+
});
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
// (C) / (D) / (F) — resolve where the local file would live and check
|
|
239
|
+
// for existing files. If Notion gave us a matching Docs Path, honour
|
|
240
|
+
// it. Otherwise scan `docs/tasks` for any `TASK-NNN-*.md` already on
|
|
241
|
+
// disk; if found, treat the row as `local-file-exists`. If not, plan a
|
|
242
|
+
// new `TASK-NNN-slug.md`.
|
|
243
|
+
const slug = slugify(row.name.length > 0 ? row.name : taskId, taskId.toLowerCase());
|
|
244
|
+
let docsRelativePath;
|
|
245
|
+
let absPath;
|
|
246
|
+
let notionNeedsDocsPath;
|
|
247
|
+
let decisionDetail;
|
|
248
|
+
if (notionDocsPath.length > 0) {
|
|
249
|
+
docsRelativePath = notionDocsPath;
|
|
250
|
+
absPath = join(inputs.cwd, notionDocsPath);
|
|
251
|
+
notionNeedsDocsPath = false;
|
|
252
|
+
decisionDetail = `notion docs path: ${notionDocsPath}`;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
const existing = await findLocalTaskFileForId(paths.docsTasks, taskId);
|
|
256
|
+
if (existing !== null) {
|
|
257
|
+
const rel = posix.join("docs/tasks", basename(existing));
|
|
258
|
+
skipped.push({
|
|
259
|
+
pageId: page.id,
|
|
260
|
+
taskId,
|
|
261
|
+
reason: "local-file-exists",
|
|
262
|
+
docsRelativePath: rel,
|
|
263
|
+
detail: `local resolved path: ${rel}\n` +
|
|
264
|
+
`notion docs path: (empty)`,
|
|
265
|
+
});
|
|
266
|
+
trace.push({
|
|
267
|
+
taskId,
|
|
268
|
+
pageId: page.id,
|
|
269
|
+
notionDocsPath: "",
|
|
270
|
+
localResolvedPath: rel,
|
|
271
|
+
decision: "skip-local-file-exists",
|
|
272
|
+
reason: "Notion Docs Path empty, but a local file matching the Task ID was found on disk",
|
|
273
|
+
});
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
docsRelativePath = posix.join("docs/tasks", `${taskId}-${slug}.md`);
|
|
277
|
+
absPath = join(paths.docsTasks, `${taskId}-${slug}.md`);
|
|
278
|
+
notionNeedsDocsPath = true;
|
|
279
|
+
decisionDetail = `local resolved path: ${docsRelativePath}`;
|
|
280
|
+
}
|
|
281
|
+
if (await pathExists(absPath)) {
|
|
282
|
+
skipped.push({
|
|
283
|
+
pageId: page.id,
|
|
284
|
+
taskId,
|
|
285
|
+
reason: "local-file-exists",
|
|
286
|
+
docsRelativePath,
|
|
287
|
+
detail: decisionDetail,
|
|
288
|
+
});
|
|
289
|
+
trace.push({
|
|
290
|
+
taskId,
|
|
291
|
+
pageId: page.id,
|
|
292
|
+
notionDocsPath,
|
|
293
|
+
localResolvedPath: docsRelativePath,
|
|
294
|
+
decision: "skip-local-file-exists",
|
|
295
|
+
reason: notionDocsPath.length > 0
|
|
296
|
+
? "Notion Docs Path matched Task ID and file already exists on disk"
|
|
297
|
+
: "local search found a file matching the Task ID",
|
|
298
|
+
});
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
entries.push({
|
|
302
|
+
pageId: page.id,
|
|
303
|
+
taskId,
|
|
304
|
+
title: row.name.length > 0 ? row.name : taskId,
|
|
305
|
+
status: row.status,
|
|
306
|
+
mvpPhase: row.mvpPhase,
|
|
307
|
+
summary: row.summary,
|
|
308
|
+
docsRelativePath,
|
|
309
|
+
absPath,
|
|
310
|
+
notionNeedsDocsPath,
|
|
311
|
+
detail: decisionDetail,
|
|
312
|
+
});
|
|
313
|
+
trace.push({
|
|
314
|
+
taskId,
|
|
315
|
+
pageId: page.id,
|
|
316
|
+
notionDocsPath,
|
|
317
|
+
localResolvedPath: docsRelativePath,
|
|
318
|
+
decision: "new-file",
|
|
319
|
+
reason: notionDocsPath.length > 0
|
|
320
|
+
? "Notion Docs Path matched Task ID — local file does not exist yet"
|
|
321
|
+
: "Notion Docs Path empty — planning fresh local file under docs/tasks",
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
return { entries, skipped, considered: res.results.length, trace };
|
|
325
|
+
}
|
|
326
|
+
export async function executePullEntry(client, entry) {
|
|
327
|
+
const md = renderPulledTaskMarkdown({
|
|
328
|
+
taskId: entry.taskId,
|
|
329
|
+
title: entry.title,
|
|
330
|
+
status: entry.status,
|
|
331
|
+
mvpPhase: entry.mvpPhase,
|
|
332
|
+
summary: entry.summary,
|
|
333
|
+
pageId: entry.pageId,
|
|
334
|
+
docsRelativePath: entry.docsRelativePath,
|
|
335
|
+
});
|
|
336
|
+
await writeText(entry.absPath, md);
|
|
337
|
+
let notionUpdated = false;
|
|
338
|
+
if (entry.notionNeedsDocsPath) {
|
|
339
|
+
await client.updatePage({
|
|
340
|
+
pageId: entry.pageId,
|
|
341
|
+
properties: {
|
|
342
|
+
"Docs Path": richTextProperty(entry.docsRelativePath),
|
|
343
|
+
},
|
|
344
|
+
});
|
|
345
|
+
notionUpdated = true;
|
|
346
|
+
}
|
|
347
|
+
return {
|
|
348
|
+
taskId: entry.taskId,
|
|
349
|
+
pageId: entry.pageId,
|
|
350
|
+
absPath: entry.absPath,
|
|
351
|
+
docsRelativePath: entry.docsRelativePath,
|
|
352
|
+
notionUpdated,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { basename, join } from "node:path";
|
|
2
|
+
import { pathExists, writeText } from "./filesystem.js";
|
|
3
|
+
import { formatTaskId, highestTaskNumber } from "./task.js";
|
|
4
|
+
import { slugify } from "./task-generator.js";
|
|
5
|
+
export async function planScaffoldEntries(inputs) {
|
|
6
|
+
const startNumber = (await highestTaskNumber(inputs.tasksDir)) + 1;
|
|
7
|
+
const baseSlug = slugify(inputs.slug ?? "planned-task", "planned-task");
|
|
8
|
+
const baseTitle = inputs.title ?? "(scaffolded TASK — fill in)";
|
|
9
|
+
const phase = inputs.phase ?? "(unassigned)";
|
|
10
|
+
const entries = [];
|
|
11
|
+
let cursor = startNumber;
|
|
12
|
+
for (let i = 0; i < inputs.count; i++) {
|
|
13
|
+
// skip numbers whose file already exists on disk so users running scaffold
|
|
14
|
+
// twice in a row don't collide with previously generated skeletons.
|
|
15
|
+
let candidatePath = "";
|
|
16
|
+
let chosen = -1;
|
|
17
|
+
while (chosen < 0) {
|
|
18
|
+
const fileName = `${formatTaskId(cursor)}-${baseSlug}.md`;
|
|
19
|
+
const abs = join(inputs.tasksDir, fileName);
|
|
20
|
+
if (!(await pathExists(abs))) {
|
|
21
|
+
chosen = cursor;
|
|
22
|
+
candidatePath = abs;
|
|
23
|
+
}
|
|
24
|
+
cursor++;
|
|
25
|
+
}
|
|
26
|
+
entries.push({
|
|
27
|
+
id: formatTaskId(chosen),
|
|
28
|
+
number: chosen,
|
|
29
|
+
slug: baseSlug,
|
|
30
|
+
title: baseTitle,
|
|
31
|
+
fileName: basename(candidatePath),
|
|
32
|
+
absPath: candidatePath,
|
|
33
|
+
phase,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return { entries, startNumber };
|
|
37
|
+
}
|
|
38
|
+
export function renderScaffoldMarkdown(entry) {
|
|
39
|
+
return `# ${entry.id} · ${entry.title}
|
|
40
|
+
|
|
41
|
+
> This file is a skeleton produced by \`vibeops task generate --scaffold\`. \`vibeops task done\` will refuse to advance the task until every section is filled in.
|
|
42
|
+
|
|
43
|
+
## Status
|
|
44
|
+
|
|
45
|
+
planned
|
|
46
|
+
|
|
47
|
+
## MVP Phase
|
|
48
|
+
|
|
49
|
+
${entry.phase}
|
|
50
|
+
|
|
51
|
+
## Goal
|
|
52
|
+
|
|
53
|
+
(scaffold — describe in 2-4 sentences what becomes possible when this TASK ships.)
|
|
54
|
+
|
|
55
|
+
## Background
|
|
56
|
+
|
|
57
|
+
(scaffold — why now, which earlier TASKs or decisions this builds on.)
|
|
58
|
+
|
|
59
|
+
## Scope
|
|
60
|
+
|
|
61
|
+
- (scaffold — item 1)
|
|
62
|
+
- (scaffold — item 2)
|
|
63
|
+
|
|
64
|
+
## Out of Scope
|
|
65
|
+
|
|
66
|
+
- (scaffold — items intentionally excluded)
|
|
67
|
+
|
|
68
|
+
## Acceptance Criteria
|
|
69
|
+
|
|
70
|
+
1. (scaffold — verifiable statement 1)
|
|
71
|
+
2. (scaffold — verifiable statement 2)
|
|
72
|
+
|
|
73
|
+
## Files to Inspect First
|
|
74
|
+
|
|
75
|
+
- (scaffold)
|
|
76
|
+
|
|
77
|
+
## Expected Files to Change
|
|
78
|
+
|
|
79
|
+
- new: (scaffold)
|
|
80
|
+
- update: (scaffold)
|
|
81
|
+
|
|
82
|
+
## Risks
|
|
83
|
+
|
|
84
|
+
- (scaffold)
|
|
85
|
+
|
|
86
|
+
## Test Plan
|
|
87
|
+
|
|
88
|
+
- (scaffold)
|
|
89
|
+
|
|
90
|
+
## Rollback Plan
|
|
91
|
+
|
|
92
|
+
- (scaffold — branch deletion or another recovery flow)
|
|
93
|
+
|
|
94
|
+
## Git Context
|
|
95
|
+
|
|
96
|
+
(populated by \`vibeops task start ${entry.id}\`)
|
|
97
|
+
|
|
98
|
+
## Notion Page
|
|
99
|
+
|
|
100
|
+
(populated by \`vibeops notion sync\`)
|
|
101
|
+
|
|
102
|
+
## Implementation Plan
|
|
103
|
+
|
|
104
|
+
1. (scaffold)
|
|
105
|
+
|
|
106
|
+
## Result
|
|
107
|
+
|
|
108
|
+
(not yet)
|
|
109
|
+
|
|
110
|
+
## Test Result
|
|
111
|
+
|
|
112
|
+
(not yet)
|
|
113
|
+
|
|
114
|
+
## Review Notes
|
|
115
|
+
|
|
116
|
+
(not yet)
|
|
117
|
+
`;
|
|
118
|
+
}
|
|
119
|
+
export async function writeScaffoldFiles(plan) {
|
|
120
|
+
const written = [];
|
|
121
|
+
for (const entry of plan.entries) {
|
|
122
|
+
if (await pathExists(entry.absPath))
|
|
123
|
+
continue;
|
|
124
|
+
await writeText(entry.absPath, renderScaffoldMarkdown(entry));
|
|
125
|
+
written.push(entry.absPath);
|
|
126
|
+
}
|
|
127
|
+
return written;
|
|
128
|
+
}
|