@su-sws/synthetic-web-team 0.1.1 → 0.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/AGENTS.md CHANGED
@@ -1,3 +1,32 @@
1
+ # This repository
2
+
3
+ This is the package that ships the Stanford Web Services contract. The contract
4
+ is the block between the `sws-agent-contract` markers below, and it is the only
5
+ part of this file `add .` copies into a project. The standards it cites as
6
+ `.sws/standards/` are at `standards/` here.
7
+
8
+ ## Setting up a Stanford site
9
+
10
+ **Three named jobs, no default:** `install` puts the skills in a person's tool
11
+ once per machine, `init` starts a new site, `add .` adds to an existing one; no
12
+ job prints help. **A project holds no skills** — correct, not a failed install.
13
+
14
+ If you are an agent asked to set up a Stanford site, install non-interactively
15
+ and read the result rather than the prose:
16
+
17
+ ```bash
18
+ npx @su-sws/synthetic-web-team init --json --answers '{"siteName":"...","unit":"..."}'
19
+ ```
20
+
21
+ Every **flag** is optional — with a TTY the job interviews instead — so **never
22
+ say the JSON form is required**. The command itself is not optional.
23
+
24
+ Act on four fields: `next[]` for next steps, `incomplete[]` for manifest fields
25
+ still holding placeholders (**ask the user, never invent an owner email**),
26
+ `counts` to tell a fresh install from a re-run, and `dependency` — since unscoped
27
+ `sws` is somebody else's package, **run `npm install` before verifying**.
28
+
29
+ <!-- BEGIN:sws-agent-contract -->
1
30
  # Stanford Web Services: agent contract
2
31
 
3
32
  You are working on a Stanford University website. This file is the behavioral
@@ -12,8 +41,8 @@ contract. Read it once, follow it throughout.
12
41
  2. **The Stanford Global Footer is immutable.** Its links may not be altered,
13
42
  reordered, or added to, and nothing else goes inside it. Unit links belong
14
43
  in a local footer above it. The exact contract is
15
- `standards/fragments/global-footer.yml`. Read it; do not type the footer
16
- from memory.
44
+ `.sws/standards/fragments/global-footer.yml`. Read it; do not type the
45
+ footer from memory.
17
46
  3. **Nothing above the Identity Bar** except a skip navigation link.
18
47
  4. **Never commit credentials.** This is the only thing in the whole system
19
48
  that blocks a build, because it is the only irreversible harm.
@@ -23,7 +52,7 @@ contract. Read it once, follow it throughout.
23
52
  not Storyblok, not decoupled Drupal. Out of scope is not forbidden, and the
24
53
  existing SWS CMS work is not wrong — but do not prescribe a content backend
25
54
  here, and do not build half of one to avoid telling someone it is not covered
26
- yet. `standards/scope.md`.
55
+ yet. `.sws/standards/scope.md`.
27
56
  7. **No cookie consent banner is required.** The Global Footer's Privacy link
28
57
  satisfies the disclosure obligation, so a banner is never the default. It is
29
58
  **not forbidden** — a unit may add one. If it does, record the choice in
@@ -34,7 +63,7 @@ contract. Read it once, follow it throughout.
34
63
 
35
64
  **Check prior art before you build.** SWS has built a lot of sites and most
36
65
  problems are solved. Run `sws prior-art find "<what you are building>"` or read
37
- `standards/prior-art/`. Then apply the precedence rule, all three clauses:
66
+ `.sws/standards/prior-art/`. Then apply the precedence rule, all three clauses:
38
67
 
39
68
  - Prior art tells you **how we solved a shape of problem**. Standards tell you
40
69
  **what to build it with**. When they disagree, standards win.
@@ -52,10 +81,10 @@ and getting it wrong fails silently. Everything else follows or does not
52
81
  matter. Prefer expressing a standard as a thing to avoid, which ages better
53
82
  than a version to require.
54
83
 
55
- **Follow the recipe, and record divergence.** `standards/recipes/` describes
56
- what to build. Deviating is supported and expected: read the swap points, take
57
- the stated cost, and record the choice in `.sws/manifest.yml`. Silent
58
- divergence is the only kind that is a problem.
84
+ **Follow the recipe, and record divergence.** `.sws/standards/recipes/`
85
+ describes what to build. Deviating is supported and expected: read the swap
86
+ points, take the stated cost, and record the choice in `.sws/manifest.yml`.
87
+ Silent divergence is the only kind that is a problem.
59
88
 
