@su-sws/synthetic-web-team 0.2.7 → 0.2.9

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.
Files changed (38) hide show
  1. package/AGENTS.md +6 -0
  2. package/README.md +113 -11
  3. package/package.json +3 -2
  4. package/packages/cli/bin/sws.mjs +162 -14
  5. package/packages/cli/src/acknowledged.mjs +6 -1
  6. package/packages/cli/src/brief.mjs +393 -0
  7. package/packages/cli/src/preflight.mjs +1 -1
  8. package/packages/cli/src/prior-art.mjs +329 -0
  9. package/packages/cli/src/report.mjs +21 -2
  10. package/packages/wizard/bin/wizard.mjs +299 -12
  11. package/packages/wizard/src/detect.mjs +111 -1
  12. package/packages/wizard/src/emit.mjs +130 -9
  13. package/skills/role-api-architect/SKILL.md +119 -61
  14. package/skills/role-backend-developer/SKILL.md +145 -55
  15. package/skills/role-compliance-officer/SKILL.md +133 -57
  16. package/skills/role-devops/SKILL.md +9 -6
  17. package/skills/role-fullstack-developer/SKILL.md +104 -37
  18. package/skills/role-identity-engineer/SKILL.md +126 -60
  19. package/skills/role-information-architect/SKILL.md +1 -1
  20. package/skills/role-infrastructure-architect/SKILL.md +105 -32
  21. package/skills/role-qa-engineer/SKILL.md +128 -57
  22. package/skills/role-security-operations/SKILL.md +137 -33
  23. package/skills/role-software-architect/SKILL.md +133 -63
  24. package/skills/role-staff-technical-architect/SKILL.md +112 -50
  25. package/skills/role-user-researcher/SKILL.md +119 -45
  26. package/skills/role-ux-designer/SKILL.md +1 -1
  27. package/skills/sws-compliance-check/SKILL.md +1 -1
  28. package/skills/sws-diverge/SKILL.md +2 -2
  29. package/skills/sws-github/SKILL.md +2 -0
  30. package/skills/sws-install/SKILL.md +1 -1
  31. package/skills/sws-netlify/SKILL.md +2 -0
  32. package/skills/sws-preflight/SKILL.md +5 -0
  33. package/skills/sws-vercel/SKILL.md +2 -0
  34. package/standards/hosting/github-pages.yml +1 -0
  35. package/standards/hosting/netlify.yml +1 -0
  36. package/standards/hosting/vercel.yml +1 -0
  37. package/standards/patterns/bolt-ons.md +1 -1
  38. package/standards/policy/identity.md +1 -1
@@ -14,10 +14,11 @@ import { homedir } from 'node:os';
14
14
  import { fileURLToPath } from 'node:url';
15
15
  import { parseArgs } from 'node:util';
16
16
  import { createInterface } from 'node:readline/promises';
17
- import { detect, deriveTier } from '../src/detect.mjs';
17
+ import { detect, deriveTier, detectClaudePlugin, CLAUDE_PLUGIN } from '../src/detect.mjs';
18
18
  import {
19
19
  plan, write, remove, ensureDevDependency, plannedMigration, readInstalled,
20
- STANDARDS_DIR, LAYOUTS, CONTAINED_CONTRACT,
20
+ plannedRetire, readDelivery, STANDARDS_DIR, LAYOUTS, CONTAINED_CONTRACT,
21
+ CLAUDE_SKILLS, PLUGIN_DELIVERY,
21
22
  } from '../src/emit.mjs';
22
23
 
23
24
  const HERE = dirname(fileURLToPath(import.meta.url));
@@ -35,6 +36,8 @@ const { values: flags, positionals } = parseArgs({
35
36
  force: { type: 'boolean', default: false },
36
37
  layout: { type: 'string' },
37
38
  remove: { type: 'boolean', default: false },
39
+ 'claude-plugin': { type: 'boolean', default: false },
40
+ 'no-claude-plugin': { type: 'boolean', default: false },
38
41
  help: { type: 'boolean', short: 'h', default: false },
39
42
  },
40
43
  });
@@ -116,6 +119,21 @@ const HELP = `
116
119
  nothing else: no standards, no AGENTS.md, nothing per-site, because at that
117
120
  point there is no site. Undo it with 'install --remove'.
118
121
 
122
+ CLAUDE CODE PLUGIN. The same skills also ship as a Claude Code plugin, with
123
+ reviewers, entry points and advisory checks on top. It is optional, and
124
+ Claude Code installs it, never this tool:
125
+
126
+ claude plugin marketplace add SU-SWS/synthetic-web-team
127
+ claude plugin install sws@su-sws
128
+
129
+ With the plugin and ~/.claude/skills both in place Claude Code lists every
130
+ skill twice, so pick one. 'install --claude-plugin' leaves Claude Code to the
131
+ plugin and keeps ~/.agents/skills for every other tool. Nothing changes
132
+ unless you pass it, and 'install --no-claude-plugin' switches back. With
133
+ --json every result has a 'plugin' field: detected (true, false or
134
+ "unknown") and delivery (skills or plugin), and next[] carries the commands
135
+ above as a step where they apply. They are reported, never run.
136
+
119
137
  'init' and 'add' write the contract into AGENTS.md, and the standards and the
120
138
  per-site record (owners, compliance tier, divergences, accepted risks) into
121
139
  .sws/, and no skills, because those are installed once for every project.
@@ -156,6 +174,16 @@ const HELP = `
156
174
  install record lists, so unrelated skills in your skills
