@codewizard-dt/bootstrap 5.3.0 → 6.0.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.
Files changed (95) hide show
  1. package/LICENSE.md +105 -0
  2. package/README.md +22 -3
  3. package/bin/cli.js +16 -0
  4. package/lib/hooks/README.md +124 -3
  5. package/lib/hooks/claude-settings-guard.js +8 -2
  6. package/lib/prompts/README.md +1 -1
  7. package/lib/prompts/migrate-wiki.md +7 -7
  8. package/lib/scripts/README.md +111 -10
  9. package/lib/scripts/bootstrap-prefs-tui.js +1222 -0
  10. package/lib/scripts/install-global.sh +137 -6
  11. package/lib/scripts/migrate-project.sh +53 -11
  12. package/lib/scripts/rename-wiki-ids.js +232 -0
  13. package/lib/scripts/templates/CLAUDE-wiki.md +6 -6
  14. package/lib/scripts/templates/bootstrap-prefs-schema.json +11 -2
  15. package/lib/scripts/templates/settings-deny.json +1 -1
  16. package/lib/scripts/templates/settings-sandbox-unattended.json +36 -0
  17. package/lib/scripts/templates/settings-sandbox.json +7 -0
  18. package/lib/scripts/templates/wiki/conventions.md +9 -9
  19. package/lib/scripts/templates/wiki/dashboard.html +527 -23
  20. package/lib/scripts/templates/wiki/index.md +2 -2
  21. package/lib/scripts/templates/wiki/work/bugs/lifecycle.md +1 -1
  22. package/lib/scripts/templates/wiki/work/decisions/index.md +12 -4
  23. package/lib/scripts/templates/wiki/work/decisions/lifecycle.md +11 -9
  24. package/lib/scripts/templates/wiki/work/requirements/index.md +12 -4
  25. package/lib/scripts/templates/wiki/work/requirements/lifecycle.md +8 -8
  26. package/lib/scripts/templates/wiki/work/roadmaps/index.md +11 -3
  27. package/lib/scripts/templates/wiki/work/roadmaps/lifecycle.md +7 -5
  28. package/lib/scripts/templates/wiki/work/tasks/index.md +1 -1
  29. package/lib/scripts/templates/wiki/work/tasks/lifecycle.md +16 -8
  30. package/lib/scripts/templates/wiki/work/uat/lifecycle.md +3 -3
  31. package/lib/scripts/wiki-dashboard-server.js +98 -0
  32. package/lib/skills/README.md +27 -22
  33. package/lib/skills/_shared/ARCHIVE-WORK-ITEM.md +103 -0
  34. package/lib/skills/_shared/ID-RESOLUTION.md +142 -0
  35. package/lib/skills/_shared/SKILL-BOILERPLATE.md +50 -0
  36. package/lib/skills/adr-assess/SKILL.md +112 -0
  37. package/lib/skills/{decision-create → adr-create}/SKILL.md +26 -26
  38. package/lib/skills/adr-deprecate/SKILL.md +190 -0
  39. package/lib/skills/adr-extract/SKILL.md +255 -0
  40. package/lib/skills/{decision-finalize → adr-finalize}/SKILL.md +38 -38
  41. package/lib/skills/{decision-next → adr-next}/SKILL.md +20 -19
  42. package/lib/skills/{decision-walkthrough → adr-walkthrough}/SKILL.md +23 -29
  43. package/lib/skills/architecture-audit/SKILL.md +1 -1
  44. package/lib/skills/autopilot/SKILL.md +110 -0
  45. package/lib/skills/bootstrap-config/SKILL.md +1 -1
  46. package/lib/skills/bug-assess/SKILL.md +3 -3
  47. package/lib/skills/bug-close/SKILL.md +13 -27
  48. package/lib/skills/{bug-file → bug-create}/SKILL.md +10 -14
  49. package/lib/skills/bug-triage/SKILL.md +5 -19
  50. package/lib/skills/demo/SKILL.md +1 -1
  51. package/lib/skills/extract-feature/SKILL.md +3 -3
  52. package/lib/skills/git-commit/SKILL.md +4 -4
  53. package/lib/skills/port-feature/SKILL.md +3 -3
  54. package/lib/skills/power-mode/SKILL.md +42 -49
  55. package/lib/skills/prd-assess/SKILL.md +105 -0
  56. package/lib/skills/{req-compile → prd-compile}/SKILL.md +6 -13
  57. package/lib/skills/{req-create → prd-create}/SKILL.md +19 -19
  58. package/lib/skills/prd-deprecate/SKILL.md +173 -0
  59. package/lib/skills/{req-finalize → prd-finalize}/SKILL.md +20 -29
  60. package/lib/skills/primer/SKILL.md +2 -2
  61. package/lib/skills/research/SKILL.md +3 -3
  62. package/lib/skills/roadmap-assess/SKILL.md +20 -20
  63. package/lib/skills/roadmap-create/SKILL.md +19 -29
  64. package/lib/skills/roadmap-next/SKILL.md +16 -28
  65. package/lib/skills/security-audit/SKILL.md +1 -1
  66. package/lib/skills/tackle/SKILL.md +13 -15
  67. package/lib/skills/{task-audit → task-assess}/SKILL.md +34 -44
  68. package/lib/skills/task-close/SKILL.md +73 -0
  69. package/lib/skills/{task-add → task-create}/SKILL.md +25 -24
  70. package/lib/skills/uat-assess/SKILL.md +124 -0
  71. package/lib/skills/uat-auto/SKILL.md +9 -7
  72. package/lib/skills/uat-auto-plus/SKILL.md +2 -2
  73. package/lib/skills/{uat-generate → uat-create}/SKILL.md +10 -12
  74. package/lib/skills/uat-skip/SKILL.md +5 -9
  75. package/lib/skills/uat-walk/SKILL.md +2 -2
  76. package/lib/skills/uat-walk/UAT-CORE.md +29 -16
  77. package/lib/skills/update-docs/SKILL.md +1 -1
  78. package/lib/skills/usage-report/SKILL.md +52 -0
  79. package/lib/skills/usage-report/scripts/pricing.json +22 -0
  80. package/lib/skills/usage-report/scripts/usage-report.js +518 -0
  81. package/lib/skills/whats-next/SKILL.md +177 -0
  82. package/lib/skills/wiki-archive/SKILL.md +12 -23
  83. package/lib/skills/wiki-lint/SKILL.md +23 -13
  84. package/lib/skills/wiki-query/SKILL.md +1 -1
  85. package/lib/skills/wiki-rotate-log/SKILL.md +1 -1
  86. package/lib/skills/wiki-tidy/SKILL.md +6 -9
  87. package/package.json +3 -3
  88. package/lib/scripts/templates/wiki/work/decisions/archive/index.md +0 -10
  89. package/lib/scripts/templates/wiki/work/requirements/archive/index.md +0 -10
  90. package/lib/scripts/templates/wiki/work/roadmaps/archive/index.md +0 -10
  91. package/lib/skills/req-extract-decisions/SKILL.md +0 -241
  92. package/lib/skills/req-retire/SKILL.md +0 -185
  93. package/lib/skills/req-update/SKILL.md +0 -265
  94. package/lib/skills/task-trash/SKILL.md +0 -115
  95. package/lib/skills/task-update/SKILL.md +0 -136
