@ontrails/trails 1.0.0-beta.13 → 1.0.0-beta.14

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 (140) hide show
  1. package/.turbo/turbo-lint.log +1 -1
  2. package/CHANGELOG.md +16 -0
  3. package/__tests__/examples.test.ts +14 -0
  4. package/dist/src/app.d.ts.map +1 -1
  5. package/dist/src/app.js +13 -2
  6. package/dist/src/app.js.map +1 -1
  7. package/dist/src/clack.d.ts +1 -1
  8. package/dist/src/clack.js +1 -1
  9. package/dist/src/cli.js +2 -2
  10. package/dist/src/cli.js.map +1 -1
  11. package/dist/src/trails/add-trail.js +13 -13
  12. package/dist/src/trails/add-trail.js.map +1 -1
  13. package/dist/src/trails/add-trailhead.d.ts +13 -0
  14. package/dist/src/trails/add-trailhead.d.ts.map +1 -0
  15. package/dist/src/trails/add-trailhead.js +88 -0
  16. package/dist/src/trails/add-trailhead.js.map +1 -0
  17. package/dist/src/trails/add-verify.js +10 -10
  18. package/dist/src/trails/add-verify.js.map +1 -1
  19. package/dist/src/trails/create-scaffold.js +26 -26
  20. package/dist/src/trails/create-scaffold.js.map +1 -1
  21. package/dist/src/trails/create.d.ts +6 -6
  22. package/dist/src/trails/create.d.ts.map +1 -1
  23. package/dist/src/trails/create.js +29 -29
  24. package/dist/src/trails/create.js.map +1 -1
  25. package/dist/src/trails/dev-clean.d.ts +9 -0
  26. package/dist/src/trails/dev-clean.d.ts.map +1 -0
  27. package/dist/src/trails/dev-clean.js +65 -0
  28. package/dist/src/trails/dev-clean.js.map +1 -0
  29. package/dist/src/trails/dev-reset.d.ts +6 -0
  30. package/dist/src/trails/dev-reset.d.ts.map +1 -0
  31. package/dist/src/trails/dev-reset.js +38 -0
  32. package/dist/src/trails/dev-reset.js.map +1 -0
  33. package/dist/src/trails/dev-stats.d.ts +7 -0
  34. package/dist/src/trails/dev-stats.d.ts.map +1 -0
  35. package/dist/src/trails/dev-stats.js +61 -0
  36. package/dist/src/trails/dev-stats.js.map +1 -0
  37. package/dist/src/trails/dev-support.d.ts +64 -0
  38. package/dist/src/trails/dev-support.d.ts.map +1 -0
  39. package/dist/src/trails/dev-support.js +178 -0
  40. package/dist/src/trails/dev-support.js.map +1 -0
  41. package/dist/src/trails/draft-promote.d.ts +18 -0
  42. package/dist/src/trails/draft-promote.d.ts.map +1 -0
  43. package/dist/src/trails/draft-promote.js +386 -0
  44. package/dist/src/trails/draft-promote.js.map +1 -0
  45. package/dist/src/trails/guide.d.ts +13 -3
  46. package/dist/src/trails/guide.d.ts.map +1 -1
  47. package/dist/src/trails/guide.js +21 -37
  48. package/dist/src/trails/guide.js.map +1 -1
  49. package/dist/src/trails/load-app.d.ts +3 -1
  50. package/dist/src/trails/load-app.d.ts.map +1 -1
  51. package/dist/src/trails/load-app.js +53 -10
  52. package/dist/src/trails/load-app.js.map +1 -1
  53. package/dist/src/trails/project.d.ts.map +1 -1
  54. package/dist/src/trails/project.js +14 -3
  55. package/dist/src/trails/project.js.map +1 -1
  56. package/dist/src/trails/survey.d.ts +4 -58
  57. package/dist/src/trails/survey.d.ts.map +1 -1
  58. package/dist/src/trails/survey.js +52 -173
  59. package/dist/src/trails/survey.js.map +1 -1
  60. package/dist/src/trails/topo-constants.d.ts +3 -0
  61. package/dist/src/trails/topo-constants.d.ts.map +1 -0
  62. package/dist/src/trails/topo-constants.js +3 -0
  63. package/dist/src/trails/topo-constants.js.map +1 -0
  64. package/dist/src/trails/topo-export.d.ts +18 -0
  65. package/dist/src/trails/topo-export.d.ts.map +1 -0
  66. package/dist/src/trails/topo-export.js +34 -0
  67. package/dist/src/trails/topo-export.js.map +1 -0
  68. package/dist/src/trails/topo-history.d.ts +24 -0
  69. package/dist/src/trails/topo-history.d.ts.map +1 -0
  70. package/dist/src/trails/topo-history.js +33 -0
  71. package/dist/src/trails/topo-history.js.map +1 -0
  72. package/dist/src/trails/topo-pin.d.ts +21 -0
  73. package/dist/src/trails/topo-pin.d.ts.map +1 -0
  74. package/dist/src/trails/topo-pin.js +35 -0
  75. package/dist/src/trails/topo-pin.js.map +1 -0
  76. package/dist/src/trails/topo-read-support.d.ts +54 -0
  77. package/dist/src/trails/topo-read-support.d.ts.map +1 -0
  78. package/dist/src/trails/topo-read-support.js +178 -0
  79. package/dist/src/trails/topo-read-support.js.map +1 -0
  80. package/dist/src/trails/topo-reports.d.ts +50 -0
  81. package/dist/src/trails/topo-reports.d.ts.map +1 -0
  82. package/dist/src/trails/topo-reports.js +122 -0
  83. package/dist/src/trails/topo-reports.js.map +1 -0
  84. package/dist/src/trails/topo-show.d.ts +23 -0
  85. package/dist/src/trails/topo-show.d.ts.map +1 -0
  86. package/dist/src/trails/topo-show.js +53 -0
  87. package/dist/src/trails/topo-show.js.map +1 -0
  88. package/dist/src/trails/topo-store-support.d.ts +13 -0
  89. package/dist/src/trails/topo-store-support.d.ts.map +1 -0
  90. package/dist/src/trails/topo-store-support.js +55 -0
  91. package/dist/src/trails/topo-store-support.js.map +1 -0
  92. package/dist/src/trails/topo-support.d.ts +87 -0
  93. package/dist/src/trails/topo-support.d.ts.map +1 -0
  94. package/dist/src/trails/topo-support.js +165 -0
  95. package/dist/src/trails/topo-support.js.map +1 -0
  96. package/dist/src/trails/topo-unpin.d.ts +15 -0
  97. package/dist/src/trails/topo-unpin.d.ts.map +1 -0
  98. package/dist/src/trails/topo-unpin.js +39 -0
  99. package/dist/src/trails/topo-unpin.js.map +1 -0
  100. package/dist/src/trails/topo-verify.d.ts +5 -0
  101. package/dist/src/trails/topo-verify.d.ts.map +1 -0
  102. package/dist/src/trails/topo-verify.js +28 -0
  103. package/dist/src/trails/topo-verify.js.map +1 -0
  104. package/dist/src/trails/topo.d.ts +5 -0
  105. package/dist/src/trails/topo.d.ts.map +1 -0
  106. package/dist/src/trails/topo.js +67 -0
  107. package/dist/src/trails/topo.js.map +1 -0
  108. package/dist/src/trails/warden.d.ts +1 -1
  109. package/dist/src/trails/warden.d.ts.map +1 -1
  110. package/dist/src/trails/warden.js +28 -27
  111. package/dist/src/trails/warden.js.map +1 -1
  112. package/dist/tsconfig.tsbuildinfo +1 -1
  113. package/package.json +8 -7
  114. package/src/__tests__/draft-promote.test.ts +144 -0
  115. package/src/__tests__/load-app.test.ts +43 -0
  116. package/src/__tests__/survey.test.ts +85 -0
  117. package/src/__tests__/topo-dev.test.ts +424 -0
  118. package/src/app.ts +22 -0
  119. package/src/trails/dev-clean.ts +73 -0
  120. package/src/trails/dev-reset.ts +44 -0
  121. package/src/trails/dev-stats.ts +64 -0
  122. package/src/trails/dev-support.ts +326 -0
  123. package/src/trails/draft-promote.ts +704 -0
  124. package/src/trails/guide.ts +22 -37
  125. package/src/trails/load-app.ts +76 -13
  126. package/src/trails/project.ts +17 -3
  127. package/src/trails/survey.ts +56 -256
  128. package/src/trails/topo-constants.ts +2 -0
  129. package/src/trails/topo-export.ts +39 -0
  130. package/src/trails/topo-history.ts +40 -0
  131. package/src/trails/topo-pin.ts +42 -0
  132. package/src/trails/topo-read-support.ts +332 -0
  133. package/src/trails/topo-reports.ts +221 -0
  134. package/src/trails/topo-show.ts +58 -0
  135. package/src/trails/topo-store-support.ts +96 -0
  136. package/src/trails/topo-support.ts +274 -0
  137. package/src/trails/topo-unpin.ts +51 -0
  138. package/src/trails/topo-verify.ts +29 -0
  139. package/src/trails/topo.ts +73 -0
  140. package/src/trails/warden.ts +1 -0
