@craft-ts/mcp 0.7.0-beta.13
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 +71 -0
- package/content/agents.md +35 -0
- package/content/best-practices.md +79 -0
- package/content/docs-index.json +658 -0
- package/dist/catalog.d.ts +27 -0
- package/dist/catalog.js +67 -0
- package/dist/catalog.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +13 -0
- package/dist/main.js.map +1 -0
- package/dist/mcp-server.d.ts +3 -0
- package/dist/mcp-server.js +144 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/resources.d.ts +10 -0
- package/dist/resources.js +63 -0
- package/dist/resources.js.map +1 -0
- package/mcp.json +10 -0
- package/package.json +62 -0
- package/plugin.json +19 -0
- package/skills/craft-ts/SKILL.md +43 -0
- package/skills/craft-ts-architecture-tests/SKILL.md +110 -0
- package/skills/craft-ts-effect-v4/SKILL.md +31 -0
- package/skills/craft-ts-routes/SKILL.md +135 -0
- package/skills/craft-ts-routes/references/di-checks.md +101 -0
- package/skills/craft-ts-routes/references/eslint-workflow.md +52 -0
- package/skills/craft-ts-routes/references/pending-and-exceptions.md +93 -0
- package/skills/craft-ts-routes/references/scaling-and-pitfalls.md +111 -0
- package/skills/craft-ts-service-migration/SKILL.md +86 -0
- package/skills/migrate-to-craft-ts/SKILL.md +135 -0
- package/skills/translate-spec-to-craft-ts/SKILL.md +86 -0
- package/skills/translate-spec-to-craft-ts/references/lexical-map.md +322 -0
- package/skills/translate-spec-to-craft-ts/references/pattern-recipes.md +123 -0
- package/skills/translate-spec-to-craft-ts/references/project-index.md +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# @craft-ts/mcp
|
|
2
|
+
|
|
3
|
+
MCP server, Agent Skills, and LLM entry points so a coding agent can use
|
|
4
|
+
`@craft-ts/core` after you import it.
|
|
5
|
+
|
|
6
|
+
This is the consumer-facing counterpart of the docs site. It does **not**
|
|
7
|
+
replace the runtime registry / log MCP servers used inside the craft-ts
|
|
8
|
+
monorepo.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install -D @craft-ts/mcp@beta
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or run it without adding a dependency:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx -y @craft-ts/mcp@beta
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Cursor / Claude Code / VS Code
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"mcpServers": {
|
|
27
|
+
"craft-ts": {
|
|
28
|
+
"command": "npx",
|
|
29
|
+
"args": ["-y", "@craft-ts/mcp@beta"]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Commit that as `.mcp.json` at the app root so the whole team gets the tools.
|
|
36
|
+
|
|
37
|
+
## Tools
|
|
38
|
+
|
|
39
|
+
| Tool | Job |
|
|
40
|
+
| --- | --- |
|
|
41
|
+
| `get_best_practices` | Craft coding rules + `AGENTS.md` snippet |
|
|
42
|
+
| `search_documentation` | Search the bundled Learn / Guide / Reference |
|
|
43
|
+
| `get_documentation_page` | One page as markdown |
|
|
44
|
+
| `find_examples` | Learn + demo example hits |
|
|
45
|
+
| `list_skills` / `get_skill` | Agent Skills shipped in this package |
|
|
46
|
+
| `get_llms_txt` | Public `llms.txt` / `llms-full.txt` URLs |
|
|
47
|
+
|
|
48
|
+
## LLM files on the docs site
|
|
49
|
+
|
|
50
|
+
- https://craft-ts.github.io/craft/llms.txt
|
|
51
|
+
- https://craft-ts.github.io/craft/llms-full.txt
|
|
52
|
+
- Every docs page also has a `.md` sibling (for example `/guide/state/local-state.md`)
|
|
53
|
+
|
|
54
|
+
## Agent Skills
|
|
55
|
+
|
|
56
|
+
Skills follow the [Agent Skills](https://agentskills.io/specification) layout
|
|
57
|
+
and are packaged as an [Agent Plugin](https://agent-plugins.org/) (`plugin.json`
|
|
58
|
+
+ `mcp.json` + `skills/`):
|
|
59
|
+
|
|
60
|
+
- `craft-ts-architecture-tests` — scaffold or run `architecture/`, freeze a graph smell
|
|
61
|
+
- `craft-ts-routes` — type-safe `craftRoutes` files
|
|
62
|
+
- `translate-spec-to-craft-ts` — map a spec onto primitives
|
|
63
|
+
- `craft-ts-service-migration` — `craftService` / `toCraftService`
|
|
64
|
+
- `migrate-to-craft-ts` — `craft-migrate` then manual follow-up
|
|
65
|
+
|
|
66
|
+
Point your agent at `node_modules/@craft-ts/mcp/skills`, or copy the `AGENTS.md`
|
|
67
|
+
snippet from `get_best_practices`.
|
|
68
|
+
|
|
69
|
+
## Docs
|
|
70
|
+
|
|
71
|
+
https://craft-ts.github.io/craft/resources/ai-agents
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# CraftTS
|
|
2
|
+
|
|
3
|
+
This application uses `@craft-ts/core` without an Angular dependency. Treat
|
|
4
|
+
Craft APIs as the default. Use Craft primitives, services, components,
|
|
5
|
+
`CraftHttpClient`, `startCraft` (or explicit `bootstrapCraft` / `hydrateCraft`),
|
|
6
|
+
and `provideCraftRouter` in authored code.
|
|
7
|
+
|
|
8
|
+
For SSR, use `renderCraft` to render one isolated request. On the browser,
|
|
9
|
+
`startCraft` automatically hydrates Craft SSR HTML or mounts a fresh client tree.
|
|
10
|
+
|
|
11
|
+
## Before writing Craft code
|
|
12
|
+
|
|
13
|
+
1. Read https://craft-ts.github.io/craft/llms.txt and follow the linked markdown pages.
|
|
14
|
+
2. If the CraftTS MCP server is configured, call `get_best_practices`, then `search_documentation` / `get_skill` instead of guessing APIs.
|
|
15
|
+
3. Skills live in `node_modules/@craft-ts/mcp/skills/` (architecture tests, routes, spec translation, service migration, full-app migration).
|
|
16
|
+
|
|
17
|
+
## Non-negotiable rules
|
|
18
|
+
|
|
19
|
+
- `yield*` every Craft reader (`state`, `query.value()`, service helpers). Use `craftUse` only at synchronous boundaries such as tests.
|
|
20
|
+
- One primitive family: `state` / `query` / `mutation` / `queryParams` / `asyncProcess`. Compose insertions with `craftPipe`.
|
|
21
|
+
- `craftService` + generated `X()` helpers for explicit dependency composition.
|
|
22
|
+
- `craftRoutes` + `componentDeps` + a per-file DI check. Split with `loadChildren` on `TS2589`.
|
|
23
|
+
- Enable `@craft-ts/dev-tools` ESLint rules and run `eslint --fix` after DI or route edits.
|
|
24
|
+
- The `architecture/` suite is the graph contract. `craft create` scaffolds it
|
|
25
|
+
at bootstrap and adds `npm run architecture`. Run it during a feature. Do not
|
|
26
|
+
add an architecture rule for the feature; encode a smell only when it is a
|
|
27
|
+
recurring product invariant not covered by a baseline helper.
|
|
28
|
+
|
|
29
|
+
## Docs
|
|
30
|
+
|
|
31
|
+
- Tutorial: https://craft-ts.github.io/craft/learn/
|
|
32
|
+
- Guide: https://craft-ts.github.io/craft/guide/
|
|
33
|
+
- API index: https://craft-ts.github.io/craft/reference/
|
|
34
|
+
- Coding agents: https://craft-ts.github.io/craft/resources/ai-agents
|
|
35
|
+
- Local dev: drive the open `ng serve` tab with the function-registry MCP tool `page` (https://craft-ts.github.io/craft/guide/ai/dev-page). That tool is not part of `@craft-ts/mcp`.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# CraftTS best practices for coding agents
|
|
2
|
+
|
|
3
|
+
This guide is the contract for generating `@craft-ts/core` code in an
|
|
4
|
+
application that already imported the library. Prefer Craft's functional and
|
|
5
|
+
generator-based model throughout.
|
|
6
|
+
|
|
7
|
+
Public docs: https://craft-ts.github.io/craft
|
|
8
|
+
LLM index: https://craft-ts.github.io/craft/llms.txt
|
|
9
|
+
Full dump: https://craft-ts.github.io/craft/llms-full.txt
|
|
10
|
+
|
|
11
|
+
For a new framework-independent app, start with `npx craft create <directory>`.
|
|
12
|
+
The prompt asks for EffectTS v4 first, then the agent integrations to install
|
|
13
|
+
(`codex`, `cursor`, `cloud-code`; `claude-code` is also supported). The starter
|
|
14
|
+
already contains a routed page, a `CraftHttpClient` API query, ESLint, unit and
|
|
15
|
+
Playwright tests, and the `architecture/` contract. Use `--effect=v4` or
|
|
16
|
+
`--effect=none` for non-interactive setup.
|
|
17
|
+
|
|
18
|
+
When MCP tools are available, call `get_best_practices` once, then `search_documentation` / `get_skill` instead of inventing APIs.
|
|
19
|
+
|
|
20
|
+
## Mental model
|
|
21
|
+
|
|
22
|
+
- Declare with a name, `yield*` what you do not own, derive the rest.
|
|
23
|
+
- One API shape for every kind of state: `state`, `query`, `mutation`, `queryParams`, `asyncProcess`.
|
|
24
|
+
- Insertions compose behaviour (`insertForm`, `insertReactOnMutation`, `insertEntities`, persistence). A primitive takes **one** insertion. Compose with `craftPipe(context, a, b)`.
|
|
25
|
+
- Services are factories (`craftService`), not classes.
|
|
26
|
+
- Components are selectorless functions (`craftComponent`) with typed hyperscript, not `@Component` + HTML templates.
|
|
27
|
+
|
|
28
|
+
## Which primitive
|
|
29
|
+
|
|
30
|
+
| Need | Primitive |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| Local UI state you own | `state` |
|
|
33
|
+
| Server read, refetch from reactive params | `query` |
|
|
34
|
+
| Server write, triggered explicitly | `mutation` |
|
|
35
|
+
| Shareable URL query-string state | `queryParams` |
|
|
36
|
+
| One-off async job with lifecycle | `asyncProcess` |
|
|
37
|
+
|
|
38
|
+
Decision page: `/guide/concepts/choose-primitive`.
|
|
39
|
+
|
|
40
|
+
## Rules you must not break
|
|
41
|
+
|
|
42
|
+
1. **`yield*` every Craft reader.** Primitive roots, insertions, `query.value()`, `query.status()`, service helpers. Do not call a reader as a function to unwrap it. In tests and other synchronous boundaries use `craftUse(reader())`.
|
|
43
|
+
2. **Keep reactive state inside Craft primitives.** Use `state`, `craftComputed`,
|
|
44
|
+
`craftEffect`, and the other documented helpers rather than ad hoc runtime
|
|
45
|
+
state.
|
|
46
|
+
3. **Do not use `async` / `await` / `for await`.** Generators, `craftSleep`, and `CraftHttpClient` replace them.
|
|
47
|
+
4. **HTTP:** `query` for reads, `mutation` for writes, both backed by `CraftHttpClient`. No raw `fetch` / `HttpClient`.
|
|
48
|
+
5. **Forms** derive from `state` + `insertForm`. Validators are `cRequired`, `cEmail`, `cMinLength`, … Submit through `insertFormSubmit` + a `mutation`. Failures are `craftException` values.
|
|
49
|
+
6. **Services:** `craftService({ name, scope }, function* () { ... })`. Consume
|
|
50
|
+
the generated `X()` helper, typically `yield* X(...)`.
|
|
51
|
+
7. **Routes:** `craftRoutes(name, [...])`, every component route has `componentDeps: {} as import('./x').GenDeps_X`, and **every file** has its own `ValidateCascadeRoutesFile` / `CanRun` check. Parent checks do not cover `loadChildren`. On `TS2589`, split with `loadChildren` — never delete the check.
|
|
52
|
+
8. **Templates:** `ifBlock` / `matchBlock` / `each` / `defer`, not `@if` / `@for`. Interactive helpers take a unique literal local name: `button('save', { type: 'button', ... }, 'Save')`. The name is `data-craft-name` and must be unique in the app (`assertInteractiveElementNamed`).
|
|
53
|
+
9. **Let ESLint keep generated aliases.** After DI or route edits, run `eslint --fix`. Do not hand-edit `GenDeps_*` or `_Check*` / `_CanRun*` blocks.
|
|
54
|
+
|
|
55
|
+
Install `@craft-ts/dev-tools` and enable the `craft-ts/*` ESLint rules. They are the compiler's partner: a missing route check or a raw `inject()` should fail CI, not production. The generated README documents `npm run lint`, `typecheck`, `test`, `architecture`, `e2e`, and, for EffectTS v4, `effect-check`.
|
|
56
|
+
|
|
57
|
+
The `architecture/` suite is the graph contract: unique HTTP, unique identities, armed route DI proofs, folder lanes. Scaffold it at app start (`craft-ts-architecture-tests`, `craft-migrate-architecture`). During a feature, run it. Do not add an architecture rule for the feature. Add a new `it()` only to freeze a spotted smell so it cannot recur.
|
|
58
|
+
|
|
59
|
+
## Default compositions
|
|
60
|
+
|
|
61
|
+
- Mutation that changes a visible list: `insertReactOnMutation` on the `query`. Prefer `optimisticPatch` for shallow fields, `optimisticUpdate` for arrays. Enable `reload: { onMutationError: true }` unless the spec forbids refetch.
|
|
62
|
+
- Pagination / no-flicker page changes: `queryParams` + `query` + `insertPaginationPlaceholderData`.
|
|
63
|
+
- Collections (add/remove/update/upsert): `insertEntities` and `removeOne` / `removeMany` / `updateOne` / `upsertMany`.
|
|
64
|
+
- Remembered filters or results: `insertStoragePersister` / `insertLocalStoragePersister`.
|
|
65
|
+
- Nested sub-state: `insertSelect`. Nested forms: `insertSelectFormTree` + `insertSubFormField`.
|
|
66
|
+
|
|
67
|
+
## Agent workflow
|
|
68
|
+
|
|
69
|
+
1. If this is app setup or `craft-migrate`, and `architecture/` is missing, load `craft-ts-architecture-tests` and scaffold the baseline. Mid-feature, offer the scaffold; do not impose it.
|
|
70
|
+
2. Map the request to primitives (`translate-spec-to-craft-ts` skill). Name the baseline helper that already covers the mapping; do not invent a rule per feature.
|
|
71
|
+
3. Search docs for the exact export (`search_documentation`, then `get_documentation_page`).
|
|
72
|
+
4. For routes, follow `craft-ts-routes`. For an existing application, use
|
|
73
|
+
`migrate-to-craft-ts` then `craft-migrate`. Load
|
|
74
|
+
`craft-ts-architecture-tests` when a graph smell must not recur.
|
|
75
|
+
5. Run the app's lint, typecheck, existing architecture tests, and tests. Do not claim success from filtered output.
|
|
76
|
+
|
|
77
|
+
Confirm symbol names against the installed `@craft-ts/core` (and `@craft-ts/component`) in `node_modules`. If they disagree with this guide, the installed package wins.
|
|
78
|
+
|
|
79
|
+
In local development, drive the already-open `ng serve` tab with the function-registry MCP tool `page` (see `/guide/ai/dev-page`). `@craft-ts/mcp` does not expose `page`; it is docs and skills for writing Craft.
|