@openpkg-ts/spec 0.8.0 → 0.10.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/dist/index.d.ts CHANGED
@@ -256,6 +256,79 @@ type OpenPkgMeta = {
256
256
  repository?: string;
257
257
  ecosystem?: string;
258
258
  };
259
+ /**
260
+ * Method used to detect the entry point for analysis.
261
+ */
262
+ type EntryPointDetectionMethod = "types" | "exports" | "main" | "module" | "fallback" | "explicit" | "llm";
263
+ /**
264
+ * Severity level for issues encountered during spec generation.
265
+ */
266
+ type GenerationIssueSeverity = "error" | "warning" | "info";
267
+ /**
268
+ * An issue encountered during spec generation.
269
+ */
270
+ type GenerationIssue = {
271
+ /** Machine-readable issue code */
272
+ code: string;
273
+ /** Human-readable issue message */
274
+ message: string;
275
+ /** Severity level */
276
+ severity: GenerationIssueSeverity;
277
+ /** Suggested resolution */
278
+ suggestion?: string;
279
+ };
280
+ /**
281
+ * Metadata about how a spec was generated.
282
+ * Provides transparency about the analysis process and any limitations.
283
+ */
284
+ type SpecGenerationInfo = {
285
+ /** ISO 8601 timestamp of when the spec was generated */
286
+ timestamp: string;
287
+ /** Information about the tool that generated the spec */
288
+ generator: {
289
+ /** Tool name (e.g., '@doccov/cli', '@doccov/api') */
290
+ name: string;
291
+ /** Tool version */
292
+ version: string;
293
+ };
294
+ /** Details about the analysis process */
295
+ analysis: {
296
+ /** Entry point file that was analyzed (relative path) */
297
+ entryPoint: string;
298
+ /** How the entry point was detected */
299
+ entryPointSource: EntryPointDetectionMethod;
300
+ /** Whether this was a declaration-only analysis (.d.ts file) */
301
+ isDeclarationOnly: boolean;
302
+ /** Whether external types from node_modules were resolved */
303
+ resolvedExternalTypes: boolean;
304
+ /** Maximum type depth used for nested type resolution */
305
+ maxTypeDepth?: number;
306
+ /** Schema extraction method and metadata */
307
+ schemaExtraction?: {
308
+ /** How schemas were extracted */
309
+ method: "standard-json-schema" | "static-ast" | "hybrid";
310
+ /** Number of schemas extracted via Standard Schema runtime */
311
+ runtimeCount?: number;
312
+ /** Vendors detected (e.g., ['zod', 'valibot']) */
313
+ vendors?: string[];
314
+ };
315
+ };
316
+ /** Environment information during generation */
317
+ environment: {
318
+ /** Detected package manager */
319
+ packageManager?: string;
320
+ /** Whether node_modules was available for type resolution */
321
+ hasNodeModules: boolean;
322
+ /** Whether this is a monorepo */
323
+ isMonorepo?: boolean;
324
+ /** Target package name (for monorepos) */
325
+ targetPackage?: string;
326
+ };
327
+ /** Issues encountered during generation */
328
+ issues: GenerationIssue[];
329
+ /** Whether the result came from cache */
330
+ fromCache?: boolean;
331
+ };
259
332
  /** Supported OpenPkg spec versions */
260
333
  type OpenPkgVersion = "0.2.0" | "0.3.0";
