@hanzlaa/rcode 2.1.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 (76) hide show
  1. package/CONTRIBUTING.md +138 -0
  2. package/README.md +83 -19
  3. package/cli/install.js +687 -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 +153 -36
  24. package/rihal/brain/sources.yaml +7 -4
  25. package/rihal/commands/audit.md +8 -0
  26. package/rihal/commands/checkpoint-preview.md +13 -0
  27. package/rihal/commands/config.md +4 -4
  28. package/rihal/commands/prfaq.md +15 -0
  29. package/rihal/commands/settings.md +2 -2
  30. package/rihal/references/agent-contracts.md +12 -0
  31. package/rihal/references/karpathy-guidelines-full.md +79 -0
  32. package/rihal/references/karpathy-guidelines.md +8 -76
  33. package/rihal/references/model-profile-resolution.md +8 -0
  34. package/rihal/references/phase-argument-parsing.md +11 -0
  35. package/rihal/references/revision-loop.md +11 -0
  36. package/rihal/references/universal-anti-patterns.md +15 -0
  37. package/rihal/skills/actions/1-analysis/rihal-prfaq/SKILL.md +10 -0
  38. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/SKILL.md +3 -1
  39. package/rihal/skills/actions/2-plan/rihal-create-milestone/SKILL.md +3 -1
  40. package/rihal/skills/actions/2-plan/rihal-create-milestone/steps/step-10-complete.md +1 -1
  41. package/rihal/skills/actions/2-plan/rihal-create-prd/SKILL.md +13 -0
  42. package/rihal/skills/actions/2-plan/rihal-create-story/SKILL.md +4 -2
  43. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/SKILL.md +10 -0
  44. package/rihal/skills/actions/4-implementation/rihal-sprint-planning/SKILL.md +3 -1
  45. package/rihal/skills/agents/hussain-pm/SKILL.md +8 -0
  46. package/rihal/skills/agents/hussain-sm/SKILL.md +8 -0
  47. package/rihal/templates/UAT.md +29 -0
  48. package/rihal/templates/milestone.md +2 -0
  49. package/rihal/templates/sprint.md +11 -28
  50. package/rihal/templates/summary.md +30 -0
  51. package/rihal/templates/verification-report.md +28 -0
  52. package/rihal/workflows/audit-milestone.md +34 -2
  53. package/rihal/workflows/audit.md +172 -0
  54. package/rihal/workflows/autonomous.md +67 -0
  55. package/rihal/workflows/checkpoint-preview.md +7 -0
  56. package/rihal/workflows/council.md +3 -1
  57. package/rihal/workflows/dashboard.md +2 -2
  58. package/rihal/workflows/debug.md +8 -1
  59. package/rihal/workflows/diagnose-issues.md +34 -0
  60. package/rihal/workflows/do.md +47 -3
  61. package/rihal/workflows/execute-sprint.md +11 -4
  62. package/rihal/workflows/execute.md +9 -3
  63. package/rihal/workflows/install.md +2 -2
  64. package/rihal/workflows/karpathy-audit.md +7 -14
  65. package/rihal/workflows/pause-work.md +7 -1
  66. package/rihal/workflows/prfaq.md +7 -0
  67. package/rihal/workflows/profile-user.md +2 -2
  68. package/rihal/workflows/progress.md +1 -1
  69. package/rihal/workflows/settings.md +116 -118
  70. package/rihal/workflows/sprint-planning.md +39 -8
  71. package/rihal/workflows/status.md +6 -1
  72. package/rihal/workflows/ui-phase.md +3 -3
  73. package/rihal/workflows/update.md +80 -22
  74. package/rihal/workflows/validate-phase.md +7 -1
  75. package/rihal/agents/rihal-ui-designer.md +0 -6
  76. 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
@@ -54,22 +54,27 @@ It's not a chatbot. It's a methodology.
54
54
 
55
55
  ## Install — one command
56
56
 
