@hanzlaa/rcode 2.2.0 → 2.3.2

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 (143) hide show
  1. package/CLAUDE.md +15 -0
  2. package/CONTRIBUTING.md +138 -0
  3. package/README.md +74 -15
  4. package/cli/install.js +312 -80
  5. package/cli/postinstall.js +4 -4
  6. package/cli/uninstall.js +8 -0
  7. package/dist/rcode.js +19777 -0
  8. package/package.json +18 -5
  9. package/rihal/DOCS-AUDIT.md +14 -0
  10. package/rihal/agents/rihal-code-reviewer.md +1 -1
  11. package/rihal/agents/rihal-codebase-mapper.md +1 -1
  12. package/rihal/agents/rihal-docs-auditor.md +1 -1
  13. package/rihal/agents/rihal-edge-case-hunter.md +1 -1
  14. package/rihal/agents/rihal-executor.md +2 -1
  15. package/rihal/agents/rihal-hussain-pm.md +1 -0
  16. package/rihal/agents/rihal-nyquist-auditor.md +1 -1
  17. package/rihal/agents/rihal-phase-researcher.md +2 -2
  18. package/rihal/agents/rihal-planner.md +3 -2
  19. package/rihal/agents/rihal-roadmapper.md +1 -0
  20. package/rihal/agents/rihal-security-adversary.md +1 -1
  21. package/rihal/agents/rihal-security-auditor.md +1 -1
  22. package/rihal/agents/rihal-sprint-checker.md +1 -1
  23. package/rihal/agents/rihal-verifier.md +1 -1
  24. package/rihal/bin/lib/roadmap.cjs +2 -3
  25. package/rihal/bin/rihal-tools.cjs +11 -31
  26. package/rihal/brain/best-practices/no-theoretical-suggestions.md +56 -0
  27. package/rihal/commands/add-phase.md +2 -2
  28. package/rihal/commands/audit.md +8 -0
  29. package/rihal/commands/checkpoint-preview.md +13 -0
  30. package/rihal/commands/cleanup.md +2 -2
  31. package/rihal/commands/config.md +4 -4
  32. package/rihal/commands/pr-branch.md +2 -2
  33. package/rihal/commands/prfaq.md +15 -0
  34. package/rihal/commands/remove-phase.md +2 -2
  35. package/rihal/commands/research-phase.md +2 -2
  36. package/rihal/commands/settings.md +2 -2
  37. package/rihal/commands/ship.md +15 -3
  38. package/rihal/commands/validate-phase.md +1 -1
  39. package/rihal/commands/verify-phase.md +2 -2
  40. package/rihal/references/agent-contracts.md +12 -0
  41. package/rihal/references/karpathy-guidelines-full.md +79 -0
  42. package/rihal/references/karpathy-guidelines.md +8 -76
  43. package/rihal/references/model-profile-resolution.md +8 -0
  44. package/rihal/references/phase-argument-parsing.md +11 -0
  45. package/rihal/references/revision-loop.md +11 -0
  46. package/rihal/references/universal-anti-patterns.md +15 -0
  47. package/rihal/skills/actions/1-analysis/research/rihal-domain-research/SKILL.md +11 -0
  48. package/rihal/skills/actions/1-analysis/research/rihal-market-research/SKILL.md +11 -0
  49. package/rihal/skills/actions/1-analysis/research/rihal-technical-research/SKILL.md +13 -0
  50. package/rihal/skills/actions/1-analysis/rihal-document-project/SKILL.md +11 -0
  51. package/rihal/skills/actions/1-analysis/rihal-prfaq/SKILL.md +12 -0
  52. package/rihal/skills/actions/1-analysis/rihal-product-brief/SKILL.md +7 -0
  53. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/SKILL.md +15 -1
  54. package/rihal/skills/actions/2-plan/rihal-create-milestone/SKILL.md +21 -1
  55. package/rihal/skills/actions/2-plan/rihal-create-milestone/steps/step-10-complete.md +1 -1
  56. package/rihal/skills/actions/2-plan/rihal-create-prd/SKILL.md +26 -0
  57. package/rihal/skills/actions/2-plan/rihal-create-story/SKILL.md +16 -2
  58. package/rihal/skills/actions/2-plan/rihal-create-ux-design/SKILL.md +12 -0
  59. package/rihal/skills/actions/2-plan/rihal-edit-prd/SKILL.md +11 -0
  60. package/rihal/skills/actions/2-plan/rihal-frontend-design/SKILL.md +13 -0
  61. package/rihal/skills/actions/2-plan/rihal-validate-prd/SKILL.md +12 -0
  62. package/rihal/skills/actions/3-solutioning/rihal-check-implementation-readiness/SKILL.md +12 -0
  63. package/rihal/skills/actions/3-solutioning/rihal-create-architecture/SKILL.md +14 -0
  64. package/rihal/skills/actions/3-solutioning/rihal-generate-project-context/SKILL.md +12 -0
  65. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/SKILL.md +16 -0
  66. package/rihal/skills/actions/4-implementation/rihal-code-review/SKILL.md +12 -0
  67. package/rihal/skills/actions/4-implementation/rihal-correct-course/SKILL.md +13 -0
  68. package/rihal/skills/actions/4-implementation/rihal-dev-story/SKILL.md +12 -0
  69. package/rihal/skills/actions/4-implementation/rihal-qa-generate-e2e-tests/SKILL.md +12 -0
  70. package/rihal/skills/actions/4-implementation/rihal-retrospective/SKILL.md +11 -0
  71. package/rihal/skills/actions/4-implementation/rihal-scaffold-project/SKILL.md +10 -0
  72. package/rihal/skills/actions/4-implementation/rihal-sprint-planning/SKILL.md +14 -1
  73. package/rihal/skills/actions/4-implementation/rihal-sprint-status/SKILL.md +10 -0
  74. package/rihal/skills/agents/ahmed-hassani-director/SKILL.md +13 -1
  75. package/rihal/skills/agents/fatima-qa/SKILL.md +14 -1
  76. package/rihal/skills/agents/haitham-frontend/SKILL.md +15 -1
  77. package/rihal/skills/agents/hanzla-engineer/SKILL.md +14 -1
  78. package/rihal/skills/agents/hussain-pm/SKILL.md +22 -1
  79. package/rihal/skills/agents/hussain-sm/SKILL.md +22 -1
  80. package/rihal/skills/agents/layla-designer/SKILL.md +15 -1
  81. package/rihal/skills/agents/majlis-council/SKILL.md +14 -1
  82. package/rihal/skills/agents/mariam-marketing/SKILL.md +15 -1
  83. package/rihal/skills/agents/nasser-eng-manager/SKILL.md +14 -1
  84. package/rihal/skills/agents/noor-writer/SKILL.md +14 -1
  85. package/rihal/skills/agents/raees-orchestrator/SKILL.md +13 -1
  86. package/rihal/skills/agents/sadiq-analyst/SKILL.md +15 -1
  87. package/rihal/skills/agents/waleed-architect/SKILL.md +16 -1
  88. package/rihal/skills/agents/yousef-backend/SKILL.md +16 -1
  89. package/rihal/skills/agents/zahra-branding/SKILL.md +15 -1
  90. package/rihal/skills/agents/zayd-ml/SKILL.md +17 -1
  91. package/rihal/skills/core/rihal-advanced-elicitation/SKILL.md +12 -0
  92. package/rihal/skills/core/rihal-brainstorming/SKILL.md +16 -0
  93. package/rihal/skills/core/rihal-clone-website/SKILL.md +21 -0
  94. package/rihal/skills/core/rihal-distillator/SKILL.md +8 -0
  95. package/rihal/skills/core/rihal-editorial-review-prose/SKILL.md +12 -0
  96. package/rihal/skills/core/rihal-editorial-review-structure/SKILL.md +18 -0
  97. package/rihal/skills/core/rihal-help/SKILL.md +12 -0
  98. package/rihal/skills/core/rihal-index-docs/SKILL.md +18 -0
  99. package/rihal/skills/core/rihal-init/SKILL.md +8 -0
  100. package/rihal/skills/core/rihal-party-mode/SKILL.md +14 -0
  101. package/rihal/skills/core/rihal-review-adversarial-general/SKILL.md +12 -0
  102. package/rihal/skills/core/rihal-review-edge-case-hunter/SKILL.md +18 -0
  103. package/rihal/skills/core/rihal-shard-doc/SKILL.md +18 -0
  104. package/rihal/team.yaml +205 -0
  105. package/rihal/templates/UAT.md +29 -0
  106. package/rihal/templates/milestone.md +2 -0
  107. package/rihal/templates/sprint.md +11 -28
  108. package/rihal/templates/summary.md +30 -0
  109. package/rihal/templates/verification-report.md +28 -0
  110. package/rihal/workflows/audit-milestone.md +34 -2
  111. package/rihal/workflows/audit.md +172 -0
  112. package/rihal/workflows/autonomous.md +67 -0
  113. package/rihal/workflows/checkpoint-preview.md +7 -0
  114. package/rihal/workflows/council.md +3 -1
  115. package/rihal/workflows/debug.md +8 -1
  116. package/rihal/workflows/diagnose-issues.md +34 -0
  117. package/rihal/workflows/do.md +47 -3
  118. package/rihal/workflows/document-project.md +1 -1
  119. package/rihal/workflows/execute-sprint.md +11 -4
  120. package/rihal/workflows/execute.md +9 -3
  121. package/rihal/workflows/help.md +1 -1
  122. package/rihal/workflows/karpathy-audit.md +7 -14
  123. package/rihal/workflows/pause-work.md +7 -1
  124. package/rihal/workflows/prfaq.md +7 -0
  125. package/rihal/workflows/profile-user.md +2 -2
  126. package/rihal/workflows/settings.md +116 -117
  127. package/rihal/workflows/ship.md +31 -1
  128. package/rihal/workflows/sprint-planning.md +39 -8
  129. package/rihal/workflows/status.md +5 -0
  130. package/rihal/workflows/ui-phase.md +3 -3
  131. package/rihal/workflows/update.md +80 -22
  132. package/rihal/workflows/validate-phase.md +7 -1
  133. package/server/dashboard.js +34 -575
  134. package/server/lib/api.js +123 -0
  135. package/server/lib/html/client.js +969 -0
  136. package/server/lib/html/css.js +416 -0
  137. package/server/lib/html/shell.js +230 -0
  138. package/server/lib/scanner.js +142 -0
  139. package/rihal/agents/rihal-ui-designer.md +0 -6
  140. package/rihal/skills/core/rihal-advanced-elicitation/rihal-advanced-elicitation/SKILL.md +0 -148
  141. package/rihal/skills/core/rihal-advanced-elicitation/rihal-advanced-elicitation/methods.csv +0 -51
  142. package/rihal/skills/core/rihal-shard-doc/rihal-shard-doc/SKILL.md +0 -122
  143. package/rihal/workflows/config.md +0 -105