60
89
  **Say which source you used.** When Figma and Decanter's CSS disagree, CSS wins
61
90
  on token names and values. When `www.stanford.edu` and Decanter disagree, note
@@ -69,14 +98,20 @@ policy behind them, offer a fix, and move on. Do not block, do not lecture, and
69
98
  do not refuse to proceed because a check failed. A person who finds this tool
70
99
  obstructive will stop using it, and then nothing is compliant.
71
100
 
101
+ **Checks nag; they never gate.** Lint, typecheck, tests, and `sws check` run in
102
+ CI, where a failure is a red check that everyone sees and a person decides
103
+ about. Do not add git hooks (pre-commit, pre-push, husky, lefthook) or agent
104
+ hooks that block (Claude Code `PreToolUse` or `Stop`, and their equivalents).
105
+ If a project already has them, leave them and suggest moving the check to CI.
106
+
72
107
  **Carrot, not stick.** Almost everything in the Stanford web ecosystem is an
73
108
  incentive rather than a mandate, and this tool has to be attractive to work with
74
109
  or it gets bypassed — someone who feels blocked simply goes their own way, and
75
110
  then you have no influence at all. **Policy governs only a sliver of a site**,
76
- mostly the page furniture in `standards/policy/brand.md`. Decanter is the easiest
77
- compliant path, not a hard line: design creativity above the footer and Identity
78
- Bar is welcome, including adopting a `www.stanford.edu` pattern before it lands in
79
- Decanter. Be the reason someone stays, not the reason they leave.
111
+ mostly the page furniture in `.sws/standards/policy/brand.md`. Decanter is the
112
+ easiest compliant path, not a hard line: design creativity above the footer and
113
+ Identity Bar is welcome, including adopting a `www.stanford.edu` pattern before
114
+ it lands in Decanter. Be the reason someone stays, not the reason they leave.
80
115
 
81
116
  If someone cannot fix something now, record it in `.sws/acknowledged.yml` with a
82
117
  reason and a review date. That is a supported action, not a workaround.
@@ -86,64 +121,58 @@ reason and a review date. That is a supported action, not a workaround.
86
121
  You can explain requirements and fix findings. You **cannot** grant an
87
122
  exception, approve a subdomain, sign off a launch, or interpret policy on the
88
123
  university's behalf. Route those to the right office and the right door, per
89
- `standards/policy/escalation.md`. Give one door with a reason, not a list of
90
- links. Never invent a door: the general contact plus an honest "they will route
91
- you" beats a confident wrong link.
124
+ `.sws/standards/policy/escalation.md`. Give one door with a reason, not a list
125
+ of links. Never invent a door: the general contact plus an honest "they will
126
+ route you" beats a confident wrong link.
92
127
 
93
128
  Do not recommend or rank vendors for anything with legal, policy, or
94
129
  procurement implications. State the obligation, name the office, stop.
95
130
 
96
- ## Installing this
97
-
98
- **Three named jobs, no default:** `install` puts the skills in a person's tool
99
- once per machine, `init` starts a new site, `add .` adds to an existing one; no
100
- job prints help. **A project holds no skills** — correct, not a failed install.
101
-
102
- If you are an agent asked to set up a Stanford site, install non-interactively
103
- and read the result rather than the prose:
104
-
105
- ```bash
106
- npx @su-sws/synthetic-web-team init --json --answers '{"siteName":"...","unit":"..."}'
107
- ```
108
-
109
- Every **flag** is optional — with a TTY the job interviews instead — so **never
110
- say the JSON form is required**. The command itself is not optional.
111
-
112
- Act on four fields: `next[]` for next steps, `incomplete[]` for manifest fields
113
- still holding placeholders (**ask the user, never invent an owner email**),
114
- `counts` to tell a fresh install from a re-run, and `dependency` — since unscoped
115
- `sws` is somebody else's package, **run `npm install` before verifying**.
116
-
117
131
  ## Where things are
118
132
 
133
+ Skills and the standards cite `standards/<path>`, which in a project means
134
+ `.sws/standards/<path>`. Everything else this package installs is under `.sws/`.
135
+
119
136
  | Path | What |
120
137
  |---|---|
