@voxgig/sdkgen 4.45.0 → 4.46.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 (156) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/action/check.js +15 -0
  3. package/dist/action/check.js.map +1 -1
  4. package/dist/action/copies.js +1 -0
  5. package/dist/action/copies.js.map +1 -1
  6. package/dist/action/doctor.d.ts +21 -2
  7. package/dist/action/doctor.js +166 -9
  8. package/dist/action/doctor.js.map +1 -1
  9. package/dist/action/package.js +9 -0
  10. package/dist/action/package.js.map +1 -1
  11. package/dist/action/remove.js +2 -1
  12. package/dist/action/remove.js.map +1 -1
  13. package/dist/action/target.d.ts +2 -1
  14. package/dist/action/target.js +50 -11
  15. package/dist/action/target.js.map +1 -1
  16. package/dist/cmp/AgentGuide.js +19 -8
  17. package/dist/cmp/AgentGuide.js.map +1 -1
  18. package/dist/cmp/AgentGuideContent.d.ts +6 -4
  19. package/dist/cmp/AgentGuideContent.js +51 -32
  20. package/dist/cmp/AgentGuideContent.js.map +1 -1
  21. package/dist/cmp/AgentGuideFeature.js +5 -3
  22. package/dist/cmp/AgentGuideFeature.js.map +1 -1
  23. package/dist/cmp/AgentGuideTop.js +84 -46
  24. package/dist/cmp/AgentGuideTop.js.map +1 -1
  25. package/dist/cmp/Changelog.js +12 -1
  26. package/dist/cmp/Changelog.js.map +1 -1
  27. package/dist/cmp/Deploy.js +22 -20
  28. package/dist/cmp/Deploy.js.map +1 -1
  29. package/dist/cmp/ExternalTarget.js +5 -5
  30. package/dist/cmp/ExternalTarget.js.map +1 -1
  31. package/dist/cmp/Feature.js +10 -3
  32. package/dist/cmp/Feature.js.map +1 -1
  33. package/dist/cmp/FeatureDocs.d.ts +6 -4
  34. package/dist/cmp/FeatureDocs.js +14 -39
  35. package/dist/cmp/FeatureDocs.js.map +1 -1
  36. package/dist/cmp/FeatureHook.d.ts +7 -1
  37. package/dist/cmp/FeatureHook.js +34 -1
  38. package/dist/cmp/FeatureHook.js.map +1 -1
  39. package/dist/cmp/PublishWorkflow.js +30 -6
  40. package/dist/cmp/PublishWorkflow.js.map +1 -1
  41. package/dist/cmp/ReadmeErrors.js +521 -18
  42. package/dist/cmp/ReadmeErrors.js.map +1 -1
  43. package/dist/cmp/ReadmeExplanation.js +280 -44
  44. package/dist/cmp/ReadmeExplanation.js.map +1 -1
  45. package/dist/cmp/ReadmeFeatures.js +16 -7
  46. package/dist/cmp/ReadmeFeatures.js.map +1 -1
  47. package/dist/cmp/ReadmeIntro.js +3 -2
  48. package/dist/cmp/ReadmeIntro.js.map +1 -1
  49. package/dist/cmp/ReadmeRefFeatures.js +34 -24
  50. package/dist/cmp/ReadmeRefFeatures.js.map +1 -1
  51. package/dist/cmp/ReadmeStation.js +11 -8
  52. package/dist/cmp/ReadmeStation.js.map +1 -1
  53. package/dist/cmp/ReadmeTop.js +472 -373
  54. package/dist/cmp/ReadmeTop.js.map +1 -1
  55. package/dist/cmp/ReadmeUnions.js +8 -2
  56. package/dist/cmp/ReadmeUnions.js.map +1 -1
  57. package/dist/cmp/Security.js +3 -2
  58. package/dist/cmp/Security.js.map +1 -1
  59. package/dist/helpers/applicability.d.ts +2 -1
  60. package/dist/helpers/applicability.js +26 -0
  61. package/dist/helpers/applicability.js.map +1 -1
  62. package/dist/helpers/copymerge.d.ts +3 -0
  63. package/dist/helpers/copymerge.js +43 -10
  64. package/dist/helpers/copymerge.js.map +1 -1
  65. package/dist/helpers/doccheck.d.ts +11 -0
  66. package/dist/helpers/doccheck.js +146 -0
  67. package/dist/helpers/doccheck.js.map +1 -0
  68. package/dist/helpers/doctext.d.ts +11 -0
  69. package/dist/helpers/doctext.js +84 -0
  70. package/dist/helpers/doctext.js.map +1 -0
  71. package/dist/helpers/exampleCall.d.ts +16 -0
  72. package/dist/helpers/exampleCall.js +334 -0
  73. package/dist/helpers/exampleCall.js.map +1 -0
  74. package/dist/helpers/exportnames.d.ts +4 -0
  75. package/dist/helpers/exportnames.js +35 -0
  76. package/dist/helpers/exportnames.js.map +1 -0
  77. package/dist/helpers/facts.d.ts +2 -1
  78. package/dist/helpers/facts.js +37 -2
  79. package/dist/helpers/facts.js.map +1 -1
  80. package/dist/helpers/modelcheck.d.ts +2 -1
  81. package/dist/helpers/modelcheck.js +13 -0
  82. package/dist/helpers/modelcheck.js.map +1 -1
  83. package/dist/helpers/opExample.d.ts +9 -2
  84. package/dist/helpers/opExample.js +22 -2
  85. package/dist/helpers/opExample.js.map +1 -1
  86. package/dist/helpers/opShape.d.ts +2 -1
  87. package/dist/helpers/opShape.js +12 -0
  88. package/dist/helpers/opShape.js.map +1 -1
  89. package/dist/helpers/packageMeta.js +21 -8
  90. package/dist/helpers/packageMeta.js.map +1 -1
  91. package/dist/helpers/semver.d.ts +2 -1
  92. package/dist/helpers/semver.js +7 -0
  93. package/dist/helpers/semver.js.map +1 -1
  94. package/dist/sdkgen.js +21 -2
  95. package/dist/sdkgen.js.map +1 -1
  96. package/dist/testkit.d.ts +1 -0
  97. package/dist/testkit.js +23 -19
  98. package/dist/testkit.js.map +1 -1
  99. package/dist/tsconfig.tsbuildinfo +1 -1
  100. package/dist/utility.js +2 -1
  101. package/dist/utility.js.map +1 -1
  102. package/model/fact.aontu +44 -0
  103. package/model/sdkgen.aontu +6 -2
  104. package/package.json +3 -1
  105. package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +1 -1
  106. package/project/.sdk/src/cmp/c/ReadmeTopQuick_c.ts +1 -1
  107. package/project/.sdk/src/cmp/clojure/ReadmeEntity_clojure.ts +12 -3
  108. package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +4 -1
  109. package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +1 -0
  110. package/project/.sdk/src/cmp/swift/ReadmeRef_swift.ts +3 -0
  111. package/project/.sdk/src/cmp/swift/ReadmeTopQuick_swift.ts +2 -1
  112. package/project/.sdk/src/cmp/zig/ReadmeOptions_zig.ts +1 -1
  113. package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +2 -2
  114. package/project/.sdk/src/cmp/zig/ReadmeTopQuick_zig.ts +2 -2
  115. package/project/sdkgen-package.json +1 -1
  116. package/src/action/check.ts +21 -0
  117. package/src/action/copies.ts +2 -0
  118. package/src/action/doctor.ts +244 -13
  119. package/src/action/package.ts +10 -0
  120. package/src/action/remove.ts +2 -1
  121. package/src/action/target.ts +66 -15
  122. package/src/cmp/AgentGuide.ts +24 -10
  123. package/src/cmp/AgentGuideContent.ts +53 -32
  124. package/src/cmp/AgentGuideFeature.ts +6 -4
  125. package/src/cmp/AgentGuideTop.ts +108 -47
  126. package/src/cmp/Changelog.ts +13 -2
  127. package/src/cmp/Deploy.ts +23 -21
  128. package/src/cmp/ExternalTarget.ts +6 -6
  129. package/src/cmp/Feature.ts +11 -4
  130. package/src/cmp/FeatureDocs.ts +21 -40
  131. package/src/cmp/FeatureHook.ts +38 -1
  132. package/src/cmp/PublishWorkflow.ts +33 -7
  133. package/src/cmp/ReadmeErrors.ts +555 -25
  134. package/src/cmp/ReadmeExplanation.ts +316 -52
  135. package/src/cmp/ReadmeFeatures.ts +18 -8
  136. package/src/cmp/ReadmeIntro.ts +3 -2
  137. package/src/cmp/ReadmeRefFeatures.ts +39 -27
  138. package/src/cmp/ReadmeStation.ts +12 -14
  139. package/src/cmp/ReadmeTop.ts +528 -387
  140. package/src/cmp/ReadmeUnions.ts +10 -2
  141. package/src/cmp/Security.ts +3 -2
  142. package/src/helpers/applicability.ts +28 -0
  143. package/src/helpers/copymerge.ts +58 -10
  144. package/src/helpers/doccheck.ts +174 -0
  145. package/src/helpers/doctext.ts +113 -0
  146. package/src/helpers/exampleCall.ts +415 -0
  147. package/src/helpers/exportnames.ts +47 -0
  148. package/src/helpers/facts.ts +47 -2
  149. package/src/helpers/modelcheck.ts +16 -0
  150. package/src/helpers/opExample.ts +34 -2
  151. package/src/helpers/opShape.ts +13 -0
  152. package/src/helpers/packageMeta.ts +21 -8
  153. package/src/helpers/semver.ts +9 -0
  154. package/src/sdkgen.ts +27 -3
  155. package/src/testkit.ts +30 -20
  156. package/src/utility.ts +2 -1
