@ericrisco/rsc 4.1.9 → 4.1.11
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 +1 -1
- package/package.json +1 -1
- package/skills/code-review/SKILL.md +3 -0
- package/skills/implement/SKILL.md +1 -1
- package/skills/review/SKILL.md +12 -0
- package/targets/agents.js +8 -2
- package/targets/claude.js +3 -3
- package/targets/danger-guard.mjs +74 -8
package/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -93,6 +93,9 @@ Read the surrounding code, trace the *value*, confirm the path is reachable.
|
|
|
93
93
|
|
|
94
94
|
If you cannot trace it to a concrete value and a reachable sink, you do not yet have a finding.
|
|
95
95
|
|
|
96
|
+
On Codex, pass the catalog ID as `agent_type`. If the router takes a `task_name`, use a unique
|
|
97
|
+
underscore name for the thread, as shown in `../review/SKILL.md`.
|
|
98
|
+
|
|
96
99
|
When several reviewers looked at the same diff, merge before reporting. Have each one end with a ` ```json findings ` block, run `npx @ericrisco/rsc review consolidate <reports…>`, and send each blocker it marks `verify` to the `finding-verifier` agent. That is the `review` skill's step, and it applies here unchanged.
|
|
97
100
|
|
|
98
101
|
## The verdict
|
|
@@ -115,7 +115,7 @@ review of the task, this first one included. Round 1 is the task's first review,
|
|
|
115
115
|
| --- | --- |
|
|
116
116
|
| 0 | none — the controls (e) still run |
|
|
117
117
|
| 1 | one fresh-context reviewer; frozen brief in `references/per-task-review.md` |
|
|
118
|
-
| 2 | the three refuters (`refuter-correctness` · `refuter-security` · `refuter-tests`) in parallel,
|
|
118
|
+
| 2 | the three refuters (`refuter-correctness` · `refuter-security` · `refuter-tests`) in parallel, using the dispatch names in `../review/SKILL.md` (Codex pairs each `agent_type` with a unique underscore `task_name`); then `review ledger panel <slug>/<task> --lenses correctness,security,tests` — the push gate checks it. Wait for every reviewer inside the turn; never end the turn to ask whether to continue |
|
|
119
119
|
|
|
120
120
|
Every reviewer gets the **spec**, the **diff as a file** (`scripts/review-package <BASE> <HEAD>`, BASE
|
|
121
121
|
= the task's *recorded* base sha, never `HEAD~1`), the **surrounding code** at that sha (not just the
|
package/skills/review/SKILL.md
CHANGED
|
@@ -139,6 +139,18 @@ fresh-context subagents** (`refuter-correctness` · `refuter-security` · `refut
|
|
|
139
139
|
told to *refute* readiness, not confirm it. Fresh context is the point: a reviewer who inherits the
|
|
140
140
|
implementer's context inherits its blind spots. The closing review is always at least tier 1.
|
|
141
141
|
|
|
142
|
+
On Codex, select the installed profile with `agent_type`. When the router asks for a
|
|
143
|
+
`task_name`, give the thread a separate name using lowercase letters, digits and underscores.
|
|
144
|
+
For a fresh review, use `fork_turns: "none"` when supported. For repeated calls, append a
|
|
145
|
+
unique suffix to the task name (for example, `finding_verifier_2`).
|
|
146
|
+
|
|
147
|
+
`agent_type` | `task_name`
|
|
148
|
+
--- | ---
|
|
149
|
+
`refuter-correctness` | `refuter_correctness`
|
|
150
|
+
`refuter-security` | `refuter_security`
|
|
151
|
+
`refuter-tests` | `refuter_tests`
|
|
152
|
+
`finding-verifier` | `finding_verifier`
|
|
153
|
+
|
|
142
154
|
**Give each refuter exactly four inputs — no more, no less.** The diff alone is not enough, and
|
|
143
155
|
that is not a detail: with only the diff, the one failure class no test suite can structurally
|
|
144
156
|
catch — *the change is correct and is not what the approved spec asked for* — is invisible to the
|
package/targets/agents.js
CHANGED
|
@@ -248,10 +248,12 @@ function renderMd(spec, model, agent, toolsFormat = spec.toolsFormat) {
|
|
|
248
248
|
return `${fm.join('\n')}${agent.body}\n`;
|
|
249
249
|
}
|
|
250
250
|
const renderJson = (model, agent) => `${JSON.stringify({ name: agent.name, description: agent.desc, ...(model ? { model } : {}), ...(agent.tools ? { tools: agent.tools } : {}), prompt: agent.body }, null, 2)}\n`;
|
|
251
|
-
function renderToml(model, agent) {
|
|
251
|
+
function renderToml(model, agent, legacyTools = false) {
|
|
252
252
|
const esc = (s) => s.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
253
253
|
// body as a TOML multiline LITERAL string ('''…''') — no escape processing.
|
|
254
|
-
|
|
254
|
+
// Codex tools config describes tool exposure, not RSC capabilities. Rebuild the
|
|
255
|
+
// former field only to recognize untouched profiles when their digest is missing.
|
|
256
|
+
const tools = legacyTools && agent.tools ? `tools = [${agent.tools.map((tool) => `"${tool}"`).join(', ')}]\n` : '';
|
|
255
257
|
return `name = "${agent.name}"\ndescription = "${esc(agent.desc)}"\n${model ? `model = "${model}"\n` : ''}${tools}developer_instructions = '''\n${agent.body}\n'''\n`;
|
|
256
258
|
}
|
|
257
259
|
|
|
@@ -307,6 +309,10 @@ function knownRenderings(target, cwd, agent) {
|
|
|
307
309
|
for (const tier of ['balanced', 'heavy']) {
|
|
308
310
|
out.add(renderAgent(target, spec, resolveModel(target, cwd, tier), agent));
|
|
309
311
|
out.add(renderAgent(target, spec, spec.model(tier), agent));
|
|
312
|
+
if (target === 'codex' && agent.tools) {
|
|
313
|
+
out.add(renderToml(resolveModel(target, cwd, tier), agent, true));
|
|
314
|
+
out.add(renderToml(spec.model(tier), agent, true));
|
|
315
|
+
}
|
|
310
316
|
if (target === 'claude') {
|
|
311
317
|
out.add(renderAgent(target, spec, resolveModel(target, cwd, tier), agent, 'list'));
|
|
312
318
|
out.add(renderAgent(target, spec, spec.model(tier), agent, 'list'));
|
package/targets/claude.js
CHANGED
|
@@ -316,15 +316,15 @@ export function wireHook(paths, sourceMd, policy = {}) {
|
|
|
316
316
|
settings.hooks.PreToolUse ||= [];
|
|
317
317
|
settings.hooks.PreToolUse = settings.hooks.PreToolUse.filter((e) => !hookWiringOf(e).includes('.rsc/danger-guard.'));
|
|
318
318
|
if (policy.dangerGuard !== false) {
|
|
319
|
-
// Danger guard: a PreToolUse
|
|
319
|
+
// Danger guard: a PreToolUse shell hook that DENIES irreversible foot-gun commands
|
|
320
320
|
// (rm -rf, git push --force, DROP/TRUNCATE, DELETE/UPDATE without WHERE, dd to /dev,
|
|
321
321
|
// curl|bash, …) when the user-profile says the user is NON-technical (default-safe
|
|
322
|
-
// when no profile exists yet
|
|
322
|
+
// when no profile exists yet). Technical profiles confirm the high-risk subset. Materialized +
|
|
323
323
|
// node-run (Windows-safe), idempotent, fail-open, opt-out via .rsc/.no-danger-guard.
|
|
324
324
|
const dgDest = join(paths.projectRoot, '.rsc', 'danger-guard.mjs');
|
|
325
325
|
copyFileSync(join(HERE, 'danger-guard.mjs'), dgDest);
|
|
326
326
|
const dgCmd = viaBootstrap('guard', at('.rsc', 'danger-guard.mjs'), `"${P}"`);
|
|
327
|
-
settings.hooks.PreToolUse.push({ matcher: 'Bash', hooks: [{ type: 'command', command: dgCmd }] });
|
|
327
|
+
settings.hooks.PreToolUse.push({ matcher: 'Bash|PowerShell', hooks: [{ type: 'command', command: dgCmd }] });
|
|
328
328
|
written.push(dgDest);
|
|
329
329
|
} else {
|
|
330
330
|
rmSync(join(paths.projectRoot, '.rsc', 'danger-guard.mjs'), { force: true });
|
package/targets/danger-guard.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// rsc Danger guard (claude). Wired by targets/claude.js onto PreToolUse (matcher Bash)
|
|
2
|
+
// rsc Danger guard (claude). Wired by targets/claude.js onto PreToolUse (matcher Bash|PowerShell)
|
|
3
3
|
// as `node ...` so it runs on every platform including Windows.
|
|
4
4
|
// argv[2] = absolute project root stdin = PreToolUse hook JSON
|
|
5
5
|
//
|
|
6
6
|
// For a NON-TECHNICAL user (per 02-DOCS/wiki/harness/user-profile.md → technical_level),
|
|
7
|
-
// it DENIES irreversible, foot-gun
|
|
7
|
+
// it DENIES irreversible, foot-gun shell commands and tells the agent to find a safer,
|
|
8
8
|
// scoped alternative. Default-safe: if there is no profile yet, the harness convention is
|
|
9
9
|
// "assume non-technical", so the guard is ON.
|
|
10
10
|
//
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
// Disable per project with .rsc/.no-danger-guard — but only when the USER explicitly asks
|
|
18
18
|
// for it (the deny message says so). Fail-open on any internal error (never brick a shell).
|
|
19
19
|
import { existsSync, readFileSync } from 'node:fs';
|
|
20
|
-
import {
|
|
20
|
+
import { homedir } from 'node:os';
|
|
21
|
+
import { join, win32 } from 'node:path';
|
|
21
22
|
|
|
22
23
|
const root = process.argv[2] || process.cwd();
|
|
23
24
|
|
|
@@ -68,12 +69,75 @@ function technicalLevel() {
|
|
|
68
69
|
}
|
|
69
70
|
const technical = technicalLevel() === 'technical';
|
|
70
71
|
|
|
71
|
-
//
|
|
72
|
+
// Claude sends the same command field for either shell.
|
|
72
73
|
let input = {};
|
|
73
74
|
try { input = JSON.parse(readFileSync(0, 'utf8') || '{}'); } catch { allow(); }
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
const tool = input.tool_name || input.toolName;
|
|
76
|
+
if (tool !== 'Bash' && tool !== 'PowerShell') allow();
|
|
77
|
+
const command = input.tool_input?.command || input.toolInput?.command || '';
|
|
78
|
+
if (typeof command !== 'string' || !command) allow();
|
|
79
|
+
|
|
80
|
+
// Read literal arguments of direct PowerShell commands. A backslash is a path separator in
|
|
81
|
+
// this shell. Quoted paths stay together and quoted text is never split at a semicolon.
|
|
82
|
+
function powerShellCommands(line) {
|
|
83
|
+
const commands = [];
|
|
84
|
+
let words = [];
|
|
85
|
+
let invoke = false;
|
|
86
|
+
for (const [token] of line.matchAll(/`\r?\n|#[^\r\n]*|'(?:''|[^'])*'|"(?:`[\s\S]|""|[^"`])*"|[;|&\r\n]|(?:`[\s\S]|[^\s;|&'"`])+/g)) {
|
|
87
|
+
if (/^`\r?\n$/.test(token) || token.startsWith('#')) continue;
|
|
88
|
+
if (/^[;|&\r\n]$/.test(token)) {
|
|
89
|
+
if (words.length) commands.push(words);
|
|
90
|
+
words = [];
|
|
91
|
+
invoke = token === '&';
|
|
92
|
+
} else {
|
|
93
|
+
words.push(invoke ? token.replace(/^(['"])(.*)\1$/, '$2') : token);
|
|
94
|
+
invoke = false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (words.length) commands.push(words);
|
|
98
|
+
return commands;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function protectedPowerShellPath(raw) {
|
|
102
|
+
const path = raw.replace(/^(['"])(.*)\1$/, '$2').replace(/\//g, '\\');
|
|
103
|
+
const target = win32.normalize(path).replace(/\\(?:\*)?$/, '').toLowerCase();
|
|
104
|
+
if (['.', '..', '*', '.git', '~'].includes(target)) return true;
|
|
105
|
+
if (!raw.startsWith("'") && ['$home', '$env:userprofile'].includes(target)) return true;
|
|
106
|
+
const absolute = win32.isAbsolute(path);
|
|
107
|
+
if (!absolute) return false;
|
|
108
|
+
const same = (value) => target === win32.normalize(value).replace(/\\$/, '').toLowerCase();
|
|
109
|
+
return same(win32.parse(path).root) || same(root) || same(homedir());
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Option values such as the include filter or the output variable are not deletion targets.
|
|
113
|
+
const PS_REMOVE_VALUE = /^-(?:filter|include|exclude|credential|erroraction|warningaction|informationaction|progressaction|errorvariable|warningvariable|informationvariable|outvariable|pipelinevariable|outbuffer)$/i;
|
|
114
|
+
function protectedRemoval(args) {
|
|
115
|
+
for (let i = 0; i < args.length; i++) {
|
|
116
|
+
const arg = args[i];
|
|
117
|
+
if (PS_REMOVE_VALUE.test(arg)) { i++; continue; }
|
|
118
|
+
if (!arg.startsWith('-') && protectedPowerShellPath(arg)) return true;
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const psCommands = tool === 'PowerShell' ? powerShellCommands(command) : null;
|
|
124
|
+
if (psCommands) {
|
|
125
|
+
for (const [name, ...args] of psCommands) {
|
|
126
|
+
if (!/^(?:Microsoft\.PowerShell\.Management\\)?(?:Remove-Item|rm|ri|del|erase|rd|rmdir)$/i.test(name)) continue;
|
|
127
|
+
const flag = (key) => args.some((arg) => arg.toLowerCase() === key || arg.toLowerCase() === key + ':$true');
|
|
128
|
+
if (!flag('-recurse') || !flag('-force') || flag('-whatif')) continue;
|
|
129
|
+
const why = 'recursively deletes files and folders with PowerShell';
|
|
130
|
+
if (!technical) deny(why);
|
|
131
|
+
if (protectedRemoval(args)) ask(why);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// PowerShell output commands and standalone string literals only display their text. Other
|
|
136
|
+
// segments still reach the shared rules, including external database clients and disk tools.
|
|
137
|
+
const cmd = psCommands
|
|
138
|
+
? psCommands.filter(([name]) => !/^(?:['"]|(?:echo|write-(?:output|host|verbose|warning|information|debug|error))$)/i.test(name))
|
|
139
|
+
.map((words) => words.join(' ')).join('; ')
|
|
140
|
+
: command;
|
|
77
141
|
|
|
78
142
|
// --- the dangerous-command list ---------------------------------------------
|
|
79
143
|
// High-signal, low-false-positive. Each rule: what it catches and the plain why.
|
|
@@ -138,11 +202,13 @@ const runSegments = () => {
|
|
|
138
202
|
|
|
139
203
|
// A git rule judges the segment that RUNS git, so `echo 'git reset --hard'` is a sentence, not a reset.
|
|
140
204
|
function gitSegment(re) {
|
|
205
|
+
if (psCommands) return psCommands.some(([name, ...args]) =>
|
|
206
|
+
/(?:^|[\\/])git(?:\.exe)?$/i.test(name) && re.test(['git', ...args].join(' ')));
|
|
141
207
|
return runSegments().some((segment) => runs(segment, 'git') && re.test(segment));
|
|
142
208
|
}
|
|
143
209
|
|
|
144
210
|
function isRmRecursiveForce() {
|
|
145
|
-
if (!/\brm\b/.test(cmd)) return false;
|
|
211
|
+
if (psCommands || !/\brm\b/.test(cmd)) return false;
|
|
146
212
|
for (const segment of runSegments()) {
|
|
147
213
|
if (!runsRm(segment)) continue;
|
|
148
214
|
const flags = rmFlagsIn(segment);
|