@ontrails/trails 1.0.0-beta.3 → 1.0.0-beta.32

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 (158) hide show
  1. package/CHANGELOG.md +975 -0
  2. package/README.md +27 -0
  3. package/package.json +30 -7
  4. package/src/app.ts +125 -2
  5. package/src/cli.ts +345 -11
  6. package/src/completions.ts +240 -0
  7. package/src/lifecycle-source-io.ts +33 -0
  8. package/src/load-app-mirror.ts +202 -0
  9. package/src/local-state-io.ts +173 -0
  10. package/src/mcp-app.ts +40 -0
  11. package/src/mcp-options.ts +77 -0
  12. package/src/mcp.ts +8 -0
  13. package/src/project-writes.ts +377 -0
  14. package/src/regrade/config.ts +152 -0
  15. package/src/release/bindings.ts +39 -0
  16. package/src/release/check.ts +844 -0
  17. package/src/release/config.ts +63 -0
  18. package/src/release/contract-facts.ts +425 -0
  19. package/src/release/index.ts +125 -0
  20. package/src/release/native-bun-publish.ts +651 -0
  21. package/src/release/native-bun-registry.ts +754 -0
  22. package/src/release/pack-coherence.ts +455 -0
  23. package/src/release/packed-artifacts-smoke.ts +236 -0
  24. package/src/release/policy.ts +1684 -0
  25. package/src/release/semver.ts +104 -0
  26. package/src/release/smoke.ts +46 -0
  27. package/src/release/wayfinder-dogfood-smoke.ts +760 -0
  28. package/src/retired-topo-command.ts +36 -0
  29. package/src/run-adapter-check.ts +76 -0
  30. package/src/run-collision.ts +126 -0
  31. package/src/run-completions-install.ts +179 -0
  32. package/src/run-example.ts +149 -0
  33. package/src/run-examples.ts +148 -0
  34. package/src/run-quiet.ts +75 -0
  35. package/src/run-release-check.ts +74 -0
  36. package/src/run-schema.ts +41 -0
  37. package/src/run-trace.ts +273 -0
  38. package/src/run-warden.ts +39 -0
  39. package/src/run-watch.ts +432 -0
  40. package/src/run-wayfind-outline.ts +166 -0
  41. package/src/scaffold-version-sync.ts +183 -0
  42. package/src/scaffold-versions.generated.ts +12 -0
  43. package/src/trails/adapter-check.ts +244 -0
  44. package/src/trails/add-surface.ts +94 -40
  45. package/src/trails/add-trail.ts +79 -41
  46. package/src/trails/add-verify.ts +95 -25
  47. package/src/trails/compile.ts +59 -0
  48. package/src/trails/completions-complete.ts +165 -0
  49. package/src/trails/completions.ts +47 -0
  50. package/src/trails/create-adapter.ts +1024 -0
  51. package/src/trails/create-scaffold.ts +399 -104
  52. package/src/trails/create-versions.ts +62 -0
  53. package/src/trails/create.ts +186 -72
  54. package/src/trails/deprecate.ts +59 -0
  55. package/src/trails/dev-clean.ts +82 -0
  56. package/src/trails/dev-reset.ts +50 -0
  57. package/src/trails/dev-stats.ts +72 -0
  58. package/src/trails/dev-support.ts +360 -0
  59. package/src/trails/doctor.ts +77 -0
  60. package/src/trails/draft-promote.ts +949 -0
  61. package/src/trails/guide.ts +71 -69
  62. package/src/trails/load-app.ts +1142 -16
  63. package/src/trails/operator-context.ts +66 -0
  64. package/src/trails/project.ts +17 -3
  65. package/src/trails/regrade.ts +292 -0
  66. package/src/trails/release-check.ts +105 -0
  67. package/src/trails/release-smoke.ts +48 -0
  68. package/src/trails/revise.ts +53 -0
  69. package/src/trails/root-dir.ts +21 -0
  70. package/src/trails/run-example.ts +475 -0
  71. package/src/trails/run-examples.ts +129 -0
  72. package/src/trails/run.ts +434 -0
  73. package/src/trails/scaffold-json.ts +58 -0
  74. package/src/trails/survey.ts +896 -227
  75. package/src/trails/topo-activation.ts +14 -0
  76. package/src/trails/topo-constants.ts +2 -0
  77. package/src/trails/topo-history.ts +47 -0
  78. package/src/trails/topo-output-schemas.ts +259 -0
  79. package/src/trails/topo-pin.ts +38 -0
  80. package/src/trails/topo-read-support.ts +363 -0
  81. package/src/trails/topo-reports.ts +809 -0
  82. package/src/trails/topo-store-support.ts +307 -0
  83. package/src/trails/topo-support.ts +219 -0
  84. package/src/trails/topo-unpin.ts +61 -0
  85. package/src/trails/topo.ts +92 -0
  86. package/src/trails/validate.ts +27 -0
  87. package/src/trails/version-lifecycle-support.ts +935 -0
  88. package/src/trails/warden-guide.ts +134 -0
  89. package/src/trails/warden.ts +198 -58
  90. package/src/trails/wayfind.ts +1001 -0
  91. package/src/versions.ts +31 -0
  92. package/.turbo/turbo-build.log +0 -1
  93. package/.turbo/turbo-lint.log +0 -3
  94. package/.turbo/turbo-typecheck.log +0 -1
  95. package/__tests__/examples.test.ts +0 -6
  96. package/dist/bin/trails.d.ts +0 -3
  97. package/dist/bin/trails.d.ts.map +0 -1
  98. package/dist/bin/trails.js +0 -4
  99. package/dist/bin/trails.js.map +0 -1
  100. package/dist/src/app.d.ts +0 -2
  101. package/dist/src/app.d.ts.map +0 -1
  102. package/dist/src/app.js +0 -11
  103. package/dist/src/app.js.map +0 -1
  104. package/dist/src/clack.d.ts +0 -9
  105. package/dist/src/clack.d.ts.map +0 -1
  106. package/dist/src/clack.js +0 -84
  107. package/dist/src/clack.js.map +0 -1
  108. package/dist/src/cli.d.ts +0 -2
  109. package/dist/src/cli.d.ts.map +0 -1
  110. package/dist/src/cli.js +0 -13
  111. package/dist/src/cli.js.map +0 -1
  112. package/dist/src/trails/add-surface.d.ts +0 -13
  113. package/dist/src/trails/add-surface.d.ts.map +0 -1
  114. package/dist/src/trails/add-surface.js +0 -88
  115. package/dist/src/trails/add-surface.js.map +0 -1
  116. package/dist/src/trails/add-trail.d.ts +0 -11
  117. package/dist/src/trails/add-trail.d.ts.map +0 -1
  118. package/dist/src/trails/add-trail.js +0 -85
  119. package/dist/src/trails/add-trail.js.map +0 -1
  120. package/dist/src/trails/add-verify.d.ts +0 -10
  121. package/dist/src/trails/add-verify.d.ts.map +0 -1
  122. package/dist/src/trails/add-verify.js +0 -67
  123. package/dist/src/trails/add-verify.js.map +0 -1
  124. package/dist/src/trails/create-scaffold.d.ts +0 -15
  125. package/dist/src/trails/create-scaffold.d.ts.map +0 -1
  126. package/dist/src/trails/create-scaffold.js +0 -288
  127. package/dist/src/trails/create-scaffold.js.map +0 -1
  128. package/dist/src/trails/create.d.ts +0 -22
  129. package/dist/src/trails/create.d.ts.map +0 -1
  130. package/dist/src/trails/create.js +0 -121
  131. package/dist/src/trails/create.js.map +0 -1
  132. package/dist/src/trails/guide.d.ts +0 -11
  133. package/dist/src/trails/guide.d.ts.map +0 -1
  134. package/dist/src/trails/guide.js +0 -80
  135. package/dist/src/trails/guide.js.map +0 -1
  136. package/dist/src/trails/load-app.d.ts +0 -4
  137. package/dist/src/trails/load-app.d.ts.map +0 -1
  138. package/dist/src/trails/load-app.js +0 -24
  139. package/dist/src/trails/load-app.js.map +0 -1
  140. package/dist/src/trails/project.d.ts +0 -8
  141. package/dist/src/trails/project.d.ts.map +0 -1
  142. package/dist/src/trails/project.js +0 -43
  143. package/dist/src/trails/project.js.map +0 -1
  144. package/dist/src/trails/survey.d.ts +0 -33
  145. package/dist/src/trails/survey.d.ts.map +0 -1
  146. package/dist/src/trails/survey.js +0 -225
  147. package/dist/src/trails/survey.js.map +0 -1
  148. package/dist/src/trails/warden.d.ts +0 -19
  149. package/dist/src/trails/warden.d.ts.map +0 -1
  150. package/dist/src/trails/warden.js +0 -88
  151. package/dist/src/trails/warden.js.map +0 -1
  152. package/dist/tsconfig.tsbuildinfo +0 -1
  153. package/src/__tests__/create.test.ts +0 -349
  154. package/src/__tests__/guide.test.ts +0 -91
  155. package/src/__tests__/load-app.test.ts +0 -15
  156. package/src/__tests__/survey.test.ts +0 -161
  157. package/src/__tests__/warden.test.ts +0 -74
  158. package/tsconfig.json +0 -9
