brumate 0.8.0 → 0.9.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 (122) hide show
  1. package/dist/{boot-BkUdiYOF.d.ts → boot-ej-9NRT3.d.ts} +20 -2
  2. package/dist/cli.js +88 -82
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{client-B0FXW5Kw.js → client-B-ww-PQ7.js} +402 -63
  5. package/dist/client-B-ww-PQ7.js.map +1 -0
  6. package/dist/{client-Cq6aTiDs.d.ts → client-Do6IBIhI.d.ts} +58 -14
  7. package/dist/{defer-BMIMP4Hq.js → defer-JD2FK9mV.js} +5 -3
  8. package/dist/defer-JD2FK9mV.js.map +1 -0
  9. package/dist/{devtools-calls-DGW6nLZ2.js → devtools-calls-DCjuSkim.js} +3 -3
  10. package/dist/{devtools-calls-DGW6nLZ2.js.map → devtools-calls-DCjuSkim.js.map} +1 -1
  11. package/dist/{devtools-panel-B1nF1KB7.js → devtools-panel-DLeWTPhU.js} +4 -4
  12. package/dist/{devtools-panel-B1nF1KB7.js.map → devtools-panel-DLeWTPhU.js.map} +1 -1
  13. package/dist/{devtools-B4prrxht.js → devtools-tuq7ATGN.js} +10 -7
  14. package/dist/devtools-tuq7ATGN.js.map +1 -0
  15. package/dist/{error-catalog-DakxjSgj.js → error-catalog-BBWB7w-E.js} +11 -4
  16. package/dist/error-catalog-BBWB7w-E.js.map +1 -0
  17. package/dist/{error-catalog-VxLbz-6p.js → error-catalog-CbmQqfat.js} +1 -1
  18. package/dist/{events-LgLdp1R7.js → events-BDVITj3P.js} +3 -5
  19. package/dist/events-BDVITj3P.js.map +1 -0
  20. package/dist/{features-DwMYKBIC.js → features-Cte5aj20.js} +8 -2
  21. package/dist/features-Cte5aj20.js.map +1 -0
  22. package/dist/{files-D5GtxwEQ.js → files-Bz0lAQzD.js} +2 -2
  23. package/dist/{files-D5GtxwEQ.js.map → files-Bz0lAQzD.js.map} +1 -1
  24. package/dist/{html-Cf5uKhLs.js → html-BYuHDvxy.js} +10 -3
  25. package/dist/html-BYuHDvxy.js.map +1 -0
  26. package/dist/index.d.ts +71 -19
  27. package/dist/index.js +3 -3
  28. package/dist/{inspect-CGl5Y8q6.js → inspect-fpaBJ5pm.js} +1305 -75
  29. package/dist/inspect-fpaBJ5pm.js.map +1 -0
  30. package/dist/{loader-BsaSuIoG.js → loader-DMxuZ6He.js} +14 -6
  31. package/dist/loader-DMxuZ6He.js.map +1 -0
  32. package/dist/{navigate-BlowKvhB.js → navigate-C5PjwYMh.js} +108 -20
  33. package/dist/navigate-C5PjwYMh.js.map +1 -0
  34. package/dist/{produce-CLABZ8k2.d.ts → produce-BDkCsGH7.d.ts} +3 -3
  35. package/dist/{rpc-C1jYVNAe.js → rpc-DOdrekhP.js} +23 -13
  36. package/dist/rpc-DOdrekhP.js.map +1 -0
  37. package/dist/runtime/bundles.d.ts +3 -2
  38. package/dist/runtime/bundles.js +20 -5
  39. package/dist/runtime/bundles.js.map +1 -1
  40. package/dist/runtime/client.d.ts +4 -3
  41. package/dist/runtime/client.js +5 -5
  42. package/dist/runtime/devtools.d.ts +3 -1
  43. package/dist/runtime/devtools.js +1 -1
  44. package/dist/runtime/events.js +1 -1
  45. package/dist/runtime/hot.d.ts +1 -1
  46. package/dist/runtime/html.js +1 -1
  47. package/dist/runtime/loader.d.ts +2 -2
  48. package/dist/runtime/loader.js +2 -2
  49. package/dist/runtime/otel.d.ts +18 -0
  50. package/dist/runtime/otel.js +127 -0
  51. package/dist/runtime/otel.js.map +1 -0
  52. package/dist/runtime/server.d.ts +4 -3
  53. package/dist/runtime/server.js +5 -5
  54. package/dist/runtime/signals.d.ts +2 -2
  55. package/dist/runtime/signals.js +4 -1
  56. package/dist/runtime/signals.js.map +1 -1
  57. package/dist/runtime/static-loader.d.ts +2 -2
  58. package/dist/runtime/static-loader.js +1 -1
  59. package/dist/runtime/store.d.ts +2 -2
  60. package/dist/runtime/store.js +1 -1
  61. package/dist/runtime/testing.d.ts +2 -2
  62. package/dist/runtime/testing.js +2 -2
  63. package/dist/search-params-qGERTLi3.js +382 -0
  64. package/dist/search-params-qGERTLi3.js.map +1 -0
  65. package/dist/{serial-ribg9NAj.js → serial-B2AJ9VGx.js} +1 -1
  66. package/dist/{serial-ioa17MuY.js → serial-Cj6pDGOq.js} +6 -6
  67. package/dist/{serial-ioa17MuY.js.map → serial-Cj6pDGOq.js.map} +1 -1
  68. package/dist/{server-DesBZv5g.d.ts → server-2-LS_KFo.d.ts} +125 -9
  69. package/dist/{server-BUuf7XPZ.js → server-CRGZMWnK.js} +545 -236
  70. package/dist/server-CRGZMWnK.js.map +1 -0
  71. package/dist/{shared-CX_YacDm.js → shared-CUBWrbiM.js} +4 -4
  72. package/dist/{shared-CX_YacDm.js.map → shared-CUBWrbiM.js.map} +1 -1
  73. package/dist/sheets-B9Zr50mf.js +105 -0
  74. package/dist/sheets-B9Zr50mf.js.map +1 -0
  75. package/dist/{signals-7VVD9C_H.d.ts → signals-BgsJK-uT.d.ts} +16 -6
  76. package/dist/{static-loader-C_en-4v8.js → static-loader-BDBtWsdg.js} +107 -19
  77. package/dist/static-loader-BDBtWsdg.js.map +1 -0
  78. package/dist/{static-loader-UKnK11Em.d.ts → static-loader-CAFn6p0l.d.ts} +2 -2
  79. package/dist/{store-9_oa0HG1.d.ts → store-BwWg-Iei.d.ts} +79 -2
  80. package/dist/store-DNr24Z8L.js +950 -0
  81. package/dist/store-DNr24Z8L.js.map +1 -0
  82. package/dist/{stream-read-BTsYstJY.js → stream-read-CiLDH60b.js} +2 -2
  83. package/dist/{stream-read-BTsYstJY.js.map → stream-read-CiLDH60b.js.map} +1 -1
  84. package/dist/{stream-read-Dek3HnqO.js → stream-read-DVoregpA.js} +1 -1
  85. package/dist/trace-DT7RGRAV.d.ts +52 -0
  86. package/dist/trace-browser-C7MFMove.js +170 -0
  87. package/dist/trace-browser-C7MFMove.js.map +1 -0
  88. package/dist/trace-flag-Dy267snx.js +7 -0
  89. package/dist/trace-flag-Dy267snx.js.map +1 -0
  90. package/dist/{trusted-g_zUJbh2.js → trusted-Bmwg4_hf.js} +12 -5
  91. package/dist/trusted-Bmwg4_hf.js.map +1 -0
  92. package/dist/view-transitions-BpnVwtS4.js +141 -0
  93. package/dist/view-transitions-BpnVwtS4.js.map +1 -0
  94. package/dist/vite.d.ts +8 -1
  95. package/dist/vite.js +356 -46
  96. package/dist/vite.js.map +1 -1
  97. package/elements.d.ts +8 -0
  98. package/package.json +13 -1
  99. package/skills/brumate/SKILL.md +9 -5
  100. package/skills/brumate/references/errors.md +95 -14
  101. package/skills/brumate/references/events.md +27 -1
  102. package/skills/brumate/references/signals.md +4 -4
  103. package/skills/brumate/references/state.md +79 -4
  104. package/skills/brumate/references/syntax.md +58 -9
  105. package/dist/client-B0FXW5Kw.js.map +0 -1
  106. package/dist/defer-BMIMP4Hq.js.map +0 -1
  107. package/dist/devtools-B4prrxht.js.map +0 -1
  108. package/dist/error-catalog-DakxjSgj.js.map +0 -1
  109. package/dist/events-LgLdp1R7.js.map +0 -1
  110. package/dist/features-DwMYKBIC.js.map +0 -1
  111. package/dist/html-Cf5uKhLs.js.map +0 -1
  112. package/dist/inspect-CGl5Y8q6.js.map +0 -1
  113. package/dist/loader-BsaSuIoG.js.map +0 -1
  114. package/dist/navigate-BlowKvhB.js.map +0 -1
  115. package/dist/rpc-C1jYVNAe.js.map +0 -1
  116. package/dist/search-params-Wg-0FsMj.js +0 -148
  117. package/dist/search-params-Wg-0FsMj.js.map +0 -1
  118. package/dist/server-BUuf7XPZ.js.map +0 -1
  119. package/dist/static-loader-C_en-4v8.js.map +0 -1
  120. package/dist/store-Cy4EEyZ7.js +0 -439
  121. package/dist/store-Cy4EEyZ7.js.map +0 -1
  122. package/dist/trusted-g_zUJbh2.js.map +0 -1
