specdx 0.4.0-alpha.9 → 0.5.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.
Files changed (115) hide show
  1. package/.claude-plugin/plugin.json +7 -2
  2. package/README.md +283 -0
  3. package/dist/{check-4FSSC6HN.js → check-RH5SCXWW.js} +68 -30
  4. package/dist/check-RH5SCXWW.js.map +1 -0
  5. package/dist/{chunk-N77RNV7J.js → chunk-3YXRWQGX.js} +217 -42
  6. package/dist/chunk-3YXRWQGX.js.map +1 -0
  7. package/dist/chunk-5WRI5ZAA.js +31 -0
  8. package/dist/chunk-6EQIDZ4D.js +185 -0
  9. package/dist/chunk-6EQIDZ4D.js.map +1 -0
  10. package/dist/chunk-6WFNZH7F.js +2846 -0
  11. package/dist/chunk-6WFNZH7F.js.map +1 -0
  12. package/dist/{chunk-AKNPCB37.js → chunk-BMOOLUPG.js} +32 -12
  13. package/dist/chunk-BMOOLUPG.js.map +1 -0
  14. package/dist/{chunk-IHTYAW7C.js → chunk-BP3SB35W.js} +111 -7
  15. package/dist/chunk-BP3SB35W.js.map +1 -0
  16. package/dist/chunk-CQETLJTZ.js +103 -0
  17. package/dist/chunk-CQETLJTZ.js.map +1 -0
  18. package/dist/chunk-DMGABJ6T.js +41 -0
  19. package/dist/chunk-DMGABJ6T.js.map +1 -0
  20. package/dist/chunk-NHD44ZYN.js +20 -0
  21. package/dist/chunk-NHD44ZYN.js.map +1 -0
  22. package/dist/{chunk-7JXW2GTJ.js → chunk-XRWLPU24.js} +18 -2
  23. package/dist/chunk-XRWLPU24.js.map +1 -0
  24. package/dist/chunk-ZIODMXST.js +1146 -0
  25. package/dist/chunk-ZIODMXST.js.map +1 -0
  26. package/dist/diff-QO7HMAK3.js +200 -0
  27. package/dist/diff-QO7HMAK3.js.map +1 -0
  28. package/dist/{dist-4DIRTBJH.js → dist-JPWHWMV2.js} +88 -26
  29. package/dist/dist-JPWHWMV2.js.map +1 -0
  30. package/dist/{dist-RL2DT3ZE.js → dist-ROHCFKYT.js} +3 -2
  31. package/dist/dist-ROHCFKYT.js.map +1 -0
  32. package/dist/generate-MS4BM7RU.js +21 -0
  33. package/dist/generate-MS4BM7RU.js.map +1 -0
  34. package/dist/{generate-story-EFHGINHA.js → generate-story-OMM322L7.js} +43 -19
  35. package/dist/generate-story-OMM322L7.js.map +1 -0
  36. package/dist/{generate-test-plan-BO7444RG.js → generate-test-plan-75W7SZIO.js} +61 -11
  37. package/dist/generate-test-plan-75W7SZIO.js.map +1 -0
  38. package/dist/{graph-5XINV7PT.js → graph-QOTMXENE.js} +49 -11
  39. package/dist/graph-QOTMXENE.js.map +1 -0
  40. package/dist/index.d.ts +302 -0
  41. package/dist/index.js +2996 -357
  42. package/dist/index.js.map +1 -1
  43. package/dist/lint-LPFLHVO4.js +184 -0
  44. package/dist/lint-LPFLHVO4.js.map +1 -0
  45. package/dist/main.js +10 -229
  46. package/dist/main.js.map +1 -1
  47. package/dist/mcp-OEC43SPF.js +35 -0
  48. package/dist/mcp-OEC43SPF.js.map +1 -0
  49. package/dist/{migrate-4KF6GHLO.js → migrate-CBP2AVLH.js} +21 -9
  50. package/dist/migrate-CBP2AVLH.js.map +1 -0
  51. package/dist/{pack-DSOODXAN.js → pack-X6FSWORJ.js} +41 -13
  52. package/dist/pack-X6FSWORJ.js.map +1 -0
  53. package/dist/{ready-6DNKIHP6.js → ready-7MJWRGLT.js} +55 -14
  54. package/dist/ready-7MJWRGLT.js.map +1 -0
  55. package/dist/skills/{specdx-author-spec.md → core/specdx-author-spec/SKILL.md} +10 -6
  56. package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-01-frontmatter.md +1 -1
  57. package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-02-sections.md +41 -0
  58. package/dist/skills/{specdx-onboard.md → core/specdx-onboard/SKILL.md} +8 -3
  59. package/dist/skills/{specdx-plan-from-spec.md → core/specdx-plan-from-spec/SKILL.md} +5 -1
  60. package/dist/skills/{specdx-pre-commit.md → core/specdx-pre-commit/SKILL.md} +16 -2
  61. package/dist/skills/{specdx-review-spec.md → core/specdx-review-spec/SKILL.md} +5 -1
  62. package/dist/skills/core/specdx-router/SKILL.md +67 -0
  63. package/dist/skills/{specdx-sprint-review.md → core/specdx-sprint-review/SKILL.md} +6 -2
  64. package/dist/skills/{specdx-start-task.md → core/specdx-start-task/SKILL.md} +5 -1
  65. package/dist/skills/{specdx-check-drift.md → experimental/specdx-check-drift/SKILL.md} +10 -4
  66. package/dist/skills/{specdx-verify.md → experimental/specdx-verify/SKILL.md} +6 -2
  67. package/dist/skills-36SRUEMR.js +121 -0
  68. package/dist/skills-36SRUEMR.js.map +1 -0
  69. package/dist/{status-WZK247CI.js → status-UUPZYX3J.js} +63 -32
  70. package/dist/status-UUPZYX3J.js.map +1 -0
  71. package/dist/{update-JTNSYX3B.js → update-EI7IJRHG.js} +22 -12
  72. package/dist/update-EI7IJRHG.js.map +1 -0
  73. package/dist/{validate-LBDYWUDX.js → validate-HTTZLQWI.js} +36 -17
  74. package/dist/validate-HTTZLQWI.js.map +1 -0
  75. package/hooks/hooks.json +12 -6
  76. package/hooks/session-start +35 -3
  77. package/package.json +28 -13
  78. package/dist/changelog-XUVHY3QK.js +0 -93
  79. package/dist/changelog-XUVHY3QK.js.map +0 -1
  80. package/dist/check-4FSSC6HN.js.map +0 -1
  81. package/dist/chunk-7JXW2GTJ.js.map +0 -1
  82. package/dist/chunk-AKNPCB37.js.map +0 -1
  83. package/dist/chunk-DAZCOUVK.js +0 -496
  84. package/dist/chunk-DAZCOUVK.js.map +0 -1
  85. package/dist/chunk-GAM4MXPC.js +0 -15
  86. package/dist/chunk-GAM4MXPC.js.map +0 -1
  87. package/dist/chunk-IHTYAW7C.js.map +0 -1
  88. package/dist/chunk-N77RNV7J.js.map +0 -1
  89. package/dist/chunk-SRZ33RJP.js +0 -1147
  90. package/dist/chunk-SRZ33RJP.js.map +0 -1
  91. package/dist/diff-OXZ34NU4.js +0 -107
  92. package/dist/diff-OXZ34NU4.js.map +0 -1
  93. package/dist/dist-4DIRTBJH.js.map +0 -1
  94. package/dist/explain-QBV3AESQ.js +0 -109
  95. package/dist/explain-QBV3AESQ.js.map +0 -1
  96. package/dist/generate-7GNPT2WJ.js +0 -13
  97. package/dist/generate-7GNPT2WJ.js.map +0 -1
  98. package/dist/generate-story-EFHGINHA.js.map +0 -1
  99. package/dist/generate-test-plan-BO7444RG.js.map +0 -1
  100. package/dist/graph-5XINV7PT.js.map +0 -1
  101. package/dist/lint-PTMWMLDQ.js +0 -122
  102. package/dist/lint-PTMWMLDQ.js.map +0 -1
  103. package/dist/mcp-BGFAPM6G.js +0 -17
  104. package/dist/mcp-BGFAPM6G.js.map +0 -1
  105. package/dist/migrate-4KF6GHLO.js.map +0 -1
  106. package/dist/pack-DSOODXAN.js.map +0 -1
  107. package/dist/ready-6DNKIHP6.js.map +0 -1
  108. package/dist/skills-3GBBWZW2.js +0 -93
  109. package/dist/skills-3GBBWZW2.js.map +0 -1
  110. package/dist/status-WZK247CI.js.map +0 -1
  111. package/dist/update-JTNSYX3B.js.map +0 -1
  112. package/dist/validate-LBDYWUDX.js.map +0 -1
  113. /package/dist/{dist-RL2DT3ZE.js.map → chunk-5WRI5ZAA.js.map} +0 -0
  114. /package/dist/skills/{spec-type-reference.md → core/specdx-author-spec/references/spec-type-reference.md} +0 -0
  115. /package/dist/skills/{specdx-author-spec → core/specdx-author-spec/references}/step-03-finalize.md +0 -0