157
175
  directories are never touched, and a file you edited is kept
158
176
  and reported rather than deleted.
177
+ --claude-plugin With 'install' only. Claude Code takes its skills from the
178
+ sws plugin, so ~/.claude/skills is not written, and the
179
+ copies this tool put there are removed: only files the
180
+ install record lists that you have not edited. An edited
181
+ copy is kept and reported (--force removes it too), and
182
+ no other skill there is touched. ~/.agents/skills is
183
+ written as always. Remembered in ~/.sws/installed.json, so
184
+ a plain 'install' keeps it. --dry-run lists what would go.
185
+ --no-claude-plugin
186
+ Switch back: 'install' writes ~/.claude/skills again.
159
187
 
160
188
  Answer keys: siteName, unit, purpose, url, recipe, businessOwnerName,
161
189
  businessOwnerEmail, techAdminName, techAdminEmail, and the booleans
@@ -324,6 +352,25 @@ if (!LAYOUTS.includes(layout)) {
324
352
  const contained = layout === 'contained';
325
353
  const contractPath = contained ? CONTAINED_CONTRACT : 'AGENTS.md';
326
354
 
355
+ // Where Claude Code gets its skills is a choice about a person's machine, so it
356
+ // belongs to `install` alone. `init` and `add` write no skills, and a flag that
357
+ // was accepted there and did nothing would read as having worked.
358
+ if (flags['claude-plugin'] && flags['no-claude-plugin']) {
359
+ die(2, '--claude-plugin and --no-claude-plugin are opposites', 'Pass one of them.');
360
+ }
361
+ if ((flags['claude-plugin'] || flags['no-claude-plugin']) && mode !== 'user') {
362
+ die(2, '--claude-plugin applies to install',
363
+ "'init' and 'add' write no skills, so there is nothing for it to choose. Run it as: install --claude-plugin");
364
+ }
365
+ if ((flags['claude-plugin'] || flags['no-claude-plugin']) && flags.remove) {
366
+ die(2, '--remove takes everything this install recorded, whichever way Claude Code gets its skills',
367
+ 'To take back only the copies in ~/.claude/skills, run: install --claude-plugin');
368
+ }
369
+
370
+ // The Claude Code plugin's install, as one line a shell can run. Reported in
371
+ // next[], never run from here.
372
+ const PLUGIN_INSTALL = CLAUDE_PLUGIN.install.join(' && ');
373
+
327
374
  const B = (s) => (process.stdout.isTTY ? `\x1b[1m${s}\x1b[0m` : s);
328
375
  const D = (s) => (process.stdout.isTTY ? `\x1b[2m${s}\x1b[0m` : s);
329
376
 
@@ -364,7 +411,48 @@ if (mode === 'user') {
364
411
  process.exit(0);
365
412
  }
366
413
 
367
- const userFiles = plan({ root, source, editors: [], answers: {}, tier: {}, scope: 'user' });
414
+ // WHICH WAY CLAUDE CODE GETS ITS SKILLS. A copy in .claude/skills, as always,
415
+ // unless the person chose the plugin: with the flag on this run, or on an
416
+ // earlier one that the install record remembers. Detecting the plugin never
417
+ // changes what is written. It only changes what is recommended, because
418
+ // removing 31 files from a home directory is a decision, not an inference.
419
+ //
420
+ // The Claude config directory is looked for under the directory being
421
+ // installed into, so an install pointed at a scratch home reads that home's
422
+ // plugin registry and not the real one.
423
+ const hasClaude = detected.some((e) => e.id === 'claude-code');
424
+ const plugin = detectClaudePlugin({ home: root });
425
+ const remembered = readDelivery(root);
426
+ const delivery = flags['claude-plugin'] ? { ...PLUGIN_DELIVERY }
427
+ : flags['no-claude-plugin'] ? null
428
+ : remembered;
429
+ const viaPlugin = Boolean(delivery);
430
+ const deliveryFrom = flags['claude-plugin'] || flags['no-claude-plugin'] ? 'flag'
431
+ : remembered ? 'record' : 'default';
432
+ // Installed AND not switched off: only then is it a second copy of the skills.
433
+ const pluginLive = plugin.detected === true && plugin.enabled !== false;
434
+ const claudeInPlay = hasClaude || plugin.detected === true || viaPlugin;
435
+ const whyUnknown = {
436
+ unreadable: 'it could not be read',
437
+ unparseable: 'it is not JSON',
438
+ 'unexpected-shape': 'it is not shaped the way this tool expects',
439
+ 'other-marketplace': `it lists ${plugin.found}, a plugin of the same name from another marketplace`,
440
+ }[plugin.reason] ?? 'it could not be read';
441
+
442
+ const userFiles = plan({ root, source, editors: [], answers: {}, tier: {}, scope: 'user', delivery });
443
+ // What choosing the plugin takes back, worked out before anything is
444
+ // written so it is on screen with the files to write. Empty by default.
445
+ const retirePlan = plannedRetire(root, userFiles, { delivery, force: flags.force });
446
+
447
+ // Choosing the plugin without having it leaves Claude Code with neither.
448
+ // Said, not refused: the order of the two installs is the person's business.
449
+ const pluginWarning = !viaPlugin || pluginLive ? null
450
+ : `Claude Code is set to take its skills from the sws plugin, so ${CLAUDE_SKILLS}/ is not written, but `
451
+ + (plugin.detected === true ? 'the plugin is installed and disabled'
452
+ : plugin.detected === 'unknown' ? `this could not tell whether the plugin is installed (${plugin.registry}: ${whyUnknown})`
453
+ : plugin.reason === 'project-scope' ? 'the plugin is installed for one project only'
454
+ : 'the plugin was not found')
455
+ + '. Until that changes Claude Code has no SWS skills from either. See next[], or switch back with `install --no-claude-plugin`.';
368
456
 
369
457
  say(`\n${B('Stanford Web Services')} ${D('installing into your tools')}\n`);
370
458
  say(` ${B('Files to write')} ${D(root)}\n`);
@@ -372,8 +460,38 @@ if (mode === 'user') {
372
460
  const n = userFiles.filter((f) => f.path.startsWith(`${target}/`)).length;
373
461
  say(` ${target}/skills/ ${D(`${n} skills`)}`);
374
462
  }
463
+ if (viaPlugin) {
464
+ say(`\n ${B('Claude Code takes its skills from the sws plugin,')} ${D(`so ${CLAUDE_SKILLS}/`)}`);
465
+ say(` ${D(`is not written. ${deliveryFrom === 'record' ? 'Remembered from an earlier run.'
466
+ : flags['dry-run'] ? "A real run records the choice, so a plain 'install' keeps it."
467
+ : "Recorded, so a plain 'install' keeps it."}`)}`);
468
+ say(` ${D("'install --no-claude-plugin' switches back.")}`);
469
+ if (retirePlan.retired.length) {
470
+ say(`\n ${B('Files to remove')}\n`);
471
+ say(` ${CLAUDE_SKILLS}/ ${D(`${retirePlan.retired.length} copies this tool wrote there, unedited since`)}`);
472
+ }
473
+ if (retirePlan.kept.length) {
474
+ say(`\n ${B(`Kept in ${CLAUDE_SKILLS}/`)} ${D(`${retirePlan.kept.length}, edited since or a symbolic link`)}`);
475
+ // A real run names them once it has finished. A dry run has no later.
476
+ if (flags['dry-run']) for (const k of retirePlan.kept) say(` ${k.path}`);
477
+ }
478
+ }
375
479
  say(`\n ${D('Nothing per-site is written here. No standards, no AGENTS.md, no')}`);
376
480
  say(` ${D('manifest — there is no project yet. Run this once per machine.')}`);
481
+ if (pluginWarning) {
482
+ say(`\n ${B(plugin.detected === 'unknown' ? 'Could not tell whether the sws plugin is in place.'
483
+ : plugin.detected === true ? 'The sws plugin is installed and disabled.'
484
+ : 'The sws plugin is not in place yet.')} ${D('Until it is,')}`);
485
+ say(` ${D('Claude Code has no SWS skills from either source.')}`);
486
+ } else if (!viaPlugin && pluginLive) {
487
+ say(`\n ${B('The sws plugin is installed in Claude Code,')} ${D('and this writes the same')}`);
488
+ say(` ${D(`skills to ${CLAUDE_SKILLS}/, so Claude Code lists each one twice.`)}`);
489
+ say(` ${D("'install --claude-plugin' leaves it the plugin's copy and removes only the")}`);
490
+ say(` ${D('copies this tool wrote.')}`);
491
+ } else if (!viaPlugin && claudeInPlay && plugin.detected === 'unknown') {
492
+ say(`\n ${D('Could not tell whether the sws Claude Code plugin is installed:')}`);
493
+ say(` ${D(`${plugin.registry}: ${whyUnknown}.`)}`);
494
+ }
377
495
 
378
496
  // Only ever the skills we wrote. A home skills directory holds other people's
379
497
  // work, and the install record is what keeps the two apart.
@@ -383,7 +501,15 @@ if (mode === 'user') {
383
501
  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.',
384
502
  },
385
503
  ];
