@ericrisco/rsc 4.1.4 → 4.1.5

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/manifest.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.1.4",
2
+ "version": "4.1.5",
3
3
  "counts": {
4
4
  "skills": 273,
5
5
  "agents": 34,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ericrisco/rsc",
3
- "version": "4.1.4",
3
+ "version": "4.1.5",
4
4
  "description": "A guided harness builder that turns your goal into a minimal, verified AI-agent setup using strict best practices.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { claudeBootstrapPath } from '../targets/claude-lifecycle.js';
2
3
  import { rmSync, rmdirSync, existsSync, cpSync, lstatSync, mkdirSync, readFileSync, realpathSync, writeFileSync, appendFileSync, readdirSync, renameSync } from 'node:fs';
3
4
  import { join, dirname, relative, resolve, sep } from 'node:path';
4
5
  import { fileURLToPath } from 'node:url';
@@ -115,6 +116,8 @@ export function managedPathsForInstall({ skillIds, agentIds = [], target, home,
115
116
  const paths = targetPaths(target, home, cwd);
116
117
  const plan = planInstall({ skillIds, target, home, cwd, hooks: policy?.alwaysOn !== false });
117
118
  const out = [paths.stateFile, versionFile(cwd), baseVersionsFile(cwd)];
119
+ // Knowledge/memory wiring also needs this shared dependency without suggest.
120
+ if (target === 'claude') out.push(claudeBootstrapPath(cwd));
118
121
  // Pi can move its managed block when the native context-file precedence changes.
119
122
  if (target === 'pi') out.push(...paths.contextFiles);
120
123
  if (policy?.context7 === false) out.push(join(cwd, '.rsc', '.no-context7'));
@@ -0,0 +1,34 @@
1
+ // Local lifecycle settings can be inherited by a worktree whose ignored runtime is
2
+ // absent. Use the same portable bootstrap as Claude's committed hook settings.
3
+ import { copyFileSync, mkdirSync, existsSync, readFileSync, rmSync } from 'node:fs';
4
+ import { dirname, join } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+
7
+ const HERE = dirname(fileURLToPath(import.meta.url));
8
+ export const claudeBootstrapPath = (cwd) => join(cwd, '.claude', 'rsc-bootstrap.mjs');
9
+
10
+ export function ensureClaudeBootstrap(cwd) {
11
+ const dest = claudeBootstrapPath(cwd);
12
+ mkdirSync(dirname(dest), { recursive: true });
13
+ copyFileSync(join(HERE, 'clone-bootstrap.mjs'), dest);
14
+ }
15
+
16
+ // script and args are internal lifecycle identifiers, never caller-provided shell text.
17
+ export function claudeLifecycleCommand(script, ...args) {
18
+ return `node "\${CLAUDE_PROJECT_DIR}/.claude/rsc-bootstrap.mjs" "quiet" "\${CLAUDE_PROJECT_DIR}" "\${CLAUDE_PROJECT_DIR}/.rsc/${script}" ${args.join(' ')}`;
19
+ }
20
+
21
+ // The committed hooks and the local lifecycle hooks share this file. Retire it
22
+ // only after both settings surfaces stop referencing it; unreadable settings retain it.
23
+ export function pruneClaudeBootstrap(cwd) {
24
+ for (const name of ['settings.json', 'settings.local.json']) {
25
+ const file = join(cwd, '.claude', name);
26
+ if (!existsSync(file)) continue;
27
+ try {
28
+ const config = JSON.parse(readFileSync(file, 'utf8'));
29
+ if (!config || typeof config !== 'object' || Array.isArray(config)) return;
30
+ if (JSON.stringify(config.hooks || {}).replace(/\\\\/g, '/').includes('.claude/rsc-bootstrap.mjs')) return;
31
+ } catch { return; }
32
+ }
33
+ try { rmSync(claudeBootstrapPath(cwd), { force: true }); } catch { /* cleanup must not break uninstall */ }
34
+ }
package/targets/claude.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { pruneClaudeBootstrap } from './claude-lifecycle.js';
1
2
  import { readFileSync, writeFileSync, existsSync, mkdirSync, copyFileSync, rmSync } from 'node:fs';
2
3
  import { dirname, join, relative, sep } from 'node:path';
3
4
  import { fileURLToPath } from 'node:url';
@@ -48,12 +49,7 @@ export function hookWiringOf(entry) {
48
49
  const ATTRIBUTION_MARKER = '.rsc/attribution-default';
49
50
 
50
51
  export function unwireHook(paths) {
51
- // The bootstrap lives in the COMMITTED tree, so leaving it behind does not just orphan a file the
52
- // way a stray `.rsc/` entry would — it leaves an executable in something the user pushes. Nothing
53
- // else removes it: uninstall and purge only ever knew about `.rsc/`.
54
- try {
55
- rmSync(join(paths.projectRoot, '.claude', 'rsc-bootstrap.mjs'), { force: true });
56
- } catch { /* never let cleanup be the thing that fails */ }
52
+ const finish = (removed) => { pruneClaudeBootstrap(paths.projectRoot); return removed; };
57
53
 
58
54
  // The shadow CLAUDE.md exists only to keep the hook from being doubled by a natively-read
59
55
  // AGENTS.md. Unwiring the hook removes the reason for it. Only ever takes back an untouched one.
@@ -61,9 +57,9 @@ export function unwireHook(paths) {
61
57
  const removed = shadow ? [shadow] : [];
62
58
 
63
59
  const file = paths.hookTarget;
64
- if (!existsSync(file)) return removed;
60
+ if (!existsSync(file)) return finish(removed);
65
61
  let settings;
66
- try { settings = JSON.parse(readFileSync(file, 'utf8')); } catch { return removed; }
62
+ try { settings = JSON.parse(readFileSync(file, 'utf8')); } catch { return finish(removed); }
67
63
  // wireHook's attribution default goes back out with it — only when wireHook wrote it (the marker)
68
64
  // and it is still untouched. The same value set by the person before rsc stays theirs.
69
65
  const marker = join(paths.projectRoot, ATTRIBUTION_MARKER);
@@ -72,9 +68,9 @@ export function unwireHook(paths) {
72
68
  if (ours) delete settings.attribution;
73
69
  try { rmSync(marker, { force: true }); } catch { /* cleanup never fails the uninstall */ }
74
70
  if (!settings.hooks) {
75
- if (!ours) return removed;
71
+ if (!ours) return finish(removed);
76
72
  writeFileSync(file, JSON.stringify(settings, null, 2) + '\n');
77
- return [...removed, file];
73
+ return finish([...removed, file]);
78
74
  }
79
75
  for (const event of Object.keys(settings.hooks)) {
80
76
  settings.hooks[event] = (settings.hooks[event] || []).filter((e) => {
@@ -85,7 +81,7 @@ export function unwireHook(paths) {
85
81
  }
86
82
  if (Object.keys(settings.hooks).length === 0) delete settings.hooks;
87
83
  writeFileSync(file, JSON.stringify(settings, null, 2) + '\n');
88
- return [...removed, file];
84
+ return finish([...removed, file]);
89
85
  }
90
86
 
91
87
  // SessionStart runs a project-local session-start.mjs via `node`: it prints
@@ -1,3 +1,4 @@
1
+ import { ensureClaudeBootstrap, claudeLifecycleCommand, pruneClaudeBootstrap } from './claude-lifecycle.js';
1
2
  // Wiring for knowledge sync (`knowledge-sync.mjs`): two lifecycle events per assistant — the person
2
3
  // sends a message, the agent finishes — in the same project-local config files the session memory
3
4
  // uses, under a needle of its own so either can be wired or removed without touching the other.
@@ -66,6 +67,7 @@ function handler(target, event) {
66
67
  ? '"$(git rev-parse --show-toplevel)/.rsc/knowledge-sync.mjs"'
67
68
  : '".rsc/knowledge-sync.mjs"';
68
69
  const value = { type: 'command', command: `node ${script} hook ${target} ${event}`, timeout: target === 'gemini' ? 10000 : 10 };
70
+ if (target === 'claude') value.command = claudeLifecycleCommand('knowledge-sync.mjs', 'hook', target, event);
69
71
  if (target === 'codex') value.commandWindows = `node "$((git rev-parse --show-toplevel).Trim())/.rsc/knowledge-sync.mjs" hook ${target} ${event}`;
70
72
  if (target === 'gemini') value.name = `rsc-knowledge-${event}`;
71
73
  return value;
@@ -145,6 +147,8 @@ export function wireKnowledge(target, cwd = process.cwd()) {
145
147
  const config = target === 'opencode' ? null : readConfig(configPath);
146
148
  if (target !== 'opencode' && !validHookConfig(config)) return { mode: 'degraded', reason: 'config-invalid', paths: [] };
147
149
 
150
+ if (target === 'claude') ensureClaudeBootstrap(cwd);
151
+
148
152
  const script = join(cwd, '.rsc', 'knowledge-sync.mjs');
149
153
  mkdirSync(dirname(script), { recursive: true });
150
154
  copyFileSync(join(HERE, 'knowledge-sync.mjs'), script);
@@ -183,6 +187,7 @@ export function unwireKnowledge(target, cwd = process.cwd()) {
183
187
  const config = readConfig(path);
184
188
  if (config) { strip(config); writeFileSync(path, `${JSON.stringify(config, null, 2)}\n`); touched.push(path); }
185
189
  }
190
+ if (target === 'claude') pruneClaudeBootstrap(cwd);
186
191
  return touched;
187
192
  }
188
193
 
package/targets/memory.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { ensureClaudeBootstrap, claudeLifecycleCommand, pruneClaudeBootstrap } from './claude-lifecycle.js';
1
2
  import {
2
3
  appendFileSync, copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync,
3
4
  } from 'node:fs';
@@ -83,6 +84,7 @@ function handler(target, event) {
83
84
  command: `node ${unixScript} ${target} ${event}`,
84
85
  timeout: target === 'gemini' ? 5000 : event === 'end' && target === 'codex' ? 3 : 5,
85
86
  };
87
+ if (target === 'claude') value.command = claudeLifecycleCommand('session-memory-adapter.mjs', target, event);
86
88
  if (target === 'codex') {
87
89
  value.commandWindows = `node \"$((git rev-parse --show-toplevel).Trim())/.rsc/session-memory-adapter.mjs\" ${target} ${event}`;
88
90
  value.additionalContextLimit = 1400;
@@ -184,6 +186,8 @@ export function wireMemory(target, cwd = process.cwd()) {
184
186
  return { mode: 'degraded', reason: 'rule-collision', paths: [] };
185
187
  }
186
188
 
189
+ if (target === 'claude') ensureClaudeBootstrap(cwd);
190
+
187
191
  const [core, adapter, cli] = commonPaths(cwd);
188
192
  mkdirSync(dirname(core), { recursive: true });
189
193
  copyFileSync(join(HERE, 'session-memory-core.mjs'), core);
@@ -264,6 +268,7 @@ export function unwireMemory(target, cwd = process.cwd()) {
264
268
  const rule = join(cwd, '.cursor', 'rules', 'rsc-memory.mdc');
265
269
  if (existsSync(rule) && readFileSync(rule, 'utf8').includes('rsc-memory:managed')) { rmSync(rule, { force: true }); touched.push(rule); }
266
270
  }
271
+ if (target === 'claude') pruneClaudeBootstrap(cwd);
267
272
  return touched;
268
273
  }
269
274