@ontrails/trails 1.0.0-beta.3 → 1.0.0-beta.4
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.
- package/CHANGELOG.md +27 -0
- package/dist/src/trails/add-surface.js +9 -9
- package/dist/src/trails/add-surface.js.map +1 -1
- package/dist/src/trails/add-trail.d.ts +1 -2
- package/dist/src/trails/add-trail.d.ts.map +1 -1
- package/dist/src/trails/add-trail.js +16 -24
- package/dist/src/trails/add-trail.js.map +1 -1
- package/dist/src/trails/add-verify.js +9 -9
- package/dist/src/trails/add-verify.js.map +1 -1
- package/dist/src/trails/create-scaffold.js +25 -25
- package/dist/src/trails/create-scaffold.js.map +1 -1
- package/dist/src/trails/create.d.ts +1 -1
- package/dist/src/trails/create.js +10 -10
- package/dist/src/trails/create.js.map +1 -1
- package/dist/src/trails/guide.js +12 -12
- package/dist/src/trails/guide.js.map +1 -1
- package/dist/src/trails/survey.d.ts +0 -2
- package/dist/src/trails/survey.d.ts.map +1 -1
- package/dist/src/trails/survey.js +21 -25
- package/dist/src/trails/survey.js.map +1 -1
- package/dist/src/trails/warden.js +28 -28
- package/dist/src/trails/warden.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/create.test.ts +7 -7
- package/src/__tests__/guide.test.ts +4 -4
- package/src/__tests__/survey.test.ts +6 -8
- package/src/__tests__/warden.test.ts +2 -2
- package/src/trails/add-surface.ts +9 -9
- package/src/trails/add-trail.ts +16 -25
- package/src/trails/add-verify.ts +9 -9
- package/src/trails/create-scaffold.ts +27 -27
- package/src/trails/create.ts +10 -10
- package/src/trails/guide.ts +14 -14
- package/src/trails/survey.ts +29 -36
- package/src/trails/warden.ts +33 -33
|
@@ -34,10 +34,8 @@ export const generateBriefReport = (app) => {
|
|
|
34
34
|
detours: hasDetours,
|
|
35
35
|
events: app.events.size > 0,
|
|
36
36
|
examples: hasExamples,
|
|
37
|
-
hikes: app.hikes.size > 0,
|
|
38
37
|
outputSchemas: hasOutputSchemas,
|
|
39
38
|
},
|
|
40
|
-
hikes: app.hikes.size,
|
|
41
39
|
name: app.name,
|
|
42
40
|
trails: app.trails.size,
|
|
43
41
|
version: '0.1.0',
|
|
@@ -47,11 +45,11 @@ export const generateBriefReport = (app) => {
|
|
|
47
45
|
// Formatting helpers
|
|
48
46
|
// ---------------------------------------------------------------------------
|
|
49
47
|
const safetyLabel = (entry) => {
|
|
50
|
-
if (entry.
|
|
51
|
-
return '
|
|
48
|
+
if (entry.intent === 'destroy') {
|
|
49
|
+
return 'destroy';
|
|
52
50
|
}
|
|
53
|
-
if (entry.
|
|
54
|
-
return '
|
|
51
|
+
if (entry.intent === 'read') {
|
|
52
|
+
return 'read';
|
|
55
53
|
}
|
|
56
54
|
return '-';
|
|
57
55
|
};
|
|
@@ -142,22 +140,6 @@ export const surveyTrail = trail('survey', {
|
|
|
142
140
|
name: 'Brief capability report',
|
|
143
141
|
},
|
|
144
142
|
],
|
|
145
|
-
implementation: async (input, ctx) => {
|
|
146
|
-
const app = await loadApp(input.module, ctx.cwd ?? '.');
|
|
147
|
-
if (input.brief) {
|
|
148
|
-
return Result.ok(generateBriefReport(app));
|
|
149
|
-
}
|
|
150
|
-
if (input.diff) {
|
|
151
|
-
return await buildSurveyDiff(app, input.breakingOnly);
|
|
152
|
-
}
|
|
153
|
-
if (input.trailId) {
|
|
154
|
-
return buildSurveyDetail(app, input.trailId);
|
|
155
|
-
}
|
|
156
|
-
if (input.generate) {
|
|
157
|
-
return await buildSurveyGenerate(app);
|
|
158
|
-
}
|
|
159
|
-
return Result.ok(formatTrailList(app));
|
|
160
|
-
},
|
|
161
143
|
input: z.object({
|
|
162
144
|
breakingOnly: z
|
|
163
145
|
.boolean()
|
|
@@ -175,6 +157,7 @@ export const surveyTrail = trail('survey', {
|
|
|
175
157
|
.describe('Path to the app module'),
|
|
176
158
|
trailId: z.string().optional().describe('Trail ID for detail view'),
|
|
177
159
|
}),
|
|
160
|
+
intent: 'read',
|
|
178
161
|
output: z.union([
|
|
179
162
|
z.object({
|
|
180
163
|
count: z.number(),
|
|
@@ -192,10 +175,8 @@ export const surveyTrail = trail('survey', {
|
|
|
192
175
|
detours: z.boolean(),
|
|
193
176
|
events: z.boolean(),
|
|
194
177
|
examples: z.boolean(),
|
|
195
|
-
hikes: z.boolean(),
|
|
196
178
|
outputSchemas: z.boolean(),
|
|
197
179
|
}),
|
|
198
|
-
hikes: z.number(),
|
|
199
180
|
name: z.string(),
|
|
200
181
|
trails: z.number(),
|
|
201
182
|
version: z.string(),
|
|
@@ -220,6 +201,21 @@ export const surveyTrail = trail('survey', {
|
|
|
220
201
|
mapPath: z.string(),
|
|
221
202
|
}),
|
|
222
203
|
]),
|
|
223
|
-
|
|
204
|
+
run: async (input, ctx) => {
|
|
205
|
+
const app = await loadApp(input.module, ctx.cwd ?? '.');
|
|
206
|
+
if (input.brief) {
|
|
207
|
+
return Result.ok(generateBriefReport(app));
|
|
208
|
+
}
|
|
209
|
+
if (input.diff) {
|
|
210
|
+
return await buildSurveyDiff(app, input.breakingOnly);
|
|
211
|
+
}
|
|
212
|
+
if (input.trailId) {
|
|
213
|
+
return buildSurveyDetail(app, input.trailId);
|
|
214
|
+
}
|
|
215
|
+
if (input.generate) {
|
|
216
|
+
return await buildSurveyGenerate(app);
|
|
217
|
+
}
|
|
218
|
+
return Result.ok(formatTrailList(app));
|
|
219
|
+
},
|
|
224
220
|
});
|
|
225
221
|
//# sourceMappingURL=survey.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"survey.js","sourceRoot":"","sources":["../../../src/trails/survey.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM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AC,CAAC,MAAM,EAAE;SACnB,CAAC;QACF,CAAC,CAAC,MAAM,CAAC;YACP,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;YAChB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;YACpB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;SACpB,CAAC;KACH,CAAC;IACF,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QACxB,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;QAExD,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7C,CAAC;QAED,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YACf,OAAO,MAAM,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;QACxD,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO,iBAAiB,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,OAAO,MAAM,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACxC,CAAC;QAED,OAAO,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -27,33 +27,6 @@ export const wardenTrail = trail('warden', {
|
|
|
27
27
|
name: 'GitHub Actions annotations',
|
|
28
28
|
},
|
|
29
29
|
],
|
|
30
|
-
implementation: async (input, ctx) => {
|
|
31
|
-
const rootDir = input.rootDir ?? ctx.cwd ?? process.cwd();
|
|
32
|
-
// oxlint-disable-next-line prefer-await-to-then -- catch converts rejection to undefined cleanly
|
|
33
|
-
const topo = await loadApp('./src/app.ts', rootDir).catch(() => undefined);
|
|
34
|
-
const report = await runWarden({
|
|
35
|
-
driftOnly: input.driftOnly,
|
|
36
|
-
lintOnly: input.lintOnly,
|
|
37
|
-
rootDir,
|
|
38
|
-
topo,
|
|
39
|
-
});
|
|
40
|
-
const formatters = {
|
|
41
|
-
github: formatGitHubAnnotations,
|
|
42
|
-
json: formatJson,
|
|
43
|
-
summary: formatSummary,
|
|
44
|
-
text: formatWardenReport,
|
|
45
|
-
};
|
|
46
|
-
const formatter = formatters[input.format] ?? formatWardenReport;
|
|
47
|
-
const formatted = formatter(report);
|
|
48
|
-
return Result.ok({
|
|
49
|
-
diagnostics: report.diagnostics,
|
|
50
|
-
drift: report.drift,
|
|
51
|
-
errorCount: report.errorCount,
|
|
52
|
-
formatted,
|
|
53
|
-
passed: report.passed,
|
|
54
|
-
warnCount: report.warnCount,
|
|
55
|
-
});
|
|
56
|
-
},
|
|
57
30
|
input: z.object({
|
|
58
31
|
driftOnly: z.boolean().default(false).describe('Only run drift detection'),
|
|
59
32
|
format: z
|
|
@@ -63,6 +36,7 @@ export const wardenTrail = trail('warden', {
|
|
|
63
36
|
lintOnly: z.boolean().default(false).describe('Only run lint rules'),
|
|
64
37
|
rootDir: z.string().optional().describe('Root directory to scan'),
|
|
65
38
|
}),
|
|
39
|
+
intent: 'read',
|
|
66
40
|
output: z.object({
|
|
67
41
|
diagnostics: z.array(z.object({
|
|
68
42
|
filePath: z.string(),
|
|
@@ -83,6 +57,32 @@ export const wardenTrail = trail('warden', {
|
|
|
83
57
|
passed: z.boolean(),
|
|
84
58
|
warnCount: z.number(),
|
|
85
59
|
}),
|
|
86
|
-
|
|
60
|
+
run: async (input, ctx) => {
|
|
61
|
+
const rootDir = input.rootDir ?? ctx.cwd ?? process.cwd();
|
|
62
|
+
// oxlint-disable-next-line prefer-await-to-then -- catch converts rejection to undefined cleanly
|
|
63
|
+
const topo = await loadApp('./src/app.ts', rootDir).catch(() => undefined);
|
|
64
|
+
const report = await runWarden({
|
|
65
|
+
driftOnly: input.driftOnly,
|
|
66
|
+
lintOnly: input.lintOnly,
|
|
67
|
+
rootDir,
|
|
68
|
+
topo,
|
|
69
|
+
});
|
|
70
|
+
const formatters = {
|
|
71
|
+
github: formatGitHubAnnotations,
|
|
72
|
+
json: formatJson,
|
|
73
|
+
summary: formatSummary,
|
|
74
|
+
text: formatWardenReport,
|
|
75
|
+
};
|
|
76
|
+
const formatter = formatters[input.format] ?? formatWardenReport;
|
|
77
|
+
const formatted = formatter(report);
|
|
78
|
+
return Result.ok({
|
|
79
|
+
diagnostics: report.diagnostics,
|
|
80
|
+
drift: report.drift,
|
|
81
|
+
errorCount: report.errorCount,
|
|
82
|
+
formatted,
|
|
83
|
+
passed: report.passed,
|
|
84
|
+
warnCount: report.warnCount,
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
87
|
});
|
|
88
88
|
//# sourceMappingURL=warden.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warden.js","sourceRoot":"","sources":["../../../src/trails/warden.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,uBAAuB,EACvB,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,EAAE;IACzC,WAAW,EAAE,sCAAsC;IACnD,QAAQ,EAAE;QACR;YACE,KAAK,EAAE;gBACL,SAAS,EAAE,KAAK;gBAChB,QAAQ,EAAE,KAAK;aAChB;YACD,IAAI,EAAE,oBAAoB;SAC3B;QACD;YACE,KAAK,EAAE;gBAC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AS;YAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,OAAO;YACP,IAAI;SACL,CAAC,CAAC;QAEH,MAAM,UAAU,GAAiD;YAC/D,MAAM,EAAE,uBAAuB;YAC/B,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,aAAa;YACtB,IAAI,EAAE,kBAAkB;SACzB,CAAC;QACF,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,kBAAkB,CAAC;QACjE,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;QAEpC,OAAO,MAAM,CAAC,EAAE,CAAC;YACf,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,SAAS;YACT,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,SAAS,EAAE,MAAM,CAAC,SAAS;SAC5B,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -74,13 +74,13 @@ const runFollow = async (
|
|
|
74
74
|
): Promise<Result<unknown, Error>> => {
|
|
75
75
|
switch (id) {
|
|
76
76
|
case 'create.scaffold': {
|
|
77
|
-
return await createScaffold.
|
|
77
|
+
return await createScaffold.run(input as never, {} as never);
|
|
78
78
|
}
|
|
79
79
|
case 'add.surface': {
|
|
80
|
-
return await addSurface.
|
|
80
|
+
return await addSurface.run(input as never, {} as never);
|
|
81
81
|
}
|
|
82
82
|
case 'add.verify': {
|
|
83
|
-
return await addVerify.
|
|
83
|
+
return await addVerify.run(input as never, {} as never);
|
|
84
84
|
}
|
|
85
85
|
default: {
|
|
86
86
|
return Result.err(new Error(`Unknown follow target: ${id}`));
|
|
@@ -96,7 +96,7 @@ const runBlaze = (
|
|
|
96
96
|
verify: boolean;
|
|
97
97
|
}>
|
|
98
98
|
) =>
|
|
99
|
-
createRoute.
|
|
99
|
+
createRoute.run(
|
|
100
100
|
{
|
|
101
101
|
dir: dirname(projectDir),
|
|
102
102
|
name: basename(projectDir),
|
|
@@ -199,7 +199,7 @@ const assertEntityStarter = (dir: string): void => {
|
|
|
199
199
|
'return Result.ok({ results: [] })',
|
|
200
200
|
]);
|
|
201
201
|
expectContainsAll(readText(dir, 'src/trails/onboard.ts'), [
|
|
202
|
-
"import { Result,
|
|
202
|
+
"import { Result, trail } from '@ontrails/core'",
|
|
203
203
|
'return Result.ok({ onboarded: true })',
|
|
204
204
|
]);
|
|
205
205
|
};
|
|
@@ -289,7 +289,7 @@ describe('trails blaze', () => {
|
|
|
289
289
|
await withTempProject(async (dir) => {
|
|
290
290
|
setupMinimalProject(dir);
|
|
291
291
|
const result = expectOk(
|
|
292
|
-
await addSurface.
|
|
292
|
+
await addSurface.run({ dir, surface: 'mcp' }, {} as never)
|
|
293
293
|
);
|
|
294
294
|
|
|
295
295
|
expect(result.created).toBe('src/mcp.ts');
|
|
@@ -313,7 +313,7 @@ describe('trails blaze', () => {
|
|
|
313
313
|
writeFileSync(join(dir, 'src', 'mcp.ts'), 'existing content');
|
|
314
314
|
|
|
315
315
|
const error = expectErr(
|
|
316
|
-
await addSurface.
|
|
316
|
+
await addSurface.run({ dir, surface: 'mcp' }, {} as never)
|
|
317
317
|
);
|
|
318
318
|
expect(error.message).toBe('MCP is already blazed. Nothing to do.');
|
|
319
319
|
});
|
|
@@ -25,13 +25,13 @@ const helloTrail = trail('hello', {
|
|
|
25
25
|
name: 'Named greeting',
|
|
26
26
|
},
|
|
27
27
|
],
|
|
28
|
-
|
|
28
|
+
input: z.object({ name: z.string().optional() }),
|
|
29
|
+
intent: 'read',
|
|
30
|
+
output: z.object({ message: z.string() }),
|
|
31
|
+
run: (input) => {
|
|
29
32
|
const name = input.name ?? 'world';
|
|
30
33
|
return Result.ok({ message: `Hello, ${name}!` });
|
|
31
34
|
},
|
|
32
|
-
input: z.object({ name: z.string().optional() }),
|
|
33
|
-
output: z.object({ message: z.string() }),
|
|
34
|
-
readOnly: true,
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
const app = topo('test-app', { hello: helloTrail });
|
|
@@ -28,20 +28,20 @@ const helloTrail = trail('hello', {
|
|
|
28
28
|
name: 'Default greeting',
|
|
29
29
|
},
|
|
30
30
|
],
|
|
31
|
-
|
|
31
|
+
input: z.object({ name: z.string().optional() }),
|
|
32
|
+
intent: 'read',
|
|
33
|
+
output: z.object({ message: z.string() }),
|
|
34
|
+
run: (input) => {
|
|
32
35
|
const name = input.name ?? 'world';
|
|
33
36
|
return Result.ok({ message: `Hello, ${name}!` });
|
|
34
37
|
},
|
|
35
|
-
input: z.object({ name: z.string().optional() }),
|
|
36
|
-
output: z.object({ message: z.string() }),
|
|
37
|
-
readOnly: true,
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
const byeTrail = trail('bye', {
|
|
41
41
|
description: 'Say goodbye',
|
|
42
|
-
implementation: (input) => Result.ok({ message: `Goodbye, ${input.name}!` }),
|
|
43
42
|
input: z.object({ name: z.string() }),
|
|
44
43
|
output: z.object({ message: z.string() }),
|
|
44
|
+
run: (input) => Result.ok({ message: `Goodbye, ${input.name}!` }),
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
const app = topo('test-app', { bye: byeTrail, hello: helloTrail });
|
|
@@ -64,7 +64,7 @@ describe('trails survey', () => {
|
|
|
64
64
|
const hello = surfaceMap.entries.find((e) => e.id === 'hello');
|
|
65
65
|
expect(hello).toBeDefined();
|
|
66
66
|
expect(hello?.kind).toBe('trail');
|
|
67
|
-
expect(hello?.
|
|
67
|
+
expect(hello?.intent).toBe('read');
|
|
68
68
|
expect(hello?.exampleCount).toBe(1);
|
|
69
69
|
});
|
|
70
70
|
|
|
@@ -129,7 +129,6 @@ describe('trails survey --brief', () => {
|
|
|
129
129
|
test('report includes correct trail count', () => {
|
|
130
130
|
const report = generateBriefReport(app);
|
|
131
131
|
expect(report.trails).toBe(2);
|
|
132
|
-
expect(report.hikes).toBe(0);
|
|
133
132
|
expect(report.events).toBe(0);
|
|
134
133
|
});
|
|
135
134
|
|
|
@@ -138,7 +137,6 @@ describe('trails survey --brief', () => {
|
|
|
138
137
|
expect(report.features.outputSchemas).toBe(true);
|
|
139
138
|
expect(report.features.examples).toBe(true);
|
|
140
139
|
expect(report.features.detours).toBe(true);
|
|
141
|
-
expect(report.features.hikes).toBe(false);
|
|
142
140
|
expect(report.features.events).toBe(false);
|
|
143
141
|
});
|
|
144
142
|
|
|
@@ -21,7 +21,7 @@ describe('trails warden', () => {
|
|
|
21
21
|
writeFileSync(
|
|
22
22
|
join(dir, 'good.ts'),
|
|
23
23
|
`trail("hello", {
|
|
24
|
-
|
|
24
|
+
run: async (input, ctx) => {
|
|
25
25
|
return Result.ok({ message: "hi" });
|
|
26
26
|
}
|
|
27
27
|
})`
|
|
@@ -54,7 +54,7 @@ describe('trails warden', () => {
|
|
|
54
54
|
writeFileSync(
|
|
55
55
|
join(dir, 'bad.ts'),
|
|
56
56
|
`trail("x", {
|
|
57
|
-
|
|
57
|
+
run: async () => { throw new Error("boom"); }
|
|
58
58
|
})`
|
|
59
59
|
);
|
|
60
60
|
const report = await runWarden({ driftOnly: true, rootDir: dir });
|
|
@@ -92,7 +92,15 @@ const writeSurfaceEntry = async (
|
|
|
92
92
|
|
|
93
93
|
export const addSurface = trail('add.surface', {
|
|
94
94
|
description: 'Add a surface to an existing project',
|
|
95
|
-
|
|
95
|
+
input: z.object({
|
|
96
|
+
dir: z.string().optional().describe('Project directory'),
|
|
97
|
+
surface: z.enum(['cli', 'mcp']).describe('Surface to add'),
|
|
98
|
+
}),
|
|
99
|
+
output: z.object({
|
|
100
|
+
created: z.string(),
|
|
101
|
+
dependency: z.string(),
|
|
102
|
+
}),
|
|
103
|
+
run: async (input) => {
|
|
96
104
|
const cwd = resolve(input.dir ?? '.');
|
|
97
105
|
const { surface } = input;
|
|
98
106
|
const entryFile = getEntryFile(surface);
|
|
@@ -108,12 +116,4 @@ export const addSurface = trail('add.surface', {
|
|
|
108
116
|
dependency: await updatePkgJsonForSurface(cwd, surface),
|
|
109
117
|
});
|
|
110
118
|
},
|
|
111
|
-
input: z.object({
|
|
112
|
-
dir: z.string().optional().describe('Project directory'),
|
|
113
|
-
surface: z.enum(['cli', 'mcp']).describe('Surface to add'),
|
|
114
|
-
}),
|
|
115
|
-
output: z.object({
|
|
116
|
-
created: z.string(),
|
|
117
|
-
dependency: z.string(),
|
|
118
|
-
}),
|
|
119
119
|
});
|
package/src/trails/add-trail.ts
CHANGED
|
@@ -14,17 +14,9 @@ import { z } from 'zod';
|
|
|
14
14
|
|
|
15
15
|
const generateTrailFile = (
|
|
16
16
|
id: string,
|
|
17
|
-
|
|
18
|
-
destructive: boolean
|
|
17
|
+
intent: 'read' | 'write' | 'destroy'
|
|
19
18
|
): string => {
|
|
20
|
-
const
|
|
21
|
-
if (readOnly) {
|
|
22
|
-
markers.push(' readOnly: true,');
|
|
23
|
-
}
|
|
24
|
-
if (destructive) {
|
|
25
|
-
markers.push(' destructive: true,');
|
|
26
|
-
}
|
|
27
|
-
const markerBlock = markers.length > 0 ? `\n${markers.join('\n')}` : '';
|
|
19
|
+
const intentLine = intent === 'write' ? '' : `\n intent: '${intent}',`;
|
|
28
20
|
|
|
29
21
|
return `import { Result, trail } from '@ontrails/core';
|
|
30
22
|
import { z } from 'zod';
|
|
@@ -37,10 +29,10 @@ export const ${id.replaceAll('.', '_')} = trail('${id}', {
|
|
|
37
29
|
name: 'TODO: add example',
|
|
38
30
|
},
|
|
39
31
|
],
|
|
40
|
-
|
|
32
|
+
run: async (input) => {
|
|
41
33
|
return Result.ok({ message: 'TODO' });
|
|
42
34
|
},
|
|
43
|
-
input: z.object({}),${
|
|
35
|
+
input: z.object({}),${intentLine}
|
|
44
36
|
output: z.object({ message: z.string() }),
|
|
45
37
|
});
|
|
46
38
|
`;
|
|
@@ -73,16 +65,23 @@ const writeWithDirs = async (
|
|
|
73
65
|
|
|
74
66
|
export const addTrail = trail('add.trail', {
|
|
75
67
|
description: 'Scaffold a new trail with tests and examples',
|
|
76
|
-
|
|
68
|
+
input: z.object({
|
|
69
|
+
id: z.string().describe('Trail ID (e.g., entity.update)'),
|
|
70
|
+
intent: z
|
|
71
|
+
.enum(['read', 'write', 'destroy'])
|
|
72
|
+
.default('write')
|
|
73
|
+
.describe('Trail intent'),
|
|
74
|
+
}),
|
|
75
|
+
output: z.object({
|
|
76
|
+
created: z.array(z.string()),
|
|
77
|
+
}),
|
|
78
|
+
run: async (input, ctx) => {
|
|
77
79
|
const { id } = input;
|
|
78
80
|
const moduleName = id.replaceAll('.', '-');
|
|
79
81
|
const cwd = resolve(ctx.cwd ?? '.');
|
|
80
82
|
|
|
81
83
|
const files = new Map<string, string>([
|
|
82
|
-
[
|
|
83
|
-
`src/trails/${moduleName}.ts`,
|
|
84
|
-
generateTrailFile(id, input.readOnly, input.destructive),
|
|
85
|
-
],
|
|
84
|
+
[`src/trails/${moduleName}.ts`, generateTrailFile(id, input.intent)],
|
|
86
85
|
[`__tests__/${moduleName}.test.ts`, generateTestFile(id)],
|
|
87
86
|
]);
|
|
88
87
|
|
|
@@ -92,12 +91,4 @@ export const addTrail = trail('add.trail', {
|
|
|
92
91
|
|
|
93
92
|
return Result.ok({ created: [...files.keys()] });
|
|
94
93
|
},
|
|
95
|
-
input: z.object({
|
|
96
|
-
destructive: z.boolean().default(false).describe('Destructive trail'),
|
|
97
|
-
id: z.string().describe('Trail ID (e.g., entity.update)'),
|
|
98
|
-
readOnly: z.boolean().default(false).describe('Read-only trail'),
|
|
99
|
-
}),
|
|
100
|
-
output: z.object({
|
|
101
|
-
created: z.array(z.string()),
|
|
102
|
-
}),
|
|
103
94
|
});
|
package/src/trails/add-verify.ts
CHANGED
|
@@ -56,7 +56,15 @@ const updatePackageJsonForVerify = async (
|
|
|
56
56
|
|
|
57
57
|
export const addVerify = trail('add.verify', {
|
|
58
58
|
description: 'Add testing and warden verification',
|
|
59
|
-
|
|
59
|
+
input: z.object({
|
|
60
|
+
dir: z.string().optional().describe('Parent directory'),
|
|
61
|
+
name: z.string().describe('Project name'),
|
|
62
|
+
}),
|
|
63
|
+
metadata: { internal: true },
|
|
64
|
+
output: z.object({
|
|
65
|
+
created: z.array(z.string()),
|
|
66
|
+
}),
|
|
67
|
+
run: async (input) => {
|
|
60
68
|
const projectDir = resolve(input.dir ?? '.', input.name);
|
|
61
69
|
const files: string[] = [];
|
|
62
70
|
|
|
@@ -76,12 +84,4 @@ export const addVerify = trail('add.verify', {
|
|
|
76
84
|
|
|
77
85
|
return Result.ok({ created: files });
|
|
78
86
|
},
|
|
79
|
-
input: z.object({
|
|
80
|
-
dir: z.string().optional().describe('Parent directory'),
|
|
81
|
-
name: z.string().describe('Project name'),
|
|
82
|
-
}),
|
|
83
|
-
markers: { internal: true },
|
|
84
|
-
output: z.object({
|
|
85
|
-
created: z.array(z.string()),
|
|
86
|
-
}),
|
|
87
87
|
});
|
|
@@ -107,7 +107,7 @@ export const hello = trail('hello', {
|
|
|
107
107
|
name: 'Named greeting',
|
|
108
108
|
},
|
|
109
109
|
],
|
|
110
|
-
|
|
110
|
+
run: (input) => {
|
|
111
111
|
const name = input.name ?? 'world';
|
|
112
112
|
return Result.ok({ message: \`Hello, \${name}!\` });
|
|
113
113
|
},
|
|
@@ -117,7 +117,7 @@ export const hello = trail('hello', {
|
|
|
117
117
|
output: z.object({
|
|
118
118
|
message: z.string(),
|
|
119
119
|
}),
|
|
120
|
-
|
|
120
|
+
intent: 'read',
|
|
121
121
|
});
|
|
122
122
|
`;
|
|
123
123
|
|
|
@@ -139,12 +139,12 @@ export const show = trail('entity.show', {
|
|
|
139
139
|
name: 'Show entity',
|
|
140
140
|
},
|
|
141
141
|
],
|
|
142
|
-
|
|
142
|
+
run: (input) => {
|
|
143
143
|
return Result.ok({ id: input.id, name: 'Example' });
|
|
144
144
|
},
|
|
145
145
|
input: z.object({ id: z.string() }),
|
|
146
146
|
output: entitySchema,
|
|
147
|
-
|
|
147
|
+
intent: 'read',
|
|
148
148
|
});
|
|
149
149
|
|
|
150
150
|
export const add = trail('entity.add', {
|
|
@@ -156,7 +156,7 @@ export const add = trail('entity.add', {
|
|
|
156
156
|
name: 'Add entity',
|
|
157
157
|
},
|
|
158
158
|
],
|
|
159
|
-
|
|
159
|
+
run: (input) => {
|
|
160
160
|
return Result.ok({ id: '1', name: input.name });
|
|
161
161
|
},
|
|
162
162
|
input: z.object({ name: z.string() }),
|
|
@@ -177,25 +177,25 @@ export const search = trail('search', {
|
|
|
177
177
|
name: 'Search entities',
|
|
178
178
|
},
|
|
179
179
|
],
|
|
180
|
-
|
|
180
|
+
run: () => {
|
|
181
181
|
return Result.ok({ results: [] });
|
|
182
182
|
},
|
|
183
183
|
input: z.object({ query: z.string() }),
|
|
184
184
|
output: z.object({
|
|
185
185
|
results: z.array(z.object({ id: z.string(), name: z.string() })),
|
|
186
186
|
}),
|
|
187
|
-
|
|
187
|
+
intent: 'read',
|
|
188
188
|
});
|
|
189
189
|
`;
|
|
190
190
|
|
|
191
|
-
const
|
|
192
|
-
`import { Result,
|
|
191
|
+
const generateOnboardTrail = (): string =>
|
|
192
|
+
`import { Result, trail } from '@ontrails/core';
|
|
193
193
|
import { z } from 'zod';
|
|
194
194
|
|
|
195
|
-
export const onboard =
|
|
195
|
+
export const onboard = trail('entity.onboard', {
|
|
196
196
|
description: 'Onboard a new entity end-to-end',
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
follow: ['entity.add'],
|
|
198
|
+
run: async (input, ctx) => {
|
|
199
199
|
const result = await ctx.follow('entity.add', { name: input.name });
|
|
200
200
|
if (result.isErr()) {
|
|
201
201
|
return result;
|
|
@@ -281,7 +281,7 @@ const starterFileGenerators: Record<Starter, () => [string, string][]> = {
|
|
|
281
281
|
entity: () => [
|
|
282
282
|
['src/trails/entity.ts', generateEntityTrails()],
|
|
283
283
|
['src/trails/search.ts', generateSearchTrail()],
|
|
284
|
-
['src/trails/onboard.ts',
|
|
284
|
+
['src/trails/onboard.ts', generateOnboardTrail()],
|
|
285
285
|
['src/events/entity-events.ts', generateEntityEvents()],
|
|
286
286
|
['src/store.ts', generateStore()],
|
|
287
287
|
],
|
|
@@ -322,19 +322,6 @@ const writeScaffoldFiles = async (
|
|
|
322
322
|
|
|
323
323
|
export const createScaffold = trail('create.scaffold', {
|
|
324
324
|
description: 'Scaffold a new Trails project',
|
|
325
|
-
implementation: async (input) => {
|
|
326
|
-
const projectDir = resolve(input.dir ?? '.', input.name);
|
|
327
|
-
const starter = (input.starter ?? 'hello') as Starter;
|
|
328
|
-
const fileMap = collectScaffoldFiles(input.name, starter);
|
|
329
|
-
const files = await writeScaffoldFiles(projectDir, fileMap);
|
|
330
|
-
mkdirSync(join(projectDir, '.trails'), { recursive: true });
|
|
331
|
-
|
|
332
|
-
return Result.ok({
|
|
333
|
-
created: files,
|
|
334
|
-
dir: projectDir,
|
|
335
|
-
name: input.name,
|
|
336
|
-
} satisfies ScaffoldResult);
|
|
337
|
-
},
|
|
338
325
|
input: z.object({
|
|
339
326
|
dir: z.string().optional().describe('Parent directory'),
|
|
340
327
|
name: z.string().describe('Project name'),
|
|
@@ -343,10 +330,23 @@ export const createScaffold = trail('create.scaffold', {
|
|
|
343
330
|
.default('hello')
|
|
344
331
|
.describe('Starter trail'),
|
|
345
332
|
}),
|
|
346
|
-
|
|
333
|
+
metadata: { internal: true },
|
|
347
334
|
output: z.object({
|
|
348
335
|
created: z.array(z.string()),
|
|
349
336
|
dir: z.string(),
|
|
350
337
|
name: z.string(),
|
|
351
338
|
}),
|
|
339
|
+
run: async (input) => {
|
|
340
|
+
const projectDir = resolve(input.dir ?? '.', input.name);
|
|
341
|
+
const starter = (input.starter ?? 'hello') as Starter;
|
|
342
|
+
const fileMap = collectScaffoldFiles(input.name, starter);
|
|
343
|
+
const files = await writeScaffoldFiles(projectDir, fileMap);
|
|
344
|
+
mkdirSync(join(projectDir, '.trails'), { recursive: true });
|
|
345
|
+
|
|
346
|
+
return Result.ok({
|
|
347
|
+
created: files,
|
|
348
|
+
dir: projectDir,
|
|
349
|
+
name: input.name,
|
|
350
|
+
} satisfies ScaffoldResult);
|
|
351
|
+
},
|
|
352
352
|
});
|