@su-sws/synthetic-web-team 0.1.2 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.2",
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.1",
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 && node scripts/validate-acknowledged.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
  },
@@ -12,7 +12,7 @@ import { join, resolve, dirname, relative } from 'node:path';
12
12
  import { fileURLToPath } from 'node:url';
13
13
  import { parseArgs } from 'node:util';
14
14
  import YAML from 'yaml';
15
- import { ALL, findHtml } from '../src/checks.mjs';
15
+ import { ALL, findHtml, scanSecrets } from '../src/checks.mjs';
16
16
  import { runAxe, RESULTS_PATH as AXE_RESULTS_PATH } from '../src/axe.mjs';
17
17
  import { runPerf, RESULTS_PATH as PERF_RESULTS_PATH } from '../src/perf.mjs';
18
18
  import { runStates, RESULTS_PATH as STATE_RESULTS_PATH } from '../src/states.mjs';
@@ -23,6 +23,8 @@ 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';
27
+ import { loadAcknowledged, applyAcknowledgements, sha256 } from '../src/acknowledged.mjs';
26
28
  // Sibling directory inside the same published package (@su-sws/synthetic-web-team), so this
27
29
  // relative path resolves in the repository and in a tarball alike. One reader
28
30
  // of the install record means the CLI and the wizard cannot disagree about what
