@moritakaaz/markflow 0.4.1 → 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.1"
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.1";
6
- export const TEMPLATE_VERSION = "0.4.1";
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.
package/test/cli.test.js CHANGED
@@ -404,6 +404,31 @@ describe("doctor", () => {
404
404
  );
405
405
  });
406
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
+
407
432
  it("spec listed by title only still warns", async (t) => {
408
433
  const dir = await tempDir(t);
409
434
  await runInit({ target: dir });
@@ -471,6 +496,52 @@ describe("doctor", () => {
471
496
  );
472
497
  });
473
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
+
474
545
  it("warns when PRD is still the template", async (t) => {
475
546
  const dir = await tempDir(t);
476
547
  await runInit({ target: dir });
@@ -483,11 +554,20 @@ describe("doctor", () => {
483
554
  const dir = await tempDir(t);
484
555
  await runInit({ target: dir });
485
556
  const result = runCli(["doctor"], dir);
486
- assert.match(result.stdout, /20 TBD left to decide now\./);
487
- 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\./);
488
559
  assert.ok(!result.stdout.includes("TBD left in docs"));
489
560
  });
490
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
+
491
571
  it("moves a real spec TBD into the now count", async (t) => {
492
572
  const dir = await tempDir(t);
493
573
  await runInit({ target: dir });
@@ -497,8 +577,8 @@ describe("doctor", () => {
497
577
  "# 01 Test\n\n## Status\n\nDraft\n\nTBD\n"
498
578
  );
499
579
  const result = runCli(["doctor"], dir);
500
- assert.match(result.stdout, /21 TBD left to decide now\./);
501
- 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\./);
502
582
  });
503
583
 
504
584
  it("warns when instruction text is left visible", async (t) => {
@@ -619,7 +699,8 @@ describe("update", () => {
619
699
  const result = await runUpdate({ target: dir });
620
700
  assert.equal(result.ok, true);
621
701
  assert.equal(result.updated, 0);
622
- assert.equal(result.skipped, 3);
702
+ assert.equal(result.skipped, 1);
703
+ assert.equal(result.kept, 2);
623
704
  const after = await readFile(join(dir, "markflow/docs/PRD.md"), "utf8");
624
705
  assert.equal(after, "MY OWN PRD TEXT\n");
625
706
  });
@@ -641,7 +722,8 @@ describe("update", () => {
641
722
  const result = await runUpdate({ target: dir });
642
723
  assert.equal(result.ok, true);
643
724
  assert.equal(result.updated, 0);
644
- assert.equal(result.skipped, 2);
725
+ assert.equal(result.skipped, 0);
726
+ assert.equal(result.kept, 2);
645
727
  const archAfter = await readFile(
646
728
  join(dir, "markflow/docs/ARCHITECTURE.md"),
647
729
  "utf8"
@@ -654,6 +736,19 @@ describe("update", () => {
654
736
  assert.ok(stackAfter.includes("Detected stacks"));
655
737
  });
656
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
+
657
752
  it("restores ARCHITECTURE.md when missing", async (t) => {
658
753
  const dir = await tempDir(t);
659
754
  await write(dir, "package.json", "{}");
@@ -677,7 +772,8 @@ describe("update", () => {
677
772
  const result = await runUpdate({ target: dir });
678
773
  assert.equal(result.ok, true);
679
774
  assert.equal(result.restored, 1);
680
- assert.equal(result.skipped, 3);
775
+ assert.equal(result.skipped, 1);
776
+ assert.equal(result.kept, 2);
681
777
  const tasks = await readFile(join(dir, "markflow/TASKS.md"), "utf8");
682
778
  assert.equal(tasks, "my own notes\n");
683
779
  });
@@ -709,7 +805,7 @@ describe("update", () => {
709
805
  marker.files["docs/OLD.md"] = "abc123";
710
806
  await writeFile(markerPath, JSON.stringify(marker, null, 2));
711
807
  const result = await runUpdate({ target: dir });
712
- assert.equal(result.kept, 1);
808
+ assert.equal(result.kept, 3);
713
809
  });
714
810
 
715
811
  it("no marker fails", async (t) => {
@@ -769,7 +865,7 @@ describe("parser", () => {
769
865
  const dir = await tempDir(t);
770
866
  const result = runCli(["--version"], dir);
771
867
  assert.equal(result.status, 0);
772
- assert.equal(result.stdout.trim(), "0.4.1");
868
+ assert.equal(result.stdout.trim(), "0.4.2");
773
869
  });
774
870
  });
775
871