121
- | `standards/scope.md` | **What this package covers.** Static sites, content in the repo, no CMS. Read it before proposing a content backend |
122
- | `standards/policy/` | Stanford requirements: MinSec, MinWeb, accessibility, privacy, brand, identity, procurement, escalation. Each file dated with `reviewed:` |
123
- | `standards/patterns/` | How SWS builds: Decanter, components, content, IA, forms, discoverability, conventions |
124
- | `standards/stack/` | `requirements.yml`, what must be installed on the machine and how to detect it — run `sws preflight`. Plus `reference-versions.yml`, a dated snapshot for the canary to diff. Advisory. **Nothing installs from either** |
125
- | `standards/recipes/` | Build contracts, with acceptance criteria per recipe |
126
- | `standards/hosting/` | `capabilities.yml`, what a site needs from a host, plus one profile per host. **SWS runs both Netlify and Vercel**, one per family, so neither is a divergence |
127
- | `standards/fragments/` | Byte-exact compliance content. The Global Footer lives here |
128
- | `standards/prior-art/` | Existing SWS work, with era, lineage, and judgment |
138
+ | `.sws/standards/scope.md` | **What this package covers.** Static sites, content in the repo, no CMS. Read it before proposing a content backend |
139
+ | `.sws/standards/policy/` | Stanford requirements: MinSec, MinWeb, accessibility, privacy, brand, identity, procurement, escalation. Each file dated with `reviewed:` |
140
+ | `.sws/standards/patterns/` | How SWS builds: Decanter, components, content, IA, forms, discoverability, conventions |
141
+ | `.sws/standards/stack/` | `requirements.yml`, what must be installed on the machine and how to detect it — run `sws preflight`. Plus `reference-versions.yml`, a dated snapshot for the canary to diff. Advisory. **Nothing installs from either** |
142
+ | `.sws/standards/recipes/` | Build contracts, with acceptance criteria per recipe |
143
+ | `.sws/standards/hosting/` | `capabilities.yml`, what a site needs from a host, plus one profile per host. **SWS runs both Netlify and Vercel**, one per family, so neither is a divergence |
144
+ | `.sws/standards/fragments/` | Byte-exact compliance content. The Global Footer lives here |
145
+ | `.sws/standards/prior-art/` | Existing SWS work, with era, lineage, and judgment |
129
146
  | `.sws/manifest.yml` | What this project is, resolved versions, divergences, prior art reused |
130
147
  | `.sws/acknowledged.yml` | Accepted risks, with reasons and review dates |
131
148
 
149
+ **Project rules go in this file, outside the `sws-agent-contract` markers**;
150
+ `npx @su-sws/synthetic-web-team add .` is the update and rewrites only what is
151
+ between them. Prefer this file to an editor's own rules file whenever the tool
152
+ reads `AGENTS.md`: `CLAUDE.md` and `GEMINI.md` hold only `@AGENTS.md`. Skills
153
+ install once per machine, so **a project holds none**. After an update, **ask
154
+ for `incomplete[]` fields, never invent an owner email**, then `npm install`.
155
+
156
+ **Assume `.claude/` is git-ignored**: it is each developer's own, so a committed
157
+ file there or pointing into it breaks for everyone else, CI included. Shared
158
+ scripts, such as an MCP `headersHelper` or one CI calls, go in `scripts/`.
159
+
132
160
  ## Current stack defaults
133
161
 
134
162
  Astro or Next, Tailwind 4 via Decanter 8, npm (yarn is fine, never convert a
135
163
  project), Playwright plus axe for testing. **Hosting: GitHub Pages for static,
136
164
  then Netlify or Vercel** — SWS runs both, one per family, so start from whichever
137
165
  the unit already administers rather than picking for them. Ship the default
138
- security headers from `standards/hosting/capabilities.yml`; a **CSP is optional
139
- and off by default**, because it breaks pages at content-edit time and the person
140
- holding that problem is the one least able to diagnose it. No
166
+ security headers from `.sws/standards/hosting/capabilities.yml`; a **CSP is
167
+ optional and off by default**, because it breaks pages at content-edit time and
168
+ the person holding that problem is the one least able to diagnose it. No
141
169
  component workshop: these sites have few components and one consumer.
142
170
 
143
- **Content is authored in the repo. No CMS.** See `standards/scope.md`. Every
144
- content change is therefore a commit that runs `sws a11y` in CI, which is a
145
- stronger control than an authoring-time overlay — but automated testing still
171
+ **Content is authored in the repo. No CMS.** See `.sws/standards/scope.md`.
172
+ Every content change is therefore a commit that runs `sws a11y` in CI, which is
173
+ a stronger control than an authoring-time overlay — but automated testing still
146
174
  catches only about 30 percent of issues, so that floor has not moved.
