@nac3/forge-cli 1.0.51 → 1.0.52

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 CHANGED
@@ -1,390 +1,466 @@
1
- # Yujin Forge
2
-
3
- **A voice-first NAC-3 development framework + build tool.** Forge
4
- gives a developer (or an institution like ADIP teaching kids to
5
- code) a single CLI + chat panel that covers the full app-creation
6
- loop: read design specs by voice, generate code scaffolds from
7
- those specs, decorate vanilla HTML into NAC-3, drive existing apps
8
- via voice + chat.
9
-
10
- > Status: **v0.2.0-alpha.59z.92** (2026-06-04). **100% manifest
11
- > verb coverage**: every one of the 72 declared NAC-3 verbs has
12
- > at least one fake-scripted scenario asserting it gets invoked
13
- > (or refuses to) in the right intent. Brain matrix QA harness
14
- > at 168 scenarios (+68 since z.61); 22 new verbs in the arc
15
- > (8 misc + git.status/branch-list + office.excel.append-sheet
16
- > + 12 others); 8 helper CLIs under `yf qa` (run, scenarios
17
- > list/show/validate/stats, verbs coverage/sample,
18
- > brain-matrix-compare); 5 ops docs (SECURITY, CONTRIBUTING,
19
- > TESTING_GUIDE, DEPLOYMENT, CI_PIPELINE); 2 new doctrines
20
- > (verb-composition, explain-results); 2 new invariant kinds
21
- > (min_text_length, verb_invoked_in_order) + structural
22
- > fixture validator + lefthook pre-commit gate. F101 MCP
23
- > bridge backend complete (slice 3 panel UI pending); F106
24
- > office.* + F107 a11y.* verbs shipped; HITO 5 agent
25
- > orchestrator design draft awaiting Pablo clarification.
26
- >
27
- > **HITO 0 -- credentials vault.** AES-256-GCM at-rest encryption
28
- > with machine fingerprint binding, atomic writes (0o600), one-shot
29
- > reveal, vault modal in chat panel. Slots: anthropic / openai /
30
- > google_voice / elevenlabs / github_token.
31
- >
32
- > **HITO 1 -- voice + reader + spec ingest.** Bidirectional voice
33
- > (Whisper + Google STT, ElevenLabs + Google + Yujin Cloud TTS) with
34
- > chunked pipelined playback (~600 ms first audio on long sections).
35
- > Voiceprint enrolment + 5-layer trust model + liveness challenge on
36
- > irreversible ops. Document reader for **txt / md / source / html /
37
- > rtf / csv / epub / pdf / docx / xlsx** (10 formats) with voice-
38
- > driven navigation (open / next / search / bookmark / recap). Spec
39
- > drag-drop: drop a PDF/DOCX/etc into chat -> Forge parses ->
40
- > Claude extracts requirements/entities/endpoints/components ->
41
- > generates a file plan -> writes the scaffold after explicit
42
- > approval -> rollback on demand.
43
- >
44
- > **Fase F -- 10-language i18n + manuals.** Panel UI + voice intent
45
- > matcher + HTML user manuals all available in
46
- > **es / en / pt / fr / ja / zh / hi / ar / de / it**. Globe button
47
- > in the chat panel swaps the active language; the new
48
- > `forge.manual.open` tool routes "abrime el manual" / "open the
49
- > manual" / "マニュアルを開いて" / etc to the right HTML manual
50
- > served through the reader pipeline. Catalog-lint refuses to
51
- > publish if any locale is missing keys.
52
- >
53
- > Earlier work still shipping: G1 (AST migrator robustness) + G2
54
- > (LLM retry loop) + G3 (multi-page HTML) + G4 (--dry-run for ai
55
- > modes) + G5 (SPEC sync) + G6 (Figma scaffolder alpha) + the v0.3.0
56
- > chat tool-use loop (`forge.read_manifest`,
57
- > `forge.consult_nac_spec`, plus the V1.11..V1.13 github/git/
58
- > lifecycle tools and the V1.28 + V1.32 reader tools).
59
- >
60
- > **988 vitest cases green** across 63 suites (Linux + macOS +
61
- > Windows CI). AI decorator validated on calc fixture (15/15
62
- > dispatch tasks OK) + Conduit-NAC3 (178/180 cross-lang at N=3).
63
- > See [yujin.app/nac-spec/migration/](https://yujin.app/nac-spec/migration/)
64
- > for the migration paper, `docs/HITO_1_ARCHITECTURE.md` for the
65
- > voice+reader internals, and `docs/EVOLUTION_PLAN.md` for what is
66
- > next.
67
-
68
- ## What it is
69
-
70
- Four things in one:
71
-
72
- 1. **An AI-powered NAC-3 decorator.** `yf migrate <dir> --ai-silent`
73
- calls Claude Sonnet 4.6 with the HTML + JS source, gets back a
74
- fully-decorated HTML + JSON manifest, post-processes the output to
75
- bake in the NAC3 runtime + contract bridge + inline `NAC.register`.
76
- Takes ~25 s and ~$0.05 per app.
77
-
78
- 2. **A Pilot installer.** `yf pilot install <dir>` injects the
79
- embedded chat + voice + multi-model bundle into any
80
- Forge-decorated app. The same UI works against any NAC-3-compliant
81
- page, regardless of how it was decorated.
82
-
83
- 3. **A React/AST migration scaffold (planned).** `yf migrate
84
- <existing-react-repo>` audits the codebase, proposes the migration
85
- path screen-by-screen, executes the diff. The audit + apply flow
86
- is in place; the React-specific AST migrator is in flight.
87
-
88
- 4. **A voice-first developer assistant (HITO 1).** `yf chat`
89
- launches a local panel with bidirectional voice, a 10-format
90
- document reader, and drag-drop spec ingest. Drop a PDF / DOCX /
91
- HTML spec into chat -> Forge extracts requirements via Claude ->
92
- generates a file scaffold plan -> writes the project after you
93
- approve. Reverse the scaffold with one click. Aimed at solo
94
- developers + institutional teams (ADIP) who want the full
95
- "read spec out loud, then write the code" cycle without leaving
96
- the keyboard or the headset. See "Voice cockpit + spec ingest"
97
- below.
98
-
99
- ## Quick start
100
-
101
- ```bash
102
- # Install
103
- npm install -g @nac3/forge-cli@latest
104
-
105
- # Guided first run: activates your license (auto-synced) + sets your
106
- # AI key (BYOK). One command, it walks you through the rest.
107
- yf onboard
108
-
109
- # Decorate a vanilla HTML app (one shot, no human input)
110
- yf migrate ./my-app --ai-silent --ai-out ./my-app-decorated
111
-
112
- # Same, but include Yujin Pilot (the embedded chat + voice cockpit)
113
- yf migrate ./my-app --ai-silent --with-pilot --ai-out ./my-app-decorated
114
-
115
- # Install Pilot into an already-decorated app
116
- yf pilot install ./my-app-decorated
117
-
118
- # Open it
119
- xdg-open ./my-app-decorated/index.html
120
- ```
121
-
122
- The decorated output is **drop-in NAC3-ready**: no CDN dependencies
123
- at runtime, the manifest is registered inline at boot, every action
124
- button is wired through `NAC.bindAction`, the floating Pilot button
125
- appears bottom-right. Click it, paste an API key (Anthropic / OpenAI
126
- / Google / DeepSeek / Groq), and drive the page by voice or text.
127
-
128
- ## Commands
129
-
130
- | Command | What it does |
131
- |---|---|
132
- | `yf new <slug>` | Bootstrap a new Yujin Forge React app from `templates/react-app/`. |
133
- | `yf migrate <repo>` | Default mode: audit a project for NAC migration without writing. |
134
- | `yf migrate <repo> --apply` | Execute the proposed React/AST migration on `.tsx`/`.jsx`. |
135
- | `yf migrate <repo> --html` | Silent HTML walker -- auto-apply on `.html` files (rule-based, no LLM). |
136
- | `yf migrate <repo> --assisted` | HTML walker with CLI prompts for ambiguous elements (rule-based, no LLM). |
137
- | `yf migrate <repo> --ai-silent` | **AI-powered.** Claude one-shot decoration of an HTML file (paid seat). |
138
- | `yf migrate <repo> --ai-assisted` | AI-powered with ambiguity-resolution round. |
139
- | `yf migrate <repo> --with-pilot` | Inject Yujin Pilot bundle into the decorated output. |
140
- | `yf pilot install <dir>` | Inject Pilot into an already-decorated NAC-3 app. |
141
- | `yf chat` | Launch the embedded Claude Code voice+text panel hooked to the current project. |
142
- | `yf test` | Run the auto-generated test corpus + mocks + report coverage by NAC pipeline stage. |
143
- | `yf ship` | Gate: tests green + NAC-3 validate clean + LLM review pass + license valid -> deploy hook. |
144
- | `yf doctor` | Diagnose the local Forge install + license + dependencies. |
145
- | `yf validate` | Validate a NAC manifest against the spec schema. |
146
- | `yf license` | Manage license tokens. |
147
-
148
- See [docs/USAGE.md](docs/USAGE.md) for every flag and worked examples.
149
-
150
- ## How decoration works
151
-
152
- A vanilla HTML/JS app starts like:
153
-
154
- ```html
155
- <button onclick="digit('7')">7</button>
156
- ```
157
-
158
- After `yf migrate --ai-silent`:
159
-
160
- ```html
161
- <body data-nac-plugin="calc">
162
- ...
163
- <button onclick="digit('7')"
164
- data-nac-id="calc.action.digit_7"
165
- data-nac-role="action"
166
- data-nac-action="digit_7">7</button>
167
- ...
168
- <script src="nac.browser.js"></script>
169
- <script src="calc.js"></script>
170
- <script src="nac-bridge.js"></script>
171
- <script>
172
- (function () {
173
- var manifest = { "plugin_slug": "calc", ... };
174
- window.NAC.register(manifest);
175
- })();
176
- </script>
177
- </body>
178
- ```
179
-
180
- Any LLM driver can now call:
181
-
182
- ```js
183
- await NAC.click_by_verb('calc', 'digit_7');
184
- ```
185
-
186
- and the host's existing `digit('7')` handler runs **plus** the
187
- `nac:action:succeeded` contract event fires (because `nac-bridge.js`
188
- re-wired the inline onclick via `NAC.bindAction`).
189
-
190
- ## How Pilot works
191
-
192
- Pilot is a single-file IIFE bundle + companion stylesheet that lives
193
- in `yujin-pilot/dist/`. `yf pilot install` (or `yf migrate
194
- --with-pilot`) copies both into the target directory and inserts the
195
- script tags before `</body>`.
196
-
197
- At runtime, Pilot mounts a floating sumi-e branch button at
198
- bottom-right. Click it: chat panel opens. Click again: switches to
199
- the "pizarra" mode (chat + voice + action trace). Configure: paste
200
- API keys for any subset of {Anthropic, OpenAI, Google, DeepSeek,
201
- Groq}. Each provider supports all the models the
202
- [NAC3 v2.3 benchmark](https://yujin.app/nac-spec/benchmark/) exercised.
203
-
204
- Pilot reads `window.NAC.list_registered_plugins()` to get the active
205
- manifest, sends it to the selected LLM with the user's utterance,
206
- parses the JSON action chain, dispatches each via
207
- `NAC.click_by_verb`, reads back any configured status probe, then
208
- speaks the result via Web Speech / ElevenLabs / Google Cloud TTS.
209
-
210
- Config persists in `localStorage` under `yujin_pilot.config`. Keys
211
- never leave the browser. (Production deployments belong behind a
212
- server proxy.)
213
-
214
- See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for the full
215
- internal architecture.
216
-
217
- ## Voice cockpit + spec ingest (HITO 1)
218
-
219
- `yf chat` opens a local panel with three views (globito / mini /
220
- full). The full view has a chat stream on the left and a "pizarra"
221
- trace on the right that shows every tool the system invoked to
222
- answer.
223
-
224
- What it covers end-to-end:
225
-
226
- - **Vault** -- modal accessible via the Keys button. Slots for
227
- `anthropic`, `openai`, `google_voice`, `elevenlabs`,
228
- `github_token`. Values are encrypted at rest with the machine
229
- fingerprint; shown once on entry, never again.
230
-
231
- - **Voice in / voice out.** Press the mic, speak; the panel
232
- records via `MediaRecorder`, ships the audio to the configured
233
- STT provider, and either dispatches a recognised reader command
234
- directly or feeds the transcript to the chat loop. Replies are
235
- spoken back via the configured TTS provider with chunked
236
- prefetch (first audio in ~600 ms even on long answers).
237
-
238
- - **Voiceprint trust.** Enroll your voice once -- subsequent voice
239
- commands are gated by a 5-layer trust model
240
- (unknown / heard / recognised / trusted / authorised). Irreversible
241
- actions (force push, branch delete, deploy) ALWAYS require a
242
- liveness challenge regardless of trust level: a random Spanish/
243
- English phrase plus a random number you have to read back.
244
-
245
- - **Document reader.** Open any file in the project root and
246
- navigate by voice: "abrime el readme", "siguiente", "buscar
247
- pricing", "marcame aqui como inicio", "volver a marca inicio",
248
- "recap". Supports **10 formats**: txt, md, source code (.ts / .py
249
- / .rs / 80+ extensions), HTML, RTF, CSV/TSV, EPUB, **PDF**
250
- (via pdfjs-dist), **DOCX** (via mammoth), **XLSX** (via sheetjs).
251
- All format detection happens automatically.
252
-
253
- - **Spec drag-drop.** Drag a spec file onto the chat panel; an
254
- overlay appears + the file uploads. Forge parses it through the
255
- same reader pipeline, then a Claude call extracts structured
256
- requirements, entities, endpoints, and UI components. A second
257
- Claude call turns the extraction into a concrete file scaffold
258
- plan (which files to create + where + what kind + which
259
- requirement each serves + open questions for clarification).
260
- Nothing is written until you POST `{approve: true}`. On approve,
261
- the scaffolder writes the planned files with hand-rolled
262
- templates per kind (model / api / component / test / doc) and
263
- records a rollback log -- one click undoes the whole scaffold.
264
-
265
- - **Reader recap modes.** Default `literal` mode joins recent
266
- spoken blocks into a TTS-friendly narrative for "que dijiste".
267
- Optional `summary` mode calls Claude for a 1-2 sentence
268
- compression; gated by env var `YF_ENABLE_CLAUDE_RECAP=1` so it
269
- cannot fire by accident and charge tokens. Cost model in
270
- `docs/RECAP_CLAUDE_COSTS.md`.
271
-
272
- ### ADIP voice-first demo loop
273
-
274
- ```
275
- User: (mic) "abrime el plan.md"
276
- -> reader.open -> TTS "El Plan"
277
- User: (mic) "siguiente"
278
- -> reader.next -> TTS "Primer paso"
279
- User: (mic) "buscar pricing"
280
- -> reader.search -> TTS top snippet
281
- ```
282
-
283
- Drag a spec PDF onto the panel:
284
-
285
- ```
286
- panel -> spec ingested. Title: ADIP Spec. 4 sections.
287
- First lines:
288
- - The system MUST register patients.
289
- - ...
290
- panel (via Claude)-> extraction: 1 requirement, 1 entity (Paciente),
291
- 1 endpoint (POST /patients), 1 component
292
- (PatientCard).
293
- panel (via Claude)-> plan: src/models/Paciente.ts +
294
- src/api/patients.ts +
295
- src/components/PatientCard.tsx + README.md.
296
- Open question: authentication unspecified.
297
- user clicks -> approve.
298
- scaffolder -> 4 files written, rollback log captured.
299
- ```
300
-
301
- If anything looks off: one `POST /api/forge/ingest/rollback` and
302
- the project is back to its prior state.
303
-
304
- ### Architecture pointer
305
-
306
- The full step-by-step voice loop, reader pipeline, voiceprint
307
- state machine, and "how to add a parser / intent / trust class"
308
- recipes live in [docs/HITO_1_ARCHITECTURE.md](docs/HITO_1_ARCHITECTURE.md).
309
-
310
- ## Why a separate product
311
-
312
- NAC (the spec) is Apache-2.0 free forever. The reference runtime
313
- `nac-spec` on npm is Apache-2.0 free forever. **Yujin Forge is the
314
- commercial build layer:**
315
-
316
- - The AI decorator (`--ai-silent` / `--ai-assisted`) burns Anthropic
317
- tokens on your behalf; the seat license is what funds that.
318
- - The chat panel, React scaffolder, test corpus generator, and mock
319
- generator are all license-gated.
320
- - The static-rule HTML walker (`--html`, `--assisted`) is open and
321
- works offline.
322
-
323
- The Apache spec attracts the ecosystem; Forge monetises the delivery
324
- experience for teams that want to skip the per-app plumbing.
325
-
326
- ## What Forge gives an app (under the hood)
327
-
328
- Every decorated output ships:
329
-
330
- 1. `index.html` -- decorated, drop-in NAC3-ready
331
- 2. `manifest.json` -- the NAC3 manifest, version-pinnable
332
- 3. `nac.browser.js` -- the NAC3 runtime (copied locally, no CDN dep)
333
- 4. `nac-bridge.js` -- ~50 lines, wires `NAC.bindAction` for every
334
- action element so the host's existing handlers stay intact AND the
335
- contract events fire
336
- 5. **With `--with-pilot`:** `pilot.bundle.js` + `pilot.css` -- the
337
- embedded chat + voice cockpit
338
-
339
- After running Forge, your app is ready to be driven by any LLM agent
340
- that understands NAC-3. Pilot is one such driver; the
341
- [600-run benchmark](https://yujin.app/nac-spec/benchmark/) was driven
342
- by a custom harness; the React SDK in
343
- [`@yujin/nac-react`](https://www.npmjs.com/package/nac-spec) is
344
- another.
345
-
346
- ## Where this lives in the Yujin ecosystem
347
-
348
- ```
349
- NAC (Apache-2.0) -- pkuschnirof/rpaforce-crm + yujin.app/nac-spec
350
- spec + reference runtime + nac-spec NPM package
351
- |
352
- | depends on
353
- v
354
- Yujin Forge (closed core) -- yujinapp/yujin-forge (build NAC apps)
355
- AI decorator, React scaffolder, license gating, this repo
356
- | sibling product
357
- v
358
- Yujin Pilot (closed core) -- yujinapp/yujin-pilot (drive NAC apps)
359
- Embedded chat + voice + multi-model cockpit
360
- |
361
- | downstream adopter
362
- v
363
- Customer apps
364
- ```
365
-
366
- ## Documentation
367
-
368
- - [README.md](README.md) -- this file
369
- - [PROJECT.md](PROJECT.md) -- topology + governance + slice/HITO process (mandatory read before touching code)
370
- - [docs/SQ.md](docs/SQ.md) -- quality standards + deliverables + pre-development checklist (Spanish, mandatory)
371
- - [docs/QUICKSTART_ADIP.md](docs/QUICKSTART_ADIP.md) -- step-by-step setup guide for the ADIP institutional rollout (Spanish)
372
- - [docs/USAGE.md](docs/USAGE.md) -- every command + flag + worked examples
373
- - [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) -- internals of the AI decorator + wiring + Pilot integration
374
- - [docs/HITO_1_ARCHITECTURE.md](docs/HITO_1_ARCHITECTURE.md) -- HITO 1 voice + reader + spec ingest reference
375
- - [docs/LANGUAGE_POLICY.md](docs/LANGUAGE_POLICY.md) -- the 10-canonical-languages rule + catalog-lint mechanism
376
- - [docs/manuals/manual.es.html](docs/manuals/manual.es.html) -- end-user manual (10 languages: es/en/pt/fr/ja/zh/hi/ar/de/it)
377
- - [docs/RECAP_CLAUDE_COSTS.md](docs/RECAP_CLAUDE_COSTS.md) -- cost model + lock mechanism for the Claude recap mode
378
- - [docs/ROADMAP_VOICE_FORGE_2026_05_23.md](docs/ROADMAP_VOICE_FORGE_2026_05_23.md) -- HITO 0/1/2/3 roadmap with decisions taken
379
- - [docs/TECHNICAL_MANUAL.md](docs/TECHNICAL_MANUAL.md) -- living manual updated at each slice close
380
- - [docs/SPEC.md](docs/SPEC.md) -- the contract Forge makes with adopting teams
381
- - [docs/COMMERCIAL_PLAN.md](docs/COMMERCIAL_PLAN.md) -- pricing + licensing model
382
- - [docs/SESSION_HANDOFF_2026_05_23_AT_DOCTOR.md](docs/SESSION_HANDOFF_2026_05_23_AT_DOCTOR.md) -- state at last session boundary
383
-
384
- ## See also
385
-
386
- - [NAC spec](https://yujin.app/nac-spec/SPEC.html)
387
- - [NAC3 v2.3 benchmark](https://yujin.app/nac-spec/benchmark/) -- 600 runs across 5 models + 3 protocols
388
- - [Migration paper](https://yujin.app/nac-spec/migration/) -- Forge silent vs assisted vs Sumi manual on a calculator
389
- - [Yujin Pilot](https://github.com/yujinapp/yujin-pilot) -- the sibling driver product
390
- - [Yujin CRM](https://github.com/pkuschnirof/rpaforce-crm) -- the first adopter of the full stack
1
+ # Yujin Forge
2
+
3
+ **A voice-first NAC-3 development framework + build tool.** Forge
4
+ gives a developer (or an institution like ADIP teaching kids to
5
+ code) a single CLI + chat panel that covers the full app-creation
6
+ loop: read design specs by voice, generate code scaffolds from
7
+ those specs, decorate vanilla HTML into NAC-3, drive existing apps
8
+ via voice + chat.
9
+
10
+ > Status: **v1.0.51** (2026-06-28). Published on npm as
11
+ > `@nac3/forge-cli` (tag `latest`). **100% manifest verb
12
+ > coverage**: every one of the **119 declared NAC-3 verbs** has
13
+ > at least one fake-scripted scenario asserting it gets invoked
14
+ > (or refuses to) in the right intent. **56 top-level CLI
15
+ > commands** (see the full list below). Brain matrix QA harness +
16
+ > 8 helper CLIs under `yf qa`; ops docs (SECURITY, CONTRIBUTING,
17
+ > TESTING_GUIDE, DEPLOYMENT, CI_PIPELINE); structural fixture
18
+ > validator + pre-commit gate. The MCP bridge config + office.* +
19
+ > a11y.* verbs shipped; brain federation (parent/child) shipped;
20
+ > the agent orchestrator surface (`yf agent`) shipped; multi-agent
21
+ > session orchestration (`yujin.session.*`, opt-in, default OFF)
22
+ > shipped 2026-06-28.
23
+ >
24
+ > **HITO 0 -- credentials vault.** AES-256-GCM at-rest encryption
25
+ > with machine fingerprint binding, atomic writes (0o600), one-shot
26
+ > reveal, vault modal in chat panel. Slots: anthropic / openai /
27
+ > google_voice / elevenlabs / github_token.
28
+ >
29
+ > **HITO 1 -- voice + reader + spec ingest.** Bidirectional voice
30
+ > (Whisper + Google STT, ElevenLabs + Google TTS) with
31
+ > chunked pipelined playback (~600 ms first audio on long sections).
32
+ > Voiceprint enrolment + 5-layer trust model + liveness challenge on
33
+ > irreversible ops. Document reader for **txt / md / source / html /
34
+ > rtf / csv / epub / pdf / docx / xlsx** (10 formats) with voice-
35
+ > driven navigation (open / next / search / bookmark / recap). Spec
36
+ > drag-drop: drop a PDF/DOCX/etc into chat -> Forge parses ->
37
+ > Claude extracts requirements/entities/endpoints/components ->
38
+ > generates a file plan -> writes the scaffold after explicit
39
+ > approval -> rollback on demand.
40
+ >
41
+ > **Fase F -- 10-language i18n + manuals.** Panel UI + voice intent
42
+ > matcher + HTML user manuals all available in
43
+ > **es / en / pt / fr / ja / zh / hi / ar / de / it**. Globe button
44
+ > in the chat panel swaps the active language; the new
45
+ > `forge.manual.open` tool routes "abrime el manual" / "open the
46
+ > manual" / "マニュアルを開いて" / etc to the right HTML manual
47
+ > served through the reader pipeline. Catalog-lint refuses to
48
+ > publish if any locale is missing keys.
49
+ >
50
+ > Earlier work still shipping: G1 (AST migrator robustness) + G2
51
+ > (LLM retry loop) + G3 (multi-page HTML) + G4 (--dry-run for ai
52
+ > modes) + G5 (SPEC sync) + G6 (Figma scaffolder alpha) + the v0.3.0
53
+ > chat tool-use loop (`forge.read_manifest`,
54
+ > `forge.consult_nac_spec`, plus the V1.11..V1.13 github/git/
55
+ > lifecycle tools and the V1.28 + V1.32 reader tools).
56
+ >
57
+ > **Full vitest suite green** (~3800 cases across ~350 suites,
58
+ > Linux + macOS + Windows CI). AI decorator validated on calc
59
+ > fixture (15/15 dispatch tasks OK) + Conduit-NAC3 (178/180
60
+ > cross-lang at N=3).
61
+ > See [yujin.app/nac-spec/migration/](https://yujin.app/nac-spec/migration/)
62
+ > for the migration paper, `docs/HITO_1_ARCHITECTURE.md` for the
63
+ > voice+reader internals, and `docs/EVOLUTION_PLAN.md` for what is
64
+ > next.
65
+
66
+ ## What it is
67
+
68
+ Four things in one:
69
+
70
+ 1. **An AI-powered NAC-3 decorator.** `yf migrate <dir> --ai-silent`
71
+ calls Claude Sonnet 4.6 with the HTML + JS source, gets back a
72
+ fully-decorated HTML + JSON manifest, post-processes the output to
73
+ bake in the NAC3 runtime + contract bridge + inline `NAC.register`.
74
+ Takes ~25 s and ~$0.05 per app.
75
+
76
+ 2. **A Pilot installer.** `yf pilot install <dir>` injects the
77
+ embedded chat + voice + multi-model bundle into any
78
+ Forge-decorated app. The same UI works against any NAC-3-compliant
79
+ page, regardless of how it was decorated.
80
+
81
+ 3. **A React/AST migration scaffold (planned).** `yf migrate
82
+ <existing-react-repo>` audits the codebase, proposes the migration
83
+ path screen-by-screen, executes the diff. The audit + apply flow
84
+ is in place; the React-specific AST migrator is in flight.
85
+
86
+ 4. **A voice-first developer assistant (HITO 1).** `yf chat`
87
+ launches a local panel with bidirectional voice, a 10-format
88
+ document reader, and drag-drop spec ingest. Drop a PDF / DOCX /
89
+ HTML spec into chat -> Forge extracts requirements via Claude ->
90
+ generates a file scaffold plan -> writes the project after you
91
+ approve. Reverse the scaffold with one click. Aimed at solo
92
+ developers + institutional teams (ADIP) who want the full
93
+ "read spec out loud, then write the code" cycle without leaving
94
+ the keyboard or the headset. See "Voice cockpit + spec ingest"
95
+ below.
96
+
97
+ ## Quick start
98
+
99
+ ```bash
100
+ # Install
101
+ npm install -g @nac3/forge-cli@latest
102
+
103
+ # Guided first run: activates your license (auto-synced) + sets your
104
+ # AI key (BYOK). One command, it walks you through the rest.
105
+ yf onboard
106
+
107
+ # Decorate a vanilla HTML app (one shot, no human input)
108
+ yf migrate ./my-app --ai-silent --ai-out ./my-app-decorated
109
+
110
+ # Same, but include Yujin Pilot (needs the separate Pilot bundle --
111
+ # see "How Pilot works"; not shipped in this repo or the npm package)
112
+ yf migrate ./my-app --ai-silent --with-pilot --ai-out ./my-app-decorated
113
+
114
+ # Install Pilot into an already-decorated app (needs the Pilot bundle)
115
+ yf pilot install ./my-app-decorated
116
+
117
+ # Open it
118
+ xdg-open ./my-app-decorated/index.html
119
+ ```
120
+
121
+ The decorated output is **drop-in NAC3-ready**: no CDN dependencies
122
+ at runtime, the manifest is registered inline at boot, every action
123
+ button is wired through `NAC.bindAction`, the floating Pilot button
124
+ appears bottom-right. Click it, paste an API key, and drive the page
125
+ by voice or text.
126
+
127
+ > NAC-3 version: Forge tracks NAC-3. The canonical version lives in
128
+ > the `nac-spec` repo (stable v2.5, latest alpha.5 at the time of
129
+ > writing); see [yujin.app/nac-spec/SPEC.html](https://yujin.app/nac-spec/SPEC.html)
130
+ > for the exact current value.
131
+
132
+ The chat-panel brain is BYOK and provider-agnostic. Forge wires
133
+ these brain providers: **Anthropic, OpenAI, Google (Gemini),
134
+ DeepSeek, xAI (Grok), Mistral, Cohere, Qwen (Alibaba DashScope),
135
+ and Zhipu GLM (z.ai)** via their own API keys, plus a **local**
136
+ brain via **Ollama** (or any OpenAI-compatible local server, no key
137
+ required). Two virtual providers complete the set: `yujin_managed`
138
+ (routes inference to the HITO 4 worker by plan/tier) and
139
+ `federation` (routes to a remote parent Forge's brain). See
140
+ `yf brain` + `yf federation`.
141
+
142
+ ## Commands
143
+
144
+ Forge ships **56 top-level commands**. The core lifecycle:
145
+
146
+ | Command | What it does |
147
+ |---|---|
148
+ | `yf new <slug>` | Bootstrap a new Yujin Forge React app from `templates/react-app/`. |
149
+ | `yf migrate <repo>` | Audit (default) or apply a NAC-3 migration on a React or HTML project. See the migrate flags below. |
150
+ | `yf pilot install <dir>` | Inject the Pilot bundle into an already-decorated NAC-3 app (separate bundle required -- see "How Pilot works"). |
151
+ | `yf chat` | Launch the embedded voice+text panel hooked to the current project. |
152
+ | `yf test` | Run the project test corpus. |
153
+ | `yf ship` | Deploy gate: validate + license + tests + build -> `dist/`. |
154
+ | `yf doctor` | Diagnose the local Forge install + license + vault + voice + reader deps. |
155
+ | `yf validate [path]` | Statically check that a directory is a valid Yujin Forge project. |
156
+ | `yf license` | Activate, inspect, or revoke a license. |
157
+ | `yf onboard` | Guided first run: license (auto-synced) + BYOK key. |
158
+ | `yf upgrade` | Self-update (npm-global in place, or point at the desktop installer). |
159
+
160
+ `yf migrate` flags: `--apply` (React/AST), `--html` / `--assisted`
161
+ (rule-based HTML walker, offline), `--ai-silent` / `--ai-assisted`
162
+ (AI-powered decoration, paid seat), `--with-pilot` (also inject the
163
+ Pilot bundle).
164
+
165
+ The rest of the surface, by area:
166
+
167
+ - **Brain + keys + cost:** `brain`, `keys`, `federation`, `limits`,
168
+ `vault`.
169
+ - **Workflow + project state:** `workflow`, `pending`, `wiring`,
170
+ `projects`, `graph`, `triage`, `discover`, `clarify`, `spec`,
171
+ `approve`, `bootstrap`, `block`, `coverage`, `operate`, `legacy`.
172
+ - **Voice + accessibility:** `voice`.
173
+ - **NAC-3 + doctrine + MCP:** `manifest`, `nac3`, `doctrine`,
174
+ `doctrines`, `lessons`, `mcp`, `agent`.
175
+ - **Testing + QA:** `gen-tests`, `gen-flow-tests`, `scenarios:emit`,
176
+ `review-screens`, `review-status`, `qa`, `test-agent`.
177
+ - **Design + scaffolding:** `figma`.
178
+ - **Deploy + ops + infra:** `deploy`, `tunnel`, `publish`, `repo`,
179
+ `app`, `support`, `log`, `provision-link`.
180
+ - **Mobile:** `mobile`.
181
+
182
+ Run `yf --help` for the authoritative list and
183
+ [docs/USAGE.md](docs/USAGE.md) for every flag and worked examples.
184
+
185
+ ## How decoration works
186
+
187
+ A vanilla HTML/JS app starts like:
188
+
189
+ ```html
190
+ <button onclick="digit('7')">7</button>
191
+ ```
192
+
193
+ After `yf migrate --ai-silent`:
194
+
195
+ ```html
196
+ <body data-nac-plugin="calc">
197
+ ...
198
+ <button onclick="digit('7')"
199
+ data-nac-id="calc.action.digit_7"
200
+ data-nac-role="action"
201
+ data-nac-action="digit_7">7</button>
202
+ ...
203
+ <script src="nac.browser.js"></script>
204
+ <script src="calc.js"></script>
205
+ <script src="nac-bridge.js"></script>
206
+ <script>
207
+ (function () {
208
+ var manifest = { "plugin_slug": "calc", ... };
209
+ window.NAC.register(manifest);
210
+ })();
211
+ </script>
212
+ </body>
213
+ ```
214
+
215
+ Any LLM driver can now call:
216
+
217
+ ```js
218
+ await NAC.click_by_verb('calc', 'digit_7');
219
+ ```
220
+
221
+ and the host's existing `digit('7')` handler runs **plus** the
222
+ `nac:action:succeeded` contract event fires (because `nac-bridge.js`
223
+ re-wired the inline onclick via `NAC.bindAction`).
224
+
225
+ ## How Pilot works
226
+
227
+ Pilot is a single-file IIFE bundle + companion stylesheet
228
+ (`pilot.bundle.js` + `pilot.css`). `yf pilot install` (or
229
+ `yf migrate --with-pilot`) copies both into the target directory and
230
+ inserts the script tags before `</body>`.
231
+
232
+ > **The Pilot bundle ships separately.** It is NOT included in this
233
+ > repository nor in the published `@nac3/forge-cli` npm package. To
234
+ > use `yf pilot install` / `yf migrate --with-pilot` you must supply
235
+ > the bundle yourself. `yf pilot install` looks for it (in order) at:
236
+ >
237
+ > 1. `--source <dir>` (an explicit path you pass), then
238
+ > 2. `../yujin-pilot/dist/` (a sibling checkout of the Pilot repo), then
239
+ > 3. `node_modules/@yujin/pilot/dist/` (if `@yujin/pilot` is installed).
240
+ >
241
+ > If none contain `pilot.bundle.js`, the command stops with a clear
242
+ > error listing exactly where it looked and how to point it at the
243
+ > bundle. Obtain the bundle from the
244
+ > [Yujin Pilot repo](https://github.com/yujinapp/yujin-pilot) (build
245
+ > its `dist/`), or pass `--source` at a path that already has it.
246
+
247
+ At runtime, Pilot mounts a floating sumi-e branch button at
248
+ bottom-right. Click it: chat panel opens. Click again: switches to
249
+ the "pizarra" mode (chat + voice + action trace). Configure: paste
250
+ an API key for any supported provider. Each provider supports all the
251
+ models the
252
+ [NAC3 benchmark](https://yujin.app/nac-spec/benchmark/) exercised.
253
+
254
+ Pilot reads `window.NAC.list_registered_plugins()` to get the active
255
+ manifest, sends it to the selected LLM with the user's utterance,
256
+ parses the JSON action chain, dispatches each via
257
+ `NAC.click_by_verb`, reads back any configured status probe, then
258
+ speaks the result via Web Speech / ElevenLabs / Google Cloud TTS.
259
+
260
+ Config persists in `localStorage` under `yujin_pilot.config`. Keys
261
+ never leave the browser. (Production deployments belong behind a
262
+ server proxy.)
263
+
264
+ See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for the full
265
+ internal architecture.
266
+
267
+ ## Voice cockpit + spec ingest (HITO 1)
268
+
269
+ `yf chat` opens a local panel with three views (globito / mini /
270
+ full). The full view has a chat stream on the left and a "pizarra"
271
+ trace on the right that shows every tool the system invoked to
272
+ answer.
273
+
274
+ What it covers end-to-end:
275
+
276
+ - **Vault** -- modal accessible via the Keys button. Slots for
277
+ `anthropic`, `openai`, `google_voice`, `elevenlabs`,
278
+ `github_token`. Values are encrypted at rest with the machine
279
+ fingerprint; shown once on entry, never again.
280
+
281
+ - **Voice in / voice out.** Press the mic, speak; the panel
282
+ records via `MediaRecorder`, ships the audio to the configured
283
+ STT provider, and either dispatches a recognised reader command
284
+ directly or feeds the transcript to the chat loop. Replies are
285
+ spoken back via the configured TTS provider with chunked
286
+ prefetch (first audio in ~600 ms even on long answers).
287
+
288
+ - **Voiceprint trust.** Enroll your voice once -- subsequent voice
289
+ commands are gated by a 5-layer trust model
290
+ (unknown / heard / recognised / trusted / authorised). Irreversible
291
+ actions (force push, branch delete, deploy) ALWAYS require a
292
+ liveness challenge regardless of trust level: a random Spanish/
293
+ English phrase plus a random number you have to read back.
294
+
295
+ - **Document reader.** Open any file in the project root and
296
+ navigate by voice: "abrime el readme", "siguiente", "buscar
297
+ pricing", "marcame aqui como inicio", "volver a marca inicio",
298
+ "recap". Supports **10 formats**: txt, md, source code (.ts / .py
299
+ / .rs / 80+ extensions), HTML, RTF, CSV/TSV, EPUB, **PDF**
300
+ (via pdfjs-dist), **DOCX** (via mammoth), **XLSX** (via sheetjs).
301
+ All format detection happens automatically.
302
+
303
+ - **Spec drag-drop.** Drag a spec file onto the chat panel; an
304
+ overlay appears + the file uploads. Forge parses it through the
305
+ same reader pipeline, then a Claude call extracts structured
306
+ requirements, entities, endpoints, and UI components. A second
307
+ Claude call turns the extraction into a concrete file scaffold
308
+ plan (which files to create + where + what kind + which
309
+ requirement each serves + open questions for clarification).
310
+ Nothing is written until you POST `{approve: true}`. On approve,
311
+ the scaffolder writes the planned files with hand-rolled
312
+ templates per kind (model / api / component / test / doc) and
313
+ records a rollback log -- one click undoes the whole scaffold.
314
+
315
+ - **Reader recap modes.** Default `literal` mode joins recent
316
+ spoken blocks into a TTS-friendly narrative for "que dijiste".
317
+ Optional `summary` mode calls Claude for a 1-2 sentence
318
+ compression; gated by env var `YF_ENABLE_CLAUDE_RECAP=1` so it
319
+ cannot fire by accident and charge tokens. Cost model in
320
+ `docs/RECAP_CLAUDE_COSTS.md`.
321
+
322
+ ### ADIP voice-first demo loop
323
+
324
+ ```
325
+ User: (mic) "abrime el plan.md"
326
+ -> reader.open -> TTS "El Plan"
327
+ User: (mic) "siguiente"
328
+ -> reader.next -> TTS "Primer paso"
329
+ User: (mic) "buscar pricing"
330
+ -> reader.search -> TTS top snippet
331
+ ```
332
+
333
+ Drag a spec PDF onto the panel:
334
+
335
+ ```
336
+ panel -> spec ingested. Title: ADIP Spec. 4 sections.
337
+ First lines:
338
+ - The system MUST register patients.
339
+ - ...
340
+ panel (via Claude)-> extraction: 1 requirement, 1 entity (Paciente),
341
+ 1 endpoint (POST /patients), 1 component
342
+ (PatientCard).
343
+ panel (via Claude)-> plan: src/models/Paciente.ts +
344
+ src/api/patients.ts +
345
+ src/components/PatientCard.tsx + README.md.
346
+ Open question: authentication unspecified.
347
+ user clicks -> approve.
348
+ scaffolder -> 4 files written, rollback log captured.
349
+ ```
350
+
351
+ If anything looks off: one `POST /api/forge/ingest/rollback` and
352
+ the project is back to its prior state.
353
+
354
+ ### Architecture pointer
355
+
356
+ The full step-by-step voice loop, reader pipeline, voiceprint
357
+ state machine, and "how to add a parser / intent / trust class"
358
+ recipes live in [docs/HITO_1_ARCHITECTURE.md](docs/HITO_1_ARCHITECTURE.md).
359
+
360
+ ## Multi-agent session orchestration (opt-in, default OFF)
361
+
362
+ The single chat session can spawn **bounded headless sub-sessions**
363
+ to do orthogonal, well-scoped work in parallel and collect the
364
+ results over the coordination bridge. This is the `yujin.session.*`
365
+ verb family (`spawn` / `collect` / `list` / `stop`).
366
+
367
+ - **Default OFF.** The whole capability is gated by
368
+ `multiagent.enabled` in the limits config (Ajustes > Limites).
369
+ While off, the `yujin.session.*` verbs are hidden from the
370
+ manifest, the doctrine is not injected, and the handlers refuse.
371
+ Turn it on explicitly to use it.
372
+ - **Orthogonal + parallel only.** A sub-session boots a whole
373
+ headless server and spends BYOK tokens, so it is reserved for
374
+ independent work (wide reads, research, analysis over a different
375
+ subsystem) that does not need the live conversation. The user
376
+ approves each spawn; set `budget_tokens` to bound the spend.
377
+ - **Restricted child scope (enforced).** A sub-session can read /
378
+ search / write files in its project root, run safe shell, and
379
+ query the graph / pendings / reader. It CANNOT push / commit, do
380
+ destructive or irreversible actions, mutate workflow / pending /
381
+ keys, or spawn its own sub-sessions (no grandchildren). Anything
382
+ outward stays with the parent, where the user can approve it.
383
+
384
+ Full rules: [docs/doctrine/session-orchestration.md](docs/doctrine/session-orchestration.md).
385
+
386
+ ## Why a separate product
387
+
388
+ NAC (the spec) is Apache-2.0 free forever. The reference runtime
389
+ `nac-spec` on npm is Apache-2.0 free forever. **Yujin Forge is the
390
+ commercial build layer:**
391
+
392
+ - The AI decorator (`--ai-silent` / `--ai-assisted`) burns Anthropic
393
+ tokens on your behalf; the seat license is what funds that.
394
+ - The chat panel, React scaffolder, test corpus generator, and mock
395
+ generator are all license-gated.
396
+ - The static-rule HTML walker (`--html`, `--assisted`) is open and
397
+ works offline.
398
+
399
+ The Apache spec attracts the ecosystem; Forge monetises the delivery
400
+ experience for teams that want to skip the per-app plumbing.
401
+
402
+ ## What Forge gives an app (under the hood)
403
+
404
+ Every decorated output ships:
405
+
406
+ 1. `index.html` -- decorated, drop-in NAC3-ready
407
+ 2. `manifest.json` -- the NAC3 manifest, version-pinnable
408
+ 3. `nac.browser.js` -- the NAC3 runtime (copied locally, no CDN dep)
409
+ 4. `nac-bridge.js` -- ~50 lines, wires `NAC.bindAction` for every
410
+ action element so the host's existing handlers stay intact AND the
411
+ contract events fire
412
+ 5. **With `--with-pilot`:** `pilot.bundle.js` + `pilot.css` -- the
413
+ embedded chat + voice cockpit
414
+
415
+ After running Forge, your app is ready to be driven by any LLM agent
416
+ that understands NAC-3. Pilot is one such driver; the
417
+ [600-run benchmark](https://yujin.app/nac-spec/benchmark/) was driven
418
+ by a custom harness; the React SDK in
419
+ [`@yujin/nac-react`](https://www.npmjs.com/package/nac-spec) is
420
+ another.
421
+
422
+ ## Where this lives in the Yujin ecosystem
423
+
424
+ ```
425
+ NAC (Apache-2.0) -- pkuschnirof/rpaforce-crm + yujin.app/nac-spec
426
+ spec + reference runtime + nac-spec NPM package
427
+ |
428
+ | depends on
429
+ v
430
+ Yujin Forge (closed core) -- yujinapp/yujin-forge (build NAC apps)
431
+ AI decorator, React scaffolder, license gating, this repo
432
+ | sibling product
433
+ v
434
+ Yujin Pilot (closed core) -- yujinapp/yujin-pilot (drive NAC apps)
435
+ Embedded chat + voice + multi-model cockpit
436
+ |
437
+ | downstream adopter
438
+ v
439
+ Customer apps
440
+ ```
441
+
442
+ ## Documentation
443
+
444
+ - [README.md](README.md) -- this file
445
+ - [PROJECT.md](PROJECT.md) -- topology + governance + slice/HITO process (mandatory read before touching code)
446
+ - [docs/SQ.md](docs/SQ.md) -- quality standards + deliverables + pre-development checklist (Spanish, mandatory)
447
+ - [docs/QUICKSTART_ADIP.md](docs/QUICKSTART_ADIP.md) -- step-by-step setup guide for the ADIP institutional rollout (Spanish)
448
+ - [docs/USAGE.md](docs/USAGE.md) -- every command + flag + worked examples
449
+ - [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) -- internals of the AI decorator + wiring + Pilot integration
450
+ - [docs/HITO_1_ARCHITECTURE.md](docs/HITO_1_ARCHITECTURE.md) -- HITO 1 voice + reader + spec ingest reference
451
+ - [docs/LANGUAGE_POLICY.md](docs/LANGUAGE_POLICY.md) -- the 10-canonical-languages rule + catalog-lint mechanism
452
+ - [docs/manuals/manual.es.html](docs/manuals/manual.es.html) -- end-user manual (10 languages: es/en/pt/fr/ja/zh/hi/ar/de/it)
453
+ - [docs/RECAP_CLAUDE_COSTS.md](docs/RECAP_CLAUDE_COSTS.md) -- cost model + lock mechanism for the Claude recap mode
454
+ - [docs/ROADMAP_VOICE_FORGE_2026_05_23.md](docs/ROADMAP_VOICE_FORGE_2026_05_23.md) -- HITO 0/1/2/3 roadmap with decisions taken
455
+ - [docs/TECHNICAL_MANUAL.md](docs/TECHNICAL_MANUAL.md) -- living manual updated at each slice close
456
+ - [docs/SPEC.md](docs/SPEC.md) -- the contract Forge makes with adopting teams
457
+ - [docs/COMMERCIAL_PLAN.md](docs/COMMERCIAL_PLAN.md) -- pricing + licensing model
458
+ - [docs/SESSION_HANDOFF_2026_05_23_AT_DOCTOR.md](docs/SESSION_HANDOFF_2026_05_23_AT_DOCTOR.md) -- state at last session boundary
459
+
460
+ ## See also
461
+
462
+ - [NAC spec](https://yujin.app/nac-spec/SPEC.html)
463
+ - [NAC3 v2.3 benchmark](https://yujin.app/nac-spec/benchmark/) -- 600 runs across 5 models + 3 protocols
464
+ - [Migration paper](https://yujin.app/nac-spec/migration/) -- Forge silent vs assisted vs Sumi manual on a calculator
465
+ - [Yujin Pilot](https://github.com/yujinapp/yujin-pilot) -- the sibling driver product
466
+ - [Yujin CRM](https://github.com/pkuschnirof/rpaforce-crm) -- the first adopter of the full stack