brumate 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/check.d.ts +3 -3
- package/dist/{boot-DkbcqdUz.d.ts → boot-Cs_P8cDu.d.ts} +2 -2
- package/dist/cli.js +77 -6
- package/dist/cli.js.map +1 -1
- package/dist/{client-CqGDbWd_.d.ts → client-BDPsTd4q.d.ts} +40 -14
- package/dist/{client-C3vRNuLi.js → client-DYIZ7BYK.js} +271 -112
- package/dist/client-DYIZ7BYK.js.map +1 -0
- package/dist/{client-routes-BtGpYCef.js → client-routes-BmPvNr4s.js} +10 -1
- package/dist/client-routes-BmPvNr4s.js.map +1 -0
- package/dist/{context-btHuB01Z.d.ts → context-BNgBXVUQ.d.ts} +7 -5
- package/dist/{context-CTiSzQRc.js → context-CU4Fpn5a.js} +10 -13
- package/dist/context-CU4Fpn5a.js.map +1 -0
- package/dist/{defer-M18UKyfG.js → defer-7JDhFxQq.js} +2 -2
- package/dist/{defer-M18UKyfG.js.map → defer-7JDhFxQq.js.map} +1 -1
- package/dist/{devtools-D9Q7a41M.js → devtools-CzSp1GGq.js} +4 -4
- package/dist/{devtools-D9Q7a41M.js.map → devtools-CzSp1GGq.js.map} +1 -1
- package/dist/{devtools-panel-DTQtljeA.js → devtools-panel-DugGrz7L.js} +32 -9
- package/dist/devtools-panel-DugGrz7L.js.map +1 -0
- package/dist/{features-CbgII-o7.js → features-DwMYKBIC.js} +6 -2
- package/dist/features-DwMYKBIC.js.map +1 -0
- package/dist/{files-DtDH5AR4.js → files-XX5yW3KL.js} +94 -3
- package/dist/files-XX5yW3KL.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/{inspect-Bonq6EJO.js → inspect-B9cRF6AM.js} +2670 -2074
- package/dist/inspect-B9cRF6AM.js.map +1 -0
- package/dist/{loader-C-S3yzep.js → loader-BGSXt_Eb.js} +5 -5
- package/dist/{loader-C-S3yzep.js.map → loader-BGSXt_Eb.js.map} +1 -1
- package/dist/{rpc-C_znDZ_w.js → rpc-B9EkaPdU.js} +3 -3
- package/dist/{rpc-C_znDZ_w.js.map → rpc-B9EkaPdU.js.map} +1 -1
- package/dist/runtime/bundles.d.ts +1 -1
- package/dist/runtime/bundles.js +2 -0
- package/dist/runtime/bundles.js.map +1 -1
- package/dist/runtime/client.d.ts +4 -4
- package/dist/runtime/client.js +4 -4
- package/dist/runtime/context.d.ts +2 -2
- package/dist/runtime/context.js +1 -1
- package/dist/runtime/devtools.d.ts +2 -2
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/html.d.ts +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/server.d.ts +4 -4
- package/dist/runtime/server.js +4 -4
- package/dist/runtime/signals.d.ts +2 -2
- package/dist/runtime/signals.js +43 -5
- package/dist/runtime/signals.js.map +1 -1
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/store.d.ts +2 -0
- package/dist/runtime/store.js +1 -0
- package/dist/runtime/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/{search-params-CM1RWR2P.js → search-params-Cy3uRphR.js} +33 -8
- package/dist/search-params-Cy3uRphR.js.map +1 -0
- package/dist/{server-BcT9icQ4.js → server-C1OTFH4r.js} +127 -14
- package/dist/server-C1OTFH4r.js.map +1 -0
- package/dist/{server-dP_ucRiJ.d.ts → server-CavhuoFI.d.ts} +32 -8
- package/dist/{shared-CzbnWkVA.d.ts → shared-CRduzyi3.d.ts} +15 -2
- package/dist/{signals-BwD4u22K.d.ts → signals-DBnq9QRW.d.ts} +46 -6
- package/dist/{static-loader-DysAET-w.d.ts → static-loader-D5hvLQK7.d.ts} +2 -2
- package/dist/{static-loader-Bt2WDkY1.js → static-loader-XGXMzfJR.js} +3 -3
- package/dist/{static-loader-Bt2WDkY1.js.map → static-loader-XGXMzfJR.js.map} +1 -1
- package/dist/store-BIBAYZo-.js +293 -0
- package/dist/store-BIBAYZo-.js.map +1 -0
- package/dist/store-xlTzAM_r.d.ts +171 -0
- package/dist/{stream-DRjx0keF.js → stream-BBnArf_5.js} +89 -3
- package/dist/stream-BBnArf_5.js.map +1 -0
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +128 -13
- package/dist/vite.js.map +1 -1
- package/elements.d.ts +268 -21
- package/package.json +5 -1
- package/skills/brumate/SKILL.md +1 -1
- package/skills/brumate/references/errors.md +127 -9
- package/skills/brumate/references/signals.md +37 -30
- package/skills/brumate/references/state.md +3 -2
- package/dist/client-C3vRNuLi.js.map +0 -1
- package/dist/client-routes-BtGpYCef.js.map +0 -1
- package/dist/context-CTiSzQRc.js.map +0 -1
- package/dist/devtools-panel-DTQtljeA.js.map +0 -1
- package/dist/features-CbgII-o7.js.map +0 -1
- package/dist/files-DtDH5AR4.js.map +0 -1
- package/dist/inspect-Bonq6EJO.js.map +0 -1
- package/dist/search-params-CM1RWR2P.js.map +0 -1
- package/dist/server-BcT9icQ4.js.map +0 -1
- package/dist/stream-DRjx0keF.js.map +0 -1
package/check.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// API: they can change in any release. They live here and not in the prelude of each generated
|
|
3
3
|
// file, so TypeScript resolves them once for the program.
|
|
4
4
|
|
|
5
|
-
import type { ElementEvents, Elements, GlobalAttributes } from 'brumate/elements';
|
|
5
|
+
import type { ElementEvent, ElementEvents, Elements, GlobalAttributes } from 'brumate/elements';
|
|
6
6
|
import type { BindableMark } from 'brumate/signals';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -27,8 +27,8 @@ export type AnyTagAttributes = Omit<GlobalAttributes<HTMLElement | SVGElement>,
|
|
|
27
27
|
export type DynamicHandle<E> = {
|
|
28
28
|
<K extends keyof ElementEvents & string>(
|
|
29
29
|
event: K,
|
|
30
|
-
handler: (event:
|
|
31
|
-
): (event:
|
|
30
|
+
handler: (event: ElementEvent<K, E>) => unknown,
|
|
31
|
+
): (event: ElementEvent<K, E>) => unknown;
|
|
32
32
|
<H>(event: string, handler: H): H;
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as SerialEntry } from "./values-B8C7CLvG.js";
|
|
2
|
-
import {
|
|
2
|
+
import { qt as ClientModule } from "./client-BDPsTd4q.js";
|
|
3
3
|
//#region src/runtime/boot.d.ts
|
|
4
4
|
interface LoaderOptions {
|
|
5
5
|
/**
|
|
@@ -51,4 +51,4 @@ interface NavigateOptions {
|
|
|
51
51
|
}
|
|
52
52
|
//#endregion
|
|
53
53
|
export { NavigateOptions as n, LoaderOptions as t };
|
|
54
|
-
//# sourceMappingURL=boot-
|
|
54
|
+
//# sourceMappingURL=boot-Cs_P8cDu.d.ts.map
|
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Q as getLocation, W as BRIDGE_EXPORT, Y as scriptBridges, Z as BrumateError, et as findError, j as analyzeProjectProps, o as CompileError, r as inspect, s as compile, w as resolveFromDisk } from "./inspect-B9cRF6AM.js";
|
|
3
|
+
import { _ as findPackages, a as findScripts, b as resolveComponentPackage, c as findServerImport, n as defaultExclude, s as findPackageServerFile, t as collectSources } from "./files-XX5yW3KL.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
6
|
-
import { cp } from "node:fs/promises";
|
|
5
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
6
|
+
import { cp, readdir } from "node:fs/promises";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
9
|
import { spawnSync } from "node:child_process";
|
|
@@ -176,6 +176,37 @@ function typeCheck(root, tscBin) {
|
|
|
176
176
|
}
|
|
177
177
|
return { records };
|
|
178
178
|
}
|
|
179
|
+
/** Finds the calls of `bridge` in scripts that are not module-level exports. */
|
|
180
|
+
async function checkScripts(root, paths) {
|
|
181
|
+
const files = /* @__PURE__ */ new Set();
|
|
182
|
+
if (paths.length === 0) for (const file of await findScripts(root, defaultExclude)) files.add(file);
|
|
183
|
+
for (const target of paths) {
|
|
184
|
+
const absolute = path.resolve(root, target);
|
|
185
|
+
if (statSync(absolute).isDirectory()) for (const file of await findScripts(absolute, defaultExclude)) files.add(file);
|
|
186
|
+
else if (/\.[cm]?[jt]sx?$/.test(absolute)) files.add(toPosix$1(absolute));
|
|
187
|
+
}
|
|
188
|
+
const entry = findError(BRIDGE_EXPORT);
|
|
189
|
+
const records = [];
|
|
190
|
+
for (const file of files) {
|
|
191
|
+
const source = readFileSync(file, "utf8");
|
|
192
|
+
for (const { call, exported } of scriptBridges(source, file)) if (exported === void 0) {
|
|
193
|
+
const start = getLocation(source, call.start);
|
|
194
|
+
records.push({
|
|
195
|
+
file: toPosix$1(path.relative(root, file)),
|
|
196
|
+
range: {
|
|
197
|
+
start,
|
|
198
|
+
end: getLocation(source, call.end)
|
|
199
|
+
},
|
|
200
|
+
severity: "error",
|
|
201
|
+
message: BRIDGE_EXPORT,
|
|
202
|
+
code: entry?.code ?? null,
|
|
203
|
+
link: entry?.link ?? null,
|
|
204
|
+
source: "brumate"
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return records;
|
|
209
|
+
}
|
|
179
210
|
/** Compiles every `.brm` file under the root, and runs the type checker. */
|
|
180
211
|
async function check(root, options = {}) {
|
|
181
212
|
const records = [];
|
|
@@ -190,7 +221,8 @@ async function check(root, options = {}) {
|
|
|
190
221
|
link: null,
|
|
191
222
|
source: "brumate"
|
|
192
223
|
});
|
|
193
|
-
const
|
|
224
|
+
const missingOnly = paths.length === 0 && (options.paths?.length ?? 0) > 0;
|
|
225
|
+
const { sources, targets } = missingOnly ? {
|
|
194
226
|
sources: /* @__PURE__ */ new Map(),
|
|
195
227
|
targets: []
|
|
196
228
|
} : await collectSources(root, paths);
|
|
@@ -200,6 +232,7 @@ async function check(root, options = {}) {
|
|
|
200
232
|
const parents = props.get(file);
|
|
201
233
|
records.push(...checkFile(sources.get(file), toPosix$1(path.relative(root, file)), file, parents && new Set(parents.keys()), packages));
|
|
202
234
|
}
|
|
235
|
+
if (!missingOnly) records.push(...await checkScripts(root, paths));
|
|
203
236
|
const notes = [];
|
|
204
237
|
if (options.types !== false) {
|
|
205
238
|
const types = typeCheck(root, options.tscBin);
|
|
@@ -234,7 +267,8 @@ With --json, prints one JSON object per line. Exits with 1 on an error.
|
|
|
234
267
|
brumate skill [folder]
|
|
235
268
|
|
|
236
269
|
Copies the skill for .brm files into folder/brumate, for coding agents.
|
|
237
|
-
|
|
270
|
+
Also copies each skill in the skills folder of the installed @brumate/*
|
|
271
|
+
packages, such as folder/brumate-ui. The folder defaults to .claude/skills.`;
|
|
238
272
|
function toPosix(file) {
|
|
239
273
|
return file.split(path.sep).join("/");
|
|
240
274
|
}
|
|
@@ -298,6 +332,32 @@ async function checkCommand(args) {
|
|
|
298
332
|
if (!json) console.log(errors === 0 ? "No errors." : `${errors} ${errors === 1 ? "error" : "errors"}.`);
|
|
299
333
|
return errors === 0 ? 0 : 1;
|
|
300
334
|
}
|
|
335
|
+
/** Lists the skill folders of the @brumate/* packages in node_modules, from the current directory up. */
|
|
336
|
+
async function findPackageSkills(start) {
|
|
337
|
+
const found = /* @__PURE__ */ new Map();
|
|
338
|
+
const warned = /* @__PURE__ */ new Set();
|
|
339
|
+
let directory = start;
|
|
340
|
+
while (true) {
|
|
341
|
+
const scope = path.join(directory, "node_modules", "@brumate");
|
|
342
|
+
const packages = await readdir(scope).catch(() => []);
|
|
343
|
+
for (const name of packages) {
|
|
344
|
+
const root = path.join(scope, name, "skills");
|
|
345
|
+
const skills = await readdir(root, { withFileTypes: true }).catch(() => []);
|
|
346
|
+
for (const skill of skills) {
|
|
347
|
+
if (!skill.isDirectory()) continue;
|
|
348
|
+
if (skill.name === "brumate") {
|
|
349
|
+
if (!warned.has(name)) {
|
|
350
|
+
warned.add(name);
|
|
351
|
+
console.error(`@brumate/${name} has a skill named brumate, which is not copied.`);
|
|
352
|
+
}
|
|
353
|
+
} else if (!found.has(skill.name)) found.set(skill.name, path.join(root, skill.name));
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
const parent = path.dirname(directory);
|
|
357
|
+
if (parent === directory) return found;
|
|
358
|
+
directory = parent;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
301
361
|
async function skillCommand(args) {
|
|
302
362
|
if (args.length > 1 || args[0]?.startsWith("-")) {
|
|
303
363
|
console.error(`brumate skill takes one folder, not ${args.join(" ")}\n\n${USAGE}`);
|
|
@@ -311,6 +371,17 @@ async function skillCommand(args) {
|
|
|
311
371
|
force: true
|
|
312
372
|
});
|
|
313
373
|
console.log(`Copied the skill to ${path.relative(process.cwd(), target) || "."}`);
|
|
374
|
+
const copies = [];
|
|
375
|
+
for (const [name, from] of await findPackageSkills(process.cwd())) {
|
|
376
|
+
const to = path.join(folder, name);
|
|
377
|
+
copies.push(cp(from, to, {
|
|
378
|
+
recursive: true,
|
|
379
|
+
force: true
|
|
380
|
+
}).then(() => {
|
|
381
|
+
console.log(`Copied the skill to ${path.relative(process.cwd(), to) || "."}`);
|
|
382
|
+
}));
|
|
383
|
+
}
|
|
384
|
+
await Promise.all(copies);
|
|
314
385
|
return 0;
|
|
315
386
|
}
|
|
316
387
|
async function main(args) {
|
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 } 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 { collectSources } 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/** 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 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 } 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.\nThe 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\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 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":";;;;;;;;;;;AAsDA,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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AW;EAAM,OAAO;CAAK,CAAC;CACzD,QAAQ,IAAI,uBAAuB,KAAK,SAAS,QAAQ,IAAI,GAAG,MAAM,KAAK,KAAK;CAChF,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 { 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,KAA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,KAAA,KAAa,YAAY,WAAW,IAAI;AAC7D;AAEA,QAAQ,WAAW,MAAM,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { t as Context } from "./context-
|
|
2
|
-
import { a as PageState, c as ScopeId,
|
|
1
|
+
import { t as Context } from "./context-BNgBXVUQ.js";
|
|
2
|
+
import { a as PageState, c as ScopeId, m as Raw, n as ElementReference, t as Binding } from "./shared-CRduzyi3.js";
|
|
3
|
+
import { a as Store } from "./store-xlTzAM_r.js";
|
|
3
4
|
import { r as SerialEntry } from "./values-B8C7CLvG.js";
|
|
4
|
-
import {
|
|
5
|
+
import { M as SearchParamOptions } from "./signals-DBnq9QRW.js";
|
|
5
6
|
//#region src/runtime/navigate.d.ts
|
|
6
7
|
/** What the devtools learn of a navigation. See `DevtoolsHooks.navigated`. */
|
|
7
8
|
interface NavigationReport {
|
|
@@ -149,6 +150,11 @@ interface ClientModule {
|
|
|
149
150
|
components?: (Component & {
|
|
150
151
|
brumateId: string;
|
|
151
152
|
})[];
|
|
153
|
+
/**
|
|
154
|
+
* The sources of `$store` that are not a context, as functions of the reader's scope, which the
|
|
155
|
+
* update part exports. See `StoreRead`.
|
|
156
|
+
*/
|
|
157
|
+
z?: ((scope: Scope) => unknown)[];
|
|
152
158
|
/** Server function ID to the memos that call it, as scope kind and update, for `refresh`. */
|
|
153
159
|
refresh?: Record<string, Update[]>;
|
|
154
160
|
/**
|
|
@@ -185,6 +191,10 @@ interface Scope {
|
|
|
185
191
|
v?: Record<string, unknown>;
|
|
186
192
|
/** The slots that hold the contexts that the scope reads, by context key. */
|
|
187
193
|
x?: Record<string, number>;
|
|
194
|
+
/** The stores that `$toStore` made in the scope, by the ID of the site. */
|
|
195
|
+
st?: Record<number, Store<unknown>>;
|
|
196
|
+
/** The functions that stop the scope's reads of stores, which run when the scope goes. */
|
|
197
|
+
stops?: (() => void)[];
|
|
188
198
|
/** The slots of a parent that the bound props of a component write, by the slot of the prop. */
|
|
189
199
|
/**
|
|
190
200
|
* What the bound props write, by the slot of the prop: a slot of a parent,
|
|
@@ -314,15 +324,15 @@ interface DevtoolsHooks {
|
|
|
314
324
|
declare const DEVTOOLS: unique symbol;
|
|
315
325
|
//#endregion
|
|
316
326
|
//#region src/runtime/client/context.d.ts
|
|
317
|
-
/**
|
|
318
|
-
* Writes a provided value, and the slot of every scope that reads it from this provider. The
|
|
319
|
-
* provider can read the same context from above, which this does not write.
|
|
320
|
-
*/
|
|
321
|
-
declare function updateContext(scope: Scope, context: Context<unknown>, value: unknown): void;
|
|
322
327
|
/** Provides a value of a context to the scopes inside `scope`. */
|
|
323
328
|
declare function provideValue<T>(context: Context<T>, value: T, scope: Scope | ScopeId): void;
|
|
324
|
-
/**
|
|
325
|
-
|
|
329
|
+
/**
|
|
330
|
+
* Reads a context. With a fallback, a read without a provider gives the fallback, or what it
|
|
331
|
+
* returns when it is a function, in place of the error. With `slot`, which only `$route()` and
|
|
332
|
+
* `$navigation()` pass, it records the slot so that `setGlobal` can write it. A provided value is
|
|
333
|
+
* read once.
|
|
334
|
+
*/
|
|
335
|
+
declare function consumeContext<T>(context: Context<T>, scope: Scope | ScopeId, ...rest: [fallback?: unknown, slot?: number]): T;
|
|
326
336
|
/**
|
|
327
337
|
* Writes a context that the runtime provides to the whole page, and the
|
|
328
338
|
* slot of every scope that reads it without a provider above it.
|
|
@@ -330,6 +340,16 @@ declare function consumeContext<T>(context: Context<T>, scope: Scope | ScopeId,
|
|
|
330
340
|
declare function setGlobal(key: string, value: unknown): void;
|
|
331
341
|
/** Reads the route of the page again, after navigation changed it. */
|
|
332
342
|
declare function updateRoute(): void;
|
|
343
|
+
/**
|
|
344
|
+
* `$store(source)` in a component that the browser renders: the value, with its slot subscribed.
|
|
345
|
+
* With no `link`, or with a `fallback`, the source is a context, whose provider gives the store, or
|
|
346
|
+
* the fallback when none is above.
|
|
347
|
+
*/
|
|
348
|
+
declare function consumeStore<T>(source: unknown, scope: Scope | ScopeId, slot: number, path?: string, link?: number, write?: boolean, fallback?: () => unknown): T;
|
|
349
|
+
/** `$toStore(value)` in a provided value of a component that the browser renders. */
|
|
350
|
+
declare function toStore<T>(value: T, scope: Scope | ScopeId, site: number, slot?: number): Store<T>;
|
|
351
|
+
/** The update of `$toStore(value)`, in the binding stage: sends the new value to the readers. */
|
|
352
|
+
declare function storeUpdate(scope: Scope, site: number, value: unknown): void;
|
|
333
353
|
//#endregion
|
|
334
354
|
//#region src/runtime/client/handlers.d.ts
|
|
335
355
|
/**
|
|
@@ -455,7 +475,7 @@ declare function keepValue(id: ScopeId, anchor: number, place: Comment | Element
|
|
|
455
475
|
* The update of the spreads of an element whose values can be promises, as `attrs` writes them.
|
|
456
476
|
* An attribute whose value is a promise keeps what it shows until the promise settles.
|
|
457
477
|
*/
|
|
458
|
-
declare function fillAttrs(scope: Scope, anchor: number, values: Record<string, unknown>, own?: string[]): void;
|
|
478
|
+
declare function fillAttrs(scope: Scope, anchor: number, values: Record<string, unknown>, own?: string[], held?: unknown): void;
|
|
459
479
|
/**
|
|
460
480
|
* The spreads of an element of cloned markup whose values can be promises, as `setSpread` writes
|
|
461
481
|
* them. An attribute whose value is a promise is written once it settles. `place` names the
|
|
@@ -539,7 +559,7 @@ declare function writeText(scope: Scope, anchor: number, value: unknown): void;
|
|
|
539
559
|
declare function attr(scope: Scope, anchor: number, name: string, value: unknown): void;
|
|
540
560
|
/** The element of a spread in markup that the browser renders goes to the `ref` of its attributes. */
|
|
541
561
|
declare function restRef<T extends Record<string, unknown>>(values: T, scope: ScopeId, anchor: number, tag?: unknown): T;
|
|
542
|
-
declare function attrs(scope: Scope, anchor: number, values: Record<string, unknown>, own?: string[]): void;
|
|
562
|
+
declare function attrs(scope: Scope, anchor: number, values: Record<string, unknown>, own?: string[], held?: unknown): void;
|
|
543
563
|
//#endregion
|
|
544
564
|
//#region src/runtime/client/lists.d.ts
|
|
545
565
|
/** The items of a `#for` list: an array as it is, since `list` only reads it, or any iterable as an array. */
|
|
@@ -767,6 +787,12 @@ declare function resolve(scope: Scope, isLoading: () => boolean, read: () => unk
|
|
|
767
787
|
* A throw is held as the value of the memo, and its readers throw.
|
|
768
788
|
*/
|
|
769
789
|
declare function memo(scope: Scope, slot: number, compute: () => unknown): void;
|
|
790
|
+
/**
|
|
791
|
+
* Computes a memo of `$gate`. The new value replaces the old one only when the guard returns
|
|
792
|
+
* true. Otherwise the memo gives its old value back, which the write skips. The first value
|
|
793
|
+
* passes, and so does one after a held error.
|
|
794
|
+
*/
|
|
795
|
+
declare function gate(scope: Scope, slot: number, guard: (prev: unknown, next: unknown) => boolean, compute: () => unknown): void;
|
|
770
796
|
/** True while a new value of a memo loads, or while the server still streams its value. */
|
|
771
797
|
declare function pending(scope: Scope, slot: number): boolean;
|
|
772
798
|
/** True when a parent bound the prop of the slot with `$bind`. */
|
|
@@ -799,5 +825,5 @@ declare const loader: {
|
|
|
799
825
|
updateRoute: typeof updateRoute;
|
|
800
826
|
};
|
|
801
827
|
//#endregion
|
|
802
|
-
export {
|
|
803
|
-
//# sourceMappingURL=client-
|
|
828
|
+
export { list as $, hooks as $t, nodes as A, leavePage as At, descendants as B, consumeContext as Bt, clone as C, rekey as Cn, wait as Ct, keepText as D, dispose as Dt, keep as E, NavigationReport as En, nameComment as Et, setOn as F, handle as Ft, sink as G, toStore as Gt, makeId as H, provideValue as Ht, setSpread as I, handlerProp as It, addHead as J, CoreOptions as Jt, prop as K, updateRoute as Kt, template as L, rpc as Lt, setAttr as M, remount as Mt, setAttrText as N, removeRoot as Nt, listNodes as O, forget as Ot, setContent as P, action as Pt, setVar as Q, build as Qt, afterInsert as R, spread as Rt, branchNodes as S, offscreen as Sn, started as St, fillList as T, retag as Tn, loadModule as Tt, removeScope as U, setGlobal as Ut, getScope as V, consumeStore as Vt, setOwner as W, storeUpdate as Wt, addStyle as X, DevtoolsHooks as Xt, addPortal as Y, DEVTOOLS as Yt, deferInBrowser as Z, Scope as Zt, updated as _, templateCall as _n, fillSpread as _t, cells as a, componentNodes as an, content as at, searchParam as b, fill as bn, loading as bt, get as c, elementAt as cn, text as ct, pending as d, readMemo as dn, track as dt, rpcPrefix as en, toList as et, resolve as f, renderMemo as fn, after as ft, update as g, insert as gn, fillSettled as gt, unreadMemo as h, children as hn, fillAttrs as ht, bindings as i, component as in, attrs as it, putText as j, leaveRoutes as jt, markBlock as k, init as kt, isBound as l, foreignNodes as ln, writeText as lt, timed as m, setSlots as mn, countLoads as mt, asyncMemo as n, skew as nn, windowStart as nt, effect as o, dynamic as on, portalTo as ot, set as p, setItem as pn, attempt as pt, spreadProps as q, ClientModule as qt, binding as r, Component as rn, attr as rt, gate as s, dynamicNodes as sn, restRef as st, loader as t, scopes as tn, windowList as tt, memo as u, place as un, guess as ut, title as v, HiddenBody as vn, fillValue as vt, fillBranch as w, reset as wn, fail as wt, appendText as x, held as xn, reveal as xt, paramEffect as y, branch as yn, keepValue as yt, createScope as z, submitAction as zt };
|
|
829
|
+
//# sourceMappingURL=client-BDPsTd4q.d.ts.map
|