@@ -44,11 +44,19 @@ mkdir -p "$GLOBAL_SKILLS_DIR"
44
44
  # Rsync skills from the template to ~/.claude/skills/
45
45
  rsync -a --checksum --omit-dir-times --out-format=' + %n' --exclude='.DS_Store' "$TEMPLATE_DIR/lib/skills/" "$GLOBAL_SKILLS_DIR/"
46
46
 
47
- # Detect stale skill folders from the wiki rename
47
+ # Detect stale skill folders from the wiki rename. A name that ships again in
48
+ # the source tree just installed above is LIVE, not stale (a later rename can
49
+ # reuse an old name, e.g. prd-*) — never list, prompt about, or remove it.
50
+ SOURCE_SKILLS_DIR="$TEMPLATE_DIR/lib/skills"
48
51
  ORPHAN_FOUND=()
52
+ ORPHAN_RM_ARGS=""
49
53
  for skill in "${ORPHAN_SKILLS[@]}"; do
54
+ if [ -f "$SOURCE_SKILLS_DIR/$skill/SKILL.md" ]; then
55
+ continue
56
+ fi
50
57
  if [ -d "$GLOBAL_SKILLS_DIR/$skill" ]; then
51
58
  ORPHAN_FOUND+=("$GLOBAL_SKILLS_DIR/$skill")
59
+ ORPHAN_RM_ARGS="$ORPHAN_RM_ARGS ~/.claude/skills/$skill"
52
60
  fi
53
61
  done
54
62
 
