@ontrails/trails 1.0.0-beta.4 → 1.0.0-beta.42

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 (165) hide show
  1. package/CHANGELOG.md +1106 -4
  2. package/README.md +27 -0
  3. package/package.json +31 -7
  4. package/src/app.ts +147 -3
  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 +42 -0
  11. package/src/mcp-options.ts +91 -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/regrade/history.ts +430 -0
  16. package/src/regrade/live-api-preserve.ts +8 -0
  17. package/src/regrade/plan-artifact.ts +285 -0
  18. package/src/release/bindings.ts +39 -0
  19. package/src/release/check.ts +844 -0
  20. package/src/release/config.ts +63 -0
  21. package/src/release/contract-facts.ts +425 -0
  22. package/src/release/index.ts +142 -0
  23. package/src/release/lock-roundtrip-smoke.ts +230 -0
  24. package/src/release/native-bun-publish.ts +651 -0
  25. package/src/release/native-bun-registry.ts +765 -0
  26. package/src/release/notes-cli.ts +171 -0
  27. package/src/release/notes.ts +390 -0
  28. package/src/release/pack-coherence.ts +455 -0
  29. package/src/release/packed-artifacts-smoke.ts +236 -0
  30. package/src/release/policy.ts +1687 -0
  31. package/src/release/semver.ts +104 -0
  32. package/src/release/smoke.ts +56 -0
  33. package/src/release/wayfinder-dogfood-smoke.ts +760 -0
  34. package/src/retired-topo-command.ts +36 -0
  35. package/src/run-adapter-check.ts +76 -0
  36. package/src/run-collision.ts +126 -0
  37. package/src/run-completions-install.ts +179 -0
  38. package/src/run-example.ts +149 -0
  39. package/src/run-examples.ts +148 -0
  40. package/src/run-quiet.ts +75 -0
  41. package/src/run-release-check.ts +74 -0
  42. package/src/run-schema.ts +74 -0
  43. package/src/run-trace.ts +273 -0
  44. package/src/run-warden.ts +39 -0
  45. package/src/run-watch.ts +432 -0
  46. package/src/run-wayfind-outline.ts +170 -0
  47. package/src/scaffold-version-sync.ts +183 -0
  48. package/src/scaffold-versions.generated.ts +12 -0
  49. package/src/trails/adapter-check.ts +244 -0
  50. package/src/trails/add-surface.ts +99 -45
  51. package/src/trails/add-trail.ts +84 -37
  52. package/src/trails/add-verify.ts +100 -30
  53. package/src/trails/compile.ts +58 -0
  54. package/src/trails/completions-complete.ts +165 -0
  55. package/src/trails/completions.ts +47 -0
  56. package/src/trails/create-adapter.ts +785 -0
  57. package/src/trails/create-scaffold.ts +401 -106
  58. package/src/trails/create-versions.ts +62 -0
  59. package/src/trails/create.ts +186 -72
  60. package/src/trails/deprecate.ts +59 -0
  61. package/src/trails/dev-clean.ts +82 -0
  62. package/src/trails/dev-reset.ts +50 -0
  63. package/src/trails/dev-stats.ts +72 -0
  64. package/src/trails/dev-support.ts +360 -0
  65. package/src/trails/doctor.ts +77 -0
  66. package/src/trails/draft-promote.ts +949 -0
  67. package/src/trails/guide.ts +70 -68
  68. package/src/trails/load-app.ts +1123 -15
  69. package/src/trails/operator-context.ts +66 -0
  70. package/src/trails/project.ts +17 -3
  71. package/src/trails/regrade.ts +3091 -0
  72. package/src/trails/release-check.ts +105 -0
  73. package/src/trails/release-smoke.ts +49 -0
  74. package/src/trails/revise.ts +53 -0
  75. package/src/trails/root-dir.ts +21 -0
  76. package/src/trails/run-example.ts +475 -0
  77. package/src/trails/run-examples.ts +129 -0
  78. package/src/trails/run.ts +434 -0
  79. package/src/trails/scaffold-json.ts +58 -0
  80. package/src/trails/survey.ts +877 -214
  81. package/src/trails/topo-activation.ts +14 -0
  82. package/src/trails/topo-constants.ts +2 -0
  83. package/src/trails/topo-history.ts +47 -0
  84. package/src/trails/topo-output-schemas.ts +259 -0
  85. package/src/trails/topo-pin.ts +38 -0
  86. package/src/trails/topo-read-support.ts +368 -0
  87. package/src/trails/topo-reports.ts +809 -0
  88. package/src/trails/topo-store-support.ts +325 -0
  89. package/src/trails/topo-support.ts +220 -0
  90. package/src/trails/topo-unpin.ts +61 -0
  91. package/src/trails/topo.ts +92 -0
  92. package/src/trails/validate.ts +27 -0
  93. package/src/trails/version-lifecycle-support.ts +936 -0
  94. package/src/trails/warden-guide.ts +134 -0
  95. package/src/trails/warden.ts +198 -58
  96. package/src/trails/wayfind-outline.ts +876 -0
  97. package/src/trails/wayfind.ts +1053 -0
  98. package/src/versions.ts +31 -0
  99. package/.turbo/turbo-build.log +0 -1
  100. package/.turbo/turbo-lint.log +0 -3
  101. package/.turbo/turbo-typecheck.log +0 -1
  102. package/__tests__/examples.test.ts +0 -6
  103. package/dist/bin/trails.d.ts +0 -3
  104. package/dist/bin/trails.d.ts.map +0 -1
  105. package/dist/bin/trails.js +0 -4
  106. package/dist/bin/trails.js.map +0 -1
  107. package/dist/src/app.d.ts +0 -2
  108. package/dist/src/app.d.ts.map +0 -1
  109. package/dist/src/app.js +0 -11
  110. package/dist/src/app.js.map +0 -1
  111. package/dist/src/clack.d.ts +0 -9
  112. package/dist/src/clack.d.ts.map +0 -1
  113. package/dist/src/clack.js +0 -84
  114. package/dist/src/clack.js.map +0 -1
  115. package/dist/src/cli.d.ts +0 -2
  116. package/dist/src/cli.d.ts.map +0 -1
  117. package/dist/src/cli.js +0 -13
  118. package/dist/src/cli.js.map +0 -1
  119. package/dist/src/trails/add-surface.d.ts +0 -13
  120. package/dist/src/trails/add-surface.d.ts.map +0 -1
  121. package/dist/src/trails/add-surface.js +0 -88
  122. package/dist/src/trails/add-surface.js.map +0 -1
  123. package/dist/src/trails/add-trail.d.ts +0 -10
  124. package/dist/src/trails/add-trail.d.ts.map +0 -1
  125. package/dist/src/trails/add-trail.js +0 -77
  126. package/dist/src/trails/add-trail.js.map +0 -1
  127. package/dist/src/trails/add-verify.d.ts +0 -10
  128. package/dist/src/trails/add-verify.d.ts.map +0 -1
  129. package/dist/src/trails/add-verify.js +0 -67
  130. package/dist/src/trails/add-verify.js.map +0 -1
  131. package/dist/src/trails/create-scaffold.d.ts +0 -15
  132. package/dist/src/trails/create-scaffold.d.ts.map +0 -1
  133. package/dist/src/trails/create-scaffold.js +0 -288
  134. package/dist/src/trails/create-scaffold.js.map +0 -1
  135. package/dist/src/trails/create.d.ts +0 -22
  136. package/dist/src/trails/create.d.ts.map +0 -1
  137. package/dist/src/trails/create.js +0 -121
  138. package/dist/src/trails/create.js.map +0 -1
  139. package/dist/src/trails/guide.d.ts +0 -11
  140. package/dist/src/trails/guide.d.ts.map +0 -1
  141. package/dist/src/trails/guide.js +0 -80
  142. package/dist/src/trails/guide.js.map +0 -1
  143. package/dist/src/trails/load-app.d.ts +0 -4
  144. package/dist/src/trails/load-app.d.ts.map +0 -1
  145. package/dist/src/trails/load-app.js +0 -24
  146. package/dist/src/trails/load-app.js.map +0 -1
  147. package/dist/src/trails/project.d.ts +0 -8
  148. package/dist/src/trails/project.d.ts.map +0 -1
  149. package/dist/src/trails/project.js +0 -43
  150. package/dist/src/trails/project.js.map +0 -1
  151. package/dist/src/trails/survey.d.ts +0 -31
  152. package/dist/src/trails/survey.d.ts.map +0 -1
  153. package/dist/src/trails/survey.js +0 -221
  154. package/dist/src/trails/survey.js.map +0 -1
  155. package/dist/src/trails/warden.d.ts +0 -19
  156. package/dist/src/trails/warden.d.ts.map +0 -1
  157. package/dist/src/trails/warden.js +0 -88
  158. package/dist/src/trails/warden.js.map +0 -1
  159. package/dist/tsconfig.tsbuildinfo +0 -1
  160. package/src/__tests__/create.test.ts +0 -349
  161. package/src/__tests__/guide.test.ts +0 -91
  162. package/src/__tests__/load-app.test.ts +0 -15
  163. package/src/__tests__/survey.test.ts +0 -159
  164. package/src/__tests__/warden.test.ts +0 -74
  165. package/tsconfig.json +0 -9
