@autotelic/protocol 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +183 -2
- package/dist/baseline.d.ts +41 -0
- package/dist/baseline.d.ts.map +1 -0
- package/dist/baseline.js +62 -0
- package/dist/baseline.js.map +1 -0
- package/dist/catalog.d.ts +275 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +437 -0
- package/dist/catalog.js.map +1 -0
- package/dist/compat.d.ts +12 -0
- package/dist/compat.d.ts.map +1 -0
- package/dist/compat.js +104 -0
- package/dist/compat.js.map +1 -0
- package/dist/config.d.ts +179 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +302 -0
- package/dist/config.js.map +1 -0
- package/dist/decode.d.ts +32 -0
- package/dist/decode.d.ts.map +1 -0
- package/dist/decode.js +71 -0
- package/dist/decode.js.map +1 -0
- package/dist/doc.d.ts +105 -0
- package/dist/doc.d.ts.map +1 -0
- package/dist/doc.js +159 -0
- package/dist/doc.js.map +1 -0
- package/dist/graph.d.ts +139 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +258 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/intent.d.ts +32 -0
- package/dist/intent.d.ts.map +1 -0
- package/dist/intent.js +54 -0
- package/dist/intent.js.map +1 -0
- package/dist/json.d.ts +3 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +18 -0
- package/dist/json.js.map +1 -0
- package/dist/lexicon.d.ts +58 -0
- package/dist/lexicon.d.ts.map +1 -0
- package/dist/lexicon.js +176 -0
- package/dist/lexicon.js.map +1 -0
- package/dist/patterns.d.ts +65 -0
- package/dist/patterns.d.ts.map +1 -0
- package/dist/patterns.js +166 -0
- package/dist/patterns.js.map +1 -0
- package/dist/recipes.d.ts +34 -0
- package/dist/recipes.d.ts.map +1 -0
- package/dist/recipes.js +74 -0
- package/dist/recipes.js.map +1 -0
- package/dist/report.d.ts +218 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +330 -0
- package/dist/report.js.map +1 -0
- package/package.json +46 -3
- package/schema/baseline.json +29 -0
- package/schema/catalog.json +206 -0
- package/schema/cutlist.config.json +103 -0
- package/schema/intent.json +43 -0
- package/schema/jig.config.json +56 -0
- package/schema/manifest.json +67 -0
- package/schema/menu.json +169 -0
- package/schema/onboarding.json +25 -0
- package/schema/patterns.json +141 -0
- package/schema/recipes.json +57 -0
- package/schema/report.json +141 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 autotelic
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,184 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @autotelic/protocol
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Not a tool.** The record formats the conformance tools agree on, as pure TypeScript
|
|
4
|
+
types, JSON Schema, and pure helpers. Zero dependencies, no runtime, no I/O.
|
|
5
|
+
|
|
6
|
+
The cohesion of `tackle` is not that the programs were merged — it is that they agree
|
|
7
|
+
on **bytes**. `plumb`, `joggle`, `cutlist`, and `jig` never import each other; they agree
|
|
8
|
+
on a file format. This package is that format.
|
|
9
|
+
|
|
10
|
+
## The model: records and lexicons
|
|
11
|
+
|
|
12
|
+
Every artifact that crosses a boundary is a **record** — a JSON document one tool writes
|
|
13
|
+
and another reads. Every record has a named, versioned **lexicon**: its contract.
|
|
14
|
+
|
|
15
|
+
- The **name** is the contract (`report`, `baseline`, `catalog`), not the file that holds
|
|
16
|
+
it. A tool-written record carries its own reference, so a reader with only the bytes — a
|
|
17
|
+
script in another language, a future tool that replaces `plumb` — can tell what it holds:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{ "lexicon": { "name": "report", "version": 1 }, "...": "..." }
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- Each lexicon **versions on its own line**. There is no global `PROTOCOL_VERSION`: a
|
|
24
|
+
change to `report` never forces a reader of `baseline` to re-reason.
|
|
25
|
+
|
|
26
|
+
- **Kind** is who owns the truth, not who writes the file:
|
|
27
|
+
|
|
28
|
+
| kind | meaning |
|
|
29
|
+
| ---------- | -------------------------------------------------------------- |
|
|
30
|
+
| `authored` | a human or agent writes it; it is the source of truth |
|
|
31
|
+
| `derived` | a tool regenerates it; it is never hand-edited |
|
|
32
|
+
| `accepted` | derived from a run, then committed as a ratchet (the baseline) |
|
|
33
|
+
|
|
34
|
+
Derived data does not belong _inside_ a record any more than a like-count belongs inside
|
|
35
|
+
a post. The baseline stores identities, never lines or counts; a report may carry tallies
|
|
36
|
+
because it is a snapshot, but nothing downstream reads truth out of them.
|
|
37
|
+
|
|
38
|
+
- **Stable identity.** Everything is keyed by a path or an identity that survives moves —
|
|
39
|
+
never a line, never a host, never a render order. `catalog.hash` and the baseline's
|
|
40
|
+
identity set are the self-certifying parts: where a reader must _verify_, prefer
|
|
41
|
+
content-addressing.
|
|
42
|
+
|
|
43
|
+
- **Many-to-many.** No format requires another format, and no format requires an app. The
|
|
44
|
+
menu carries the catalog's `hash` but does not need the catalog to be read; `plumb` reads
|
|
45
|
+
the manifest without importing this package; a repo with only `oxlint` can use `jig`
|
|
46
|
+
without installing `cutlist`. That tolerance is the point.
|
|
47
|
+
|
|
48
|
+
## The lexicons
|
|
49
|
+
|
|
50
|
+
| name | owner | kind | ver | schema | fixtures |
|
|
51
|
+
| ---------------- | -------------------- | -------- | --- | ---------------------------- | -------------------------- |
|
|
52
|
+
| `report` | `@autotelic/jig-cli` | derived | 1 | `schema/report.json` | `fixtures/report/` |
|
|
53
|
+
| `baseline` | `@autotelic/jig-cli` | accepted | 1 | `schema/baseline.json` | `fixtures/baseline/` |
|
|
54
|
+
| `catalog` | `@autotelic/cutlist` | derived | 1 | `schema/catalog.json` | `fixtures/catalog/` |
|
|
55
|
+
| `manifest` | `@autotelic/cutlist` | derived | 1 | `schema/manifest.json` | `fixtures/manifest/` |
|
|
56
|
+
| `menu` | `@autotelic/cutlist` | derived | 1 | `schema/menu.json` | `fixtures/menu/` |
|
|
57
|
+
| `intent` | `@autotelic/cutlist` | authored | 1 | `schema/intent.json` | `fixtures/intent/` |
|
|
58
|
+
| `patterns` | `@autotelic/cutlist` | derived | 1 | `schema/patterns.json` | `fixtures/patterns/` |
|
|
59
|
+
| `recipes` | `@autotelic/cutlist` | derived | 1 | `schema/recipes.json` | `fixtures/recipes/` |
|
|
60
|
+
| `onboarding` | `@autotelic/jig-cli` | authored | 1 | `schema/onboarding.json` | `fixtures/onboarding/` |
|
|
61
|
+
| `cutlist.config` | `@autotelic/cutlist` | authored | 1 | `schema/cutlist.config.json` | `fixtures/cutlist.config/` |
|
|
62
|
+
| `jig.config` | `@autotelic/jig-cli` | authored | 1 | `schema/jig.config.json` | `fixtures/jig.config/` |
|
|
63
|
+
|
|
64
|
+
Authored records name their lexicon by `$schema` (`$schema/*.json` is exported for
|
|
65
|
+
autocomplete), or by their path when the format is one file per key: an `intent/<key>.json`
|
|
66
|
+
sidecar may omit both. The manifest's reference is optional because its first readers predate
|
|
67
|
+
versioning; `cutlist`'s projector always writes it.
|
|
68
|
+
|
|
69
|
+
`menu` is a **mixed** record: `composedOf`, `orphans`, `duplicates`, and `hash` are derived
|
|
70
|
+
and regenerated; `summary`, `status`, and `useInstead` are authored intent. `MENU.md` is the
|
|
71
|
+
rendering; this record is the model.
|
|
72
|
+
|
|
73
|
+
`intent` is the authored sidecar: one file per part, keyed by the part's stable id or name.
|
|
74
|
+
It is where the lifecycle (`stable`, `beta`, `experimental`, `deprecated`) and the sentence
|
|
75
|
+
that says what a part is for live, beside the generated catalog rather than inside it.
|
|
76
|
+
|
|
77
|
+
`patterns` and `recipes` are the derived views an agent reads next: the stable shape and the
|
|
78
|
+
relations around it, then the import and minimal shape for a composition or load-bearing
|
|
79
|
+
part. `jig menu` reads both without importing cutlist; they are records for the same reason
|
|
80
|
+
the menu is.
|
|
81
|
+
|
|
82
|
+
`onboarding` is a **declared** lexicon: its schema and fixtures exist and are checked, but no
|
|
83
|
+
engine serializes it yet (`jig` writes a cookbook, not this record). When `jig` adopts it, the
|
|
84
|
+
schema does not change.
|
|
85
|
+
|
|
86
|
+
## The evolution rule, enforced
|
|
87
|
+
|
|
88
|
+
Once a lexicon is in the wild you may **add an optional field**. You may never change
|
|
89
|
+
whether a field is optional, never remove one, and never reinterpret existing bytes. A
|
|
90
|
+
breaking change is a **new lexicon name** — `report` → `report.v2` — not a new meaning for
|
|
91
|
+
`report`.
|
|
92
|
+
|
|
93
|
+
The rule is checked, not documented:
|
|
94
|
+
|
|
95
|
+
- `fixtures/compat/<lexicon>.vN.json` is a **frozen corpus** — one record per lexicon per
|
|
96
|
+
released version, in the bytes that were valid at the time.
|
|
97
|
+
- `scripts/lexicon-compat.mjs` validates every frozen record against the **current**
|
|
98
|
+
schema with an independent validator (Ajv, a devDependency — the runtime stays
|
|
99
|
+
dependency-free). A schema change that would reject an old record fails the build. It is
|
|
100
|
+
wired into the root gate (`pnpm lexicon:compat`, part of `pnpm check`).
|
|
101
|
+
- `src/compat.ts` adds a best-effort structural pre-check (`schemaBreakingChanges`): newly
|
|
102
|
+
required fields, removed properties, narrowed types, removed enum values, closed
|
|
103
|
+
`additionalProperties`. The corpus is the guarantee; this is the early warning.
|
|
104
|
+
|
|
105
|
+
The one migration the rule carries forward: a record written before per-lexicon versioning
|
|
106
|
+
carries `protocolVersion: "0.1.0"` and no `lexicon`. Every decoder still accepts it, and
|
|
107
|
+
`fixtures/*/legacy.json` pins that fact.
|
|
108
|
+
|
|
109
|
+
## Reading and writing
|
|
110
|
+
|
|
111
|
+
**Read defensively, write strictly.** Every lexicon has a pure decoder that takes
|
|
112
|
+
`unknown` and returns a typed value or `undefined` — never a throw. A malformed or stale
|
|
113
|
+
record degrades to silence (a miss, an empty view), never a crash and never a false
|
|
114
|
+
finding. Decoders ignore fields they do not know, so a record from a newer tool still
|
|
115
|
+
reads; a known field of the wrong type fails the record whole, because a partial read is a
|
|
116
|
+
false finding waiting to happen.
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
import { decodeCatalog, decodeManifest, decodeReport, parseJson } from "@autotelic/protocol"
|
|
120
|
+
|
|
121
|
+
const report = decodeReport(parseJson(text)) // Report | undefined
|
|
122
|
+
const manifest = decodeManifest(parseJson(text)) // UiManifest; EMPTY_MANIFEST on junk
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Nothing here does I/O. `parseJson` is the format's one text reader — a malformed document is
|
|
126
|
+
a miss, never a throw — and every decoder takes the `unknown` it produced.
|
|
127
|
+
|
|
128
|
+
## The judges
|
|
129
|
+
|
|
130
|
+
The TypeScript is not allowed to judge its own output:
|
|
131
|
+
|
|
132
|
+
- **JSON Schema**, under `schema/`, is the language-neutral form. `pnpm test` validates
|
|
133
|
+
every golden and legacy fixture against it with Ajv — a judge that is not the TypeScript.
|
|
134
|
+
- **The conformance matrix** (`src/conformance.test.ts`) checks each real engine output
|
|
135
|
+
against the schema it must satisfy: `jig check` → `report`, `cutlist build` →
|
|
136
|
+
`catalog`/`manifest`/`menu`, and each authored config. Drift no single package's tests
|
|
137
|
+
would catch shows up here.
|
|
138
|
+
- **A second, independent reader** (`scripts/read-report.mjs`) reads a report with nothing
|
|
139
|
+
but Node's standard library and no import of this package. If it ever needs the package,
|
|
140
|
+
the format has quietly become an API.
|
|
141
|
+
- **Malformed fixtures**: every lexicon has a `malformed.json` that the schema rejects and
|
|
142
|
+
the decoder degrades to silence, and a test for each.
|
|
143
|
+
|
|
144
|
+
## Leaving the workspace
|
|
145
|
+
|
|
146
|
+
`report` is projected outward so findings arrive in standard shapes. `protocol` **specifies
|
|
147
|
+
those projections; it does not render them** — see [`docs/projections.md`](./docs/projections.md)
|
|
148
|
+
for the field-by-field mapping to SARIF 2.1.0, LSP 3.17, and Code Climate, with worked
|
|
149
|
+
examples under `fixtures/projections/` checked by `src/projections.test.ts`. The
|
|
150
|
+
implementations live in a rendering host (`jig`), which is allowed to render.
|
|
151
|
+
|
|
152
|
+
The priority is not symmetric: SARIF is the load-bearing interchange, LSP is the editor
|
|
153
|
+
contract, and Code Climate is a courtesy. The report is the truth; a projection is a
|
|
154
|
+
rendering, and if a target cannot express something, the information is dropped, not bent
|
|
155
|
+
back into the report.
|
|
156
|
+
|
|
157
|
+
## Scoping a run
|
|
158
|
+
|
|
159
|
+
A run can be narrowed to what a change introduced. The record — a proposed lexicon,
|
|
160
|
+
`changeset` — and its two matchers are specified in [`docs/scoping.md`](./docs/scoping.md):
|
|
161
|
+
`jig` computes the change set once, and any engine can read it. The **choice** of scope
|
|
162
|
+
stays in the tools; only the measurement crosses the boundary. The proposal is not yet a
|
|
163
|
+
schema, so the lexicons table above does not list it.
|
|
164
|
+
|
|
165
|
+
## What must never be in this package
|
|
166
|
+
|
|
167
|
+
- No runtime dependency, no imports, no `effect`, no I/O, no rendering, no CLI.
|
|
168
|
+
- No policy: severity ceilings, gate modes, and ownership rules belong to the tools. This
|
|
169
|
+
package names their vocabulary and nothing more.
|
|
170
|
+
- No engine's private need leaked into a shared format. If `plumb` wants a field, it
|
|
171
|
+
teaches its _own_ reader first.
|
|
172
|
+
- No line numbers as identity; no ordering as contract beyond a documented total order; no
|
|
173
|
+
behavior beyond pure functions that are genuinely part of the format's semantics.
|
|
174
|
+
|
|
175
|
+
## Why a format and not a shared package
|
|
176
|
+
|
|
177
|
+
A shared _runtime dependency_ couples releases: bump `protocol` and every engine must
|
|
178
|
+
re-release together. A shared _format_ does not — the tools agree on JSON and TypeScript
|
|
179
|
+
shapes, and each decodes defensively on its own terms. That is what keeps four tools
|
|
180
|
+
independently adoptable while still feeling like one product.
|
|
181
|
+
|
|
182
|
+
`plumb` is the proof: it does not depend on this package. It reads the manifest defensively
|
|
183
|
+
(a stale catalog degrades to silence, never to false findings) and tolerates fields it does
|
|
184
|
+
not know. Add a field here, and plumb ignores it until its reader learns it.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type LexiconRef } from "./lexicon.ts";
|
|
2
|
+
import type { Diagnostic } from "./report.ts";
|
|
3
|
+
/** The accepted state of a repository. */
|
|
4
|
+
export interface Baseline {
|
|
5
|
+
readonly lexicon: LexiconRef;
|
|
6
|
+
readonly identities: ReadonlyArray<string>;
|
|
7
|
+
}
|
|
8
|
+
/** The rule a finding names, engine and rule: `plumb/no-raw-html-layout`. */
|
|
9
|
+
export declare const ruleNameOf: (diagnostic: Diagnostic) => string;
|
|
10
|
+
/** A finding's stable name, falling back to engine+rule+file when it declared none. */
|
|
11
|
+
export declare const identityOf: (diagnostic: Diagnostic) => string;
|
|
12
|
+
/** The baseline for the findings in front of you. What `--update-baseline` writes. */
|
|
13
|
+
export declare const accept: (diagnostics: ReadonlyArray<Diagnostic>) => Baseline;
|
|
14
|
+
/**
|
|
15
|
+
* Read a baseline, or `undefined` when it is not one.
|
|
16
|
+
*
|
|
17
|
+
* A malformed ledger is a miss, not an empty ledger with a different meaning: the caller
|
|
18
|
+
* decides what "no baseline" means (for `jig` it is `accept([])`), and conflating corrupt
|
|
19
|
+
* with empty here would hide the difference.
|
|
20
|
+
*/
|
|
21
|
+
export declare const decodeBaseline: (value: unknown) => Baseline | undefined;
|
|
22
|
+
/** How a run compares to what was already accepted. */
|
|
23
|
+
export interface BaselineDiff {
|
|
24
|
+
/** Findings not in the baseline. These are what a gate fails on. */
|
|
25
|
+
readonly novel: ReadonlyArray<Diagnostic>;
|
|
26
|
+
/** Findings the baseline already accepted. */
|
|
27
|
+
readonly known: ReadonlyArray<Diagnostic>;
|
|
28
|
+
/** Identities the baseline held that no longer fire. The ratchet moving down. */
|
|
29
|
+
readonly stale: ReadonlyArray<string>;
|
|
30
|
+
}
|
|
31
|
+
/** Compare findings against a baseline. */
|
|
32
|
+
export declare const diffBaseline: (baseline: Baseline, diagnostics: ReadonlyArray<Diagnostic>) => BaselineDiff;
|
|
33
|
+
/**
|
|
34
|
+
* One sentence per violation, for a gate to print.
|
|
35
|
+
*
|
|
36
|
+
* A baseline violation is a *new identity*, and the message names it so a reader can
|
|
37
|
+
* tell "you introduced one finding" from "someone changed a rule's identity." An empty
|
|
38
|
+
* list means the ratchet held.
|
|
39
|
+
*/
|
|
40
|
+
export declare const ratchetViolations: (diff: BaselineDiff) => ReadonlyArray<string>;
|
|
41
|
+
//# sourceMappingURL=baseline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseline.d.ts","sourceRoot":"","sources":["../src/baseline.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAiB7C,0CAA0C;AAC1C,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;IAC5B,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAC3C;AAED,6EAA6E;AAC7E,eAAO,MAAM,UAAU,eAAgB,UAAU,KAAG,MACP,CAAA;AAE7C,uFAAuF;AACvF,eAAO,MAAM,UAAU,eAAgB,UAAU,KAAG,MAC4B,CAAA;AAEhF,sFAAsF;AACtF,eAAO,MAAM,MAAM,gBAAiB,aAAa,CAAC,UAAU,CAAC,KAAG,QAG9D,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,UAAW,OAAO,KAAG,QAAQ,GAAG,SAM1D,CAAA;AAED,uDAAuD;AACvD,MAAM,WAAW,YAAY;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;IACzC,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;IACzC,iFAAiF;IACjF,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CACtC;AAED,2CAA2C;AAC3C,eAAO,MAAM,YAAY,aACb,QAAQ,eACL,aAAa,CAAC,UAAU,CAAC,KACrC,YAaF,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,SAAU,YAAY,KAAG,aAAa,CAAC,MAAM,CAW1E,CAAA"}
|
package/dist/baseline.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { arrayOf, isRecord, readLexiconRef, str } from "./decode.js";
|
|
2
|
+
import { lexiconRef } from "./lexicon.js";
|
|
3
|
+
/** The rule a finding names, engine and rule: `plumb/no-raw-html-layout`. */
|
|
4
|
+
export const ruleNameOf = (diagnostic) => `${diagnostic.engine}/${diagnostic.ruleId}`;
|
|
5
|
+
/** A finding's stable name, falling back to engine+rule+file when it declared none. */
|
|
6
|
+
export const identityOf = (diagnostic) => diagnostic.identity ?? `${ruleNameOf(diagnostic)}:${diagnostic.location.file}`;
|
|
7
|
+
/** The baseline for the findings in front of you. What `--update-baseline` writes. */
|
|
8
|
+
export const accept = (diagnostics) => ({
|
|
9
|
+
lexicon: lexiconRef("baseline"),
|
|
10
|
+
identities: [...new Set(diagnostics.map(identityOf))].sort((a, b) => a.localeCompare(b)),
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Read a baseline, or `undefined` when it is not one.
|
|
14
|
+
*
|
|
15
|
+
* A malformed ledger is a miss, not an empty ledger with a different meaning: the caller
|
|
16
|
+
* decides what "no baseline" means (for `jig` it is `accept([])`), and conflating corrupt
|
|
17
|
+
* with empty here would hide the difference.
|
|
18
|
+
*/
|
|
19
|
+
export const decodeBaseline = (value) => {
|
|
20
|
+
if (!isRecord(value))
|
|
21
|
+
return undefined;
|
|
22
|
+
const lexicon = readLexiconRef(value, "baseline");
|
|
23
|
+
const identities = arrayOf(value.identities, str);
|
|
24
|
+
if (lexicon === undefined || identities === undefined)
|
|
25
|
+
return undefined;
|
|
26
|
+
return { lexicon, identities: [...identities].sort((a, b) => a.localeCompare(b)) };
|
|
27
|
+
};
|
|
28
|
+
/** Compare findings against a baseline. */
|
|
29
|
+
export const diffBaseline = (baseline, diagnostics) => {
|
|
30
|
+
const accepted = new Set(baseline.identities);
|
|
31
|
+
const novel = [];
|
|
32
|
+
const known = [];
|
|
33
|
+
const seen = new Set();
|
|
34
|
+
for (const diagnostic of diagnostics) {
|
|
35
|
+
const identity = identityOf(diagnostic);
|
|
36
|
+
seen.add(identity);
|
|
37
|
+
if (accepted.has(identity))
|
|
38
|
+
known.push(diagnostic);
|
|
39
|
+
else
|
|
40
|
+
novel.push(diagnostic);
|
|
41
|
+
}
|
|
42
|
+
const stale = baseline.identities.filter((identity) => !seen.has(identity));
|
|
43
|
+
return { novel, known, stale };
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* One sentence per violation, for a gate to print.
|
|
47
|
+
*
|
|
48
|
+
* A baseline violation is a *new identity*, and the message names it so a reader can
|
|
49
|
+
* tell "you introduced one finding" from "someone changed a rule's identity." An empty
|
|
50
|
+
* list means the ratchet held.
|
|
51
|
+
*/
|
|
52
|
+
export const ratchetViolations = (diff) => {
|
|
53
|
+
const byKey = new Map();
|
|
54
|
+
for (const diagnostic of diff.novel) {
|
|
55
|
+
const key = ruleNameOf(diagnostic);
|
|
56
|
+
byKey.set(key, (byKey.get(key) ?? 0) + 1);
|
|
57
|
+
}
|
|
58
|
+
return [...byKey.entries()]
|
|
59
|
+
.sort((left, right) => left[0].localeCompare(right[0]))
|
|
60
|
+
.map(([key, count]) => `${key}: ${count} new finding${count === 1 ? "" : "s"} not in the baseline`);
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=baseline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseline.js","sourceRoot":"","sources":["../src/baseline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAA;AAwB1D,6EAA6E;AAC7E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAAsB,EAAU,EAAE,CAC3D,GAAG,UAAU,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,EAAE,CAAA;AAE7C,uFAAuF;AACvF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAAsB,EAAU,EAAE,CAC3D,UAAU,CAAC,QAAQ,IAAI,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAA;AAEhF,sFAAsF;AACtF,MAAM,CAAC,MAAM,MAAM,GAAG,CAA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CAAC,CAAA"}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { type LexiconRef } from "./lexicon.ts";
|
|
2
|
+
import { type Tiers, type TierName } from "./config.ts";
|
|
3
|
+
import { type Intent, type PartStatus } from "./intent.ts";
|
|
4
|
+
/** Every field a component carries wherever it is rendered — the catalog's, and the manifest's. */
|
|
5
|
+
interface ComponentFields {
|
|
6
|
+
/** Repository-relative, forward-slashed. */
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly tier: TierName;
|
|
10
|
+
/** Route owners, first-segment. `shared` for importers under shared roots. */
|
|
11
|
+
readonly owners: ReadonlyArray<string>;
|
|
12
|
+
/** Declared prop names. */
|
|
13
|
+
readonly props: ReadonlyArray<string>;
|
|
14
|
+
/** Rendered JSX tag names. */
|
|
15
|
+
readonly tags: ReadonlyArray<string>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* What a part IS, as opposed to where it sits.
|
|
19
|
+
*
|
|
20
|
+
* A file is not one thing: a context module can also export the hook that reads it, and a
|
|
21
|
+
* provider is a component that supplies a context. `kind` is the one a list puts it under;
|
|
22
|
+
* `roles` is every fact that holds. Both are derived from declarations, not filenames.
|
|
23
|
+
*/
|
|
24
|
+
export type PartRole = "component" | "hook" | "context" | "provider" | "barrel" | "route" | "module";
|
|
25
|
+
/** One top-level declaration, the unit a role is read from. Raw material for rules. */
|
|
26
|
+
export interface CatalogDeclaration {
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly kind: "function" | "class" | "variable" | "type";
|
|
29
|
+
readonly exported: boolean;
|
|
30
|
+
readonly renders: boolean;
|
|
31
|
+
readonly calls: ReadonlyArray<string>;
|
|
32
|
+
readonly objectKeys?: ReadonlyArray<string>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* One composition feature: the provider/context/hook pattern as the tree attempts it.
|
|
36
|
+
*
|
|
37
|
+
* This is a derived view over parts — a context in a directory plus a provider or a
|
|
38
|
+
* dot-notation barrel — not a stored classification. It exists so a consumer can read a
|
|
39
|
+
* feature as one thing without re-joining the declarations itself.
|
|
40
|
+
*/
|
|
41
|
+
export interface CatalogFeature {
|
|
42
|
+
/** Repository-relative directory the parts share. */
|
|
43
|
+
readonly dir: string;
|
|
44
|
+
/** The public name: the barrel's object name, else a PascalCase directory. */
|
|
45
|
+
readonly name: string;
|
|
46
|
+
/** The module that calls `createContext`. */
|
|
47
|
+
readonly context: string;
|
|
48
|
+
readonly provider?: string;
|
|
49
|
+
readonly barrel?: string;
|
|
50
|
+
/** Component modules in the feature that are not the context, provider, or barrel. */
|
|
51
|
+
readonly blocks: ReadonlyArray<string>;
|
|
52
|
+
readonly hooks: ReadonlyArray<string>;
|
|
53
|
+
/** Keys of the provider's supplied value; `state/actions/meta` when tripartite. */
|
|
54
|
+
readonly valueKeys: ReadonlyArray<string>;
|
|
55
|
+
}
|
|
56
|
+
/** One component as the crawler classified it. */
|
|
57
|
+
export interface CatalogComponent extends ComponentFields {
|
|
58
|
+
/**
|
|
59
|
+
* The part's stable identity: its repository-relative path without the source
|
|
60
|
+
* extension, with `/` flattened to `--`. `name` is for reading; this is for joining.
|
|
61
|
+
*
|
|
62
|
+
* Optional because catalogs written before ids landed carry none. A reader falls back
|
|
63
|
+
* to `name` — the old join — so a stale artifact degrades rather than disappears.
|
|
64
|
+
*/
|
|
65
|
+
readonly id?: string;
|
|
66
|
+
/** The role a list puts this part under. Optional: older catalogs called everything a component. */
|
|
67
|
+
readonly kind?: PartRole;
|
|
68
|
+
/** Every role the part carries, of which `kind` is the first by convention. */
|
|
69
|
+
readonly roles?: ReadonlyArray<PartRole>;
|
|
70
|
+
/** The directory of the composition feature this part belongs to, when it is in one. */
|
|
71
|
+
readonly feature?: string;
|
|
72
|
+
/** The public names a consumer imports from this module, types excluded. */
|
|
73
|
+
readonly exports?: ReadonlyArray<string>;
|
|
74
|
+
/** How many modules import it. Inventory says it exists; this says it is used. */
|
|
75
|
+
readonly usedBy?: number;
|
|
76
|
+
/** Top-level declarations. The raw material a rule reads instead of re-parsing source. */
|
|
77
|
+
readonly declarations?: ReadonlyArray<CatalogDeclaration>;
|
|
78
|
+
/**
|
|
79
|
+
* The parts this one renders, resolved through its own imports and in source order.
|
|
80
|
+
*
|
|
81
|
+
* Optional: a catalog written before edges landed has none, and a part that renders no
|
|
82
|
+
* catalog part (a wrapper around a host element, a leaf primitive) carries none either.
|
|
83
|
+
* Absent means "no edge", never "unknown" — `tags` still records every name.
|
|
84
|
+
*/
|
|
85
|
+
readonly renders?: ReadonlyArray<RenderEdge>;
|
|
86
|
+
/**
|
|
87
|
+
* The behavioral skeleton: the headless primitive it wraps, the headless
|
|
88
|
+
* sub-components it renders, the hooks it calls, and its token-class categories.
|
|
89
|
+
*
|
|
90
|
+
* This — not props ∪ tags — is the similarity signature. Props are surface area,
|
|
91
|
+
* and two components can share almost none of it while being the same concept (the
|
|
92
|
+
* `Combobox`/`ComboBoxV2` pair scores ~0.18 on props and ~1.0 on skeleton).
|
|
93
|
+
*/
|
|
94
|
+
readonly signature: ReadonlyArray<string>;
|
|
95
|
+
/** Whether the source carries a documentation block the catalog could read. */
|
|
96
|
+
readonly documented: boolean;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* One JSX element the part renders, resolved to a catalog part.
|
|
100
|
+
*
|
|
101
|
+
* `tags` is a bag of names: `<Link>` (the router's), `<Button>` (the primitive), and
|
|
102
|
+
* `<StatusStepper>` (a local part) are the same kind of string there. Which part a tag
|
|
103
|
+
* means is a fact about the file's imports, and the crawler already resolved those for the
|
|
104
|
+
* use-graph — so the render edge costs one lookup, not a second analysis.
|
|
105
|
+
*
|
|
106
|
+
* The edge points at the part, not at the export: a cutlist part is a module, so a binding
|
|
107
|
+
* that resolves to `./button.tsx` names that part however the call site spells it.
|
|
108
|
+
*/
|
|
109
|
+
export interface RenderEdge {
|
|
110
|
+
/** The path of the part rendered. */
|
|
111
|
+
readonly part: string;
|
|
112
|
+
/** The tag as written, including a member expression: `Combobox.Input`. */
|
|
113
|
+
readonly tag: string;
|
|
114
|
+
/** One-based line in the rendering module. The first site, when a part renders twice. */
|
|
115
|
+
readonly line: number;
|
|
116
|
+
/** How many sites in the module render it. */
|
|
117
|
+
readonly count: number;
|
|
118
|
+
}
|
|
119
|
+
/** Two components the crawler proposes as near-duplicates, for a judge to confirm. */
|
|
120
|
+
export interface DuplicateCandidate {
|
|
121
|
+
readonly left: string;
|
|
122
|
+
readonly right: string;
|
|
123
|
+
readonly score: number;
|
|
124
|
+
readonly basis: "skeleton";
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A connected group of near-duplicates, with the most-used member as the canonical.
|
|
128
|
+
*
|
|
129
|
+
* A pair is a finding; a cluster is a decision. When three variants of one dialog exist,
|
|
130
|
+
* the useful question is not "are these two the same?" but "which one is the system, and
|
|
131
|
+
* why were the others written?" The canonical is chosen by adoption rather than by file
|
|
132
|
+
* order, because the version people already import is the one a migration should keep.
|
|
133
|
+
*/
|
|
134
|
+
export interface DuplicateCluster {
|
|
135
|
+
/** The path of the member with the most importers. */
|
|
136
|
+
readonly canonical: string;
|
|
137
|
+
/** The canonical's name, for a heading a person can read. */
|
|
138
|
+
readonly name: string;
|
|
139
|
+
readonly members: ReadonlyArray<string>;
|
|
140
|
+
/** The strongest pair in the cluster. */
|
|
141
|
+
readonly score: number;
|
|
142
|
+
/** Summed importers across every member; the size of the workaround. */
|
|
143
|
+
readonly usedBy: number;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The adoption facts a catalog can know without reading authored intent.
|
|
147
|
+
*
|
|
148
|
+
* `sharedReach` is a ratio rather than a count because the denominator is the thing that
|
|
149
|
+
* grows: a repo with a thousand local pages and ten shared imports is not healthier than
|
|
150
|
+
* a smaller one, and a count would reward the wrong direction. The denominator is the
|
|
151
|
+
* modules OUTSIDE the shared layer: the library importing itself is not adoption.
|
|
152
|
+
*/
|
|
153
|
+
export interface CatalogHealth {
|
|
154
|
+
readonly parts: number;
|
|
155
|
+
/** Share of component/hook/route modules outside the shared layer that import a shared part. */
|
|
156
|
+
readonly sharedReach: number;
|
|
157
|
+
/** Adopter modules that import no shared or primitive part. */
|
|
158
|
+
readonly localOnly: number;
|
|
159
|
+
readonly duplicateClusters: number;
|
|
160
|
+
}
|
|
161
|
+
/** The token vocabulary, as four closed sets. */
|
|
162
|
+
export interface CatalogTokens {
|
|
163
|
+
readonly colors: ReadonlyArray<string>;
|
|
164
|
+
readonly type: ReadonlyArray<string>;
|
|
165
|
+
readonly shape: ReadonlyArray<string>;
|
|
166
|
+
readonly spacing: ReadonlyArray<string>;
|
|
167
|
+
}
|
|
168
|
+
/** The whole model. */
|
|
169
|
+
export interface Catalog {
|
|
170
|
+
readonly lexicon: LexiconRef;
|
|
171
|
+
/** Content hash of everything below. `--check` compares it against the tree. */
|
|
172
|
+
readonly hash: string;
|
|
173
|
+
readonly root: string;
|
|
174
|
+
readonly tokens: CatalogTokens;
|
|
175
|
+
readonly tiers: Tiers;
|
|
176
|
+
readonly sharedRoots: ReadonlyArray<string>;
|
|
177
|
+
readonly localRoots: ReadonlyArray<string>;
|
|
178
|
+
readonly components: ReadonlyArray<CatalogComponent>;
|
|
179
|
+
/** Composition features, derived from parts. Absent in catalogs that predate them. */
|
|
180
|
+
readonly features?: ReadonlyArray<CatalogFeature>;
|
|
181
|
+
/** Adoption and duplication pressure. Absent in catalogs that predate them. */
|
|
182
|
+
readonly health?: CatalogHealth;
|
|
183
|
+
/** Near-duplicate clusters, derived from the candidate pairs. */
|
|
184
|
+
readonly clusters?: ReadonlyArray<DuplicateCluster>;
|
|
185
|
+
readonly orphans: ReadonlyArray<string>;
|
|
186
|
+
readonly duplicates: ReadonlyArray<DuplicateCandidate>;
|
|
187
|
+
}
|
|
188
|
+
/** A component as the lint manifest carries it. */
|
|
189
|
+
export interface ManifestComponent extends ComponentFields {
|
|
190
|
+
/** What it is. A rule can scope itself to components without re-deriving the role. */
|
|
191
|
+
readonly kind?: PartRole;
|
|
192
|
+
readonly roles?: ReadonlyArray<PartRole>;
|
|
193
|
+
/** The composition feature's directory, when it belongs to one. */
|
|
194
|
+
readonly feature?: string;
|
|
195
|
+
/** The names a consumer imports, so a rule can match an import binding to a part. */
|
|
196
|
+
readonly exports?: ReadonlyArray<string>;
|
|
197
|
+
readonly usedBy?: number;
|
|
198
|
+
/** Authored lifecycle. A rule can refuse a direct import of a retired part. */
|
|
199
|
+
readonly status?: PartStatus;
|
|
200
|
+
/** Authored migration target, carried to the rule that reports the import. */
|
|
201
|
+
readonly useInstead?: ReadonlyArray<string>;
|
|
202
|
+
/** Carried so a reader CAN use the corrected metric; older readers ignore it. */
|
|
203
|
+
readonly signature?: ReadonlyArray<string>;
|
|
204
|
+
}
|
|
205
|
+
/** The manifest `plumb-ui` parses. */
|
|
206
|
+
export interface UiManifest {
|
|
207
|
+
readonly lexicon: LexiconRef;
|
|
208
|
+
readonly colors: ReadonlyArray<string>;
|
|
209
|
+
readonly sharedRoots: ReadonlyArray<string>;
|
|
210
|
+
readonly localRoots: ReadonlyArray<string>;
|
|
211
|
+
readonly components: ReadonlyArray<ManifestComponent>;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Project the catalog onto the lint manifest. One source, one lookup table.
|
|
215
|
+
*
|
|
216
|
+
* Intent is optional because the catalog is derived and the manifest is a projection:
|
|
217
|
+
* a caller that has not read `intent/` still gets a valid manifest, just one whose rules
|
|
218
|
+
* cannot see a retirement. The caller that HAS read it passes the same map the menu uses,
|
|
219
|
+
* so a rule and a person never disagree about which part is retired.
|
|
220
|
+
*/
|
|
221
|
+
export declare const projectManifest: (catalog: Catalog, intent: ReadonlyMap<string, Intent> | undefined) => UiManifest;
|
|
222
|
+
/** The signature a component is compared by. */
|
|
223
|
+
export declare const signatureOf: (component: CatalogComponent) => ReadonlySet<string>;
|
|
224
|
+
/**
|
|
225
|
+
* React's own mechanics, not the part's domain.
|
|
226
|
+
*
|
|
227
|
+
* `useState`/`useEffect`/`useRef` are the frame every interactive component is built in,
|
|
228
|
+
* exactly like a host `<div>`. Two components that share only those are not thereby the same
|
|
229
|
+
* concept, and keeping them made a page of generic hook matches score 1.0 and swamp the real
|
|
230
|
+
* duplicates. They stay in the catalog signature — an agent may want them — but not in the
|
|
231
|
+
* signature a similarity question compares.
|
|
232
|
+
*
|
|
233
|
+
* The set lives in the format rather than in `cutlist` because the duplicate join and the
|
|
234
|
+
* `similar` query must answer by the same metric; a second copy is a second opinion.
|
|
235
|
+
*/
|
|
236
|
+
export declare const INCIDENTAL_HOOKS: ReadonlySet<string>;
|
|
237
|
+
/** The signature a similarity question compares: the part's composition, not React's frame. */
|
|
238
|
+
export declare const comparableSignatureOf: (signature: ReadonlyArray<string>) => ReadonlySet<string>;
|
|
239
|
+
/**
|
|
240
|
+
* Jaccard overlap of two signatures.
|
|
241
|
+
*
|
|
242
|
+
* Two empty signatures are NOT similar: an undocumented component with no recognisable
|
|
243
|
+
* skeleton should match nothing, not everything.
|
|
244
|
+
*/
|
|
245
|
+
export declare const similarityOf: ({ left, right, }: {
|
|
246
|
+
readonly left: ReadonlySet<string>;
|
|
247
|
+
readonly right: ReadonlySet<string>;
|
|
248
|
+
}) => number;
|
|
249
|
+
/** The nearest same-or-higher-tier twin of a component, at or above a threshold. */
|
|
250
|
+
export declare const nearestDuplicate: (catalog: Catalog, subject: CatalogComponent, threshold: number) => DuplicateCandidate | null;
|
|
251
|
+
/** An empty catalog, for a project that generates none. Every consumer degrades to silence. */
|
|
252
|
+
export declare const emptyCatalog: (root: string) => Catalog;
|
|
253
|
+
export declare const PART_ROLES: ReadonlyArray<PartRole>;
|
|
254
|
+
/** Read one feature record, or `undefined` when it is not one. */
|
|
255
|
+
export declare const decodeFeature: (value: unknown) => CatalogFeature | undefined;
|
|
256
|
+
/** Read a health block, or `undefined` when malformed. */
|
|
257
|
+
export declare const decodeHealth: (value: unknown) => CatalogHealth | undefined;
|
|
258
|
+
/** Read one duplicate cluster, or `undefined` when malformed. */
|
|
259
|
+
export declare const decodeCluster: (value: unknown) => DuplicateCluster | undefined;
|
|
260
|
+
/** Read one render edge, or `undefined` when malformed. */
|
|
261
|
+
export declare const decodeRenderEdge: (value: unknown) => RenderEdge | undefined;
|
|
262
|
+
/** Read one component, or `undefined` when malformed. */
|
|
263
|
+
export declare const decodeCatalogComponent: (value: unknown) => CatalogComponent | undefined;
|
|
264
|
+
/** Read one duplicate candidate, or `undefined` when malformed. */
|
|
265
|
+
export declare const decodeDuplicate: (value: unknown) => DuplicateCandidate | undefined;
|
|
266
|
+
/** Read a catalog, or `undefined` when the whole model is malformed. */
|
|
267
|
+
export declare const decodeCatalog: (value: unknown) => Catalog | undefined;
|
|
268
|
+
/** Read one manifest component, or `undefined` when malformed. */
|
|
269
|
+
export declare const decodeManifestComponent: (value: unknown) => ManifestComponent | undefined;
|
|
270
|
+
/** The empty manifest, for a project that generates none. `plumb-ui`'s fail-open value. */
|
|
271
|
+
export declare const EMPTY_MANIFEST: UiManifest;
|
|
272
|
+
/** Read the manifest, degrading to the empty one — the shape `plumb` already reads. */
|
|
273
|
+
export declare const decodeManifest: (value: unknown) => UiManifest;
|
|
274
|
+
export {};
|
|
275
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAe,KAAK,KAAK,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,EAAiB,KAAK,MAAM,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AAYzE,mGAAmG;AACnG,UAAU,eAAe;IACvB,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,E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