@lunora/cli 1.0.0-alpha.8 → 1.0.0-alpha.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE.md +6 -0
  2. package/__assets__/package-og.svg +1 -1
  3. package/dist/bin.mjs +1 -1
  4. package/dist/index.d.mts +293 -134
  5. package/dist/index.d.ts +293 -134
  6. package/dist/index.mjs +8 -9
  7. package/dist/packem_chunks/handler.mjs +87 -6
  8. package/dist/packem_chunks/handler10.mjs +8 -14
  9. package/dist/packem_chunks/handler11.mjs +20 -189
  10. package/dist/packem_chunks/handler12.mjs +176 -115
  11. package/dist/packem_chunks/handler13.mjs +118 -52
  12. package/dist/packem_chunks/handler14.mjs +50 -43
  13. package/dist/packem_chunks/handler15.mjs +48 -67
  14. package/dist/packem_chunks/handler16.mjs +85 -37
  15. package/dist/packem_chunks/handler17.mjs +39 -100
  16. package/dist/packem_chunks/handler18.mjs +87 -152
  17. package/dist/packem_chunks/handler19.mjs +148 -67
  18. package/dist/packem_chunks/handler2.mjs +6 -4
  19. package/dist/packem_chunks/handler20.mjs +77 -75
  20. package/dist/packem_chunks/handler21.mjs +71 -288
  21. package/dist/packem_chunks/handler3.mjs +8 -4
  22. package/dist/packem_chunks/handler4.mjs +2 -2
  23. package/dist/packem_chunks/handler5.mjs +7 -4
  24. package/dist/packem_chunks/handler6.mjs +10 -7
  25. package/dist/packem_chunks/handler7.mjs +2 -2
  26. package/dist/packem_chunks/handler8.mjs +1 -1
  27. package/dist/packem_chunks/handler9.mjs +323 -12
  28. package/dist/packem_chunks/planDevCommand.mjs +758 -81
  29. package/dist/packem_chunks/runCodegenCommand.mjs +5 -4
  30. package/dist/packem_chunks/runDeployCommand.mjs +126 -20
  31. package/dist/packem_chunks/runInitCommand.mjs +1661 -179
  32. package/dist/packem_chunks/runMigrateGenerateCommand.mjs +47 -41
  33. package/dist/packem_chunks/runResetCommand.mjs +2 -2
  34. package/dist/packem_chunks/runRpcCommand.mjs +3 -2
  35. package/dist/packem_shared/{COMMANDS-Bn8luojF.mjs → COMMANDS-D0tmnAwr.mjs} +106 -27
  36. package/dist/packem_shared/{DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs → DEFAULT_IMPORT_BATCH_SIZE-D0VOTerB.mjs} +7 -2
  37. package/dist/packem_shared/{api-spec-CtA6ilu4.mjs → api-spec-Bx0iKbxA.mjs} +3 -1
  38. package/dist/packem_shared/{buildRegistryIndex-BcYe607_.mjs → buildRegistryIndex-BS5ig822.mjs} +1 -1
  39. package/dist/packem_shared/codegen-error-DJG-ghs_.mjs +31 -0
  40. package/dist/packem_shared/{command-BDXcJCCJ.mjs → command-lYnl4QyF.mjs} +6 -1
  41. package/dist/packem_shared/{commands-DqsEzojt.mjs → commands-ClEvcz3V.mjs} +224 -18
  42. package/dist/packem_shared/{createLogger-CHPNjFw2.mjs → createLogger-CIWSHrTL.mjs} +40 -8
  43. package/dist/packem_shared/{createRecordingSpawner-DxI3mebw.mjs → createRecordingSpawner-WuSn20kb.mjs} +23 -2
  44. package/dist/packem_shared/{detect-package-manager-DYp7n3mJ.mjs → detect-package-manager-DvEthdCw.mjs} +26 -30
  45. package/dist/packem_shared/{insertSchemaExtension-BuzF6-t2.mjs → insertSchemaExtension-DAqbfr9Z.mjs} +15 -10
  46. package/dist/packem_shared/{open-url-Dfq6fAyT.mjs → open-url-4PBLY9X0.mjs} +3 -2
  47. package/dist/packem_shared/{output-format-7gyGR3h8.mjs → output-format-B4642rjE.mjs} +1 -1
  48. package/dist/packem_shared/{parseManifest--vZf2FY1.mjs → parseManifest-Dbp-Q2q3.mjs} +36 -9
  49. package/dist/packem_shared/prompt-cancelled-APzX1Im-.mjs +9 -0
  50. package/dist/packem_shared/runAddCommand-DGjFXGqa.mjs +4 -0
  51. package/dist/packem_shared/storage-DEXpJkXh.mjs +84 -0
  52. package/dist/packem_shared/tui-prompts-BjEN8XgP.mjs +658 -0
  53. package/dist/packem_shared/wrangler-secrets-Dq_Fkbm-.mjs +49 -0
  54. package/package.json +16 -13
  55. package/skills/lunora-quickstart/SKILL.md +25 -5
  56. package/skills/lunora-setup-storage/SKILL.md +7 -3
  57. package/dist/packem_shared/features-ocSSpZtS.mjs +0 -24
  58. package/dist/packem_shared/parseArgs-YXFuKdEk.mjs +0 -56
  59. package/dist/packem_shared/runAddCommand-G544_v6e.mjs +0 -4
  60. package/dist/packem_shared/tui-prompts-XHFxlOg5.mjs +0 -269