@@ -1,5 +1,6 @@
1
1
  import { kindCollection } from '../helpers/kindCollection'
2
2
 
3
+ import Fs from 'node:fs'
3
4
  import Path from 'node:path'
4
5
 
5
6
  import { template } from 'jostraca'
@@ -31,7 +32,13 @@ import type { TreeDef } from './kind'
31
32
  import { resolveSource } from './resolve'
32
33
  import type { Source } from './resolve'
33
34
 
34
- import { definitionPath } from '../helpers/definition'
35
+ import {
36
+ definitionPath, definitionNames, migrateIncludes,
37
+ } from '../helpers/definition'
38
+
39
+ import { compileModel, slashComments } from '../helpers/modelcheck'
40
+
41
+ import { packageRoot } from '../helpers/shipped'
35
42
 
36
43
  import { findFeatureSources, featureExcludes } from '../helpers/featureSource'
37
44
 
@@ -44,6 +51,10 @@ import type { CopyRecord } from './copies'
44
51
 
45
52
  import { MERGE } from '../helpers/copymerge'
46
53
 
54
+ import { compareVersions } from '../helpers/semver'
55
+
56
+ import { isTypeScript, missingExports } from '../helpers/exportnames'
57
+
47
58
 
48
59
  const IGNORED_RE = /(~|-jostraca-off)$/
