@hanzlaa/rcode 3.4.4 → 3.4.6

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 (213) hide show
  1. package/AGENTS.md +1 -1
  2. package/CONTRIBUTING.md +63 -1
  3. package/README.md +9 -4
  4. package/cli/generate-command-skills.cjs +21 -9
  5. package/cli/index.js +0 -0
  6. package/cli/install.js +126 -7
  7. package/cli/lib/manifest.cjs +1 -1
  8. package/cli/uninstall.js +8 -0
  9. package/dist/rcode.js +1279 -2004
  10. package/package.json +16 -17
  11. package/rihal/agents/rihal-ahmed.md +2 -1
  12. package/rihal/agents/rihal-code-fixer.md +46 -0
  13. package/rihal/agents/rihal-code-reviewer.md +46 -1
  14. package/rihal/agents/rihal-deviation-analyzer.md +1 -0
  15. package/rihal/agents/rihal-docs-auditor.md +106 -1
  16. package/rihal/agents/rihal-edge-case-hunter.md +47 -1
  17. package/rihal/agents/rihal-executor.md +1 -1
  18. package/rihal/agents/rihal-khalid.md +40 -1
  19. package/rihal/agents/rihal-layla.md +2 -1
  20. package/rihal/agents/rihal-nasser.md +2 -1
  21. package/rihal/agents/rihal-noor.md +3 -2
  22. package/rihal/agents/rihal-nyquist-auditor.md +1 -1
  23. package/rihal/agents/rihal-phase-researcher.md +46 -1
  24. package/rihal/agents/rihal-planner.md +1 -1
  25. package/rihal/agents/rihal-profiler.md +45 -2
  26. package/rihal/agents/rihal-project-researcher.md +47 -0
  27. package/rihal/agents/rihal-remediation-planner.md +45 -0
  28. package/rihal/agents/rihal-roadmapper.md +46 -0
  29. package/rihal/agents/rihal-security-adversary.md +46 -1
  30. package/rihal/agents/rihal-security-auditor.md +45 -1
  31. package/rihal/agents/rihal-ui-auditor.md +44 -1
  32. package/rihal/agents/rihal-ux-designer.md +41 -1
  33. package/rihal/agents/rihal-zahra.md +2 -1
  34. package/rihal/agents/rihal-zayd.md +2 -1
  35. package/rihal/bin/lib/config.cjs +13 -1
  36. package/rihal/bin/lib/council-panel.cjs +185 -23
  37. package/rihal/bin/lib/roadmap.cjs +27 -2
  38. package/rihal/bin/rihal-tools.cjs +1837 -99
  39. package/rihal/commands/audit.md +2 -2
  40. package/rihal/commands/capture.md +12 -0
  41. package/rihal/commands/diagnose-issues.md +18 -0
  42. package/rihal/commands/discuss-phase-power.md +18 -0
  43. package/rihal/commands/feature-drift.md +18 -0
  44. package/rihal/commands/karpathy-audit.md +18 -0
  45. package/rihal/commands/lens-audit.md +70 -0
  46. package/rihal/commands/new-project-research.md +18 -0
  47. package/rihal/commands/new-project-roadmap.md +18 -0
  48. package/rihal/commands/phase.md +11 -0
  49. package/rihal/references/continuation-format.md +3 -3
  50. package/rihal/references/output-format.md +79 -0
  51. package/rihal/references/revision-loop.md +1 -1
  52. package/rihal/references/verb-dictionary.md +85 -28
  53. package/rihal/skills/actions/1-analysis/rihal-prfaq/SKILL.md +1 -1
  54. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/SKILL.md +12 -2
  55. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/steps/step-04-final-validation.md +12 -0
  56. package/rihal/skills/actions/2-plan/rihal-create-prd/SKILL.md +12 -2
  57. package/rihal/skills/actions/2-plan/rihal-create-story/SKILL.md +12 -2
  58. package/rihal/skills/actions/4-implementation/rihal-browser-verify/SKILL.md +1 -1
  59. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/SKILL.md +1 -1
  60. package/rihal/skills/actions/4-implementation/rihal-ci/SKILL.md +1 -1
  61. package/rihal/skills/actions/4-implementation/rihal-code-review/SKILL.md +16 -4
  62. package/rihal/skills/actions/4-implementation/rihal-debug/SKILL.md +14 -1
  63. package/rihal/skills/actions/4-implementation/rihal-git-flow/SKILL.md +1 -1
  64. package/rihal/skills/actions/4-implementation/rihal-harden/SKILL.md +1 -1
  65. package/rihal/skills/actions/4-implementation/rihal-incremental/SKILL.md +1 -1
  66. package/rihal/skills/actions/4-implementation/rihal-migrate/SKILL.md +1 -1
  67. package/rihal/skills/actions/4-implementation/rihal-perf/SKILL.md +1 -1
  68. package/rihal/skills/actions/4-implementation/rihal-prove-it/SKILL.md +1 -1
  69. package/rihal/skills/actions/4-implementation/rihal-scaffold-project/steps/step-01-target.md +6 -0
  70. package/rihal/skills/actions/4-implementation/rihal-source-truth/SKILL.md +1 -1
  71. package/rihal/skills/actions/4-implementation/rihal-sprint-planning/SKILL.md +14 -3
  72. package/rihal/skills/actions/4-implementation/rihal-trim/SKILL.md +1 -1
  73. package/rihal/skills/agents/ahmed-hassani-director/SKILL.md +15 -1
  74. package/rihal/skills/agents/dalil-scout/SKILL.md +14 -2
  75. package/rihal/skills/agents/fatima-qa/SKILL.md +16 -1
  76. package/rihal/skills/agents/haitham-frontend/SKILL.md +13 -1
  77. package/rihal/skills/agents/hanzla-engineer/SKILL.md +13 -1
  78. package/rihal/skills/agents/hussain-pm/SKILL.md +16 -1
  79. package/rihal/skills/agents/hussain-sm/SKILL.md +14 -1
  80. package/rihal/skills/agents/layla-designer/SKILL.md +13 -1
  81. package/rihal/skills/agents/majlis-council/SKILL.md +16 -1
  82. package/rihal/skills/agents/mariam-marketing/SKILL.md +14 -1
  83. package/rihal/skills/agents/nasser-eng-manager/SKILL.md +16 -1
  84. package/rihal/skills/agents/noor-writer/SKILL.md +15 -1
  85. package/rihal/skills/agents/raees-orchestrator/SKILL.md +15 -1
  86. package/rihal/skills/agents/rihal-cross-platform-auditor/SKILL.md +162 -0
  87. package/rihal/skills/agents/rihal-dep-auditor/SKILL.md +151 -0
  88. package/rihal/skills/agents/rihal-deviation-analyzer/SKILL.md +78 -0
  89. package/rihal/skills/agents/rihal-i18n-auditor/SKILL.md +152 -0
  90. package/rihal/skills/agents/rihal-observability-auditor/SKILL.md +156 -0
  91. package/rihal/skills/agents/sadiq-analyst/SKILL.md +12 -2
  92. package/rihal/skills/agents/waleed-architect/SKILL.md +12 -2
  93. package/rihal/skills/agents/yousef-backend/SKILL.md +12 -2
  94. package/rihal/skills/agents/zahra-branding/SKILL.md +15 -1
  95. package/rihal/skills/agents/zayd-ml/SKILL.md +13 -1
  96. package/rihal/skills/core/rihal-advanced-elicitation/SKILL.md +2 -2
  97. package/rihal/skills/core/rihal-auth-audit/SKILL.md +1 -1
  98. package/rihal/skills/core/rihal-brainstorming/SKILL.md +13 -2
  99. package/rihal/skills/core/rihal-client-gate/SKILL.md +1 -1
  100. package/rihal/skills/core/rihal-clone-website/SKILL.md +11 -1
  101. package/rihal/skills/core/rihal-deploy-unify/SKILL.md +1 -1
  102. package/rihal/skills/core/rihal-distillator/SKILL.md +2 -2
  103. package/rihal/skills/core/rihal-editorial-review-prose/SKILL.md +1 -1
  104. package/rihal/skills/core/rihal-editorial-review-structure/SKILL.md +2 -2
  105. package/rihal/skills/core/rihal-help/SKILL.md +18 -1
  106. package/rihal/skills/core/rihal-incident-record/SKILL.md +1 -1
  107. package/rihal/skills/core/rihal-index-docs/SKILL.md +1 -1
  108. package/rihal/skills/core/rihal-memory-audit/SKILL.md +18 -1
  109. package/rihal/skills/core/rihal-memory-init/SKILL.md +13 -1
  110. package/rihal/skills/core/rihal-memory-update/SKILL.md +13 -1
  111. package/rihal/skills/core/rihal-mvp-graduate/SKILL.md +1 -1
  112. package/rihal/skills/core/rihal-ocr-consistency/SKILL.md +1 -1
  113. package/rihal/skills/core/rihal-rebrand/SKILL.md +1 -1
  114. package/rihal/skills/core/rihal-review-adversarial-general/SKILL.md +1 -1
  115. package/rihal/skills/core/rihal-review-edge-case-hunter/SKILL.md +17 -1
  116. package/rihal/skills/core/rihal-shard-doc/SKILL.md +1 -1
  117. package/rihal/skills/core/rihal-theme-system/SKILL.md +1 -1
  118. package/rihal/team.yaml +0 -7
  119. package/rihal/templates/RESEARCH.md +84 -0
  120. package/rihal/templates/VALIDATION.md +45 -0
  121. package/rihal/templates/memory/INDEX.md +1 -0
  122. package/rihal/templates/memory/project/design-system.md +128 -0
  123. package/rihal/templates/summary.md +33 -3
  124. package/rihal/workflows/add-tests.md +1 -1
  125. package/rihal/workflows/add-todo.md +6 -0
  126. package/rihal/workflows/analyze-dependencies.md +6 -0
  127. package/rihal/workflows/audit-fix.md +12 -0
  128. package/rihal/workflows/audit-milestone.md +2 -2
  129. package/rihal/workflows/audit.md +23 -14
  130. package/rihal/workflows/autonomous-smart-discuss.md +247 -0
  131. package/rihal/workflows/autonomous.md +54 -267
  132. package/rihal/workflows/capture.md +60 -0
  133. package/rihal/workflows/chain.md +1 -1
  134. package/rihal/workflows/code-review-fix.md +6 -3
  135. package/rihal/workflows/code-review.md +34 -10
  136. package/rihal/workflows/complete-milestone.md +17 -8
  137. package/rihal/workflows/correct-course.md +6 -0
  138. package/rihal/workflows/council.md +37 -23
  139. package/rihal/workflows/create-architecture.md +31 -0
  140. package/rihal/workflows/create-epics-and-stories.md +7 -1
  141. package/rihal/workflows/create-prd.md +25 -0
  142. package/rihal/workflows/dashboard.md +1 -1
  143. package/rihal/workflows/debug.md +8 -0
  144. package/rihal/workflows/decisions.md +1 -1
  145. package/rihal/workflows/diff.md +6 -0
  146. package/rihal/workflows/discuss-phase-discuss-areas.md +271 -0
  147. package/rihal/workflows/discuss-phase.md +27 -266
  148. package/rihal/workflows/do.md +51 -12
  149. package/rihal/workflows/docs-update.md +3 -0
  150. package/rihal/workflows/document-project.md +7 -1
  151. package/rihal/workflows/edit-prd.md +31 -0
  152. package/rihal/workflows/enable-hooks.md +1 -1
  153. package/rihal/workflows/execute-regression-gates.md +131 -0
  154. package/rihal/workflows/execute-sprint.md +31 -2
  155. package/rihal/workflows/execute-verify-phase-goal.md +136 -0
  156. package/rihal/workflows/execute-waves.md +404 -0
  157. package/rihal/workflows/execute.md +101 -642
  158. package/rihal/workflows/feature-drift.md +243 -0
  159. package/rihal/workflows/forensics.md +10 -2
  160. package/rihal/workflows/health.md +65 -16
  161. package/rihal/workflows/help.md +36 -9
  162. package/rihal/workflows/import.md +17 -3
  163. package/rihal/workflows/init.md +20 -10
  164. package/rihal/workflows/install.md +2 -10
  165. package/rihal/workflows/lens-audit.md +689 -0
  166. package/rihal/workflows/map-codebase.md +7 -1
  167. package/rihal/workflows/memory-audit.md +67 -5
  168. package/rihal/workflows/memory-distill.md +10 -0
  169. package/rihal/workflows/memory-init.md +4 -0
  170. package/rihal/workflows/memory-update.md +4 -0
  171. package/rihal/workflows/new-milestone.md +7 -1
  172. package/rihal/workflows/new-project-create-roadmap.md +176 -0
  173. package/rihal/workflows/new-project-define-requirements.md +160 -0
  174. package/rihal/workflows/new-project-research-decision.md +247 -0
  175. package/rihal/workflows/new-project.md +3 -557
  176. package/rihal/workflows/note.md +1 -1
  177. package/rihal/workflows/phase.md +54 -0
  178. package/rihal/workflows/plan-milestone-gaps.md +1 -1
  179. package/rihal/workflows/plan-prd-express.md +108 -0
  180. package/rihal/workflows/plan-research-validation.md +313 -0
  181. package/rihal/workflows/plan-spawn-planner.md +204 -0
  182. package/rihal/workflows/plan.md +91 -532
  183. package/rihal/workflows/plant-seed.md +1 -1
  184. package/rihal/workflows/pr-branch.md +1 -1
  185. package/rihal/workflows/profile-user.md +1 -1
  186. package/rihal/workflows/quick.md +3 -3
  187. package/rihal/workflows/remove-phase.md +6 -1
  188. package/rihal/workflows/remove-workspace.md +6 -0
  189. package/rihal/workflows/rerun.md +1 -1
  190. package/rihal/workflows/research-phase.md +4 -2
  191. package/rihal/workflows/resume-work.md +8 -3
  192. package/rihal/workflows/retrospective.md +31 -0
  193. package/rihal/workflows/review-adversarial.md +12 -0
  194. package/rihal/workflows/review.md +6 -0
  195. package/rihal/workflows/scaffold-project.md +31 -0
  196. package/rihal/workflows/scan.md +10 -0
  197. package/rihal/workflows/secure-phase.md +15 -2
  198. package/rihal/workflows/session-report.md +32 -7
  199. package/rihal/workflows/ship.md +7 -2
  200. package/rihal/workflows/show.md +6 -0
  201. package/rihal/workflows/sprint-status.md +4 -4
  202. package/rihal/workflows/status.md +2 -2
  203. package/rihal/workflows/ui-phase.md +1 -1
  204. package/rihal/workflows/undo.md +2 -3
  205. package/rihal/workflows/update.md +2 -2
  206. package/rihal/workflows/validate-phase.md +1 -1
  207. package/rihal/workflows/validate-prd.md +31 -0
  208. package/rihal/workflows/verify-phase.md +38 -5
  209. package/rihal/workflows/verify-work.md +25 -11
  210. package/rihal/workflows/workstream.md +20 -8
  211. package/server/lib/html/client.js +13 -63
  212. package/server/lib/html/shell.js +0 -1
  213. package/server/lib/scanner.js +33 -2
