# Input Foundry — AI context

Service: https://mayphus.org/typing
Purpose: build, test, and customize Rime/Yuanshu schemes and keyboard layouts.

## Public workbench

- `/typing/`: choose a supported method/layout, try real browser Rime, and build a package.
- `/typing/api/schemas`: JSON catalog. Each item has `id`, `config`, `slug`, and supported `artifacts`.
- `/typing/engine-package.json?schema=<id>`: exact engine configuration and resources.
- `/typing/keyboard-pages.json?schema=<id>&artifact=<target>`: generated keyboard pages.
- `POST /typing/build`: URL-encoded `artifact=rime` or `artifact=yuanshu`, plus one to eight repeated `schemas=<id>` fields; returns an installable ZIP. Use only targets listed by the catalog. Builds are rate limited. Browser cross-origin builds are rejected.
- `/typing/customize`: compose and download a custom-work brief. This is a local form, not an AI chat or arbitrary custom compiler.
- `/typing/guide`: installation and device-check guidance.

## Custom work with an AI assistant

Open the owner's private `mayphus/input-foundry` repository in your authorized coding workspace. Use its `.agents/skills/customize-input-method/SKILL.md` and `docs/custom-work.md`. Repository access is required for compiler source changes; public users can still use the preset builder and download briefs.

A brief should specify device/app, base schema, requested changes, behavior to preserve and concrete input/output test cases. The assistant edits source, validates dependencies and composition, and delivers a preview plus package. Preview and export use the same renderer. Custom work is not automatically added to the public catalog.

Keep personal dictionaries and unpublished customer work private. Browser typing stays in the browser; no AI service receives it. A successful browser test does not prove installation or native gestures on a phone.

## Version 1 package planning

`GET /typing/api/v1/plan?artifact=rime&schemas=double-pinyin-flypy`

This read-only endpoint validates a preset selection without building or installing
anything. Use one `artifact` (`rime` or `yuanshu`) and one to eight repeated
`schemas` parameters. Only catalog IDs or slugs are accepted; aliases normalize
to canonical IDs and duplicates collapse in first-occurrence order. Unknown
fields, targets and incompatible combinations fail explicitly. Queries are
limited to 4096 URL-encoded bytes. This is not an arbitrary configuration compiler.

A successful JSON response has `api_version: "1"`, `artifact`, ordered `schemas`,
expected ZIP `files` (path and uncompressed size), `merge_policy`,
`publication_digest`, `digest_scope`, and the existing `build` form contract.
Later schemas win shared-file conflicts. Preserve selection order when building.
The digest identifies the preset package manifest, not the ZIP bytes, a signature,
or proof of installation. The ZIP response includes the same digest in
`X-Input-Foundry-Publication`; compare it with the plan because a release may change
between requests. Re-plan if they differ.

Errors use `{ "api_version": "1", "error": { "code": "…", "message": "…", "field": "…" } }`
with HTTP 400 for invalid input, 413 for oversized queries, 405 for unsupported
methods, 503 for unavailable catalog/packages, or 500 for unexpected failures.
The optional `field` identifies the parameter, never internal source paths.
Codes include `ARTIFACT_REQUIRED`, `INVALID_ARTIFACT`, `SCHEMA_COUNT`,
`UNKNOWN_SCHEMA`, `UNSUPPORTED_COMBINATION`, `UNKNOWN_FIELD`, `INVALID_ENCODING`,
`QUERY_TOO_LARGE`, `METHOD_NOT_ALLOWED`, `CATALOG_UNAVAILABLE`,
`PACKAGE_UNAVAILABLE` and `INTERNAL_ERROR`.

Use the existing `POST /typing/build` to download the ZIP after checking the plan.
Its URL-encoded contract, limits and rate safeguards remain unchanged; it shares
the planner's selection and file merge logic. Browser typing and custom-work
briefs are not submitted to this endpoint or to an AI provider.