@@ -1,5 +1,6 @@
1
1
  import { r as SerialEntry } from "./values-B8C7CLvG.js";
2
- import { qt as ClientModule } from "./client-Cq6aTiDs.js";
2
+ import { n as TraceHandler } from "./trace-DT7RGRAV.js";
3
+ import { Xt as ClientModule } from "./client-Do6IBIhI.js";
3
4
  //#region src/runtime/boot.d.ts
4
5
  interface LoaderOptions {
5
6
  /**
@@ -33,6 +34,23 @@ interface LoaderOptions {
33
34
  onError?: (error: unknown, info: {
34
35
  scope?: number | string;
35
36
  }) => void;
37
+ /**
38
+ * Receives a span for each event with the load and the run of its handler, for each server
39
+ * function that the page calls and for each navigation. See `TraceSpan`.
40
+ *
41
+ * - A server function call and a navigation send `traceparent` to the same origin, so the spans
42
+ * of the server join the trace. A request to another origin sends none, and neither does a
43
+ * page that a link loaded early (before the click, so it cannot join a trace). A request that
44
+ * the server redirects to another origin keeps the header.
45
+ * - A call or a navigation joins the trace of a handler only when the handler makes it before
46
+ * its first `await`. Handlers overlap, so a later call could belong to another handler. A
47
+ * call after an `await`, from a memo or from a form, is the root of a trace of its own.
48
+ * - A span has no argument, result, query string or form value. A navigation has the route
49
+ * pattern, such as `/items/[id]`, once the page arrives, and none when it fails.
50
+ * - The Vite plugin leaves the code out of a build whose entry does not pass `onTrace` to the
51
+ * loader. See the `trace` option of the plugin when the entry is elsewhere.
52
+ */
53
+ onTrace?: TraceHandler;
36
54
  }