@@ -0,0 +1,689 @@
1
+ # Workflow: rihal-lens-audit
2
+
3
+ <purpose>
4
+ Run a structured 15-lens code audit against the current project. Each lens
5
+ delegates to its mapped primary skill via Task() subagent dispatch — the skill
6
+ provides domain expertise; this workflow handles orchestration, aggregation,
7
+ and GH issue body generation. Never fixes anything; audit-first, fix-second.
8
+ </purpose>
9
+
10
+ ## Skill Mapping
11
+
12
+ | Lens | Name | Primary Skill | Secondary |
13
+ |------|------|--------------|-----------|
14
+ | 1 | Security | `rihal-security-auditor` | `rihal-security-adversary` |
15
+ | 2 | Performance | `rihal-perf` | — |
16
+ | 3 | Testability | `rihal-fatima` | `rihal-edge-case-hunter` |
17
+ | 4 | Extensibility | `rihal-waleed` | — |
18
+ | 5 | Dep Health | `rihal-dep-auditor` | — |
19
+ | 6 | Error Recovery | `rihal-debugger` | — |
20
+ | 7 | State Machine | `rihal-deviation-analyzer` | — |
21
+ | 8 | i18n | `rihal-i18n-auditor` | — |
22
+ | 9 | Documentation | `rihal-docs-auditor` | — |
23
+ | 10 | Cross-platform | `rihal-cross-platform-auditor` | — |
24
+ | 11 | Karpathy | `rihal-code-reviewer` | `rihal-hanzla` |
25
+ | 12 | SXO/UX | `rihal-layla` | — |
26
+ | 13 | Observability | `rihal-observability-auditor` | — |
27
+ | 14 | Naming | `rihal-codebase-mapper` | `rihal-code-reviewer` |
28
+ | 15 | Coverage | `rihal-nyquist-auditor` | `rihal-fatima` |
29
+
30
+ ## Step 0 — Usage check
31
+
32
+ If `$ARGUMENTS` is `--help` or `-h`:
33
+
34
+ ```
35
+ /rihal-lens-audit # interactive — asks which lens
36
+ /rihal-lens-audit all # run all 15 lenses sequentially
37
+ /rihal-lens-audit <N> # run lens N (1-15) only
38
+ /rihal-lens-audit <name> # run by name, e.g. "security", "performance"
39
+
40
+ Lenses and their primary skills:
41
+ 1. security — rihal-security-auditor + rihal-security-adversary
42
+ 2. performance — rihal-perf
43
+ 3. testability — rihal-fatima + rihal-edge-case-hunter
44
+ 4. extensibility — rihal-waleed
45
+ 5. dep-health — rihal-dep-auditor
46
+ 6. error-recovery — rihal-debugger
47
+ 7. state-machine — rihal-deviation-analyzer
48
+ 8. i18n — rihal-i18n-auditor
49
+ 9. documentation — rihal-docs-auditor
50
+ 10. cross-platform — rihal-cross-platform-auditor
51
+ 11. karpathy — rihal-code-reviewer + rihal-hanzla
52
+ 12. sxo — rihal-layla
53
+ 13. observability — rihal-observability-auditor
54
+ 14. naming — rihal-codebase-mapper + rihal-code-reviewer
55
+ 15. coverage — rihal-nyquist-auditor + rihal-fatima
56
+ ```
57
+
58
+ STOP after printing help.
59
+
60
+ ## Step 1 — Resolve target lens(es)
61
+
62
+ ```bash
63
+ TOOL="node .rihal/bin/rihal-tools.cjs"
64
+ INIT=$($TOOL init 2>/dev/null || echo '{"ok":false}')
65
+ MODE=$($TOOL config-get mode 2>/dev/null || echo "guided")
66
+ RESPONSE_LANGUAGE=$($TOOL config-get response_language 2>/dev/null || echo "english")
67
+ ```
68
+
69
+ If INIT is empty or INIT.ok is false, print error and exit:
70
+ ```
71
+ rihal-tools not found. Run: npx @hanzlaa/rcode install .
72
+ ```
73
+
74
+ Parse `$ARGUMENTS`:
75
+ - `all` → `LENSES=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)`
76
+ - digit 1–15 → `LENSES=(<N>)`
77
+ - known lens name → map to number → `LENSES=(<N>)`
78
+ - empty → continue to Step 2 (interactive picker)
79
+
80
+ Name → number mapping:
81
+ `security=1, performance=2, testability=3, extensibility=4, dep-health=5,`
82
+ `error-recovery=6, state-machine=7, i18n=8, documentation=9, cross-platform=10,`
83
+ `karpathy=11, sxo=12, observability=13, naming=14, coverage=15`
84
+
85
+ ## Step 2 — Interactive picker (when no argument given)
86
+
87
+ Call AskUserQuestion:
88
+
89
+ ```
90
+ Question:
91
+ Kaun sa lens run karna hai? (Which lens to run?)
92
+
93
+ Options:
94
+ 1. security — rihal-security-auditor (injection, secrets, auth)
95
+ 2. performance — rihal-perf (unbounded reads, wasted passes)
96
+ 3. testability — rihal-fatima (coverage gaps, untested paths)
97
+ 4. extensibility — rihal-waleed (hardcoded values, scalability)
98
+ 5. dep-health — rihal-dep-auditor (CVEs, unused, loose pins)
99
+ 6. error-recovery — rihal-debugger (swallowed errors, missing fallbacks)
100
+ 7. state-machine — rihal-deviation-analyzer (transitions, schema drift)
101
+ 8. i18n — rihal-i18n-auditor (hardcoded strings, RTL, response_language)
102
+ 9. documentation — rihal-docs-auditor (Next Up, dead links, 5-component)
103
+ 10. cross-platform — rihal-cross-platform-auditor (bash-isms, macOS flags)
104
+ 11. karpathy — rihal-code-reviewer + rihal-hanzla (overengineering, stubs)
105
+ 12. sxo — rihal-layla (dead-end flows, missing guidance)
106
+ 13. observability — rihal-observability-auditor (unguarded calls, silent fails)
107
+ 14. naming — rihal-codebase-mapper (naming drift, PLAN.md vs SPRINT.md)
108
+ 15. coverage — rihal-nyquist-auditor (parity gaps, untested commands)
109
+ 16. all — run all 15 lenses
110
+ 0. cancel
111
+ ```
112
+
113
+ Set `LENSES` from the choice.
114
+
115
+ ## Step 3 — Determine scope
116
+
117
+ ```bash
118
+ # Collect scope context for skill prompts
119
+ SCOPE_DIRS="rihal/ .rihal/"
120
+ [ -d src ] && SCOPE_DIRS="$SCOPE_DIRS src/"
121
+ [ -d lib ] && SCOPE_DIRS="$SCOPE_DIRS lib/"
122
+ SCOPE_SUMMARY="Scope: $SCOPE_DIRS. Response language: $RESPONSE_LANGUAGE."
123
+
124
+ # Collect project context for richer prompts
125
+ PROJECT_NAME=$($TOOL config-get project.name 2>/dev/null || basename "$PWD")
126
+ GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
127
+ GIT_SHA=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
128
+ CONTEXT="Project: $PROJECT_NAME. Branch: $GIT_BRANCH ($GIT_SHA). $SCOPE_SUMMARY"
129
+ ```
130
+
131
+ ## Step 4 — Dispatch each lens to its primary skill
132
+
133
+ For each lens number in `LENSES`:
134
+
135
+ **Partial-fail protocol:** if a subagent Task() call errors, log
136
+ `Lens N ({name}): subagent error — skipping` and continue with remaining lenses.
137
+ Never halt the whole audit because one lens's skill fails.
138
+
139
+ ---
140
+
141
+ ### Lens 1 — Security
142
+
143
+ ```
144
+ PRIMARY = Task(
145
+ subagent_type="rihal-security-auditor",
146
+ model="sonnet",
147
+ prompt="Audit-only — do NOT fix anything. {CONTEXT}
148
+
149
+ Run Lens 1 (Security) audit. Check:
150
+ - Hardcoded secrets / tokens / passwords in any file
151
+ - Path traversal: unsanitised user input in file read paths
152
+ - Shell injection: unquoted variables in exec/spawn/execSync calls
153
+ - Auth bypass: skipAuth, bypassAuth, noAuth patterns
154
+ - Insecure defaults in config files
155
+
156
+ Apply OWASP Top 10 and Semgrep security rule patterns.
157
+
158
+ Return findings as: file:line — description [severity: critical|warn|info]
159
+ If no findings: respond with exactly PASS"
160
+ )
161
+
162
+ SECONDARY = Task(
163
+ subagent_type="rihal-security-adversary",
164
+ model="sonnet",
165
+ prompt="Adversarial security review. {CONTEXT}
166
+
167
+ Think like an attacker. Find exploitation paths in:
168
+ - Input validation gaps
169
+ - Trust boundary violations
170
+ - Privilege escalation opportunities
171
+
172
+ Return: file:line — attack vector [critical|warn]
173
+ If clean: PASS"
174
+ )
175
+
176
+ FINDINGS[security] = merge(PRIMARY, SECONDARY)
177
+ ```
178
+
179
+ ---
180
+
181
+ ### Lens 2 — Performance
182
+
183
+ ```
184
+ RESULT = Task(
185
+ subagent_type="rihal-code-reviewer",
186
+ model="sonnet",
187
+ prompt="Audit-only — do NOT optimize anything. {CONTEXT}
188
+
189
+ Run Lens 2 (Performance) audit. Check:
190
+ - Unbounded file reads (find without -maxdepth, cat without head)
191
+ - readFileSync / fs.readFileSync inside loops
192
+ - JSON.parse on large blobs without size guard or try/catch
193
+ - Synchronous operations blocking the event loop
194
+ - Missing pagination or limit on list operations
195
+
196
+ Reference: Lighthouse CI thresholds, Node.js clinic.js flame graph patterns.
197
+
198
+ Return: file:line — description [critical|warn|info]
199
+ If clean: PASS"
200
+ )
201
+
202
+ FINDINGS[performance] = RESULT
203
+ ```
204
+
205
+ ---
206
+
207
+ ### Lens 3 — Testability
208
+
209
+ ```
210
+ PRIMARY = Task(
211
+ subagent_type="rihal-fatima",
212
+ model="sonnet",
213
+ prompt="Audit-only — do NOT write tests. {CONTEXT}
214
+
215
+ Run Lens 3 (Testability) audit. Check:
216
+ - Code paths with no test coverage
217
+ - Functions/workflows with no corresponding test or parity check
218
+ - Missing assertions (tests that never assert)
219
+ - Test files that import from production but never call the function
220
+ - Success criteria sections with no verifiable acceptance check
221
+
222
+ Reference: Istanbul/c8 coverage thresholds, mutation testing patterns.
223
+
224
+ Return: file:line — description [critical|warn|info]
225
+ If clean: PASS"
226
+ )
227
+
228
+ SECONDARY = Task(
229
+ subagent_type="rihal-edge-case-hunter",
230
+ model="sonnet",
231
+ prompt="Enumerate edge cases and boundary conditions. {CONTEXT}
232
+
233
+ Find:
234
+ - Boundary values not tested (off-by-one, empty input, null)
235
+ - Undefined state transitions
236
+ - Race conditions in parallel subagent spawns
237
+
238
+ Return: file:line — edge case description [critical|warn|info]
239
+ If clean: PASS"
240
+ )
241
+
242
+ FINDINGS[testability] = merge(PRIMARY, SECONDARY)
243
+ ```
244
+
245
+ ---
246
+
247
+ ### Lens 4 — Extensibility
248
+
249
+ ```
250
+ RESULT = Task(
251
+ subagent_type="rihal-waleed",
252
+ model="sonnet",
253
+ prompt="Architecture audit — do NOT redesign anything. {CONTEXT}
254
+
255
+ Run Lens 4 (Extensibility) audit. Check:
256
+ - Hardcoded mode/target lists that require source edits to extend
257
+ - Dispatch chains with >10 branches (missing strategy pattern)
258
+ - Hardcoded model IDs / API endpoints without config fallback
259
+ - Missing ADR for significant architectural decisions
260
+ - Scalability ceilings: N+1 patterns, unbounded collections
261
+
262
+ Reference: SOLID principles (Open/Closed), Strategy pattern, ADR format.
263
+
264
+ Return: file:line — description [critical|warn|info]
265
+ If clean: PASS"
266
+ )
267
+
268
+ FINDINGS[extensibility] = RESULT
269
+ ```
270
+
271
+ ---
272
+
273
+ ### Lens 5 — Dependency Health
274
+
275
+ ```
276
+ RESULT = Task(
277
+ subagent_type="rihal-code-reviewer",
278
+ model="sonnet",
279
+ prompt="Audit-only — do NOT install or update packages. {CONTEXT}
280
+
281
+ Run Lens 5 (Dep Health) audit:
282
+ - Run pnpm audit or npm audit and report CVEs
283
+ - Detect unused packages (imported nowhere in source)
284
+ - Flag loose version pins (^ or ~ prefix)
285
+ - Check for lock file presence (pnpm-lock.yaml / package-lock.json)
286
+ - Check engines.node field matches .nvmrc
287
+
288
+ Reference: Snyk severity scoring, OWASP Dependency-Check, Renovate pin policies.
289
+
290
+ Return: dep-name — issue [critical|warn|info]
291
+ If clean: PASS"
292
+ )
293
+
294
+ FINDINGS[dep-health] = RESULT
295
+ ```
296
+
297
+ ---
298
+
299
+ ### Lens 6 — Error Recovery
300
+
301
+ ```
302
+ RESULT = Task(
303
+ subagent_type="rihal-debugger",
304
+ model="sonnet",
305
+ prompt="Error recovery audit — do NOT fix anything. {CONTEXT}
306
+
307
+ Run Lens 6 (Error Recovery) audit. Find missing error handling:
308
+ - Shell calls ($(...)) without 2>/dev/null or try/catch
309
+ - Task() subagent calls with no failure branch in the workflow
310
+ - JSON.parse without try/catch wrapping
311
+ - INIT= assignments with no .ok check in next 15 lines
312
+ - 2>/dev/null lines with no || fallback value
313
+ - Missing graceful-degrade paths when an optional subagent fails
314
+
315
+ Reference: Bash set -euo pipefail patterns, Node.js error-first callbacks.
316
+
317
+ Return: file:line — description [critical|warn|info]
318
+ If clean: PASS"
319
+ )
320
+
321
+ FINDINGS[error-recovery] = RESULT
322
+ ```
323
+
324
+ ---
325
+
326
+ ### Lens 7 — State Machine
327
+
328
+ ```
329
+ RESULT = Task(
330
+ subagent_type="rihal-deviation-analyzer",
331
+ model="sonnet",
332
+ prompt="State machine audit — do NOT modify state. {CONTEXT}
333
+
334
+ Run Lens 7 (State Machine) audit. Check:
335
+ - Phase transitions without guards (complete→executing without --force)
336
+ - state.json schema drift (phases missing number/name/status fields)
337
+ - Workflows writing to .planning/ without checking if directory exists
338
+ - Workflows that auto-insert phantom phase stubs (number corruption)
339
+ - Missing migrate-schema call before reading phase state
340
+
341
+ Reference: XState finite state machine patterns, event sourcing invariants.
342
+
343
+ Return: file:line — description [critical|warn|info]
344
+ If clean: PASS"
345
+ )
346
+
347
+ FINDINGS[state-machine] = RESULT
348
+ ```
349
+
350
+ ---
351
+
352
+ ### Lens 8 — i18n
353
+
354
+ ```
355
+ RESULT = Task(
356
+ subagent_type="rihal-i18n-auditor",
357
+ model="sonnet",
358
+ prompt="i18n audit — do NOT add translations. {CONTEXT}
359
+
360
+ Run Lens 8 (i18n) audit. Check:
361
+ - Workflows that spawn subagents without passing response_language
362
+ - Hardcoded English strings in output/echo/print blocks
363
+ - AskUserQuestion prompts that are English-only (no RTL/Arabic variant)
364
+ - ASCII box-drawing banners that will break with Arabic text
365
+ - config-get calls that skip the response_language key
366
+
367
+ Reference: i18next namespace patterns, formatjs ICU messages, rtlcss flip rules.
368
+
369
+ Return: file:line — description [critical|warn|info]
370
+ If clean: PASS"
371
+ )
372
+
373
+ FINDINGS[i18n] = RESULT
374
+ ```
375
+
376
+ ---
377
+
378
+ ### Lens 9 — Documentation
379
+
380
+ ```
381
+ RESULT = Task(
382
+ subagent_type="rihal-docs-auditor",
383
+ model="sonnet",
384
+ prompt="Documentation audit — do NOT write docs. {CONTEXT}
385
+
386
+ Run Lens 9 (Documentation) audit. Check:
387
+ - Workflows missing a '## Next Up' or 'Next Up' footer
388
+ - Dead @.rihal/ references (file path does not exist in rihal/)
389
+ - README.md referencing /rihal-<command> that has no command file
390
+ - Skills (SKILL.md) missing required sections: Overview, Workflow, Output Format, Examples
391
+ - CHANGELOG.md more than 5 commits behind HEAD
392
+
393
+ Reference: Divio documentation system (tutorial/how-to/reference/explanation).
394
+
395
+ Return: file:line — description [critical|warn|info]
396
+ If clean: PASS"
397
+ )
398
+
399
+ FINDINGS[documentation] = RESULT
400
+ ```
401
+
402
+ ---
403
+
404
+ ### Lens 10 — Cross-platform
405
+
406
+ ```
407
+ RESULT = Task(
408
+ subagent_type="rihal-code-reviewer",
409
+ model="sonnet",
410
+ prompt="Cross-platform audit — do NOT fix scripts. {CONTEXT}
411
+
412
+ Run Lens 10 (Cross-platform) audit. Check:
413
+ - BSD sed -i '' vs GNU sed -i divergence
414
+ - macOS-only tools: greadlink, gsed, gfind, gawk, gdate
415
+ - Bash-isms in #!/bin/sh scripts: [[ ]], arrays, mapfile, process substitution
416
+ - Hardcoded absolute Unix paths (/home/, /usr/, /etc/) in Node.js source
417
+ - CRLF line endings in .md/.yaml/.sh files
418
+ - npm scripts using Unix-only && chains (use cross-env / shx instead)
419
+
420
+ Reference: ShellCheck POSIX rules, cross-env ★6.2k, shx ★1.6k.
421
+
422
+ Return: file:line — description [critical|warn|info]
423
+ If clean: PASS"
424
+ )
425
+
426
+ FINDINGS[cross-platform] = RESULT
427
+ ```
428
+
429
+ ---
430
+
431
+ ### Lens 11 — Karpathy
432
+
433
+ ```
434
+ PRIMARY = Task(
435
+ subagent_type="rihal-code-reviewer",
436
+ model="sonnet",
437
+ prompt="Karpathy 4-principle audit — do NOT fix code. {CONTEXT}
438
+
439
+ Run Lens 11 (Karpathy) audit against recent changes (HEAD~20..HEAD):
440
+
441
+ Principle 1 (Think Before Coding): unclear assumptions, magic numbers without comment
442
+ Principle 2 (Simplicity First): dead code, unused imports, speculative abstractions
443
+ Principle 3 (Surgical Changes): whitespace-only diffs, reformatting unrelated code
444
+ Principle 4 (Goal-Driven Execution): TODOs, stubs, not-implemented errors, mock data
445
+
446
+ Return: file:line — principle N violation — description [critical|warn|info]
447
+ If clean: PASS"
448
+ )
449
+
450
+ SECONDARY = Task(
451
+ subagent_type="rihal-hanzla",
452
+ model="sonnet",
453
+ prompt="Implementation quality audit — do NOT refactor. {CONTEXT}
454
+
455
+ Review recent code (HEAD~10..HEAD) for:
456
+ - Overengineered abstractions that add complexity without clear benefit
457
+ - Code that could be 3 lines but is 30
458
+ - Unclear variable/function names
459
+ - Missing error messages that would help debug production failures
460
+
461
+ Return: file:line — description [warn|info]
462
+ If clean: PASS"
463
+ )
464
+
465
+ FINDINGS[karpathy] = merge(PRIMARY, SECONDARY)
466
+ ```
467
+
468
+ ---
469
+
470
+ ### Lens 12 — SXO/UX
471
+
472
+ ```
473
+ RESULT = Task(
474
+ subagent_type="rihal-layla",
475
+ model="sonnet",
476
+ prompt="UX flow audit — do NOT redesign flows. {CONTEXT}
477
+
478
+ Run Lens 12 (SXO/UX) audit on rihal workflows. Check:
479
+ - Dead-end workflows (no Next Up footer, no forward dispatch)
480
+ - AskUserQuestion prompts with no cancel/exit option (option 0)
481
+ - Error-exit paths that print an error but suggest no recovery command
482
+ - Dispatch table rows that reference non-existent commands
483
+ - Menus with >8 options (cognitive overload — flag for splitting)
484
+
485
+ Reference: Nielsen 10 usability heuristics, WCAG 2.1 AA error messages.
486
+
487
+ Return: file:line — description [critical|warn|info]
488
+ If clean: PASS"
489
+ )
490
+
491
+ FINDINGS[sxo] = RESULT
492
+ ```
493
+
494
+ ---
495
+
496
+ ### Lens 13 — Observability
497
+
498
+ ```
499
+ RESULT = Task(
500
+ subagent_type="rihal-code-reviewer",
501
+ model="sonnet",
502
+ prompt="Observability audit — do NOT add instrumentation. {CONTEXT}
503
+
504
+ Run Lens 13 (Observability) audit. Check:
505
+ - rihal-tools calls without 2>/dev/null or error guard
506
+ - Task() calls where result is never captured or checked
507
+ - Bare 2>/dev/null at end of line with no || fallback echo
508
+ - INIT= assignments with no .ok check within next 15 lines
509
+ - console.log/error/warn in production Node.js code (not test files)
510
+ - Shell scripts missing set -euo pipefail
511
+
512
+ Reference: OpenTelemetry structured logging, Pino ★13k, Winston ★22k.
513
+
514
+ Return: file:line — description [critical|warn|info]
515
+ If clean: PASS"
516
+ )
517
+
518
+ FINDINGS[observability] = RESULT
519
+ ```
520
+
521
+ ---
522
+
523
+ ### Lens 14 — Naming Consistency
524
+
525
+ ```
526
+ PRIMARY = Task(
527
+ subagent_type="rihal-codebase-mapper",
528
+ model="sonnet",
529
+ prompt="Naming consistency audit — do NOT rename anything. {CONTEXT}
530
+
531
+ Run Lens 14 (Naming) audit. Produce a CONVENTIONS scan:
532
+ - PLAN.md references that should be SPRINT.md (stale naming)
533
+ - rihal: namespace (colon) that should be rihal- (hyphen)
534
+ - Agent directory names that do not match their SKILL.md name: field
535
+ - PHASE_NUM variable used where PHASE_NUMBER is the standard
536
+ - CamelCase vs snake_case drift in config keys
537
+
538
+ Return: file:line — drift description [warn|info]
539
+ If clean: PASS"
540
+ )
541
+
542
+ SECONDARY = Task(
543
+ subagent_type="rihal-code-reviewer",
544
+ model="sonnet",
545
+ prompt="Variable naming audit in recent code changes. {CONTEXT}
546
+
547
+ Review HEAD~10..HEAD for:
548
+ - Inconsistent naming style within the same file (camelCase vs snake_case mixed)
549
+ - Unclear abbreviations (tgt, tmp, obj, val without context)
550
+ - Boolean variables not prefixed with is/has/should/can
551
+
552
+ Return: file:line — description [warn|info]
553
+ If clean: PASS"
554
+ )
555
+
556
+ FINDINGS[naming] = merge(PRIMARY, SECONDARY)
557
+ ```
558
+
559
+ ---
560
+
561
+ ### Lens 15 — Coverage
562
+
563
+ ```
564
+ PRIMARY = Task(
565
+ subagent_type="rihal-nyquist-auditor",
566
+ model="sonnet",
567
+ prompt="Coverage audit — do NOT generate tests. {CONTEXT}
568
+
569
+ Run Lens 15 (Coverage) audit. Fill Nyquist gaps:
570
+ - Commands in rihal/commands/ with no parity test entry
571
+ - Subagent types referenced in workflows but no SKILL.md directory
572
+ - Workflows referenced in commands that do not exist in rihal/workflows/
573
+ - Skills in team.yaml with no corresponding skills/agents/ directory
574
+ - Acceptance criteria rows with no verifiable check (vague 'should work')
575
+
576
+ Return: file:line — gap description [critical|warn|info]
577
+ If clean: PASS"
578
+ )
579
+
580
+ SECONDARY = Task(
581
+ subagent_type="rihal-fatima",
582
+ model="sonnet",
583
+ prompt="Release gate — coverage quality check. {CONTEXT}
584
+
585
+ Review test strategy gaps:
586
+ - Critical workflows with no behavioral regression test
587
+ - Integration points between workflows that have no end-to-end test
588
+ - Config keys that are read but never validated
589
+
590
+ Return: gap description [critical|warn]
591
+ If clean: PASS"
592
+ )
593
+
594
+ FINDINGS[coverage] = merge(PRIMARY, SECONDARY)
595
+ ```
596
+
597
+ ---
598
+
599
+ ## Step 5 — Compile findings per lens
600
+
601
+ For each lens that was run, print:
602
+
603
+ ```
604
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
605
+ Lens {N}: {NAME} (primary: {skill})
606
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
607
+ Findings: {count}
608
+
609
+ {file:line — description [severity]}
610
+ ...
611
+
612
+ Status: PASS (0) | WARN ({n}) | FAIL ({n critical})
613
+ ```
614
+
615
+ If `FINDINGS[lens]` is `PASS` or empty: print `✓ Lens {N} ({name}): PASS`.
616
+
617
+ ## Step 6 — Output GitHub issue bodies
618
+
619
+ For each lens with findings ≥ 1, print a ready-to-file issue template:
620
+
621
+ ```markdown
622
+ ---
623
+ ### Issue: [lens-audit] Lens {N} ({name}) — {count} findings
624
+
625
+ **Labels:** `lens-audit`, `{lens-name}`
626
+ **Skill used:** `{primary-skill}`
627
+
628
+ **Body:**
629
+ ## Findings — Lens {N}: {name}
630
+
631
+ | File | Line | Description | Severity |
632
+ |------|------|-------------|----------|
633
+ {rows}
634
+
635
+ ## Reproduce
636
+ Run: `/rihal-audit lens {N}` on commit `{git rev-parse --short HEAD}`
637
+
638
+ ## Suggested fix
639
+ {one-line fix suggestion per critical finding}
640
+ ```
641
+
642
+ Print to stdout only — do NOT create issues automatically.
643
+
644
+ ## Step 7 — Summary banner
645
+
646
+ ```
647
+ ╔══════════════════════════════════════════════════════╗
648
+ ║ LENS AUDIT COMPLETE ║
649
+ ╠══════════════════════════════════════════════════════╣
650
+ ║ Lenses run: {count} ║
651
+ ║ Total findings: {total} ║
652
+ ║ Critical: {critical} ║
653
+ ║ Warnings: {warnings} ║
654
+ ╚══════════════════════════════════════════════════════╝
655
+
656
+ {N}. {lens-name} — {count} findings (primary: {skill})
657
+ ...
658
+
659
+ Next: file the GH issues above, then run /rihal-audit fix to address them.
660
+ ```
661
+
662
+ ## Success Criteria
663
+
664
+ - [ ] Skill mapping table is shown at top of output
665
+ - [ ] Each lens dispatches to its primary skill via Task(subagent_type=...)
666
+ - [ ] Secondary skills run in parallel where applicable (L1, L3, L11, L14, L15)
667
+ - [ ] Partial-fail: one skill error does not abort remaining lenses
668
+ - [ ] PASS case handled cleanly (no spurious findings printed)
669
+ - [ ] GH issue bodies printed to stdout only
670
+ - [ ] Summary banner shows per-lens skill attribution
671
+ - [ ] response_language passed through to all subagent prompts
672
+
673
+ ## On Error
674
+
675
+ - **rihal-tools not found**: print `Run: npx @hanzlaa/rcode install .` and STOP.
676
+ - **Lens N out of range (not 1–15)**: print valid range and STOP.
677
+ - **Subagent skill not installed**: note `(skill not available — skipping)`, continue.
678
+ - **Scope dirs empty**: note `(no source files in scope)` per lens, still run dispatch.
679
+ - **Karpathy dispatch fails** (Lens 11): note failure, continue with remaining lenses.
680
+
681
+ ## Next Up
682
+
683
+ ```
684
+ File findings as GH issues: gh issue create --title "[lens-audit] Lens N..." --body "..."
685
+ Auto-fix what's fixable: /rihal-audit fix
686
+ Re-run a single lens: /rihal-audit lens <N>
687
+ Full re-audit after fixes: /rihal-audit lens all
688
+ View audit settings: /rihal-settings show
689
+ ```