@@ -0,0 +1,14 @@
1
+ export {
2
+ deriveActivationGraph,
3
+ deriveDeclaredTrailActivation,
4
+ deriveSignalActivationRelations,
5
+ } from '@ontrails/topography';
6
+ export type {
7
+ ActivationChainReport,
8
+ ActivationEdgeReport,
9
+ ActivationGraphReport,
10
+ ActivationOverviewReport,
11
+ ActivationSourceReport,
12
+ SignalActivationRelations,
13
+ TrailActivationReport,
14
+ } from '@ontrails/topography';
@@ -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
+ description: 'List saved topo snapshots, including pinned references',
24
+ examples: [
25
+ {
26
+ input: createIsolatedExampleInput('topo-history'),
27
+ name: 'Show topo history',
28
+ },
29
+ ],
30
+ implementation: (input: TopoHistoryTrailInput, ctx) => {
31
+ const rootDirResult = resolveTrailRootDir(input.rootDir, ctx.cwd);
32
+ if (rootDirResult.isErr()) {
33
+ return rootDirResult;
34
+ }
35
+ const rootDir = rootDirResult.value;
36
+ return Result.ok(listTopoHistory({ limit: input.limit, rootDir }));
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 entityDetailOutput = z.object({
70
+ description: z.string().optional(),
71
+ exampleCount: z.number(),
72
+ id: z.string(),
73
+ identity: z.string().optional(),
74
+ kind: z.literal('entity'),
75
+ references: z
76
+ .array(
77
+ z.object({
78
+ entity: 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
+ description: z.string().nullable(),
205
+ detours: z
206
+ .array(
207
+ z.object({
208
+ maxAttempts: z.number(),
209
+ on: z.string(),
210
+ })
211
+ )
212
+ .readonly()
213
+ .nullable(),
214
+ entities: z.array(z.string()).readonly(),
215
+ entityDetails: z.array(entityDetailOutput).readonly(),
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
+ description: 'Pin the current topo under a durable name',
13
+ examples: [
14
+ {
15
+ input: {
16
+ ...createIsolatedExampleInput('topo-pin'),
17
+ name: 'before-auth-refactor',
18
+ },
19
+ name: 'Pin the current topo',
20
+ },
21
+ ],
22
+ implementation: async (input, ctx) =>
23
+ withFreshOperatorApp(input, ctx, ({ lease, rootDir }) =>
24
+ Result.ok(
25
+ pinCurrentTopoSnapshot(lease.app, { name: input.name, rootDir })
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
+ });