@ontrails/trails 1.0.0-beta.13 → 1.0.0-beta.15
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/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +29 -0
- package/__tests__/examples.test.ts +39 -0
- package/dist/src/app.d.ts.map +1 -1
- package/dist/src/app.js +12 -1
- package/dist/src/app.js.map +1 -1
- package/dist/src/cli.js +4 -3
- package/dist/src/cli.js.map +1 -1
- package/dist/src/trails/add-surface.d.ts +3 -3
- package/dist/src/trails/add-surface.d.ts.map +1 -1
- package/dist/src/trails/add-surface.js +46 -24
- package/dist/src/trails/add-surface.js.map +1 -1
- package/dist/src/trails/add-trail.d.ts +3 -1
- package/dist/src/trails/add-trail.d.ts.map +1 -1
- package/dist/src/trails/add-trail.js +49 -22
- package/dist/src/trails/add-trail.js.map +1 -1
- package/dist/src/trails/add-trailhead.d.ts +13 -0
- package/dist/src/trails/add-trailhead.d.ts.map +1 -0
- package/dist/src/trails/add-trailhead.js +88 -0
- package/dist/src/trails/add-trailhead.js.map +1 -0
- package/dist/src/trails/add-verify.d.ts +1 -1
- package/dist/src/trails/add-verify.d.ts.map +1 -1
- package/dist/src/trails/add-verify.js +17 -16
- package/dist/src/trails/add-verify.js.map +1 -1
- package/dist/src/trails/create-scaffold.d.ts +1 -1
- package/dist/src/trails/create-scaffold.d.ts.map +1 -1
- package/dist/src/trails/create-scaffold.js +34 -27
- package/dist/src/trails/create-scaffold.js.map +1 -1
- package/dist/src/trails/create.d.ts +9 -13
- package/dist/src/trails/create.d.ts.map +1 -1
- package/dist/src/trails/create.js +40 -35
- package/dist/src/trails/create.js.map +1 -1
- package/dist/src/trails/dev-clean.d.ts +9 -0
- package/dist/src/trails/dev-clean.d.ts.map +1 -0
- package/dist/src/trails/dev-clean.js +66 -0
- package/dist/src/trails/dev-clean.js.map +1 -0
- package/dist/src/trails/dev-reset.d.ts +6 -0
- package/dist/src/trails/dev-reset.d.ts.map +1 -0
- package/dist/src/trails/dev-reset.js +39 -0
- package/dist/src/trails/dev-reset.js.map +1 -0
- package/dist/src/trails/dev-stats.d.ts +7 -0
- package/dist/src/trails/dev-stats.d.ts.map +1 -0
- package/dist/src/trails/dev-stats.js +61 -0
- package/dist/src/trails/dev-stats.js.map +1 -0
- package/dist/src/trails/dev-support.d.ts +64 -0
- package/dist/src/trails/dev-support.d.ts.map +1 -0
- package/dist/src/trails/dev-support.js +181 -0
- package/dist/src/trails/dev-support.js.map +1 -0
- package/dist/src/trails/draft-promote.d.ts +18 -0
- package/dist/src/trails/draft-promote.d.ts.map +1 -0
- package/dist/src/trails/draft-promote.js +400 -0
- package/dist/src/trails/draft-promote.js.map +1 -0
- package/dist/src/trails/guide.d.ts +14 -4
- package/dist/src/trails/guide.d.ts.map +1 -1
- package/dist/src/trails/guide.js +22 -41
- package/dist/src/trails/guide.js.map +1 -1
- package/dist/src/trails/load-app.d.ts +9 -1
- package/dist/src/trails/load-app.d.ts.map +1 -1
- package/dist/src/trails/load-app.js +404 -13
- package/dist/src/trails/load-app.js.map +1 -1
- package/dist/src/trails/project.d.ts.map +1 -1
- package/dist/src/trails/project.js +14 -3
- package/dist/src/trails/project.js.map +1 -1
- package/dist/src/trails/survey.d.ts +6 -60
- package/dist/src/trails/survey.d.ts.map +1 -1
- package/dist/src/trails/survey.js +83 -182
- package/dist/src/trails/survey.js.map +1 -1
- package/dist/src/trails/topo-constants.d.ts +3 -0
- package/dist/src/trails/topo-constants.d.ts.map +1 -0
- package/dist/src/trails/topo-constants.js +3 -0
- package/dist/src/trails/topo-constants.js.map +1 -0
- package/dist/src/trails/topo-export.d.ts +19 -0
- package/dist/src/trails/topo-export.d.ts.map +1 -0
- package/dist/src/trails/topo-export.js +31 -0
- package/dist/src/trails/topo-export.js.map +1 -0
- package/dist/src/trails/topo-history.d.ts +20 -0
- package/dist/src/trails/topo-history.d.ts.map +1 -0
- package/dist/src/trails/topo-history.js +32 -0
- package/dist/src/trails/topo-history.js.map +1 -0
- package/dist/src/trails/topo-pin.d.ts +17 -0
- package/dist/src/trails/topo-pin.d.ts.map +1 -0
- package/dist/src/trails/topo-pin.js +31 -0
- package/dist/src/trails/topo-pin.js.map +1 -0
- package/dist/src/trails/topo-read-support.d.ts +58 -0
- package/dist/src/trails/topo-read-support.d.ts.map +1 -0
- package/dist/src/trails/topo-read-support.js +167 -0
- package/dist/src/trails/topo-read-support.js.map +1 -0
- package/dist/src/trails/topo-reports.d.ts +54 -0
- package/dist/src/trails/topo-reports.d.ts.map +1 -0
- package/dist/src/trails/topo-reports.js +128 -0
- package/dist/src/trails/topo-reports.js.map +1 -0
- package/dist/src/trails/topo-show.d.ts +23 -0
- package/dist/src/trails/topo-show.d.ts.map +1 -0
- package/dist/src/trails/topo-show.js +49 -0
- package/dist/src/trails/topo-show.js.map +1 -0
- package/dist/src/trails/topo-store-support.d.ts +13 -0
- package/dist/src/trails/topo-store-support.d.ts.map +1 -0
- package/dist/src/trails/topo-store-support.js +55 -0
- package/dist/src/trails/topo-store-support.js.map +1 -0
- package/dist/src/trails/topo-support.d.ts +76 -0
- package/dist/src/trails/topo-support.d.ts.map +1 -0
- package/dist/src/trails/topo-support.js +132 -0
- package/dist/src/trails/topo-support.js.map +1 -0
- package/dist/src/trails/topo-unpin.d.ts +20 -0
- package/dist/src/trails/topo-unpin.d.ts.map +1 -0
- package/dist/src/trails/topo-unpin.js +44 -0
- package/dist/src/trails/topo-unpin.js.map +1 -0
- package/dist/src/trails/topo-verify.d.ts +5 -0
- package/dist/src/trails/topo-verify.d.ts.map +1 -0
- package/dist/src/trails/topo-verify.js +24 -0
- package/dist/src/trails/topo-verify.js.map +1 -0
- package/dist/src/trails/topo.d.ts +5 -0
- package/dist/src/trails/topo.d.ts.map +1 -0
- package/dist/src/trails/topo.js +63 -0
- package/dist/src/trails/topo.js.map +1 -0
- package/dist/src/trails/warden.d.ts +3 -2
- package/dist/src/trails/warden.d.ts.map +1 -1
- package/dist/src/trails/warden.js +37 -27
- package/dist/src/trails/warden.js.map +1 -1
- package/dist/src/versions.d.ts +12 -0
- package/dist/src/versions.d.ts.map +1 -0
- package/dist/src/versions.js +23 -0
- package/dist/src/versions.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -7
- package/src/__tests__/add-trail.test.ts +97 -0
- package/src/__tests__/create.test.ts +91 -27
- package/src/__tests__/draft-promote.test.ts +144 -0
- package/src/__tests__/guide.test.ts +10 -5
- package/src/__tests__/load-app.test.ts +406 -2
- package/src/__tests__/survey.test.ts +221 -60
- package/src/__tests__/topo-dev.test.ts +426 -0
- package/src/app.ts +24 -2
- package/src/clack.ts +1 -1
- package/src/cli.ts +4 -3
- package/src/trails/add-surface.ts +150 -0
- package/src/trails/add-trail.ts +46 -10
- package/src/trails/add-verify.ts +11 -6
- package/src/trails/create-scaffold.ts +16 -3
- package/src/trails/create.ts +76 -71
- package/src/trails/dev-clean.ts +77 -0
- package/src/trails/dev-reset.ts +45 -0
- package/src/trails/dev-stats.ts +67 -0
- package/src/trails/dev-support.ts +328 -0
- package/src/trails/draft-promote.ts +739 -0
- package/src/trails/guide.ts +23 -41
- package/src/trails/load-app.ts +556 -14
- package/src/trails/project.ts +17 -3
- package/src/trails/survey.ts +110 -285
- package/src/trails/topo-constants.ts +2 -0
- package/src/trails/topo-export.ts +35 -0
- package/src/trails/topo-history.ts +38 -0
- package/src/trails/topo-pin.ts +38 -0
- package/src/trails/topo-read-support.ts +329 -0
- package/src/trails/topo-reports.ts +228 -0
- package/src/trails/topo-show.ts +54 -0
- package/src/trails/topo-store-support.ts +104 -0
- package/src/trails/topo-support.ts +230 -0
- package/src/trails/topo-unpin.ts +56 -0
- package/src/trails/topo-verify.ts +25 -0
- package/src/trails/topo.ts +69 -0
- package/src/trails/warden.ts +13 -3
- package/src/versions.ts +43 -0
- package/tsconfig.tests.json +10 -0
- package/src/trails/add-trailhead.ts +0 -121
package/.turbo/turbo-lint.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# trails
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2003fa5: Prepare the Trails CLI for beta.15 release publishing: derive the CLI version from package metadata, scaffold publishable package ranges, add HTTP surface generation, include the scaffold toolchain dependencies, and avoid generating unsupported Warden flags.
|
|
8
|
+
- Updated dependencies [4ad6b25]
|
|
9
|
+
- @ontrails/core@1.0.0-beta.15
|
|
10
|
+
- @ontrails/cli@1.0.0-beta.15
|
|
11
|
+
- @ontrails/tracing@1.0.0-beta.15
|
|
12
|
+
- @ontrails/warden@1.0.0-beta.15
|
|
13
|
+
- @ontrails/logging@1.0.0-beta.15
|
|
14
|
+
- @ontrails/schema@1.0.0-beta.15
|
|
15
|
+
|
|
16
|
+
## 1.0.0-beta.14
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- 69057e9: Add hierarchical CLI command trees and structured input, enforce established-only topo exports across trailheads, move developer topo and tracker state onto shared `trails.db` with pins and maintenance flows, and ship schema-derived stores through `@ontrails/store` and its Drizzle runtime.
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [69057e9]
|
|
25
|
+
- @ontrails/cli@1.0.0-beta.14
|
|
26
|
+
- @ontrails/core@1.0.0-beta.14
|
|
27
|
+
- @ontrails/logging@1.0.0-beta.14
|
|
28
|
+
- @ontrails/schema@1.0.0-beta.14
|
|
29
|
+
- @ontrails/tracker@1.0.0-beta.14
|
|
30
|
+
- @ontrails/warden@1.0.0-beta.14
|
|
31
|
+
|
|
3
32
|
## 1.0.0-beta.13
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
/* oxlint-disable eslint-plugin-jest/require-hook -- testExamples registers tests at module scope */
|
|
2
|
+
import { afterAll, beforeAll } from 'bun:test';
|
|
3
|
+
import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
5
|
+
|
|
2
6
|
import { testExamples } from '@ontrails/testing';
|
|
3
7
|
|
|
4
8
|
import { app } from '../src/app.js';
|
|
5
9
|
|
|
10
|
+
const trailsWorkspaceDir = resolve(import.meta.dir, '..', '.trails');
|
|
11
|
+
const trailsGitignorePath = join(trailsWorkspaceDir, '.gitignore');
|
|
12
|
+
const trailsWorkspaceSubdirs = ['config', 'dev', 'generated'] as const;
|
|
13
|
+
const trailsGitignore = `# Local config overrides
|
|
14
|
+
config/
|
|
15
|
+
|
|
16
|
+
# Development state
|
|
17
|
+
dev/
|
|
18
|
+
|
|
19
|
+
# Generated artifacts
|
|
20
|
+
generated/
|
|
21
|
+
|
|
22
|
+
# Shared Trails database
|
|
23
|
+
trails.db
|
|
24
|
+
trails.db-shm
|
|
25
|
+
trails.db-wal
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
const resetTrailsWorkspace = (): void => {
|
|
29
|
+
rmSync(trailsWorkspaceDir, { force: true, recursive: true });
|
|
30
|
+
mkdirSync(trailsWorkspaceDir, { recursive: true });
|
|
31
|
+
for (const subdir of trailsWorkspaceSubdirs) {
|
|
32
|
+
mkdirSync(join(trailsWorkspaceDir, subdir), { recursive: true });
|
|
33
|
+
}
|
|
34
|
+
writeFileSync(trailsGitignorePath, trailsGitignore);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
beforeAll(() => {
|
|
38
|
+
resetTrailsWorkspace();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
afterAll(() => {
|
|
42
|
+
resetTrailsWorkspace();
|
|
43
|
+
});
|
|
44
|
+
|
|
6
45
|
testExamples(app);
|
package/dist/src/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,GAAG,+BAqBf,CAAC"}
|
package/dist/src/app.js
CHANGED
|
@@ -4,8 +4,19 @@ import * as addTrail from './trails/add-trail.js';
|
|
|
4
4
|
import * as addVerify from './trails/add-verify.js';
|
|
5
5
|
import * as create from './trails/create.js';
|
|
6
6
|
import * as createScaffold from './trails/create-scaffold.js';
|
|
7
|
+
import * as devClean from './trails/dev-clean.js';
|
|
8
|
+
import * as devReset from './trails/dev-reset.js';
|
|
9
|
+
import * as devStats from './trails/dev-stats.js';
|
|
10
|
+
import * as draftPromote from './trails/draft-promote.js';
|
|
7
11
|
import * as guide from './trails/guide.js';
|
|
8
12
|
import * as survey from './trails/survey.js';
|
|
13
|
+
import * as topoExport from './trails/topo-export.js';
|
|
14
|
+
import * as topoHistory from './trails/topo-history.js';
|
|
15
|
+
import * as topoPin from './trails/topo-pin.js';
|
|
16
|
+
import * as topoShow from './trails/topo-show.js';
|
|
17
|
+
import * as topoCommand from './trails/topo.js';
|
|
18
|
+
import * as topoUnpin from './trails/topo-unpin.js';
|
|
19
|
+
import * as topoVerify from './trails/topo-verify.js';
|
|
9
20
|
import * as warden from './trails/warden.js';
|
|
10
|
-
export const app = topo('trails', survey, guide, warden, create, createScaffold, addSurface, addVerify, addTrail);
|
|
21
|
+
export const app = topo('trails', survey, topoCommand, topoShow, topoHistory, topoPin, topoUnpin, topoExport, topoVerify, devStats, devClean, devReset, guide, draftPromote, warden, create, createScaffold, addSurface, addVerify, addTrail);
|
|
11
22
|
//# sourceMappingURL=app.js.map
|
package/dist/src/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAC;AACtD,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AAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAE7C,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CACrB,QAAQ,EACR,MAAM,EACN,WAAW,EACX,QAAQ,EACR,WAAW,EACX,OAAO,EACP,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,YAAY,EACZ,MAAM,EACN,MAAM,EACN,cAAc,EACd,UAAU,EACV,SAAS,EACT,QAAQ,CACT,CAAC"}
|
package/dist/src/cli.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { outputModePreset } from '@ontrails/cli';
|
|
2
|
-
import {
|
|
2
|
+
import { surface } from '@ontrails/cli/commander';
|
|
3
3
|
import { app } from './app.js';
|
|
4
4
|
import { resolveInputWithClack } from './clack.js';
|
|
5
|
+
import { trailsPackageVersion } from './versions.js';
|
|
5
6
|
// oxlint-disable-next-line require-hook -- CLI entry point
|
|
6
|
-
|
|
7
|
+
await surface(app, {
|
|
7
8
|
description: 'Agent-native, contract-first TypeScript framework',
|
|
8
9
|
name: 'trails',
|
|
9
10
|
presets: [outputModePreset()],
|
|
10
11
|
resolveInput: resolveInputWithClack,
|
|
11
|
-
version:
|
|
12
|
+
version: trailsPackageVersion,
|
|
12
13
|
});
|
|
13
14
|
//# sourceMappingURL=cli.js.map
|
package/dist/src/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,2DAA2D;AAC3D,MAAM,OAAO,CAAC,GAAG,EAAE;IACjB,WAAW,EAAE,mDAAmD;IAChE,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC7B,YAAY,EAAE,qBAAqB;IACnC,OAAO,EAAE,oBAAoB;CAC9B,CAAC,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `add.surface` trail -- Add a surface to an existing project.
|
|
3
3
|
*
|
|
4
|
-
* Generates
|
|
4
|
+
* Generates surface entry points and updates package.json dependencies.
|
|
5
5
|
*/
|
|
6
6
|
export declare const addSurface: import("@ontrails/core").Trail<{
|
|
7
|
-
surface: "cli" | "mcp";
|
|
7
|
+
surface: "cli" | "http" | "mcp";
|
|
8
8
|
dir?: string | undefined;
|
|
9
9
|
}, {
|
|
10
10
|
created: string;
|
|
11
11
|
dependency: string;
|
|
12
|
-
}>;
|
|
12
|
+
}, never>;
|
|
13
13
|
//# sourceMappingURL=add-surface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-surface.d.ts","sourceRoot":"","sources":["../../../src/trails/add-surface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"add-surface.d.ts","sourceRoot":"","sources":["../../../src/trails/add-surface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqHH,eAAO,MAAM,UAAU;;;;;;SA4BrB,CAAC"}
|
|
@@ -1,37 +1,56 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `add.surface` trail -- Add a surface to an existing project.
|
|
3
3
|
*
|
|
4
|
-
* Generates
|
|
4
|
+
* Generates surface entry points and updates package.json dependencies.
|
|
5
5
|
*/
|
|
6
6
|
import { existsSync, mkdirSync } from 'node:fs';
|
|
7
7
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
8
8
|
import { Result, trail } from '@ontrails/core';
|
|
9
9
|
import { z } from 'zod';
|
|
10
|
+
import { ontrailsPackageRange, scaffoldDependencyVersions, } from '../versions.js';
|
|
10
11
|
import { findTopoPath } from './project.js';
|
|
11
|
-
const generateCliEntry = (appImportPath) => `import {
|
|
12
|
+
const generateCliEntry = (appImportPath) => `import { surface } from '@ontrails/cli/commander';
|
|
12
13
|
|
|
13
14
|
import { app } from '${appImportPath}';
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
await surface(app);
|
|
16
17
|
`;
|
|
17
|
-
const generateMcpEntry = (appImportPath) => `import {
|
|
18
|
+
const generateMcpEntry = (appImportPath) => `import { surface } from '@ontrails/mcp';
|
|
18
19
|
|
|
19
20
|
import { app } from '${appImportPath}';
|
|
20
21
|
|
|
21
|
-
await
|
|
22
|
+
await surface(app);
|
|
22
23
|
`;
|
|
24
|
+
const generateHttpEntry = (appImportPath) => `import { surface } from '@ontrails/hono';
|
|
25
|
+
|
|
26
|
+
import { app } from '${appImportPath}';
|
|
27
|
+
|
|
28
|
+
await surface(app, { port: 3000 });
|
|
29
|
+
`;
|
|
30
|
+
const surfaceEntryFiles = {
|
|
31
|
+
cli: 'src/cli.ts',
|
|
32
|
+
http: 'src/http.ts',
|
|
33
|
+
mcp: 'src/mcp.ts',
|
|
34
|
+
};
|
|
35
|
+
const surfaceDependencies = {
|
|
36
|
+
cli: ['@ontrails/cli'],
|
|
37
|
+
http: ['@ontrails/hono', '@ontrails/http'],
|
|
38
|
+
mcp: ['@ontrails/mcp'],
|
|
39
|
+
};
|
|
23
40
|
/** Resolve the entry file for a surface. */
|
|
24
|
-
const getEntryFile = (surface) => surface
|
|
41
|
+
const getEntryFile = (surface) => surfaceEntryFiles[surface];
|
|
25
42
|
// ---------------------------------------------------------------------------
|
|
26
43
|
// Trail definition
|
|
27
44
|
// ---------------------------------------------------------------------------
|
|
28
45
|
/** Patch deps and optionally bin in a parsed package.json. */
|
|
29
46
|
const patchPkgDeps = (pkg, surface, cwd) => {
|
|
30
|
-
const depName =
|
|
47
|
+
const [depName = ''] = surfaceDependencies[surface];
|
|
31
48
|
const deps = (pkg['dependencies'] ?? {});
|
|
32
|
-
|
|
49
|
+
for (const dependency of surfaceDependencies[surface]) {
|
|
50
|
+
deps[dependency] = ontrailsPackageRange;
|
|
51
|
+
}
|
|
33
52
|
if (surface === 'cli') {
|
|
34
|
-
deps['commander'] =
|
|
53
|
+
deps['commander'] = scaffoldDependencyVersions.commander;
|
|
35
54
|
pkg['bin'] = {
|
|
36
55
|
[pkg['name'] ?? basename(cwd)]: './src/cli.ts',
|
|
37
56
|
};
|
|
@@ -43,7 +62,7 @@ const patchPkgDeps = (pkg, surface, cwd) => {
|
|
|
43
62
|
const updatePkgJsonForSurface = async (cwd, surface) => {
|
|
44
63
|
const pkgPath = join(cwd, 'package.json');
|
|
45
64
|
if (!existsSync(pkgPath)) {
|
|
46
|
-
return surface
|
|
65
|
+
return surfaceDependencies[surface][0] ?? '';
|
|
47
66
|
}
|
|
48
67
|
const pkg = (await Bun.file(pkgPath).json());
|
|
49
68
|
const depName = patchPkgDeps(pkg, surface, cwd);
|
|
@@ -55,34 +74,37 @@ const writeSurfaceEntry = async (cwd, surface) => {
|
|
|
55
74
|
const entryFile = getEntryFile(surface);
|
|
56
75
|
const fullEntryPath = join(cwd, entryFile);
|
|
57
76
|
const appImport = (await findTopoPath(cwd)) ?? './app.js';
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
:
|
|
77
|
+
const generators = {
|
|
78
|
+
cli: generateCliEntry,
|
|
79
|
+
http: generateHttpEntry,
|
|
80
|
+
mcp: generateMcpEntry,
|
|
81
|
+
};
|
|
82
|
+
const content = generators[surface](appImport);
|
|
61
83
|
mkdirSync(dirname(fullEntryPath), { recursive: true });
|
|
62
84
|
await Bun.write(fullEntryPath, content);
|
|
63
85
|
return entryFile;
|
|
64
86
|
};
|
|
65
87
|
export const addSurface = trail('add.surface', {
|
|
66
|
-
|
|
67
|
-
input: z.object({
|
|
68
|
-
dir: z.string().optional().describe('Project directory'),
|
|
69
|
-
surface: z.enum(['cli', 'mcp']).describe('Surface to add'),
|
|
70
|
-
}),
|
|
71
|
-
output: z.object({
|
|
72
|
-
created: z.string(),
|
|
73
|
-
dependency: z.string(),
|
|
74
|
-
}),
|
|
75
|
-
run: async (input) => {
|
|
88
|
+
blaze: async (input) => {
|
|
76
89
|
const cwd = resolve(input.dir ?? '.');
|
|
77
90
|
const { surface } = input;
|
|
78
91
|
const entryFile = getEntryFile(surface);
|
|
79
92
|
if (existsSync(join(cwd, entryFile))) {
|
|
80
|
-
return Result.err(new Error(`${surface.toUpperCase()}
|
|
93
|
+
return Result.err(new Error(`${surface.toUpperCase()} surface already exists. Nothing to do.`));
|
|
81
94
|
}
|
|
82
95
|
return Result.ok({
|
|
83
96
|
created: await writeSurfaceEntry(cwd, surface),
|
|
84
97
|
dependency: await updatePkgJsonForSurface(cwd, surface),
|
|
85
98
|
});
|
|
86
99
|
},
|
|
100
|
+
description: 'Add a surface to an existing project',
|
|
101
|
+
input: z.object({
|
|
102
|
+
dir: z.string().optional().describe('Project directory'),
|
|
103
|
+
surface: z.enum(['cli', 'http', 'mcp']).describe('Surface to add'),
|
|
104
|
+
}),
|
|
105
|
+
output: z.object({
|
|
106
|
+
created: z.string(),
|
|
107
|
+
dependency: z.string(),
|
|
108
|
+
}),
|
|
87
109
|
});
|
|
88
110
|
//# sourceMappingURL=add-surface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-surface.js","sourceRoot":"","sources":["../../../src/trails/add-surface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scaffold a new trail file with tests.
|
|
3
3
|
*/
|
|
4
4
|
export declare const addTrail: import("@ontrails/core").Trail<{
|
|
5
|
+
description: string;
|
|
6
|
+
exampleName: string;
|
|
5
7
|
id: string;
|
|
6
8
|
intent: "read" | "write" | "destroy";
|
|
7
9
|
}, {
|
|
8
10
|
created: string[];
|
|
9
|
-
}>;
|
|
11
|
+
}, never>;
|
|
10
12
|
//# sourceMappingURL=add-trail.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-trail.d.ts","sourceRoot":"","sources":["../../../src/trails/add-trail.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"add-trail.d.ts","sourceRoot":"","sources":["../../../src/trails/add-trail.ts"],"names":[],"mappings":"AAAA;;GAEG;AA4EH,eAAO,MAAM,QAAQ;;;;;;;SAmDnB,CAAC"}
|
|
@@ -8,35 +8,44 @@ import { z } from 'zod';
|
|
|
8
8
|
// ---------------------------------------------------------------------------
|
|
9
9
|
// Helpers
|
|
10
10
|
// ---------------------------------------------------------------------------
|
|
11
|
-
const
|
|
11
|
+
const literal = (value) => JSON.stringify(value);
|
|
12
|
+
const deriveExampleMessage = (id) => `${id} completed`;
|
|
13
|
+
const generateTrailFile = (id, description, exampleName, intent) => {
|
|
12
14
|
const intentLine = intent === 'write' ? '' : `\n intent: '${intent}',`;
|
|
15
|
+
const exampleMessage = deriveExampleMessage(id);
|
|
13
16
|
return `import { Result, trail } from '@ontrails/core';
|
|
14
17
|
import { z } from 'zod';
|
|
15
18
|
|
|
16
19
|
export const ${id.replaceAll('.', '_')} = trail('${id}', {
|
|
17
|
-
|
|
20
|
+
blaze: async () => {
|
|
21
|
+
return Result.ok({ message: ${literal(exampleMessage)} });
|
|
22
|
+
},
|
|
23
|
+
description: ${literal(description)},
|
|
18
24
|
examples: [
|
|
19
25
|
{
|
|
26
|
+
expected: { message: ${literal(exampleMessage)} },
|
|
20
27
|
input: {},
|
|
21
|
-
name:
|
|
28
|
+
name: ${literal(exampleName)},
|
|
22
29
|
},
|
|
23
30
|
],
|
|
24
|
-
run: async (input) => {
|
|
25
|
-
return Result.ok({ message: 'TODO' });
|
|
26
|
-
},
|
|
27
31
|
input: z.object({}),${intentLine}
|
|
28
32
|
output: z.object({ message: z.string() }),
|
|
29
33
|
});
|
|
30
34
|
`;
|
|
31
35
|
};
|
|
32
|
-
const generateTestFile = (id) => {
|
|
36
|
+
const generateTestFile = (id, exampleName) => {
|
|
33
37
|
const moduleName = id.replaceAll('.', '-');
|
|
34
38
|
const trailName = id.replaceAll('.', '_');
|
|
39
|
+
const exampleMessage = deriveExampleMessage(id);
|
|
35
40
|
return `import { testTrail } from '@ontrails/testing';
|
|
36
41
|
import { ${trailName} } from '../src/trails/${moduleName}.js';
|
|
37
42
|
|
|
38
43
|
testTrail(${trailName}, [
|
|
39
|
-
{
|
|
44
|
+
{
|
|
45
|
+
description: ${literal(exampleName)},
|
|
46
|
+
expectValue: { message: ${literal(exampleMessage)} },
|
|
47
|
+
input: {},
|
|
48
|
+
},
|
|
40
49
|
]);
|
|
41
50
|
`;
|
|
42
51
|
};
|
|
@@ -49,29 +58,47 @@ const writeWithDirs = async (filePath, content) => {
|
|
|
49
58
|
await Bun.write(filePath, content);
|
|
50
59
|
};
|
|
51
60
|
export const addTrail = trail('add.trail', {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
id: z.string().describe('Trail ID (e.g., entity.update)'),
|
|
55
|
-
intent: z
|
|
56
|
-
.enum(['read', 'write', 'destroy'])
|
|
57
|
-
.default('write')
|
|
58
|
-
.describe('Trail intent'),
|
|
59
|
-
}),
|
|
60
|
-
output: z.object({
|
|
61
|
-
created: z.array(z.string()),
|
|
62
|
-
}),
|
|
63
|
-
run: async (input, ctx) => {
|
|
61
|
+
args: ['id'],
|
|
62
|
+
blaze: async (input, ctx) => {
|
|
64
63
|
const { id } = input;
|
|
65
64
|
const moduleName = id.replaceAll('.', '-');
|
|
66
65
|
const cwd = resolve(ctx.cwd ?? '.');
|
|
67
66
|
const files = new Map([
|
|
68
|
-
[
|
|
69
|
-
|
|
67
|
+
[
|
|
68
|
+
`src/trails/${moduleName}.ts`,
|
|
69
|
+
generateTrailFile(id, input.description, input.exampleName, input.intent),
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
`__tests__/${moduleName}.test.ts`,
|
|
73
|
+
generateTestFile(id, input.exampleName),
|
|
74
|
+
],
|
|
70
75
|
]);
|
|
71
76
|
for (const [relativePath, content] of files) {
|
|
72
77
|
await writeWithDirs(join(cwd, relativePath), content);
|
|
73
78
|
}
|
|
74
79
|
return Result.ok({ created: [...files.keys()] });
|
|
75
80
|
},
|
|
81
|
+
description: 'Scaffold a new trail with tests and examples',
|
|
82
|
+
input: z.object({
|
|
83
|
+
description: z
|
|
84
|
+
.string()
|
|
85
|
+
.min(1, 'Trail description is required')
|
|
86
|
+
.describe('Trail description'),
|
|
87
|
+
exampleName: z
|
|
88
|
+
.string()
|
|
89
|
+
.min(1, 'Starter example name is required')
|
|
90
|
+
.describe('Starter example name'),
|
|
91
|
+
id: z
|
|
92
|
+
.string()
|
|
93
|
+
.min(1, 'Trail ID is required')
|
|
94
|
+
.describe('Trail ID (e.g., entity.update)'),
|
|
95
|
+
intent: z
|
|
96
|
+
.enum(['read', 'write', 'destroy'])
|
|
97
|
+
.default('write')
|
|
98
|
+
.describe('Trail intent'),
|
|
99
|
+
}),
|
|
100
|
+
output: z.object({
|
|
101
|
+
created: z.array(z.string()),
|
|
102
|
+
}),
|
|
76
103
|
});
|
|
77
104
|
//# sourceMappingURL=add-trail.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-trail.js","sourceRoot":"","sources":["../../../src/trails/add-trail.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC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AC,MAAM,CAAC;QACf,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KAC7B,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `add.trailhead` trail -- Add a trailhead to an existing project.
|
|
3
|
+
*
|
|
4
|
+
* Generates the CLI or MCP entry point and updates package.json dependencies.
|
|
5
|
+
*/
|
|
6
|
+
export declare const addTrailhead: import("@ontrails/core").Trail<{
|
|
7
|
+
trailhead: "cli" | "mcp";
|
|
8
|
+
dir?: string | undefined;
|
|
9
|
+
}, {
|
|
10
|
+
created: string;
|
|
11
|
+
dependency: string;
|
|
12
|
+
}, never>;
|
|
13
|
+
//# sourceMappingURL=add-trailhead.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-trailhead.d.ts","sourceRoot":"","sources":["../../../src/trails/add-trailhead.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwFH,eAAO,MAAM,YAAY;;;;;;SA4BvB,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `add.trailhead` trail -- Add a trailhead to an existing project.
|
|
3
|
+
*
|
|
4
|
+
* Generates the CLI or MCP entry point and updates package.json dependencies.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, mkdirSync } from 'node:fs';
|
|
7
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
8
|
+
import { Result, trail } from '@ontrails/core';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { findTopoPath } from './project.js';
|
|
11
|
+
const generateCliEntry = (appImportPath) => `import { surface } from '@ontrails/cli/commander';
|
|
12
|
+
|
|
13
|
+
import { app } from '${appImportPath}';
|
|
14
|
+
|
|
15
|
+
await surface(app);
|
|
16
|
+
`;
|
|
17
|
+
const generateMcpEntry = (appImportPath) => `import { surface } from '@ontrails/mcp';
|
|
18
|
+
|
|
19
|
+
import { app } from '${appImportPath}';
|
|
20
|
+
|
|
21
|
+
await surface(app);
|
|
22
|
+
`;
|
|
23
|
+
/** Resolve the entry file for a trailhead. */
|
|
24
|
+
const getEntryFile = (trailhead) => trailhead === 'cli' ? 'src/cli.ts' : 'src/mcp.ts';
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
// Trail definition
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
/** Patch deps and optionally bin in a parsed package.json. */
|
|
29
|
+
const patchPkgDeps = (pkg, trailhead, cwd) => {
|
|
30
|
+
const depName = trailhead === 'cli' ? '@ontrails/cli' : '@ontrails/mcp';
|
|
31
|
+
const deps = (pkg['dependencies'] ?? {});
|
|
32
|
+
deps[depName] = 'workspace:*';
|
|
33
|
+
if (trailhead === 'cli') {
|
|
34
|
+
deps['commander'] = '^14.0.0';
|
|
35
|
+
pkg['bin'] = {
|
|
36
|
+
[pkg['name'] ?? basename(cwd)]: './src/cli.ts',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
pkg['dependencies'] = Object.fromEntries(Object.entries(deps).toSorted(([a], [b]) => a.localeCompare(b)));
|
|
40
|
+
return depName;
|
|
41
|
+
};
|
|
42
|
+
/** Update package.json with trailhead dependency and CLI bin if needed. */
|
|
43
|
+
const updatePkgJsonForTrailhead = async (cwd, trailhead) => {
|
|
44
|
+
const pkgPath = join(cwd, 'package.json');
|
|
45
|
+
if (!existsSync(pkgPath)) {
|
|
46
|
+
return trailhead === 'cli' ? '@ontrails/cli' : '@ontrails/mcp';
|
|
47
|
+
}
|
|
48
|
+
const pkg = (await Bun.file(pkgPath).json());
|
|
49
|
+
const depName = patchPkgDeps(pkg, trailhead, cwd);
|
|
50
|
+
await Bun.write(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
51
|
+
return depName;
|
|
52
|
+
};
|
|
53
|
+
/** Create the entry file for a trailhead and return the relative path. */
|
|
54
|
+
const writeTrailheadEntry = async (cwd, trailhead) => {
|
|
55
|
+
const entryFile = getEntryFile(trailhead);
|
|
56
|
+
const fullEntryPath = join(cwd, entryFile);
|
|
57
|
+
const appImport = (await findTopoPath(cwd)) ?? './app.js';
|
|
58
|
+
const content = trailhead === 'cli'
|
|
59
|
+
? generateCliEntry(appImport)
|
|
60
|
+
: generateMcpEntry(appImport);
|
|
61
|
+
mkdirSync(dirname(fullEntryPath), { recursive: true });
|
|
62
|
+
await Bun.write(fullEntryPath, content);
|
|
63
|
+
return entryFile;
|
|
64
|
+
};
|
|
65
|
+
export const addTrailhead = trail('add.trailhead', {
|
|
66
|
+
blaze: async (input) => {
|
|
67
|
+
const cwd = resolve(input.dir ?? '.');
|
|
68
|
+
const { trailhead } = input;
|
|
69
|
+
const entryFile = getEntryFile(trailhead);
|
|
70
|
+
if (existsSync(join(cwd, entryFile))) {
|
|
71
|
+
return Result.err(new Error(`${trailhead.toUpperCase()} trailhead already exists. Nothing to do.`));
|
|
72
|
+
}
|
|
73
|
+
return Result.ok({
|
|
74
|
+
created: await writeTrailheadEntry(cwd, trailhead),
|
|
75
|
+
dependency: await updatePkgJsonForTrailhead(cwd, trailhead),
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
description: 'Add a trailhead to an existing project',
|
|
79
|
+
input: z.object({
|
|
80
|
+
dir: z.string().optional().describe('Project directory'),
|
|
81
|
+
trailhead: z.enum(['cli', 'mcp']).describe('Trailhead to add'),
|
|
82
|
+
}),
|
|
83
|
+
output: z.object({
|
|
84
|
+
created: z.string(),
|
|
85
|
+
dependency: z.string(),
|
|
86
|
+
}),
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=add-trailhead.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-trailhead.js","sourceRoot":"","sources":["../../../src/trails/add-trailhead.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE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,CAAC,MAAM,CAAC;QACf,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;KACvB,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-verify.d.ts","sourceRoot":"","sources":["../../../src/trails/add-verify.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"add-verify.d.ts","sourceRoot":"","sources":["../../../src/trails/add-verify.ts"],"names":[],"mappings":"AAAA;;GAEG;AA2DH,eAAO,MAAM,SAAS;;;;;SA8BpB,CAAC"}
|