@@ -1,3 +1,7 @@
1
+ // ../check/dist/check.js
2
+ import { readFile as readFile3 } from "fs/promises";
3
+ import { join as join10 } from "path";
4
+
1
5
  // ../check/dist/spec-parsers.js
2
6
  function extractSection(content, heading) {
3
7
  const headingPattern = new RegExp(`^##\\s+${escapeRegex(heading)}\\s*$`, "im");
@@ -13,34 +17,55 @@ function escapeRegex(str) {
13
17
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
14
18
  }
15
19
  var HTTP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE"]);
20
+ function pathParams(path) {
21
+ return (path.match(/:([A-Za-z_][A-Za-z0-9_]*)/g) ?? []).map((p) => p.slice(1));
22
+ }
23
+ function hasEndpointsSection(content) {
24
+ return extractSection(content, "Endpoints") !== null;
25
+ }
16
26
  function parseEndpoints(content) {
17
27
  const section = extractSection(content, "Endpoints");
18
28
  if (!section)
19
29
  return [];
20
30
  const results = [];
31
+ const seen = /* @__PURE__ */ new Set();
32
+ const push = (rawMethod, path, description) => {
33
+ const method = rawMethod.toUpperCase();
34
+ if (!HTTP_METHODS.has(method))
35
+ return;
36
+ const key = `${method} ${path}`;
37
+ if (seen.has(key))
38
+ return;
39
+ seen.add(key);
40
+ results.push({
41
+ method,
42
+ path,
43
+ params: pathParams(path),
44
+ description: description && description.length > 0 ? description : void 0
45
+ });
46
+ };
21
47
  const headingPattern = /^###\s+(GET|POST|PUT|PATCH|DELETE)\s+(\S+)/im;
22
- const blocks = section.split(/^(?=###\s)/m);
23
- for (const block of blocks) {
48
+ for (const block of section.split(/^(?=###\s)/m)) {
24
49
  const headingMatch = headingPattern.exec(block);
25
50
  if (!headingMatch)
26
51
  continue;
27
- const rawMethod = headingMatch[1].toUpperCase();
28
- if (!HTTP_METHODS.has(rawMethod))
29
- continue;
30
- const method = rawMethod;
31
- const path = headingMatch[2];
32
- const params = (path.match(/:([A-Za-z_][A-Za-z0-9_]*)/g) ?? []).map((p) => p.slice(1));
33
52
  const afterHeading = block.slice(headingMatch.index + headingMatch[0].length);
34
53
  const descriptionLine = afterHeading.split("\n").map((l) => l.trim()).find((l) => l.length > 0 && !l.startsWith("#") && !l.startsWith("-"));
35
- results.push({
36
- method,
37
- path,
38
- params,
39
- description: descriptionLine
40
- });
54
+ push(headingMatch[1], headingMatch[2], descriptionLine);
55
+ }
56
+ const bulletPattern = new RegExp(
57
+ "^\\s*[-*+]\\s+[`*_]*\\s*(GET|POST|PUT|PATCH|DELETE)[`*_]*\\s+[`*_]*(/[^\\s`*_]*)[`*_]*\\s*(?:[\u2014\u2013:-]\\s*(.*))?$",
58
+ // optional description
59
+ "gim"
60
+ );
61
+ let bulletMatch;
62
+ while ((bulletMatch = bulletPattern.exec(section)) !== null) {
63
+ push(bulletMatch[1], bulletMatch[2], bulletMatch[3]?.trim());
41
64
  }
42
65
  return results;
43
66
  }
67
+ var TYPE_SHAPE = /^[A-Za-z_$][\w$.<>[\]]*(?:\s*[|&]\s*[A-Za-z_$][\w$.<>[\]]*)*$/;
68
+ var TYPE_NAME_SHAPE = /^[A-Za-z_$][\w$]*(?:<[\w$,\s[\]]+>)?$/;
44
69
  function parseTypeDefinitions(content) {
45
70
  const section = extractSection(content, "Data Model");
46
71
  if (!section)
@@ -48,25 +73,94 @@ function parseTypeDefinitions(content) {
48
73
  const results = [];
49
74
  const blocks = section.split(/^(?=###\s)/m);
50
75
  for (const block of blocks) {
51
- const headingMatch = /^###\s+(\S+)/m.exec(block);
76
+ const headingMatch = /^###\s+(.+?)\s*$/m.exec(block);
52
77
  if (!headingMatch)
53
78
  continue;
54
- const name = headingMatch[1];
79
+ const name = headingMatch[1].trim().replace(/^`|`$/g, "");
80
+ if (!TYPE_NAME_SHAPE.test(name))
81
+ continue;
55
82
  const fields = [];
56
- const fieldPattern = /^-\s+`([^`]+)`\s*:\s*(.+)/gm;
83
+ const fieldPattern = /^-\s+(?:`([^`]+)`|([A-Za-z_$][\w$]*\??))\s*:\s*(.+)/gm;
57
84
  let fieldMatch;
58
85
  while ((fieldMatch = fieldPattern.exec(block)) !== null) {
59
- const rawName = fieldMatch[1];
86
+ const backticked = fieldMatch[1] !== void 0;
87
+ const rawName = fieldMatch[1] ?? fieldMatch[2];
60
88
  const optional = rawName.endsWith("?");
61
89
  const fieldName = optional ? rawName.slice(0, -1) : rawName;
62
- const rawType = fieldMatch[2].trim();
90
+ const rawType = fieldMatch[3].trim();
63
91
  const type = rawType.replace(/\s*\(.*?\)\s*$/, "").trim();
92
+ if (!backticked && !TYPE_SHAPE.test(type))
93
+ continue;
64
94
  fields.push({ name: fieldName, type, optional });
65
95
  }
96
+ if (fields.length === 0)
97
+ fields.push(...parseFieldTable(block));
98
+ if (fields.length === 0)
99
+ continue;
66
100
  results.push({ name, fields });
67
101
  }
68
102
  return results;
69
103
  }
104
+ function tableCells(line) {
105
+ const trimmed = line.trim();
106
+ if (!trimmed.startsWith("|"))
107
+ return null;
108
+ return trimmed.replace(/^\|/, "").replace(/\|$/, "").split("|").map((cell) => cell.trim().replace(/^`|`$/g, ""));
109
+ }
110
+ function isTableRule(cells) {
111
+ return cells.every((cell) => /^:?-{2,}:?$/.test(cell));
112
+ }
113
+ function parseFieldTable(block) {
114
+ const rows = block.split("\n").map(tableCells);
115
+ const headerIndex = rows.findIndex((r) => r !== null);
116
+ if (headerIndex === -1)
117
+ return [];
118
+ const header = rows[headerIndex];
119
+ const nameColumn = header.findIndex((h) => /^(field|name|property|attribute|key)s?$/i.test(h));
120
+ const typeColumn = header.findIndex((h) => /^types?$/i.test(h));
121
+ if (nameColumn === -1 || typeColumn === -1)
122
+ return [];
123
+ const fields = [];
124
+ for (const cells of rows.slice(headerIndex + 1)) {
125
+ if (cells === null)
126
+ continue;
127
+ if (isTableRule(cells))
128
+ continue;
129
+ const rawName = cells[nameColumn];
130
+ const rawType = cells[typeColumn];
131
+ if (!rawName || !rawType)
132
+ continue;
133
+ const optional = rawName.endsWith("?");
134
+ const name = optional ? rawName.slice(0, -1) : rawName;
135
+ if (!/^[A-Za-z_$][\w$]*$/.test(name))
136
+ continue;
137
+ fields.push({ name, type: rawType.replace(/\s*\(.*?\)\s*$/, "").trim(), optional });
138
+ }
139
+ return fields;
140
+ }
141
+ function unreadableTypeBlocks(content) {
142
+ const section = extractSection(content, "Data Model");
143
+ if (!section)
144
+ return [];
145
+ const unreadable = [];
146
+ for (const block of section.split(/^(?=###\s)/m)) {
147
+ const headingMatch = /^###\s+(.+?)\s*$/m.exec(block);
148
+ if (!headingMatch)
149
+ continue;
150
+ const name = headingMatch[1].trim().replace(/^`|`$/g, "");
151
+ if (!TYPE_NAME_SHAPE.test(name))
152
+ continue;
153
+ const hasTable = block.split("\n").some((line) => tableCells(line) !== null);
154
+ if (!hasTable)
155
+ continue;
156
+ const parsed = parseTypeDefinitions(`## Data Model
157
+
158
+ ${block}`);
159
+ if (parsed.length === 0)
160
+ unreadable.push(name);
161
+ }
162
+ return unreadable;
163
+ }
70
164
  function parseTestCases(content) {
71
165
  const section = extractSection(content, "Test Cases");
72
166
  if (!section)
@@ -83,7 +177,15 @@ function parseTestCases(content) {
83
177
  const bulletMatch = /^-\s+(.+)/.exec(line);
84
178
  if (!bulletMatch)
85
179
  continue;
86
- const bulletText = bulletMatch[1].trim();
180
+ let bulletText = bulletMatch[1].trim();
181
+ let caseId;
182
+ const idMatch = /^\*{0,2}(TC\d+)\*{0,2}\s*[:.-]\s*/i.exec(bulletText);
183
+ if (idMatch) {
184
+ caseId = idMatch[1].toUpperCase();
185
+ bulletText = bulletText.slice(idMatch[0].length).trim();
186
+ if (!bulletText)
187
+ continue;
188
+ }
87
189
  const colonIdx = bulletText.indexOf(":");
88
190
  if (colonIdx !== -1) {
89
191
  const label = bulletText.slice(0, colonIdx).trim();
@@ -92,11 +194,15 @@ function parseTestCases(content) {
92
194
  for (const item of items) {
93
195
  const trimmed = item.trim();
94
196
  if (trimmed) {
95
- results.push({ description: `${label}: ${trimmed}`, section: currentSection });
197
+ results.push({
198
+ description: `${label}: ${trimmed}`,
199
+ section: currentSection,
200
+ id: caseId
201
+ });
96
202
  }
97
203
  }
98
204
  } else {
99
- results.push({ description: bulletText, section: currentSection });
205
+ results.push({ description: bulletText, section: currentSection, id: caseId });
100
206
  }
101
207
  }
102
208
  return results;
@@ -339,9 +445,10 @@ async function walkAppDir(dir, pathPrefix, results) {
339
445
  }
340
446
  }
341
447
  }
342
- async function extractNextjsRoutes(projectDir, appDir = "app") {
343
- const scanDir = join3(projectDir, appDir);
344
- if (!existsSync3(scanDir)) {
448
+ async function extractNextjsRoutes(projectDir, appDir) {
449
+ const candidates = appDir !== void 0 ? [appDir] : ["app", "src/app"];
450
+ const scanDir = candidates.map((dir) => join3(projectDir, dir)).find((dir) => existsSync3(dir));
451
+ if (!scanDir) {
345
452
  return [];
346
453
  }
347
454
  let tsMorph;
@@ -618,7 +725,7 @@ function inferZodType(node, SyntaxKind) {
618
725
  }
619
726
 
620
727
  // ../check/dist/extractors/prisma.js
621
- import { readFile } from "fs/promises";
728
+ import { readFile, readdir as readdir2 } from "fs/promises";
622
729
  import { join as join6 } from "path";
623
730
  var PRISMA_TYPE_MAP = {
624
731
  String: "string",
@@ -631,14 +738,37 @@ var PRISMA_TYPE_MAP = {
631
738
  Json: "unknown",
632
739
  Bytes: "Buffer"
633
740
  };
634
- async function extractPrismaModels(projectDir) {
635
- const schemaPath = join6(projectDir, "schema.prisma");
636
- let content;
741
+ async function findPrismaSchemas(projectDir) {
742
+ const found = [];
743
+ for (const relative of ["prisma/schema.prisma", "schema.prisma"]) {
744
+ const path = join6(projectDir, relative);
745
+ try {
746
+ await readFile(path, "utf-8");
747
+ found.push(path);
748
+ } catch {
749
+ }
750
+ }
751
+ const schemaDir = join6(projectDir, "prisma", "schema");
637
752
  try {
638
- content = await readFile(schemaPath, "utf-8");
753
+ for (const entry of await readdir2(schemaDir)) {
754
+ if (entry.endsWith(".prisma"))
755
+ found.push(join6(schemaDir, entry));
756
+ }
639
757
  } catch {
758
+ }
759
+ return found;
760
+ }
761
+ async function extractPrismaModels(projectDir) {
762
+ const schemaPaths = await findPrismaSchemas(projectDir);
763
+ if (schemaPaths.length === 0)
640
764
  return [];
765
+ const models = [];
766
+ for (const schemaPath of schemaPaths) {
767
+ models.push(...parseSchema(await readFile(schemaPath, "utf-8"), schemaPath));
641
768
  }
769
+ return models;
770
+ }
771
+ function parseSchema(content, schemaPath) {
642
772
  const models = [];
643
773
  const modelRe = /^model\s+(\w+)\s*\{([^}]+)\}/gm;
644
774
  let modelMatch;
@@ -789,7 +919,11 @@ function matchTypes(specTypes, codeTypes, specId) {
789
919
  specSection: "Data Models",
790
920
  expected: `Type: ${specType.name}`,
791
921
  severity: "error",
792
- suggestion: `Implement type "${specType.name}" in code`
922
+ suggestion: `Implement type "${specType.name}" in code`,
923
+ // The score's types denominator counts fields; an absent type must
924
+ // subtract all of its fields, not 1, or a project that implements
925
+ // nothing of an N-field model scores (N-1)/N.
926
+ weight: specType.fields.length
793
927
  });
794
928
  continue;
795
929
  }
@@ -857,7 +991,10 @@ function matchTests(specCases, codeTests, specId) {
857
991
  category: "test",
858
992
  specId,
859
993
  specSection: specCase.section,
860
- expected: specCase.description,
994
+ // `expected` keeps the case ID so the finding can be traced back to a
995
+ // line in the test plan; the suggestion is the test name to write, and
996
+ // the spec's own label is no part of that.
997
+ expected: specCase.id ? `${specCase.id}: ${specCase.description}` : specCase.description,
861
998
  severity: "warn",
862
999
  suggestion: `Add a test matching: "${specCase.description}"`
863
1000
  });
@@ -951,8 +1088,12 @@ async function checkArtifacts(specs, projectDir, tsMorphAvailable) {
951
1088
  continue;
952
1089
  }
953
1090
  for (const name of artifact.exports) {
954
- total += 1;
955
- if (!exported.has(name)) {
1091
+ if (exported.has(name)) {
1092
+ total += 1;
1093
+ continue;
1094
+ }
1095
+ if (enforced) {
1096
+ total += 1;
956
1097
  findings.push({
957
1098
  type: "missing",
958
1099
  category: "artifact",
@@ -962,6 +1103,17 @@ async function checkArtifacts(specs, projectDir, tsMorphAvailable) {
962
1103
  severity: "error",
963
1104
  suggestion: `Export ${name} from ${artifact.path} or update the artifacts list in ${specId}.`
964
1105
  });
1106
+ } else {
1107
+ pending += 1;
1108
+ findings.push({
1109
+ type: "pending",
1110
+ category: "artifact",
1111
+ specId,
1112
+ codeLocation: { file: artifact.path, line: 1 },
1113
+ expected: `export "${name}" from ${artifact.path}`,
1114
+ severity: "info",
1115
+ suggestion: `planned by ${specId} (status: ${String(status)}) \u2014 not yet implemented; enforced once the spec is approved.`
1116
+ });
965
1117
  }
966
1118
  }
967
1119
  }
@@ -970,7 +1122,7 @@ async function checkArtifacts(specs, projectDir, tsMorphAvailable) {
970
1122
  notes.push(`artifact export checks skipped for ${skippedExports} export(s): ts-morph is not available or the file could not be parsed.`);
971
1123
  }
972
1124
  if (pending > 0) {
973
- notes.push(`${pending} declared artifact(s) pending: planned by specs that are not yet approved. They are excluded from the score and become enforceable when the spec status changes to approved.`);
1125
+ notes.push(`${pending} declared artifact assertion(s) pending: files or exports planned by specs that are not yet approved. They are excluded from the score and become enforceable when the spec status changes to approved.`);
974
1126
  }
975
1127
  return { findings, total, checked: total, pending, notes };
976
1128
  }
@@ -980,7 +1132,7 @@ function computeScore(findings, totals) {
980
1132
  const missingByCategory = { route: 0, type: 0, test: 0, artifact: 0 };
981
1133
  for (const f of findings) {
982
1134
  if (f.type === "missing" || f.type === "mismatch") {
983
- missingByCategory[f.category] = (missingByCategory[f.category] ?? 0) + 1;
1135
+ missingByCategory[f.category] = (missingByCategory[f.category] ?? 0) + (f.weight ?? 1);
984
1136
  }
985
1137
  }
986
1138
  const categoryMap = {
@@ -1032,6 +1184,15 @@ async function detectFramework(projectDir) {
1032
1184
  }
1033
1185
 
1034
1186
  // ../check/dist/check.js
1187
+ async function usesPrisma(projectDir) {
1188
+ try {
1189
+ const pkg = JSON.parse(await readFile3(join10(projectDir, "package.json"), "utf-8"));
1190
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
1191
+ return "prisma" in deps || "@prisma/client" in deps;
1192
+ } catch {
1193
+ return false;
1194
+ }
1195
+ }
1035
1196
  async function runCheck(specs, projectDir, config = {}) {
1036
1197
  const findings = [];
1037
1198
  const notes = [];
@@ -1043,7 +1204,7 @@ async function runCheck(specs, projectDir, config = {}) {
1043
1204
  let codeTestCount = null;
1044
1205
  const tsMorphAvailable = await import("ts-morph").then(() => true, () => false);
1045
1206
  if (!tsMorphAvailable) {
1046
- notes.push("route and type extraction skipped: ts-morph is not installed. Install specdx and ts-morph as devDependencies (pnpm add -D specdx ts-morph) \u2014 an ephemeral runner like pnpm dlx cannot provide it.");
1207
+ notes.push("route, type and test extraction skipped: ts-morph is not installed. Install specdx and ts-morph as devDependencies (pnpm add -D specdx ts-morph) \u2014 an ephemeral runner like pnpm dlx cannot provide it.");
1047
1208
  }
1048
1209
  const framework = config.framework && config.framework !== "auto" ? config.framework : await detectFramework(projectDir);
1049
1210
  const apiContractSpecs = specs.filter((s) => s.frontmatter.type === "api-contract");
@@ -1054,27 +1215,41 @@ async function runCheck(specs, projectDir, config = {}) {
1054
1215
  const specEndpoints = parseEndpoints(spec.content);
1055
1216
  routeTotal += specEndpoints.length;
1056
1217
  findings.push(...matchRoutes(specEndpoints, codeRoutes, spec.frontmatter.id));
1218
+ if (specEndpoints.length === 0 && hasEndpointsSection(spec.content)) {
1219
+ notes.push(`${spec.frontmatter.id}: no endpoints recognised in its Endpoints section, so routes were not assessed. Write each endpoint as \`- GET /path \u2014 description\` or as a \`### GET /path\` heading.`);
1220
+ }
1057
1221
  }
1058
1222
  if (framework === null) {
1059
1223
  notes.push("no supported framework detected (express, hono, nextjs) \u2014 route extraction ran in fallback mode across all extractors.");
1060
1224
  }
1061
1225
  }
1062
1226
  const designSpecs = specs.filter((s) => s.frontmatter.type === "technical-design");
1063
- if (designSpecs.length > 0) {
1227
+ const prismaSchemaFound = (await findPrismaSchemas(projectDir)).length > 0;
1228
+ if (designSpecs.length > 0 && (tsMorphAvailable || prismaSchemaFound)) {
1064
1229
  const codeTypes = [
1065
1230
  ...tsMorphAvailable ? await extractTypeScriptTypes(projectDir, config.types_dir) : [],
1066
1231
  ...tsMorphAvailable ? await extractZodSchemas(projectDir, config.types_dir) : [],
1067
1232
  ...await extractPrismaModels(projectDir)
1068
1233
  ];
1069
1234
  codeTypeCount = codeTypes.length;
1235
+ if (await usesPrisma(projectDir) && !prismaSchemaFound) {
1236
+ notes.push("a prisma dependency is declared but no schema was found at prisma/schema.prisma, schema.prisma or prisma/schema/*.prisma \u2014 Prisma models were not assessed.");
1237
+ }
1070
1238
  for (const spec of designSpecs) {
1071
1239
  const specTypes = parseTypeDefinitions(spec.content);
1072
- typeTotal += specTypes.reduce((sum, t) => sum + t.fields.length, 0);
1240
+ const fieldCount = specTypes.reduce((sum, t) => sum + t.fields.length, 0);
1241
+ typeTotal += fieldCount;
1073
1242
  findings.push(...matchTypes(specTypes, codeTypes, spec.frontmatter.id));
1243
+ if (fieldCount === 0 && /^##\s+Data Model\s*$/im.test(spec.content)) {
1244
+ notes.push(`${spec.frontmatter.id}: no fields recognised in its Data Model, so types were not assessed. Write fields as \`- name: type\` (one per line, under a \`### TypeName\` heading).`);
1245
+ }
1246
+ for (const name of unreadableTypeBlocks(spec.content)) {
1247
+ notes.push(`${spec.frontmatter.id}: no fields recognised under \`### ${name}\`, so that type was not assessed. A table needs a field column and a type column, or write fields as \`- name: type\`.`);
1248
+ }
1074
1249
  }
1075
1250
  }
1076
1251
  const testPlanSpecs = specs.filter((s) => s.frontmatter.type === "test-plan");
1077
- if (testPlanSpecs.length > 0) {
1252
+ if (testPlanSpecs.length > 0 && tsMorphAvailable) {
1078
1253
  const codeTests = await extractTestDescriptions(projectDir, config.tests_dir);
1079
1254
  codeTestCount = codeTests.length;
1080
1255
  for (const spec of testPlanSpecs) {
@@ -1127,7 +1302,7 @@ async function extractRoutes(projectDir, config, framework) {
1127
1302
  async function analyzeWithAi(findings, context) {
1128
1303
  const apiKey = process.env["ANTHROPIC_API_KEY"];
1129
1304
  if (!apiKey) {
1130
- throw new Error("ANTHROPIC_API_KEY environment variable is required for --ai mode. Set it or use the sdx:verify skill instead (no API key needed).");
1305
+ throw new Error("ANTHROPIC_API_KEY environment variable is required for --ai mode. Set it or use the specdx-verify skill instead (no API key needed).");
1131
1306
  }
1132
1307
  if (findings.length === 0) {
1133
1308
  return { findings, assessments: [], summary: "No findings to analyze." };
@@ -1183,4 +1358,4 @@ export {
1183
1358
  runCheck,
1184
1359
  analyzeWithAi
1185
1360
  };
1186
- //# sourceMappingURL=chunk-N77RNV7J.js.map
1361
+ //# sourceMappingURL=chunk-3YXRWQGX.js.map