@@ -75,7 +83,7 @@ if [ ${#ORPHAN_FOUND[@]} -gt 0 ]; then
75
83
  done
76
84
  echo "Removed."
77
85
  else
78
- echo "Skipped. To remove manually: rm -rf ~/.claude/skills/{adr-create,adr-finalize,adr-next,adr-walkthrough,prd-create,prd-finalize,prd-extract-decisions,prd-update,prd-trash,prd-compile}"
86
+ echo "Skipped. To remove manually: rm -rf$ORPHAN_RM_ARGS"
79
87
  fi
80
88
  fi
81
89
 
@@ -155,6 +163,27 @@ else
155
163
  fi
156
164
  echo ""
157
165
 
166
+ # 6b. Install the unattended-runs sandbox profile (TASK-031) into
167
+ # ~/.claude/templates/. COPIED ONLY — never merged into settings.json.
168
+ #
169
+ # A user-scope `sandbox.enabled: true` would sandbox every session, human
170
+ # ones included, and the installer plus every nested-`claude` script break
171
+ # inside a sandboxed Bash by design. The profile is instead a standalone
172
+ # settings file a launcher passes per session with `claude --settings`, at the
173
+ # same place that passes --dangerously-skip-permissions (power-mode,
174
+ # uat-auto-plus). Nothing reads it unless a launcher opts in, so it is inert
175
+ # on platforms with no sandbox backend. A missing template only warns:
176
+ # `set -e` must not abort the local installs over an optional file.
177
+ echo "Installing unattended-runs sandbox profile (~/.claude/templates/settings-sandbox-unattended.json)..."
178
+ if [ -f "$SCRIPT_DIR/templates/settings-sandbox-unattended.json" ]; then
179
+ mkdir -p "$HOME/.claude/templates"
180
+ cp "$SCRIPT_DIR/templates/settings-sandbox-unattended.json" "$HOME/.claude/templates/settings-sandbox-unattended.json"
181
+ echo " Installed. Start unattended runs with: claude --settings ~/.claude/templates/settings-sandbox-unattended.json"
182
+ else
183
+ echo "Warning: settings-sandbox-unattended.json not found — the unattended-runs sandbox profile was not installed." >&2
184
+ fi
185
+ echo ""
186
+
158
187
  # 7. Settle the skill-consent preferences that have never been answered.
159
188
  #
160
189
  # These are the schema's `consumer: skill` keys: the ones that change what a
@@ -260,7 +289,7 @@ else
260
289
  # back to the schema's value.
261
290
  if ! prefs_stored_global uatGenerate.promoteTests; then
262
291
  echo ""
263
- echo " Where should /uat-generate write the unit tests it promotes out of UAT cases?"
292
+ echo " Where should /uat-create write the unit tests it promotes out of UAT cases?"
264
293
  echo " A dedicated folder keeps the suite in one place; beside puts src/parse.ts's test at"
265
294
  echo " src/parse.test.ts. A project's existing layout always wins over this answer."
266
295
  TEST_LOCATION_ANSWER="$(prompt_letter_choice skip \
@@ -306,6 +335,102 @@ else
306
335
  fi
307
336
  echo ""
308
337
 
338
+ # 7b. Offer to scaffold the Claude Code sandbox block into ~/.claude/settings.json.
339
+ #
340
+ # A separate step from 7 because it is not a `consumer: skill` key: the
341
+ # answer decides whether THIS INSTALLER edits settings.json, and `yes` runs a
342
+ # merge instead of only recording a value. Same store, same helpers, same
343
+ # rules though — the question is asked only while sandbox.scaffold has no
344
+ # STORED global answer (prefs_stored_global, not prefs_get: the key has no
345
+ # schema default, but the probe keeps this consistent with step 7), `skip`
346
+ # records nothing so a bare Enter or EOF leaves it open, and a non-interactive
347
+ # run prints one note and writes nothing.
348
+ #
349
+ # THE MERGE NEVER OVERWRITES. `--set-key sandbox` keeps a pre-existing
350
+ # "sandbox" key that differs from the template and warns instead (the warning
351
+ # is on stderr; 2>&1 folds it into $SANDBOX_OUT so the user sees it). `yes`
352
+ # still records true in that case — the user's consent to scaffold is real,
353
+ # and the answer settles the question — but the restart reminder is printed
354
+ # only when the key was actually set, since nothing changed otherwise.
355
+ #
356
+ # PLATFORM GUARD. The sandbox is macOS (Seatbelt) / Linux / WSL2 only. Native
357
+ # Windows shells (MINGW/MSYS/CYGWIN) are skipped with a note and record
358
+ # nothing, because writing a block the platform cannot honor would be a false
359
+ # "configured". Linux and WSL2 additionally need bubblewrap and socat; their
360
+ # absence only warns, since the user can install them after the merge.
361
+ #
362
+ # GUARDED AS A WHOLE, like step 8: any failure warns and the install
363
+ # continues, because `set -euo pipefail` must not abort the local installs
364
+ # over an optional convenience. SANDBOX_CONFIGURED gates the summary token
365
+ # below (BUG-0010) so it names only what actually ran.
366
+ SANDBOX_CONFIGURED=0
367
+
368
+ configure_sandbox() {
369
+ local answer
370
+ echo "Checking Claude Code sandbox (sandbox.scaffold)..."
371
+ if ! has_tty; then
372
+ echo " Non-interactive terminal: skipping the sandbox question."
373
+ return 0
374
+ fi
375
+ if prefs_stored_global sandbox.scaffold; then
376
+ echo " Already answered — nothing to ask."
377
+ return 0
378
+ fi
379
+
380
+ echo ""
381
+ echo " Enable Claude Code's sandbox in ~/.claude/settings.json?"
382
+ echo " It adds OS-level containment for Bash and every process it spawns."
383
+ echo " docker commands are incompatible with the sandbox, so docker and docker-compose are"
384
+ echo " pre-listed under sandbox.excludedCommands. If another command fails under the sandbox,"
385
+ echo " add it to excludedCommands. A \"sandbox\" key you already have is never overwritten."
386
+ answer="$(prompt_letter_choice skip " [y]es / [n]o / [s]kip for now: " yes no skip)"
387
+ case "$answer" in
388
+ yes)
389
+ case "$(uname -s)" in
390
+ MINGW*|MSYS*|CYGWIN*)
391
+ echo " The sandbox is not supported on native Windows (use WSL2) — skipping; you will be asked again next sync."
392
+ return 0
393
+ ;;
394
+ Linux*)
395
+ if ! command -v bwrap >/dev/null 2>&1 || ! command -v socat >/dev/null 2>&1; then
396
+ echo " Warning: the sandbox on Linux/WSL2 needs bubblewrap and socat, and one or both are missing." >&2
397
+ echo " Install them (e.g. sudo apt-get install bubblewrap socat, or sudo dnf install bubblewrap socat), then restart Claude Code." >&2
398
+ fi
399
+ ;;
400
+ esac
401
+ if [ ! -f "$SCRIPT_DIR/templates/settings-sandbox.json" ]; then
402
+ echo " Warning: templates/settings-sandbox.json not found — sandbox not configured." >&2
403
+ return 1
404
+ fi
405
+ if ! SANDBOX_OUT="$(node "$SCRIPT_DIR/merge-settings-deny.js" --set-key sandbox --set-value "$(cat "$SCRIPT_DIR/templates/settings-sandbox.json")" 2>&1)"; then
406
+ echo "$SANDBOX_OUT" >&2
407
+ return 1
408
+ fi
409
+ echo "$SANDBOX_OUT"
410
+ prefs_set sandbox.scaffold --global true
411
+ echo " sandbox.scaffold = true"
412
+ SANDBOX_CONFIGURED=1
413
+ case "$SANDBOX_OUT" in
414
+ *'"sandbox" set'*)
415
+ echo " Restart Claude Code sessions to pick up the sandbox."
416
+ ;;
417
+ esac
418
+ ;;
419
+ no)
420
+ prefs_set sandbox.scaffold --global false
421
+ echo " sandbox.scaffold = false"
422
+ ;;
423
+ *)
424
+ echo " sandbox.scaffold left unanswered — settings.json is unchanged, and you will be asked again next sync."
425
+ ;;
426
+ esac
427
+ }
428
+
429
+ if ! configure_sandbox; then
430
+ echo "Warning: sandbox setup failed — hooks, skills, and settings were installed; re-run 'bootstrap install' to retry." >&2
431
+ fi
432
+ echo ""
433
+
309
434
  # 8. Ensure global MCP servers are installed (user scope, non-interactive) —
310
435
  # LAST because it is the only network-dependent step, and guarded so a
311
436
  # failure warns instead of aborting the local installs above.
@@ -325,8 +450,14 @@ fi
325
450
  # is skipped entirely under --skip-mcps and claiming it otherwise overstates
326
451
  # the summary's own job (evidence of what ran) on the most common invocation