386
- if (detected.some((e) => e.id === 'claude-code')) {
504
+ if (hasClaude && pluginLive) {
505
+ // The plugin already registers this server for Claude Code, under the same
506
+ // command, so registering it again at user scope would only be a second
507
+ // definition of one server.
508
+ userNext.push({
509
+ kind: 'optional-mcp', command: 'npx -y @su-sws/synthetic-web-team-mcp --help',
510
+ why: 'An MCP server for these standards. The sws plugin already carries it for Claude Code, so nothing is needed there. For any other tool it can be registered in that 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.',
511
+ });
512
+ } else if (hasClaude) {
387
513
  userNext.push({
388
514
  kind: 'optional-mcp', command: 'claude mcp add --scope user sws -- npx -y @su-sws/synthetic-web-team-mcp',
389
515
  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.',
@@ -394,16 +520,85 @@ if (mode === 'user') {
394
520
  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.',
395
521
  });
396
522
  }
523
+ const mcpStep = userNext[userNext.length - 1];
524
+
525
+ // The plugin, as data, and only where Claude Code is one of the tools. At
526
+ // most one entry, and which one depends on what was found:
527
+ //
528
+ // not installed how to install it. Optional, unless the person
529
+ // already chose it, in which case it is what
530
+ // stands between Claude Code and any skills.
531
+ // installed, copies too how to stop every skill being listed twice
532
+ // could not tell the read-only command that settles it
533
+ //
534
+ // None of these is run from here. Each changes a person's Claude Code setup,
535
+ // or deletes files from their home directory, so each is theirs to run.
536
+ if (claudeInPlay) {
537
+ const carries = 'It carries the same skills as this install, plus read-only reviewers, entry points for starting, reviewing and shipping a site, and advisory checks that never block.';
538
+ if (plugin.detected === 'unknown') {
539
+ userNext.push({
540
+ kind: 'check-plugin', command: 'claude plugin list',
541
+ why: `Could not tell whether the sws Claude Code plugin is installed: ${plugin.registry}: ${whyUnknown}. This command only reads, and its answer settles it. `
542
+ + (viaPlugin
543
+ ? 'If it is not listed, Claude Code has no SWS skills until it is installed.'
544
+ : `If it is listed, \`install --claude-plugin\` stops Claude Code listing every skill twice. If it is not, the plugin is optional.`),
545
+ });
546
+ } else if (plugin.detected === false) {
547
+ const oneProject = plugin.reason === 'project-scope';
548
+ const partial = oneProject ? ' It is installed for one project only at the moment; this installs it for every project.' : '';
549
+ userNext.push(viaPlugin ? {
550
+ kind: 'install-plugin', command: PLUGIN_INSTALL,
551
+ why: `Claude Code is set to take its skills from the sws plugin, and the plugin ${oneProject ? 'is installed for one project only' : 'was not found'}, so until this is run Claude Code has no SWS skills${oneProject ? ' anywhere else' : ''}. It changes the person's Claude Code setup, so it is theirs to run; this tool never runs it. \`install --no-claude-plugin\` is the way back to a copy in ~/.claude/skills.`,
552
+ } : {
553
+ kind: 'optional-plugin', command: PLUGIN_INSTALL,
554
+ why: `The Claude Code plugin. Optional, never required. ${carries}${partial} It changes the person's Claude Code setup, so ask before running it; this tool never runs it. Afterwards run \`install --claude-plugin\`, or Claude Code lists every skill twice: once from the plugin and once from ~/.claude/skills.`,
555
+ });
556
+ } else if (plugin.enabled === false) {
557
+ // Switched off on purpose, most likely. Only worth a step when the
558
+ // person has also said the plugin is where the skills come from.
559
+ if (viaPlugin) {
560
+ userNext.push({
561
+ kind: 'enable-plugin', command: `claude plugin enable ${CLAUDE_PLUGIN.id}`,
562
+ why: 'Claude Code is set to take its skills from the sws plugin, and the plugin is installed and disabled, so Claude Code has no SWS skills. Enable it, or switch back with `install --no-claude-plugin`.',
563
+ });
564
+ }
565
+ } else if (!viaPlugin) {
566
+ userNext.push({
567
+ kind: 'retire-duplicate-skills', command: 'npx @su-sws/synthetic-web-team install --claude-plugin',
568
+ why: `The sws plugin is installed in Claude Code${plugin.version ? ` (${plugin.version})` : ''} and this install writes the same skills into ~/.claude/skills, so Claude Code lists every skill twice, updated through two channels, and a bare skill name resolves to the home copy. This leaves Claude Code to the plugin: it removes only the copies this tool wrote there and you have not edited, keeps ~/.agents/skills for every other tool, and remembers the choice. Optional, and \`install --no-claude-plugin\` undoes it.`,
569
+ });
570
+ }
571
+ }
572
+ const pluginStep = userNext.find((n) => ['optional-plugin', 'install-plugin', 'enable-plugin', 'retire-duplicate-skills', 'check-plugin'].includes(n.kind));
397
573
 
574
+ // `plugin` is what was found and what was chosen, in one place. `detected` is
575
+ // true, false or the string "unknown"; `delivery` is where Claude Code's
576
+ // skills come from as of this run, `skills` (a copy in .claude/skills) or
577
+ // `plugin`. `retired` and `kept` are what the choice took back and what it
578
+ // left: on a dry run, what it would.
398
579
  const emitUserJson = (wr) => console.log(JSON.stringify({
399
580
  ok: true, schema: 1, scope: 'user', mode: 'install',
400
581
  tool: '@su-sws/synthetic-web-team',
401
582
  version: contentVersion,
402
- warnings: versionWarning ? [versionWarning] : [],
583
+ warnings: [versionWarning, pluginWarning].filter(Boolean),
403
584
  root,
404
585
  source,
405
586
  written: Boolean(wr),
406
587
  editors: detected.map((e) => ({ id: e.id, label: e.label, evidence: e.evidence })),
588
+ plugin: {
589
+ id: plugin.id,
590
+ detected: plugin.detected,
591
+ delivery: viaPlugin ? 'plugin' : 'skills',
592
+ deliveryFrom,
593
+ reason: plugin.reason,
594
+ enabled: plugin.enabled,
595
+ version: plugin.version,
596
+ scope: plugin.scope,
597
+ registry: plugin.registry,
598
+ ...(plugin.found ? { found: plugin.found } : {}),
599
+ retired: (wr ?? retirePlan).retired,
600
+ kept: (wr ?? retirePlan).kept,
601
+ },
407
602
  counts: {
408
603
  files: userFiles.length,
409
604
  ...(wr ? {
@@ -412,12 +607,17 @@ if (mode === 'user') {
412
607
  } : {}),
413
608
  },
414
609
  files: wr ? wr.results : userFiles.map((x) => ({ path: x.path, status: 'planned' })),
415
- conflicts: wr?.conflicts ?? [],
610
+ // An edited copy that choosing the plugin would leave behind is a conflict
611
+ // whether or not this run writes, so a dry run lists it too.
612
+ conflicts: wr?.conflicts ?? retirePlan.kept.map((k) => k.path),
416
613
  orphans: wr?.orphans ?? [],
417
614
  next: userNext,
418
615
  notes: [
419
616
  'Skills only. Nothing per-site is installed at user scope.',
420
617
  'Uninstall with `--remove`, which deletes only what the install record lists.',
618
+ ...(viaPlugin ? [
619
+ `Claude Code takes its skills from the sws plugin, so ${CLAUDE_SKILLS}/ under the home directory is not written. Any other tool that reads that directory loses its copy too: whether VS Code Copilot or Cline read it at user level has not been established. .agents/skills is written as always. \`install --no-claude-plugin\` switches back.`,
620
+ ] : []),
421
621
  ],
422
622
  }, null, 2));
423
623
 
@@ -429,7 +629,8 @@ if (mode === 'user') {
429
629
 
430
630
  if (interactive) {
431
631
  const rl = createInterface({ input: process.stdin, output: process.stdout });
432
- const go = (await rl.question(`\n Write these ${userFiles.length} files? ${D('[Y/n]')}: `)).trim().toLowerCase();
632
+ const alsoRemove = retirePlan.retired.length ? ` and remove ${retirePlan.retired.length} from ${CLAUDE_SKILLS}/` : '';
633
+ const go = (await rl.question(`\n Write these ${userFiles.length} files${alsoRemove}? ${D('[Y/n]')}: `)).trim().toLowerCase();
433
634
  await rl.close();
434
635
  if (go && !go.startsWith('y')) {
435
636
  say('\n Nothing written.\n');
@@ -437,24 +638,54 @@ if (mode === 'user') {
437
638
  }
438
639
  }
439
640
 
440
- const wr = write(root, userFiles, { force: flags.force, version: contentVersion, scope: 'user' });
641
+ const wr = write(root, userFiles, { force: flags.force, version: contentVersion, scope: 'user', delivery });
642
+
643
+ // Copies kept in a directory that is no longer written are conflicts too, but
644
+ // not ones a newer version would resolve, so they get their own words below.
645
+ const keptPaths = new Set(wr.kept.map((k) => k.path));
646
+ const writeConflicts = wr.conflicts.filter((c) => !keptPaths.has(c));
441
647
 
442
- if (wr.created === 0 && wr.updated === 0) {
648
+ if (wr.created === 0 && wr.updated === 0 && wr.retired.length === 0) {
443
649
  say(`\n ${B('Already installed.')} ${wr.unchanged} skills, nothing to change.\n`);
444
650
  } else {
445
651
  const parts = [];
446
652
  if (wr.created) parts.push(`${wr.created} created`);
447
653
  if (wr.updated) parts.push(`${wr.updated} updated`);
448
654
  if (wr.unchanged) parts.push(`${wr.unchanged} unchanged`);
655
+ if (wr.retired.length) parts.push(`${wr.retired.length} removed from ${CLAUDE_SKILLS}/`);
449
656
  if (wr.conflicts.length) parts.push(`${wr.conflicts.length} left alone`);
450
657
  say(`\n ${B('Done.')} ${parts.join(', ')}.\n`);
451
658
  }
452
659
 
453
- if (wr.conflicts.length) {
660
+ if (wr.retired.length) {
661
+ say(` ${B(`Removed ${wr.retired.length} skill(s) from ${CLAUDE_SKILLS}/.`)} ${D(pluginLive
662
+ ? 'Claude Code reads them from' : 'Claude Code will read them from')}`);
663
+ say(` ${D(`the sws plugin ${pluginLive ? 'now' : 'once it is in place'}. Only copies this tool wrote and you had not`)}`);
664
+ say(` ${D('edited were removed; every other skill in that directory is untouched.')}`);
665
+ say('');
666
+ }
667
+ if (wr.kept.length) {
668
+ const editedKept = wr.kept.filter((k) => k.reason !== 'symlink');
669
+ const linkedKept = wr.kept.filter((k) => k.reason === 'symlink');
670
+ if (editedKept.length) {
671
+ say(` ${B(`Kept in ${CLAUDE_SKILLS}/ because you edited them:`)}`);
672
+ for (const k of editedKept) say(` ${k.path}`);
673
+ say(` ${D('Your edit is your work. Claude Code lists each of these beside the')}`);
674
+ say(` ${D("plugin's copy until it is gone. Re-run with --force to remove them too.")}`);
675
+ }
676
+ if (linkedKept.length) {
677
+ say(` ${B(`Kept in ${CLAUDE_SKILLS}/ because they are symbolic links:`)}`);
678
+ for (const k of linkedKept) say(` ${k.path}`);
679
+ say(` ${D('A link is never removed, with or without --force.')}`);
680
+ }
681
+ say('');
682
+ }
683
+
684
+ if (writeConflicts.length) {
454
685
  // A link is never written through, and --force does not change that, so it
455
686
  // must not be listed as an edit that --force would discard.
456
687
  const linked = new Set(wr.results.filter((r) => r.reason === 'symlink').map((r) => r.path));
457
- const edited = wr.conflicts.filter((c) => !linked.has(c));
688
+ const edited = writeConflicts.filter((c) => !linked.has(c));
458
689
  if (edited.length) {
459
690
  say(` ${B('Left alone because you edited them:')}`);
460
691
  for (const c of edited) say(` ${c}`);
@@ -471,7 +702,25 @@ if (mode === 'user') {
471
702
  say(` ${B('Next')}`);
472
703
  say(` 1. Open a Stanford project and ask your agent to run the sws-install skill,`);
473
704
  say(` ${D('or: npx @su-sws/synthetic-web-team init (new site) / add . (existing)')}`);
474
- say(` 2. ${D('Optional MCP server: ' + userNext[userNext.length - 1].command)}`);
705
+ say(` 2. ${D('Optional MCP server: ' + mcpStep.command)}`);
706
+ if (pluginStep) {
707
+ // The same step next[] carries, in a sentence. The install is two commands,
708
+ // so they are printed one to a line rather than joined.
709
+ const lines = pluginStep.command === PLUGIN_INSTALL ? CLAUDE_PLUGIN.install : [pluginStep.command];
710
+ const lead = {
711
+ 'optional-plugin': D('Optional Claude Code plugin, with the same skills and reviewers on top:'),
712
+ 'install-plugin': 'Install the Claude Code plugin. Claude Code has no SWS skills until then:',
713
+ 'enable-plugin': 'Enable the Claude Code plugin. Claude Code has no SWS skills until then:',
714
+ 'retire-duplicate-skills': 'Claude Code lists every skill twice. To leave it the plugin\'s copy:',
715
+ 'check-plugin': D('Find out whether the Claude Code plugin is installed:'),
716
+ }[pluginStep.kind];
717
+ const dim = pluginStep.kind === 'optional-plugin' || pluginStep.kind === 'check-plugin' ? D : (x) => x;
718
+ say(` 3. ${lead}`);
719
+ for (const l of lines) say(` ${dim(l)}`);
720
+ if (pluginStep.kind === 'optional-plugin') {
721
+ say(` ${D("Then 'install --claude-plugin', so Claude Code lists each skill once.")}`);
722
+ }
723
+ }
475
724
  say('');
476
725
  say(` ${D('To uninstall: npx @su-sws/synthetic-web-team install --remove')}`);
477
726
  say(` ${D('It removes only the files this install recorded, so anything else in')}`);
@@ -568,6 +817,18 @@ if (!chosen.length) {
568
817
  say(` ${D('and the skills come from the once-per-machine install.')}`);
569
818
  }
570
819
 
820
+ // The Claude Code plugin, seen from a project: whether it is there, and one
821
+ // optional pointer at it when it is not. A project install writes no skills, so
822
+ // there is no copy to reconcile here and nothing else to say. The pointer is
823
+ // for the root layout only. A contained project asked for nothing outside
824
+ // .sws/, and that includes advice about the rest of someone's machine.
825
+ const claudePlugin = detectClaudePlugin();
826
+ //
827
+ // Only when it is plainly absent. Installed for one project reads as `false`
828
+ // too, and that project may be this one, so that case gets no pointer either.
829
+ const pointAtPlugin = !contained && chosen.some((e) => e.id === 'claude-code')
830
+ && claudePlugin.detected === false && claudePlugin.reason !== 'project-scope';
831
+
571
832
  // --- the machine-readable result --------------------------------------------
572
833
  //
573
834
  // One JSON document on stdout, defined once and used by both the dry-run and the
@@ -634,6 +895,12 @@ function emitJson({ written, write: wr }) {
634
895
  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_DIR}/. It was added next to any servers you already had. Remove the entry if you do not want it, and later updates will leave it out.`,
635
896
  });
636
897
  }
898
+ if (pointAtPlugin) {
899
+ next.push({
900
+ kind: 'optional-plugin', command: PLUGIN_INSTALL,
901
+ why: 'The Claude Code plugin. Optional, never required: this project works without it, because the contract and the standards are already here. It carries the skills, plus read-only reviewers, entry points for starting, reviewing and shipping a site, and advisory checks that never block. It changes the person\'s Claude Code setup, so ask before running it; this tool never runs it. If the skills are also installed in ~/.claude/skills, run `install --claude-plugin` afterwards so Claude Code lists each one once.',
902
+ });
903
+ }
637
904
  // `npx sws` has to resolve to node_modules/.bin/sws. Unscoped `sws` on the
638
905
  // public registry is an unrelated package, so this step is what makes the
639
906
  // verify step below run OUR CLI rather than a stranger's.
@@ -675,6 +942,20 @@ function emitJson({ written, write: wr }) {
675
942
  tier: { tier: tier.tier, because: tier.because, adds: tier.adds },
676
943
  answers,
677
944
  editors: chosen.map((e) => ({ id: e.id, label: e.label, emits: e.emits })),
945
+ // The same field `install` reports, without `retired` and `kept`: a project
946
+ // install never touches a skills directory. `delivery` is read from the
947
+ // per-machine install record, which is where that choice is kept.
948
+ plugin: {
949
+ id: claudePlugin.id,
950
+ detected: claudePlugin.detected,
951
+ delivery: readDelivery(homedir()) ? 'plugin' : 'skills',
952
+ reason: claudePlugin.reason,
953
+ enabled: claudePlugin.enabled,
954
+ version: claudePlugin.version,
955
+ scope: claudePlugin.scope,
956
+ registry: claudePlugin.registry,
957
+ ...(claudePlugin.found ? { found: claudePlugin.found } : {}),
958
+ },
678
959
  counts: {
679
960
  files: files.length,
680
961
  skills: skillCount,
@@ -892,6 +1173,12 @@ if (depResult.status === 'added' || depResult.status === 'present') {
892
1173
  say(` ${step()}. Check it: npx sws doctor`);
893
1174
  say(` ${step()}. Fill in the blanks in .sws/manifest.yml: owners, Siteimprove, ODA review.`);
894
1175
  say('');
1176
+ if (pointAtPlugin) {
1177
+ say(` ${D('Optional, for Claude Code: the sws plugin adds reviewers, entry points and')}`);
1178
+ say(` ${D('advisory checks to the same skills. This project works without it.')}`);
1179
+ for (const c of CLAUDE_PLUGIN.install) say(` ${D(c)}`);
1180
+ say('');
1181
+ }
895
1182
  say(` ${D('Everything is advisory. The only thing that fails a build is a committed')}`);
896
1183
  say(` ${D('credential. If something cannot be fixed now, record it in')}`);
897
1184
  say(` ${D('.sws/acknowledged.yml with a reason and a review date.')}`);
@@ -4,7 +4,7 @@
4
4
  // editor somebody does not use is a small harm; failing to offer one they do
5
5
  // use is a bigger one.
6
6
 
7
- import { existsSync } from 'node:fs';
7
+ import { existsSync, readFileSync } from 'node:fs';
8
8
  import { join } from 'node:path';
9
9
  import { homedir } from 'node:os';
10
10
 
@@ -93,6 +93,116 @@ export function detect(root = process.cwd()) {
93
93
  });
94
94
  }
95
95
 
96
+ // --- the Claude Code plugin --------------------------------------------------
97
+ //
98
+ // The same skills also ship as a Claude Code plugin. With the plugin enabled
99
+ // AND the copies `install` writes into ~/.claude/skills, Claude Code lists
100
+ // every skill twice, from two update channels, and a bare skill name resolves
101
+ // to the home copy. So the wizard needs to know whether the plugin is there.
102
+ //
103
+ // Its name and marketplace, and the commands that install it. The wizard
104
+ // reports these and never runs them: installing a plugin changes a person's
105
+ // Claude Code setup, which is theirs to change.
106
+ export const CLAUDE_PLUGIN = {
107
+ name: 'sws',
108
+ marketplace: 'su-sws',
109
+ id: 'sws@su-sws',
110
+ repository: 'SU-SWS/synthetic-web-team',
111
+ install: [
112
+ 'claude plugin marketplace add SU-SWS/synthetic-web-team',
113
+ 'claude plugin install sws@su-sws',
114
+ ],
115
+ };
116
+
117
+ /**
118
+ * Is the sws plugin installed in Claude Code, for this person?
119
+ *
120
+ * READ ONLY, AND IT SPAWNS NOTHING. It reads the registry Claude Code keeps of
121
+ * installed plugins, `plugins/installed_plugins.json` under the Claude config
122
+ * directory. `claude plugin list --json` would be the documented route, but it
123
+ * needs the binary on PATH and a child process, and a wizard that runs inside
124
+ * an agent's shell should not start the agent's own CLI to ask a question a
125
+ * file answers.
126
+ *
127
+ * That file is Claude Code's, not ours, and its shape is not a published
128
+ * contract. So every way it can surprise us is an answer rather than a throw,
129
+ * and there are three answers, not two:
130
+ *
131
+ * true listed for the whole machine (scope `user` or `managed`)
132
+ * false no registry at all, or a registry that does not list it, or one
133
+ * that lists it for a single project only. A project install does
134
+ * not cover the person's other projects, so the home copies still
135
+ * matter and nothing here should suggest retiring them.
136
+ * 'unknown' the registry is there and could not be read, is not JSON, or
137
+ * is not shaped the way this expects; or it lists a plugin named
138
+ * sws from some other marketplace. Guessing either way is worse
139
+ * than saying so: `false` would recommend installing something
140
+ * that may be installed, `true` would recommend deleting copies
141
+ * that may be the only ones.
142
+ *
143
+ * `enabled` comes from `enabledPlugins` in the same directory's settings.json,
144
+ * and is only looked at once the plugin is found. An installed plugin someone
145
+ * switched off delivers no skills, so it must not count as a second copy.
146
+ *
147
+ * `home` and `env` are parameters so this can be pointed at a scratch
148
+ * directory. CLAUDE_CONFIG_DIR relocates the whole config directory and
149
+ * CLAUDE_CODE_PLUGIN_CACHE_DIR the plugins directory inside it; both are
150
+ * honoured, because a detector that only ever read ~/.claude would answer
151
+ * `false` for exactly the people who moved it.
152
+ */
153
+ export function detectClaudePlugin({ home = homedir(), env = process.env } = {}) {
154
+ const configDir = env.CLAUDE_CONFIG_DIR || join(home, '.claude');
155
+ const registry = join(env.CLAUDE_CODE_PLUGIN_CACHE_DIR || join(configDir, 'plugins'), 'installed_plugins.json');
156
+ const answer = (detected, reason, more = {}) => ({
157
+ id: CLAUDE_PLUGIN.id, detected, reason, version: null, scope: null, enabled: null, registry, ...more,
158
+ });
159
+ const isObj = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
160
+
161
+ let raw;
162
+ try {
163
+ raw = readFileSync(registry, 'utf8');
164
+ } catch (err) {
165
+ // No file is the ordinary state of a machine with no plugins, or with no
166
+ // Claude Code. Anything else (a directory in its place, no permission) is
167
+ // a registry we could not read, which is not the same as an empty one.
168
+ return err?.code === 'ENOENT' || err?.code === 'ENOTDIR'
169
+ ? answer(false, 'no-registry')
170
+ : answer('unknown', 'unreadable');
171
+ }
172
+
173
+ let json;
174
+ try { json = JSON.parse(raw); } catch { return answer('unknown', 'unparseable'); }
175
+ if (!isObj(json) || !isObj(json.plugins)) return answer('unknown', 'unexpected-shape');
176
+
177
+ const listed = json.plugins[CLAUDE_PLUGIN.id];
178
+ if (listed === undefined) {
179
+ // Same plugin name, another marketplace: a fork, or someone else's `sws`.
180
+ const other = Object.keys(json.plugins).find((k) => k.startsWith(`${CLAUDE_PLUGIN.name}@`));
181
+ return other ? answer('unknown', 'other-marketplace', { found: other }) : answer(false, 'not-listed');
182
+ }
183
+
184
+ // One entry per scope it is installed at. A single object is tolerated.
185
+ const entries = Array.isArray(listed) ? listed : [listed];
186
+ if (!entries.length) return answer(false, 'not-listed');
187
+ if (!entries.every((e) => isObj(e) && typeof e.scope === 'string')) return answer('unknown', 'unexpected-shape');
188
+
189
+ const text = (v) => (typeof v === 'string' ? v : null);
190
+ const wide = entries.find((e) => e.scope === 'user' || e.scope === 'managed');
191
+ if (!wide) {
192
+ return entries.every((e) => e.scope === 'project' || e.scope === 'local')
193
+ ? answer(false, 'project-scope', { version: text(entries[0].version), scope: entries[0].scope })
194
+ : answer('unknown', 'unexpected-shape');
195
+ }
196
+
197
+ let enabled = 'unknown';
198
+ try {
199
+ const flag = JSON.parse(readFileSync(join(configDir, 'settings.json'), 'utf8'))?.enabledPlugins?.[CLAUDE_PLUGIN.id];
200
+ if (flag === true || flag === false) enabled = flag;
201
+ } catch { /* no settings file, or one that is not plain JSON: unknown */ }
202
+
203
+ return answer(true, 'listed', { version: text(wide.version), scope: wide.scope, enabled });
204
+ }
205
+
96
206
  // Tier derivation. The person is asked about the WORLD, never about MinSec.
97
207
  // Nobody should have to read a security matrix to start a website.
98
208
  export function deriveTier({ collectsPersonalData, authenticates, payments, regulated }) {