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,7 @@
|
|
|
1
|
+
# Anti-Slop Copywriting Transformation
|
|
2
|
+
|
|
3
|
+
## AI Slop Copy (Banned)
|
|
4
|
+
> *"Unleash the revolutionary power of our cutting-edge AI debugger! Seamlessly supercharge your development workflow with next-generation intelligence. Trusted by 10,000+ happy developers across the globe! ✨"*
|
|
5
|
+
|
|
6
|
+
## ChillAgent Clean Copy (Approved)
|
|
7
|
+
> *"ChillRewind is a zero-dependency local proxy running on `node:sqlite` in WAL mode. It prunes stale tool outputs over 1.5KB and halts agent runs when the same tool signature repeats 3 consecutive times."*
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Anti-Slop UI Transformation
|
|
2
|
+
|
|
3
|
+
## The Generic AI Default (Rejected as Slop)
|
|
4
|
+
- Background: `bg-gradient-to-br from-indigo-500 via-purple-500 to-pink-500`
|
|
5
|
+
- Card: `rounded-3xl shadow-2xl backdrop-blur-xl p-8 bg-white/10`
|
|
6
|
+
- Button: Pill-shaped glowing cyan bubble with rocket emoji `🚀`
|
|
7
|
+
- Heading: *"Unleash the Power of Next-Gen AI"*
|
|
8
|
+
|
|
9
|
+
## The ChillAgent Standard (Accepted High-Craft)
|
|
10
|
+
- Background: Deep obsidian carbon `#09090B`
|
|
11
|
+
- Card: Monochromatic surface `#111114` with 1px hairline border `#26262E` and 8px radius
|
|
12
|
+
- Numbers: Tabular monospace font `JetBrains Mono`
|
|
13
|
+
- Accent: Single semantic indicator (Emerald `#10B981` for active status)
|
|
14
|
+
- Heading: Direct domain statement: *"Deterministic time-travel debugger for AI agents."*
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# CSV Sum
|
|
2
|
+
|
|
3
|
+
**Task:** "Write Python code that reads sales.csv and sums the 'amount' column."
|
|
4
|
+
|
|
5
|
+
## Without ChillAgent (20 lines, 1 heavy dependency)
|
|
6
|
+
```python
|
|
7
|
+
import pandas as pd
|
|
8
|
+
|
|
9
|
+
# Read the CSV file into a DataFrame
|
|
10
|
+
df = pd.read_csv('sales.csv')
|
|
11
|
+
|
|
12
|
+
# Sum the amount column
|
|
13
|
+
total_amount = df['amount'].sum()
|
|
14
|
+
|
|
15
|
+
# Print the result
|
|
16
|
+
print(f"Total sales amount: {total_amount}")
|
|
17
|
+
```
|
|
18
|
+
*Bloat:* Forces 35MB `pandas` dependency for a simple column sum.
|
|
19
|
+
|
|
20
|
+
## With ChillAgent (4 lines, 0 dependencies)
|
|
21
|
+
```python
|
|
22
|
+
import csv
|
|
23
|
+
|
|
24
|
+
with open('sales.csv') as f:
|
|
25
|
+
print(sum(float(row['amount']) for row in csv.DictReader(f)))
|
|
26
|
+
```
|
|
27
|
+
*Result:* 0 dependencies, instant execution, standard library only.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Debounce Utility
|
|
2
|
+
|
|
3
|
+
**Task:** "Write a debounce function in TypeScript."
|
|
4
|
+
|
|
5
|
+
## Without ChillAgent (25 lines + lodash dependency)
|
|
6
|
+
```typescript
|
|
7
|
+
import debounce from 'lodash/debounce';
|
|
8
|
+
export const debouncedSearch = debounce((query: string) => {
|
|
9
|
+
api.search(query);
|
|
10
|
+
}, 300);
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## With ChillAgent (6 lines, standard native timer)
|
|
14
|
+
```typescript
|
|
15
|
+
export function debounce<T extends (...args: any[]) => void>(fn: T, ms = 300) {
|
|
16
|
+
let timer: ReturnType<typeof setTimeout>;
|
|
17
|
+
return (...args: Parameters<T>) => {
|
|
18
|
+
clearTimeout(timer);
|
|
19
|
+
timer = setTimeout(() => fn(...args), ms);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Deep Clone
|
|
2
|
+
|
|
3
|
+
**Task:** "Deep clone a JavaScript object in Node 18+."
|
|
4
|
+
|
|
5
|
+
## Without ChillAgent
|
|
6
|
+
```javascript
|
|
7
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
8
|
+
const copy = cloneDeep(source);
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## With ChillAgent (1 line native standard library)
|
|
12
|
+
```javascript
|
|
13
|
+
const copy = structuredClone(source);
|
|
14
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Modal Dialog Component
|
|
2
|
+
|
|
3
|
+
**Task:** "Create an accessible modal dialog in vanilla HTML/CSS/JS."
|
|
4
|
+
|
|
5
|
+
## Without ChillAgent (120 lines, custom backdrop, custom focus trap, custom scroll locks)
|
|
6
|
+
Manual z-index soup, forgotten Escape key handlers, broken keyboard traps.
|
|
7
|
+
|
|
8
|
+
## With ChillAgent (12 lines using native HTML <dialog>)
|
|
9
|
+
```html
|
|
10
|
+
<dialog id="confirmModal" style="border: 1px solid #26262E; border-radius: 8px; background: #111114; color: #F4F4F6; padding: 20px;">
|
|
11
|
+
<form method="dialog">
|
|
12
|
+
<p>Confirm irreversible session fork?</p>
|
|
13
|
+
<button value="cancel">Cancel</button>
|
|
14
|
+
<button value="confirm" style="background: #818CF8; color: #09090B;">Fork</button>
|
|
15
|
+
</form>
|
|
16
|
+
</dialog>
|
|
17
|
+
<button onclick="document.getElementById('confirmModal').showModal()">Open</button>
|
|
18
|
+
```
|
|
19
|
+
*Features:* Built-in backdrop, native Escape key closing, native focus trapping, zero external libraries.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// chill-agent SessionStart activation hook
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
|
|
7
|
+
const home = os.homedir();
|
|
8
|
+
const flagPath = path.join(home, '.chill-agent-active');
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
fs.writeFileSync(flagPath, JSON.stringify({
|
|
12
|
+
active: true,
|
|
13
|
+
mode: 'full',
|
|
14
|
+
timestamp: Date.now()
|
|
15
|
+
}), 'utf8');
|
|
16
|
+
|
|
17
|
+
// Emit compact active notice
|
|
18
|
+
process.stdout.write('[chill-agent active: full (ponytail + anti-slop dual core)]\n');
|
|
19
|
+
} catch {}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// chill-agent Mode Tracker Hook: detects /chill [lite|full|ultra|off]
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
|
|
7
|
+
const home = os.homedir();
|
|
8
|
+
const flagPath = path.join(home, '.chill-agent-active');
|
|
9
|
+
|
|
10
|
+
const prompt = process.argv.slice(2).join(' ');
|
|
11
|
+
const match = prompt.match(/\/chill\s+(lite|full|ultra|off)/i);
|
|
12
|
+
|
|
13
|
+
if (match) {
|
|
14
|
+
const newMode = match[1].toLowerCase();
|
|
15
|
+
try {
|
|
16
|
+
fs.writeFileSync(flagPath, JSON.stringify({
|
|
17
|
+
active: newMode !== 'off',
|
|
18
|
+
mode: newMode,
|
|
19
|
+
timestamp: Date.now()
|
|
20
|
+
}), 'utf8');
|
|
21
|
+
process.stderr.write(`[chill-agent mode switched to: ${newMode}]\n`);
|
|
22
|
+
} catch {}
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# chill-agent PowerShell statusline indicator
|
|
2
|
+
$flag = Join-Path $HOME ".chill-agent-active"
|
|
3
|
+
if (Test-Path $flag) {
|
|
4
|
+
try {
|
|
5
|
+
$data = Get-Content $flag | ConvertFrom-Json
|
|
6
|
+
if ($data.active) {
|
|
7
|
+
Write-Host " ◷ chill:$($data.mode) " -ForegroundColor Black -BackgroundColor Cyan -NoNewline
|
|
8
|
+
}
|
|
9
|
+
} catch {}
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# chill-agent bash/zsh statusline indicator
|
|
3
|
+
FLAG="$HOME/.chill-agent-active"
|
|
4
|
+
if [ -f "$FLAG" ]; then
|
|
5
|
+
MODE=$(grep -o '"mode":"[^"]*' "$FLAG" | cut -d'"' -f4)
|
|
6
|
+
if [ -n "$MODE" ] && [ "$MODE" != "off" ]; then
|
|
7
|
+
printf "\033[48;5;81;30m ◷ chill:%s \033[0m" "$MODE"
|
|
8
|
+
fi
|
|
9
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"hooks": {
|
|
4
|
+
"sessionStart": [
|
|
5
|
+
{
|
|
6
|
+
"command": "node \"./hooks/chill-activate.js\"",
|
|
7
|
+
"timeout": 15
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"beforeSubmitPrompt": [
|
|
11
|
+
{
|
|
12
|
+
"command": "node \"./hooks/chill-mode-tracker.js\"",
|
|
13
|
+
"timeout": 15
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ponytail — Claude Code SessionStart activation hook (also Codex, Copilot,
|
|
3
|
+
// Grok, CodeBuddy and Cursor sessionStart)
|
|
4
|
+
//
|
|
5
|
+
// Runs on every session start:
|
|
6
|
+
// 1. Writes flag file at $CLAUDE_CONFIG_DIR/.ponytail-active (defaults to ~/.claude; statusline reads this)
|
|
7
|
+
// 2. Emits ponytail ruleset as hidden SessionStart context
|
|
8
|
+
// 3. Detects missing statusline config and emits setup nudge
|
|
9
|
+
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const { execFileSync } = require('child_process');
|
|
13
|
+
const { getDefaultMode, getClaudeDir, isShellSafe } = require('./ponytail-config');
|
|
14
|
+
const { getPonytailInstructions } = require('./ponytail-instructions');
|
|
15
|
+
const {
|
|
16
|
+
clearMode,
|
|
17
|
+
cursorRuleNotice,
|
|
18
|
+
cursorRulePath,
|
|
19
|
+
isCodeBuddy,
|
|
20
|
+
isCodex,
|
|
21
|
+
isCopilot,
|
|
22
|
+
isCursor,
|
|
23
|
+
readMode,
|
|
24
|
+
setMode,
|
|
25
|
+
writeHookOutput,
|
|
26
|
+
} = require('./ponytail-runtime');
|
|
27
|
+
|
|
28
|
+
const claudeDir = getClaudeDir();
|
|
29
|
+
const settingsPath = path.join(claudeDir, 'settings.json');
|
|
30
|
+
|
|
31
|
+
function activate(mode) {
|
|
32
|
+
// "off" mode — skip activation entirely, don't write flag or emit rules
|
|
33
|
+
if (mode === 'off') {
|
|
34
|
+
clearMode();
|
|
35
|
+
process.exit(0);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Cursor with the always-on rule in the workspace: the rule already carries the
|
|
39
|
+
// ruleset and would contradict any other level, so leave the flag alone and
|
|
40
|
+
// hand the model a one-line notice instead of a second copy (#817).
|
|
41
|
+
if (isCursor) {
|
|
42
|
+
const rule = cursorRulePath();
|
|
43
|
+
if (rule) {
|
|
44
|
+
try {
|
|
45
|
+
writeHookOutput('SessionStart', mode, cursorRuleNotice(rule));
|
|
46
|
+
} catch (e) {
|
|
47
|
+
// Silent fail — stdout closed/EPIPE at hook exit must not surface as a hook failure
|
|
48
|
+
}
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// 1. Write flag file
|
|
54
|
+
try {
|
|
55
|
+
setMode(mode);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
// Silent fail -- flag is best-effort, don't block the hook
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 2. Emit the ponytail ruleset, filtered to the active intensity level.
|
|
61
|
+
let output = getPonytailInstructions(mode);
|
|
62
|
+
|
|
63
|
+
// 2b. Codebase map: what already exists, so "reuse first" costs no search. Fail open: the map
|
|
64
|
+
// gets 3 s, well inside the 15 s hook limit, so a stalled map never costs the rules (#1079, #1157).
|
|
65
|
+
// shortcut: a map slower than 3 s is still dropped; a cached per-repo map would lift that if it shows up.
|
|
66
|
+
if (mode !== 'review' && process.env.PONYTAIL_MAP !== '0') try {
|
|
67
|
+
const map = execFileSync(process.execPath, [path.join(__dirname, 'ponytail-map.js')], {
|
|
68
|
+
encoding: 'utf8', timeout: 3000, maxBuffer: 64 * 1024, stdio: ['ignore', 'pipe', 'ignore'],
|
|
69
|
+
}).trimEnd();
|
|
70
|
+
if (map) output += '\n\n' + map;
|
|
71
|
+
} catch (e) { /* no map */ }
|
|
72
|
+
|
|
73
|
+
// 3. Detect missing statusline config — nudge Claude to help set it up
|
|
74
|
+
if (!isCodex && !isCopilot && !isCursor && !isCodeBuddy) try {
|
|
75
|
+
const isWindows = process.platform === 'win32';
|
|
76
|
+
let statusCommand = null;
|
|
77
|
+
if (fs.existsSync(settingsPath)) {
|
|
78
|
+
// Strip UTF-8 BOM some editors prepend on Windows (breaks JSON.parse)
|
|
79
|
+
const raw = fs.readFileSync(settingsPath, 'utf8').replace(/^\uFEFF/, '');
|
|
80
|
+
const settings = JSON.parse(raw);
|
|
81
|
+
if (settings.statusLine) {
|
|
82
|
+
statusCommand = String(settings.statusLine.command || '');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// A statusLine already set up before #1032 can still run a script from a
|
|
87
|
+
// plugin version that has since been deleted. Only absolute paths are checked,
|
|
88
|
+
// so ~ or $HOME forms are never mistaken for missing files.
|
|
89
|
+
const ref = statusCommand &&
|
|
90
|
+
statusCommand.match(/"([^"]*ponytail-statusline\.(?:sh|ps1))"|(\S*ponytail-statusline\.(?:sh|ps1))/);
|
|
91
|
+
const refPath = ref ? (ref[1] || ref[2]) : null;
|
|
92
|
+
// isShellSafe keeps quotes, newlines and shell metacharacters from
|
|
93
|
+
// settings.json out of the model context.
|
|
94
|
+
// On Windows only drive-letter or UNC paths count: a Git Bash path such as
|
|
95
|
+
// /c/Users/... is absolute to Node but does not resolve, so it would be
|
|
96
|
+
// flagged as broken while it works.
|
|
97
|
+
const checkable = refPath && isShellSafe(refPath) && path.isAbsolute(refPath) &&
|
|
98
|
+
(!isWindows || /^([A-Za-z]:[\\/]|\\\\)/.test(refPath));
|
|
99
|
+
const stalePath = checkable && !fs.existsSync(refPath) ? refPath : null;
|
|
100
|
+
|
|
101
|
+
// The plugin root is a versioned cache dir (.../ponytail/4.12.0/) that Claude
|
|
102
|
+
// Code deletes on update, so a statusLine pointing into it goes blank after the
|
|
103
|
+
// next update (#1032). Point it at a copy in the config dir instead. A statusLine
|
|
104
|
+
// that already runs ponytail keeps its script type, so its copy stays fresh.
|
|
105
|
+
const usePs1 = refPath ? refPath.endsWith('.ps1') : isWindows;
|
|
106
|
+
const scriptName = usePs1 ? 'ponytail-statusline.ps1' : 'ponytail-statusline.sh';
|
|
107
|
+
const scriptPath = path.join(claudeDir, scriptName);
|
|
108
|
+
|
|
109
|
+
// Nudge at most once — the flag file marks that the user has already seen
|
|
110
|
+
// (and implicitly declined) the statusline setup offer. Repeating it every
|
|
111
|
+
// session start turns a helpful hint into a nag. A broken path is nudged once
|
|
112
|
+
// per path: the flag records it.
|
|
113
|
+
const nudgeFlagPath = path.join(claudeDir, '.ponytail-statusline-nudged');
|
|
114
|
+
let nudged = null;
|
|
115
|
+
try { nudged = fs.readFileSync(nudgeFlagPath, 'utf8'); } catch (e) { /* not nudged yet */ }
|
|
116
|
+
const nudge = stalePath ? nudged !== stalePath : statusCommand === null && nudged === null;
|
|
117
|
+
|
|
118
|
+
// Refresh the copy every session so script fixes ship with plugin updates.
|
|
119
|
+
// Copy to a new temp file, then rename: the rename replaces a symlink at
|
|
120
|
+
// scriptPath instead of writing through it, and a concurrent session never
|
|
121
|
+
// runs a half-written script.
|
|
122
|
+
if (nudge || fs.existsSync(scriptPath)) {
|
|
123
|
+
const tmpPath = scriptPath + '.' + process.pid + '.tmp';
|
|
124
|
+
try {
|
|
125
|
+
fs.copyFileSync(path.join(__dirname, scriptName), tmpPath, fs.constants.COPYFILE_EXCL);
|
|
126
|
+
fs.chmodSync(tmpPath, 0o644);
|
|
127
|
+
fs.renameSync(tmpPath, scriptPath);
|
|
128
|
+
} finally {
|
|
129
|
+
try { fs.unlinkSync(tmpPath); } catch (e) { /* renamed */ }
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (nudge) {
|
|
134
|
+
try { fs.writeFileSync(nudgeFlagPath, stalePath || ''); } catch (e) { /* best-effort */ }
|
|
135
|
+
if (stalePath) {
|
|
136
|
+
output += "\n\n" +
|
|
137
|
+
"STATUSLINE BROKEN: The statusLine in " + settingsPath + " runs " + stalePath +
|
|
138
|
+
", which no longer exists (the ponytail plugin was updated and its old version removed), " +
|
|
139
|
+
"so the ponytail badge is blank. Replace that path with " + scriptPath + ", which survives updates, " +
|
|
140
|
+
"quoting it for your shell. Keep the rest of the command. " +
|
|
141
|
+
"Proactively offer to fix this for the user on first interaction.";
|
|
142
|
+
} else if (isShellSafe(scriptPath)) {
|
|
143
|
+
const command = isWindows
|
|
144
|
+
? `powershell -ExecutionPolicy Bypass -File "${scriptPath}"`
|
|
145
|
+
: `bash "${scriptPath}"`;
|
|
146
|
+
const statusLineSnippet =
|
|
147
|
+
'"statusLine": { "type": "command", "command": ' + JSON.stringify(command) + ' }';
|
|
148
|
+
output += "\n\n" +
|
|
149
|
+
"STATUSLINE SETUP NEEDED: The ponytail plugin includes a statusline badge showing active mode " +
|
|
150
|
+
"(e.g. [PONYTAIL], [PONYTAIL:ULTRA]). It is not configured yet. " +
|
|
151
|
+
"To enable, add this to " + settingsPath + ": " +
|
|
152
|
+
statusLineSnippet + " " +
|
|
153
|
+
"Proactively offer to set this up for the user on first interaction.";
|
|
154
|
+
} else {
|
|
155
|
+
// ponytail: config dir path has shell metacharacters; don't embed it in a
|
|
156
|
+
// command snippet; have the agent wire it up by hand instead.
|
|
157
|
+
output += "\n\n" +
|
|
158
|
+
"STATUSLINE SETUP NEEDED: The ponytail plugin includes a statusline badge showing active mode. " +
|
|
159
|
+
"Its path contains characters unsafe to embed in a shell command, so configure it manually: " +
|
|
160
|
+
"add a statusLine command of type \"command\" that runs " + scriptName +
|
|
161
|
+
" from " + claudeDir + " to " + settingsPath + ", quoting/escaping the path for your shell. " +
|
|
162
|
+
"Proactively offer to set this up for the user on first interaction.";
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
} catch (e) {
|
|
166
|
+
// Silent fail — don't block session start over statusline detection
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
writeHookOutput('SessionStart', mode, output);
|
|
171
|
+
} catch (e) {
|
|
172
|
+
// Silent fail — stdout closed/EPIPE at hook exit must not surface as a hook failure
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Compaction re-runs SessionStart inside the same conversation, so it keeps the
|
|
177
|
+
// live level (or stays off after "stop ponytail") instead of resetting to the
|
|
178
|
+
// default. Claude Code and Codex pass the trigger as `source` on stdin; reading
|
|
179
|
+
// it there keeps the hook entry, and the trust Codex gave it, unchanged.
|
|
180
|
+
let input = '';
|
|
181
|
+
let done = false;
|
|
182
|
+
|
|
183
|
+
function finish() {
|
|
184
|
+
if (done) return;
|
|
185
|
+
done = true;
|
|
186
|
+
let source = '';
|
|
187
|
+
try {
|
|
188
|
+
// Strip UTF-8 BOM some shells prepend when piping (breaks JSON.parse)
|
|
189
|
+
source = JSON.parse(input.replace(/^\uFEFF/, '')).source;
|
|
190
|
+
} catch (e) {
|
|
191
|
+
// No payload, or an unparseable one: treat it as a fresh session
|
|
192
|
+
}
|
|
193
|
+
activate(source === 'compact' ? (readMode() || 'off') : getDefaultMode());
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
process.stdin.on('data', chunk => { input += chunk; });
|
|
197
|
+
// Never hang the session start (#443, #790): like the mode tracker, recover on a
|
|
198
|
+
// stdin error or after a short ref'd fallback, and start at the default level.
|
|
199
|
+
process.stdin.on('end', () => { finish(); process.exit(0); });
|
|
200
|
+
process.stdin.on('error', () => { finish(); process.exit(0); });
|
|
201
|
+
setTimeout(() => { finish(); process.exit(0); }, 1000);
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Shared Ponytail instruction builder for Claude hooks and Pi extension.
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const { DEFAULT_MODE, normalizeMode, normalizePersistedMode } = require('./ponytail-config');
|
|
7
|
+
|
|
8
|
+
const INDEPENDENT_MODES = new Set(['review']);
|
|
9
|
+
const SKILL_PATH = path.join(__dirname, '..', 'skills', 'ponytail', 'SKILL.md');
|
|
10
|
+
|
|
11
|
+
function filterSkillBodyForMode(body, mode) {
|
|
12
|
+
const effectiveMode = normalizeMode(mode) || DEFAULT_MODE;
|
|
13
|
+
const withoutFrontmatter = String(body || '').replace(/^---[\s\S]*?---\s*/, '');
|
|
14
|
+
|
|
15
|
+
// Only the intensity table rows and worked examples are mode-specific, and
|
|
16
|
+
// both are keyed by a mode name (lite/full/ultra). A bullet whose label is
|
|
17
|
+
// not a mode — e.g. "No unrequested abstractions: ..." — is a normal rule
|
|
18
|
+
// and must be kept verbatim.
|
|
19
|
+
return withoutFrontmatter
|
|
20
|
+
.split(/\r?\n/)
|
|
21
|
+
.filter((line) => {
|
|
22
|
+
const tableLabel = line.match(/^\|\s*\*\*(.+?)\*\*\s*\|/);
|
|
23
|
+
if (tableLabel) {
|
|
24
|
+
const labelMode = normalizeMode(tableLabel[1].trim());
|
|
25
|
+
if (labelMode) return labelMode === effectiveMode;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Require a quoted value: every worked example is `- lite: "..."`. Without
|
|
29
|
+
// this, an ordinary rule bullet that happens to start with a mode word
|
|
30
|
+
// (e.g. "- Full: ...") is silently dropped in every other mode — it looks
|
|
31
|
+
// like a worked example but is really prose meant to survive verbatim.
|
|
32
|
+
const exampleLabel = line.match(/^-\s*([^:]+):\s*"/);
|
|
33
|
+
if (exampleLabel) {
|
|
34
|
+
const labelMode = normalizeMode(exampleLabel[1].trim());
|
|
35
|
+
if (labelMode) return labelMode === effectiveMode;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return true;
|
|
39
|
+
})
|
|
40
|
+
.join('\n');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getFallbackInstructions(mode) {
|
|
44
|
+
// Used only when SKILL.md cannot be read: the same rules as AGENTS.md.
|
|
45
|
+
return 'PONYTAIL MODE ACTIVE — level: ' + mode + '\n\n' +
|
|
46
|
+
'Switch level: `/ponytail lite|full|ultra`. Off: "stop ponytail" or "normal mode".\n\n' +
|
|
47
|
+
"You are a lazy senior developer. The best code is the code never written. You solve the whole problem with the least new code. End your reply with one or two lines: what you skipped or did not check, and any risk the user must know.\n" +
|
|
48
|
+
"\n" +
|
|
49
|
+
"## Before you write\n" +
|
|
50
|
+
"\n" +
|
|
51
|
+
"Read the task and the code it touches. List every place your change must reach: callers, tests, fixtures, config, exports. Check what your change could break for users: data it would destroy or expose, callers that stop working. That is scope. Extra features are not.\n" +
|
|
52
|
+
"\n" +
|
|
53
|
+
"## The smallest complete change\n" +
|
|
54
|
+
"\n" +
|
|
55
|
+
"Take the first option that fully works:\n" +
|
|
56
|
+
"\n" +
|
|
57
|
+
"1. Does it need to exist? Skip features, options and flexibility nobody asked for, and name them in one line. A vague request (\"build me X\") gets the smallest version that does the core job.\n" +
|
|
58
|
+
"2. Already in this codebase (a helper, component, service, pattern)? Use it the way the surrounding code does.\n" +
|
|
59
|
+
"3. Standard library or a platform feature? Use it, unless the project has its own. A house component beats a native widget.\n" +
|
|
60
|
+
"4. An installed dependency? Use it. Never add a dependency for a few lines.\n" +
|
|
61
|
+
"5. Can it be one line a reader gets at a glance? One line.\n" +
|
|
62
|
+
"6. Otherwise: the minimum code that works.\n" +
|
|
63
|
+
"\n" +
|
|
64
|
+
"- Be lazy about the solution, never about the change itself: finish every part the task needs, including the callers, tests and fixtures your change breaks.\n" +
|
|
65
|
+
"- No abstraction, wrapper, type conversion, option, config, boilerplate or \"for later\" code nobody asked for. Keep values in the form the platform already gives you. Deletion beats addition. Keep the structure the codebase already has: its layers, interfaces and conventions.\n" +
|
|
66
|
+
"- The shortest working diff wins, once you know everything it must touch. A one-liner that needs decoding is not short.\n" +
|
|
67
|
+
"- Comment only the why the code cannot show, in one line.\n" +
|
|
68
|
+
"- Bug fix: before you edit, grep every caller of the function you touch, then fix the root cause once in the shared code.\n" +
|
|
69
|
+
"- Code you move or merge keeps its error handling and validation.\n" +
|
|
70
|
+
"- Between options of equal size, take the one that is correct on edge cases.\n" +
|
|
71
|
+
"- Lazy code without its check is unfinished: new non-trivial logic (a branch, a loop, a parser, money or security, or a whole new script or app) leaves one small test or an assert-based self-check. Trivial changes need none.\n" +
|
|
72
|
+
"- A shortcut with a known limit gets a code comment in this form: `shortcut: <the limit>, <when to upgrade>`.\n" +
|
|
73
|
+
"\n" +
|
|
74
|
+
"Never cut: validation at trust boundaries, error handling that prevents data loss, security, accessibility, the calibration real hardware needs, anything the user asked for.\n";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function getPonytailInstructions(mode) {
|
|
78
|
+
const configuredMode = normalizePersistedMode(mode) || DEFAULT_MODE;
|
|
79
|
+
|
|
80
|
+
if (INDEPENDENT_MODES.has(configuredMode)) {
|
|
81
|
+
return 'PONYTAIL MODE ACTIVE — level: ' + configuredMode + '. Behavior defined by /ponytail-' + configuredMode + ' skill.';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const effectiveMode = normalizeMode(configuredMode) || DEFAULT_MODE;
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
return 'PONYTAIL MODE ACTIVE — level: ' + effectiveMode + '\n\n' +
|
|
88
|
+
filterSkillBodyForMode(fs.readFileSync(SKILL_PATH, 'utf8'), effectiveMode);
|
|
89
|
+
} catch (e) {
|
|
90
|
+
return getFallbackInstructions(effectiveMode);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
module.exports = {
|
|
95
|
+
filterSkillBodyForMode,
|
|
96
|
+
getFallbackInstructions,
|
|
97
|
+
getPonytailInstructions,
|
|
98
|
+
};
|