@solobrand/mcp 0.0.0-stage → 0.1.1
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 +167 -2
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +9 -0
- package/dist/bin.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge.d.ts +45 -0
- package/dist/knowledge.d.ts.map +1 -0
- package/dist/knowledge.js +164 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/messages.d.ts +52 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +95 -0
- package/dist/messages.js.map +1 -0
- package/dist/node-fs.d.ts +22 -0
- package/dist/node-fs.d.ts.map +1 -0
- package/dist/node-fs.js +129 -0
- package/dist/node-fs.js.map +1 -0
- package/dist/search.d.ts +19 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +72 -0
- package/dist/search.js.map +1 -0
- package/dist/server.d.ts +19 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +38 -0
- package/dist/server.js.map +1 -0
- package/dist/tools.d.ts +78 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +432 -0
- package/dist/tools.js.map +1 -0
- package/knowledge/seed/pitfalls/auth.en.md +11 -0
- package/knowledge/seed/pitfalls/auth.es.md +11 -0
- package/knowledge/seed/pitfalls/huecos.en.md +11 -0
- package/knowledge/seed/pitfalls/huecos.es.md +11 -0
- package/knowledge/seed/pitfalls/workers.en.md +11 -0
- package/knowledge/seed/pitfalls/workers.es.md +11 -0
- package/knowledge/seed/recipes/add-model.en.md +27 -0
- package/knowledge/seed/recipes/add-model.es.md +27 -0
- package/knowledge/seed/recipes/api-tokens.en.md +11 -0
- package/knowledge/seed/recipes/api-tokens.es.md +11 -0
- package/knowledge/seed/recipes/crm-events.en.md +13 -0
- package/knowledge/seed/recipes/crm-events.es.md +13 -0
- package/knowledge/seed/recipes/huecos.en.md +21 -0
- package/knowledge/seed/recipes/huecos.es.md +21 -0
- package/package.json +46 -4
- package/scripts/copy-knowledge.mjs +29 -0
package/README.md
CHANGED
|
@@ -1,3 +1,168 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @solobrand/mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The **development** MCP server of the SoloBrand framework: it runs over stdio next to your
|
|
4
|
+
app and gives an AI assistant the framework's rules, recipes and pitfalls (the same Markdown
|
|
5
|
+
as the docs site), the `app.json` contract, and the generator and its checks, run against the
|
|
6
|
+
app directory. Operating hosted apps (deploy, logs, DB, secrets) is SoloBrand's remote MCP.
|
|
7
|
+
|
|
8
|
+
Part of the [SoloBrand framework](../../README.md). Frozen contract: `src/index.ts`
|
|
9
|
+
(`KnowledgeEntry`, `TOOL_NAMES`), see CONTRIBUTING.md.
|
|
10
|
+
|
|
11
|
+
## Tools
|
|
12
|
+
|
|
13
|
+
| Tool | Input | What it does |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| `framework_overview` | `locale?` | What the framework is and the rules: write only in huecos, change app.json then regenerate, never edit framework files, run verify/guard/audit. Lists recipes and pitfalls. **Call first.** |
|
|
16
|
+
| `framework_recipe` | `topic`, `locale?` | A recipe by id, words or tag (`add-model`, `api tokens`, `huecos`, `crm-events`…). Unknown topic → the list. |
|
|
17
|
+
| `framework_pitfalls` | `area?`, `locale?` | Known mistakes by area (`auth`, `huecos`, `workers`…). No area → the areas. |
|
|
18
|
+
| `spec_schema` | — | The JSON Schema of `app.json` (from `@solobrand/generator/schema/app.schema.json`). |
|
|
19
|
+
| `spec_validate` | `spec?` (text/object), `path?`, `locale?` | Validates with `@solobrand/generator`; every problem with its JSON path. Default: `./app.json`. `path` can't leave the app dir. |
|
|
20
|
+
| `generate` | `write?`, `locale?` | Runs the generator on `./app.json`. **Dry run by default**; `write: true` writes. Reports written/unchanged/skipped, orphan huecos, obsolete files. |
|
|
21
|
+
| `verify` | `locale?` | Files in sync with app.json (missing, stale). |
|
|
22
|
+
| `guard` | `locale?` | Nothing generated edited outside a hueco (path:line). |
|
|
23
|
+
| `audit` | `locale?` | Routes/requests/policies neither generated nor marked `// @a-mano`. |
|
|
24
|
+
| `docs_search` | `query`, `limit?`, `locale?` | BM25 over the docs, accent-insensitive, es/en. |
|
|
25
|
+
| `package_list` | `locale?` | Installed `@solobrand/*` with versions and descriptions. |
|
|
26
|
+
|
|
27
|
+
Every input is a JSON Schema with `additionalProperties: false`; bad arguments come back as an
|
|
28
|
+
error result (never a crash). Answers are short text, in `en` by default or `es`
|
|
29
|
+
(`locale` argument, or `SOLOBRAND_LOCALE=es`). Every sentence is a translation key
|
|
30
|
+
(`src/messages.ts`).
|
|
31
|
+
|
|
32
|
+
## Install and configure
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install -D @solobrand/mcp
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Always name the package (`-p @solobrand/mcp`): a bare `npx solobrand-mcp` outside a project
|
|
39
|
+
that has it installed would fetch whatever npm package is called `solobrand-mcp`.
|
|
40
|
+
|
|
41
|
+
The server runs against its working directory (your app root). Override with
|
|
42
|
+
`SOLOBRAND_APP_DIR`; set `SOLOBRAND_LOCALE=es` for Spanish answers.
|
|
43
|
+
|
|
44
|
+
**Claude Code** (from the app root):
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
claude mcp add solobrand -- npx -y -p @solobrand/mcp solobrand-mcp
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
or commit `.mcp.json` at the app root:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"mcpServers": {
|
|
55
|
+
"solobrand": { "command": "npx", "args": ["-y", "-p", "@solobrand/mcp", "solobrand-mcp"] }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Cursor** — `.cursor/mcp.json`:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"mcpServers": {
|
|
65
|
+
"solobrand": { "command": "npx", "args": ["-y", "-p", "@solobrand/mcp", "solobrand-mcp"], "env": { "SOLOBRAND_LOCALE": "es" } }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**VS Code (Copilot agent mode)** — `.vscode/mcp.json`:
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"servers": {
|
|
75
|
+
"solobrand": { "type": "stdio", "command": "npx", "args": ["-y", "-p", "@solobrand/mcp", "solobrand-mcp"] }
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Windsurf** — `~/.codeium/windsurf/mcp_config.json`, **Claude Desktop** —
|
|
81
|
+
`claude_desktop_config.json` (these don't start in your project, so give the directory):
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"mcpServers": {
|
|
86
|
+
"solobrand": {
|
|
87
|
+
"command": "npx",
|
|
88
|
+
"args": ["-y", "-p", "@solobrand/mcp", "solobrand-mcp"],
|
|
89
|
+
"env": { "SOLOBRAND_APP_DIR": "/absolute/path/to/my-app" }
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Zed** — `settings.json`:
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"context_servers": {
|
|
100
|
+
"solobrand": { "command": { "path": "npx", "args": ["-y", "-p", "@solobrand/mcp", "solobrand-mcp"] } }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Knowledge
|
|
106
|
+
|
|
107
|
+
- `docs/**/*.md` of the framework repo is copied into `knowledge/docs/` by
|
|
108
|
+
`scripts/copy-knowledge.mjs` (`npm run build` and `prepack` in this package), so the
|
|
109
|
+
published package carries the docs. Inside the monorepo the live `docs/` is read instead.
|
|
110
|
+
- `knowledge/seed/` holds seed recipes and pitfalls (es and en), so the server is useful
|
|
111
|
+
before the docs land. A docs page with the same id and locale wins over the seed.
|
|
112
|
+
- A page's locale: front matter `locale:`, else a `.es.md` / `.en.md` suffix, else an
|
|
113
|
+
`es/` / `en/` path segment, else `es`. Its id: the path without the locale and `.md`
|
|
114
|
+
(`recipes/add-model`). Recipes live under `recipes/` (or `recetas/`, `guides/`, `guias/`),
|
|
115
|
+
pitfalls under `pitfalls/` (or `trampas/`, `errores/`). Front matter `title:` and
|
|
116
|
+
`tags: [a, b]` are optional (the title defaults to the first `#` heading).
|
|
117
|
+
- The docs' single-page `recipes.md` and `pitfalls.md` are split into one entry per `##`
|
|
118
|
+
section (`recipes/rate-limit-a-route`). Both locales share headings in the same order
|
|
119
|
+
(`docs/STRUCTURE.md`), so section *i* takes its id from the English heading in es and en.
|
|
120
|
+
`STRUCTURE.md` and `.vitepress/` are skipped.
|
|
121
|
+
|
|
122
|
+
## Reusing the tool table (SoloBrand's remote MCP)
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import { TOOLS, callTool, loadKnowledge, type ToolContext } from '@solobrand/mcp';
|
|
126
|
+
|
|
127
|
+
const ctx: ToolContext = { cwd: '/app', fs: myFileSystem, knowledge: await loadKnowledge(), locale: 'es' };
|
|
128
|
+
for (const tool of TOOLS) remote.register(tool.name, tool.inputSchema, (args) => tool.handler(args, ctx));
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Each `ToolDefinition` has `name`, `title`, `description`, a plain JSON Schema `inputSchema`,
|
|
132
|
+
MCP `annotations` (only `generate` is not read-only) and `handler(args, ctx) → { text, isError? }`.
|
|
133
|
+
`fs` is the generator's `FileSystem` port, so the remote can run them over R2 or memory.
|
|
134
|
+
`createServer(ctx)` returns an SDK `Server` you can connect to any transport.
|
|
135
|
+
|
|
136
|
+
## Status
|
|
137
|
+
|
|
138
|
+
**TERMINADO** (F7, 2026-11-28)
|
|
139
|
+
|
|
140
|
+
**Implemented**
|
|
141
|
+
- stdio server on the official `@modelcontextprotocol/sdk` (low-level `Server`), binary
|
|
142
|
+
`solobrand-mcp`, server instructions with the rules.
|
|
143
|
+
- The 11 tools of `TOOL_NAMES`, exported as `TOOLS` / `TOOLS_BY_NAME` / `callTool`.
|
|
144
|
+
- Knowledge loader (front matter, locale detection, docs-over-seed precedence, sectioned
|
|
145
|
+
recipes/pitfalls pages split per `##`), copy script, seed (4 recipes, 3 pitfall areas,
|
|
146
|
+
es + en), BM25 search with accent folding and es/en stopwords.
|
|
147
|
+
- Node `FileSystem` adapter (`nodeFileSystem`, with `realpath`) for the generator's port.
|
|
148
|
+
- es/en messages for every answer.
|
|
149
|
+
- Windows: paths go through `node:path`, with `win32` or `posix` chosen from the app root
|
|
150
|
+
(`pathApi`): a `C:\…` / UNC / backslash root gets Windows rules (drives, case, `\`), a
|
|
151
|
+
POSIX root (in-memory or remote app) behaves the same on every host.
|
|
152
|
+
- Paths the tools read (`spec_validate`'s `path`) must stay inside the app dir both
|
|
153
|
+
lexically (`insideRoot`) and after resolving symlinks (`resolveInside`, realpath of the
|
|
154
|
+
file and of the root): a link inside the app pointing outside is refused.
|
|
155
|
+
|
|
156
|
+
**Tested** (67 tests, ~99 % lines): every tool handler with fixtures (the `reservas`
|
|
157
|
+
spec, an in-memory app), argument validation and unknown tools, path traversal refused in
|
|
158
|
+
`spec_validate` on POSIX and win32 roots (parent dirs, other drives, drive-relative, rooted,
|
|
159
|
+
UNC), symlink/junction escapes refused on the real file system, an app root reached through a
|
|
160
|
+
link, win32 `package_list`, `__proto__` spec refused, dry run writes nothing, generate →
|
|
161
|
+
verify/guard/audit clean, guard catches an edit outside a hueco, audit catches an unmarked
|
|
162
|
+
hand-rolled route, orphan/obsolete reporting, file-system errors become error results; the
|
|
163
|
+
server over an in-memory MCP client; the built binary end to end over real stdio.
|
|
164
|
+
|
|
165
|
+
**Notes**
|
|
166
|
+
- No `fix` tool (not in `TOOL_NAMES`).
|
|
167
|
+
- The root `npm run build` runs `tsc -b` only; run `npm run build -w @solobrand/mcp` (or
|
|
168
|
+
publish, via `prepack`) to refresh `knowledge/docs/`.
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** `solobrand-mcp`: the development MCP over stdio, run from the app directory. */
|
|
3
|
+
import { startServer } from './server.js';
|
|
4
|
+
const env = process.env.SOLOBRAND_LOCALE;
|
|
5
|
+
startServer({ cwd: process.env.SOLOBRAND_APP_DIR ?? process.cwd(), ...(env === 'es' || env === 'en' ? { locale: env } : {}) }).catch((e) => {
|
|
6
|
+
process.stderr.write(`solobrand-mcp: ${e instanceof Error ? e.message : String(e)}\n`);
|
|
7
|
+
process.exit(1);
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,mFAAmF;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;AACzC,WAAW,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAU,EAAE,EAAE;IAClJ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACvF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @solobrand/mcp — public contracts (FROZEN by F0). Implemented by F7 (P24-62).
|
|
3
|
+
*
|
|
4
|
+
* The DEVELOPMENT MCP (stdio, runs next to the code). Knowledge comes from the
|
|
5
|
+
* same Markdown as the documentation site (docs/), so the MCP and the docs never
|
|
6
|
+
* disagree. Operating hosted apps (deploy, logs, DB, secrets) is SoloBrand's
|
|
7
|
+
* remote MCP (P24-22).
|
|
8
|
+
*/
|
|
9
|
+
export interface KnowledgeEntry {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly title: string;
|
|
12
|
+
readonly locale: 'es' | 'en';
|
|
13
|
+
readonly body: string;
|
|
14
|
+
readonly tags: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
export declare const TOOL_NAMES: readonly ["framework_overview", "framework_recipe", "framework_pitfalls", "spec_schema", "spec_validate", "generate", "verify", "guard", "audit", "docs_search", "package_list"];
|
|
17
|
+
export type ToolName = (typeof TOOL_NAMES)[number];
|
|
18
|
+
export { TOOLS, TOOLS_BY_NAME, callTool, installedPackages, insideRoot, isInside, pathApi, resolveInside, schemaPath, slug, LIST_LIMIT, type ToolContext, type ToolDefinition, type ToolResult, type JsonSchemaObject, type InstalledPackage, } from './tools.js';
|
|
19
|
+
export { loadKnowledge, parseEntry, splitSections, expandSections, SECTIONED_PAGES, splitFrontMatter, inLocale, defaultKnowledgeDirs, PACKAGE_ROOT, LOCALES, type Locale } from './knowledge.js';
|
|
20
|
+
export { Bm25Index, tokenize, snippet, type SearchHit } from './search.js';
|
|
21
|
+
export { mcpMessages, t, type McpMessageKey } from './messages.js';
|
|
22
|
+
export { nodeFileSystem, confinedPath, OutsideRootError, SKIPPED_DIRS, type NodeFileSystem } from './node-fs.js';
|
|
23
|
+
export { createServer, startServer, SERVER_NAME, SERVER_VERSION, SERVER_INSTRUCTIONS, type StartOptions } from './server.js';
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED,eAAO,MAAM,UAAU,kLAYb,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAGnD,OAAO,EACL,KAAK,EACL,aAAa,EACb,QAAQ,EACR,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,OAAO,EACP,aAAa,EACb,UAAU,EACV,IAAI,EACJ,UAAU,EACV,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACjM,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AACjH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,mBAAmB,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const TOOL_NAMES = [
|
|
2
|
+
'framework_overview',
|
|
3
|
+
'framework_recipe',
|
|
4
|
+
'framework_pitfalls',
|
|
5
|
+
'spec_schema',
|
|
6
|
+
'spec_validate',
|
|
7
|
+
'generate',
|
|
8
|
+
'verify',
|
|
9
|
+
'guard',
|
|
10
|
+
'audit',
|
|
11
|
+
'docs_search',
|
|
12
|
+
'package_list',
|
|
13
|
+
];
|
|
14
|
+
// ── Implementation (F7) ────────────────────────────────────────────────
|
|
15
|
+
export { TOOLS, TOOLS_BY_NAME, callTool, installedPackages, insideRoot, isInside, pathApi, resolveInside, schemaPath, slug, LIST_LIMIT, } from './tools.js';
|
|
16
|
+
export { loadKnowledge, parseEntry, splitSections, expandSections, SECTIONED_PAGES, splitFrontMatter, inLocale, defaultKnowledgeDirs, PACKAGE_ROOT, LOCALES } from './knowledge.js';
|
|
17
|
+
export { Bm25Index, tokenize, snippet } from './search.js';
|
|
18
|
+
export { mcpMessages, t } from './messages.js';
|
|
19
|
+
export { nodeFileSystem, confinedPath, OutsideRootError, SKIPPED_DIRS } from './node-fs.js';
|
|
20
|
+
export { createServer, startServer, SERVER_NAME, SERVER_VERSION, SERVER_INSTRUCTIONS } from './server.js';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgBA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,oBAAoB;IACpB,kBAAkB;IAClB,oBAAoB;IACpB,aAAa;IACb,eAAe;IACf,UAAU;IACV,QAAQ;IACR,OAAO;IACP,OAAO;IACP,aAAa;IACb,cAAc;CACN,CAAC;AAIX,0EAA0E;AAC1E,OAAO,EACL,KAAK,EACL,aAAa,EACb,QAAQ,EACR,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,OAAO,EACP,aAAa,EACb,UAAU,EACV,IAAI,EACJ,UAAU,GAMX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,YAAY,EAAE,OAAO,EAAe,MAAM,gBAAgB,CAAC;AACjM,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAkB,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,CAAC,EAAsB,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAuB,MAAM,cAAc,CAAC;AACjH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,mBAAmB,EAAqB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { KnowledgeEntry } from './index.js';
|
|
2
|
+
export type Locale = KnowledgeEntry['locale'];
|
|
3
|
+
export declare const LOCALES: readonly Locale[];
|
|
4
|
+
/** This package's root (works from `src/` in tests and from `dist/` once built). */
|
|
5
|
+
export declare const PACKAGE_ROOT: string;
|
|
6
|
+
/**
|
|
7
|
+
* Where knowledge is read from, in priority order. Inside the framework
|
|
8
|
+
* monorepo the live `docs/` is read (so edits show without a build); once
|
|
9
|
+
* installed, the copy in `knowledge/docs/`. The seed always comes last.
|
|
10
|
+
*/
|
|
11
|
+
export declare function defaultKnowledgeDirs(root?: string): string[];
|
|
12
|
+
interface FrontMatter {
|
|
13
|
+
readonly fields: Record<string, string>;
|
|
14
|
+
readonly body: string;
|
|
15
|
+
}
|
|
16
|
+
/** A minimal `---` front matter reader: `key: value` lines, `[a, b]` lists. */
|
|
17
|
+
export declare function splitFrontMatter(text: string): FrontMatter;
|
|
18
|
+
/**
|
|
19
|
+
* Turns one Markdown file into an entry. `relPath` is POSIX and relative to
|
|
20
|
+
* the knowledge dir. The locale comes from front matter, then a `.es.md` /
|
|
21
|
+
* `.en.md` suffix, then an `es/` or `en/` path segment, else Spanish (the
|
|
22
|
+
* framework's first language). The id drops the extension and the locale.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseEntry(relPath: string, text: string): KnowledgeEntry;
|
|
25
|
+
/** Pages written as one page of `##` sections, served one section per entry. */
|
|
26
|
+
export declare const SECTIONED_PAGES: ReadonlySet<string>;
|
|
27
|
+
interface Section {
|
|
28
|
+
readonly heading: string;
|
|
29
|
+
readonly body: string;
|
|
30
|
+
}
|
|
31
|
+
/** The `## ` sections of a Markdown body (headings inside code fences don't count). */
|
|
32
|
+
export declare function splitSections(body: string): Section[];
|
|
33
|
+
/**
|
|
34
|
+
* Replaces each sectioned page by one entry per `##` section, id
|
|
35
|
+
* `<page>/<slug>`. Both locales keep the same headings in the same order
|
|
36
|
+
* (docs/STRUCTURE.md), so section i takes its slug from the English heading
|
|
37
|
+
* when there is one: `recipes/rate-limit-a-route` in es and en alike.
|
|
38
|
+
*/
|
|
39
|
+
export declare function expandSections(entries: readonly KnowledgeEntry[]): KnowledgeEntry[];
|
|
40
|
+
/** Reads every `*.md` under the given dirs. Earlier dirs win on (id, locale). */
|
|
41
|
+
export declare function loadKnowledge(dirs?: readonly string[]): Promise<KnowledgeEntry[]>;
|
|
42
|
+
/** Entries in `locale`, plus those only available in the other locale. */
|
|
43
|
+
export declare function inLocale(entries: readonly KnowledgeEntry[], locale: Locale): KnowledgeEntry[];
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=knowledge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge.d.ts","sourceRoot":"","sources":["../src/knowledge.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,MAAM,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;AAC9C,eAAO,MAAM,OAAO,EAAE,SAAS,MAAM,EAAiB,CAAC;AAEvD,oFAAoF;AACpF,eAAO,MAAM,YAAY,QAAsD,CAAC;AAEhF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,GAAE,MAAqB,GAAG,MAAM,EAAE,CAI1E;AAED,UAAU,WAAW;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAU1D;AAeD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAoBxE;AAKD,gFAAgF;AAChF,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,MAAM,CAA0D,CAAC;AAE3G,UAAU,OAAO;IACf,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAUD,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,CAWrD;AAWD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,GAAG,cAAc,EAAE,CAgBnF;AAED,iFAAiF;AACjF,wBAAsB,aAAa,CAAC,IAAI,GAAE,SAAS,MAAM,EAA2B,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAe/G;AAED,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,EAAE,CAI7F"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The knowledge the MCP serves: the Markdown of the docs site (`docs/`, copied
|
|
3
|
+
* into `knowledge/docs/` at build time) plus the seed recipes this package
|
|
4
|
+
* ships (`knowledge/seed/`). A docs entry wins over a seed entry with the same
|
|
5
|
+
* id and locale, so the MCP and the docs never disagree once docs land.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
import { readFile } from 'node:fs/promises';
|
|
9
|
+
import { dirname, join } from 'node:path';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import { nodeFileSystem } from './node-fs.js';
|
|
12
|
+
export const LOCALES = ['es', 'en'];
|
|
13
|
+
/** This package's root (works from `src/` in tests and from `dist/` once built). */
|
|
14
|
+
export const PACKAGE_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
15
|
+
/**
|
|
16
|
+
* Where knowledge is read from, in priority order. Inside the framework
|
|
17
|
+
* monorepo the live `docs/` is read (so edits show without a build); once
|
|
18
|
+
* installed, the copy in `knowledge/docs/`. The seed always comes last.
|
|
19
|
+
*/
|
|
20
|
+
export function defaultKnowledgeDirs(root = PACKAGE_ROOT) {
|
|
21
|
+
const repo = join(root, '..', '..');
|
|
22
|
+
const inRepo = existsSync(join(repo, 'packages', 'mcp', 'package.json')) && existsSync(join(repo, 'docs'));
|
|
23
|
+
return [inRepo ? join(repo, 'docs') : join(root, 'knowledge', 'docs'), join(root, 'knowledge', 'seed')];
|
|
24
|
+
}
|
|
25
|
+
/** A minimal `---` front matter reader: `key: value` lines, `[a, b]` lists. */
|
|
26
|
+
export function splitFrontMatter(text) {
|
|
27
|
+
const normalized = text.replace(/^/, '').replace(/\r\n/g, '\n');
|
|
28
|
+
const m = /^---\n([\s\S]*?)\n---\n?/.exec(normalized);
|
|
29
|
+
if (!m)
|
|
30
|
+
return { fields: {}, body: normalized };
|
|
31
|
+
const fields = {};
|
|
32
|
+
for (const line of m[1].split('\n')) {
|
|
33
|
+
const kv = /^([A-Za-z_][\w-]*)\s*:\s*(.*)$/.exec(line);
|
|
34
|
+
if (kv)
|
|
35
|
+
fields[kv[1].toLowerCase()] = kv[2].trim().replace(/^["']|["']$/g, '');
|
|
36
|
+
}
|
|
37
|
+
return { fields, body: normalized.slice(m[0].length) };
|
|
38
|
+
}
|
|
39
|
+
function parseList(value) {
|
|
40
|
+
if (value === undefined || value === '')
|
|
41
|
+
return [];
|
|
42
|
+
return value
|
|
43
|
+
.replace(/^\[|\]$/g, '')
|
|
44
|
+
.split(',')
|
|
45
|
+
.map((t) => t.trim().replace(/^["']|["']$/g, ''))
|
|
46
|
+
.filter((t) => t !== '');
|
|
47
|
+
}
|
|
48
|
+
function isLocale(value) {
|
|
49
|
+
return value === 'es' || value === 'en';
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Turns one Markdown file into an entry. `relPath` is POSIX and relative to
|
|
53
|
+
* the knowledge dir. The locale comes from front matter, then a `.es.md` /
|
|
54
|
+
* `.en.md` suffix, then an `es/` or `en/` path segment, else Spanish (the
|
|
55
|
+
* framework's first language). The id drops the extension and the locale.
|
|
56
|
+
*/
|
|
57
|
+
export function parseEntry(relPath, text) {
|
|
58
|
+
const { fields, body } = splitFrontMatter(text);
|
|
59
|
+
let segments = relPath.replace(/\.md$/i, '').split('/');
|
|
60
|
+
let locale = 'es';
|
|
61
|
+
const last = segments[segments.length - 1];
|
|
62
|
+
const suffix = /\.(es|en)$/.exec(last);
|
|
63
|
+
if (suffix) {
|
|
64
|
+
locale = suffix[1];
|
|
65
|
+
segments[segments.length - 1] = last.slice(0, -3);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const seg = segments.find((s) => isLocale(s));
|
|
69
|
+
if (seg !== undefined)
|
|
70
|
+
locale = seg;
|
|
71
|
+
}
|
|
72
|
+
segments = segments.filter((s) => !isLocale(s));
|
|
73
|
+
if (isLocale(fields.locale))
|
|
74
|
+
locale = fields.locale;
|
|
75
|
+
const id = fields.id ?? segments.join('/');
|
|
76
|
+
const heading = /^#\s+(.+)$/m.exec(body);
|
|
77
|
+
const title = fields.title ?? (heading ? heading[1].trim() : (segments[segments.length - 1] ?? id));
|
|
78
|
+
const tags = parseList(fields.tags);
|
|
79
|
+
return { id, title, locale, body: body.trim(), tags };
|
|
80
|
+
}
|
|
81
|
+
/** Files that are about the docs, not the framework. */
|
|
82
|
+
const SKIPPED_FILES = /(^|\/)(STRUCTURE\.md|CHANGELOG\.md)$|(^|\/)\.vitepress\//i;
|
|
83
|
+
/** Pages written as one page of `##` sections, served one section per entry. */
|
|
84
|
+
export const SECTIONED_PAGES = new Set(['recipes', 'pitfalls', 'recetas', 'trampas']);
|
|
85
|
+
/** Cleans a heading for a title: no VitePress badges or anchors. */
|
|
86
|
+
function cleanHeading(text) {
|
|
87
|
+
return text
|
|
88
|
+
.replace(/<Badge\b[^>]*\/?>(?:<\/Badge>)?/g, '')
|
|
89
|
+
.replace(/\s*\{#[^}]*\}\s*$/, '')
|
|
90
|
+
.trim();
|
|
91
|
+
}
|
|
92
|
+
/** The `## ` sections of a Markdown body (headings inside code fences don't count). */
|
|
93
|
+
export function splitSections(body) {
|
|
94
|
+
const out = [];
|
|
95
|
+
let fence = null;
|
|
96
|
+
for (const line of body.split('\n')) {
|
|
97
|
+
const f = /^\s*(```+|~~~+)/.exec(line);
|
|
98
|
+
if (f)
|
|
99
|
+
fence = fence === null ? f[1].slice(0, 3) : line.trim().startsWith(fence) ? null : fence;
|
|
100
|
+
const h = fence === null ? /^##\s+(.+)$/.exec(line) : null;
|
|
101
|
+
if (h)
|
|
102
|
+
out.push({ heading: cleanHeading(h[1]), lines: [line] });
|
|
103
|
+
else
|
|
104
|
+
out[out.length - 1]?.lines.push(line);
|
|
105
|
+
}
|
|
106
|
+
return out.map((s) => ({ heading: s.heading, body: s.lines.join('\n').trim() }));
|
|
107
|
+
}
|
|
108
|
+
function slugOf(text) {
|
|
109
|
+
return text
|
|
110
|
+
.toLowerCase()
|
|
111
|
+
.normalize('NFD')
|
|
112
|
+
.replace(/\p{M}+/gu, '')
|
|
113
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
114
|
+
.replace(/^-|-$/g, '');
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Replaces each sectioned page by one entry per `##` section, id
|
|
118
|
+
* `<page>/<slug>`. Both locales keep the same headings in the same order
|
|
119
|
+
* (docs/STRUCTURE.md), so section i takes its slug from the English heading
|
|
120
|
+
* when there is one: `recipes/rate-limit-a-route` in es and en alike.
|
|
121
|
+
*/
|
|
122
|
+
export function expandSections(entries) {
|
|
123
|
+
const out = [];
|
|
124
|
+
for (const entry of entries) {
|
|
125
|
+
const page = entry.id.split('/').pop();
|
|
126
|
+
if (!SECTIONED_PAGES.has(page)) {
|
|
127
|
+
out.push(entry);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const en = entries.find((e) => e.id === entry.id && e.locale === 'en');
|
|
131
|
+
const enHeadings = en ? splitSections(en.body).map((s) => s.heading) : [];
|
|
132
|
+
splitSections(entry.body).forEach((section, i) => {
|
|
133
|
+
const slug = slugOf(enHeadings[i] ?? section.heading) || String(i + 1);
|
|
134
|
+
out.push({ id: `${entry.id}/${slug}`, title: section.heading, locale: entry.locale, body: section.body, tags: entry.tags });
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
/** Reads every `*.md` under the given dirs. Earlier dirs win on (id, locale). */
|
|
140
|
+
export async function loadKnowledge(dirs = defaultKnowledgeDirs()) {
|
|
141
|
+
const fs = nodeFileSystem();
|
|
142
|
+
const seen = new Map();
|
|
143
|
+
for (const dir of dirs) {
|
|
144
|
+
const fromDir = [];
|
|
145
|
+
for (const rel of await fs.list(dir)) {
|
|
146
|
+
if (!/\.md$/i.test(rel) || SKIPPED_FILES.test(rel))
|
|
147
|
+
continue;
|
|
148
|
+
fromDir.push(parseEntry(rel, await readFile(join(dir, rel), 'utf8')));
|
|
149
|
+
}
|
|
150
|
+
for (const entry of expandSections(fromDir)) {
|
|
151
|
+
const key = `${entry.locale}:${entry.id}`;
|
|
152
|
+
if (!seen.has(key))
|
|
153
|
+
seen.set(key, entry);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return [...seen.values()].sort((a, b) => (a.id === b.id ? (a.locale < b.locale ? -1 : 1) : a.id < b.id ? -1 : 1));
|
|
157
|
+
}
|
|
158
|
+
/** Entries in `locale`, plus those only available in the other locale. */
|
|
159
|
+
export function inLocale(entries, locale) {
|
|
160
|
+
const preferred = entries.filter((e) => e.locale === locale);
|
|
161
|
+
const have = new Set(preferred.map((e) => e.id));
|
|
162
|
+
return [...preferred, ...entries.filter((e) => e.locale !== locale && !have.has(e.id))];
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=knowledge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge.js","sourceRoot":"","sources":["../src/knowledge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,MAAM,CAAC,MAAM,OAAO,GAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC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C,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Every sentence the MCP's tools print, as a translation key with es and en. */
|
|
2
|
+
import type { Locale } from './knowledge.js';
|
|
3
|
+
declare const en: {
|
|
4
|
+
readonly 'mcp.overview.title': "SoloBrand Framework";
|
|
5
|
+
readonly 'mcp.overview.what': "Full-stack TypeScript for apps on Cloudflare Workers for Platforms: one Worker + static assets + one D1 + one R2 per app, with Laravel semantics (container and providers, validated config, Result/AppError, FormRequest rules/authorize/handle, models and migrations on D1, auth that comes done, a React + Vite kit). app.json is the spec; @solobrand/generator turns it into every piece and leaves huecos for business logic.";
|
|
6
|
+
readonly 'mcp.overview.rules': "Rules (always):";
|
|
7
|
+
readonly 'mcp.overview.rule.huecos': "Write business logic only inside huecos: between `// @hueco <name>` and `// @fin-hueco`.";
|
|
8
|
+
readonly 'mcp.overview.rule.spec': "To add or change models, fields, policies, events or auth: edit app.json, then regenerate (tool `generate`, or `sb generate`). Never hand-write what the generator produces.";
|
|
9
|
+
readonly 'mcp.overview.rule.framework': "Never edit framework files: generated skeletons, node_modules/@solobrand/*, .solobrand/manifest.json.";
|
|
10
|
+
readonly 'mcp.overview.rule.checks': "Before finishing: run `verify` (spec and files in sync), `guard` (nothing edited outside huecos) and `audit` (hand-rolled routes/requests/policies carry `// @a-mano`).";
|
|
11
|
+
readonly 'mcp.overview.rule.security': "Policies are closed by default; someone else's row is 404, never 403. Text a person reads is a translation key (es and en).";
|
|
12
|
+
readonly 'mcp.overview.recipes': "Recipes (framework_recipe):";
|
|
13
|
+
readonly 'mcp.overview.pitfalls': "Pitfalls (framework_pitfalls):";
|
|
14
|
+
readonly 'mcp.none': "(none)";
|
|
15
|
+
readonly 'mcp.recipe.not_found': "No recipe matches \"{topic}\". Available:";
|
|
16
|
+
readonly 'mcp.pitfalls.not_found': "No pitfalls match \"{area}\". Areas:";
|
|
17
|
+
readonly 'mcp.pitfalls.all': "Pitfalls by area (call framework_pitfalls with an area for the details):";
|
|
18
|
+
readonly 'mcp.search.empty': "Nothing in the docs matches \"{query}\".";
|
|
19
|
+
readonly 'mcp.search.results': "{count} result(s) for \"{query}\":";
|
|
20
|
+
readonly 'mcp.spec.valid': "app.json is valid: app \"{app}\", {models} model(s).";
|
|
21
|
+
readonly 'mcp.spec.invalid': "app.json has {count} problem(s):";
|
|
22
|
+
readonly 'mcp.spec.missing': "No app.json found at {path}. Pass `spec` (the JSON) or `path`.";
|
|
23
|
+
readonly 'mcp.spec.not_json': "The spec is not valid JSON.";
|
|
24
|
+
readonly 'mcp.path.outside': "The path \"{path}\" is outside the app directory; refused.";
|
|
25
|
+
readonly 'mcp.generate.dry_run': "Dry run (nothing written). Call generate with write: true to apply.";
|
|
26
|
+
readonly 'mcp.generate.applied': "Generated.";
|
|
27
|
+
readonly 'mcp.generate.would_write': "Would write ({count}):";
|
|
28
|
+
readonly 'mcp.generate.written': "Written ({count}):";
|
|
29
|
+
readonly 'mcp.generate.unchanged': "Unchanged: {count}";
|
|
30
|
+
readonly 'mcp.generate.skipped': "Skipped (`once` files that already exist): {count}";
|
|
31
|
+
readonly 'mcp.generate.orphans': "Orphan huecos (code kept in .solobrand/orphans, move it by hand) ({count}):";
|
|
32
|
+
readonly 'mcp.generate.obsolete': "Obsolete files (no longer produced, left on disk) ({count}):";
|
|
33
|
+
readonly 'mcp.generate.failed': "Generation failed: {message}";
|
|
34
|
+
readonly 'mcp.generate.refused': "Nothing was written: {count} generated file(s) were edited outside their huecos and regenerating would erase that code. Move each change into a hueco (or undo it), then generate again. Only a person can override this, with `sb generate --force` in a terminal.";
|
|
35
|
+
readonly 'mcp.generate.outside_root': "Nothing more was written: {path} is reached through a symlink or junction that leads outside the app. Remove it and generate again.";
|
|
36
|
+
readonly 'mcp.check.clean': "{check}: clean, no findings.";
|
|
37
|
+
readonly 'mcp.check.findings': "{check}: {count} finding(s):";
|
|
38
|
+
readonly 'mcp.check.failed': "{check} could not run: {message}";
|
|
39
|
+
readonly 'mcp.check.hint.guard': "Move that code into a hueco, or change app.json and regenerate.";
|
|
40
|
+
readonly 'mcp.check.hint.verify': "Run generate (write: true) to bring the files in line with app.json.";
|
|
41
|
+
readonly 'mcp.check.hint.audit': "Generate it from app.json, or mark the file `// @a-mano` if it is deliberately hand-written.";
|
|
42
|
+
readonly 'mcp.packages.none': "No @solobrand/* packages installed under {cwd}.";
|
|
43
|
+
readonly 'mcp.packages.title': "Installed @solobrand/* packages:";
|
|
44
|
+
readonly 'mcp.more': "…and {count} more";
|
|
45
|
+
readonly 'mcp.args.invalid': "Invalid arguments: {details}";
|
|
46
|
+
readonly 'mcp.tool.unknown': "Unknown tool \"{name}\".";
|
|
47
|
+
};
|
|
48
|
+
export type McpMessageKey = keyof typeof en;
|
|
49
|
+
export declare const mcpMessages: Readonly<Record<Locale, Readonly<Record<McpMessageKey, string>>>>;
|
|
50
|
+
export declare function t(locale: Locale, key: McpMessageKey, params?: Readonly<Record<string, string | number>>): string;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,QAAA,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CE,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,EAAE,CAAC;AAiD5C,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,CAAc,CAAC;AAEzG,wBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAM,GAAG,MAAM,CAEpH"}
|