Skip to content

Commit 8904013

Browse files
committed
fix(opencode): keep the one-shot review out of the mode flag
`/ponytail review` was validated with `normalizePersistedMode`, so the argument was written to the long-lived `.ponytail-active` flag. Every later session then injected only the one-line `level: review` stub instead of the ruleset, until the user switched back to a real level. Review is a one-shot skill, never a persistent level (#377, #736), and every other host already rejects it as a command argument. Validate the command argument with `normalizeMode` (runtime levels only). Reading is unchanged: a stored `review` flag is still honored.
1 parent 552acd5 commit 8904013

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎.opencode/plugins/ponytail.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
2323
// The shared instruction builder is CommonJS; bridge to it from this ES module.
2424
const require = createRequire(import.meta.url);
2525
const { getPonytailInstructions } = require('../../hooks/ponytail-instructions');
26-
const { getDefaultMode, normalizePersistedMode } = require('../../hooks/ponytail-config');
26+
const { getDefaultMode, normalizeMode, normalizePersistedMode } = require('../../hooks/ponytail-config');
2727
const { parseCommandFile, parseSkillFile } = require('./ponytail-frontmatter.cjs');
2828

2929
// OpenCode has no flag-file convention of its own; keep mode beside its config.
@@ -55,7 +55,7 @@ function persistMode(args) {
5555
const wanted = String(args == null ? '' : args).trim();
5656
// Bare /ponytail switches ponytail on, or keeps the level when it already is (#639).
5757
if (!wanted && readMode() !== 'off') return;
58-
const mode = wanted ? normalizePersistedMode(wanted) : (getDefaultMode() === 'off' ? 'full' : getDefaultMode());
58+
const mode = wanted ? normalizeMode(wanted) : (getDefaultMode() === 'off' ? 'full' : getDefaultMode());
5959
if (!mode) return;
6060
writeMode(mode);
6161
console.log('ponytail ' + mode);

‎tests/opencode-plugin.test.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ test('V2 unsupported /ponytail arguments do not reset the current mode', async (
140140
const { added } = await setupV2();
141141
fs.writeFileSync(statePath, 'ultra');
142142
await added.commands.ponytail.execute({ sessionID: 's', prompt: { text: 'status' }, delivery: 'steer' });
143+
await added.commands.ponytail.execute({ sessionID: 's', prompt: { text: 'review' }, delivery: 'steer' });
143144
assert.equal(fs.readFileSync(statePath, 'utf8'), 'ultra');
144145
});
145146

@@ -216,6 +217,7 @@ test('unsupported /ponytail arguments do not reset the current mode', async () =
216217
const hooks = await loadPlugin.server({});
217218
fs.writeFileSync(statePath, 'ultra');
218219
await hooks['command.execute.before']({ command: 'ponytail', arguments: 'status', sessionID: 's' });
220+
await hooks['command.execute.before']({ command: 'ponytail', arguments: 'review', sessionID: 's' });
219221
assert.equal(fs.readFileSync(statePath, 'utf8'), 'ultra');
220222
});
221223

0 commit comments

Comments
 (0)