@raven.js/cli 1.0.0-alpha.23 → 1.0.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/README.md CHANGED
@@ -1,23 +1,31 @@
1
- # @raven.js/cli
1
+ # RavenJS CLI
2
2
 
3
- CLI tool for RavenJS framework.
3
+ The RavenJS CLI is designed for **Agent consumption**. AI skills (raven-setup, raven-add, raven-learn, raven-use) invoke it via `bunx raven`. Humans typically run only `bunx raven init`; all other workflows go through skills.
4
4
 
5
- ## Installation
5
+ ---
6
6
 
7
- ```bash
8
- npm install -g @raven.js/cli
9
- ```
7
+ ## Commands
10
8
 
11
- ## Usage
9
+ | Command | Description |
10
+ |---------|-------------|
11
+ | `bunx raven init` | Initialize AI skills and raven root. Run once before using raven-setup. |
12
+ | `bunx raven add <module>` | Add a module. Installs dependencies (`dependsOn`) in topological order, copies files, and rewrites `@ravenjs/*` imports to relative paths. |
13
+ | `bunx raven status` | Installation status for all modules. Output is JSON for Agent consumption. |
14
+ | `bunx raven guide <module>` | Output README and source for a module. Used by raven-learn. |
12
15
 
13
- ```bash
14
- raven --help
15
- ```
16
+ ---
16
17
 
17
- ## Updating
18
+ ## Options
18
19
 
19
- ```bash
20
- npm update -g @raven.js/cli
21
- ```
20
+ | Option | Description |
21
+ |--------|-------------|
22
+ | `--root <dir>` | RavenJS root directory (default: `raven`). Overridable via `RAVEN_ROOT`. |
23
+ | `--source <path>` | Local module source path instead of GitHub. Overridable via `RAVEN_SOURCE`. |
24
+ | `--registry <path>` | Path to registry JSON (default: bundled with CLI). Overridable via `RAVEN_DEFAULT_REGISTRY_PATH`. |
25
+ | `--verbose, -v` | Verbose output. |
22
26
 
