forgebook 0.1.0 → 0.1.3
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/README.md +26 -5
- package/dist/bin/forgebook/agentClient.d.ts +22 -0
- package/dist/bin/forgebook/agentClient.d.ts.map +1 -0
- package/dist/bin/forgebook/agentClient.js +70 -0
- package/dist/bin/forgebook/agentClient.js.map +1 -0
- package/dist/bin/forgebook/agentText.d.ts +18 -0
- package/dist/bin/forgebook/agentText.d.ts.map +1 -0
- package/dist/bin/forgebook/agentText.js +44 -0
- package/dist/bin/forgebook/agentText.js.map +1 -0
- package/dist/bin/forgebook/forgebook.mjs +228 -49
- package/dist/bin/forgebook/forgebook.mjs.map +1 -1
- package/dist/bin/forgebook/mcpTools.d.ts +12 -0
- package/dist/bin/forgebook/mcpTools.d.ts.map +1 -0
- package/dist/bin/forgebook/mcpTools.js +89 -0
- package/dist/bin/forgebook/mcpTools.js.map +1 -0
- package/dist/bin/forgebook-docs/forgebook-docs.mjs +1 -2
- package/dist/bin/forgebook-docs/forgebook-docs.mjs.map +1 -1
- package/dist/src/backdrops.d.ts +4 -4
- package/dist/src/componentDocs.d.ts +1 -1
- package/dist/src/componentDocs.js +1 -1
- package/dist/src/frame/frameClock.d.ts +3 -3
- package/dist/src/frame/frameView.js +1 -1
- package/dist/src/frame/mountFrame.d.ts +2 -2
- package/dist/src/frame/mountFrame.js +2 -2
- package/dist/src/frame/storyModule.d.ts +1 -1
- package/dist/src/frame/storyModule.d.ts.map +1 -1
- package/dist/src/frame/storyRun.d.ts +2 -2
- package/dist/src/frame/storyRun.js +1 -1
- package/dist/src/messages.d.ts +1 -1
- package/dist/src/messages.js +1 -1
- package/dist/src/shell/ClockControls.d.ts +1 -1
- package/dist/src/shell/ClockControls.js +1 -1
- package/dist/src/shell/ComponentPage.js +1 -1
- package/dist/src/shell/ComponentPage.js.map +1 -1
- package/dist/src/shell/EventsTab.d.ts +1 -1
- package/dist/src/shell/FrameView.d.ts +1 -1
- package/dist/src/shell/PartsTab.d.ts +1 -1
- package/dist/src/shell/PropsTab.d.ts +1 -1
- package/dist/src/shell/Shell.js +3 -3
- package/dist/src/shell/Shell.js.map +1 -1
- package/dist/src/shell/Sidebar.d.ts +1 -1
- package/dist/src/shell/Sidebar.js +3 -3
- package/dist/src/shell/Stage.d.ts +1 -1
- package/dist/src/shell/Stage.js +1 -1
- package/dist/src/shell/StageViewport.d.ts +1 -2
- package/dist/src/shell/StageViewport.d.ts.map +1 -1
- package/dist/src/shell/StageViewport.js +1 -2
- package/dist/src/shell/StageViewport.js.map +1 -1
- package/dist/src/shell/Toolbar.js +1 -1
- package/dist/src/shell/treeSearch.d.ts +2 -2
- package/dist/src/shell/useFrameMessages.d.ts +1 -1
- package/dist/src/shell/useFrameMessages.d.ts.map +1 -1
- package/dist/src/storyBackground.d.ts +1 -1
- package/dist/src/storyClock.d.ts +2 -2
- package/dist/src/storyClock.js +2 -2
- package/dist/src/storyTree.d.ts +7 -7
- package/dist/src/storyTree.d.ts.map +1 -1
- package/dist/src/viewState.d.ts +11 -2
- package/dist/src/viewState.d.ts.map +1 -1
- package/dist/src/viewState.js +15 -0
- package/dist/src/viewState.js.map +1 -1
- package/dist/src/vite/agent.types.d.ts +90 -0
- package/dist/src/vite/agent.types.d.ts.map +1 -0
- package/dist/src/vite/agent.types.js +1 -0
- package/dist/src/vite/agent.types.js.map +1 -0
- package/dist/src/vite/agentApi.d.ts +94 -0
- package/dist/src/vite/agentApi.d.ts.map +1 -0
- package/dist/src/vite/agentApi.js +162 -0
- package/dist/src/vite/agentApi.js.map +1 -0
- package/dist/src/vite/agentRoutes.d.ts +45 -0
- package/dist/src/vite/agentRoutes.d.ts.map +1 -0
- package/dist/src/vite/agentRoutes.js +94 -0
- package/dist/src/vite/agentRoutes.js.map +1 -0
- package/dist/src/vite/docsProgram.js +1 -1
- package/dist/src/vite/forcedStates.d.ts +1 -1
- package/dist/src/vite/forcedStates.js +1 -1
- package/dist/src/vite/forgebookPlugin.d.ts.map +1 -1
- package/dist/src/vite/forgebookPlugin.js +10 -3
- package/dist/src/vite/forgebookPlugin.js.map +1 -1
- package/dist/src/vite/highlightCode.js +1 -1
- package/dist/src/vite/mcpProtocol.d.ts +73 -0
- package/dist/src/vite/mcpProtocol.d.ts.map +1 -0
- package/dist/src/vite/mcpProtocol.js +181 -0
- package/dist/src/vite/mcpProtocol.js.map +1 -0
- package/dist/src/vite/pages.d.ts +12 -0
- package/dist/src/vite/pages.d.ts.map +1 -1
- package/dist/src/vite/pages.js +21 -0
- package/dist/src/vite/pages.js.map +1 -1
- package/dist/src/vite/storyFilesModule.js +1 -1
- package/dist/src/vite/typeScriptPieces.js +2 -2
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -5,12 +5,12 @@ per story, switches for theme, contrast, motion and language, and a props table
|
|
|
5
5
|
|
|
6
6
|
> **Status:** 0.x, early. Its author's design system runs on it; the API may still change between minor versions,
|
|
7
7
|
> and every change is in the
|
|
8
|
-
> [changelog](https://github.com/
|
|
8
|
+
> [changelog](https://github.com/ensiria/forgebook/blob/develop/packages/forgebook/CHANGELOG.md).
|
|
9
9
|
|
|
10
10
|
**Requirements:** Node 22.18 or later · Vite 8 (the catalogue is built on it; other bundlers are not supported) · React 19 today, through
|
|
11
11
|
[`@forgebook/react`](https://www.npmjs.com/package/@forgebook/react); other frameworks plug in through the same
|
|
12
12
|
adapter (the catalogue's own interface is React either way) · npm, pnpm, yarn or bun ·
|
|
13
|
-
[MIT licence](https://github.com/
|
|
13
|
+
[MIT licence](https://github.com/ensiria/forgebook/blob/develop/packages/forgebook/LICENSE)
|
|
14
14
|
|
|
15
15
|
## Install
|
|
16
16
|
|
|
@@ -116,10 +116,31 @@ its name.
|
|
|
116
116
|
| Command | What it does |
|
|
117
117
|
|---|---|
|
|
118
118
|
| `forgebook dev` / `forgebook build` | Runs the catalogue of `forgebook.config.ts`, or builds it into static files |
|
|
119
|
+
| `forgebook stories` | Lists every story with its id and links; fails when the story index has problems |
|
|
120
|
+
| `forgebook story <id>` | One story: its args, its component's props, its links in a view (`--view theme=dark`) |
|
|
121
|
+
| `forgebook mcp` | Serves the same answers to an agent over the Model Context Protocol |
|
|
119
122
|
| `forgebook-docs` | Writes a package's `CATALOG.md` from its exports, their TSDoc and its stories |
|
|
120
123
|
| `forgebook-texts` | Checks a package's story texts and lists what each language still has to translate |
|
|
121
124
|
|
|
122
|
-
Each command prints its options with `--help`.
|
|
125
|
+
Each command prints its options with `--help`; `stories` and `story` print JSON with `--json`.
|
|
126
|
+
|
|
127
|
+
## For agents
|
|
128
|
+
|
|
129
|
+
A coding agent can use the catalogue while it works: find a story's id, read a story's args and its component's
|
|
130
|
+
props, and hand a person the link that opens it. Add the MCP server to the project's agent configuration, for
|
|
131
|
+
example `.mcp.json` for Claude Code:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{ "mcpServers": { "forgebook": { "command": "npx", "args": ["forgebook", "mcp"] } } }
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
It offers three tools: `list_stories`, `get_story` and `story_address`. Run from the catalogue's folder (or give
|
|
138
|
+
`--config`), it uses the running `forgebook dev` when there is one, and starts a dev server of its own otherwise,
|
|
139
|
+
kept while the agent's session lasts. The links name `http://localhost:5173` unless `--url` (or `FORGEBOOK_URL`) says
|
|
140
|
+
where `forgebook dev` runs.
|
|
141
|
+
|
|
142
|
+
In CI, `forgebook stories --json` fails on a broken story file (a title taken twice, a title that cannot be placed),
|
|
143
|
+
and its JSON lists every story for a script.
|
|
123
144
|
|
|
124
145
|
## Packages
|
|
125
146
|
|
|
@@ -133,5 +154,5 @@ Each command prints its options with `--help`.
|
|
|
133
154
|
## Contributing
|
|
134
155
|
|
|
135
156
|
Bugs, proposals and pull requests:
|
|
136
|
-
[CONTRIBUTING.md](https://github.com/
|
|
137
|
-
[SECURITY.md](https://github.com/
|
|
157
|
+
[CONTRIBUTING.md](https://github.com/ensiria/forgebook/blob/develop/CONTRIBUTING.md). Security problems:
|
|
158
|
+
[SECURITY.md](https://github.com/ensiria/forgebook/blob/develop/SECURITY.md).
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type AgentAnswer } from "../../src/vite/agentRoutes.ts";
|
|
2
|
+
import type { ResolvedConfig } from "../../src/vite/configFile.ts";
|
|
3
|
+
/** Where `forgebook dev` serves when no port is given: Vite's default. */
|
|
4
|
+
export declare const DEFAULT_ORIGIN = "http://localhost:5173";
|
|
5
|
+
/** The catalogue's answers, from wherever they come. */
|
|
6
|
+
export type CatalogueClient = {
|
|
7
|
+
/** Asks one of the API's paths (`stories`, `story`) with its query. */
|
|
8
|
+
readonly ask: (route: string, params: URLSearchParams) => Promise<AgentAnswer>;
|
|
9
|
+
/** Where the answers come from: the running server's address, or none for a server of its own. */
|
|
10
|
+
readonly runningAt: string | undefined;
|
|
11
|
+
/** Stops the server it started; nothing for a running one. */
|
|
12
|
+
readonly close: () => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The catalogue's answers: the running dev server at the address when it serves this catalogue, a server of its own
|
|
16
|
+
* otherwise.
|
|
17
|
+
*
|
|
18
|
+
* @param config - the catalogue's configuration.
|
|
19
|
+
* @param url - where `forgebook dev` runs, when not at Vite's default address.
|
|
20
|
+
*/
|
|
21
|
+
export declare const catalogueClient: (config: ResolvedConfig, url: string | undefined) => Promise<CatalogueClient>;
|
|
22
|
+
//# sourceMappingURL=agentClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentClient.d.ts","sourceRoot":"","sources":["../../../bin/forgebook/agentClient.ts"],"names":[],"mappings":"AAcA,OAAO,EAAa,KAAK,WAAW,EAA4B,MAAM,+BAA+B,CAAC;AACtG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,0EAA0E;AAC1E,eAAO,MAAM,cAAc,0BAA0B,CAAC;AAEtD,wDAAwD;AACxD,MAAM,MAAM,eAAe,GAAG;IAC5B,uEAAuE;IACvE,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAC/E,kGAAkG;IAClG,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC,CAAC;AAiDF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC1B,QAAQ,cAAc,EACtB,KAAK,MAAM,GAAG,SAAS,KACtB,OAAO,CAAC,eAAe,CAGzB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How `forgebook stories`, `forgebook story` and `forgebook mcp` get their answers: from the catalogue's running dev
|
|
3
|
+
* server when it serves this catalogue, otherwise from a dev server of their own, started without listening.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* A running `forgebook dev` answers at once and its links work. A server of their own is started in the same process
|
|
7
|
+
* (Vite in middleware mode: no port, nothing reachable from outside) and the same function answers; its links name
|
|
8
|
+
* where `forgebook dev` serves by default, so they work once it runs. A server found at the address is used only when
|
|
9
|
+
* it says it serves this catalogue's folder (`ROOT_HEADER`), never another project's catalogue on the same port.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { createServer } from "vite";
|
|
14
|
+
import { AGENT_API, agentAnswer, ROOT_HEADER } from "../../src/vite/agentRoutes.js";
|
|
15
|
+
import { catalogueVite } from "./catalogueVite.js";
|
|
16
|
+
/** Where `forgebook dev` serves when no port is given: Vite's default. */
|
|
17
|
+
export const DEFAULT_ORIGIN = "http://localhost:5173";
|
|
18
|
+
/**
|
|
19
|
+
* Asks a running dev server, if one at the address serves this catalogue.
|
|
20
|
+
*
|
|
21
|
+
* @param origin - the address to try.
|
|
22
|
+
* @param config - the catalogue's configuration, whose folder the server must name.
|
|
23
|
+
* @returns the client, or none when nothing there serves this catalogue.
|
|
24
|
+
*/
|
|
25
|
+
const runningClient = async (origin, config) => {
|
|
26
|
+
const ask = async (route, params) => {
|
|
27
|
+
const response = await fetch(`${origin}${AGENT_API}${route}?${params.toString()}`);
|
|
28
|
+
return { status: response.status, body: await response.json() };
|
|
29
|
+
};
|
|
30
|
+
try {
|
|
31
|
+
const probe = await fetch(`${origin}${AGENT_API}stories`, { signal: AbortSignal.timeout(2000) });
|
|
32
|
+
if (probe.headers.get(ROOT_HEADER) !== config.dir)
|
|
33
|
+
return undefined;
|
|
34
|
+
await probe.body?.cancel();
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
return { ask, runningAt: origin, close: async () => undefined };
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A dev server of its own, in middleware mode, and the answers from it.
|
|
43
|
+
*
|
|
44
|
+
* @param config - the catalogue's configuration.
|
|
45
|
+
* @param origin - the address the links name.
|
|
46
|
+
*/
|
|
47
|
+
const ownClient = async (config, origin) => {
|
|
48
|
+
const server = await createServer(await catalogueVite(config, {
|
|
49
|
+
server: { middlewareMode: true, hmr: false },
|
|
50
|
+
appType: "custom",
|
|
51
|
+
logLevel: "error"
|
|
52
|
+
}));
|
|
53
|
+
return {
|
|
54
|
+
ask: (route, params) => agentAnswer((id) => server.ssrLoadModule(id), config, route, params, origin),
|
|
55
|
+
runningAt: undefined,
|
|
56
|
+
close: () => server.close()
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* The catalogue's answers: the running dev server at the address when it serves this catalogue, a server of its own
|
|
61
|
+
* otherwise.
|
|
62
|
+
*
|
|
63
|
+
* @param config - the catalogue's configuration.
|
|
64
|
+
* @param url - where `forgebook dev` runs, when not at Vite's default address.
|
|
65
|
+
*/
|
|
66
|
+
export const catalogueClient = async (config, url) => {
|
|
67
|
+
const origin = (url ?? DEFAULT_ORIGIN).replace(/\/+$/, "");
|
|
68
|
+
return (await runningClient(origin, config)) ?? ownClient(config, origin);
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=agentClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentClient.js","sourceRoot":"","sources":["../../../bin/forgebook/agentClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,YAAY,EAAsB,MAAM,MAAM,CAAC;AAExD,OAAO,EAAE,SAAS,EAAoB,WAAW,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEtG,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,0EAA0E;AAC1E,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAYtD;;;;;;GAMG;AACH,MAAM,aAAa,GAAG,KAAK,EACzB,MAAc,EACd,MAAsB,EACgB,EAAE;IACxC,MAAM,GAAG,GAAG,KAAK,EAAE,KAAa,EAAE,MAAuB,EAAwB,EAAE;QACjF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACnF,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;IAClE,CAAC,CAAC;IACF,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,GAAG,SAAS,SAAS,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjG,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,MAAM,CAAC,GAAG;YAAE,OAAO,SAAS,CAAC;QACpE,MAAM,KAAK,CAAC,IAAI,EAAE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iria/cli-kit/log.types";
|
|
2
|
+
import type { StoriesDocument, StoryDocument } from "../../src/vite/agent.types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* The stories as a table: one row per story, its id first (what `forgebook story` takes, never cut), then its
|
|
5
|
+
* component's title and its name.
|
|
6
|
+
*
|
|
7
|
+
* @param document - the stories document.
|
|
8
|
+
* @param style - colours, glyphs and width.
|
|
9
|
+
*/
|
|
10
|
+
export declare const storiesText: (document: StoriesDocument, style: OutputStyle) => string;
|
|
11
|
+
/**
|
|
12
|
+
* One story's facts: where it is, where it opens, its args and its component's props.
|
|
13
|
+
*
|
|
14
|
+
* @param document - the story document.
|
|
15
|
+
* @param style - colours, glyphs and width.
|
|
16
|
+
*/
|
|
17
|
+
export declare const storyText: (document: StoryDocument, style: OutputStyle) => string;
|
|
18
|
+
//# sourceMappingURL=agentText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentText.d.ts","sourceRoot":"","sources":["../../../bin/forgebook/agentText.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAKpF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,eAAe,EAAE,OAAO,WAAW,KAAG,MAUzE,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,UAAU,aAAa,EAAE,OAAO,WAAW,KAAG,MAYvE,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The answers of `forgebook stories` and `forgebook story` as text for a terminal: a table of the stories, one story's
|
|
3
|
+
* facts, and the problems. Pure: documents in, text out, laid out with cli-kit's helpers.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Nothing is cut to the terminal's width: ids and links are what a reader copies, so a long line wraps instead.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { keyValue, table } from "@ensiria/cli-kit/layout";
|
|
11
|
+
/** The style with no width to fit, so no cell is cut. */
|
|
12
|
+
const uncut = (style) => ({ ...style, width: Number.POSITIVE_INFINITY });
|
|
13
|
+
/**
|
|
14
|
+
* The stories as a table: one row per story, its id first (what `forgebook story` takes, never cut), then its
|
|
15
|
+
* component's title and its name.
|
|
16
|
+
*
|
|
17
|
+
* @param document - the stories document.
|
|
18
|
+
* @param style - colours, glyphs and width.
|
|
19
|
+
*/
|
|
20
|
+
export const storiesText = (document, style) => table(document.components.flatMap((component) => component.stories.map((story) => [
|
|
21
|
+
story.id,
|
|
22
|
+
`${component.title} › ${story.name}${story.isUnlisted ? " (unlisted)" : ""}`
|
|
23
|
+
])), { columns: [{ header: "Id" }, { header: "Story", tone: "muted" }] }, uncut(style));
|
|
24
|
+
/**
|
|
25
|
+
* One story's facts: where it is, where it opens, its args and its component's props.
|
|
26
|
+
*
|
|
27
|
+
* @param document - the story document.
|
|
28
|
+
* @param style - colours, glyphs and width.
|
|
29
|
+
*/
|
|
30
|
+
export const storyText = (document, style) => {
|
|
31
|
+
const entries = [
|
|
32
|
+
["Story", `${document.component.title} › ${document.story.name}`],
|
|
33
|
+
["Id", document.story.id],
|
|
34
|
+
["File", document.component.file],
|
|
35
|
+
["Opens at", document.story.links.address],
|
|
36
|
+
["Frame", document.story.links.frame],
|
|
37
|
+
["Args", JSON.stringify(document.args)],
|
|
38
|
+
["Props", document.docs === undefined ? "none" : document.docs.props.map((prop) => prop.name).join(", ")]
|
|
39
|
+
];
|
|
40
|
+
if (document.story.description !== undefined)
|
|
41
|
+
entries.push(["About", document.story.description]);
|
|
42
|
+
return keyValue(entries, uncut(style));
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=agentText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentText.js","sourceRoot":"","sources":["../../../bin/forgebook/agentText.ts"],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,CAAC,KAAK,CAAC,OAAO,CAAC;QAC1C,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;QACrC,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KAC1G,CAAC;IACF,IAAI,QAAQ,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS;QAAE,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAClG,OAAO,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC"}
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* The `forgebook` command: runs a catalogue from its `forgebook.config.ts` (`dev`, the dev server) or builds it into
|
|
4
|
-
* static files (`build`), with no page or Vite configuration of the app's own
|
|
4
|
+
* static files (`build`), with no page or Vite configuration of the app's own; and answers tools and agents
|
|
5
|
+
* (`stories`, `story`) with what the catalogue shows.
|
|
5
6
|
*
|
|
6
7
|
* @module
|
|
7
8
|
*/
|
|
8
9
|
import { resolve } from "node:path";
|
|
9
|
-
import {
|
|
10
|
+
import { createInterface } from "node:readline";
|
|
11
|
+
import { defineCommands } from "@ensiria/cli-kit/commands";
|
|
12
|
+
import { EXIT } from "@ensiria/cli-kit/constants";
|
|
13
|
+
import { formatJson, readPackageVersion } from "@ensiria/cli-kit/files";
|
|
14
|
+
import { ScriptError } from "@ensiria/cli-kit/script";
|
|
10
15
|
import { build, createServer } from "vite";
|
|
16
|
+
import { filteredStories, isStoriesDocument, isStoryDocument } from "../../src/vite/agentApi.js";
|
|
11
17
|
import { CONFIG_FILES, findConfigFile, loadConfigFile } from "../../src/vite/configFile.js";
|
|
18
|
+
import { answerMcpMessage, NEW_SESSION } from "../../src/vite/mcpProtocol.js";
|
|
19
|
+
import { catalogueClient } from "./agentClient.js";
|
|
20
|
+
import { storiesText, storyText } from "./agentText.js";
|
|
12
21
|
import { catalogueVite } from "./catalogueVite.js";
|
|
22
|
+
import { catalogueTools } from "./mcpTools.js";
|
|
13
23
|
/** The command, as the hints print it. */
|
|
14
24
|
const COMMAND = "forgebook";
|
|
15
25
|
/**
|
|
@@ -31,63 +41,232 @@ const configOf = async (file) => {
|
|
|
31
41
|
throw new ScriptError(error instanceof Error ? error.message : String(error));
|
|
32
42
|
}
|
|
33
43
|
};
|
|
34
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Asks the catalogue one of its answers, from its running dev server or one started for the answer.
|
|
46
|
+
*
|
|
47
|
+
* @param config - the catalogue's configuration.
|
|
48
|
+
* @param url - where `forgebook dev` runs, when not at Vite's default address.
|
|
49
|
+
* @param route - the answer (`stories`, `story`).
|
|
50
|
+
* @param params - its query.
|
|
51
|
+
* @param log - where to say where the answer comes from.
|
|
52
|
+
* @throws a `ScriptError` when the catalogue answers with an error.
|
|
53
|
+
*/
|
|
54
|
+
const askCatalogue = async (config, url, route, params, log) => {
|
|
55
|
+
const client = await catalogueClient(config, url);
|
|
56
|
+
log.debug(client.runningAt === undefined
|
|
57
|
+
? "No catalogue running: answered by a server of its own"
|
|
58
|
+
: `Asked ${client.runningAt}`);
|
|
59
|
+
let answer;
|
|
60
|
+
try {
|
|
61
|
+
answer = await client.ask(route, params);
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
await client.close();
|
|
65
|
+
}
|
|
66
|
+
if (answer.status !== 200) {
|
|
67
|
+
const { body } = answer;
|
|
68
|
+
const message = typeof body === "object" && body !== null && "error" in body && typeof body.error === "string"
|
|
69
|
+
? body.error
|
|
70
|
+
: `The catalogue answered ${answer.status}`;
|
|
71
|
+
throw new ScriptError(message);
|
|
72
|
+
}
|
|
73
|
+
return answer.body;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Prints an answer, its JSON with `--json`, its problems as warnings, and ends with a failure when it has problems,
|
|
77
|
+
* so a CI step fails on a broken story file.
|
|
78
|
+
*
|
|
79
|
+
* @param text - the answer as text for a terminal.
|
|
80
|
+
* @param document - the answer as data.
|
|
81
|
+
* @param problems - what is wrong in it.
|
|
82
|
+
* @param context - the run's io, logger and `--json` mode.
|
|
83
|
+
* @throws a reported `ScriptError` when there are problems.
|
|
84
|
+
*/
|
|
85
|
+
const printAnswer = (text, document, problems, context) => {
|
|
86
|
+
context.io.stdout.write(context.isJson ? formatJson(document) : `${text}\n`);
|
|
87
|
+
for (const problem of problems)
|
|
88
|
+
context.log.warn(problem);
|
|
89
|
+
if (problems.length > 0)
|
|
90
|
+
throw new ScriptError(`${problems.length} problems`, { exitCode: EXIT.failure, isReported: true });
|
|
91
|
+
};
|
|
92
|
+
await defineCommands({
|
|
35
93
|
name: "forgebook",
|
|
36
94
|
command: COMMAND,
|
|
37
|
-
summary: "Run a catalogue of stories from its forgebook.config.ts,
|
|
95
|
+
summary: "Run a catalogue of stories from its forgebook.config.ts, build it, or answer tools and agents about it.",
|
|
38
96
|
icon: "docs",
|
|
39
97
|
options: {
|
|
40
98
|
config: {
|
|
41
99
|
type: "string",
|
|
42
100
|
valueName: "file",
|
|
43
101
|
description: "The configuration file; forgebook.config.ts in the current folder by default."
|
|
44
|
-
},
|
|
45
|
-
port: {
|
|
46
|
-
type: "string",
|
|
47
|
-
valueName: "number",
|
|
48
|
-
description: "dev: the port to listen on; Vite's by default."
|
|
49
|
-
},
|
|
50
|
-
host: {
|
|
51
|
-
type: "string",
|
|
52
|
-
valueName: "address",
|
|
53
|
-
description: "dev: the address to listen on; localhost by default."
|
|
54
|
-
},
|
|
55
|
-
out: { type: "string", valueName: "folder", description: "build: the folder to write; dist by default." },
|
|
56
|
-
force: {
|
|
57
|
-
type: "boolean",
|
|
58
|
-
description: "dev: pre-bundle the dependencies again, ignoring Vite's cache (as a first start does)."
|
|
59
102
|
}
|
|
60
103
|
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
...(port === undefined ? {} : { port, strictPort: true }),
|
|
80
|
-
...(options.host === undefined ? {} : { host: options.host })
|
|
104
|
+
commands: (forgebook) => ({
|
|
105
|
+
dev: forgebook.command({
|
|
106
|
+
summary: "Run the catalogue's dev server.",
|
|
107
|
+
options: {
|
|
108
|
+
port: {
|
|
109
|
+
type: "string",
|
|
110
|
+
valueName: "number",
|
|
111
|
+
description: "The port to listen on; Vite's by default."
|
|
112
|
+
},
|
|
113
|
+
host: {
|
|
114
|
+
type: "string",
|
|
115
|
+
valueName: "address",
|
|
116
|
+
description: "The address to listen on; localhost by default."
|
|
117
|
+
},
|
|
118
|
+
force: {
|
|
119
|
+
type: "boolean",
|
|
120
|
+
description: "Pre-bundle the dependencies again, ignoring Vite's cache (as a first start does)."
|
|
121
|
+
}
|
|
81
122
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
123
|
+
examples: [
|
|
124
|
+
{ command: `${COMMAND} dev`, description: "Run the catalogue of the folder you are in." },
|
|
125
|
+
{ command: `${COMMAND} dev --port 6006`, description: "On a given port." }
|
|
126
|
+
],
|
|
127
|
+
run: async ({ options, onInterrupt }) => {
|
|
128
|
+
const config = await configOf(options.config);
|
|
129
|
+
const port = options.port === undefined ? undefined : Number(options.port);
|
|
130
|
+
if (port !== undefined && !Number.isInteger(port))
|
|
131
|
+
throw new ScriptError(`--port ${options.port} is not a port`);
|
|
132
|
+
const server = await createServer(await catalogueVite(config, {
|
|
133
|
+
server: {
|
|
134
|
+
...(port === undefined ? {} : { port, strictPort: true }),
|
|
135
|
+
...(options.host === undefined ? {} : { host: options.host })
|
|
136
|
+
},
|
|
137
|
+
...(options.force === true ? { optimizeDeps: { force: true } } : {})
|
|
138
|
+
}));
|
|
139
|
+
await server.listen();
|
|
140
|
+
server.printUrls();
|
|
141
|
+
await new Promise((done) => {
|
|
142
|
+
onInterrupt(() => {
|
|
143
|
+
void server.close().then(done);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}),
|
|
148
|
+
build: forgebook.command({
|
|
149
|
+
summary: "Build the catalogue into static files.",
|
|
150
|
+
options: {
|
|
151
|
+
out: { type: "string", valueName: "folder", description: "The folder to write; dist by default." }
|
|
152
|
+
},
|
|
153
|
+
examples: [{ command: `${COMMAND} build --out site`, description: "Build it into static files." }],
|
|
154
|
+
run: async ({ options, log }) => {
|
|
155
|
+
const config = await configOf(options.config);
|
|
156
|
+
await build(await catalogueVite(config, { build: { outDir: resolve(config.dir, options.out ?? "dist") } }));
|
|
157
|
+
log.success(`${config.title} built`);
|
|
158
|
+
}
|
|
159
|
+
}),
|
|
160
|
+
stories: forgebook.command({
|
|
161
|
+
summary: "List the catalogue's stories, with their ids and links; fail when the index has problems.",
|
|
162
|
+
json: true,
|
|
163
|
+
options: {
|
|
164
|
+
source: { type: "string", valueName: "id", description: "Only this source's stories." },
|
|
165
|
+
component: {
|
|
166
|
+
type: "string",
|
|
167
|
+
valueName: "text",
|
|
168
|
+
description: "Only components whose title holds this text."
|
|
169
|
+
},
|
|
170
|
+
view: {
|
|
171
|
+
type: "string",
|
|
172
|
+
valueName: "query",
|
|
173
|
+
description: "The view the links open in, as the catalogue's address writes it (theme=dark&lang=it)."
|
|
174
|
+
},
|
|
175
|
+
url: {
|
|
176
|
+
type: "string",
|
|
177
|
+
env: "FORGEBOOK_URL",
|
|
178
|
+
valueName: "address",
|
|
179
|
+
description: "Where forgebook dev runs, when not at Vite's default address (http://localhost:5173)."
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
examples: [
|
|
183
|
+
{ command: `${COMMAND} stories`, description: "Every story." },
|
|
184
|
+
{ command: `${COMMAND} stories --component button --json`, description: "The buttons, as JSON." }
|
|
185
|
+
],
|
|
186
|
+
run: async ({ options, io, log, isJson, style }) => {
|
|
187
|
+
const config = await configOf(options.config);
|
|
188
|
+
const params = new URLSearchParams({ view: options.view ?? "" });
|
|
189
|
+
const body = await askCatalogue(config, options.url, "stories", params, log);
|
|
190
|
+
if (!isStoriesDocument(body))
|
|
191
|
+
throw new ScriptError("The catalogue's answer has an unexpected shape");
|
|
192
|
+
const document = filteredStories(body, { source: options.source, component: options.component });
|
|
193
|
+
printAnswer(storiesText(document, style), document, document.problems, { io, log, isJson });
|
|
194
|
+
}
|
|
195
|
+
}),
|
|
196
|
+
mcp: forgebook.command({
|
|
197
|
+
summary: "Serve the catalogue's stories to an agent over the Model Context Protocol, on stdin and stdout.",
|
|
198
|
+
header: false,
|
|
199
|
+
options: {
|
|
200
|
+
url: {
|
|
201
|
+
type: "string",
|
|
202
|
+
env: "FORGEBOOK_URL",
|
|
203
|
+
valueName: "address",
|
|
204
|
+
description: "Where forgebook dev runs, when not at Vite's default address (http://localhost:5173)."
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
examples: [
|
|
208
|
+
{
|
|
209
|
+
command: `${COMMAND} mcp`,
|
|
210
|
+
description: "What an agent's MCP configuration runs (npx forgebook mcp)."
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
run: async ({ options, io, log }) => {
|
|
214
|
+
const config = await configOf(options.config);
|
|
215
|
+
// kept for the server's life: an agent's questions in a row each answer at once
|
|
216
|
+
const client = await catalogueClient(config, options.url);
|
|
217
|
+
log.debug(client.runningAt === undefined ? "Answering from a server of its own" : `Asking ${client.runningAt}`);
|
|
218
|
+
const server = {
|
|
219
|
+
info: { name: "forgebook", version: readPackageVersion(import.meta.dirname) },
|
|
220
|
+
instructions: `The stories of the Forgebook catalogue "${config.title}". list_stories finds a story's id, get_story gives its args and its component's props, story_address gives the links a person opens to see it.`,
|
|
221
|
+
tools: catalogueTools(client.ask)
|
|
222
|
+
};
|
|
223
|
+
let session = NEW_SESSION;
|
|
224
|
+
// stdout carries only the protocol's messages, one per line, answered in the order they came
|
|
225
|
+
for await (const line of createInterface({ input: io.stdin })) {
|
|
226
|
+
if (line.trim() === "")
|
|
227
|
+
continue;
|
|
228
|
+
const step = await answerMcpMessage(line, session, server);
|
|
229
|
+
session = step.session;
|
|
230
|
+
if (step.reply !== undefined)
|
|
231
|
+
io.stdout.write(`${step.reply}\n`);
|
|
232
|
+
}
|
|
233
|
+
await client.close();
|
|
234
|
+
}
|
|
235
|
+
}),
|
|
236
|
+
story: forgebook.command({
|
|
237
|
+
summary: "One story in detail: its args, its component's props, its links; fail when it cannot be read.",
|
|
238
|
+
json: true,
|
|
239
|
+
options: {
|
|
240
|
+
view: {
|
|
241
|
+
type: "string",
|
|
242
|
+
valueName: "query",
|
|
243
|
+
description: "The view the links open in, as the catalogue's address writes it (theme=dark&lang=it)."
|
|
244
|
+
},
|
|
245
|
+
url: {
|
|
246
|
+
type: "string",
|
|
247
|
+
env: "FORGEBOOK_URL",
|
|
248
|
+
valueName: "address",
|
|
249
|
+
description: "Where forgebook dev runs, when not at Vite's default address (http://localhost:5173)."
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
positionals: [
|
|
253
|
+
{ name: "id", description: "The story's id, as forgebook stories lists it.", required: true }
|
|
254
|
+
],
|
|
255
|
+
examples: [
|
|
256
|
+
{
|
|
257
|
+
command: `${COMMAND} story kit:actions-button--primary --view theme=dark --json`,
|
|
258
|
+
description: "A story, its links in the dark theme, as JSON."
|
|
259
|
+
}
|
|
260
|
+
],
|
|
261
|
+
run: async ({ args, options, io, log, isJson, style }) => {
|
|
262
|
+
const config = await configOf(options.config);
|
|
263
|
+
const params = new URLSearchParams({ id: args.id, view: options.view ?? "" });
|
|
264
|
+
const body = await askCatalogue(config, options.url, "story", params, log);
|
|
265
|
+
if (!isStoryDocument(body))
|
|
266
|
+
throw new ScriptError("The catalogue's answer has an unexpected shape");
|
|
267
|
+
printAnswer(storyText(body, style), body, body.problems, { io, log, isJson });
|
|
268
|
+
}
|
|
269
|
+
})
|
|
270
|
+
})
|
|
92
271
|
}).run();
|
|
93
272
|
//# sourceMappingURL=forgebook.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forgebook.mjs","sourceRoot":"","sources":["../../../bin/forgebook/forgebook.mts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"forgebook.mjs","sourceRoot":"","sources":["../../../bin/forgebook/forgebook.mts"],"names":[],"mappings":";AACA;;;;;;GAMG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGxE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAG3C,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAEjG,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EAEf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,E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KACH,CAAC;CACH,CAAC,CAAC,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentAnswer } from "../../src/vite/agentRoutes.ts";
|
|
2
|
+
import type { McpTool } from "../../src/vite/mcpProtocol.ts";
|
|
3
|
+
/** Asks the catalogue one of its answers. */
|
|
4
|
+
type Ask = (route: string, params: URLSearchParams) => Promise<AgentAnswer>;
|
|
5
|
+
/**
|
|
6
|
+
* The tools, asking the catalogue through `ask`.
|
|
7
|
+
*
|
|
8
|
+
* @param ask - asks the catalogue (the running dev server, or the server `forgebook mcp` keeps).
|
|
9
|
+
*/
|
|
10
|
+
export declare const catalogueTools: (ask: Ask) => readonly McpTool[];
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=mcpTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpTools.d.ts","sourceRoot":"","sources":["../../../bin/forgebook/mcpTools.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,+BAA+B,CAAC;AAE5E,6CAA6C;AAC7C,KAAK,GAAG,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAqB5E;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,GAAG,KAAG,SAAS,OAAO,EAmEzD,CAAC"}
|