@su-sws/synthetic-web-team 0.1.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 +149 -0
- package/README.md +321 -0
- package/package.json +58 -0
- package/packages/cli/bin/sws.mjs +722 -0
- package/packages/cli/src/axe.mjs +164 -0
- package/packages/cli/src/browser.mjs +192 -0
- package/packages/cli/src/checks.mjs +1254 -0
- package/packages/cli/src/github.mjs +131 -0
- package/packages/cli/src/history.mjs +137 -0
- package/packages/cli/src/perf.mjs +245 -0
- package/packages/cli/src/preflight.mjs +185 -0
- package/packages/cli/src/report.mjs +315 -0
- package/packages/cli/src/states.mjs +556 -0
- package/packages/wizard/bin/wizard.mjs +767 -0
- package/packages/wizard/src/detect.mjs +135 -0
- package/packages/wizard/src/emit.mjs +553 -0
- package/skills/role-accessibility-lead/SKILL.md +183 -0
- package/skills/role-api-architect/SKILL.md +65 -0
- package/skills/role-backend-developer/SKILL.md +66 -0
- package/skills/role-compliance-officer/SKILL.md +73 -0
- package/skills/role-content-designer/SKILL.md +145 -0
- package/skills/role-devops/SKILL.md +200 -0
- package/skills/role-discoverability/SKILL.md +164 -0
- package/skills/role-frontend-developer/SKILL.md +167 -0
- package/skills/role-fullstack-developer/SKILL.md +56 -0
- package/skills/role-identity-engineer/SKILL.md +77 -0
- package/skills/role-information-architect/SKILL.md +136 -0
- package/skills/role-infrastructure-architect/SKILL.md +60 -0
- package/skills/role-qa-engineer/SKILL.md +81 -0
- package/skills/role-security-operations/SKILL.md +56 -0
- package/skills/role-software-architect/SKILL.md +75 -0
- package/skills/role-staff-technical-architect/SKILL.md +73 -0
- package/skills/role-strategist/SKILL.md +122 -0
- package/skills/role-user-researcher/SKILL.md +66 -0
- package/skills/role-ux-designer/SKILL.md +159 -0
- package/skills/sws-compliance-check/SKILL.md +153 -0
- package/skills/sws-decanter/SKILL.md +191 -0
- package/skills/sws-deploy/SKILL.md +162 -0
- package/skills/sws-diverge/SKILL.md +131 -0
- package/skills/sws-github/SKILL.md +171 -0
- package/skills/sws-install/SKILL.md +97 -0
- package/skills/sws-netlify/SKILL.md +110 -0
- package/skills/sws-onboard/SKILL.md +85 -0
- package/skills/sws-preflight/SKILL.md +87 -0
- package/skills/sws-prior-art/SKILL.md +137 -0
- package/skills/sws-vercel/SKILL.md +117 -0
- package/standards/fragments/global-footer.yml +137 -0
- package/standards/fragments/identity-bar.yml +180 -0
- package/standards/hosting/capabilities.yml +215 -0
- package/standards/hosting/github-pages.yml +306 -0
- package/standards/hosting/netlify.yml +234 -0
- package/standards/hosting/vercel.yml +284 -0
- package/standards/patterns/components.md +162 -0
- package/standards/patterns/content.md +130 -0
- package/standards/patterns/decanter.md +352 -0
- package/standards/patterns/discoverability.md +121 -0
- package/standards/patterns/forms.md +116 -0
- package/standards/patterns/ia.md +126 -0
- package/standards/patterns/motion.md +267 -0
- package/standards/patterns/sws-conventions.md +225 -0
- package/standards/policy/accessibility.md +241 -0
- package/standards/policy/brand.md +213 -0
- package/standards/policy/escalation.md +53 -0
- package/standards/policy/identity.md +96 -0
- package/standards/policy/minsec.md +119 -0
- package/standards/policy/minweb.md +87 -0
- package/standards/policy/privacy.md +114 -0
- package/standards/policy/procurement.md +79 -0
- package/standards/prior-art/README.md +205 -0
- package/standards/prior-art/catalog.yml +409 -0
- package/standards/prior-art/patterns/INDEX.md +53 -0
- package/standards/prior-art/repos.yml +734 -0
- package/standards/recipes/astro-ssr/RECIPE.md +274 -0
- package/standards/recipes/astro-ssr/acceptance.yml +168 -0
- package/standards/recipes/astro-static/RECIPE.md +468 -0
- package/standards/recipes/astro-static/acceptance.yml +800 -0
- package/standards/recipes/next-ssr/RECIPE.md +407 -0
- package/standards/recipes/next-ssr/acceptance.yml +187 -0
- package/standards/scope.md +111 -0
- package/standards/stack/performance-budget.yml +95 -0
- package/standards/stack/reference-versions.yml +168 -0
- package/standards/stack/requirements.yml +154 -0
|
@@ -0,0 +1,767 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The install wizard.
|
|
3
|
+
//
|
|
4
|
+
// Commitments enforced here:
|
|
5
|
+
// - Ask about the WORLD, derive the compliance tier. Nobody should read a
|
|
6
|
+
// security matrix to start a website.
|
|
7
|
+
// - Show every file before writing anything.
|
|
8
|
+
// - Never block. If a step fails, hand over the recipe and let the agent do it.
|
|
9
|
+
// - Emitted per-editor files are thin pointers, so nothing needs regenerating.
|
|
10
|
+
|
|
11
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
12
|
+
import { join, resolve, dirname } from 'node:path';
|
|
13
|
+
import { homedir } from 'node:os';
|
|
14
|
+
import { fileURLToPath } from 'node:url';
|
|
15
|
+
import { parseArgs } from 'node:util';
|
|
16
|
+
import { createInterface } from 'node:readline/promises';
|
|
17
|
+
import { detect, deriveTier } from '../src/detect.mjs';
|
|
18
|
+
import { plan, write, remove, ensureDevDependency } from '../src/emit.mjs';
|
|
19
|
+
|
|
20
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
|
|
22
|
+
const { values: flags, positionals } = parseArgs({
|
|
23
|
+
allowPositionals: true,
|
|
24
|
+
options: {
|
|
25
|
+
source: { type: 'string' },
|
|
26
|
+
yes: { type: 'boolean', default: false },
|
|
27
|
+
'dry-run': { type: 'boolean', default: false },
|
|
28
|
+
editors: { type: 'string' },
|
|
29
|
+
answers: { type: 'string' },
|
|
30
|
+
json: { type: 'boolean', default: false },
|
|
31
|
+
interactive: { type: 'boolean', default: false },
|
|
32
|
+
force: { type: 'boolean', default: false },
|
|
33
|
+
remove: { type: 'boolean', default: false },
|
|
34
|
+
help: { type: 'boolean', short: 'h', default: false },
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Three modes. `user` installs the skills into the person's tool and writes
|
|
39
|
+
// nothing per-site. `add` and `new` are the project install, unchanged.
|
|
40
|
+
//
|
|
41
|
+
// POSITIONALS ARE [mode, dir], AND A MISSING MODE USED TO BE SILENTLY COSTLY.
|
|
42
|
+
// `wizard.mjs /some/path` made the path the mode, fell through to 'new', left
|
|
43
|
+
// the directory undefined, and installed into the CURRENT directory instead --
|
|
44
|
+
// 46 files into the wrong repository, with an exit code of 0. That was already
|
|
45
|
+
// found once from the MCP side (see the note in packages/mcp/src/scaffold.mjs)
|
|
46
|
+
// and worked around there by always passing a mode; the wizard kept the trap.
|
|
47
|
+
// So an unrecognised first positional is now read as the directory, which is
|
|
48
|
+
// what anyone typing it meant.
|
|
49
|
+
// Each job is NAMED, and none of them is the default.
|
|
50
|
+
//
|
|
51
|
+
// `install` writes 60 files into a home directory; `init` and `add` write 46
|
|
52
|
+
// into whatever directory you are standing in. Picking one of those on the
|
|
53
|
+
// strength of a guess is not a defensible default, and guessing from the
|
|
54
|
+
// directory cannot work anyway: an empty directory is exactly the `init` case,
|
|
55
|
+
// so "empty means install into the editor" would hijack the commonest flow.
|
|
56
|
+
//
|
|
57
|
+
// `new` is a silent alias for `init`, kept because the MCP scaffolder passes a
|
|
58
|
+
// mode positional and muscle memory is cheap to honour.
|
|
59
|
+
const COMMANDS = new Map([
|
|
60
|
+
['install', 'user'],
|
|
61
|
+
['init', 'new'],
|
|
62
|
+
['initialize', 'new'],
|
|
63
|
+
['new', 'new'],
|
|
64
|
+
['add', 'add'],
|
|
65
|
+
]);
|
|
66
|
+
const cmdGiven = positionals[0] !== undefined && COMMANDS.has(positionals[0]);
|
|
67
|
+
const mode = cmdGiven ? COMMANDS.get(positionals[0]) : null;
|
|
68
|
+
const dirArg = cmdGiven ? positionals[1] : positionals[0];
|
|
69
|
+
|
|
70
|
+
// A user install targets the home directory. The optional directory overrides
|
|
71
|
+
// it, which exists so this can be exercised against a scratch directory rather
|
|
72
|
+
// than a real ~/.claude/skills -- there were 584 unrelated skills in the one on
|
|
73
|
+
// the machine this was written on, and none of them are ours to risk.
|
|
74
|
+
const root = mode === 'user'
|
|
75
|
+
? resolve(dirArg ?? homedir())
|
|
76
|
+
: resolve(dirArg ?? '.');
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
// AGENTS ARE THE PRIMARY CALLER, so non-interactive is the DEFAULT and prompting
|
|
81
|
+
// is the special case.
|
|
82
|
+
//
|
|
83
|
+
// This inverted after testing what an agent actually experiences. Prompts used
|
|
84
|
+
// to be gated on `!--yes` alone, which produced two failure modes and no useful
|
|
85
|
+
// output in either:
|
|
86
|
+
//
|
|
87
|
+
// stdin closed exit 13, no diagnostic
|
|
88
|
+
// stdin an open pipe HUNG FOREVER, which is the worst possible outcome for
|
|
89
|
+
// a caller that cannot answer and cannot see the prompt
|
|
90
|
+
//
|
|
91
|
+
// A robot has no TTY. So: prompt only when there is demonstrably a human on both
|
|
92
|
+
// ends, or when --interactive is passed explicitly. Everything else runs to
|
|
93
|
+
// completion and reports.
|
|
94
|
+
const hasHuman = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
95
|
+
const interactive = flags.interactive || (hasHuman && !flags.yes && !flags.json);
|
|
96
|
+
|
|
97
|
+
// With --json, stdout is a single JSON document and nothing else. Prose goes to
|
|
98
|
+
// stderr, so a caller can pipe stdout straight into a parser.
|
|
99
|
+
const say = (...a) => (flags.json ? console.error(...a) : console.log(...a));
|
|
100
|
+
|
|
101
|
+
const HELP = `
|
|
102
|
+
synthetic-web-team <install|init|add> [dir]
|
|
103
|
+
|
|
104
|
+
Installs the Stanford Web Services agent team. THREE JOBS, and no default --
|
|
105
|
+
each writes to a different place, so it will not guess which you meant:
|
|
106
|
+
|
|
107
|
+
install once per machine, into your editor
|
|
108
|
+
init a new site, in an empty directory
|
|
109
|
+
add an existing project, in its root
|
|
110
|
+
|
|
111
|
+
'install' writes the 30 skills into ~/.claude/skills and ~/.agents/skills and
|
|
112
|
+
nothing else: no standards, no AGENTS.md, nothing per-site, because at that
|
|
113
|
+
point there is no site. Undo it with 'install --remove'.
|
|
114
|
+
|
|
115
|
+
'init' and 'add' write AGENTS.md, the standards, and the per-site record
|
|
116
|
+
(owners, compliance tier, divergences, accepted risks) into one repository,
|
|
117
|
+
and no skills, because those are installed once for every project. 'init'
|
|
118
|
+
additionally hands back the recipe to follow to build the pages; 'add' assumes
|
|
119
|
+
you already have a site and leaves your source alone.
|
|
120
|
+
|
|
121
|
+
FOR AGENTS. Non-interactive is the first-class path. One command, no prompts,
|
|
122
|
+
parseable output, stable exit codes:
|
|
123
|
+
|
|
124
|
+
npx @su-sws/synthetic-web-team init --json --answers '{"siteName":"...","unit":"..."}'
|
|
125
|
+
|
|
126
|
+
Non-interactive is the DEFAULT whenever stdin is not a TTY, so an agent cannot
|
|
127
|
+
hang on a prompt. With --json, stdout is exactly one JSON document and all
|
|
128
|
+
prose goes to stderr.
|
|
129
|
+
|
|
130
|
+
Every flag is optional. With a TTY on both ends each job interviews you
|
|
131
|
+
instead. Running with no job prints this text and writes nothing.
|
|
132
|
+
|
|
133
|
+
--json Emit one JSON document on stdout. Implies non-interactive.
|
|
134
|
+
--answers <json> Answers as JSON, or a path to a .json file. Without this an
|
|
135
|
+
unattended run uses placeholder values, which then sit in
|
|
136
|
+
.sws/manifest.yml looking like real ones.
|
|
137
|
+
--source <dir> Where the standards live (default: auto-detect)
|
|
138
|
+
--editors <ids> Comma-separated, skips detection. e.g. claude-code,cursor
|
|
139
|
+
--yes Accept defaults, no prompts.
|
|
140
|
+
--interactive Force prompts even without a TTY.
|
|
141
|
+
--force Overwrite files you have edited locally. Off by default.
|
|
142
|
+
--dry-run Report what would be written, write nothing.
|
|
143
|
+
--remove Uninstall. Valid with 'install' only. Deletes just the files the
|
|
144
|
+
install record lists, so unrelated skills in your skills
|
|
145
|
+
directories are never touched, and a file you edited is kept
|
|
146
|
+
and reported rather than deleted.
|
|
147
|
+
|
|
148
|
+
Answer keys: siteName, unit, purpose, url, recipe, businessOwnerName,
|
|
149
|
+
businessOwnerEmail, techAdminName, techAdminEmail, and the booleans
|
|
150
|
+
collectsPersonalData, authenticates, payments, regulated (these four derive
|
|
151
|
+
the compliance tier).
|
|
152
|
+
|
|
153
|
+
UPDATING. Re-running is the update, at either scope: content is rewritten from
|
|
154
|
+
source, project state (.sws/manifest.yml, .sws/acknowledged.yml) is preserved,
|
|
155
|
+
and any file you edited yourself is reported as a conflict and left alone on
|
|
156
|
+
every run until it matches again. .sws/installed.json records what was written
|
|
157
|
+
so an edit can be told from an old version. Pass --force to discard your edits.
|
|
158
|
+
|
|
159
|
+
An editor install and a project install carry their own versions, so they can
|
|
160
|
+
drift. 'sws doctor' reports the difference as a note rather than a finding:
|
|
161
|
+
being behind is a maintenance fact about the toolchain, not a compliance fact
|
|
162
|
+
about the site.
|
|
163
|
+
|
|
164
|
+
Exit codes: 0 success or dry run, 2 bad input or no content found,
|
|
165
|
+
3 nothing written because a human declined.
|
|
166
|
+
`;
|
|
167
|
+
|
|
168
|
+
if (flags.help) {
|
|
169
|
+
console.log(HELP);
|
|
170
|
+
process.exit(0);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Where the content comes from, in order of specificity.
|
|
174
|
+
//
|
|
175
|
+
// The first entry is the important one: `AGENTS.md`, `skills/` and `standards/`
|
|
176
|
+
// ship in the same package as this file (@su-sws/synthetic-web-team), so walking up three
|
|
177
|
+
// directories finds them under `npx` exactly as it does in this repository.
|
|
178
|
+
// That is the whole reason content and tools are one package -- an earlier split
|
|
179
|
+
// needed a separate `@su-sws/standards` import here, and could skew versions.
|
|
180
|
+
function findSource() {
|
|
181
|
+
const looksRight = (c) => c
|
|
182
|
+
&& existsSync(join(c, 'AGENTS.md'))
|
|
183
|
+
&& existsSync(join(c, 'skills'))
|
|
184
|
+
&& existsSync(join(c, 'standards'));
|
|
185
|
+
|
|
186
|
+
// An explicit --source is still checked. Previously it was returned unchecked,
|
|
187
|
+
// so a wrong path surfaced later as an unhandled ENOENT and exit 1 instead of
|
|
188
|
+
// a structured error -- which for an agent is the difference between a fixable
|
|
189
|
+
// message and a stack trace.
|
|
190
|
+
if (flags.source) {
|
|
191
|
+
const p = resolve(flags.source);
|
|
192
|
+
return looksRight(p) ? p : { badSource: p };
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// 1. the package this file ships in (also the repo root), 2. the cwd
|
|
196
|
+
for (const c of [resolve(HERE, '..', '..', '..'), process.cwd()]) {
|
|
197
|
+
if (looksRight(c)) return c;
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// One exit path for failures, so a caller never has to parse prose to find out
|
|
203
|
+
// what went wrong.
|
|
204
|
+
function die(code, error, detail) {
|
|
205
|
+
if (flags.json) {
|
|
206
|
+
console.log(JSON.stringify({ ok: false, error, detail, root, mode }, null, 2));
|
|
207
|
+
} else {
|
|
208
|
+
console.error(` ${error}`);
|
|
209
|
+
if (detail) console.error(` ${detail}`);
|
|
210
|
+
}
|
|
211
|
+
process.exit(code);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// ---- answers supplied up front, which is how an agent should do it ---------
|
|
215
|
+
//
|
|
216
|
+
// Without this an unattended run silently uses DEFAULTS, and "Example Unit"
|
|
217
|
+
// with empty owner emails lands in .sws/manifest.yml looking like a real
|
|
218
|
+
// answer. MinWeb requires both owners to be identifiable, so writing
|
|
219
|
+
// placeholders is worse than writing nothing.
|
|
220
|
+
function suppliedAnswers() {
|
|
221
|
+
if (!flags.answers) return null;
|
|
222
|
+
let raw = flags.answers;
|
|
223
|
+
if (!raw.trimStart().startsWith('{')) {
|
|
224
|
+
const p = resolve(raw);
|
|
225
|
+
if (!existsSync(p)) die(2, `--answers file not found: ${p}`);
|
|
226
|
+
raw = readFileSync(p, 'utf8');
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
const j = JSON.parse(raw);
|
|
230
|
+
if (!j || typeof j !== 'object' || Array.isArray(j)) throw new Error('not a JSON object');
|
|
231
|
+
const known = new Set(Object.keys(DEFAULTS));
|
|
232
|
+
const unknown = Object.keys(j).filter((k) => !known.has(k));
|
|
233
|
+
if (unknown.length) {
|
|
234
|
+
die(2, `--answers has unknown key(s): ${unknown.join(', ')}`,
|
|
235
|
+
`Known keys: ${[...known].join(', ')}`);
|
|
236
|
+
}
|
|
237
|
+
return j;
|
|
238
|
+
} catch (err) {
|
|
239
|
+
die(2, `--answers is not valid JSON: ${err.message}`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// The version of @su-sws/synthetic-web-team, which is the content version because content and
|
|
244
|
+
// tools ship in one package. Recorded in .sws/installed.json so `sws doctor` can
|
|
245
|
+
// say whether a project is behind.
|
|
246
|
+
const contentVersion = (() => {
|
|
247
|
+
for (const c of [resolve(HERE, '..', '..', '..', 'package.json')]) {
|
|
248
|
+
try { return JSON.parse(readFileSync(c, 'utf8')).version ?? null; } catch { /* next */ }
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
})();
|
|
252
|
+
|
|
253
|
+
// A null version is not fatal, but it must not be silent. It gets recorded in
|
|
254
|
+
// .sws/installed.json, and `sws doctor` compares that against its own version to
|
|
255
|
+
// tell a project it is behind -- so a null disables the staleness nag FOREVER,
|
|
256
|
+
// with nothing on screen to say so. Found by running this project's own install
|
|
257
|
+
// prompt against a partial checkout.
|
|
258
|
+
const versionWarning = contentVersion
|
|
259
|
+
? null
|
|
260
|
+
: 'Could not determine the standards version, so .sws/installed.json will record null '
|
|
261
|
+
+ 'and `sws doctor` will never report this project as behind. This usually means an '
|
|
262
|
+
+ 'incomplete checkout: the package.json beside AGENTS.md is missing.';
|
|
263
|
+
|
|
264
|
+
if (versionWarning) console.error(` warning: ${versionWarning}`);
|
|
265
|
+
|
|
266
|
+
// The project declares a dependency on this package so `npx sws` resolves to
|
|
267
|
+
// the CLI in node_modules/.bin. Unscoped `sws` on the public registry is
|
|
268
|
+
// SOMEBODY ELSE'S package, so without this declaration every verify step this
|
|
269
|
+
// tool prints would run unrelated code. The range follows the content version
|
|
270
|
+
// because the standards and the CLI ship together.
|
|
271
|
+
const DEP_NAME = '@su-sws/synthetic-web-team';
|
|
272
|
+
const depRange = contentVersion ? `^${contentVersion}` : null;
|
|
273
|
+
let depResult = { status: 'not-attempted' };
|
|
274
|
+
|
|
275
|
+
// No job named means no job done. This is the fix for a real hazard rather than
|
|
276
|
+
// pedantry: the previous default wrote 46 files into the current directory, and
|
|
277
|
+
// `wizard.mjs /some/path` silently did exactly that because the path was read as
|
|
278
|
+
// the mode. Now an unknown first argument says so and writes nothing.
|
|
279
|
+
if (!cmdGiven) {
|
|
280
|
+
if (positionals[0] !== undefined) {
|
|
281
|
+
die(2, `unknown command: ${positionals[0]}`,
|
|
282
|
+
'Expected install (into your editor), init (a new site), or add (an existing project). '
|
|
283
|
+
+ 'A directory goes after the command, not before it.');
|
|
284
|
+
}
|
|
285
|
+
console.log(HELP);
|
|
286
|
+
process.exit(0);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const source = findSource();
|
|
290
|
+
if (source?.badSource) {
|
|
291
|
+
die(2, `--source is not a standards source: ${source.badSource}`,
|
|
292
|
+
'Expected it to contain AGENTS.md, skills/ and standards/.');
|
|
293
|
+
}
|
|
294
|
+
if (!source) {
|
|
295
|
+
die(2, 'Could not find the standards content.',
|
|
296
|
+
'Expected it beside this tool, or in the current directory. Pass --source <dir>.');
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const B = (s) => (process.stdout.isTTY ? `\x1b[1m${s}\x1b[0m` : s);
|
|
300
|
+
const D = (s) => (process.stdout.isTTY ? `\x1b[2m${s}\x1b[0m` : s);
|
|
301
|
+
|
|
302
|
+
// --- user scope -------------------------------------------------------------
|
|
303
|
+
//
|
|
304
|
+
// Installs the skills into the person's tool, then stops. There is no site at
|
|
305
|
+
// this point, so there is no interview, no tier, no manifest and no dependency
|
|
306
|
+
// -- almost none of the project flow below applies, which is why this is its own
|
|
307
|
+
// path rather than a set of conditionals threaded through it.
|
|
308
|
+
if (mode === 'user') {
|
|
309
|
+
const detected = detect(root).filter((e) => e.detected);
|
|
310
|
+
|
|
311
|
+
if (flags.remove) {
|
|
312
|
+
const r = remove(root, { dryRun: flags['dry-run'], force: flags.force });
|
|
313
|
+
|
|
314
|
+
if (r.status === 'no-record') {
|
|
315
|
+
say(`\n ${B('Nothing to remove.')} ${D('No .sws/installed.json under ' + root + ',')}`);
|
|
316
|
+
say(` ${D('so there is no record of what was ours and nothing is safe to delete.')}\n`);
|
|
317
|
+
} else {
|
|
318
|
+
const verb = flags['dry-run'] ? 'Would remove' : 'Removed';
|
|
319
|
+
say(`\n ${B(verb + ' ' + r.removed.length + ' file(s).')}` +
|
|
320
|
+
(r.missing.length ? D(` ${r.missing.length} already gone.`) : ''));
|
|
321
|
+
if (r.kept.length) {
|
|
322
|
+
say(`\n ${B('Kept because you edited them:')}`);
|
|
323
|
+
for (const k of r.kept) say(` ${k}`);
|
|
324
|
+
say(` ${D('Your edit is your work. Re-run with --force to delete these too.')}`);
|
|
325
|
+
}
|
|
326
|
+
say('');
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (flags.json) {
|
|
330
|
+
console.log(JSON.stringify({
|
|
331
|
+
ok: true, schema: 1, scope: 'user', mode: 'install --remove',
|
|
332
|
+
tool: '@su-sws/synthetic-web-team', version: contentVersion,
|
|
333
|
+
root, written: !flags['dry-run'], ...r,
|
|
334
|
+
}, null, 2));
|
|
335
|
+
}
|
|
336
|
+
process.exit(0);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const userFiles = plan({ root, source, editors: [], answers: {}, tier: {}, scope: 'user' });
|
|
340
|
+
|
|
341
|
+
say(`\n${B('Stanford Web Services')} ${D('installing into your tools')}\n`);
|
|
342
|
+
say(` ${B('Files to write')} ${D(root)}\n`);
|
|
343
|
+
for (const target of [...new Set(userFiles.map((f) => f.path.split('/skills/')[0]))]) {
|
|
344
|
+
const n = userFiles.filter((f) => f.path.startsWith(`${target}/`)).length;
|
|
345
|
+
say(` ${target}/skills/ ${D(`${n} skills`)}`);
|
|
346
|
+
}
|
|
347
|
+
say(`\n ${D('Nothing per-site is written here. No standards, no AGENTS.md, no')}`);
|
|
348
|
+
say(` ${D('manifest — there is no project yet. Run this once per machine.')}`);
|
|
349
|
+
|
|
350
|
+
// Only ever the skills we wrote. A home skills directory holds other people's
|
|
351
|
+
// work, and the install record is what keeps the two apart.
|
|
352
|
+
const userNext = [
|
|
353
|
+
{
|
|
354
|
+
kind: 'init-project', skill: 'sws-install',
|
|
355
|
+
why: 'The second half of the install. Run it inside a repository to write AGENTS.md, the standards, and the per-site record. The skills you just installed are what know how to do it.',
|
|
356
|
+
},
|
|
357
|
+
];
|
|
358
|
+
if (detected.some((e) => e.id === 'claude-code')) {
|
|
359
|
+
userNext.push({
|
|
360
|
+
kind: 'optional-mcp', command: 'claude mcp add --scope user sws -- npx -y @su-sws/synthetic-web-team-mcp',
|
|
361
|
+
why: 'Registers the standards as MCP tools for every project at once. Optional, never required: everything it exposes is also a file under standards/ once a project is initialised.',
|
|
362
|
+
});
|
|
363
|
+
} else {
|
|
364
|
+
userNext.push({
|
|
365
|
+
kind: 'optional-mcp', command: 'npx -y @su-sws/synthetic-web-team-mcp --help',
|
|
366
|
+
why: 'An MCP server for these standards, which can be registered in your tool\'s user-level MCP config so it covers every project. Optional, never required. Paths differ per tool, so this does not guess at one.',
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const emitUserJson = (wr) => console.log(JSON.stringify({
|
|
371
|
+
ok: true, schema: 1, scope: 'user', mode: 'install',
|
|
372
|
+
tool: '@su-sws/synthetic-web-team',
|
|
373
|
+
version: contentVersion,
|
|
374
|
+
warnings: versionWarning ? [versionWarning] : [],
|
|
375
|
+
root,
|
|
376
|
+
source,
|
|
377
|
+
written: Boolean(wr),
|
|
378
|
+
editors: detected.map((e) => ({ id: e.id, label: e.label, evidence: e.evidence })),
|
|
379
|
+
counts: {
|
|
380
|
+
files: userFiles.length,
|
|
381
|
+
...(wr ? {
|
|
382
|
+
created: wr.created, updated: wr.updated, unchanged: wr.unchanged,
|
|
383
|
+
conflicts: wr.conflicts.length,
|
|
384
|
+
} : {}),
|
|
385
|
+
},
|
|
386
|
+
files: wr ? wr.results : userFiles.map((x) => ({ path: x.path, status: 'planned' })),
|
|
387
|
+
conflicts: wr?.conflicts ?? [],
|
|
388
|
+
orphans: wr?.orphans ?? [],
|
|
389
|
+
next: userNext,
|
|
390
|
+
notes: [
|
|
391
|
+
'Skills only. Nothing per-site is installed at user scope.',
|
|
392
|
+
'Uninstall with `--remove`, which deletes only what the install record lists.',
|
|
393
|
+
],
|
|
394
|
+
}, null, 2));
|
|
395
|
+
|
|
396
|
+
if (flags['dry-run']) {
|
|
397
|
+
say(`\n ${D('Dry run. Nothing written.')}\n`);
|
|
398
|
+
if (flags.json) emitUserJson(null);
|
|
399
|
+
process.exit(0);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (interactive) {
|
|
403
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
404
|
+
const go = (await rl.question(`\n Write these ${userFiles.length} files? ${D('[Y/n]')}: `)).trim().toLowerCase();
|
|
405
|
+
await rl.close();
|
|
406
|
+
if (go && !go.startsWith('y')) {
|
|
407
|
+
say('\n Nothing written.\n');
|
|
408
|
+
process.exit(3);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
const wr = write(root, userFiles, { force: flags.force, version: contentVersion, scope: 'user' });
|
|
413
|
+
|
|
414
|
+
if (wr.created === 0 && wr.updated === 0) {
|
|
415
|
+
say(`\n ${B('Already installed.')} ${wr.unchanged} skills, nothing to change.\n`);
|
|
416
|
+
} else {
|
|
417
|
+
const parts = [];
|
|
418
|
+
if (wr.created) parts.push(`${wr.created} created`);
|
|
419
|
+
if (wr.updated) parts.push(`${wr.updated} updated`);
|
|
420
|
+
if (wr.unchanged) parts.push(`${wr.unchanged} unchanged`);
|
|
421
|
+
if (wr.conflicts.length) parts.push(`${wr.conflicts.length} left alone`);
|
|
422
|
+
say(`\n ${B('Done.')} ${parts.join(', ')}.\n`);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (wr.conflicts.length) {
|
|
426
|
+
say(` ${B('Left alone because you edited them:')}`);
|
|
427
|
+
for (const c of wr.conflicts) say(` ${c}`);
|
|
428
|
+
say(` ${D('Re-run with --force to take the new versions and discard your edits.')}`);
|
|
429
|
+
say('');
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
say(` ${B('Next')}`);
|
|
433
|
+
say(` 1. Open a Stanford project and ask your agent to run the sws-install skill,`);
|
|
434
|
+
say(` ${D('or: npx @su-sws/synthetic-web-team init (new site) / add . (existing)')}`);
|
|
435
|
+
say(` 2. ${D('Optional MCP server: ' + userNext[userNext.length - 1].command)}`);
|
|
436
|
+
say('');
|
|
437
|
+
say(` ${D('To uninstall: npx @su-sws/synthetic-web-team install --remove')}`);
|
|
438
|
+
say(` ${D('It removes only the files this install recorded, so anything else in')}`);
|
|
439
|
+
say(` ${D('your skills directories is untouched.')}`);
|
|
440
|
+
say('');
|
|
441
|
+
|
|
442
|
+
if (flags.json) emitUserJson(wr);
|
|
443
|
+
process.exit(0);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// --- interview --------------------------------------------------------------
|
|
447
|
+
|
|
448
|
+
const DEFAULTS = {
|
|
449
|
+
siteName: 'Example Unit', unit: 'Example Unit', purpose: 'Public information site',
|
|
450
|
+
url: '', recipe: 'astro-static',
|
|
451
|
+
businessOwnerName: '', businessOwnerEmail: '',
|
|
452
|
+
techAdminName: '', techAdminEmail: '',
|
|
453
|
+
collectsPersonalData: false, authenticates: false, payments: false, regulated: false,
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
async function interview() {
|
|
457
|
+
const supplied = suppliedAnswers();
|
|
458
|
+
if (!interactive) return { ...DEFAULTS, ...(supplied ?? {}) };
|
|
459
|
+
|
|
460
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
461
|
+
const ask = async (q, dflt = '') => {
|
|
462
|
+
const a = (await rl.question(` ${q}${dflt ? D(` (${dflt})`) : ''}: `)).trim();
|
|
463
|
+
return a || dflt;
|
|
464
|
+
};
|
|
465
|
+
const yes = async (q, dflt = false) => {
|
|
466
|
+
const a = (await rl.question(` ${q} ${D(dflt ? '[Y/n]' : '[y/N]')}: `)).trim().toLowerCase();
|
|
467
|
+
return a ? a.startsWith('y') : dflt;
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
const A = { ...DEFAULTS, ...(supplied ?? {}) };
|
|
471
|
+
console.log(`\n${B('Stanford Web Services')} ${D('project setup')}\n`);
|
|
472
|
+
|
|
473
|
+
console.log(D(' What is this site?'));
|
|
474
|
+
A.siteName = await ask('Site name', A.siteName);
|
|
475
|
+
A.unit = await ask('Stanford unit', A.siteName);
|
|
476
|
+
A.purpose = await ask('One line: what should change because this site exists', A.purpose);
|
|
477
|
+
A.url = await ask('Planned URL, if known', '');
|
|
478
|
+
|
|
479
|
+
// The tier questions. Note none of them mention MinSec.
|
|
480
|
+
console.log(`\n${D(' What does it handle? This sets the compliance requirements.')}`);
|
|
481
|
+
A.collectsPersonalData = await yes('Will it collect or display information about individuals?');
|
|
482
|
+
A.authenticates = await yes('Will people log in?');
|
|
483
|
+
if (A.collectsPersonalData || A.authenticates) {
|
|
484
|
+
A.payments = await yes('Will it take payments?');
|
|
485
|
+
A.regulated = await yes('Will it handle health, financial, or export-controlled data?');
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
console.log(`\n${D(' Who owns it? MinWeb requires both to be identifiable.')}`);
|
|
489
|
+
A.businessOwnerName = await ask('Business owner name', '');
|
|
490
|
+
A.businessOwnerEmail = await ask('Business owner Stanford email', '');
|
|
491
|
+
A.techAdminName = await ask('Technical administrator name', '');
|
|
492
|
+
A.techAdminEmail = await ask('Technical administrator Stanford email', '');
|
|
493
|
+
|
|
494
|
+
await rl.close();
|
|
495
|
+
return A;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// --- run --------------------------------------------------------------------
|
|
499
|
+
|
|
500
|
+
const answers = await interview();
|
|
501
|
+
const tier = deriveTier(answers);
|
|
502
|
+
|
|
503
|
+
let editors = detect(root);
|
|
504
|
+
if (flags.editors) {
|
|
505
|
+
const want = flags.editors.split(',').map((s) => s.trim());
|
|
506
|
+
editors = editors.map((e) => ({ ...e, detected: want.includes(e.id) }));
|
|
507
|
+
}
|
|
508
|
+
let chosen = editors.filter((e) => e.detected);
|
|
509
|
+
|
|
510
|
+
if (interactive && !flags.editors) {
|
|
511
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
512
|
+
console.log(`\n${D(' Which AI tools do you use? Detected ones are pre-selected.')}`);
|
|
513
|
+
editors.forEach((e, i) => {
|
|
514
|
+
const mark = e.detected ? B('x') : ' ';
|
|
515
|
+
console.log(` ${String(i + 1).padStart(2)}. [${mark}] ${e.label}` +
|
|
516
|
+
(e.evidence.length ? D(` found ${e.evidence.join(', ')}`) : ''));
|
|
517
|
+
});
|
|
518
|
+
const a = (await rl.question(`\n Numbers to toggle, or Enter to accept: `)).trim();
|
|
519
|
+
await rl.close();
|
|
520
|
+
for (const n of a.split(/[\s,]+/).filter(Boolean)) {
|
|
521
|
+
const i = Number(n) - 1;
|
|
522
|
+
if (editors[i]) editors[i].detected = !editors[i].detected;
|
|
523
|
+
}
|
|
524
|
+
chosen = editors.filter((e) => e.detected);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
if (!chosen.length) {
|
|
528
|
+
console.log(`\n ${D('No editors selected. The universal core still works everywhere:')}`);
|
|
529
|
+
console.log(` ${D('AGENTS.md plus .agents/skills and .claude/skills.')}`);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// --- the machine-readable result --------------------------------------------
|
|
533
|
+
//
|
|
534
|
+
// One JSON document on stdout, defined once and used by both the dry-run and the
|
|
535
|
+
// real path so they cannot describe the same install differently.
|
|
536
|
+
//
|
|
537
|
+
// `next` is DATA, not prose. The caller of this tool is an agent whose whole
|
|
538
|
+
// reason for installing is to then act, and "Hand your agent
|
|
539
|
+
// standards/recipes/astro-static/RECIPE.md" is a sentence a robot has to parse
|
|
540
|
+
// out of decorated terminal output. Each step names a kind, a path or command,
|
|
541
|
+
// and why — so the agent can pick the one it is able to do.
|
|
542
|
+
//
|
|
543
|
+
// `incomplete` is the field that matters most. An unattended install writes
|
|
544
|
+
// placeholder owners into .sws/manifest.yml, and MinWeb requires both owners to
|
|
545
|
+
// be identifiable. Rather than pretend that is done, the result says which
|
|
546
|
+
// fields are still placeholders so the agent can ask its user.
|
|
547
|
+
function emitJson({ written, write: wr }) {
|
|
548
|
+
const placeholder = [];
|
|
549
|
+
if (!answers.businessOwnerEmail) placeholder.push('owners.business.email');
|
|
550
|
+
if (!answers.businessOwnerName) placeholder.push('owners.business.name');
|
|
551
|
+
if (!answers.techAdminEmail) placeholder.push('owners.technical.email');
|
|
552
|
+
if (!answers.techAdminName) placeholder.push('owners.technical.name');
|
|
553
|
+
if (answers.siteName === 'Example Unit') placeholder.push('site.name');
|
|
554
|
+
if (!answers.url) placeholder.push('site.url');
|
|
555
|
+
|
|
556
|
+
const next = [];
|
|
557
|
+
next.push({
|
|
558
|
+
kind: 'read-contract', path: 'AGENTS.md',
|
|
559
|
+
why: 'The behavioral contract. Read it before doing anything else in this project.',
|
|
560
|
+
});
|
|
561
|
+
next.push({
|
|
562
|
+
kind: 'orient', skill: 'sws-onboard',
|
|
563
|
+
why: 'Reads .sws/manifest.yml and states the stack, tier, and decisions already made.',
|
|
564
|
+
});
|
|
565
|
+
if (mode === 'new') {
|
|
566
|
+
next.push({
|
|
567
|
+
kind: 'follow-recipe', path: `standards/recipes/${answers.recipe}/RECIPE.md`,
|
|
568
|
+
why: 'The build contract, with acceptance criteria. Follow it rather than improvising.',
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
if (placeholder.length) {
|
|
572
|
+
next.push({
|
|
573
|
+
kind: 'complete-manifest', path: '.sws/manifest.yml', fields: placeholder,
|
|
574
|
+
why: 'These are placeholders, not answers. MinWeb requires a named business owner and technical administrator with valid Stanford email. Ask the user; do not invent them.',
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
if (chosen.some((e) => e.emits.some((x) => x.endsWith('mcp.json')))) {
|
|
578
|
+
next.push({
|
|
579
|
+
kind: 'optional-mcp', command: 'npx -y @su-sws/synthetic-web-team-mcp --help',
|
|
580
|
+
why: 'An MCP server for these standards was added to your client config. It is a second entry point, never a requirement: sws_get_standard, sws_footer_html, sws_check, sws_decanter_token, sws_scaffold. Everything it exposes is also a file under standards/. Remove the entry if you do not want it.',
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
// `npx sws` has to resolve to node_modules/.bin/sws. Unscoped `sws` on the
|
|
584
|
+
// public registry is an unrelated package, so this step is what makes the
|
|
585
|
+
// verify step below run OUR CLI rather than a stranger's.
|
|
586
|
+
if (depResult.status === 'added' || depResult.status === 'present') {
|
|
587
|
+
next.push({
|
|
588
|
+
kind: 'install-dependencies', command: 'npm install',
|
|
589
|
+
why: `${DEP_NAME} is declared in devDependencies. Installing puts the sws CLI in node_modules/.bin, so \`npx sws\` runs this package instead of the unrelated \`sws\` package on the public registry.`,
|
|
590
|
+
});
|
|
591
|
+
} else {
|
|
592
|
+
next.push({
|
|
593
|
+
kind: 'add-dependency', command: `npm install -D ${DEP_NAME}`,
|
|
594
|
+
why: `Do this once the project has a package.json. Without the local dependency \`npx sws\` fetches the unrelated \`sws\` package from the public registry rather than this CLI.`,
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
next.push({
|
|
598
|
+
kind: 'verify', command: 'npx sws doctor --format json',
|
|
599
|
+
why: 'Advisory compliance report. Exits 0 always. Run `sws a11y` and `sws perf` first if the site is built.',
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
console.log(JSON.stringify({
|
|
603
|
+
ok: true,
|
|
604
|
+
schema: 1,
|
|
605
|
+
// Symmetrical with the user-scope document, and the value echoes the command
|
|
606
|
+
// that was run rather than the internal mode name, so a caller can report
|
|
607
|
+
// back what it did without a lookup table.
|
|
608
|
+
scope: 'project',
|
|
609
|
+
tool: '@su-sws/synthetic-web-team',
|
|
610
|
+
version: contentVersion,
|
|
611
|
+
warnings: versionWarning ? [versionWarning] : [],
|
|
612
|
+
previousVersion: wr?.previousVersion ?? null,
|
|
613
|
+
mode: mode === 'add' ? 'add' : 'init',
|
|
614
|
+
written,
|
|
615
|
+
root,
|
|
616
|
+
source,
|
|
617
|
+
interactive,
|
|
618
|
+
tier: { tier: tier.tier, because: tier.because, adds: tier.adds },
|
|
619
|
+
answers,
|
|
620
|
+
editors: chosen.map((e) => ({ id: e.id, label: e.label, emits: e.emits })),
|
|
621
|
+
counts: {
|
|
622
|
+
files: files.length,
|
|
623
|
+
skills: skillCount,
|
|
624
|
+
standards: stdCount,
|
|
625
|
+
...(wr ? {
|
|
626
|
+
created: wr.created, updated: wr.updated, unchanged: wr.unchanged,
|
|
627
|
+
preserved: wr.preserved, conflicts: wr.conflicts.length,
|
|
628
|
+
} : {}),
|
|
629
|
+
},
|
|
630
|
+
files: wr ? wr.results : files.map((x) => ({ path: x.path, status: 'planned' })),
|
|
631
|
+
incomplete: placeholder,
|
|
632
|
+
dependency: { name: DEP_NAME, range: depRange, ...depResult },
|
|
633
|
+
conflicts: wr?.conflicts ?? [],
|
|
634
|
+
orphans: wr?.orphans ?? [],
|
|
635
|
+
next,
|
|
636
|
+
notes: [
|
|
637
|
+
'Everything is advisory except committed credentials, which are the one blocking check.',
|
|
638
|
+
'Automated accessibility testing covers roughly 30 percent of issues per ODA guidance. A passing report is a floor, not a conformance claim.',
|
|
639
|
+
],
|
|
640
|
+
}, null, 2));
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// --- tier explanation, before the file list ---------------------------------
|
|
644
|
+
|
|
645
|
+
say(`\n ${B('Compliance tier: ' + tier.tier.toUpperCase())} ${D('because ' + tier.because)}`);
|
|
646
|
+
for (const a of tier.adds) say(` ${D('·')} ${a}`);
|
|
647
|
+
if (tier.tier !== 'low') {
|
|
648
|
+
say(`\n ${B('This is above a basic static site.')} ${D('A Data Risk Assessment may be')}`);
|
|
649
|
+
say(` ${D('required before deploy. Route to UIT Security: standards/policy/escalation.md')}`);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// --- review, then write -----------------------------------------------------
|
|
653
|
+
|
|
654
|
+
const files = plan({ root, source, editors: chosen, answers, tier });
|
|
655
|
+
|
|
656
|
+
const skillCount = files.filter((f) => f.path.endsWith('SKILL.md')).length;
|
|
657
|
+
const stdCount = files.filter((f) => f.path.startsWith('standards/')).length;
|
|
658
|
+
const shown = files.filter((f) => !f.path.endsWith('SKILL.md') && !f.path.startsWith('standards/'));
|
|
659
|
+
|
|
660
|
+
say(`\n ${B('Files to write')} ${D(root)}\n`);
|
|
661
|
+
for (const f of shown) {
|
|
662
|
+
say(` ${f.path}${f.note ? D(' ' + f.note) : ''}`);
|
|
663
|
+
}
|
|
664
|
+
say(` ${D(`+ ${skillCount} skill files across .agents/skills and .claude/skills`)}`);
|
|
665
|
+
say(` ${D(`+ ${stdCount} files under standards/`)}`);
|
|
666
|
+
|
|
667
|
+
if (flags['dry-run']) {
|
|
668
|
+
depResult = ensureDevDependency(root, { name: DEP_NAME, range: depRange, dryRun: true });
|
|
669
|
+
say(`\n ${D('Dry run. Nothing written.')}\n`);
|
|
670
|
+
if (flags.json) emitJson({ written: false, write: null });
|
|
671
|
+
process.exit(0);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
if (interactive) {
|
|
675
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
676
|
+
const go = (await rl.question(`\n Write these ${files.length} files? ${D('[Y/n]')}: `)).trim().toLowerCase();
|
|
677
|
+
await rl.close();
|
|
678
|
+
if (go && !go.startsWith('y')) {
|
|
679
|
+
// Exit 3, not 0: a human declining is a different outcome from success, and
|
|
680
|
+
// a caller should be able to tell them apart.
|
|
681
|
+
say('\n Nothing written.\n');
|
|
682
|
+
process.exit(3);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
const result = write(root, files, { force: flags.force, version: contentVersion });
|
|
687
|
+
depResult = ensureDevDependency(root, { name: DEP_NAME, range: depRange });
|
|
688
|
+
|
|
689
|
+
// Say what actually changed, not how many files were considered. On a re-run
|
|
690
|
+
// this reads "nothing to do", which is the truth and what a caller should
|
|
691
|
+
// report onward.
|
|
692
|
+
if (result.created === 0 && result.updated === 0) {
|
|
693
|
+
say(`\n ${B('Already installed.')} ${result.unchanged + result.preserved} files, nothing to change.\n`);
|
|
694
|
+
} else {
|
|
695
|
+
const parts = [];
|
|
696
|
+
if (result.created) parts.push(`${result.created} created`);
|
|
697
|
+
if (result.updated) parts.push(`${result.updated} updated`);
|
|
698
|
+
if (result.unchanged) parts.push(`${result.unchanged} unchanged`);
|
|
699
|
+
if (result.preserved) parts.push(`${result.preserved} preserved`);
|
|
700
|
+
if (result.conflicts.length) parts.push(`${result.conflicts.length} left alone`);
|
|
701
|
+
say(`\n ${B('Done.')} ${parts.join(', ')}.\n`);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// Conflicts and orphans, before the next steps: they need a decision.
|
|
705
|
+
if (result.conflicts.length) {
|
|
706
|
+
say(` ${B('Left alone because you edited them:')}`);
|
|
707
|
+
for (const c of result.conflicts) say(` ${c}`);
|
|
708
|
+
say(` ${D('Re-run with --force to take the new versions and discard your edits.')}`);
|
|
709
|
+
say('');
|
|
710
|
+
}
|
|
711
|
+
if (result.orphans.length) {
|
|
712
|
+
say(` ${B('No longer shipped, still in your project:')}`);
|
|
713
|
+
for (const o of result.orphans) say(` ${o}`);
|
|
714
|
+
say(` ${D('Not deleted. Remove them yourself if you agree they are stale.')}`);
|
|
715
|
+
say('');
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
// The dependency decides whether `npx sws` runs this CLI or an unrelated
|
|
719
|
+
// package of the same name off the public registry, so it is reported, never
|
|
720
|
+
// silent -- either way round.
|
|
721
|
+
if (depResult.status === 'added') {
|
|
722
|
+
say(` ${B('Added to package.json:')} ${DEP_NAME} ${depResult.range} ${D('(devDependencies)')}`);
|
|
723
|
+
say(` ${D('Run npm install and `npx sws` uses this CLI, not the unrelated `sws`')}`);
|
|
724
|
+
say(` ${D('package on the public registry.')}`);
|
|
725
|
+
say('');
|
|
726
|
+
} else if (depResult.status === 'no-package-json') {
|
|
727
|
+
say(` ${B('No package.json here yet.')} ${D('Add ' + DEP_NAME + ' to')}`);
|
|
728
|
+
say(` ${D('devDependencies once the recipe creates one, so `npx sws` resolves locally')}`);
|
|
729
|
+
say(` ${D('rather than fetching the unrelated `sws` package from the registry.')}`);
|
|
730
|
+
say('');
|
|
731
|
+
} else if (depResult.status === 'unparseable') {
|
|
732
|
+
say(` ${B('Could not read package.json:')} ${D(depResult.detail)}`);
|
|
733
|
+
say(` ${D('Left alone. Add ' + DEP_NAME + ' to devDependencies yourself.')}`);
|
|
734
|
+
say('');
|
|
735
|
+
} else if (depResult.status === 'skipped-unknown-version') {
|
|
736
|
+
say(` ${B('No version to pin,')} ${D('so package.json was left alone. Add')}`);
|
|
737
|
+
say(` ${D(DEP_NAME + ' to devDependencies yourself.')}`);
|
|
738
|
+
say('');
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
// --- what happens next ------------------------------------------------------
|
|
742
|
+
|
|
743
|
+
say(` ${B('Next')}`);
|
|
744
|
+
|
|
745
|
+
// Counted rather than hardcoded. The literals used to run 1, 2, then 3 with no
|
|
746
|
+
// step 2 in `add` mode, and threading the dependency step through would have
|
|
747
|
+
// made that worse.
|
|
748
|
+
let stepNo = 0;
|
|
749
|
+
const step = () => ++stepNo;
|
|
750
|
+
if (mode === 'new') {
|
|
751
|
+
say(` ${step()}. Scaffold the site. Hand your agent standards/recipes/${answers.recipe}/RECIPE.md,`);
|
|
752
|
+
say(` ${D('or run the upstream scaffolder yourself: npm create astro@latest')}`);
|
|
753
|
+
}
|
|
754
|
+
if (depResult.status === 'added' || depResult.status === 'present') {
|
|
755
|
+
say(` ${step()}. Install dependencies: npm install`);
|
|
756
|
+
} else {
|
|
757
|
+
say(` ${step()}. Add the CLI: npm install -D ${DEP_NAME}`);
|
|
758
|
+
}
|
|
759
|
+
say(` ${step()}. Check it: npx sws doctor`);
|
|
760
|
+
say(` ${step()}. Fill in the blanks in .sws/manifest.yml: owners, Siteimprove, ODA review.`);
|
|
761
|
+
say('');
|
|
762
|
+
say(` ${D('Everything is advisory. The only thing that fails a build is a committed')}`);
|
|
763
|
+
say(` ${D('credential. If something cannot be fixed now, record it in')}`);
|
|
764
|
+
say(` ${D('.sws/acknowledged.yml with a reason and a review date.')}`);
|
|
765
|
+
say('');
|
|
766
|
+
|
|
767
|
+
if (flags.json) emitJson({ written: true, write: result });
|