@beignet/cli 0.0.39 → 0.0.41

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 (112) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +110 -16
  3. package/dist/analysis/source-index.d.ts +38 -0
  4. package/dist/analysis/source-index.d.ts.map +1 -0
  5. package/dist/analysis/source-index.js +271 -0
  6. package/dist/analysis/source-index.js.map +1 -0
  7. package/dist/analysis/workspace.d.ts +16 -0
  8. package/dist/analysis/workspace.d.ts.map +1 -0
  9. package/dist/analysis/workspace.js +134 -0
  10. package/dist/analysis/workspace.js.map +1 -0
  11. package/dist/app-map-schema.d.ts +5 -0
  12. package/dist/app-map-schema.d.ts.map +1 -0
  13. package/dist/app-map-schema.js +26 -0
  14. package/dist/app-map-schema.js.map +1 -0
  15. package/dist/app-map.d.ts +96 -0
  16. package/dist/app-map.d.ts.map +1 -0
  17. package/dist/app-map.js +1141 -0
  18. package/dist/app-map.js.map +1 -0
  19. package/dist/check.d.ts +7 -0
  20. package/dist/check.d.ts.map +1 -1
  21. package/dist/check.js +20 -5
  22. package/dist/check.js.map +1 -1
  23. package/dist/config.d.ts +1 -1
  24. package/dist/config.d.ts.map +1 -1
  25. package/dist/config.js +4 -2
  26. package/dist/config.js.map +1 -1
  27. package/dist/db.d.ts +32 -7
  28. package/dist/db.d.ts.map +1 -1
  29. package/dist/db.js +182 -14
  30. package/dist/db.js.map +1 -1
  31. package/dist/explain.d.ts +98 -0
  32. package/dist/explain.d.ts.map +1 -0
  33. package/dist/explain.js +512 -0
  34. package/dist/explain.js.map +1 -0
  35. package/dist/framework.d.ts +3 -0
  36. package/dist/framework.d.ts.map +1 -0
  37. package/dist/framework.js +6 -0
  38. package/dist/framework.js.map +1 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +79 -2
  41. package/dist/index.js.map +1 -1
  42. package/dist/inspect.d.ts +4 -2
  43. package/dist/inspect.d.ts.map +1 -1
  44. package/dist/inspect.js +173 -36
  45. package/dist/inspect.js.map +1 -1
  46. package/dist/lib.d.ts +4 -0
  47. package/dist/lib.d.ts.map +1 -1
  48. package/dist/lib.js +2 -0
  49. package/dist/lib.js.map +1 -1
  50. package/dist/make/payments.d.ts.map +1 -1
  51. package/dist/make/payments.js +2 -0
  52. package/dist/make/payments.js.map +1 -1
  53. package/dist/make.d.ts.map +1 -1
  54. package/dist/make.js +157 -3
  55. package/dist/make.js.map +1 -1
  56. package/dist/mcp.d.ts +1 -1
  57. package/dist/mcp.d.ts.map +1 -1
  58. package/dist/mcp.js +69 -1
  59. package/dist/mcp.js.map +1 -1
  60. package/dist/preflight.d.ts.map +1 -1
  61. package/dist/preflight.js +10 -0
  62. package/dist/preflight.js.map +1 -1
  63. package/dist/provider-add.d.ts.map +1 -1
  64. package/dist/provider-add.js +167 -13
  65. package/dist/provider-add.js.map +1 -1
  66. package/dist/provider-audit.d.ts +6 -0
  67. package/dist/provider-audit.d.ts.map +1 -1
  68. package/dist/provider-audit.js +63 -15
  69. package/dist/provider-audit.js.map +1 -1
  70. package/dist/templates/agents.d.ts.map +1 -1
  71. package/dist/templates/agents.js +17 -4
  72. package/dist/templates/agents.js.map +1 -1
  73. package/dist/templates/base.d.ts.map +1 -1
  74. package/dist/templates/base.js +10 -4
  75. package/dist/templates/base.js.map +1 -1
  76. package/dist/templates/index.d.ts +1 -1
  77. package/dist/templates/index.d.ts.map +1 -1
  78. package/dist/templates/index.js +8 -1
  79. package/dist/templates/index.js.map +1 -1
  80. package/dist/templates/server.d.ts +3 -0
  81. package/dist/templates/server.d.ts.map +1 -1
  82. package/dist/templates/server.js +55 -1
  83. package/dist/templates/server.js.map +1 -1
  84. package/dist/templates/shadcn.js +1 -1
  85. package/dist/templates/shared.js +1 -1
  86. package/package.json +2 -2
  87. package/skills/app-structure/SKILL.md +38 -5
  88. package/src/analysis/source-index.ts +395 -0
  89. package/src/analysis/workspace.ts +180 -0
  90. package/src/app-map-schema.ts +28 -0
  91. package/src/app-map.ts +1705 -0
  92. package/src/check.ts +27 -4
  93. package/src/config.ts +7 -3
  94. package/src/db.ts +232 -14
  95. package/src/explain.ts +786 -0
  96. package/src/framework.ts +13 -0
  97. package/src/index.ts +113 -2
  98. package/src/inspect.ts +259 -40
  99. package/src/lib.ts +36 -0
  100. package/src/make/payments.ts +7 -0
  101. package/src/make.ts +232 -2
  102. package/src/mcp.ts +107 -1
  103. package/src/preflight.ts +14 -0
  104. package/src/provider-add.ts +211 -12
  105. package/src/provider-audit.ts +127 -22
  106. package/src/templates/agents.ts +17 -4
  107. package/src/templates/base.ts +22 -4
  108. package/src/templates/index.ts +18 -1
  109. package/src/templates/server.ts +58 -1
  110. package/src/templates/shadcn.ts +1 -1
  111. package/src/templates/shared.ts +1 -1
  112. package/src/test-helpers/generated-app.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @beignet/cli