@@ -1,79 +1,60 @@
1
- import { runCodegen } from '@lunora/codegen';
2
- import { validateWranglerProject, inferLunoraBindings, reconcileWranglerBindings } from '@lunora/config';
3
- import { p as parseApiSpec } from '../packem_shared/api-spec-CtA6ilu4.mjs';
4
- import { d as defineHandler } from '../packem_shared/command-BDXcJCCJ.mjs';
5
- import { r as runSchemaDriftGate } from '../packem_shared/schema-drift-gate-BtBt0as0.mjs';
1
+ import { readLinkedProject } from '@lunora/config';
2
+ import { d as defineHandler } from '../packem_shared/command-lYnl4QyF.mjs';
3
+ import { e as execArgsFor, d as detectPackageManager } from '../packem_shared/detect-package-manager-DvEthdCw.mjs';
4
+ import { defaultSpawner } from '../packem_shared/createRecordingSpawner-WuSn20kb.mjs';
6
5
 
7
- const provisionBindings = async (cwd, logger) => {
8
- try {
9
- const inferred = await inferLunoraBindings({ projectRoot: cwd });
10
- const reconciled = reconcileWranglerBindings(cwd, inferred);
11
- if (reconciled.changed) {
12
- logger.success(`provisioned bindings: ${reconciled.added.join(", ")} → ${reconciled.wranglerPath ?? "wrangler.jsonc"}`);
13
- }
14
- for (const warning of reconciled.warnings) {
15
- logger.warn(warning);
16
- }
17
- } catch (error) {
18
- const message = error instanceof Error ? error.message : String(error);
19
- logger.warn(`binding inference skipped: ${message}`);
20
- }
21
- };
22
- const runPrepareCommand = async (options) => {
6
+ const LOG_FORMATS = /* @__PURE__ */ new Set(["json", "pretty"]);
7
+ const runLogsCommand = async (options) => {
23
8
  const cwd = options.cwd ?? process.cwd();
24
- options.logger.info("running codegen");
25
- let codegen;
26
- try {
27
- codegen = runCodegen({ apiSpec: options.apiSpec, projectRoot: cwd });
28
- options.logger.success("codegen complete");
29
- } catch (error) {
30
- const message = error instanceof Error ? error.message : String(error);
31
- options.logger.error(`codegen failed: ${message}`);
32
- return {
33
- code: 1,
34
- error: `codegen failed: ${message}`,
35
- validation: { problems: [], wranglerPath: void 0 }
36
- };
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);
16
+ }
17
+ const env = options.env ?? readLinkedProject(cwd)?.env;
18
+ if (env !== void 0) {
19
+ args.push("--env", env);
20
+ }
21
+ if (options.format !== void 0) {
22
+ args.push("--format", options.format);
23
+ }
24
+ if (options.status !== void 0) {
25
+ args.push("--status", options.status);
37
26
  }
38
- const gate = runSchemaDriftGate({
39
- allowDrift: options.allowSchemaDrift === true,
40
- codegen,
41
- logger: options.logger,
42
- updateBaseline: options.updateSchemaBaseline === true
43
- });
44
- if (gate.blocked) {
45
- return {
46
- code: 1,
47
- error: "schema drift gate blocked prepare",
48
- schemaDrift: { blocked: true, reason: gate.reason },
49
- validation: { problems: [], wranglerPath: void 0 }
50
- };
27
+ if (options.search !== void 0) {
28
+ args.push("--search", options.search);
51
29
  }
52
- await provisionBindings(cwd, options.logger);
53
- const validation = validateWranglerProject({ projectRoot: cwd });
54
- if (validation.problems.length > 0) {
55
- options.logger.error("wrangler.jsonc validation failed:");
56
- for (const problem of validation.problems) {
57
- options.logger.error(` - ${problem}`);
58
- }
59
- return {
60
- code: 1,
61
- error: "wrangler validation failed",
62
- validation
63
- };
30
+ if (options.temporary) {
31
+ args.push("--temporary");
64
32
  }
65
- gate.rebless?.();
66
- options.logger.success("project is ready to deploy");
67
- return { code: 0, validation };
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
+ };
68
46
  };
69
47
  const execute = defineHandler(
70
- ({ cwd, logger, options }) => runPrepareCommand({
71
- allowSchemaDrift: options.allowSchemaDrift === true,
72
- apiSpec: parseApiSpec(options.apiSpec),
48
+ ({ argument, cwd, logger, options }) => runLogsCommand({
73
49
  cwd,
50
+ env: options.env,
51
+ format: options.format,
74
52
  logger,
75
- updateSchemaBaseline: options.updateSchemaBaseline === true
53
+ search: options.search,
54
+ status: options.status,
55
+ temporary: options.temporary === true,
56
+ worker: argument[0]
76
57
  })
77
58
  );
78
59
 
79
- export { execute, runPrepareCommand };
60
+ export { execute, runLogsCommand };
@@ -1,43 +1,91 @@
1
- import { d as defineHandler } from '../packem_shared/command-BDXcJCCJ.mjs';
2
- import { r as runAddCommand, b as runRegistryViewCommand, a as runBuildIndexCommand } from '../packem_shared/commands-DqsEzojt.mjs';
1
+ import { runCodegen } from '@lunora/codegen';
2
+ import { validateWranglerProject, inferLunoraBindings, reconcileWranglerBindings, reconcileWranglerCompatibilityDate } 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
+ import { d as defineHandler } from '../packem_shared/command-lYnl4QyF.mjs';
6
+ import { r as runSchemaDriftGate } from '../packem_shared/schema-drift-gate-BtBt0as0.mjs';
3
7
 
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
- });
8
+ const provisionBindings = async (cwd, logger) => {
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}`);
22
21
  }
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 });
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}`);
25
32
  }