147
175
 
148
176
  Push to `main` deploys. Pull requests are first-class but never required, and
149
177
  nothing should make one mandatory.
178
+ <!-- END:sws-agent-contract -->
package/README.md CHANGED
@@ -24,11 +24,11 @@ Early. The plan is complete and reviewed; the implementation is partway through.
24
24
  | `next-ssr` recipe | Written, extends `astro-static`. Renamed from `next-netlify` on 2026-09-03. Not yet executed end to end |
25
25
  | Hosting profiles | **New.** `standards/hosting/`: a capability contract plus GitHub Pages, Netlify, and Vercel |
26
26
  | Shared skills | **8 of 8 done**, including `sws-github` (provisions a repo and Pages deploy through `gh`) and `sws-preflight` (is this machine equipped?) |
27
- | Role skills | **8 of 8 built, 11 of 11 stubs.** 30 skills total, all validated |
27
+ | Role skills | **8 of 8 built, 11 of 11 stubs.** 31 skills total, all validated |
28
28
  | Documentation site | **Working.** [`site/`](site/), built by our own recipe, scores 100/100 with zero failures |
29
29
  | `sws` CLI | **Working.** `preflight` reports whether the machine has the tools to build at all. `doctor` and `check` run 13 check modules against 68 criteria. `sws a11y` runs axe and an interactive-state audit — hover and focus measured with a real mouse and a real Tab key — and `sws perf` measures a byte budget, all in real Chromium |
30
30
  | Report delivery | **Working.** PR comment and a persistent "Site health" issue, both updated in place. Score trend, sparkline, HTML artifact, README badge |
31
- | Install wizard | **Working, agent-first, two-part.** `user` scope installs the skills into your tools once per machine and is removable; project scope installs `AGENTS.md`, the standards, and the per-site record. Non-interactive by default off a TTY, `--json` result with machine-readable next steps, `--answers` input, idempotent re-runs that preserve project state |
31
+ | Install wizard | **Working, agent-first, two-part.** `user` scope installs the skills into your tools once per machine and is removable; project scope merges the contract into `AGENTS.md` and puts the standards and the per-site record under `.sws/`. Non-interactive by default off a TTY, `--json` result with machine-readable next steps, `--answers` input, idempotent re-runs that preserve project state |
32
32
  | Copy-a-prompt install | **Working.** Five prompts on the site — install into your editor, start a new site, add to an existing project, review, update — each carrying an `npx` route and a `git clone` fallback |
33
33
  | Publishable packages | **Working, not yet published.** Two packages — `@su-sws/synthetic-web-team` and `@su-sws/synthetic-web-team-mcp` — verified by installing the tarballs into a clean project with no repository present |
34
34
  | Updates | **Working.** Re-install is the update: project state preserved, local edits reported as conflicts rather than overwritten, stale files reported not deleted, staleness nag in `sws doctor` |
@@ -64,7 +64,7 @@ unreachable.
64
64
  npx @su-sws/synthetic-web-team install