261
334
  type OpenPkg = {
@@ -266,6 +339,8 @@ type OpenPkg = {
266
339
  types?: SpecType[];
267
340
  examples?: SpecExample[];
268
341
  extensions?: SpecExtension;
342
+ /** Required metadata about how this spec was generated */
343
+ generation: SpecGenerationInfo;
269
344
  };
270
345
  declare const SCHEMA_VERSION: OpenPkgVersion;
271
346
  declare const SCHEMA_URL = "https://unpkg.com/@openpkg-ts/spec/schemas/v0.3.0/openpkg.schema.json";
@@ -326,6 +401,63 @@ declare function diffSpec(oldSpec: SpecWithDocs, newSpec: SpecWithDocs): SpecDif
326
401
  * @returns Categorized breaking changes sorted by severity (high first)
327
402
  */
328
403
  declare function categorizeBreakingChanges(breaking: string[], oldSpec: SpecWithDocs, newSpec: SpecWithDocs, memberChanges?: MemberChangeInfo[]): CategorizedBreaking[];
404
+ /**
405
+ * Semver version bump type.
406
+ */
407
+ type SemverBump = "major" | "minor" | "patch" | "none";
408
+ /**
409
+ * Semver recommendation result.
410
+ */
411
+ interface SemverRecommendation {
412
+ /** Recommended version bump */
413
+ bump: SemverBump;
414
+ /** Reason for the recommendation */
415
+ reason: string;
416
+ /** Count of breaking changes */
417
+ breakingCount: number;
418
+ /** Count of non-breaking additions */
419
+ additionCount: number;
420
+ /** Whether only docs changed */
421
+ docsOnlyChanges: boolean;
422
+ }
423
+ /**
424
+ * Recommend a semver version bump based on spec diff.
425
+ *
426
+ * - MAJOR: Any breaking changes (removals or signature changes)
427
+ * - MINOR: New exports/types added (non-breaking)
428
+ * - PATCH: Documentation-only changes
429
+ * - NONE: No changes
430
+ *
431
+ * @param diff - The spec diff result
432
+ * @returns Semver recommendation with reason
433
+ *
434
+ * @example
435
+ * ```typescript
436
+ * import { diffSpec, recommendSemverBump } from '@openpkg-ts/spec';
437
+ *
438
+ * const diff = diffSpec(oldSpec, newSpec);
439
+ * const recommendation = recommendSemverBump(diff);
440
+ *
441
+ * console.log(`Recommended: ${recommendation.bump}`);
442
+ * console.log(`Reason: ${recommendation.reason}`);
443
+ * ```
444
+ */
445
+ declare function recommendSemverBump(diff: SpecDiff): SemverRecommendation;
446
+ /**
447
+ * Calculate the next version number based on current version and recommended bump.
448
+ *
449
+ * @param currentVersion - Current version string (e.g., "1.2.3")
450
+ * @param bump - Recommended bump type
451
+ * @returns Next version string
452
+ *
453
+ * @example
454
+ * ```typescript
455
+ * calculateNextVersion('1.2.3', 'major'); // '2.0.0'
456
+ * calculateNextVersion('1.2.3', 'minor'); // '1.3.0'
457
+ * calculateNextVersion('1.2.3', 'patch'); // '1.2.4'
458
+ * ```
459
+ */
460
+ declare function calculateNextVersion(currentVersion: string, bump: SemverBump): string;
329
461
  declare function normalize(spec: OpenPkg): OpenPkg;
330
462
  /** Supported schema versions */
331
463
  type SchemaVersion = "0.1.0" | "0.2.0" | "0.3.0" | "latest";
@@ -363,4 +495,4 @@ declare function assertSpec(spec: unknown, version?: SchemaVersion): asserts spe
363
495
  * @returns Array of validation errors (empty if valid)
364
496
  */
365
497
  declare function getValidationErrors(spec: unknown, version?: SchemaVersion): SpecError[];
366
- export { validateSpec, normalize, getValidationErrors, diffSpec, dereference, categorizeBreakingChanges, assertSpec, SpecVisibility, SpecTypeParameter, SpecTypeKind, SpecTypeAliasKind, SpecType, SpecThrows, SpecTag, SpecSource, SpecSignatureReturn, SpecSignatureParameter, SpecSignature, SpecSchemaRef, SpecSchemaPrimitive, SpecSchemaGeneric, SpecSchemaFallback, SpecSchemaComposite, SpecSchemaCombinator, SpecSchema, SpecRelationType, SpecRelation, SpecMember, SpecMappedType, SpecExtension, SpecExportKind, SpecExport, SpecExampleLanguage, SpecExample, SpecDocsMetadata, SpecDocDrift, SpecDiff, SpecDecorator, SpecConditionalType, SCHEMA_VERSION, SCHEMA_URL, OpenPkgVersion, OpenPkgMeta, OpenPkg, MemberChangeInfo, JSON_SCHEMA_DRAFT, DriftType, DriftCategory, DRIFT_CATEGORY_LABELS, DRIFT_CATEGORY_DESCRIPTIONS, DRIFT_CATEGORIES, CategorizedBreaking, BreakingSeverity };
498
+ export { validateSpec, recommendSemverBump, normalize, getValidationErrors, diffSpec, dereference, categorizeBreakingChanges, calculateNextVersion, assertSpec, SpecVisibility, SpecTypeParameter, SpecTypeKind, SpecTypeAliasKind, SpecType, SpecThrows, SpecTag, SpecSource, SpecSignatureReturn, SpecSignatureParameter, SpecSignature, SpecSchemaRef, SpecSchemaPrimitive, SpecSchemaGeneric, SpecSchemaFallback, SpecSchemaComposite, SpecSchemaCombinator, SpecSchema, SpecRelationType, SpecRelation, SpecMember, SpecMappedType, SpecGenerationInfo, SpecExtension, SpecExportKind, SpecExport, SpecExampleLanguage, SpecExample, SpecDocsMetadata, SpecDocDrift, SpecDiff, SpecDecorator, SpecConditionalType, SemverRecommendation, SemverBump, SCHEMA_VERSION, SCHEMA_URL, OpenPkgVersion, OpenPkgMeta, OpenPkg, MemberChangeInfo, JSON_SCHEMA_DRAFT, GenerationIssueSeverity, GenerationIssue, EntryPointDetectionMethod, DriftType, DriftCategory, DRIFT_CATEGORY_LABELS, DRIFT_CATEGORY_DESCRIPTIONS, DRIFT_CATEGORIES, CategorizedBreaking, BreakingSeverity };
package/dist/index.js CHANGED
@@ -282,6 +282,72 @@ function categorizeBreakingChanges(breaking, oldSpec, newSpec, memberChanges) {
282
282
  const severityOrder = { high: 0, medium: 1, low: 2 };
283
283
  return categorized.sort((a, b) => severityOrder[a.severity] - severityOrder[b.severity]);
284
284
  }
285
+ function recommendSemverBump(diff) {
286
+ const breakingCount = diff.breaking.length;
287
+ const additionCount = diff.nonBreaking.length;
288
+ const docsOnlyCount = diff.docsOnly.length;
289
+ if (breakingCount > 0) {
290
+ return {
291
+ bump: "major",
292
+ reason: `${breakingCount} breaking change${breakingCount === 1 ? "" : "s"} detected`,
293
+ breakingCount,
294
+ additionCount,
295
+ docsOnlyChanges: false
296
+ };
297
+ }
298
+ if (additionCount > 0) {
299
+ return {
300
+ bump: "minor",
301
+ reason: `${additionCount} new export${additionCount === 1 ? "" : "s"} added`,
302
+ breakingCount: 0,
303
+ additionCount,
304
+ docsOnlyChanges: false
305
+ };
306
+ }
307
+ if (docsOnlyCount > 0) {
308
+ return {
309
+ bump: "patch",
310
+ reason: `${docsOnlyCount} documentation-only change${docsOnlyCount === 1 ? "" : "s"}`,
311
+ breakingCount: 0,
312
+ additionCount: 0,
313
+ docsOnlyChanges: true
314
+ };
315
+ }
316
+ return {
317
+ bump: "none",
318
+ reason: "No changes detected",
319
+ breakingCount: 0,
320
+ additionCount: 0,
321
+ docsOnlyChanges: false
322
+ };
323
+ }
324
+ function calculateNextVersion(currentVersion, bump) {
325
+ if (bump === "none") {
326
+ return currentVersion;
327
+ }
328
+ const normalized = currentVersion.replace(/^v/, "");
329
+ const match = normalized.match(/^(\d+)\.(\d+)\.(\d+)/);
330
+ if (!match) {
331
+ return currentVersion;
332
+ }
333
+ let [, major, minor, patch] = match.map(Number);
334
+ switch (bump) {
335
+ case "major":
336
+ major++;
337
+ minor = 0;
338
+ patch = 0;
339
+ break;
340
+ case "minor":
341
+ minor++;
342
+ patch = 0;
343
+ break;
344
+ case "patch":
345
+ patch++;
346
+ break;
347
+ }
348
+ const prefix = currentVersion.startsWith("v") ? "v" : "";
349
+ return `${prefix}${major}.${minor}.${patch}`;
350
+ }
285
351
  // src/normalize.ts
286
352
  var DEFAULT_ECOSYSTEM = "js/ts";
287
353
  var arrayFieldsByExport = ["signatures", "members", "examples", "tags"];
@@ -1083,7 +1149,7 @@ var openpkg_schema_default3 = {
1083
1149
  title: "OpenPkg Specification",
1084
1150
  description: "Schema for OpenPkg specification files",
1085
1151
  type: "object",
1086
- required: ["openpkg", "meta", "exports"],
1152
+ required: ["openpkg", "meta", "exports", "generation"],
1087
1153
  properties: {
1088
1154
  $schema: {
1089
1155
  type: "string",
@@ -1141,12 +1207,174 @@ var openpkg_schema_default3 = {
1141
1207
  $ref: "#/$defs/typeDef"
1142
1208
  }
1143
1209
  },
1144
- docs: {
1145
- $ref: "#/$defs/docsMetadata",
1146
- description: "Aggregate documentation coverage metadata"
1210
+ examples: {
1211
+ type: "array",
1212
+ description: "Package-level usage examples",
1213
+ items: {
1214
+ $ref: "#/$defs/example"
1215
+ }
1216
+ },
1217
+ extensions: {
1218
+ type: "object",
1219
+ description: "Custom extension data",
1220
+ additionalProperties: true
1221
+ },
1222
+ generation: {
1223
+ $ref: "#/$defs/generationInfo",
1224
+ description: "Required metadata about how this spec was generated"
1147
1225
  }
1148
1226
  },
1149
1227
  $defs: {
1228
+ entryPointDetectionMethod: {
1229
+ type: "string",
1230
+ description: "Method used to detect the entry point for analysis",
1231
+ enum: ["types", "exports", "main", "module", "fallback", "explicit", "llm"]
1232
+ },
1233
+ generationIssueSeverity: {
1234
+ type: "string",
1235
+ description: "Severity level for issues encountered during spec generation",
1236
+ enum: ["error", "warning", "info"]
1237
+ },
1238
+ generationIssue: {
1239
+ type: "object",
1240
+ description: "An issue encountered during spec generation",
1241
+ required: ["code", "message", "severity"],
1242
+ properties: {
1243
+ code: {
1244
+ type: "string",
1245
+ description: "Machine-readable issue code"
1246
+ },
1247
+ message: {
1248
+ type: "string",
1249
+ description: "Human-readable issue message"
1250
+ },
1251
+ severity: {
1252
+ $ref: "#/$defs/generationIssueSeverity"
1253
+ },
1254
+ suggestion: {
1255
+ type: "string",
1256
+ description: "Suggested resolution"
1257
+ }
1258
+ },
1259
+ additionalProperties: false
1260
+ },
1261
+ generationInfo: {
1262
+ type: "object",
1263
+ description: "Metadata about how the spec was generated",
1264
+ required: ["timestamp", "generator", "analysis", "environment", "issues"],
1265
+ properties: {
1266
+ timestamp: {
1267
+ type: "string",
1268
+ format: "date-time",
1269
+ description: "ISO 8601 timestamp of when the spec was generated"
1270
+ },
1271
+ generator: {
1272
+ type: "object",
1273
+ description: "Information about the tool that generated the spec",
1274
+ required: ["name", "version"],
1275
+ properties: {
1276
+ name: {
1277
+ type: "string",
1278
+ description: "Tool name (e.g., '@doccov/cli', '@doccov/api')"
1279
+ },
1280
+ version: {
1281
+ type: "string",
1282
+ description: "Tool version"
1283
+ }
1284
+ },
1285
+ additionalProperties: false
1286
+ },
1287
+ analysis: {
1288
+ type: "object",
1289
+ description: "Details about the analysis process",
1290
+ required: [
1291
+ "entryPoint",
1292
+ "entryPointSource",
1293
+ "isDeclarationOnly",
1294
+ "resolvedExternalTypes"
1295
+ ],
1296
+ properties: {
1297
+ entryPoint: {
1298
+ type: "string",
1299
+ description: "Entry point file that was analyzed (relative path)"
1300
+ },
1301
+ entryPointSource: {
1302
+ $ref: "#/$defs/entryPointDetectionMethod"
1303
+ },
1304
+ isDeclarationOnly: {
1305
+ type: "boolean",
1306
+ description: "Whether this was a declaration-only analysis (.d.ts file)"
1307
+ },
1308
+ resolvedExternalTypes: {
1309
+ type: "boolean",
1310
+ description: "Whether external types from node_modules were resolved"
1311
+ },
1312
+ maxTypeDepth: {
1313
+ type: "integer",
1314
+ description: "Maximum type depth used for nested type resolution"
1315
+ },
1316
+ schemaExtraction: {
1317
+ type: "object",
1318
+ description: "Schema extraction method and metadata",
1319
+ properties: {
1320
+ method: {
1321
+ type: "string",
1322
+ description: "How schemas were extracted",
1323
+ enum: ["standard-json-schema", "static-ast", "hybrid"]
1324
+ },
1325
+ runtimeCount: {
1326
+ type: "integer",
1327
+ description: "Number of schemas extracted via Standard Schema runtime"
1328
+ },
1329
+ vendors: {
1330
+ type: "array",
1331
+ description: "Vendors detected (e.g., ['zod', 'valibot'])",
1332
+ items: { type: "string" }
1333
+ }
1334
+ },
1335
+ additionalProperties: false
1336
+ }
1337
+ },
1338
+ additionalProperties: false
1339
+ },
1340
+ environment: {
1341
+ type: "object",
1342
+ description: "Environment information during generation",
1343
+ required: ["hasNodeModules"],
1344
+ properties: {
1345
+ packageManager: {
1346
+ type: "string",
1347
+ description: "Detected package manager"
1348
+ },
1349
+ hasNodeModules: {
1350
+ type: "boolean",
1351
+ description: "Whether node_modules was available for type resolution"
1352
+ },
1353
+ isMonorepo: {
1354
+ type: "boolean",
1355
+ description: "Whether this is a monorepo"
1356
+ },
1357
+ targetPackage: {
1358
+ type: "string",
1359
+ description: "Target package name (for monorepos)"
1360
+ }
1361
+ },
1362
+ additionalProperties: false
1363
+ },
1364
+ issues: {
1365
+ type: "array",
1366
+ description: "Issues encountered during generation",
1367
+ items: {
1368
+ $ref: "#/$defs/generationIssue"
1369
+ }
1370
+ },
1371
+ fromCache: {
1372
+ type: "boolean",
1373
+ description: "Whether the result came from cache"
1374
+ }
1375
+ },
1376
+ additionalProperties: false
1377
+ },
1150
1378
  docSignal: {
1151
1379
  type: "string",
1152
1380
  enum: ["description", "params", "returns", "examples"]
@@ -1259,7 +1487,9 @@ var openpkg_schema_default3 = {
1259
1487
  "interface",
1260
1488
  "type",
1261
1489
  "enum",
1490
+ "module",
1262
1491
  "namespace",
1492
+ "reference",
1263
1493
  "external"
1264
1494
  ]
1265
1495
  },
@@ -1288,7 +1518,7 @@ var openpkg_schema_default3 = {
1288
1518
  members: {
1289
1519
  type: "array",
1290
1520
  description: "Class/interface/enum members",
1291
- items: { type: "object" }
1521
+ items: { $ref: "#/$defs/member" }
1292
1522
  },
1293
1523
  extends: {
1294
1524
  type: "string",
@@ -1309,6 +1539,24 @@ var openpkg_schema_default3 = {
1309
1539
  source: {
1310
1540
  $ref: "#/$defs/sourceLocation"
1311
1541
  },
1542
+ deprecated: {
1543
+ type: "boolean",
1544
+ description: "Whether this export is deprecated"
1545
+ },
1546
+ flags: {
1547
+ type: "object",
1548
+ description: "Export flags (readonly, abstract, etc.)",
1549
+ additionalProperties: true
1550
+ },
1551
+ schema: {
1552
+ $ref: "#/$defs/schema",
1553
+ description: "Inline schema for the export"
1554
+ },
1555
+ typeParameters: {
1556
+ type: "array",
1557
+ description: "Generic type parameters",
1558
+ items: { $ref: "#/$defs/typeParameter" }
1559
+ },
1312
1560
  docs: {
1313
1561
  $ref: "#/$defs/docsMetadata",
1314
1562
  description: "Documentation coverage metadata for this export"
@@ -1398,7 +1646,7 @@ var openpkg_schema_default3 = {
1398
1646
  members: {
1399
1647
  type: "array",
1400
1648
  description: "Members for classes/interfaces/enums",
1401
- items: { type: "object" }
1649
+ items: { $ref: "#/$defs/member" }
1402
1650
  },
1403
1651
  extends: {
1404
1652
  type: "string",
@@ -1419,6 +1667,10 @@ var openpkg_schema_default3 = {
1419
1667
  source: {
1420
1668
  $ref: "#/$defs/sourceLocation"
1421
1669
  },
1670
+ rawComments: {
1671
+ type: "string",
1672
+ description: "Raw JSDoc/TSDoc comment text"
1673
+ },
1422
1674
  typeAliasKind: {
1423
1675
  $ref: "#/$defs/typeAliasKind",
1424
1676
  description: "Kind of type alias"
@@ -1539,7 +1791,7 @@ var openpkg_schema_default3 = {
1539
1791
  },
1540
1792
  parameter: {
1541
1793
  type: "object",
1542
- required: ["name", "required"],
1794
+ required: ["name"],
1543
1795
  properties: {
1544
1796
  name: {
1545
1797
  type: "string",
@@ -1582,6 +1834,26 @@ var openpkg_schema_default3 = {
1582
1834
  }
1583
1835
  }
1584
1836
  },
1837
+ schemaType: {
1838
+ type: "string",
1839
+ description: "Explicit type enum aligned with TypeScript type system",
1840
+ enum: [
1841
+ "string",
1842
+ "number",
1843
+ "boolean",
1844
+ "integer",
1845
+ "null",
1846
+ "undefined",
1847
+ "any",
1848
+ "unknown",
1849
+ "never",
1850
+ "void",
1851
+ "array",
1852
+ "tuple",
1853
+ "object",
1854
+ "function"
1855
+ ]
1856
+ },
1585
1857
  schema: {
1586
1858
  description: "Flexible JSON Schema for type representation",
1587
1859
  oneOf: [
@@ -1594,6 +1866,11 @@ var openpkg_schema_default3 = {
1594
1866
  format: { type: "string" },
1595
1867
  enum: { type: "array" },
1596
1868
  items: { $ref: "#/$defs/schema" },
1869
+ prefixedItems: {
1870
+ type: "array",
1871
+ items: { $ref: "#/$defs/schema" },
1872
+ description: "Tuple element schemas (draft-2020-12)"
1873
+ },
1597
1874
  properties: {
1598
1875
  type: "object",
1599
1876
  additionalProperties: { $ref: "#/$defs/schema" }
@@ -1614,14 +1891,13 @@ var openpkg_schema_default3 = {
1614
1891
  description: { type: "string" },
1615
1892
  minItems: { type: "integer" },
1616
1893
  maxItems: { type: "integer" },
1617
- signatures: { type: "array" }
1894
+ signatures: { type: "array", items: { $ref: "#/$defs/signature" } }
1618
1895
  }
1619
1896
  }
1620
1897
  ]
1621
1898
  },
1622
1899
  sourceLocation: {
1623
1900
  type: "object",
1624
- required: ["file", "line"],
1625
1901
  properties: {
1626
1902
  file: {
1627
1903
  type: "string",
@@ -1631,6 +1907,10 @@ var openpkg_schema_default3 = {
1631
1907
  type: "integer",
1632
1908
  description: "Line number in source file",
1633
1909
  minimum: 1
1910
+ },
1911
+ url: {
1912
+ type: "string",
1913
+ description: "URL to source (e.g., GitHub permalink)"
1634
1914
  }
1635
1915
  }
1636
1916
  },
@@ -1773,6 +2053,56 @@ var openpkg_schema_default3 = {
1773
2053
  }
1774
2054
  ]
1775
2055
  },
2056
+ visibility: {
2057
+ type: "string",
2058
+ description: "Visibility modifier for class members",
2059
+ enum: ["public", "protected", "private"]
2060
+ },
2061
+ member: {
2062
+ type: "object",
2063
+ description: "Class/interface/enum member definition",
2064
+ properties: {
2065
+ id: {
2066
+ type: "string",
2067
+ description: "Unique identifier for the member"
2068
+ },
2069
+ name: {
2070
+ type: "string",
2071
+ description: "Member name"
2072
+ },
2073
+ kind: {
2074
+ type: "string",
2075
+ description: "Kind of member (e.g., 'property', 'method', 'constructor')"
2076
+ },
2077
+ description: {
2078
+ type: "string",
2079
+ description: "JSDoc/TSDoc description"
2080
+ },
2081
+ visibility: {
2082
+ $ref: "#/$defs/visibility"
2083
+ },
2084
+ tags: {
2085
+ type: "array",
2086
+ items: { $ref: "#/$defs/tag" }
2087
+ },
2088
+ flags: {
2089
+ type: "object",
2090
+ description: "Member flags (static, readonly, abstract, etc.)",
2091
+ additionalProperties: true
2092
+ },
2093
+ schema: {
2094
+ $ref: "#/$defs/schema"
2095
+ },
2096
+ signatures: {
2097
+ type: "array",
2098
+ items: { $ref: "#/$defs/signature" }
2099
+ },
2100
+ decorators: {
2101
+ type: "array",
2102
+ items: { $ref: "#/$defs/decorator" }
2103
+ }
2104
+ }
2105
+ },
1776
2106
  relationType: {
1777
2107
  type: "string",
1778
2108
  description: "Type of relationship between exports",
@@ -1860,11 +2190,13 @@ function getValidationErrors(spec, version = "latest") {
1860
2190
  }
1861
2191
  export {
1862
2192
  validateSpec,
2193
+ recommendSemverBump,
1863
2194
  normalize,
1864
2195
  getValidationErrors,
1865
2196
  diffSpec,
1866
2197
  dereference,
1867
2198
  categorizeBreakingChanges,
2199
+ calculateNextVersion,
1868
2200
  assertSpec,
1869
2201
  SCHEMA_VERSION,
1870
2202
  SCHEMA_URL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpkg-ts/spec",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "Shared schema, validation, and diff utilities for OpenPkg specs",
5
5
  "keywords": [
6
6
  "openpkg",
@@ -4,7 +4,7 @@
4
4
  "title": "OpenPkg Specification",
5
5
  "description": "Schema for OpenPkg specification files",
6
6
  "type": "object",
7
- "required": ["openpkg", "meta", "exports"],
7
+ "required": ["openpkg", "meta", "exports", "generation"],
8
8
  "properties": {
9
9
  "$schema": {
10
10
  "type": "string",
@@ -62,12 +62,174 @@
62
62
  "$ref": "#/$defs/typeDef"
63
63
  }
64
64
  },
65
- "docs": {
66
- "$ref": "#/$defs/docsMetadata",
67
- "description": "Aggregate documentation coverage metadata"
65
+ "examples": {
66
+ "type": "array",
67
+ "description": "Package-level usage examples",
68
+ "items": {
69
+ "$ref": "#/$defs/example"
70
+ }
71
+ },
72
+ "extensions": {
73
+ "type": "object",
74
+ "description": "Custom extension data",
75
+ "additionalProperties": true
76
+ },
77
+ "generation": {
78
+ "$ref": "#/$defs/generationInfo",
79
+ "description": "Required metadata about how this spec was generated"
68
80
  }
69
81
  },
70
82
  "$defs": {
83
+ "entryPointDetectionMethod": {
84
+ "type": "string",
85
+ "description": "Method used to detect the entry point for analysis",
86
+ "enum": ["types", "exports", "main", "module", "fallback", "explicit", "llm"]
87
+ },
88
+ "generationIssueSeverity": {
89
+ "type": "string",
90
+ "description": "Severity level for issues encountered during spec generation",
91
+ "enum": ["error", "warning", "info"]
92
+ },
93
+ "generationIssue": {
94
+ "type": "object",
95
+ "description": "An issue encountered during spec generation",
96
+ "required": ["code", "message", "severity"],
97
+ "properties": {
98
+ "code": {
99
+ "type": "string",
100
+ "description": "Machine-readable issue code"
101
+ },
102
+ "message": {
103
+ "type": "string",
104
+ "description": "Human-readable issue message"
105
+ },
106
+ "severity": {
107
+ "$ref": "#/$defs/generationIssueSeverity"
108
+ },
109
+ "suggestion": {
110
+ "type": "string",
111
+ "description": "Suggested resolution"
112
+ }
113
+ },
114
+ "additionalProperties": false
115
+ },
116
+ "generationInfo": {
117
+ "type": "object",
118
+ "description": "Metadata about how the spec was generated",
119
+ "required": ["timestamp", "generator", "analysis", "environment", "issues"],
120
+ "properties": {
121
+ "timestamp": {
122
+ "type": "string",
123
+ "format": "date-time",
124
+ "description": "ISO 8601 timestamp of when the spec was generated"
125
+ },
126
+ "generator": {
127
+ "type": "object",
128
+ "description": "Information about the tool that generated the spec",
129
+ "required": ["name", "version"],
130
+ "properties": {
131
+ "name": {
132
+ "type": "string",
133
+ "description": "Tool name (e.g., '@doccov/cli', '@doccov/api')"
134
+ },
135
+ "version": {
136
+ "type": "string",
137
+ "description": "Tool version"
138
+ }
139
+ },
140
+ "additionalProperties": false
141
+ },
142
+ "analysis": {
143
+ "type": "object",
144
+ "description": "Details about the analysis process",
145
+ "required": [
146
+ "entryPoint",
147
+ "entryPointSource",
148
+ "isDeclarationOnly",
149
+ "resolvedExternalTypes"
150
+ ],
151
+ "properties": {
152
+ "entryPoint": {
153
+ "type": "string",
154
+ "description": "Entry point file that was analyzed (relative path)"
155
+ },
156
+ "entryPointSource": {
157
+ "$ref": "#/$defs/entryPointDetectionMethod"
158
+ },
159
+ "isDeclarationOnly": {
160
+ "type": "boolean",
161
+ "description": "Whether this was a declaration-only analysis (.d.ts file)"
162
+ },
163
+ "resolvedExternalTypes": {
164
+ "type": "boolean",
165
+ "description": "Whether external types from node_modules were resolved"
166
+ },
167
+ "maxTypeDepth": {
168
+ "type": "integer",
169
+ "description": "Maximum type depth used for nested type resolution"
170
+ },
171
+ "schemaExtraction": {
172
+ "type": "object",
173
+ "description": "Schema extraction method and metadata",
174
+ "properties": {
175
+ "method": {
176
+ "type": "string",
177
+ "description": "How schemas were extracted",
178
+ "enum": ["standard-json-schema", "static-ast", "hybrid"]
179
+ },
180
+ "runtimeCount": {
181
+ "type": "integer",
182
+ "description": "Number of schemas extracted via Standard Schema runtime"
183
+ },
184
+ "vendors": {
185
+ "type": "array",
186
+ "description": "Vendors detected (e.g., ['zod', 'valibot'])",
187
+ "items": { "type": "string" }
188
+ }
189
+ },
190
+ "additionalProperties": false
191
+ }
192
+ },
193
+ "additionalProperties": false
194
+ },
195
+ "environment": {
196
+ "type": "object",
197
+ "description": "Environment information during generation",
198
+ "required": ["hasNodeModules"],
199
+ "properties": {
200
+ "packageManager": {
201
+ "type": "string",
202
+ "description": "Detected package manager"
203
+ },
204
+ "hasNodeModules": {
205
+ "type": "boolean",
206
+ "description": "Whether node_modules was available for type resolution"
207
+ },
208
+ "isMonorepo": {
209
+ "type": "boolean",
210
+ "description": "Whether this is a monorepo"
211
+ },
212
+ "targetPackage": {
213
+ "type": "string",
214
+ "description": "Target package name (for monorepos)"
215
+ }
216
+ },
217
+ "additionalProperties": false
218
+ },
219
+ "issues": {
220
+ "type": "array",
221
+ "description": "Issues encountered during generation",
222
+ "items": {
223
+ "$ref": "#/$defs/generationIssue"
224
+ }
225
+ },
226
+ "fromCache": {
227
+ "type": "boolean",
228
+ "description": "Whether the result came from cache"
229
+ }
230
+ },
231
+ "additionalProperties": false
232
+ },
71
233
  "docSignal": {
72
234
  "type": "string",
73
235
  "enum": ["description", "params", "returns", "examples"]
@@ -180,7 +342,9 @@
180
342
  "interface",
181
343
  "type",
182
344
  "enum",
345
+ "module",
183
346
  "namespace",
347
+ "reference",
184
348
  "external"
185
349
  ]
186
350
  },
@@ -209,7 +373,7 @@
209
373
  "members": {
210
374
  "type": "array",
211
375
  "description": "Class/interface/enum members",
212
- "items": { "type": "object" }
376
+ "items": { "$ref": "#/$defs/member" }
213
377
  },
214
378
  "extends": {
215
379
  "type": "string",
@@ -230,6 +394,24 @@
230
394
  "source": {
231
395
  "$ref": "#/$defs/sourceLocation"
232
396
  },
397
+ "deprecated": {
398
+ "type": "boolean",
399
+ "description": "Whether this export is deprecated"
400
+ },
401
+ "flags": {
402
+ "type": "object",
403
+ "description": "Export flags (readonly, abstract, etc.)",
404
+ "additionalProperties": true
405
+ },
406
+ "schema": {
407
+ "$ref": "#/$defs/schema",
408
+ "description": "Inline schema for the export"
409
+ },
410
+ "typeParameters": {
411
+ "type": "array",
412
+ "description": "Generic type parameters",
413
+ "items": { "$ref": "#/$defs/typeParameter" }
414
+ },
233
415
  "docs": {
234
416
  "$ref": "#/$defs/docsMetadata",
235
417
  "description": "Documentation coverage metadata for this export"
@@ -319,7 +501,7 @@
319
501
  "members": {
320
502
  "type": "array",
321
503
  "description": "Members for classes/interfaces/enums",
322
- "items": { "type": "object" }
504
+ "items": { "$ref": "#/$defs/member" }
323
505
  },
324
506
  "extends": {
325
507
  "type": "string",
@@ -340,6 +522,10 @@
340
522
  "source": {
341
523
  "$ref": "#/$defs/sourceLocation"
342
524
  },
525
+ "rawComments": {
526
+ "type": "string",
527
+ "description": "Raw JSDoc/TSDoc comment text"
528
+ },
343
529
  "typeAliasKind": {
344
530
  "$ref": "#/$defs/typeAliasKind",
345
531
  "description": "Kind of type alias"
@@ -460,7 +646,7 @@
460
646
  },
461
647
  "parameter": {
462
648
  "type": "object",
463
- "required": ["name", "required"],
649
+ "required": ["name"],
464
650
  "properties": {
465
651
  "name": {
466
652
  "type": "string",
@@ -503,6 +689,26 @@
503
689
  }
504
690
  }
505
691
  },
692
+ "schemaType": {
693
+ "type": "string",
694
+ "description": "Explicit type enum aligned with TypeScript type system",
695
+ "enum": [
696
+ "string",
697
+ "number",
698
+ "boolean",
699
+ "integer",
700
+ "null",
701
+ "undefined",
702
+ "any",
703
+ "unknown",
704
+ "never",
705
+ "void",
706
+ "array",
707
+ "tuple",
708
+ "object",
709
+ "function"
710
+ ]
711
+ },
506
712
  "schema": {
507
713
  "description": "Flexible JSON Schema for type representation",
508
714
  "oneOf": [
@@ -515,6 +721,11 @@
515
721
  "format": { "type": "string" },
516
722
  "enum": { "type": "array" },
517
723
  "items": { "$ref": "#/$defs/schema" },
724
+ "prefixedItems": {
725
+ "type": "array",
726
+ "items": { "$ref": "#/$defs/schema" },
727
+ "description": "Tuple element schemas (draft-2020-12)"
728
+ },
518
729
  "properties": {
519
730
  "type": "object",
520
731
  "additionalProperties": { "$ref": "#/$defs/schema" }
@@ -535,14 +746,13 @@
535
746
  "description": { "type": "string" },
536
747
  "minItems": { "type": "integer" },
537
748
  "maxItems": { "type": "integer" },
538
- "signatures": { "type": "array" }
749
+ "signatures": { "type": "array", "items": { "$ref": "#/$defs/signature" } }
539
750
  }
540
751
  }
541
752
  ]
542
753
  },
543
754
  "sourceLocation": {
544
755
  "type": "object",
545
- "required": ["file", "line"],
546
756
  "properties": {
547
757
  "file": {
548
758
  "type": "string",
@@ -552,6 +762,10 @@
552
762
  "type": "integer",
553
763
  "description": "Line number in source file",
554
764
  "minimum": 1
765
+ },
766
+ "url": {
767
+ "type": "string",
768
+ "description": "URL to source (e.g., GitHub permalink)"
555
769
  }
556
770
  }
557
771
  },
@@ -694,6 +908,56 @@
694
908
  }
695
909
  ]
696
910
  },
911
+ "visibility": {
912
+ "type": "string",
913
+ "description": "Visibility modifier for class members",
914
+ "enum": ["public", "protected", "private"]
915
+ },
916
+ "member": {
917
+ "type": "object",
918
+ "description": "Class/interface/enum member definition",
919
+ "properties": {
920
+ "id": {
921
+ "type": "string",
922
+ "description": "Unique identifier for the member"
923
+ },
924
+ "name": {
925
+ "type": "string",
926
+ "description": "Member name"
927
+ },
928
+ "kind": {
929
+ "type": "string",
930
+ "description": "Kind of member (e.g., 'property', 'method', 'constructor')"
931
+ },
932
+ "description": {
933
+ "type": "string",
934
+ "description": "JSDoc/TSDoc description"
935
+ },
936
+ "visibility": {
937
+ "$ref": "#/$defs/visibility"
938
+ },
939
+ "tags": {
940
+ "type": "array",
941
+ "items": { "$ref": "#/$defs/tag" }
942
+ },
943
+ "flags": {
944
+ "type": "object",
945
+ "description": "Member flags (static, readonly, abstract, etc.)",
946
+ "additionalProperties": true
947
+ },
948
+ "schema": {
949
+ "$ref": "#/$defs/schema"
950
+ },
951
+ "signatures": {
952
+ "type": "array",
953
+ "items": { "$ref": "#/$defs/signature" }
954
+ },
955
+ "decorators": {
956
+ "type": "array",
957
+ "items": { "$ref": "#/$defs/decorator" }
958
+ }
959
+ }
960
+ },
697
961
  "relationType": {
698
962
  "type": "string",
699
963
  "description": "Type of relationship between exports",