57
- In any project directory:
57
+ In any project directory (existing codebase OR empty folder):
58
58
 
59
59
  ```bash
60
60
  npx @hanzlaa/rcode install
61
61
  ```
62
62
 
63
- That's it. One unified installer. Pure file shipping, no runtime dependencies. Installs into:
63
+ [Live on npm](https://www.npmjs.com/package/@hanzlaa/rcode) as `@hanzlaa/rcode` · current version `v2.1.0`. See [`docs/install.md`](docs/install.md) for flavors (module subsets, IDE options, version pinning, yolo mode).
64
+
65
+ One unified installer. Pure file shipping, no runtime dependencies. Installs into:
64
66
 
65
67
  - `.rihal/` — config, workflows, references, bin (Rihal infrastructure)
66
- - `.claude/agents/` — 44 first-class subagents
67
- - `.claude/commands/rihal/` — 93 slash commands
68
- - `.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
+ - `rihal/brain/` — Rihal standards pulled from upstream (PR / commit / architecture docs)
69
72
  - `.planning/` — where your artifacts land (council sessions, plans, chains, summaries)
70
73
 
71
74
  Restart Claude Code (or your IDE), type `/`, and every `rihal:*` command appears.
72
75
 
76
+ Update anytime with `npx @hanzlaa/rcode update` (or `/rihal:update` inside a Claude session).
77
+
73
78
  ### Then begin the rihla
74
79
 
75
80
  ```
@@ -231,6 +236,17 @@ The classifier recognizes `dubai`, `affiliate`, `bnanai`, `karobar`, `site banan
231
236
  → panel: [mariam, hussain-pm, sadiq]
232
237
  ```
233
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
+
234
250
  ### Karpathy coding guidelines
235
251
 
236
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:
@@ -240,7 +256,7 @@ The classifier recognizes `dubai`, `affiliate`, `bnanai`, `karobar`, `site banan
240
256
  3. **Surgical changes** — touch only what's needed, match existing style
241
257
  4. **Goal-driven execution** — define verifiable success criteria
242
258
 
243
- 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.
244
260
 
245
261
  ```
246
262
  /rihal:karpathy-audit HEAD~5..HEAD
@@ -293,7 +309,7 @@ Recent additions in this session:
293
309
 
294
310
  ---
295
311
 
296
- ## Full command surface (69 commands)
312
+ ## Full command surface (99 commands)
297
313
 
298
314
  ### Router + lifecycle
299
315
  `init` · `do` · `help` · `status` · `stats` · `health` · `forensics` · `update`
@@ -301,14 +317,17 @@ Recent additions in this session:
301
317
  ### Discovery + research
302
318
  `new-project` · `map-codebase` · `scan` · `explore` · `document-project` · `analyze-dependencies` · `discuss-phase-power`
303
319
 
320
+ ### Discovery + validation
321
+ `prfaq` · `brainstorm` · `market-research` · `domain-research` · `technical-research` · `product-brief`
322
+
304
323
  ### Planning
305
- `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`
306
325
 
307
326
  ### Execution
308
327
  `execute` · `quick` · `autonomous` · `audit-fix` · `undo` · `check-implementation-readiness`
309
328
 
310
329
  ### Observability + review
311
- `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`
312
331
 
313
332
  ### Recovery + correction
314
333
  `pause-work` · `resume-work` · `correct-course` · `next` · `config`
@@ -397,16 +416,61 @@ Full install = all 3 modules = 201 files.
397
416
  ## Testing
398
417
 
399
418
  ```bash
400
- 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
401
421
  ```
402
422
 
403
- 95 tests across 10 test files (8 compliance + 87 unit) verify:
404
- - Every command has a matching workflow file
405
- - Every agent has valid frontmatter + constraints
406
- - Module manifests match installed files
407
- - rihal-tools.cjs help matches implemented subcommands
408
- - Panel scorer routes correctly across 10+ question types
409
- - 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
+ ```
410
474
 
411
475
  ---
412
476