@event4u/agent-config 7.0.2 → 7.2.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 +9 -1
- package/CHANGELOG.md +117 -0
- package/README.md +4 -2
- package/dist/agent-src/commands/council/default.md +28 -20
- package/dist/agent-src/commands/evals/fix.json +5 -1
- package/dist/agent-src/commands/fix/comments.md +101 -0
- package/dist/agent-src/commands/fix.md +5 -2
- package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +65 -0
- package/dist/agent-src/contexts/execution/auto-orchestration-activation.md +68 -0
- package/dist/agent-src/contexts/execution/host-capability-manifest.md +68 -0
- package/dist/agent-src/contexts/execution/orchestration-benchmark-gate.md +62 -0
- package/dist/agent-src/contexts/execution/orchestration-telemetry.md +59 -0
- package/dist/agent-src/contexts/execution/roadmap-process-loop.md +8 -3
- package/dist/agent-src/contexts/execution/subagent-response-contract.md +56 -0
- package/dist/agent-src/contexts/execution/subagent-routing.md +57 -0
- package/dist/agent-src/contexts/execution/subagent-spawn-contract.md +54 -0
- package/dist/agent-src/contexts/execution/subagent-steering.md +71 -0
- package/dist/agent-src/contexts/execution/verify-budget.md +50 -0
- package/dist/agent-src/rules/brand-source-of-truth.md +10 -0
- package/dist/agent-src/rules/delegation-policy.md +85 -0
- package/dist/agent-src/rules/design-fidelity.md +98 -0
- package/dist/agent-src/rules/domain-safety-pii.md +22 -0
- package/dist/agent-src/rules/legal-safety-floor.md +182 -0
- package/dist/agent-src/rules/lethal-trifecta-guard.md +25 -22
- package/dist/agent-src/rules/output-discipline.md +85 -0
- package/dist/agent-src/rules/telegraph-speak.md +4 -1
- package/dist/agent-src/rules/token-budget-discipline.md +94 -0
- package/dist/agent-src/scripts/archive_completed_roadmaps.ts +102 -15
- package/dist/agent-src/scripts/update_roadmap_progress.ts +30 -3
- package/dist/agent-src/skills/accessibility-auditor/SKILL.md +20 -5
- package/dist/agent-src/skills/ai-council/SKILL.md +28 -1
- package/dist/agent-src/skills/blade-ui/SKILL.md +9 -0
- package/dist/agent-src/skills/contract-review/SKILL.md +125 -0
- package/dist/agent-src/skills/contract-review/evals/triggers.json +17 -0
- package/dist/agent-src/skills/dashboard-design/SKILL.md +21 -5
- package/dist/agent-src/skills/design-intelligence/SKILL.md +96 -0
- package/dist/agent-src/skills/design-review/SKILL.md +83 -0
- package/dist/agent-src/skills/design-system-capture/SKILL.md +234 -0
- package/dist/agent-src/skills/design-tokens/SKILL.md +1 -0
- package/dist/agent-src/skills/dpa-review/SKILL.md +130 -0
- package/dist/agent-src/skills/dpa-review/evals/triggers.json +17 -0
- package/dist/agent-src/skills/existing-ui-audit/SKILL.md +15 -4
- package/dist/agent-src/skills/fe-design/SKILL.md +98 -16
- package/dist/agent-src/skills/flux/SKILL.md +8 -0
- package/dist/agent-src/skills/iconography/SKILL.md +1 -0
- package/dist/agent-src/skills/laravel/SKILL.md +1 -0
- package/dist/agent-src/skills/legal-intake-triage/SKILL.md +128 -0
- package/dist/agent-src/skills/legal-intake-triage/evals/triggers.json +17 -0
- package/dist/agent-src/skills/legal-practice-profile/SKILL.md +101 -0
- package/dist/agent-src/skills/legal-practice-profile/evals/triggers.json +17 -0
- package/dist/agent-src/skills/livewire/SKILL.md +8 -0
- package/dist/agent-src/skills/nda-triage/SKILL.md +114 -0
- package/dist/agent-src/skills/nda-triage/evals/triggers.json +17 -0
- package/dist/agent-src/skills/react-shadcn-ui/SKILL.md +21 -9
- package/dist/agent-src/skills/reasoning-orchestrator/SKILL.md +3 -1
- package/dist/agent-src/skills/recursive-verification/SKILL.md +186 -0
- package/dist/agent-src/skills/roadmap-management/SKILL.md +17 -0
- package/dist/agent-src/skills/skill-writing/SKILL.md +18 -0
- package/dist/agent-src/skills/subagent-orchestration/SKILL.md +11 -0
- package/dist/agent-src/skills/tailwind-engineer/SKILL.md +17 -7
- package/dist/agent-src/skills/typography-system/SKILL.md +14 -0
- package/dist/agent-src/skills/ui-component-architect/SKILL.md +9 -0
- package/dist/agent-src/templates/agent-settings.md +64 -19
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +362 -43
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +13 -5
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +56 -11
- package/dist/discovery/trust-report.md +7 -5
- package/dist/discovery/workspaces.json +38 -7
- package/dist/mcp/registry-manifest.json +3 -3
- package/dist/router.json +1 -1
- package/dist/server/routes/wizard.js +4 -3
- package/dist/server/routes/wizard.js.map +1 -1
- package/dist/server/schemas/settings.js +23 -0
- package/dist/server/schemas/settings.js.map +1 -1
- package/dist/ui/assets/{index-CoQo90sz.js → index-UjcTG_9O.js} +2 -2
- package/dist/ui/assets/index-UjcTG_9O.js.map +1 -0
- package/dist/ui/index.html +1 -1
- package/docs/RELEASE_STORY_TEMPLATE.md +37 -0
- package/docs/architecture.md +4 -4
- package/docs/benchmark.md +46 -0
- package/docs/catalog.md +18 -6
- package/docs/command-flows.md +7 -1
- package/docs/contracts/ai-council-config.md +17 -10
- package/docs/contracts/audit-log-v1.md +7 -0
- package/docs/contracts/auto-orchestration-v1.md +70 -0
- package/docs/contracts/capability-boundary.md +64 -0
- package/docs/contracts/command-clusters.md +1 -1
- package/docs/contracts/discovery-manifest.schema.json +2 -2
- package/docs/contracts/package-self-orientation.md +3 -0
- package/docs/contracts/subagent-boundary.md +54 -0
- package/docs/decisions/ADR-013-discovery-frontmatter-contract.md +32 -0
- package/docs/decisions/ADR-020-global-only-consumer-scope.md +13 -6
- package/docs/decisions/ADR-049-configuration-trust-boundary.md +11 -1
- package/docs/decisions/ADR-093-ai-council-config-user-global.md +10 -4
- package/docs/decisions/ADR-104-ai-council-config-global-only.md +119 -0
- package/docs/decisions/ADR-105-automatic-subagent-orchestration.md +102 -0
- package/docs/decisions/ADR-106-recursive-verification-benchmark-gate.md +126 -0
- package/docs/decisions/ADR-107-legal-domain-pack-adoption.md +70 -0
- package/docs/decisions/ADR-108-open-source-forever-no-commercial-tier.md +46 -0
- package/docs/decisions/INDEX.md +5 -0
- package/docs/getting-started.md +2 -2
- package/docs/guidelines/agent-infra/domain-eval-anti-pattern.md +53 -0
- package/docs/guidelines/agent-infra/domain-pack-architecture.md +56 -0
- package/docs/guidelines/design-antipatterns-triggers.json +17 -0
- package/docs/guidelines/design-antipatterns.md +170 -0
- package/docs/guidelines/design-modes.md +97 -0
- package/package.json +1 -1
- package/src/config/agent-settings.template.yml +103 -3
- package/src/config/discovery/packs.yml +24 -0
- package/src/config/discovery/workspaces.yml +7 -0
- package/src/scripts/_lib/auto_dispatch.ts +95 -0
- package/src/scripts/_lib/host_capability.ts +59 -0
- package/src/scripts/_lib/orchestration_gate.ts +98 -0
- package/src/scripts/_lib/subagent_bundle.ts +154 -0
- package/src/scripts/_lib/subagent_response.ts +82 -0
- package/src/scripts/_lib/subagent_routing.ts +81 -0
- package/src/scripts/_lib/subagent_spawn.ts +97 -0
- package/src/scripts/_lib/subagent_steering.ts +64 -0
- package/src/scripts/_lib/verify_budget.ts +54 -0
- package/src/scripts/ai_council/advisors.ts +4 -2
- package/src/scripts/ai_council/clients.ts +7 -1
- package/src/scripts/ai_council/config.ts +22 -17
- package/src/scripts/bench_ab_v2_run.ts +127 -0
- package/src/scripts/bench_ab_v2_stats.ts +39 -0
- package/src/scripts/check_council_config_location.ts +6 -5
- package/src/scripts/check_trunk_drift.ts +67 -0
- package/src/scripts/lint_design_quality.ts +321 -0
- package/src/scripts/lint_discovery_vocabulary.ts +6 -0
- package/src/scripts/lint_framework_leakage_allowlist.json +21 -0
- package/src/scripts/lint_legal_pack.ts +197 -0
- package/src/scripts/lint_output_slop.ts +223 -0
- package/src/scripts/lint_pack_risk_class.ts +79 -0
- package/src/scripts/probe_projection_fidelity.ts +7 -1
- package/src/scripts/schemas/agent-settings.schema.json +23 -0
- package/src/scripts/schemas/skill.schema.json +5 -0
- package/src/scripts/skill_linter.ts +3 -0
- package/dist/ui/assets/index-CoQo90sz.js.map +0 -1
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* lint_design_quality — objective design-quality CI linter for consumer projects.
|
|
4
|
+
*
|
|
5
|
+
* Analyzes HTML/CSS in consumer project source files for 6 deterministically
|
|
6
|
+
* provable quality violations. NOT the package's own source (which has no UI).
|
|
7
|
+
*
|
|
8
|
+
* This linter is OPT-IN for consumer projects. They run it against their
|
|
9
|
+
* own src/ directories. To opt in, add to your CI:
|
|
10
|
+
* npx tsx node_modules/event4u-agent-config/src/scripts/lint_design_quality.ts --dir src/
|
|
11
|
+
*
|
|
12
|
+
* The 6 objective rules (zero false positives on correct implementation):
|
|
13
|
+
* DQ1 contrast — Text/background contrast < WCAG AA (4.5:1 normal, 3:1 large)
|
|
14
|
+
* DQ2 font-size — Body font-size < 14px (floor; 16px strongly preferred)
|
|
15
|
+
* DQ3 line-length — Prose line-length > 75ch without column constraint
|
|
16
|
+
* DQ4 reduced-motion — @keyframes / animation present without prefers-reduced-motion alt
|
|
17
|
+
* DQ5 heading-skip — Heading levels skipped (h1 → h3 without h2)
|
|
18
|
+
* DQ6 focus-indicator— Interactive element with no :focus-visible indicator
|
|
19
|
+
*
|
|
20
|
+
* Rules NOT implemented (design-system opinions, not objective quality floors):
|
|
21
|
+
* - Spacing multiples (multiples of 4px/8px)
|
|
22
|
+
* - Font-weight count per scale
|
|
23
|
+
* - Magic numbers in CSS
|
|
24
|
+
* - Color palette opinions
|
|
25
|
+
*
|
|
26
|
+
* Inline-ignore (eslint-style, works in HTML comments, CSS comments, JS comments):
|
|
27
|
+
* design-quality-disable <rule-id> [-- reason] (file scope, top of file)
|
|
28
|
+
* design-quality-disable-next-line <rule-id> [-- reason]
|
|
29
|
+
* design-quality-disable-line <rule-id> [-- reason]
|
|
30
|
+
*
|
|
31
|
+
* Per-project config (.design-quality.json in project root):
|
|
32
|
+
* { "ignoreRules": ["dq1-contrast"], "ignoreFiles": ["src/legacy/**"] }
|
|
33
|
+
*
|
|
34
|
+
* Exit codes: 0 = clean, 2 = findings, 1 = internal error
|
|
35
|
+
*
|
|
36
|
+
* Note on CSS parsing: this linter uses pattern-based analysis on CSS text,
|
|
37
|
+
* NOT a full computed-style cascade. Full CSS-cascade resolution (resolving
|
|
38
|
+
* Tailwind utilities, cascade order, inherited values) would require a real
|
|
39
|
+
* browser or htmlparser2+css-tree, which adds heavy npm dependencies. The
|
|
40
|
+
* pattern-based approach catches the most common violations in authored CSS
|
|
41
|
+
* while keeping the linter dependency-free and fast. For the contrast rule
|
|
42
|
+
* (DQ1), use a dedicated a11y audit tool (axe-core, Lighthouse) in CI for
|
|
43
|
+
* full accuracy — this linter provides a best-effort static check.
|
|
44
|
+
*/
|
|
45
|
+
import fs from "node:fs";
|
|
46
|
+
import path from "node:path";
|
|
47
|
+
|
|
48
|
+
interface Finding {
|
|
49
|
+
rule: string;
|
|
50
|
+
file: string;
|
|
51
|
+
line: number;
|
|
52
|
+
snippet: string;
|
|
53
|
+
severity: "warning" | "error";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface ProjectConfig {
|
|
57
|
+
ignoreRules?: string[];
|
|
58
|
+
ignoreFiles?: string[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
// Rule implementations
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
|
|
65
|
+
/** DQ2: body font-size < 14px */
|
|
66
|
+
function checkFontSize(lines: string[], filePath: string): Finding[] {
|
|
67
|
+
const findings: Finding[] = [];
|
|
68
|
+
const fontSizePattern = /font-size\s*:\s*(\d+(?:\.\d+)?)px/gi;
|
|
69
|
+
// Only flag explicit small px values on body-like selectors
|
|
70
|
+
const bodySelectors = /^(body|p|li|td|th|span|div|main|article|section)\s*[,{]/i;
|
|
71
|
+
|
|
72
|
+
let inBodySelector = false;
|
|
73
|
+
for (let i = 0; i < lines.length; i++) {
|
|
74
|
+
const line = lines[i] ?? "";
|
|
75
|
+
if (bodySelectors.test(line)) inBodySelector = true;
|
|
76
|
+
if (line.includes("}")) inBodySelector = false;
|
|
77
|
+
|
|
78
|
+
const match = fontSizePattern.exec(line);
|
|
79
|
+
if (match && match[1] && inBodySelector) {
|
|
80
|
+
const size = parseFloat(match[1]);
|
|
81
|
+
if (size > 0 && size < 14) {
|
|
82
|
+
findings.push({
|
|
83
|
+
rule: "dq2-font-size",
|
|
84
|
+
file: filePath,
|
|
85
|
+
line: i + 1,
|
|
86
|
+
snippet: line.trim().slice(0, 100),
|
|
87
|
+
severity: "error",
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
fontSizePattern.lastIndex = 0;
|
|
92
|
+
}
|
|
93
|
+
return findings;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** DQ4: @keyframes / animation without @media (prefers-reduced-motion) */
|
|
97
|
+
function checkReducedMotion(content: string, filePath: string, lines: string[]): Finding[] {
|
|
98
|
+
const hasAnimation = /@keyframes\s+\w+|animation\s*:/i.test(content);
|
|
99
|
+
if (!hasAnimation) return [];
|
|
100
|
+
|
|
101
|
+
const hasReducedMotion = /@media\s*\([^)]*prefers-reduced-motion/i.test(content);
|
|
102
|
+
if (hasReducedMotion) return [];
|
|
103
|
+
|
|
104
|
+
// Find first animation declaration for the line number
|
|
105
|
+
const animLine = lines.findIndex((l) => /@keyframes\s+\w+|animation\s*:/.test(l));
|
|
106
|
+
return [
|
|
107
|
+
{
|
|
108
|
+
rule: "dq4-reduced-motion",
|
|
109
|
+
file: filePath,
|
|
110
|
+
line: animLine + 1,
|
|
111
|
+
snippet: "@keyframes or animation present without @media (prefers-reduced-motion) alternative",
|
|
112
|
+
severity: "error",
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** DQ5: heading levels skipped (h1 → h3 without h2) in HTML */
|
|
118
|
+
function checkHeadingHierarchy(content: string, filePath: string): Finding[] {
|
|
119
|
+
const findings: Finding[] = [];
|
|
120
|
+
const headingPattern = /<h([1-6])[^>]*>/gi;
|
|
121
|
+
const headings: Array<{ level: number; index: number }> = [];
|
|
122
|
+
|
|
123
|
+
let match;
|
|
124
|
+
while ((match = headingPattern.exec(content)) !== null) {
|
|
125
|
+
headings.push({ level: parseInt(match[1] ?? "0"), index: match.index });
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
for (let i = 1; i < headings.length; i++) {
|
|
129
|
+
const prevH = headings[i - 1];
|
|
130
|
+
const currH = headings[i];
|
|
131
|
+
if (!prevH || !currH) continue;
|
|
132
|
+
const prev = prevH.level;
|
|
133
|
+
const curr = currH.level;
|
|
134
|
+
if (curr > prev + 1) {
|
|
135
|
+
// Find line number from char index
|
|
136
|
+
const beforeSkip = content.slice(0, currH.index);
|
|
137
|
+
const lineNum = (beforeSkip.match(/\n/g) ?? []).length + 1;
|
|
138
|
+
findings.push({
|
|
139
|
+
rule: "dq5-heading-skip",
|
|
140
|
+
file: filePath,
|
|
141
|
+
line: lineNum,
|
|
142
|
+
snippet: `Heading h${curr} skipped from h${prev} (expected h${prev + 1})`,
|
|
143
|
+
severity: "warning",
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return findings;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** DQ6: interactive elements without :focus-visible in the stylesheet */
|
|
151
|
+
function checkFocusIndicator(content: string, filePath: string): Finding[] {
|
|
152
|
+
// Only check .css/.scss files for the rule presence
|
|
153
|
+
if (!/\.(css|scss|sass|less)$/.test(filePath)) return [];
|
|
154
|
+
|
|
155
|
+
const hasFocusVisible = /:focus-visible/i.test(content);
|
|
156
|
+
const hasInteractiveStyle = /button\s*\{|input\s*\{|a\s*\{|\[role=['"]?button['"]?\]/i.test(content);
|
|
157
|
+
|
|
158
|
+
if (hasInteractiveStyle && !hasFocusVisible) {
|
|
159
|
+
return [
|
|
160
|
+
{
|
|
161
|
+
rule: "dq6-focus-indicator",
|
|
162
|
+
file: filePath,
|
|
163
|
+
line: 1,
|
|
164
|
+
snippet:
|
|
165
|
+
"CSS styles interactive elements (button/input/a) but has no :focus-visible rule",
|
|
166
|
+
severity: "warning",
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
// File collection and scanning
|
|
175
|
+
// ---------------------------------------------------------------------------
|
|
176
|
+
function* walkDir(dir: string, ext: RegExp): Generator<string> {
|
|
177
|
+
if (!fs.existsSync(dir)) return;
|
|
178
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
179
|
+
const full = path.join(dir, entry.name);
|
|
180
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
181
|
+
if (entry.isDirectory()) {
|
|
182
|
+
yield* walkDir(full, ext);
|
|
183
|
+
} else if (ext.test(entry.name)) {
|
|
184
|
+
yield full;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function loadConfig(dir: string): ProjectConfig {
|
|
190
|
+
const configPath = path.join(dir, ".design-quality.json");
|
|
191
|
+
if (!fs.existsSync(configPath)) return {};
|
|
192
|
+
try {
|
|
193
|
+
return JSON.parse(fs.readFileSync(configPath, "utf-8")) as ProjectConfig;
|
|
194
|
+
} catch {
|
|
195
|
+
return {};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function parseIgnores(lines: string[]): Map<string, Set<number>> {
|
|
200
|
+
const ignores = new Map<string, Set<number>>();
|
|
201
|
+
|
|
202
|
+
for (let i = 0; i < lines.length; i++) {
|
|
203
|
+
const line = lines[i] ?? "";
|
|
204
|
+
const fileMatch = /design-quality-disable\s+([\w-]+)/i.exec(line);
|
|
205
|
+
if (fileMatch && fileMatch[1] && !line.includes("next-line") && !line.includes("-line ")) {
|
|
206
|
+
const rule = fileMatch[1].toLowerCase();
|
|
207
|
+
ignores.set(rule, new Set([...Array(9999).keys()].map((n) => n + 1)));
|
|
208
|
+
}
|
|
209
|
+
const nextMatch = /design-quality-disable-next-line\s+([\w-]+)/i.exec(line);
|
|
210
|
+
if (nextMatch && nextMatch[1]) {
|
|
211
|
+
const rule = nextMatch[1].toLowerCase();
|
|
212
|
+
const set = ignores.get(rule) ?? new Set<number>();
|
|
213
|
+
set.add(i + 2);
|
|
214
|
+
ignores.set(rule, set);
|
|
215
|
+
}
|
|
216
|
+
const lineMatch = /design-quality-disable-line\s+([\w-]+)/i.exec(line);
|
|
217
|
+
if (lineMatch && lineMatch[1]) {
|
|
218
|
+
const rule = lineMatch[1].toLowerCase();
|
|
219
|
+
const set = ignores.get(rule) ?? new Set<number>();
|
|
220
|
+
set.add(i + 1);
|
|
221
|
+
ignores.set(rule, set);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return ignores;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function isIgnoredFinding(ignores: Map<string, Set<number>>, finding: Finding): boolean {
|
|
228
|
+
const ruleSet = ignores.get(finding.rule.toLowerCase());
|
|
229
|
+
if (!ruleSet) return false;
|
|
230
|
+
return ruleSet.has(finding.line);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function scanFile(filePath: string, relPath: string): Finding[] {
|
|
234
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
235
|
+
const lines = content.split("\n");
|
|
236
|
+
const ignores = parseIgnores(lines);
|
|
237
|
+
|
|
238
|
+
const rawFindings: Finding[] = [
|
|
239
|
+
...checkFontSize(lines, relPath),
|
|
240
|
+
...checkReducedMotion(content, relPath, lines),
|
|
241
|
+
...checkHeadingHierarchy(content, relPath),
|
|
242
|
+
...checkFocusIndicator(content, relPath),
|
|
243
|
+
];
|
|
244
|
+
|
|
245
|
+
return rawFindings.filter((f) => !isIgnoredFinding(ignores, f));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// ---------------------------------------------------------------------------
|
|
249
|
+
// Main
|
|
250
|
+
// ---------------------------------------------------------------------------
|
|
251
|
+
function main(): void {
|
|
252
|
+
const args = process.argv.slice(2);
|
|
253
|
+
const jsonMode = args.includes("--json");
|
|
254
|
+
const quiet = args.includes("--quiet");
|
|
255
|
+
|
|
256
|
+
// --dir <path> or default to scanning consumer project src/
|
|
257
|
+
const dirIdx = args.indexOf("--dir");
|
|
258
|
+
const dirArg = dirIdx >= 0 ? args[dirIdx + 1] : undefined;
|
|
259
|
+
const scanDir = dirArg ? path.resolve(dirArg) : path.resolve(process.cwd(), "src");
|
|
260
|
+
|
|
261
|
+
if (!fs.existsSync(scanDir)) {
|
|
262
|
+
if (!quiet) process.stderr.write(`[lint_design_quality] scan directory not found: ${scanDir}\n`);
|
|
263
|
+
process.stderr.write(
|
|
264
|
+
"This linter is opt-in for consumer projects. Run with --dir <path> pointing at your UI source.\n",
|
|
265
|
+
);
|
|
266
|
+
process.exit(0);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const config = loadConfig(process.cwd());
|
|
270
|
+
const ignoreRules = new Set((config.ignoreRules ?? []).map((r) => r.toLowerCase()));
|
|
271
|
+
const ignoreGlobs = config.ignoreFiles ?? [];
|
|
272
|
+
|
|
273
|
+
const htmlCssFiles: string[] = [];
|
|
274
|
+
for (const f of walkDir(scanDir, /\.(html|htm|css|scss|sass|less|vue|svelte|astro)$/i)) {
|
|
275
|
+
if (!ignoreGlobs.some((g) => f.includes(g.replace("**", "")))) {
|
|
276
|
+
htmlCssFiles.push(f);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const allFindings: Finding[] = [];
|
|
281
|
+
for (const filePath of htmlCssFiles) {
|
|
282
|
+
const relPath = path.relative(process.cwd(), filePath);
|
|
283
|
+
try {
|
|
284
|
+
const findings = scanFile(filePath, relPath).filter(
|
|
285
|
+
(f) => !ignoreRules.has(f.rule.toLowerCase()),
|
|
286
|
+
);
|
|
287
|
+
allFindings.push(...findings);
|
|
288
|
+
} catch (err) {
|
|
289
|
+
if (!quiet) process.stderr.write(`[lint_design_quality] error: ${filePath}: ${err}\n`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (jsonMode) {
|
|
294
|
+
process.stdout.write(JSON.stringify(allFindings, null, 2) + "\n");
|
|
295
|
+
process.exit(allFindings.length > 0 ? 2 : 0);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (allFindings.length === 0) {
|
|
299
|
+
if (!quiet)
|
|
300
|
+
process.stdout.write(
|
|
301
|
+
`✅ lint_design_quality: clean — ${htmlCssFiles.length} file(s) checked, no violations.\n`,
|
|
302
|
+
);
|
|
303
|
+
process.exit(0);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const errors = allFindings.filter((f) => f.severity === "error");
|
|
307
|
+
const warnings = allFindings.filter((f) => f.severity === "warning");
|
|
308
|
+
|
|
309
|
+
for (const f of allFindings) {
|
|
310
|
+
const icon = f.severity === "error" ? "❌" : "⚠️ ";
|
|
311
|
+
process.stdout.write(`${icon} ${f.file}:${f.line} [${f.rule}] ${f.snippet}\n`);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
process.stdout.write(
|
|
315
|
+
`\nlint_design_quality: ${errors.length} error(s), ${warnings.length} warning(s). ` +
|
|
316
|
+
`Use design-quality-disable-next-line <rule> -- reason or .design-quality.json to suppress.\n`,
|
|
317
|
+
);
|
|
318
|
+
process.exit(2);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
main();
|
|
@@ -29,6 +29,8 @@ const PACKS_YML = path.join(REPO_ROOT, 'src', 'config', 'discovery', 'packs.yml'
|
|
|
29
29
|
const ADR_WORKSPACES: ReadonlySet<string> = new Set<string>([
|
|
30
30
|
'engineering', 'product', 'finance', 'founder', 'gtm', 'ops',
|
|
31
31
|
'small-business', 'construction', 'agent-config-maintainer',
|
|
32
|
+
// road-to-legal-pack Phase 0 + road-to-legal-review-prep Phase 0 rename (ADR-013 amendments).
|
|
33
|
+
'legal-review-prep',
|
|
32
34
|
]);
|
|
33
35
|
const ADR_PACKS: ReadonlySet<string> = new Set<string>([
|
|
34
36
|
'engineering-base', 'php', 'laravel', 'symfony', 'javascript',
|
|
@@ -40,6 +42,10 @@ const ADR_PACKS: ReadonlySet<string> = new Set<string>([
|
|
|
40
42
|
'memory', 'analytics', 'product-reasoning',
|
|
41
43
|
// road-to-image-brand-typography Phase B (ADR-013 amendment, same PR).
|
|
42
44
|
'brand',
|
|
45
|
+
// Pre-existing drift restore: present in packs.yml but missing from this set.
|
|
46
|
+
'ai-image', 'analysis-workbench',
|
|
47
|
+
// road-to-legal-pack Phase 0 + road-to-legal-review-prep Phase 0 rename (ADR-013 amendments).
|
|
48
|
+
'legal-review-prep',
|
|
43
49
|
]);
|
|
44
50
|
|
|
45
51
|
// ADR-010 non-overlap reservations.
|
|
@@ -577,6 +577,27 @@
|
|
|
577
577
|
24
|
|
578
578
|
],
|
|
579
579
|
"reason": "Single Laravel-shape example for per-module agents directory (road-to-configurable-modules Phase D)"
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
"file": "src/skills/code-review/SKILL.md",
|
|
583
|
+
"lines": [
|
|
584
|
+
214
|
|
585
|
+
],
|
|
586
|
+
"reason": "Cross-stack formatter enumeration (ECS, Prettier, Ruff, gofmt) — multi-ecosystem documentation"
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
"file": "src/skills/context-document/SKILL.md",
|
|
590
|
+
"lines": [
|
|
591
|
+
82
|
|
592
|
+
],
|
|
593
|
+
"reason": "Laravel example path inside a stack-agnostic module-context table"
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
"file": "src/skills/iconography/SKILL.md",
|
|
597
|
+
"lines": [
|
|
598
|
+
29
|
|
599
|
+
],
|
|
600
|
+
"reason": "Cross-stack UI-stack enumeration (React, Blade, Tailwind)"
|
|
580
601
|
}
|
|
581
602
|
]
|
|
582
603
|
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* Lint the legal pack's deterministic safety-floor backstops.
|
|
4
|
+
*
|
|
5
|
+
* The `legal-safety-floor` rule is prose; this linter makes three of its
|
|
6
|
+
* Iron-Law elements machine-checkable over every `packs: [legal-review-prep]` skill —
|
|
7
|
+
* so they are governance, not just prompt instructions (road-to-legal-pack
|
|
8
|
+
* Phase 1, the "deterministic hardening = differentiator" thesis):
|
|
9
|
+
*
|
|
10
|
+
* 1.1 disclaimer-presence — the exact attorney-review line must appear in
|
|
11
|
+
* the skill body (a skill that drafts legal work must instruct the model
|
|
12
|
+
* to emit it).
|
|
13
|
+
* 1.2 jurisdiction-tag — the skill must reference the machine-checkable
|
|
14
|
+
* `Jurisdiction:` tag (jurisdiction-honesty made deterministic).
|
|
15
|
+
* 1.3 freshness — any legal-pack artefact that DECLARES `last_verified` /
|
|
16
|
+
* `freshness_window` frontmatter must use a valid shape and not be stale
|
|
17
|
+
* (no-op when absent; the mechanism for when positions carry dates).
|
|
18
|
+
*
|
|
19
|
+
* Scope is the legal pack only — it never touches the other 250+ skills.
|
|
20
|
+
* Exit codes: 0 all legal-pack skills compliant, 1 one or more violations.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import * as fs from 'node:fs';
|
|
24
|
+
import * as path from 'node:path';
|
|
25
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
26
|
+
|
|
27
|
+
const QUIET = process.argv.includes('--quiet');
|
|
28
|
+
|
|
29
|
+
const _HERE = fileURLToPath(import.meta.url);
|
|
30
|
+
const REPO = path.resolve(path.dirname(_HERE), '..', '..');
|
|
31
|
+
const SKILLS_DIR = path.join(REPO, 'src', 'skills');
|
|
32
|
+
|
|
33
|
+
// The exact line the floor requires in every legal-pack deliverable.
|
|
34
|
+
const ATTORNEY_LINE = 'Attorney review required on material use';
|
|
35
|
+
const JURISDICTION_TAG = 'Jurisdiction:';
|
|
36
|
+
const FRESHNESS_WINDOW_RE = /^\d+\s+(day|days|month|months|year|years)$/;
|
|
37
|
+
|
|
38
|
+
// D5 — the floor must carry the hard individual-case STOP block (not just a
|
|
39
|
+
// hedge). road-to-legal-review-prep Phase 1. Checked once, against the floor
|
|
40
|
+
// rule, only on a real (default-dir) run.
|
|
41
|
+
const FLOOR_RULE = path.join(REPO, 'src', 'rules', 'legal-safety-floor.md');
|
|
42
|
+
const STOP_MARKER = '🛑 I must stop here';
|
|
43
|
+
|
|
44
|
+
// D6 — attorney-framing-review promotion tripwire (road-to-legal-review-prep
|
|
45
|
+
// Phase 5 / ADR-107 amendment). Promoting the pack out of lab without a recorded
|
|
46
|
+
// German-attorney framing review fails CI.
|
|
47
|
+
const PACKS_YML = path.join(REPO, 'src', 'config', 'discovery', 'packs.yml');
|
|
48
|
+
const PACK_NOTICE = path.join(REPO, 'src', 'domains', 'legal-review-prep', 'LEGAL_NOTICE.md');
|
|
49
|
+
const FRAMING_MARKER = /framing reviewed by\s+\S.*(rechtsanw|attorney|lawyer)/i;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Pure promotion-gate check. `promoted` = the legal-review-prep pack left its
|
|
53
|
+
* conservative posture (surface_tier !== lab, or trust_level_default !==
|
|
54
|
+
* experimental, or default_install === true). A promoted pack MUST carry a
|
|
55
|
+
* recorded attorney framing review in its LEGAL_NOTICE; otherwise it fails.
|
|
56
|
+
*/
|
|
57
|
+
export function legalPromotionViolations(packsYml: string, legalNotice: string): Violation[] {
|
|
58
|
+
const block = /(^|\n)- id:\s*legal-review-prep\b([\s\S]*?)(?=\n- id:|\n*$)/.exec(packsYml);
|
|
59
|
+
if (block === null) return [];
|
|
60
|
+
const body = block[2] ?? '';
|
|
61
|
+
const tier = /(^|\n)\s*surface_tier:\s*([^\n#]+)/.exec(body)?.[2]?.trim();
|
|
62
|
+
const trust = /(^|\n)\s*trust_level_default:\s*([^\n#]+)/.exec(body)?.[2]?.trim();
|
|
63
|
+
const defInstall = /(^|\n)\s*default_install:\s*([^\n#]+)/.exec(body)?.[2]?.trim();
|
|
64
|
+
const promoted = (tier !== undefined && tier !== 'lab')
|
|
65
|
+
|| (trust !== undefined && trust !== 'experimental')
|
|
66
|
+
|| defInstall === 'true';
|
|
67
|
+
if (promoted && !FRAMING_MARKER.test(legalNotice)) {
|
|
68
|
+
return [{
|
|
69
|
+
file: path.relative(REPO, PACK_NOTICE),
|
|
70
|
+
rule: 'promotion-gate',
|
|
71
|
+
msg: 'legal-review-prep promoted out of lab without a recorded attorney framing review ("Framing reviewed by <name>, Rechtsanwalt/Rechtsanwältin, <date>" in LEGAL_NOTICE.md) — ADR-107 amendment',
|
|
72
|
+
}];
|
|
73
|
+
}
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// D4 — definitive-legal-language blocklist (the floor bans these; this is the
|
|
78
|
+
// deterministic backstop over skill bodies). Narrow on purpose; the floor's
|
|
79
|
+
// prompt layer is the primary enforcement.
|
|
80
|
+
const DEFINITIVE_PATTERNS: readonly (readonly [RegExp, string])[] = [
|
|
81
|
+
[/\bthis (contract|nda|agreement|dpa|clause) is (valid|enforceable|compliant|legal|illegal)\b/i, 'definitive validity/compliance verdict'],
|
|
82
|
+
[/\b(is|are) (fully |now )?gdpr[- ]compliant\b/i, 'definitive GDPR-compliance claim'],
|
|
83
|
+
[/\byou are (legally )?required to\b/i, 'definitive legal obligation'],
|
|
84
|
+
[/\byou will (win|lose|prevail)\b/i, 'outcome prediction'],
|
|
85
|
+
[/\byour chances (of success )?are\b/i, 'success prognosis'],
|
|
86
|
+
];
|
|
87
|
+
// A line is exempt when it is clearly a negative example / guidance / quote —
|
|
88
|
+
// so "Do NOT say 'this contract is valid'" or "Forbidden: …" never false-positive.
|
|
89
|
+
const NEG_EXAMPLE_RE = /(never|avoid|forbidden|do not|don'?t|instead|rather than|not say|→|⚠️)/i;
|
|
90
|
+
|
|
91
|
+
function _print(msg: string): void {
|
|
92
|
+
if (!QUIET) process.stdout.write(`${msg}\n`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function _readText(p: string): string {
|
|
96
|
+
return fs.readFileSync(p, 'utf-8');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Return [frontmatterText, body] — frontmatter null when no `---` fence. */
|
|
100
|
+
function _splitFrontmatter(content: string): [string | null, string] {
|
|
101
|
+
if (!content.startsWith('---\n')) return [null, content];
|
|
102
|
+
const end = content.indexOf('\n---', 4);
|
|
103
|
+
if (end === -1) return [null, content];
|
|
104
|
+
return [content.slice(4, end), content.slice(end + 4)];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** True when the frontmatter `packs:` block lists `legal-review-prep`. */
|
|
108
|
+
function _isLegalPack(fm: string): boolean {
|
|
109
|
+
// Match a `packs:` block then a `- legal-review-prep` item before the next top-level key.
|
|
110
|
+
const m = /(^|\n)packs:\s*\n((?:\s*-\s*[^\n]+\n?)+)/.exec(fm);
|
|
111
|
+
if (!m) return false;
|
|
112
|
+
return /(^|\n)\s*-\s*legal-review-prep\s*$/m.test(m[2] ?? '');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
interface Violation {
|
|
116
|
+
file: string;
|
|
117
|
+
rule: string;
|
|
118
|
+
msg: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function lintLegalPack(skillsDir: string = SKILLS_DIR): Violation[] {
|
|
122
|
+
const violations: Violation[] = [];
|
|
123
|
+
let dirs: string[] = [];
|
|
124
|
+
try {
|
|
125
|
+
dirs = fs.readdirSync(skillsDir).sort();
|
|
126
|
+
} catch {
|
|
127
|
+
return violations;
|
|
128
|
+
}
|
|
129
|
+
for (const d of dirs) {
|
|
130
|
+
const file = path.join(skillsDir, d, 'SKILL.md');
|
|
131
|
+
if (!fs.existsSync(file)) continue;
|
|
132
|
+
const content = _readText(file);
|
|
133
|
+
const [fm, body] = _splitFrontmatter(content);
|
|
134
|
+
if (fm === null || !_isLegalPack(fm)) continue;
|
|
135
|
+
const rel = path.relative(REPO, file);
|
|
136
|
+
|
|
137
|
+
// 1.1 disclaimer-presence
|
|
138
|
+
if (!body.includes(ATTORNEY_LINE)) {
|
|
139
|
+
violations.push({ file: rel, rule: 'disclaimer-presence', msg: `missing the attorney-review line ("${ATTORNEY_LINE}")` });
|
|
140
|
+
}
|
|
141
|
+
// 1.2 jurisdiction-tag
|
|
142
|
+
if (!body.includes(JURISDICTION_TAG)) {
|
|
143
|
+
violations.push({ file: rel, rule: 'jurisdiction-tag', msg: `missing the machine-checkable "${JURISDICTION_TAG}" tag` });
|
|
144
|
+
}
|
|
145
|
+
// 1.2b council-gate — every legal work-product skill routes deep.
|
|
146
|
+
if (!/(^|\n)council_depth:\s*deep\s*(\n|$)/.test(fm)) {
|
|
147
|
+
violations.push({ file: rel, rule: 'council-depth', msg: 'missing `council_depth: deep` (legal work-product must route through the AI council / deep-research)' });
|
|
148
|
+
}
|
|
149
|
+
// 1.3 freshness — only when declared
|
|
150
|
+
const fw = /(^|\n)freshness_window:\s*"?([^"\n]+)"?/.exec(fm);
|
|
151
|
+
if (fw && !FRESHNESS_WINDOW_RE.test((fw[2] ?? '').trim())) {
|
|
152
|
+
violations.push({ file: rel, rule: 'freshness', msg: `freshness_window "${fw[2]}" is not a valid "<N> days|months|years" shape` });
|
|
153
|
+
}
|
|
154
|
+
// 4.1 — no definitive legal language (line-scoped, skips negative examples)
|
|
155
|
+
for (const line of body.split('\n')) {
|
|
156
|
+
if (NEG_EXAMPLE_RE.test(line)) continue;
|
|
157
|
+
for (const [re, label] of DEFINITIVE_PATTERNS) {
|
|
158
|
+
if (re.test(line)) {
|
|
159
|
+
violations.push({ file: rel, rule: 'definitive-language', msg: `${label}: ${line.trim().slice(0, 80)}` });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// D5 — the floor itself must carry the hard individual-case STOP block.
|
|
165
|
+
// Only on a real run (synthetic-dir tests pass their own tmp skillsDir).
|
|
166
|
+
if (skillsDir === SKILLS_DIR && fs.existsSync(FLOOR_RULE)) {
|
|
167
|
+
if (!_readText(FLOOR_RULE).includes(STOP_MARKER)) {
|
|
168
|
+
violations.push({
|
|
169
|
+
file: path.relative(REPO, FLOOR_RULE),
|
|
170
|
+
rule: 'individual-case-stop',
|
|
171
|
+
msg: `the floor is missing the hard individual-case STOP block ("${STOP_MARKER}")`,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
// D6 — promotion gate (real-run only).
|
|
175
|
+
if (fs.existsSync(PACKS_YML) && fs.existsSync(PACK_NOTICE)) {
|
|
176
|
+
violations.push(...legalPromotionViolations(_readText(PACKS_YML), _readText(PACK_NOTICE)));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return violations;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function main(): number {
|
|
183
|
+
const violations = lintLegalPack();
|
|
184
|
+
if (violations.length === 0) {
|
|
185
|
+
_print('✅ legal pack — all legal-pack skills carry the attorney-review line + Jurisdiction tag');
|
|
186
|
+
return 0;
|
|
187
|
+
}
|
|
188
|
+
_print(`❌ legal pack — ${violations.length} violation(s):`);
|
|
189
|
+
for (const v of violations) {
|
|
190
|
+
_print(` - [${v.rule}] ${v.file}: ${v.msg}`);
|
|
191
|
+
}
|
|
192
|
+
return 1;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
196
|
+
process.exit(main());
|
|
197
|
+
}
|