65
65
  ```
66
66
 
67
- That writes the 30 skills to `~/.claude/skills/` and `~/.agents/skills/` and
67
+ That writes the 31 skills to `~/.claude/skills/` and `~/.agents/skills/` and
68
68
  nothing else — no standards, no `AGENTS.md`, nothing per-site, because at that
69
69
  point there is no site. It touches no file it did not write, so unrelated skills
70
70
  already in those directories are safe, and `install --remove` takes it back out.
@@ -86,6 +86,15 @@ owns it, and which AI tools you use, then shows you every file before writing
86
86
  anything. **A project gets no skills** — they are already installed for every
87
87
  project — so their absence there is correct.
88
88
 
89
+ **It adds to what your project already has.** The contract goes into `AGENTS.md`
90
+ between `<!-- BEGIN:sws-agent-contract -->` and `<!-- END:sws-agent-contract -->`,
91
+ the way Next.js adds its own block, so your rules and other tools' blocks stay
92
+ where they are. `CLAUDE.md` and `GEMINI.md` are exactly `@AGENTS.md`, and only
93
+ for the tools that do not read `AGENTS.md` themselves. The MCP server is added to
94
+ `.mcp.json` next to the servers you already have. Everything else goes under
95
+ `.sws/`: the standards in `.sws/standards/`, nothing at your root, and nothing in
96
+ `.claude/`, which many teams git-ignore.
97
+
89
98
  Where a `package.json` is present it also adds `@su-sws/synthetic-web-team` to
90
99
  your `devDependencies`, so that `npx sws` afterwards runs this CLI. Unscoped
91
100
  `sws` on the public registry is an unrelated package, and without the local
@@ -118,7 +127,7 @@ Three fields in the result are the ones an agent should act on:
118
127
  |---|---|
119
128
  | `next[]` | What to do next, **as data**: `read-contract`, `orient`, `follow-recipe`, `complete-manifest`, `verify`. Each has a path or command and a `why` |
120
129
  | `incomplete[]` | Manifest fields that are still placeholders. **Ask the user for these; do not invent them** — MinWeb requires a named business owner and technical administrator with valid Stanford email |
121
- | `counts` | `created` / `updated` / `unchanged` / `preserved`. A re-run reports `unchanged`, so "already installed" is a truthful answer rather than a second claim of success |
130
+ | `counts` | `created` / `updated` / `merged` / `unchanged` / `preserved` / `moved`. A re-run reports `unchanged`, so "already installed" is a truthful answer rather than a second claim of success |
122
131
 
123
132
  Exit codes: `0` success or dry run, `2` bad input or no content found, `3` a human
124
133
  declined at the confirmation prompt.
@@ -144,6 +153,8 @@ Three guarantees make that safe to run at any time:
144
153
  |---|---|
145
154
  | `preserved` | `.sws/manifest.yml` and `.sws/acknowledged.yml` are **never** overwritten. They hold your owners, resolved versions, recorded divergences and accepted risks |
146
155
  | `conflict` | A file **you edited** is reported and left alone. `--force` overrides |
156
+ | `merged` | Our part was added to **your own** file: the contract to `AGENTS.md`, the import to `CLAUDE.md`, the `sws` server to `.mcp.json` and the other MCP configs, a marked pointer to `.github/copilot-instructions.md`. The rest of the file is untouched, and a later update replaces only our part. Remove the `sws` server and updates leave it out |
157
+ | `moved` | Files an earlier version put in `standards/` at the root are moved into `.sws/standards/`, edits and all. Only files the install record lists: a `standards/` folder of your own stays put. **If your code or CI still reads `standards/`**, as a footer generated from `standards/fragments/global-footer.yml` does, the move waits and `deferred` lists each reference, so the next build does not break. Change them and re-run |
147
158
  | `orphan` | A file we shipped before and no longer do is **reported, not deleted**, every run until you remove it |
148
159
 
149
160
  `.sws/installed.json` records the hash of everything written, which is what lets
@@ -173,14 +184,14 @@ node /path/to/synthetic-web-team/packages/wizard/bin/wizard.mjs
173
184
  Or copy the files by hand, which is all the wizard is really doing:
174
185
 
175
186
  ```bash
176
- # From your project root
177
- cp -r path/to/synthetic-web-team/AGENTS.md .
178
- cp -r path/to/synthetic-web-team/standards .
179
- mkdir -p .agents .claude
187
+ # From your project root. The contract is the marked block, appended so any
188
+ # AGENTS.md you already have keeps its content.
189
+ sed -n '/BEGIN:sws-agent-contract/,/END:sws-agent-contract/p' path/to/synthetic-web-team/AGENTS.md >> AGENTS.md
190
+ mkdir -p .sws && cp -r path/to/synthetic-web-team/standards .sws/standards
191
+ grep -qx '@AGENTS.md' CLAUDE.md 2>/dev/null || echo '@AGENTS.md' >> CLAUDE.md
180
192
  # Skills go in your HOME directory, once, not in the project
181
193
  cp -r path/to/synthetic-web-team/skills ~/.agents/skills
182
194
  cp -r path/to/synthetic-web-team/skills ~/.claude/skills
