@nac3/runtime 2.6.0 → 2.9.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 CHANGED
@@ -14,8 +14,10 @@ npm install @nac3/runtime
14
14
  - The v2.0 brownfield extensions (scope tree, ephemeral capture,
15
15
  HMAC, isTrusted).
16
16
  - A reference chat client that wires voice + LLM + dispatcher.
17
- - A CLI (`npx nac validate <dir>`) that statically lints HTML/PHP
18
- for NAC contract violations.
17
+ - A CLI (`npx nac validate <target>`) with three modes: a static
18
+ lint over your markup, a **harness** mode that mounts a page in Node
19
+ and decides the conformance requirements that do not need a browser,
20
+ and a URL mode that drives a real one.
19
21
  - TypeScript types.
20
22
 
21
23
  ## Hello world (vanilla)
@@ -86,11 +88,17 @@ export function Greet() {
86
88
 
87
89
  ## CLI
88
90
 
91
+ Three modes, and they do not pretend to be each other.
92
+
93
+ ### 1. Static lint -- reads files, executes nothing
94
+
89
95
  ```
90
96
  npx @nac3/runtime validate ./src
91
97
  ```
92
98
 
93
- Static lint over your HTML/PHP. Reports:
99
+ It reads 28 markup and template extensions (`--ext=.foo` adds more),
100
+ **says how many files it read**, and refuses when it read none -- a
101
+ tree it could not open must not look like a conforming one. Reports:
94
102
 
95
103
  - `tab_role_drift` -- a `data-nac-id="tab.X"` without
96
104
  `data-nac-role="tab"`.
@@ -101,18 +109,77 @@ Static lint over your HTML/PHP. Reports:
101
109
  - `tab_id_manifest_role_drift` -- manifest entry id like `tab.X`
102
110
  but the entry's role isn't `'tab'`.
103
111
 
112
+ - `no_lintable_files` -- it read ZERO files, so it is reporting
113
+ nothing about this tree. Not the same as a clean tree, and it says
114
+ so instead of printing `Total findings: 0`.
115
+
104
116
  Exit codes:
105
117
 
106
118
  - `0` -- no findings at the configured severity (default `error`).
107
119
  - `1` -- findings at or above the configured severity.
108
120
  - `2` -- target not found / argument error.
109
121
 
122
+ ### 2. Harness -- mounts the page in Node
123
+
124
+ ```
125
+ npx @nac3/runtime validate ./page.html --harness --requirements
126
+ ```
127
+
128
+ It parses the markup into a synthesised document, loads the runtime,
129
+ **runs the page's own scripts** in a sandbox with no network, and then
130
+ asks the runtime the same questions the browser mode asks -- with the
131
+ same observer and the same decider table, so the two modes cannot form
132
+ two opinions about what the contract says.
133
+
134
+ Of the eleven requirements of SPEC.md section 8 it **decides five** and
135
+ **declares the other six**, each with the reason it cannot:
136
+
137
+ - three are a human judgement no tool makes (which widgets an agent
138
+ *should* be able to operate is the author's call);
139
+ - two are behavioural -- the completion event comes from your handler,
140
+ so they need the page driven (`--drive`, mode 3);
141
+ - and one is `validate_global({probe: true})`, which asks the document
142
+ whether an element is *reachable*. A synthesised document answers
143
+ whatever its stub decides, not what a browser would, so deciding it
144
+ here would be measuring the stub.
145
+
146
+ A mode that decided eleven of eleven would be lying about at least one
147
+ of them. What it *can* decide it decides for real, including in the
148
+ negative: an id your manifest advertises that nothing paints makes
149
+ "`NAC.click(id)` works for every advertised id" **false** without
150
+ driving anything.
151
+
152
+ It **executes your page**, which is the difference between this mode
153
+ and the lint above. The lint still touches nothing.
154
+
155
+ Exit codes:
156
+
157
+ - `0` -- nothing decidable fails at level 1 (the normal answer: no
158
+ level can be *asserted* from Node, and that is not a failure of your
159
+ page).
160
+ - `1` -- a level 1 requirement was decided to FAIL. A decided failure
161
+ at level 2 or 3 is printed and does not fail the run: a page that
162
+ never aimed at level 3 is not broken for lacking an HMAC.
163
+ - `2` -- nothing to mount, or more than one page and no `index`.
164
+
165
+ ### 3. URL -- drives a real browser
166
+
167
+ ```
168
+ npx @nac3/runtime validate https://example.org/app --drive
169
+ ```
170
+
171
+ Needs Playwright, which is **not** a dependency of this package
172
+ (`npm i -D playwright && npx playwright install chromium`). This is
173
+ the only mode that can report a conformance level, because three of
174
+ the four requirements of level 1 are about what the page DOES.
175
+
110
176
  ## Subpath imports
111
177
 
112
178
  ```js
113
179
  import NAC from '@nac3/runtime';
114
180
  import '@nac3/runtime/extensions'; // v2.0 brownfield primitives
115
181
  import '@nac3/runtime/chat-client'; // reference voice + chat client
182
+ import '@nac3/runtime/mcp-interop'; // optional: drive a SECOND app by name
116
183
  ```
117
184
 
118
185
  ## Status
@@ -135,6 +202,47 @@ import '@nac3/runtime/chat-client'; // reference voice + chat client
135
202
 
136
203
  Apache-2.0. See `LICENSE`.
137
204
 
205
+ ## What the tarball contains
206
+
207
+ `npm install @nac3/runtime` gives you the **built** artefacts and the
208
+ documents that describe them -- nothing else:
209
+
210
+ ```
211
+ dist/ the runtime, the extensions, the chat client, the CLI
212
+ README.md LICENSE NOTICE SPEC.md CHANGELOG.md contract-head.json
213
+ ```
214
+
215
+ That is the whole published file set (`files` in `package.json`), and
216
+ it is deliberate: what an adopter needs is the artefact plus the text
217
+ that governs it.
218
+
219
+ **So two of the package's own scripts do not work from an install, and
220
+ that is by design rather than an oversight:**
221
+
222
+ | Script | Needs |
223
+ |---|---|
224
+ | `npm run build` | the repository -- it reads `js/nac.js` (the authoritative version constant), `SPEC.md` and `scripts/`, none of which ship |
225
+ | `npm test` | the repository -- the 22-suite battery lives in `test/`, which does not ship |
226
+
227
+ `prepublishOnly` and `postpublish` reach `../scripts/` for the same
228
+ reason. They only ever run on `npm publish`, which only happens from a
229
+ checkout, so they are correct where they run and impossible anywhere
230
+ else.
231
+
232
+ To build or test, clone the repository:
233
+
234
+ ```sh
235
+ git clone https://github.com/yujinapp/nac-spec.git
236
+ cd nac-spec/runtime
237
+ npm run build
238
+ npm test
239
+ ```
240
+
241
+ This section is not a convention anyone has to remember:
242
+ `test/battery-coverage.mjs` refuses a `package.json` with a script
243
+ that reaches outside the published file set without a written reason,
244
+ and it checks that this heading still exists.
245
+
138
246
  ## Repository
139
247
 
140
248
  [github.com/yujinapp/nac-spec](https://github.com/yujinapp/nac-spec)