49
60
 
@@ -108,6 +119,10 @@ type DoctorReport = {
108
119
  // add wrote it: the source moved on, so refreshing it discards nothing.
109
120
  outdated: string[]
110
121
 
122
+ // As outdated, but copied from a newer release of the package than the one
123
+ // installed: a refresh would put older copies back.
124
+ ahead: string[]
125
+
111
126
  // The forked and edited findings the copy record has no entry for, so
112
127
  // nothing shows whether the project changed them.
113
128
  unrecorded: string[]
@@ -117,6 +132,16 @@ type DoctorReport = {
117
132
  // the project's own, not drift.
118
133
  customized: string[]
119
134
 
135
+ // Customized TypeScript copies that lack a name their source exports, so a
136
+ // copy importing it does not compile.
137
+ unfolded: Unfolded[]
138
+
139
+ // Items whose copies this generator's record dates from before COPY_FLOOR.
140
+ belowFloor: string[]
141
+
142
+ // Item model files that do not compile, so the model leaves the item out.
143
+ unreadable: Unreadable[]
144
+
120
145
  // Declared items whose source is not installed; their copies are kept.
121
146
  unresolved: string[]
122
147
 
@@ -140,18 +165,46 @@ type ItemDrift = {
140
165
 
141
166
  outdated: number
142
167
 
168
+ ahead: number
169
+
143
170
  // Forked, edited, missing and stale files.
144
171
  changed: number
145
172
 
146
173
  customized: number
147
174
 
175
+ belowFloor?: boolean
176
+
148
177
  unresolved?: string
149
178
  }
150
179
 
151
180
 
181
+ type Unreadable = {
182
+ file: string
183
+ item: string
184
+ error: string
185
+ oldSyntax: boolean
186
+ }
187
+
188
+
189
+ // The oldest release of this generator whose component copies build with it.
190
+ const COPY_FLOOR = '4.23.0'
191
+
192
+ // The oldest release whose copied model files this generator reads.
193
+ const MODEL_FLOOR = '1.3.18'
194
+
195
+ const SHIPPED_PACKAGE: string =
196
+ JSON.parse(Fs.readFileSync(Path.join(packageRoot(), 'package.json'), 'utf8')).name
197
+
198
+
199
+ type Unfolded = {
200
+ file: string
201
+ item: string
202
+ names: string[]
203
+ }
204
+
152
205
  type Category = 'forked' | 'edited' | 'missing' | 'stale'
153
206
 
154
- type Found = (category: Category, label: string) => void
207
+ type Found = (category: Category, label: string, lacking?: () => string[]) => void
155
208
 
156
209
 
157
210
  const CMD_MAP: any = {
@@ -297,7 +350,8 @@ async function doctor(
297
350
  forked: [], edited: [], stale: [], missing: [], additive: [],
298
351
  superseded: [], unwired: [], orphanModel: [],
299
352
  resyncPending: [], aliasedDiff: [],
300
- outdated: [], unrecorded: [], customized: [], unresolved: [], byItem: {},
353
+ outdated: [], ahead: [], unrecorded: [], customized: [], unfolded: [],
354
+ belowFloor: [], unreadable: [], unresolved: [], byItem: {},
301
355
  ignoredLog: false, ok: true,
302
356
  }
303
357
 
@@ -312,6 +366,8 @@ async function doctor(
312
366
 
313
367
  report.orphanModel = orphanModelFiles(actx)
314
368
 
369
+ report.unreadable = unreadableModels(actx, report.orphanModel)
370
+
315
371
  const kinds = Object.keys(KINDS).sort()
316
372
 
317
373
  const counts: Record<string, number> = {}
@@ -389,8 +445,9 @@ async function doctor(
389
445
  // authoritative either way.
390
446
  report.ok = 0 === report.forked.length + report.edited.length -
391
447
  report.customized.length + report.stale.length + report.missing.length + report.superseded.length +
392
- report.orphanModel.length + report.outdated.length +
393
- report.unresolved.length
448
+ report.orphanModel.length + report.outdated.length + report.ahead.length +
449
+ report.unfolded.length + report.belowFloor.length +
450
+ report.unreadable.length + report.unresolved.length
394
451
 
395
452
  const customized = new Set(report.customized)
396
453
  const unmergeable = MERGE === projectCopyMode(actx) ? new Set(report.unrecorded) : new Set()
@@ -408,6 +465,7 @@ async function doctor(
408
465
  ['resyncPending', 'RESYNC PENDING (predates provenance; `target add` updates it)'],
409
466
  ['aliasedDiff', 'aliased model differs from its origin (project-owned, not drift)'],
410
467
  ['outdated', 'OUTDATED (unchanged since it was copied, but its source has moved on)'],
468
+ ['ahead', 'AHEAD (unchanged since it was copied from a newer release than the one installed)'],
411
469
  ['unresolved', 'UNRESOLVED (declared, but its source is not installed; install it)'],
412
470
  ] as [keyof DoctorReport, string][]) {
413
471
  for (const file of (report[kind] as string[])) {
@@ -421,8 +479,41 @@ async function doctor(
421
479
  }
422
480
  }
423
481
 
482
+ for (const { file, item, error, oldSyntax } of report.unreadable) {
483
+ log.info({
484
+ point: 'doctor-finding', kind: 'unreadable', file, error,
485
+ note: 'UNREADABLE: ' + file + ' does not compile (' + error + '), so the ' +
486
+ 'model leaves ' + item.replace('/', ' ') + ' out. ' + unreadableRemedy(item, oldSyntax)
487
+ })
488
+ }
489
+
490
+ for (const { file, names } of report.unfolded) {
491
+ log.info({
492
+ point: 'doctor-finding', kind: 'unfolded', file, names,
493
+ note: 'UNFOLDED (customized, but lacks ' + names.join(', ') +
494
+ ', which its source exports): ' + file
495
+ })
496
+ }
497
+
424
498
  for (const item of Object.keys(report.byItem).sort()) {
425
499
  const drift = report.byItem[item]
500
+
501
+ if (true === drift.belowFloor) {
502
+ log.info({ point: 'doctor-below-floor', item, ...drift, note: belowFloorNote(item, drift) })
503
+ continue
504
+ }
505
+
506
+ if (null == copies.items[item] && null == drift.unresolved && 0 < drift.changed) {
507
+ log.info({
508
+ point: 'doctor-unrecorded-item', item, ...drift,
509
+ note: item.replace('/', ' ') + ': nothing records which release wrote ' +
510
+ 'its copies, and ' + drift.changed + ' differ from the installed ' +
511
+ 'source. Copies from before ' + COPY_FLOOR + ' do not build with this ' +
512
+ 'generator: if the .sdk build fails in them, commit, then run ' +
513
+ '`voxgig-sdkgen ' + refreshCommand(item) + ' --force`.'
514
+ })
515
+ }
516
+
426
517
  if (0 < drift.outdated) {
427
518
  log.info({
428
519
  point: 'doctor-outdated', item, ...drift,
@@ -430,6 +521,13 @@ async function doctor(
430
521
  refreshCommand(item, drift.package) + '` refreshes them'
431
522
  })
432
523
  }
524
+ if (0 < drift.ahead) {
525
+ log.info({
526
+ point: 'doctor-ahead', item, ...drift,
527
+ note: aheadNote(item, drift) + ' - `voxgig-sdkgen ' +
528
+ forwardCommand(drift.package as string) + '` moves it up to them'
529
+ })
530
+ }
433
531
  }
434
532
 
435
533
  log.info({
@@ -446,6 +544,10 @@ async function doctor(
446
544
  resyncPending: report.resyncPending.length,
447
545
  aliasedDiff: report.aliasedDiff.length,
448
546
  outdated: report.outdated.length,
547
+ ahead: report.ahead.length,
548
+ unfolded: report.unfolded.length,
549
+ belowFloor: report.belowFloor.length,
550
+ unreadable: report.unreadable.length,
449
551
  unresolved: report.unresolved.length,
450
552
  customized: report.customized.length,
451
553
  note: report.ok ?
@@ -454,7 +556,10 @@ async function doctor(
454
556
  ('.sdk has drifted: ' + report.forked.length + ' forked, ' +
455
557
  report.edited.length + ' edited, ' + report.stale.length + ' stale, ' +
456
558
  report.missing.length + ' missing, ' + report.outdated.length +
457
- ' outdated, ' + report.unresolved.length + ' unresolved')
559
+ ' outdated, ' + report.ahead.length + ' ahead, ' +
560
+ report.unfolded.length + ' unfolded, ' + report.belowFloor.length +
561
+ ' below the floor, ' + report.unreadable.length + ' unreadable, ' +
562
+ report.unresolved.length + ' unresolved')
458
563
  })
459
564
 
460
565
  return { report }
@@ -525,6 +630,7 @@ function noteUnresolved(
525
630
  report.byItem[item] = {
526
631
  ...pkgOf(declared.package),
527
632
  outdated: 0,
633
+ ahead: 0,
528
634
  changed: 0,
529
635
  customized: 0,
530
636
  unresolved: from,
@@ -681,9 +787,13 @@ function compareTrees(
681
787
 
682
788
  const from = landed.get(rel) as string
683
789
 
684
- if (differs(fs, from, Path.join(tree.project, rel),
685
- model, tree.replace, undefined, tree.rewrite)) {
686
- found(tree.kind, label + rel)
790
+ const at = Path.join(tree.project, rel)
791
+
792
+ if (differs(fs, from, at, model, tree.replace, undefined, tree.rewrite)) {
793
+ found(tree.kind, label + rel, isTypeScript(rel) ? () => {
794
+ const { expected, actual } = renderPair(fs, from, at, model, tree.replace, tree.rewrite)
795
+ return missingExports(expected, actual)
796
+ } : undefined)
687
797
  }
688
798
  }
689
799
 
@@ -909,16 +1019,18 @@ function noteDrift(
909
1019
  const item = itemKey(kind, source.name)
910
1020
  const copied = copies.items[item]
911
1021
  const merging = MERGE === projectCopyMode(actx)
1022
+ const ahead = null != source.package && copied?.package === source.package &&
1023
+ 0 < (compareVersions(copied?.version ?? '', source.version ?? '') ?? 0)
912
1024
 
913
- return (category: Category, label: string) => {
914
- let into: Category | 'outdated' = category
1025
+ return (category: Category, label: string, lacking?: () => string[]) => {
1026
+ let into: Category | 'outdated' | 'ahead' = category
915
1027
  let custom = false
916
1028
 
917
1029
  if ('forked' === category || 'edited' === category) {
918
1030
  const same = untouched(fs, actx.folder, copies, label)
919
1031
 
920
1032
  if (true === same) {
921
- into = 'outdated'
1033
+ into = ahead ? 'ahead' : 'outdated'
922
1034
  }
923
1035
  else if (undefined === same) {
924
1036
  report.unrecorded.push(label)
@@ -926,23 +1038,37 @@ function noteDrift(
926
1038
  else if (merging) {
927
1039
  custom = true
928
1040
  report.customized.push(label)
1041
+
1042
+ const names = lacking?.() ?? []
1043
+ if (0 < names.length) {
1044
+ report.unfolded.push({ file: label, item, names })
1045
+ }
929
1046
  }
930
1047
  }
931
1048
 
932
1049
  report[into].push(label)
933
1050
 
1051
+ if (null == report.byItem[item] && belowFloor(copied)) {
1052
+ report.belowFloor.push(item)
1053
+ }
1054
+
934
1055
  const drift = report.byItem[item] = report.byItem[item] ?? {
935
1056
  ...pkgOf(source.package ?? copied?.package),
936
1057
  ...(null == copied?.version ? {} : { from: copied.version }),
937
1058
  ...(null == source.version ? {} : { to: source.version }),
938
1059
  outdated: 0,
1060
+ ahead: 0,
939
1061
  changed: 0,
940
1062
  customized: 0,
1063
+ ...(belowFloor(copied) ? { belowFloor: true } : {}),
941
1064
  }
942
1065
 
943
1066
  if ('outdated' === into) {
944
1067
  drift.outdated++
945
1068
  }
1069
+ else if ('ahead' === into) {
1070
+ drift.ahead++
1071
+ }
946
1072
  else {
947
1073
  drift.changed++
948
1074
  }
@@ -954,6 +1080,64 @@ function noteDrift(
954
1080
  }
955
1081
 
956
1082
 
1083
+ // The floor holds for this generator's own copies; another package keeps its own.
1084
+ function belowFloor(copied?: { package?: string, version?: string }): boolean {
1085
+ return SHIPPED_PACKAGE === copied?.package &&
1086
+ 0 > (compareVersions(copied?.version ?? '', COPY_FLOOR) ?? 0)
1087
+ }
1088
+
1089
+
1090
+ function belowFloorNote(item: string, drift: ItemDrift): string {
1091
+ return item.replace('/', ' ') + ': ' + (drift.outdated + drift.changed) +
1092
+ ' file(s) were copied from ' + drift.package + ' ' + drift.from +
1093
+ ', older than ' + COPY_FLOOR + ', the oldest release whose copies this ' +
1094
+ 'generator builds. Commit, then run `voxgig-sdkgen ' + refreshCommand(item) +
1095
+ ' --force` to replace them.'
1096
+ }
1097
+
1098
+
1099
+ function unreadableRemedy(item: string, oldSyntax: boolean): string {
1100
+ return (oldSyntax ? 'It uses `//` comments, as model files copied before ' +
1101
+ MODEL_FLOOR + ' do, and this generator does not read them. ' : '') +
1102
+ 'Commit, then run `voxgig-sdkgen ' + refreshCommand(item) + ' --force` to ' +
1103
+ 'replace it.'
1104
+ }
1105
+
1106
+
1107
+ // An included item model file that fails to compile leaves no error behind:
1108
+ // the model simply lacks the item. Compiled alone, the failure shows.
1109
+ function unreadableModels(actx: ActionContext, orphans: string[]): Unreadable[] {
1110
+ const fs = actx.fs()
1111
+ const root = actx.folder
1112
+ const found: Unreadable[] = []
1113
+
1114
+ for (const kind of Object.keys(KINDS).sort()) {
1115
+ const declared = kindCollection(actx.model, kind) ?? {}
1116
+
1117
+ for (const name of definitionNames(fs, root, kind)) {
1118
+ const path = definitionPath(root, kind, name)
1119
+ const file = Path.relative(root, path).split(Path.sep).join('/')
1120
+
1121
+ if (null != declared[name] || !fs.existsSync(path) || orphans.includes(file)) {
1122
+ continue
1123
+ }
1124
+
1125
+ const text = String(fs.readFileSync(path, 'utf8'))
1126
+ const compiled = compileModel(migrateIncludes(text), path, { strict: false })
1127
+
1128
+ if (0 < compiled.errors.length) {
1129
+ found.push({
1130
+ file, item: itemKey(kind, name), error: compiled.errors[0],
1131
+ oldSyntax: 0 < slashComments(text).length,
1132
+ })
1133
+ }
1134
+ }
1135
+ }
1136
+
1137
+ return found
1138
+ }
1139
+
1140
+
957
1141
  function pkgOf(name?: string): { package?: string } {
958
1142
  return null == name ? {} : { package: name }
959
1143
  }
@@ -971,6 +1155,19 @@ function refreshCommand(item: string, pkg?: string): string {
971
1155
  }
972
1156
 
973
1157
 
1158
+ // Fetches the latest release, which a re-add from the installed one is not.
1159
+ function forwardCommand(pkg: string): string {
1160
+ return 'package update ' + pkg
1161
+ }
1162
+
1163
+
1164
+ function aheadNote(item: string, drift: ItemDrift): string {
1165
+ return item.replace('/', ' ') + ': ' + drift.ahead + ' file(s) are ' +
1166
+ 'unchanged copies from ' + drift.package + ' ' + drift.from +
1167
+ ', newer than the installed ' + drift.to
1168
+ }
1169
+
1170
+
974
1171
  function outdatedNote(item: string, drift: ItemDrift): string {
975
1172
  return item.replace('/', ' ') + ': ' + drift.outdated +
976
1173
  ' file(s) are unchanged copies' + sinceCopied(drift.package, [drift])
@@ -1166,20 +1363,42 @@ function copyWarnings(report: DoctorReport): string[] {
1166
1363
  groups.set(key, group)
1167
1364
  }
1168
1365
 
1366
+ const lines: string[] = report.ignoredLog ? [IGNORED_LOG] : []
1367
+
1368
+ for (const { file, item, oldSyntax } of report.unreadable) {
1369
+ lines.push(file + ' does not compile, so this run leaves ' +
1370
+ item.replace('/', ' ') + ' out. ' + unreadableRemedy(item, oldSyntax)
1371
+ .replace('`voxgig-sdkgen', '`npx voxgig-sdkgen'))
1372
+ }
1373
+
1169
1374
  for (const item of Object.keys(report.byItem).sort()) {
1170
1375
  const drift = report.byItem[item]
1171
1376
  const command = refreshCommand(item, drift.package)
1172
1377
 
1378
+ if (true === drift.belowFloor) {
1379
+ lines.push(belowFloorNote(item, drift).replace('`voxgig-sdkgen', '`npx voxgig-sdkgen'))
1380
+ continue
1381
+ }
1382
+
1173
1383
  if (0 < drift.outdated) {
1174
1384
  add('outdated\n' + command, item, drift.outdated, drift)
1175
1385
  }
1176
1386
 
1387
+ if (0 < drift.ahead) {
1388
+ add('ahead\n' + forwardCommand(drift.package as string), item, drift.ahead, drift)
1389
+ }
1390
+
1177
1391
  if (0 < drift.changed - drift.customized) {
1178
1392
  add('changed\n' + command, item, drift.changed - drift.customized, drift)
1179
1393
  }
1180
1394
  }
1181
1395
 
1182
- const lines: string[] = report.ignoredLog ? [IGNORED_LOG] : []
1396
+ for (const { file, item, names } of report.unfolded) {
1397
+ lines.push(file + ': lacks ' + names.join(', ') + ', which the installed ' +
1398
+ 'copy exports, so a copy that imports ' + (1 === names.length ? 'it' : 'them') +
1399
+ ' does not compile. Fold the incoming change into it, or commit, then run ' +
1400
+ '`npx voxgig-sdkgen ' + refreshCommand(item) + ' --force` to take the incoming copy.')
1401
+ }
1183
1402
 
1184
1403
  for (const item of report.unresolved) {
1185
1404
  lines.push(item.replace('/', ' ') + ': declared from ' +
@@ -1202,6 +1421,14 @@ function copyWarnings(report: DoctorReport): string[] {
1202
1421
  sinceCopied(pkg, group.drift) + ', so this run generates from ' +
1203
1422
  'older templates. Run ' + refresh + ' to refresh them.')
1204
1423
  }
1424
+ else if ('ahead' === what) {
1425
+ lines.push(group.items.join(', ') + ': ' + group.files +
1426
+ ' file(s) in .sdk were copied from a newer ' + pkg + ' than the ' +
1427
+ 'installed ' + installed + ', so this run generates from templates ' +
1428
+ 'written for a generator this is not. Run ' + refresh + ' to move ' +
1429
+ 'the installed package up to them; refreshing from ' + installed +
1430
+ ' would put older copies back.')
1431
+ }
1205
1432
  else {
1206
1433
  lines.push(group.items.join(', ') + ': ' + group.files +
1207
1434
  ' file(s) in .sdk differ from what ' + installed + ' installs: ' +
@@ -1221,9 +1448,13 @@ export type {
1221
1448
  DoctorReport,
1222
1449
  DoctorScope,
1223
1450
  ItemDrift,
1451
+ Unfolded,
1452
+ Unreadable,
1224
1453
  }
1225
1454
 
1226
1455
  export {
1456
+ COPY_FLOOR,
1457
+ MODEL_FLOOR,
1227
1458
  action_doctor,
1228
1459
  doctor,
1229
1460
  copyCheck,
@@ -673,6 +673,16 @@ async function preCheck(
673
673
  })
674
674
  }
675
675
 
676
+ if (0 < report.ahead.length && true === flags.nofetch) {
677
+ actx.log.warn({
678
+ point: 'package-update-older', package: pkgname,
679
+ files: report.ahead.length,
680
+ note: pkgname + ': ' + report.ahead.length + ' file(s) were copied ' +
681
+ 'from a newer release than the one installed; --no-fetch puts its ' +
682
+ 'older copies back'
683
+ })
684
+ }
685
+
676
686
  const changed = [...report.forked, ...report.edited]
677
687
 
678
688
  if (0 === changed.length) {
@@ -290,7 +290,8 @@ function planOutput(
290
290
  const fs = actx.fs()
291
291
  const root = actx.folder
292
292
 
293
- if (null != declared?.output?.path) {
293
+ // The base schema defaults the path to '', which declares no output.
294
+ if ('' !== (declared?.output?.path ?? '')) {
294
295
  plan.notes.push(plan.name + ': generates out of tree (' +
295
296
  declared.output.path + '); that output is not touched')
296
297
  return
@@ -554,32 +554,23 @@ function trimFeatures(
554
554
  }
555
555
 
556
556
 
557
+ type TargetFeature = { trim: boolean, fullset: string[] }
558
+
559
+
557
560
  function readTargetFeature(
558
561
  ctx$: any,
559
562
  tfolder: string,
560
563
  torigname: string,
561
564
  tname: string,
562
- ): { trim: boolean, fullset: string[] } {
565
+ ): TargetFeature {
563
566
  const { log } = ctx$
564
567
  const fs = ctx$.fs()
565
568
 
566
569
  const path = definitionPathAny(fs, tfolder, 'target', torigname)
567
570
 
571
+ let source: TargetFeature
568
572
  try {
569
- const errs: any[] = []
570
- const src = migrateIncludes(fs.readFileSync(path, 'utf8'))
571
- const model = new Aontu().generate(src, { path, errs })
572
-
573
- if (0 < errs.length) {
574
- throw new Error(errs.map((e: any) => e.msg || String(e)).join('\n'))
575
- }
576
-
577
- const feature = model?.main?.[KIT]?.target?.[torigname]?.feature ?? {}
578
-
579
- return {
580
- trim: false !== feature.trim,
581
- fullset: Array.isArray(feature.fullset) ? feature.fullset : [],
582
- }
573
+ source = compiledTargetFeature(fs, path, torigname)
583
574
  }
584
575
  catch (err: any) {
585
576
  log.warn({
@@ -590,6 +581,66 @@ function readTargetFeature(
590
581
  })
591
582
  return { trim: false, fullset: [] }
592
583
  }
584
+
585
+ const own = projectTargetFeature(ctx$, tname)
586
+
587
+ return {
588
+ trim: own.trim ?? source.trim,
589
+ fullset: own.fullset ?? source.fullset,
590
+ }
591
+ }
592
+
593
+
594
+ function compiledTargetFeature(fs: any, path: string, name: string): TargetFeature {
595
+ const errs: any[] = []
596
+ const src = migrateIncludes(fs.readFileSync(path, 'utf8'))
597
+ const model = new Aontu().generate(src, { path, errs })
598
+
599
+ if (0 < errs.length) {
600
+ throw new Error(errs.map((e: any) => e.msg || String(e)).join('\n'))
601
+ }
602
+
603
+ const feature = model?.main?.[KIT]?.target?.[name]?.feature ?? {}
604
+
605
+ return {
606
+ trim: false !== feature.trim,
607
+ fullset: Array.isArray(feature.fullset) ? feature.fullset : [],
608
+ }
609
+ }
610
+
611
+
612
+ // What the project sets for itself: where its compiled model differs from
613
+ // the copy of the target file it holds, the setting comes from elsewhere in
614
+ // its model and survives the re-add, so the add must follow it as generate
615
+ // does. Anything else came with the copy, and the incoming copy replaces it.
616
+ function projectTargetFeature(ctx$: any, tname: string): Partial<TargetFeature> {
617
+ const compiled = ctx$.model?.main?.[KIT]?.target?.[tname]?.feature
618
+ if (null == compiled) {
619
+ return {}
620
+ }
621
+
622
+ const fs = ctx$.fs()
623
+ const path = definitionPathAny(fs, ctx$.folder ?? '.', 'target', tname)
624
+
625
+ let copied: TargetFeature = { trim: true, fullset: [] }
626
+ if (fs.existsSync(path)) {
627
+ try {
628
+ copied = compiledTargetFeature(fs, path, tname)
629
+ }
630
+ catch (_err) {
631
+ return {}
632
+ }
633
+ }
634
+
635
+ const own: Partial<TargetFeature> = {}
636
+ if ('boolean' === typeof compiled.trim && compiled.trim !== copied.trim) {
637
+ own.trim = compiled.trim
638
+ }
639
+ if (Array.isArray(compiled.fullset) &&
640
+ JSON.stringify(compiled.fullset) !== JSON.stringify(copied.fullset)) {
641
+ own.fullset = [...compiled.fullset]
642
+ }
643
+ return own
593
644
  }
594
645
 
595
646
 
@@ -12,8 +12,11 @@ import {
12
12
  claudePointer,
13
13
  featuresEnabled,
14
14
  isDirLayout,
15
- featureRuntimeFile,
15
+ featureTemplates,
16
+ writesFeatureGuides,
16
17
  featureHooks,
18
+ regenerationStatement,
19
+ copiesStatement,
17
20
  } from './AgentGuideContent'
18
21
 
19
22
  import { AgentGuideFeature } from './AgentGuideFeature'
@@ -54,6 +57,8 @@ npm run build # only if you changed a component
54
57
  npm run generate # refreshes this ${lang}/ directory
55
58
  \`\`\`
56
59
 
60
+ ${regenerationStatement()}
61
+
57
62
  Then build and test the generated output:
58
63
 
59
64
  ${langCommandsBlock(lang)}
@@ -69,6 +74,7 @@ ${langCommandsBlock(lang)}
69
74
  Decision rule: *same for every API → template; depends on the API →
70
75
  component.* After editing a component run \`npm run build\` before
71
76
  \`npm run generate\`; template-only edits just need \`npm run generate\`.
77
+ ${copiesStatement(model)}
72
78
 
73
79
  `)
74
80
 
@@ -88,19 +94,27 @@ Each feature's runtime and its own guide live in \`src/feature/<name>/\`.
88
94
  `)
89
95
  }
90
96
  else {
91
- Content(`Each feature is a flat file in the \`feature/\` package. Its hooks and
92
- default activation come from \`.sdk/model/feature/<name>.aontu\`; customise
93
- the runtime under \`.sdk/tm/${lang}/feature/\` and regenerate.
94
-
95
- | Feature | Runtime file | Active hooks |
96
- | --- | --- | --- |
97
+ const templates = featureTemplates(ctx$.fs(), target, features)
98
+ const shared = 0 === Object.keys(templates).length
99
+ Content(`Each feature's hooks and default activation come from
100
+ \`.sdk/model/feature/<name>.aontu\`. ${shared
101
+ ? `This target has no template per
102
+ feature: customise its features in the runtime under \`.sdk/tm/${lang}/\`
103
+ and regenerate.`
104
+ : `Its runtime is generated from the template
105
+ listed here: customise that and regenerate.`}
106
+
107
+ | Feature | ${shared ? '' : 'Template | '}Active hooks |
108
+ | --- | ${shared ? '' : '--- | '}--- |
97
109
  `)
98
110
  features.forEach((f: any) => {
99
- const file = featureRuntimeFile(target, f)
111
+ const template = templates[f.name]
100
112
  const hooks = featureHooks(f)
101
113
  const hookList = hooks.length ? hooks.map((h: string) => '\`' + h + '\`').join(', ') : '—'
102
114
  const label = f.title ? `**${f.name}** — ${f.title}` : `**${f.name}**`
103
- Content(`| ${label} | \`feature/${file}\` | ${hookList} |
115
+ const where = shared ? '' :
116
+ (null == template ? '—' : '\`.sdk/tm/' + lang + '/' + template + '\`') + ' | '
117
+ Content(`| ${label} | ${where}${hookList} |
104
118
  `)
105
119
  })
106
120
  Content(`
@@ -129,7 +143,7 @@ Generated by [@voxgig/sdkgen](https://github.com/voxgig/sdkgen). See the
129
143
  // where each feature has its own directory to hold the guide. Flat-layout
130
144
  // targets document features inline above; phase-disabled targets
131
145
  // (go-cli/go-mcp) get no feature docs at all.
132
- if (featuresOn && dirLayout) {
146
+ if (writesFeatureGuides(model, target)) {
133
147
  features.forEach((feature: any) => {
134
148
  AgentGuideFeature({ target, feature })
135
149
  })