ultra11y 5.56.2 → 5.57.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.opencode/plugins/ultra11y.js +201 -34
- package/README.md +6 -5
- package/package.json +3 -1
- package/scripts/ultra11y.mjs +122 -38
- package/scripts/verify-skill-bundle.mjs +11 -1
- package/skills/review-a11y/SKILL.md +1 -1
- package/skills/review-a11y/scripts/ultra11y.mjs +122 -38
- package/skills/ultra11y/SKILL.md +2 -2
- package/skills/ultra11y/references/harnesses.md +23 -7
- package/skills/ultra11y/scripts/ultra11y.mjs +122 -38
- package/skills/ultra11y/templates/gitlab-ci.yml +1 -1
- package/src/cli.ts +18 -2
- package/src/install/index.ts +15 -3
- package/src/install/opencode.ts +148 -37
- package/src/types.ts +1 -1
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"name": "ultra11y",
|
|
11
11
|
"source": "./",
|
|
12
12
|
"description": "RGAA 4.1.2 accessibility audits on a WCAG 2.2 AA core: automatic review before commit, push and pull request, plus dated, evidenced Markdown, HTML and per-page conformance reports in Claude Code.",
|
|
13
|
-
"version": "5.
|
|
13
|
+
"version": "5.57.0",
|
|
14
14
|
"author": { "name": "maxgfr" },
|
|
15
15
|
"homepage": "https://github.com/SocialGouv/ultra11y",
|
|
16
16
|
"repository": "https://github.com/SocialGouv/ultra11y",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ultra11y",
|
|
3
3
|
"description": "RGAA 4.1.2 accessibility audits, the French State's standard, on a WCAG 2.2 AA core: automatic review before commit, push and pull request, plus dated, evidenced Markdown, HTML and per-page conformance reports. Never declares conforming what it has not verified.",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.57.0",
|
|
5
5
|
"author": { "name": "maxgfr" },
|
|
6
6
|
"homepage": "https://github.com/SocialGouv/ultra11y",
|
|
7
7
|
"repository": "https://github.com/SocialGouv/ultra11y",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ultra11y",
|
|
3
3
|
"description": "RGAA 4.1.2 accessibility audits, the French State's standard, on a WCAG 2.2 AA core: automatic review before commit, push and pull request, plus dated, evidenced Markdown, HTML and per-page conformance reports. Never declares conforming what it has not verified.",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.57.0",
|
|
5
5
|
"author": { "name": "maxgfr", "url": "https://github.com/maxgfr" },
|
|
6
6
|
"homepage": "https://github.com/SocialGouv/ultra11y",
|
|
7
7
|
"repository": "https://github.com/SocialGouv/ultra11y",
|
|
@@ -7,27 +7,46 @@
|
|
|
7
7
|
// the cost of a string test on each shell call, and the 2.5 MB engine is spawned only once
|
|
8
8
|
// something could possibly be a publishing command.
|
|
9
9
|
//
|
|
10
|
+
// ONE FILE, BOTH MAJORS. OpenCode 1 and OpenCode 2 read different things from this module:
|
|
11
|
+
//
|
|
12
|
+
// - OpenCode 2 reads the default export's `{ id, setup(ctx) }` and nothing else. `setup`
|
|
13
|
+
// registers the gate with `ctx.tool.hook("execute.before")` and the two skills with
|
|
14
|
+
// `ctx.skill.transform`.
|
|
15
|
+
// - OpenCode 1 ≥ 1.18.28 sees a default object carrying `server()` and calls ONLY that —
|
|
16
|
+
// the named exports are then ignored, so the gate is registered once.
|
|
17
|
+
// - Older OpenCode 1 calls every export that is a function (or an object's `server`), so
|
|
18
|
+
// it reaches the same `Ultra11yPlugin` twice. `oncePerCall` below makes the second
|
|
19
|
+
// registration a no-op on the same tool call, so the engine still runs once per call.
|
|
20
|
+
//
|
|
21
|
+
// The module therefore exports FUNCTIONS ONLY besides `default`: an old V1 loader throws
|
|
22
|
+
// "Plugin export is not a function" on any other value, and that kills the whole plugin.
|
|
23
|
+
//
|
|
10
24
|
// TWO RULES, the same two that govern src/hook.ts.
|
|
11
25
|
//
|
|
12
26
|
// 1. NEVER break a session. Every unexpected condition — no engine, spawn failure,
|
|
13
|
-
// timeout, unreadable output
|
|
14
|
-
//
|
|
15
|
-
// can never surface to the user
|
|
27
|
+
// timeout, unreadable output, a host API that is missing or shaped differently — is a
|
|
28
|
+
// silent no-op. The single `throw` in each entry point is our own decision and nothing
|
|
29
|
+
// else; the try/catch closes BEFORE it, so a bug in here can never surface to the user
|
|
30
|
+
// as a blocked `git push`.
|
|
16
31
|
// 2. NEVER loop. The anti-loop marker lives in the engine (loopKey/firstSighting in
|
|
17
32
|
// src/hook.ts) and keys on the session id, so passing OpenCode's sessionID through is
|
|
18
33
|
// all that is required: one review per state of the change, exactly as on Claude Code.
|
|
19
34
|
//
|
|
20
|
-
// Zero dependencies, `node:` builtins only — it is loaded straight from disk by OpenCode
|
|
35
|
+
// Zero dependencies, `node:` builtins only — it is loaded straight from disk by OpenCode,
|
|
36
|
+
// and OpenCode 2 refuses to resolve `@opencode/plugin` from a plugin's own node_modules.
|
|
21
37
|
import { spawnSync } from "node:child_process";
|
|
22
|
-
import { existsSync } from "node:fs";
|
|
38
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
23
39
|
import { homedir } from "node:os";
|
|
24
|
-
import { dirname, join } from "node:path";
|
|
40
|
+
import { dirname, isAbsolute, join } from "node:path";
|
|
25
41
|
import { fileURLToPath } from "node:url";
|
|
26
42
|
|
|
27
43
|
// Ownership marker: `ultra11y install --opencode` refuses to overwrite a plugin file that
|
|
28
|
-
// does not carry it, so a user's own ultra11y.js is never clobbered.
|
|
44
|
+
// does not carry it, so a user's own ultra11y.js is never clobbered. Kept as text, not as
|
|
45
|
+
// an export (see above).
|
|
29
46
|
const ULTRA11Y_OPENCODE_PLUGIN = "ULTRA11Y_OPENCODE_PLUGIN";
|
|
30
|
-
const ULTRA11Y_PLUGIN_VERSION = "5.
|
|
47
|
+
const ULTRA11Y_PLUGIN_VERSION = "5.57.0";
|
|
48
|
+
const PLUGIN_ID = "ultra11y";
|
|
49
|
+
const SKILL_NAMES = ["ultra11y", "review-a11y"];
|
|
31
50
|
|
|
32
51
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
33
52
|
|
|
@@ -44,12 +63,117 @@ function resolveEngine() {
|
|
|
44
63
|
return null;
|
|
45
64
|
}
|
|
46
65
|
|
|
66
|
+
/** The directory holding the two skills, or null: the package's own `skills/` on the
|
|
67
|
+
* npm/checkout route, or `<configDir>/skills/` where `install --opencode` copies them. */
|
|
68
|
+
function resolveSkillsDir() {
|
|
69
|
+
for (const d of [join(here, "..", "..", "skills"), join(here, "..", "skills")]) {
|
|
70
|
+
if (SKILL_NAMES.every((n) => existsSync(join(d, n, "SKILL.md")))) return d;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The Node to run the engine with. Inside OpenCode `process.execPath` is NOT node: both
|
|
76
|
+
* majors ship as a Bun-compiled binary, and `<opencode> engine.mjs hook` prints
|
|
77
|
+
* OpenCode's own CLI help — which would then be thrown at the agent as a "finding". So
|
|
78
|
+
* under Bun the engine runs on the `node` from PATH; a missing node is a spawn error,
|
|
79
|
+
* and a spawn error is silence (rule 1). */
|
|
80
|
+
function nodeRuntime() {
|
|
81
|
+
if (process.env.ULTRA11Y_NODE) return process.env.ULTRA11Y_NODE;
|
|
82
|
+
return process.versions?.bun ? "node" : process.execPath;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Every block the engine emits starts with this (src/hook.ts). Anything else on stdout is
|
|
86
|
+
* not a decision of ours, and blocking a `git push` with it would break the session. */
|
|
87
|
+
const DECISION_PREFIX = "ultra11y:";
|
|
88
|
+
|
|
47
89
|
/** Same literal as hooks/pre-tool-use.mjs — tests/harness-sync.test.ts asserts they match,
|
|
48
90
|
* because two prefilters that disagree mean one harness silently reviews less. */
|
|
49
91
|
const PREFILTER = /\bgit\b|\bgh\b/;
|
|
50
92
|
|
|
93
|
+
/** `bash` on both majors; `shell` is accepted too, should a release rename it. */
|
|
94
|
+
const isShell = (tool) => /^(?:bash|shell)$/i.test(String(tool ?? ""));
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The decision, shared by both entry points: the text to block with, or "" to let the call
|
|
98
|
+
* through. NEVER throws — rule 1 — whatever the host hands in.
|
|
99
|
+
*/
|
|
100
|
+
function review({ tool, args, directory, sessionID }) {
|
|
101
|
+
try {
|
|
102
|
+
if (!isShell(tool)) return "";
|
|
103
|
+
const command = args?.command;
|
|
104
|
+
if (typeof command !== "string" || !PREFILTER.test(command)) return "";
|
|
105
|
+
if (process.env.SKIP_A11Y || process.env.ULTRA11Y_HOOK === "off") return "";
|
|
106
|
+
|
|
107
|
+
const engine = resolveEngine();
|
|
108
|
+
if (!engine) return "";
|
|
109
|
+
|
|
110
|
+
// A `workdir` argument is where the command really runs; otherwise the plugin's own
|
|
111
|
+
// location is the best answer the host gives.
|
|
112
|
+
const workdir = typeof args?.workdir === "string" && isAbsolute(args.workdir) ? args.workdir : null;
|
|
113
|
+
const payload = {
|
|
114
|
+
tool_name: "Bash",
|
|
115
|
+
tool_input: { command },
|
|
116
|
+
cwd: workdir ?? (typeof directory === "string" && directory ? directory : process.cwd()),
|
|
117
|
+
session_id: typeof sessionID === "string" && sessionID ? sessionID : `opencode-${process.pid}`,
|
|
118
|
+
};
|
|
119
|
+
const run = spawnSync(nodeRuntime(), [engine, "hook", "--opencode"], {
|
|
120
|
+
input: JSON.stringify(payload),
|
|
121
|
+
encoding: "utf8",
|
|
122
|
+
timeout: 20_000,
|
|
123
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
124
|
+
});
|
|
125
|
+
if (run.error || run.status !== 0) return "";
|
|
126
|
+
const text = (run.stdout ?? "").trim();
|
|
127
|
+
return text.startsWith(DECISION_PREFIX) ? text : "";
|
|
128
|
+
} catch {
|
|
129
|
+
return ""; // unreadable input, spawn failure, timeout — say nothing
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Tool-call ids already reviewed. An old OpenCode 1 can register this plugin twice from
|
|
134
|
+
* one module (named export + default `server`); the second hook must not run the engine
|
|
135
|
+
* again on the same call. Bounded, and best-effort: no id means no de-duplication. */
|
|
136
|
+
const seenCalls = new Set();
|
|
137
|
+
function oncePerCall(callID) {
|
|
138
|
+
if (typeof callID !== "string" || !callID) return true;
|
|
139
|
+
if (seenCalls.has(callID)) return false;
|
|
140
|
+
seenCalls.add(callID);
|
|
141
|
+
if (seenCalls.size > 512) seenCalls.delete(seenCalls.values().next().value);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Read one bundled SKILL.md into the shape OpenCode 2's skill editor takes. The ids and
|
|
146
|
+
* names are branded strings in @opencode/schema, but the brand is type-only — a plain
|
|
147
|
+
* string is what the host stores. Null on anything unexpected. */
|
|
148
|
+
function readSkill(dir, name) {
|
|
149
|
+
try {
|
|
150
|
+
const path = join(dir, name, "SKILL.md");
|
|
151
|
+
const text = readFileSync(path, "utf8");
|
|
152
|
+
const fm = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
|
|
153
|
+
if (!fm) return null;
|
|
154
|
+
const field = (key) => {
|
|
155
|
+
const m = new RegExp(`^${key}:[ \\t]*(.*)$`, "m").exec(fm[1]);
|
|
156
|
+
if (!m) return undefined;
|
|
157
|
+
const raw = m[1].trim();
|
|
158
|
+
if (raw.startsWith('"')) {
|
|
159
|
+
try {
|
|
160
|
+
return JSON.parse(raw);
|
|
161
|
+
} catch {
|
|
162
|
+
return raw.slice(1, -1);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return raw;
|
|
166
|
+
};
|
|
167
|
+
const id = field("name") || name;
|
|
168
|
+
return { id, name: id, description: field("description"), path, content: text.slice(fm[0].length).trim() };
|
|
169
|
+
} catch {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** OpenCode 1 — the plugin function. Also what `server()` returns for V1 ≥ 1.18.28. */
|
|
51
175
|
export const Ultra11yPlugin = async (ctx) => {
|
|
52
|
-
const
|
|
176
|
+
const directory = ctx?.directory ?? ctx?.worktree;
|
|
53
177
|
|
|
54
178
|
return {
|
|
55
179
|
/** Register the two bundled skills so `review-a11y` is invocable by name once the gate
|
|
@@ -57,7 +181,8 @@ export const Ultra11yPlugin = async (ctx) => {
|
|
|
57
181
|
* the user still has the skills via `ultra11y install --opencode`. */
|
|
58
182
|
config: async (config) => {
|
|
59
183
|
try {
|
|
60
|
-
|
|
184
|
+
const skillsDir = resolveSkillsDir();
|
|
185
|
+
if (!skillsDir) return;
|
|
61
186
|
config.skills ??= {};
|
|
62
187
|
config.skills.paths ??= [];
|
|
63
188
|
if (!config.skills.paths.includes(skillsDir)) config.skills.paths.push(skillsDir);
|
|
@@ -67,31 +192,12 @@ export const Ultra11yPlugin = async (ctx) => {
|
|
|
67
192
|
},
|
|
68
193
|
|
|
69
194
|
"tool.execute.before": async (input, output) => {
|
|
70
|
-
let text;
|
|
195
|
+
let text = "";
|
|
71
196
|
try {
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
if (typeof command !== "string" || !PREFILTER.test(command)) return;
|
|
75
|
-
if (process.env.SKIP_A11Y || process.env.ULTRA11Y_HOOK === "off") return;
|
|
76
|
-
|
|
77
|
-
const engine = resolveEngine();
|
|
78
|
-
if (!engine) return;
|
|
79
|
-
|
|
80
|
-
const payload = {
|
|
81
|
-
tool_name: "Bash",
|
|
82
|
-
tool_input: { command },
|
|
83
|
-
cwd: ctx?.directory ?? ctx?.worktree ?? process.cwd(),
|
|
84
|
-
session_id: input?.sessionID ?? `opencode-${process.pid}`,
|
|
85
|
-
};
|
|
86
|
-
const run = spawnSync(process.execPath, [engine, "hook", "--opencode"], {
|
|
87
|
-
input: JSON.stringify(payload),
|
|
88
|
-
encoding: "utf8",
|
|
89
|
-
timeout: 20_000,
|
|
90
|
-
maxBuffer: 8 * 1024 * 1024,
|
|
91
|
-
});
|
|
92
|
-
text = (run.stdout ?? "").trim();
|
|
197
|
+
if (!isShell(input?.tool) || !oncePerCall(input?.callID)) return;
|
|
198
|
+
text = review({ tool: input?.tool, args: output?.args, directory, sessionID: input?.sessionID });
|
|
93
199
|
} catch {
|
|
94
|
-
return;
|
|
200
|
+
return;
|
|
95
201
|
}
|
|
96
202
|
// Outside the try on purpose: this is the ONLY error allowed to reach the agent.
|
|
97
203
|
if (text) throw new Error(text);
|
|
@@ -99,4 +205,65 @@ export const Ultra11yPlugin = async (ctx) => {
|
|
|
99
205
|
};
|
|
100
206
|
};
|
|
101
207
|
|
|
102
|
-
|
|
208
|
+
/** OpenCode 2 — `setup(ctx)`. Each registration is independent and individually wrapped:
|
|
209
|
+
* a host without `ctx.skill` still gets the gate, and the reverse. The registrations are
|
|
210
|
+
* disposed with the plugin's scope; the returned cleanup only makes that explicit. */
|
|
211
|
+
async function setup(ctx) {
|
|
212
|
+
const registrations = [];
|
|
213
|
+
const keep = (r) => {
|
|
214
|
+
if (r && typeof r.dispose === "function") registrations.push(r);
|
|
215
|
+
};
|
|
216
|
+
const directory = ctx?.location?.directory ?? ctx?.location?.project?.directory;
|
|
217
|
+
|
|
218
|
+
try {
|
|
219
|
+
const skillsDir = resolveSkillsDir();
|
|
220
|
+
const skills = skillsDir ? SKILL_NAMES.map((n) => readSkill(skillsDir, n)).filter(Boolean) : [];
|
|
221
|
+
// Read once here: transform callbacks must be synchronous and replayable.
|
|
222
|
+
if (skills.length > 0 && typeof ctx?.skill?.transform === "function") {
|
|
223
|
+
keep(
|
|
224
|
+
await ctx.skill.transform((editor) => {
|
|
225
|
+
try {
|
|
226
|
+
// A copy the user installed under ~/.config/opencode/skills/ wins over ours.
|
|
227
|
+
for (const s of skills) if (!editor.get(s.id)) editor.add({ ...s });
|
|
228
|
+
} catch {
|
|
229
|
+
/* a registry that rejects us leaves the session as it was */
|
|
230
|
+
}
|
|
231
|
+
}),
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
} catch {
|
|
235
|
+
/* the skills are a convenience; never fail the plugin over them */
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
try {
|
|
239
|
+
if (typeof ctx?.tool?.hook === "function") {
|
|
240
|
+
keep(
|
|
241
|
+
await ctx.tool.hook("execute.before", async (event) => {
|
|
242
|
+
let text = "";
|
|
243
|
+
try {
|
|
244
|
+
text = review({ tool: event?.tool, args: event?.input, directory, sessionID: event?.sessionID });
|
|
245
|
+
} catch {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
// Outside the try on purpose: this is the ONLY error allowed to reach the agent.
|
|
249
|
+
if (text) throw new Error(text);
|
|
250
|
+
}),
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
} catch {
|
|
254
|
+
/* no gate is better than a broken session */
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return async () => {
|
|
258
|
+
for (const r of registrations.splice(0)) {
|
|
259
|
+
try {
|
|
260
|
+
await r.dispose();
|
|
261
|
+
} catch {
|
|
262
|
+
/* already gone */
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** The entry both majors read: `setup` for OpenCode 2, `server` for OpenCode 1 ≥ 1.18.28. */
|
|
269
|
+
export default { id: PLUGIN_ID, setup, server: Ultra11yPlugin };
|
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ pull request — you never type the skill's name:
|
|
|
17
17
|
|---|---|
|
|
18
18
|
| **Claude Code** | `/plugin marketplace add SocialGouv/ultra11y` then `/plugin install ultra11y@ultra11y` |
|
|
19
19
|
| **OpenAI Codex CLI** | `codex plugin marketplace add SocialGouv/ultra11y` then `codex plugin add ultra11y@ultra11y` |
|
|
20
|
-
| **OpenCode** | `npx ultra11y install --opencode` — or pin `"
|
|
20
|
+
| **OpenCode** 1.x and 2.x | `npx ultra11y install --opencode` — or pin `"plugins": ["ultra11y@latest"]` in `opencode.json` (OpenCode 1: `"plugin"`) |
|
|
21
21
|
| **Anything else** | `npx ultra11y install --agents-md` (no hook API: see the caveat below) |
|
|
22
22
|
|
|
23
23
|
<sub>Prefer the skills only, without the automatic hook? `npx skills add SocialGouv/ultra11y`
|
|
@@ -87,14 +87,15 @@ so `review-a11y` runs before the work goes out — you never type the skill's na
|
|
|
87
87
|
```
|
|
88
88
|
/plugin marketplace add SocialGouv/ultra11y # Claude Code
|
|
89
89
|
codex plugin marketplace add SocialGouv/ultra11y # Codex CLI
|
|
90
|
-
npx ultra11y install --opencode # OpenCode
|
|
90
|
+
npx ultra11y install --opencode # OpenCode 1.x or 2.x (detected; --opencode-version 1|2)
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
Codex's hook engine is a near-clone of Claude Code's — same events, same envelope, and it
|
|
94
94
|
exports `${CLAUDE_PLUGIN_ROOT}` too — so both harnesses share one `hooks/hooks.json`.
|
|
95
|
-
OpenCode has no permission-decision channel, so there the gate surfaces as a **failed
|
|
96
|
-
call whose error message carries the findings**.
|
|
97
|
-
|
|
95
|
+
OpenCode has no permission-decision channel, so there the gate surfaces as a **failed shell
|
|
96
|
+
call whose error message carries the findings**. One plugin file serves OpenCode 1 and
|
|
97
|
+
OpenCode 2, whose plugin APIs differ: V2 reads its `setup(ctx)`, V1 its `server()`.
|
|
98
|
+
Per-harness deltas, the Codex feature flag and the trust prompt: [`skills/ultra11y/references/harnesses.md`](skills/ultra11y/references/harnesses.md).
|
|
98
99
|
|
|
99
100
|
Four things worth knowing, because they bound what "automatic" means here:
|
|
100
101
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ultra11y",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.57.0",
|
|
4
4
|
"description": "Audit d'accessibilité RGAA 4.1.2, le référentiel de l'État : rapport daté, grille des 106 critères, backlog et tickets. Moteur statique, navigateur et jugement IA contre-vérifié. Il ne déclare jamais conforme ce qu'il n'a pas vérifié. Socle WCAG 2.2 AA.",
|
|
5
5
|
"homepage": "https://socialgouv.github.io/ultra11y/",
|
|
6
6
|
"type": "module",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
".": "./.opencode/plugins/ultra11y.js",
|
|
13
|
+
"./server": "./.opencode/plugins/ultra11y.js",
|
|
13
14
|
"./playwright": {
|
|
14
15
|
"types": "./dist/playwright.d.ts",
|
|
15
16
|
"import": "./dist/playwright.mjs",
|
|
@@ -50,6 +51,7 @@
|
|
|
50
51
|
"test:coverage": "vitest run --coverage",
|
|
51
52
|
"test:perf": "vitest run --config vitest.perf.config.ts",
|
|
52
53
|
"test:browser": "vitest run --config vitest.browser.config.ts",
|
|
54
|
+
"test:opencode": "vitest run --config vitest.opencode.config.ts",
|
|
53
55
|
"bench": "node scripts/bench.mjs",
|
|
54
56
|
"typecheck": "tsc --noEmit",
|
|
55
57
|
"lint": "biome ci .",
|
package/scripts/ultra11y.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { join as join55, relative as relative7, resolve as resolve18, sep as sep
|
|
|
6
6
|
import { fileURLToPath as fileURLToPath6, pathToFileURL as pathToFileURL3 } from "url";
|
|
7
7
|
|
|
8
8
|
// src/types.ts
|
|
9
|
-
var VERSION = "5.
|
|
9
|
+
var VERSION = "5.57.0";
|
|
10
10
|
var SCHEMA_VERSION = 2;
|
|
11
11
|
function isAdjudicated(by) {
|
|
12
12
|
return by === "agent" || by === "human";
|
|
@@ -72291,61 +72291,129 @@ function codexHooksEnabled(codexDir) {
|
|
|
72291
72291
|
}
|
|
72292
72292
|
|
|
72293
72293
|
// src/install/opencode.ts
|
|
72294
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
72294
72295
|
import { existsSync as existsSync36, readFileSync as readFileSync30, rmSync as rmSync8 } from "fs";
|
|
72295
72296
|
import { join as join46 } from "path";
|
|
72296
72297
|
var OPENCODE_MARKER = "ULTRA11Y_OPENCODE_PLUGIN";
|
|
72297
|
-
|
|
72298
|
-
|
|
72298
|
+
var PLUGIN_DIRS = ["plugin", "plugins"];
|
|
72299
|
+
function dirFor(major) {
|
|
72300
|
+
return major === 2 ? "plugins" : "plugin";
|
|
72299
72301
|
}
|
|
72300
|
-
function
|
|
72301
|
-
|
|
72302
|
-
|
|
72302
|
+
function opencodePinKey(major) {
|
|
72303
|
+
return major === 2 ? "plugins" : "plugin";
|
|
72304
|
+
}
|
|
72305
|
+
var pluginFile = (configDir, dir) => join46(configDir, dir, "ultra11y.js");
|
|
72306
|
+
var ours = (path) => existsSync36(path) && readFileSync30(path, "utf8").includes(OPENCODE_MARKER);
|
|
72307
|
+
function parseOpencodeVersion(text) {
|
|
72308
|
+
const m = /\bv?(\d+)\.\d+\.\d+/.exec(text);
|
|
72309
|
+
if (!m) return null;
|
|
72310
|
+
const major = Number(m[1]);
|
|
72311
|
+
if (major === 1) return 1;
|
|
72312
|
+
return major >= 2 ? 2 : null;
|
|
72313
|
+
}
|
|
72314
|
+
var runOpencodeVersion = () => {
|
|
72315
|
+
const r = spawnSync2("opencode", ["--version"], {
|
|
72316
|
+
encoding: "utf8",
|
|
72317
|
+
timeout: 1e4,
|
|
72318
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
72319
|
+
// npm's global shim on Windows is opencode.cmd, which only a shell resolves.
|
|
72320
|
+
shell: process.platform === "win32"
|
|
72321
|
+
});
|
|
72322
|
+
return { status: r.status, stdout: r.stdout ?? "", error: r.error };
|
|
72323
|
+
};
|
|
72324
|
+
function detectOpencodeMajor(run2 = runOpencodeVersion) {
|
|
72325
|
+
try {
|
|
72326
|
+
const r = run2();
|
|
72327
|
+
if (r.error || r.status !== 0) return null;
|
|
72328
|
+
return parseOpencodeVersion(r.stdout);
|
|
72329
|
+
} catch {
|
|
72330
|
+
return null;
|
|
72331
|
+
}
|
|
72332
|
+
}
|
|
72333
|
+
function parseOpencodeMajorFlag(value) {
|
|
72334
|
+
if (value === void 0) return {};
|
|
72335
|
+
const v = typeof value === "string" ? value.trim().replace(/^v/i, "") : "";
|
|
72336
|
+
if (v === "1" || v === "2") return { major: Number(v) };
|
|
72337
|
+
return { error: `--opencode-version takes 1 or 2 (got ${typeof value === "string" ? JSON.stringify(value) : "no value"}).` };
|
|
72338
|
+
}
|
|
72339
|
+
function isUltra11yPin(entry2) {
|
|
72340
|
+
const spec = typeof entry2 === "string" ? entry2 : Array.isArray(entry2) ? entry2[0] : entry2?.package;
|
|
72341
|
+
return typeof spec === "string" && /^ultra11y(@|$)/.test(spec);
|
|
72342
|
+
}
|
|
72343
|
+
function pinnedKeys(configDir) {
|
|
72344
|
+
try {
|
|
72345
|
+
const cfg = JSON.parse(readFileSync30(join46(configDir, "opencode.json"), "utf8"));
|
|
72346
|
+
return ["plugin", "plugins"].filter((k) => Array.isArray(cfg?.[k]) && cfg[k].some(isUltra11yPin));
|
|
72347
|
+
} catch {
|
|
72348
|
+
return [];
|
|
72349
|
+
}
|
|
72350
|
+
}
|
|
72351
|
+
function installOpencode({ configDir, pluginSource, skillsSource, enginePath, major = null }) {
|
|
72352
|
+
const dir = dirFor(major);
|
|
72353
|
+
const target = pluginFile(configDir, dir);
|
|
72354
|
+
if (existsSync36(target) && !ours(target)) {
|
|
72303
72355
|
throw new Error(`refusing to overwrite ${target}: it is not a file ultra11y wrote. Remove it manually if you want the plugin here.`);
|
|
72304
72356
|
}
|
|
72305
72357
|
const reports = [writeTextWithBackup(target, readFileSync30(pluginSource, "utf8"))];
|
|
72358
|
+
const guidance = [];
|
|
72306
72359
|
if (enginePath && existsSync36(enginePath)) {
|
|
72307
|
-
reports.push(writeTextWithBackup(join46(configDir,
|
|
72360
|
+
reports.push(writeTextWithBackup(join46(configDir, dir, "ultra11y.mjs"), readFileSync30(enginePath, "utf8")));
|
|
72308
72361
|
}
|
|
72309
72362
|
if (skillsSource) reports.push(...copySkillsInto(skillsSource, join46(configDir, "skills")));
|
|
72310
|
-
|
|
72311
|
-
|
|
72312
|
-
|
|
72313
|
-
|
|
72314
|
-
|
|
72315
|
-
|
|
72316
|
-
|
|
72317
|
-
}
|
|
72363
|
+
for (const other of PLUGIN_DIRS) {
|
|
72364
|
+
if (other === dir) continue;
|
|
72365
|
+
const stale = pluginFile(configDir, other);
|
|
72366
|
+
if (!ours(stale)) continue;
|
|
72367
|
+
rmSync8(stale, { force: true });
|
|
72368
|
+
rmSync8(join46(configDir, other, "ultra11y.mjs"), { force: true });
|
|
72369
|
+
guidance.push(`opencode: moved the plugin from ${other}/ to ${dir}/ \u2014 it is loaded from one place only.`);
|
|
72370
|
+
}
|
|
72371
|
+
const key2 = opencodePinKey(major);
|
|
72372
|
+
guidance.push(
|
|
72373
|
+
major === null ? "opencode: no `opencode` on PATH to ask its version \u2014 wired plugin/, which OpenCode 1 and 2 both read (pass --opencode-version 1|2 to choose)." : `opencode: wired for OpenCode ${major}.`,
|
|
72374
|
+
"opencode: restart the session \u2014 plugins load at startup.",
|
|
72375
|
+
`opencode: the alternative is an npm pin \u2014 add "${key2}": ["ultra11y@latest"] to ${join46(configDir, "opencode.json")} and drop this file.`,
|
|
72376
|
+
"opencode: the gate surfaces as a blocked tool call whose error message carries the findings (OpenCode has no permission-decision channel)."
|
|
72377
|
+
);
|
|
72378
|
+
const pins = pinnedKeys(configDir);
|
|
72379
|
+
if (pins.length > 0) {
|
|
72380
|
+
guidance.push(`opencode: opencode.json also pins ultra11y under "${pins.join('", "')}" \u2014 remove the pin or this file, or the gate runs twice.`);
|
|
72381
|
+
}
|
|
72382
|
+
return { reports, guidance };
|
|
72318
72383
|
}
|
|
72319
72384
|
function uninstallOpencode({ configDir }) {
|
|
72320
72385
|
const reports = [];
|
|
72321
|
-
const
|
|
72322
|
-
|
|
72386
|
+
for (const dir of PLUGIN_DIRS) {
|
|
72387
|
+
const target = pluginFile(configDir, dir);
|
|
72388
|
+
if (!ours(target)) continue;
|
|
72323
72389
|
rmSync8(target, { force: true });
|
|
72324
|
-
rmSync8(join46(configDir,
|
|
72390
|
+
rmSync8(join46(configDir, dir, "ultra11y.mjs"), { force: true });
|
|
72325
72391
|
reports.push({ path: target, changed: true });
|
|
72326
72392
|
}
|
|
72327
72393
|
const configPath = join46(configDir, "opencode.json");
|
|
72328
72394
|
if (existsSync36(configPath)) {
|
|
72329
72395
|
reports.push(
|
|
72330
72396
|
editJsonFile(configPath, (root) => {
|
|
72331
|
-
|
|
72332
|
-
|
|
72333
|
-
|
|
72334
|
-
|
|
72397
|
+
for (const key2 of ["plugin", "plugins"]) {
|
|
72398
|
+
if (!Array.isArray(root[key2])) continue;
|
|
72399
|
+
const kept = root[key2].filter((p) => !isUltra11yPin(p));
|
|
72400
|
+
if (kept.length > 0) root[key2] = kept;
|
|
72401
|
+
else delete root[key2];
|
|
72402
|
+
}
|
|
72335
72403
|
})
|
|
72336
72404
|
);
|
|
72337
72405
|
}
|
|
72338
72406
|
return { reports, guidance: [] };
|
|
72339
72407
|
}
|
|
72408
|
+
function opencodePluginPath(configDir) {
|
|
72409
|
+
for (const dir of PLUGIN_DIRS) if (ours(pluginFile(configDir, dir))) return pluginFile(configDir, dir);
|
|
72410
|
+
return null;
|
|
72411
|
+
}
|
|
72412
|
+
function opencodePluginTarget(configDir, major) {
|
|
72413
|
+
return pluginFile(configDir, dirFor(major));
|
|
72414
|
+
}
|
|
72340
72415
|
function opencodeWired(configDir) {
|
|
72341
|
-
|
|
72342
|
-
if (existsSync36(target) && readFileSync30(target, "utf8").includes(OPENCODE_MARKER)) return true;
|
|
72343
|
-
try {
|
|
72344
|
-
const cfg = JSON.parse(readFileSync30(join46(configDir, "opencode.json"), "utf8"));
|
|
72345
|
-
return Array.isArray(cfg.plugin) && cfg.plugin.some((p) => /^ultra11y(@|$)/.test(String(p)));
|
|
72346
|
-
} catch {
|
|
72347
|
-
return false;
|
|
72348
|
-
}
|
|
72416
|
+
return opencodePluginPath(configDir) !== null || pinnedKeys(configDir).length > 0;
|
|
72349
72417
|
}
|
|
72350
72418
|
|
|
72351
72419
|
// src/install/index.ts
|
|
@@ -72399,17 +72467,19 @@ function installForTargets(opts) {
|
|
|
72399
72467
|
break;
|
|
72400
72468
|
}
|
|
72401
72469
|
const configDir = opts.project === true ? join47(cwd, ".opencode") : opencodeConfigDir();
|
|
72470
|
+
const major = opts.opencodeVersion ?? detectOpencodeMajor();
|
|
72402
72471
|
if (!opts.dryRun) {
|
|
72403
72472
|
const engine = existsSync37(pinnedEnginePath()) ? pinnedEnginePath() : join47(packageRoot() ?? "", "scripts", "ultra11y.mjs");
|
|
72404
72473
|
const out3 = installOpencode({
|
|
72405
72474
|
configDir,
|
|
72406
72475
|
pluginSource: source,
|
|
72407
72476
|
skillsSource: opts.skills === false ? null : bundledSkillsDir(),
|
|
72408
|
-
enginePath: existsSync37(engine) ? engine : null
|
|
72477
|
+
enginePath: existsSync37(engine) ? engine : null,
|
|
72478
|
+
major
|
|
72409
72479
|
});
|
|
72410
72480
|
r.reports.push(...out3.reports);
|
|
72411
72481
|
r.guidance.push(...out3.guidance);
|
|
72412
|
-
} else r.reports.push({ path:
|
|
72482
|
+
} else r.reports.push({ path: opencodePluginTarget(configDir, major), changed: false });
|
|
72413
72483
|
break;
|
|
72414
72484
|
}
|
|
72415
72485
|
case "agents-md": {
|
|
@@ -72479,7 +72549,7 @@ function statusReport(opts = {}) {
|
|
|
72479
72549
|
// A wired hook behind a disabled feature flag never fires and looks fine. Say so.
|
|
72480
72550
|
note: codexOn && !codexHooksEnabled(codexDir) ? "WIRED BUT INERT: `[features] hooks = true` is not set in config.toml" : void 0
|
|
72481
72551
|
},
|
|
72482
|
-
{ target: "opencode", wired: opencodeWired(ocDir), path:
|
|
72552
|
+
{ target: "opencode", wired: opencodeWired(ocDir), path: opencodePluginPath(ocDir) ?? opencodePluginTarget(ocDir, null) },
|
|
72483
72553
|
{ target: "agents-md", wired: agentsMdWired(root), path: agentsMdPath(root) }
|
|
72484
72554
|
];
|
|
72485
72555
|
}
|
|
@@ -78484,7 +78554,7 @@ Usage:
|
|
|
78484
78554
|
ultra11y import --from file <report.json> | --from ara <id> [--source <adapter>] [--out <dir>] [--json]
|
|
78485
78555
|
ultra11y mcp [--transport stdio|http] [--cwd <dir>] [--allow-write] [--port <n>] [--bind <addr>] [--allow-remote] [--allow-origin <o>] [--max-response-bytes <n>]
|
|
78486
78556
|
ultra11y hook --claude-code|--codex|--opencode (internal: the PreToolUse hook; payload on stdin)
|
|
78487
|
-
ultra11y install --claude-code | --codex | --opencode | --agents-md | --all [--project] [--dry-run] [--no-skills]
|
|
78557
|
+
ultra11y install --claude-code | --codex | --opencode | --agents-md | --all [--project] [--dry-run] [--no-skills] [--opencode-version 1|2]
|
|
78488
78558
|
ultra11y uninstall --claude-code | --codex | --opencode | --agents-md | --all [--project]
|
|
78489
78559
|
ultra11y status [--json] [--project] [--browser [--cwd <dir>]] (doctor: which agents run the review; --browser asks whether the scan tier resolves here)
|
|
78490
78560
|
ultra11y dev [--port <n>] [--root <dir>] [--standard <pack>] [--lang auto|en|fr] (dev side-car: live overlay + per-page dashboard)
|
|
@@ -78930,6 +79000,9 @@ function isCommand(s) {
|
|
|
78930
79000
|
return !!s && COMMANDS.includes(s);
|
|
78931
79001
|
}
|
|
78932
79002
|
var VALUE_FLAGS2 = /* @__PURE__ */ new Set([
|
|
79003
|
+
// `install --opencode --opencode-version 1|2`: the OpenCode major to wire for, instead of
|
|
79004
|
+
// asking the `opencode` on PATH.
|
|
79005
|
+
"opencode-version",
|
|
78933
79006
|
// `judge --refute <VERIFY.todo.json>`: put already-written claims on trial, through the same
|
|
78934
79007
|
// transport the adjudication pass uses.
|
|
78935
79008
|
"refute",
|
|
@@ -79944,7 +80017,18 @@ function cmdInstall(p) {
|
|
|
79944
80017
|
console.log(agentsMdBlock(repoRoot() ?? process.cwd()));
|
|
79945
80018
|
if (targets.length === 1) return 0;
|
|
79946
80019
|
}
|
|
79947
|
-
const
|
|
80020
|
+
const oc = parseOpencodeMajorFlag(p.flags["opencode-version"]);
|
|
80021
|
+
if (oc.error) {
|
|
80022
|
+
console.error(`ultra11y install: ${oc.error}`);
|
|
80023
|
+
return 2;
|
|
80024
|
+
}
|
|
80025
|
+
const results = installForTargets({
|
|
80026
|
+
targets,
|
|
80027
|
+
project: p.flags.project === true,
|
|
80028
|
+
dryRun,
|
|
80029
|
+
skills: p.flags["no-skills"] !== true,
|
|
80030
|
+
opencodeVersion: oc.major
|
|
80031
|
+
});
|
|
79948
80032
|
return reportInstall(results, dryRun ? "would wire" : "wired");
|
|
79949
80033
|
}
|
|
79950
80034
|
function cmdUninstall(p) {
|
|
@@ -81941,13 +82025,13 @@ function diffAgainstExternal(p, result, scope, standard, lang, file) {
|
|
|
81941
82025
|
console.error(`ultra11y pages --diff: the imported audit is keyed by "${ext2.standard}" but --standard is "${standard}".`);
|
|
81942
82026
|
return 2;
|
|
81943
82027
|
}
|
|
81944
|
-
const
|
|
82028
|
+
const ours2 = /* @__PURE__ */ new Map();
|
|
81945
82029
|
for (const page of derivePages(result, scope)) {
|
|
81946
82030
|
const m = /* @__PURE__ */ new Map();
|
|
81947
82031
|
for (const c2 of pageCriterionRows(result, page, standard, lang)) m.set(c2.id, c2.status);
|
|
81948
|
-
|
|
82032
|
+
ours2.set(page.id, m);
|
|
81949
82033
|
}
|
|
81950
|
-
const d = diffSides({ byPage:
|
|
82034
|
+
const d = diffSides({ byPage: ours2 }, sideOfExternal(ext2));
|
|
81951
82035
|
if (p.flags.json) {
|
|
81952
82036
|
console.log(JSON.stringify({ standard, external: ext2.source, ...d }, null, 2));
|
|
81953
82037
|
return 0;
|
|
@@ -292,7 +292,11 @@ if (!existsSync(ocPath)) bad(`missing ${OC_REL} — OpenCode would have no plugi
|
|
|
292
292
|
else {
|
|
293
293
|
const src = readFileSync(ocPath, "utf8");
|
|
294
294
|
src.includes("ULTRA11Y_OPENCODE_PLUGIN") ? ok("plugin carries the ownership marker") : bad(`${OC_REL} has no ULTRA11Y_OPENCODE_PLUGIN marker — the installer would refuse to manage it`);
|
|
295
|
-
src.includes('"tool.execute.before"') ? ok("plugin declares tool.execute.before") : bad(`${OC_REL} declares no "tool.execute.before" — nothing would gate a commit`);
|
|
295
|
+
src.includes('"tool.execute.before"') ? ok("plugin declares tool.execute.before (OpenCode 1)") : bad(`${OC_REL} declares no "tool.execute.before" — nothing would gate a commit on OpenCode 1`);
|
|
296
|
+
src.includes('ctx.tool.hook("execute.before"') ? ok("plugin registers execute.before (OpenCode 2)") : bad(`${OC_REL} never calls ctx.tool.hook("execute.before") — nothing would gate a commit on OpenCode 2`);
|
|
297
|
+
/^export default \{ id: PLUGIN_ID, setup, server: Ultra11yPlugin \};$/m.test(src)
|
|
298
|
+
? ok("plugin default-exports { id, setup, server } — read by both majors")
|
|
299
|
+
: bad(`${OC_REL} must default-export { id: PLUGIN_ID, setup, server: Ultra11yPlugin }: OpenCode 2 reads setup(), OpenCode 1 ≥ 1.18.28 reads server()`);
|
|
296
300
|
|
|
297
301
|
const foreign = [...src.matchAll(/^import .*? from ["']([^"']+)["']/gm)].map((m) => m[1]).filter((s) => !s.startsWith("node:"));
|
|
298
302
|
foreign.length === 0 ? ok("plugin imports only node: builtins") : bad(`${OC_REL} imports ${foreign.join(", ")} — it must stay zero-dependency, it is loaded from outside any node_modules`);
|
|
@@ -307,6 +311,12 @@ else {
|
|
|
307
311
|
// is not in files[] publishes a package whose pin route is broken.
|
|
308
312
|
pkg.main === OC_REL ? ok(`package.json main points at ${OC_REL}`) : bad(`package.json "main" is "${pkg.main ?? "unset"}" — it must be "${OC_REL}" or the opencode.json npm pin cannot resolve the plugin`);
|
|
309
313
|
existsSync(join(root, pkg.main ?? "")) ? ok("package.json main resolves on disk") : bad(`package.json "main" points at a file that does not exist`);
|
|
314
|
+
// OpenCode 2 resolves a `"plugins": ["ultra11y@latest"]` pin through `exports` (`.` or
|
|
315
|
+
// `./server`); OpenCode 1 reads `./server`, then `main`. All of them must be the plugin.
|
|
316
|
+
for (const sub of [".", "./server"]) {
|
|
317
|
+
const target = pkg.exports?.[sub];
|
|
318
|
+
target === `./${OC_REL}` ? ok(`package.json exports["${sub}"] is the plugin`) : bad(`package.json exports["${sub}"] is ${JSON.stringify(target)} — it must be "./${OC_REL}" for an OpenCode npm pin to load the plugin`);
|
|
319
|
+
}
|
|
310
320
|
(pkg.files ?? []).includes(pkg.main?.split("/")[0]) ? ok("package.json files[] carries main's directory") : bad(`package.json "files" is missing "${pkg.main?.split("/")[0]}" — main would not be published`);
|
|
311
321
|
|
|
312
322
|
// Two prefilters that disagree mean one harness silently reviews less than the other.
|