@canonical/pragma-cli 0.27.1-experimental.0 → 0.30.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 (344) hide show
  1. package/README.md +67 -15
  2. package/dist/pragma +0 -0
  3. package/package.json +16 -17
  4. package/src/config/defaultConfig.test.ts +33 -0
  5. package/src/config/defaultConfig.ts +59 -0
  6. package/src/config/defaults.json +17 -0
  7. package/src/config/findProjectConfigPath.test.ts +53 -0
  8. package/src/config/findProjectConfigPath.ts +36 -0
  9. package/src/config/index.ts +17 -2
  10. package/src/config/mergeConfigFileUpdate.ts +58 -0
  11. package/src/config/parseConfigValues.ts +215 -0
  12. package/src/config/readConfig.test.ts +104 -13
  13. package/src/config/readConfig.ts +12 -117
  14. package/src/config/readConfigLayers.test.ts +107 -0
  15. package/src/config/readConfigLayers.ts +115 -0
  16. package/src/config/resolveGlobalConfigPath.ts +13 -0
  17. package/src/config/resolveWriteConfigPath.test.ts +53 -0
  18. package/src/config/resolveWriteConfigPath.ts +31 -0
  19. package/src/config/types.ts +88 -2
  20. package/src/config/writeConfig.ts +25 -43
  21. package/src/constants.ts +12 -1
  22. package/src/domains/block/commands/index.ts +2 -1
  23. package/src/domains/block/commands/list.ts +5 -90
  24. package/src/domains/block/commands/lookup.ts +8 -167
  25. package/src/domains/block/commands/sample.ts +55 -0
  26. package/src/domains/block/formatters/index.ts +2 -1
  27. package/src/domains/block/formatters/sample.ts +21 -0
  28. package/src/domains/block/index.ts +3 -3
  29. package/src/domains/block/mcp/specs.ts +36 -168
  30. package/src/domains/block/operations/index.ts +2 -1
  31. package/src/domains/block/operations/lookup.ts +9 -0
  32. package/src/domains/block/operations/sample.ts +41 -0
  33. package/src/domains/block/orchestration/blockEmptyError.test.ts +26 -0
  34. package/src/domains/block/orchestration/resolveBlockLookup.ts +11 -3
  35. package/src/domains/block/stories.test.ts +28 -0
  36. package/src/domains/block/stories.ts +254 -0
  37. package/src/domains/config/commands/channel.test.ts +14 -3
  38. package/src/domains/config/commands/channel.ts +11 -7
  39. package/src/domains/config/commands/configScope.ts +46 -0
  40. package/src/domains/config/commands/framework.test.ts +105 -0
  41. package/src/domains/config/commands/framework.ts +91 -0
  42. package/src/domains/config/commands/index.ts +2 -0
  43. package/src/domains/config/commands/show.ts +5 -45
  44. package/src/domains/config/commands/tier.test.ts +13 -2
  45. package/src/domains/config/commands/tier.ts +11 -7
  46. package/src/domains/config/commands/trace.test.ts +165 -0
  47. package/src/domains/config/commands/trace.ts +83 -0
  48. package/src/domains/config/formatters/channel.test.ts +20 -6
  49. package/src/domains/config/formatters/channel.ts +14 -11
  50. package/src/domains/config/formatters/framework.ts +37 -0
  51. package/src/domains/config/formatters/index.ts +2 -0
  52. package/src/domains/config/formatters/show.test.ts +27 -0
  53. package/src/domains/config/formatters/show.ts +27 -4
  54. package/src/domains/config/formatters/tier.test.ts +26 -10
  55. package/src/domains/config/formatters/tier.ts +19 -11
  56. package/src/domains/config/formatters/trace.ts +28 -0
  57. package/src/domains/config/index.ts +15 -2
  58. package/src/domains/config/mcp/specs.ts +33 -53
  59. package/src/domains/config/operations/index.ts +1 -0
  60. package/src/domains/config/operations/show.test.ts +18 -0
  61. package/src/domains/config/operations/show.ts +7 -1
  62. package/src/domains/config/operations/types.ts +7 -0
  63. package/src/domains/config/operations/validateFramework.ts +24 -0
  64. package/src/domains/config/stories.ts +42 -0
  65. package/src/domains/config/tasks/index.ts +3 -0
  66. package/src/domains/config/tasks/setChannel.ts +13 -22
  67. package/src/domains/config/tasks/setFramework.ts +21 -0
  68. package/src/domains/config/tasks/setTier.ts +10 -23
  69. package/src/domains/config/tasks/setTrace.ts +20 -0
  70. package/src/domains/config/tasks/writeConfigField.ts +41 -0
  71. package/src/domains/create/commands/component.ts +5 -5
  72. package/src/domains/doctor/operations/checks/checkConfigFile.ts +19 -5
  73. package/src/domains/doctor/operations/checks/checkKeStore.ts +5 -5
  74. package/src/domains/doctor/operations/checks/checkMcpCommands.ts +130 -0
  75. package/src/domains/doctor/operations/checks/checkMcpConfigured.ts +1 -1
  76. package/src/domains/doctor/operations/checks/checkPackageRefs.ts +30 -48
  77. package/src/domains/doctor/operations/checks/checkSkillsSymlinked.ts +1 -1
  78. package/src/domains/doctor/operations/checks/index.ts +1 -0
  79. package/src/domains/doctor/operations/checks.test.ts +162 -8
  80. package/src/domains/doctor/operations/runChecks.test.ts +85 -4
  81. package/src/domains/doctor/operations/runChecks.ts +50 -12
  82. package/src/domains/graph/helpers/resolveUri.test.ts +50 -0
  83. package/src/domains/graph/helpers/resolveUri.ts +28 -21
  84. package/src/domains/graphql/commands/build.test.ts +196 -0
  85. package/src/domains/graphql/commands/build.ts +117 -0
  86. package/src/domains/graphql/commands/check.test.ts +141 -0
  87. package/src/domains/graphql/commands/check.ts +81 -0
  88. package/src/domains/graphql/commands/index.ts +5 -0
  89. package/src/domains/graphql/commands/serve.test.ts +40 -0
  90. package/src/domains/graphql/commands/serve.ts +131 -0
  91. package/src/domains/graphql/constants.ts +10 -0
  92. package/src/domains/graphql/formatters/index.ts +3 -0
  93. package/src/domains/graphql/formatters/report.ts +78 -0
  94. package/src/domains/graphql/helpers/gatherSources.test.ts +92 -0
  95. package/src/domains/graphql/helpers/gatherSources.ts +58 -0
  96. package/src/domains/graphql/helpers/index.ts +6 -0
  97. package/src/domains/graphql/helpers/parsePrefixes.test.ts +44 -0
  98. package/src/domains/graphql/helpers/parsePrefixes.ts +38 -0
  99. package/src/domains/graphql/helpers/resolveSourceFiles.test.ts +56 -0
  100. package/src/domains/graphql/helpers/resolveSourceFiles.ts +45 -0
  101. package/src/domains/graphql/helpers/routeGraphql.test.ts +43 -0
  102. package/src/domains/graphql/helpers/routeGraphql.ts +28 -0
  103. package/src/domains/graphql/index.ts +24 -0
  104. package/src/domains/graphql/operations/compileSchema.test.ts +95 -0
  105. package/src/domains/graphql/operations/compileSchema.ts +107 -0
  106. package/src/domains/graphql/operations/createSchemaServer.test.ts +50 -0
  107. package/src/domains/graphql/operations/createSchemaServer.ts +75 -0
  108. package/src/domains/graphql/operations/index.ts +12 -0
  109. package/src/domains/graphql/types.ts +29 -0
  110. package/src/domains/info/operations/collectInfo.test.ts +16 -5
  111. package/src/domains/info/operations/collectInfo.ts +16 -19
  112. package/src/domains/llm/capabilities.test.ts +91 -0
  113. package/src/domains/llm/commands/capabilities.ts +28 -0
  114. package/src/domains/llm/commands/index.ts +1 -0
  115. package/src/domains/llm/data/commandReference.ts +90 -18
  116. package/src/domains/llm/data/decisionTrees.ts +15 -13
  117. package/src/domains/llm/data/index.ts +2 -0
  118. package/src/domains/llm/data/toolCatalog.ts +190 -0
  119. package/src/domains/llm/formatters/capabilities.ts +50 -0
  120. package/src/domains/llm/formatters/index.ts +1 -0
  121. package/src/domains/llm/index.ts +3 -2
  122. package/src/domains/llm/mcp/index.ts +1 -1
  123. package/src/domains/llm/mcp/specs.ts +59 -52
  124. package/src/domains/llm/types.ts +40 -0
  125. package/src/domains/modifier/commands/index.ts +2 -1
  126. package/src/domains/modifier/commands/list.ts +5 -38
  127. package/src/domains/modifier/commands/lookup.ts +8 -79
  128. package/src/domains/modifier/commands/sample.ts +53 -0
  129. package/src/domains/modifier/formatters/index.ts +2 -1
  130. package/src/domains/modifier/formatters/sample.ts +15 -0
  131. package/src/domains/modifier/index.ts +7 -3
  132. package/src/domains/modifier/mcp/specs.ts +38 -70
  133. package/src/domains/modifier/operations/index.ts +2 -1
  134. package/src/domains/modifier/operations/lookup.ts +9 -0
  135. package/src/domains/modifier/operations/sample.ts +32 -0
  136. package/src/domains/modifier/orchestration/modifierEmptyError.test.ts +26 -0
  137. package/src/domains/modifier/orchestration/modifierEmptyError.ts +7 -2
  138. package/src/domains/modifier/orchestration/resolveModifierLookup.ts +15 -2
  139. package/src/domains/modifier/stories.test.ts +20 -0
  140. package/src/domains/modifier/stories.ts +77 -0
  141. package/src/domains/ontology/commands/list.ts +5 -58
  142. package/src/domains/ontology/commands/show.ts +6 -58
  143. package/src/domains/ontology/formatters/show.ts +7 -1
  144. package/src/domains/ontology/mcp/specs.ts +7 -84
  145. package/src/domains/ontology/stories.test.ts +36 -0
  146. package/src/domains/ontology/stories.ts +108 -0
  147. package/src/domains/refs/operations/index.ts +1 -1
  148. package/src/domains/refs/operations/paths.ts +29 -1
  149. package/src/domains/refs/operations/updateRefs.test.ts +6 -3
  150. package/src/domains/refs/operations/updateRefs.ts +2 -36
  151. package/src/domains/setup/commands/skills.test.ts +6 -2
  152. package/src/domains/setup/commands/skills.ts +6 -2
  153. package/src/domains/setup/helpers/runSetupTask.test.ts +148 -150
  154. package/src/domains/setup/helpers/runSetupTask.ts +62 -70
  155. package/src/domains/setup/operations/setupMcp.test.ts +6 -1
  156. package/src/domains/shared/bootStore.ts +92 -50
  157. package/src/domains/shared/compactUri.test.ts +11 -0
  158. package/src/domains/shared/compactUri.ts +10 -5
  159. package/src/domains/shared/context.ts +2 -2
  160. package/src/domains/shared/contracts.ts +12 -0
  161. package/src/domains/shared/createInteractivePromptSession.test.ts +439 -0
  162. package/src/domains/shared/createInteractivePromptSession.ts +236 -0
  163. package/src/domains/shared/emptyErrorRecovery.test.ts +109 -0
  164. package/src/domains/shared/loaders/bundledLoader.test.ts +248 -0
  165. package/src/domains/shared/loaders/bundledLoader.ts +206 -0
  166. package/src/domains/shared/loaders/gitLoader.ts +31 -0
  167. package/src/domains/shared/loaders/index.ts +9 -0
  168. package/src/domains/shared/loaders/localLoader.ts +87 -0
  169. package/src/domains/shared/loaders/readPackageDir.ts +147 -0
  170. package/src/domains/shared/loaders/storyAssetsPlugin.test.ts +84 -0
  171. package/src/domains/shared/loaders/storyAssetsPlugin.ts +46 -0
  172. package/src/domains/shared/lookupMany.test.ts +120 -0
  173. package/src/domains/shared/lookupMany.ts +43 -3
  174. package/src/domains/shared/mergeAndParseRefs.test.ts +89 -0
  175. package/src/domains/shared/mergeAndParseRefs.ts +44 -0
  176. package/src/domains/shared/packages.ts +14 -120
  177. package/src/domains/shared/pickRandom.ts +22 -0
  178. package/src/domains/shared/resolveConfiguredGraphs.test.ts +27 -0
  179. package/src/domains/shared/resolveConfiguredGraphs.ts +41 -0
  180. package/src/domains/shared/runtime.ts +7 -63
  181. package/src/domains/shared/sampleFormatters.ts +47 -0
  182. package/src/domains/shared/semanticPackage.ts +112 -0
  183. package/src/domains/shared/stories/compileLookupCommand.test.ts +145 -0
  184. package/src/domains/shared/stories/compileLookupCommand.ts +100 -0
  185. package/src/domains/shared/stories/compileLookupTool.test.ts +105 -0
  186. package/src/domains/shared/stories/compileLookupTool.ts +96 -0
  187. package/src/domains/shared/stories/compileReadCommand.test.ts +121 -0
  188. package/src/domains/shared/stories/compileReadCommand.ts +48 -0
  189. package/src/domains/shared/stories/compileReadTool.test.ts +64 -0
  190. package/src/domains/shared/stories/compileReadTool.ts +38 -0
  191. package/src/domains/shared/stories/condense.test.ts +18 -0
  192. package/src/domains/shared/stories/condense.ts +15 -0
  193. package/src/domains/shared/stories/index.ts +20 -0
  194. package/src/domains/shared/stories/normalizeNames.test.ts +20 -0
  195. package/src/domains/shared/stories/normalizeNames.ts +22 -0
  196. package/src/domains/shared/stories/pack/applyPackFilters.test.ts +102 -0
  197. package/src/domains/shared/stories/pack/applyPackFilters.ts +76 -0
  198. package/src/domains/shared/stories/pack/buildLookupQuery.test.ts +51 -0
  199. package/src/domains/shared/stories/pack/buildLookupQuery.ts +80 -0
  200. package/src/domains/shared/stories/pack/collectPackStories.test.ts +108 -0
  201. package/src/domains/shared/stories/pack/collectPackStories.ts +76 -0
  202. package/src/domains/shared/stories/pack/compilePackCommands.ts +40 -0
  203. package/src/domains/shared/stories/pack/compilePackStories.test.ts +146 -0
  204. package/src/domains/shared/stories/pack/compilePackStories.ts +253 -0
  205. package/src/domains/shared/stories/pack/compilePackToolSpecs.ts +43 -0
  206. package/src/domains/shared/stories/pack/index.ts +28 -0
  207. package/src/domains/shared/stories/pack/runSelectQuery.ts +31 -0
  208. package/src/domains/shared/stories/pack/standardParity.test.ts +308 -0
  209. package/src/domains/shared/stories/pack/types.ts +104 -0
  210. package/src/domains/shared/stories/pack/validateStoryPackDefinition.test.ts +240 -0
  211. package/src/domains/shared/stories/pack/validateStoryPackDefinition.ts +408 -0
  212. package/src/domains/shared/stories/projectCliParameters.test.ts +59 -0
  213. package/src/domains/shared/stories/projectCliParameters.ts +57 -0
  214. package/src/domains/shared/stories/projectToolParams.test.ts +50 -0
  215. package/src/domains/shared/stories/projectToolParams.ts +32 -0
  216. package/src/domains/shared/stories/requirePragmaContext.test.ts +23 -0
  217. package/src/domains/shared/stories/requirePragmaContext.ts +23 -0
  218. package/src/domains/shared/stories/resolveLookupDetailed.test.ts +57 -0
  219. package/src/domains/shared/stories/resolveLookupDetailed.ts +27 -0
  220. package/src/domains/shared/stories/types.ts +171 -0
  221. package/src/domains/shared/suggestions/detectCrossDomain.test.ts +43 -0
  222. package/src/domains/shared/suggestions/detectCrossDomain.ts +116 -0
  223. package/src/domains/shared/suggestions/expandGlob.test.ts +92 -0
  224. package/src/domains/shared/suggestions/expandGlob.ts +52 -0
  225. package/src/domains/shared/suggestions/expandLookupQueries.ts +57 -0
  226. package/src/domains/shared/suggestions/index.ts +7 -0
  227. package/src/domains/shared/suggestions/listDomainNames.ts +61 -0
  228. package/src/domains/shared/suggestions/suggestNames.test.ts +70 -0
  229. package/src/domains/shared/suggestions/suggestNames.ts +130 -0
  230. package/src/domains/shared/types/index.ts +1 -0
  231. package/src/domains/shared/types/runtime.ts +4 -1
  232. package/src/domains/shared/types/sample.ts +17 -0
  233. package/src/domains/skill/commands/index.ts +3 -1
  234. package/src/domains/skill/commands/list.test.ts +6 -2
  235. package/src/domains/skill/commands/list.ts +5 -63
  236. package/src/domains/skill/commands/lookup.test.ts +118 -0
  237. package/src/domains/skill/commands/lookup.ts +14 -0
  238. package/src/domains/skill/formatters/index.ts +1 -0
  239. package/src/domains/skill/formatters/lookup.test.ts +46 -0
  240. package/src/domains/skill/formatters/lookup.ts +57 -0
  241. package/src/domains/skill/helpers/resolveSkillSources.ts +48 -16
  242. package/src/domains/skill/index.ts +7 -3
  243. package/src/domains/skill/mcp/specs.ts +10 -29
  244. package/src/domains/skill/operations/discover.test.ts +61 -30
  245. package/src/domains/skill/operations/discover.ts +28 -37
  246. package/src/domains/skill/operations/index.ts +2 -1
  247. package/src/domains/skill/operations/list.test.ts +15 -7
  248. package/src/domains/skill/operations/lookup.test.ts +91 -0
  249. package/src/domains/skill/operations/lookup.ts +70 -0
  250. package/src/domains/skill/stories.test.ts +43 -0
  251. package/src/domains/skill/stories.ts +103 -0
  252. package/src/domains/skill/types.ts +8 -0
  253. package/src/domains/standard/commands/index.ts +2 -1
  254. package/src/domains/standard/commands/list.ts +5 -84
  255. package/src/domains/standard/commands/lookup.ts +8 -93
  256. package/src/domains/standard/commands/sample.ts +57 -0
  257. package/src/domains/standard/formatters/index.ts +2 -1
  258. package/src/domains/standard/formatters/sample.ts +15 -0
  259. package/src/domains/standard/index.ts +8 -1
  260. package/src/domains/standard/mcp/specs.ts +44 -152
  261. package/src/domains/standard/operations/index.ts +2 -1
  262. package/src/domains/standard/operations/lookup.ts +9 -0
  263. package/src/domains/standard/operations/sample.ts +35 -0
  264. package/src/domains/standard/orchestration/resolveStandardLookup.ts +15 -2
  265. package/src/domains/standard/orchestration/standardEmptyError.test.ts +33 -0
  266. package/src/domains/standard/orchestration/standardEmptyError.ts +16 -6
  267. package/src/domains/standard/stories.test.ts +24 -0
  268. package/src/domains/standard/stories.ts +151 -0
  269. package/src/domains/tier/commands/list.ts +5 -55
  270. package/src/domains/tier/mcp/specs.ts +5 -31
  271. package/src/domains/tier/stories.test.ts +22 -0
  272. package/src/domains/tier/stories.ts +52 -0
  273. package/src/domains/token/commands/index.ts +2 -1
  274. package/src/domains/token/commands/sample.ts +53 -0
  275. package/src/domains/token/formatters/index.ts +2 -1
  276. package/src/domains/token/formatters/sample.ts +16 -0
  277. package/src/domains/token/index.ts +8 -1
  278. package/src/domains/token/mcp/specs.ts +52 -2
  279. package/src/domains/token/operations/index.ts +2 -1
  280. package/src/domains/token/operations/lookup.ts +9 -0
  281. package/src/domains/token/operations/sample.ts +32 -0
  282. package/src/domains/token/orchestration/resolveTokenLookup.ts +15 -2
  283. package/src/domains/token/orchestration/tokenEmptyError.test.ts +33 -0
  284. package/src/domains/token/orchestration/tokenEmptyError.ts +5 -2
  285. package/src/domains/trace/commands/clear.ts +71 -0
  286. package/src/domains/trace/commands/index.ts +5 -0
  287. package/src/domains/trace/commands/sessions.ts +32 -0
  288. package/src/domains/trace/commands/show.ts +145 -0
  289. package/src/domains/trace/formatters/index.ts +9 -0
  290. package/src/domains/trace/formatters/sessions.ts +80 -0
  291. package/src/domains/trace/formatters/show.ts +122 -0
  292. package/src/domains/trace/index.ts +17 -0
  293. package/src/domains/trace/operations/index.ts +8 -0
  294. package/src/domains/trace/operations/listSessions.test.ts +55 -0
  295. package/src/domains/trace/operations/listSessions.ts +52 -0
  296. package/src/domains/trace/operations/readTraceLog.test.ts +100 -0
  297. package/src/domains/trace/operations/readTraceLog.ts +104 -0
  298. package/src/domains/trace/tracePlugin.test.ts +171 -0
  299. package/src/domains/trace/tracePlugin.ts +159 -0
  300. package/src/domains/trace/types.ts +65 -0
  301. package/src/error/PragmaError.ts +15 -2
  302. package/src/error/types.ts +15 -1
  303. package/src/mcp/error/serializeErrorPayload.ts +7 -0
  304. package/src/mcp/error/types.ts +8 -0
  305. package/src/mcp/registerResources.test.ts +405 -75
  306. package/src/mcp/registerResources.ts +5 -299
  307. package/src/mcp/resources/buildGraphIndex.ts +167 -0
  308. package/src/mcp/resources/buildResourceList.test.ts +97 -0
  309. package/src/mcp/resources/buildResourceList.ts +176 -0
  310. package/src/mcp/resources/classifyEntity.test.ts +40 -0
  311. package/src/mcp/resources/classifyEntity.ts +27 -0
  312. package/src/mcp/resources/constants.ts +105 -0
  313. package/src/mcp/resources/displayPredicates.ts +62 -0
  314. package/src/mcp/resources/pickFirstValue.test.ts +29 -0
  315. package/src/mcp/resources/pickFirstValue.ts +26 -0
  316. package/src/mcp/resources/pickPrimaryType.test.ts +41 -0
  317. package/src/mcp/resources/pickPrimaryType.ts +26 -0
  318. package/src/mcp/resources/rankUriCompletions.test.ts +52 -0
  319. package/src/mcp/resources/rankUriCompletions.ts +64 -0
  320. package/src/mcp/resources/readEntity.ts +169 -0
  321. package/src/mcp/resources/registerResources.ts +126 -0
  322. package/src/mcp/resources/types.ts +128 -0
  323. package/src/mcp/tools/index.ts +9 -0
  324. package/src/mcp/tools/registerTools.test.ts +84 -12
  325. package/src/mcp/types.ts +4 -0
  326. package/src/mcp/utils/wrapTool.test.ts +1 -0
  327. package/src/pipeline/collectCommands.ts +15 -2
  328. package/src/pipeline/renderError.ts +15 -0
  329. package/src/pipeline/resolveCommandKind.ts +8 -1
  330. package/src/pipeline/runCli.ts +51 -6
  331. package/src/testing/createTestMcpClient.ts +5 -1
  332. package/src/testing/graphqlFixtures.ts +72 -0
  333. package/src/testing/index.ts +17 -0
  334. package/src/testing/integration/__snapshots__/executor-golden.test.ts.snap +1207 -0
  335. package/src/testing/integration/cross-binary-byte-equality.test.ts +129 -0
  336. package/src/testing/integration/executor-execution.test.ts +101 -0
  337. package/src/testing/integration/executor-golden.test.ts +145 -0
  338. package/src/testing/integration/mcp-surface.test.ts +11 -5
  339. package/src/testing/integration/parity.test.ts +17 -12
  340. package/src/testing/regression/0001-skill-discovery-granularity.test.ts +71 -0
  341. package/src/testing/setupXdgIsolation.ts +15 -0
  342. package/src/testing/standardParityFixtures.ts +92 -0
  343. package/src/testing/storyFixtures.ts +63 -0
  344. package/src/pipeline/runInteractiveCommand.ts +0 -198
