@lunora/cli 1.0.0-alpha.90 → 1.0.0-alpha.92

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/dist/bin.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { runCli } from './packem_shared/COMMANDS-DZ0NnuqI.mjs';
2
+ import { runCli } from './packem_shared/COMMANDS-CstRNuDU.mjs';
3
3
 
4
4
  try {
5
5
  const code = await runCli();
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { COMMANDS, VERSION, runCli } from './packem_shared/COMMANDS-DZ0NnuqI.mjs';
1
+ export { COMMANDS, VERSION, runCli } from './packem_shared/COMMANDS-CstRNuDU.mjs';
2
2
  export { runCodegenCommand } from './packem_chunks/runCodegenCommand.mjs';
3
3
  export { DEFAULT_IMPORT_BATCH_SIZE, runExportCommand, runImportCommand } from './packem_shared/DEFAULT_IMPORT_BATCH_SIZE-D0VOTerB.mjs';
4
4
  export { runDeployCommand } from './packem_chunks/runDeployCommand.mjs';
@@ -1,60 +1,100 @@
1
- import { readLinkedProject } from '@lunora/config';
1
+ import { runCodegen } from '@lunora/codegen';
2
+ import { validateWranglerProject, inferLunoraBindings, reconcileWranglerBindings, reconcileWranglerCompatibilityDate, reconcileWranglerCrons } from '@lunora/config';
3
+ import { p as parseApiSpec } from '../packem_shared/api-spec-Bx0iKbxA.mjs';
4
+ import { r as renderCodegenFailure } from '../packem_shared/codegen-error-DJG-ghs_.mjs';
2
5
  import { d as defineHandler } from '../packem_shared/command-lYnl4QyF.mjs';
3
- import { e as execArgsFor, d as detectPackageManager } from '../packem_shared/detect-package-manager-v4hHpQd0.mjs';
4
- import { defaultSpawner } from '../packem_shared/createRecordingSpawner-WuSn20kb.mjs';
6
+ import { r as runSchemaDriftGate } from '../packem_shared/schema-drift-gate-BtBt0as0.mjs';
5
7
 
6
- const LOG_FORMATS = /* @__PURE__ */ new Set(["json", "pretty"]);
7
- const runLogsCommand = async (options) => {
8
- const cwd = options.cwd ?? process.cwd();
9
- if (options.format !== void 0 && !LOG_FORMATS.has(options.format)) {
10
- options.logger.error(`logs: unknown --format "${options.format}" — expected pretty | json`);
11
- return { code: 1, descriptor: void 0, error: "invalid format" };
12
- }
13
- const args = ["tail"];
14
- if (options.worker !== void 0) {
15
- args.push(options.worker);
8
+ const provisionBindings = async (cwd, logger, cronTriggers = []) => {
9
+ try {
10
+ const inferred = await inferLunoraBindings({ projectRoot: cwd });
11
+ const reconciled = reconcileWranglerBindings(cwd, inferred);
12
+ if (reconciled.changed) {
13
+ logger.success(`provisioned bindings: ${reconciled.added.join(", ")} ${reconciled.wranglerPath ?? "wrangler.jsonc"}`);
14
+ }
15
+ for (const warning of reconciled.warnings) {
16
+ logger.warn(warning);
17
+ }
18
+ } catch (error) {
19
+ const message = error instanceof Error ? error.message : String(error);
20
+ logger.warn(`binding inference skipped: ${message}`);
16
21
  }
17
- const env = options.env ?? readLinkedProject(cwd)?.env;
18
- if (env !== void 0) {
19
- args.push("--env", env);
22
+ try {
23
+ const reconciled = reconcileWranglerCompatibilityDate(cwd);
24
+ if (reconciled.changed) {
25
+ logger.success(
26
+ `bumped compatibility_date to ${reconciled.date ?? "unknown"} (Workers Cache enabled) → ${reconciled.wranglerPath ?? "wrangler.jsonc"}`
27
+ );
28
+ }
29
+ } catch (error) {
30
+ const message = error instanceof Error ? error.message : String(error);
31
+ logger.warn(`compatibility date sync skipped: ${message}`);
20
32
  }
21
- if (options.format !== void 0) {
22
- args.push("--format", options.format);
33
+ try {
34
+ const reconciled = reconcileWranglerCrons(cwd, cronTriggers);
35
+ if (reconciled.changed) {
36
+ logger.success(`synced ${String(cronTriggers.length)} cron trigger(s) → ${reconciled.wranglerPath ?? "wrangler.jsonc"}`);
37
+ }
38
+ } catch (error) {
39
+ const message = error instanceof Error ? error.message : String(error);
40
+ logger.warn(`cron trigger sync skipped: ${message}`);
23
41
  }
24
- if (options.status !== void 0) {
25
- args.push("--status", options.status);
42
+ };
43
+ const runPrepareCommand = async (options) => {
44
+ const cwd = options.cwd ?? process.cwd();
45
+ options.logger.info("running codegen");
46
+ let codegen;
47
+ try {
48
+ codegen = runCodegen({ apiSpec: options.apiSpec, projectRoot: cwd });
49
+ options.logger.success("codegen complete");
50
+ } catch (error) {
51
+ const message = error instanceof Error ? error.message : String(error);
52
+ options.logger.error(renderCodegenFailure(error));
53
+ return {
54
+ code: 1,
55
+ error: `codegen failed: ${message}`,
56
+ validation: { problems: [], wranglerPath: void 0 }
57
+ };
26
58
  }
27
- if (options.search !== void 0) {
28
- args.push("--search", options.search);
59
+ const gate = runSchemaDriftGate({
60
+ allowDrift: options.allowSchemaDrift === true,
61
+ codegen,
62
+ logger: options.logger,
63
+ updateBaseline: options.updateSchemaBaseline === true
64
+ });
65
+ if (gate.blocked) {
66
+ return {
67
+ code: 1,
68
+ error: "schema drift gate blocked prepare",
69
+ schemaDrift: { blocked: true, reason: gate.reason },
70
+ validation: { problems: [], wranglerPath: void 0 }
71
+ };
29
72
  }
30
- if (options.temporary) {
31
- args.push("--temporary");
73
+ await provisionBindings(cwd, options.logger, codegen.cronTriggers);
74
+ const validation = validateWranglerProject({ projectRoot: cwd });
75
+ if (validation.problems.length > 0) {
76
+ options.logger.error("wrangler.jsonc validation failed:");
77
+ for (const problem of validation.problems) {
78
+ options.logger.error(` - ${problem}`);
79
+ }
80
+ return {
81
+ code: 1,
82
+ error: "wrangler validation failed",
83
+ validation
84
+ };
32
85
  }
33
- const exec = execArgsFor(detectPackageManager(cwd), "wrangler", args);
34
- const descriptor = {
35
- args: exec.args,
36
- command: exec.command,
37
- cwd
38
- };
39
- options.logger.info(`tailing logs via ${descriptor.command} ${descriptor.args.join(" ")}`);
40
- const spawner = options.spawner ?? defaultSpawner;
41
- const result = await spawner(descriptor);
42
- return {
43
- code: result.code,
44
- descriptor
45
- };
86
+ gate.rebless?.();
87
+ options.logger.success("project is ready to deploy");
88
+ return { code: 0, validation };
46
89
  };
47
90
  const execute = defineHandler(
48
- ({ argument, cwd, logger, options }) => runLogsCommand({
91
+ ({ cwd, logger, options }) => runPrepareCommand({
92
+ allowSchemaDrift: options.allowSchemaDrift === true,
93
+ apiSpec: parseApiSpec(options.apiSpec),
49
94
  cwd,
50
- env: options.env,
51
- format: options.format,
52
95
  logger,
53
- search: options.search,
54
- status: options.status,
55
- temporary: options.temporary === true,
56
- worker: argument[0]
96
+ updateSchemaBaseline: options.updateSchemaBaseline === true
57
97
  })
58
98
  );
59
99
 
60
- export { execute, runLogsCommand };
100
+ export { execute, runPrepareCommand };
@@ -1,100 +1,44 @@
1
- import { runCodegen } from '@lunora/codegen';
2
- import { validateWranglerProject, inferLunoraBindings, reconcileWranglerBindings, reconcileWranglerCompatibilityDate, reconcileWranglerCrons } from '@lunora/config';
3
- import { p as parseApiSpec } from '../packem_shared/api-spec-Bx0iKbxA.mjs';
4
- import { r as renderCodegenFailure } from '../packem_shared/codegen-error-DJG-ghs_.mjs';
5
1
  import { d as defineHandler } from '../packem_shared/command-lYnl4QyF.mjs';
6
- import { r as runSchemaDriftGate } from '../packem_shared/schema-drift-gate-BtBt0as0.mjs';
2
+ import { r as runAddCommand, b as runRegistryViewCommand, a as runBuildIndexCommand } from '../packem_shared/commands-D5Yxt9VY.mjs';
7
3
 
8
- const provisionBindings = async (cwd, logger, cronTriggers = []) => {
9
- try {
10
- const inferred = await inferLunoraBindings({ projectRoot: cwd });
11
- const reconciled = reconcileWranglerBindings(cwd, inferred);
12
- if (reconciled.changed) {
13
- logger.success(`provisioned bindings: ${reconciled.added.join(", ")} → ${reconciled.wranglerPath ?? "wrangler.jsonc"}`);
14
- }
15
- for (const warning of reconciled.warnings) {
16
- logger.warn(warning);
17
- }
18
- } catch (error) {
19
- const message = error instanceof Error ? error.message : String(error);
20
- logger.warn(`binding inference skipped: ${message}`);
4
+ const execute = defineHandler(({ argument, cwd, logger, options }) => {
5
+ const subcommand = argument[0];
6
+ const names = argument.slice(1);
7
+ if (subcommand === "add") {
8
+ return runAddCommand({
9
+ allowUnsafeSource: options.allowUnsafeSource === true,
10
+ cwd,
11
+ diff: options.diff === true,
12
+ dryRun: options.dryRun === true,
13
+ from: options.from,
14
+ json: options.json === true,
15
+ logger,
16
+ names,
17
+ overwrite: options.overwrite === true,
18
+ ref: options.ref,
19
+ source: options.source,
20
+ yes: options.yes === true
21
+ });
21
22
  }
22
- try {
23
- const reconciled = reconcileWranglerCompatibilityDate(cwd);
24
- if (reconciled.changed) {
25
- logger.success(
26
- `bumped compatibility_date to ${reconciled.date ?? "unknown"} (Workers Cache enabled) → ${reconciled.wranglerPath ?? "wrangler.jsonc"}`
27
- );
28
- }
29
- } catch (error) {
30
- const message = error instanceof Error ? error.message : String(error);
31
- logger.warn(`compatibility date sync skipped: ${message}`);
23
+ if (subcommand === "list") {
24
+ return runAddCommand({ cwd, from: options.from, json: options.json === true, list: true, logger, names: [], ref: options.ref, source: options.source });
32
25
  }
33
- try {
34
- const reconciled = reconcileWranglerCrons(cwd, cronTriggers);
35
- if (reconciled.changed) {
36
- logger.success(`synced ${String(cronTriggers.length)} cron trigger(s) → ${reconciled.wranglerPath ?? "wrangler.jsonc"}`);
37
- }
38
- } catch (error) {
39
- const message = error instanceof Error ? error.message : String(error);
40
- logger.warn(`cron trigger sync skipped: ${message}`);
26
+ if (subcommand === "view") {
27
+ return runRegistryViewCommand({
28
+ allowUnsafeSource: options.allowUnsafeSource === true,
29
+ cwd,
30
+ from: options.from,
31
+ logger,
32
+ names,
33
+ ref: options.ref,
34
+ source: options.source
35
+ });
41
36
  }
42
- };
43
- const runPrepareCommand = async (options) => {
44
- const cwd = options.cwd ?? process.cwd();
45
- options.logger.info("running codegen");
46
- let codegen;
47
- try {
48
- codegen = runCodegen({ apiSpec: options.apiSpec, projectRoot: cwd });
49
- options.logger.success("codegen complete");
50
- } catch (error) {
51
- const message = error instanceof Error ? error.message : String(error);
52
- options.logger.error(renderCodegenFailure(error));
53
- return {
54
- code: 1,
55
- error: `codegen failed: ${message}`,
56
- validation: { problems: [], wranglerPath: void 0 }
57
- };
37
+ if (subcommand === "build") {
38
+ return runBuildIndexCommand({ check: options.check === true, from: options.from, logger, out: options.out });
58
39
  }
59
- const gate = runSchemaDriftGate({
60
- allowDrift: options.allowSchemaDrift === true,
61
- codegen,
62
- logger: options.logger,
63
- updateBaseline: options.updateSchemaBaseline === true
64
- });
65
- if (gate.blocked) {
66
- return {
67
- code: 1,
68
- error: "schema drift gate blocked prepare",
69
- schemaDrift: { blocked: true, reason: gate.reason },
70
- validation: { problems: [], wranglerPath: void 0 }
71
- };
72
- }
73
- await provisionBindings(cwd, options.logger, codegen.cronTriggers);
74
- const validation = validateWranglerProject({ projectRoot: cwd });
75
- if (validation.problems.length > 0) {
76
- options.logger.error("wrangler.jsonc validation failed:");
77
- for (const problem of validation.problems) {
78
- options.logger.error(` - ${problem}`);
79
- }
80
- return {
81
- code: 1,
82
- error: "wrangler validation failed",
83
- validation
84
- };
85
- }
86
- gate.rebless?.();
87
- options.logger.success("project is ready to deploy");
88
- return { code: 0, validation };
89
- };
90
- const execute = defineHandler(
91
- ({ cwd, logger, options }) => runPrepareCommand({
92
- allowSchemaDrift: options.allowSchemaDrift === true,
93
- apiSpec: parseApiSpec(options.apiSpec),
94
- cwd,
95
- logger,
96
- updateSchemaBaseline: options.updateSchemaBaseline === true
97
- })
98
- );
40
+ logger.error("registry: unknown subcommand. Usage: lunora registry <add|list|view|build> [names…]");
41
+ return { code: 1 };
42
+ });
99
43
 
100
- export { execute, runPrepareCommand };
44
+ export { execute };
@@ -1,44 +1,105 @@
1
+ import { existsSync, readFileSync, readdirSync, statSync, mkdirSync, writeFileSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { AGENT_RULES_DIR, detectAgentRules, LUNORA_SKILL_NAMES } from '@lunora/config';
4
+ import { join, relative, dirname } from '@visulima/path';
1
5
  import { d as defineHandler } from '../packem_shared/command-lYnl4QyF.mjs';
2
- import { r as runAddCommand, b as runRegistryViewCommand, a as runBuildIndexCommand } from '../packem_shared/commands-D5Yxt9VY.mjs';
3
6
 
7
+ const resolveBundledSkillsDirectory = (startDirectory = dirname(fileURLToPath(import.meta.url))) => {
8
+ let directory = startDirectory;
9
+ for (let index = 0; index < 6; index += 1) {
10
+ const packageJson = join(directory, "package.json");
11
+ if (existsSync(packageJson)) {
12
+ try {
13
+ const parsed = JSON.parse(readFileSync(packageJson, "utf8"));
14
+ if (parsed.name === "@lunora/cli") {
15
+ const skills = join(directory, "skills");
16
+ return existsSync(skills) ? skills : void 0;
17
+ }
18
+ } catch {
19
+ }
20
+ }
21
+ const parent = dirname(directory);
22
+ if (parent === directory) {
23
+ break;
24
+ }
25
+ directory = parent;
26
+ }
27
+ return void 0;
28
+ };
29
+ const listBundledSkills = (skillsDirectory) => readdirSync(skillsDirectory).filter((name) => {
30
+ const directory = join(skillsDirectory, name);
31
+ return statSync(directory).isDirectory() && existsSync(join(directory, "SKILL.md"));
32
+ });
33
+ const copySkill = (source, destination, overwrite) => {
34
+ mkdirSync(destination, { recursive: true });
35
+ let wrote = false;
36
+ for (const entry of readdirSync(source)) {
37
+ const from = join(source, entry);
38
+ const to = join(destination, entry);
39
+ if (statSync(from).isDirectory()) {
40
+ wrote = copySkill(from, to, overwrite) || wrote;
41
+ continue;
42
+ }
43
+ if (existsSync(to) && !overwrite) {
44
+ continue;
45
+ }
46
+ writeFileSync(to, readFileSync(from));
47
+ wrote = true;
48
+ }
49
+ return wrote;
50
+ };
51
+ const runRulesInstall = (options) => {
52
+ const cwd = options.cwd ?? process.cwd();
53
+ const overwrite = options.overwrite === true;
54
+ const skillsDirectory = resolveBundledSkillsDirectory();
55
+ if (skillsDirectory === void 0) {
56
+ options.logger.error("rules: could not locate the bundled skills (is @lunora/cli installed correctly?).");
57
+ return { code: 1, installed: [], skipped: [] };
58
+ }
59
+ const installed = [];
60
+ const skipped = [];
61
+ for (const name of listBundledSkills(skillsDirectory)) {
62
+ const destination = join(cwd, AGENT_RULES_DIR, name);
63
+ const wrote = copySkill(join(skillsDirectory, name), destination, overwrite);
64
+ if (wrote) {
65
+ installed.push(name);
66
+ } else {
67
+ skipped.push(name);
68
+ }
69
+ }
70
+ const target = relative(cwd, join(cwd, AGENT_RULES_DIR)) || AGENT_RULES_DIR;
71
+ if (installed.length > 0) {
72
+ options.logger.success(`Installed ${String(installed.length)} Lunora skill(s) into ${target}/: ${installed.join(", ")}.`);
73
+ }
74
+ if (skipped.length > 0) {
75
+ options.logger.info(`Skipped ${String(skipped.length)} existing skill(s) (re-run with --overwrite to replace): ${skipped.join(", ")}.`);
76
+ }
77
+ options.logger.info("Your AI coding agent will pick these up automatically. Start with the `lunora` skill.");
78
+ return { code: 0, installed, skipped };
79
+ };
80
+ const runRulesCheck = (options) => {
81
+ const cwd = options.cwd ?? process.cwd();
82
+ const status = detectAgentRules(cwd);
83
+ if (status.installed) {
84
+ options.logger.success(`Lunora agent rules are installed (${String(status.present.length)}/${String(LUNORA_SKILL_NAMES.length)} skills).`);
85
+ if (status.missing.length > 0) {
86
+ options.logger.info(`Missing: ${status.missing.join(", ")}. Run \`lunora rules install\` to add them.`);
87
+ }
88
+ return { code: 0, installed: status.present, skipped: [] };
89
+ }
90
+ options.logger.warn("Lunora agent rules are not installed. Run `lunora rules install` so your AI agent knows how to use Lunora.");
91
+ return { code: options.strict === true ? 1 : 0, installed: status.present, skipped: [] };
92
+ };
4
93
  const execute = defineHandler(({ argument, cwd, logger, options }) => {
5
- const subcommand = argument[0];
6
- const names = argument.slice(1);
7
- if (subcommand === "add") {
8
- return runAddCommand({
9
- allowUnsafeSource: options.allowUnsafeSource === true,
10
- cwd,
11
- diff: options.diff === true,
12
- dryRun: options.dryRun === true,
13
- from: options.from,
14
- json: options.json === true,
15
- logger,
16
- names,
17
- overwrite: options.overwrite === true,
18
- ref: options.ref,
19
- source: options.source,
20
- yes: options.yes === true
21
- });
22
- }
23
- if (subcommand === "list") {
24
- return runAddCommand({ cwd, from: options.from, json: options.json === true, list: true, logger, names: [], ref: options.ref, source: options.source });
25
- }
26
- if (subcommand === "view") {
27
- return runRegistryViewCommand({
28
- allowUnsafeSource: options.allowUnsafeSource === true,
29
- cwd,
30
- from: options.from,
31
- logger,
32
- names,
33
- ref: options.ref,
34
- source: options.source
35
- });
36
- }
37
- if (subcommand === "build") {
38
- return runBuildIndexCommand({ check: options.check === true, from: options.from, logger, out: options.out });
39
- }
40
- logger.error("registry: unknown subcommand. Usage: lunora registry <add|list|view|build> [names…]");
94
+ const subcommand = argument[0] ?? "check";
95
+ if (subcommand === "install") {
96
+ return runRulesInstall({ cwd, logger, overwrite: options.overwrite === true });
97
+ }
98
+ if (subcommand === "check") {
99
+ return runRulesCheck({ cwd, logger, strict: options.strict === true });
100
+ }
101
+ logger.error("rules: unknown subcommand. Usage: lunora rules <install|check>");
41
102
  return { code: 1 };
42
103
  });
43
104
 
44
- export { execute };
105
+ export { execute, resolveBundledSkillsDirectory, runRulesCheck, runRulesInstall };