@hanzlaa/rcode 2.5.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/rihal/workflows/init.md +10 -0
- package/rihal/workflows/scan.md +160 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzlaa/rcode",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Rihal Code (rcode) — installable context-brain for Rihalians. 43 agents, 99 slash commands, 56 skills, pullable Rihal standards. Unified install for Claude Code, Cursor, and Gemini.",
|
|
5
5
|
"main": "cli/index.js",
|
|
6
6
|
"bin": {
|
package/rihal/workflows/init.md
CHANGED
|
@@ -128,6 +128,16 @@ test -f .rihal/state.json || node .rihal/bin/rihal-tools.cjs state init --projec
|
|
|
128
128
|
|
|
129
129
|
If the project has code (from Step 1 detection), produce `.rihal/RIHLA.md`. This is the journey baseline — a lightweight snapshot, not a full audit. Use `/rihal:map-codebase` or `/rihal:scan` later for deep analysis.
|
|
130
130
|
|
|
131
|
+
**Memory-bank refresh on `--reset`.** When `--reset` is passed AND `.planning/codebase/` already contains docs from a previous scan, also chain to `/rihal:scan --refresh --focus tech+arch` immediately after writing RIHLA.md. The refresh path:
|
|
132
|
+
|
|
133
|
+
- Captures pre-state (commits since last doc mtime, manifest hashes, top-level dirs).
|
|
134
|
+
- Briefs the user on what changed since the last scan.
|
|
135
|
+
- Overwrites the docs and appends an entry to `.planning/codebase/CHANGELOG.md`.
|
|
136
|
+
|
|
137
|
+
Skip the chain if `--skip-scan` is set, no existing docs are present (nothing stale to refresh), or the user passes `--no-refresh`.
|
|
138
|
+
|
|
139
|
+
This makes init+reset a true memory-bank refresh — RIHLA baseline updated, codebase docs reconciled with current code, CHANGELOG entry written.
|
|
140
|
+
|
|
131
141
|
Gather (parallel reads, all bounded):
|
|
132
142
|
|
|
133
143
|
```bash
|
package/rihal/workflows/scan.md
CHANGED
|
@@ -20,7 +20,7 @@ If `$ARGUMENTS` is empty or contains only `--help` or `-h`:
|
|
|
20
20
|
|
|
21
21
|
**Usage:**
|
|
22
22
|
```
|
|
23
|
-
/rihal:scan [--focus tech|arch|quality|concerns|tech+arch]
|
|
23
|
+
/rihal:scan [--focus tech|arch|quality|concerns|tech+arch] [--refresh] [--reset]
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
**Examples:**
|
|
@@ -28,8 +28,20 @@ If `$ARGUMENTS` is empty or contains only `--help` or `-h`:
|
|
|
28
28
|
/rihal:scan --focus tech
|
|
29
29
|
/rihal:scan --focus arch
|
|
30
30
|
/rihal:scan --focus tech+arch
|
|
31
|
+
/rihal:scan --refresh # auto-update stale docs, brief diff, log to CHANGELOG.md
|
|
32
|
+
/rihal:scan --reset --focus tech+arch # silent overwrite (CI / autonomous)
|
|
31
33
|
```
|
|
32
34
|
|
|
35
|
+
**Refresh flag — memory-bank pattern.** When `--refresh` is passed AND existing docs are present, the orchestrator:
|
|
36
|
+
|
|
37
|
+
1. Captures a *pre-state snapshot* (top-level dirs, manifests, dep counts, file counts, git HEAD).
|
|
38
|
+
2. Reads the oldest existing target doc's mtime — anchor for "changes since last scan".
|
|
39
|
+
3. Runs git log + dir diff + manifest diff against that anchor.
|
|
40
|
+
4. Spawns Dalil with the diff context, instructs him to overwrite docs AND prepend a "Changes since last scan" section to each.
|
|
41
|
+
5. Appends a structured entry to `.planning/codebase/CHANGELOG.md` with the brief.
|
|
42
|
+
|
|
43
|
+
This is the canonical way to keep the memory bank fresh without losing the audit trail of what changed and why.
|
|
44
|
+
|
|
33
45
|
<process>
|
|
34
46
|
|
|
35
47
|
## Focus-to-Document Mapping
|
|
@@ -48,7 +60,11 @@ Parse the user's input for `--focus <area>`. Default to `tech+arch` if not speci
|
|
|
48
60
|
|
|
49
61
|
Validate that the focus is one of: `tech`, `arch`, `quality`, `concerns`, `tech+arch`.
|
|
50
62
|
|
|
51
|
-
|
|
63
|
+
Also parse:
|
|
64
|
+
- `--refresh` → auto-update mode (briefs the user on what changed, then overwrites)
|
|
65
|
+
- `--reset` → silent overwrite (no prompt, no brief — for CI / autonomous chains)
|
|
66
|
+
|
|
67
|
+
If invalid focus:
|
|
52
68
|
```
|
|
53
69
|
Unknown focus area: "{input}". Valid options: tech, arch, quality, concerns, tech+arch
|
|
54
70
|
```
|
|
@@ -68,16 +84,83 @@ For each target document, check if it already exists in `.planning/codebase/`:
|
|
|
68
84
|
ls -la .planning/codebase/{DOCUMENT}.md 2>/dev/null
|
|
69
85
|
```
|
|
70
86
|
|
|
71
|
-
|
|
87
|
+
**Three modes:**
|
|
88
|
+
|
|
89
|
+
### 2a — Refresh mode (`--refresh` flag)
|
|
90
|
+
|
|
91
|
+
Skip the [y/N] prompt. Instead, run the diff analysis in Step 2c and proceed to dispatch with refresh context.
|
|
92
|
+
|
|
93
|
+
### 2b — Reset mode (`--reset` flag)
|
|
94
|
+
|
|
95
|
+
Silent overwrite. No prompt, no brief, no CHANGELOG entry. Use only for CI or chained autonomous workflows.
|
|
96
|
+
|
|
97
|
+
### 2c — Default mode (no flag)
|
|
98
|
+
|
|
99
|
+
If any target doc exists, show their mod dates AND age in days, AND a one-line activity hint, then ask:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# For each existing doc, compute relative age:
|
|
103
|
+
for DOC in {document_list}; do
|
|
104
|
+
if [ -f ".planning/codebase/$DOC" ]; then
|
|
105
|
+
MTIME=$(stat -c %Y ".planning/codebase/$DOC" 2>/dev/null || stat -f %m ".planning/codebase/$DOC" 2>/dev/null)
|
|
106
|
+
NOW=$(date +%s)
|
|
107
|
+
AGE_DAYS=$(( (NOW - MTIME) / 86400 ))
|
|
108
|
+
COMMITS_SINCE=$(git log --oneline --since="@$MTIME" 2>/dev/null | wc -l | tr -d ' ')
|
|
109
|
+
echo " - $DOC ({date}, ${AGE_DAYS}d ago, ${COMMITS_SINCE} commits since)"
|
|
110
|
+
fi
|
|
111
|
+
done
|
|
112
|
+
```
|
|
113
|
+
|
|
72
114
|
```
|
|
73
115
|
Existing documents found:
|
|
74
|
-
- STACK.md
|
|
75
|
-
- INTEGRATIONS.md
|
|
116
|
+
- STACK.md (2026-03-22, 35d ago, 14 commits since)
|
|
117
|
+
- INTEGRATIONS.md (2026-03-22, 35d ago, 14 commits since)
|
|
118
|
+
|
|
119
|
+
These docs are stale. Three options:
|
|
120
|
+
[Y] Refresh — analyze what changed, briefly explain, then overwrite + log to CHANGELOG.md
|
|
121
|
+
[o] Overwrite blind — skip the diff brief, just rebuild
|
|
122
|
+
[n] Keep as-is, exit
|
|
123
|
+
```
|
|
76
124
|
|
|
77
|
-
|
|
125
|
+
Map the answer:
|
|
126
|
+
- `Y` / `y` / empty → set internal mode to **refresh**, continue to Step 2d
|
|
127
|
+
- `o` → set mode to **reset**, continue to Step 4
|
|
128
|
+
- `n` / `no` → exit
|
|
129
|
+
|
|
130
|
+
## Step 2d — Pre-state capture (refresh mode only)
|
|
131
|
+
|
|
132
|
+
Before dispatching Dalil, capture a structured snapshot for diff comparison. Fire each command and save the output verbatim — it goes into the dispatch prompt and the CHANGELOG entry.
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Anchor mtime — oldest existing target doc
|
|
136
|
+
ANCHOR_TS=$(for DOC in {document_list}; do
|
|
137
|
+
[ -f ".planning/codebase/$DOC" ] && stat -c %Y ".planning/codebase/$DOC" 2>/dev/null || stat -f %m ".planning/codebase/$DOC" 2>/dev/null
|
|
138
|
+
done | sort -n | head -1)
|
|
139
|
+
ANCHOR_DATE=$(date -d "@$ANCHOR_TS" -u +%Y-%m-%d 2>/dev/null || date -r "$ANCHOR_TS" -u +%Y-%m-%d 2>/dev/null)
|
|
140
|
+
|
|
141
|
+
# Commits since anchor
|
|
142
|
+
echo "=== COMMITS SINCE $ANCHOR_DATE ==="
|
|
143
|
+
git log --oneline --since="@$ANCHOR_TS" 2>/dev/null | head -50
|
|
144
|
+
|
|
145
|
+
# Top-level dir set
|
|
146
|
+
echo "=== TOP-LEVEL DIRS ==="
|
|
147
|
+
find . -maxdepth 1 -type d -not -name '.git' -not -name 'node_modules' -not -name '.next' -not -name 'dist' -not -name '.venv' -not -name '__pycache__' | sort
|
|
148
|
+
|
|
149
|
+
# Manifest hashes (changed if deps shifted)
|
|
150
|
+
echo "=== MANIFEST HASHES ==="
|
|
151
|
+
for M in package.json pnpm-lock.yaml pyproject.toml requirements.txt Cargo.toml go.mod; do
|
|
152
|
+
[ -f "$M" ] && echo "$M $(sha256sum "$M" 2>/dev/null | awk '{print $1}' || shasum -a 256 "$M" | awk '{print $1}')"
|
|
153
|
+
done
|
|
154
|
+
|
|
155
|
+
# Source file count by language
|
|
156
|
+
echo "=== SOURCE FILE COUNTS ==="
|
|
157
|
+
for EXT in py ts tsx js jsx go rs rb; do
|
|
158
|
+
COUNT=$(find . -name "*.$EXT" -not -path '*/node_modules/*' -not -path '*/.venv/*' -not -path '*/dist/*' 2>/dev/null | wc -l | tr -d ' ')
|
|
159
|
+
[ "$COUNT" -gt 0 ] && echo "*.$EXT $COUNT"
|
|
160
|
+
done
|
|
78
161
|
```
|
|
79
162
|
|
|
80
|
-
|
|
163
|
+
Store this entire output as `$PRE_STATE` for the dispatch prompt.
|
|
81
164
|
|
|
82
165
|
## Step 3: Create output directory
|
|
83
166
|
|
|
@@ -121,7 +204,9 @@ Always first-person. Always include the deliverable path. If a topic phrase isn'
|
|
|
121
204
|
|
|
122
205
|
## Step 5: Spawn mapper agent
|
|
123
206
|
|
|
124
|
-
Spawn a single `rihal-codebase-mapper` agent. Pass the persona instructions in the prompt so the agent's own response opens in-character
|
|
207
|
+
Spawn a single `rihal-codebase-mapper` agent. Pass the persona instructions in the prompt so the agent's own response opens in-character.
|
|
208
|
+
|
|
209
|
+
**Base prompt (always sent):**
|
|
125
210
|
|
|
126
211
|
```
|
|
127
212
|
Task(
|
|
@@ -144,6 +229,35 @@ Task(
|
|
|
144
229
|
)
|
|
145
230
|
```
|
|
146
231
|
|
|
232
|
+
**Refresh-mode addendum (append to the prompt above when mode === "refresh"):**
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
REFRESH MODE — this is NOT a first scan. Existing docs are present and stale.
|
|
236
|
+
|
|
237
|
+
Anchor date (last scan): {ANCHOR_DATE}
|
|
238
|
+
Pre-state snapshot (verbatim from orchestrator):
|
|
239
|
+
{PRE_STATE}
|
|
240
|
+
|
|
241
|
+
Additional requirements for refresh runs:
|
|
242
|
+
1. After the Scan Scope section in EACH document, insert a section titled
|
|
243
|
+
'## Changes since last scan ({ANCHOR_DATE} → today)' that lists, in bullets:
|
|
244
|
+
- new files / removed files relevant to this doc's focus
|
|
245
|
+
- new dependencies / removed dependencies (for STACK.md / INTEGRATIONS.md)
|
|
246
|
+
- new modules / removed modules (for ARCHITECTURE.md / STRUCTURE.md)
|
|
247
|
+
- new TODO/FIXME or eliminated ones (for CONCERNS.md)
|
|
248
|
+
- 3-7 most-important commit subjects from the pre-state COMMITS list
|
|
249
|
+
that materially shaped the current state
|
|
250
|
+
2. The body of each document must reflect CURRENT state — not a diff. The
|
|
251
|
+
'Changes since last scan' section is the ONLY place where pre-state and
|
|
252
|
+
diff narrative belongs.
|
|
253
|
+
3. Include a final line in your return summary:
|
|
254
|
+
'Brief: {one-paragraph plain-English summary of the most important changes
|
|
255
|
+
since last scan, suitable for posting to CHANGELOG.md}'
|
|
256
|
+
The orchestrator extracts this verbatim.
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
When refresh mode is active, also include `topic_keyword` (if any) and the resolved focus in the prompt as before.
|
|
260
|
+
|
|
147
261
|
## Step 6: Announce return (persona-driven)
|
|
148
262
|
|
|
149
263
|
When the agent returns, print the RETURNED banner per `.rihal/references/dispatch-banner.md`. Filled-in template:
|
|
@@ -184,6 +298,44 @@ If the document is missing its Scan Scope section, do NOT print the success bann
|
|
|
184
298
|
|
|
185
299
|
Until the next `Task()` dispatch, answer follow-up questions about the scan AS Dalil — first-person, sign with `— Dalil`. If the user asks something outside Dalil's scope (e.g. strategy, planning, code editing), hand off explicitly per the dispatch-banner spec and print a fresh DISPATCH banner for the new persona.
|
|
186
300
|
|
|
301
|
+
## Step 6.5: Append to CHANGELOG.md (refresh mode only)
|
|
302
|
+
|
|
303
|
+
When mode === "refresh", extract Dalil's `Brief:` line from his RETURNED summary and append a structured entry to `.planning/codebase/CHANGELOG.md`. Create the file if missing. Use the Read tool first if updating, then Edit/Write — never blind-overwrite a file with prior entries.
|
|
304
|
+
|
|
305
|
+
**Entry format:**
|
|
306
|
+
|
|
307
|
+
```markdown
|
|
308
|
+
## {today's ISO date} — refresh
|
|
309
|
+
|
|
310
|
+
**Anchor:** {ANCHOR_DATE} ({age in days} days ago)
|
|
311
|
+
**Focus:** {focus}
|
|
312
|
+
**Commits since anchor:** {count}
|
|
313
|
+
**Docs touched:** {comma-separated list}
|
|
314
|
+
|
|
315
|
+
{Dalil's Brief: line, verbatim, formatted as a paragraph}
|
|
316
|
+
|
|
317
|
+
**Top-level signals:**
|
|
318
|
+
- Source roots: {comma-separated list of dirs from PRE_STATE}
|
|
319
|
+
- Languages: {detected mix}
|
|
320
|
+
- Manifest changes: {hash diff summary, e.g. "package.json: changed", "pyproject.toml: unchanged"}
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Insert at the TOP of the file body (newest-first), under any pre-existing `# Changelog — Codebase Memory Bank` H1. If the file doesn't exist, write it with this header:
|
|
326
|
+
|
|
327
|
+
```markdown
|
|
328
|
+
# Changelog — Codebase Memory Bank
|
|
329
|
+
|
|
330
|
+
This file tracks structural changes between scans. Each entry is auto-written by `/rihal:scan --refresh`. Newest entries first.
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
{first entry here}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
This file is **read by future `/rihal:scan --refresh` runs** as additional anchor context — the memory bank is self-improving across scans.
|
|
338
|
+
|
|
187
339
|
## Step 7: Final cue (orchestrator-level, after RETURNED banner)
|
|
188
340
|
|
|
189
341
|
The RETURNED banner above is Dalil's voice. After it, the orchestrator may add ONE neutral cue line if the user might want a deeper scan:
|