gen-cordis-catalog.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. /**
  2. * Generate the Cordis event and service catalogs from static declarations.
  3. * The walk enforces event modes plus JSDoc parameter/return completeness;
  4. * inherited Cordis services come from the curated table below. `--check`
  5. * verifies both committed artifacts.
  6. */
  7. import { globSync, readFileSync, writeFileSync } from 'node:fs'
  8. import { resolve, sep } from 'node:path'
  9. import ts from 'typescript'
  10. import { checkParams, checkReturns, parseJsDoc, parseTags, pointer, rawJsDoc, reportViolations, type Mode } from './jsdoc.ts'
  11. import { cordisModuleBody, eventMembers, serviceClasses } from './cordis-walk.ts'
  12. const root = resolve(import.meta.dirname, '..')
  13. const OUT_EVENTS = 'docs/cordis-catalog/events.md'
  14. const OUT_SERVICES = 'docs/cordis-catalog/services.md'
  15. /** The fenced-block info string for generated signature blocks (skipped by
  16. * doc-typecheck, since a bare signature fragment is not standalone-compilable). */
  17. const FENCE = 'ts cordis-catalog'
  18. /**
  19. * One primary core-data-structures page per signature type, shared by the
  20. * Cordis and config catalogs; union names intentionally do not reuse the
  21. * type-equivalence manifest's map-symbol entries.
  22. */
  23. // TODO(catalog-type-links): verify or generate link-map coverage.
  24. export const LINK_MAP: Record<string, string> = {
  25. Agent: 'core.md',
  26. ContentBlock: 'core.md',
  27. Message: 'core.md',
  28. MessageSource: 'core.md',
  29. GenerateOptions: 'core.md',
  30. LlmCallConfig: 'core.md',
  31. SessionEvent: 'core.md',
  32. SessionStartSource: 'core.md',
  33. StreamChunk: 'llm-streaming.md',
  34. TurnEndReason: 'session.md',
  35. ToolDefinition: 'tools.md',
  36. ToolExecution: 'tools.md',
  37. ToolExecutionInput: 'tools.md',
  38. ToolExecutionResult: 'tools.md',
  39. ToolExecutionToken: 'tools.md',
  40. ApprovalOutcome: 'approval.md',
  41. ApprovalPolicy: 'approval.md',
  42. ApprovalRequest: 'approval.md',
  43. BashExecRequest: 'bash.md',
  44. BashExecSpec: 'bash.md',
  45. BashRunResult: 'bash.md',
  46. ConfinedArgv: 'sandbox.md',
  47. SandboxMode: 'sandbox.md',
  48. SandboxPolicy: 'sandbox.md',
  49. CodeRunRequest: 'code-runtime.md',
  50. CodeRunResult: 'code-runtime.md',
  51. FsEditOutcome: 'filesystem.md',
  52. FsEditRequest: 'filesystem.md',
  53. FsInfo: 'filesystem.md',
  54. FsTarget: 'filesystem.md',
  55. FsVersion: 'filesystem.md',
  56. FsWriteIntent: 'filesystem.md',
  57. FsWriteOutcome: 'filesystem.md',
  58. FsPolicyExec: 'filesystem.md',
  59. FileReadOutcome: 'filesystem.md',
  60. }
  61. /** One harness event, extracted from an `interface Events` block. */
  62. interface EventEntry {
  63. /** Scoped name, e.g. `agent/request`. */
  64. name: string
  65. /** The scope prefix, e.g. `agent` (everything before the first `/`). */
  66. scope: string
  67. /** Full signature text (the method-signature member, JSDoc stripped). */
  68. signature: string
  69. /** Dispatch mode from the `@mode` tag. */
  70. mode: Mode
  71. /** Description prose (JSDoc minus the `@mode` tag), one line per paragraph. */
  72. doc: string
  73. /** Source pointer `packages/…/file.ts:line` of the declaration. */
  74. source: string
  75. }
  76. /** One harness service, extracted from an `interface Context` block. */
  77. interface ServiceEntry {
  78. /** The `ctx.<key>` name, e.g. `llm`. */
  79. key: string
  80. /** The service class/interface name, e.g. `LlmService`. */
  81. type: string
  82. /** Whether the service class is abstract (a seam interface). */
  83. abstract: boolean
  84. /** Class-level JSDoc prose, one line per paragraph. */
  85. doc: string
  86. /** Public method signatures (bodies stripped), in source order. */
  87. methods: string[]
  88. /** Source pointer of the class declaration. */
  89. source: string
  90. }
  91. /** A terse inherited-tier entry (pinned vendor surface). */
  92. interface InheritedEntry {
  93. name: string
  94. summary: string
  95. /** Source pointer `vendor/…:line`. */
  96. source: string
  97. }
  98. // cordisModuleBody / eventMembers / serviceClasses live in cordis-walk.ts,
  99. // shared with gen-website-api.ts — one walk, two renderers.
  100. /** The signature text of a method-signature member (everything but a body). */
  101. function memberSignature(member: ts.TypeElement | ts.ClassElement, sf: ts.SourceFile): string {
  102. const full = member.getText(sf)
  103. const body = (member as { body?: ts.Node }).body
  104. const sig = body ? full.slice(0, full.length - body.getText(sf).length) : full
  105. return sig.replace(/\s*;?\s*$/, '').replace(/\s+/g, ' ').trim()
  106. }
  107. /** Walk every harness `interface Events` block and extract its events, hard-
  108. * erroring (aggregated) on any JSDoc-completeness violation: a missing/
  109. * contradicted `@mode`, missing description prose, or an undocumented payload
  110. * parameter. `scanRoot` defaults to the repo root; tests pass a fixture dir. */
  111. export function collectEvents(scanRoot: string = root): EventEntry[] {
  112. const entries: EventEntry[] = []
  113. const violations: string[] = []
  114. for (const rel of globSync('packages/*/*/src/*.ts', { cwd: scanRoot }).map(s => s.split(sep).join('/')).sort()) {
  115. const abs = resolve(scanRoot, rel)
  116. const text = readFileSync(abs, 'utf8')
  117. if (!text.includes('interface Events')) continue
  118. const sf = ts.createSourceFile(abs, text, ts.ScriptTarget.Latest, true)
  119. const body = cordisModuleBody(sf)
  120. if (!body) continue
  121. for (const { name, member } of eventMembers(body, sf)) {
  122. const signature = memberSignature(member, sf)
  123. const raw = rawJsDoc(text, member)
  124. const { doc, mode } = parseJsDoc(raw)
  125. const src = pointer(rel, sf, member)
  126. const where = `event '${name}' (${src})`
  127. if (!mode) {
  128. violations.push(`${where} is missing an @mode tag. Add '@mode emit|waterfall|parallel|serial' to its JSDoc (see AGENTS.md).`)
  129. }
  130. // Conclusive structural check: a trailing `next: () => …` parameter is a
  131. // waterfall. (emit vs parallel vs serial is not structurally
  132. // distinguishable, so it is trusted from the tag.)
  133. const last = member.parameters.at(-1)
  134. const hasNext = !!last && last.name.getText(sf) === 'next'
  135. if (mode && hasNext && mode !== 'waterfall') {
  136. violations.push(`${where} has a trailing 'next' parameter (structurally a waterfall) but is tagged '@mode ${mode}'. Fix the tag or the signature.`)
  137. }
  138. if (mode && !hasNext && mode === 'waterfall') {
  139. violations.push(`${where} is tagged '@mode waterfall' but has no trailing 'next' parameter. A waterfall delegates via next().`)
  140. }
  141. if (!doc) violations.push(`${where} has no description prose. Say what happened / what a listener may do, above the block tags.`)
  142. // Payload parameters need a non-empty @param. The `this` receiver is not
  143. // payload, and a waterfall's trailing `next` is covered by its mode.
  144. const { params } = parseTags(raw)
  145. checkParams(where, 'event', member.parameters, params, sf,
  146. p => (ts.isIdentifier(p.name) && p.name.text === 'this') || (hasNext && p === last), violations)
  147. if (mode) entries.push({ name, scope: name.split('/')[0] ?? name, signature, mode, doc, source: src })
  148. }
  149. }
  150. reportViolations('gen-cordis-catalog', violations)
  151. return entries
  152. }
  153. /** Walk every harness `interface Context` block + its service class, hard-
  154. * erroring (aggregated) on any JSDoc-completeness violation: a class or public
  155. * method without JSDoc prose, an undocumented parameter, a stale `@param`, a
  156. * missing `@returns` on a non-void method, or an inferred (unannotated) return
  157. * type the pure-AST walk cannot classify.
  158. * `scanRoot` defaults to the repo root; tests pass a fixture dir. */
  159. export function collectServices(scanRoot: string = root): ServiceEntry[] {
  160. const entries: ServiceEntry[] = []
  161. const violations: string[] = []
  162. for (const rel of globSync('packages/*/*/src/index.ts', { cwd: scanRoot }).map(s => s.split(sep).join('/')).sort()) {
  163. const abs = resolve(scanRoot, rel)
  164. const text = readFileSync(abs, 'utf8')
  165. if (!text.includes('interface Context')) continue
  166. const sf = ts.createSourceFile(abs, text, ts.ScriptTarget.Latest, true)
  167. const body = cordisModuleBody(sf)
  168. if (!body) continue
  169. // Resolve each ctx key to its service class (shared walk) and emit an entry.
  170. for (const { key, type, cls, abstract, doc: clsDoc } of serviceClasses(body, sf, rel, violations)) {
  171. const methods: string[] = []
  172. for (const member of cls.members) {
  173. if (!ts.isMethodDeclaration(member)) continue
  174. // Only instance methods callable through `ctx.<key>` are surface;
  175. // private, protected, and static methods are not.
  176. const nonPublic = member.modifiers?.some(m =>
  177. m.kind === ts.SyntaxKind.PrivateKeyword
  178. || m.kind === ts.SyntaxKind.ProtectedKeyword
  179. || m.kind === ts.SyntaxKind.StaticKeyword)
  180. || ts.isPrivateIdentifier(member.name)
  181. if (nonPublic) continue
  182. const memberName = member.name.getText(sf)
  183. if (memberName.startsWith('[')) continue // computed/symbol members
  184. methods.push(memberSignature(member, sf))
  185. const where = `service method ctx.${key}.${memberName} (${pointer(rel, sf, member)})`
  186. const raw = rawJsDoc(text, member)
  187. if (!raw) { violations.push(`${where} has no JSDoc.`); continue }
  188. if (!parseJsDoc(raw).doc) violations.push(`${where} has no description prose above its block tags.`)
  189. const { params, returns } = parseTags(raw)
  190. // Every parameter needs a non-empty @param (`this` receiver exempt),
  191. // and a non-void ANNOTATED result needs a non-empty @returns — the
  192. // shared checkers carry the exact contract.
  193. checkParams(where, 'service', member.parameters, params, sf,
  194. p => ts.isIdentifier(p.name) && p.name.text === 'this', violations)
  195. checkReturns(where, member.type, returns, sf, violations)
  196. }
  197. entries.push({
  198. key,
  199. type,
  200. abstract,
  201. doc: clsDoc,
  202. methods,
  203. source: pointer(rel, sf, cls),
  204. })
  205. }
  206. }
  207. reportViolations('gen-cordis-catalog', violations)
  208. return entries.sort((a, b) => a.key.localeCompare(b.key))
  209. }
  210. /**
  211. * The inherited tier — cordis core + loader/hmr/timer. Curated, terse, and
  212. * hand-summarized because (a) it is pinned vendor source that changes only on a
  213. * deliberate vendor sync, (b) the cordis-core `Context` mixes true ctx members
  214. * with non-service fields (`root`, `baseUrl`, `logger`) that a blind walk would
  215. * wrongly surface as services, and (c) the internal/* events carry no JSDoc to
  216. * render. Source pointers are verified against vendor by `verify-md-links`'
  217. * sibling check is N/A; keep them current on a vendor bump.
  218. */
  219. const INHERITED_EVENTS: InheritedEntry[] = [
  220. { name: 'internal/plugin', summary: 'A plugin fiber was created.', source: 'vendor/cordis/src/events.ts:328' },
  221. { name: 'internal/status', summary: 'A fiber changed lifecycle state.', source: 'vendor/cordis/src/events.ts:330' },
  222. { name: 'internal/service', summary: 'Interception hook for a service binding (no core producer).', source: 'vendor/cordis/src/events.ts:332' },
  223. { name: 'internal/update', summary: 'Waterfall: a fiber config update is being applied.', source: 'vendor/cordis/src/events.ts:334' },
  224. { name: 'internal/get', summary: 'Waterfall: a service is being read from the store.', source: 'vendor/cordis/src/events.ts:336' },
  225. { name: 'internal/set', summary: 'Waterfall: a service is being written to the store.', source: 'vendor/cordis/src/events.ts:338' },
  226. { name: 'internal/listener', summary: 'A listener was registered.', source: 'vendor/cordis/src/events.ts:340' },
  227. { name: 'internal/dispatch', summary: 'An event is being dispatched to listeners.', source: 'vendor/cordis/src/events.ts:342' },
  228. { name: 'hmr/change', summary: 'A watched source file changed on disk.', source: 'vendor/hmr/src/index.ts:20' },
  229. { name: 'hmr/reload', summary: 'Plugins are being reloaded after a change.', source: 'vendor/hmr/src/index.ts:21' },
  230. { name: 'exit', summary: 'The process is exiting on a signal.', source: 'vendor/loader/src/index.ts:23' },
  231. { name: 'loader/config-update', summary: 'The loader config tree changed.', source: 'vendor/loader/src/index.ts:24' },
  232. { name: 'loader/entry-init', summary: 'A config entry is being initialized.', source: 'vendor/loader/src/index.ts:25' },
  233. { name: 'loader/partial-dispose', summary: 'An entry is being partially disposed on reload.', source: 'vendor/loader/src/index.ts:26' },
  234. { name: 'loader/patch-context', summary: 'A context is being patched during a reload.', source: 'vendor/loader/src/index.ts:27' },
  235. ]
  236. export const INHERITED_SERVICES: InheritedEntry[] = [
  237. { name: 'ctx.on / ctx.once', summary: 'Register an event listener (disposable).', source: 'vendor/cordis/src/events.ts:34' },
  238. { name: 'ctx.emit / ctx.parallel / ctx.serial / ctx.bail / ctx.waterfall', summary: 'Dispatch an event (sync / awaited / first-bail / veto-chain).', source: 'vendor/cordis/src/events.ts:34' },
  239. { name: 'ctx.plugin / ctx.inject', summary: 'Load a plugin / declare required services.', source: 'vendor/cordis/src/registry.ts:164' },
  240. { name: 'ctx.effect', summary: 'Register a disposable side effect tied to the fiber.', source: 'vendor/cordis/src/fiber.ts:9' },
  241. { name: 'ctx.get / ctx.set / ctx.provide / ctx.accessor / ctx.mixin', summary: 'Low-level service-store access and binding.', source: 'vendor/cordis/src/reflect.ts:7' },
  242. { name: 'ctx.extend / ctx.isolate / ctx.intercept', summary: 'Derive a child context (scoped services / isolation / interception).', source: 'vendor/cordis/src/context.ts:42' },
  243. { name: 'ctx.root / ctx.scope / ctx.fiber / ctx.registry / ctx.reflect / ctx.events / ctx.logger', summary: 'Ambient handles onto the running context graph.', source: 'vendor/cordis/src/context.ts:16' },
  244. { name: 'ctx.timer (+ interval / timeout / throttle / debounce / setTimeout / setInterval)', summary: 'Disposable timer helpers. The `timer` key is provided at runtime; the six helpers are mixed onto ctx directly (declared via Pick).', source: 'vendor/timer/src/index.ts:4' },
  245. { name: 'ctx.loader', summary: 'The config Loader that booted the app (present under the loader).', source: 'vendor/loader/src/index.ts:30' },
  246. { name: 'ctx.hmr', summary: 'The hot-module-reload watcher (present under the hmr plugin).', source: 'vendor/hmr/src/index.ts:15' },
  247. ]
  248. /** Render the cross-link "Types:" line for a signature, or '' if none apply. */
  249. function typeLinks(signature: string): string {
  250. const seen = new Set<string>()
  251. for (const name of Object.keys(LINK_MAP)) {
  252. if (new RegExp(`\\b${name}\\b`).test(signature)) seen.add(name)
  253. }
  254. if (seen.size === 0) return ''
  255. const links = [...seen].sort().map(n => `[${n}](../core-data-structures/${LINK_MAP[n]})`)
  256. return `Types: ${links.join(' · ')}`
  257. }
  258. /** Render one harness event entry. */
  259. function renderEvent(e: EventEntry): string[] {
  260. const out = [`### \`${e.name}\` — ${e.mode}`, '']
  261. if (e.doc) out.push(e.doc, '')
  262. out.push('```' + FENCE, e.signature, '```', '')
  263. const links = typeLinks(e.signature)
  264. if (links) out.push(links, '')
  265. out.push(`Source: [\`${e.source}\`](../../${e.source.split(':')[0]})`, '')
  266. return out
  267. }
  268. /** Render one harness service entry. */
  269. function renderService(s: ServiceEntry): string[] {
  270. const kind = s.abstract ? ' (abstract seam)' : ''
  271. const out = [`## \`ctx.${s.key}\` — \`${s.type}\`${kind}`, '']
  272. if (s.doc) out.push(s.doc, '')
  273. if (s.methods.length) {
  274. out.push('```' + FENCE, ...s.methods, '```', '')
  275. const links = typeLinks(s.methods.join('\n'))
  276. if (links) out.push(links, '')
  277. }
  278. out.push(`Source: [\`${s.source}\`](../../${s.source.split(':')[0]})`, '')
  279. return out
  280. }
  281. /** The shared generated-file banner comment. */
  282. const BANNER = [
  283. '<!-- Generated by scripts/gen-cordis-catalog.ts — do not edit by hand.',
  284. ' Run `pnpm run gen-cordis-catalog` to regenerate. -->',
  285. '',
  286. ]
  287. /** The shared GENERATED + freshness-gate + fence notice paragraph. */
  288. const GATE_NOTICE = 'This file is GENERATED from source (`scripts/gen-cordis-catalog.ts`) and verified fresh by `pnpm run verify-cordis-catalog` (part of `doc-sync`) — do not edit it by hand. Signature blocks use a `ts cordis-catalog` fence (skipped by doc-typecheck, since a bare signature is not standalone-compilable). Type names in a signature link to the page that documents them.'
  289. /** Render the events catalog (pure, deterministic given sorted inputs). */
  290. function renderEvents(events: EventEntry[]): string {
  291. const lines: string[] = [
  292. ...BANNER,
  293. '# Cordis Events Catalog',
  294. '',
  295. 'Every cordis event a plugin can listen to: exact signature, dispatch mode, and the declaration\'s JSDoc. This is one axis of the **wiring** reference a plugin author works against — the callable `ctx.<key>` surface is the sibling [services catalog](services.md), and [core-data-structures/](../core-data-structures/core.md) catalogs the *data structures* these signatures move around.',
  296. '',
  297. GATE_NOTICE,
  298. '',
  299. 'The **harness tier** below (the `@deepseek-ai/dsh-*` packages) is the vocabulary this repo owns, grouped by scope. The **inherited tier** at the end is the cordis-core + loader/hmr/timer event surface a plugin also sees — pinned vendor source, summarized tersely.',
  300. '',
  301. 'Dispatch modes: **emit** (fire-and-forget), **waterfall** (each listener gets `next()` and may transform or veto — see [waterfall semantics](../cordis-primer.md#cordis-waterfall-semantics)), **parallel** (awaited fan-out; all listeners run), **serial** (awaited in registration order until one returns a bail value — anything other than `null`, `false`, or `undefined`).',
  302. '',
  303. ]
  304. const scopes = [...new Set(events.map(e => e.scope))].sort()
  305. for (const scope of scopes) {
  306. lines.push(`## \`${scope}/*\``, '')
  307. for (const e of events.filter(x => x.scope === scope).sort((a, b) => a.name.localeCompare(b.name))) {
  308. lines.push(...renderEvent(e))
  309. }
  310. }
  311. lines.push(
  312. '## Inherited events (cordis core + loader/hmr/timer)',
  313. '',
  314. 'The framework events every plugin also sees, beyond the harness vocabulary above. This is pinned vendor source ([vendoring policy](../../vendor/README.md)); it is summarized here so the page is a complete picture of the event bus, without elevating framework internals to the harness tier\'s prominence.',
  315. '',
  316. )
  317. for (const e of INHERITED_EVENTS) {
  318. lines.push(`- \`${e.name}\` — ${e.summary} ([\`${e.source}\`](../../${e.source.split(':')[0]}))`)
  319. }
  320. lines.push('')
  321. return lines.join('\n')
  322. }
  323. /** Render the services catalog (pure, deterministic given sorted inputs). */
  324. function renderServices(services: ServiceEntry[]): string {
  325. const lines: string[] = [
  326. ...BANNER,
  327. '# Cordis Services Catalog',
  328. '',
  329. 'Every `ctx.<key>` service a plugin can call: the exact public interface plus the class JSDoc. This is one axis of the **wiring** reference a plugin author works against — the events a plugin listens to are the sibling [events catalog](events.md), and [core-data-structures/](../core-data-structures/core.md) catalogs the *data structures* these signatures move around. An abstract seam (e.g. `ctx.bash`) is implemented by a separate package; the interface is what consumers code against.',
  330. '',
  331. GATE_NOTICE,
  332. '',
  333. 'The **harness tier** below (the `@deepseek-ai/dsh-*` packages) is the vocabulary this repo owns. The **inherited tier** at the end is the cordis-core + loader/hmr/timer `ctx` surface a plugin also sees — pinned vendor source, summarized tersely.',
  334. '',
  335. ]
  336. for (const s of services) lines.push(...renderService(s))
  337. lines.push(
  338. '## Inherited `ctx` members (cordis core + loader/hmr/timer)',
  339. '',
  340. 'The framework `ctx` surface every plugin also sees, beyond the harness services above. This is pinned vendor source ([vendoring policy](../../vendor/README.md)); it is summarized here so the page is a complete picture of what `ctx` offers, without elevating framework internals to the harness tier\'s prominence.',
  341. '',
  342. )
  343. for (const s of INHERITED_SERVICES) {
  344. lines.push(`- \`${s.name}\` — ${s.summary} ([\`${s.source}\`](../../${s.source.split(':')[0]}))`)
  345. }
  346. lines.push('')
  347. return lines.join('\n')
  348. }
  349. /** CLI entry: `--write` (default) writes both catalogs, `--check` fails if
  350. * either is stale. Guarded behind an entry-point check so importing this module
  351. * for tests neither regenerates the committed files nor calls process.exit. */
  352. function main(): void {
  353. const outputs: [string, string][] = [
  354. [OUT_EVENTS, renderEvents(collectEvents())],
  355. [OUT_SERVICES, renderServices(collectServices())],
  356. ]
  357. if (process.argv.includes('--check')) {
  358. const stale: string[] = []
  359. for (const [out, content] of outputs) {
  360. let committed: string | null = null
  361. try {
  362. committed = readFileSync(resolve(root, out), 'utf8')
  363. } catch {
  364. // Only ENOENT (not yet generated) is expected; a present-but-unreadable
  365. // file is not a state this repo produces. Either way the remedy is the
  366. // same — regenerate — so treat a read failure as "stale".
  367. committed = null
  368. }
  369. if (committed !== content) stale.push(out)
  370. }
  371. if (stale.length === 0) {
  372. console.log(`gen-cordis-catalog: ${OUT_EVENTS} and ${OUT_SERVICES} are up to date.`)
  373. process.exit(0)
  374. }
  375. console.error(`gen-cordis-catalog: ${stale.join(' and ')} ${stale.length === 1 ? 'is' : 'are'} stale. Run \`pnpm run gen-cordis-catalog\` and commit the result.`)
  376. process.exit(1)
  377. }
  378. for (const [out, content] of outputs) writeFileSync(resolve(root, out), content)
  379. console.log(`gen-cordis-catalog: wrote ${OUT_EVENTS} and ${OUT_SERVICES}.`)
  380. }
  381. // Run only when invoked as a script, not when imported by a test.
  382. if (process.argv[1] && import.meta.filename === resolve(process.argv[1])) {
  383. main()
  384. }