2
2
 
3
+ ## 0.0.41
4
+
5
+ ### Patch Changes
6
+
7
+ - 4516b4a: Expose source-backed app explanations and the full validation loop through new CLI APIs and MCP tools with provider-registration evidence, working-directory-aware actions, bounded output, request cancellation, and honest execution safety annotations.
8
+ - bdda67d: Add a deterministic app architecture map through `beignet map`, the public CLI library API, and a token-bounded `app_map` MCP tool.
9
+ - 5d4bb96: Add a generated Inngest v4 production path with shared clients, runtime-aware registries, Next.js serve routes, registry drift checks, production credential preflight, and explicit single-attempt retry semantics.
10
+ - @beignet/core@0.0.41
11
+
12
+ ## 0.0.40
13
+
14
+ ### Patch Changes
15
+
16
+ - 3c57a51: Add a Web Fetch framework profile for route inspection, doctor checks, and framework-aware generators.
17
+ - f7bcd30: Add push-assisted Next.js outbox draining after successful Unit of Work transactions while retaining cron recovery.
18
+ - Updated dependencies [f7bcd30]
19
+ - @beignet/core@0.0.40
20
+
3
21
  ## 0.0.39
4
22
 
5
23
  ### Patch Changes
package/README.md CHANGED
@@ -171,6 +171,7 @@ Inspect the app, then generate the next feature:
171
171
  ```bash
172
172
  # in another terminal, from my-app
173
173
  bun beignet routes
174
+ bun beignet map
174
175
  bun run lint
175
176
  bun beignet lint
176
177
  bun beignet doctor
@@ -223,7 +224,12 @@ beignet db seed [--dry-run] [--json] [--cwd <dir>]
223
224
  beignet db reset [--dry-run] [--json] [--cwd <dir>]
224
225
  beignet db schema sync [--dialect sqlite|postgres|mysql] [--tables audit,idempotency,outbox] [--output <path>] [--dry-run] [--json] [--cwd <dir>]
225
226
  beignet routes [--json] [--cwd <dir>]
226
- beignet check [--json] [--fix] [--cwd <dir>]
227
+ beignet map [--json] [--feature <name>] [--kind <kinds>] [--cwd <dir>]
228
+ beignet explain feature <name> [--json] [--cwd <dir>]
229
+ beignet explain route <method-and-path> [--json] [--cwd <dir>]
230
+ beignet explain provider <package-or-port> [--json] [--cwd <dir>]
231
+ beignet explain diagnostic <code> [--json] [--cwd <dir>]
232
+ beignet check [--json] [--fix] [--preflight] [--cwd <dir>]
227
233
  beignet lint [--json] [--cwd <dir>] [--format human|json|github]
228
234
  beignet doctor [--json] [--strict] [--fix] [--cwd <dir>] [--format human|json|github]
229
235
  beignet provider add <preset> [--dry-run] [--json] [--cwd <dir>]
@@ -333,7 +339,7 @@ partial command line; it exists for the shell integration and is safe to
333
339
  ignore otherwise. Completions complete whatever `beignet` resolves to on your
334
340
  `PATH`, such as the app-local bin installed by generated apps.
335
341
 
336
- Beignet CLI commands are convention-aware. `routes`, `lint`, `doctor`, and
342
+ Beignet CLI commands are convention-aware. `routes`, `map`, `lint`, `doctor`, and
337
343
  generators work best in the Next.js layout created by `beignet create`:
338
344
 
339
345
  ```txt