@@ -84,6 +86,10 @@ const USAGE = `
84
86
  project, plus: npx playwright install chromium
85
87
  perf Measure the performance budget in a real browser. Writes
86
88
  .sws/perf-results.json. Needs @playwright/test. Exits 0.
89
+ digest <path>[:<line>]
90
+ Print the sha256 of each value the secrets check matches in
91
+ a file, to narrow an acknowledgement to one false positive.
92
+ Local only: no report ever carries these hashes.
87
93
  prior-art scan Index Stanford projects on this machine. Never transmitted.
88
94
  version
89
95
 
@@ -128,28 +134,30 @@ if (flags.help) { console.log(USAGE); process.exit(0); }
128
134
  // install record" nag silently stopped firing. Verified: a fresh project with
129
135
  // its record deleted reported nothing.
130
136
  //
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.
137
+ // The vendored standards are the right test now. They are what a project
138
+ // install actually writes, and `site/` has neither them nor an AGENTS.md, so
139
+ // the original false nag stays fixed.
140
+ //
141
+ // They moved once more, from `standards/` at the root to `.sws/standards/`, so
142
+ // the install stops adding a top-level folder to someone else's repository.
143
+ // Either counts: an older install keeps the root copy until its next `add .`
144
+ // moves it.
134
145
  function wizardInstalled(dir) {
135
- return existsSync(join(dir, 'AGENTS.md')) && existsSync(join(dir, 'standards'));
146
+ return existsSync(join(dir, 'AGENTS.md'))
147
+ && (existsSync(join(dir, '.sws', 'standards')) || existsSync(join(dir, 'standards')));
136
148
  }
137
149
 
138
150
  // --- locate things ----------------------------------------------------------
139
151
 
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
- }
152
+ // See src/standards.mjs for the order and why. The bundled copy ships in the
153
+ // same package as this file.
154
+ const findStandards = () => locateStandards(root, {
155
+ explicit: flags.standards,
156
+ bundled: resolve(HERE, '..', '..', '..', 'standards'),
157
+ });
158
+
159
+ const NO_STANDARDS = 'Could not find the standards: looked in .sws/standards/, standards/, '
160
+ + 'and beside this CLI. Pass --standards <dir>.';
153
161
 
154
162
  function findDist() {
155
163
  if (flags.dist) return resolve(flags.dist);
@@ -165,15 +173,6 @@ function loadManifest() {
165
173
  try { return YAML.parse(readFileSync(p, 'utf8')) || {}; } catch { return {}; }
166
174
  }
167
175
 
168
- function loadAcknowledged() {
169
- const p = join(root, '.sws', 'acknowledged.yml');
170
- if (!existsSync(p)) return [];
171
- try {
172
- const y = YAML.parse(readFileSync(p, 'utf8'));
173
- return Array.isArray(y) ? y : (y?.accepted ?? []);
174
- } catch { return []; }
175
- }
176
-
177
176
  // Recipes may `extends: <recipeId>`. Only differences live in the child, so the
178
177
  // shared criteria cannot drift between recipes, which is the failure this whole
179
178
  // project is organised against.
@@ -225,7 +224,7 @@ function loadAcceptance(standards, recipeId, seen = new Set()) {
225
224
  async function run() {
226
225
  const standards = findStandards();
227
226
  if (!standards) {
228
- console.error('Could not find a standards/ directory. Pass --standards <dir>.');
227
+ console.error(NO_STANDARDS);
229
228
  process.exit(2);
230
229
  }
231
230
 
@@ -255,25 +254,30 @@ async function run() {
255
254
  // Attach weights and severities from the criteria. A finding with no matching
256
255
  // criterion still reports, at weight 0, so a check is never silently dropped.
257
256
  const byId = new Map((acceptance.criteria || []).map((c) => [c.id, c]));
258
- const ack = loadAcknowledged();
257
+ const ack = loadAcknowledged(root);
259
258
  const now = new Date();
260
259
 
260
+ // An acknowledgement covers what it names, not the whole check: see
261
+ // src/acknowledged.mjs. Entries a blocking check cannot honour are reported.
261
262
  const findings = raw.map((f) => {
262
263
  const c = byId.get(f.id) || {};
263
- const a = ack.find((x) => x.check === f.id);
264
- let state = f.state;
265
- let note;
266
- if (a && state === 'fail') {
267
- state = 'acknowledged';
268
- note = `accepted by ${a.accepted_by ?? 'unknown'}${a.reason ? `: ${a.reason}` : ''}`;
269
- if (a.review_by && new Date(a.review_by) < now) note += ` [review overdue since ${a.review_by}]`;
264
+ const blocking = Boolean(f.blocking || c.severity === 'block');
265
+ const entries = ack.filter((x) => x.check === f.id);
266
+ const a = entries.length ? applyAcknowledgements(f, entries, { blocking, now }) : null;
267
+ if (a?.ignored.length) {
268
+ console.error(` warning: ${a.ignored.length} acknowledgement(s) for ${f.id} ignored; the report says why.`);
270
269
  }
270
+ // The value hashes were for matching entries, just above. Nothing below
271
+ // this line, no report, comment or artifact, gets to see them.
272
+ const locations = (a?.locations ?? f.locations)?.map(({ sha256: _hash, ...l }) => l);
271
273
  return {
272
- ...f, state,
273
- detail: note ? `${f.detail} (${note})` : f.detail,
274
+ ...f,
275
+ state: a?.state ?? f.state,
276
+ detail: a?.detail ?? f.detail,
277
+ ...(locations ? { locations } : {}),
274
278
  weight: c.weight ?? 0,
275
279
  severity: c.severity ?? 'warn',
276
- blocking: f.blocking || c.severity === 'block',
280
+ blocking,
277
281
  policy: c.policy ?? null,
278
282
  };
279
283
  });
@@ -631,7 +635,7 @@ async function perf() {
631
635
  function runPreflight() {
632
636
  const standards = findStandards();
633
637
  if (!standards) {
634
- console.error('Could not find a standards/ directory. Pass --standards <dir>.');
638
+ console.error(NO_STANDARDS);
635
639
  return 2;
636
640
  }
637
641
 
@@ -690,6 +694,39 @@ function runPreflight() {
690
694
  return ready || !flags.strict ? 0 : 1;
691
695
  }
692
696
 
697
+ // --- digest -----------------------------------------------------------------
698
+ // The sha256 that narrows an acknowledgement to one matched value. Computed
699
+ // here, on this machine, from the file itself, because no report carries it:
700
+ // a hash of a human-chosen password in a public PR comment is a guess-checker.
701
+ // Reading the value from the file also keeps it out of shell history.
702
+
703
+ function runDigest() {
704
+ const target = positionals[1];
705
+ const m = target?.match(/^(.+?)(?::(\d+))?$/);
706
+ if (!m) {
707
+ console.error('Usage: sws digest <path>[:<line>]');
708
+ return 2;
709
+ }
710
+ const [, rel, lineArg] = m;
711
+ const p = resolve(root, rel);
712
+ if (!existsSync(p)) {
713
+ console.error(`No such file: ${rel}`);
714
+ return 2;
715
+ }
716
+ const hits = scanSecrets(readFileSync(p, 'utf8'))
717
+ .filter((s) => !s.placeholder && (!lineArg || s.line === Number(lineArg)));
718
+ if (!hits.length) {
719
+ console.log(` Nothing the secrets check would report in ${rel}${lineArg ? ` at line ${lineArg}` : ''}.`);
720
+ return 0;
721
+ }
722
+ for (const s of hits) console.log(` ${rel}:${s.line} ${s.label} sha256: ${sha256(s.value)}`);
723
+ console.log('');
724
+ console.log(' Only if a match is NOT a credential, accept just that one, in .sws/acknowledged.yml:');
725
+ console.log(` - check: minweb.no-secrets\n path: ${rel.replace(/^\.\//, '')}\n sha256: <from above>`);
726
+ console.log(' A real credential is rotated, never accepted.');
727
+ return 0;
728
+ }
729
+
693
730
  // --- dispatch ---------------------------------------------------------------
694
731
 
695
732
  switch (cmd) {
@@ -706,6 +743,9 @@ switch (cmd) {
706
743
  case 'perf':
707
744
  process.exit(await perf());
708
745
  break;
746
+ case 'digest':
747
+ process.exit(runDigest());
748
+ break;
709
749
  case 'prior-art':
710
750
  console.log('prior-art scan is not implemented yet. It will index Stanford');
711
751
  console.log('projects on this machine (metadata only) to .sws/prior-art.local.yml,');