@loredotlink/cli 0.1.180

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/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@loredotlink/cli",
3
+ "version": "0.1.180",
4
+ "description": "Lore CLI",
5
+ "type": "module",
6
+ "bin": {
7
+ "lore": "./dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "scripts/nodeVersionGuard.mjs",
12
+ "scripts/runPostinstallCommand.mjs"
13
+ ],
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "engines": {
18
+ "node": ">=20"
19
+ },
20
+ "devDependencies": {
21
+ "@biomejs/biome": "^1.9.4",
22
+ "@sentry/esbuild-plugin": "^5.2.1",
23
+ "@ts-rest/core": "3.53.0-rc.1",
24
+ "@types/node": "^22.16.5",
25
+ "@types/react": "^19.0.0",
26
+ "drizzle-orm": "^0.45.2",
27
+ "esbuild": "^0.28.1",
28
+ "ink-testing-library": "^4.0.0",
29
+ "smol-toml": "^1.6.1",
30
+ "tsx": "^4.22.4",
31
+ "typescript": "^5.9.3",
32
+ "@lore/identity-store": "0.1.0",
33
+ "@lore/contracts": "0.1.0",
34
+ "@lore/transcript-locate": "0.1.0",
35
+ "@lore/transcripts": "0.1.0",
36
+ "@lore/db": "0.1.0"
37
+ },
38
+ "dependencies": {
39
+ "@sentry/node": "^10.47.0",
40
+ "citty": "^0.2.2",
41
+ "ink": "^6.0.0",
42
+ "react": "^19.0.0",
43
+ "yaml": "2.8.3",
44
+ "zod": "^4.4.3"
45
+ },
46
+ "scripts": {
47
+ "bootstrap:dev-auth": "tsx scripts/bootstrapDevAuth.mjs",
48
+ "dev": "node scripts/runDev.mjs",
49
+ "dev:reload": "SENTRY_SPOTLIGHT=1 pnpm run postinstall && node scripts/runDev.mjs",
50
+ "dev:watch": "tsx src/index.ts _run_upload --watch",
51
+ "postinstall": "node scripts/runPostinstallCommand.mjs postinstall:migrate && node scripts/runPostinstallCommand.mjs postinstall:refresh-background-binary",
52
+ "build": "node scripts/build.mjs",
53
+ "build:prod": "node scripts/build.mjs --prod",
54
+ "gen:scrubber-rules": "node scripts/generateBaselineRules.mjs",
55
+ "start": "node dist/index.js",
56
+ "tui:stories": "tsx src/index.ts tui:stories",
57
+ "lint": "biome check src",
58
+ "typecheck": "tsc --noEmit",
59
+ "test": "node scripts/runTests.mjs",
60
+ "test:skill-sync:e2e": "env NODE_ENV=test S3_BUCKET=test AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test tsx --test --experimental-test-isolation=none --import ../api/src/test/setup.ts src/skills/skillSync.e2e.ts"
61
+ }
62
+ }
@@ -0,0 +1,27 @@
1
+ // Shared by the runtime CLI guard (src/lib/requireNode20.ts) and the
2
+ // postinstall shim (scripts/runPostinstallCommand.mjs). Kept as `.mjs`
3
+ // so the postinstall script — which runs plain Node, no bundler — can
4
+ // import it directly; esbuild bundles it into the CLI for the runtime
5
+ // guard.
6
+ //
7
+ // The minimum is driven by Ink 6 and its transitive deps (notably
8
+ // string-width 8), which use the RegExp `v` (unicodeSets) flag at
9
+ // module init. That flag requires Node >= 20; on Node 18 the module
10
+ // crashes with `SyntaxError: Invalid flags supplied to RegExp
11
+ // constructor 'v'` before any of our code runs.
12
+ export const MIN_NODE_MAJOR = 20;
13
+
14
+ export function checkNodeVersion(version = process.versions.node) {
15
+ const major = Number.parseInt(version.split('.')[0] ?? '', 10);
16
+ if (!Number.isFinite(major) || major <= 0) {
17
+ return { ok: true, currentVersion: version, message: null };
18
+ }
19
+ if (major < MIN_NODE_MAJOR) {
20
+ return {
21
+ ok: false,
22
+ currentVersion: version,
23
+ message: `requires Node.js >= ${MIN_NODE_MAJOR}.0.0 (found ${version})`,
24
+ };
25
+ }
26
+ return { ok: true, currentVersion: version, message: null };
27
+ }
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from 'node:child_process';
3
+ import { existsSync } from 'node:fs';
4
+ import path from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+
7
+ import { checkNodeVersion } from './nodeVersionGuard.mjs';
8
+
9
+ // Skip postinstall (rather than crashing it) on unsupported Node so
10
+ // `npm install` finishes and the user only sees the engines warning.
11
+ // The CLI's runtime guard reports the same constraint on next run.
12
+ const nodeVersion = checkNodeVersion();
13
+ if (!nodeVersion.ok) {
14
+ console.warn(`lore: skipping postinstall — ${nodeVersion.message}.`);
15
+ process.exit(0);
16
+ }
17
+
18
+ const allowedCommands = new Set([
19
+ 'postinstall:migrate',
20
+ 'postinstall:refresh-background-binary',
21
+ ]);
22
+
23
+ const command = process.argv[2];
24
+ const commandArgs = process.argv.slice(3);
25
+
26
+ if (!allowedCommands.has(command)) {
27
+ console.error(
28
+ `expected one of ${Array.from(allowedCommands).join(', ')}, got ${command ?? 'nothing'}`,
29
+ );
30
+ process.exit(1);
31
+ }
32
+
33
+ const packageRoot = fileURLToPath(new URL('..', import.meta.url));
34
+ const distEntrypoint = path.join(packageRoot, 'dist', 'index.js');
35
+ const sourceEntrypoint = path.join(packageRoot, 'src', 'index.ts');
36
+ const localTsxBin = path.join(
37
+ packageRoot,
38
+ 'node_modules',
39
+ '.bin',
40
+ process.platform === 'win32' ? 'tsx.cmd' : 'tsx',
41
+ );
42
+ // If `sourceEntrypoint` exists, run that; otherwise run `distEntrypoint`.
43
+ // `src` is not distributed through NPM, so in prod only `distEntrypoint` will exist.
44
+ // This may be brittle for other environments if/when we introduce other environments.
45
+ // https://ampcode.com/threads/T-019dfafa-c2db-72e5-a874-dc50f383b5c0
46
+ const useSource = existsSync(sourceEntrypoint);
47
+ const entrypoint = useSource ? sourceEntrypoint : distEntrypoint;
48
+ const executable = useSource
49
+ ? existsSync(localTsxBin)
50
+ ? localTsxBin
51
+ : 'tsx'
52
+ : process.execPath;
53
+
54
+ if (!existsSync(entrypoint)) {
55
+ console.error(`CLI entrypoint not found at ${entrypoint}`);
56
+ process.exit(1);
57
+ }
58
+
59
+ const result = spawnSync(
60
+ executable,
61
+ [entrypoint, command, ...commandArgs],
62
+ {
63
+ cwd: packageRoot,
64
+ stdio: 'inherit',
65
+ shell: process.platform === 'win32' && useSource,
66
+ },
67
+ );
68
+
69
+ if (result.error) {
70
+ console.error(result.error.message);
71
+ process.exit(1);
72
+ }
73
+
74
+ if (result.signal) {
75
+ console.error(`postinstall command terminated by ${result.signal}`);
76
+ process.exit(1);
77
+ }
78
+
79
+ process.exit(result.status ?? 1);