@moritakaaz/markflow 0.1.0 → 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/README.md +3 -2
- package/package.json +1 -1
- package/src/discover.js +4 -0
- package/src/doctor.js +131 -13
- package/src/index.js +5 -2
- package/src/init.js +78 -36
- package/src/minimal.js +22 -0
- package/src/update.js +17 -3
- package/src/versions.js +2 -2
- package/templates/AGENTS.md +1 -0
- package/templates/markflow/.agents/PROMPTS.md +5 -1
- package/templates/markflow/.agents/workflows/onboarding.md +22 -0
- package/templates/markflow/docs/API.md +3 -3
- package/templates/markflow/docs/ARCHITECTURE.md +3 -3
- package/templates/markflow/docs/CODING_STANDARDS.md +5 -3
- package/templates/markflow/docs/DATA_MODEL.md +4 -4
- package/templates/markflow/docs/DEPLOY.md +3 -3
- package/templates/markflow/docs/GLOSSARY.md +7 -2
- package/templates/markflow/docs/MCP.md +2 -2
- package/templates/markflow/docs/PRD.md +5 -5
- package/templates/markflow/docs/STACK.md +2 -1
- package/templates/markflow/docs/TESTING.md +3 -3
- package/templates/markflow/docs/adr/001-initial-stack.md +2 -2
- package/templates/markflow/docs/adr/_template.md +5 -5
- package/templates/markflow/specs/_template.md +5 -5
- package/templates/markflow/specs/index.md +1 -0
- package/test/cli.test.js +297 -4
package/README.md
CHANGED
|
@@ -11,15 +11,16 @@ Run tests with npm test from this folder. Tests use temp dirs only. They never t
|
|
|
11
11
|
Install it with npx @moritakaaz/markflow init. Then run one of these commands. A command you do not know is rejected and creates no files.
|
|
12
12
|
|
|
13
13
|
- `markflow init` creates the docs layer in the current repo.
|
|
14
|
+
- `markflow init --minimal` creates only PRD, ARCHITECTURE, one spec, and TASKS, plus AGENTS.md and the markflow README. Doctor checks only those files in a minimal project. Run plain `markflow init` later to add the rest.
|
|
14
15
|
- `markflow init --agent claude` also creates CLAUDE.md. Use `--agent codex` for Codex, which reads AGENTS.md. Use `--agent cursor` for .cursor/rules/markflow.mdc. Use `--agent copilot` for .github/copilot-instructions.md.
|
|
15
16
|
- `markflow doctor` checks the docs layer for missing files, leftover placeholders, broken internal links, and specs missing from the index. It reports errors, warnings, and info. Only errors make it exit with 1.
|
|
16
|
-
- `markflow update` restores missing files and updates files the user did not change. It also protects AGENTS.md and agent files with the same hash check. Use `markflow update --preview` to see what would change without changing any file. The CLI, methodology, and template each have their own version. See src/versions.js for the methodology and template versions.
|
|
17
|
+
- `markflow update` restores missing files and updates files the user did not change. It also protects AGENTS.md and agent files with the same hash check. ARCHITECTURE.md and STACK.md belong to the user after init, so update restores them when missing but never changes their content. Use `markflow update --preview` to see what would change without changing any file. The CLI, methodology, and template each have their own version. See src/versions.js for the methodology and template versions.
|
|
17
18
|
- `markflow --help` shows the commands.
|
|
18
19
|
- `markflow --version` shows the CLI version.
|
|
19
20
|
|
|
20
21
|
Init reads a repo, then copies the base templates into it. It is non-interactive by default. It does not init a framework. It does not install app dependencies.
|
|
21
22
|
|
|
22
|
-
Use --agent to pick the agent file. The default is generic and creates AGENTS.md only. Use --agent claude to also create CLAUDE.md. Use --agent cursor to also create .
|
|
23
|
+
Use --agent to pick the agent file. The default is generic and creates AGENTS.md only. Use --agent claude to also create CLAUDE.md. Use --agent cursor to also create .cursor/rules/markflow.mdc.
|
|
23
24
|
|
|
24
25
|
Init also writes markflow/.markflow.json. That file holds the cli, methodology, and template versions used at init time.
|
|
25
26
|
|
package/package.json
CHANGED
package/src/discover.js
CHANGED
package/src/doctor.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
// It reports errors, warnings, and info.
|
|
3
3
|
// Errors fail the check. Warnings and info do not.
|
|
4
4
|
import { readdir, readFile, stat } from "node:fs/promises";
|
|
5
|
-
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
6
|
+
import { findTemplatesDir } from "./templates.js";
|
|
7
|
+
import { MINIMAL_REQUIRED } from "./minimal.js";
|
|
6
8
|
|
|
7
9
|
const REQUIRED = [
|
|
8
10
|
"AGENTS.md",
|
|
@@ -18,7 +20,7 @@ const REQUIRED = [
|
|
|
18
20
|
"markflow/.markflow.json",
|
|
19
21
|
];
|
|
20
22
|
|
|
21
|
-
const AGENT_FILES = ["CLAUDE.md", ".
|
|
23
|
+
const AGENT_FILES = ["CLAUDE.md", ".cursor/rules/markflow.mdc"];
|
|
22
24
|
|
|
23
25
|
async function walk(dir, out) {
|
|
24
26
|
let entries;
|
|
@@ -39,6 +41,73 @@ async function walk(dir, out) {
|
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
// First sentence of each fill-in instruction in the templates.
|
|
45
|
+
// The full lines live inside HTML comments in the templates.
|
|
46
|
+
// A doc that still shows one of these as visible text was not filled in.
|
|
47
|
+
const INSTRUCTIONS = [
|
|
48
|
+
"Write one short paragraph.",
|
|
49
|
+
"List the main users.",
|
|
50
|
+
"List the core features.",
|
|
51
|
+
"List what this project will not do.",
|
|
52
|
+
"Write how you will know this project works.",
|
|
53
|
+
"Write what discovery found.",
|
|
54
|
+
"Write where code lives.",
|
|
55
|
+
"Write how a request or a job moves through the system.",
|
|
56
|
+
"Add one row per library.",
|
|
57
|
+
"Add one entry per term.",
|
|
58
|
+
"Write what you test at each level.",
|
|
59
|
+
"Write the exact command to run tests.",
|
|
60
|
+
"List the edge cases that often break.",
|
|
61
|
+
"Write your naming pattern here.",
|
|
62
|
+
"Write your function format here.",
|
|
63
|
+
"Write the order of parts in a file here.",
|
|
64
|
+
"List the main entities.",
|
|
65
|
+
"Write how entities link to each other.",
|
|
66
|
+
"Write the rules for data.",
|
|
67
|
+
"Write how schema changes are made and tested.",
|
|
68
|
+
"Write how auth works.",
|
|
69
|
+
"List each endpoint with method, path, request, and response.",
|
|
70
|
+
"Write the shared rules.",
|
|
71
|
+
"Write the steps from main branch to production.",
|
|
72
|
+
"List the env vars that are required.",
|
|
73
|
+
"Write how to roll back a bad release.",
|
|
74
|
+
"Add one entry per server.",
|
|
75
|
+
"Write how the master config in `.agents/mcp.json` is copied to your AI tool.",
|
|
76
|
+
"Write what this feature must do in one or two sentences.",
|
|
77
|
+
"Write who uses this feature.",
|
|
78
|
+
"List what must be true when this feature is done.",
|
|
79
|
+
"List what this feature will not do.",
|
|
80
|
+
"Write how you will test this feature.",
|
|
81
|
+
"Write the decision in one sentence.",
|
|
82
|
+
"Write why this decision was needed.",
|
|
83
|
+
"List the options you considered.",
|
|
84
|
+
"Write what you picked and why.",
|
|
85
|
+
"Write Draft or Approved.",
|
|
86
|
+
"Write the picked stack and the main reason.",
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
// Remove HTML comments, so hidden instructions do not count as visible text.
|
|
90
|
+
function stripComments(text) {
|
|
91
|
+
return text.replace(/<!--[\s\S]*?-->/g, "");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Lines of one ## section, or null when the section is missing.
|
|
95
|
+
function sectionLines(text, heading) {
|
|
96
|
+
const lines = text.split("\n");
|
|
97
|
+
const start = lines.findIndex((line) => line.trim() === "## " + heading);
|
|
98
|
+
if (start === -1) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const out = [];
|
|
102
|
+
for (let i = start + 1; i < lines.length; i += 1) {
|
|
103
|
+
if (lines[i].startsWith("## ")) {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
out.push(lines[i]);
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
|
|
42
111
|
function findLinks(text) {
|
|
43
112
|
const links = [];
|
|
44
113
|
const re = /\[[^\]]*\]\(([^)\s]+)\)/g;
|
|
@@ -53,15 +122,6 @@ export async function runDoctor(options) {
|
|
|
53
122
|
const root = (options && options.target) || process.cwd();
|
|
54
123
|
const errors = [];
|
|
55
124
|
const warnings = [];
|
|
56
|
-
for (const file of REQUIRED) {
|
|
57
|
-
try {
|
|
58
|
-
await stat(join(root, file));
|
|
59
|
-
console.log("OK " + file);
|
|
60
|
-
} catch {
|
|
61
|
-
console.log("Error Missing " + file);
|
|
62
|
-
errors.push(file);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
125
|
let marker = null;
|
|
66
126
|
try {
|
|
67
127
|
marker = JSON.parse(
|
|
@@ -72,7 +132,18 @@ export async function runDoctor(options) {
|
|
|
72
132
|
errors.push("markflow/.markflow.json");
|
|
73
133
|
}
|
|
74
134
|
} catch {
|
|
75
|
-
// Missing marker is already reported
|
|
135
|
+
// Missing marker is already reported below.
|
|
136
|
+
}
|
|
137
|
+
const required =
|
|
138
|
+
marker && marker.minimal === true ? MINIMAL_REQUIRED : REQUIRED;
|
|
139
|
+
for (const file of required) {
|
|
140
|
+
try {
|
|
141
|
+
await stat(join(root, file));
|
|
142
|
+
console.log("OK " + file);
|
|
143
|
+
} catch {
|
|
144
|
+
console.log("Error Missing " + file);
|
|
145
|
+
errors.push(file);
|
|
146
|
+
}
|
|
76
147
|
}
|
|
77
148
|
if (marker && marker.files) {
|
|
78
149
|
for (const rel of Object.keys(marker.files)) {
|
|
@@ -103,6 +174,14 @@ export async function runDoctor(options) {
|
|
|
103
174
|
console.log("Error Placeholder left in " + rel);
|
|
104
175
|
errors.push(rel);
|
|
105
176
|
}
|
|
177
|
+
const visible = stripComments(text);
|
|
178
|
+
for (const phrase of INSTRUCTIONS) {
|
|
179
|
+
if (visible.includes(phrase)) {
|
|
180
|
+
console.log("Warning Instruction text left in " + rel);
|
|
181
|
+
warnings.push(rel);
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
106
185
|
tbd += text.split("TBD").length - 1;
|
|
107
186
|
for (const link of findLinks(text)) {
|
|
108
187
|
if (
|
|
@@ -125,6 +204,26 @@ export async function runDoctor(options) {
|
|
|
125
204
|
}
|
|
126
205
|
}
|
|
127
206
|
}
|
|
207
|
+
try {
|
|
208
|
+
const templatesDir = await findTemplatesDir();
|
|
209
|
+
const projectName =
|
|
210
|
+
(marker && marker.project) || basename(root);
|
|
211
|
+
const prdTemplate = (
|
|
212
|
+
await readFile(join(templatesDir, "markflow/docs/PRD.md"), "utf8")
|
|
213
|
+
)
|
|
214
|
+
.split("{{project_name}}")
|
|
215
|
+
.join(projectName);
|
|
216
|
+
const prdText = await readFile(
|
|
217
|
+
join(root, "markflow/docs/PRD.md"),
|
|
218
|
+
"utf8"
|
|
219
|
+
);
|
|
220
|
+
if (prdText === prdTemplate) {
|
|
221
|
+
console.log("Warning PRD is still the template markflow/docs/PRD.md");
|
|
222
|
+
warnings.push("markflow/docs/PRD.md");
|
|
223
|
+
}
|
|
224
|
+
} catch {
|
|
225
|
+
// Template or PRD is missing, so skip this check.
|
|
226
|
+
}
|
|
128
227
|
let specTotal = 0;
|
|
129
228
|
let specDraft = 0;
|
|
130
229
|
try {
|
|
@@ -141,14 +240,33 @@ export async function runDoctor(options) {
|
|
|
141
240
|
}
|
|
142
241
|
specTotal += 1;
|
|
143
242
|
const text = await readFile(file, "utf8");
|
|
243
|
+
const rel = file.slice(root.length + 1);
|
|
144
244
|
if (text.includes("Status") && text.includes("Draft")) {
|
|
145
245
|
specDraft += 1;
|
|
146
246
|
}
|
|
147
247
|
if (!indexText.includes(name)) {
|
|
148
|
-
const rel = file.slice(root.length + 1);
|
|
149
248
|
console.log("Warning Spec not listed in index " + rel);
|
|
150
249
|
warnings.push(rel);
|
|
151
250
|
}
|
|
251
|
+
const acceptance = sectionLines(text, "Acceptance");
|
|
252
|
+
if (acceptance !== null) {
|
|
253
|
+
const cases = stripComments(acceptance.join("\n"))
|
|
254
|
+
.split("\n")
|
|
255
|
+
.filter((line) => line.trim() !== "");
|
|
256
|
+
if (cases.length === 0) {
|
|
257
|
+
console.log("Warning Empty acceptance in " + rel);
|
|
258
|
+
warnings.push(rel);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
const status = sectionLines(text, "Status");
|
|
262
|
+
if (
|
|
263
|
+
status !== null &&
|
|
264
|
+
status.some((line) => line.trim() === "Approved") &&
|
|
265
|
+
text.includes("TBD")
|
|
266
|
+
) {
|
|
267
|
+
console.log("Warning Approved spec still has TBD in " + rel);
|
|
268
|
+
warnings.push(rel);
|
|
269
|
+
}
|
|
152
270
|
}
|
|
153
271
|
} catch {
|
|
154
272
|
// Missing specs folder is already reported above.
|
package/src/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { runUpdate } from "./update.js";
|
|
|
9
9
|
|
|
10
10
|
const HELP = [
|
|
11
11
|
"Usage",
|
|
12
|
-
" markflow init [--agent generic|claude|codex|cursor|copilot]",
|
|
12
|
+
" markflow init [--agent generic|claude|codex|cursor|copilot] [--minimal]",
|
|
13
13
|
" markflow doctor",
|
|
14
14
|
" markflow update [--preview]",
|
|
15
15
|
" markflow --help",
|
|
@@ -49,7 +49,10 @@ if (args.length === 0) {
|
|
|
49
49
|
const result = await runUpdate({ preview: args.includes("--preview") });
|
|
50
50
|
process.exitCode = result.ok ? 0 : 1;
|
|
51
51
|
} else if (args[0] === "init") {
|
|
52
|
-
const result = await runInit({
|
|
52
|
+
const result = await runInit({
|
|
53
|
+
agent: parseAgent(args.slice(1)),
|
|
54
|
+
minimal: args.includes("--minimal"),
|
|
55
|
+
});
|
|
53
56
|
process.exitCode = result.ok === false ? 1 : 0;
|
|
54
57
|
} else {
|
|
55
58
|
console.log("Unknown command " + args[0] + ".");
|
package/src/init.js
CHANGED
|
@@ -9,16 +9,46 @@ import { hashText } from "./hash.js";
|
|
|
9
9
|
import { AGENTS } from "./agents.js";
|
|
10
10
|
import { findTemplatesDir } from "./templates.js";
|
|
11
11
|
import { METHODOLOGY_VERSION, TEMPLATE_VERSION } from "./versions.js";
|
|
12
|
+
import { MINIMAL_FILES } from "./minimal.js";
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
// True when any minimal file lives under this dir.
|
|
15
|
+
function underFilter(filter, dirRel) {
|
|
16
|
+
if (!filter) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
const prefix = "markflow/" + dirRel + "/";
|
|
20
|
+
for (const file of filter) {
|
|
21
|
+
if (file.startsWith(prefix)) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function copyDir(src, dest, projectName, base, createdPaths, filter) {
|
|
14
29
|
let created = 0;
|
|
15
30
|
const entries = await readdir(src, { withFileTypes: true });
|
|
16
31
|
for (const entry of entries) {
|
|
17
32
|
const srcPath = join(src, entry.name);
|
|
18
33
|
const destPath = join(dest, entry.name);
|
|
19
34
|
if (entry.isDirectory()) {
|
|
35
|
+
const dirRel = destPath.slice(base.length + 1);
|
|
36
|
+
if (!underFilter(filter, dirRel)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
20
39
|
await mkdir(destPath, { recursive: true });
|
|
21
|
-
created += await copyDir(
|
|
40
|
+
created += await copyDir(
|
|
41
|
+
srcPath,
|
|
42
|
+
destPath,
|
|
43
|
+
projectName,
|
|
44
|
+
base,
|
|
45
|
+
createdPaths,
|
|
46
|
+
filter
|
|
47
|
+
);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const rel = destPath.slice(base.length + 1);
|
|
51
|
+
if (filter && !filter.has("markflow/" + rel)) {
|
|
22
52
|
continue;
|
|
23
53
|
}
|
|
24
54
|
try {
|
|
@@ -31,17 +61,44 @@ async function copyDir(src, dest, projectName) {
|
|
|
31
61
|
const replaced = text.split("{{project_name}}").join(projectName);
|
|
32
62
|
await mkdir(dirname(destPath), { recursive: true });
|
|
33
63
|
await writeFile(destPath, replaced);
|
|
64
|
+
createdPaths.push(rel);
|
|
34
65
|
created += 1;
|
|
35
66
|
}
|
|
36
67
|
return created;
|
|
37
68
|
}
|
|
38
69
|
|
|
70
|
+
// Fill the ARCHITECTURE.md template with discovery results.
|
|
71
|
+
// Throws when the template lines are gone, so a template
|
|
72
|
+
// change fails loudly instead of silently skipping the fill.
|
|
73
|
+
export function fillArchitecture(text, context) {
|
|
74
|
+
if (
|
|
75
|
+
!text.includes("- Language. TBD") ||
|
|
76
|
+
!text.includes("- Framework. TBD")
|
|
77
|
+
) {
|
|
78
|
+
throw new Error("ARCHITECTURE.md template changed, fill failed.");
|
|
79
|
+
}
|
|
80
|
+
const names = context.stacks.map((s) => s.name).join(", ");
|
|
81
|
+
const evidence = context.stacks
|
|
82
|
+
.map((s) => s.evidence + " (" + s.confidence + ")")
|
|
83
|
+
.join(", ");
|
|
84
|
+
return text
|
|
85
|
+
.replace("- Language. TBD", "- Language. " + names)
|
|
86
|
+
.replace(
|
|
87
|
+
"- Framework. TBD",
|
|
88
|
+
"- Framework. TBD\n- Evidence. " +
|
|
89
|
+
evidence +
|
|
90
|
+
"\n- Monorepo. " +
|
|
91
|
+
(context.monorepo ? "Yes" : "No")
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
39
95
|
export async function runInit(options) {
|
|
40
96
|
const agent = options.agent || "generic";
|
|
41
97
|
if (!(agent in AGENTS)) {
|
|
42
98
|
console.log("Unknown agent.");
|
|
43
99
|
return { agent, copied: 0, ok: false };
|
|
44
100
|
}
|
|
101
|
+
const minimal = options.minimal === true;
|
|
45
102
|
const target = options.target || process.cwd();
|
|
46
103
|
const context = await discover(target);
|
|
47
104
|
const srcDir = dirname(fileURLToPath(import.meta.url));
|
|
@@ -60,30 +117,21 @@ export async function runInit(options) {
|
|
|
60
117
|
const stackPath = join(markflowDest, "docs/STACK.md");
|
|
61
118
|
const archExisted = await exists(archPath);
|
|
62
119
|
const stackExisted = await exists(stackPath);
|
|
120
|
+
const createdPaths = [];
|
|
63
121
|
const created = await copyDir(
|
|
64
122
|
join(templatesDir, "markflow"),
|
|
65
123
|
markflowDest,
|
|
66
|
-
context.projectName
|
|
124
|
+
context.projectName,
|
|
125
|
+
markflowDest,
|
|
126
|
+
createdPaths,
|
|
127
|
+
minimal ? new Set(MINIMAL_FILES) : null
|
|
67
128
|
);
|
|
68
129
|
if (context.stacks.length > 0) {
|
|
69
|
-
const names = context.stacks.map((s) => s.name).join(", ");
|
|
70
|
-
const evidence = context.stacks
|
|
71
|
-
.map((s) => s.evidence + " (" + s.confidence + ")")
|
|
72
|
-
.join(", ");
|
|
73
130
|
if (!archExisted) {
|
|
74
131
|
const arch = await readFile(archPath, "utf8");
|
|
75
|
-
|
|
76
|
-
.replace("- Language. TBD", "- Language. " + names)
|
|
77
|
-
.replace(
|
|
78
|
-
"- Framework. TBD",
|
|
79
|
-
"- Framework. TBD\n- Evidence. " +
|
|
80
|
-
evidence +
|
|
81
|
-
"\n- Monorepo. " +
|
|
82
|
-
(context.monorepo ? "Yes" : "No")
|
|
83
|
-
);
|
|
84
|
-
await writeFile(archPath, filled);
|
|
132
|
+
await writeFile(archPath, fillArchitecture(arch, context));
|
|
85
133
|
}
|
|
86
|
-
if (!stackExisted) {
|
|
134
|
+
if (!stackExisted && (await exists(stackPath))) {
|
|
87
135
|
const stack = await readFile(stackPath, "utf8");
|
|
88
136
|
const lines = context.stacks.map(
|
|
89
137
|
(s) => "- " + s.name + " from " + s.evidence + ", confidence " + s.confidence
|
|
@@ -152,35 +200,29 @@ export async function runInit(options) {
|
|
|
152
200
|
}
|
|
153
201
|
}
|
|
154
202
|
marker.agent = marker.agent || agent;
|
|
203
|
+
marker.minimal = minimal;
|
|
155
204
|
marker.discovery = {
|
|
156
205
|
mode: context.mode,
|
|
157
206
|
stacks: context.stacks,
|
|
158
207
|
manifests: context.manifests,
|
|
159
208
|
monorepo: context.monorepo,
|
|
160
209
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
if (entry.name === ".markflow.json") {
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
const rel = full.slice(markflowDest.length + 1);
|
|
173
|
-
if (!(rel in marker.files)) {
|
|
174
|
-
marker.files[rel] = hashText(await readFile(full, "utf8"));
|
|
175
|
-
}
|
|
176
|
-
}
|
|
210
|
+
// Record hashes only for files this run created.
|
|
211
|
+
// A file the user wrote before init stays untracked,
|
|
212
|
+
// so update never treats it as a template file.
|
|
213
|
+
for (const rel of createdPaths) {
|
|
214
|
+
marker.files[rel] = hashText(
|
|
215
|
+
await readFile(join(markflowDest, rel), "utf8")
|
|
216
|
+
);
|
|
177
217
|
}
|
|
178
|
-
await collectHashes(markflowDest);
|
|
179
218
|
await writeFile(markerPath, JSON.stringify(marker, null, 2) + "\n");
|
|
219
|
+
let nextStep;
|
|
180
220
|
if (created > 0) {
|
|
181
221
|
console.log("Created markflow folder.");
|
|
222
|
+
nextStep = "Open your AI tool and say: start onboarding.";
|
|
223
|
+
console.log("Next step. " + nextStep);
|
|
182
224
|
} else {
|
|
183
225
|
console.log("markflow folder already exists.");
|
|
184
226
|
}
|
|
185
|
-
return { ...context, agent, copied: created };
|
|
227
|
+
return { ...context, agent, copied: created, nextStep, minimal };
|
|
186
228
|
}
|
package/src/minimal.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Files init --minimal creates. Everything else stays out.
|
|
2
|
+
// Paths are relative to the project root.
|
|
3
|
+
export const MINIMAL_FILES = [
|
|
4
|
+
"AGENTS.md",
|
|
5
|
+
"markflow/README.md",
|
|
6
|
+
"markflow/TASKS.md",
|
|
7
|
+
"markflow/docs/PRD.md",
|
|
8
|
+
"markflow/docs/ARCHITECTURE.md",
|
|
9
|
+
"markflow/specs/index.md",
|
|
10
|
+
"markflow/specs/_template.md",
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
// Files doctor checks in a minimal project.
|
|
14
|
+
export const MINIMAL_REQUIRED = [
|
|
15
|
+
"AGENTS.md",
|
|
16
|
+
"markflow/README.md",
|
|
17
|
+
"markflow/TASKS.md",
|
|
18
|
+
"markflow/docs/PRD.md",
|
|
19
|
+
"markflow/docs/ARCHITECTURE.md",
|
|
20
|
+
"markflow/specs/index.md",
|
|
21
|
+
"markflow/.markflow.json",
|
|
22
|
+
];
|
package/src/update.js
CHANGED
|
@@ -8,6 +8,7 @@ import { hashText } from "./hash.js";
|
|
|
8
8
|
import { AGENTS } from "./agents.js";
|
|
9
9
|
import { findTemplatesDir } from "./templates.js";
|
|
10
10
|
import { METHODOLOGY_VERSION, TEMPLATE_VERSION } from "./versions.js";
|
|
11
|
+
import { MINIMAL_FILES } from "./minimal.js";
|
|
11
12
|
|
|
12
13
|
async function listFiles(dir, base, out) {
|
|
13
14
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
@@ -21,6 +22,10 @@ async function listFiles(dir, base, out) {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
// Files init fills from discovery. After init they belong to the user.
|
|
26
|
+
// Update restores them when missing but never changes their content.
|
|
27
|
+
const USER_OWNED = new Set(["docs/ARCHITECTURE.md", "docs/STACK.md"]);
|
|
28
|
+
|
|
24
29
|
export async function runUpdate(options) {
|
|
25
30
|
const preview = options && options.preview;
|
|
26
31
|
const target = (options && options.target) || process.cwd();
|
|
@@ -42,13 +47,17 @@ export async function runUpdate(options) {
|
|
|
42
47
|
const rels = [];
|
|
43
48
|
await listFiles(join(templatesDir, "markflow"), join(templatesDir, "markflow"), rels);
|
|
44
49
|
const templateSet = new Set(rels);
|
|
50
|
+
const syncRels =
|
|
51
|
+
marker.minimal === true
|
|
52
|
+
? rels.filter((rel) => MINIMAL_FILES.includes("markflow/" + rel))
|
|
53
|
+
: rels;
|
|
45
54
|
let updated = 0;
|
|
46
55
|
let restored = 0;
|
|
47
56
|
let skipped = 0;
|
|
48
57
|
let kept = 0;
|
|
49
58
|
const files = { ...stored };
|
|
50
59
|
const rootFiles = { ...storedRoot };
|
|
51
|
-
async function sync(rel, dest, templateText, storedMap, newMap) {
|
|
60
|
+
async function sync(rel, dest, templateText, storedMap, newMap, userOwned) {
|
|
52
61
|
const templateHash = hashText(templateText);
|
|
53
62
|
let current = null;
|
|
54
63
|
try {
|
|
@@ -63,6 +72,11 @@ export async function runUpdate(options) {
|
|
|
63
72
|
newMap[rel] = templateHash;
|
|
64
73
|
return;
|
|
65
74
|
}
|
|
75
|
+
if (userOwned) {
|
|
76
|
+
console.log("Skipped " + rel + ", user owned.");
|
|
77
|
+
skipped += 1;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
66
80
|
if (storedMap[rel] && hashText(current) === storedMap[rel]) {
|
|
67
81
|
if (templateHash !== storedMap[rel]) {
|
|
68
82
|
console.log((preview ? "Would update " : "Updated ") + rel);
|
|
@@ -77,11 +91,11 @@ export async function runUpdate(options) {
|
|
|
77
91
|
console.log("Skipped " + rel + ", modified.");
|
|
78
92
|
skipped += 1;
|
|
79
93
|
}
|
|
80
|
-
for (const rel of
|
|
94
|
+
for (const rel of syncRels) {
|
|
81
95
|
const templateText = (await readFile(join(templatesDir, "markflow", rel), "utf8"))
|
|
82
96
|
.split("{{project_name}}")
|
|
83
97
|
.join(projectName);
|
|
84
|
-
await sync(rel, join(target, "markflow", rel), templateText, stored, files);
|
|
98
|
+
await sync(rel, join(target, "markflow", rel), templateText, stored, files, USER_OWNED.has(rel));
|
|
85
99
|
}
|
|
86
100
|
for (const rel of Object.keys(stored)) {
|
|
87
101
|
if (!templateSet.has(rel)) {
|
package/src/versions.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
// Bump methodology when the docs in docs change.
|
|
3
3
|
// Bump template when the files in templates change.
|
|
4
4
|
// The CLI version comes from package.json.
|
|
5
|
-
export const METHODOLOGY_VERSION = "0.
|
|
6
|
-
export const TEMPLATE_VERSION = "0.
|
|
5
|
+
export const METHODOLOGY_VERSION = "0.2.0";
|
|
6
|
+
export const TEMPLATE_VERSION = "0.2.0";
|
package/templates/AGENTS.md
CHANGED
|
@@ -18,6 +18,7 @@ Start with these files in order.
|
|
|
18
18
|
- Code is in English. Docs are in English for this template. Change the doc language in `markflow/docs/PRD.md` when the project needs another language.
|
|
19
19
|
- All code lives in the source folder found during discovery. Tests live in the test folder found during discovery. Do not create new top level folders for code.
|
|
20
20
|
- Specs in `markflow/specs` are the source for intent and requirements. If code differs from a spec, stop and check both. Do not assume the spec is always right.
|
|
21
|
+
- Every claim in a doc comes from one of three places. What the user said. What the code shows. Or TBD. Never invent a decision or an architecture detail.
|
|
21
22
|
- All links inside `markflow` must be relative to that folder. Do not use absolute paths from the root.
|
|
22
23
|
|
|
23
24
|
## If you are human and you do not use AI
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
# PROMPTS.md
|
|
2
2
|
|
|
3
3
|
Purpose. This file holds standard prompts for {{project_name}}.
|
|
4
|
-
Read when. You need a prompt for review, refactor, or a new feature.
|
|
4
|
+
Read when. You need a prompt for onboarding, review, refactor, or a new feature.
|
|
5
5
|
Do not read when. You already have a prompt that works. Use it.
|
|
6
6
|
|
|
7
|
+
## Onboarding
|
|
8
|
+
|
|
9
|
+
Interview me one question at a time. Start with the problem and the users. Then write PRD.md and ARCHITECTURE.md from my answers and from the code. Mark what you do not know as TBD and list the open questions at the end.
|
|
10
|
+
|
|
7
11
|
## Code review
|
|
8
12
|
|
|
9
13
|
Review the change against the spec and CODING_STANDARDS.md. List what breaks the spec. List what breaks the standards. Do not praise without reason.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Onboarding
|
|
2
|
+
|
|
3
|
+
Purpose. This file is the SOP to interview a new user and fill the first docs.
|
|
4
|
+
Read when. A project just got Markflow and the PRD is still the template.
|
|
5
|
+
Do not read when. The PRD is already filled. Use the other workflows instead.
|
|
6
|
+
|
|
7
|
+
## Steps
|
|
8
|
+
|
|
9
|
+
1. Ask one question at a time. Wait for the answer before you ask the next one.
|
|
10
|
+
2. Start with the problem. What hurts today, and for whom.
|
|
11
|
+
3. Ask who uses the product. Ask what each user must be able to do.
|
|
12
|
+
4. Ask what the product must not do.
|
|
13
|
+
5. Read the code to learn the stack and the layout. Use only what the code shows.
|
|
14
|
+
6. Write PRD.md from the answers. Write ARCHITECTURE.md from the answers and from the code.
|
|
15
|
+
7. Mark anything you do not know as TBD. Never invent a decision or an architecture detail.
|
|
16
|
+
8. End with a list of open questions. The user answers them to clear the TBD marks.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
|
|
20
|
+
- One question per message. No lists of questions.
|
|
21
|
+
- Every claim in PRD.md and ARCHITECTURE.md comes from the user, from the code, or is TBD.
|
|
22
|
+
- Do not write code in this workflow. Docs first. Code starts after the first spec is approved.
|
|
@@ -6,11 +6,11 @@ Do not read when. You work on code that does not touch the API.
|
|
|
6
6
|
|
|
7
7
|
## Auth
|
|
8
8
|
|
|
9
|
-
Write how auth works. If there is no auth yet, write TBD.
|
|
9
|
+
<!-- Write how auth works. If there is no auth yet, write TBD. -->
|
|
10
10
|
|
|
11
11
|
## Endpoints
|
|
12
12
|
|
|
13
|
-
List each endpoint with method, path, request, and response. Keep each entry short.
|
|
13
|
+
<!-- List each endpoint with method, path, request, and response. Keep each entry short. -->
|
|
14
14
|
|
|
15
15
|
### TBD
|
|
16
16
|
|
|
@@ -21,4 +21,4 @@ List each endpoint with method, path, request, and response. Keep each entry sho
|
|
|
21
21
|
|
|
22
22
|
## Rules
|
|
23
23
|
|
|
24
|
-
Write the shared rules. Examples are error format and pagination. Do not repeat one endpoint detail here.
|
|
24
|
+
<!-- Write the shared rules. Examples are error format and pagination. Do not repeat one endpoint detail here. -->
|
|
@@ -6,7 +6,7 @@ Do not read when. You need one feature detail. Open its spec instead.
|
|
|
6
6
|
|
|
7
7
|
## Detected stack
|
|
8
8
|
|
|
9
|
-
Write what discovery found. If discovery found nothing yet, write TBD.
|
|
9
|
+
<!-- Write what discovery found. If discovery found nothing yet, write TBD. -->
|
|
10
10
|
|
|
11
11
|
- Language. TBD
|
|
12
12
|
- Framework. TBD
|
|
@@ -14,11 +14,11 @@ Write what discovery found. If discovery found nothing yet, write TBD.
|
|
|
14
14
|
|
|
15
15
|
## Layout
|
|
16
16
|
|
|
17
|
-
Write where code lives. Write where tests live. Do not invent folders that do not exist yet. Mark planned folders as planned.
|
|
17
|
+
<!-- Write where code lives. Write where tests live. Do not invent folders that do not exist yet. Mark planned folders as planned. -->
|
|
18
18
|
|
|
19
19
|
## Flow
|
|
20
20
|
|
|
21
|
-
Write how a request or a job moves through the system. Use short steps. Keep it to five steps or less when you can.
|
|
21
|
+
<!-- Write how a request or a job moves through the system. Use short steps. Keep it to five steps or less when you can. -->
|
|
22
22
|
|
|
23
23
|
1. TBD
|
|
24
24
|
2. TBD
|
|
@@ -11,7 +11,7 @@ Docs use English for this template. Change the doc language in PRD when the proj
|
|
|
11
11
|
|
|
12
12
|
## 2. Naming
|
|
13
13
|
|
|
14
|
-
Write your naming pattern here. Decide the case for files, functions, and constants. Then follow it everywhere.
|
|
14
|
+
<!-- Write your naming pattern here. Decide the case for files, functions, and constants. Then follow it everywhere. -->
|
|
15
15
|
|
|
16
16
|
- Files. TBD
|
|
17
17
|
- Functions. TBD
|
|
@@ -19,7 +19,9 @@ Write your naming pattern here. Decide the case for files, functions, and consta
|
|
|
19
19
|
|
|
20
20
|
## 3. Function format
|
|
21
21
|
|
|
22
|
-
Write your function format here. Decide how long a function can be and how many tasks it should do.
|
|
22
|
+
<!-- Write your function format here. Decide how long a function can be and how many tasks it should do. -->
|
|
23
|
+
|
|
24
|
+
One function should do one task.
|
|
23
25
|
|
|
24
26
|
## 4. Comments
|
|
25
27
|
|
|
@@ -27,7 +29,7 @@ Write a comment only when logic is hard to follow without it. Use simple comment
|
|
|
27
29
|
|
|
28
30
|
## 5. File structure
|
|
29
31
|
|
|
30
|
-
Write the order of parts in a file here. Decide what comes first, imports or constants or the main function. Then follow it.
|
|
32
|
+
<!-- Write the order of parts in a file here. Decide what comes first, imports or constants or the main function. Then follow it. -->
|
|
31
33
|
|
|
32
34
|
## 6. What to avoid
|
|
33
35
|
|
|
@@ -6,18 +6,18 @@ Do not read when. You only change UI text. That does not touch data.
|
|
|
6
6
|
|
|
7
7
|
## Entities
|
|
8
8
|
|
|
9
|
-
List the main entities. One line per entity. Say what it holds.
|
|
9
|
+
<!-- List the main entities. One line per entity. Say what it holds. -->
|
|
10
10
|
|
|
11
11
|
- TBD
|
|
12
12
|
|
|
13
13
|
## Relations
|
|
14
14
|
|
|
15
|
-
Write how entities link to each other. Use plain words. Avoid jargon when you can.
|
|
15
|
+
<!-- Write how entities link to each other. Use plain words. Avoid jargon when you can. -->
|
|
16
16
|
|
|
17
17
|
## Rules
|
|
18
18
|
|
|
19
|
-
Write the rules for data. Examples are what must stay unique and what must never be deleted. Mark rules you are unsure about as TBD.
|
|
19
|
+
<!-- Write the rules for data. Examples are what must stay unique and what must never be deleted. Mark rules you are unsure about as TBD. -->
|
|
20
20
|
|
|
21
21
|
## Migrations
|
|
22
22
|
|
|
23
|
-
Write how schema changes are made and tested. Keep it short.
|
|
23
|
+
<!-- Write how schema changes are made and tested. Keep it short. -->
|
|
@@ -6,7 +6,7 @@ Do not read when. You only change local code. That does not need deploy notes.
|
|
|
6
6
|
|
|
7
7
|
## Release flow
|
|
8
8
|
|
|
9
|
-
Write the steps from main branch to production. Keep each step to one line.
|
|
9
|
+
<!-- Write the steps from main branch to production. Keep each step to one line. -->
|
|
10
10
|
|
|
11
11
|
1. TBD
|
|
12
12
|
2. TBD
|
|
@@ -14,10 +14,10 @@ Write the steps from main branch to production. Keep each step to one line.
|
|
|
14
14
|
|
|
15
15
|
## Env vars
|
|
16
16
|
|
|
17
|
-
List the env vars that are required. Do not write real secrets here. Write example values only. Real values live in local env files.
|
|
17
|
+
<!-- List the env vars that are required. Do not write real secrets here. Write example values only. Real values live in local env files. -->
|
|
18
18
|
|
|
19
19
|
- TBD
|
|
20
20
|
|
|
21
21
|
## Rollback
|
|
22
22
|
|
|
23
|
-
Write how to roll back a bad release. Keep it short.
|
|
23
|
+
<!-- Write how to roll back a bad release. Keep it short. -->
|
|
@@ -6,6 +6,11 @@ Do not read when. You already know the term. Skip it.
|
|
|
6
6
|
|
|
7
7
|
## Terms
|
|
8
8
|
|
|
9
|
-
Add one entry per term. Keep each definition to one or two sentences.
|
|
9
|
+
<!-- Add one entry per term. Keep each definition to one or two sentences. -->
|
|
10
10
|
|
|
11
|
-
-
|
|
11
|
+
- PRD. A product requirements document. It says what the product is for, who uses it, and what it must do. It does not say how to build it.
|
|
12
|
+
- Spec. A specification for one piece of work. It lists the goal, the scope, the steps, and the acceptance cases that prove the work is done. Code starts only after a spec is approved.
|
|
13
|
+
- Task. One small unit of work from TASKS.md. A task belongs to a spec or to a fix that is too small for a spec.
|
|
14
|
+
- Architecture. The layout of the system. It names the stack, the main parts, and how they connect. It also records the evidence for each choice.
|
|
15
|
+
- TBD. To be decided. A mark for something unknown. Never guess a TBD. Ask a human or check the code, then replace the mark with the answer.
|
|
16
|
+
- Evidence. Proof from the repo. A file, a test result, or a line of code that shows a claim is true. A claim without evidence is a guess.
|
|
@@ -6,13 +6,13 @@ Do not read when. You work without AI. MCP is optional for humans.
|
|
|
6
6
|
|
|
7
7
|
## Servers
|
|
8
8
|
|
|
9
|
-
Add one entry per server. Say what it is for and what env it needs.
|
|
9
|
+
<!-- Add one entry per server. Say what it is for and what env it needs. -->
|
|
10
10
|
|
|
11
11
|
- TBD. Purpose. TBD. Env needed. TBD.
|
|
12
12
|
|
|
13
13
|
## Setup
|
|
14
14
|
|
|
15
|
-
Write how the master config in `.agents/mcp.json` is copied to your AI tool. Do not put API keys in that file. Use env vars. List the env names in DEPLOY.md, not the real values.
|
|
15
|
+
<!-- Write how the master config in `.agents/mcp.json` is copied to your AI tool. Do not put API keys in that file. Use env vars. List the env names in DEPLOY.md, not the real values. -->
|
|
16
16
|
|
|
17
17
|
## Rules
|
|
18
18
|
|
|
@@ -6,24 +6,24 @@ Do not read when. You need code detail. Open a spec in `specs` instead.
|
|
|
6
6
|
|
|
7
7
|
## Vision
|
|
8
8
|
|
|
9
|
-
Write one short paragraph. What problem does this project solve. Who has that problem today.
|
|
9
|
+
<!-- Write one short paragraph. What problem does this project solve. Who has that problem today. -->
|
|
10
10
|
|
|
11
11
|
## Users
|
|
12
12
|
|
|
13
|
-
List the main users. Write one line per user type. Say what each type needs most.
|
|
13
|
+
<!-- List the main users. Write one line per user type. Say what each type needs most. -->
|
|
14
14
|
|
|
15
15
|
## Features
|
|
16
16
|
|
|
17
|
-
List the core features. Keep each item to one line for now. Detail goes in a spec later.
|
|
17
|
+
<!-- List the core features. Keep each item to one line for now. Detail goes in a spec later. -->
|
|
18
18
|
|
|
19
19
|
- TBD
|
|
20
20
|
|
|
21
21
|
## Out of scope
|
|
22
22
|
|
|
23
|
-
List what this project will not do. This stops scope creep early.
|
|
23
|
+
<!-- List what this project will not do. This stops scope creep early. -->
|
|
24
24
|
|
|
25
25
|
- TBD
|
|
26
26
|
|
|
27
27
|
## Success
|
|
28
28
|
|
|
29
|
-
Write how you will know this project works. Use plain words. Avoid numbers you cannot check.
|
|
29
|
+
<!-- Write how you will know this project works. Use plain words. Avoid numbers you cannot check. -->
|
|
@@ -6,9 +6,10 @@ Do not read when. You only fix a bug in existing code. That does not change the
|
|
|
6
6
|
|
|
7
7
|
## Libraries
|
|
8
8
|
|
|
9
|
-
Add one row per library. Keep the reason short.
|
|
9
|
+
<!-- Add one row per library. Keep the reason short. -->
|
|
10
10
|
|
|
11
11
|
| Need | Library | MCP server | Reason |
|
|
12
|
+
|---|---|---|---|
|
|
12
13
|
| Auth | TBD | TBD | TBD |
|
|
13
14
|
| Database | TBD | TBD | TBD |
|
|
14
15
|
| UI | TBD | TBD | TBD |
|
|
@@ -6,7 +6,7 @@ Do not read when. You only edit docs. Docs do not need tests.
|
|
|
6
6
|
|
|
7
7
|
## Levels
|
|
8
8
|
|
|
9
|
-
Write what you test at each level. Keep it short.
|
|
9
|
+
<!-- Write what you test at each level. Keep it short. -->
|
|
10
10
|
|
|
11
11
|
- Unit. TBD
|
|
12
12
|
- Integration. TBD
|
|
@@ -14,11 +14,11 @@ Write what you test at each level. Keep it short.
|
|
|
14
14
|
|
|
15
15
|
## How to run tests
|
|
16
16
|
|
|
17
|
-
Write the exact command to run tests. Write what a pass looks like.
|
|
17
|
+
<!-- Write the exact command to run tests. Write what a pass looks like. -->
|
|
18
18
|
|
|
19
19
|
## Edge cases
|
|
20
20
|
|
|
21
|
-
List the edge cases that often break. Add new ones when you find them.
|
|
21
|
+
<!-- List the edge cases that often break. Add new ones when you find them. -->
|
|
22
22
|
|
|
23
23
|
- TBD
|
|
24
24
|
|
|
@@ -10,7 +10,7 @@ The initial stack is TBD. Discovery will fill this in during init.
|
|
|
10
10
|
|
|
11
11
|
## Context
|
|
12
12
|
|
|
13
|
-
Write what discovery found. List the manifest files that proved the stack.
|
|
13
|
+
<!-- Write what discovery found. List the manifest files that proved the stack. -->
|
|
14
14
|
|
|
15
15
|
## Options considered
|
|
16
16
|
|
|
@@ -18,7 +18,7 @@ Write what discovery found. List the manifest files that proved the stack.
|
|
|
18
18
|
|
|
19
19
|
## Outcome
|
|
20
20
|
|
|
21
|
-
Write the picked stack and the main reason. Mark anything unsure as TBD.
|
|
21
|
+
<!-- Write the picked stack and the main reason. Mark anything unsure as TBD. -->
|
|
22
22
|
|
|
23
23
|
## Status
|
|
24
24
|
|
|
@@ -6,22 +6,22 @@ Do not read when. You only fix a small bug. That does not need an ADR.
|
|
|
6
6
|
|
|
7
7
|
## Decision
|
|
8
8
|
|
|
9
|
-
Write the decision in one sentence.
|
|
9
|
+
<!-- Write the decision in one sentence. -->
|
|
10
10
|
|
|
11
11
|
## Context
|
|
12
12
|
|
|
13
|
-
Write why this decision was needed. Keep it short.
|
|
13
|
+
<!-- Write why this decision was needed. Keep it short. -->
|
|
14
14
|
|
|
15
15
|
## Options considered
|
|
16
16
|
|
|
17
|
-
List the options you considered. One line per option.
|
|
17
|
+
<!-- List the options you considered. One line per option. -->
|
|
18
18
|
|
|
19
19
|
- TBD
|
|
20
20
|
|
|
21
21
|
## Outcome
|
|
22
22
|
|
|
23
|
-
Write what you picked and why. Write what you gave up.
|
|
23
|
+
<!-- Write what you picked and why. Write what you gave up. -->
|
|
24
24
|
|
|
25
25
|
## Status
|
|
26
26
|
|
|
27
|
-
Write Draft or Approved.
|
|
27
|
+
<!-- Write Draft or Approved. -->
|
|
@@ -6,27 +6,27 @@ Do not read when. You implement a spec that already exists. Open that spec inste
|
|
|
6
6
|
|
|
7
7
|
## Goal
|
|
8
8
|
|
|
9
|
-
Write what this feature must do in one or two sentences.
|
|
9
|
+
<!-- Write what this feature must do in one or two sentences. -->
|
|
10
10
|
|
|
11
11
|
## Users
|
|
12
12
|
|
|
13
|
-
Write who uses this feature.
|
|
13
|
+
<!-- Write who uses this feature. -->
|
|
14
14
|
|
|
15
15
|
## Requirements
|
|
16
16
|
|
|
17
|
-
List what must be true when this feature is done. Use plain words. Each item must be checkable.
|
|
17
|
+
<!-- List what must be true when this feature is done. Use plain words. Each item must be checkable. -->
|
|
18
18
|
|
|
19
19
|
- [ ] TBD
|
|
20
20
|
|
|
21
21
|
## Out of scope
|
|
22
22
|
|
|
23
|
-
List what this feature will not do.
|
|
23
|
+
<!-- List what this feature will not do. -->
|
|
24
24
|
|
|
25
25
|
- TBD
|
|
26
26
|
|
|
27
27
|
## Acceptance
|
|
28
28
|
|
|
29
|
-
Write how you will test this feature. List the main cases.
|
|
29
|
+
<!-- Write how you will test this feature. List the main cases. -->
|
|
30
30
|
|
|
31
31
|
## Status
|
|
32
32
|
|
package/test/cli.test.js
CHANGED
|
@@ -10,7 +10,7 @@ import { dirname, join } from "node:path";
|
|
|
10
10
|
import { fileURLToPath } from "node:url";
|
|
11
11
|
import { discover } from "../src/discover.js";
|
|
12
12
|
import { runDoctor } from "../src/doctor.js";
|
|
13
|
-
import { runInit } from "../src/init.js";
|
|
13
|
+
import { fillArchitecture, runInit } from "../src/init.js";
|
|
14
14
|
import { runUpdate } from "../src/update.js";
|
|
15
15
|
|
|
16
16
|
const CLI = join(dirname(fileURLToPath(import.meta.url)), "../src/index.js");
|
|
@@ -81,6 +81,20 @@ describe("discover", () => {
|
|
|
81
81
|
assert.equal(result.workspace.detected, true);
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
+
it("skips venv, target, and .next dirs", async (t) => {
|
|
85
|
+
const dir = await tempDir(t);
|
|
86
|
+
await write(dir, "package.json", "{}");
|
|
87
|
+
await write(dir, "venv/requirements.txt", "");
|
|
88
|
+
await write(dir, "target/Cargo.toml", "");
|
|
89
|
+
await write(dir, ".next/package.json", "{}");
|
|
90
|
+
const result = await discover(dir);
|
|
91
|
+
assert.deepEqual(
|
|
92
|
+
result.stacks.map((s) => s.name),
|
|
93
|
+
["JavaScript"]
|
|
94
|
+
);
|
|
95
|
+
assert.deepEqual(result.manifests, ["package.json"]);
|
|
96
|
+
});
|
|
97
|
+
|
|
84
98
|
it("records test and CI configs", async (t) => {
|
|
85
99
|
const dir = await tempDir(t);
|
|
86
100
|
await write(dir, "vitest.config.ts", "");
|
|
@@ -139,6 +153,78 @@ describe("init", () => {
|
|
|
139
153
|
assert.ok(text.includes("STACK.md"));
|
|
140
154
|
});
|
|
141
155
|
|
|
156
|
+
it("fillArchitecture fills language and evidence", () => {
|
|
157
|
+
const filled = fillArchitecture("- Language. TBD\n- Framework. TBD\n", {
|
|
158
|
+
stacks: [{ name: "Go", evidence: "go.mod", confidence: "high" }],
|
|
159
|
+
monorepo: false,
|
|
160
|
+
});
|
|
161
|
+
assert.ok(filled.includes("- Language. Go"));
|
|
162
|
+
assert.ok(filled.includes("- Evidence. go.mod (high)"));
|
|
163
|
+
assert.ok(filled.includes("- Monorepo. No"));
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("fillArchitecture throws when template lines are missing", () => {
|
|
167
|
+
assert.throws(
|
|
168
|
+
() =>
|
|
169
|
+
fillArchitecture("# ARCHITECTURE\n\nNo lines here.\n", {
|
|
170
|
+
stacks: [{ name: "Go", evidence: "go.mod", confidence: "high" }],
|
|
171
|
+
monorepo: false,
|
|
172
|
+
}),
|
|
173
|
+
/template changed/
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("minimal init creates only the minimal files", async (t) => {
|
|
178
|
+
const dir = await tempDir(t);
|
|
179
|
+
const result = await runInit({ target: dir, minimal: true });
|
|
180
|
+
assert.equal(result.minimal, true);
|
|
181
|
+
for (const file of [
|
|
182
|
+
"AGENTS.md",
|
|
183
|
+
"markflow/README.md",
|
|
184
|
+
"markflow/TASKS.md",
|
|
185
|
+
"markflow/docs/PRD.md",
|
|
186
|
+
"markflow/docs/ARCHITECTURE.md",
|
|
187
|
+
"markflow/specs/index.md",
|
|
188
|
+
"markflow/specs/_template.md",
|
|
189
|
+
]) {
|
|
190
|
+
await readFile(join(dir, file), "utf8");
|
|
191
|
+
}
|
|
192
|
+
for (const file of [
|
|
193
|
+
"markflow/docs/STACK.md",
|
|
194
|
+
"markflow/docs/CODING_STANDARDS.md",
|
|
195
|
+
"markflow/CHANGELOG.md",
|
|
196
|
+
]) {
|
|
197
|
+
await assert.rejects(readFile(join(dir, file), "utf8"));
|
|
198
|
+
}
|
|
199
|
+
const marker = JSON.parse(
|
|
200
|
+
await readFile(join(dir, "markflow/.markflow.json"), "utf8")
|
|
201
|
+
);
|
|
202
|
+
assert.equal(marker.minimal, true);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it("full init upgrades a minimal project", async (t) => {
|
|
206
|
+
const dir = await tempDir(t);
|
|
207
|
+
await runInit({ target: dir, minimal: true });
|
|
208
|
+
const result = await runInit({ target: dir });
|
|
209
|
+
assert.equal(result.minimal, false);
|
|
210
|
+
await readFile(join(dir, "markflow/docs/STACK.md"), "utf8");
|
|
211
|
+
const marker = JSON.parse(
|
|
212
|
+
await readFile(join(dir, "markflow/.markflow.json"), "utf8")
|
|
213
|
+
);
|
|
214
|
+
assert.equal(marker.minimal, false);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("init suggests onboarding on first run only", async (t) => {
|
|
218
|
+
const dir = await tempDir(t);
|
|
219
|
+
const first = await runInit({ target: dir });
|
|
220
|
+
assert.equal(
|
|
221
|
+
first.nextStep,
|
|
222
|
+
"Open your AI tool and say: start onboarding."
|
|
223
|
+
);
|
|
224
|
+
const second = await runInit({ target: dir });
|
|
225
|
+
assert.equal(second.nextStep, undefined);
|
|
226
|
+
});
|
|
227
|
+
|
|
142
228
|
it("unknown agent fails and creates no files", async (t) => {
|
|
143
229
|
const dir = await tempDir(t);
|
|
144
230
|
const result = await runInit({ target: dir, agent: "bogus" });
|
|
@@ -169,7 +255,116 @@ describe("doctor", () => {
|
|
|
169
255
|
await write(dir, "markflow/specs/99-new.md", "# Spec\n\nStatus\n\nDraft\n");
|
|
170
256
|
const result = await runDoctor({ target: dir });
|
|
171
257
|
assert.equal(result.ok, true);
|
|
172
|
-
assert.
|
|
258
|
+
assert.ok(result.warnings.some((w) => w.includes("99-new.md")));
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it("warns on empty acceptance in a spec", async (t) => {
|
|
262
|
+
const dir = await tempDir(t);
|
|
263
|
+
await runInit({ target: dir });
|
|
264
|
+
await write(
|
|
265
|
+
dir,
|
|
266
|
+
"markflow/specs/01-test.md",
|
|
267
|
+
"# Test spec\n\n## Goal\n\nDo a thing.\n\n## Acceptance\n\nWrite how you will test this feature. List the main cases.\n\n## Status\n\nDraft\n"
|
|
268
|
+
);
|
|
269
|
+
const index = await readFile(
|
|
270
|
+
join(dir, "markflow/specs/index.md"),
|
|
271
|
+
"utf8"
|
|
272
|
+
);
|
|
273
|
+
await write(dir, "markflow/specs/index.md", index + "\n01-test.md\n");
|
|
274
|
+
const result = await runDoctor({ target: dir });
|
|
275
|
+
assert.equal(result.ok, true);
|
|
276
|
+
assert.ok(
|
|
277
|
+
result.warnings.some((w) => w.includes("01-test.md"))
|
|
278
|
+
);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it("warns on approved spec with TBD", async (t) => {
|
|
282
|
+
const dir = await tempDir(t);
|
|
283
|
+
await runInit({ target: dir });
|
|
284
|
+
await write(
|
|
285
|
+
dir,
|
|
286
|
+
"markflow/specs/01-test.md",
|
|
287
|
+
"# Test spec\n\n## Goal\n\nDo a thing with TBD parts.\n\n## Acceptance\n\n- The thing works.\n\n## Status\n\nApproved\n"
|
|
288
|
+
);
|
|
289
|
+
const index = await readFile(
|
|
290
|
+
join(dir, "markflow/specs/index.md"),
|
|
291
|
+
"utf8"
|
|
292
|
+
);
|
|
293
|
+
await write(dir, "markflow/specs/index.md", index + "\n01-test.md\n");
|
|
294
|
+
const result = await runDoctor({ target: dir });
|
|
295
|
+
assert.equal(result.ok, true);
|
|
296
|
+
assert.ok(
|
|
297
|
+
result.warnings.some((w) => w.includes("01-test.md"))
|
|
298
|
+
);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
it("warns when PRD is still the template", async (t) => {
|
|
302
|
+
const dir = await tempDir(t);
|
|
303
|
+
await runInit({ target: dir });
|
|
304
|
+
const result = await runDoctor({ target: dir });
|
|
305
|
+
assert.equal(result.ok, true);
|
|
306
|
+
assert.ok(result.warnings.includes("markflow/docs/PRD.md"));
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
it("warns when instruction text is left visible", async (t) => {
|
|
310
|
+
const dir = await tempDir(t);
|
|
311
|
+
await runInit({ target: dir });
|
|
312
|
+
await write(
|
|
313
|
+
dir,
|
|
314
|
+
"markflow/docs/PRD.md",
|
|
315
|
+
"Our product.\n\nWrite one short paragraph. About the problem.\n"
|
|
316
|
+
);
|
|
317
|
+
const result = await runDoctor({ target: dir });
|
|
318
|
+
assert.equal(result.ok, true);
|
|
319
|
+
assert.ok(result.warnings.includes("markflow/docs/PRD.md"));
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it("hidden instructions do not warn", async (t) => {
|
|
323
|
+
const dir = await tempDir(t);
|
|
324
|
+
await runInit({ target: dir });
|
|
325
|
+
const result = await runDoctor({ target: dir });
|
|
326
|
+
assert.equal(result.ok, true);
|
|
327
|
+
assert.equal(
|
|
328
|
+
result.warnings.filter((w) => w === "markflow/docs/PRD.md").length,
|
|
329
|
+
1
|
|
330
|
+
);
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it("template spec still warns on empty acceptance", async (t) => {
|
|
334
|
+
const dir = await tempDir(t);
|
|
335
|
+
await runInit({ target: dir });
|
|
336
|
+
await write(
|
|
337
|
+
dir,
|
|
338
|
+
"markflow/specs/01-test.md",
|
|
339
|
+
"# Test spec\n\n## Goal\n\n<!-- Write what this feature must do in one or two sentences. -->\n\n- [ ] TBD\n\n## Acceptance\n\n<!-- Write how you will test this feature. List the main cases. -->\n\n## Status\n\nDraft\n"
|
|
340
|
+
);
|
|
341
|
+
const index = await readFile(
|
|
342
|
+
join(dir, "markflow/specs/index.md"),
|
|
343
|
+
"utf8"
|
|
344
|
+
);
|
|
345
|
+
await write(dir, "markflow/specs/index.md", index + "\n01-test.md\n");
|
|
346
|
+
const result = await runDoctor({ target: dir });
|
|
347
|
+
assert.equal(result.ok, true);
|
|
348
|
+
assert.ok(
|
|
349
|
+
result.warnings.some((w) => w.includes("01-test.md"))
|
|
350
|
+
);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it("doctor passes on a minimal project", async (t) => {
|
|
354
|
+
const dir = await tempDir(t);
|
|
355
|
+
await runInit({ target: dir, minimal: true });
|
|
356
|
+
const result = await runDoctor({ target: dir });
|
|
357
|
+
assert.equal(result.ok, true);
|
|
358
|
+
assert.equal(result.errors.length, 0);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
it("no PRD warning when PRD is filled", async (t) => {
|
|
362
|
+
const dir = await tempDir(t);
|
|
363
|
+
await runInit({ target: dir });
|
|
364
|
+
await write(dir, "markflow/docs/PRD.md", "Our own product.\n");
|
|
365
|
+
const result = await runDoctor({ target: dir });
|
|
366
|
+
assert.equal(result.ok, true);
|
|
367
|
+
assert.ok(!result.warnings.includes("markflow/docs/PRD.md"));
|
|
173
368
|
});
|
|
174
369
|
|
|
175
370
|
it("placeholder in AGENTS.md fails", async (t) => {
|
|
@@ -179,9 +374,84 @@ describe("doctor", () => {
|
|
|
179
374
|
const result = await runDoctor({ target: dir });
|
|
180
375
|
assert.equal(result.ok, false);
|
|
181
376
|
});
|
|
377
|
+
|
|
378
|
+
it("placeholder in cursor file fails", async (t) => {
|
|
379
|
+
const dir = await tempDir(t);
|
|
380
|
+
await runInit({ target: dir, agent: "cursor" });
|
|
381
|
+
await write(dir, ".cursor/rules/markflow.mdc", "{{project_name}}\n");
|
|
382
|
+
const result = await runDoctor({ target: dir });
|
|
383
|
+
assert.equal(result.ok, false);
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
it("old cursorrules file is no longer checked", async (t) => {
|
|
387
|
+
const dir = await tempDir(t);
|
|
388
|
+
await runInit({ target: dir });
|
|
389
|
+
await write(dir, ".cursorrules", "{{project_name}}\n");
|
|
390
|
+
const result = await runDoctor({ target: dir });
|
|
391
|
+
assert.equal(result.ok, true);
|
|
392
|
+
});
|
|
182
393
|
});
|
|
183
394
|
|
|
184
395
|
describe("update", () => {
|
|
396
|
+
it("keeps a file the user wrote before init", async (t) => {
|
|
397
|
+
const dir = await tempDir(t);
|
|
398
|
+
await write(dir, "markflow/docs/PRD.md", "MY OWN PRD TEXT\n");
|
|
399
|
+
await runInit({ target: dir });
|
|
400
|
+
const before = await readFile(join(dir, "markflow/docs/PRD.md"), "utf8");
|
|
401
|
+
assert.equal(before, "MY OWN PRD TEXT\n");
|
|
402
|
+
const result = await runUpdate({ target: dir });
|
|
403
|
+
assert.equal(result.ok, true);
|
|
404
|
+
assert.equal(result.updated, 0);
|
|
405
|
+
assert.equal(result.skipped, 3);
|
|
406
|
+
const after = await readFile(join(dir, "markflow/docs/PRD.md"), "utf8");
|
|
407
|
+
assert.equal(after, "MY OWN PRD TEXT\n");
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
it("keeps filled ARCHITECTURE.md and STACK.md on update", async (t) => {
|
|
411
|
+
const dir = await tempDir(t);
|
|
412
|
+
await write(dir, "package.json", "{}");
|
|
413
|
+
await runInit({ target: dir });
|
|
414
|
+
const archBefore = await readFile(
|
|
415
|
+
join(dir, "markflow/docs/ARCHITECTURE.md"),
|
|
416
|
+
"utf8"
|
|
417
|
+
);
|
|
418
|
+
assert.ok(archBefore.includes("- Language. JavaScript"));
|
|
419
|
+
const stackBefore = await readFile(
|
|
420
|
+
join(dir, "markflow/docs/STACK.md"),
|
|
421
|
+
"utf8"
|
|
422
|
+
);
|
|
423
|
+
assert.ok(stackBefore.includes("Detected stacks"));
|
|
424
|
+
const result = await runUpdate({ target: dir });
|
|
425
|
+
assert.equal(result.ok, true);
|
|
426
|
+
assert.equal(result.updated, 0);
|
|
427
|
+
assert.equal(result.skipped, 2);
|
|
428
|
+
const archAfter = await readFile(
|
|
429
|
+
join(dir, "markflow/docs/ARCHITECTURE.md"),
|
|
430
|
+
"utf8"
|
|
431
|
+
);
|
|
432
|
+
assert.ok(archAfter.includes("- Language. JavaScript"));
|
|
433
|
+
const stackAfter = await readFile(
|
|
434
|
+
join(dir, "markflow/docs/STACK.md"),
|
|
435
|
+
"utf8"
|
|
436
|
+
);
|
|
437
|
+
assert.ok(stackAfter.includes("Detected stacks"));
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
it("restores ARCHITECTURE.md when missing", async (t) => {
|
|
441
|
+
const dir = await tempDir(t);
|
|
442
|
+
await write(dir, "package.json", "{}");
|
|
443
|
+
await runInit({ target: dir });
|
|
444
|
+
await rm(join(dir, "markflow/docs/ARCHITECTURE.md"));
|
|
445
|
+
const result = await runUpdate({ target: dir });
|
|
446
|
+
assert.equal(result.ok, true);
|
|
447
|
+
assert.equal(result.restored, 1);
|
|
448
|
+
const arch = await readFile(
|
|
449
|
+
join(dir, "markflow/docs/ARCHITECTURE.md"),
|
|
450
|
+
"utf8"
|
|
451
|
+
);
|
|
452
|
+
assert.ok(arch.includes("- Language. TBD"));
|
|
453
|
+
});
|
|
454
|
+
|
|
185
455
|
it("restores a deleted file and skips a modified file", async (t) => {
|
|
186
456
|
const dir = await tempDir(t);
|
|
187
457
|
await runInit({ target: dir });
|
|
@@ -190,11 +460,21 @@ describe("update", () => {
|
|
|
190
460
|
const result = await runUpdate({ target: dir });
|
|
191
461
|
assert.equal(result.ok, true);
|
|
192
462
|
assert.equal(result.restored, 1);
|
|
193
|
-
assert.equal(result.skipped,
|
|
463
|
+
assert.equal(result.skipped, 3);
|
|
194
464
|
const tasks = await readFile(join(dir, "markflow/TASKS.md"), "utf8");
|
|
195
465
|
assert.equal(tasks, "my own notes\n");
|
|
196
466
|
});
|
|
197
467
|
|
|
468
|
+
it("update keeps a minimal project minimal", async (t) => {
|
|
469
|
+
const dir = await tempDir(t);
|
|
470
|
+
await runInit({ target: dir, minimal: true });
|
|
471
|
+
const result = await runUpdate({ target: dir });
|
|
472
|
+
assert.equal(result.ok, true);
|
|
473
|
+
await assert.rejects(
|
|
474
|
+
readFile(join(dir, "markflow/docs/STACK.md"), "utf8")
|
|
475
|
+
);
|
|
476
|
+
});
|
|
477
|
+
|
|
198
478
|
it("preview changes nothing", async (t) => {
|
|
199
479
|
const dir = await tempDir(t);
|
|
200
480
|
await runInit({ target: dir });
|
|
@@ -255,11 +535,24 @@ describe("parser", () => {
|
|
|
255
535
|
assert.match(result.stdout, /Usage/);
|
|
256
536
|
});
|
|
257
537
|
|
|
538
|
+
it("init --minimal exits 0 and marks the project minimal", async (t) => {
|
|
539
|
+
const dir = await tempDir(t);
|
|
540
|
+
const result = runCli(["init", "--minimal"], dir);
|
|
541
|
+
assert.equal(result.status, 0);
|
|
542
|
+
await assert.rejects(
|
|
543
|
+
readFile(join(dir, "markflow/docs/STACK.md"), "utf8")
|
|
544
|
+
);
|
|
545
|
+
const marker = JSON.parse(
|
|
546
|
+
await readFile(join(dir, "markflow/.markflow.json"), "utf8")
|
|
547
|
+
);
|
|
548
|
+
assert.equal(marker.minimal, true);
|
|
549
|
+
});
|
|
550
|
+
|
|
258
551
|
it("--version prints the version", async (t) => {
|
|
259
552
|
const dir = await tempDir(t);
|
|
260
553
|
const result = runCli(["--version"], dir);
|
|
261
554
|
assert.equal(result.status, 0);
|
|
262
|
-
assert.equal(result.stdout.trim(), "0.
|
|
555
|
+
assert.equal(result.stdout.trim(), "0.2.0");
|
|
263
556
|
});
|
|
264
557
|
});
|
|
265
558
|
|