wrxn-reversa 1.8.1 → 1.8.3

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/README.md CHANGED
@@ -49,7 +49,7 @@ The installer will:
49
49
  2. Ask which agents to install — all selected by default
50
50
  3. Collect project name, language, and preferences
51
51
  4. Install skills in `.agents/skills/` and add a discovery mirror for engines such as Claude Code.
52
- 5. Write the routing card for each engine (`.claude/rules/reversa.md`, `.agents/rules/reversa.md`, or a marked block in `AGENTS.md`, etc.)
52
+ 5. Write the routing card in a marked block in `AGENTS.md`, in `CLAUDE.md` for Claude Code, and in the engine rule files.
53
53
  6. Create the `.reversa/` structure with state, configuration, and plan
54
54
  7. Generate SHA-256 manifest for safe updates
55
55
 
@@ -63,7 +63,10 @@ The installer will:
63
63
  > [!IMPORTANT]
64
64
  > ### 🔒 Guaranteed immutability of the legacy project
65
65
  >
66
- > The installer creates new files (`.claude/rules/reversa.md`, `.agents/rules/reversa.md`, `.agents/skills/`, etc.). In an existing instruction file such as `AGENTS.md` it only adds a marked Reversa block, and only if you choose "Merge"; it **never deletes any existing file** in your project. During analysis, agents operate under a strict and inviolable directive: **all writes are restricted to `.reversa/` and `_reversa_sdd/`** — no other file in your project is touched.
66
+ > Install and update place the full marked routing block at the start of `AGENTS.md`, regardless of file size.
67
+ > They preserve your text and keep edited Reversa blocks unchanged.
68
+ > For other existing instruction files, install asks before it adds a new block.
69
+ > During analysis, agents follow the project's Reversa write policy.
67
70
 
68
71
  > [!CAUTION]
69
72
  > ### 💾 Back up your project before starting
@@ -416,9 +419,9 @@ Every statement in the specs is marked with:
416
419
 
417
420
  | Engine | File created | Skills path | Activation |
418
421
  |--------|-------------|-------------|------------|
419
- | Claude Code ⭐ | `.claude/rules/reversa.md` | `.claude/skills/reversa-*/` and `.agents/skills/reversa-*/` | `/reversa` |
422
+ | Claude Code ⭐ | `CLAUDE.md` and `.claude/rules/reversa.md` | `.claude/skills/reversa-*/` and `.agents/skills/reversa-*/` | `/reversa` |
420
423
  | Codex ⭐ | `AGENTS.md` | `.agents/skills/reversa-*/` | `reversa` |
421
- | OMP ⭐ | `.agents/rules/reversa.md` | `.agents/skills/reversa-*/` | `reversa` |
424
+ | OMP ⭐ | `AGENTS.md` and `.agents/rules/reversa.md` | `.agents/skills/reversa-*/` | `reversa` |
422
425
  | Cursor ⭐ | `.cursor/rules/reversa.mdc` | `.agents/skills/reversa-*/` | `/reversa` |
423
426
  | Gemini CLI | `GEMINI.md` | `.agents/skills/reversa-*/` | `/reversa` |
424
427
  | Windsurf | `.windsurfrules` | `.agents/skills/reversa-*/` | `/reversa` |
@@ -3,16 +3,17 @@ import { join } from 'path';
3
3
  import { execFileSync } from 'child_process';
4
4
 
5
5
  import { CANONICAL_SKILLS_DIR } from './skill-layout.js';
6
- const AGENTS_BLOCK = { file: 'AGENTS.md', kind: 'block' };
6
+ const AGENTS_BLOCK = { file: 'AGENTS.md', kind: 'block', addOnUpdate: true };
7
+ const CLAUDE_BLOCK = { file: 'CLAUDE.md', kind: 'block', compact: true, addOnUpdate: true };
7
8
  const engine = (id, name, star, entry, skillsDir = CANONICAL_SKILLS_DIR) => ({ id, name, star, entry, skillsDir });
8
9
 
9
10
  // entry: onde fica o cartão de roteamento do Reversa.
10
11
  // kind 'owned' = arquivo só do Reversa; 'block' = bloco com marcas num arquivo do usuário.
11
12
  export const ENGINES = [
12
13
  engine('claude-code', 'Claude Code', true,
13
- { file: '.claude/rules/reversa.md', kind: 'owned', compact: true, legacyFile: 'CLAUDE.md' }, '.claude/skills'),
14
+ { file: '.claude/rules/reversa.md', kind: 'owned', compact: true }, '.claude/skills'),
14
15
  engine('codex', 'Codex', true, AGENTS_BLOCK),