@@ -0,0 +1,33 @@
1
+ import { Result, trail } from '@ontrails/core';
2
+ import { z } from 'zod';
3
+ import { DEFAULT_TOPO_HISTORY_LIMIT, isolatedExampleInput, listTopoHistory, topoPinOutput, topoSaveOutput, } from './topo-support.js';
4
+ export const topoHistoryTrail = trail('topo.history', {
5
+ blaze: (input, ctx) => {
6
+ const rootDir = input.rootDir ?? ctx.cwd ?? process.cwd();
7
+ return Result.ok(listTopoHistory({ limit: input.limit, rootDir }));
8
+ },
9
+ description: 'List saved topo metadata, including pins and recent autosaves',
10
+ examples: [
11
+ {
12
+ input: isolatedExampleInput('topo-history'),
13
+ name: 'Show topo history',
14
+ },
15
+ ],
16
+ input: z.object({
17
+ limit: z
18
+ .number()
19
+ .default(DEFAULT_TOPO_HISTORY_LIMIT)
20
+ .describe('Maximum number of autosaves to return'),
21
+ rootDir: z.string().optional().describe('Workspace root directory'),
22
+ }),
23
+ intent: 'read',
24
+ output: z.object({
25
+ dbPath: z.string(),
26
+ limit: z.number(),
27
+ pinCount: z.number(),
28
+ pins: z.array(topoPinOutput),
29
+ saveCount: z.number(),
30
+ saves: z.array(topoSaveOutput),
31
+ }),
32
+ });
33
+ //# sourceMappingURL=topo-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topo-history.js","sourceRoot":"","sources":["../../../src/trails/topo-history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,cAAc,EAAE;IACpD,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACpB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,GAAG,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAC1D,OAAO,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IACrE,CAAC;IACD,WAAW,EAAE,+DAA+D;IAC5E,QAAQ,EAAE;QACR;YACE,KAAK,EAAE,oBAAoB,CAAC,cAAc,CAAC;YAC3C,IAAI,EAAE,mBAAmB;SAC1B;KACF;IACD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,KAAK,EAAE,CAAC;aACL,MAAM,EAAE;aACR,OAAO,CAAC,0BAA0B,CAAC;aACnC,QAAQ,CAAC,uCAAuC,CAAC;QACpD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;KACpE,CAAC;IACF,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;QAClB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;QACjB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;QACpB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QACrB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC;KAC/B,CAAC;CACH,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ export declare const topoPinTrail: import("@ontrails/core").Trail<{
2
+ module: string;
3
+ name: string;
4
+ rootDir?: string | undefined;
5
+ }, {
6
+ pin: {
7
+ createdAt: string;
8
+ name: string;
9
+ saveId: string;
10
+ };
11
+ save: {
12
+ createdAt: string;
13
+ gitDirty: boolean;
14
+ id: string;
15
+ provisionCount: number;
16
+ signalCount: number;
17
+ trailCount: number;
18
+ gitSha?: string | undefined;
19
+ };
20
+ }>;
21
+ //# sourceMappingURL=topo-pin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topo-pin.d.ts","sourceRoot":"","sources":["../../../src/trails/topo-pin.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;EA6BvB,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { Result, trail } from '@ontrails/core';
2
+ import { z } from 'zod';
3
+ import { loadApp } from './load-app.js';
4
+ import { DEFAULT_APP_MODULE, isolatedExampleInput, pinCurrentTopo, topoPinOutput, topoSaveOutput, } from './topo-support.js';
5
+ export const topoPinTrail = trail('topo.pin', {
6
+ blaze: async (input, ctx) => {
7
+ const rootDir = input.rootDir ?? ctx.cwd ?? process.cwd();
8
+ const app = await loadApp(input.module, rootDir);
9
+ return Result.ok(pinCurrentTopo(app, { name: input.name, rootDir }));
10
+ },
11
+ description: 'Pin the current topo under a durable name',
12
+ examples: [
13
+ {
14
+ input: {
15
+ ...isolatedExampleInput('topo-pin'),
16
+ name: 'before-auth-refactor',
17
+ },
18
+ name: 'Pin the current topo',
19
+ },
20
+ ],
21
+ input: z.object({
22
+ module: z
23
+ .string()
24
+ .default(DEFAULT_APP_MODULE)
25
+ .describe('Path to the app module'),
26
+ name: z.string().describe('Pin name'),
27
+ rootDir: z.string().optional().describe('Workspace root directory'),
28
+ }),
29
+ intent: 'write',
30
+ output: z.object({
31
+ pin: topoPinOutput,
32
+ save: topoSaveOutput,
33
+ }),
34
+ });
35
+ //# sourceMappingURL=topo-pin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topo-pin.js","sourceRoot":"","sources":["../../../src/trails/topo-pin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC,UAAU,EAAE;IAC5C,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,GAAG,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAC1D,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjD,OAAO,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IACvE,CAAC;IACD,WAAW,EAAE,2CAA2C;IACxD,QAAQ,EAAE;QACR;YACE,KAAK,EAAE;gBACL,GAAG,oBAAoB,CAAC,UAAU,CAAC;gBACnC,IAAI,EAAE,sBAAsB;aAC7B;YACD,IAAI,EAAE,sBAAsB;SAC7B;KACF;IACD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,MAAM,EAAE,CAAC;aACN,MAAM,EAAE;aACR,OAAO,CAAC,kBAAkB,CAAC;aAC3B,QAAQ,CAAC,wBAAwB,CAAC;QACrC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC;QACrC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;KACpE,CAAC;IACF,MAAM,EAAE,OAAO;IACf,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,GAAG,EAAE,aAAa;QAClB,IAAI,EAAE,cAAc;KACrB,CAAC;CACH,CAAC,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Read-only topo store consumer helpers.
3
+ *
4
+ * Extracted from topo-support.ts so this branch (trl-132) owns its own file,
5
+ * keeping absorb routing clean across the stack.
6
+ */
7
+ import type { Topo } from '@ontrails/core';
8
+ import { Result } from '@ontrails/core';
9
+ import type { BriefReport, SurveyListReport } from './topo-reports.js';
10
+ import type { TopoSummaryReport, TopoVerifyReport } from './topo-support.js';
11
+ interface CurrentTrailDetail {
12
+ readonly crosses: string[];
13
+ readonly description: string | null;
14
+ readonly detours: Readonly<Record<string, readonly string[]>> | null;
15
+ readonly examples: unknown[];
16
+ readonly id: string;
17
+ readonly intent: 'destroy' | 'read' | 'write';
18
+ readonly kind: string;
19
+ readonly provisions: string[];
20
+ readonly safety: string;
21
+ }
22
+ interface CurrentProvisionDetail {
23
+ readonly description: string | null;
24
+ readonly health: 'available' | 'none';
25
+ readonly id: string;
26
+ readonly kind: 'provision';
27
+ readonly lifetime: 'singleton';
28
+ readonly usedBy: string[];
29
+ }
30
+ export declare const buildTopoSummary: (app: Topo, options?: {
31
+ readonly rootDir?: string;
32
+ }) => TopoSummaryReport;
33
+ export declare const buildCurrentTopoBrief: (app: Topo, options?: {
34
+ readonly rootDir?: string;
35
+ }) => BriefReport;
36
+ export declare const buildCurrentTopoList: (app: Topo, options?: {
37
+ readonly rootDir?: string;
38
+ }) => SurveyListReport;
39
+ export declare const buildCurrentGuideEntries: (app: Topo, options?: {
40
+ readonly rootDir?: string;
41
+ }) => readonly {
42
+ readonly description: string;
43
+ readonly exampleCount: number;
44
+ readonly id: string;
45
+ readonly kind: string;
46
+ }[];
47
+ export declare const buildCurrentTopoDetail: (app: Topo, id: string, options?: {
48
+ readonly rootDir?: string;
49
+ }) => CurrentProvisionDetail | CurrentTrailDetail | undefined;
50
+ export declare const verifyCurrentTopo: (app: Topo, options?: {
51
+ readonly rootDir?: string;
52
+ }) => Promise<Result<TopoVerifyReport, Error>>;
53
+ export {};
54
+ //# sourceMappingURL=topo-read-support.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topo-read-support.d.ts","sourceRoot":"","sources":["../../../src/trails/topo-read-support.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAKL,MAAM,EACP,MAAM,gBAAgB,CAAC;AAUxB,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAiB7E,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,OAAO,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AM,wBAAwB,GACnC,KAAK,IAAI,EACT,UAAU;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,KACtC,SAAS;IACV,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,EAUA,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,KAAK,IAAI,EACT,IAAI,MAAM,EACV,UAAU;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,KACtC,sBAAsB,GAAG,kBAAkB,GAAG,SAahD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,KAAK,IAAI,EACT,UAAU;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,KACtC,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAwCzC,CAAC"}
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Read-only topo store consumer helpers.
3
+ *
4
+ * Extracted from topo-support.ts so this branch (trl-132) owns its own file,
5
+ * keeping absorb routing clean across the stack.
6
+ */
7
+ import { existsSync } from 'node:fs';
8
+ import { join } from 'node:path';
9
+ import { ConflictError, createTopoStore, InternalError, NotFoundError, Result, } from '@ontrails/core';
10
+ import { listTopoSaves } from '@ontrails/core/internal/topo-saves';
11
+ import { openReadTrailsDb, resolveTrailsDbPath, resolveTrailsDir, } from '@ontrails/core/internal/trails-db';
12
+ import { readTrailheadLockData } from '@ontrails/schema';
13
+ import { REPORT_CONTRACT_VERSION, REPORT_VERSION } from './topo-constants.js';
14
+ import { createCurrentTopoSave, LOCK_PATH, resolveRootDir, } from './topo-support.js';
15
+ // ---------------------------------------------------------------------------
16
+ // Store helpers
17
+ // ---------------------------------------------------------------------------
18
+ const topoStoreRef = (saveId) => ({ saveId });
19
+ const hasCommittedLock = (trailsDir) => existsSync(join(trailsDir, 'trails.lock')) ||
20
+ existsSync(join(trailsDir, 'trailhead.lock'));
21
+ const readTrailheadEntries = (trailheadMapJson) => JSON.parse(trailheadMapJson).entries;
22
+ const buildBriefReportFromStore = (app, store, ref, save) => {
23
+ const trails = store.trails.list({ save: ref });
24
+ const exportRecord = store.exports.get(ref);
25
+ const trailEntries = exportRecord === undefined
26
+ ? []
27
+ : readTrailheadEntries(exportRecord.trailheadMapJson).filter((entry) => entry.kind === 'trail');
28
+ return {
29
+ contractVersion: REPORT_CONTRACT_VERSION,
30
+ features: {
31
+ detours: trailEntries.some((entry) => (Object.keys(entry.detours ?? {}).length ?? 0) > 0),
32
+ examples: trails.some((trail) => trail.hasExamples),
33
+ outputSchemas: trails.some((trail) => trail.hasOutput),
34
+ provisions: save.provisionCount > 0,
35
+ signals: save.signalCount > 0,
36
+ },
37
+ name: app.name,
38
+ provisions: save.provisionCount,
39
+ signals: save.signalCount,
40
+ trails: save.trailCount,
41
+ version: REPORT_VERSION,
42
+ };
43
+ };
44
+ const buildSurveyListFromStore = (store, ref) => {
45
+ const trails = store.trails.list({ save: ref });
46
+ const provisions = store.provisions.list({ save: ref });
47
+ return {
48
+ count: trails.length,
49
+ entries: trails.map((trail) => ({
50
+ examples: trail.exampleCount,
51
+ id: trail.id,
52
+ kind: trail.kind,
53
+ safety: trail.safety,
54
+ })),
55
+ provisionCount: provisions.length,
56
+ provisions: provisions.map((provision) => ({
57
+ description: provision.description,
58
+ health: provision.health,
59
+ id: provision.id,
60
+ kind: provision.kind,
61
+ lifetime: provision.lifetime,
62
+ usedBy: provision.usedBy,
63
+ })),
64
+ };
65
+ };
66
+ const buildTrailDetailFromStore = (detail) => ({
67
+ crosses: [...(detail?.crosses ?? [])],
68
+ description: detail?.description ?? null,
69
+ detours: detail?.detours ?? null,
70
+ examples: [...(detail?.examples ?? [])],
71
+ id: detail?.id ?? '',
72
+ intent: detail?.intent ?? 'write',
73
+ kind: detail?.kind ?? 'trail',
74
+ provisions: [...(detail?.provisions ?? [])],
75
+ safety: detail?.safety ?? '-',
76
+ });
77
+ const buildProvisionDetailFromStore = (provision) => ({
78
+ description: provision.description,
79
+ health: provision.health,
80
+ id: provision.id,
81
+ kind: provision.kind,
82
+ lifetime: provision.lifetime,
83
+ usedBy: [...provision.usedBy],
84
+ });
85
+ // ---------------------------------------------------------------------------
86
+ // withCurrentTopoStore
87
+ // ---------------------------------------------------------------------------
88
+ /**
89
+ * Run a read callback against the latest topo store state.
90
+ *
91
+ * Uses the most recent existing save when available, only creating a new save
92
+ * when no prior save exists. This avoids unbounded save accumulation from
93
+ * read-only operations like survey, guide, and show.
94
+ */
95
+ const withCurrentTopoStore = (app, rootDir, read) => {
96
+ const dbPath = resolveTrailsDbPath({ rootDir });
97
+ const existingSave = existsSync(dbPath)
98
+ ? (() => {
99
+ const db = openReadTrailsDb({ rootDir });
100
+ try {
101
+ return listTopoSaves(db)[0];
102
+ }
103
+ finally {
104
+ db.close();
105
+ }
106
+ })()
107
+ : undefined;
108
+ const save = existingSave ?? createCurrentTopoSave(app, { rootDir });
109
+ const store = createTopoStore({ rootDir });
110
+ return read(store, topoStoreRef(save.id), save);
111
+ };
112
+ // ---------------------------------------------------------------------------
113
+ // Public read-only consumers
114
+ // ---------------------------------------------------------------------------
115
+ export const buildTopoSummary = (app, options) => {
116
+ const rootDir = resolveRootDir(options?.rootDir);
117
+ const trailsDir = resolveTrailsDir({ rootDir });
118
+ return withCurrentTopoStore(app, rootDir, (store, ref, save) => ({
119
+ app: buildBriefReportFromStore(app, store, ref, save),
120
+ dbPath: resolveTrailsDbPath({ rootDir }),
121
+ list: buildSurveyListFromStore(store, ref),
122
+ lockExists: hasCommittedLock(trailsDir),
123
+ lockPath: LOCK_PATH,
124
+ }));
125
+ };
126
+ export const buildCurrentTopoBrief = (app, options) => {
127
+ const rootDir = resolveRootDir(options?.rootDir);
128
+ return withCurrentTopoStore(app, rootDir, (store, ref, save) => buildBriefReportFromStore(app, store, ref, save));
129
+ };
130
+ export const buildCurrentTopoList = (app, options) => {
131
+ const rootDir = resolveRootDir(options?.rootDir);
132
+ return withCurrentTopoStore(app, rootDir, (store, ref) => buildSurveyListFromStore(store, ref));
133
+ };
134
+ export const buildCurrentGuideEntries = (app, options) => {
135
+ const rootDir = resolveRootDir(options?.rootDir);
136
+ return withCurrentTopoStore(app, rootDir, (store, ref) => store.trails.list({ save: ref }).map((trail) => ({
137
+ description: trail.description ?? '(no description)',
138
+ exampleCount: trail.exampleCount,
139
+ id: trail.id,
140
+ kind: trail.kind,
141
+ })));
142
+ };
143
+ export const buildCurrentTopoDetail = (app, id, options) => {
144
+ const rootDir = resolveRootDir(options?.rootDir);
145
+ return withCurrentTopoStore(app, rootDir, (store, ref) => {
146
+ const trail = store.trails.get(id, { save: ref });
147
+ if (trail !== undefined) {
148
+ return buildTrailDetailFromStore(trail);
149
+ }
150
+ const provision = store.provisions.get(id, { save: ref });
151
+ return provision === undefined
152
+ ? undefined
153
+ : buildProvisionDetailFromStore(provision);
154
+ });
155
+ };
156
+ export const verifyCurrentTopo = async (app, options) => {
157
+ const rootDir = resolveRootDir(options?.rootDir);
158
+ const committedLock = await readTrailheadLockData({
159
+ dir: resolveTrailsDir({ rootDir }),
160
+ });
161
+ if (committedLock === null) {
162
+ return Result.err(new NotFoundError('No committed trails.lock found. Run `trails topo export` first.'));
163
+ }
164
+ const currentHash = withCurrentTopoStore(app, rootDir, (store, ref) => store.exports.get(ref)?.trailheadHash);
165
+ if (currentHash === undefined) {
166
+ return Result.err(new InternalError('No stored topo export found for the current topo save'));
167
+ }
168
+ if (committedLock.hash !== currentHash) {
169
+ return Result.err(new ConflictError('trails.lock is stale. Run `trails topo export` to refresh it.'));
170
+ }
171
+ return Result.ok({
172
+ committedHash: committedLock.hash,
173
+ currentHash,
174
+ lockPath: LOCK_PATH,
175
+ stale: false,
176
+ });
177
+ };
178
+ //# sourceMappingURL=topo-read-support.js.map
@@ -0,0 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+ import type { Topo, Trail } from '@ontrails/core';
2
+ export interface BriefReport {
3
+ readonly name: string;
4
+ readonly version: string;
5
+ readonly contractVersion: string;
6
+ readonly features: {
7
+ readonly provisions: boolean;
8
+ readonly outputSchemas: boolean;
9
+ readonly examples: boolean;
10
+ readonly detours: boolean;
11
+ readonly signals: boolean;
12
+ };
13
+ readonly trails: number;
14
+ readonly signals: number;
15
+ readonly provisions: number;
16
+ }
17
+ export interface SurveyListReport {
18
+ readonly count: number;
19
+ readonly entries: readonly {
20
+ readonly examples: number;
21
+ readonly id: string;
22
+ readonly kind: string;
23
+ readonly safety: string;
24
+ }[];
25
+ readonly provisionCount: number;
26
+ readonly provisions: readonly {
27
+ readonly description: string | null;
28
+ readonly health: 'available' | 'none';
29
+ readonly id: string;
30
+ readonly kind: 'provision';
31
+ readonly lifetime: 'singleton';
32
+ readonly usedBy: readonly string[];
33
+ }[];
34
+ }
35
+ export interface TrailDetailReport {
36
+ readonly description: string | null;
37
+ readonly detours: Trail<unknown, unknown>['detours'] | null;
38
+ readonly examples: readonly unknown[];
39
+ readonly crosses: readonly string[];
40
+ readonly id: string;
41
+ readonly intent: 'read' | 'write' | 'destroy';
42
+ readonly kind: string;
43
+ readonly safety: string;
44
+ readonly provisions: readonly string[];
45
+ }
46
+ export declare const generateBriefReport: (app: Topo) => BriefReport;
47
+ export declare const formatProvisionDetail: (app: Topo, provisionId: string) => object;
48
+ export declare const generateSurveyList: (app: Topo) => SurveyListReport;
49
+ export declare const generateTrailDetail: (item: Trail<unknown, unknown>) => TrailDetailReport;
50
+ //# sourceMappingURL=topo-reports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topo-reports.d.ts","sourceRoot":"","sources":["../../../src/trails/topo-reports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAIlD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;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,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IAC5D,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAgCD,eAAO,MAAM,mBAAmB,GAAI,KAAK,IAAI,KAAG,WAmB/C,CAAC;AAwCF,eAAO,MAAM,qBAAqB,GAChC,KAAK,IAAI,EACT,aAAa,MAAM,KAClB,MAYF,CAAC;AAiBF,eAAO,MAAM,kBAAkB,GAAI,KAAK,IAAI,KAAG,gBA4B9C,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,MAAM,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,KAC5B,iBAgBF,CAAC"}
@@ -0,0 +1,122 @@
1
+ import { REPORT_CONTRACT_VERSION, REPORT_VERSION } from './topo-constants.js';
2
+ const trailHas = (raw, key) => {
3
+ if (key === 'examples') {
4
+ return Array.isArray(raw[key]) && raw[key].length > 0;
5
+ }
6
+ return Boolean(raw[key]);
7
+ };
8
+ const detectFeatures = (app) => {
9
+ const trails = [...app.trails.values()].map((item) => item);
10
+ return {
11
+ hasDetours: trails.some((r) => trailHas(r, 'detours')),
12
+ hasExamples: trails.some((r) => trailHas(r, 'examples')),
13
+ hasOutputSchemas: trails.some((r) => trailHas(r, 'output')),
14
+ hasProvisions: trails.some((r) => Array.isArray(r['provisions']) &&
15
+ r['provisions'].length > 0),
16
+ };
17
+ };
18
+ export const generateBriefReport = (app) => {
19
+ const { hasDetours, hasExamples, hasOutputSchemas, hasProvisions } = detectFeatures(app);
20
+ return {
21
+ contractVersion: REPORT_CONTRACT_VERSION,
22
+ features: {
23
+ detours: hasDetours,
24
+ examples: hasExamples,
25
+ outputSchemas: hasOutputSchemas,
26
+ provisions: hasProvisions,
27
+ signals: app.signals.size > 0,
28
+ },
29
+ name: app.name,
30
+ provisions: app.provisions.size,
31
+ signals: app.signals.size,
32
+ trails: app.trails.size,
33
+ version: REPORT_VERSION,
34
+ };
35
+ };
36
+ const safetyLabel = (entry) => {
37
+ if (entry.intent === 'destroy') {
38
+ return 'destroy';
39
+ }
40
+ if (entry.intent === 'write') {
41
+ return 'write';
42
+ }
43
+ if (entry.intent === 'read') {
44
+ return 'read';
45
+ }
46
+ return '-';
47
+ };
48
+ const buildProvisionUsage = (app) => {
49
+ const usage = new Map();
50
+ for (const trailDef of app.list()) {
51
+ for (const declaredProvision of trailDef.provisions) {
52
+ const users = usage.get(declaredProvision.id) ?? [];
53
+ users.push(trailDef.id);
54
+ usage.set(declaredProvision.id, users);
55
+ }
56
+ }
57
+ return new Map([...usage.entries()].map(([id, users]) => [id, users.toSorted()]));
58
+ };
59
+ const provisionHealthStatus = (provision) => provision.health === undefined ? 'none' : 'available';
60
+ export const formatProvisionDetail = (app, provisionId) => {
61
+ const item = app.getProvision(provisionId);
62
+ const usedBy = buildProvisionUsage(app).get(provisionId) ?? [];
63
+ return {
64
+ description: item?.description ?? null,
65
+ health: item ? provisionHealthStatus(item) : 'none',
66
+ id: provisionId,
67
+ kind: 'provision',
68
+ lifetime: 'singleton',
69
+ usedBy,
70
+ };
71
+ };
72
+ const formatProvisionList = (app) => {
73
+ const usage = buildProvisionUsage(app);
74
+ return app
75
+ .listProvisions()
76
+ .map((provision) => ({
77
+ description: provision.description ?? null,
78
+ health: provisionHealthStatus(provision),
79
+ id: provision.id,
80
+ kind: provision.kind,
81
+ lifetime: 'singleton',
82
+ usedBy: usage.get(provision.id) ?? [],
83
+ }))
84
+ .toSorted((a, b) => a.id.localeCompare(b.id));
85
+ };
86
+ export const generateSurveyList = (app) => {
87
+ const items = app.list();
88
+ const entries = items.map((item) => {
89
+ const safety = safetyLabel(item);
90
+ const examples = Array.isArray(item.examples)
91
+ ? item.examples.length
92
+ : 0;
93
+ return {
94
+ examples,
95
+ id: item.id,
96
+ kind: item.kind,
97
+ safety,
98
+ };
99
+ });
100
+ const provisions = formatProvisionList(app);
101
+ return {
102
+ count: items.length,
103
+ entries,
104
+ provisionCount: provisions.length,
105
+ provisions,
106
+ };
107
+ };
108
+ export const generateTrailDetail = (item) => {
109
+ const safety = safetyLabel(item);
110
+ return {
111
+ crosses: item.crosses.toSorted(),
112
+ description: item.description ?? null,
113
+ detours: item.detours ?? null,
114
+ examples: item.examples ?? [],
115
+ id: item.id,
116
+ intent: item.intent,
117
+ kind: item.kind,
118
+ provisions: item.provisions.map((provision) => provision.id).toSorted(),
119
+ safety,
120
+ };
121
+ };
122
+ //# sourceMappingURL=topo-reports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topo-reports.js","sourceRoot":"","sources":["../../../src/trails/topo-reports.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAiD9E,MAAM,QAAQ,GAAG,CAAC,GAA4B,EAAE,GAAW,EAAW,EAAE;IACtE,IAAI,GAAG,KAAK,UAAU,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAK,GAAG,CAAC,GAAG,CAAe,CAAC,MAAM,GAAG,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CACrB,GAAS,EAMT,EAAE;IACF,MAAM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AC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;QACvE,MAAM;KACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ export declare const topoShowTrail: import("@ontrails/core").Trail<{
2
+ id: string;
3
+ module: string;
4
+ rootDir?: string | undefined;
5
+ }, {
6
+ crosses: string[];
7
+ description: unknown;
8
+ detours: unknown;
9
+ examples: unknown[];
10
+ id: string;
11
+ intent: "read" | "write" | "destroy";
12
+ kind: string;
13
+ provisions: string[];
14
+ safety: string;
15
+ } | {
16
+ description: string | null;
17
+ health: "available" | "none";
18
+ id: string;
19
+ kind: "provision";
20
+ lifetime: "singleton";
21
+ usedBy: string[];
22
+ }>;
23
+ //# sourceMappingURL=topo-show.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topo-show.d.ts","sourceRoot":"","sources":["../../../src/trails/topo-show.ts"],"names":[],"mappings":"AA4BA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;EA6BxB,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { NotFoundError, Result, trail } from '@ontrails/core';
2
+ import { z } from 'zod';
3
+ import { loadApp } from './load-app.js';
4
+ import { buildCurrentTopoDetail } from './topo-read-support.js';
5
+ import { DEFAULT_APP_MODULE } from './topo-support.js';
6
+ const trailDetailOutput = z.object({
7
+ crosses: z.array(z.string()),
8
+ description: z.unknown().nullable(),
9
+ detours: z.unknown().nullable(),
10
+ examples: z.array(z.unknown()),
11
+ id: z.string(),
12
+ intent: z.enum(['read', 'write', 'destroy']),
13
+ kind: z.string(),
14
+ provisions: z.array(z.string()),
15
+ safety: z.string(),
16
+ });
17
+ const provisionDetailOutput = z.object({
18
+ description: z.string().nullable(),
19
+ health: z.enum(['available', 'none']),
20
+ id: z.string(),
21
+ kind: z.literal('provision'),
22
+ lifetime: z.literal('singleton'),
23
+ usedBy: z.array(z.string()),
24
+ });
25
+ export const topoShowTrail = trail('topo.show', {
26
+ blaze: async (input, ctx) => {
27
+ const rootDir = input.rootDir ?? ctx.cwd ?? process.cwd();
28
+ const app = await loadApp(input.module, rootDir);
29
+ const detail = buildCurrentTopoDetail(app, input.id, { rootDir });
30
+ if (detail !== undefined) {
31
+ return Result.ok(detail);
32
+ }
33
+ return Result.err(new NotFoundError(`Trail or provision not found: ${input.id}`));
34
+ },
35
+ description: 'Show detail for a current trail or provision',
36
+ examples: [
37
+ {
38
+ input: { id: 'topo' },
39
+ name: 'Show current trail detail',
40
+ },
41
+ ],
42
+ input: z.object({
43
+ id: z.string().describe('Trail or provision ID to inspect'),
44
+ module: z
45
+ .string()
46
+ .default(DEFAULT_APP_MODULE)
47
+ .describe('Path to the app module'),
48
+ rootDir: z.string().optional().describe('Workspace root directory'),
49
+ }),
50
+ intent: 'read',
51
+ output: z.union([trailDetailOutput, provisionDetailOutput]),
52
+ });
53
+ //# sourceMappingURL=topo-show.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topo-show.js","sourceRoot":"","sources":["../../../src/trails/topo-show.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC5B,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACnC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC/B,QAAQ,EAAE,CAAC,CAA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EAAE,CAAC;YACzB,OAAO,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,MAAM,CAAC,GAAG,CACf,IAAI,aAAa,CAAC,iCAAiC,KAAK,CAAC,EAAE,EAAE,CAAC,CAC/D,CAAC;IACJ,CAAC;IACD,WAAW,EAAE,8CAA8C;IAC3D,QAAQ,EAAE;QACR;YACE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;YACrB,IAAI,EAAE,2BAA2B;SAClC;KACF;IACD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;QAC3D,MAAM,EAAE,CAAC;aACN,MAAM,EAAE;aACR,OAAO,CAAC,kBAAkB,CAAC;aAC3B,QAAQ,CAAC,wBAAwB,CAAC;QACrC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;KACpE,CAAC;IACF,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;CAC5D,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Stored-export pipeline for topo persistence.
3
+ *
4
+ * Extracted from topo-support.ts so this branch (trl-131) owns its own file,
5
+ * keeping absorb routing clean across the stack.
6
+ */
7
+ import type { Topo } from '@ontrails/core';
8
+ import { Result } from '@ontrails/core';
9
+ import type { TopoExportReport } from './topo-support.js';
10
+ export declare const exportCurrentTopo: (app: Topo, options?: {
11
+ readonly rootDir?: string;
12
+ }) => Promise<Result<TopoExportReport, Error>>;
13
+ //# sourceMappingURL=topo-store-support.d.ts.map