@moritakaaz/markflow 0.4.0 → 0.4.2

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 CHANGED
@@ -19,5 +19,5 @@
19
19
  "test": "node --test"
20
20
  },
21
21
  "type": "module",
22
- "version": "0.4.0"
22
+ "version": "0.4.2"
23
23
  }
package/src/doctor.js CHANGED
@@ -127,6 +127,12 @@ function sectionLines(text, heading) {
127
127
  return out;
128
128
  }
129
129
 
130
+ // A spec counts as listed only when its exact file name appears.
131
+ // A substring match would also match old-login.md for login.md.
132
+ function indexLists(indexText, name) {
133
+ return indexText.split(/[\s|,()]+/).includes(name);
134
+ }
135
+
130
136
  function findLinks(text) {
131
137
  const links = [];
132
138
  const re = /\[[^\]]*\]\(([^)\s]+)\)/g;
@@ -202,7 +208,7 @@ export async function runDoctor(options) {
202
208
  break;
203
209
  }
204
210
  }
205
- const count = text.split("TBD").length - 1;
211
+ const count = visible.split("TBD").length - 1;
206
212
  if (isTbdNow(rel)) {
207
213
  tbdNow += count;
208
214
  } else {
@@ -273,10 +279,14 @@ export async function runDoctor(options) {
273
279
  specTotal += 1;
274
280
  const text = await readFile(file, "utf8");
275
281
  const rel = file.slice(root.length + 1);
276
- if (text.includes("Status") && text.includes("Draft")) {
282
+ const status = sectionLines(text, "Status");
283
+ if (
284
+ status !== null &&
285
+ status.some((line) => line.trim() === "Draft")
286
+ ) {
277
287
  specDraft += 1;
278
288
  }
279
- if (!indexText.includes(name)) {
289
+ if (!indexLists(indexText, name)) {
280
290
  console.log("Warning Spec not listed in index " + rel);
281
291
  warnings.push(rel);
282
292
  }
@@ -290,11 +300,10 @@ export async function runDoctor(options) {
290
300
  warnings.push(rel);
291
301
  }
292
302
  }
293
- const status = sectionLines(text, "Status");
294
303
  if (
295
304
  status !== null &&
296
305
  status.some((line) => line.trim() === "Approved") &&
297
- text.includes("TBD")
306
+ stripComments(text).includes("TBD")
298
307
  ) {
299
308
  console.log("Warning Approved spec still has TBD in " + rel);
300
309
  warnings.push(rel);
package/src/update.js CHANGED
@@ -73,8 +73,16 @@ export async function runUpdate(options) {
73
73
  return;
74
74
  }
75
75
  if (userOwned) {
76
- console.log("Skipped " + rel + ", user owned.");
77
- skipped += 1;
76
+ if (storedMap[rel] && hashText(current) === storedMap[rel]) {
77
+ console.log("Kept " + rel + ", user owned.");
78
+ kept += 1;
79
+ } else if (storedMap[rel]) {
80
+ console.log("Skipped " + rel + ", modified.");
81
+ skipped += 1;
82
+ } else {
83
+ console.log("Skipped " + rel + ", user owned.");
84
+ skipped += 1;
85
+ }
78
86
  return;
79
87
  }
80
88
  if (storedMap[rel] && hashText(current) === storedMap[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.4.0";
6
- export const TEMPLATE_VERSION = "0.4.0";
5
+ export const METHODOLOGY_VERSION = "0.4.2";
6
+ export const TEMPLATE_VERSION = "0.4.2";
@@ -17,7 +17,8 @@ Start with these files in order.
17
17
 
18
18
  ## Rules you must not break
19
19
 
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.
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
+ - Keep these words in English in every doc. Status, Acceptance, Approved, Draft, and TBD. Doctor reads them. Write the rest in any language.
21
22
  - 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.
22
23
  - 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.
23
24
  - 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.
@@ -7,8 +7,8 @@ Do not read when. The PRD is already filled. Use the other workflows instead.
7
7
  ## Steps
8
8
 
9
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 which language to use in this conversation. Then ask which language to use for docs and code comments. Ask each one as its own question. Code names stay in English.
10
+ 2. Ask which language to use in this conversation. Then ask which language to use for docs and code comments. Ask each one as its own question. Code names stay in English.
11
+ 3. Start with the problem. What hurts today, and for whom.
12
12
  4. Ask who uses the product. Ask what each user must be able to do.
13
13
  5. Ask what the product must not do.
14
14
  6. Read the code to learn the stack and the layout. Use only what the code shows.
package/test/cli.test.js CHANGED
@@ -303,6 +303,10 @@ describe("init", () => {
303
303
  assert.ok(workflow.includes("which language to use in this conversation"));
304
304
  assert.ok(workflow.includes("which language to use for docs and code comments"));
305
305
  assert.ok(workflow.includes("Code names stay in English"));
306
+ assert.ok(
307
+ workflow.indexOf("which language to use in this conversation") <
308
+ workflow.indexOf("Start with the problem")
309
+ );
306
310
  const prd = await readFile(join(dir, "markflow/docs/PRD.md"), "utf8");
307
311
  assert.ok(prd.includes("## Language"));
308
312
  assert.ok(prd.includes("- Conversation. TBD"));
@@ -400,6 +404,31 @@ describe("doctor", () => {
400
404
  );
401
405
  });
402
406
 
407
+ it("spec with a similar name in index still warns", async (t) => {
408
+ const dir = await tempDir(t);
409
+ await runInit({ target: dir });
410
+ await write(
411
+ dir,
412
+ "markflow/specs/login.md",
413
+ "# Login\n\n## Goal\n\nLog in.\n\n## Acceptance\n\n- The user logs in.\n\n## Status\n\nDraft\n"
414
+ );
415
+ const index = await readFile(
416
+ join(dir, "markflow/specs/index.md"),
417
+ "utf8"
418
+ );
419
+ await write(
420
+ dir,
421
+ "markflow/specs/index.md",
422
+ index.replace(
423
+ "| 01 | TBD | TBD | Draft |",
424
+ "| 01 | old-login.md | Old login | Draft |"
425
+ )
426
+ );
427
+ const result = await runDoctor({ target: dir });
428
+ assert.equal(result.ok, true);
429
+ assert.ok(result.warnings.some((w) => w.includes("login.md")));
430
+ });
431
+
403
432
  it("spec listed by title only still warns", async (t) => {
404
433
  const dir = await tempDir(t);
405
434
  await runInit({ target: dir });
@@ -467,6 +496,52 @@ describe("doctor", () => {
467
496
  );
468
497
  });
469
498
 
499
+ it("Indonesian spec with English keywords passes", async (t) => {
500
+ const dir = await tempDir(t);
501
+ await runInit({ target: dir });
502
+ const agents = await readFile(join(dir, "AGENTS.md"), "utf8");
503
+ assert.ok(agents.includes("Keep these words in English in every doc."));
504
+ await write(
505
+ dir,
506
+ "markflow/specs/01-masuk.md",
507
+ "# Masuk\n\n## Goal\n\nPengguna bisa masuk.\n\n## Acceptance\n\n- Pengguna masuk dengan kata sandi yang benar.\n- Pengguna gagal masuk dengan kata sandi yang salah.\n\n## Status\n\nApproved\n"
508
+ );
509
+ const index = await readFile(
510
+ join(dir, "markflow/specs/index.md"),
511
+ "utf8"
512
+ );
513
+ await write(
514
+ dir,
515
+ "markflow/specs/index.md",
516
+ index.replace(
517
+ "| 01 | TBD | TBD | Draft |",
518
+ "| 01 | 01-masuk.md | Masuk | Approved |"
519
+ )
520
+ );
521
+ const result = await runDoctor({ target: dir });
522
+ assert.equal(result.ok, true);
523
+ assert.ok(!result.warnings.some((w) => w.includes("01-masuk.md")));
524
+ const counts = runCli(["doctor"], dir);
525
+ assert.match(counts.stdout, /1 specs, 0 draft\./);
526
+ });
527
+
528
+ it("approved spec with Draft in a note is not a draft", async (t) => {
529
+ const dir = await tempDir(t);
530
+ await runInit({ target: dir });
531
+ await write(
532
+ dir,
533
+ "markflow/specs/01-test.md",
534
+ "# Test spec\n\n## Goal\n\nDo a thing.\n\n## Acceptance\n\n- The thing works.\n\n## Status\n\nApproved\n\nNote. Draft copy was reviewed by the team.\n"
535
+ );
536
+ const index = await readFile(
537
+ join(dir, "markflow/specs/index.md"),
538
+ "utf8"
539
+ );
540
+ await write(dir, "markflow/specs/index.md", index + "\n01-test.md\n");
541
+ const result = runCli(["doctor"], dir);
542
+ assert.match(result.stdout, /1 specs, 0 draft\./);
543
+ });
544
+
470
545
  it("warns when PRD is still the template", async (t) => {
471
546
  const dir = await tempDir(t);
472
547
  await runInit({ target: dir });
@@ -479,11 +554,20 @@ describe("doctor", () => {
479
554
  const dir = await tempDir(t);
480
555
  await runInit({ target: dir });
481
556
  const result = runCli(["doctor"], dir);
482
- assert.match(result.stdout, /20 TBD left to decide now\./);
483
- assert.match(result.stdout, /39 TBD left for later\./);
557
+ assert.match(result.stdout, /19 TBD left to decide now\./);
558
+ assert.match(result.stdout, /37 TBD left for later\./);
484
559
  assert.ok(!result.stdout.includes("TBD left in docs"));
485
560
  });
486
561
 
562
+ it("hidden TBD in a comment is not counted", async (t) => {
563
+ const dir = await tempDir(t);
564
+ await runInit({ target: dir });
565
+ const prd = await readFile(join(dir, "markflow/docs/PRD.md"), "utf8");
566
+ await write(dir, "markflow/docs/PRD.md", prd + "\n<!-- TBD -->\n");
567
+ const result = runCli(["doctor"], dir);
568
+ assert.match(result.stdout, /19 TBD left to decide now\./);
569
+ });
570
+
487
571
  it("moves a real spec TBD into the now count", async (t) => {
488
572
  const dir = await tempDir(t);
489
573
  await runInit({ target: dir });
@@ -493,8 +577,8 @@ describe("doctor", () => {
493
577
  "# 01 Test\n\n## Status\n\nDraft\n\nTBD\n"
494
578
  );
495
579
  const result = runCli(["doctor"], dir);
496
- assert.match(result.stdout, /21 TBD left to decide now\./);
497
- assert.match(result.stdout, /39 TBD left for later\./);
580
+ assert.match(result.stdout, /20 TBD left to decide now\./);
581
+ assert.match(result.stdout, /37 TBD left for later\./);
498
582
  });
499
583
 
500
584
  it("warns when instruction text is left visible", async (t) => {
@@ -615,7 +699,8 @@ describe("update", () => {
615
699
  const result = await runUpdate({ target: dir });
616
700
  assert.equal(result.ok, true);
617
701
  assert.equal(result.updated, 0);
618
- assert.equal(result.skipped, 3);
702
+ assert.equal(result.skipped, 1);
703
+ assert.equal(result.kept, 2);
619
704
  const after = await readFile(join(dir, "markflow/docs/PRD.md"), "utf8");
620
705
  assert.equal(after, "MY OWN PRD TEXT\n");
621
706
  });
@@ -637,7 +722,8 @@ describe("update", () => {
637
722
  const result = await runUpdate({ target: dir });
638
723
  assert.equal(result.ok, true);
639
724
  assert.equal(result.updated, 0);
640
- assert.equal(result.skipped, 2);
725
+ assert.equal(result.skipped, 0);
726
+ assert.equal(result.kept, 2);
641
727
  const archAfter = await readFile(
642
728
  join(dir, "markflow/docs/ARCHITECTURE.md"),
643
729
  "utf8"
@@ -650,6 +736,19 @@ describe("update", () => {
650
736
  assert.ok(stackAfter.includes("Detected stacks"));
651
737
  });
652
738
 
739
+ it("untouched user owned file is kept, not skipped", async (t) => {
740
+ const dir = await tempDir(t);
741
+ await write(dir, "package.json", "{}");
742
+ await runInit({ target: dir, minimal: true });
743
+ const result = runCli(["update", "--preview"], dir);
744
+ assert.ok(
745
+ result.stdout.includes("Kept docs/ARCHITECTURE.md, user owned.")
746
+ );
747
+ assert.ok(
748
+ !result.stdout.includes("Skipped docs/ARCHITECTURE.md")
749
+ );
750
+ });
751
+
653
752
  it("restores ARCHITECTURE.md when missing", async (t) => {
654
753
  const dir = await tempDir(t);
655
754
  await write(dir, "package.json", "{}");
@@ -673,7 +772,8 @@ describe("update", () => {
673
772
  const result = await runUpdate({ target: dir });
674
773
  assert.equal(result.ok, true);
675
774
  assert.equal(result.restored, 1);
676
- assert.equal(result.skipped, 3);
775
+ assert.equal(result.skipped, 1);
776
+ assert.equal(result.kept, 2);
677
777
  const tasks = await readFile(join(dir, "markflow/TASKS.md"), "utf8");
678
778
  assert.equal(tasks, "my own notes\n");
679
779
  });
@@ -705,7 +805,7 @@ describe("update", () => {
705
805
  marker.files["docs/OLD.md"] = "abc123";
706
806
  await writeFile(markerPath, JSON.stringify(marker, null, 2));
707
807
  const result = await runUpdate({ target: dir });
708
- assert.equal(result.kept, 1);
808
+ assert.equal(result.kept, 3);
709
809
  });
710
810
 
711
811
  it("no marker fails", async (t) => {
@@ -765,7 +865,7 @@ describe("parser", () => {
765
865
  const dir = await tempDir(t);
766
866
  const result = runCli(["--version"], dir);
767
867
  assert.equal(result.status, 0);
768
- assert.equal(result.stdout.trim(), "0.4.0");
868
+ assert.equal(result.stdout.trim(), "0.4.2");
769
869
  });
770
870
  });
771
871