@@ -0,0 +1,14 @@
1
+ export {
2
+ deriveActivationGraph,
3
+ deriveDeclaredTrailActivation,
4
+ deriveSignalActivationRelations,
5
+ } from '@ontrails/topographer';
6
+ export type {
7
+ ActivationChainReport,
8
+ ActivationEdgeReport,
9
+ ActivationGraphReport,
10
+ ActivationOverviewReport,
11
+ ActivationSourceReport,
12
+ SignalActivationRelations,
13
+ TrailActivationReport,
14
+ } from '@ontrails/topographer';
@@ -0,0 +1,2 @@
1
+ export const REPORT_CONTRACT_VERSION = '2026-03';
2
+ export const REPORT_VERSION = '0.1.0';
@@ -0,0 +1,47 @@
1
+ import { Result, trail } from '@ontrails/core';
2
+ import { z } from 'zod';
3
+
4
+ import {
5
+ DEFAULT_TOPO_HISTORY_LIMIT,
6
+ createIsolatedExampleInput,
7
+ listTopoHistory,
8
+ topoSnapshotOutput,
9
+ } from './topo-support.js';
10
+ import { resolveTrailRootDir } from './root-dir.js';
11
+
12
+ const topoHistoryTrailInputSchema = z.object({
13
+ limit: z
14
+ .number()
15
+ .default(DEFAULT_TOPO_HISTORY_LIMIT)
16
+ .describe('Maximum number of snapshots to return'),
17
+ rootDir: z.string().optional().describe('Workspace root directory'),
18
+ });
19
+
20
+ type TopoHistoryTrailInput = z.output<typeof topoHistoryTrailInputSchema>;
21
+
22
+ export const topoHistoryTrail = trail('topo.history', {
23
+ blaze: (input: TopoHistoryTrailInput, ctx) => {
24
+ const rootDirResult = resolveTrailRootDir(input.rootDir, ctx.cwd);
25
+ if (rootDirResult.isErr()) {
26
+ return rootDirResult;
27
+ }
28
+ const rootDir = rootDirResult.value;
29
+ return Result.ok(listTopoHistory({ limit: input.limit, rootDir }));
30
+ },
31
+ description: 'List saved topo snapshots, including pinned references',
32
+ examples: [
33
+ {
34
+ input: createIsolatedExampleInput('topo-history'),
35
+ name: 'Show topo history',
36
+ },
37
+ ],
38
+ input: topoHistoryTrailInputSchema,
39
+ intent: 'read',
40
+ output: z.object({
41
+ dbPath: z.string(),
42
+ limit: z.number(),
43
+ pinnedCount: z.number(),
44
+ snapshotCount: z.number(),
45
+ snapshots: z.array(topoSnapshotOutput),
46
+ }),
47
+ });
@@ -0,0 +1,259 @@
1
+ import { z } from 'zod';
2
+
3
+ const jsonSchemaOutput = z.record(z.string(), z.unknown());
4
+
5
+ export const activationChainOutput = z.object({
6
+ consumer: z.string(),
7
+ producer: z.string(),
8
+ signal: z.string(),
9
+ });
10
+
11
+ export const activationSourceOutput = z
12
+ .object({
13
+ cron: z.string().optional(),
14
+ hasParse: z.literal(true).optional(),
15
+ hasPayloadSchema: z.literal(true).optional(),
16
+ hasVerify: z.literal(true).optional(),
17
+ id: z.string(),
18
+ input: z.unknown().optional(),
19
+ inputSchema: jsonSchemaOutput.optional(),
20
+ key: z.string(),
21
+ kind: z.string(),
22
+ meta: z.record(z.string(), z.unknown()).optional(),
23
+ method: z.string().optional(),
24
+ parseOutputSchema: jsonSchemaOutput.optional(),
25
+ path: z.string().optional(),
26
+ payloadSchema: jsonSchemaOutput.optional(),
27
+ timezone: z.string().optional(),
28
+ })
29
+ .catchall(z.unknown());
30
+
31
+ export const activationEdgeOutput = z
32
+ .object({
33
+ hasWhere: z.boolean(),
34
+ sourceId: z.string(),
35
+ sourceKey: z.string(),
36
+ sourceKind: z.string(),
37
+ trailId: z.string(),
38
+ where: z.object({ predicate: z.literal(true) }).optional(),
39
+ })
40
+ .catchall(z.unknown());
41
+
42
+ export const activationOverviewOutput = z.object({
43
+ chainCount: z.number(),
44
+ chains: z.array(activationChainOutput).readonly(),
45
+ edgeCount: z.number(),
46
+ edges: z.array(activationEdgeOutput).readonly(),
47
+ signalIds: z.array(z.string()).readonly(),
48
+ sourceCount: z.number(),
49
+ sourceKeys: z.array(z.string()).readonly(),
50
+ trailIds: z.array(z.string()).readonly(),
51
+ });
52
+
53
+ const topoGraphLayerOutput = z.object({
54
+ input: jsonSchemaOutput.optional(),
55
+ name: z.string(),
56
+ scope: z.enum(['topo', 'trail']),
57
+ });
58
+
59
+ const fieldOverrideOutput = z.object({
60
+ field: z.string(),
61
+ overrides: z
62
+ .array(z.enum(['hint', 'label', 'message', 'options']))
63
+ .readonly(),
64
+ provenance: z.object({
65
+ source: z.literal('trail.fields'),
66
+ }),
67
+ });
68
+
69
+ const contourDetailOutput = z.object({
70
+ description: z.string().optional(),
71
+ exampleCount: z.number(),
72
+ id: z.string(),
73
+ identity: z.string().optional(),
74
+ kind: z.literal('contour'),
75
+ references: z
76
+ .array(
77
+ z.object({
78
+ contour: z.string(),
79
+ field: z.string(),
80
+ identity: z.string(),
81
+ })
82
+ )
83
+ .readonly()
84
+ .optional(),
85
+ schema: jsonSchemaOutput.optional(),
86
+ surfaces: z.array(z.string()).readonly(),
87
+ });
88
+
89
+ const surfaceProjectionBaseOutput = {
90
+ derivedName: z.string(),
91
+ source: z.enum(['authored', 'default-derived']),
92
+ trailId: z.string(),
93
+ } as const;
94
+
95
+ export const surfaceProjectionOutput = z.discriminatedUnion('surface', [
96
+ z.object({
97
+ ...surfaceProjectionBaseOutput,
98
+ commandPath: z.array(z.string()).readonly(),
99
+ method: z.null(),
100
+ surface: z.literal('cli'),
101
+ }),
102
+ z.object({
103
+ ...surfaceProjectionBaseOutput,
104
+ method: z.null(),
105
+ surface: z.literal('mcp'),
106
+ toolName: z.string(),
107
+ }),
108
+ z.object({
109
+ ...surfaceProjectionBaseOutput,
110
+ method: z.string(),
111
+ path: z.string(),
112
+ surface: z.literal('http'),
113
+ }),
114
+ ]);
115
+
116
+ export const shippedSurfaceInventoryOutput = z.object({
117
+ count: z.number(),
118
+ excludedSurfaces: z
119
+ .array(
120
+ z.object({
121
+ reason: z.string(),
122
+ status: z.literal('planned'),
123
+ surface: z.literal('websocket'),
124
+ })
125
+ )
126
+ .readonly(),
127
+ projections: z.array(surfaceProjectionOutput).readonly(),
128
+ shippedSurfaces: z.array(z.enum(['cli', 'mcp', 'http'])).readonly(),
129
+ trails: z
130
+ .array(
131
+ z.object({
132
+ explicitSurfaces: z.array(z.string()).readonly(),
133
+ projections: z.array(surfaceProjectionOutput).readonly(),
134
+ trailId: z.string(),
135
+ })
136
+ )
137
+ .readonly(),
138
+ });
139
+
140
+ const trailVersionEntryOutput = z.object({
141
+ composes: z.array(z.string()).readonly().optional(),
142
+ detours: z
143
+ .array(
144
+ z.object({
145
+ maxAttempts: z.number(),
146
+ on: z.string(),
147
+ })
148
+ )
149
+ .readonly()
150
+ .optional(),
151
+ exampleCount: z.number(),
152
+ examples: z.array(z.unknown()).readonly().optional(),
153
+ input: jsonSchemaOutput,
154
+ kind: z.enum(['revision', 'fork']),
155
+ marker: z.string(),
156
+ output: jsonSchemaOutput,
157
+ resources: z.array(z.string()).readonly().optional(),
158
+ status: z
159
+ .object({
160
+ state: z.enum(['deprecated', 'archived']),
161
+ })
162
+ .catchall(z.unknown())
163
+ .optional(),
164
+ });
165
+
166
+ export const trailDetailOutput = z.object({
167
+ activatedBy: z.array(z.string()).readonly(),
168
+ activates: z.array(z.string()).readonly(),
169
+ activationChains: z.array(activationChainOutput).readonly(),
170
+ activationContext: z.object({
171
+ edgeCount: z.number(),
172
+ sourceCount: z.number(),
173
+ sourceKeys: z.array(z.string()).readonly(),
174
+ trailIds: z.array(z.string()).readonly(),
175
+ }),
176
+ activationEdges: z.array(activationEdgeOutput).readonly(),
177
+ activationSources: z.array(activationSourceOutput).readonly(),
178
+ cli: z
179
+ .object({
180
+ path: z.array(z.string()).readonly(),
181
+ routes: z
182
+ .array(
183
+ z.object({
184
+ kind: z.enum(['alias', 'canonical']),
185
+ path: z.array(z.string()).readonly(),
186
+ source: z.enum(['derived', 'surface', 'trail']),
187
+ target: z.string(),
188
+ })
189
+ )
190
+ .readonly()
191
+ .optional(),
192
+ })
193
+ .nullable(),
194
+ composedLayers: z.object({
195
+ surface: z.object({
196
+ cli: z.array(z.string()).readonly(),
197
+ http: z.array(z.string()).readonly(),
198
+ mcp: z.array(z.string()).readonly(),
199
+ }),
200
+ topo: z.array(z.string()).readonly(),
201
+ trail: z.array(z.string()).readonly(),
202
+ }),
203
+ composes: z.array(z.string()).readonly(),
204
+ contourDetails: z.array(contourDetailOutput).readonly(),
205
+ contours: z.array(z.string()).readonly(),
206
+ description: z.string().nullable(),
207
+ detours: z
208
+ .array(
209
+ z.object({
210
+ maxAttempts: z.number(),
211
+ on: z.string(),
212
+ })
213
+ )
214
+ .readonly()
215
+ .nullable(),
216
+ examples: z.array(z.unknown()).readonly(),
217
+ fieldOverrides: z.array(fieldOverrideOutput).readonly(),
218
+ fires: z.array(z.string()).readonly(),
219
+ governance: z.record(z.string(), z.unknown()).nullable(),
220
+ id: z.string(),
221
+ input: jsonSchemaOutput.nullable(),
222
+ intent: z.enum(['read', 'write', 'destroy']),
223
+ kind: z.literal('trail'),
224
+ layers: z.array(topoGraphLayerOutput).readonly(),
225
+ on: z.array(z.string()).readonly(),
226
+ output: jsonSchemaOutput.nullable(),
227
+ pattern: z.string().nullable(),
228
+ resources: z.array(z.string()).readonly(),
229
+ safety: z.string(),
230
+ supports: z.array(z.number()).readonly(),
231
+ surfaceProjections: z.array(surfaceProjectionOutput).readonly(),
232
+ surfaces: z.array(z.string()).readonly(),
233
+ version: z.number().nullable(),
234
+ versions: z.record(z.string(), trailVersionEntryOutput),
235
+ });
236
+
237
+ export const resourceDetailOutput = z.object({
238
+ description: z.string().nullable(),
239
+ health: z.enum(['available', 'none']),
240
+ id: z.string(),
241
+ kind: z.literal('resource'),
242
+ lifetime: z.literal('singleton'),
243
+ usedBy: z.array(z.string()).readonly(),
244
+ });
245
+
246
+ export const signalDetailOutput = z.object({
247
+ consumers: z.array(z.string()).readonly(),
248
+ description: z.string().nullable(),
249
+ examples: z.array(z.unknown()).readonly(),
250
+ from: z.array(z.string()).readonly(),
251
+ id: z.string(),
252
+ kind: z.literal('signal'),
253
+ // null when the surface-map entry is missing for this signal (e.g. partial
254
+ // import or schema migration). Coherent with the list view's
255
+ // `payloadSchema: false` flag — distinguishes "schema not found" from
256
+ // "schema accepts any value" (the latter would be `{}`).
257
+ payload: z.record(z.string(), z.unknown()).nullable(),
258
+ producers: z.array(z.string()).readonly(),
259
+ });
@@ -0,0 +1,38 @@
1
+ import { Result, trail } from '@ontrails/core';
2
+ import { z } from 'zod';
3
+
4
+ import { withFreshOperatorApp } from './operator-context.js';
5
+ import {
6
+ createIsolatedExampleInput,
7
+ pinCurrentTopoSnapshot,
8
+ topoSnapshotOutput,
9
+ } from './topo-support.js';
10
+
11
+ export const topoPinTrail = trail('topo.pin', {
12
+ blaze: async (input, ctx) =>
13
+ withFreshOperatorApp(input, ctx, ({ lease, rootDir }) =>
14
+ Result.ok(
15
+ pinCurrentTopoSnapshot(lease.app, { name: input.name, rootDir })
16
+ )
17
+ ),
18
+ description: 'Pin the current topo under a durable name',
19
+ examples: [
20
+ {
21
+ input: {
22
+ ...createIsolatedExampleInput('topo-pin'),
23
+ name: 'before-auth-refactor',
24
+ },
25
+ name: 'Pin the current topo',
26
+ },
27
+ ],
28
+ input: z.object({
29
+ module: z.string().optional().describe('Path to the app module'),
30
+ name: z.string().describe('Pin name'),
31
+ rootDir: z.string().optional().describe('Workspace root directory'),
32
+ }),
33
+ intent: 'write',
34
+ output: z.object({
35
+ snapshot: topoSnapshotOutput,
36
+ }),
37
+ permit: { scopes: ['topo:write'] },
38
+ });