@@ -0,0 +1,141 @@
1
+ import { mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
+ import {
6
+ EX_PREFIX_ENTRY,
7
+ GRAPHQL_CLEAN_TTL,
8
+ GRAPHQL_ERROR_TTL,
9
+ GRAPHQL_FATAL_TTL,
10
+ } from "#testing";
11
+ import type { PragmaContext } from "../../shared/context.js";
12
+ import type { GraphqlCompileReport } from "../types.js";
13
+ import checkCommand from "./check.js";
14
+
15
+ let dir: string;
16
+ let stdoutSpy: ReturnType<typeof vi.spyOn>;
17
+
18
+ beforeEach(() => {
19
+ dir = mkdtempSync(join(tmpdir(), "pragma-graphql-check-"));
20
+ writeFileSync(join(dir, "clean.ttl"), GRAPHQL_CLEAN_TTL);
21
+ writeFileSync(join(dir, "error.ttl"), GRAPHQL_ERROR_TTL);
22
+ writeFileSync(join(dir, "fatal.ttl"), GRAPHQL_FATAL_TTL);
23
+ stdoutSpy = vi.spyOn(process.stdout, "write").mockImplementation(() => true);
24
+ });
25
+
26
+ afterEach(() => {
27
+ stdoutSpy.mockRestore();
28
+ rmSync(dir, { recursive: true, force: true });
29
+ });
30
+
31
+ function makeCtx(overrides: Partial<PragmaContext> = {}): PragmaContext {
32
+ return {
33
+ cwd: dir,
34
+ globalFlags: { llm: false, format: "text" as const, verbose: false },
35
+ store: {} as PragmaContext["store"],
36
+ config: { tier: undefined, channel: "normal" },
37
+ ...overrides,
38
+ } as PragmaContext;
39
+ }
40
+
41
+ function printedOutput(): string {
42
+ return stdoutSpy.mock.calls.map((call) => call[0]).join("");
43
+ }
44
+
45
+ describe("graphql check command", () => {
46
+ it("passes a clean ontology with a summary line", async () => {
47
+ const ctx = makeCtx();
48
+ const result = await checkCommand.execute(
49
+ { sources: ["clean.ttl"], prefix: [EX_PREFIX_ENTRY] },
50
+ ctx,
51
+ );
52
+
53
+ expect(result.tag).toBe("output");
54
+ if (result.tag !== "output") throw new Error("Expected output result");
55
+ const text = result.render.plain(result.value);
56
+ expect(text).toContain("1 source file: 0 errors, 0 warnings, 0 info");
57
+ });
58
+
59
+ it("exits non-zero and prints diagnostics on error diagnostics", async () => {
60
+ const ctx = makeCtx();
61
+ const result = await checkCommand.execute(
62
+ { sources: ["error.ttl"], prefix: [EX_PREFIX_ENTRY] },
63
+ ctx,
64
+ );
65
+
66
+ expect(result.tag).toBe("exit");
67
+ if (result.tag !== "exit") throw new Error("Expected exit result");
68
+ expect(result.code).toBe(1);
69
+
70
+ const printed = printedOutput();
71
+ expect(printed).toContain("M001");
72
+ expect(printed).toContain("error");
73
+ expect(printed).toContain("1 error, 2 warnings, 0 info");
74
+ });
75
+
76
+ it("exits non-zero when compilation fails entirely", async () => {
77
+ const ctx = makeCtx();
78
+ const result = await checkCommand.execute(
79
+ { sources: ["fatal.ttl"], prefix: [EX_PREFIX_ENTRY] },
80
+ ctx,
81
+ );
82
+
83
+ expect(result.tag).toBe("exit");
84
+ if (result.tag !== "exit") throw new Error("Expected exit result");
85
+ expect(result.code).toBe(1);
86
+ expect(printedOutput()).toContain("C003");
87
+ });
88
+
89
+ it("passes with warnings when prefixes are not registered", async () => {
90
+ const ctx = makeCtx();
91
+ const result = await checkCommand.execute({ sources: ["clean.ttl"] }, ctx);
92
+
93
+ expect(result.tag).toBe("output");
94
+ if (result.tag !== "output") throw new Error("Expected output result");
95
+ const text = result.render.plain(result.value);
96
+ expect(text).toContain("1 warning");
97
+ expect(text).toContain("0 errors");
98
+ });
99
+
100
+ it("writes no artifacts", async () => {
101
+ const ctx = makeCtx();
102
+ const before = readdirSync(dir).sort();
103
+ await checkCommand.execute(
104
+ { sources: ["clean.ttl"], prefix: [EX_PREFIX_ENTRY] },
105
+ ctx,
106
+ );
107
+
108
+ expect(readdirSync(dir).sort()).toEqual(before);
109
+ });
110
+
111
+ it("renders json output", async () => {
112
+ const ctx = makeCtx({
113
+ globalFlags: { llm: false, format: "json" as const, verbose: false },
114
+ });
115
+ const result = await checkCommand.execute(
116
+ { sources: ["clean.ttl"], prefix: [EX_PREFIX_ENTRY] },
117
+ ctx,
118
+ );
119
+
120
+ expect(result.tag).toBe("output");
121
+ if (result.tag !== "output") throw new Error("Expected output result");
122
+ const parsed = JSON.parse(
123
+ result.render.plain(result.value),
124
+ ) as GraphqlCompileReport;
125
+ expect(parsed.diagnostics).toEqual([]);
126
+ expect(parsed.artifacts).toBeUndefined();
127
+ });
128
+
129
+ it("throws a structured error when explicit sources match nothing", async () => {
130
+ const ctx = makeCtx();
131
+
132
+ await expect(
133
+ checkCommand.execute({ sources: ["no-such-*.ttl"] }, ctx),
134
+ ).rejects.toMatchObject({
135
+ code: "INVALID_INPUT",
136
+ recovery: {
137
+ message: "No files matched the given paths or glob patterns.",
138
+ },
139
+ });
140
+ });
141
+ });
@@ -0,0 +1,81 @@
1
+ import {
2
+ type CommandDefinition,
3
+ type CommandResult,
4
+ createExitResult,
5
+ createOutputResult,
6
+ } from "@canonical/cli-core";
7
+ import { selectFormatter } from "../../shared/formatters.js";
8
+ import { reportFormatters } from "../formatters/index.js";
9
+ import { gatherSources, parsePrefixes } from "../helpers/index.js";
10
+ import { compileSchema } from "../operations/index.js";
11
+ import type { GraphqlCompileReport } from "../types.js";
12
+
13
+ /** Narrow an unknown param to a string array. */
14
+ function readStringArray(value: unknown): string[] {
15
+ return Array.isArray(value)
16
+ ? value.filter((item): item is string => typeof item === "string")
17
+ : [];
18
+ }
19
+
20
+ /**
21
+ * Builds the `pragma graphql check` command definition.
22
+ *
23
+ * Runs the same compile as `graphql build` but writes no artifacts —
24
+ * a CI gate. Prints all compiler diagnostics and exits non-zero when
25
+ * compilation fails or any error-severity diagnostic is produced.
26
+ */
27
+ const checkCommand: CommandDefinition = {
28
+ path: ["graphql", "check"],
29
+ description: "Compile TTL sources and fail on error diagnostics",
30
+ parameters: [
31
+ {
32
+ name: "sources",
33
+ description:
34
+ "TTL files or globs (default: the configured semantic packages)",
35
+ type: "multiselect",
36
+ positional: true,
37
+ },
38
+ {
39
+ name: "prefix",
40
+ description: "Ontology prefix as name=namespace (repeatable)",
41
+ type: "multiselect",
42
+ },
43
+ ],
44
+ meta: {
45
+ examples: [
46
+ "pragma graphql check ontology.ttl",
47
+ 'pragma graphql check "data/*.ttl" --prefix ds=https://ds.canonical.com/',
48
+ ],
49
+ },
50
+ async execute(params, ctx): Promise<CommandResult> {
51
+ const sources = await gatherSources(
52
+ readStringArray(params.sources),
53
+ ctx.cwd,
54
+ );
55
+ const prefixes = parsePrefixes(readStringArray(params.prefix));
56
+ const outcome = await compileSchema({ sources, prefixes, cwd: ctx.cwd });
57
+
58
+ const report: GraphqlCompileReport = {
59
+ diagnostics: outcome.diagnostics,
60
+ files: outcome.files,
61
+ sourcesHash: outcome.sourcesHash,
62
+ };
63
+
64
+ const hasErrors =
65
+ outcome.status === "failed" ||
66
+ outcome.diagnostics.some((d) => d.severity === "error");
67
+
68
+ if (hasErrors) {
69
+ process.stdout.write(
70
+ `${selectFormatter(ctx, reportFormatters)(report)}\n`,
71
+ );
72
+ return createExitResult(1);
73
+ }
74
+
75
+ return createOutputResult(report, {
76
+ plain: selectFormatter(ctx, reportFormatters),
77
+ });
78
+ },
79
+ };
80
+
81
+ export default checkCommand;
@@ -0,0 +1,5 @@
1
+ /** @module Barrel for graphql command builders. */
2
+
3
+ export { default as buildCommand } from "./build.js";
4
+ export { default as checkCommand } from "./check.js";
5
+ export { default as serveCommand } from "./serve.js";
@@ -0,0 +1,40 @@
1
+ import { afterEach, describe, expect, it } from "vitest";
2
+ import type { PragmaContext } from "../../shared/context.js";
3
+ import serveCommand, { readPort } from "./serve.js";
4
+
5
+ describe("readPort", () => {
6
+ it("parses a valid port", () => {
7
+ expect(readPort("4001")).toBe(4001);
8
+ });
9
+
10
+ it("falls back to the default for non-string values", () => {
11
+ expect(readPort(undefined)).toBe(4000);
12
+ expect(readPort(4001)).toBe(4000);
13
+ });
14
+
15
+ it("falls back to the default for out-of-range or unparseable values", () => {
16
+ expect(readPort("0")).toBe(4000);
17
+ expect(readPort("70000")).toBe(4000);
18
+ expect(readPort("not-a-port")).toBe(4000);
19
+ });
20
+ });
21
+
22
+ describe("graphql serve command", () => {
23
+ const ctx = { cwd: process.cwd() } as PragmaContext;
24
+ const original = (globalThis as Record<string, unknown>).Bun;
25
+
26
+ afterEach(() => {
27
+ (globalThis as Record<string, unknown>).Bun = original;
28
+ });
29
+
30
+ it("requires the Bun runtime", async () => {
31
+ (globalThis as Record<string, unknown>).Bun = undefined;
32
+
33
+ await expect(serveCommand.execute({}, ctx)).rejects.toMatchObject({
34
+ code: "STORE_ERROR",
35
+ recovery: {
36
+ message: "Run the compiled `pragma` binary or use `bun run`.",
37
+ },
38
+ });
39
+ });
40
+ });
@@ -0,0 +1,131 @@
1
+ import {
2
+ type CommandDefinition,
3
+ type CommandResult,
4
+ createOutputResult,
5
+ } from "@canonical/cli-core";
6
+ import { PragmaError } from "#error";
7
+ import { DEFAULT_PORT } from "../constants.js";
8
+ import { gatherSources, parsePrefixes } from "../helpers/index.js";
9
+ import routeGraphql from "../helpers/routeGraphql.js";
10
+ import createSchemaServer, {
11
+ type SchemaServer,
12
+ } from "../operations/createSchemaServer.js";
13
+
14
+ /** Narrow an unknown param to a string array. */
15
+ function readStringArray(value: unknown): string[] {
16
+ return Array.isArray(value)
17
+ ? value.filter((item): item is string => typeof item === "string")
18
+ : [];
19
+ }
20
+
21
+ /** Parse the --port flag, falling back to the default on anything invalid. */
22
+ export function readPort(value: unknown): number {
23
+ if (typeof value !== "string") {
24
+ return DEFAULT_PORT;
25
+ }
26
+ const port = Number.parseInt(value, 10);
27
+ return Number.isInteger(port) && port > 0 && port < 65536
28
+ ? port
29
+ : DEFAULT_PORT;
30
+ }
31
+
32
+ /**
33
+ * Listen on `port` and block until the process is interrupted, then stop
34
+ * the server and dispose the store.
35
+ *
36
+ * @note Impure — opens a network listener and registers signal handlers.
37
+ */
38
+ /* v8 ignore start -- the live Bun.serve listener and signal loop run under `pragma graphql serve`, not unit tests */
39
+ async function listen(server: SchemaServer, port: number): Promise<void> {
40
+ const httpServer = Bun.serve({
41
+ port,
42
+ fetch: (request) => routeGraphql(request, server.handler, port),
43
+ });
44
+ await new Promise<void>((resolve) => {
45
+ const shutdown = (): void => {
46
+ httpServer.stop();
47
+ server.dispose();
48
+ resolve();
49
+ };
50
+ process.once("SIGINT", shutdown);
51
+ process.once("SIGTERM", shutdown);
52
+ });
53
+ }
54
+ /* v8 ignore stop */
55
+
56
+ /**
57
+ * Builds the `pragma graphql serve` command definition.
58
+ *
59
+ * Compiles the configured ontologies (or explicit TTL sources) and serves
60
+ * a local GraphQL + GraphiQL endpoint until interrupted. With no positional
61
+ * sources it serves every TTL across the semantic packages in
62
+ * `pragma.config.json`.
63
+ */
64
+ const serveCommand: CommandDefinition = {
65
+ path: ["graphql", "serve"],
66
+ description:
67
+ "Serve a local GraphQL + GraphiQL endpoint over the configured ontologies",
68
+ parameters: [
69
+ {
70
+ name: "sources",
71
+ description:
72
+ "TTL files or globs to serve (default: the configured semantic packages)",
73
+ type: "multiselect",
74
+ positional: true,
75
+ },
76
+ {
77
+ name: "port",
78
+ description: `Port to listen on (default ${DEFAULT_PORT})`,
79
+ type: "string",
80
+ },
81
+ {
82
+ name: "prefix",
83
+ description: "Ontology prefix as name=namespace (repeatable)",
84
+ type: "multiselect",
85
+ },
86
+ ],
87
+ meta: {
88
+ examples: [
89
+ "pragma graphql serve",
90
+ "pragma graphql serve ontology.ttl --port 4001",
91
+ ],
92
+ },
93
+ async execute(params, ctx): Promise<CommandResult> {
94
+ if (typeof Bun === "undefined") {
95
+ throw PragmaError.storeError(
96
+ "`pragma graphql serve` requires the Bun runtime.",
97
+ {
98
+ recovery: {
99
+ message: "Run the compiled `pragma` binary or use `bun run`.",
100
+ },
101
+ },
102
+ );
103
+ }
104
+
105
+ const sources = await gatherSources(
106
+ readStringArray(params.sources),
107
+ ctx.cwd,
108
+ );
109
+ const prefixes = parsePrefixes(readStringArray(params.prefix));
110
+ const port = readPort(params.port);
111
+
112
+ const server = await createSchemaServer({ sources, prefixes });
113
+ const errorCount = server.diagnostics.filter(
114
+ (d) => d.severity === "error",
115
+ ).length;
116
+ process.stdout.write(
117
+ `[ke-graphql] schema compiled — ${server.diagnostics.length} diagnostic(s)${
118
+ errorCount > 0 ? `, ${errorCount} error(s)` : ""
119
+ }\n[ke-graphql] GraphiQL on http://localhost:${port}/graphql (Ctrl-C to stop)\n`,
120
+ );
121
+
122
+ await listen(server, port);
123
+
124
+ return createOutputResult(
125
+ { port, diagnostics: server.diagnostics },
126
+ { plain: () => `Stopped the graphql server on port ${port}.` },
127
+ );
128
+ },
129
+ };
130
+
131
+ export default serveCommand;
@@ -0,0 +1,10 @@
1
+ /** Default port `pragma graphql serve` listens on. */
2
+ const DEFAULT_PORT = 4000;
3
+
4
+ /** Default output path for the SDL written by `pragma graphql build`. */
5
+ const DEFAULT_SDL_PATH = "./schema.graphql";
6
+
7
+ /** Default output path for the extraction artifact written by `pragma graphql build`. */
8
+ const DEFAULT_EXTRACTION_PATH = "./extraction.json";
9
+
10
+ export { DEFAULT_EXTRACTION_PATH, DEFAULT_PORT, DEFAULT_SDL_PATH };
@@ -0,0 +1,3 @@
1
+ /** @module Barrel for graphql formatters. */
2
+
3
+ export { default as reportFormatters } from "./report.js";
@@ -0,0 +1,78 @@
1
+ import type { Diagnostic } from "@canonical/ke-graphql";
2
+ import chalk from "chalk";
3
+ import type { Formatters } from "../../shared/formatters.js";
4
+ import type { GraphqlCompileReport } from "../types.js";
5
+
6
+ /** Count diagnostics of one severity. */
7
+ function countSeverity(
8
+ diagnostics: readonly Diagnostic[],
9
+ severity: Diagnostic["severity"],
10
+ ): number {
11
+ return diagnostics.filter((d) => d.severity === severity).length;
12
+ }
13
+
14
+ /** Pluralize a count: `1 error`, `2 errors`. */
15
+ function plural(count: number, word: string): string {
16
+ return `${count} ${word}${count !== 1 ? "s" : ""}`;
17
+ }
18
+
19
+ /** One-line summary of diagnostic counts and compiled sources. */
20
+ function summaryLine(report: GraphqlCompileReport): string {
21
+ const errors = countSeverity(report.diagnostics, "error");
22
+ const warnings = countSeverity(report.diagnostics, "warning");
23
+ const infos = countSeverity(report.diagnostics, "info");
24
+ return `${plural(report.files.length, "source file")}: ${plural(errors, "error")}, ${plural(warnings, "warning")}, ${infos} info`;
25
+ }
26
+
27
+ function colorSeverity(severity: Diagnostic["severity"]): string {
28
+ if (severity === "error") return chalk.red(severity);
29
+ if (severity === "warning") return chalk.yellow(severity);
30
+ return chalk.dim(severity);
31
+ }
32
+
33
+ /**
34
+ * Formatters for `pragma graphql build` and `pragma graphql check` output.
35
+ *
36
+ * - **plain**: one line per diagnostic (severity, code, message, source),
37
+ * a summary line with counts, and `Wrote <path>` lines for artifacts.
38
+ * - **llm**: condensed Markdown under a `## GraphQL Compile` heading.
39
+ * - **json**: serialized {@link GraphqlCompileReport} as indented JSON.
40
+ */
41
+ const formatters: Formatters<GraphqlCompileReport> = {
42
+ plain(report) {
43
+ const lines = report.diagnostics.map(
44
+ (d) =>
45
+ `${colorSeverity(d.severity)} ${chalk.bold(d.code)}: ${d.message}${d.source ? ` (${d.source})` : ""}`,
46
+ );
47
+ lines.push(summaryLine(report));
48
+ if (report.artifacts) {
49
+ lines.push(`Wrote ${report.artifacts.sdl}`);
50
+ lines.push(`Wrote ${report.artifacts.extraction}`);
51
+ }
52
+ return lines.join("\n");
53
+ },
54
+
55
+ llm(report) {
56
+ const lines = ["## GraphQL Compile", ""];
57
+ for (const d of report.diagnostics) {
58
+ lines.push(
59
+ `- **${d.severity}** \`${d.code}\`: ${d.message}${d.source ? ` (\`${d.source}\`)` : ""}`,
60
+ );
61
+ }
62
+ if (report.diagnostics.length > 0) {
63
+ lines.push("");
64
+ }
65
+ lines.push(`**Summary:** ${summaryLine(report)}`);
66
+ if (report.artifacts) {
67
+ lines.push(`**SDL:** \`${report.artifacts.sdl}\``);
68
+ lines.push(`**Extraction:** \`${report.artifacts.extraction}\``);
69
+ }
70
+ return lines.join("\n");
71
+ },
72
+
73
+ json(report) {
74
+ return JSON.stringify(report, null, 2);
75
+ },
76
+ };
77
+
78
+ export default formatters;
@@ -0,0 +1,92 @@
1
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
+ import { GRAPHQL_CLEAN_TTL } from "#testing";
6
+ import resolveConfiguredGraphs from "../../shared/resolveConfiguredGraphs.js";
7
+ import gatherSources from "./gatherSources.js";
8
+
9
+ vi.mock("../../shared/resolveConfiguredGraphs.js", () => ({
10
+ default: vi.fn(),
11
+ }));
12
+
13
+ const mockResolve = vi.mocked(resolveConfiguredGraphs);
14
+
15
+ describe("gatherSources", () => {
16
+ let dir: string;
17
+
18
+ beforeEach(() => {
19
+ dir = mkdtempSync(join(tmpdir(), "pragma-gather-"));
20
+ writeFileSync(join(dir, "a.ttl"), GRAPHQL_CLEAN_TTL);
21
+ writeFileSync(join(dir, "b.ttl"), GRAPHQL_CLEAN_TTL);
22
+ mockResolve.mockReset();
23
+ });
24
+
25
+ afterEach(() => {
26
+ rmSync(dir, { recursive: true, force: true });
27
+ });
28
+
29
+ it("reads explicit files into inline sources, ignoring the config", async () => {
30
+ const sources = await gatherSources(["a.ttl"], dir);
31
+
32
+ expect(sources).toEqual([
33
+ {
34
+ content: GRAPHQL_CLEAN_TTL,
35
+ format: "turtle",
36
+ path: join(dir, "a.ttl"),
37
+ },
38
+ ]);
39
+ expect(mockResolve).not.toHaveBeenCalled();
40
+ });
41
+
42
+ it("expands glob patterns", async () => {
43
+ const sources = await gatherSources(["*.ttl"], dir);
44
+
45
+ expect(sources.map((source) => source.path).sort()).toEqual([
46
+ join(dir, "a.ttl"),
47
+ join(dir, "b.ttl"),
48
+ ]);
49
+ });
50
+
51
+ it("throws when explicit sources match nothing", async () => {
52
+ await expect(gatherSources(["none-*.ttl"], dir)).rejects.toMatchObject({
53
+ code: "INVALID_INPUT",
54
+ recovery: {
55
+ message: "No files matched the given paths or glob patterns.",
56
+ },
57
+ });
58
+ });
59
+
60
+ it("falls back to the configured package graphs when no sources are given", async () => {
61
+ mockResolve.mockResolvedValue([
62
+ {
63
+ path: "definitions/ontology.ttl",
64
+ content: GRAPHQL_CLEAN_TTL,
65
+ format: "turtle",
66
+ },
67
+ ]);
68
+
69
+ const sources = await gatherSources([], dir);
70
+
71
+ expect(mockResolve).toHaveBeenCalledWith(dir);
72
+ expect(sources).toEqual([
73
+ {
74
+ content: GRAPHQL_CLEAN_TTL,
75
+ format: "turtle",
76
+ path: "definitions/ontology.ttl",
77
+ },
78
+ ]);
79
+ });
80
+
81
+ it("throws when no sources are given and no packages resolve", async () => {
82
+ mockResolve.mockResolvedValue([]);
83
+
84
+ await expect(gatherSources([], dir)).rejects.toMatchObject({
85
+ code: "INVALID_INPUT",
86
+ recovery: {
87
+ message:
88
+ "No TTL sources given and no semantic packages resolved. Pass TTL files or globs, or configure `packages` in pragma.config.json and install them.",
89
+ },
90
+ });
91
+ });
92
+ });
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Resolve the TTL sources for a graphql command.
3
+ *
4
+ * When positional paths or globs are given they win; otherwise the sources
5
+ * are the union of every configured semantic package's graphs (the
6
+ * `pragma.config.json` packages, falling back to the defaults). Either way
7
+ * the result is a list of ke `InlineSource`s (content + provenance path),
8
+ * so the compiler and the dev server load the exact same bytes.
9
+ *
10
+ * @note Impure — reads files and resolves packages from disk.
11
+ *
12
+ * @param positional - Explicit TTL file paths or glob patterns (may be empty).
13
+ * @param cwd - Working directory for file and config resolution.
14
+ * @returns In-memory TTL sources to compile or serve.
15
+ * @throws PragmaError (INVALID_INPUT) when nothing resolves.
16
+ */
17
+
18
+ import { readFileSync } from "node:fs";
19
+ import type { InlineSource } from "@canonical/ke";
20
+ import { PragmaError } from "#error";
21
+ import resolveConfiguredGraphs from "../../shared/resolveConfiguredGraphs.js";
22
+ import resolveSourceFiles from "./resolveSourceFiles.js";
23
+
24
+ export default async function gatherSources(
25
+ positional: readonly string[],
26
+ cwd: string,
27
+ ): Promise<InlineSource[]> {
28
+ if (positional.length > 0) {
29
+ const files = resolveSourceFiles([...positional], cwd);
30
+ if (files.length === 0) {
31
+ throw PragmaError.invalidInput("sources", positional.join(", "), {
32
+ recovery: {
33
+ message: "No files matched the given paths or glob patterns.",
34
+ },
35
+ });
36
+ }
37
+ return files.map((path) => ({
38
+ content: readFileSync(path, "utf-8"),
39
+ format: "turtle" as const,
40
+ path,
41
+ }));
42
+ }
43
+
44
+ const graphs = await resolveConfiguredGraphs(cwd);
45
+ if (graphs.length === 0) {
46
+ throw PragmaError.invalidInput("sources", "(none)", {
47
+ recovery: {
48
+ message:
49
+ "No TTL sources given and no semantic packages resolved. Pass TTL files or globs, or configure `packages` in pragma.config.json and install them.",
50
+ },
51
+ });
52
+ }
53
+ return graphs.map((graph) => ({
54
+ content: graph.content,
55
+ format: graph.format,
56
+ path: graph.path,
57
+ }));
58
+ }
@@ -0,0 +1,6 @@
1
+ /** @module Barrel for graphql helpers. */
2
+
3
+ export { default as gatherSources } from "./gatherSources.js";
4
+ export { default as parsePrefixes } from "./parsePrefixes.js";
5
+ export { default as resolveSourceFiles } from "./resolveSourceFiles.js";
6
+ export { default as routeGraphql } from "./routeGraphql.js";