riskrails 3.2.2 → 4.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.
Files changed (149) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.codex-plugin/plugin.json +1 -1
  4. package/README.md +50 -84
  5. package/agents/ai-reviewer.md.tmpl +1 -1
  6. package/ai/using-riskrails.md +0 -3
  7. package/bin/menu.js +116 -0
  8. package/bin/riskrails.js +132 -79
  9. package/hooks/ai-path-guard-defaults.json +1 -1
  10. package/hooks/context-guard.py +2 -4
  11. package/hooks/guard/dialog.py +14 -2
  12. package/hooks/guard/paths.py +3 -6
  13. package/hooks/guard/scope.py +1 -3
  14. package/hooks/runtime-gate.py +18 -58
  15. package/instructions/routing.md +2 -2
  16. package/package.json +1 -1
  17. package/scripts/ai-path +1 -1
  18. package/scripts/resolve-profile.py +0 -3
  19. package/skills/ai-audit/templates/ai-sdlc-adoption-plan.md +1 -1
  20. package/skills/ai-audit/templates/play-scoring-rubric.md +1 -1
  21. package/skills/ai-init/scaffold-ai.sh +2 -1
  22. package/skills/ai-init/templates/.ai/AGENTS.md +6 -6
  23. package/skills/ai-init/templates/.ai/VERSION +1 -1
  24. package/skills/ai-init/templates/.ai/policies/safety.md +4 -3
  25. package/skills/ai-init/templates/.ai/policies/security.md +1 -2
  26. package/skills/ai-init/templates/.ai/policies/testing.md +5 -12
  27. package/skills/ai-init/templates/.ai/policies/verification.md +18 -0
  28. package/skills/ai-init/templates/.ai/policies/weight.json +0 -1
  29. package/skills/ai-init/templates/.ai/policies/weight.md +1 -2
  30. package/skills/ai-init/templates/.ai/policies/weight.project.json +4 -0
  31. package/skills/ai-init/templates/.ai/project/architecture.md +1 -1
  32. package/skills/ai-init/templates/.ai/project/initial-assessment.md +2 -2
  33. package/skills/ai-init/templates/.ai/project/overview.md +1 -1
  34. package/skills/ai-init/templates/.ai/rules/README.md +2 -2
  35. package/skills/ai-init/templates/.ai/state/README.md +1 -1
  36. package/skills/ai-task/memory_store.py +8 -9
  37. package/skills/ai-task/rr_state/cli.py +2 -2
  38. package/skills/ai-task/rr_state/dialog.py +2 -4
  39. package/skills/ai-task/rr_state/dialog_cmd.py +183 -6
  40. package/skills/ai-task/rr_state/fs.py +5 -13
  41. package/skills/ai-task/rr_state/labels.py +14 -2
  42. package/skills/ai-task/rr_state/memory_cmd.py +7 -4
  43. package/skills/ai-task/rr_state/profile.py +2 -4
  44. package/skills/ai-task/rr_state/questions_cmd.py +1 -1
  45. package/skills/ai-task/rr_state/report.py +3 -4
  46. package/skills/ai-task/rr_state/runtime.py +1 -1
  47. package/skills/ai-task/rr_state/start.py +7 -7
  48. package/skills/ai-task/sensors.py +10 -11
  49. package/skills/ai-task/state.py +4 -24
  50. package/skills/ai-task/weight.py +17 -17
  51. package/skills/ai-task/weight_overlay.py +38 -0
  52. package/skills/project-init/templates/constitution.md +2 -2
  53. package/skills/project-update/history/blobs/00f5e27ce2d66e3a1d8b222b013ae8fa1fed32612d91a551e0c661cee3ef9c2d +34 -0
  54. package/skills/project-update/history/blobs/0a6b1b6dd06a35582b2e9989a1f41c40abc29254b8e482714fcc6f0a7b16c406 +32 -0
  55. package/skills/project-update/history/blobs/0aeb04b04262683cac6513545683486a73dc473b447bba43b5aaab18403957a6 +34 -0
  56. package/skills/project-update/history/blobs/0ce913a28996f546f72d570b0e5a376362e993ce4d805bc4aae57d38caa44212 +41 -0
  57. package/skills/project-update/history/blobs/0ea9e36446b624b73b2a821231b2ee66a357b43d584a5b23da48b3c800855e65 +41 -0
  58. package/skills/project-update/history/blobs/0fb1d68678a1349195b2e79433bb20174d25874e3bfd0b70410bb4e428b4e4b8 +35 -0
  59. package/skills/project-update/history/blobs/119b2b9d0f9c647a243540724edac6b29afa020c69aa205797bcfa9eb06bc021 +35 -0
  60. package/skills/project-update/history/blobs/1d0fe3ee5fb8260ba610942d4bbdfff7410fbe80ed826ac07f32985031dc2b3f +34 -0
  61. package/skills/project-update/history/blobs/1de9a37ed6402893dcab6e61ddbf15ffd35f15a6d84b18e675a0c5bf4e981f85 +42 -0
  62. package/skills/project-update/history/blobs/1f44e1a236233dcbab58064f39b69f798b35d1d9a29f8c615b5b12854ce633cb +15 -0
  63. package/skills/project-update/history/blobs/1f824645299579cbdd8141642ddbb4bca9fd5fe9d3112f036d8221f0811e0abf +40 -0
  64. package/skills/project-update/history/blobs/235fb88393cfe20dd58b35fe9785cc45baf5ffe21a13d926652d76ec68cea8b7 +35 -0
  65. package/skills/project-update/history/blobs/3918b4ee011d9477b9d2779e2893ab599749c406d4b09439a9748b64fbff58f3 +18 -0
  66. package/skills/project-update/history/blobs/449273200dfec2a56885c881ff34d40e8ecc00da53c24c2d09b7fbeb1004d255 +40 -0
  67. package/skills/project-update/history/blobs/4c45aee9b9fc5f6b4e1d9739e434c4094975a5a8dec6b9703fb25f3080680c77 +124 -0
  68. package/skills/project-update/history/blobs/4dd3fa12bc45acc8c836ab65d790248ca7504a021bca6677499d17bb3d798ed9 +64 -0
  69. package/skills/project-update/history/blobs/51e3f15095d7123ea8566b512479ee10a6cb2f336b7352a259a083a887bd7116 +33 -0
  70. package/skills/project-update/history/blobs/5497a204967bea7dab29079a6e1dfa3d8713b2d2cb294c2779378039f03a55fc +36 -0
  71. package/skills/project-update/history/blobs/60c4d7e7fde7049d92d84295fc13ca9a91eb2de423be08f093b3ee5d5e817ff8 +64 -0
  72. package/skills/project-update/history/blobs/6221b7c14cc04634e485e562d464c6860d45666a7f63e293c06bb2944ff556cc +27 -0
  73. package/skills/project-update/history/blobs/637971cfb844ef4285e2886a4b1c834fb2ed5c46e773adb88c2c147fea626ad3 +33 -0
  74. package/skills/project-update/history/blobs/65af2282eea2a51fcc27a4acf2c26c727b0961c30e1be13176369200c460c219 +34 -0
  75. package/skills/project-update/history/blobs/66ecd73e303e7bbc1aa8ee72435d0d10812ff7b2eff0adac59bbf0a303e2cc01 +41 -0
  76. package/skills/project-update/history/blobs/6a43bf32461b22b87fafe2865529dc04fa66cd00182a2a7598aa071667ca255a +35 -0
  77. package/skills/project-update/history/blobs/6d6dee8634abf9ac057bb206828b83a893a2afcf4f86bbe69e839a3b47d0adde +48 -0
  78. package/skills/project-update/history/blobs/7224ede803ea81e65a456e21b6028a0e848e8a880456c6503eebe7534ca4f6aa +74 -0
  79. package/skills/project-update/history/blobs/765a39a202617096c232017822ae738d37e4405430c71700dc7bc14bf1ba794e +33 -0
  80. package/skills/project-update/history/blobs/77577440a933d1cabd8c6f4a6401cf361a784aa09a25500a6f7b44ead8ab5e55 +41 -0
  81. package/skills/project-update/history/blobs/7bae90789625d6fb9071ecb412d14a8d1eb0bc5659d8d284c4eaf213e1b5de56 +67 -0
  82. package/skills/project-update/history/blobs/7bcdf9a0e6b85277b9b60669150224b9414d2e32821ff06f4d148eb1d18785bb +42 -0
  83. package/skills/project-update/history/blobs/7f834103e9d97aea44e76717bcdcbbe349c560e5b81a42ce85a1cec341041281 +4 -0
  84. package/skills/project-update/history/blobs/7fb3acb0211818efebc2234863db0b8c846022a7280a6d2d69f267dbf63db48c +34 -0
  85. package/skills/project-update/history/blobs/87f0855859ff68cc6c988cc0b631ee7f56af7fbba062172bf80e01f4982cc054 +35 -0
  86. package/skills/project-update/history/blobs/8abab74759766d02b5cb7b0c3e59a3d440b25a454216cd8fea325c23fd822d36 +33 -0
  87. package/skills/project-update/history/blobs/8ec171f0fbdf38cc6996d496f01491fd1f21f04a435a118ad979b127a8be06f1 +85 -0
  88. package/skills/project-update/history/blobs/a1fb50e6c86fae1679ef3351296fd6713411a08cf8dd1790a4fd05fae8688164 +1 -0
  89. package/skills/project-update/history/blobs/a3df7268feb0780be0d2cf9acced6ed81780a7790f36fe024b6ea0b1bd6eb7a6 +35 -0
  90. package/skills/project-update/history/blobs/b28721136482dafb9fd2801af340364cb97e9f6eaa987908606c786045b8d334 +28 -0
  91. package/skills/project-update/history/blobs/b3726422d767f9219fea633bea77f0c99ad9af843c591e6e928e1ccd2a47f374 +27 -0
  92. package/skills/project-update/history/blobs/b3839425f9d0ab2efa42a6f5e9488ec2d26ca5fb8dcd694b8ab098e10743ca46 +32 -0
  93. package/skills/project-update/history/blobs/ba14a457e83f9dde65e4190fdfab83b912f7398c1442a2a1cb3d89bfac741cf3 +8 -0
  94. package/skills/project-update/history/blobs/bceb7189444bb6291b262ca08e34db01010dda2f6e64d696231ec3c343c95c66 +34 -0
  95. package/skills/project-update/history/blobs/bf82a2bb4fce1bd349ff66118930a01d61a7af8e2bd8d200c721d43afc58c713 +34 -0
  96. package/skills/project-update/history/blobs/c4dbeb180292a6199ad73a3be861ece07c1f8bf6bf0cc7ca204412bc8e1bb1d8 +31 -0
  97. package/skills/project-update/history/blobs/c644838866df2001a42501a988dd7b77aacf862bf09d22b465f3cd8a22c6b6eb +33 -0
  98. package/skills/project-update/history/blobs/c980d74f76a4bdfb38c94b573ac10a54eb50b850b052e15fa6f2442889b36ccb +32 -0
  99. package/skills/project-update/history/blobs/ceed2f3bd937f862d0e6ca59ce1b1e3603e19a0d7f85d90d6dfeb7bf690153be +29 -0
  100. package/skills/project-update/history/blobs/d51ea2e893482a20c5882056cf8043327ca1dc1c957927f6746929a47ee8368e +45 -0
  101. package/skills/project-update/history/blobs/d78f5e0bb1380259fce2cce009785a9a11f6de8b87a160080b9872c059f95060 +34 -0
  102. package/skills/project-update/history/blobs/d97f46a2cca020406252b1f7baa4184617fa71faca3885e2379c44ae4e1d9327 +67 -0
  103. package/skills/project-update/history/blobs/da3ecd4c4c414c93d04488685931df39a56bf959bfeb9c45cb1aea2c13bd991b +38 -0
  104. package/skills/project-update/history/blobs/e129bf71a5a922e24b2c1bc8daa8a5d2b5589b0069770e17ce17e7db5ed4e7a4 +27 -0
  105. package/skills/project-update/history/blobs/e504529519a371892838725f8b89b5d32e3300e345bcbf2643a3a1a48434b3dd +24 -0
  106. package/skills/project-update/history/blobs/e9e62d03ca70b3dffccef8dceeb214173352cfef005145e519f0e037993f1c03 +36 -0
  107. package/skills/project-update/history/blobs/effefbaaf4beb8f1ba55081d6b7e74bf25ebb91045dd10613418f17b95fa7182 +33 -0
  108. package/skills/project-update/history/blobs/f6af4581bafbf62b257d57e06c3ae2c5998aeca608ee7df037fcc3c3e4b563a9 +34 -0
  109. package/skills/project-update/history/blobs/fc35045777d29630303430752a651b3e553580a581036a02cc103eb96a46f4b0 +34 -0
  110. package/skills/project-update/history/blobs/fdc21345c77f92a42d244aa104f393f439a0ff9981a9fd462bd837e8a47931bb +48 -0
  111. package/skills/project-update/history/index.json +34 -14
  112. package/skills/project-update/render_instructions.py +12 -45
  113. package/skills/project-update/update.py +757 -1172
  114. package/skills/rr-setup/SKILL.md +114 -97
  115. package/skills/rr-setup/scaffold_ai.py +15 -9
  116. package/skills/rr-setup/setup.py +462 -164
  117. package/skills/rr-status/status.py +7 -10
  118. package/skills/usage-report/usage-report.py +4 -5
  119. package/skills/ai-audit/SKILL.md +0 -9
  120. package/skills/ai-init/SKILL.md +0 -9
  121. package/skills/ai-status/SKILL.md +0 -9
  122. package/skills/ai-task/SKILL.md +0 -9
  123. package/skills/project-init/SKILL.md +0 -9
  124. package/skills/project-update/SKILL.md +0 -9
  125. package/skills/project-update/adopt-map.json +0 -91
  126. package/skills/project-update/adopt.py +0 -2225
  127. package/skills/project-update/migrations/0001_schema_version.py +0 -13
  128. package/skills/project-update/migrations/0002_task_journal.py +0 -123
  129. package/skills/project-update/migrations/0003_context_diet.py +0 -65
  130. package/skills/project-update/migrations/0004_deterministic_gates.py +0 -57
  131. package/skills/project-update/migrations/0005_runtimes_and_plans.py +0 -35
  132. package/skills/project-update/migrations/0006_shared_files.py +0 -154
  133. package/skills/project-update/migrations/0007_weight_model.py +0 -295
  134. package/skills/project-update/migrations/0008_renames.py +0 -43
  135. package/skills/project-update/migrations/0009_state_file.py +0 -25
  136. package/skills/project-update/migrations/0010_dialog_switch.py +0 -30
  137. package/skills/project-update/migrations/0011_retire_risk_tiers.py +0 -37
  138. package/skills/project-update/migrations/README.md +0 -76
  139. package/skills/project-update/migrations/__init__.py +0 -186
  140. package/skills/sdlc-intent/SKILL.md +0 -9
  141. package/skills/sdlc-plan/SKILL.md +0 -9
  142. package/skills/sdlc-spec/SKILL.md +0 -9
  143. package/skills/usage-report/SKILL.md +0 -10
  144. /package/{ai/workflows/refactoring.md → skills/project-update/history/blobs/36cb593293496fbcf38df828a9b9b2bc0d5a53333f584a5319ebc3d799016e24} +0 -0
  145. /package/{ai/workflows/feature.md → skills/project-update/history/blobs/56e16072c2f3edc6c8897c690d09a11d12fc414c3e3f361f359f7dc609a21282} +0 -0
  146. /package/{ai/workflows/hotfix.md → skills/project-update/history/blobs/8cbefbf1aa412bae3e5019acd40b8fe0598fceba6c781906b3bc6dbd014f6b23} +0 -0
  147. /package/{ai/workflows/bugfix.md → skills/project-update/history/blobs/af56dc16e44ae1d8c3dac4c3ca82e2163b719553c02ea455e77430bab9a14089} +0 -0
  148. /package/{ai/workflows/investigation.md → skills/project-update/history/blobs/b9e09cb24958cd6831589997558974bd6356305306e8f9685e226bcdc30d60ac} +0 -0
  149. /package/{ai/agents/manager.md → skills/project-update/history/blobs/d0cf6388f35a92a0cf607d33909278382f6d7b6a4c32e281b9f9e0ea652c7b91} +0 -0
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: rr-setup
3
- description: Set up and maintain the .ai/ layer of an existing production codebase. With no flag, scaffold docs/sdlc/, the runtime directory and .ai/, survey the code into .ai/project/ (light or full), write the Verification commands, the weight table's project entries and the constitution — read-only towards application code. --update brings a project's files up to the installed plugin (migrations, three-way merges, the managed block); --adopt moves a foreign AI-tool structure (Spec Kit, Kiro, Cursor, Copilot, AI-DLC, an oversized CLAUDE.md or AGENTS.md) into this layout with nothing lost; --audit scores the repository against the twelve plays and writes docs/ai-sdlc-adoption-plan.md. Use on "/rr-setup", "set up this project", "analyse this project for AI work", "update the rules", "обнови правилата", "audit our AI setup", or when /rr-status says the project is behind.
4
- argument-hint: [--survey light|full] | --update [--apply] | --adopt [--mode coexist] | --audit [context]
3
+ description: Set up and maintain the .ai/ layer of an existing production codebase. With no flag, scaffold docs/sdlc/, the runtime directory and .ai/, ask the open options (memory, runtimes, survey depth, verify command) in one dialog, survey the code into .ai/project/ (light or full), write the Verification commands, the weight table's project entries and the constitution — read-only towards application code. --options asks them all again; --update regenerates a project's files from the installed plugin (a copy that is a shipped version is replaced, an edited one waits for the human, the project's own files are kept); run it right after installing a new riskrails; --audit scores the repository against the twelve plays and writes docs/ai-sdlc-adoption-plan.md. Use on "/rr-setup", "set up this project", "analyse this project for AI work", "update the rules", "обнови правилата", "audit our AI setup", or when /rr-status says the project is behind.
4
+ argument-hint: [--survey light|full] | --options | --update [--apply] | --audit [context]
5
5
  ---
6
6
 
7
7
  # /rr-setup $ARGUMENTS
@@ -17,29 +17,74 @@ UPDATE="python3 $AI_HOME/skills/project-update/update.py $PWD"
17
17
  SETUP="python3 $AI_HOME/skills/rr-setup/setup.py"
18
18
  ```
19
19
 
20
- `--update`, `--adopt` and `--audit` go to their sections below; anything else
20
+ `--options`, `--update` and `--audit` go to their sections below; anything else
21
21
  is **Setup**. In every mode: no application code changes — not a rename, not a
22
22
  formatting fix. Problems you find are written down, never fixed. Never read
23
23
  `.env`, secrets, dumps or production logs. Do not commit; suggest the `git add`.
24
24
 
25
25
  ## Setup
26
26
 
27
+ 0. **Options.** Project memory, the runtimes, the survey depth and `verify_command`
28
+ are asked once, in one dialog, before any work; the picks feed steps 1, 3 and 5.
29
+
30
+ ```bash
31
+ "$AI_HOME/skills/ai-init/scaffold-ai.sh" "$PWD" --runtime none # 0a
32
+ $SETUP options --open # 0b; --options adds --all, a given --survey adds --skip survey
33
+ ```
34
+
35
+ **0a** makes `.ai/` (so `.ai/policies/dialog.json`) and its `.gitignore` lines, with no
36
+ instruction file and no runtime directory; only this script takes `none`
37
+ (`project-scaffold.sh` refuses it). If its output does **not** list
38
+ `.ai/project/overview.md`, the project was set up before.
39
+
40
+ **0b** prints one of three first lines:
41
+ - `OPTIONS_DIALOG D<n> …`, then state.py's `DIALOG_PENDING` line and a JSON: send that
42
+ JSON exactly as printed with the dialog tool the line names (AskUserQuestion; Codex:
43
+ request_user_input).
44
+ - `OPTIONS_FALLBACK <why>`: nothing was opened. Ask the numbered questions after it in
45
+ chat as printed, the answers being the picks; show its `memory is the human's` line
46
+ as printed and never run it.
47
+ - `OPTIONS_NONE`: nothing to ask.
48
+
49
+ Exit 6 (no first line, the reason on stderr): `DECISION_LIMIT` or `DECISION_DUPLICATE`
50
+ means a decision is already open — settle every one first (`$STATE decision show` and
51
+ send it, or `$STATE decision fallback --id <Dn> --why "<why>"`), then run 0b once more.
52
+ Any other refusal, or a second one: ask the questions of steps 1, 3 and 5 in prose and,
53
+ in a git work tree, give the human for their own terminal, with `$AI_HOME` and `$PWD`
54
+ substituted: `python3 "<home>/skills/ai-task/state.py" --root "<project>" memory enable
55
+ --period quarter [--index sqlite]`.
56
+
57
+ **0c** — the human answers. After a dialog, a memory command they picked is run first,
58
+ at once, verbatim and alone; it prints `memory: via dialog (consent C<n>, decision D<n>)`
59
+ and its pick settles its decision. Then `$STATE decision settle --id <Dn>` for each other
60
+ decision: it prints `D<n> settled: <label> (set)` and `SETUP_PICK <key>=<value>`, after
61
+ a decline `SETUP_PICK <key>=`. Apply each pick where its step needs it:
62
+ - `runtime=<v>` → step 1's two scaffolds with `--runtime <v>`;
63
+ - `verify=<cmd>` → `$SETUP verify --set "<cmd>"` after step 2; `keep` and `edit` → nothing;
64
+ - `survey=light` or `full` → step 3's depth; `keep` → no new survey;
65
+ - `memory=off` or `keep` → nothing: a picked command already ran.
66
+
67
+ An empty value (`verify=` is "Not now"; any key after a decline) or `other` → the step
68
+ as it was without the dialog: step 1 passes `auto`, step 3 surveys `light`, step 5 asks
69
+ in chat.
27
70
  1. **Scaffold.** Both scripts are idempotent, never overwrite, and print what
28
- they created; note it. They take `--runtime auto|claude|codex|both` (`auto`
29
- follows `CLAUDE.md`/`.claude/` and `AGENTS.md`/`.codex/`); pass `both` when
30
- the repository is worked on from both runtimes.
71
+ they created; note it, 0a's too. They take `--runtime auto|claude|codex|both`
72
+ (`auto` follows `CLAUDE.md`/`.claude/` and `AGENTS.md`/`.codex/`); pass the
73
+ `runtime` pick, else `auto` — `both` when the repository is worked on from
74
+ both runtimes.
31
75
 
32
76
  ```bash
33
- "$AI_HOME/hooks/project-scaffold.sh" "$PWD" # docs/sdlc/, the runtime dir, .gitignore
34
- "$AI_HOME/skills/ai-init/scaffold-ai.sh" "$PWD" # .ai/
77
+ "$AI_HOME/hooks/project-scaffold.sh" "$PWD" --runtime <pick> # docs/sdlc/, the runtime dir, .gitignore
78
+ "$AI_HOME/skills/ai-init/scaffold-ai.sh" "$PWD" --runtime <pick> # the instruction file; .ai/ is 0a's
35
79
  ```
36
80
 
37
- If `.ai/project/overview.md` was **not** created, the project was set up
81
+ If 0a did **not** create `.ai/project/overview.md`, the project was set up
38
82
  before: run **--update** below, then ask whether the survey should be
39
83
  refreshed; a refresh never overwrites a `.ai/project/` file a human edited
40
- without saying so first. If only an instruction file was created (no `.ai/`
41
- wanted), fill its Commands / Conventions / Architecture from the manifests —
42
- one line per command, five sentences of architecture — and stop.
84
+ without saying so first. If 0a and this step together created only an
85
+ instruction file (no `.ai/` wanted), fill its Commands / Conventions /
86
+ Architecture from the manifests — one line per command, five sentences of
87
+ architecture — and stop.
43
88
  2. **Stack.** `$SETUP survey` first: the project's own toolbox
44
89
  (`.claude/{skills,commands,rules,agents,hooks}`, `.codex/*`, `bin/*.sh`,
45
90
  Makefile targets) with each item's purpose, the guards a project hook
@@ -51,13 +96,15 @@ formatting fix. Problems you find are written down, never fixed. Never read
51
96
  (`phpunit.xml*`, `phpstan.neon*`, `playwright.config.*` …). For Symfony or
52
97
  Sylius also: bundles, entities, state machines, Messenger, event
53
98
  subscribers, payment, shipping, tax, promotions, ERP or fiscal integrations.
54
- 3. **Survey.** `--survey light` is the default, for a developer who knows the
55
- project: ask for a ten-minute brain dump (entry points, modules that matter,
56
- integrations, unwritten business rules, areas nobody dares touch), confirm
99
+ Then write the `verify=<cmd>` pick, if any (0c).
100
+ 3. **Survey.** The depth is the `survey` pick or `--survey light|full`. `light`,
101
+ the default, is for a developer who knows the project: ask for a ten-minute
102
+ brain dump (entry points, modules that matter, integrations,
103
+ unwritten business rules, areas nobody dares touch), confirm
57
104
  each claim with `grep -n`, then fan out exactly **two** `ai-discovery` agents
58
105
  in one message: (1) legacy, risks and code that looks unused; (2) tests,
59
106
  CI/CD, data and configuration — how secrets are supplied, never their
60
- values. `--survey full`, for a codebase new to you: one `Explore` for the
107
+ values. `full`, for a codebase new to you: one `Explore` for the
61
108
  inventory, then six `ai-discovery` agents in one message — entry points;
62
109
  domain modules; integrations and their failure handling; business rules and
63
110
  legacy; tests and CI/CD; data and configuration. Hand each the slice of the
@@ -68,14 +115,15 @@ formatting fix. Problems you find are written down, never fixed. Never read
68
115
  write `Documented behaviour / Observed behaviour / Evidence / Risk` and do
69
116
  not resolve it.
70
117
  5. **Policies.** Fill the project sections of `.ai/policies/coding.md` and
71
- `testing.md` only if step 1 created them. The **Verification** block of
118
+ `testing.md` only if 0a created them. The **Verification** block of
72
119
  `testing.md` is the feedback loop every task runs:
73
120
  - `verify_command` — the fast suite to the end, the e2e group **excluded**;
74
121
  - `step_test_command` — the same runner on given paths (`{files}`);
75
122
  - `e2e_command` — the end-to-end suite, or `none` when there is none;
76
123
  - two or three lines of what healthy output looks like.
77
124
 
78
- `verify_command` comes from the human: show the one `$SETUP survey`
125
+ `verify_command` comes from the human: the `verify=<cmd>` pick is their yes,
126
+ written at the end of step 2; without one, show the one `$SETUP survey`
79
127
  proposed, ask, and only after a yes in chat write it with
80
128
  `$SETUP verify --set "<command>"` (exit 3: one is already set — the human
81
129
  edits it). `$SETUP check` then exits 0; `VERIFY_COMMAND_MISSING` (exit 1)
@@ -90,13 +138,13 @@ formatting fix. Problems you find are written down, never fixed. Never read
90
138
  that `.claude/settings.json` keeps `"enableAllProjectMcpServers": false` and
91
139
  that each server in a checked-in `.mcp.json` sits in `enabledMcpjsonServers`
92
140
  only if it earned it, else in `disabledMcpjsonServers`; say what you found.
93
- 6. **Weight table.** Propose this codebase's own paths for
94
- `.ai/policies/weight.json`: `domain.modules` (money, identity, personal
95
- data), `domain.customer_visible`, `scope.hot_paths`,
141
+ 6. **Weight table.** The plugin ships the table; this codebase's own paths go in
142
+ `.ai/policies/weight.project.json`, laid over it: `domain.modules` (money,
143
+ identity, personal data), `domain.customer_visible`, `scope.hot_paths`,
96
144
  `reversibility.needs_step` and `irreversible`, and one or two `examples` per
97
- mode. The JSON is the human's to edit (the path guard refuses yours); once
98
- they have, `$STATE weight --mirror` regenerates `weight.md`. The thresholds
99
- are not this skill's to move.
145
+ mode. The JSON is the human's to edit (the path guard refuses yours);
146
+ `--update` renders `weight.md` from the table and the overlay. The
147
+ thresholds are not this skill's to move.
100
148
  7. **Constitution.** Fill `docs/sdlc/constitution.md`: C1–C5 ship prefilled;
101
149
  C6 onwards are one line each, drawn from what the code and tests already
102
150
  enforce. Leave a slot empty rather than write a platitude; at most fifteen.
@@ -108,8 +156,8 @@ formatting fix. Problems you find are written down, never fixed. Never read
108
156
  security observations, missing documentation, areas agents must not touch
109
157
  casually, the weight-table entries you chose, recommended next improvements —
110
158
  recommendations only, none implemented. When the survey found a toolbox,
111
- offer **--adopt**'s own-toolbox path.
112
- 9. **Report.** Files created (a tree from the scaffold output), surprising
159
+ name each toolbox item the project keeps using; they stay where they are.
160
+ 9. **Report.** Files created (a tree from the scaffold output, 0a's too), surprising
113
161
  findings, the modes and what puts a change in each, the safety restrictions
114
162
  in force (hooks versus policy), the tooling the workflows reuse, assumptions,
115
163
  unresolved questions and who can answer them, the survey's superpowers
@@ -118,29 +166,49 @@ formatting fix. Problems you find are written down, never fixed. Never read
118
166
  `/rr-plan <it>`. Claim nothing was validated that was not run. Suggest
119
167
  `git add .ai .gitignore docs/sdlc` plus the instruction files created.
120
168
 
169
+ ## --options
170
+
171
+ Reopens every option on a set-up project: 0a, then `$SETUP options --open --all`, then
172
+ send, settle and apply as in step 0 — a `survey` pick runs steps 3–4 at that depth, as a
173
+ refresh (step 1), and a `verify` command is written at once. Say what changed and stop;
174
+ no other step reruns. A project 0a just scaffolded (it listed
175
+ `.ai/project/overview.md`) continues as the plain **Setup**.
176
+
121
177
  ## --update
122
178
 
123
- The script does the update; you show it, confirm what is owed, and merge what
124
- it cannot.
179
+ The script regenerates; you show it, confirm what is owed, and merge what it
180
+ cannot. It converts nothing but the one split. A tree that still holds an old
181
+ shape it detects (the pre-3.4b task state without `state.json`, the risk-tier
182
+ policy without a weight table, a pre-3.4b block marker) is refused with `KEPT_UNREADABLE` (exit 6); a
183
+ project last updated before 3.1.0 goes through `npx riskrails@3.1.0` first. Run it right after a new
184
+ riskrails is installed: until then the project's old shapes are not read.
125
185
 
126
186
  1. `$STATE status`: with a task in flight, say that updating policies mid-task
127
187
  can change what the rest of it needs, and ask whether to finish it first.
128
188
  2. `$UPDATE` — the dry run; show it as is. Up to date and no hint: say so, stop.
129
- `schema N -> M` means migrations run first; `[NNNN]` marks their lines; a
130
- `move` carries edits to the new path and keeps the original under
131
- `.ai/reports/project-update-<date>/`; `delete?` is a proposal (step 4).
132
- 3. Lines marked `policy` change `.ai/policies/*.json`, which humans own: explain
133
- each in one plain sentence and ask, unless `$ARGUMENTS` holds `--apply`.
189
+ A `regenerate` is a file that matches a version the plugin once shipped and is
190
+ replaced; a `regenerate?` or `delete?` is a proposal for the human (step 4); a
191
+ `create` is a file the project lacks. A project that still has the mixed
192
+ `testing.md` and `weight.json` gets `verification.md` and `weight.project.json`
193
+ split out of them once.
194
+ 3. A `split` row writes `verification.md` or `weight.project.json`, which humans
195
+ own from then on: say in one plain sentence what it carries out of
196
+ `testing.md` or `weight.json`, and ask, unless `$ARGUMENTS` holds `--apply`.
134
197
  4. `$UPDATE --apply`. Exit 3 stopped on a changed, non-regular or unwritable
135
198
  file and names it; nothing after it was written — run the dry run again.
136
- **A `delete?` is the human's.** Never pass `--confirm-delete` or `--confirm-cleanup`, not even with
199
+ Exit 6 (`KEPT_UNREADABLE`): a file the update keeps cannot be read; nothing was
200
+ written — name it, the human fixes or removes it, then run again.
201
+ **A `regenerate?` and a `delete?` are the human's.** Never pass `--confirm-delete` or `--confirm-cleanup`, not even with
137
202
  `--apply`. Give them, with `$AI_HOME` and `$PWD` substituted, for their own
138
203
  terminal (the `!` prefix is refused):
139
204
  `python3 "<home>/skills/project-update/update.py" "<project>" --apply --confirm-delete "<your name>"`.
140
- The schema stays put until it is settled — that command, or deleting the
141
- file by hand; there is no third way. Two kinds are housekeeping, not
142
- migrations: `[sdlc]` — an unedited `docs/sdlc/*/TEMPLATE.md`, which the plugin
143
- now supplies (an edited one stays as the project's override); `[cleanup]` —
205
+ Exit 5 (`CONFIRM_REFUSED`) means an agent session ran it; it wrote nothing.
206
+ Every file replaced or deleted that way is first copied under
207
+ `.ai/reports/project-update-<date>/original/`. Two kinds are housekeeping:
208
+ `[rules]` — every rule source `.ai/rules/<slug>.md` (an update does not keep
209
+ them; confirming deletes the source and its rendered blocks with it) and a
210
+ rendered rule file whose source is gone or no longer sets `paths:`, both
211
+ settled by `--confirm-delete`; `[cleanup]` —
144
212
  the `*.log` files of closed tasks, and the report and log files of an
145
213
  abandoned task (its `state.json` stays) or of one unclosed for more than seven
146
214
  days (never the task in flight; and none when `.ai/state/state.json` is unreadable).
@@ -151,16 +219,15 @@ it cannot.
151
219
  commit `.ai/` first (the hint says so), and an `original/` copy is kept as for any
152
220
  other deletion. They have their own command, the human's too, never passed by the agent:
153
221
  `python3 "<home>/skills/project-update/update.py" "<project>" --apply --confirm-cleanup "<your name>"`.
154
- Show both groups as printed. For 0006 (shared files) the order is:
155
- `install.sh` for every runtime used, commit `.ai/`, read the `delete?` list,
156
- then the command with no task in flight. Rollback is git:
222
+ Show both groups as printed. Rollback is git:
157
223
  `git restore --source=<commit before> --staged --worktree -- .ai`, before
158
224
  the plugin itself is rolled back.
159
- 5. A `conflict` line: the project file was edited here and changed upstream.
160
- Markdown, or the managed block (inside the markers only): read both, keep
161
- everything project-specific, take the plugin's rules and structure, edit the
162
- project file, delete the copy. A JSON policy: show both values for each
163
- listed path and say which the plugin expects and why; the human edits it.
225
+ 5. A `regenerate?` row: the project edited a file the plugin generates. Read
226
+ its reason; anything project-specific in it belongs in a file the update keeps
227
+ (`.ai/project/`, `weight.project.json`, `verification.md`, the instruction
228
+ file outside the managed block — not `.ai/rules/`, whose sources are `[rules]`
229
+ rows too) — say where, the human moves it,
230
+ then confirms. Never edit the generated file to dodge the row.
164
231
  6. Hints. `verify_command is empty`: show `$SETUP survey`'s proposal, ask for
165
232
  the one command and what a green run ends with, write it with
166
233
  `$SETUP verify --set`, and fill the rest of the Verification block. `the managed block is N B`:
@@ -169,8 +236,7 @@ it cannot.
169
236
  fifteen principles or 4096 B: offer to move policy into `.ai/policies/`.
170
237
  `that rule is not rendered`: name the `.ai/rules/` file and what it lacks
171
238
  (`paths:` and a body). `overrides the plugin's shared copy`: offer to diff
172
- each and delete those that add nothing. `foreign structure detected`: offer
173
- **--adopt**. `tracked by git but ignored`: show the line as printed and give
239
+ each and delete those that add nothing. `tracked by git but ignored`: show the line as printed and give
174
240
  the human the command it prints, exactly as printed, plus a commit, for their
175
241
  own terminal (never rebuilt from the path; only the xargs form untracks every
176
242
  such file under `.ai/state`, a printed `rm --cached -- <path>` one file; a
@@ -180,55 +246,6 @@ it cannot.
180
246
  and what is the human's. Suggest `git add -A .ai docs/sdlc .gitignore` plus
181
247
  the runtime directories and instruction files.
182
248
 
183
- ## --adopt
184
-
185
- **A project's own toolbox** — its `.claude/` skills, commands, rules, agents
186
- and hooks, `.codex/*`, `bin/*.sh`, Makefile targets — is production behaviour
187
- (C1), not a foreign structure: it is inventoried in place, never copied or
188
- moved. `$SETUP adopt` shows `.ai/policies/toolbox.md` (one line per item: link,
189
- purpose, KNOWN FACT `file:line` or UNKNOWN) and the router rows it appends to
190
- `.ai/AGENTS.md` — one per skill or command, naming its job and its `/<name>`. A
191
- project hook doing a plugin guard's job is kept and noted; a guard with none is
192
- reported. Ask "apply?", then `$SETUP adopt --apply`; it is idempotent. Exit 3:
193
- `toolbox.md` differs from the inventory (a human edited it) — show both, never
194
- overwrite. A foreign tool's structure, below, can be present as well.
195
-
196
- Every command is `$UPDATE --adopt …`, with `--mode coexist` on each when the team
197
- still uses the other tool (router rows only, nothing moves). Exit 5
198
- `ADOPT_REFUSED`: show the first line and stop. Exit 2: the routing table or a
199
- migration could not be read (reason on stderr, prefixed `project-update:`),
200
- nothing written. Exit 4 `ADOPT_INCOMPLETE`:
201
- `unmapped` files and a `split?` are yours to settle, then dry-run again; a
202
- `conflict` or a check `FAIL` left after that is the human's — never edit a
203
- destination or a source to make it pass.
204
-
205
- 1. Preconditions: no task in flight (`$STATE status`), `git status` clean,
206
- `$UPDATE --check` exits 0. Otherwise stop and say which failed.
207
- 2. `$UPDATE --adopt`; show it as is.
208
- 3. Each `unmapped` file: ask the human (drop with a reason, or copy to a named
209
- destination) and write the answers to `.ai/reports/adopt-<date>/decisions.json`
210
- as `{"version": 1, "unmapped": {"<path>": {"action": "drop", "why": "…"}}}`.
211
- A glob key settles a directory (`drop` or `ignore` only); an exact path wins
212
- over a glob, a longer glob over a shorter one.
213
- 4. A `split?` (an instruction file too large to keep): on a `pro` or `plus` plan
214
- (`jq -r .plan "$AI_HOME/riskrails/profile.json"`), when that fails, or
215
- under `AI_UNATTENDED`, use `--split fallback` — every line outside the managed
216
- block moves verbatim to `.ai/policies/adopted/`. Otherwise run
217
- `--split-request` and write the proposal yourself, once, to the `proposal`
218
- path the request names: line ranges, destinations from `allowed_dest`,
219
- headings from its `outline` — never text (the tool refuses that). A proposal
220
- for the same file sha is reused.
221
- 5. `$UPDATE --adopt --diff`; show it and ask "apply?".
222
- 6. `$UPDATE --adopt --apply` (with `--split fallback` if step 4 chose it); show
223
- the two `check` lines and read out each `no-dangling` warning. On a FAIL read
224
- `dropped.jsonl`, amend the proposal or decisions, run again.
225
- 7. Point at `.ai/reports/adopt-<date>/report.md`; suggest `git add` of the new
226
- structure and the report directory, and a commit.
227
- 8. Cleanup is the human's: show `$UPDATE --adopt --cleanup`, then give the full
228
- command with both paths absolute for their own terminal —
229
- `python3 "<home>/skills/project-update/update.py" "<project>" --adopt --cleanup --apply --confirm-delete "<your name>"`.
230
- Setting `AI_UNATTENDED` to pass it is the same act as typing their name.
231
-
232
249
  ## --audit
233
250
 
234
251
  The only file written is `docs/ai-sdlc-adoption-plan.md`; everything else is
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env python3
2
2
  """Idempotent .ai/ scaffold for RiskRails.
3
- scaffold_ai.py [project-dir] [--runtime auto|claude|codex|both] (default: $PWD, auto)
3
+ scaffold_ai.py [project-dir] [--runtime auto|claude|codex|both|none] (default: $PWD, auto)
4
4
  skills/ai-init/scaffold-ai.sh execs it; the templates stay in skills/ai-init/.
5
5
 
6
6
  Never overwrites an existing file. Run it as often as you like: it creates what
@@ -14,6 +14,10 @@ that points at it differs — CLAUDE.md for Claude Code, AGENTS.md for Codex.
14
14
  A port of the shell script it replaced, kept to its bytes: the same files and
15
15
  modes, the same listing in the same order, the same messages and exit codes
16
16
  (tests/test_scaffold_differential.py runs the frozen shell beside it).
17
+
18
+ One value is new, and the shell refuses it: `--runtime none` (or AI_RUNTIMES=none) scaffolds .ai/ and its
19
+ .gitignore lines and no instruction file, so /rr-setup can open .ai/ before the project's runtimes are chosen.
20
+ Like `both` and `auto` it is a whole value: inside a list it is an unknown runtime, as in the shell.
17
21
  """
18
22
  import errno
19
23
  import json
@@ -27,8 +31,9 @@ import sys
27
31
  NAME = "scaffold-ai"
28
32
  # The directory the shell script ran from: templates and the runtime it was installed for.
29
33
  HERE = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "ai-init"))
34
+ SHIPPED_WEIGHT = ".ai/policies/weight.json"
30
35
  RUNTIMES = ("claude", "codex", "gemini", "junie")
31
- BLOCK = re.compile(rb"<!-- (riskrails|claude-agentic|[Cc]odex-agentic):start -->")
36
+ BLOCK = re.compile(rb"<!-- riskrails:start -->")
32
37
 
33
38
 
34
39
  class Exit(Exception):
@@ -142,7 +147,9 @@ def logical_cd(root):
142
147
 
143
148
 
144
149
  def runtimes(runtime, root):
145
- """The runtimes in scope: what the project declares (auto), or the list given."""
150
+ """The runtimes in scope: what the project declares (auto), the list given, or none at all."""
151
+ if runtime == "none":
152
+ return set()
146
153
  if runtime == "both":
147
154
  runtime = "claude,codex"
148
155
  if runtime == "auto":
@@ -212,15 +219,14 @@ def main(argv):
212
219
  root = stdin_cwd()
213
220
  root = logical_cd(root or logical_pwd())
214
221
  project = os.fsencode("/" if root == "/" else os.path.basename(root))
215
- tpl = env("RISKRAILS_TEMPLATES") or env("CLAUDE_AGENTIC_TEMPLATES") or os.path.join(HERE, "templates")
222
+ tpl = env("RISKRAILS_TEMPLATES") or os.path.join(HERE, "templates")
216
223
  if not os.path.isdir(os.path.join(tpl, ".ai")):
217
224
  raise Exit(1, "%s: templates not found at %s (run riskrails/install.sh)" % (NAME, tpl))
218
225
  on = runtimes(runtime, root)
219
226
  created = []
220
227
 
221
228
  # A project that already has .ai/ carries a schema version this scaffold must not
222
- # invent: writing .ai/VERSION here would tell /project-update that every migration
223
- # has already run. Only a fresh tree starts at the shipped schema.
229
+ # invent: only a fresh tree starts at the shipped schema.
224
230
  had_ai = os.path.isdir(os.path.join(root, ".ai"))
225
231
 
226
232
  # Copy the .ai/ tree, file by file, skipping anything that already exists.
@@ -231,6 +237,8 @@ def main(argv):
231
237
  dst = os.path.join(root, rel)
232
238
  if os.path.exists(dst) or (rel == ".ai/VERSION" and had_ai):
233
239
  continue
240
+ if rel == SHIPPED_WEIGHT: # A2: the plugin's table is read from the plugin, never copied
241
+ continue
234
242
  os.makedirs(os.path.dirname(dst), exist_ok=True)
235
243
  # cp: the source's permission bits, less the umask.
236
244
  shutil.copyfile(src, dst)
@@ -253,9 +261,7 @@ def main(argv):
253
261
  created.append(".gitignore (appended)")
254
262
 
255
263
  # The instruction file: create a minimal one if absent, then append the managed
256
- # block once. An existing file is never replaced — only appended to. A legacy
257
- # Codex-agentic pair is the block under its old name: nothing is appended beside
258
- # it; /project-update renames it.
264
+ # block once. An existing file is never replaced — only appended to.
259
265
  def instruction_file(name, minimal, block):
260
266
  md = os.path.join(root, name)
261
267
  os.makedirs(os.path.dirname(md), exist_ok=True)