@ontrails/trails 1.0.0-beta.2 → 1.0.0-beta.22
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 +647 -0
- package/README.md +26 -0
- package/package.json +28 -7
- package/src/app.ts +86 -2
- package/src/clack.ts +22 -0
- package/src/cli.ts +330 -11
- package/src/completions.ts +240 -0
- package/src/lifecycle-source-io.ts +33 -0
- package/src/load-app-mirror.ts +202 -0
- package/src/local-state-io.ts +153 -0
- package/src/mcp-app.ts +30 -0
- package/src/mcp-options.ts +77 -0
- package/src/mcp.ts +8 -0
- package/src/project-writes.ts +377 -0
- package/src/release/bindings.ts +39 -0
- package/src/release/check.ts +818 -0
- package/src/release/config.ts +63 -0
- package/src/release/contract-facts.ts +425 -0
- package/src/release/index.ts +85 -0
- package/src/release/native-bun-publish.ts +651 -0
- package/src/release/native-bun-registry.ts +350 -0
- package/src/release/packed-artifacts-smoke.ts +236 -0
- package/src/release/smoke.ts +46 -0
- package/src/release/wayfinder-dogfood-smoke.ts +226 -0
- package/src/retired-topo-command.ts +36 -0
- package/src/run-adapter-check.ts +76 -0
- package/src/run-collision.ts +126 -0
- package/src/run-completions-install.ts +179 -0
- package/src/run-example.ts +149 -0
- package/src/run-examples.ts +148 -0
- package/src/run-quiet.ts +75 -0
- package/src/run-release-check.ts +74 -0
- package/src/run-trace.ts +273 -0
- package/src/run-warden.ts +39 -0
- package/src/run-watch.ts +432 -0
- package/src/scaffold-version-sync.ts +183 -0
- package/src/scaffold-versions.generated.ts +12 -0
- package/src/trails/adapter-check.ts +244 -0
- package/src/trails/add-surface.ts +94 -40
- package/src/trails/add-trail.ts +79 -41
- package/src/trails/add-verify.ts +95 -25
- package/src/trails/compile.ts +67 -0
- package/src/trails/completions-complete.ts +165 -0
- package/src/trails/completions.ts +47 -0
- package/src/trails/create-adapter.ts +1084 -0
- package/src/trails/create-scaffold.ts +399 -104
- package/src/trails/create-versions.ts +62 -0
- package/src/trails/create.ts +185 -71
- package/src/trails/deprecate.ts +59 -0
- package/src/trails/dev-clean.ts +82 -0
- package/src/trails/dev-reset.ts +50 -0
- package/src/trails/dev-stats.ts +72 -0
- package/src/trails/dev-support.ts +340 -0
- package/src/trails/doctor.ts +56 -0
- package/src/trails/draft-promote.ts +949 -0
- package/src/trails/guide.ts +74 -68
- package/src/trails/load-app.ts +1143 -15
- package/src/trails/project.ts +17 -3
- package/src/trails/release-check.ts +104 -0
- package/src/trails/release-smoke.ts +48 -0
- package/src/trails/revise.ts +53 -0
- package/src/trails/root-dir.ts +21 -0
- package/src/trails/run-example.ts +491 -0
- package/src/trails/run-examples.ts +145 -0
- package/src/trails/run.ts +410 -0
- package/src/trails/scaffold-json.ts +58 -0
- package/src/trails/survey.ts +881 -226
- package/src/trails/topo-activation.ts +385 -0
- package/src/trails/topo-constants.ts +2 -0
- package/src/trails/topo-history.ts +47 -0
- package/src/trails/topo-output-schemas.ts +248 -0
- package/src/trails/topo-pin.ts +52 -0
- package/src/trails/topo-read-support.ts +313 -0
- package/src/trails/topo-reports.ts +807 -0
- package/src/trails/topo-store-support.ts +174 -0
- package/src/trails/topo-support.ts +220 -0
- package/src/trails/topo-unpin.ts +61 -0
- package/src/trails/topo.ts +106 -0
- package/src/trails/validate.ts +38 -0
- package/src/trails/version-lifecycle-support.ts +945 -0
- package/src/trails/warden-guide.ts +129 -0
- package/src/trails/warden.ts +165 -58
- package/src/versions.ts +31 -0
- package/.turbo/turbo-build.log +0 -1
- package/.turbo/turbo-lint.log +0 -3
- package/.turbo/turbo-typecheck.log +0 -1
- package/__tests__/examples.test.ts +0 -6
- package/dist/bin/trails.d.ts +0 -3
- package/dist/bin/trails.d.ts.map +0 -1
- package/dist/bin/trails.js +0 -4
- package/dist/bin/trails.js.map +0 -1
- package/dist/src/app.d.ts +0 -2
- package/dist/src/app.d.ts.map +0 -1
- package/dist/src/app.js +0 -11
- package/dist/src/app.js.map +0 -1
- package/dist/src/clack.d.ts +0 -9
- package/dist/src/clack.d.ts.map +0 -1
- package/dist/src/clack.js +0 -62
- package/dist/src/clack.js.map +0 -1
- package/dist/src/cli.d.ts +0 -2
- package/dist/src/cli.d.ts.map +0 -1
- package/dist/src/cli.js +0 -13
- package/dist/src/cli.js.map +0 -1
- package/dist/src/trails/add-surface.d.ts +0 -13
- package/dist/src/trails/add-surface.d.ts.map +0 -1
- package/dist/src/trails/add-surface.js +0 -88
- package/dist/src/trails/add-surface.js.map +0 -1
- package/dist/src/trails/add-trail.d.ts +0 -11
- package/dist/src/trails/add-trail.d.ts.map +0 -1
- package/dist/src/trails/add-trail.js +0 -85
- package/dist/src/trails/add-trail.js.map +0 -1
- package/dist/src/trails/add-verify.d.ts +0 -10
- package/dist/src/trails/add-verify.d.ts.map +0 -1
- package/dist/src/trails/add-verify.js +0 -67
- package/dist/src/trails/add-verify.js.map +0 -1
- package/dist/src/trails/create-scaffold.d.ts +0 -15
- package/dist/src/trails/create-scaffold.d.ts.map +0 -1
- package/dist/src/trails/create-scaffold.js +0 -288
- package/dist/src/trails/create-scaffold.js.map +0 -1
- package/dist/src/trails/create.d.ts +0 -22
- package/dist/src/trails/create.d.ts.map +0 -1
- package/dist/src/trails/create.js +0 -121
- package/dist/src/trails/create.js.map +0 -1
- package/dist/src/trails/guide.d.ts +0 -11
- package/dist/src/trails/guide.d.ts.map +0 -1
- package/dist/src/trails/guide.js +0 -80
- package/dist/src/trails/guide.js.map +0 -1
- package/dist/src/trails/load-app.d.ts +0 -4
- package/dist/src/trails/load-app.d.ts.map +0 -1
- package/dist/src/trails/load-app.js +0 -24
- package/dist/src/trails/load-app.js.map +0 -1
- package/dist/src/trails/project.d.ts +0 -8
- package/dist/src/trails/project.d.ts.map +0 -1
- package/dist/src/trails/project.js +0 -43
- package/dist/src/trails/project.js.map +0 -1
- package/dist/src/trails/survey.d.ts +0 -33
- package/dist/src/trails/survey.d.ts.map +0 -1
- package/dist/src/trails/survey.js +0 -225
- package/dist/src/trails/survey.js.map +0 -1
- package/dist/src/trails/warden.d.ts +0 -19
- package/dist/src/trails/warden.d.ts.map +0 -1
- package/dist/src/trails/warden.js +0 -88
- package/dist/src/trails/warden.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/__tests__/create.test.ts +0 -349
- package/src/__tests__/guide.test.ts +0 -91
- package/src/__tests__/load-app.test.ts +0 -15
- package/src/__tests__/survey.test.ts +0 -161
- package/src/__tests__/warden.test.ts +0 -74
- package/tsconfig.json +0 -9
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'bun:test';
|
|
2
|
-
|
|
3
|
-
import { topo, trail, Result } from '@ontrails/core';
|
|
4
|
-
import {
|
|
5
|
-
generateSurfaceMap,
|
|
6
|
-
hashSurfaceMap,
|
|
7
|
-
diffSurfaceMaps,
|
|
8
|
-
} from '@ontrails/schema';
|
|
9
|
-
import type { SurfaceMap } from '@ontrails/schema';
|
|
10
|
-
import { z } from 'zod';
|
|
11
|
-
|
|
12
|
-
import { generateBriefReport } from '../trails/survey.js';
|
|
13
|
-
import type { BriefReport } from '../trails/survey.js';
|
|
14
|
-
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
// Test fixtures
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
|
|
19
|
-
const helloTrail = trail('hello', {
|
|
20
|
-
description: 'Say hello',
|
|
21
|
-
detours: {
|
|
22
|
-
NotFoundError: ['search'],
|
|
23
|
-
},
|
|
24
|
-
examples: [
|
|
25
|
-
{
|
|
26
|
-
expected: { message: 'Hello, world!' },
|
|
27
|
-
input: {},
|
|
28
|
-
name: 'Default greeting',
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
implementation: (input) => {
|
|
32
|
-
const name = input.name ?? 'world';
|
|
33
|
-
return Result.ok({ message: `Hello, ${name}!` });
|
|
34
|
-
},
|
|
35
|
-
input: z.object({ name: z.string().optional() }),
|
|
36
|
-
output: z.object({ message: z.string() }),
|
|
37
|
-
readOnly: true,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const byeTrail = trail('bye', {
|
|
41
|
-
description: 'Say goodbye',
|
|
42
|
-
implementation: (input) => Result.ok({ message: `Goodbye, ${input.name}!` }),
|
|
43
|
-
input: z.object({ name: z.string() }),
|
|
44
|
-
output: z.object({ message: z.string() }),
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const app = topo('test-app', { bye: byeTrail, hello: helloTrail });
|
|
48
|
-
|
|
49
|
-
// ---------------------------------------------------------------------------
|
|
50
|
-
// Tests
|
|
51
|
-
// ---------------------------------------------------------------------------
|
|
52
|
-
|
|
53
|
-
describe('trails survey', () => {
|
|
54
|
-
test('generateSurfaceMap includes all trails', () => {
|
|
55
|
-
const surfaceMap = generateSurfaceMap(app);
|
|
56
|
-
expect(surfaceMap.entries.length).toBe(2);
|
|
57
|
-
const ids = surfaceMap.entries.map((e) => e.id);
|
|
58
|
-
expect(ids).toContain('hello');
|
|
59
|
-
expect(ids).toContain('bye');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test('surface map entries have expected fields', () => {
|
|
63
|
-
const surfaceMap = generateSurfaceMap(app);
|
|
64
|
-
const hello = surfaceMap.entries.find((e) => e.id === 'hello');
|
|
65
|
-
expect(hello).toBeDefined();
|
|
66
|
-
expect(hello?.kind).toBe('trail');
|
|
67
|
-
expect(hello?.readOnly).toBe(true);
|
|
68
|
-
expect(hello?.exampleCount).toBe(1);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test('JSON output is valid JSON', () => {
|
|
72
|
-
const surfaceMap = generateSurfaceMap(app);
|
|
73
|
-
const json = JSON.stringify(surfaceMap, null, 2);
|
|
74
|
-
const parsed = JSON.parse(json) as SurfaceMap;
|
|
75
|
-
expect(parsed.version).toBe('1.0');
|
|
76
|
-
expect(parsed.entries.length).toBe(2);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test('hashSurfaceMap produces stable hash', () => {
|
|
80
|
-
const surfaceMap = generateSurfaceMap(app);
|
|
81
|
-
const hash1 = hashSurfaceMap(surfaceMap);
|
|
82
|
-
const hash2 = hashSurfaceMap(surfaceMap);
|
|
83
|
-
expect(hash1).toBe(hash2);
|
|
84
|
-
// SHA-256 hex
|
|
85
|
-
expect(hash1.length).toBe(64);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test('diffSurfaceMaps detects added trails', () => {
|
|
89
|
-
const prev = generateSurfaceMap(topo('test', { hello: helloTrail }));
|
|
90
|
-
const curr = generateSurfaceMap(app);
|
|
91
|
-
const diff = diffSurfaceMaps(prev, curr);
|
|
92
|
-
|
|
93
|
-
expect(diff.info.length).toBeGreaterThan(0);
|
|
94
|
-
const addedBye = diff.info.find((e) => e.id === 'bye');
|
|
95
|
-
expect(addedBye).toBeDefined();
|
|
96
|
-
expect(addedBye?.change).toBe('added');
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
test('diffSurfaceMaps detects removed trails', () => {
|
|
100
|
-
const prev = generateSurfaceMap(app);
|
|
101
|
-
const curr = generateSurfaceMap(topo('test', { hello: helloTrail }));
|
|
102
|
-
const diff = diffSurfaceMaps(prev, curr);
|
|
103
|
-
|
|
104
|
-
expect(diff.hasBreaking).toBe(true);
|
|
105
|
-
const removedBye = diff.breaking.find((e) => e.id === 'bye');
|
|
106
|
-
expect(removedBye).toBeDefined();
|
|
107
|
-
expect(removedBye?.change).toBe('removed');
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
test('diffSurfaceMaps returns empty for identical maps', () => {
|
|
111
|
-
const map = generateSurfaceMap(app);
|
|
112
|
-
const diff = diffSurfaceMaps(map, map);
|
|
113
|
-
expect(diff.entries.length).toBe(0);
|
|
114
|
-
expect(diff.hasBreaking).toBe(false);
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
// ---------------------------------------------------------------------------
|
|
119
|
-
// Brief mode (formerly scout)
|
|
120
|
-
// ---------------------------------------------------------------------------
|
|
121
|
-
|
|
122
|
-
describe('trails survey --brief', () => {
|
|
123
|
-
test('produces a valid capability report', () => {
|
|
124
|
-
const report = generateBriefReport(app);
|
|
125
|
-
expect(report.name).toBe('test-app');
|
|
126
|
-
expect(report.contractVersion).toBe('2026-03');
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
test('report includes correct trail count', () => {
|
|
130
|
-
const report = generateBriefReport(app);
|
|
131
|
-
expect(report.trails).toBe(2);
|
|
132
|
-
expect(report.hikes).toBe(0);
|
|
133
|
-
expect(report.events).toBe(0);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
test('detects features in use', () => {
|
|
137
|
-
const report = generateBriefReport(app);
|
|
138
|
-
expect(report.features.outputSchemas).toBe(true);
|
|
139
|
-
expect(report.features.examples).toBe(true);
|
|
140
|
-
expect(report.features.detours).toBe(true);
|
|
141
|
-
expect(report.features.hikes).toBe(false);
|
|
142
|
-
expect(report.features.events).toBe(false);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
test('JSON output is valid', () => {
|
|
146
|
-
const report = generateBriefReport(app);
|
|
147
|
-
const json = JSON.stringify(report, null, 2);
|
|
148
|
-
const parsed = JSON.parse(json) as BriefReport;
|
|
149
|
-
expect(parsed.name).toBe('test-app');
|
|
150
|
-
expect(parsed.trails).toBe(2);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
test('empty app reports zero features', () => {
|
|
154
|
-
const emptyApp = topo('empty', {});
|
|
155
|
-
const report = generateBriefReport(emptyApp);
|
|
156
|
-
expect(report.trails).toBe(0);
|
|
157
|
-
expect(report.features.outputSchemas).toBe(false);
|
|
158
|
-
expect(report.features.examples).toBe(false);
|
|
159
|
-
expect(report.features.detours).toBe(false);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'bun:test';
|
|
2
|
-
import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
|
|
6
|
-
import { formatWardenReport, runWarden } from '@ontrails/warden';
|
|
7
|
-
|
|
8
|
-
const makeTempDir = (): string => {
|
|
9
|
-
const dir = join(
|
|
10
|
-
tmpdir(),
|
|
11
|
-
`trails-warden-test-${Date.now()}-${Math.random().toString(36).slice(2)}`
|
|
12
|
-
);
|
|
13
|
-
mkdirSync(dir, { recursive: true });
|
|
14
|
-
return dir;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
describe('trails warden', () => {
|
|
18
|
-
test('runs lint + drift checks and produces a report', async () => {
|
|
19
|
-
const dir = makeTempDir();
|
|
20
|
-
try {
|
|
21
|
-
writeFileSync(
|
|
22
|
-
join(dir, 'good.ts'),
|
|
23
|
-
`trail("hello", {
|
|
24
|
-
implementation: async (input, ctx) => {
|
|
25
|
-
return Result.ok({ message: "hi" });
|
|
26
|
-
}
|
|
27
|
-
})`
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const report = await runWarden({ rootDir: dir });
|
|
31
|
-
expect(report.diagnostics).toBeDefined();
|
|
32
|
-
expect(typeof report.errorCount).toBe('number');
|
|
33
|
-
expect(typeof report.warnCount).toBe('number');
|
|
34
|
-
expect(typeof report.passed).toBe('boolean');
|
|
35
|
-
} finally {
|
|
36
|
-
rmSync(dir, { force: true, recursive: true });
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test('lintOnly skips drift detection', async () => {
|
|
41
|
-
const dir = makeTempDir();
|
|
42
|
-
try {
|
|
43
|
-
writeFileSync(join(dir, 'empty.ts'), 'export {}');
|
|
44
|
-
const report = await runWarden({ lintOnly: true, rootDir: dir });
|
|
45
|
-
expect(report.drift).toBeNull();
|
|
46
|
-
} finally {
|
|
47
|
-
rmSync(dir, { force: true, recursive: true });
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test('driftOnly skips lint rules', async () => {
|
|
52
|
-
const dir = makeTempDir();
|
|
53
|
-
try {
|
|
54
|
-
writeFileSync(
|
|
55
|
-
join(dir, 'bad.ts'),
|
|
56
|
-
`trail("x", {
|
|
57
|
-
implementation: async () => { throw new Error("boom"); }
|
|
58
|
-
})`
|
|
59
|
-
);
|
|
60
|
-
const report = await runWarden({ driftOnly: true, rootDir: dir });
|
|
61
|
-
expect(report.diagnostics.length).toBe(0);
|
|
62
|
-
expect(report.drift).not.toBeNull();
|
|
63
|
-
} finally {
|
|
64
|
-
rmSync(dir, { force: true, recursive: true });
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('formatWardenReport produces human-readable output', async () => {
|
|
69
|
-
const report = await runWarden({ rootDir: '/dev/null' });
|
|
70
|
-
const output = formatWardenReport(report);
|
|
71
|
-
expect(output).toContain('Warden Report');
|
|
72
|
-
expect(typeof output).toBe('string');
|
|
73
|
-
});
|
|
74
|
-
});
|