327
452
  # path — both setup-project.sh and update-project.sh call this with --skip-mcps.
453
+ # "sandbox" is gated the same way on SANDBOX_CONFIGURED: step 7b only sets it
454
+ # when the user answered yes and the merge actually ran, so a non-tty run, a
455
+ # no/skip, or a platform skip never claims it.
456
+ SUMMARY_TOKENS="hooks + skills + deny list + hooks wiring + file suggestion + preferences"
457
+ if [ "$SANDBOX_CONFIGURED" -eq 1 ]; then
458
+ SUMMARY_TOKENS="$SUMMARY_TOKENS + sandbox"
459
+ fi
328
460
  if [ "$SKIP_MCPS" = false ]; then
329
- echo "Global setup complete (hooks + skills + deny list + hooks wiring + file suggestion + preferences + MCPs)."
330
- else
331
- echo "Global setup complete (hooks + skills + deny list + hooks wiring + file suggestion + preferences)."
461
+ SUMMARY_TOKENS="$SUMMARY_TOKENS + MCPs"
332
462
  fi
463
+ echo "Global setup complete ($SUMMARY_TOKENS)."
@@ -40,7 +40,7 @@ fi
40
40
 
41
41
  PROJECT_DIR="$(resolve_project_dir "$1")" || exit 1
42
42
  shift
43
- EXTRA_CONTEXT="${*}"
43
+ EXTRA_CONTEXT="$*"
44
44
 
45
45
  # --- Preflight 1: legacy content must exist -------------------------------
46
46
  LEGACY_FAMILIES=(tasks uat adr prd bugs roadmaps)
@@ -55,18 +55,30 @@ for fam in "${LEGACY_FAMILIES[@]}"; do
55
55
  fi
56
56
  done
57
57
 