@@ -372,14 +378,33 @@ reports misplaced or stale workflow artifacts when they drift from the app
372
378
  layout.
373
379
 
374
380
  Use `beignet.config.ts`, `beignet.config.js`,
375
- `beignet.config.mjs`, or `beignet.config.json` when your app keeps
376
- the same architecture under different paths:
381
+ `beignet.config.mjs`, or `beignet.config.json` to select the server adapter
382
+ profile or when your app keeps the same architecture under different paths.
383
+ `"next"` is the default; use `"web"` when the server exposes
384
+ `createFetchServer(...)` from `@beignet/web`:
385
+
386
+ ```ts
387
+ import { defineConfig } from "@beignet/cli/config";
388
+
389
+ export default defineConfig({
390
+ framework: "web",
391
+ });
392
+ ```
393
+
394
+ The web profile derives route coverage from canonical feature route groups in
395
+ the central `defineRoutes(...)` registry passed to `createFetchServer(...)`, so
396
+ `routes` and `doctor` do not require Next.js `app/api/` files. Vite and Bun do
397
+ not need separate values: they are client tooling and a Fetch host,
398
+ respectively.
399
+
400
+ Path overrides remain available for either profile:
377
401
 
378
402
  ```ts
379
403
  // beignet.config.ts
380
404
  import { defineConfig } from "@beignet/cli/config";
381
405
 
382
406
  export default defineConfig({
407
+ framework: "next",
383
408
  paths: {
384
409
  appContext: "src/app-context.ts",
385
410
  contracts: "src/features",
@@ -403,6 +428,11 @@ config before inspecting or writing files. When `appContext` is moved under a
403
428
  source root such as `src/app-context.ts`, client setup follows that root at
404
429
  `src/client/index.ts`.
405
430
 
431
+ Framework-neutral generators work in both profiles. `make payments`,
432
+ `make upload`, `make outbox`, and `make schedule --route` currently generate
433
+ Next.js App Router handlers and therefore reject `framework: "web"` before
434
+ writing. The `create` command also remains a Next.js scaffold.
435
+
406
436
  The generated `lib/beignet-test-runner.ts` also resolves all four supported
407
437
  config formats and includes configured test, feature, route, server, port,
408
438
  infra-port, route-builder, and use-case-builder roots in test discovery.
@@ -730,10 +760,14 @@ out of task definitions. Both receive `TaskRunContextArgs` from
730
760
  `--tenant` value — so tenant scoping stays out of task input schemas.
731
761
 
732
762
  `make outbox` creates `server/outbox.ts` and a bounded
733
- `app/api/cron/outbox/drain` route. `make event` and `make job` create that
734
- outbox path on first use and register the feature's `postEvents` and
735
- `postJobs` registries in `defineOutboxRegistry({...})`; `beignet doctor`
736
- reports events and jobs the registry cannot deliver.
763
+ `app/api/cron/outbox/drain` route. On Next.js 15.1 or newer it also wraps the
764
+ database Unit of Work from a server-local provider with
765
+ `createObservedUnitOfWork(...)` and schedules one push-assisted drain through
766
+ `after()`. Older Next.js versions retain valid cron-only wiring. `make event`
767
+ and `make job` create that outbox path on first use and register the feature's
768
+ `postEvents` and `postJobs` registries in `defineOutboxRegistry({...})`;
769
+ `beignet doctor` reports events and jobs the registry cannot deliver. Keep the
770
+ route as the durable recovery sweep even when the deferred trigger is present.
737
771
 
738
772
  Generators wire the provider-backed ports their output depends on. `make
