@hanzlaa/rcode 2.2.0 → 2.3.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 (72) hide show
  1. package/CONTRIBUTING.md +138 -0
  2. package/README.md +76 -17
  3. package/cli/install.js +312 -80
  4. package/cli/uninstall.js +8 -0
  5. package/dist/rcode.js +19777 -0
  6. package/package.json +17 -4
  7. package/rihal/DOCS-AUDIT.md +14 -0
  8. package/rihal/agents/rihal-code-reviewer.md +1 -1
  9. package/rihal/agents/rihal-codebase-mapper.md +1 -1
  10. package/rihal/agents/rihal-docs-auditor.md +1 -1
  11. package/rihal/agents/rihal-edge-case-hunter.md +1 -1
  12. package/rihal/agents/rihal-executor.md +1 -1
  13. package/rihal/agents/rihal-hussain-pm.md +1 -0
  14. package/rihal/agents/rihal-nyquist-auditor.md +1 -1
  15. package/rihal/agents/rihal-phase-researcher.md +1 -2
  16. package/rihal/agents/rihal-planner.md +1 -1
  17. package/rihal/agents/rihal-roadmapper.md +1 -0
  18. package/rihal/agents/rihal-security-adversary.md +1 -1
  19. package/rihal/agents/rihal-security-auditor.md +1 -1
  20. package/rihal/agents/rihal-sprint-checker.md +1 -1
  21. package/rihal/agents/rihal-verifier.md +1 -1
  22. package/rihal/bin/lib/roadmap.cjs +2 -3
  23. package/rihal/bin/rihal-tools.cjs +11 -31
  24. package/rihal/commands/audit.md +8 -0
  25. package/rihal/commands/checkpoint-preview.md +13 -0
  26. package/rihal/commands/config.md +4 -4
  27. package/rihal/commands/prfaq.md +15 -0
  28. package/rihal/commands/settings.md +2 -2
  29. package/rihal/references/agent-contracts.md +12 -0
  30. package/rihal/references/karpathy-guidelines-full.md +79 -0
  31. package/rihal/references/karpathy-guidelines.md +8 -76
  32. package/rihal/references/model-profile-resolution.md +8 -0
  33. package/rihal/references/phase-argument-parsing.md +11 -0
  34. package/rihal/references/revision-loop.md +11 -0
  35. package/rihal/references/universal-anti-patterns.md +15 -0
  36. package/rihal/skills/actions/1-analysis/rihal-prfaq/SKILL.md +10 -0
  37. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/SKILL.md +3 -1
  38. package/rihal/skills/actions/2-plan/rihal-create-milestone/SKILL.md +3 -1
  39. package/rihal/skills/actions/2-plan/rihal-create-milestone/steps/step-10-complete.md +1 -1
  40. package/rihal/skills/actions/2-plan/rihal-create-prd/SKILL.md +13 -0
  41. package/rihal/skills/actions/2-plan/rihal-create-story/SKILL.md +4 -2
  42. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/SKILL.md +10 -0
  43. package/rihal/skills/actions/4-implementation/rihal-sprint-planning/SKILL.md +3 -1
  44. package/rihal/skills/agents/hussain-pm/SKILL.md +8 -0
  45. package/rihal/skills/agents/hussain-sm/SKILL.md +8 -0
  46. package/rihal/templates/UAT.md +29 -0
  47. package/rihal/templates/milestone.md +2 -0
  48. package/rihal/templates/sprint.md +11 -28
  49. package/rihal/templates/summary.md +30 -0
  50. package/rihal/templates/verification-report.md +28 -0
  51. package/rihal/workflows/audit-milestone.md +34 -2
  52. package/rihal/workflows/audit.md +172 -0
  53. package/rihal/workflows/autonomous.md +67 -0
  54. package/rihal/workflows/checkpoint-preview.md +7 -0
  55. package/rihal/workflows/council.md +3 -1
  56. package/rihal/workflows/debug.md +8 -1
  57. package/rihal/workflows/diagnose-issues.md +34 -0
  58. package/rihal/workflows/do.md +47 -3
  59. package/rihal/workflows/execute-sprint.md +11 -4
  60. package/rihal/workflows/execute.md +9 -3
  61. package/rihal/workflows/karpathy-audit.md +7 -14
  62. package/rihal/workflows/pause-work.md +7 -1
  63. package/rihal/workflows/prfaq.md +7 -0
  64. package/rihal/workflows/profile-user.md +2 -2
  65. package/rihal/workflows/settings.md +116 -118
  66. package/rihal/workflows/sprint-planning.md +39 -8
  67. package/rihal/workflows/status.md +5 -0
  68. package/rihal/workflows/ui-phase.md +3 -3
  69. package/rihal/workflows/update.md +80 -22
  70. package/rihal/workflows/validate-phase.md +7 -1
  71. package/rihal/agents/rihal-ui-designer.md +0 -6
  72. package/rihal/workflows/config.md +0 -105