15
- engine('omp', 'OMP', true, { file: '.agents/rules/reversa.md', kind: 'owned' }),
16
+ engine('omp', 'OMP', true, AGENTS_BLOCK),
16
17
  engine('cursor', 'Cursor', true,
17
18
  { file: '.cursor/rules/reversa.mdc', kind: 'owned', frontmatter: 'alwaysApply', legacyFile: '.cursorrules' }),
18
19
  engine('gemini-cli', 'Gemini CLI', false, { file: 'GEMINI.md', kind: 'block' }),
@@ -33,8 +34,9 @@ export const SHARED_RULE = { file: '.agents/rules/reversa.md', kind: 'owned', fr
33
34
 
34
35
  // Destinos únicos do cartão para um conjunto de engines.
35
36
  export function entryTargets(engines) {
36
- const targets = new Map([[SHARED_RULE.file, SHARED_RULE]]);
37
- for (const { entry } of engines) {
37
+ const targets = new Map([[SHARED_RULE.file, SHARED_RULE], [AGENTS_BLOCK.file, AGENTS_BLOCK]]);
38
+ for (const { id, entry } of engines) {
39
+ if (id === 'claude-code') targets.set(CLAUDE_BLOCK.file, CLAUDE_BLOCK);
38
40
  const seen = targets.get(entry.file);
39
41
  if (!seen) targets.set(entry.file, entry);
40
42
  else if (entry.compact && !seen.compact) targets.set(entry.file, { ...seen, compact: true });
@@ -4,7 +4,7 @@ import {
4
4
  readdirSync, statSync, chmodSync,
5
5
  copyFileSync, unlinkSync,
6
6
  } from 'fs';
7
- import { join, dirname, resolve, basename } from 'path';
7
+ import { join, dirname, resolve } from 'path';
8
8
  import { fileURLToPath } from 'url';
9
9
  import { askMergeStrategy } from './prompts.js';
10
10
  import { readJsonSafe } from '../utils/json-safe.js';
@@ -18,6 +18,11 @@ const REPO_ROOT = resolve(__dirname, '..', '..');
18
18
  const AGENTS_DIR = join(REPO_ROOT, 'agents');
19
19
  const TEMPLATES_DIR = join(REPO_ROOT, 'templates');
20
20
 
21
+ function placeEntryBlock(file, text, block, range) {
22
+ if (file !== 'AGENTS.md') return upsertBlock(text, block, range);
23
+ return block + (range ? text.slice(0, range.start) + text.slice(range.end) : text);
24
+ }
25
+
21
26
  export class Writer {
22
27
  constructor(projectRoot) {
23
28
  this.projectRoot = projectRoot;
@@ -145,7 +150,7 @@ export class Writer {
145
150
  const text = readFileSync(destPath, 'utf8');
146
151
  const found = findBlock(text);
147
152
  if (found.status === 'ok' && !found.edited) {
148
- writeFileSync(destPath, upsertBlock(text, block, found), 'utf8');
153
+ writeFileSync(destPath, placeEntryBlock(target.file, text, block, found), 'utf8');
149
154
  this.entryBlocks[target.file] = { mode: records[target.file]?.mode ?? 'merged', sha256 };
150
155
  return;
151
156
  }
@@ -153,23 +158,15 @@ export class Writer {
153
158
  console.log(` Kept ${target.file}: Reversa block was edited or its markers are damaged`);
154
159
  return;
155
160
  }
156
- if (records[target.file]?.mode === 'skipped') return;
157
-
158
- const strategy = await askMergeStrategy(target.file);
159
- if (strategy !== 'merge') {
160
- this.entryBlocks[target.file] = { mode: 'skipped' };
161
- return;
162
- }
163
- const merged = upsertBlock(text, block);
164
- if (basename(target.file) === 'AGENTS.md') {
165
- const bytes = Buffer.byteLength(merged);
166
- if (bytes > 32768) {
167
- console.log(" Not merged into AGENTS.md: the result would exceed Codex's 32 KiB project_doc_max_bytes limit.");
161
+ const legacy = target.file === 'AGENTS.md' ? findLegacyBlock(text) : null;
162
+ if (target.file !== 'AGENTS.md') {
163
+ if (records[target.file]?.mode === 'skipped') return;
164
+ if (await askMergeStrategy(target.file) !== 'merge') {
168
165
  this.entryBlocks[target.file] = { mode: 'skipped' };
169
166
  return;
170
167
  }
171
- if (bytes > 28672) console.log(" Warning: AGENTS.md will be close to Codex's 32 KiB limit.");
172
168
  }
169
+ const merged = placeEntryBlock(target.file, text, block, legacy);
173
170
  writeFileSync(destPath, merged, 'utf8');
174
171
  this.entryBlocks[target.file] = { mode: 'merged', sha256 };
175
172
  }
@@ -424,20 +421,22 @@ export class Writer {
424
421
  for (const target of targets) {
425
422
  const card = renderCard(target, opts);
426
423
  if (target.kind === 'owned') this._planContent(plan, target.file, card, index);
427
- else this._planBlock(plan, target.file, card, index, records);
424
+ else this._planBlock(plan, target, card, index, records);
428
425
  if (target.legacyFile) this._planLegacy(plan, target.legacyFile, index);
429
426
  }
430
427
  return plan;
431
428
  }
432
429
 
433
- _planBlock(plan, rel, card, index, records) {
430
+ _planBlock(plan, { file: rel, addOnUpdate }, card, index, records) {
434
431
  const block = renderBlock(card);
435
432
  const sha256 = cardHash(card);
436
433
  const state = pathState(this.projectRoot, rel);
437
434
  const dropKey = index.get(rel)?.key;
438
435
  if (state === 'missing') {
439
- if (records[rel]?.mode === 'created' || index.has(rel)) {
440
- plan.writes.push({ rel, reason: 'restore', content: block, block: { mode: 'created', sha256 }, dropKey });
436
+ if (rel !== 'AGENTS.md' && records[rel]?.mode === 'skipped') return;
437
+ const restore = records[rel]?.mode === 'created' || index.has(rel);
438
+ if (restore || addOnUpdate) {
439
+ plan.writes.push({ rel, reason: restore ? 'restore' : 'new', content: block, block: { mode: 'created', sha256 }, dropKey });
441
440
  }
442
441
  return;
443
442
  }
@@ -449,9 +448,10 @@ export class Writer {
449
448
  const baseline = hashContent(text);
450
449
  const found = findBlock(text);
451
450
  if (found.status === 'ok' && !found.edited) {
452
- if (found.inner === card) return;
451
+ const content = placeEntryBlock(rel, text, block, found);
452
+ if (content === text) return;
453
453
  plan.writes.push({
454
- rel, reason: 'refresh', content: upsertBlock(text, block, found), baseline,
454
+ rel, reason: 'refresh', content, baseline,
455
455
  block: { mode: records[rel]?.mode ?? 'merged', sha256 }, dropKey,
456
456
  });
457
457
  } else if (found.status === 'ok') {
@@ -466,15 +466,16 @@ export class Writer {
466
466
  plan.kept.push({ rel, reason: 'damaged markers' });
467
467
  } else {
468
468
  const legacy = findLegacyBlock(text);
469
- if (!legacy) return;
469
+ if (!legacy && (!addOnUpdate || (rel !== 'AGENTS.md' && records[rel]?.mode === 'skipped'))) return;
470
+ const content = placeEntryBlock(rel, text, block, legacy);
470
471
  plan.writes.push({
471
- rel, reason: 'migrate', content: upsertBlock(text, block, legacy), baseline,
472
- block: { mode: index.has(rel) && legacy.start === 0 ? 'created' : 'merged', sha256 }, dropKey,
472
+ rel, reason: legacy ? 'migrate' : 'refresh', content, baseline,
473
+ block: { mode: index.has(rel) && legacy?.start === 0 ? 'created' : 'merged', sha256 }, dropKey,
473
474
  });
474
475
  }
475
476
  }
476
477
 
477
- // Arquivo usado antes do cartão (CLAUDE.md, .cursorrules): sai só o texto do Reversa.
478
+ // Remove the old Reversa text after moving the card to a different file.
478
479
  _planLegacy(plan, rel, index) {
479
480
  if (pathState(this.projectRoot, rel) !== 'file') return;
480
481
  const text = readFileSync(join(this.projectRoot, rel), 'utf8');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrxn-reversa",
3
- "version": "1.8.1",
3
+ "version": "1.8.3",
4
4
  "description": "Transform legacy systems into executable specifications for AI coding agents",
5
5
  "bin": {
6
6
  "wrxn-reversa": "bin/reversa.js"