@chiralkit/cli 0.1.0-alpha.0 → 0.2.0-alpha.0
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 +56 -61
- package/dist/add.d.ts +13 -0
- package/dist/add.js +51 -114
- package/dist/add.js.map +1 -1
- package/dist/config.d.ts +3 -1
- package/dist/config.js +6 -3
- package/dist/config.js.map +1 -1
- package/dist/doctor-invariants.d.ts +1 -1
- package/dist/doctor-invariants.js +20 -9
- package/dist/doctor-invariants.js.map +1 -1
- package/dist/doctor.js +29 -9
- package/dist/doctor.js.map +1 -1
- package/dist/index.js +5 -99
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -0
- package/dist/init.js +25 -16
- package/dist/init.js.map +1 -1
- package/dist/installers/context.d.ts +5 -1
- package/dist/installers/context.js +15 -7
- package/dist/installers/context.js.map +1 -1
- package/dist/installers/index.js +4 -0
- package/dist/installers/index.js.map +1 -1
- package/dist/installers/react/react/installer.d.ts +10 -0
- package/dist/installers/react/react/installer.js +16 -0
- package/dist/installers/react/react/installer.js.map +1 -0
- package/dist/installers/react/react/manifest.json +22 -0
- package/dist/installers/stencil/django-template/installer.js.map +1 -1
- package/dist/installers/stencil/react/installer.js +2 -1
- package/dist/installers/stencil/react/installer.js.map +1 -1
- package/dist/lock.d.ts +1 -0
- package/dist/lock.js +1 -0
- package/dist/lock.js.map +1 -1
- package/dist/manifest.js +1 -1
- package/dist/manifest.js.map +1 -1
- package/dist/operations/add-remote.d.ts +47 -0
- package/dist/operations/add-remote.js +376 -0
- package/dist/operations/add-remote.js.map +1 -0
- package/dist/operations/add.d.ts +33 -0
- package/dist/operations/add.js +183 -0
- package/dist/operations/add.js.map +1 -0
- package/dist/operations/index.d.ts +8 -0
- package/dist/operations/index.js +5 -0
- package/dist/operations/index.js.map +1 -0
- package/dist/operations/result.d.ts +9 -0
- package/dist/operations/result.js +2 -0
- package/dist/operations/result.js.map +1 -0
- package/dist/operations/update.d.ts +53 -0
- package/dist/operations/update.js +406 -0
- package/dist/operations/update.js.map +1 -0
- package/dist/paths-migrate.d.ts +12 -0
- package/dist/paths-migrate.js +242 -0
- package/dist/paths-migrate.js.map +1 -0
- package/dist/public-cli.d.ts +6 -0
- package/dist/public-cli.js +76 -0
- package/dist/public-cli.js.map +1 -0
- package/dist/registry-layout.d.ts +3 -5
- package/dist/registry-layout.js +32 -33
- package/dist/registry-layout.js.map +1 -1
- package/dist/remote/fetch-item.d.ts +12 -0
- package/dist/remote/fetch-item.js +66 -0
- package/dist/remote/fetch-item.js.map +1 -0
- package/dist/remote/file-targets.d.ts +8 -0
- package/dist/remote/file-targets.js +31 -0
- package/dist/remote/file-targets.js.map +1 -0
- package/dist/remote/registry-url.d.ts +5 -0
- package/dist/remote/registry-url.js +32 -0
- package/dist/remote/registry-url.js.map +1 -0
- package/dist/remote/terminal.d.ts +1 -0
- package/dist/remote/terminal.js +10 -0
- package/dist/remote/terminal.js.map +1 -0
- package/dist/source-paths.d.ts +9 -0
- package/dist/source-paths.js +51 -0
- package/dist/source-paths.js.map +1 -0
- package/dist/tokens-migrate/fixtures/shadcn-v4/components.json +5 -0
- package/dist/tokens-migrate/map-to-chiral.d.ts +9 -0
- package/dist/tokens-migrate/map-to-chiral.js +70 -0
- package/dist/tokens-migrate/map-to-chiral.js.map +1 -0
- package/dist/tokens-migrate/parse-shadcn-css.d.ts +2 -0
- package/dist/tokens-migrate/parse-shadcn-css.js +34 -0
- package/dist/tokens-migrate/parse-shadcn-css.js.map +1 -0
- package/dist/tokens-migrate/render-chiraltokens.d.ts +8 -0
- package/dist/tokens-migrate/render-chiraltokens.js +33 -0
- package/dist/tokens-migrate/render-chiraltokens.js.map +1 -0
- package/dist/tokens-migrate/run.d.ts +3 -0
- package/dist/tokens-migrate/run.js +120 -0
- package/dist/tokens-migrate/run.js.map +1 -0
- package/dist/tokens-migrate/types.d.ts +25 -0
- package/dist/{automation/parsers → tokens-migrate}/types.js.map +1 -1
- package/dist/update.d.ts +2 -19
- package/dist/update.js +19 -378
- package/dist/update.js.map +1 -1
- package/package.json +41 -14
- package/dist/agents/subprocess.d.ts +0 -10
- package/dist/agents/subprocess.js +0 -43
- package/dist/agents/subprocess.js.map +0 -1
- package/dist/automation/index.d.ts +0 -14
- package/dist/automation/index.js +0 -129
- package/dist/automation/index.js.map +0 -1
- package/dist/automation/install.d.ts +0 -19
- package/dist/automation/install.js +0 -116
- package/dist/automation/install.js.map +0 -1
- package/dist/automation/parsers/audit-report.d.ts +0 -2
- package/dist/automation/parsers/audit-report.js +0 -42
- package/dist/automation/parsers/audit-report.js.map +0 -1
- package/dist/automation/parsers/exit-code.d.ts +0 -2
- package/dist/automation/parsers/exit-code.js +0 -6
- package/dist/automation/parsers/exit-code.js.map +0 -1
- package/dist/automation/parsers/index.d.ts +0 -10
- package/dist/automation/parsers/index.js +0 -13
- package/dist/automation/parsers/index.js.map +0 -1
- package/dist/automation/parsers/observer-snapshot.d.ts +0 -2
- package/dist/automation/parsers/observer-snapshot.js +0 -30
- package/dist/automation/parsers/observer-snapshot.js.map +0 -1
- package/dist/automation/parsers/plan-report.d.ts +0 -2
- package/dist/automation/parsers/plan-report.js +0 -53
- package/dist/automation/parsers/plan-report.js.map +0 -1
- package/dist/automation/parsers/refinement-report.d.ts +0 -2
- package/dist/automation/parsers/refinement-report.js +0 -149
- package/dist/automation/parsers/refinement-report.js.map +0 -1
- package/dist/automation/parsers/types.d.ts +0 -7
- package/dist/automation/run.d.ts +0 -25
- package/dist/automation/run.js +0 -68
- package/dist/automation/run.js.map +0 -1
- package/dist/automation/schema.d.ts +0 -130
- package/dist/automation/schema.js +0 -46
- package/dist/automation/schema.js.map +0 -1
- package/dist/automation/status.d.ts +0 -16
- package/dist/automation/status.js +0 -56
- package/dist/automation/status.js.map +0 -1
- package/dist/automation/verifiers/index.d.ts +0 -7
- package/dist/automation/verifiers/index.js +0 -5
- package/dist/automation/verifiers/index.js.map +0 -1
- package/dist/automation/verifiers/shell.d.ts +0 -5
- package/dist/automation/verifiers/shell.js +0 -17
- package/dist/automation/verifiers/shell.js.map +0 -1
- package/dist/automation/verifiers/types.d.ts +0 -12
- package/dist/automation/verifiers/types.js +0 -2
- package/dist/automation/verifiers/types.js.map +0 -1
- package/dist/backlog/add.d.ts +0 -10
- package/dist/backlog/add.js +0 -30
- package/dist/backlog/add.js.map +0 -1
- package/dist/backlog/index.d.ts +0 -1
- package/dist/backlog/index.js +0 -53
- package/dist/backlog/index.js.map +0 -1
- package/dist/generate.d.ts +0 -1
- package/dist/generate.js +0 -275
- package/dist/generate.js.map +0 -1
- package/dist/generator/agent.d.ts +0 -8
- package/dist/generator/agent.js +0 -66
- package/dist/generator/agent.js.map +0 -1
- package/dist/generator/api.d.ts +0 -7
- package/dist/generator/api.js +0 -42
- package/dist/generator/api.js.map +0 -1
- package/dist/generator/config.d.ts +0 -23
- package/dist/generator/config.js +0 -121
- package/dist/generator/config.js.map +0 -1
- package/dist/generator/parse-response.d.ts +0 -5
- package/dist/generator/parse-response.js +0 -58
- package/dist/generator/parse-response.js.map +0 -1
- package/dist/generator/prompt.d.ts +0 -9
- package/dist/generator/prompt.js +0 -166
- package/dist/generator/prompt.js.map +0 -1
- package/dist/generator/request.d.ts +0 -17
- package/dist/generator/request.js +0 -15
- package/dist/generator/request.js.map +0 -1
- package/dist/generators/prompts/stencil.md +0 -45
- package/dist/generators/prompts/vue.md +0 -54
- package/dist/pm/audit.d.ts +0 -36
- package/dist/pm/audit.js +0 -147
- package/dist/pm/audit.js.map +0 -1
- package/dist/pm/backlog.d.ts +0 -3
- package/dist/pm/backlog.js +0 -123
- package/dist/pm/backlog.js.map +0 -1
- package/dist/pm/brief.d.ts +0 -4
- package/dist/pm/brief.js +0 -18
- package/dist/pm/brief.js.map +0 -1
- package/dist/pm/git.d.ts +0 -3
- package/dist/pm/git.js +0 -43
- package/dist/pm/git.js.map +0 -1
- package/dist/pm/grid.d.ts +0 -8
- package/dist/pm/grid.js +0 -16
- package/dist/pm/grid.js.map +0 -1
- package/dist/pm/index.d.ts +0 -25
- package/dist/pm/index.js +0 -199
- package/dist/pm/index.js.map +0 -1
- package/dist/pm/observe.d.ts +0 -55
- package/dist/pm/observe.js +0 -177
- package/dist/pm/observe.js.map +0 -1
- package/dist/pm/plan.d.ts +0 -54
- package/dist/pm/plan.js +0 -151
- package/dist/pm/plan.js.map +0 -1
- package/dist/pm/refinement-worktree.d.ts +0 -31
- package/dist/pm/refinement-worktree.js +0 -160
- package/dist/pm/refinement-worktree.js.map +0 -1
- package/dist/pm/refinement.d.ts +0 -79
- package/dist/pm/refinement.js +0 -326
- package/dist/pm/refinement.js.map +0 -1
- package/dist/pm/render.d.ts +0 -2
- package/dist/pm/render.js +0 -39
- package/dist/pm/render.js.map +0 -1
- package/dist/pm/roadmap-rings.d.ts +0 -7
- package/dist/pm/roadmap-rings.js +0 -31
- package/dist/pm/roadmap-rings.js.map +0 -1
- package/dist/pm/roadmap.d.ts +0 -2
- package/dist/pm/roadmap.js +0 -118
- package/dist/pm/roadmap.js.map +0 -1
- package/dist/pm/snapshot.d.ts +0 -10
- package/dist/pm/snapshot.js +0 -129
- package/dist/pm/snapshot.js.map +0 -1
- package/dist/pm/types.d.ts +0 -99
- package/dist/pm/types.js +0 -29
- package/dist/pm/types.js.map +0 -1
- package/dist/scaffold-registry.d.ts +0 -10
- package/dist/scaffold-registry.js +0 -283
- package/dist/scaffold-registry.js.map +0 -1
- package/dist/scaffold.d.ts +0 -1
- package/dist/scaffold.js +0 -32
- package/dist/scaffold.js.map +0 -1
- package/dist/spec-from-react.d.ts +0 -11
- package/dist/spec-from-react.js +0 -522
- package/dist/spec-from-react.js.map +0 -1
- package/dist/spec-from-stencil.d.ts +0 -7
- package/dist/spec-from-stencil.js +0 -275
- package/dist/spec-from-stencil.js.map +0 -1
- package/dist/spec.d.ts +0 -1
- package/dist/spec.js +0 -60
- package/dist/spec.js.map +0 -1
- package/dist/tokens-map.d.ts +0 -11
- package/dist/tokens-map.js +0 -43
- package/dist/tokens-map.js.map +0 -1
- package/dist/workspace-init.d.ts +0 -9
- package/dist/workspace-init.js +0 -119
- package/dist/workspace-init.js.map +0 -1
- /package/dist/{automation/parsers → tokens-migrate}/types.js +0 -0
package/README.md
CHANGED
|
@@ -2,96 +2,91 @@
|
|
|
2
2
|
|
|
3
3
|
CLI for the Chiralkit registry.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Quick start: ChiralUI from the hosted registry
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- `chiralkit add <module>` — copy a module's files into the current project.
|
|
9
|
-
- `chiralkit spec from-stencil <name>` — draft a `spec.json` from a Stencil component's source.
|
|
10
|
-
- `chiralkit scaffold registry <name> [--force]` — onboard a Stencil component from `<designSystemPath>/ds-<name>/` into the registry (envelope + spec + reversed symlinks + `generation.json`).
|
|
11
|
-
- `chiralkit generate <name> [--stack <s>] [--dry-run] [--debug-prompt] [--force]` — LLM-generate a stack implementation from `spec.json`.
|
|
12
|
-
- `chiralkit doctor` — lint the registry (envelopes, specs, implementations).
|
|
7
|
+
In a React project (Vite, or Next.js with the App Router), with no chiralkit checkout. The native components import their own CSS file, which the Next.js Pages Router rejects outside `_app`.
|
|
13
8
|
|
|
14
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npx @chiralkit/cli@alpha add button
|
|
11
|
+
```
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
`ck add` fetches the module from `https://chiralkit.dev/r/v1`, creates `ck/chiralkit.config.json` if it is missing, copies the source into `src/chiralkit/` (the code is yours to edit), installs the `tokens` module it depends on, and records every file hash in `ck/chiralkit.lock.json`. Import `src/chiralkit/tokens/chiraltokens.css` once in your app entry; the CLI prints this hint after writing the tokens.
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
- `--registry <url>` picks another registry base, for example `--registry http://localhost:4321/r/v1` for a local build. Only `https` is accepted, plus plain `http` for `localhost`. Dependencies are resolved by name against the same base.
|
|
16
|
+
- **Modules in this alpha:** `button`, `input`, `select` (native React components with their own CSS) and `tokens`. The other ChiralUI components arrive as their native React implementations land.
|
|
17
|
+
- **`ck add tokens`** installs the ChiralUI tokens on their own as a module: it writes `src/chiralkit/tokens/chiraltokens.css` and records `tokens` in the lock. You do not need to install `@chiralkit/tokens` from npm.
|
|
18
|
+
- The items follow the shadcn registry-item format, so `npx shadcn@latest add https://chiralkit.dev/r/v1/react/button.json` writes the same `Button.tsx`. On that path shadcn merges the dark token values under its `.dark` class, while ChiralUI's own `chiraltokens.css` switches on `:root[data-theme="dark"]`; use whichever selector your app toggles.
|
|
19
|
+
- `ck update` does not update remote installs yet; it skips them and says so.
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
## Design token contracts
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"agent": "claude-code"
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
```
|
|
23
|
+
Generated token maps and component specs should use the layered token catalog from `@chiralkit/tokens`: primitive values, semantic roles, and interactive states. Avoid emitting deprecated flat `--ds-color-*`, `--ds-spacing-*`, `--ds-radius-*`, or `--ds-font-*` aliases in new specs. The aliases remain available for existing consumers during migration and are scheduled for removal in a future major release.
|
|
24
|
+
|
|
25
|
+
## Commands
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
- `ck init [--source-root <path>]` — detect your framework and write `ck/chiralkit.config.json`.
|
|
28
|
+
- `ck add <module> [--registry <url>]` — copy a module's files into the current project from the hosted registry (`https://chiralkit.dev/r/v1` by default).
|
|
29
|
+
- `ck update [name] [--check] [--yes]` — bump installed modules to the current registry version, with a diff preview.
|
|
30
|
+
- `ck lock --init` — snapshot the installed modules into `ck/chiralkit.lock.json`.
|
|
31
|
+
- `ck tokens migrate [--from <css>] [--out <path>] [--dry-run] [--force]` — write `tokens/chiraltokens.css` from your shadcn/ui theme (no AI).
|
|
32
|
+
- `ck paths migrate [--to <root>] [--check] [--yes]` — preview or apply a move of installed files into the source namespace.
|
|
33
|
+
- `ck doctor` — lint the registry (envelopes, specs, implementations).
|
|
34
|
+
- `ck manifest [--lang en|es]` — print the project mark and manifesto.
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
## Consumer source paths
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
New React and HTML consumers use `src/chiralkit/`; Django uses `templates/chiralkit/`. Choose a custom root with `ck init --source-root custom/chiral`. New configs make `paths.source` authoritative and set `paths.components` to the same root:
|
|
35
39
|
|
|
36
40
|
```json
|
|
37
41
|
{
|
|
38
|
-
"
|
|
39
|
-
|
|
42
|
+
"framework": "react",
|
|
43
|
+
"registry_path": "../chiralkit",
|
|
44
|
+
"paths": {
|
|
45
|
+
"source": "src/chiralkit",
|
|
46
|
+
"components": "src/chiralkit",
|
|
47
|
+
"assets": "public/chiralkit"
|
|
40
48
|
}
|
|
41
49
|
}
|
|
42
50
|
```
|
|
43
51
|
|
|
44
|
-
|
|
52
|
+
Init creates `tokens/`, `primitives/`, `patterns/`, `enantiomers/`, `features/`, `compositions/layouts/` and `compositions/pages/`. Supported installers select source destinations using module ring metadata; this does not introduce support for additional module types or installers. Configuration and the lockfile stay in `ck/`; public/static assets keep their framework-native destination.
|
|
45
53
|
|
|
46
|
-
|
|
54
|
+
Existing configs without `paths.source` keep `paths.components` as the legacy fallback. Add and update preserve configured paths and already locked destinations until an explicit migration.
|
|
47
55
|
|
|
48
|
-
|
|
49
|
-
- `--dry-run` — call the LLM but do not write files; print the response.
|
|
50
|
-
- `--debug-prompt` — print the prompt that WOULD be sent (AI SDK messages JSON in API mode; plaintext stdin in agent mode) and exit; do NOT invoke the LLM. Useful for debugging and for manually pasting into an agent that isn't wired yet.
|
|
51
|
-
- `--force` — overwrite even if `generation.json.manually_edited` is `true`.
|
|
56
|
+
`ck tokens migrate` writes `<paths.source>/tokens/chiraltokens.css` with a configured source root, or `src/chiralkit/tokens/chiraltokens.css` in a new standalone project. Legacy configs and an existing standalone `ck/chiraltokens.css` retain the old output. `--out` always wins; `--dry-run` writes nothing, and existing output requires `--force` to overwrite.
|
|
52
57
|
|
|
53
|
-
|
|
58
|
+
### Explicit path migration
|
|
54
59
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"maintainer": {
|
|
60
|
-
"design_system_path": "packages/design-system/src/components",
|
|
61
|
-
"registry_path": "registry"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
60
|
+
```bash
|
|
61
|
+
ck paths migrate # print a plan; no writes
|
|
62
|
+
ck paths migrate --check # exit 1 if changes are needed, otherwise 0
|
|
63
|
+
ck paths migrate --to src/chiralkit --yes # apply after reviewing the plan
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
1. `<registryPath>/<name>/component.json` — envelope with parsed `tag` + flattened `tokens_used`. Human fields (`description`, `category`, `translations`) start as sensible placeholders (`description: "TODO: describe <name>"`, `category: "primitive"`, `translations: {}`) — edit them after.
|
|
69
|
-
2. `<registryPath>/<name>/spec.json` — via `spec from-stencil`.
|
|
70
|
-
3. `<registryPath>/<name>/implementations/stencil/*` — per-file reversed symlinks (git mode 120000) into the source dir. Files-only, hidden-file-skipping, sub-directory-skipping. `--force` first sweeps any pre-existing symlinks so orphans don't survive source-file renames.
|
|
71
|
-
4. `<registryPath>/<name>/implementations/stencil/generation.json` — baseline `{manually_edited: true, ...nulls}`.
|
|
66
|
+
Only locked source files and known token CSS move. Assets, unknown files, local edits, original lock hashes and unknown metadata are preserved. Missing tracked files or destination collisions abort before writes. The config and lockfile remain in `ck/`.
|
|
72
67
|
|
|
73
|
-
|
|
68
|
+
**Application imports are not rewritten.** Review the printed old-to-new import map and manually adjust consumer imports when applying the migration. Re-running an applied migration is a no-op.
|
|
74
69
|
|
|
75
|
-
##
|
|
70
|
+
## Programmatic operations
|
|
76
71
|
|
|
77
|
-
|
|
78
|
-
ck pm # deterministic local dashboard; no model required
|
|
79
|
-
ck pm --brief # same snapshot plus the read-only ck-pm interpretation
|
|
80
|
-
```
|
|
72
|
+
Node hosts can use `@chiralkit/cli/operations` without starting the CLI or connecting a terminal. The entry exports `planAdd`, `applyAddPlan`, `planUpdate`, `applyUpdatePlan` and `formatUpdatePlan`, with their TypeScript contracts.
|
|
81
73
|
|
|
82
|
-
|
|
74
|
+
```ts
|
|
75
|
+
import { planAdd, applyAddPlan, planUpdate, applyUpdatePlan } from '@chiralkit/cli/operations';
|
|
83
76
|
|
|
84
|
-
|
|
77
|
+
const installation = await planAdd({ moduleName: 'figure-canvas', cwd: projectRoot });
|
|
78
|
+
if (installation.status === 'blocked') throw new Error(installation.message);
|
|
79
|
+
// Inspect the plan before explicitly applying it. No files are installed yet.
|
|
80
|
+
await applyAddPlan(installation.plan); // Silent by default; accepts an optional log callback.
|
|
85
81
|
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
const update = await planUpdate({ cwd: projectRoot });
|
|
83
|
+
if (update.status === 'blocked') throw new Error(update.message);
|
|
84
|
+
// A terminal, workspace or other Node host decides whether to apply the plan.
|
|
85
|
+
if (update.plan.modules.length > 0) await applyUpdatePlan(update.plan);
|
|
88
86
|
```
|
|
89
87
|
|
|
90
|
-
|
|
91
|
-
- `priority`: `P0 | P1 | P2 | P3`, expressing attraction toward doing the task now.
|
|
92
|
-
- `status`: `ready | active | blocked | done`.
|
|
93
|
-
- `[x]` requires `status:done`; unchecked tasks cannot be `done`.
|
|
88
|
+
Both planning operations share `OperationPreparation<TPlan>`: `{ status: "ready", plan }` or `{ status: "blocked", code, message }`. Planning reads configuration, registry metadata and installed files; it does not install files, modify package dependencies, write locks or prompt. Execution performs writes and returns data. `applyAddPlan` accepts `{ log, now }`; `applyUpdatePlan` accepts `{ now }`. The clock is optional and returns an ISO timestamp. CLI adapters translate blocked results into their existing messages and exit codes.
|
|
94
89
|
|
|
95
|
-
|
|
90
|
+
These are ephemeral plans for an explicit application root (`cwd`). They are not serialized transactions or protection against concurrent external edits. Update execution preserves the plan's lock snapshot. Filesystem operations remain Node-specific; this entry is not a browser API. Existing config/lock formats and legacy or namespaced destinations remain unchanged.
|
|
96
91
|
|
|
97
|
-
|
|
92
|
+
This is the first Chiral Architecture increment: shared vocabulary and helpers support inspectable plans and feature operations; the terminal composes them. Planning and execution form a pipeline, not a claimed enantiomeric pair. Unifying installer update/receipt algorithms and reviewing other commands remain separate work.
|
package/dist/add.d.ts
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { type ModuleType } from "@chiralkit/registry-schema";
|
|
2
|
+
export type AddArgs = {
|
|
3
|
+
ok: true;
|
|
4
|
+
name: string;
|
|
5
|
+
registry: string | undefined;
|
|
6
|
+
type: ModuleType | undefined;
|
|
7
|
+
} | {
|
|
8
|
+
ok: false;
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
/** Parse `ck add` arguments: `--flag value` or `--flag=value`; any other `--flag` is an error. */
|
|
12
|
+
export declare function parseAddArgs(args: string[]): AddArgs;
|
|
13
|
+
export declare const REMOTE_TYPE_UNSUPPORTED = "--type is not supported with the remote registry yet.";
|
|
2
14
|
export declare function runAdd(moduleName: string, cwd?: string, opts?: {
|
|
3
15
|
type?: ModuleType;
|
|
16
|
+
registry?: string;
|
|
4
17
|
}): Promise<void>;
|
package/dist/add.js
CHANGED
|
@@ -1,118 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const modules = await walkAllKitRegistries(kitsRoot);
|
|
15
|
-
const matches = modules.filter((m) => m.name === moduleName && (type === undefined || m.family === TYPE_TO_FAMILY[type]));
|
|
16
|
-
if (matches.length === 0) {
|
|
17
|
-
throw new Error(type
|
|
18
|
-
? `Module '${moduleName}' (type '${type}') not found under ${kitsRoot}.`
|
|
19
|
-
: `Module '${moduleName}' not found under ${kitsRoot}.`);
|
|
20
|
-
}
|
|
21
|
-
if (matches.length > 1) {
|
|
22
|
-
const families = matches.map((m) => m.family).join(", ");
|
|
23
|
-
throw new Error(`Module '${moduleName}' exists in multiple families (${families}). Pass --type <t> to disambiguate.`);
|
|
24
|
-
}
|
|
25
|
-
return matches[0];
|
|
26
|
-
}
|
|
27
|
-
export async function runAdd(moduleName, cwd = process.cwd(), opts = {}) {
|
|
28
|
-
const config = await readConfig(cwd);
|
|
29
|
-
const registryRoot = resolve(cwd, config.registry_path);
|
|
30
|
-
const ref = await resolveModuleRef(resolveKitsRoot(), moduleName, opts.type);
|
|
31
|
-
let raw;
|
|
32
|
-
try {
|
|
33
|
-
raw = await readFile(ref.envelopePath, "utf8");
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
throw new Error(`Module '${moduleName}' not found at ${ref.envelopePath}.`);
|
|
37
|
-
}
|
|
38
|
-
const mod = parseModule(JSON.parse(raw));
|
|
39
|
-
if (mod.type !== "ui-component") {
|
|
40
|
-
throw new Error(`Only ui-component modules supported in v0. Got: ${mod.type}`);
|
|
41
|
-
}
|
|
42
|
-
const spec = mod.spec;
|
|
43
|
-
const installer = findInstaller(spec.tech, config.framework);
|
|
44
|
-
if (!installer.supports(mod)) {
|
|
45
|
-
throw new Error(`Installer for '${spec.tech}' × '${config.framework}' does not support module '${mod.name}'.`);
|
|
46
|
-
}
|
|
47
|
-
const ctx = createInstallContext(cwd, registryRoot, config);
|
|
48
|
-
await installer.install(mod, ctx);
|
|
49
|
-
await recordInstall(cwd, ref, mod, config.paths.components);
|
|
50
|
-
console.log(`Added: ${mod.name}@${mod.metadata.version} (${spec.tech} → ${config.framework})`);
|
|
51
|
-
}
|
|
52
|
-
// Appends (or replaces) the module's entry in chiralkit.lock.json. Runs
|
|
53
|
-
// after the installer, so writing succeeds only when the copy did. When
|
|
54
|
-
// the lock does not exist yet, it is created — 'add' is the natural
|
|
55
|
-
// bootstrap point so first-time projects do not need to run 'lock --init'
|
|
56
|
-
// before they have anything to lock.
|
|
57
|
-
async function recordInstall(cwd, ref, mod, componentsRel) {
|
|
58
|
-
if (!(await lockExists(cwd)) && (await legacyLockExists(cwd))) {
|
|
59
|
-
throw new Error(legacyLockMigrationHint(cwd));
|
|
60
|
-
}
|
|
61
|
-
const lock = (await lockExists(cwd))
|
|
62
|
-
? await readLock(cwd)
|
|
63
|
-
: { modules: {} };
|
|
64
|
-
const componentsAbs = resolve(cwd, componentsRel);
|
|
65
|
-
const registryBases = await collectRegistryFileBasenames(ref.moduleDir);
|
|
66
|
-
const files = {};
|
|
67
|
-
for (const base of registryBases) {
|
|
68
|
-
const abs = join(componentsAbs, base);
|
|
69
|
-
try {
|
|
70
|
-
const h = await hashFile(abs);
|
|
71
|
-
files[toRelativePosix(cwd, abs)] = h;
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
// File was in the registry but not written to the consumer; skip.
|
|
75
|
-
// This happens on stacks where component.assets covers only a
|
|
76
|
-
// subset of the registry source tree (e.g. Django ships from
|
|
77
|
-
// runtime.assets, not per-component).
|
|
1
|
+
import { MODULE_TYPES } from "@chiralkit/registry-schema";
|
|
2
|
+
import { planAdd, applyAddPlan } from "./operations/add.js";
|
|
3
|
+
import { applyRemoteAddPlan, planRemoteAdd, shouldUseRemote } from "./operations/add-remote.js";
|
|
4
|
+
const ADD_VALUE_FLAGS = new Set(["--registry", "--type"]);
|
|
5
|
+
/** Parse `ck add` arguments: `--flag value` or `--flag=value`; any other `--flag` is an error. */
|
|
6
|
+
export function parseAddArgs(args) {
|
|
7
|
+
const values = {};
|
|
8
|
+
let name;
|
|
9
|
+
for (let i = 0; i < args.length; i++) {
|
|
10
|
+
const arg = args[i];
|
|
11
|
+
if (!arg.startsWith("--")) {
|
|
12
|
+
name ??= arg;
|
|
13
|
+
continue;
|
|
78
14
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
15
|
+
const eq = arg.indexOf("=");
|
|
16
|
+
const flag = eq < 0 ? arg : arg.slice(0, eq);
|
|
17
|
+
if (!ADD_VALUE_FLAGS.has(flag))
|
|
18
|
+
return { ok: false, message: `add: unknown option ${arg}` };
|
|
19
|
+
let value;
|
|
20
|
+
if (eq >= 0)
|
|
21
|
+
value = arg.slice(eq + 1);
|
|
22
|
+
else if (args[i + 1] !== undefined && !args[i + 1].startsWith("--"))
|
|
23
|
+
value = args[++i];
|
|
24
|
+
values[flag] = value;
|
|
25
|
+
}
|
|
26
|
+
const registry = values["--registry"];
|
|
27
|
+
if ("--registry" in values && !registry)
|
|
28
|
+
return { ok: false, message: "--registry requires a URL." };
|
|
29
|
+
const type = values["--type"];
|
|
30
|
+
if ("--type" in values && !MODULE_TYPES.includes(type ?? "")) {
|
|
31
|
+
return { ok: false, message: `--type must be one of ${MODULE_TYPES.join(", ")}. Got: ${type || "(missing)"}` };
|
|
32
|
+
}
|
|
33
|
+
if (!name)
|
|
34
|
+
return { ok: false, message: "add: missing module name" };
|
|
35
|
+
return { ok: true, name, registry, type: type };
|
|
87
36
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const s = await stat(p);
|
|
106
|
-
if (s.isFile())
|
|
107
|
-
out.push(e.name);
|
|
108
|
-
}
|
|
109
|
-
catch {
|
|
110
|
-
/* dangling symlink; skip */
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
await walk(moduleDir);
|
|
116
|
-
return out.filter((b) => b !== MODULE_ENVELOPE_FILENAME && b !== "spec.json");
|
|
37
|
+
export const REMOTE_TYPE_UNSUPPORTED = "--type is not supported with the remote registry yet.";
|
|
38
|
+
export async function runAdd(moduleName, cwd = process.cwd(), opts = {}) {
|
|
39
|
+
const log = (message) => console.log(message);
|
|
40
|
+
if (await shouldUseRemote(cwd, { registry: opts.registry })) {
|
|
41
|
+
if (opts.type !== undefined)
|
|
42
|
+
throw new Error(REMOTE_TYPE_UNSUPPORTED);
|
|
43
|
+
const preparation = await planRemoteAdd({ moduleName, cwd, registryUrl: opts.registry });
|
|
44
|
+
if (preparation.status === "blocked")
|
|
45
|
+
throw new Error(preparation.message);
|
|
46
|
+
await applyRemoteAddPlan(preparation.plan, { log });
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const preparation = await planAdd({ moduleName, cwd, type: opts.type });
|
|
50
|
+
if (preparation.status === "blocked")
|
|
51
|
+
throw new Error(preparation.message);
|
|
52
|
+
const result = await applyAddPlan(preparation.plan, { log });
|
|
53
|
+
console.log(`Added: ${result.name}@${result.version} (${result.tech} → ${result.framework})`);
|
|
117
54
|
}
|
|
118
55
|
//# sourceMappingURL=add.js.map
|
package/dist/add.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.js","sourceRoot":"","sources":["../src/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../src/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAmB,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAMhG,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE1D,kGAAkG;AAClG,MAAM,UAAU,YAAY,CAAC,IAAc;IACzC,MAAM,MAAM,GAAuC,EAAE,CAAC;IACtD,IAAI,IAAwB,CAAC;IAC7B,K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pD,OAAO;IACT,CAAC;IACD,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACxE,IAAI,WAAW,CAAC,MAAM,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC3E,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7D,OAAO,CAAC,GAAG,CACT,UAAU,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,KAAK,MAAM,CAAC,IAAI,MAAM,MAAM,CAAC,SAAS,GAAG,CACjF,CAAC;AACJ,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -3,12 +3,14 @@ export declare const CONFIG_DIR = "ck";
|
|
|
3
3
|
export declare const CONFIG_FILE = "chiralkit.config.json";
|
|
4
4
|
export declare function configPath(cwd: string): string;
|
|
5
5
|
export interface ChiralkitPaths {
|
|
6
|
+
source?: string;
|
|
6
7
|
components: string;
|
|
7
8
|
assets: string;
|
|
8
9
|
}
|
|
9
10
|
export interface ChiralkitConfig {
|
|
10
11
|
framework: FrameworkTarget;
|
|
11
|
-
registry_path
|
|
12
|
+
registry_path?: string;
|
|
13
|
+
registry_url?: string;
|
|
12
14
|
paths: ChiralkitPaths;
|
|
13
15
|
}
|
|
14
16
|
export declare function defaultPaths(framework: FrameworkTarget): ChiralkitPaths;
|
package/dist/config.js
CHANGED
|
@@ -6,19 +6,22 @@ export function configPath(cwd) {
|
|
|
6
6
|
return join(cwd, CONFIG_DIR, CONFIG_FILE);
|
|
7
7
|
}
|
|
8
8
|
export function defaultPaths(framework) {
|
|
9
|
+
const source = framework === "django-template" ? "templates/chiralkit" : "src/chiralkit";
|
|
9
10
|
switch (framework) {
|
|
10
11
|
case "react":
|
|
11
12
|
return {
|
|
12
|
-
|
|
13
|
+
source: source,
|
|
14
|
+
components: source,
|
|
13
15
|
assets: "public/chiralkit",
|
|
14
16
|
};
|
|
15
17
|
case "django-template":
|
|
16
18
|
return {
|
|
17
|
-
|
|
19
|
+
source: source,
|
|
20
|
+
components: source,
|
|
18
21
|
assets: "static/chiralkit-ds",
|
|
19
22
|
};
|
|
20
23
|
case "html":
|
|
21
|
-
return { components:
|
|
24
|
+
return { source: source, components: source, assets: "assets" };
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
export async function configExists(cwd) {
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAG1C,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAC/B,MAAM,CAAC,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAEnD,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;AAC5C,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAG1C,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAC/B,MAAM,CAAC,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAEnD,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;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AAI,KAAK,CACb,GAAG,UAAU,IAAI,WAAW,4IAA4I,CACzK,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG,CAA4B,CAAC;IAC3C,MAAM,EAAE,GAAG,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACvC,MAAM,EAAE,GAAG,KAAK,CAAC,eAAe,CAAC,CAAC;IAClC,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CACb,gJAAgJ,CACjJ,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CACb,oGAAoG,CACrG,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,kBAAkB,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { CHIRAL_RING } from "@chiralkit/registry-schema";
|
|
1
2
|
// The four invariants defined in 2026-07-24-agent-modules-design.md §3.
|
|
2
|
-
//
|
|
3
|
+
// Ring comparison reads envelope.metadata.ring (source of truth since 5ef54b2).
|
|
3
4
|
export function runInvariants(modules) {
|
|
4
5
|
const errors = [];
|
|
5
6
|
const oks = [];
|
|
@@ -11,9 +12,9 @@ export function runInvariants(modules) {
|
|
|
11
12
|
if (spec.pipeline_stage !== undefined && m.type !== "agent") {
|
|
12
13
|
errors.push(`${m.name}: pipeline_stage is only valid for type=agent (found type=${m.type})`);
|
|
13
14
|
}
|
|
14
|
-
// Rule 4b: pipeline_stage only at
|
|
15
|
-
if (spec.pipeline_stage !== undefined && m.metadata.
|
|
16
|
-
errors.push(`${m.name}: pipeline_stage is only valid at
|
|
15
|
+
// Rule 4b: pipeline_stage only at the chiral ring (specialists).
|
|
16
|
+
if (spec.pipeline_stage !== undefined && m.metadata.ring !== CHIRAL_RING) {
|
|
17
|
+
errors.push(`${m.name}: pipeline_stage is only valid at ring ${CHIRAL_RING} (found ring=${m.metadata.ring})`);
|
|
17
18
|
}
|
|
18
19
|
if (spec.enantiomer_of === undefined)
|
|
19
20
|
continue;
|
|
@@ -28,9 +29,19 @@ export function runInvariants(modules) {
|
|
|
28
29
|
if (reportedPairs.has(key))
|
|
29
30
|
continue;
|
|
30
31
|
reportedPairs.add(key);
|
|
31
|
-
// Rule 1: reciprocity.
|
|
32
|
+
// Rule 1: reciprocity (involution). A partner that points at a third
|
|
33
|
+
// module which points back is an established pair: m is a third claimant.
|
|
32
34
|
if (partnerSpec.enantiomer_of !== m.name) {
|
|
33
|
-
|
|
35
|
+
const claimed = partnerSpec.enantiomer_of
|
|
36
|
+
? byName.get(partnerSpec.enantiomer_of)
|
|
37
|
+
: undefined;
|
|
38
|
+
const claimedSpec = claimed?.spec;
|
|
39
|
+
if (claimed && claimedSpec?.enantiomer_of === partner.name) {
|
|
40
|
+
errors.push(`${m.name}: third claimant of "${partner.name}", which is already paired with "${claimed.name}"`);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
errors.push(`${key}: reciprocity broken (${partner.name}.enantiomer_of=${partnerSpec.enantiomer_of ?? "unset"})`);
|
|
44
|
+
}
|
|
34
45
|
continue;
|
|
35
46
|
}
|
|
36
47
|
// Rule 2: matching chiral_axis.
|
|
@@ -38,9 +49,9 @@ export function runInvariants(modules) {
|
|
|
38
49
|
errors.push(`${key}: chiral_axis mismatch ("${spec.chiral_axis}" vs "${partnerSpec.chiral_axis}")`);
|
|
39
50
|
continue;
|
|
40
51
|
}
|
|
41
|
-
// Rule 3: same metadata.
|
|
42
|
-
if (m.metadata.
|
|
43
|
-
errors.push(`${key}: metadata.
|
|
52
|
+
// Rule 3: same metadata.ring.
|
|
53
|
+
if (m.metadata.ring !== partner.metadata.ring) {
|
|
54
|
+
errors.push(`${key}: metadata.ring mismatch (${m.metadata.ring} vs ${partner.metadata.ring})`);
|
|
44
55
|
continue;
|
|
45
56
|
}
|
|
46
57
|
oks.push(`chirality: ${key} on axis "${spec.chiral_axis}"`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor-invariants.js","sourceRoot":"","sources":["../src/doctor-invariants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"doctor-invariants.js","sourceRoot":"","sources":["../src/doctor-invariants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,MAAM,4BAA4B,CAAC;AAOtE,wEAAwE;AACxE,gFAAgF;AAChF,MAAM,UAAU,aAAa,CAAC,OAAiB;IAC7C,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAU,CAAC,CAAC,CAAC;IACjE,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IAExC,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,CAAC,CAAC,IAId,CAAC;QAEF,2CAA2C;QAC3C,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC5D,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,6DAA6D,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QAC/F,CAAC;QACD,iEAAiE;QACjE,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YACzE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,0CAA0C,WAAW,gBAAgB,CAAC,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,CAA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O,GAAG,CAAC,CAAC;YACpH,CAAC;YACD,SAAS;QACX,CAAC;QACD,gCAAgC;QAChC,IAAI,IAAI,CAAC,WAAW,KAAK,WAAW,CAAC,WAAW,EAAE,CAAC;YACjD,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,4BAA4B,IAAI,CAAC,WAAW,SAAS,WAAW,CAAC,WAAW,IAAI,CAAC,CAAC;YACpG,SAAS;QACX,CAAC;QACD,8BAA8B;QAC9B,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC9C,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,6BAA6B,CAAC,CAAC,QAAQ,CAAC,IAAI,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC;YAC/F,SAAS;QACX,CAAC;QAED,GAAG,CAAC,IAAI,CAAC,cAAc,GAAG,aAAa,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AACzB,CAAC"}
|
package/dist/doctor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readdir, readFile, realpath } from "node:fs/promises";
|
|
2
2
|
import { join, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { parseComponentContract, parseAgentCapabilities, parseAgentSpec, parseModule, } from "@chiralkit/registry-schema";
|
|
4
|
+
import { parseComponentContract, parseAgentCapabilities, parseAgentContract, parseAgentSpec, parseModule, } from "@chiralkit/registry-schema";
|
|
5
5
|
import { resolveKitsRoot } from "@chiralkit/kits";
|
|
6
6
|
import { MODULE_ENVELOPE_FILENAME, walkAllKitRegistries, } from "./registry-layout.js";
|
|
7
7
|
import { runInvariants } from "./doctor-invariants.js";
|
|
@@ -55,7 +55,7 @@ async function checkEnvelope(label, moduleDir, r) {
|
|
|
55
55
|
try {
|
|
56
56
|
const raw = await readFile(path, "utf8");
|
|
57
57
|
const parsed = parseModule(JSON.parse(raw));
|
|
58
|
-
ok(r, `envelope: ${label} —
|
|
58
|
+
ok(r, `envelope: ${label} — ring=${parsed.metadata.ring}, type=${parsed.type}`);
|
|
59
59
|
return parsed;
|
|
60
60
|
}
|
|
61
61
|
catch (e) {
|
|
@@ -117,16 +117,16 @@ async function checkSpec(label, moduleDir, envelope, repoRoot, r) {
|
|
|
117
117
|
return null;
|
|
118
118
|
}
|
|
119
119
|
ok(r, `spec.json: ${label} v${parsed.version}`);
|
|
120
|
-
//
|
|
121
|
-
// shouldn't declare a state_machine;
|
|
122
|
-
// have no conformance rule at this layer.
|
|
120
|
+
// Ring conformance: only meaningful for ui-component today. Ring 1a
|
|
121
|
+
// (primitive) shouldn't declare a state_machine; ring 1b (pattern) should.
|
|
122
|
+
// Other rings have no conformance rule at this layer.
|
|
123
123
|
if (envelope?.type === "ui-component") {
|
|
124
124
|
const hasStateMachine = parsed.state_machine !== undefined;
|
|
125
|
-
if (envelope.metadata.
|
|
126
|
-
warn(r, `
|
|
125
|
+
if (envelope.metadata.ring === "1a" && hasStateMachine) {
|
|
126
|
+
warn(r, `ring conformance: ${label} — ring 1a (primitive) with state_machine (usually a pattern in disguise; check?)`);
|
|
127
127
|
}
|
|
128
|
-
if (envelope.metadata.
|
|
129
|
-
warn(r, `
|
|
128
|
+
if (envelope.metadata.ring === "1b" && !hasStateMachine) {
|
|
129
|
+
warn(r, `ring conformance: ${label} — ring 1b (pattern) without state_machine (usually pattern behavior deserves explicit modeling)`);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
return parsed;
|
|
@@ -154,6 +154,24 @@ async function readDeclaredAgentFile(moduleDir, declared) {
|
|
|
154
154
|
return { problem: `${declared} is not readable` };
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
+
async function validateTokensAndContract(moduleDir, spec, problems) {
|
|
158
|
+
for (const declared of Object.values(spec.tokens ?? {})) {
|
|
159
|
+
const file = await readDeclaredAgentFile(moduleDir, declared);
|
|
160
|
+
if (file.problem)
|
|
161
|
+
problems.push(file.problem);
|
|
162
|
+
}
|
|
163
|
+
if (!spec.contract.endsWith(".json"))
|
|
164
|
+
return;
|
|
165
|
+
const contract = await readDeclaredAgentFile(moduleDir, spec.contract);
|
|
166
|
+
if (contract.problem)
|
|
167
|
+
return; // already reported by the locator checks
|
|
168
|
+
try {
|
|
169
|
+
parseAgentContract(JSON.parse(contract.content ?? ""));
|
|
170
|
+
}
|
|
171
|
+
catch (e) {
|
|
172
|
+
problems.push(`${spec.contract} is invalid: ${e.message}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
157
175
|
export async function validateAgentFiles(moduleDir, spec) {
|
|
158
176
|
const problems = [];
|
|
159
177
|
const warnings = [];
|
|
@@ -167,6 +185,7 @@ export async function validateAgentFiles(moduleDir, spec) {
|
|
|
167
185
|
if (file.problem)
|
|
168
186
|
problems.push(file.problem);
|
|
169
187
|
}
|
|
188
|
+
await validateTokensAndContract(moduleDir, spec, problems);
|
|
170
189
|
warnings.push("legacy runtime-target agent locator is deprecated; migrate to entry + capabilities");
|
|
171
190
|
return { problems, warnings };
|
|
172
191
|
}
|
|
@@ -191,6 +210,7 @@ export async function validateAgentFiles(moduleDir, spec) {
|
|
|
191
210
|
problems.push(`${spec.capabilities} is invalid: ${e.message}`);
|
|
192
211
|
}
|
|
193
212
|
}
|
|
213
|
+
await validateTokensAndContract(moduleDir, spec, problems);
|
|
194
214
|
return { problems, warnings };
|
|
195
215
|
}
|
|
196
216
|
async function checkImplementations(label, moduleDir, spec, r) {
|