37
55
  interface NavigateOptions {
38
56
  /**
@@ -51,4 +69,4 @@ interface NavigateOptions {
51
69
  }
52
70
  //#endregion
53
71
  export { NavigateOptions as n, LoaderOptions as t };
54
- //# sourceMappingURL=boot-BkUdiYOF.d.ts.map
72
+ //# sourceMappingURL=boot-ej-9NRT3.d.ts.map
package/dist/cli.js CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
- import { a as findError } from "./error-catalog-DakxjSgj.js";
3
- import { A as analyzeProjectProps, C as resolveFromDisk, Q as getLocation, W as BRIDGE_EXPORT, Y as scriptBridges, Z as BrumateError, o as CompileError, r as inspect, s as compile } from "./inspect-CGl5Y8q6.js";
4
- import { _ as findPackages, a as findScripts, b as resolveComponentPackage, c as findServerImport, n as defaultExclude, s as findPackageServerFile, t as collectSources } from "./files-D5GtxwEQ.js";
2
+ import { a as findError } from "./error-catalog-BBWB7w-E.js";
3
+ import { $ as scriptBridges, C as planModuleSignals, D as resolveFromDisk, E as isReactiveModule, J as BRIDGE_EXPORT, P as analyzeProjectProps, S as findSignalImports, T as ModuleError, nt as getLocation, o as CompileError, r as inspect, s as compile, tt as BrumateError } from "./inspect-fpaBJ5pm.js";
4
+ import { _ as findPackages, a as findScripts, b as resolveComponentPackage, c as findServerImport, n as defaultExclude, s as findPackageServerFile, t as collectSources } from "./files-Bz0lAQzD.js";
5
5
  import { createRequire } from "node:module";
6
+ import { parseSync } from "oxc-parser";
6
7
  import { existsSync, readFileSync, statSync } from "node:fs";
7
8
  import { cp, readdir } from "node:fs/promises";
8
9
  import path from "node:path";
9
- import { fileURLToPath } from "node:url";
10
- import { spawnSync } from "node:child_process";
10
+ import { fileURLToPath, pathToFileURL } from "node:url";
11
11
  //#region src/check-command.ts
12
12
  /** How many records are errors. Warnings do not count. */
13
13
  function errorCount(records) {
@@ -19,7 +19,7 @@ function toPosix$1(file) {
19
19
  return file.split(path.sep).join("/");
20
20
  }
21
21
  function fromDiagnostic(source, file, diagnostic) {
22
- const entry = diagnostic.severity === "error" ? findError(diagnostic.message) : void 0;
22
+ const entry = findError(diagnostic.message);
23
23
  const first = Math.min(diagnostic.range.start, source.length);
24
24
  return {
25
25
  file,
@@ -79,105 +79,110 @@ function checkFile(source, file, absolute, liveProps, packages) {
79
79
  throw error;
80
80
  }
81
81
  }
82
- const TS_LINE = /^(.+?)\((\d+),(\d+)\): (error|warning) (TS\d+|BRM\d*): (.*)$/;
83
- const TS_GLOBAL = /^(error|warning) (TS\d+): (.*)$/;
84
- /** Reads the lines that `tsc` prints without colors. */
85
- function parseTypeOutput(output, root) {
86
- const records = [];
87
- let last;
88
- for (const line of output.split("\n")) {
89
- const match = TS_LINE.exec(line);
90
- if (match) {
91
- last = void 0;
92
- if (match[5].startsWith("BRM")) continue;
93
- const position = {
94
- line: Number(match[2]),
95
- column: Number(match[3])
96
- };
97
- last = {
98
- file: toPosix$1(path.relative(root, path.resolve(root, match[1]))),
99
- range: {
100
- start: position,
101
- end: position
102
- },
103
- severity: match[4] === "warning" ? "warning" : "error",
104
- message: match[6],
105
- code: match[5],
106
- link: null,
107
- source: "typescript"
108
- };
109
- records.push(last);
110
- continue;
111
- }
112
- const global = TS_GLOBAL.exec(line);
113
- if (global) {
114
- last = {
115
- file: null,
116
- range: null,
117
- severity: global[1] === "warning" ? "warning" : "error",
118
- message: global[3],
119
- code: global[2],
120
- link: null,
121
- source: "typescript"
122
- };
123
- records.push(last);
124
- continue;
125
- }
126
- if (last && /^\s+\S/.test(line)) last.message += `\n${line}`;
127
- }
128
- return records;
129
- }
130
82
  /**
131
- * Runs `brumate-tsc`, the type checker of `.brm` files. It has no API that
132
- * gives its errors, so its output is read. Without the package, it gives a
133
- * note and no records.
83
+ * Type-checks the project with `@brumate/tsc`, which the project installs. Without the package
84
+ * or a tsconfig.json, it gives a note and no records.
134
85
  */
135
- function typeCheck(root, tscBin) {
86
+ async function typeCheck(root, tscModule) {
136
87
  if (!existsSync(path.join(root, "tsconfig.json"))) return {
137
88
  records: [],
138
89
  note: "The type check was skipped: there is no tsconfig.json in the current directory."
139
90
  };
140
- let bin;
91
+ let file;
141
92
  try {
142
93
  const require = createRequire(path.join(root, "noop.js"));
143
- bin = tscBin ?? path.join(path.dirname(require.resolve("@brumate/tsc/package.json")), "bin/brumate-tsc.js");
94
+ file = tscModule ?? require.resolve("@brumate/tsc");
144
95
  } catch {
145
96
  return {
146
97
  records: [],
147
98
  note: "The type check was skipped: install @brumate/tsc to run it, or pass --no-types."
148
99
  };
149
100
  }
150
- const result = spawnSync(process.execPath, [
151
- bin,
152
- "--noEmit",
153
- "--pretty",
154
- "false"
155
- ], {
156
- cwd: root,
157
- encoding: "utf8",
158
- maxBuffer: 67108864
159
- });
160
- const records = parseTypeOutput(`${result.stdout}\n${result.stderr}`, root);
161
- function fail(message) {
101
+ const records = [];
102
+ try {
103
+ const tsc = await import(pathToFileURL(file).href);
104
+ if (typeof tsc.checkProject !== "function") return {
105
+ records: [],
106
+ note: "The type check was skipped: update @brumate/tsc to a version with checkProject, or pass --no-types."
107
+ };
108
+ for (const item of tsc.checkProject(root)) {
109
+ if (item.code.startsWith("BRM")) continue;
110
+ records.push({
111
+ ...item,
112
+ link: null,
113
+ source: "typescript"
114
+ });
115
+ }
116
+ } catch (error) {
162
117
  records.push({
163
118
  file: null,
164
119
  range: null,
165
120
  severity: "error",
166
- message,
121
+ message: `The type check did not finish: ${error instanceof Error ? error.message : String(error)}`,
167
122
  code: null,
168
123
  link: null,
169
124
  source: "typescript"
170
125
  });
171
126
  }
172
- if (result.error) fail(`The type check did not finish: ${result.error.message}`);
173
- else if (result.signal) fail(`The type check was stopped by ${result.signal}`);
174
- else if (result.status !== 0 && errorCount(records) === 0) {
175
- const text = `${result.stdout}${result.stderr}`.trim();
176
- if (!/error BRM\d*:/.test(text)) fail(text || `The type check ended with status ${result.status}`);
177
- }
178
127
  return { records };
179
128
  }
180
- /** Finds the calls of `bridge` in scripts that are not module-level exports. */
129
+ /** The message of BRM208, for a signal that a plain file imports. */
130
+ function signalImportMessage(name, specifier) {
131
+ return `"${name}" is a signal of ${specifier}, and a file of plain code gets its store, not its value. Import it in a component, or read it in a function that the module exports`;
132
+ }
133
+ /**
134
+ * Finds the problems of module signals in a script file: a form that the top level of a module
135
+ * cannot take, and a signal that a plain file imports.
136
+ */
137
+ function checkModuleSignals(source, file, root) {
138
+ const records = [];
139
+ const name = toPosix$1(path.relative(root, file));
140
+ if (isReactiveModule(file)) {
141
+ if (!source.includes("brumate/signals")) return records;
142
+ try {
143
+ const program = parseSync(file, source, {
144
+ lang: "ts",
145
+ preserveParens: false
146
+ }).program;
147
+ planModuleSignals(program, source, false, file);
148
+ } catch (error) {
149
+ if (!(error instanceof ModuleError)) throw error;
150
+ const entry = findError(error.message);
151
+ const start = getLocation(source, error.offset);
152
+ records.push({
153
+ file: name,
154
+ range: {
155
+ start,
156
+ end: start
157
+ },
158
+ severity: "error",
159
+ message: error.message,
160
+ code: entry?.code ?? null,
161
+ link: entry?.link ?? null,
162
+ source: "brumate"
163
+ });
164
+ }
165
+ return records;
166
+ }
167
+ for (const item of findSignalImports(source, file, resolveFromDisk)) {
168
+ const message = signalImportMessage(item.name, item.specifier);
169
+ const entry = findError(message);
170
+ records.push({
171
+ file: name,
172
+ range: {
173
+ start: getLocation(source, item.start),
174
+ end: getLocation(source, item.end)
175
+ },
176
+ severity: "error",
177
+ message,
178
+ code: entry?.code ?? null,
179
+ link: entry?.link ?? null,
180
+ source: "brumate"
181
+ });
182
+ }
183
+ return records;
184
+ }
185
+ /** Finds the calls of `bridge` in scripts that are not module-level exports, and module signal problems. */
181
186
  async function checkScripts(root, paths) {
182
187
  const files = /* @__PURE__ */ new Set();
183
188
  if (paths.length === 0) for (const file of await findScripts(root, defaultExclude)) files.add(file);
@@ -190,6 +195,7 @@ async function checkScripts(root, paths) {
190
195
  const records = [];
191
196
  for (const file of files) {
192
197
  const source = readFileSync(file, "utf8");
198
+ records.push(...checkModuleSignals(source, file, root));
193
199
  for (const { call, exported } of scriptBridges(source, file)) if (exported === void 0) {
194
200
  const start = getLocation(source, call.start);
195
201
  records.push({
@@ -236,7 +242,7 @@ async function check(root, options = {}) {
236
242
  if (!missingOnly) records.push(...await checkScripts(root, paths));
237
243
  const notes = [];
238
244
  if (options.types !== false) {
239
- const types = typeCheck(root, options.tscBin);
245
+ const types = await typeCheck(root, options.tscModule);
240
246
  records.push(...types.records);
241
247
  if (types.note) notes.push(types.note);
242
248
  }
@@ -261,7 +267,7 @@ Without paths, inspects every .brm file under the current directory.
261
267
 
262
268
  brumate check [--json] [--no-types] [files or directories]
263
269
 
264
- Compiles every .brm file and type-checks the project with brumate-tsc.
270
+ Compiles every .brm file and type-checks the project with @brumate/tsc.
265
271
  Prints each problem with its place, its code and a link to the docs.
266
272
  With --json, prints one JSON object per line. Exits with 1 on an error.
267
273
 
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":["toPosix"],"sources":["../src/check-command.ts","../src/cli.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { CompileError, compile } from './compile.ts';\nimport type { Diagnostic } from './model.ts';\nimport { findError } from './error-catalog.ts';\nimport { BrumateError, getLocation } from './error.ts';\nimport { BRIDGE_EXPORT, scriptBridges } from './bridges.ts';\nimport { collectSources, defaultExclude, findScripts } from './files.ts';\nimport { resolveFromDisk } from './modules.ts';\nimport type { BrumatePackage } from './packages.ts';\nimport { findPackages, resolveComponentPackage } from './packages.ts';\nimport { analyzeProjectProps } from './project.ts';\nimport { findPackageServerFile, findServerImport } from './server-files.ts';\n\n/** A place in a file. Lines and columns start at 1. */\nexport interface CheckPosition {\n line: number;\n column: number;\n}\n\n/** One problem, as `brumate check --json` prints it. */\nexport interface CheckRecord {\n /** The file, relative to the current directory. Null for a problem of the whole project. */\n file: string | null;\n /** Where the problem is. The type checker gives a start only, so its end is the start. */\n range: { start: CheckPosition; end: CheckPosition } | null;\n severity: 'error' | 'warning';\n /** The message without its code or its place. */\n message: string;\n /** `BRM012` for an error of the compiler, `TS2322` for one of TypeScript, null for a warning. */\n code: string | null;\n /** The page of the docs that explains the code, null when there is none. */\n link: string | null;\n /** Who found it. */\n source: 'brumate' | 'typescript';\n}\n\nexport interface CheckOptions {\n /** Files or directories to check. Defaults to the root. */\n paths?: string[];\n /** Runs the type checker too. Defaults to true. */\n types?: boolean;\n /** The `brumate-tsc` script to run. Defaults to the one of the installed @brumate/tsc. */\n tscBin?: string;\n}\n\nexport interface CheckResult {\n records: CheckRecord[];\n /** Why the type check did not run, such as a missing package. */\n notes: string[];\n}\n\n/** How many records are errors. Warnings do not count. */\nexport function errorCount(records: CheckRecord[]): number {\n let count = 0;\n for (const record of records) {\n if (record.severity === 'error') {\n count++;\n }\n }\n return count;\n}\n\nfunction toPosix(file: string): string {\n return file.split(path.sep).join('/');\n}\n\nfunction fromDiagnostic(source: string, file: string, diagnostic: Diagnostic): CheckRecord {\n const entry = diagnostic.severity === 'error' ? findError(diagnostic.message) : undefined;\n // A range at the end of the file stays in the file.\n const first = Math.min(diagnostic.range.start, source.length);\n const start = getLocation(source, first);\n const end = getLocation(source, Math.min(Math.max(first, diagnostic.range.end), source.length));\n return {\n file,\n range: { start, end },\n severity: diagnostic.severity === 'error' ? 'error' : 'warning',\n message: diagnostic.message,\n code: entry?.code ?? null,\n link: entry?.link ?? null,\n source: 'brumate',\n };\n}\n\n/** Compiles one file and gives its errors and warnings. */\nfunction checkFile(\n source: string,\n file: string,\n absolute: string,\n liveProps: Set<string> | undefined,\n packages: BrumatePackage[],\n): CheckRecord[] {\n try {\n const result = compile(source, {\n filename: file,\n path: absolute,\n liveProps,\n serverImport: (specifier) =>\n specifier.startsWith('.')\n ? findServerImport(absolute, specifier)\n : findPackageServerFile(packages, absolute, specifier),\n resolveModule: (specifier, importer) => {\n const local = resolveFromDisk(specifier, importer);\n const found =\n local === undefined ? resolveComponentPackage(packages, specifier, importer) : undefined;\n return found ? { path: found, source: readFileSync(found, 'utf8') } : local;\n },\n });\n const records: CheckRecord[] = [];\n for (const warning of result.warnings) {\n records.push(fromDiagnostic(source, file, warning));\n }\n return records;\n } catch (error) {\n if (error instanceof CompileError) {\n const records: CheckRecord[] = [];\n for (const diagnostic of error.diagnostics) {\n records.push(fromDiagnostic(source, file, diagnostic));\n }\n return records;\n }\n if (error instanceof BrumateError) {\n // The message holds the code and the place. The parts are in the entry and the location.\n const message = error.message.replace(/ \\([^()]*:\\d+:\\d+\\)$/, '').replace(/ \\[BRM\\d+\\]$/, '');\n const entry = findError(message);\n const start = error.location;\n return [\n {\n file,\n range: { start, end: getLocation(source, Math.min(error.offset + 1, source.length)) },\n severity: 'error',\n message,\n code: entry?.code ?? null,\n link: entry?.link ?? null,\n source: 'brumate',\n },\n ];\n }\n throw error;\n }\n}\n\nconst TS_LINE = /^(.+?)\\((\\d+),(\\d+)\\): (error|warning) (TS\\d+|BRM\\d*): (.*)$/;\nconst TS_GLOBAL = /^(error|warning) (TS\\d+): (.*)$/;\n\n/** Reads the lines that `tsc` prints without colors. */\nexport function parseTypeOutput(output: string, root: string): CheckRecord[] {\n const records: CheckRecord[] = [];\n let last: CheckRecord | undefined;\n for (const line of output.split('\\n')) {\n const match = TS_LINE.exec(line);\n if (match) {\n last = undefined;\n // Syntax errors of `.brm` files are reported by the compiler, with their codes.\n if (match[5]!.startsWith('BRM')) {\n continue;\n }\n const position = { line: Number(match[2]), column: Number(match[3]) };\n last = {\n file: toPosix(path.relative(root, path.resolve(root, match[1]!))),\n range: { start: position, end: position },\n severity: match[4] === 'warning' ? 'warning' : 'error',\n message: match[6]!,\n code: match[5]!,\n link: null,\n source: 'typescript',\n };\n records.push(last);\n continue;\n }\n const global = TS_GLOBAL.exec(line);\n if (global) {\n last = {\n file: null,\n range: null,\n severity: global[1] === 'warning' ? 'warning' : 'error',\n message: global[3]!,\n code: global[2]!,\n link: null,\n source: 'typescript',\n };\n records.push(last);\n continue;\n }\n // The lines under a message, indented, belong to it.\n if (last && /^\\s+\\S/.test(line)) {\n last.message += `\\n${line}`;\n }\n }\n return records;\n}\n\n/**\n * Runs `brumate-tsc`, the type checker of `.brm` files. It has no API that\n * gives its errors, so its output is read. Without the package, it gives a\n * note and no records.\n */\nfunction typeCheck(root: string, tscBin?: string): { records: CheckRecord[]; note?: string } {\n if (!existsSync(path.join(root, 'tsconfig.json'))) {\n return {\n records: [],\n note: 'The type check was skipped: there is no tsconfig.json in the current directory.',\n };\n }\n let bin: string;\n try {\n const require = createRequire(path.join(root, 'noop.js'));\n bin =\n tscBin ??\n path.join(path.dirname(require.resolve('@brumate/tsc/package.json')), 'bin/brumate-tsc.js');\n } catch {\n return {\n records: [],\n note: 'The type check was skipped: install @brumate/tsc to run it, or pass --no-types.',\n };\n }\n const result = spawnSync(process.execPath, [bin, '--noEmit', '--pretty', 'false'], {\n cwd: root,\n encoding: 'utf8',\n maxBuffer: 64 * 1024 * 1024,\n });\n const records = parseTypeOutput(`${result.stdout}\\n${result.stderr}`, root);\n function fail(message: string): void {\n records.push({\n file: null,\n range: null,\n severity: 'error',\n message,\n code: null,\n link: null,\n source: 'typescript',\n });\n }\n if (result.error) {\n // The process did not start, ran too long for a timeout, or printed more than maxBuffer.\n fail(`The type check did not finish: ${result.error.message}`);\n } else if (result.signal) {\n fail(`The type check was stopped by ${result.signal}`);\n } else if (result.status !== 0 && errorCount(records) === 0) {\n // A failure that has no error line of TypeScript, such as an unreadable tsconfig.json. A\n // failure of syntax errors only is reported by the compiler.\n const text = `${result.stdout}${result.stderr}`.trim();\n if (!/error BRM\\d*:/.test(text)) {\n fail(text || `The type check ended with status ${result.status}`);\n }\n }\n return { records };\n}\n\n/** Finds the calls of `bridge` in scripts that are not module-level exports. */\nasync function checkScripts(root: string, paths: string[]): Promise<CheckRecord[]> {\n const files = new Set<string>();\n if (paths.length === 0) {\n for (const file of await findScripts(root, defaultExclude)) {\n files.add(file);\n }\n }\n for (const target of paths) {\n const absolute = path.resolve(root, target);\n if (statSync(absolute).isDirectory()) {\n for (const file of await findScripts(absolute, defaultExclude)) {\n files.add(file);\n }\n } else if (/\\.[cm]?[jt]sx?$/.test(absolute)) {\n files.add(toPosix(absolute));\n }\n }\n const entry = findError(BRIDGE_EXPORT);\n const records: CheckRecord[] = [];\n for (const file of files) {\n const source = readFileSync(file, 'utf8');\n for (const { call, exported } of scriptBridges(source, file)) {\n if (exported === undefined) {\n const start = getLocation(source, call.start);\n records.push({\n file: toPosix(path.relative(root, file)),\n range: { start, end: getLocation(source, call.end) },\n severity: 'error',\n message: BRIDGE_EXPORT,\n code: entry?.code ?? null,\n link: entry?.link ?? null,\n source: 'brumate',\n });\n }\n }\n }\n return records;\n}\n\n/** Compiles every `.brm` file under the root, and runs the type checker. */\nexport async function check(root: string, options: CheckOptions = {}): Promise<CheckResult> {\n const records: CheckRecord[] = [];\n // A path that does not exist is a problem of its own. The others are still checked.\n const paths: string[] = [];\n for (const target of options.paths ?? []) {\n if (existsSync(path.resolve(root, target))) {\n paths.push(target);\n } else {\n records.push({\n file: toPosix(target),\n range: null,\n severity: 'error',\n message: 'This file or directory does not exist',\n code: null,\n link: null,\n source: 'brumate',\n });\n }\n }\n const missingOnly = paths.length === 0 && (options.paths?.length ?? 0) > 0;\n const { sources, targets } = missingOnly\n ? { sources: new Map<string, string>(), targets: [] }\n : await collectSources(root, paths);\n const props = analyzeProjectProps(sources);\n\n const packages = findPackages(root);\n for (const file of targets) {\n const parents = props.get(file);\n records.push(\n ...checkFile(\n sources.get(file)!,\n toPosix(path.relative(root, file)),\n file,\n parents && new Set(parents.keys()),\n packages,\n ),\n );\n }\n\n if (!missingOnly) {\n records.push(...(await checkScripts(root, paths)));\n }\n\n const notes: string[] = [];\n if (options.types !== false) {\n const types = typeCheck(root, options.tscBin);\n records.push(...types.records);\n if (types.note) {\n notes.push(types.note);\n }\n }\n return { records, notes };\n}\n\n/** One line for a person: `file:line:column: error BRM012: message`. */\nexport function formatRecord(record: CheckRecord): string {\n const place = record.file\n ? `${record.file}${record.range ? `:${record.range.start.line}:${record.range.start.column}` : ''}: `\n : '';\n const code = record.code ? ` ${record.code}` : '';\n const link = record.link ? `\\n ${record.link}` : '';\n return `${place}${record.severity}${code}: ${record.message}${link}`;\n}\n","#!/usr/bin/env node\nimport { cp, readdir } from 'node:fs/promises';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { check, errorCount, formatRecord } from './check-command.ts';\nimport { CompileError } from './compile.ts';\nimport { collectSources } from './files.ts';\nimport { inspect } from './inspect.ts';\nimport type { InspectReport } from './inspect.ts';\nimport { analyzeProjectProps } from './project.ts';\n\nconst USAGE = `Usage: brumate inspect [--json] [files or directories]\n\nShows what each component ships to the client, and why.\nWithout paths, inspects every .brm file under the current directory.\n\n brumate check [--json] [--no-types] [files or directories]\n\nCompiles every .brm file and type-checks the project with brumate-tsc.\nPrints each problem with its place, its code and a link to the docs.\nWith --json, prints one JSON object per line. Exits with 1 on an error.\n\n brumate skill [folder]\n\nCopies the skill for .brm files into folder/brumate, for coding agents.\nAlso copies each skill in the skills folder of the installed @brumate/*\npackages, such as folder/brumate-ui. The folder defaults to .claude/skills.`;\n\nfunction toPosix(file: string): string {\n return file.split(path.sep).join('/');\n}\n\n/** Shows parent files relative to the current directory. */\nfunction relativeParents(\n parents: Map<string, Set<string>>,\n root: string,\n): Map<string, Set<string>> {\n const result = new Map<string, Set<string>>();\n for (const [prop, files] of parents) {\n const relative = new Set<string>();\n for (const file of files) {\n relative.add(toPosix(path.relative(root, file)));\n }\n result.set(prop, relative);\n }\n return result;\n}\n\nasync function inspectCommand(args: string[]): Promise<number> {\n const json = args.includes('--json');\n const paths: string[] = [];\n for (const arg of args) {\n if (arg !== '--json') {\n paths.push(arg);\n }\n }\n const root = process.cwd();\n\n // Props are analyzed across every file under the current directory.\n const { sources, targets } = await collectSources(root, paths);\n const props = analyzeProjectProps(sources);\n\n const reports: InspectReport[] = [];\n const texts: string[] = [];\n let failed = false;\n for (const file of targets) {\n const source = sources.get(file)!;\n const filename = toPosix(path.relative(root, file));\n try {\n const parents = props.get(file);\n const result = inspect(source, {\n filename,\n liveProps: parents && new Set(parents.keys()),\n parents: parents && relativeParents(parents, root),\n });\n reports.push(result.report);\n texts.push(result.text);\n } catch (error) {\n if (!(error instanceof CompileError)) {\n throw error;\n }\n failed = true;\n console.error(error.message);\n }\n }\n console.log(json ? JSON.stringify(reports, null, 2) : texts.join('\\n\\n'));\n return failed ? 1 : 0;\n}\n\nasync function checkCommand(args: string[]): Promise<number> {\n const flags = new Set(['--json', '--no-types']);\n const paths: string[] = [];\n for (const arg of args) {\n if (!arg.startsWith('-')) {\n paths.push(arg);\n } else if (!flags.has(arg)) {\n console.error(`brumate check does not know ${arg}\\n\\n${USAGE}`);\n return 1;\n }\n }\n const { records, notes } = await check(process.cwd(), {\n paths,\n types: !args.includes('--no-types'),\n });\n const json = args.includes('--json');\n for (const record of records) {\n console.log(json ? JSON.stringify(record) : formatRecord(record));\n }\n for (const note of notes) {\n console.error(note);\n }\n const errors = errorCount(records);\n if (!json) {\n console.log(errors === 0 ? 'No errors.' : `${errors} ${errors === 1 ? 'error' : 'errors'}.`);\n }\n return errors === 0 ? 0 : 1;\n}\n\n/** Lists the skill folders of the @brumate/* packages in node_modules, from the current directory up. */\nasync function findPackageSkills(start: string): Promise<Map<string, string>> {\n // The name brumate is the skill of this package. A package never replaces it.\n const found = new Map<string, string>();\n const warned = new Set<string>();\n let directory = start;\n while (true) {\n const scope = path.join(directory, 'node_modules', '@brumate');\n // oxlint-disable-next-line no-await-in-loop -- The walk goes up in order, so the nearest node_modules wins.\n const packages = await readdir(scope).catch(() => []);\n for (const name of packages) {\n const root = path.join(scope, name, 'skills');\n // oxlint-disable-next-line no-await-in-loop -- Same walk, in order.\n const skills = await readdir(root, { withFileTypes: true }).catch(() => []);\n for (const skill of skills) {\n if (!skill.isDirectory()) {\n continue;\n }\n if (skill.name === 'brumate') {\n if (!warned.has(name)) {\n warned.add(name);\n console.error(`@brumate/${name} has a skill named brumate, which is not copied.`);\n }\n } else if (!found.has(skill.name)) {\n found.set(skill.name, path.join(root, skill.name));\n }\n }\n }\n const parent = path.dirname(directory);\n if (parent === directory) {\n return found;\n }\n directory = parent;\n }\n}\n\nasync function skillCommand(args: string[]): Promise<number> {\n if (args.length > 1 || args[0]?.startsWith('-')) {\n console.error(`brumate skill takes one folder, not ${args.join(' ')}\\n\\n${USAGE}`);\n return 1;\n }\n const folder = path.resolve(args[0] ?? '.claude/skills');\n const target = path.join(folder, 'brumate');\n // The skill is in the package, next to dist and src.\n const source = fileURLToPath(new URL('../skills/brumate', import.meta.url));\n await cp(source, target, { recursive: true, force: true });\n console.log(`Copied the skill to ${path.relative(process.cwd(), target) || '.'}`);\n\n // Each @brumate package that has skills adds them, so they match its version.\n const copies: Promise<void>[] = [];\n for (const [name, from] of await findPackageSkills(process.cwd())) {\n const to = path.join(folder, name);\n // The line prints once the copy is done, so a failed copy shows no success.\n copies.push(\n cp(from, to, { recursive: true, force: true }).then(() => {\n console.log(`Copied the skill to ${path.relative(process.cwd(), to) || '.'}`);\n }),\n );\n }\n await Promise.all(copies);\n return 0;\n}\n\nasync function main(args: string[]): Promise<number> {\n const [command, ...rest] = args;\n if (command === 'skill') {\n return skillCommand(rest);\n }\n if (command === 'check') {\n return checkCommand(rest);\n }\n if (command === 'inspect') {\n return inspectCommand(rest);\n }\n console.log(USAGE);\n return command === undefined || command === '--help' ? 0 : 1;\n}\n\nprocess.exitCode = await main(process.argv.slice(2));\n"],"mappings":";;;;;;;;;;;;AAuDA,SAAgB,WAAW,SAAgC;CACzD,IAAI,QAAQ;CACZ,KAAK,MAAM,UAAU,SACnB,IAAI,OAAO,aAAa,SACtB;CAGJ,OAAO;AACT;AAEA,SAASA,UAAQ,MAAsB;CACrC,OAAO,KAAK,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG;AACtC;AAEA,SAAS,eAAe,QAAgB,MAAc,YAAqC;CACzF,MAAM,QAAQ,WAAW,aAAa,UAAU,UAAU,WAAW,OAAO,IAAI,KAAA;CAEhF,MAAM,QAAQ,KAAK,IAAI,WAAW,MAAM,OAAO,OAAO,MAAM;CAG5D,OAAO;EACL;EACA,OAAO;GAAE,OAJG,YAAY,QAAQ,KAInB;GAAG,KAHN,YAAY,QAAQ,KAAK,IAAI,KAAK,IAAI,OAAO,WAAW,MAAM,GAAG,GAAG,OAAO,MAAM,CAGzE;EAAE;EACpB,UAAU,WAAW,aAAa,UAAU,UAAU;EACtD,SAAS,WAAW;EACpB,MAAM,OAAO,QAAQ;EACrB,MAAM,OAAO,QAAQ;EACrB,QAAQ;CACV;AACF;;AAGA,SAAS,UACP,QACA,MACA,UACA,WACA,UACe;CACf,IAAI;EACF,MAAM,SAAS,QAAQ,QAAQ;GA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M,SAAS,cAAc,IAAI,IAAI,qBAAqB,YAAY,GAAG,CAAC;CAC1E,MAAM,GAAG,QAAQ,QAAQ;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;CACzD,QAAQ,IAAI,uBAAuB,KAAK,SAAS,QAAQ,IAAI,GAAG,MAAM,KAAK,KAAK;CAGhF,MAAM,SAA0B,CAAC;CACjC,KAAK,MAAM,CAAC,MAAM,SAAS,MAAM,kBAAkB,QAAQ,IAAI,CAAC,GAAG;EACjE,MAAM,KAAK,KAAK,KAAK,QAAQ,IAAI;EAEjC,OAAO,KACL,GAAG,MAAM,IAAI;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC,CAAC,CAAC,WAAW;GACxD,QAAQ,IAAI,uBAAuB,KAAK,SAAS,QAAQ,IAAI,GAAG,EAAE,KAAK,KAAK;EAC9E,CAAC,CACH;CACF;CACA,MAAM,QAAQ,IAAI,MAAM;CACxB,OAAO;AACT;AAEA,eAAe,KAAK,MAAiC;CACnD,MAAM,CAAC,SAAS,GAAG,QAAQ;CAC3B,IAAI,YAAY,SACd,OAAO,aAAa,IAAI;CAE1B,IAAI,YAAY,SACd,OAAO,aAAa,IAAI;CAE1B,IAAI,YAAY,WACd,OAAO,eAAe,IAAI;CAE5B,QAAQ,IAAI,KAAK;CACjB,OAAO,YAAY,KAAA,KAAa,YAAY,WAAW,IAAI;AAC7D;AAEA,QAAQ,WAAW,MAAM,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"cli.js","names":["toPosix"],"sources":["../src/check-command.ts","../src/cli.ts"],"sourcesContent":["import { existsSync, readFileSync, statSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { parseSync } from 'oxc-parser';\nimport { CompileError, compile } from './compile.ts';\nimport type { Diagnostic } from './model.ts';\nimport { findError } from './error-catalog.ts';\nimport { BrumateError, getLocation } from './error.ts';\nimport { BRIDGE_EXPORT, scriptBridges } from './bridges.ts';\nimport { collectSources, defaultExclude, findScripts } from './files.ts';\nimport { ModuleError, isReactiveModule, resolveFromDisk } from './modules.ts';\nimport { findSignalImports, planModuleSignals } from './module-signals.ts';\nimport type { BrumatePackage } from './packages.ts';\nimport { findPackages, resolveComponentPackage } from './packages.ts';\nimport { analyzeProjectProps } from './project.ts';\nimport { findPackageServerFile, findServerImport } from './server-files.ts';\n\n/** A place in a file. Lines and columns start at 1. */\nexport interface CheckPosition {\n line: number;\n column: number;\n}\n\n/** One problem, as `brumate check --json` prints it. */\nexport interface CheckRecord {\n /** The file, relative to the current directory. Null for a problem of the whole project. */\n file: string | null;\n /** Where the problem is. The type checker gives a start only, so its end is the start. */\n range: { start: CheckPosition; end: CheckPosition } | null;\n severity: 'error' | 'warning';\n /** The message without its code or its place. */\n message: string;\n /** `BRM012` for an error of the compiler, `TS2322` for one of TypeScript, null for a warning. */\n code: string | null;\n /** The page of the docs that explains the code, null when there is none. */\n link: string | null;\n /** Who found it. */\n source: 'brumate' | 'typescript';\n}\n\nexport interface CheckOptions {\n /** Files or directories to check. Defaults to the root. */\n paths?: string[];\n /** Runs the type checker too. Defaults to true. */\n types?: boolean;\n /** The module that exports `checkProject`. Defaults to the @brumate/tsc of the project. */\n tscModule?: string;\n}\n\nexport interface CheckResult {\n records: CheckRecord[];\n /** Why the type check did not run, such as a missing package. */\n notes: string[];\n}\n\n/** How many records are errors. Warnings do not count. */\nexport function errorCount(records: CheckRecord[]): number {\n let count = 0;\n for (const record of records) {\n if (record.severity === 'error') {\n count++;\n }\n }\n return count;\n}\n\nfunction toPosix(file: string): string {\n return file.split(path.sep).join('/');\n}\n\nfunction fromDiagnostic(source: string, file: string, diagnostic: Diagnostic): CheckRecord {\n const entry = findError(diagnostic.message);\n // A range at the end of the file stays in the file.\n const first = Math.min(diagnostic.range.start, source.length);\n const start = getLocation(source, first);\n const end = getLocation(source, Math.min(Math.max(first, diagnostic.range.end), source.length));\n return {\n file,\n range: { start, end },\n severity: diagnostic.severity === 'error' ? 'error' : 'warning',\n message: diagnostic.message,\n code: entry?.code ?? null,\n link: entry?.link ?? null,\n source: 'brumate',\n };\n}\n\n/** Compiles one file and gives its errors and warnings. */\nfunction checkFile(\n source: string,\n file: string,\n absolute: string,\n liveProps: Set<string> | undefined,\n packages: BrumatePackage[],\n): CheckRecord[] {\n try {\n const result = compile(source, {\n filename: file,\n path: absolute,\n liveProps,\n serverImport: (specifier) =>\n specifier.startsWith('.')\n ? findServerImport(absolute, specifier)\n : findPackageServerFile(packages, absolute, specifier),\n resolveModule: (specifier, importer) => {\n const local = resolveFromDisk(specifier, importer);\n const found =\n local === undefined ? resolveComponentPackage(packages, specifier, importer) : undefined;\n return found ? { path: found, source: readFileSync(found, 'utf8') } : local;\n },\n });\n const records: CheckRecord[] = [];\n for (const warning of result.warnings) {\n records.push(fromDiagnostic(source, file, warning));\n }\n return records;\n } catch (error) {\n if (error instanceof CompileError) {\n const records: CheckRecord[] = [];\n for (const diagnostic of error.diagnostics) {\n records.push(fromDiagnostic(source, file, diagnostic));\n }\n return records;\n }\n if (error instanceof BrumateError) {\n // The message holds the code and the place. The parts are in the entry and the location.\n const message = error.message.replace(/ \\([^()]*:\\d+:\\d+\\)$/, '').replace(/ \\[BRM\\d+\\]$/, '');\n const entry = findError(message);\n const start = error.location;\n return [\n {\n file,\n range: { start, end: getLocation(source, Math.min(error.offset + 1, source.length)) },\n severity: 'error',\n message,\n code: entry?.code ?? null,\n link: entry?.link ?? null,\n source: 'brumate',\n },\n ];\n }\n throw error;\n }\n}\n\n/** The part of `@brumate/tsc` that `check` uses. */\ninterface TscModule {\n checkProject(root: string): Array<{\n file: string | null;\n range: { start: CheckPosition; end: CheckPosition } | null;\n severity: 'error' | 'warning';\n message: string;\n code: string;\n }>;\n}\n\n/**\n * Type-checks the project with `@brumate/tsc`, which the project installs. Without the package\n * or a tsconfig.json, it gives a note and no records.\n */\nasync function typeCheck(\n root: string,\n tscModule?: string,\n): Promise<{ records: CheckRecord[]; note?: string }> {\n if (!existsSync(path.join(root, 'tsconfig.json'))) {\n return {\n records: [],\n note: 'The type check was skipped: there is no tsconfig.json in the current directory.',\n };\n }\n\n // Find the package from the project, since brumate does not depend on it.\n let file: string;\n try {\n const require = createRequire(path.join(root, 'noop.js'));\n file = tscModule ?? require.resolve('@brumate/tsc');\n } catch {\n return {\n records: [],\n note: 'The type check was skipped: install @brumate/tsc to run it, or pass --no-types.',\n };\n }\n\n // Run it. A failure to load or run is an error of the check, not a crash.\n const records: CheckRecord[] = [];\n try {\n const tsc = (await import(pathToFileURL(file).href)) as Partial<TscModule>;\n // A @brumate/tsc from before checkProject cannot run the check.\n if (typeof tsc.checkProject !== 'function') {\n return {\n records: [],\n note: 'The type check was skipped: update @brumate/tsc to a version with checkProject, or pass --no-types.',\n };\n }\n for (const item of tsc.checkProject(root)) {\n // Syntax errors of `.brm` files are reported by the compiler, with their codes.\n if (item.code.startsWith('BRM')) {\n continue;\n }\n records.push({ ...item, link: null, source: 'typescript' });\n }\n } catch (error) {\n records.push({\n file: null,\n range: null,\n severity: 'error',\n message: `The type check did not finish: ${error instanceof Error ? error.message : String(error)}`,\n code: null,\n link: null,\n source: 'typescript',\n });\n }\n return { records };\n}\n\n/** The message of BRM208, for a signal that a plain file imports. */\nfunction signalImportMessage(name: string, specifier: string): string {\n return `\"${name}\" is a signal of ${specifier}, and a file of plain code gets its store, not its value. Import it in a component, or read it in a function that the module exports`;\n}\n\n/**\n * Finds the problems of module signals in a script file: a form that the top level of a module\n * cannot take, and a signal that a plain file imports.\n */\nfunction checkModuleSignals(source: string, file: string, root: string): CheckRecord[] {\n const records: CheckRecord[] = [];\n const name = toPosix(path.relative(root, file));\n if (isReactiveModule(file)) {\n if (!source.includes('brumate/signals')) {\n return records;\n }\n try {\n const program = parseSync(file, source, { lang: 'ts', preserveParens: false }).program;\n planModuleSignals(program, source, false, file);\n } catch (error) {\n if (!(error instanceof ModuleError)) {\n throw error;\n }\n const entry = findError(error.message);\n const start = getLocation(source, error.offset);\n records.push({\n file: name,\n range: { start, end: start },\n severity: 'error',\n message: error.message,\n code: entry?.code ?? null,\n link: entry?.link ?? null,\n source: 'brumate',\n });\n }\n return records;\n }\n for (const item of findSignalImports(source, file, resolveFromDisk)) {\n const message = signalImportMessage(item.name, item.specifier);\n const entry = findError(message);\n records.push({\n file: name,\n range: { start: getLocation(source, item.start), end: getLocation(source, item.end) },\n severity: 'error',\n message,\n code: entry?.code ?? null,\n link: entry?.link ?? null,\n source: 'brumate',\n });\n }\n return records;\n}\n\n/** Finds the calls of `bridge` in scripts that are not module-level exports, and module signal problems. */\nasync function checkScripts(root: string, paths: string[]): Promise<CheckRecord[]> {\n const files = new Set<string>();\n if (paths.length === 0) {\n for (const file of await findScripts(root, defaultExclude)) {\n files.add(file);\n }\n }\n for (const target of paths) {\n const absolute = path.resolve(root, target);\n if (statSync(absolute).isDirectory()) {\n for (const file of await findScripts(absolute, defaultExclude)) {\n files.add(file);\n }\n } else if (/\\.[cm]?[jt]sx?$/.test(absolute)) {\n files.add(toPosix(absolute));\n }\n }\n const entry = findError(BRIDGE_EXPORT);\n const records: CheckRecord[] = [];\n for (const file of files) {\n const source = readFileSync(file, 'utf8');\n records.push(...checkModuleSignals(source, file, root));\n for (const { call, exported } of scriptBridges(source, file)) {\n if (exported === undefined) {\n const start = getLocation(source, call.start);\n records.push({\n file: toPosix(path.relative(root, file)),\n range: { start, end: getLocation(source, call.end) },\n severity: 'error',\n message: BRIDGE_EXPORT,\n code: entry?.code ?? null,\n link: entry?.link ?? null,\n source: 'brumate',\n });\n }\n }\n }\n return records;\n}\n\n/** Compiles every `.brm` file under the root, and runs the type checker. */\nexport async function check(root: string, options: CheckOptions = {}): Promise<CheckResult> {\n const records: CheckRecord[] = [];\n // A path that does not exist is a problem of its own. The others are still checked.\n const paths: string[] = [];\n for (const target of options.paths ?? []) {\n if (existsSync(path.resolve(root, target))) {\n paths.push(target);\n } else {\n records.push({\n file: toPosix(target),\n range: null,\n severity: 'error',\n message: 'This file or directory does not exist',\n code: null,\n link: null,\n source: 'brumate',\n });\n }\n }\n const missingOnly = paths.length === 0 && (options.paths?.length ?? 0) > 0;\n const { sources, targets } = missingOnly\n ? { sources: new Map<string, string>(), targets: [] }\n : await collectSources(root, paths);\n const props = analyzeProjectProps(sources);\n\n const packages = findPackages(root);\n for (const file of targets) {\n const parents = props.get(file);\n records.push(\n ...checkFile(\n sources.get(file)!,\n toPosix(path.relative(root, file)),\n file,\n parents && new Set(parents.keys()),\n packages,\n ),\n );\n }\n\n if (!missingOnly) {\n records.push(...(await checkScripts(root, paths)));\n }\n\n const notes: string[] = [];\n if (options.types !== false) {\n const types = await typeCheck(root, options.tscModule);\n records.push(...types.records);\n if (types.note) {\n notes.push(types.note);\n }\n }\n return { records, notes };\n}\n\n/** One line for a person: `file:line:column: error BRM012: message`. */\nexport function formatRecord(record: CheckRecord): string {\n const place = record.file\n ? `${record.file}${record.range ? `:${record.range.start.line}:${record.range.start.column}` : ''}: `\n : '';\n const code = record.code ? ` ${record.code}` : '';\n const link = record.link ? `\\n ${record.link}` : '';\n return `${place}${record.severity}${code}: ${record.message}${link}`;\n}\n","#!/usr/bin/env node\nimport { cp, readdir } from 'node:fs/promises';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { check, errorCount, formatRecord } from './check-command.ts';\nimport { CompileError } from './compile.ts';\nimport { collectSources } from './files.ts';\nimport { inspect } from './inspect.ts';\nimport type { InspectReport } from './inspect.ts';\nimport { analyzeProjectProps } from './project.ts';\n\nconst USAGE = `Usage: brumate inspect [--json] [files or directories]\n\nShows what each component ships to the client, and why.\nWithout paths, inspects every .brm file under the current directory.\n\n brumate check [--json] [--no-types] [files or directories]\n\nCompiles every .brm file and type-checks the project with @brumate/tsc.\nPrints each problem with its place, its code and a link to the docs.\nWith --json, prints one JSON object per line. Exits with 1 on an error.\n\n brumate skill [folder]\n\nCopies the skill for .brm files into folder/brumate, for coding agents.\nAlso copies each skill in the skills folder of the installed @brumate/*\npackages, such as folder/brumate-ui. The folder defaults to .claude/skills.`;\n\nfunction toPosix(file: string): string {\n return file.split(path.sep).join('/');\n}\n\n/** Shows parent files relative to the current directory. */\nfunction relativeParents(\n parents: Map<string, Set<string>>,\n root: string,\n): Map<string, Set<string>> {\n const result = new Map<string, Set<string>>();\n for (const [prop, files] of parents) {\n const relative = new Set<string>();\n for (const file of files) {\n relative.add(toPosix(path.relative(root, file)));\n }\n result.set(prop, relative);\n }\n return result;\n}\n\nasync function inspectCommand(args: string[]): Promise<number> {\n const json = args.includes('--json');\n const paths: string[] = [];\n for (const arg of args) {\n if (arg !== '--json') {\n paths.push(arg);\n }\n }\n const root = process.cwd();\n\n // Props are analyzed across every file under the current directory.\n const { sources, targets } = await collectSources(root, paths);\n const props = analyzeProjectProps(sources);\n\n const reports: InspectReport[] = [];\n const texts: string[] = [];\n let failed = false;\n for (const file of targets) {\n const source = sources.get(file)!;\n const filename = toPosix(path.relative(root, file));\n try {\n const parents = props.get(file);\n const result = inspect(source, {\n filename,\n liveProps: parents && new Set(parents.keys()),\n parents: parents && relativeParents(parents, root),\n });\n reports.push(result.report);\n texts.push(result.text);\n } catch (error) {\n if (!(error instanceof CompileError)) {\n throw error;\n }\n failed = true;\n console.error(error.message);\n }\n }\n console.log(json ? JSON.stringify(reports, null, 2) : texts.join('\\n\\n'));\n return failed ? 1 : 0;\n}\n\nasync function checkCommand(args: string[]): Promise<number> {\n const flags = new Set(['--json', '--no-types']);\n const paths: string[] = [];\n for (const arg of args) {\n if (!arg.startsWith('-')) {\n paths.push(arg);\n } else if (!flags.has(arg)) {\n console.error(`brumate check does not know ${arg}\\n\\n${USAGE}`);\n return 1;\n }\n }\n const { records, notes } = await check(process.cwd(), {\n paths,\n types: !args.includes('--no-types'),\n });\n const json = args.includes('--json');\n for (const record of records) {\n console.log(json ? JSON.stringify(record) : formatRecord(record));\n }\n for (const note of notes) {\n console.error(note);\n }\n const errors = errorCount(records);\n if (!json) {\n console.log(errors === 0 ? 'No errors.' : `${errors} ${errors === 1 ? 'error' : 'errors'}.`);\n }\n return errors === 0 ? 0 : 1;\n}\n\n/** Lists the skill folders of the @brumate/* packages in node_modules, from the current directory up. */\nasync function findPackageSkills(start: string): Promise<Map<string, string>> {\n // The name brumate is the skill of this package. A package never replaces it.\n const found = new Map<string, string>();\n const warned = new Set<string>();\n let directory = start;\n while (true) {\n const scope = path.join(directory, 'node_modules', '@brumate');\n // oxlint-disable-next-line no-await-in-loop -- The walk goes up in order, so the nearest node_modules wins.\n const packages = await readdir(scope).catch(() => []);\n for (const name of packages) {\n const root = path.join(scope, name, 'skills');\n // oxlint-disable-next-line no-await-in-loop -- Same walk, in order.\n const skills = await readdir(root, { withFileTypes: true }).catch(() => []);\n for (const skill of skills) {\n if (!skill.isDirectory()) {\n continue;\n }\n if (skill.name === 'brumate') {\n if (!warned.has(name)) {\n warned.add(name);\n console.error(`@brumate/${name} has a skill named brumate, which is not copied.`);\n }\n } else if (!found.has(skill.name)) {\n found.set(skill.name, path.join(root, skill.name));\n }\n }\n }\n const parent = path.dirname(directory);\n if (parent === directory) {\n return found;\n }\n directory = parent;\n }\n}\n\nasync function skillCommand(args: string[]): Promise<number> {\n if (args.length > 1 || args[0]?.startsWith('-')) {\n console.error(`brumate skill takes one folder, not ${args.join(' ')}\\n\\n${USAGE}`);\n return 1;\n }\n const folder = path.resolve(args[0] ?? '.claude/skills');\n const target = path.join(folder, 'brumate');\n // The skill is in the package, next to dist and src.\n const source = fileURLToPath(new URL('../skills/brumate', import.meta.url));\n await cp(source, target, { recursive: true, force: true });\n console.log(`Copied the skill to ${path.relative(process.cwd(), target) || '.'}`);\n\n // Each @brumate package that has skills adds them, so they match its version.\n const copies: Promise<void>[] = [];\n for (const [name, from] of await findPackageSkills(process.cwd())) {\n const to = path.join(folder, name);\n // The line prints once the copy is done, so a failed copy shows no success.\n copies.push(\n cp(from, to, { recursive: true, force: true }).then(() => {\n console.log(`Copied the skill to ${path.relative(process.cwd(), to) || '.'}`);\n }),\n );\n }\n await Promise.all(copies);\n return 0;\n}\n\nasync function main(args: string[]): Promise<number> {\n const [command, ...rest] = args;\n if (command === 'skill') {\n return skillCommand(rest);\n }\n if (command === 'check') {\n return checkCommand(rest);\n }\n if (command === 'inspect') {\n return inspectCommand(rest);\n }\n console.log(USAGE);\n return command === undefined || command === '--help' ? 0 : 1;\n}\n\nprocess.exitCode = await main(process.argv.slice(2));\n"],"mappings":";;;;;;;;;;;;AAyDA,SAAgB,WAAW,SAAgC;CACzD,IAAI,QAAQ;CACZ,KAAK,MAAM,UAAU,SACnB,IAAI,OAAO,aAAa,SACtB;CAGJ,OAAO;AACT;AAEA,SAASA,UAAQ,MAAsB;CACrC,OAAO,KAAK,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG;AACtC;AAEA,SAAS,eAAe,QAAgB,MAAc,YAAqC;CACzF,MAAM,QAAQ,UAAU,WAAW,OAAO;CAE1C,MAAM,QAAQ,KAAK,IAAI,WAAW,MAAM,OAAO,OAAO,MAAM;CAG5D,OAAO;EACL;EACA,OAAO;GAAE,OAJG,YAAY,QAAQ,KAInB;GAAG,KAHN,YAAY,QAAQ,KAAK,IAAI,KAAK,IAAI,OAAO,WAAW,MAAM,GAAG,GAAG,OAAO,MAAM,CAGzE;EAAE;EACpB,UAAU,WAAW,aAAa,UAAU,UAAU;EACtD,SAAS,WAAW;EACpB,MAAM,OAAO,QAAQ;EACrB,MAAM,OAAO,QAAQ;EACrB,QAAQ;CACV;AACF;;AAGA,SAAS,UACP,QACA,MACA,UACA,WACA,UACe;CACf,IAAI;EACF,MAAM,SAAS,QAAQ,QAAQ;GAC7B,UAAU;GACV,MAAM;GACN;GACA,eAAe,cACb,UAAU,WAAW,GAAG,IACpB,iBAAiB,UAAU,SAAS,IACpC,sBAAsB,UAAU,UAAU,SAAS;GACzD,gBAAgB,WAAW,aAAa;IACtC,MAAM,QAAQ,gBAAgB,WAAW,QAAQ;IACjD,MAAM,QACJ,UAAU,KAAA,IAAY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