26
- if (subcommand === "view") {
27
- return runRegistryViewCommand({
28
- allowUnsafeSource: options.allowUnsafeSource === true,
29
- from: options.from,
30
- logger,
31
- names,
32
- ref: options.ref,
33
- source: options.source
34
- });
33
+ };
34
+ const runPrepareCommand = async (options) => {
35
+ const cwd = options.cwd ?? process.cwd();
36
+ options.logger.info("running codegen");
37
+ let codegen;
38
+ try {
39
+ codegen = runCodegen({ apiSpec: options.apiSpec, projectRoot: cwd });
40
+ options.logger.success("codegen complete");
41
+ } catch (error) {
42
+ const message = error instanceof Error ? error.message : String(error);
43
+ options.logger.error(renderCodegenFailure(error));
44
+ return {
45
+ code: 1,
46
+ error: `codegen failed: ${message}`,
47
+ validation: { problems: [], wranglerPath: void 0 }
48
+ };
35
49
  }
36
- if (subcommand === "build") {
37
- return runBuildIndexCommand({ check: options.check === true, from: options.from, logger, out: options.out });
50
+ const gate = runSchemaDriftGate({
51
+ allowDrift: options.allowSchemaDrift === true,
52
+ codegen,
53
+ logger: options.logger,
54
+ updateBaseline: options.updateSchemaBaseline === true
55
+ });
56
+ if (gate.blocked) {
57
+ return {
58
+ code: 1,
59
+ error: "schema drift gate blocked prepare",
60
+ schemaDrift: { blocked: true, reason: gate.reason },
61
+ validation: { problems: [], wranglerPath: void 0 }
62
+ };
38
63
  }
39
- logger.error("registry: unknown subcommand. Usage: lunora registry <add|list|view|build> [names…]");
40
- return { code: 1 };
41
- });
64
+ await provisionBindings(cwd, options.logger);
65
+ const validation = validateWranglerProject({ projectRoot: cwd });
66
+ if (validation.problems.length > 0) {
67
+ options.logger.error("wrangler.jsonc validation failed:");
68
+ for (const problem of validation.problems) {
69
+ options.logger.error(` - ${problem}`);
70
+ }
71
+ return {
72
+ code: 1,
73
+ error: "wrangler validation failed",
74
+ validation
75
+ };
76
+ }
77
+ gate.rebless?.();
78
+ options.logger.success("project is ready to deploy");
79
+ return { code: 0, validation };
80
+ };
81
+ const execute = defineHandler(
82
+ ({ cwd, logger, options }) => runPrepareCommand({
83
+ allowSchemaDrift: options.allowSchemaDrift === true,
84
+ apiSpec: parseApiSpec(options.apiSpec),
85
+ cwd,
86
+ logger,
87
+ updateSchemaBaseline: options.updateSchemaBaseline === true
88
+ })
89
+ );
42
90
 
43
- export { execute };
91
+ export { execute, runPrepareCommand };
@@ -1,105 +1,44 @@
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';
5
- import { d as defineHandler } from '../packem_shared/command-BDXcJCCJ.mjs';
1
+ 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-ClEvcz3V.mjs';
6
3
 
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
- };
93
4
  const execute = defineHandler(({ argument, cwd, logger, options }) => {
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>");
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…]");
102
41
  return { code: 1 };
103
42
  });
104
43
 
105
- export { execute, resolveBundledSkillsDirectory, runRulesCheck, runRulesInstall };
44
+ export { execute };