@moritakaaz/markflow 0.4.2 → 0.4.4
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/package.json +1 -1
- package/src/doctor.js +47 -1
- package/src/versions.js +2 -2
- package/templates/AGENTS.md +12 -0
- package/templates/markflow/docs/PRD.md +2 -2
- package/test/cli.test.js +112 -3
package/package.json
CHANGED
package/src/doctor.js
CHANGED
|
@@ -127,10 +127,27 @@ function sectionLines(text, heading) {
|
|
|
127
127
|
return out;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
// A language line is unanswered when it still says TBD or when the
|
|
131
|
+
// value after the label is empty.
|
|
132
|
+
function languageUnanswered(line) {
|
|
133
|
+
if (line.includes("TBD")) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
const dot = line.indexOf(".");
|
|
137
|
+
if (dot === -1) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return line.slice(dot + 1).trim() === "";
|
|
141
|
+
}
|
|
142
|
+
|
|
130
143
|
// A spec counts as listed only when its exact file name appears.
|
|
131
144
|
// A substring match would also match old-login.md for login.md.
|
|
145
|
+
// A path form such as specs/login.md also counts.
|
|
132
146
|
function indexLists(indexText, name) {
|
|
133
|
-
|
|
147
|
+
if (indexText.split(/[\s|,()]+/).includes(name)) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
return indexText.includes("/" + name);
|
|
134
151
|
}
|
|
135
152
|
|
|
136
153
|
function findLinks(text) {
|
|
@@ -262,6 +279,21 @@ export async function runDoctor(options) {
|
|
|
262
279
|
if (stillTemplate.length > 0) {
|
|
263
280
|
console.log("Next. Fill " + stillTemplate[0] + ".");
|
|
264
281
|
}
|
|
282
|
+
if (!stillTemplate.includes("markflow/docs/PRD.md")) {
|
|
283
|
+
try {
|
|
284
|
+
const prdText = await readFile(
|
|
285
|
+
join(root, "markflow/docs/PRD.md"),
|
|
286
|
+
"utf8"
|
|
287
|
+
);
|
|
288
|
+
const language = sectionLines(prdText, "Language");
|
|
289
|
+
if (language !== null && language.some(languageUnanswered)) {
|
|
290
|
+
console.log("Warning Language not answered in markflow/docs/PRD.md");
|
|
291
|
+
warnings.push("markflow/docs/PRD.md");
|
|
292
|
+
}
|
|
293
|
+
} catch {
|
|
294
|
+
// Missing PRD is already reported above.
|
|
295
|
+
}
|
|
296
|
+
}
|
|
265
297
|
let specTotal = 0;
|
|
266
298
|
let specDraft = 0;
|
|
267
299
|
try {
|
|
@@ -308,6 +340,20 @@ export async function runDoctor(options) {
|
|
|
308
340
|
console.log("Warning Approved spec still has TBD in " + rel);
|
|
309
341
|
warnings.push(rel);
|
|
310
342
|
}
|
|
343
|
+
if (status !== null) {
|
|
344
|
+
const statusLines = stripComments(status.join("\n"))
|
|
345
|
+
.split("\n")
|
|
346
|
+
.map((line) => line.trim())
|
|
347
|
+
.filter((line) => line !== "");
|
|
348
|
+
if (
|
|
349
|
+
statusLines.length > 0 &&
|
|
350
|
+
!statusLines.includes("Draft") &&
|
|
351
|
+
!statusLines.includes("Approved")
|
|
352
|
+
) {
|
|
353
|
+
console.log("Warning Unknown status in " + rel);
|
|
354
|
+
warnings.push(rel);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
311
357
|
}
|
|
312
358
|
} catch {
|
|
313
359
|
// Missing specs folder is already reported above.
|
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.4.
|
|
6
|
-
export const TEMPLATE_VERSION = "0.4.
|
|
5
|
+
export const METHODOLOGY_VERSION = "0.4.4";
|
|
6
|
+
export const TEMPLATE_VERSION = "0.4.4";
|
package/templates/AGENTS.md
CHANGED
|
@@ -18,12 +18,24 @@ Start with these files in order.
|
|
|
18
18
|
## Rules you must not break
|
|
19
19
|
|
|
20
20
|
- 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. The Markflow repo itself is English only. Your project is not.
|
|
21
|
+
- Use English in file and folder names too.
|
|
21
22
|
- Keep these words in English in every doc. Status, Acceptance, Approved, Draft, and TBD. Doctor reads them. Write the rest in any language.
|
|
23
|
+
- Write short sentences. Write like you talk to a teammate. Avoid em dashes. Avoid colons in prose.
|
|
24
|
+
- Keep commits small. One logical change per commit. Use the imperative mood. Keep the subject short and clear. Good examples are Add README and Fix typo in PRINCIPLES.
|
|
25
|
+
- Do not invent architecture or decisions. If you do not know something, say so and ask. Do not overwrite user files without approval. Do not change code outside the scope of your task.
|
|
26
|
+
- Every doc file starts with a short note on what it is for and when to read it. Keep the README short. Put details in docs.
|
|
27
|
+
- Follow the file naming style of the language. Use English words, and kebab-case when the language has no rule.
|
|
28
|
+
- Write a comment only when logic is hard to follow without it. Use simple comments. For one line use //. For many lines use /* */. Do not use decorative comment lines.
|
|
22
29
|
- 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.
|
|
23
30
|
- 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.
|
|
24
31
|
- 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.
|
|
25
32
|
- All links inside `markflow` must be relative to that folder. Do not use absolute paths from the root.
|
|
26
33
|
|
|
34
|
+
### When the docs are in English
|
|
35
|
+
|
|
36
|
+
- Avoid formal and cliché words. Avoid words like delve, leverage, seamless, robust, and cutting edge.
|
|
37
|
+
- Use contractions. Write don't instead of do not when it sounds natural.
|
|
38
|
+
|
|
27
39
|
## If you are human and you do not use AI
|
|
28
40
|
|
|
29
41
|
Ignore the `markflow/.agents` folder. Read `README.md` and `CONTRIBUTING.md` in this project instead.
|
|
@@ -12,8 +12,8 @@ Do not read when. You need code detail. Open a spec in `specs` instead.
|
|
|
12
12
|
|
|
13
13
|
<!-- Write which language to use in this conversation and which language to use for docs and code comments. Code names stay in English. -->
|
|
14
14
|
|
|
15
|
-
- Conversation. TBD
|
|
16
|
-
- Docs. TBD
|
|
15
|
+
- Conversation language. TBD
|
|
16
|
+
- Docs language. TBD
|
|
17
17
|
|
|
18
18
|
## Users
|
|
19
19
|
|
package/test/cli.test.js
CHANGED
|
@@ -309,8 +309,8 @@ describe("init", () => {
|
|
|
309
309
|
);
|
|
310
310
|
const prd = await readFile(join(dir, "markflow/docs/PRD.md"), "utf8");
|
|
311
311
|
assert.ok(prd.includes("## Language"));
|
|
312
|
-
assert.ok(prd.includes("- Conversation. TBD"));
|
|
313
|
-
assert.ok(prd.includes("- Docs. TBD"));
|
|
312
|
+
assert.ok(prd.includes("- Conversation language. TBD"));
|
|
313
|
+
assert.ok(prd.includes("- Docs language. TBD"));
|
|
314
314
|
});
|
|
315
315
|
|
|
316
316
|
it("tasks list the first five steps and review names the user as approver", async (t) => {
|
|
@@ -429,6 +429,56 @@ describe("doctor", () => {
|
|
|
429
429
|
assert.ok(result.warnings.some((w) => w.includes("login.md")));
|
|
430
430
|
});
|
|
431
431
|
|
|
432
|
+
it("spec listed as a path passes", async (t) => {
|
|
433
|
+
const dir = await tempDir(t);
|
|
434
|
+
await runInit({ target: dir });
|
|
435
|
+
await write(
|
|
436
|
+
dir,
|
|
437
|
+
"markflow/specs/login.md",
|
|
438
|
+
"# Login\n\n## Goal\n\nLog in.\n\n## Acceptance\n\n- The user logs in.\n\n## Status\n\nDraft\n"
|
|
439
|
+
);
|
|
440
|
+
const index = await readFile(
|
|
441
|
+
join(dir, "markflow/specs/index.md"),
|
|
442
|
+
"utf8"
|
|
443
|
+
);
|
|
444
|
+
await write(
|
|
445
|
+
dir,
|
|
446
|
+
"markflow/specs/index.md",
|
|
447
|
+
index.replace(
|
|
448
|
+
"| 01 | TBD | TBD | Draft |",
|
|
449
|
+
"| 01 | specs/login.md | Login | Draft |"
|
|
450
|
+
)
|
|
451
|
+
);
|
|
452
|
+
const result = await runDoctor({ target: dir });
|
|
453
|
+
assert.equal(result.ok, true);
|
|
454
|
+
assert.ok(!result.warnings.some((w) => w.includes("login.md")));
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it("spec listed as a markdown link passes", async (t) => {
|
|
458
|
+
const dir = await tempDir(t);
|
|
459
|
+
await runInit({ target: dir });
|
|
460
|
+
await write(
|
|
461
|
+
dir,
|
|
462
|
+
"markflow/specs/login.md",
|
|
463
|
+
"# Login\n\n## Goal\n\nLog in.\n\n## Acceptance\n\n- The user logs in.\n\n## Status\n\nDraft\n"
|
|
464
|
+
);
|
|
465
|
+
const index = await readFile(
|
|
466
|
+
join(dir, "markflow/specs/index.md"),
|
|
467
|
+
"utf8"
|
|
468
|
+
);
|
|
469
|
+
await write(
|
|
470
|
+
dir,
|
|
471
|
+
"markflow/specs/index.md",
|
|
472
|
+
index.replace(
|
|
473
|
+
"| 01 | TBD | TBD | Draft |",
|
|
474
|
+
"| 01 | [Login](login.md) | Login | Draft |"
|
|
475
|
+
)
|
|
476
|
+
);
|
|
477
|
+
const result = await runDoctor({ target: dir });
|
|
478
|
+
assert.equal(result.ok, true);
|
|
479
|
+
assert.ok(!result.warnings.some((w) => w.includes("login.md")));
|
|
480
|
+
});
|
|
481
|
+
|
|
432
482
|
it("spec listed by title only still warns", async (t) => {
|
|
433
483
|
const dir = await tempDir(t);
|
|
434
484
|
await runInit({ target: dir });
|
|
@@ -525,6 +575,26 @@ describe("doctor", () => {
|
|
|
525
575
|
assert.match(counts.stdout, /1 specs, 0 draft\./);
|
|
526
576
|
});
|
|
527
577
|
|
|
578
|
+
it("warns on unknown status value", async (t) => {
|
|
579
|
+
const dir = await tempDir(t);
|
|
580
|
+
await runInit({ target: dir });
|
|
581
|
+
await write(
|
|
582
|
+
dir,
|
|
583
|
+
"markflow/specs/01-test.md",
|
|
584
|
+
"# Test spec\n\n## Goal\n\nDo a thing.\n\n## Acceptance\n\n- The thing works.\n\n## Status\n\nDisetujui\n"
|
|
585
|
+
);
|
|
586
|
+
const index = await readFile(
|
|
587
|
+
join(dir, "markflow/specs/index.md"),
|
|
588
|
+
"utf8"
|
|
589
|
+
);
|
|
590
|
+
await write(dir, "markflow/specs/index.md", index + "\n01-test.md\n");
|
|
591
|
+
const result = await runDoctor({ target: dir });
|
|
592
|
+
assert.equal(result.ok, true);
|
|
593
|
+
assert.ok(result.warnings.some((w) => w.includes("01-test.md")));
|
|
594
|
+
const counts = runCli(["doctor"], dir);
|
|
595
|
+
assert.match(counts.stdout, /1 specs, 0 draft\./);
|
|
596
|
+
});
|
|
597
|
+
|
|
528
598
|
it("approved spec with Draft in a note is not a draft", async (t) => {
|
|
529
599
|
const dir = await tempDir(t);
|
|
530
600
|
await runInit({ target: dir });
|
|
@@ -542,6 +612,45 @@ describe("doctor", () => {
|
|
|
542
612
|
assert.match(result.stdout, /1 specs, 0 draft\./);
|
|
543
613
|
});
|
|
544
614
|
|
|
615
|
+
it("warns when language is not answered in PRD", async (t) => {
|
|
616
|
+
const dir = await tempDir(t);
|
|
617
|
+
await runInit({ target: dir });
|
|
618
|
+
await write(
|
|
619
|
+
dir,
|
|
620
|
+
"markflow/docs/PRD.md",
|
|
621
|
+
"Our own product.\n\n## Language\n\n- Conversation language. Indonesian\n- Docs language. TBD\n"
|
|
622
|
+
);
|
|
623
|
+
const result = await runDoctor({ target: dir });
|
|
624
|
+
assert.equal(result.ok, true);
|
|
625
|
+
assert.ok(result.warnings.includes("markflow/docs/PRD.md"));
|
|
626
|
+
});
|
|
627
|
+
|
|
628
|
+
it("warns when a language value is empty", async (t) => {
|
|
629
|
+
const dir = await tempDir(t);
|
|
630
|
+
await runInit({ target: dir });
|
|
631
|
+
await write(
|
|
632
|
+
dir,
|
|
633
|
+
"markflow/docs/PRD.md",
|
|
634
|
+
"Our own product.\n\n## Language\n\n- Conversation language. Indonesian\n- Docs language. \n"
|
|
635
|
+
);
|
|
636
|
+
const result = await runDoctor({ target: dir });
|
|
637
|
+
assert.equal(result.ok, true);
|
|
638
|
+
assert.ok(result.warnings.includes("markflow/docs/PRD.md"));
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
it("no language warning when both languages are answered", async (t) => {
|
|
642
|
+
const dir = await tempDir(t);
|
|
643
|
+
await runInit({ target: dir });
|
|
644
|
+
await write(
|
|
645
|
+
dir,
|
|
646
|
+
"markflow/docs/PRD.md",
|
|
647
|
+
"Our own product.\n\n## Language\n\n- Conversation language. Indonesian\n- Docs language. Indonesian\n"
|
|
648
|
+
);
|
|
649
|
+
const result = await runDoctor({ target: dir });
|
|
650
|
+
assert.equal(result.ok, true);
|
|
651
|
+
assert.ok(!result.warnings.includes("markflow/docs/PRD.md"));
|
|
652
|
+
});
|
|
653
|
+
|
|
545
654
|
it("warns when PRD is still the template", async (t) => {
|
|
546
655
|
const dir = await tempDir(t);
|
|
547
656
|
await runInit({ target: dir });
|
|
@@ -865,7 +974,7 @@ describe("parser", () => {
|
|
|
865
974
|
const dir = await tempDir(t);
|
|
866
975
|
const result = runCli(["--version"], dir);
|
|
867
976
|
assert.equal(result.status, 0);
|
|
868
|
-
assert.equal(result.stdout.trim(), "0.4.
|
|
977
|
+
assert.equal(result.stdout.trim(), "0.4.4");
|
|
869
978
|
});
|
|
870
979
|
});
|
|
871
980
|
|