739
773
  event` (and `make resource --events`) wires `eventBus: EventBusPort` with
@@ -806,8 +840,11 @@ messages. Both support bounded `--limit` runs and `--dry-run` previews.
806
840
  There is intentionally no separate `beignet jobs drain` command. Outbox-backed
807
841
  jobs drain through the outbox beside durable events. Direct provider jobs should
808
842
  use provider-owned worker entrypoints, such as a BullMQ worker built with
809
- `createBullMQJobWorker(...)` or an Inngest route built with
810
- `createInngestJobFunction(...)`.
843
+ `createBullMQJobWorker(...)` or the generated Inngest `server/inngest.ts`
844
+ registry. Next apps receive `app/api/inngest/route.ts`; non-Next apps receive a
845
+ `createAppInngestFunctions(...)` factory for their runtime adapter. When the
846
+ Inngest provider is installed, `beignet make job` maintains the central
847
+ registry.
811
848
 
812
849
  Use `beignet schedule run` when you need to run a schedule explicitly from a
813
850
  local shell, CI job, or worker entrypoint:
@@ -916,6 +953,51 @@ Use JSON output when you want to feed the route catalog into another tool:
916
953
  beignet routes --json
917
954
  ```
918
955
 
956
+ ## Map app architecture
957
+
958
+ Build a deterministic, source-backed graph of the app:
959
+
960
+ ```bash
961
+ beignet map
962
+ beignet map --feature issues
963
+ beignet map --json --kind route,use-case,event,listener
964
+ ```
965
+
966
+ The human view summarizes contracts, use cases, workflows, ports, UI, and tests
967
+ per feature. JSON is a versioned `schemaVersion: 1` payload with features,
968
+ contracts, route groups, use cases, policies and abilities, workflow
969
+ definitions and registries, agent capabilities, ports, app/package providers,
970
+ tables, OpenAPI exposure, tests, cross-feature dependencies, doctor/lint
971
+ findings, and unresolved references. Every node has a stable ID and source;
972
+ every edge carries source evidence and confidence.
973
+
974
+ `--feature` keeps that feature plus its direct relationships, while `--kind`
975
+ accepts one or a comma-separated list of node kinds. These projections make
976
+ the same full graph practical for coding-agent context windows. The command is
977
+ report-only and does not fail because doctor or lint findings are present.
978
+
979
+ ## Explain mapped app concepts
980
+
981
+ Resolve one app-map target into deterministic, source-backed context:
982
+
983
+ ```bash
984
+ beignet explain feature issues
985
+ beignet explain route "POST /api/issues"
986
+ beignet explain provider storage
987
+ beignet explain diagnostic BEIGNET_ROUTE_GROUP_UNREGISTERED
988
+ ```
989
+
990
+ Human output summarizes relevant relationships, conventions, findings,
991
+ suggested files, and follow-up commands. `--json` returns the versioned
992
+ `schemaVersion: 1` payload used by the MCP `explain` tool. Feature explanations
993
+ bound their relationship list and report full and returned counts; use
994
+ `beignet map --feature <name> --json` or a route explanation for the omitted
995
+ detail. Provider explanations include the matching entry in the configured
996
+ provider registry when static provider audit proves it. Human output names
997
+ the app root, and command actions in JSON carry their own `cwd`, so an
998
+ explanation requested with `--cwd` stays copy-pasteable. Explain is report-only
999
+ and never changes the app.
1000
+
919
1001
  ## Run the validation loop
920
1002
 
921
1003
  Run `check` when you want the whole validation loop as one command:
@@ -929,12 +1011,14 @@ It runs `beignet lint`, `beignet doctor --strict`, and the app's own `lint`,
929
1011
  in that order. Every step runs even when an earlier one fails, so a single
930
1012
  run reports everything that needs fixing; the command exits non-zero when any
931
1013
  step fails. Missing package scripts are reported as skipped, never as
932
- failures.
1014
+ failures. Failed package-script output retains at most the last 64 KiB of each
1015
+ stream.
933
1016
 
934
1017
  Use `beignet check --fix` to apply doctor's low-risk registration fixes
935
1018
  before checking, and `beignet check --json` for a versioned payload
936
1019
  (`schemaVersion: 1`) with the step list, statuses, captured failure output,
937
- and applied fixes. The individual commands below still work when you need one
1020
+ and applied fixes. Add `--preflight` to run the runtime environment gate after
1021
+ strict doctor. The individual commands below still work when you need one
938
1022
  check alone or its `--format github` output.