183
- echo '@AGENTS.md' > CLAUDE.md
184
195
  ```
185
196
 
186
197
  Those two skill paths between them are read natively by Claude Code, VS Code Copilot, Cursor, Codex CLI, Gemini CLI, Zed, Antigravity, and Cline. No build step, no compiler, no plugin to install.
@@ -202,8 +213,8 @@ node packages/cli/bin/sws.mjs doctor --standards standards
202
213
 
203
214
  | Path | What it does |
204
215
  |---|---|
205
- | [`AGENTS.md`](AGENTS.md) | The behavioral contract. 100 lines, read by every tool |
206
- | [`skills/`](skills/) | The team: 30 skills, each one `SKILL.md` with two frontmatter keys. 8 built roles, 11 honest stubs, 11 shared |
216
+ | [`AGENTS.md`](AGENTS.md) | The behavioral contract: the block between the `sws-agent-contract` markers, at most 150 lines, read by every tool. The rest of the file is about this repository and does not ship |
217
+ | [`skills/`](skills/) | The team: 31 skills, each one `SKILL.md` with two frontmatter keys. 8 built roles, 11 honest stubs, 12 shared |
207
218
  | [`standards/policy/`](standards/policy/) | Stanford requirements: MinSec, MinWeb, accessibility, privacy, brand, identity, procurement, escalation. Each file carries a `reviewed:` date |
208
219
  | [`standards/patterns/`](standards/patterns/) | How SWS actually builds: Decanter, components, content, IA, forms, discoverability, plus conventions derived from reading 11 production repos |
209
220
  | [`standards/stack/`](standards/stack/) | `reference-versions.yml`, a dated baseline. Advisory — nothing installs from it. Plus `performance-budget.yml`, the byte budget `sws perf` enforces |
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@su-sws/synthetic-web-team",
3
- "version": "0.1.1",
4
- "description": "Stanford Web Services standards and agent team: policy, patterns, recipes, fragments, prior art, 30 skills, the two-part install wizard, and the advisory compliance CLI.",
3
+ "version": "0.2.0",
4
+ "description": "Stanford Web Services standards and agent team: policy, patterns, recipes, fragments, prior art, 31 skills, the two-part install wizard, and the advisory compliance CLI.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
7
7
  "type": "git",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "scripts": {
11
11
  "sync-skills": "node scripts/sync-skills.mjs",
12
- "validate": "node scripts/validate-skills.mjs && node scripts/validate-emit.mjs && node scripts/validate-criteria.mjs && node scripts/validate-state-classifier.mjs",
12
+ "validate": "node scripts/validate-skills.mjs && node scripts/validate-emit.mjs && node scripts/validate-install.mjs && node scripts/validate-criteria.mjs && node scripts/validate-state-classifier.mjs && node scripts/validate-hooks.mjs",
13
13
  "check": "npm run validate && npm run sync-skills -- --check",
14
14
  "pack:all": "mkdir -p .pack && npm pack --pack-destination ./.pack && npm pack -w @su-sws/synthetic-web-team-mcp --pack-destination ./.pack"
15
15
  },
@@ -23,6 +23,7 @@ import {
23
23
  import * as history from '../src/history.mjs';
24
24
  import * as gh from '../src/github.mjs';
25
25
  import { preflight, summarise } from '../src/preflight.mjs';
26
+ import { findStandards as locateStandards } from '../src/standards.mjs';
26
27
  // Sibling directory inside the same published package (@su-sws/synthetic-web-team), so this
27
28
  // relative path resolves in the repository and in a tarball alike. One reader
28
29
  // of the install record means the CLI and the wizard cannot disagree about what
@@ -128,28 +129,30 @@ if (flags.help) { console.log(USAGE); process.exit(0); }
128
129
  // install record" nag silently stopped firing. Verified: a fresh project with
129
130
  // its record deleted reported nothing.
130
131
  //
131
- // `standards/` is the right test now. It is what a project install actually
132
- // vendors, and `site/` has neither it nor an AGENTS.md, so the original false
133
- // nag stays fixed.
132
+ // The vendored standards are the right test now. They are what a project
133
+ // install actually writes, and `site/` has neither them nor an AGENTS.md, so
134
+ // the original false nag stays fixed.
135
+ //
136
+ // They moved once more, from `standards/` at the root to `.sws/standards/`, so
137
+ // the install stops adding a top-level folder to someone else's repository.
138
+ // Either counts: an older install keeps the root copy until its next `add .`
139
+ // moves it.
134
140
  function wizardInstalled(dir) {
135
- return existsSync(join(dir, 'AGENTS.md')) && existsSync(join(dir, 'standards'));
141
+ return existsSync(join(dir, 'AGENTS.md'))
142
+ && (existsSync(join(dir, '.sws', 'standards')) || existsSync(join(dir, 'standards')));
136
143
  }
137
144
 
138
145
  // --- locate things ----------------------------------------------------------
139
146
 
140
- // A project normally vendors `standards/` (the wizard copies it in), so the
141
- // local lookups come first and win. The last entry is the copy that ships
142
- // alongside this CLI, which covers `npx -p @su-sws/synthetic-web-team sws doctor` in a project
143
- // that never vendored them.
144
- function findStandards() {
145
- if (flags.standards) return resolve(flags.standards);
146
- for (const c of [
147
- join(root, 'standards'),
148
- join(root, '.sws', 'standards'),
149
- resolve(HERE, '..', '..', '..', 'standards'),
150
- ]) if (existsSync(c)) return c;
151
- return null;
152
- }
147
+ // See src/standards.mjs for the order and why. The bundled copy ships in the
148
+ // same package as this file.
149
+ const findStandards = () => locateStandards(root, {
150
+ explicit: flags.standards,
151
+ bundled: resolve(HERE, '..', '..', '..', 'standards'),
152
+ });
153
+
154
+ const NO_STANDARDS = 'Could not find the standards: looked in .sws/standards/, standards/, '
155
+ + 'and beside this CLI. Pass --standards <dir>.';
153
156
 
154
157
  function findDist() {
155
158
  if (flags.dist) return resolve(flags.dist);
@@ -225,7 +228,7 @@ function loadAcceptance(standards, recipeId, seen = new Set()) {
225
228
  async function run() {
226
229
  const standards = findStandards();
227
230
  if (!standards) {
228
- console.error('Could not find a standards/ directory. Pass --standards <dir>.');
231
+ console.error(NO_STANDARDS);
229
232
  process.exit(2);
230
233
  }
231
234
 
@@ -631,7 +634,7 @@ async function perf() {
631
634
  function runPreflight() {
632
635
  const standards = findStandards();
633
636
  if (!standards) {
634
- console.error('Could not find a standards/ directory. Pass --standards <dir>.');
637
+ console.error(NO_STANDARDS);
635
638
  return 2;
636
639
  }
637
640
 
@@ -965,16 +965,18 @@ export function workflow({ root }) {
965
965
  if (up === d) break;
966
966
  d = up;
967
967
  }
968
+ const hooks = hookFinding(root);
968
969
  if (!dir) {
969
970
  return [
970
971
  bad('workflow.push-to-main-deploys', 'no .github/workflows directory',
971
972
  'Push to main should deploy. Pull requests are first-class but never required.'),
972
973
  dunno('workflow.report-reaches-a-reader', 'no workflows to inspect'),
974
+ hooks,
973
975
  ];
974
976
  }
975
977
  const files = readdirSync(dir).filter((f) => /\.ya?ml$/.test(f)).map((f) => join(dir, f));
976
978
  const all = files.map(read).join('\n---\n');
977
- const out = [];
979
+ const out = [hooks];
978
980
 
979
981
  out.push(/on:[\s\S]{0,200}push:[\s\S]{0,120}branches:\s*\[?\s*['"]?main/.test(all)
980
982
  ? ok('workflow.push-to-main-deploys', 'triggers on push to main')
@@ -992,6 +994,74 @@ export function workflow({ root }) {
992
994
  return out;
993
995
  }
994
996
 
997
+ // Checks nag, they never gate. A problem should show up as a failed GitHub
998
+ // Action that everyone can see and a person decides about, not as a refused
999
+ // commit or an agent that will not stop. A pilot added both kinds of hook and
1000
+ // then took them all out again. So a hook that can refuse is reported, with the
1001
+ // suggestion to run the same check in CI. It is never removed: a team may have
1002
+ // chosen it, which is the same reasoning as branch protection.
1003
+ //
1004
+ // Only what the team shares counts. A developer's own .git/hooks are theirs,
1005
+ // and so is a .claude/settings.json that git ignores, which many teams do.
1006
+ const BLOCKING_AGENT_EVENTS = ['PreToolUse', 'Stop', 'SubagentStop'];
1007
+
1008
+ // The client-side git hooks whose failure refuses the operation. A README, a
1009
+ // helper script, or a post-* hook in .husky/ cannot stop anything.
1010
+ const BLOCKING_GIT_HOOKS = new Set(['applypatch-msg', 'pre-applypatch', 'pre-commit', 'pre-merge-commit',
1011
+ 'prepare-commit-msg', 'commit-msg', 'pre-rebase', 'pre-push']);
1012
+
1013
+ function hookFinding(root) {
1014
+ let repo = root;
1015
+ for (let d = root, i = 0; i < 6; i++) {
1016
+ if (existsSync(join(d, '.git'))) { repo = d; break; }
1017
+ const up = dirname(d);
1018
+ if (up === d) break;
1019
+ d = up;
1020
+ }
1021
+
1022
+ const found = [];
1023
+ const husky = join(repo, '.husky');
1024
+ if (existsSync(husky) && statSync(husky).isDirectory()) {
1025
+ const named = readdirSync(husky)
1026
+ .filter((n) => BLOCKING_GIT_HOOKS.has(n) && statSync(join(husky, n)).isFile());
1027
+ if (named.length) found.push(`.husky/ (${named.join(', ')})`);
1028
+ }
1029
+ for (const n of ['lefthook.yml', 'lefthook.yaml', '.lefthook.yml', '.lefthook.yaml', '.pre-commit-config.yaml']) {
1030
+ if (existsSync(join(repo, n))) found.push(n);
1031
+ }
1032
+ try {
1033
+ const j = pkg(repo);
1034
+ for (const k of ['simple-git-hooks', 'pre-commit', 'pre-push']) if (j?.[k]) found.push(`package.json "${k}"`);
1035
+ if (j?.husky?.hooks) found.push('package.json "husky.hooks"');
1036
+ } catch { /* an unreadable package.json is the build check's to report */ }
1037
+
1038
+ const settings = join(repo, '.claude', 'settings.json');
1039
+ if (existsSync(settings) && !gitIgnores(repo, '.claude/settings.json')) {
1040
+ try {
1041
+ const events = Object.keys(JSON.parse(read(settings))?.hooks ?? {})
1042
+ .filter((e) => BLOCKING_AGENT_EVENTS.includes(e));
1043
+ if (events.length) found.push(`.claude/settings.json hooks (${events.join(', ')})`);
1044
+ } catch { /* not ours to parse for anything else */ }
1045
+ }
1046
+
1047
+ return found.length
1048
+ ? bad('workflow.no-blocking-hooks', `hooks that can refuse a commit or stop an agent: ${found.join('; ')}`,
1049
+ 'Run the same check in CI instead, where a failure is a red check everyone can see and nothing is refused. Leave these in place unless the team agrees to move them: someone may have chosen them.')
1050
+ : ok('workflow.no-blocking-hooks', 'no shared git hooks or blocking agent hooks');
1051
+ }
1052
+
1053
+ // True only when git says so. Outside a repository, or with no git, the answer
1054
+ // is false, so the file counts as shared, which is what .claude/settings.json is
1055
+ // for by default.
1056
+ function gitIgnores(repo, rel) {
1057
+ try {
1058
+ execFileSync('git', ['check-ignore', '-q', rel], { cwd: repo, stdio: 'ignore' });
1059
+ return true;
1060
+ } catch {
1061
+ return false;
1062
+ }
1063
+ }
1064
+
995
1065
  // Consent tooling, by package name and by the script hosts these products load
996
1066
  // from. Stanford requires NO cookie banner: the Global Footer's Privacy link
997
1067
  // carries the disclosure, and guidance actively tells units not to build one.
@@ -0,0 +1,26 @@
1
+ // Where the standards are, for a project at `root`.
2
+ //
3
+ // A project vendors them (the wizard copies them in), so the local lookups come
4
+ // first and win. The last candidate is the copy that ships alongside the CLI,
5
+ // which covers `npx -p @su-sws/synthetic-web-team sws doctor` in a project that
6
+ // never vendored them.
7
+ //
8
+ // `.sws/standards` comes first because a root `standards/` can be the team's
9
+ // own folder with nothing of ours in it. So every candidate must also carry the
10
+ // Global Footer contract, the one file every copy of ours has, before it wins.
11
+ // The root is still read because an older install keeps its standards there
12
+ // until `add .` can move them.
13
+ //
14
+ // Its own module so it can be tested: the CLI's CI calls all pass --standards,
15
+ // so nothing else exercises this.
16
+
17
+ import { existsSync } from 'node:fs';
18
+ import { join, resolve } from 'node:path';
19
+
20
+ export function findStandards(root, { explicit = null, bundled = null } = {}) {
21
+ if (explicit) return resolve(explicit);
22
+ for (const c of [join(root, '.sws', 'standards'), join(root, 'standards'), bundled]) {
23
+ if (c && existsSync(join(c, 'fragments', 'global-footer.yml'))) return c;
24
+ }
25
+ return null;
26
+ }