package/CONTRIBUTING.md CHANGED
@@ -4,6 +4,144 @@ Thank you for contributing. These guidelines exist to keep the module maintainab
4
4
 
5
5
  ---
6
6
 
7
+ ## Architecture overview — what are all these files?
8
+
9
+ Before you touch anything, you need a mental model of how the four building blocks fit together. Every feature in Rihal Code is assembled from the same four pieces.
10
+
11
+ ### The four building blocks
12
+
13
+ | Layer | Where | What it is |
14
+ |-------|-------|-----------|
15
+ | **Command** | `rihal/commands/*.md` | The slash command entry point — what you type in Claude Code |
16
+ | **Workflow** | `rihal/workflows/*.md` | Step-by-step orchestration instructions for multi-step tasks |
17
+ | **Skill** | `rihal/skills/actions/*/SKILL.md` | Deep, domain-specific instructions for complex multi-stage tasks |
18
+ | **Agent** | `rihal/agents/*.md` + `rihal/skills/agents/*/SKILL.md` | A specialized persona spawned by a workflow or skill to do focused work |
19
+
20
+ ### Commands — the entry point
21
+
22
+ A command file is tiny. It registers a slash command in Claude Code's UI and points at the logic that handles it:
23
+
24
+ ```markdown
25
+ ---
26
+ name: rihal:prfaq
27
+ description: Working Backwards PRFAQ challenge
28
+ allowed-tools: [Read, Write, Agent, AskUserQuestion, WebSearch]
29
+ ---
30
+
31
+ @.rihal/skills/rihal-prfaq/SKILL.md
32
+ ```
33
+
34
+ That `@-include` line tells Claude to load the target file's contents as context. Without a command file, a skill is unreachable via `/` — it can only be triggered by describing the task in natural language.
35
+
36
+ **Rule:** Every capability intended to be user-typed as `/rihal:something` needs a matching `rihal/commands/something.md`.
37
+
38
+ ### Workflows — orchestration logic
39
+
40
+ Workflows are prose instructions — markdown files Claude reads as a script to follow. They handle control flow: read state, ask a question, dispatch to a sub-workflow, report results. Most slash commands point to a workflow:
41
+
42
+ ```
43
+ /rihal:audit → commands/audit.md → @workflows/audit.md
44
+ ```
45
+
46
+ Workflows are the right tool when the task is a sequence of steps that Claude drives (check state → ask user → run something → report). They should not contain deep domain knowledge — that belongs in skills.
47
+
48
+ ### Skills — deep domain knowledge
49
+
50
+ Skills go deeper than workflows. A skill like `rihal-prfaq` has its own folder with multi-stage reference files, sub-agent definitions, and templates:
51
+
52
+ ```
53
+ rihal/skills/actions/1-analysis/rihal-prfaq/
54
+ ├── SKILL.md ← main entry, loaded by the command
55
+ ├── references/
56
+ │ ├── press-release.md ← Stage 2 instructions
57
+ │ ├── customer-faq.md ← Stage 3
58
+ │ ├── internal-faq.md ← Stage 4
59
+ │ └── verdict.md ← Stage 5
60
+ ├── agents/
61
+ │ ├── artifact-analyzer.md ← sub-agent spawned inline
62
+ │ └── web-researcher.md
63
+ └── assets/
64
+ └── prfaq-template.md
65
+ ```
66
+
67
+ Skills are the right tool when the task has multiple stages, needs sub-agent parallelism, or carries domain-specific coaching logic (e.g., how to run a PRFAQ gauntlet, how to do a Karpathy code review).
68
+
69
+ Skills have **two activation paths**:
70
+ 1. **Via command** — `/rihal:prfaq` loads the SKILL.md directly
71
+ 2. **Phrase-activated** — when a user describes the task, Claude picks up the skill from its `description` field in the YAML frontmatter
72
+
73
+ ### Agents — focused specialists
74
+
75
+ Agents are spawned by workflows and skills to do a specific job. They have a persona, a set of tools, and deferral rules (Hanzla defers to Waleed on architecture; Waleed defers to Sadiq on whether to build).
76
+
77
+ There are two kinds:
78
+
79
+ **Sub-agents** live inside skill folders (`rihal/skills/agents/*/SKILL.md`). They're invoked by their parent skill, not by the user directly. Example: the PRFAQ skill spawns `artifact-analyzer` and `web-researcher` in parallel during Stage 1.
80
+
81
+ **Council agents** live in `rihal/agents/*.md`. They're the named characters (Waleed, Hanzla, Fatima, Sadiq…) that `/rihal:council` assembles into a panel. These are installed to `.claude/agents/` and can be spawned from any workflow.
82
+
83
+ ### How they chain for a real request
84
+
85
+ ```
86
+ User types: /rihal:council "Should we use Redis?"
87
+
88
+ commands/council.md ← slash command entry
89
+ │ @-includes
90
+ workflows/council.md ← orchestration: pick agents, frame question
91
+ │ spawns (parallel)
92
+ ┌──────────┴───────────────┐
93
+ ▼ ▼
94
+ agents/rihal-waleed.md agents/rihal-sadiq.md
95
+ (architecture answer) (strategic kill criteria)
96
+ └──────────┬───────────────┘
97
+
98
+ synthesize → output to user
99
+ ```
100
+
101
+ A more complex chain involving a skill:
102
+
103
+ ```
104
+ User types: /rihal:prfaq
105
+
106
+ commands/prfaq.md
107
+ │ @-includes
108
+ skills/rihal-prfaq/SKILL.md ← Stage 1: ignition + context gathering
109
+ │ spawns (parallel)
110
+ ┌──────────┴────────────────────┐
111
+ ▼ ▼
112
+ skills/.../artifact-analyzer.md skills/.../web-researcher.md
113
+ └──────────┬────────────────────┘
114
+
115
+ references/press-release.md ← Stage 2: loaded by SKILL.md
116
+ references/customer-faq.md ← Stage 3
117
+ references/verdict.md ← Stage 5: output + PRD distillate
118
+ ```
119
+
120
+ ### Which layer do I edit?
121
+
122
+ | I want to… | Edit this |
123
+ |-----------|-----------|
124
+ | Add a new `/rihal:something` slash command | Create `rihal/commands/something.md` pointing to a workflow or skill |
125
+ | Change the steps in an existing command | Edit the workflow it points to |
126
+ | Improve how a persona thinks (Hanzla, Waleed, etc.) | Edit `rihal/skills/agents/<name>/SKILL.md` or `rihal/agents/<name>.md` |
127
+ | Add a new agent to `/rihal:council` | Edit `rihal/agents/team.yaml` + add agent file |
128
+ | Improve a complex multi-stage task (PRFAQ, code review, etc.) | Edit the skill's stage reference files |
129
+ | Add a new skill triggered by natural language | Create `rihal/skills/actions/<category>/<name>/SKILL.md` — no command file needed if slash is not required |
130
+ | Fix a broken `@-include` reference | Check that the target file exists at `.rihal/<path>` after install |
131
+
132
+ ### The install chain
133
+
134
+ The source tree in `rihal/` is **not what Claude reads at runtime**. On install, `cli/install.js` copies everything into `.rihal/` and `.claude/`. When a command `@-includes` `.rihal/workflows/audit.md`, it's reading the installed copy. If you edit the source but don't reinstall, Claude still sees the old version.
135
+
136
+ ```bash
137
+ # After editing source files:
138
+ node cli/install.js . --force-overwrite --yes
139
+ ```
140
+
141
+ This is why the compliance check runs against the source tree but the reload window step (after install) is what actually activates your changes.
142
+
143
+ ---
144
+
7
145
  ## Who owns what — contribute to YOUR slice
