@beignet/cli 0.0.48 → 0.0.49

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 (88) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +76 -21
  3. package/dist/analysis/contract-factories.d.ts +17 -0
  4. package/dist/analysis/contract-factories.d.ts.map +1 -0
  5. package/dist/analysis/contract-factories.js +176 -0
  6. package/dist/analysis/contract-factories.js.map +1 -0
  7. package/dist/analysis/layers.d.ts +5 -0
  8. package/dist/analysis/layers.d.ts.map +1 -0
  9. package/dist/analysis/layers.js +172 -0
  10. package/dist/analysis/layers.js.map +1 -0
  11. package/dist/analysis/port-wiring.d.ts +23 -0
  12. package/dist/analysis/port-wiring.d.ts.map +1 -0
  13. package/dist/analysis/port-wiring.js +379 -0
  14. package/dist/analysis/port-wiring.js.map +1 -0
  15. package/dist/analysis/source-index.d.ts +5 -0
  16. package/dist/analysis/source-index.d.ts.map +1 -1
  17. package/dist/analysis/source-index.js +171 -42
  18. package/dist/analysis/source-index.js.map +1 -1
  19. package/dist/analysis/workspace.d.ts +10 -4
  20. package/dist/analysis/workspace.d.ts.map +1 -1
  21. package/dist/analysis/workspace.js +66 -6
  22. package/dist/analysis/workspace.js.map +1 -1
  23. package/dist/app-map.d.ts.map +1 -1
  24. package/dist/app-map.js +311 -92
  25. package/dist/app-map.js.map +1 -1
  26. package/dist/check.js +37 -3
  27. package/dist/check.js.map +1 -1
  28. package/dist/explain.js +4 -4
  29. package/dist/explain.js.map +1 -1
  30. package/dist/inspect.d.ts.map +1 -1
  31. package/dist/inspect.js +415 -168
  32. package/dist/inspect.js.map +1 -1
  33. package/dist/lint.d.ts.map +1 -1
  34. package/dist/lint.js +309 -487
  35. package/dist/lint.js.map +1 -1
  36. package/dist/make/inbox.d.ts.map +1 -1
  37. package/dist/make/inbox.js +11 -4
  38. package/dist/make/inbox.js.map +1 -1
  39. package/dist/make/payments.js +2 -2
  40. package/dist/make.d.ts.map +1 -1
  41. package/dist/make.js +144 -8
  42. package/dist/make.js.map +1 -1
  43. package/dist/mcp.d.ts +1 -1
  44. package/dist/mcp.d.ts.map +1 -1
  45. package/dist/mcp.js +19 -19
  46. package/dist/mcp.js.map +1 -1
  47. package/dist/provider-add.d.ts.map +1 -1
  48. package/dist/provider-add.js +142 -7
  49. package/dist/provider-add.js.map +1 -1
  50. package/dist/registry-edits.d.ts +7 -0
  51. package/dist/registry-edits.d.ts.map +1 -1
  52. package/dist/registry-edits.js +237 -53
  53. package/dist/registry-edits.js.map +1 -1
  54. package/dist/templates/agents.d.ts.map +1 -1
  55. package/dist/templates/agents.js +16 -0
  56. package/dist/templates/agents.js.map +1 -1
  57. package/dist/templates/base.d.ts.map +1 -1
  58. package/dist/templates/base.js +9 -1
  59. package/dist/templates/base.js.map +1 -1
  60. package/dist/templates/server.d.ts.map +1 -1
  61. package/dist/templates/server.js +2 -0
  62. package/dist/templates/server.js.map +1 -1
  63. package/dist/templates/shared.d.ts +1 -0
  64. package/dist/templates/shared.d.ts.map +1 -1
  65. package/dist/templates/shared.js +3 -2
  66. package/dist/templates/shared.js.map +1 -1
  67. package/package.json +7 -6
  68. package/skills/app-structure/SKILL.md +46 -5
  69. package/src/analysis/contract-factories.ts +256 -0
  70. package/src/analysis/layers.ts +266 -0
  71. package/src/analysis/port-wiring.ts +506 -0
  72. package/src/analysis/source-index.ts +225 -57
  73. package/src/analysis/workspace.ts +115 -6
  74. package/src/app-map.ts +418 -109
  75. package/src/check.ts +51 -3
  76. package/src/explain.ts +4 -4
  77. package/src/inspect.ts +583 -215
  78. package/src/lint.ts +393 -643
  79. package/src/make/inbox.ts +11 -4
  80. package/src/make/payments.ts +2 -2
  81. package/src/make.ts +225 -8
  82. package/src/mcp.ts +19 -22
  83. package/src/provider-add.ts +186 -7
  84. package/src/registry-edits.ts +313 -63
  85. package/src/templates/agents.ts +16 -0
  86. package/src/templates/base.ts +9 -1
  87. package/src/templates/server.ts +2 -0
  88. package/src/templates/shared.ts +3 -2
package/src/check.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { readFile } from "node:fs/promises";
1
+ import { readdir, readFile, stat } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { createPainter } from "./ansi.js";
4
4
  import { detectPackageManager, spawnCommand } from "./db.js";