23
- For more information, see https://github.com/myWsq/RavenJS
27
+ ---
28
+
29
+ ## Agent-facing output
30
+
31
+ All commands except `raven init` and `raven guide` output JSON by default. `raven status` includes version info, file hashes, and modified file status for Agent decision-making.
package/dist/raven ADDED
@@ -0,0 +1,482 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+
4
+ // index.ts
5
+ import { cac } from "cac";
6
+ import { mkdir, readdir, stat } from "fs/promises";
7
+ import { join, dirname, resolve, isAbsolute } from "path";
8
+ import { cwd } from "process";
9
+ import pc from "picocolors";
10
+ import { spinner as makeSpinner, log } from "@clack/prompts";
11
+ import { parse, stringify } from "yaml";
12
+ function loadCliVersion() {
13
+ return process.env.RAVEN_CLI_VERSION ?? "0.0.0";
14
+ }
15
+ var GITHUB_REPO = "myWsq/RavenJS";
16
+ var GITHUB_RAW_URL = `https://raw.githubusercontent.com/${GITHUB_REPO}`;
17
+ var DEFAULT_ROOT = "raven";
18
+ async function loadRegistry(options) {
19
+ const candidates = [];
20
+ if (options?.registry) {
21
+ candidates.push(isAbsolute(options.registry) ? options.registry : resolve(cwd(), options.registry));
22
+ }
23
+ if (process.env.RAVEN_DEFAULT_REGISTRY_PATH) {
24
+ const p = process.env.RAVEN_DEFAULT_REGISTRY_PATH;
25
+ candidates.push(isAbsolute(p) ? p : resolve(cwd(), p));
26
+ }
27
+ candidates.push(join(import.meta.dir, "registry.json"));
28
+ for (const p of candidates) {
29
+ const exists = await Bun.file(p).exists();
30
+ if (exists)
31
+ return await Bun.file(p).json();
32
+ }
33
+ console.error("registry.json not found. Run 'bun run build' in packages/cli first, or use --registry <path>.");
34
+ process.exit(1);
35
+ }
36
+ function getRoot(options) {
37
+ return options.root || process.env.RAVEN_ROOT || DEFAULT_ROOT;
38
+ }
39
+ function getSource(options) {
40
+ return options.source || process.env.RAVEN_SOURCE;
41
+ }
42
+ function resolveSourcePath(source) {
43
+ if (!source || source === "github")
44
+ return;
45
+ return isAbsolute(source) ? source : resolve(cwd(), source);
46
+ }
47
+ async function verboseLog(message, options) {
48
+ if (options?.verbose) {
49
+ console.log(message);
50
+ }
51
+ }
52
+ function error(message) {
53
+ console.error(message);
54
+ process.exit(1);
55
+ }
56
+ function success(message) {
57
+ log.success(message);
58
+ }
59
+ function printSectionHeader(title) {
60
+ log.step(title);
61
+ }
62
+ function printListItem(item) {
63
+ log.message(item, { symbol: pc.dim("-") });
64
+ }
65
+ async function ensureDir(path) {
66
+ try {
67
+ await mkdir(path, { recursive: true });
68
+ } catch (e) {
69
+ if (e.code !== "EEXIST")
70
+ throw e;
71
+ }
72
+ }
73
+ async function isDirEmpty(path) {
74
+ try {
75
+ const entries = await readdir(path);
76
+ return entries.length === 0;
77
+ } catch (e) {
78
+ if (e.code === "ENOENT")
79
+ return true;
80
+ throw e;
81
+ }
82
+ }
83
+ async function pathExists(path) {
84
+ try {
85
+ await stat(path);
86
+ return true;
87
+ } catch (e) {
88
+ if (e.code === "ENOENT")
89
+ return false;
90
+ throw e;
91
+ }
92
+ }
93
+ async function ensureRavenInstalled(options) {
94
+ const targetDir = cwd();
95
+ const root = getRoot(options);
96
+ const ravenDir = join(targetDir, root);
97
+ if (!await pathExists(ravenDir)) {
98
+ error(`RavenJS not installed at ${root}/. Run 'raven init' first.`);
99
+ }
100
+ const yamlPath = join(ravenDir, "raven.yaml");
101
+ try {
102
+ const content = await Bun.file(yamlPath).text();
103
+ const config = parse(content);
104
+ if (!config?.version) {
105
+ error("Invalid raven.yaml: version field is missing");
106
+ }
107
+ return { ravenDir, version: config.version };
108
+ } catch (e) {
109
+ error(`Failed to load raven.yaml: ${e.message}`);
110
+ }
111
+ }
112
+ function getModuleNames(registry) {
113
+ return Object.keys(registry.modules);
114
+ }
115
+ function getInstallOrder(moduleName, registry, installed) {
116
+ const result = [];
117
+ const visited = new Set;
118
+ const recStack = new Set;
119
+ const path = [];
120
+ let cycle = null;
121
+ function visit(name) {
122
+ if (recStack.has(name)) {
123
+ const idx = path.indexOf(name);
124
+ cycle = path.slice(idx).concat(name);
125
+ return;
126
+ }
127
+ if (visited.has(name))
128
+ return;
129
+ visited.add(name);
130
+ recStack.add(name);
131
+ path.push(name);
132
+ const mod = registry.modules[name];
133
+ if (mod?.dependsOn) {
134
+ for (const dep of mod.dependsOn) {
135
+ if (registry.modules[dep])
136
+ visit(dep);
137
+ }
138
+ }
139
+ if (!installed.has(name)) {
140
+ result.push(name);
141
+ }
142
+ path.pop();
143
+ recStack.delete(name);
144
+ }
145
+ visit(moduleName);
146
+ if (cycle !== null) {
147
+ error(`Circular dependency: ${cycle.join(" -> ")}`);
148
+ }
149
+ return result;
150
+ }
151
+ var RAVENJS_PREFIX = "@raven.js/";
152
+ function replaceRavenImports(content, fromModuleDir, registry) {
153
+ const moduleNames = Object.keys(registry.modules);
154
+ let out = content;
155
+ const depth = fromModuleDir.split("/").filter(Boolean).length;
156
+ const prefix = depth > 0 ? "../".repeat(depth) : "./";
157
+ for (const modName of moduleNames) {
158
+ const pkg = `${RAVENJS_PREFIX}${modName}`;
159
+ const rel = prefix + modName;
160
+ const dq = new RegExp(`from\\s+"${pkg.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}"`, "g");
161
+ const sq = new RegExp(`from\\s+'${pkg.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}'`, "g");
162
+ out = out.replace(dq, `from "${rel}"`).replace(sq, `from '${rel}'`);
163
+ }
164
+ return out;
165
+ }
166
+ async function downloadFile(url, destPath) {
167
+ const response = await fetch(url);
168
+ if (!response.ok) {
169
+ throw new Error(`Failed to download ${url}: ${response.status}`);
170
+ }
171
+ const content = await response.text();
172
+ await ensureDir(dirname(destPath));
173
+ await Bun.write(destPath, content);
174
+ }
175
+ async function copyLocalFile(srcPath, destPath) {
176
+ const exists = await Bun.file(srcPath).exists();
177
+ if (!exists) {
178
+ throw new Error(`Missing local file: ${srcPath}`);
179
+ }
180
+ await ensureDir(dirname(destPath));
181
+ await Bun.write(destPath, Bun.file(srcPath));
182
+ }
183
+ var SOURCE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx"];
184
+ function isSourceFile(file) {
185
+ return SOURCE_EXTENSIONS.some((ext) => file.endsWith(ext));
186
+ }
187
+ async function downloadModule(registry, moduleName, version, destDir, options, targetSubdir) {
188
+ const module = registry.modules[moduleName];
189
+ if (!module) {
190
+ throw new Error(`Module ${moduleName} not found in registry`);
191
+ }
192
+ const sourcePath = resolveSourcePath(getSource(options || {}));
193
+ if (sourcePath) {
194
+ verboseLog(`Using local source: ${sourcePath}`, options);
195
+ }
196
+ verboseLog(`Downloading ${moduleName} files...`, options);
197
+ const fromModuleDir = targetSubdir ?? moduleName;
198
+ const modifiedFiles = [];
199
+ const downloads = module.files.map(async (file) => {
200
+ let destPath;
201
+ if (module.fileMapping && module.fileMapping[file]) {
202
+ destPath = join(destDir, module.fileMapping[file]);
203
+ } else if (targetSubdir) {
204
+ destPath = join(destDir, targetSubdir, file);
205
+ } else {
206
+ destPath = join(destDir, moduleName, file);
207
+ }
208
+ verboseLog(` Downloading ${file}...`, options);
209
+ let content;
210
+ if (sourcePath) {
211
+ const primaryPath = join(sourcePath, "modules", moduleName, file);
212
+ const fallbackPath = join(sourcePath, moduleName, file);
213
+ const src = await Bun.file(primaryPath).exists() ? primaryPath : await Bun.file(fallbackPath).exists() ? fallbackPath : "";
214
+ if (!src)
215
+ throw new Error(`Missing local file: ${primaryPath}`);
216
+ content = await Bun.file(src).text();
217
+ } else {
218
+ const url = `${GITHUB_RAW_URL}/v${version}/modules/${moduleName}/${file}`;
219
+ const response = await fetch(url);
220
+ if (!response.ok)
221
+ throw new Error(`Failed to download ${url}: ${response.status}`);
222
+ content = await response.text();
223
+ }
224
+ if (isSourceFile(file)) {
225
+ content = replaceRavenImports(content, fromModuleDir, registry);
226
+ }
227
+ await ensureDir(dirname(destPath));
228
+ await Bun.write(destPath, content);
229
+ modifiedFiles.push(destPath);
230
+ });
231
+ await Promise.all(downloads);
232
+ return modifiedFiles;
233
+ }
234
+ async function downloadAiResources(registry, version, destDir, options) {
235
+ const ai = registry.ai;
236
+ if (!ai?.claude) {
237
+ throw new Error("AI resources not found in registry");
238
+ }
239
+ const mapping = ai.claude;
240
+ const entries = Object.entries(mapping);
241
+ const sourcePath = resolveSourcePath(getSource(options || {}));
242
+ if (sourcePath) {
243
+ verboseLog(`Using local source: ${sourcePath}`, options);
244
+ }
245
+ verboseLog("Downloading AI resources...", options);
246
+ const modifiedFiles = [];
247
+ const downloads = entries.map(async ([file, destRel]) => {
248
+ const destPath = join(destDir, destRel);
249
+ verboseLog(` Downloading ${file}...`, options);
250
+ if (sourcePath) {
251
+ const sourceFile = join(sourcePath, "packages", "ai", file);
252
+ await copyLocalFile(sourceFile, destPath);
253
+ } else {
254
+ const url = `${GITHUB_RAW_URL}/v${version}/packages/ai/${file}`;
255
+ await downloadFile(url, destPath);
256
+ }
257
+ modifiedFiles.push(destPath);
258
+ });
259
+ await Promise.all(downloads);
260
+ return modifiedFiles;
261
+ }
262
+ async function cmdInit(options) {
263
+ const registry = await loadRegistry(options);
264
+ const targetDir = cwd();
265
+ const root = getRoot(options);
266
+ const ravenDir = join(targetDir, root);
267
+ verboseLog(`Initializing RavenJS in ${targetDir}`, options);
268
+ const version = registry.version;
269
+ const modifiedFiles = [];
270
+ const ravenRootExists = await pathExists(ravenDir);
271
+ const ravenYamlPath = join(ravenDir, "raven.yaml");
272
+ const ravenYamlExists = await pathExists(ravenYamlPath);
273
+ const doInit = async () => {
274
+ if (!ravenRootExists || !ravenYamlExists) {
275
+ await ensureDir(ravenDir);
276
+ await createRavenYaml(ravenDir, version);
277
+ modifiedFiles.push(ravenYamlPath);
278
+ }
279
+ const dotClaudeDir = join(targetDir, ".claude");
280
+ await ensureDir(dotClaudeDir);
281
+ const aiFiles = await downloadAiResources(registry, version, targetDir, options);
282
+ modifiedFiles.push(...aiFiles);
283
+ };
284
+ if (options?.verbose) {
285
+ await doInit();
286
+ } else {
287
+ const s = makeSpinner();
288
+ s.start("Initializing RavenJS...");
289
+ try {
290
+ await doInit();
291
+ } catch (e) {
292
+ s.stop("Initialization failed");
293
+ error(e.message);
294
+ }
295
+ s.stop("Initializing RavenJS...");
296
+ }
297
+ success("RavenJS initialized successfully!");
298
+ printSectionHeader("Modified Files");
299
+ for (const file of modifiedFiles) {
300
+ printListItem(file);
301
+ }
302
+ }
303
+ async function createRavenYaml(destDir, version) {
304
+ const content = stringify({ version });
305
+ await Bun.write(join(destDir, "raven.yaml"), content);
306
+ }
307
+ async function getInstalledModules(ravenDir, registry) {
308
+ const installed = new Set;
309
+ for (const name of getModuleNames(registry)) {
310
+ const modDir = join(ravenDir, name);
311
+ if (await pathExists(modDir) && !await isDirEmpty(modDir)) {
312
+ installed.add(name);
313
+ }
314
+ }
315
+ return installed;
316
+ }
317
+ async function cmdAdd(moduleName, options) {
318
+ const registry = await loadRegistry(options);
319
+ if (!moduleName) {
320
+ error(`Please specify a module to add. Available: ${getModuleNames(registry).join(", ")}`);
321
+ }
322
+ const available = getModuleNames(registry);
323
+ if (!available.includes(moduleName)) {
324
+ error(`Unknown module: ${moduleName}`);
325
+ }
326
+ const { ravenDir, version } = await ensureRavenInstalled(options);
327
+ const installed = await getInstalledModules(ravenDir, registry);
328
+ const order = getInstallOrder(moduleName, registry, installed);
329
+ try {
330
+ const modifiedFiles = [];
331
+ const allDependencies = {};
332
+ for (const name of order) {
333
+ const files = await downloadModule(registry, name, version, ravenDir, options);
334
+ modifiedFiles.push(...files);
335
+ const mod = registry.modules[name];
336
+ if (mod?.dependencies) {
337
+ Object.assign(allDependencies, mod.dependencies);
338
+ }
339
+ }
340
+ console.log(JSON.stringify({ success: true, moduleName, modifiedFiles, dependencies: allDependencies }));
341
+ } catch (e) {
342
+ error(e.message);
343
+ }
344
+ }
345
+ async function computeFileHash(filePath) {
346
+ const content = await Bun.file(filePath).bytes();
347
+ const hasher = new Bun.CryptoHasher("sha256");
348
+ hasher.update(content);
349
+ return hasher.digest("hex");
350
+ }
351
+ async function getStatus(registry, options) {
352
+ const targetDir = cwd();
353
+ const root = getRoot(options);
354
+ const ravenDir = join(targetDir, root);
355
+ let currentVersion;
356
+ const modifiedFiles = [];
357
+ const fileHashes = {};
358
+ const knownModules = getModuleNames(registry).sort();
359
+ const moduleStatus = [];
360
+ if (await pathExists(ravenDir)) {
361
+ const yamlPath = join(ravenDir, "raven.yaml");
362
+ try {
363
+ const content = await Bun.file(yamlPath).text();
364
+ const config = parse(content);
365
+ if (config?.version) {
366
+ currentVersion = config.version;
367
+ }
368
+ } catch (_e) {
369
+ }
370
+ for (const name of knownModules) {
371
+ const modDir = join(ravenDir, name);
372
+ const installed = await pathExists(modDir) && !await isDirEmpty(modDir);
373
+ const mod = registry.modules[name];
374
+ moduleStatus.push({
375
+ name,
376
+ installed,
377
+ description: mod?.description
378
+ });
379
+ }
380
+ async function traverseDir(dir, baseDir) {
381
+ const dirEntries = await readdir(dir, { withFileTypes: true });
382
+ for (const e of dirEntries) {
383
+ const fullPath = join(dir, e.name);
384
+ const relPath = fullPath.slice(baseDir.length + 1);
385
+ if (e.isDirectory()) {
386
+ await traverseDir(fullPath, baseDir);
387
+ } else {
388
+ const hash = await computeFileHash(fullPath);
389
+ fileHashes[relPath] = hash;
390
+ }
391
+ }
392
+ }
393
+ await traverseDir(ravenDir, ravenDir);
394
+ }
395
+ let latestVersion;
396
+ try {
397
+ const response = await fetch(`https://api.github.com/repos/${GITHUB_REPO}/releases/latest`);
398
+ if (response.ok) {
399
+ const data = await response.json();
400
+ latestVersion = data.tag_name.replace(/^v/, "");
401
+ }
402
+ } catch (e) {
403
+ }
404
+ if (moduleStatus.length === 0) {
405
+ for (const name of knownModules) {
406
+ const mod = registry.modules[name];
407
+ moduleStatus.push({ name, installed: false, description: mod?.description });
408
+ }
409
+ }
410
+ return {
411
+ modules: moduleStatus,
412
+ version: currentVersion,
413
+ latestVersion,
414
+ modifiedFiles,
415
+ fileHashes
416
+ };
417
+ }
418
+ async function cmdStatus(options) {
419
+ const registry = await loadRegistry(options);
420
+ const status = await getStatus(registry, options);
421
+ console.log(JSON.stringify(status));
422
+ }
423
+ async function cmdGuide(moduleName, options) {
424
+ const { ravenDir } = await ensureRavenInstalled(options);
425
+ const availableModules = [];
426
+ try {
427
+ const entries = await readdir(ravenDir, { withFileTypes: true });
428
+ for (const entry of entries) {
429
+ if (entry.isDirectory() && entry.name !== ".") {
430
+ availableModules.push(entry.name);
431
+ }
432
+ }
433
+ } catch (e) {
434
+ error(`Failed to list modules: ${e}`);
435
+ }
436
+ const moduleDir = join(ravenDir, moduleName);
437
+ if (!await pathExists(moduleDir)) {
438
+ error(`Module '${moduleName}' not found.${availableModules.length > 0 ? ` Available: ${availableModules.join(", ")}` : ""}`);
439
+ }
440
+ const output = [];
441
+ const readmePath = join(moduleDir, "README.md");
442
+ if (await pathExists(readmePath)) {
443
+ const readmeContent = await Bun.file(readmePath).text();
444
+ output.push("<readme>");
445
+ output.push(readmeContent);
446
+ output.push("</readme>");
447
+ output.push("");
448
+ }
449
+ async function collectCodeFiles(dir, baseDir) {
450
+ const entries = await readdir(dir, { withFileTypes: true });
451
+ for (const entry of entries) {
452
+ const fullPath = join(dir, entry.name);
453
+ if (entry.isDirectory()) {
454
+ await collectCodeFiles(fullPath, baseDir);
455
+ } else if (entry.isFile()) {
456
+ const relPath = fullPath.slice(baseDir.length + 1);
457
+ const content = await Bun.file(fullPath).text();
458
+ output.push(`<code>`);
459
+ output.push(`File: ${relPath}`);
460
+ output.push(`\`\`\``);
461
+ output.push(content);
462
+ output.push("```");
463
+ output.push("</code>");
464
+ output.push("");
465
+ }
466
+ }
467
+ }
468
+ await collectCodeFiles(moduleDir, moduleDir);
469
+ console.log(output.join(`
470
+ `));
471
+ }
472
+ var cli = cac("raven");
473
+ cli.version(loadCliVersion()).help();
474
+ cli.option("--registry <path>", "Registry json path (default: same dir as CLI)").option("--root <dir>", "RavenJS root directory (default: raven)").option("--source <path>", "Local module source path (default: github)").option("--verbose, -v", "Verbose output");
475
+ cli.command("init", "Initialize RavenJS AI resources").action((options) => cmdInit(options));
476
+ cli.command("add <module>", "Add a module (e.g., jtd-validator)").action((module, options) => cmdAdd(module, options));
477
+ cli.command("status", "Show RavenJS installation status (core, modules)").action((options) => cmdStatus(options));
478
+ cli.command("guide <module>", "Get guide for a specific module (outputs README and source code)").action((moduleName, options) => cmdGuide(moduleName, options));
479
+ cli.parse();
480
+
481
+ //# debugId=7F5651AB289BE2E864756E2164756E21
482
+ //# sourceMappingURL=raven.map
package/dist/raven.map ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../index.ts"],
4
+ "sourcesContent": [
5
+ "#!/usr/bin/env bun\n\nimport { cac } from \"cac\";\nimport { mkdir, rm, readdir, stat } from \"fs/promises\";\nimport { join, dirname, resolve, isAbsolute } from \"path\";\nimport { cwd } from \"process\";\nimport pc from \"picocolors\";\nimport { spinner as makeSpinner, log } from \"@clack/prompts\";\nimport { parse, stringify } from \"yaml\";\n\nfunction loadCliVersion(): string {\n return process.env.RAVEN_CLI_VERSION ?? \"0.0.0\";\n}\n\nconst GITHUB_REPO = \"myWsq/RavenJS\";\nconst GITHUB_RAW_URL = `https://raw.githubusercontent.com/${GITHUB_REPO}`;\nconst DEFAULT_ROOT = \"raven\";\n\ninterface CLIOptions {\n verbose?: boolean;\n root?: string;\n source?: string;\n prerelease?: boolean;\n registry?: string;\n}\n\ninterface RegistryModule {\n files: string[];\n fileMapping?: Record<string, string>;\n dependencies?: Record<string, string>;\n dependsOn?: string[];\n description?: string;\n}\n\ninterface RegistryAi {\n claude: Record<string, string>;\n}\n\ninterface Registry {\n version: string;\n modules: Record<string, RegistryModule>;\n ai: RegistryAi;\n}\n\nasync function loadRegistry(options?: { registry?: string }): Promise<Registry> {\n const candidates: string[] = [];\n if (options?.registry) {\n candidates.push(isAbsolute(options.registry) ? options.registry : resolve(cwd(), options.registry));\n }\n if (process.env.RAVEN_DEFAULT_REGISTRY_PATH) {\n const p = process.env.RAVEN_DEFAULT_REGISTRY_PATH;\n candidates.push(isAbsolute(p) ? p : resolve(cwd(), p));\n }\n candidates.push(join(import.meta.dir, \"registry.json\"));\n\n for (const p of candidates) {\n const exists = await Bun.file(p).exists();\n if (exists) return (await Bun.file(p).json()) as Registry;\n }\n console.error(\n \"registry.json not found. Run 'bun run build' in packages/cli first, or use --registry <path>.\",\n );\n process.exit(1);\n}\n\nfunction getRoot(options: CLIOptions): string {\n return options.root || process.env.RAVEN_ROOT || DEFAULT_ROOT;\n}\n\nfunction getSource(options: CLIOptions): string | undefined {\n return options.source || process.env.RAVEN_SOURCE;\n}\n\nfunction resolveSourcePath(source?: string): string | undefined {\n if (!source || source === \"github\") return undefined;\n return isAbsolute(source) ? source : resolve(cwd(), source);\n}\n\nasync function verboseLog(message: string, options?: CLIOptions) {\n if (options?.verbose) {\n console.log(message);\n }\n}\n\nfunction error(message: string): never {\n // Use stderr for programmatic consumption (e.g. tests, piping). @clack/prompts\n // log.error writes to stdout which breaks stderr-based assertions.\n console.error(message);\n process.exit(1);\n}\n\nfunction success(message: string) {\n log.success(message);\n}\n\nfunction printSectionHeader(title: string) {\n log.step(title);\n}\n\nfunction printListItem(item: string) {\n log.message(item, { symbol: pc.dim(\"-\") });\n}\n\nasync function ensureDir(path: string) {\n try {\n await mkdir(path, { recursive: true });\n } catch (e: any) {\n if (e.code !== \"EEXIST\") throw e;\n }\n}\n\nasync function isDirEmpty(path: string): Promise<boolean> {\n try {\n const entries = await readdir(path);\n return entries.length === 0;\n } catch (e: any) {\n if (e.code === \"ENOENT\") return true;\n throw e;\n }\n}\n\nasync function pathExists(path: string): Promise<boolean> {\n try {\n await stat(path);\n return true;\n } catch (e: any) {\n if (e.code === \"ENOENT\") return false;\n throw e;\n }\n}\n\nasync function ensureRavenInstalled(options: CLIOptions): Promise<{ ravenDir: string; version: string }> {\n const targetDir = cwd();\n const root = getRoot(options);\n const ravenDir = join(targetDir, root);\n\n if (!(await pathExists(ravenDir))) {\n error(`RavenJS not installed at ${root}/. Run 'raven init' first.`);\n }\n\n const yamlPath = join(ravenDir, \"raven.yaml\");\n try {\n const content = await Bun.file(yamlPath).text();\n const config = parse(content) as RavenYamlConfig;\n if (!config?.version) {\n error(\"Invalid raven.yaml: version field is missing\");\n }\n return { ravenDir, version: config.version };\n } catch (e: any) {\n error(`Failed to load raven.yaml: ${e.message}`);\n }\n}\n\nfunction getModuleNames(registry: Registry): string[] {\n return Object.keys(registry.modules);\n}\n\nfunction getInstallOrder(\n moduleName: string,\n registry: Registry,\n installed: Set<string>,\n): string[] {\n const result: string[] = [];\n const visited = new Set<string>();\n const recStack = new Set<string>();\n const path: string[] = [];\n let cycle: string[] | null = null;\n\n function visit(name: string) {\n if (recStack.has(name)) {\n const idx = path.indexOf(name);\n cycle = path.slice(idx).concat(name);\n return;\n }\n if (visited.has(name)) return;\n visited.add(name);\n recStack.add(name);\n path.push(name);\n\n const mod = registry.modules[name];\n if (mod?.dependsOn) {\n for (const dep of mod.dependsOn) {\n if (registry.modules[dep]) visit(dep);\n }\n }\n if (!installed.has(name)) {\n result.push(name);\n }\n path.pop();\n recStack.delete(name);\n }\n\n visit(moduleName);\n if (cycle !== null) {\n error(`Circular dependency: ${(cycle as string[]).join(\" -> \")}`);\n }\n return result;\n}\n\nconst RAVENJS_PREFIX = \"@raven.js/\";\n\nfunction replaceRavenImports(\n content: string,\n fromModuleDir: string,\n registry: Registry,\n): string {\n const moduleNames = Object.keys(registry.modules);\n let out = content;\n const depth = fromModuleDir.split(\"/\").filter(Boolean).length;\n const prefix = depth > 0 ? \"../\".repeat(depth) : \"./\";\n for (const modName of moduleNames) {\n const pkg = `${RAVENJS_PREFIX}${modName}`;\n const rel = prefix + modName;\n\n const dq = new RegExp(`from\\\\s+\"${pkg.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}\"`, \"g\");\n const sq = new RegExp(`from\\\\s+'${pkg.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}'`, \"g\");\n out = out.replace(dq, `from \"${rel}\"`).replace(sq, `from '${rel}'`);\n }\n return out;\n}\n\nasync function downloadFile(url: string, destPath: string): Promise<void> {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`Failed to download ${url}: ${response.status}`);\n }\n const content = await response.text();\n await ensureDir(dirname(destPath));\n await Bun.write(destPath, content);\n}\n\nasync function copyLocalFile(srcPath: string, destPath: string): Promise<void> {\n const exists = await Bun.file(srcPath).exists();\n if (!exists) {\n throw new Error(`Missing local file: ${srcPath}`);\n }\n await ensureDir(dirname(destPath));\n await Bun.write(destPath, Bun.file(srcPath));\n}\n\nconst SOURCE_EXTENSIONS = [\".ts\", \".tsx\", \".js\", \".jsx\"];\n\nfunction isSourceFile(file: string): boolean {\n return SOURCE_EXTENSIONS.some((ext) => file.endsWith(ext));\n}\n\nasync function downloadModule(\n registry: Registry,\n moduleName: string,\n version: string,\n destDir: string,\n options?: CLIOptions,\n targetSubdir?: string,\n): Promise<string[]> {\n const module = registry.modules[moduleName];\n if (!module) {\n throw new Error(`Module ${moduleName} not found in registry`);\n }\n\n const sourcePath = resolveSourcePath(getSource(options || {}));\n if (sourcePath) {\n verboseLog(`Using local source: ${sourcePath}`, options);\n }\n verboseLog(`Downloading ${moduleName} files...`, options);\n\n const fromModuleDir = targetSubdir ?? moduleName;\n\n const modifiedFiles: string[] = [];\n const downloads = module.files.map(async (file: string) => {\n let destPath: string;\n\n if (module.fileMapping && module.fileMapping[file]) {\n destPath = join(destDir, module.fileMapping[file]);\n } else if (targetSubdir) {\n destPath = join(destDir, targetSubdir, file);\n } else {\n destPath = join(destDir, moduleName, file);\n }\n\n verboseLog(` Downloading ${file}...`, options);\n\n let content: string;\n if (sourcePath) {\n const primaryPath = join(sourcePath, \"modules\", moduleName, file);\n const fallbackPath = join(sourcePath, moduleName, file);\n const src = (await Bun.file(primaryPath).exists())\n ? primaryPath\n : (await Bun.file(fallbackPath).exists())\n ? fallbackPath\n : \"\";\n if (!src) throw new Error(`Missing local file: ${primaryPath}`);\n content = await Bun.file(src).text();\n } else {\n const url = `${GITHUB_RAW_URL}/v${version}/modules/${moduleName}/${file}`;\n const response = await fetch(url);\n if (!response.ok) throw new Error(`Failed to download ${url}: ${response.status}`);\n content = await response.text();\n }\n\n if (isSourceFile(file)) {\n content = replaceRavenImports(content, fromModuleDir, registry);\n }\n\n await ensureDir(dirname(destPath));\n await Bun.write(destPath, content);\n modifiedFiles.push(destPath);\n });\n\n await Promise.all(downloads);\n return modifiedFiles;\n}\n\nasync function downloadAiResources(\n registry: Registry,\n version: string,\n destDir: string,\n options?: CLIOptions,\n): Promise<string[]> {\n const ai = registry.ai;\n if (!ai?.claude) {\n throw new Error(\"AI resources not found in registry\");\n }\n\n const mapping = ai.claude;\n const entries = Object.entries(mapping);\n\n const sourcePath = resolveSourcePath(getSource(options || {}));\n if (sourcePath) {\n verboseLog(`Using local source: ${sourcePath}`, options);\n }\n verboseLog(\"Downloading AI resources...\", options);\n\n const modifiedFiles: string[] = [];\n const downloads = entries.map(async ([file, destRel]) => {\n const destPath = join(destDir, destRel);\n verboseLog(` Downloading ${file}...`, options);\n\n if (sourcePath) {\n const sourceFile = join(sourcePath, \"packages\", \"ai\", file);\n await copyLocalFile(sourceFile, destPath);\n } else {\n const url = `${GITHUB_RAW_URL}/v${version}/packages/ai/${file}`;\n await downloadFile(url, destPath);\n }\n modifiedFiles.push(destPath);\n });\n\n await Promise.all(downloads);\n return modifiedFiles;\n}\n\nasync function cmdInit(options: CLIOptions) {\n const registry = await loadRegistry(options);\n const targetDir = cwd();\n const root = getRoot(options);\n const ravenDir = join(targetDir, root);\n\n verboseLog(`Initializing RavenJS in ${targetDir}`, options);\n\n const version = registry.version;\n const modifiedFiles: string[] = [];\n\n const ravenRootExists = await pathExists(ravenDir);\n const ravenYamlPath = join(ravenDir, \"raven.yaml\");\n const ravenYamlExists = await pathExists(ravenYamlPath);\n\n const doInit = async () => {\n if (!ravenRootExists || !ravenYamlExists) {\n await ensureDir(ravenDir);\n await createRavenYaml(ravenDir, version);\n modifiedFiles.push(ravenYamlPath);\n }\n\n const dotClaudeDir = join(targetDir, \".claude\");\n await ensureDir(dotClaudeDir);\n const aiFiles = await downloadAiResources(registry, version, targetDir, options);\n modifiedFiles.push(...aiFiles);\n };\n\n if (options?.verbose) {\n await doInit();\n } else {\n const s = makeSpinner();\n s.start(\"Initializing RavenJS...\");\n try {\n await doInit();\n } catch (e: any) {\n s.stop(\"Initialization failed\");\n error(e.message);\n }\n s.stop(\"Initializing RavenJS...\");\n }\n\n success(\"RavenJS initialized successfully!\");\n\n printSectionHeader(\"Modified Files\");\n for (const file of modifiedFiles) {\n printListItem(file);\n }\n}\n\ninterface RavenYamlConfig {\n version: string;\n}\n\nasync function createRavenYaml(destDir: string, version: string) {\n const content = stringify({ version });\n await Bun.write(join(destDir, \"raven.yaml\"), content);\n}\n\nasync function getInstalledModules(ravenDir: string, registry: Registry): Promise<Set<string>> {\n const installed = new Set<string>();\n for (const name of getModuleNames(registry)) {\n const modDir = join(ravenDir, name);\n if ((await pathExists(modDir)) && !(await isDirEmpty(modDir))) {\n installed.add(name);\n }\n }\n return installed;\n}\n\nasync function cmdAdd(moduleName: string, options: CLIOptions) {\n const registry = await loadRegistry(options);\n if (!moduleName) {\n error(`Please specify a module to add. Available: ${getModuleNames(registry).join(\", \")}`);\n }\n\n const available = getModuleNames(registry);\n\n if (!available.includes(moduleName)) {\n error(`Unknown module: ${moduleName}`);\n }\n\n const { ravenDir, version } = await ensureRavenInstalled(options);\n\n const installed = await getInstalledModules(ravenDir, registry);\n const order = getInstallOrder(moduleName, registry, installed);\n\n try {\n const modifiedFiles: string[] = [];\n const allDependencies: Record<string, string> = {};\n for (const name of order) {\n const files = await downloadModule(registry, name, version, ravenDir, options);\n modifiedFiles.push(...files);\n const mod = registry.modules[name];\n if (mod?.dependencies) {\n Object.assign(allDependencies, mod.dependencies);\n }\n }\n\n console.log(JSON.stringify({ success: true, moduleName, modifiedFiles, dependencies: allDependencies }));\n } catch (e: any) {\n error(e.message);\n }\n}\n\n// === SECTION: Status ===\n\ninterface ModuleStatus {\n name: string;\n installed: boolean;\n description?: string;\n}\n\ninterface StatusResult {\n modules: ModuleStatus[];\n version?: string;\n latestVersion?: string;\n modifiedFiles?: string[];\n fileHashes?: Record<string, string>;\n}\n\nasync function computeFileHash(filePath: string): Promise<string> {\n const content = await Bun.file(filePath).bytes();\n const hasher = new Bun.CryptoHasher(\"sha256\");\n hasher.update(content);\n return hasher.digest(\"hex\");\n}\n\nasync function getStatus(registry: Registry, options: CLIOptions): Promise<StatusResult> {\n const targetDir = cwd();\n const root = getRoot(options);\n const ravenDir = join(targetDir, root);\n\n let currentVersion: string | undefined;\n const modifiedFiles: string[] = [];\n const fileHashes: Record<string, string> = {};\n\n const knownModules = getModuleNames(registry).sort();\n const moduleStatus: ModuleStatus[] = [];\n\n if (await pathExists(ravenDir)) {\n const yamlPath = join(ravenDir, \"raven.yaml\");\n try {\n const content = await Bun.file(yamlPath).text();\n const config = parse(content) as RavenYamlConfig;\n if (config?.version) {\n currentVersion = config.version;\n }\n } catch (_e) {\n // raven.yaml missing or invalid\n }\n\n for (const name of knownModules) {\n const modDir = join(ravenDir, name);\n const installed =\n (await pathExists(modDir)) && !(await isDirEmpty(modDir));\n const mod = registry.modules[name];\n moduleStatus.push({ \n name, \n installed,\n description: mod?.description,\n });\n }\n\n // Compute file hashes for all files in raven/\n async function traverseDir(dir: string, baseDir: string) {\n const dirEntries = await readdir(dir, { withFileTypes: true });\n for (const e of dirEntries) {\n const fullPath = join(dir, e.name);\n const relPath = fullPath.slice(baseDir.length + 1);\n if (e.isDirectory()) {\n await traverseDir(fullPath, baseDir);\n } else {\n const hash = await computeFileHash(fullPath);\n fileHashes[relPath] = hash;\n }\n }\n }\n await traverseDir(ravenDir, ravenDir);\n }\n\n // Try to get latest version from GitHub\n let latestVersion: string | undefined;\n try {\n const response = await fetch(\n `https://api.github.com/repos/${GITHUB_REPO}/releases/latest`,\n );\n if (response.ok) {\n const data = await response.json();\n latestVersion = data.tag_name.replace(/^v/, \"\");\n }\n } catch (e) {\n // ignore if can't fetch latest version\n }\n\n if (moduleStatus.length === 0) {\n for (const name of knownModules) {\n const mod = registry.modules[name];\n moduleStatus.push({ name, installed: false, description: mod?.description });\n }\n }\n\n return {\n modules: moduleStatus,\n version: currentVersion,\n latestVersion,\n modifiedFiles,\n fileHashes,\n };\n}\n\ninterface StatusCLIOptions extends CLIOptions {}\n\nasync function cmdStatus(options: StatusCLIOptions) {\n const registry = await loadRegistry(options);\n const status = await getStatus(registry, options);\n console.log(JSON.stringify(status));\n}\n\nasync function cmdGuide(moduleName: string, options: CLIOptions) {\n const { ravenDir } = await ensureRavenInstalled(options);\n\n const availableModules: string[] = [];\n try {\n const entries = await readdir(ravenDir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory() && entry.name !== \".\") {\n availableModules.push(entry.name);\n }\n }\n } catch (e) {\n error(`Failed to list modules: ${e}`);\n }\n\n const moduleDir = join(ravenDir, moduleName);\n if (!(await pathExists(moduleDir))) {\n error(\n `Module '${moduleName}' not found.${availableModules.length > 0 ? ` Available: ${availableModules.join(\", \")}` : \"\"}`,\n );\n }\n\n const output: string[] = [];\n\n const readmePath = join(moduleDir, \"README.md\");\n if (await pathExists(readmePath)) {\n const readmeContent = await Bun.file(readmePath).text();\n output.push(\"<readme>\");\n output.push(readmeContent);\n output.push(\"</readme>\");\n output.push(\"\");\n }\n\n async function collectCodeFiles(dir: string, baseDir: string) {\n const entries = await readdir(dir, { withFileTypes: true });\n for (const entry of entries) {\n const fullPath = join(dir, entry.name);\n if (entry.isDirectory()) {\n await collectCodeFiles(fullPath, baseDir);\n } else if (entry.isFile()) {\n const relPath = fullPath.slice(baseDir.length + 1);\n const content = await Bun.file(fullPath).text();\n output.push(`<code>`);\n output.push(`File: ${relPath}`);\n output.push(`\\`\\`\\``);\n output.push(content);\n output.push(\"```\");\n output.push(\"</code>\");\n output.push(\"\");\n }\n }\n }\n\n await collectCodeFiles(moduleDir, moduleDir);\n\n console.log(output.join(\"\\n\"));\n}\n\nconst cli = cac(\"raven\");\ncli.version(loadCliVersion()).help();\n\ncli\n .option(\n \"--registry <path>\",\n \"Registry json path (default: same dir as CLI)\",\n )\n .option(\"--root <dir>\", \"RavenJS root directory (default: raven)\")\n .option(\"--source <path>\", \"Local module source path (default: github)\")\n .option(\"--verbose, -v\", \"Verbose output\");\n\ncli\n .command(\"init\", \"Initialize RavenJS AI resources\")\n .action((options) => cmdInit(options as CLIOptions));\n\ncli\n .command(\"add <module>\", \"Add a module (e.g., jtd-validator)\")\n .action((module, options) => cmdAdd(module, options as CLIOptions));\n\n\ncli\n .command(\"status\", \"Show RavenJS installation status (core, modules)\")\n .action((options) => cmdStatus(options as StatusCLIOptions));\n\n\ncli\n .command(\"guide <module>\", \"Get guide for a specific module (outputs README and source code)\")\n .action((moduleName, options) => cmdGuide(moduleName, options as CLIOptions));\n\ncli.parse();\n"
6
+ ],
7
+ "mappings": ";;;;AAEA;AACA;AACA;AACA;AACA;AACA,oBAAS;AACT;AAEA,SAAS,cAAc,GAAW;AAChC,SAAO,QAAQ,IAAI,qBAAqB;AAAA;AAG1C,IAAM,cAAc;AACpB,IAAM,iBAAiB,qCAAqC;AAC5D,IAAM,eAAe;AA4BrB,eAAe,YAAY,CAAC,SAAoD;AAC9E,QAAM,aAAuB,CAAC;AAC9B,MAAI,SAAS,UAAU;AACrB,eAAW,KAAK,WAAW,QAAQ,QAAQ,IAAI,QAAQ,WAAW,QAAQ,IAAI,GAAG,QAAQ,QAAQ,CAAC;AAAA,EACpG;AACA,MAAI,QAAQ,IAAI,6BAA6B;AAC3C,UAAM,IAAI,QAAQ,IAAI;AACtB,eAAW,KAAK,WAAW,CAAC,IAAI,IAAI,QAAQ,IAAI,GAAG,CAAC,CAAC;AAAA,EACvD;AACA,aAAW,KAAK,KAAK,YAAY,KAAK,eAAe,CAAC;AAEtD,aAAW,KAAK,YAAY;AAC1B,UAAM,SAAS,MAAM,IAAI,KAAK,CAAC,EAAE,OAAO;AACxC,QAAI;AAAQ,aAAQ,MAAM,IAAI,KAAK,CAAC,EAAE,KAAK;AAAA,EAC7C;AACA,UAAQ,MACN,+FACF;AACA,UAAQ,KAAK,CAAC;AAAA;AAGhB,SAAS,OAAO,CAAC,SAA6B;AAC5C,SAAO,QA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CAAC;AAG7D,IACG,QAAQ,kBAAkB,kEAAkE,EAC5F,OAAO,CAAC,YAAY,YAAY,SAAS,YAAY,OAAqB,CAAC;AAE9E,IAAI,MAAM;",
8
+ "debugId": "7F5651AB289BE2E864756E2164756E21",
9
+ "names": []
10
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0-alpha.23",
2
+ "version": "1.0.0",
3
3
  "modules": {
4
4
  "core": {
5
5
  "files": [
package/package.json CHANGED
@@ -1,16 +1,27 @@
1
1
  {
2
2
  "name": "@raven.js/cli",
3
- "version": "1.0.0-alpha.23",
3
+ "version": "1.0.0",
4
4
  "description": "CLI tool for RavenJS framework",
5
+ "type": "module",
6
+ "scripts": {
7
+ "build": "bun run scripts/build.ts"
8
+ },
5
9
  "bin": {
6
- "raven": "./raven"
10
+ "raven": "./dist/raven"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "README.md"
15
+ ],
16
+ "engines": {
17
+ "bun": ">=1.0"
7
18
  },
8
- "optionalDependencies": {
9
- "@raven.js/cli-linux-x64": "1.0.0-alpha.23",
10
- "@raven.js/cli-linux-arm64": "1.0.0-alpha.23",
11
- "@raven.js/cli-darwin-x64": "1.0.0-alpha.23",
12
- "@raven.js/cli-darwin-arm64": "1.0.0-alpha.23",
13
- "@raven.js/cli-windows-x64": "1.0.0-alpha.23"
19
+ "dependencies": {
20
+ "@clack/prompts": "^1.0.1",
21
+ "cac": "^6.7.14",
22
+ "picocolors": "^1.1.1",
23
+ "semver": "^7.7.4",
24
+ "yaml": "^2.6.0"
14
25
  },
15
26
  "keywords": [
16
27
  "ravenjs",
@@ -21,10 +32,5 @@
21
32
  "repository": {
22
33
  "type": "git",
23
34
  "url": "https://github.com/myWsq/RavenJS.git"
24
- },
25
- "files": [
26
- "raven",
27
- "README.md",
28
- "registry.json"
29
- ]
30
- }
35
+ }
36
+ }
package/raven DELETED
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env node
2
- const { spawn } = require('child_process');
3
- const path = require('path');
4
- const os = require('os');
5
- const fs = require('fs');
6
-
7
- const registryPath = path.resolve(__dirname, 'registry.json');
8
- if (!fs.existsSync(registryPath)) {
9
- console.error('registry.json not found at ' + registryPath);
10
- process.exit(1);
11
- }
12
-
13
- const knownWindowsPackages = {
14
- 'win32 x64': '@raven.js/cli-windows-x64'
15
- };
16
-
17
- const knownUnixlikePackages = {
18
- 'linux x64': '@raven.js/cli-linux-x64',
19
- 'linux arm64': '@raven.js/cli-linux-arm64',
20
- 'darwin x64': '@raven.js/cli-darwin-x64',
21
- 'darwin arm64': '@raven.js/cli-darwin-arm64'
22
- };
23
-
24
- function pkgAndSubpathForCurrentPlatform() {
25
- let pkg;
26
- let subpath;
27
- const platformKey = `${process.platform} ${os.arch()}`;
28
-
29
- if (platformKey in knownWindowsPackages) {
30
- pkg = knownWindowsPackages[platformKey];
31
- subpath = 'raven.exe';
32
- } else if (platformKey in knownUnixlikePackages) {
33
- pkg = knownUnixlikePackages[platformKey];
34
- subpath = 'raven';
35
- } else {
36
- throw new Error(`Unsupported platform: ${platformKey}`);
37
- }
38
-
39
- return { pkg, subpath };
40
- }
41
-
42
- function generateBinPath() {
43
- const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
44
- return require.resolve(`${pkg}/${subpath}`);
45
- }
46
-
47
- const binaryPath = generateBinPath();
48
-
49
- const child = spawn(binaryPath, process.argv.slice(2), {
50
- stdio: 'inherit',
51
- env: { ...process.env, RAVEN_DEFAULT_REGISTRY_PATH: registryPath, RAVEN_CLI_VERSION: "1.0.0-alpha.23" }
52
- });
53
- child.on('exit', (code) => process.exit(code || 0));