* feat: refine ruleset from a full-project field review
A reviewer ran ponytail across a 9-phase rewrite (protocol, PC app, simulator,
RPi daemon, ESP32 firmware) and flagged three gaps. All three land in SKILL.md
and propagate to AGENTS.md + the rule copies:
- Promote the one-runnable-check rule to a headline ("Lazy code without its
check is unfinished"), enforced as a check-rule-copies invariant.
- Hardware carve-out in "When NOT to be lazy": a real device is never the spec
ideal (clock drift, sensor offset), leave the calibration knob.
- Clarify the Output rule: explanation the user explicitly asked for is not
debt, only unrequested prose is.
Fallback instructions kept in sync. Rule-copy check + tests green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test: add a behavior gate proving the refinements actually fire
The refinements were verified as injected text, but injected != behavioral.
This adds a behavior eval that probes each refined rule on a task that should
trigger it:
- hardware -> does the output leave a calibration knob?
- explanation -> when a write-up is explicitly requested, is it given in full?
- onecheck -> is a runnable check left behind?
benchmarks/behavior.yaml runs the probes (baseline vs ponytail arm); the
grader benchmarks/behavior.js is proven by tests/behavior.test.js (8 cases,
RED/GREEN, no API key, runs in CI). Live-confirmed: the model under the
current ruleset passes all three gates, graded by the same grader.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
93 lines
4.4 KiB
JavaScript
93 lines
4.4 KiB
JavaScript
#!/usr/bin/env node
|
|
// Shared Ponytail instruction builder for Claude hooks and Pi extension.
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { DEFAULT_MODE, normalizeMode, normalizePersistedMode } = require('./ponytail-config');
|
|
|
|
const INDEPENDENT_MODES = new Set(['review']);
|
|
const SKILL_PATH = path.join(__dirname, '..', 'skills', 'ponytail', 'SKILL.md');
|
|
|
|
function filterSkillBodyForMode(body, mode) {
|
|
const effectiveMode = normalizeMode(mode) || DEFAULT_MODE;
|
|
const withoutFrontmatter = String(body || '').replace(/^---[\s\S]*?---\s*/, '');
|
|
|
|
// Only the intensity table rows and worked examples are mode-specific, and
|
|
// both are keyed by a mode name (lite/full/ultra). A bullet whose label is
|
|
// not a mode — e.g. "No unrequested abstractions: ..." — is a normal rule
|
|
// and must be kept verbatim.
|
|
return withoutFrontmatter
|
|
.split(/\r?\n/)
|
|
.filter((line) => {
|
|
const tableLabel = line.match(/^\|\s*\*\*(.+?)\*\*\s*\|/);
|
|
if (tableLabel) {
|
|
const labelMode = normalizeMode(tableLabel[1].trim());
|
|
if (labelMode) return labelMode === effectiveMode;
|
|
}
|
|
|
|
const exampleLabel = line.match(/^-\s*([^:]+):\s*/);
|
|
if (exampleLabel) {
|
|
const labelMode = normalizeMode(exampleLabel[1].trim());
|
|
if (labelMode) return labelMode === effectiveMode;
|
|
}
|
|
|
|
return true;
|
|
})
|
|
.join('\n');
|
|
}
|
|
|
|
function getFallbackInstructions(mode) {
|
|
return 'PONYTAIL MODE ACTIVE — level: ' + mode + '\n\n' +
|
|
'You are a lazy senior developer. Lazy means efficient, not careless. The best code is the code never written.\n\n' +
|
|
'## Persistence\n\n' +
|
|
'ACTIVE EVERY RESPONSE. No drift back to over-building. Still active if unsure. Off only: "stop ponytail" / "normal mode".\n\n' +
|
|
'Current level: **' + mode + '**. Switch: `/ponytail lite|full|ultra`.\n\n' +
|
|
'## The ladder\n\n' +
|
|
'Before any code, stop at the first rung that holds:\n' +
|
|
'1. Does this need to be built at all? (YAGNI)\n' +
|
|
'2. Does the standard library do this? Use it.\n' +
|
|
'3. Does a native platform feature cover it? Use it.\n' +
|
|
'4. Does an already-installed dependency solve it? Use it.\n' +
|
|
'5. Can this be one line? Make it one line.\n' +
|
|
'6. Only then: write the minimum code that works.\n\n' +
|
|
'## Rules\n\n' +
|
|
'No abstractions that were not requested. No avoidable dependencies. No boilerplate nobody asked for. ' +
|
|
'Deletion over addition. Boring over clever. Fewest files possible. ' +
|
|
'Ship the lazy version and question the complex request in the same response — never stall. ' +
|
|
'Between two same-size stdlib options, pick the one correct on edge cases. ' +
|
|
'Mark intentional simplifications with a `ponytail:` comment — a shortcut with a known ceiling names the ceiling and the upgrade path in the comment.\n\n' +
|
|
'## Output\n\n' +
|
|
'Code first. Then at most three short lines: what was skipped, when to add it. ' +
|
|
'If the explanation is longer than the code, delete the explanation. ' +
|
|
'Explanation the user explicitly asked for is not debt, give it in full.\n\n' +
|
|
'## When NOT to be lazy\n\n' +
|
|
'Never simplify away: input validation at trust boundaries, error handling that prevents data loss, ' +
|
|
'security measures, accessibility basics, the calibration real hardware needs (the platform is never the spec ideal), anything the user explicitly asked to keep. ' +
|
|
'Lazy code without its check is unfinished: non-trivial logic leaves ONE runnable check behind (assert-based demo/self-check or one small test file; no frameworks). Trivial one-liners need no test.\n\n' +
|
|
'## Boundaries\n\n' +
|
|
'Ponytail governs what you build, not how you talk. "stop ponytail" or "normal mode": revert. Level persists until changed or session end.';
|
|
}
|
|
|
|
function getPonytailInstructions(mode) {
|
|
const configuredMode = normalizePersistedMode(mode) || DEFAULT_MODE;
|
|
|
|
if (INDEPENDENT_MODES.has(configuredMode)) {
|
|
return 'PONYTAIL MODE ACTIVE — level: ' + configuredMode + '. Behavior defined by /ponytail-' + configuredMode + ' skill.';
|
|
}
|
|
|
|
const effectiveMode = normalizeMode(configuredMode) || DEFAULT_MODE;
|
|
|
|
try {
|
|
return 'PONYTAIL MODE ACTIVE — level: ' + effectiveMode + '\n\n' +
|
|
filterSkillBodyForMode(fs.readFileSync(SKILL_PATH, 'utf8'), effectiveMode);
|
|
} catch (e) {
|
|
return getFallbackInstructions(effectiveMode);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
filterSkillBodyForMode,
|
|
getFallbackInstructions,
|
|
getPonytailInstructions,
|
|
};
|