@@ -0,0 +1,123 @@
1
+ /**
2
+ * API route handlers — all /api/* endpoints.
3
+ */
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const { scanState } = require('./scanner');
7
+
8
+ function handleApiState(req, res, rihalDir) {
9
+ const state = scanState(rihalDir);
10
+ res.writeHead(200, { 'Content-Type': 'application/json' });
11
+ res.end(JSON.stringify(state, null, 2));
12
+ }
13
+
14
+ function handleApiFiles(req, res, projectRoot) {
15
+ const PLANNING_DIR = path.join(projectRoot, '.planning');
16
+ const ARTIFACT_DIRS = ['phases', 'brainstorms', 'council-sessions', 'summaries', 'memory'];
17
+ const ROOT_FILES = ['ROADMAP.md', 'STATE.md', 'PROJECT.md'];
18
+
19
+ const groups = [];
20
+
21
+ const rootFiles = ROOT_FILES
22
+ .filter(f => { try { fs.accessSync(path.join(PLANNING_DIR, f)); return true; } catch { return false; } })
23
+ .map(f => ({ label: f.replace('.md', ''), path: '.planning/' + f }));
24
+ if (rootFiles.length) groups.push({ group: 'Overview', files: rootFiles });
25
+
26
+ for (const dir of ARTIFACT_DIRS) {
27
+ const full = path.join(PLANNING_DIR, dir);
28
+ const files = [];
29
+ function walkArtifacts(d, prefix, depth) {
30
+ if (depth > 3) return;
31
+ let entries;
32
+ try { entries = fs.readdirSync(d, { withFileTypes: true }); } catch { return; }
33
+ for (const e of entries) {
34
+ if (e.name.startsWith('.')) continue;
35
+ const rel = prefix + '/' + e.name;
36
+ if (e.isDirectory()) walkArtifacts(path.join(d, e.name), rel, depth + 1);
37
+ else if (e.isFile() && e.name.endsWith('.md')) {
38
+ const parentDir = prefix.split('/').filter(Boolean).pop() || '';
39
+ const parentLabel = parentDir
40
+ ? parentDir.replace(/^\d+-/, '').replace(/-/g, ' ') + ' › '
41
+ : '';
42
+ const base = e.name.replace('.md', '');
43
+ const sprintMatch = base.match(/^\d{2}-(\d{2})-([A-Z]+)$/);
44
+ const phaseMatch = base.match(/^(\d{2})-([A-Z]+)$/);
45
+ const dateMatch = base.match(/^\d{4}-\d{2}-\d{2}-(.+)$/);
46
+ let fileLabel;
47
+ if (sprintMatch) {
48
+ fileLabel = sprintMatch[2].charAt(0) + sprintMatch[2].slice(1).toLowerCase() + ' ' + parseInt(sprintMatch[1], 10);
49
+ } else if (phaseMatch) {
50
+ fileLabel = phaseMatch[2].charAt(0) + phaseMatch[2].slice(1).toLowerCase() + ' ' + parseInt(phaseMatch[1], 10);
51
+ } else if (dateMatch) {
52
+ fileLabel = dateMatch[1].replace(/-/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
53
+ } else if (base === base.toUpperCase() && /^[A-Z_-]+$/.test(base)) {
54
+ fileLabel = base.charAt(0) + base.slice(1).toLowerCase();
55
+ } else {
56
+ fileLabel = base.replace(/-/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
57
+ }
58
+ files.push({ label: parentLabel + fileLabel, path: '.planning/' + dir + rel });
59
+ }
60
+ }
61
+ }
62
+ walkArtifacts(full, '', 0);
63
+ if (files.length) {
64
+ const groupLabel = dir.charAt(0).toUpperCase() + dir.slice(1).replace(/-/g, ' ');
65
+ groups.push({ group: groupLabel, files });
66
+ }
67
+ }
68
+
69
+ res.writeHead(200, { 'Content-Type': 'application/json' });
70
+ res.end(JSON.stringify(groups));
71
+ }
72
+
73
+ function handleApiFile(req, res, projectRoot) {
74
+ const url = req.url || '';
75
+ const params = new URLSearchParams(url.split('?')[1] || '');
76
+ const relPath = params.get('path') || '';
77
+ if (!relPath) {
78
+ res.writeHead(400); res.end('Missing path parameter'); return;
79
+ }
80
+ // Fix #321: decode URL-encoded characters before resolving
81
+ const decoded = decodeURIComponent(relPath);
82
+ const resolved = path.resolve(projectRoot, decoded.replace(/^\//, ''));
83
+ if (!resolved.startsWith(projectRoot + path.sep) && resolved !== projectRoot) {
84
+ res.writeHead(403); res.end('Forbidden'); return;
85
+ }
86
+ if (!resolved.endsWith('.md')) {
87
+ res.writeHead(403); res.end('Forbidden: only .md files'); return;
88
+ }
89
+ let content;
90
+ try { content = fs.readFileSync(resolved, 'utf8'); }
91
+ catch { res.writeHead(404); res.end('File not found'); return; }
92
+ res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
93
+ res.end(content);
94
+ }
95
+
96
+ // Fix #265: hierarchy endpoint
97
+ function handleApiHierarchy(req, res, rihalDir) {
98
+ const state = scanState(rihalDir);
99
+ const phases = state.raw?.phases || [];
100
+ const hierarchy = {
101
+ milestone: state.milestone || 'M1',
102
+ phases: phases.map(p => ({
103
+ id: p.id,
104
+ name: p.name,
105
+ status: p.status,
106
+ sprints: (p.sprints || []).map(s => ({
107
+ id: s.id,
108
+ goal: s.goal,
109
+ status: s.status,
110
+ stories: (s.stories || []).map(t => ({
111
+ id: t.id,
112
+ title: t.title,
113
+ status: t.status,
114
+ points: t.points || null,
115
+ })),
116
+ })),
117
+ })),
118
+ };
119
+ res.writeHead(200, { 'Content-Type': 'application/json' });
120
+ res.end(JSON.stringify(hierarchy, null, 2));
121
+ }
122
+
123
+ module.exports = { handleApiState, handleApiFiles, handleApiFile, handleApiHierarchy };