chill-agent 1.3.0 → 1.5.0
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/.agents/plugins/marketplace.json +39 -0
- package/.agents/rules/ponytail.md +30 -0
- package/.claude-plugin/marketplace.json +17 -0
- package/.claude-plugin/plugin.json +35 -0
- package/.cline-plugin/plugin.json +35 -0
- package/.clinerules/chill-agent +274 -0
- package/.clinerules/ponytail.md +30 -0
- package/.codex-plugin/plugin.json +35 -0
- package/.cursor/rules/chill-agent.mdc +278 -0
- package/.cursor/rules/ponytail.mdc +36 -0
- package/.cursor-plugin/plugin.json +35 -0
- package/.devin-plugin/plugin.json +35 -0
- package/.grok-plugin/marketplace.json +16 -0
- package/.grok-plugin/plugin.json +35 -0
- package/.kimi-plugin/plugin.json +35 -0
- package/.kiro/steering/ponytail.md +35 -0
- package/.omp-plugin/plugin.json +35 -0
- package/.openclaw/skills/chill-audit/SKILL.md +103 -0
- package/.openclaw/skills/chill-debt/SKILL.md +44 -0
- package/.openclaw/skills/chill-gain/SKILL.md +52 -0
- package/.openclaw/skills/chill-help/SKILL.md +76 -0
- package/.openclaw/skills/chill-review/SKILL.md +101 -0
- package/.openclaw/skills/chill-slop/SKILL.md +274 -0
- package/.openclaw/skills/chill-slop-code/SKILL.md +93 -0
- package/.openclaw/skills/chill-slop-copywriting/SKILL.md +80 -0
- package/.openclaw/skills/chill-slop-human/SKILL.md +73 -0
- package/.openclaw/skills/chill-slop-mobile/SKILL.md +95 -0
- package/.openclaw/skills/chill-slop-ui/SKILL.md +114 -0
- package/.openclaw/skills/ponytail/SKILL.md +52 -0
- package/.openclaw/skills/ponytail-audit/SKILL.md +103 -0
- package/.openclaw/skills/ponytail-debt/SKILL.md +44 -0
- package/.openclaw/skills/ponytail-gain/SKILL.md +52 -0
- package/.openclaw/skills/ponytail-help/SKILL.md +76 -0
- package/.openclaw/skills/ponytail-review/SKILL.md +101 -0
- package/.opencode/command/chill-audit.toml +2 -0
- package/.opencode/command/chill-debt.toml +2 -0
- package/.opencode/command/chill-gain.toml +2 -0
- package/.opencode/command/chill-help.toml +2 -0
- package/.opencode/command/chill-review.toml +2 -0
- package/.opencode/command/chill.toml +2 -0
- package/.opencode/command/ponytail-audit.md +5 -0
- package/.opencode/command/ponytail-debt.md +5 -0
- package/.opencode/command/ponytail-gain.md +5 -0
- package/.opencode/command/ponytail-help.md +5 -0
- package/.opencode/command/ponytail-review.md +5 -0
- package/.opencode/command/ponytail.md +5 -0
- package/.opencode/plugins/index.js +4 -0
- package/.opencode/plugins/ponytail-frontmatter.cjs +63 -0
- package/.opencode/plugins/ponytail.mjs +206 -0
- package/.qoder-plugin/plugin.json +35 -0
- package/.windsurf/rules/chill-agent.md +274 -0
- package/.windsurf/rules/ponytail.md +30 -0
- package/AGENTS.md +19 -0
- package/__init__.py +228 -0
- package/benchmarks/README.md +10 -0
- package/benchmarks/loc.js +21 -0
- package/benchmarks/results/token-efficiency.md +10 -0
- package/commands/ponytail-audit.toml +2 -0
- package/commands/ponytail-debt.toml +2 -0
- package/commands/ponytail-gain.toml +2 -0
- package/commands/ponytail-help.toml +2 -0
- package/commands/ponytail-review.toml +2 -0
- package/commands/ponytail.toml +2 -0
- package/examples/README.md +8 -0
- package/examples/anti-slop-copy.md +7 -0
- package/examples/anti-slop-ui.md +14 -0
- package/examples/csv-sum.md +27 -0
- package/examples/debounce.md +22 -0
- package/examples/deep-clone.md +14 -0
- package/examples/modal-dialog.md +19 -0
- package/hooks/chill-activate.js +19 -0
- package/hooks/chill-mode-tracker.js +23 -0
- package/hooks/chill-statusline.ps1 +10 -0
- package/hooks/chill-statusline.sh +9 -0
- package/hooks/claude-codex-hooks.json +11 -0
- package/hooks/copilot-hooks.json +11 -0
- package/hooks/cursor-hooks.json +17 -0
- package/hooks/ponytail-activate.js +201 -0
- package/hooks/ponytail-instructions.js +98 -0
- package/hooks/ponytail-mode-tracker.js +216 -0
- package/hooks/ponytail-runtime.js +182 -0
- package/hooks/ponytail-statusline.ps1 +24 -0
- package/hooks/ponytail-statusline.sh +18 -0
- package/hooks/qoder-hooks.json +11 -0
- package/i18n/README.es.md +17 -0
- package/i18n/README.id.md +25 -0
- package/i18n/README.ja.md +17 -0
- package/i18n/README.zh-CN.md +17 -0
- package/package.json +29 -3
- package/pi-extension/index.js +254 -0
- package/pi-extension/package.json +8 -0
- package/scripts/check-rule-copies.js +74 -0
- package/scripts/check-versions.js +77 -0
- package/scripts/cursor-hooks.js +145 -0
- package/scripts/generate-chillslop.mjs +42 -0
- package/scripts/generate-examples.mjs +149 -0
- package/scripts/generate-plugin-doors.mjs +108 -0
- package/scripts/sync-ponytail.mjs +65 -0
- package/scripts/uninstall.js +92 -0
- package/skills/ponytail/SKILL.md +52 -0
- package/skills/ponytail-audit/SKILL.md +103 -0
- package/skills/ponytail-debt/SKILL.md +44 -0
- package/skills/ponytail-gain/SKILL.md +52 -0
- package/skills/ponytail-help/SKILL.md +76 -0
- package/skills/ponytail-review/SKILL.md +101 -0
- package/tests/commands.test.js +94 -0
- package/tests/copilot-plugin.test.js +35 -0
- package/tests/correctness.test.js +245 -0
- package/tests/cursor-hooks.test.js +343 -0
- package/tests/gemini-extension.test.js +91 -0
- package/tests/grok-plugin.test.js +39 -0
- package/tests/hermes-plugin.test.js +403 -0
- package/tests/hooks.test.js +1005 -0
- package/tests/kimi-plugin.test.js +25 -0
- package/tests/loc.test.js +18 -0
- package/tests/manifests.test.js +29 -0
- package/tests/openclaw-skills.test.js +26 -0
- package/tests/opencode-plugin.test.js +340 -0
- package/tests/qoder-plugin.test.js +84 -0
- package/tests/rules.test.js +34 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ponytail-help
|
|
3
|
+
description: >
|
|
4
|
+
Quick reference for ponytail levels, skills and commands. One-shot display.
|
|
5
|
+
Use for /ponytail-help, "ponytail help", "how do I use ponytail".
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Ponytail Help
|
|
9
|
+
|
|
10
|
+
Display this reference card when invoked. One-shot, do NOT change mode,
|
|
11
|
+
write flag files, or persist anything.
|
|
12
|
+
|
|
13
|
+
## Levels
|
|
14
|
+
|
|
15
|
+
| Level | Trigger | What change |
|
|
16
|
+
|-------|---------|-------------|
|
|
17
|
+
| **Lite** | `/ponytail lite` | Build what was asked, name the smaller option in one line. |
|
|
18
|
+
| **Full** | `/ponytail` | The smallest complete change, a check where the logic needs one, and a reply that names what was skipped and any risk. Default. |
|
|
19
|
+
| **Ultra** | `/ponytail ultra` | Also questions the request and pushes back before building. |
|
|
20
|
+
|
|
21
|
+
Level sticks until changed or session end.
|
|
22
|
+
|
|
23
|
+
## Skills
|
|
24
|
+
|
|
25
|
+
| Skill | Trigger | What it does |
|
|
26
|
+
|-------|---------|--------------|
|
|
27
|
+
| **ponytail** | `/ponytail` | Lazy mode itself: least new code, clear replies that name skipped work and risks. |
|
|
28
|
+
| **ponytail-review** | `/ponytail-review` | Quality review of a diff: bugs, security, load, missing tests, speed, what to cut. Each finding says what goes wrong and how to fix it. |
|
|
29
|
+
| **ponytail-audit** | `/ponytail-audit` | The same quality review for the whole repo, ranked. |
|
|
30
|
+
| **ponytail-debt** | `/ponytail-debt` | Harvest `shortcut:` comments into a tracked ledger. |
|
|
31
|
+
| **ponytail-gain** | `/ponytail-gain` | Measured-impact scoreboard: less code, less cost, more speed. |
|
|
32
|
+
| **ponytail-help** | `/ponytail-help` | This card. |
|
|
33
|
+
|
|
34
|
+
In Codex CLI and the IDE extension, invoke skills with `$ponytail:ponytail`,
|
|
35
|
+
`$ponytail:ponytail-review`, or `$ponytail:ponytail-help`. Claude Code and OpenCode use the
|
|
36
|
+
slash-command forms above (OpenCode ships all six as slash commands).
|
|
37
|
+
|
|
38
|
+
## Deactivate
|
|
39
|
+
|
|
40
|
+
Say "stop ponytail" or "normal mode". Resume anytime with `/ponytail`.
|
|
41
|
+
`/ponytail off` also works.
|
|
42
|
+
|
|
43
|
+
## Band (Claude Code)
|
|
44
|
+
|
|
45
|
+
`/ponytail band` hides the band above the prompt, the same command brings it back.
|
|
46
|
+
`/ponytail band on` and `/ponytail band off` set it directly. The level stays.
|
|
47
|
+
`/ponytail band import` adds your past Claude Code sessions (cost, agent time, tokens) to the board.
|
|
48
|
+
|
|
49
|
+
## Configure Default Mode
|
|
50
|
+
|
|
51
|
+
Default mode = `full`, auto-active every session. Change it:
|
|
52
|
+
|
|
53
|
+
**Environment variable** (highest priority):
|
|
54
|
+
```bash
|
|
55
|
+
export PONYTAIL_DEFAULT_MODE=ultra
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Config file** (`~/.config/ponytail/config.json`, Windows: `%APPDATA%\ponytail\config.json`):
|
|
59
|
+
```json
|
|
60
|
+
{ "defaultMode": "lite" }
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Set `"off"` to disable auto-activation on session start, activate manually
|
|
64
|
+
with `/ponytail` when wanted.
|
|
65
|
+
|
|
66
|
+
Resolution: env var > config file > `full`.
|
|
67
|
+
|
|
68
|
+
## Update
|
|
69
|
+
|
|
70
|
+
Enable auto-update once: open `/plugin`, go to Marketplaces, pick ponytail, Enable auto-update. Claude Code then pulls new versions at startup (run `/reload-plugins` when it prompts). Manual refresh: `/plugin marketplace update ponytail` then `/reload-plugins`.
|
|
71
|
+
|
|
72
|
+
If `/plugin` is not recognized, your Claude Code is out of date. Update it (`npm install -g @anthropic-ai/claude-code@latest`, or `brew upgrade claude-code`) and restart. Other hosts use their own update flow.
|
|
73
|
+
|
|
74
|
+
## More
|
|
75
|
+
|
|
76
|
+
Full docs + examples: https://github.com/DietrichGebert/ponytail
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ponytail-review
|
|
3
|
+
description: >
|
|
4
|
+
Quality review of a change: is the logic right, is it safe, does it hold
|
|
5
|
+
under real load, is risky code tested, is it fast enough, and is every line
|
|
6
|
+
needed. Reads the connected code, not only the diff. Each finding is
|
|
7
|
+
explained in plain English. Use for "review this", "code review", "review
|
|
8
|
+
the last commit", "review my PR", "is this over-engineered", /ponytail-review.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Review a change like the senior developer who will be paged when it breaks.
|
|
12
|
+
Order of importance: correct, safe, holds under load, tested, fast, lean.
|
|
13
|
+
Lean still matters: every extra line must be read, tested and fixed later.
|
|
14
|
+
This is a report the user asked for, so give it in full.
|
|
15
|
+
|
|
16
|
+
## 1. Understand first
|
|
17
|
+
|
|
18
|
+
- Review what the user names: uncommitted or staged changes, a branch, a PR
|
|
19
|
+
link, or files. Nothing named: the uncommitted changes, or the last commit
|
|
20
|
+
if there are none.
|
|
21
|
+
- Read the diff, then the code it touches: callers of every changed function,
|
|
22
|
+
the functions it calls, the tests, the README.
|
|
23
|
+
- Trace the real flow: where data comes in, what is stored, what goes out.
|
|
24
|
+
- A change can break code it does not touch. When a signature, return value
|
|
25
|
+
or behavior changes, grep every caller.
|
|
26
|
+
- Find the expected load in the repo (README, deploy config): one person
|
|
27
|
+
running a script, or many users and processes at once. Judge scale against
|
|
28
|
+
that, and say which load you assumed.
|
|
29
|
+
|
|
30
|
+
## 2. Look for
|
|
31
|
+
|
|
32
|
+
1. **Bug:** wrong result, crash, missed edge case (empty, zero, last item,
|
|
33
|
+
rounding, time zones), a caller broken by the change, a fix applied in one
|
|
34
|
+
caller while the shared function stays broken.
|
|
35
|
+
2. **Risk:** security holes (injection, weak randomness, secrets, missing
|
|
36
|
+
checks on input from users), data loss (errors swallowed, writes in the
|
|
37
|
+
wrong order, no transaction).
|
|
38
|
+
3. **Scale:** fine for one user, wrong for many: check-then-write races, the
|
|
39
|
+
same work done by every process, memory or lists that only grow, a query
|
|
40
|
+
per item, O(n^2) on big input, per-process state that must be shared.
|
|
41
|
+
4. **Missing test:** risky new logic (a branch, a parser, money, security,
|
|
42
|
+
data writes, a bug fix) with no test that fails when it breaks. One good
|
|
43
|
+
test, not coverage.
|
|
44
|
+
5. **Speed:** big slowdowns are problems. Small wins (work repeated in a hot
|
|
45
|
+
loop) are suggestions; some software counts every millisecond.
|
|
46
|
+
6. **Lean:** code that should not exist or should be smaller.
|
|
47
|
+
- delete: dead code, unused options, speculative features
|
|
48
|
+
- reuse: the repo already has this helper (name the path)
|
|
49
|
+
- stdlib / native: the standard library or platform already does it; a
|
|
50
|
+
new dependency for a few lines
|
|
51
|
+
- yagni: abstraction with one implementation, config nobody sets
|
|
52
|
+
- merge: near-copies that must change together
|
|
53
|
+
- split: one function doing several unrelated jobs, so it is hard to read
|
|
54
|
+
or test. Split by job, never by line count, and never into helpers that
|
|
55
|
+
exist only to make a function shorter.
|
|
56
|
+
|
|
57
|
+
## 3. Check before you report
|
|
58
|
+
|
|
59
|
+
- Every finding needs a concrete case: "this input or situation leads to this
|
|
60
|
+
wrong result". No case, no finding.
|
|
61
|
+
- Re-read the lines and confirm: the caller exists, the value can really be
|
|
62
|
+
empty, the code really is unused.
|
|
63
|
+
- A shortcut marked with a `shortcut:` (or older `ponytail:`) comment that names its limit is a
|
|
64
|
+
decision, not a finding, unless the expected load already crosses it.
|
|
65
|
+
- Propose the smallest fix that works. Prefer fixes that delete code. Never
|
|
66
|
+
add layers, frameworks or config the problem does not need.
|
|
67
|
+
- No style taste, no "consider", no vague worries.
|
|
68
|
+
|
|
69
|
+
## 4. Output
|
|
70
|
+
|
|
71
|
+
Very simple English: short sentences, everyday words. Explain a technical
|
|
72
|
+
term the first time you use it. The reader may never have seen this code.
|
|
73
|
+
|
|
74
|
+
Start with `What this change does:` in two or three sentences.
|
|
75
|
+
|
|
76
|
+
Then the findings in three groups, skip empty groups:
|
|
77
|
+
- **Must fix:** bug, security, data loss, breaks at the expected load.
|
|
78
|
+
- **Should fix:** risky code without a test, real slowness, duplication, a
|
|
79
|
+
function that mixes jobs, code that should not exist.
|
|
80
|
+
- **Nice to have:** small speed-ups, shorter forms.
|
|
81
|
+
|
|
82
|
+
Number findings across all groups, so the user can say "fix 2 and 5".
|
|
83
|
+
Every finding has all four parts, each one or two short sentences:
|
|
84
|
+
|
|
85
|
+
2. **Orders land on the wrong day** (`billing/close_day.py:L40-52`)
|
|
86
|
+
- **What this is:** At midnight this job closes the day and bills all orders of that day.
|
|
87
|
+
- **Problem:** It takes "today" from the server clock, which runs in UTC. An order placed
|
|
88
|
+
at 00:30 in Berlin is billed on the day before.
|
|
89
|
+
- **Fix:** Compute the day once in the shop's time zone:
|
|
90
|
+
`datetime.now(ZoneInfo("Europe/Berlin")).date()`. One line, nothing else changes.
|
|
91
|
+
- **If we skip it:** Late orders show the wrong date, and accounting fixes them by hand.
|
|
92
|
+
|
|
93
|
+
End with:
|
|
94
|
+
- `Verdict: Ship.` or `Verdict: fix 1 and 3 first.`
|
|
95
|
+
- `Lean: -<N> lines possible.` when lean findings exist.
|
|
96
|
+
- `Not checked:` one line, if something mattered and you could not check it.
|
|
97
|
+
|
|
98
|
+
Nothing found: `What this change does:`, then `Looks good. Ship.` and one line
|
|
99
|
+
on what you checked.
|
|
100
|
+
|
|
101
|
+
Lists findings, changes no code.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Every ponytail command the pi extension registers must also ship as a
|
|
3
|
+
// file-based command for the hosts that need one: Claude Code (commands/*.toml,
|
|
4
|
+
// which Gemini CLI reuses) and OpenCode (.opencode/command/*.md). /ponytail-help
|
|
5
|
+
// was advertised in the README and the help card but missing both files; this
|
|
6
|
+
// guards that drift -- a registered command with no adapter file fails here.
|
|
7
|
+
|
|
8
|
+
const test = require('node:test');
|
|
9
|
+
const assert = require('node:assert/strict');
|
|
10
|
+
const { spawnSync } = require('child_process');
|
|
11
|
+
const fs = require('fs');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
|
|
14
|
+
const root = path.join(__dirname, '..');
|
|
15
|
+
|
|
16
|
+
// pi-extension registers the canonical command set.
|
|
17
|
+
const piSource = fs.readFileSync(path.join(root, 'pi-extension', 'index.js'), 'utf8');
|
|
18
|
+
const commands = [...piSource.matchAll(/registerCommand\(["']([\w-]+)["']/g)].map((m) => m[1]);
|
|
19
|
+
|
|
20
|
+
test('pi registers at least the base command', () => {
|
|
21
|
+
assert.ok(commands.includes('ponytail'), 'expected pi to register a ponytail command');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('every registered command ships a Claude commands/*.toml', () => {
|
|
25
|
+
for (const name of commands) {
|
|
26
|
+
assert.ok(
|
|
27
|
+
fs.existsSync(path.join(root, 'commands', `${name}.toml`)),
|
|
28
|
+
`missing commands/${name}.toml`,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('every registered command ships an OpenCode .opencode/command/*.md', () => {
|
|
34
|
+
for (const name of commands) {
|
|
35
|
+
assert.ok(
|
|
36
|
+
fs.existsSync(path.join(root, '.opencode', 'command', `${name}.md`)),
|
|
37
|
+
`missing .opencode/command/${name}.md`,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// /ponytail-debt documents one grep for the whole tree, shipped in four copies.
|
|
43
|
+
// It missed C-style /* ponytail: */ block comments (#810), so the ledger silently
|
|
44
|
+
// skipped every C/Java/CSS marker. Feed each shipped expression to real grep
|
|
45
|
+
// rather than restating it here: a copied regex only tests the copy.
|
|
46
|
+
const debtCopies = [
|
|
47
|
+
'skills/ponytail-debt/SKILL.md',
|
|
48
|
+
'.openclaw/skills/ponytail-debt/SKILL.md',
|
|
49
|
+
'commands/ponytail-debt.toml',
|
|
50
|
+
'.opencode/command/ponytail-debt.md',
|
|
51
|
+
];
|
|
52
|
+
const debtSamples = [
|
|
53
|
+
['# ponytail: hash marker', true],
|
|
54
|
+
['#ponytail: hash marker, no space', true],
|
|
55
|
+
['// ponytail: slash marker', true],
|
|
56
|
+
['//ponytail: slash marker, no space', true],
|
|
57
|
+
['/* ponytail: block marker, closed here */', true],
|
|
58
|
+
['/*ponytail: block marker, no space */', true],
|
|
59
|
+
['/* ponytail: block opener, closed some lines below', true],
|
|
60
|
+
['prose that merely mentions ponytail: markers stays out of the ledger', false],
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
test('every ponytail-debt copy greps #, // and /* markers but not prose', (t) => {
|
|
64
|
+
const input = debtSamples.map(([line]) => line).join('\n') + '\n';
|
|
65
|
+
const expected = debtSamples.flatMap(([line, hit], i) => (hit ? [`${i + 1}:${line}`] : []));
|
|
66
|
+
|
|
67
|
+
for (const rel of debtCopies) {
|
|
68
|
+
const documented = fs.readFileSync(path.join(root, rel), 'utf8').match(/git grep [^']*-nE '([^']+)'/);
|
|
69
|
+
assert.ok(documented, `${rel} no longer documents a git grep ... -nE '<pattern>'`);
|
|
70
|
+
|
|
71
|
+
const result = spawnSync('grep', ['-nE', documented[1]], { input, encoding: 'utf8', timeout: 5000 });
|
|
72
|
+
if (result.error) {
|
|
73
|
+
if (result.error.code === 'ENOENT') return t.skip('grep not available on this platform');
|
|
74
|
+
throw result.error;
|
|
75
|
+
}
|
|
76
|
+
assert.equal(result.status, 0, `grep failed for ${rel}: ${result.stderr}`);
|
|
77
|
+
assert.deepEqual(result.stdout.split('\n').filter(Boolean), expected, `${rel} misses or over-matches markers`);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// The full documented command must skip .git and whatever .gitignore ignores, in any stack (#948, #1100).
|
|
82
|
+
test('the ponytail-debt scan skips .git and ignored dirs like node_modules, dist, build and .next', (t) => {
|
|
83
|
+
const cmd = fs.readFileSync(path.join(root, 'skills/ponytail-debt/SKILL.md'), 'utf8').match(/`(git grep [^`]+)`/)[1];
|
|
84
|
+
const dir = fs.mkdtempSync(path.join(require('os').tmpdir(), 'ponytail-debt-'));
|
|
85
|
+
for (const sub of ['src', '.git', 'node_modules/pkg', 'dist', 'build', '.next']) {
|
|
86
|
+
fs.mkdirSync(path.join(dir, sub), { recursive: true });
|
|
87
|
+
fs.writeFileSync(path.join(dir, sub, 'a.js'), '// ponytail: marker\n');
|
|
88
|
+
}
|
|
89
|
+
fs.writeFileSync(path.join(dir, '.gitignore'), 'node_modules/\ndist/\nbuild/\n.next/\n');
|
|
90
|
+
const result = spawnSync('sh', ['-c', cmd], { cwd: dir, encoding: 'utf8', timeout: 5000 });
|
|
91
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
92
|
+
if (result.error || result.status === 127) return t.skip(`sh/git not available: ${result.error ? result.error.code : result.stderr}`);
|
|
93
|
+
assert.deepEqual(result.stdout.split('\n').filter(Boolean), ['src/a.js:1:// ponytail: marker']);
|
|
94
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Smoke test for the Copilot plugin adapter: keep command wiring minimal and
|
|
3
|
+
// ensure the debt command is part of the shared command surface.
|
|
4
|
+
|
|
5
|
+
const test = require('node:test');
|
|
6
|
+
const assert = require('node:assert/strict');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
const root = path.join(__dirname, '..');
|
|
11
|
+
const REQUIRED_COMMAND_FILES = [
|
|
12
|
+
'ponytail.toml',
|
|
13
|
+
'ponytail-review.toml',
|
|
14
|
+
'ponytail-audit.toml',
|
|
15
|
+
'ponytail-debt.toml',
|
|
16
|
+
'ponytail-gain.toml',
|
|
17
|
+
'ponytail-help.toml',
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
function readJSON(relPath) {
|
|
21
|
+
return JSON.parse(fs.readFileSync(path.join(root, relPath), 'utf8'));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
test('copilot plugin command directory includes ponytail-debt', () => {
|
|
25
|
+
const manifest = readJSON('.github/plugin/plugin.json');
|
|
26
|
+
assert.equal(manifest.name, 'ponytail');
|
|
27
|
+
assert.equal(manifest.commands, 'commands/');
|
|
28
|
+
|
|
29
|
+
for (const file of REQUIRED_COMMAND_FILES) {
|
|
30
|
+
assert.ok(
|
|
31
|
+
fs.existsSync(path.join(root, manifest.commands, file)),
|
|
32
|
+
`missing command file: ${manifest.commands}${file}`,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Unit test for the correctness benchmark assertion. Feeds known-good and
|
|
3
|
+
// known-bad LLM outputs through each task checker and asserts the expected
|
|
4
|
+
// pass/fail verdict. Runs without promptfoo — just node:test + the module.
|
|
5
|
+
|
|
6
|
+
const test = require('node:test');
|
|
7
|
+
const assert = require('node:assert/strict');
|
|
8
|
+
const correctness = require('../benchmarks/correctness');
|
|
9
|
+
|
|
10
|
+
// Helper: wrap code in a fenced block and call the assertion with task vars.
|
|
11
|
+
function check(task, lang, code) {
|
|
12
|
+
const output = '```' + lang + '\n' + code + '\n```';
|
|
13
|
+
return correctness(output, { vars: { task } });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// --- Email validator ---
|
|
17
|
+
|
|
18
|
+
test('email: correct one-liner passes', () => {
|
|
19
|
+
const result = check(
|
|
20
|
+
'Write me a Python function that validates email addresses.',
|
|
21
|
+
'python',
|
|
22
|
+
'def validate_email(email):\n return "@" in email and "." in email.split("@")[-1] and email.split("@")[0] != ""',
|
|
23
|
+
);
|
|
24
|
+
assert.equal(result.pass, true);
|
|
25
|
+
assert.equal(result.score, 1);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('email: always-true validator fails', () => {
|
|
29
|
+
const result = check(
|
|
30
|
+
'Write me a Python function that validates email addresses.',
|
|
31
|
+
'python',
|
|
32
|
+
'def validate_email(email):\n return True',
|
|
33
|
+
);
|
|
34
|
+
assert.equal(result.pass, false);
|
|
35
|
+
assert.equal(result.score, 0);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('email: no code block fails', () => {
|
|
39
|
+
const result = correctness('Here is my answer: just use regex.', {
|
|
40
|
+
vars: { task: 'Write me a Python function that validates email addresses.' },
|
|
41
|
+
});
|
|
42
|
+
assert.equal(result.pass, false);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('email: bare unfenced code is still scored (#65)', () => {
|
|
46
|
+
const result = correctness('import re\ndef validate_email(e):\n return bool(re.match(r"^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$", e))', {
|
|
47
|
+
vars: { task: 'Write me a Python function that validates email addresses.' },
|
|
48
|
+
});
|
|
49
|
+
assert.equal(result.pass, true);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// --- Debounce ---
|
|
53
|
+
|
|
54
|
+
test('debounce: correct implementation passes', () => {
|
|
55
|
+
const result = check(
|
|
56
|
+
'Add debounce to a search input in vanilla JavaScript.',
|
|
57
|
+
'javascript',
|
|
58
|
+
`function debounce(fn, delay) {
|
|
59
|
+
let timer;
|
|
60
|
+
return function(...args) {
|
|
61
|
+
clearTimeout(timer);
|
|
62
|
+
timer = setTimeout(() => fn.apply(this, args), delay);
|
|
63
|
+
};
|
|
64
|
+
}`,
|
|
65
|
+
);
|
|
66
|
+
assert.equal(result.pass, true);
|
|
67
|
+
assert.equal(result.score, 1);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('debounce: immediate-call implementation fails', () => {
|
|
71
|
+
const result = check(
|
|
72
|
+
'Add debounce to a search input in vanilla JavaScript.',
|
|
73
|
+
'javascript',
|
|
74
|
+
`function debounce(fn, delay) {
|
|
75
|
+
return function(...args) { fn.apply(this, args); };
|
|
76
|
+
}`,
|
|
77
|
+
);
|
|
78
|
+
assert.equal(result.pass, false);
|
|
79
|
+
assert.equal(result.score, 0);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('debounce: bare unfenced arrow function is still scored (#65)', () => {
|
|
83
|
+
const result = correctness('const debounce = (fn, delay) => {\n let t;\n return (...a) => { clearTimeout(t); t = setTimeout(() => fn(...a), delay); };\n};', {
|
|
84
|
+
vars: { task: 'Write a reusable debounce function in vanilla JavaScript: debounce(fn, delay).' },
|
|
85
|
+
});
|
|
86
|
+
assert.equal(result.pass, true);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// --- CSV sum ---
|
|
90
|
+
|
|
91
|
+
test('csv: correct pandas one-liner passes', () => {
|
|
92
|
+
const result = check(
|
|
93
|
+
"Write Python code that reads sales.csv and sums the 'amount' column.",
|
|
94
|
+
'python',
|
|
95
|
+
`import pandas as pd
|
|
96
|
+
df = pd.read_csv('sales.csv')
|
|
97
|
+
print(df['amount'].sum())`,
|
|
98
|
+
);
|
|
99
|
+
assert.equal(result.pass, true);
|
|
100
|
+
assert.equal(result.score, 1);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('csv: an exception in the code is reported, not swallowed (#919)', () => {
|
|
104
|
+
const result = check(
|
|
105
|
+
"Write Python code that reads sales.csv and sums the 'amount' column.",
|
|
106
|
+
'python',
|
|
107
|
+
`raise RuntimeError("boom")`,
|
|
108
|
+
);
|
|
109
|
+
assert.equal(result.pass, false);
|
|
110
|
+
assert.match(result.reason, /boom/);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('csv: code that prints wrong value fails', () => {
|
|
114
|
+
const result = check(
|
|
115
|
+
"Write Python code that reads sales.csv and sums the 'amount' column.",
|
|
116
|
+
'python',
|
|
117
|
+
`print(999)`,
|
|
118
|
+
);
|
|
119
|
+
assert.equal(result.pass, false);
|
|
120
|
+
assert.equal(result.score, 0);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('csv: value containing 351 as substring fails (e.g. 13510)', () => {
|
|
124
|
+
const result = check(
|
|
125
|
+
"Write Python code that reads sales.csv and sums the 'amount' column.",
|
|
126
|
+
'python',
|
|
127
|
+
`print(13510)`,
|
|
128
|
+
);
|
|
129
|
+
assert.equal(result.pass, false);
|
|
130
|
+
assert.equal(result.score, 0);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('csv: timeout can be raised for slow pandas startup', () => {
|
|
134
|
+
const previous = process.env.PONYTAIL_CORRECTNESS_TIMEOUT_MS;
|
|
135
|
+
try {
|
|
136
|
+
process.env.PONYTAIL_CORRECTNESS_TIMEOUT_MS = '1';
|
|
137
|
+
const timedOut = check(
|
|
138
|
+
"Write Python code that reads sales.csv and sums the 'amount' column.",
|
|
139
|
+
'python',
|
|
140
|
+
`import time
|
|
141
|
+
time.sleep(0.05)
|
|
142
|
+
print(351)`,
|
|
143
|
+
);
|
|
144
|
+
assert.equal(timedOut.pass, false);
|
|
145
|
+
assert.match(timedOut.reason, /ETIMEDOUT|timed out/i);
|
|
146
|
+
|
|
147
|
+
process.env.PONYTAIL_CORRECTNESS_TIMEOUT_MS = '1000';
|
|
148
|
+
const completed = check(
|
|
149
|
+
"Write Python code that reads sales.csv and sums the 'amount' column.",
|
|
150
|
+
'python',
|
|
151
|
+
`import time
|
|
152
|
+
time.sleep(0.05)
|
|
153
|
+
print(351)`,
|
|
154
|
+
);
|
|
155
|
+
assert.equal(completed.pass, true);
|
|
156
|
+
assert.equal(completed.score, 1);
|
|
157
|
+
} finally {
|
|
158
|
+
if (previous === undefined) delete process.env.PONYTAIL_CORRECTNESS_TIMEOUT_MS;
|
|
159
|
+
else process.env.PONYTAIL_CORRECTNESS_TIMEOUT_MS = previous;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// --- React countdown ---
|
|
164
|
+
|
|
165
|
+
test('countdown: valid React component passes', () => {
|
|
166
|
+
const result = check(
|
|
167
|
+
'Build me a countdown timer component in React.',
|
|
168
|
+
'javascript',
|
|
169
|
+
`import { useState, useEffect } from 'react';
|
|
170
|
+
export default function Countdown({ seconds }) {
|
|
171
|
+
const [count, setCount] = useState(seconds);
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
if (count <= 0) return;
|
|
174
|
+
const id = setInterval(() => setCount(prev => prev - 1), 1000);
|
|
175
|
+
return () => clearInterval(id);
|
|
176
|
+
}, [count]);
|
|
177
|
+
return <div>{count}</div>;
|
|
178
|
+
}`,
|
|
179
|
+
);
|
|
180
|
+
assert.equal(result.pass, true);
|
|
181
|
+
assert.equal(result.score, 1);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('countdown: static div without state fails', () => {
|
|
185
|
+
const result = check(
|
|
186
|
+
'Build me a countdown timer component in React.',
|
|
187
|
+
'javascript',
|
|
188
|
+
`export default function Countdown() { return <div>10</div>; }`,
|
|
189
|
+
);
|
|
190
|
+
assert.equal(result.pass, false);
|
|
191
|
+
assert.equal(result.score, 0);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// --- Rate limiter ---
|
|
195
|
+
|
|
196
|
+
test('ratelimit: FastAPI with limit logic passes', () => {
|
|
197
|
+
const result = check(
|
|
198
|
+
'Add rate limiting to my FastAPI endpoint so users can\'t spam it.',
|
|
199
|
+
'python',
|
|
200
|
+
`from fastapi import FastAPI, HTTPException
|
|
201
|
+
import time
|
|
202
|
+
|
|
203
|
+
app = FastAPI()
|
|
204
|
+
requests = {}
|
|
205
|
+
|
|
206
|
+
@app.get("/api")
|
|
207
|
+
def endpoint(user: str = "anon"):
|
|
208
|
+
now = time.time()
|
|
209
|
+
window = requests.get(user, [])
|
|
210
|
+
window = [t for t in window if now - t < 60]
|
|
211
|
+
if len(window) >= 10:
|
|
212
|
+
raise HTTPException(429, "Too Many Requests")
|
|
213
|
+
window.append(now)
|
|
214
|
+
requests[user] = window
|
|
215
|
+
return {"ok": True}`,
|
|
216
|
+
);
|
|
217
|
+
assert.equal(result.pass, true);
|
|
218
|
+
assert.equal(result.score, 1);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test('ratelimit: plain endpoint without limiting fails', () => {
|
|
222
|
+
const result = check(
|
|
223
|
+
'Add rate limiting to my FastAPI endpoint.',
|
|
224
|
+
'python',
|
|
225
|
+
`from fastapi import FastAPI
|
|
226
|
+
app = FastAPI()
|
|
227
|
+
|
|
228
|
+
@app.get("/api")
|
|
229
|
+
def endpoint():
|
|
230
|
+
return {"ok": True}`,
|
|
231
|
+
);
|
|
232
|
+
assert.equal(result.pass, false);
|
|
233
|
+
assert.equal(result.score, 0);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// --- Edge cases ---
|
|
237
|
+
|
|
238
|
+
test('unknown task is gracefully skipped', () => {
|
|
239
|
+
const result = correctness('```python\nprint("hi")\n```', {
|
|
240
|
+
vars: { task: 'Explain quantum computing.' },
|
|
241
|
+
});
|
|
242
|
+
assert.equal(result.pass, true);
|
|
243
|
+
assert.equal(result.score, 1);
|
|
244
|
+
assert.match(result.reason, /unknown task/i);
|
|
245
|
+
});
|