58
- if [ ${#LEGACY_FOUND[@]} -eq 0 ]; then
59
- echo "Nothing to migrate: no legacy .docs/ artifact content found in $PROJECT_DIR."
58
+ # Second migration concern: wiki work items still carrying the pre-rename IDs
59
+ # (DEC-NNNN decisions, REQ-NNNN requirements). Handled deterministically by
60
+ # rename-wiki-ids.js, independent of whether any legacy .docs/ content exists.
61
+ RENAME_COUNT="$(node "$SCRIPT_DIR/rename-wiki-ids.js" --count "$PROJECT_DIR")"
62
+
63
+ if [ ${#LEGACY_FOUND[@]} -eq 0 ] && [ "$RENAME_COUNT" -eq 0 ]; then
64
+ echo "Nothing to migrate: no legacy .docs/ artifact content and no DEC-/REQ- work items found in $PROJECT_DIR."
60
65
  exit 0
61
66
  fi
62
67
 
63
- echo "Legacy .docs/ content found in $PROJECT_DIR:"
64
- for entry in "${LEGACY_FOUND[@]}"; do
65
- fam="${entry%%:*}"
66
- count="${entry##*:}"
67
- echo " .docs/$fam — $count markdown file(s)"
68
- done
69
- echo ""
68
+ if [ ${#LEGACY_FOUND[@]} -gt 0 ]; then
69
+ echo "Legacy .docs/ content found in $PROJECT_DIR:"
70
+ for entry in "${LEGACY_FOUND[@]}"; do
71
+ fam="${entry%%:*}"
72
+ count="${entry##*:}"
73
+ echo " .docs/$fam — $count markdown file(s)"
74
+ done
75
+ echo ""
76
+ fi
77
+
78
+ if [ "$RENAME_COUNT" -gt 0 ]; then
79
+ echo "Legacy work-item IDs found: $RENAME_COUNT file(s) to rename (DEC-→ADR-, REQ-→PRD-)."
80
+ echo ""
81
+ fi
70
82
 
71
83
  # --- Detect git repo (used by both dry-run and live paths) -----------------
72
84
  if git -C "$PROJECT_DIR" rev-parse --git-dir &>/dev/null; then
@@ -86,8 +98,12 @@ if [ "$DRY_RUN" = true ]; then
86
98
  echo " ${f#"$PROJECT_DIR/"}"
87
99
  done
88
100
  done
101
+ if [ "$RENAME_COUNT" -gt 0 ]; then
102
+ echo "ID rename (DEC-→ADR-, REQ-→PRD-):"
103
+ node "$SCRIPT_DIR/rename-wiki-ids.js" --dry-run "$PROJECT_DIR"
104
+ fi
89
105
  echo ""
90
- echo "Target layout: wiki/work/{tasks,uat,decisions,requirements,bugs,roadmaps}/"
106
+ [ ${#LEGACY_FOUND[@]} -gt 0 ] && echo "Target layout: wiki/work/{tasks,uat,decisions,requirements,bugs,roadmaps}/"
91
107
  if [ "$IS_GIT" = true ]; then
92
108
  echo "Run without --dry-run to migrate (requires clean git tree)."
93
109
  else
@@ -119,6 +135,32 @@ else
119
135
  echo ""
120
136
  fi
121
137
 
138
+ # --- Rename DEC-/REQ- work items to ADR-/PRD- (deterministic, no Claude) ----
139
+ if [ "$RENAME_COUNT" -gt 0 ]; then
140
+ echo "Renaming legacy work-item IDs (DEC-→ADR-, REQ-→PRD-)..."
141
+ node "$SCRIPT_DIR/rename-wiki-ids.js" "$PROJECT_DIR"
142
+ echo ""
143
+
144
+ if [ ${#LEGACY_FOUND[@]} -eq 0 ]; then
145
+ echo "============================="
146
+ echo " Migration run complete"
147
+ echo "============================="
148
+ echo ""
149
+ if [ "$IS_GIT" = true ]; then
150
+ echo "Next steps (changes are on branch 'wiki-migration', uncommitted):"
151
+ echo " 1. Review: git status && git diff"
152
+ echo " 2. Health-check: open Claude Code and run /wiki-lint"
153
+ echo " 3. Commit: git add -A && git commit -m 'Rename DEC-/REQ- work items to ADR-/PRD-'"
154
+ echo " 4. Merge: switch back and merge wiki-migration when satisfied"
155
+ else
156
+ echo "Next steps:"
157
+ echo " 1. Review: check wiki/work/decisions and wiki/work/requirements"
158
+ echo " 2. Health-check: open Claude Code and run /wiki-lint"
159
+ fi
160
+ exit 0
161
+ fi
162
+ fi
163
+
122
164
  # --- Scaffold first: wiki tree + CLAUDE.md schema + tiered guides ----------
123
165
  "$SCRIPT_DIR/sync-wiki-scaffold.sh" --interactive "$PROJECT_DIR"
124
166
  echo ""
@@ -0,0 +1,232 @@
1
+ #!/usr/bin/env node
2
+ // Rename legacy work-item IDs in a project's wiki: DEC-NNNN -> ADR-NNNN
3
+ // (wiki/work/decisions/) and REQ-NNNN -> PRD-NNNN (wiki/work/requirements/).
4
+ // Run by `bootstrap migrate` (migrate-project.sh) so a project that already
5
+ // moved to the wiki layout under the old names catches up with the ADR/PRD
6
+ // vocabulary the current skills and lifecycle docs use.
7
+ //
8
+ // WHAT IT CHANGES
9
+ // 1. Filenames: DEC-0003-slug.md -> ADR-0003-slug.md (active dir and
10
+ // archive/), via `git mv` when the project is a git repo and the file is
11
+ // tracked (history preserved), plain rename otherwise.
12
+ // 2. References: every occurrence of a renamed ID (`DEC-0003`, as `id:`,
13
+ // `[[DEC-0003#D2]]`, `implements::[[DEC-0003]]`, link text, and link
14
+ // targets like `../decisions/DEC-0003-slug.md`) in every .md file under
15
+ // wiki/, rewritten to the new ID.
16
+ // 3. Aliases: each renamed file keeps its old ID as an alias
17
+ // (`aliases: [ADR-0003, DEC-0003]`) so links that cannot be rewritten
18
+ // still resolve.
19
+ // 4. wiki/log.md: one appended entry recording the rename.
20
+ //
21
+ // WHAT IT DELIBERATELY DOES NOT CHANGE
22
+ // - wiki/log.md and wiki/log-*.md existing content (append-only by rule).
23
+ // - raw/ (immutable), and anything outside wiki/.
24
+ // - Text that merely looks like an ID. Only IDs that belong to a file being
25
+ // renamed are rewritten (a PRD listing its own "REQ-1 ... REQ-2"
26
+ // functional requirements is left alone unless a REQ-0001 file exists).
27
+ // - Renamed skill names mentioned in prose.
28
+ //
29
+ // Idempotent: a second run finds nothing to rename. Aborts before touching
30
+ // anything if a rename target already exists (e.g. both DEC-0003 and ADR-0003
31
+ // are present).
32
+ //
33
+ // Usage: rename-wiki-ids.js [--dry-run | --count] <path-to-project>
34
+ // --dry-run print the plan, change nothing
35
+ // --count print only the number of files that would be renamed
36
+ // Exit: 0 ok (including nothing to do), 1 collision or write failure.
37
+
38
+ 'use strict';
39
+
40
+ const fs = require('fs');
41
+ const path = require('path');
42
+ const { spawnSync } = require('child_process');
43
+
44
+ const RENAMES = [
45
+ { family: 'decisions', from: 'DEC', to: 'ADR' },
46
+ { family: 'requirements', from: 'REQ', to: 'PRD' },
47
+ ];
48
+ const META_BASENAMES = new Set(['index.md', 'lifecycle.md']);
49
+
50
+ function isLogFile(relPath) {
51
+ return /^wiki\/log(-[^/]*)?\.md$/.test(relPath.split(path.sep).join('/'));
52
+ }
53
+
54
+ function collectMarkdown(dir) {
55
+ if (!fs.existsSync(dir)) return [];
56
+ const out = [];
57
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
58
+ const full = path.join(dir, entry.name);
59
+ if (entry.isDirectory()) out.push(...collectMarkdown(full));
60
+ else if (entry.isFile() && entry.name.endsWith('.md')) out.push(full);
61
+ }
62
+ return out;
63
+ }
64
+
65
+ function escapeRegExp(s) {
66
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
67
+ }
68
+
69
+ function isGitRepo(projectDir) {
70
+ return spawnSync('git', ['-C', projectDir, 'rev-parse', '--git-dir'], { stdio: 'ignore' }).status === 0;
71
+ }
72
+
73
+ /** Build the rename plan: which files move, and the old-ID -> new-ID map. */
74
+ function buildPlan(projectDir) {
75
+ const files = [];
76
+ const idMap = new Map();
77
+
78
+ for (const { family, from, to } of RENAMES) {
79
+ const familyDir = path.join(projectDir, 'wiki', 'work', family);
80
+ const nameRe = new RegExp(`^(${from})-(\\d+)(.*)\\.md$`);
81
+ const idRe = new RegExp(`^id:\\s*(${from}-\\d+)\\s*$`, 'm');
82
+
83
+ for (const file of collectMarkdown(familyDir)) {
84
+ const base = path.basename(file);
85
+ if (META_BASENAMES.has(base)) continue;
86
+
87
+ const nameMatch = base.match(nameRe);
88
+ if (nameMatch) {
89
+ const oldId = `${from}-${nameMatch[2]}`;
90
+ const newId = `${to}-${nameMatch[2]}`;
91
+ idMap.set(oldId, newId);
92
+ files.push({ from: file, to: path.join(path.dirname(file), `${to}-${nameMatch[2]}${nameMatch[3]}.md`), oldId, newId });
93
+ continue;
94
+ }
95
+
96
+ // Filename already renamed by hand but frontmatter still carries the old ID.
97
+ const fm = fs.readFileSync(file, 'utf8').match(/^---\r?\n([\s\S]*?)\r?\n---/);
98
+ const idMatch = fm && fm[1].match(idRe);
99
+ if (idMatch) idMap.set(idMatch[1], idMatch[1].replace(`${from}-`, `${to}-`));
100
+ }
101
+ }
102
+ return { files, idMap };
103
+ }
104
+
105
+ function findCollisions(files) {
106
+ const seen = new Set();
107
+ const collisions = [];
108
+ for (const f of files) {
109
+ if (fs.existsSync(f.to) || seen.has(f.to)) collisions.push(f);
110
+ seen.add(f.to);
111
+ }
112
+ return collisions;
113
+ }
114
+
115
+ function rewriteReferences(text, idMap) {
116
+ const ids = [...idMap.keys()].map(escapeRegExp).join('|');
117
+ const re = new RegExp(`\\b(${ids})(?![0-9])`, 'g');
118
+ return text.replace(re, (m) => idMap.get(m));
119
+ }
120
+
121
+ /** Ensure a renamed file's frontmatter lists its old ID as an alias. Returns
122
+ * the text unchanged if there is no frontmatter or aliases are block-style. */
123
+ function ensureOldAlias(text, oldId, newId) {
124
+ const m = text.match(/^(---\r?\n)([\s\S]*?\r?\n)(---\r?\n)/);
125
+ if (!m) return { text, warned: false };
126
+ const eol = m[1].includes('\r\n') ? '\r\n' : '\n';
127
+ let block = m[2];
128
+
129
+ const inline = block.match(/^aliases:[ \t]*\[(.*)\][ \t]*$/m);
130
+ if (inline) {
131
+ const items = inline[1].split(',').map((s) => s.trim()).filter(Boolean);
132
+ if (items.includes(oldId)) return { text, warned: false };
133
+ block = block.replace(inline[0], `aliases: [${[...items, oldId].join(', ')}]`);
134
+ } else if (/^aliases:/m.test(block)) {
135
+ return { text, warned: true };
136
+ } else if (/^id:[ \t]*\S+[ \t]*$/m.test(block)) {
137
+ block = block.replace(/^(id:[ \t]*\S+)[ \t]*$/m, `$1${eol}aliases: [${newId}, ${oldId}]`);
138
+ } else {
139
+ return { text, warned: false };
140
+ }
141
+ return { text: text.slice(0, m.index) + m[1] + block + m[3] + text.slice(m.index + m[0].length), warned: false };
142
+ }
143
+
144
+ function appendLog(projectDir, renamedCount, rewrittenCount) {
145
+ const logPath = path.join(projectDir, 'wiki', 'log.md');
146
+ if (!fs.existsSync(logPath)) return;
147
+ const existing = fs.readFileSync(logPath, 'utf8');
148
+ const date = new Date().toISOString().slice(0, 10);
149
+ const entry =
150
+ `## [${date}] migrate | renamed DEC→ADR and REQ→PRD IDs\n` +
151
+ `Renamed ${renamedCount} file(s) and rewrote references in ${rewrittenCount} file(s) under wiki/. ` +
152
+ `Old IDs kept as aliases on the renamed files; existing log entries left unedited.\n`;
153
+ fs.appendFileSync(logPath, (existing.endsWith('\n') ? '' : '\n') + '\n' + entry);
154
+ }
155
+
156
+ function main(argv) {
157
+ const dryRun = argv.includes('--dry-run');
158
+ const countOnly = argv.includes('--count');
159
+ const projectDir = argv.find((a) => !a.startsWith('--'));
160
+ if (!projectDir) {
161
+ console.error('Usage: rename-wiki-ids.js [--dry-run | --count] <path-to-project>');
162
+ return 1;
163
+ }
164
+ if (!fs.existsSync(path.join(projectDir, 'wiki'))) {
165
+ if (countOnly) console.log(0);
166
+ else console.log(' wiki/ not found — nothing to rename.');
167
+ return 0;
168
+ }
169
+
170
+ const { files, idMap } = buildPlan(projectDir);
171
+ if (countOnly) {
172
+ console.log(files.length);
173
+ return 0;
174
+ }
175
+ if (idMap.size === 0) {
176
+ console.log(' No DEC-/REQ- work items found — nothing to rename.');
177
+ return 0;
178
+ }
179
+
180
+ const collisions = findCollisions(files);
181
+ if (collisions.length > 0) {
182
+ console.error('Error: rename targets already exist — resolve these before migrating:');
183
+ for (const c of collisions) {
184
+ console.error(` ${path.relative(projectDir, c.from)} -> ${path.relative(projectDir, c.to)}`);
185
+ }
186
+ return 1;
187
+ }
188
+
189
+ const oldIdFor = new Map(files.map((f) => [f.to, f.oldId]));
190
+ const wikiFiles = collectMarkdown(path.join(projectDir, 'wiki')).filter(
191
+ (f) => !isLogFile(path.relative(projectDir, f)),
192
+ );
193
+
194
+ if (dryRun) {
195
+ console.log(` ${files.length} file(s) would be renamed:`);
196
+ for (const f of files) console.log(` ${path.relative(projectDir, f.from)} -> ${path.basename(f.to)}`);
197
+ const refCount = wikiFiles.filter((f) => rewriteReferences(fs.readFileSync(f, 'utf8'), idMap) !== fs.readFileSync(f, 'utf8')).length;
198
+ console.log(` References would be rewritten in ${refCount} file(s) under wiki/ (log entries untouched).`);
199
+ return 0;
200
+ }
201
+
202
+ const useGit = isGitRepo(projectDir);
203
+ for (const f of files) {
204
+ const moved = useGit && spawnSync('git', ['-C', projectDir, 'mv', f.from, f.to], { stdio: 'ignore' }).status === 0;
205
+ if (!moved) fs.renameSync(f.from, f.to);
206
+ console.log(` renamed ${path.relative(projectDir, f.from)} -> ${path.basename(f.to)}`);
207
+ }
208
+
209
+ let rewritten = 0;
210
+ for (const original of wikiFiles) {
211
+ // Renamed files now live at their new path.
212
+ const file = files.find((f) => f.from === original)?.to ?? original;
213
+ const before = fs.readFileSync(file, 'utf8');
214
+ let after = rewriteReferences(before, idMap);
215
+ const oldId = oldIdFor.get(file);
216
+ if (oldId) {
217
+ const res = ensureOldAlias(after, oldId, idMap.get(oldId));
218
+ after = res.text;
219
+ if (res.warned) console.error(` Warning: ${path.relative(projectDir, file)} has block-style aliases — add ${oldId} by hand.`);
220
+ }
221
+ if (after !== before) {
222
+ fs.writeFileSync(file, after);
223
+ rewritten++;
224
+ }
225
+ }
226
+
227
+ appendLog(projectDir, files.length, rewritten);
228
+ console.log(` Renamed ${files.length} file(s); rewrote references in ${rewritten} file(s).`);
229
+ return 0;
230
+ }
231
+
232
+ process.exit(main(process.argv.slice(2)));
@@ -17,10 +17,10 @@ CLAUDE.md This schema section.
17
17
  - `wiki/knowledge/concepts/` — patterns, ideas, conventions, recurring themes
18
18
  - `wiki/knowledge/entities/{people,organisations,tools,components}/` — one page per entity, filed by sub-type
19
19
 
20
- **`wiki/work/`** — stateful lifecycle artifacts, organized by status. Active files are **never moved** after creation; state lives in the `status:` frontmatter field. Each family has a `lifecycle.md` (schema + valid transitions), an `index.md` listing **only active items**, and an `archive/` subdirectory for terminal items. When an item leaves the active set, delete its line from the family index; terminal items may be moved to `archive/` by `/wiki-archive`.
20
+ **`wiki/work/`** — stateful lifecycle artifacts, organized by status. Active files are **never moved** after creation; state lives in the `status:` frontmatter field. Each family has a `lifecycle.md` (schema + valid transitions), and an `index.md`. **Tasks, UAT and bugs** archive: their index lists **only active items** (delete the line when an item leaves the active set), and terminal items may be moved to an `archive/` subdirectory by `/wiki-archive`. **Roadmaps, decisions and requirements** close in place: the file never moves, and the family `index.md` moves its row from `## Active` to `## Closed`.
21
21
 
22
- - `wiki/work/requirements/` — REQ-NNNN
23
- - `wiki/work/decisions/` — DEC-NNNN (per-decision `#DM`)
22
+ - `wiki/work/requirements/` — PRD-NNNN
23
+ - `wiki/work/decisions/` — ADR-NNNN (per-decision `#DM`)
24
24
  - `wiki/work/roadmaps/` — ROADMAP-NNNN
25
25
  - `wiki/work/tasks/` — TASK-NNNN
26
26
  - `wiki/work/uat/` — UAT-NNNN (own family, one per task)
@@ -48,9 +48,9 @@ Keep the two from duplicating or contradicting each other: project-specific stat
48
48
  | `/wiki-ingest <raw-file>` | Process a source from `raw/` into the wiki — summary page, entity/concept updates, index + log entries |
49
49
  | `/wiki-query <question>` | Answer from the wiki with citations; auto-ingest relevant un-ingested `raw/` sources when coverage is missing; offer to file valuable synthesis back as a new page |
50
50
  | `/wiki-lint` | Health-check — contradictions, orphan pages, stale claims, index drift, never-ingested raw sources |
51
- | `/wiki-archive [family]` | Batch-move terminal work items into `<family>/archive/`; update `archive/index.md` and log the operation |
51
+ | `/wiki-archive [family]` | Batch-move terminal tasks, UAT and bugs into `<family>/archive/`; update `archive/index.md` and log the operation (roadmaps, decisions and requirements close in place and are never archived) |
52
52
  | `/wiki-rotate-log` | Rotate `wiki/log.md` to a timestamped archive file when it exceeds ~500 lines; create a fresh `log.md` with an archive pointer |
53
- | `/wiki-tidy` | One-shot cleanup — lint, archive terminal items across all families, then rotate log if overgrown; phases run in sequence with user confirmation |
53
+ | `/wiki-tidy` | One-shot cleanup — lint, archive terminal tasks/UAT/bugs, then rotate log if overgrown; phases run in sequence with user confirmation |
54
54
 
55
55
  ### CRITICAL wiki rules
56
56
 
@@ -60,5 +60,5 @@ Keep the two from duplicating or contradicting each other: project-specific stat
60
60
  4. Flag contradictions explicitly — when a new source conflicts with an existing page, add a `> **Contradiction:**` callout citing both; never silently overwrite
61
61
  5. Answer from the wiki, not general knowledge — if the wiki lacks coverage, say so and suggest `/wiki-ingest` for relevant sources
62
62
  6. Atomic pages — one concept, entity, or artifact per file; split a page rather than let it cover two things
63
- 7. Typed links — when a link has a meaning, annotate it inline as `rel::[[target]]` (e.g. `implements::[[REQ-012]]`, `supersedes::[[DEC-0003#D2]]`); keep the two domains separate — never file a stateful artifact under `knowledge/` or a timeless synthesis under `work/`
63
+ 7. Typed links — when a link has a meaning, annotate it inline as `rel::[[target]]` (e.g. `implements::[[PRD-012]]`, `supersedes::[[ADR-0003#D2]]`); keep the two domains separate — never file a stateful artifact under `knowledge/` or a timeless synthesis under `work/`
64
64
  8. Template-owned files are read-only — never edit `wiki/guides/*`, `wiki/conventions.md`, `wiki/work/*/lifecycle.md`, or `wiki/dashboard.html`; they are refreshed from the bootstrap templates and local edits will be lost
@@ -149,7 +149,7 @@
149
149
  "scope": "global",
150
150
  "consumer": "installer",
151
151
  "summary": "Delete stale skill folders in ~/.claude/skills/ left by the wiki rename",
152
- "detail": "Asked by install-global.sh:72 when any renamed-away skill folder (the adr-* and prd-* families) is still present in ~/.claude/skills/. true removes those folders with rm -rf; false keeps them, and they continue to appear as duplicate slash commands alongside their renamed replacements. The list of orphan names is fixed in the script — this key does not decide which folders qualify, only whether the deletion runs.",
152
+ "detail": "Asked by install-global.sh:80 when any renamed-away skill folder (the adr-* and prd-* families) is still present in ~/.claude/skills/ and is not a live skill in the installed lib/skills/ tree. true removes those folders with rm -rf; false keeps them, and they continue to appear as duplicate slash commands alongside their renamed replacements. The list of orphan names is fixed in the script — this key does not decide which folders qualify, only whether the deletion runs.",
153
153
  "values": "true | false",
154
154
  "default": null,
155
155
  "askedBy": "install-global.sh"
@@ -211,7 +211,7 @@
211
211
  "uatGenerate.promoteTests": {
212
212
  "scope": "either",
213
213
  "consumer": "skill",
214
- "summary": "Where /uat-generate writes the unit tests it promotes out of UAT cases",
214
+ "summary": "Where /uat-create writes the unit tests it promotes out of UAT cases",
215
215
  "detail": "The question is WHERE promoted tests land, not whether they exist. 'dedicated' is today's behavior: they go in the project's dedicated test directory, resolved by looking at the repo first (an existing test directory) and falling back to the language default — test/ for JS/TS, tests/ for Python, spec/ where that is the local idiom. The directory is detected rather than stored, because this grammar is a closed enumeration of literal tokens and a stored path would be free text. 'sibling' puts each test beside the file under test using the language's own convention (src/parse.ts -> src/parse.test.ts). 'never' writes nothing: the skill still runs its promotability analysis and records the verdict on each UAT case, it just creates no file. An existing test file that already covers the unit is extended in place under every value, and a project's visible layout wins over a stored answer that contradicts it — so this key is a default for new work, not an override of the repo. It affects what lands on disk, not how the UAT itself is judged. Legacy true/false/ask values from the key's earlier grammar are mapped by the skill: true -> dedicated, false -> never, ask -> ask once per run.",
216
216
  "values": "sibling | never | dedicated",
217
217
  "default": "dedicated",
@@ -225,5 +225,14 @@
225
225
  "values": "true | false | ask",
226
226
  "default": true,
227
227
  "askedBy": "install-global.sh"
228
+ },
229
+ "sandbox.scaffold": {
230
+ "scope": "global",
231
+ "consumer": "installer",
232
+ "summary": "Whether install-global.sh merges the Claude Code sandbox block into ~/.claude/settings.json",
233
+ "detail": "Asked by install-global.sh step 7b. true merges lib/scripts/templates/settings-sandbox.json ({\"enabled\": true, \"excludedCommands\": [\"docker *\", \"docker-compose *\"]}) into ~/.claude/settings.json as the \"sandbox\" key; false leaves the settings alone. Enabling the sandbox adds OS-level containment (macOS Seatbelt, Linux/WSL2 bubblewrap + socat) for Bash and its child processes. docker commands are incompatible with the sandbox, so they are pre-listed under sandbox.excludedCommands as the escape hatch; add any other tool that fails under the sandbox to excludedCommands the same way. A pre-existing \"sandbox\" key in settings.json is never overwritten, whatever this key says. Native Windows and WSL1 are unsupported and skipped. Unset means the question is asked again on the next sync.",
234
+ "values": "true | false",
235
+ "default": null,
236
+ "askedBy": "install-global.sh"
228
237
  }
229
238
  }
@@ -75,7 +75,7 @@
75
75
  "Bash(rm -rf /Volumes*)",
76
76
  "Bash(git * --force*)",
77
77
  "Bash(git push * +*)",
78
- "Bash(git push * :*)",
78
+ "Bash(git push *)",
79
79
  "Bash(git push --mirror*)",
80
80
  "Bash(git push --delete*)",
81
81
  "Bash(git filter-branch*)",
@@ -0,0 +1,36 @@
1
+ {
2
+ "sandbox": {
3
+ "enabled": true,
4
+ "failIfUnavailable": true,
5
+ "allowUnsandboxedCommands": false,
6
+ "autoAllowBashIfSandboxed": true,
7
+ "filesystem": {
8
+ "denyRead": ["~/.ssh", "~/.gnupg"]
9
+ },
10
+ "network": {
11
+ "strictAllowlist": true,
12
+ "allowedDomains": [
13
+ "registry.npmjs.org",
14
+ "pypi.org",
15
+ "files.pythonhosted.org",
16
+ "github.com"
17
+ ],
18
+ "allowLocalBinding": true
19
+ },
20
+ "credentials": {
21
+ "files": [
22
+ { "path": "~/.aws/credentials", "mode": "deny" },
23
+ { "path": "~/.netrc", "mode": "deny" },
24
+ { "path": "~/.npmrc", "mode": "deny" },
25
+ { "path": "~/.config/gh/hosts.yml", "mode": "deny" }
26
+ ],
27
+ "envVars": [
28
+ { "name": "GITHUB_TOKEN", "mode": "deny" },
29
+ { "name": "GH_TOKEN", "mode": "deny" },
30
+ { "name": "AWS_SECRET_ACCESS_KEY", "mode": "deny" },
31
+ { "name": "AWS_SESSION_TOKEN", "mode": "deny" },
32
+ { "name": "NPM_TOKEN", "mode": "deny" }
33
+ ]
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "enabled": true,
3
+ "excludedCommands": [
4
+ "docker *",
5
+ "docker-compose *"
6
+ ]
7
+ }