939
1023
 
940
1024
  ## Gate the deploy environment
@@ -1107,8 +1191,8 @@ Use `beignet provider audit` when you want a report-only inventory of the
1107
1191
  provider packages installed in an app. The human audit prints provider
1108
1192
  metadata validity, registration status, required env, required tables, and
1109
1193
  declared app ports. `beignet provider audit --json` returns a versioned
1110
- `schemaVersion: 1` payload with active variants and watchers for scripts and
1111
- coding agents. The command does not fail CI for missing setup; stable,
1194
+ `schemaVersion: 1` payload with active variants, watchers, and source locations
1195
+ for matching provider-registry entries. The command does not fail CI for missing setup; stable,
1112
1196
  actionable findings belong in `doctor`.
1113
1197
 
1114
1198
  Use `beignet doctor --strict` for CI-oriented checks that may be noisy locally,
@@ -1144,8 +1228,18 @@ call the CLI as tools:
1144
1228
  beignet mcp
1145
1229
  ```
1146
1230
 
1147
- The server exposes six tools:
1148
-
1231
+ The server exposes nine tools:
1232
+
1233
+ - `app_map` - project the source-backed app graph by optional `feature`,
1234
+ `kinds`, and `includeDiagnostics` inputs (read-only)
1235
+ - `explain` - explain one source-backed feature, route, provider, or diagnostic
1236
+ with `{ kind, target }`, returning relationships, conventions, findings,
1237
+ suggested files, and follow-up commands (read-only)
1238
+ - `check` - run the complete validation loop and return versioned step
1239
+ results, bounded failure output, durations, and overall `ok`; accepts
1240
+ `{ preflight?: boolean, timeoutMs?: number }`, cancels the active script with
1241
+ the MCP request, and does not apply Beignet fixes. App scripts retain their
1242
+ normal side effects, so this is an execution tool rather than a read-only tool
1149
1243
  - `routes` - list app routes and contracts (read-only)
1150
1244
  - `doctor` - drift diagnostics as JSON, `{ strict?: boolean }` defaults to
1151
1245
  `true` (read-only)
@@ -0,0 +1,38 @@
1
+ import ts from "typescript";
2
+ import { type AnalysisWorkspace } from "./workspace.js";
3
+ export type AnalysisSourceLocation = {
4
+ file: string;
5
+ exportName?: string;
6
+ line?: number;
7
+ column?: number;
8
+ };
9
+ export type ResolvedSourceReference = {
10
+ file: string;
11
+ exportName: string;
12
+ declaration?: ts.Declaration;
13
+ };
14
+ export type LocalImportReference = {
15
+ file: string;
16
+ importPath: string;
17
+ resolvedFile: string;
18
+ kind: "type" | "value";
19
+ line: number;
20
+ column: number;
21
+ };
22
+ export type SourceIndex = {
23
+ resolveName(file: string, name: string): Promise<ResolvedSourceReference | undefined>;
24
+ resolveExpression(file: string, expression: ts.Expression): Promise<ResolvedSourceReference | undefined>;
25
+ resolveExport(file: string, exportName: string): Promise<ResolvedSourceReference | undefined>;
26
+ sourceLocation(file: string, node: ts.Node, exportName?: string): Promise<AnalysisSourceLocation>;
27
+ };
28
+ export declare function createSourceIndex(workspace: AnalysisWorkspace): SourceIndex;
29
+ export declare function exportedVariableDeclarations(sourceFile: ts.SourceFile): Array<{
30
+ exportName: string;
31
+ declaration: ts.VariableDeclaration;
32
+ }>;
33
+ export declare function literalText(node: ts.Node | undefined): string | undefined;
34
+ export declare function propertyAssignment(object: ts.ObjectLiteralExpression, name: string): ts.PropertyAssignment | undefined;
35
+ export declare function propertyName(node: ts.PropertyName): string | undefined;
36
+ export declare function visitCalls(node: ts.Node, visit: (call: ts.CallExpression) => void): void;
37
+ export declare function localImportReferences(workspace: AnalysisWorkspace, file: string): Promise<LocalImportReference[]>;
38
+ //# sourceMappingURL=source-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-index.d.ts","sourceRoot":"","sources":["../../src/analysis/source-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,KAAK,iBAAiB,EAA0B,MAAM,gBAAgB,CAAC;AAEhF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,oBAAo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I,EAAE,EAAE,CAAC,YAAY,GAAG,MAAM,GAAG,SAAS,CAGtE;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,KAAK,IAAI,GACvC,IAAI,CAMN;AAED,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,iBAAiB,EAC5B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAkDjC"}
@@ -0,0 +1,271 @@
1
+ import ts from "typescript";
2
+ import { resolveLocalSourceFile } from "./workspace.js";
3
+ export function createSourceIndex(workspace) {
4
+ const indexes = new Map();
5
+ const readIndex = async (file) => {
6
+ const cached = indexes.get(file);
7
+ if (cached)
8
+ return cached;
9
+ const sourceFile = await workspace.readSourceFile(file);
10
+ const index = {
11
+ declarations: new Map(),
12
+ imports: new Map(),
13
+ reexports: new Map(),
14
+ exportStars: [],
15
+ };
16
+ indexes.set(file, index);
17
+ for (const statement of sourceFile.statements) {
18
+ if (ts.isImportDeclaration(statement)) {
19
+ const source = moduleText(statement.moduleSpecifier);
20
+ const target = source
21
+ ? resolveLocalSourceFile(workspace, file, source)
22
+ : undefined;
23
+ if (!target || !statement.importClause)
24
+ continue;
25
+ if (statement.importClause.name) {
26
+ index.imports.set(statement.importClause.name.text, {
27
+ kind: "named",
28
+ file: target,
29
+ exportName: "default",
30
+ });
31
+ }
32
+ const bindings = statement.importClause.namedBindings;
33
+ if (bindings && ts.isNamespaceImport(bindings)) {
34
+ index.imports.set(bindings.name.text, {
35
+ kind: "namespace",
36
+ file: target,
37
+ });
38
+ }
39
+ else if (bindings && ts.isNamedImports(bindings)) {
40
+ for (const element of bindings.elements) {
41
+ index.imports.set(element.name.text, {
42
+ kind: "named",
43
+ file: target,
44
+ exportName: element.propertyName?.text ?? element.name.text,
45
+ });
46
+ }
47
+ }
48
+ continue;
49
+ }
50
+ if (ts.isExportDeclaration(statement)) {
51
+ const source = statement.moduleSpecifier
52
+ ? moduleText(statement.moduleSpecifier)
53
+ : undefined;
54
+ const target = source
55
+ ? resolveLocalSourceFile(workspace, file, source)
56
+ : undefined;
57
+ if (!target)
58
+ continue;
59
+ if (!statement.exportClause) {
60
+ index.exportStars.push(target);
61
+ continue;
62
+ }
63
+ if (ts.isNamedExports(statement.exportClause)) {
64
+ for (const element of statement.exportClause.elements) {
65
+ index.reexports.set(element.name.text, {
66
+ file: target,
67
+ exportName: element.propertyName?.text ?? element.name.text,
68
+ });
69
+ }
70
+ }
71
+ continue;
72
+ }
73
+ if (ts.isVariableStatement(statement) && hasExportModifier(statement)) {
74
+ for (const declaration of statement.declarationList.declarations) {
75
+ if (ts.isIdentifier(declaration.name)) {
76
+ index.declarations.set(declaration.name.text, declaration);
77
+ }
78
+ }
79
+ continue;
80
+ }
81
+ if ((ts.isFunctionDeclaration(statement) ||
82
+ ts.isClassDeclaration(statement) ||
83
+ ts.isInterfaceDeclaration(statement) ||
84
+ ts.isTypeAliasDeclaration(statement) ||
85
+ ts.isEnumDeclaration(statement)) &&
86
+ hasExportModifier(statement) &&
87
+ statement.name) {
88
+ index.declarations.set(statement.name.text, statement);
89
+ }
90
+ }
91
+ return index;
92
+ };
93
+ const resolveExport = async (file, exportName, visited = new Set()) => {
94
+ const key = `${file}#${exportName}`;
95
+ if (visited.has(key))
96
+ return undefined;
97
+ visited.add(key);
98
+ const index = await readIndex(file);
99
+ const declaration = index.declarations.get(exportName);
100
+ if (declaration)
101
+ return { file, exportName, declaration };
102
+ const reexport = index.reexports.get(exportName);
103
+ if (reexport) {
104
+ return ((await resolveExport(reexport.file, reexport.exportName, visited)) ?? {
105
+ file: reexport.file,
106
+ exportName: reexport.exportName,
107
+ });
108
+ }
109
+ for (const target of index.exportStars) {
110
+ const resolved = await resolveExport(target, exportName, visited);
111
+ if (resolved)
112
+ return resolved;
113
+ }
114
+ return undefined;
115
+ };
116
+ return {
117
+ async resolveName(file, name) {
118
+ const index = await readIndex(file);
119
+ const local = index.declarations.get(name);
120
+ if (local) {
121
+ return { file, exportName: name, declaration: local };
122
+ }
123
+ const binding = index.imports.get(name);
124
+ if (binding?.kind !== "named")
125
+ return undefined;
126
+ return ((await resolveExport(binding.file, binding.exportName)) ?? {
127
+ file: binding.file,
128
+ exportName: binding.exportName,
129
+ });
130
+ },
131
+ async resolveExpression(file, rawExpression) {
132
+ const expression = unwrapExpression(rawExpression);
133
+ const index = await readIndex(file);
134
+ if (ts.isIdentifier(expression)) {
135
+ const local = index.declarations.get(expression.text);
136
+ if (local) {
137
+ return { file, exportName: expression.text, declaration: local };
138
+ }
139
+ const binding = index.imports.get(expression.text);
140
+ if (binding?.kind !== "named")
141
+ return undefined;
142
+ return ((await resolveExport(binding.file, binding.exportName)) ?? {
143
+ file: binding.file,
144
+ exportName: binding.exportName,
145
+ });
146
+ }
147
+ if (ts.isPropertyAccessExpression(expression) &&
148
+ ts.isIdentifier(expression.expression)) {
149
+ const binding = index.imports.get(expression.expression.text);
150
+ if (binding?.kind !== "namespace")
151
+ return undefined;
152
+ return ((await resolveExport(binding.file, expression.name.text)) ?? {
153
+ file: binding.file,
154
+ exportName: expression.name.text,
155
+ });
156
+ }
157
+ return undefined;
158
+ },
159
+ resolveExport(file, exportName) {
160
+ return resolveExport(file, exportName);
161
+ },
162
+ async sourceLocation(file, node, exportName) {
163
+ const sourceFile = await workspace.readSourceFile(file);
164
+ const position = sourceFile.getLineAndCharacterOfPosition(node.getStart());
165
+ return {
166
+ file,
167
+ ...(exportName ? { exportName } : {}),
168
+ line: position.line + 1,
169
+ column: position.character + 1,
170
+ };
171
+ },
172
+ };
173
+ }
174
+ export function exportedVariableDeclarations(sourceFile) {
175
+ const declarations = [];
176
+ for (const statement of sourceFile.statements) {
177
+ if (!ts.isVariableStatement(statement) || !hasExportModifier(statement)) {
178
+ continue;
179
+ }
180
+ for (const declaration of statement.declarationList.declarations) {
181
+ if (ts.isIdentifier(declaration.name)) {
182
+ declarations.push({
183
+ exportName: declaration.name.text,
184
+ declaration,
185
+ });
186
+ }
187
+ }
188
+ }
189
+ return declarations;
190
+ }
191
+ export function literalText(node) {
192
+ return node &&
193
+ (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node))
194
+ ? node.text
195
+ : undefined;
196
+ }
197
+ export function propertyAssignment(object, name) {
198
+ return object.properties.find((property) => ts.isPropertyAssignment(property) && propertyName(property.name) === name);
199
+ }
200
+ export function propertyName(node) {
201
+ if (ts.isIdentifier(node) || ts.isStringLiteral(node))
202
+ return node.text;
203
+ return undefined;
204
+ }
205
+ export function visitCalls(node, visit) {
206
+ const walk = (current) => {
207
+ if (ts.isCallExpression(current))
208
+ visit(current);
209
+ current.forEachChild(walk);
210
+ };
211
+ walk(node);
212
+ }
213
+ export async function localImportReferences(workspace, file) {
214
+ const sourceFile = await workspace.readSourceFile(file);
215
+ const references = [];
216
+ for (const statement of sourceFile.statements) {
217
+ if (!ts.isImportDeclaration(statement) &&
218
+ !ts.isExportDeclaration(statement)) {
219
+ continue;
220
+ }
221
+ if (!statement.moduleSpecifier)
222
+ continue;
223
+ const importPath = moduleText(statement.moduleSpecifier);
224
+ const resolvedFile = importPath
225
+ ? resolveLocalSourceFile(workspace, file, importPath)
226
+ : undefined;
227
+ if (!importPath || !resolvedFile)
228
+ continue;
229
+ const position = sourceFile.getLineAndCharacterOfPosition(statement.getStart(sourceFile));
230
+ const typeOnly = ts.isImportDeclaration(statement)
231
+ ? Boolean(statement.importClause?.isTypeOnly ||
232
+ (statement.importClause?.namedBindings &&
233
+ ts.isNamedImports(statement.importClause.namedBindings) &&
234
+ statement.importClause.namedBindings.elements.length > 0 &&
235
+ statement.importClause.namedBindings.elements.every((element) => element.isTypeOnly)))
236
+ : statement.isTypeOnly ||
237
+ (statement.exportClause &&
238
+ ts.isNamedExports(statement.exportClause) &&
239
+ statement.exportClause.elements.length > 0 &&
240
+ statement.exportClause.elements.every((element) => element.isTypeOnly));
241
+ references.push({
242
+ file,
243
+ importPath,
244
+ resolvedFile,
245
+ kind: typeOnly ? "type" : "value",
246
+ line: position.line + 1,
247
+ column: position.character + 1,
248
+ });
249
+ }
250
+ return references;
251
+ }
252
+ function moduleText(node) {
253
+ return ts.isStringLiteral(node) ? node.text : undefined;
254
+ }
255
+ function hasExportModifier(node) {
256
+ return Boolean(ts.canHaveModifiers(node) &&
257
+ ts
258
+ .getModifiers(node)
259
+ ?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword));
260
+ }
261
+ function unwrapExpression(expression) {
262
+ let current = expression;
263
+ while (ts.isAsExpression(current) ||
264
+ ts.isSatisfiesExpression(current) ||
265
+ ts.isParenthesizedExpression(current) ||
266
+ ts.isNonNullExpression(current)) {
267
+ current = current.expression;
268
+ }
269
+ return current;
270
+ }
271
+ //# sourceMappingURL=source-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-index.js","sourceRoot":"","sources":["../../src/analysis/source-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAA0B,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAuDhF,MAAM,UAAU,iBAAiB,CAAC,SAA4B;IAC5D,MAAM,OAAO,GAAG,IAAI,GAAG,EAAqB,CAAC;IAE7C,MAAM,SAAS,GAAG,KAAK,EAAE,IAAY,EAAsB,EAAE;QAC3D,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAE1B,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QACxD,MAAM,KAAK,GAAc;YACvB,YAAY,EAAE,IAAI,GAAG,EAAE;YACvB,OAAO,EAAE,IAAI,GAAG,EAAE;YAClB,SAAS,EAAE,IAAI,GAAG,EAAE;YACpB,WAAW,EAAE,EAAE;SAChB,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAA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ResolvedBeignetConfig } from "../config.js";
3
+ export type AnalysisWorkspace = {
4
+ targetDir: string;
5
+ files: string[];
6
+ fileSet: Set<string>;
7
+ config: ResolvedBeignetConfig;
8
+ atAliasRoot: string;
9
+ readSource(file: string): Promise<string>;
10
+ readSourceFile(file: string): Promise<ts.SourceFile>;
11
+ };
12
+ export declare function createAnalysisWorkspace(cwd?: string): Promise<AnalysisWorkspace>;
13
+ export declare function assertDirectory(targetDir: string): Promise<void>;
14
+ export declare function listProjectFiles(targetDir: string): Promise<string[]>;
15
+ export declare function resolveLocalSourceFile(workspace: Pick<AnalysisWorkspace, "atAliasRoot" | "fileSet">, importerFile: string, importPath: string): string | undefined;
16
+ //# sourceMappingURL=workspace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/analysis/workspace.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,cAAc,CAAC;AAWtB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;CACtD,CAAC;AAEF,wBAAsB,uBAAuB,CAC3C,GAAG,SAAgB,GAClB,OAAO,CAAC,iBAAiB,CAAC,CAyC5B;AAED,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYtE;AAED,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAqB3E;AAED,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,aAAa,GAAG,SAAS,CAAC,EAC7D,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,MAAM,GAAG,SAAS,CA6BpB"}