8
146
 
9
147
  Rihal Code v2 is organized around **role ownership** (issue #160). Find your role, touch only that slice, open a focused PR. CODEOWNERS in `.github/CODEOWNERS` routes reviews automatically.
package/README.md CHANGED
@@ -37,8 +37,8 @@ Rihal Code packages a lot. To keep things approachable, everything is organized
37
37
 
38
38
  Most AI tools give you one assistant pretending to be everything. **Rihal Code gives you Rihal's team — and Rihal's brain — inside every project.**
39
39
 
40
- - **44 agents** with clear roles, cultural identity (Arabic names), and hard scope boundaries
41
- - **93 slash commands** covering research, planning, execution, verification, and recovery
40
+ - **45 agents** with clear roles, cultural identity (Arabic names), and hard scope boundaries
41
+ - **99 slash commands** covering research, planning, execution, verification, and recovery
42
42
  - **3 execution modes**: parallel debate (`/rihal:council`), sequential pipelines (`/rihal:chain`), and quick-sync (`/rihal:discuss`)
43
43
  - **File-based state** in `.rihal/` that every workflow reads and updates
44
44
  - **Intent guards** on every workflow — catch wrong commands early with copy-paste redirects
@@ -65,9 +65,9 @@ npx @hanzlaa/rcode install
65
65
  One unified installer. Pure file shipping, no runtime dependencies. Installs into:
66
66
 
67
67
  - `.rihal/` — config, workflows, references, bin (Rihal infrastructure)
68
- - `.claude/agents/` — 44 first-class subagents
69
- - `.claude/commands/rihal/` — 93 slash commands
70
- - `.claude/skills/` — 58 phrase-activated skills (scaffold-project, create-prd, retrospective, etc.)
68
+ - `.claude/agents/` — 45 first-class subagents
69
+ - `.claude/commands/rihal/` — 99 slash commands
70
+ - `.claude/skills/` — 57 phrase-activated skills (scaffold-project, create-prd, prfaq, retrospective, etc.)
71
71
  - `rihal/brain/` — Rihal standards pulled from upstream (PR / commit / architecture docs)
72
72
  - `.planning/` — where your artifacts land (council sessions, plans, chains, summaries)
73
73
 
@@ -236,6 +236,17 @@ The classifier recognizes `dubai`, `affiliate`, `bnanai`, `karobar`, `site banan
236
236
  → panel: [mariam, hussain-pm, sadiq]
237
237
  ```
238
238
 
239
+ ### PRFAQ — validate before you build
240
+
241
+ Amazon's "Working Backwards" method: write the finished-product press release *before* writing a line of code. If you can't write a compelling press release, the product isn't ready. `/rihal:prfaq` runs a 5-stage coaching gauntlet — Ignition → Press Release → Customer FAQ → Internal FAQ → Verdict — and outputs a battle-hardened concept document plus a PRD distillate ready for `/rihal:create-prd`.
242
+
243
+ **When to use it:** Any time a PM or engineer wants to validate whether an idea is worth building before committing sprint capacity. The skill challenges vague thinking, enforces customer-first framing, and gives a build/refine/kill verdict.
244
+
245
+ ```
246
+ /rihal:prfaq → interactive gauntlet
247
+ /rihal:prfaq --headless --customer "..." --problem "..." --solution "..." → autonomous first draft
248
+ ```
249
+
239
250
  ### Karpathy coding guidelines
240
251
 
241
252
  4 behavioral principles from [Andrej Karpathy's observations on LLM coding pitfalls](https://github.com/forrestchang/andrej-karpathy-skills), wired into every code-writing agent as hard constraints:
@@ -245,7 +256,7 @@ The classifier recognizes `dubai`, `affiliate`, `bnanai`, `karobar`, `site banan
245
256
  3. **Surgical changes** — touch only what's needed, match existing style
246
257
  4. **Goal-driven execution** — define verifiable success criteria
247
258
 
248
- Audit recent changes:
259
+ `/rihal:karpathy-audit` runs these 4 principles as a post-hoc audit against any diff or phase. Use it after implementation to catch bloated, over-engineered, or scope-creeping changes before they land in a PR.
249
260
 
250
261
  ```
251
262
  /rihal:karpathy-audit HEAD~5..HEAD
@@ -298,7 +309,7 @@ Recent additions in this session:
298
309
 
299
310
  ---
300
311
 
301
- ## Full command surface (69 commands)
312
+ ## Full command surface (99 commands)
302
313
 
303
314
  ### Router + lifecycle
304
315
  `init` · `do` · `help` · `status` · `stats` · `health` · `forensics` · `update`
@@ -306,14 +317,17 @@ Recent additions in this session:
306
317
  ### Discovery + research
307
318
  `new-project` · `map-codebase` · `scan` · `explore` · `document-project` · `analyze-dependencies` · `discuss-phase-power`
308
319
 
320
+ ### Discovery + validation
321
+ `prfaq` · `brainstorm` · `market-research` · `domain-research` · `technical-research` · `product-brief`
322
+
309
323
  ### Planning
310
- `plan` · `chain` · `create-epics-and-stories` · `create-story` · `dev-story` · `sprint-planning` · `brainstorm`
324
+ `plan` · `chain` · `create-epics-and-stories` · `create-story` · `dev-story` · `sprint-planning`
311
325
 
312
326
  ### Execution
313
327
  `execute` · `quick` · `autonomous` · `audit-fix` · `undo` · `check-implementation-readiness`
314
328
 
315
329
  ### Observability + review
316
- `code-review` · `code-review-fix` · `review-adversarial` · `review-edge-case-hunter` · `karpathy-audit` · `secure-phase` · `show` · `why` · `rerun` · `diff`
330
+ `code-review` · `code-review-fix` · `review-adversarial` · `review-edge-case-hunter` · `karpathy-audit` · `checkpoint-preview` · `secure-phase` · `show` · `why` · `rerun` · `diff`
317
331
 
318
332
  ### Recovery + correction
319
333
  `pause-work` · `resume-work` · `correct-course` · `next` · `config`
@@ -402,16 +416,61 @@ Full install = all 3 modules = 201 files.
402
416
  ## Testing
403
417
 
404
418
  ```bash
405
- node --test test/*.cjs test/lib/*.cjs
419
+ node --test # full suite (95 tests, ~1s)
420
+ node --test --test-reporter=spec # verbose output with test names
406
421
  ```
407
422
 
408
- 95 tests across 10 test files (8 compliance + 87 unit) verify:
409
- - Every command has a matching workflow file
410
- - Every agent has valid frontmatter + constraints
411
- - Module manifests match installed files
412
- - rihal-tools.cjs help matches implemented subcommands
413
- - Panel scorer routes correctly across 10+ question types
414
- - Classifier handles Roman Urdu + Arabic + edge cases
423
+ **95 tests · 0 failures · pure Node stdlib (no test runner install needed)**
424
+
425
+ ### Test scenarios
426
+
427
+ | Suite | Tests | What it verifies |
428
+ |-------|-------|-----------------|
429
+ | `compliance.test.cjs` | 8 | Architecture invariants every command routes through a workflow, every agent has valid frontmatter, all module manifests resolve, `rihal-tools.cjs` subcommands match help text |
430
+ | `classifier.test.cjs` | 10 | Question classifier handles Roman Urdu, Arabic (unicode), English, ambiguous, and multilingual inputs; routes to correct intent (greenfield / market / codebase) |
431
+ | `panel-scorer.test.cjs` | 12 | Council panel scorer selects correct agents for market, greenfield, and codebase questions; `--agents` override bypasses scoring; `--full` returns all agents |
432
+ | `lib/config.test.cjs` | 15 | Config loader merges hardcoded → user → project layers; validates enum values; `suggestClosest` catches typos |
433
+ | `lib/fsutil.test.cjs` | 8 | `writeFileAtomic` creates parents, overwrites cleanly, leaves no temp files, handles custom chmod modes |
434
+ | `lib/manifest.test.cjs` | 12 | `readPackageManifest` discovers agents/actions; `verifyClaudeInstall` detects drift; `verifyInstall` aggregates multi-editor state |
435
+ | `lib/memory-bank.test.cjs` | 10 | Fingerprint stability, staleness detection on hash change and structure change, `never/stale/fresh` thresholds |
436
+ | `lib/prompts.test.cjs` | 15 | `askText`, `askConfirm`, `askChoice` in piped (CI) mode; re-prompt on bad input; `PromptAbortError` on max attempts; `closeSession` idempotency |
437
+ | `lib/no-absolute-home-paths.test.cjs` | 3 | No slash command template embeds absolute `$HOME` paths (install portability) |
438
+ | `lib/wizard-piped.test.cjs` | 2 | Full install in piped mode against temp dir; every known slash command installs non-empty |
439
+
440
+ ### Post-install health check
441
+
442
+ Every install runs 5 automated smoke tests before exiting:
443
+
444
+ ```
445
+ Health check:
446
+ ✓ rihal-tools.cjs runs — syntax ok
447
+ ✓ .rihal/config.yaml present — 412 bytes
448
+ ✓ .rihal/state.json parses — valid JSON
449
+ ✓ agents installed — 43
450
+ ✓ skills + commands installed — 56 skills + 99 commands
451
+ ```
452
+
453
+ A failed check prints the debug command and returns exit code 1 so CI catches broken installs.
454
+
455
+ ### CI pipeline
456
+
457
+ Three jobs run on every push and pull request to `main`:
458
+
459
+ | Job | What it checks |
460
+ |-----|----------------|
461
+ | `test` | Runs `node --test` on Node 18, 20, 22, and 24 — no `npm install` needed |
462
+ | `no-new-deps` | Blocks any addition to `dependencies{}` (runtime zero-dep invariant); audits `devDependencies` against approved build-tool list |
463
+ | `syntax-check` | `node -c` on every file in `cli/` to catch parse errors before runtime |
464
+
465
+ The release pipeline additionally runs `npm ci && npm run build:cli` to produce `dist/rcode.js` (the self-contained esbuild bundle published to npm), then runs a compliance check and attaches the artefact to the GitHub Release.
466
+
467
+ ### Run a single suite
468
+
469
+ ```bash
470
+ node --test test/compliance.test.cjs # architecture invariants only
471
+ node --test test/lib/config.test.cjs # config layer only
472
+ node --test test/lib/manifest.test.cjs # install verification only
473
+ ```
415
474
 
416
475
  ---
417
476