@@ -75,6 +75,7 @@ export async function checkApp(
75
75
  options: CheckAppOptions = {},
76
76
  ): Promise<CheckAppResult> {
77
77
  const targetDir = path.resolve(options.cwd ?? process.cwd());
78
+ const scripts = await readAppPackageScripts(targetDir);
78
79
  const runner = await detectPackageManager(targetDir);
79
80
  const steps: CheckStep[] = [];
80
81
  const record = (step: CheckStep): void => {
@@ -99,7 +100,6 @@ export async function checkApp(
99
100
  );
100
101
  }
101
102
 
102
- const scripts = await readPackageScripts(targetDir);
103
103
  for (const script of scriptStepNames) {
104
104
  options.signal?.throwIfAborted();
105
105
  record(await scriptStep(targetDir, runner, script, scripts, options));
@@ -269,7 +269,7 @@ async function scriptStep(
269
269
  };
270
270
  }
271
271
 
272
- async function readPackageScripts(
272
+ async function readAppPackageScripts(
273
273
  targetDir: string,
274
274
  ): Promise<Record<string, string>> {
275
275
  let source: string;
@@ -282,11 +282,59 @@ async function readPackageScripts(
282
282
  }
283
283
 
284
284
  const parsed = JSON.parse(source) as {
285
+ dependencies?: Record<string, string>;
286
+ optionalDependencies?: Record<string, string>;
285
287
  scripts?: Record<string, string>;
286
288
  };
289
+ const dependencies = {
290
+ ...parsed.dependencies,
291
+ ...parsed.optionalDependencies,
292
+ };
293
+ if (
294
+ !["@beignet/core", "@beignet/next", "@beignet/web"].some(
295
+ (packageName) => dependencies[packageName] !== undefined,
296
+ )
297
+ ) {
298
+ throw new Error(
299
+ "package.json does not declare a Beignet runtime dependency. Run beignet check from a Beignet app root that depends on @beignet/core, @beignet/next, or @beignet/web.",
300
+ );
301
+ }
302
+ if (!(await hasBeignetAppStructure(targetDir))) {
303
+ throw new Error(
304
+ "package.json declares a Beignet runtime dependency, but no Beignet app structure was found. Run beignet check from an app root containing app-context.ts, beignet.config.*, or features/ with server/index.ts.",
305
+ );
306
+ }
287
307
  return parsed.scripts ?? {};
288
308
  }
289
309
 
310
+ async function hasBeignetAppStructure(targetDir: string): Promise<boolean> {
311
+ const entries = await readdir(targetDir, { withFileTypes: true });
312
+ const entryByName = new Map(entries.map((entry) => [entry.name, entry]));
313
+ if (entryByName.get("app-context.ts")?.isFile()) return true;
314
+ if (
315
+ [
316
+ "beignet.config.ts",
317
+ "beignet.config.json",
318
+ "beignet.config.mjs",
319
+ "beignet.config.js",
320
+ ].some((file) => entryByName.get(file)?.isFile())
321
+ ) {
322
+ return true;
323
+ }
324
+ if (
325
+ !entryByName.get("features")?.isDirectory() ||
326
+ !entryByName.get("server")?.isDirectory()
327
+ ) {
328
+ return false;
329
+ }
330
+
331
+ try {
332
+ return (await stat(path.join(targetDir, "server/index.ts"))).isFile();
333
+ } catch {
334
+ return false;
335
+ }
336
+ }
337
+
290
338
  async function preflightStep(
291
339
  targetDir: string,
292
340
  options: {
package/src/explain.ts CHANGED
@@ -795,7 +795,7 @@ const conventionsByTargetKind = {
795
795
  ],
796
796
  job: [
797
797
  "Jobs represent background work and remain explicit at provider-backed execution boundaries.",
798
- "Feature jobs register through central runtime or outbox registries before workers can dispatch them.",
798
+ "Feature jobs register through central runtime or outbox registries before workers can dispatch them; registration does not install the required jobs port.",
799
799
  ],
800
800
  schedule: [
801
801
  "Schedules represent time-based triggers and delegate work to application workflows.",
@@ -819,11 +819,11 @@ const conventionsByTargetKind = {
819
819
  ],
820
820
  registry: [
821
821
  "Registries explicitly compose feature declarations into the runtime surface inspected by doctor and app-map.",
822
- "Central registries remain the source of truth for runtime wiring and integrity checks.",
822
+ "Central registries remain the source of truth for runtime wiring and integrity checks; outbox registries containing jobs depend on a bound or deferred jobs dispatcher.",
823
823
  ],
824
824
  port: [
825
825
  "Ports define app-facing dependency interfaces; infrastructure adapters provide their concrete implementations.",
826
- "App ports wire through infra/port-wiring.ts and remain available to use cases through application context.",
826
+ "App ports wire through the configured port-wiring file and remain available to use cases through application context; deferred ports are verified during server startup.",
827
827
  ],
828
828
  provider: [
829
829
  "Ports define app-facing interfaces, providers adapt external systems, and app infrastructure wires them together.",
@@ -839,7 +839,7 @@ const conventionsByTargetKind = {
839
839
  ],
840
840
  entrypoint: [
841
841
  "Runtime entrypoints compose the server or expose thin framework adapters over registered routes.",
842
- "Entrypoints reuse central context, routes, providers, and workflow registries instead of duplicating application behavior.",
842
+ "Entrypoints reuse central context, routes, providers, and workflow registries instead of duplicating application behavior; outbox drains require delivery ports before they claim messages.",
843
843
  ],
844
844
  test: [
845
845
  "Feature behavior tests stay under features/<feature>/tests and exercise use cases, routes, policies, workflows, and UI.",