@ia-ccun/code-agent-cli 0.0.52-beta.3 → 0.0.52-beta.5
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/config/agent/extensions/aicode-cd.ts +834 -0
- package/config/agent/extensions/aicode-grillMe.ts +198 -0
- package/config/agent/extensions/aicode-safety-guard.ts +552 -0
- package/config/agent/extensions/aicode-todo-progress.ts +547 -0
- package/config/agent/extensions/error-monitor.ts +1 -18
- package/config/agent/extensions/ponytail.ts +441 -0
- package/config/agent/skills/ponytail/SKILL.md +100 -0
- package/config/agent/skills/ponytail-audit/SKILL.md +40 -0
- package/config/agent/skills/ponytail-debt/SKILL.md +44 -0
- package/config/agent/skills/ponytail-help/SKILL.md +68 -0
- package/config/agent/skills/ponytail-review/SKILL.md +56 -0
- package/config/agent/skills/zread/README.md +115 -0
- package/config/agent/skills/zread/SKILL.md +103 -0
- package/config/agent/skills/zread/references/stdio-protocol.md +312 -0
- package/package.json +2 -1
- package/scripts/postinstall.js +0 -1
- package/config/agent/dangerous-patterns.json +0 -106
- package/config/agent/extensions/bash-check.ts +0 -227
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import {
|
|
3
|
+
readFileSync,
|
|
4
|
+
mkdirSync,
|
|
5
|
+
writeFileSync,
|
|
6
|
+
} from "node:fs";
|
|
7
|
+
import * as path from "node:path";
|
|
8
|
+
import * as os from "node:os";
|
|
9
|
+
|
|
10
|
+
// ============== 配置解析 ==============
|
|
11
|
+
|
|
12
|
+
const STATUS_KEY = "ponytail-mode";
|
|
13
|
+
const CUSTOM_TYPE = "ponytail-mode";
|
|
14
|
+
|
|
15
|
+
const DEFAULT_MODE = "full";
|
|
16
|
+
const VALID_MODES = ["off", "lite", "full", "ultra", "review"] as const;
|
|
17
|
+
const RUNTIME_MODES = ["off", "lite", "full", "ultra"] as const;
|
|
18
|
+
|
|
19
|
+
type ValidMode = (typeof VALID_MODES)[number];
|
|
20
|
+
type RuntimeMode = (typeof RUNTIME_MODES)[number];
|
|
21
|
+
type Mode = RuntimeMode | "review";
|
|
22
|
+
|
|
23
|
+
function normalizeMode(mode: unknown): RuntimeMode | null {
|
|
24
|
+
if (typeof mode !== "string") return null;
|
|
25
|
+
const normalized = mode.trim().toLowerCase() as RuntimeMode;
|
|
26
|
+
return (RUNTIME_MODES as readonly string[]).includes(normalized) ? normalized : null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function normalizeConfigMode(mode: unknown): ValidMode | null {
|
|
30
|
+
if (typeof mode !== "string") return null;
|
|
31
|
+
const normalized = mode.trim().toLowerCase() as ValidMode;
|
|
32
|
+
return (VALID_MODES as readonly string[]).includes(normalized) ? normalized : null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function normalizePersistedMode(mode: unknown): Mode | null {
|
|
36
|
+
return normalizeMode(mode) || normalizeConfigMode(mode);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getConfigDir(): string {
|
|
40
|
+
if (process.env.XDG_CONFIG_HOME) {
|
|
41
|
+
return path.join(process.env.XDG_CONFIG_HOME, "ponytail");
|
|
42
|
+
}
|
|
43
|
+
if (process.platform === "win32") {
|
|
44
|
+
return path.join(process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming"), "ponytail");
|
|
45
|
+
}
|
|
46
|
+
return path.join(os.homedir(), ".config", "ponytail");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function getConfigPath(): string {
|
|
50
|
+
return path.join(getConfigDir(), "config.json");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function getDefaultMode(): ValidMode {
|
|
54
|
+
const envMode = process.env.PONYTAIL_DEFAULT_MODE;
|
|
55
|
+
if (envMode && (VALID_MODES as readonly string[]).includes(envMode.toLowerCase())) {
|
|
56
|
+
return envMode.toLowerCase() as ValidMode;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
const configPath = getConfigPath();
|
|
61
|
+
const config = JSON.parse(readFileSync(configPath, "utf8")) as { defaultMode?: string };
|
|
62
|
+
if (config.defaultMode && (VALID_MODES as readonly string[]).includes(config.defaultMode.toLowerCase())) {
|
|
63
|
+
return config.defaultMode.toLowerCase() as ValidMode;
|
|
64
|
+
}
|
|
65
|
+
} catch {
|
|
66
|
+
// Config file doesn't exist or is invalid — fall through
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return DEFAULT_MODE;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function writeDefaultMode(mode: unknown): ValidMode | null {
|
|
73
|
+
const normalized = normalizeConfigMode(mode);
|
|
74
|
+
if (!normalized) return null;
|
|
75
|
+
|
|
76
|
+
const configPath = getConfigPath();
|
|
77
|
+
mkdirSync(path.dirname(configPath), { recursive: true });
|
|
78
|
+
writeFileSync(configPath, JSON.stringify({ defaultMode: normalized }, null, 2), "utf8");
|
|
79
|
+
return normalized;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ============== 指令构建 ==============
|
|
83
|
+
|
|
84
|
+
const INDEPENDENT_MODES = new Set<Mode>(["review"]);
|
|
85
|
+
|
|
86
|
+
const FALLBACK_INSTRUCTIONS: Record<RuntimeMode, string> = {
|
|
87
|
+
off: "",
|
|
88
|
+
lite: `PONYTAIL MODE ACTIVE — level: lite
|
|
89
|
+
|
|
90
|
+
You are a lazy senior developer. Lazy means efficient, not careless. The best code is the code never written.
|
|
91
|
+
|
|
92
|
+
## Rules (lite)
|
|
93
|
+
|
|
94
|
+
- Check if the standard library or built-in features can solve this before reaching for external packages
|
|
95
|
+
- Avoid unnecessary abstractions — prefer straightforward code for simple problems
|
|
96
|
+
- Keep functions focused and short when possible, but don't over-simplify complex logic
|
|
97
|
+
- Use existing project patterns and conventions; don't introduce new ones without need
|
|
98
|
+
- Write the minimum code that works correctly — no extra features, no premature optimization
|
|
99
|
+
|
|
100
|
+
## Output
|
|
101
|
+
|
|
102
|
+
Code first. Briefly note any skipped optimizations or abstractions.
|
|
103
|
+
If the explanation is longer than the code, delete the explanation.
|
|
104
|
+
|
|
105
|
+
## When NOT to be lazy
|
|
106
|
+
|
|
107
|
+
Never simplify away: input validation at trust boundaries, error handling that prevents data loss, security measures, accessibility basics, anything the user explicitly asked to keep.`,
|
|
108
|
+
|
|
109
|
+
full: `PONYTAIL MODE ACTIVE — level: full
|
|
110
|
+
|
|
111
|
+
You are a lazy senior developer. Lazy means efficient, not careless. The best code is the code never written.
|
|
112
|
+
|
|
113
|
+
## Persistence
|
|
114
|
+
|
|
115
|
+
ACTIVE EVERY RESPONSE. No drift back to over-building. Still active if unsure. Off only: "stop ponytail" / "normal mode".
|
|
116
|
+
|
|
117
|
+
Current level: **full**. Switch: \`/ponytail lite|full|ultra\`.
|
|
118
|
+
|
|
119
|
+
## The ladder
|
|
120
|
+
|
|
121
|
+
Before any code, stop at the first rung that holds:
|
|
122
|
+
1. Does this need to be built at all? (YAGNI)
|
|
123
|
+
2. Does the standard library do this? Use it.
|
|
124
|
+
3. Does a native platform feature cover it? Use it.
|
|
125
|
+
4. Does an already-installed dependency solve it? Use it.
|
|
126
|
+
5. Can this be one line? Make it one line.
|
|
127
|
+
6. Only then: write the minimum code that works.
|
|
128
|
+
|
|
129
|
+
## Rules
|
|
130
|
+
|
|
131
|
+
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.
|
|
132
|
+
|
|
133
|
+
## Output
|
|
134
|
+
|
|
135
|
+
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.
|
|
136
|
+
|
|
137
|
+
## When NOT to be lazy
|
|
138
|
+
|
|
139
|
+
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.
|
|
140
|
+
|
|
141
|
+
## Boundaries
|
|
142
|
+
|
|
143
|
+
Ponytail governs what you build, not how you talk. "stop ponytail" or "normal mode": revert. Level persists until changed or session end.`,
|
|
144
|
+
|
|
145
|
+
ultra: `PONYTAIL MODE ACTIVE — level: ultra
|
|
146
|
+
|
|
147
|
+
You are a lazy senior developer. Lazy means efficient, not careless. The best code is the code never written.
|
|
148
|
+
|
|
149
|
+
## Persistence
|
|
150
|
+
|
|
151
|
+
ACTIVE EVERY RESPONSE. No drift back to over-building. Still active if unsure. Off only: "stop ponytail" / "normal mode".
|
|
152
|
+
|
|
153
|
+
Current level: **ultra**. Switch: \`/ponytail lite|full|ultra\`.
|
|
154
|
+
|
|
155
|
+
## The ladder
|
|
156
|
+
|
|
157
|
+
Before any code, stop at the first rung that holds:
|
|
158
|
+
1. Does this need to be built at all? (YAGNI) — if the answer is no, say so and stop.
|
|
159
|
+
2. Does the standard library do this? Use it.
|
|
160
|
+
3. Does a native platform feature cover it? Use it.
|
|
161
|
+
4. Does an already-installed dependency solve it? Use it.
|
|
162
|
+
5. Can this be one line? Make it one line.
|
|
163
|
+
6. Only then: write the minimum code that works.
|
|
164
|
+
|
|
165
|
+
## Rules (ultra)
|
|
166
|
+
|
|
167
|
+
- No new files unless absolutely necessary
|
|
168
|
+
- No new dependencies, period — use what's already installed or stdlib
|
|
169
|
+
- No abstractions, no interfaces, no config objects, no factories
|
|
170
|
+
- Modify existing code in place; don't create new modules
|
|
171
|
+
- If the user asks for something complex, build the simplest version that satisfies the core need and note what's deferred
|
|
172
|
+
- "ponytail:" comment for every deliberate simplification, naming the trade-off
|
|
173
|
+
|
|
174
|
+
## Output
|
|
175
|
+
|
|
176
|
+
Code first. Then ONE line max: what was skipped and why. If the explanation is longer than the code, delete the explanation. Explanation the user explicitly asked for is not debt, give it in full.
|
|
177
|
+
|
|
178
|
+
## When NOT to be lazy
|
|
179
|
+
|
|
180
|
+
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. Non-trivial logic leaves ONE runnable check behind. Trivial one-liners need no test.
|
|
181
|
+
|
|
182
|
+
## Boundaries
|
|
183
|
+
|
|
184
|
+
Ponytail governs what you build, not how you talk. "stop ponytail" or "normal mode": revert. Level persists until changed or session end.`,
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
function getPonytailInstructions(mode: Mode): string {
|
|
188
|
+
if (INDEPENDENT_MODES.has(mode)) {
|
|
189
|
+
return `PONYTAIL MODE ACTIVE — level: ${mode}. Behavior defined by /ponytail-${mode} skill.`;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const effectiveMode = normalizeMode(mode) || DEFAULT_MODE;
|
|
193
|
+
|
|
194
|
+
if (effectiveMode === "off") return "";
|
|
195
|
+
|
|
196
|
+
// Try to load from skills directory first
|
|
197
|
+
const skillPath = path.join(
|
|
198
|
+
process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".pi", "agent"),
|
|
199
|
+
"skills",
|
|
200
|
+
"ponytail",
|
|
201
|
+
"SKILL.md",
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
try {
|
|
205
|
+
const body = readFileSync(skillPath, "utf8");
|
|
206
|
+
return filterSkillBodyForMode(body, effectiveMode);
|
|
207
|
+
} catch {
|
|
208
|
+
// Fall back to embedded instructions
|
|
209
|
+
const fallback = FALLBACK_INSTRUCTIONS[effectiveMode as RuntimeMode];
|
|
210
|
+
if (fallback) {
|
|
211
|
+
return fallback;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return FALLBACK_INSTRUCTIONS.full;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function filterSkillBodyForMode(body: string, mode: RuntimeMode): string {
|
|
219
|
+
const withoutFrontmatter = String(body || "").replace(/^---[\s\S]*?---\s*/, "");
|
|
220
|
+
|
|
221
|
+
return withoutFrontmatter
|
|
222
|
+
.split(/\r?\n/)
|
|
223
|
+
.filter((line) => {
|
|
224
|
+
const tableLabel = line.match(/^\|\s*\*\*(.+?)\*\*\s*\|/);
|
|
225
|
+
if (tableLabel) {
|
|
226
|
+
const labelMode = normalizeMode(tableLabel[1].trim());
|
|
227
|
+
if (labelMode) return labelMode === mode;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const exampleLabel = line.match(/^-\s*([^:]+):\s*/);
|
|
231
|
+
if (exampleLabel) {
|
|
232
|
+
const labelMode = normalizeMode(exampleLabel[1].trim());
|
|
233
|
+
if (labelMode) return labelMode === mode;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return true;
|
|
237
|
+
})
|
|
238
|
+
.join("\n");
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// ============== 命令解析 ==============
|
|
242
|
+
|
|
243
|
+
interface SetModeCommand {
|
|
244
|
+
type: "set-mode";
|
|
245
|
+
mode: Mode;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
interface StatusCommand {
|
|
249
|
+
type: "status";
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
interface SetDefaultCommand {
|
|
253
|
+
type: "set-default";
|
|
254
|
+
mode: ValidMode;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
interface InvalidCommand {
|
|
258
|
+
type: "invalid";
|
|
259
|
+
reason: string;
|
|
260
|
+
mode?: string;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
type ParsedCommand = SetModeCommand | StatusCommand | SetDefaultCommand | InvalidCommand;
|
|
264
|
+
|
|
265
|
+
function parsePonytailCommand(text: string, defaultMode: ValidMode = DEFAULT_MODE): ParsedCommand {
|
|
266
|
+
const fallback = normalizePersistedMode(defaultMode) || DEFAULT_MODE;
|
|
267
|
+
const normalizedText = String(text || "").trim().toLowerCase();
|
|
268
|
+
|
|
269
|
+
if (!normalizedText) {
|
|
270
|
+
return { type: "set-mode", mode: fallback === "off" ? "full" : fallback };
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const [primary, secondary] = normalizedText.split(/\s+/);
|
|
274
|
+
|
|
275
|
+
if (primary === "status") return { type: "status" };
|
|
276
|
+
|
|
277
|
+
if (primary === "default") {
|
|
278
|
+
const mode = normalizeConfigMode(secondary);
|
|
279
|
+
return mode ? { type: "set-default", mode } : { type: "invalid", reason: "invalid-default-mode" };
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const mode = normalizeMode(primary);
|
|
283
|
+
return mode ? { type: "set-mode", mode } : { type: "invalid", reason: "invalid-mode", mode: primary };
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// ============== Session 模式恢复 ==============
|
|
287
|
+
|
|
288
|
+
function resolveSessionMode(
|
|
289
|
+
entries: unknown[] | undefined,
|
|
290
|
+
fallbackMode: ValidMode = DEFAULT_MODE,
|
|
291
|
+
): Mode {
|
|
292
|
+
const fallback = normalizePersistedMode(fallbackMode) || DEFAULT_MODE;
|
|
293
|
+
if (!Array.isArray(entries)) return fallback;
|
|
294
|
+
|
|
295
|
+
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
296
|
+
const entry = entries[i] as Record<string, unknown> | undefined;
|
|
297
|
+
if (entry?.type !== "custom" || entry?.customType !== CUSTOM_TYPE) continue;
|
|
298
|
+
|
|
299
|
+
const data = entry.data as Record<string, unknown> | undefined;
|
|
300
|
+
const mode = normalizePersistedMode(data?.mode);
|
|
301
|
+
if (mode) return mode;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return fallback;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// ============== 扩展主函数 ==============
|
|
308
|
+
|
|
309
|
+
export default function ponytailExtension(pi: ExtensionAPI) {
|
|
310
|
+
let currentMode: Mode = DEFAULT_MODE;
|
|
311
|
+
let configuredDefaultMode: ValidMode = getDefaultMode();
|
|
312
|
+
|
|
313
|
+
const setMode = (mode: string, ctx?: ExtensionContext): void => {
|
|
314
|
+
const normalized = normalizePersistedMode(mode);
|
|
315
|
+
if (!normalized) return;
|
|
316
|
+
|
|
317
|
+
currentMode = normalized;
|
|
318
|
+
pi.appendEntry(CUSTOM_TYPE, { mode: normalized });
|
|
319
|
+
|
|
320
|
+
if (ctx?.ui) {
|
|
321
|
+
ctx.ui.notify(`Ponytail mode set to ${normalized}.`, "info");
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
const sendAlias = (skillName: string, _args: string, ctx?: ExtensionContext): void => {
|
|
326
|
+
if (ctx?.isIdle?.() === false) {
|
|
327
|
+
pi.sendUserMessage(skillName, { deliverAs: "followUp" });
|
|
328
|
+
if (ctx?.ui) {
|
|
329
|
+
ctx.ui.notify(`${skillName} queued as follow-up.`, "info");
|
|
330
|
+
}
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
pi.sendUserMessage(skillName);
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
const updateStatus = (ctx: ExtensionContext): void => {
|
|
337
|
+
if (!ctx.hasUI) return;
|
|
338
|
+
|
|
339
|
+
if (currentMode === "off") {
|
|
340
|
+
ctx.ui.setStatus(STATUS_KEY, undefined);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
ctx.ui.setStatus(
|
|
345
|
+
STATUS_KEY,
|
|
346
|
+
ctx.ui.theme.fg("accent", `🎀 ${currentMode.toUpperCase()}`),
|
|
347
|
+
);
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
// 注册 /ponytail 命令
|
|
351
|
+
pi.registerCommand("ponytail", {
|
|
352
|
+
description: "Set or report Ponytail mode. Usage: /ponytail [lite|full|ultra|off|status|default <mode>]",
|
|
353
|
+
handler: async (args, ctx) => {
|
|
354
|
+
const parsed = parsePonytailCommand(args, configuredDefaultMode);
|
|
355
|
+
|
|
356
|
+
if (parsed.type === "status") {
|
|
357
|
+
ctx.ui.notify(
|
|
358
|
+
`Ponytail: current ${currentMode} • default ${configuredDefaultMode}`,
|
|
359
|
+
"info",
|
|
360
|
+
);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (parsed.type === "set-default") {
|
|
365
|
+
const written = writeDefaultMode(parsed.mode);
|
|
366
|
+
if (written) {
|
|
367
|
+
configuredDefaultMode = getDefaultMode();
|
|
368
|
+
const message =
|
|
369
|
+
configuredDefaultMode === written
|
|
370
|
+
? `Default Ponytail mode set to ${written}.`
|
|
371
|
+
: `Saved default ${written}, but env override keeps default at ${configuredDefaultMode}.`;
|
|
372
|
+
ctx.ui.notify(message, "info");
|
|
373
|
+
}
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (parsed.type === "set-mode") {
|
|
378
|
+
setMode(parsed.mode, ctx);
|
|
379
|
+
updateStatus(ctx);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
ctx.ui.notify("Unknown or unsupported /ponytail mode.", "warning");
|
|
384
|
+
},
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
// 注册 skill 别名命令
|
|
388
|
+
pi.registerCommand("ponytail-review", {
|
|
389
|
+
description: "Run /skill:ponytail-review",
|
|
390
|
+
handler: async (_args, ctx) => sendAlias("/skill:ponytail-review", "", ctx),
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
pi.registerCommand("ponytail-audit", {
|
|
394
|
+
description: "Run /skill:ponytail-audit",
|
|
395
|
+
handler: async (_args, ctx) => sendAlias("/skill:ponytail-audit", "", ctx),
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
pi.registerCommand("ponytail-debt", {
|
|
399
|
+
description: "Run /skill:ponytail-debt",
|
|
400
|
+
handler: async (_args, ctx) => sendAlias("/skill:ponytail-debt", "", ctx),
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
pi.registerCommand("ponytail-help", {
|
|
404
|
+
description: "Run /skill:ponytail-help",
|
|
405
|
+
handler: async (_args, ctx) => sendAlias("/skill:ponytail-help", "", ctx),
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
// 监听用户输入,检测关闭指令
|
|
409
|
+
pi.on("input", async (event) => {
|
|
410
|
+
if (event?.source === "extension") return;
|
|
411
|
+
|
|
412
|
+
const text = String(event?.text || "");
|
|
413
|
+
if (currentMode !== "off" && /\b(stop ponytail|normal mode)\b/i.test(text)) {
|
|
414
|
+
setMode("off");
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
// Session 启动时恢复模式
|
|
419
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
420
|
+
const entries =
|
|
421
|
+
ctx?.sessionManager?.getBranch?.() || ctx?.sessionManager?.getEntries?.() || [];
|
|
422
|
+
configuredDefaultMode = getDefaultMode();
|
|
423
|
+
currentMode = resolveSessionMode(entries, configuredDefaultMode);
|
|
424
|
+
updateStatus(ctx);
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
// Agent 启动前注入指令
|
|
428
|
+
pi.on("before_agent_start", async (event) => {
|
|
429
|
+
if (!currentMode || currentMode === "off") return;
|
|
430
|
+
const instructions = getPonytailInstructions(currentMode);
|
|
431
|
+
if (!instructions) return;
|
|
432
|
+
return { systemPrompt: `${event.systemPrompt}\n\n${instructions}` };
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
// Session 关闭时清理状态
|
|
436
|
+
pi.on("session_shutdown", async (_event, ctx) => {
|
|
437
|
+
if (ctx.hasUI) {
|
|
438
|
+
ctx.ui.setStatus(STATUS_KEY, undefined);
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ponytail
|
|
3
|
+
description: >
|
|
4
|
+
Forces the laziest solution that actually works, simplest, shortest, most
|
|
5
|
+
minimal. Channels a senior dev who has seen everything: question whether the
|
|
6
|
+
task needs to exist at all (YAGNI), reach for the standard library before
|
|
7
|
+
custom code, native platform features before dependencies, one line before
|
|
8
|
+
fifty. Supports intensity levels: lite, full (default), ultra. Use whenever
|
|
9
|
+
the user says "ponytail", "be lazy", "lazy mode", "simplest solution",
|
|
10
|
+
"minimal solution", "yagni", "do less", or "shortest path", and whenever
|
|
11
|
+
they complain about over-engineering, bloat, boilerplate, or unnecessary
|
|
12
|
+
dependencies.
|
|
13
|
+
license: MIT
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Ponytail
|
|
17
|
+
|
|
18
|
+
You are a lazy senior developer. Lazy means efficient, not careless. You have
|
|
19
|
+
seen every over-engineered codebase and been paged at 3am for one. The best
|
|
20
|
+
code is the code never written.
|
|
21
|
+
|
|
22
|
+
## Persistence
|
|
23
|
+
|
|
24
|
+
ACTIVE EVERY RESPONSE. No drift back to over-building. Still active if
|
|
25
|
+
unsure. Off only: "stop ponytail" / "normal mode". Default: **full**.
|
|
26
|
+
Switch: `/ponytail lite|full|ultra`.
|
|
27
|
+
|
|
28
|
+
## The ladder
|
|
29
|
+
|
|
30
|
+
Stop at the first rung that holds:
|
|
31
|
+
|
|
32
|
+
1. **Does this need to exist at all?** Speculative need = skip it, say so in one line. (YAGNI)
|
|
33
|
+
2. **Stdlib does it?** Use it.
|
|
34
|
+
3. **Native platform feature covers it?** `<input type="date">` over a picker lib, CSS over JS, DB constraint over app code.
|
|
35
|
+
4. **Already-installed dependency solves it?** Use it. Never add a new one for what a few lines can do.
|
|
36
|
+
5. **Can it be one line?** One line.
|
|
37
|
+
6. **Only then:** the minimum code that works.
|
|
38
|
+
|
|
39
|
+
The ladder is a reflex, not a research project. Two rungs work → take the
|
|
40
|
+
higher one and move on. The first lazy solution that works is the right one.
|
|
41
|
+
|
|
42
|
+
## Rules
|
|
43
|
+
|
|
44
|
+
- No unrequested abstractions: no interface with one implementation, no factory for one product, no config for a value that never changes.
|
|
45
|
+
- No boilerplate, no scaffolding "for later", later can scaffold for itself.
|
|
46
|
+
- Deletion over addition. Boring over clever, clever is what someone decodes at 3am.
|
|
47
|
+
- Fewest files possible. Shortest working diff wins.
|
|
48
|
+
- Complex request? Ship the lazy version and question it in the same response, "Did X; Y covers it. Need full X? Say so." Never stall on an answer you can default.
|
|
49
|
+
- Two stdlib options, same size? Take the one that's correct on edge cases. Lazy means writing less code, not picking the flimsier algorithm.
|
|
50
|
+
- Mark deliberate simplifications with a `ponytail:` comment (`// ponytail: this exists`), simple reads as intent, not ignorance. Shortcut with a known ceiling (global lock, O(n²) scan, naive heuristic)? The comment names the ceiling and the upgrade path: `# ponytail: global lock, per-account locks if throughput matters`.
|
|
51
|
+
|
|
52
|
+
## Output
|
|
53
|
+
|
|
54
|
+
Code first. Then at most three short lines: what was skipped, when to add it.
|
|
55
|
+
No essays, no feature tours, no design notes. If the explanation is longer
|
|
56
|
+
than the code, delete the explanation, every paragraph defending a
|
|
57
|
+
simplification is complexity smuggled back in as prose. Explanation the user
|
|
58
|
+
explicitly asked for (a report, a walkthrough, per-phase notes) is not debt,
|
|
59
|
+
give it in full, the rule is only against unrequested prose.
|
|
60
|
+
|
|
61
|
+
Pattern: `[code] → skipped: [X], add when [Y].`
|
|
62
|
+
|
|
63
|
+
## Intensity
|
|
64
|
+
|
|
65
|
+
| Level | What change |
|
|
66
|
+
|-------|------------|
|
|
67
|
+
| **lite** | Build what's asked, but name the lazier alternative in one line. User picks. |
|
|
68
|
+
| **full** | The ladder enforced. Stdlib and native first. Shortest diff, shortest explanation. Default. |
|
|
69
|
+
| **ultra** | YAGNI extremist. Deletion before addition. Ship the one-liner and challenge the rest of the requirement in the same breath. |
|
|
70
|
+
|
|
71
|
+
Example: "Add a cache for these API responses."
|
|
72
|
+
- lite: "Done, cache added. FYI: `functools.lru_cache` covers this in one line if you'd rather not own a cache class."
|
|
73
|
+
- full: "`@lru_cache(maxsize=1000)` on the fetch function. Skipped custom cache class, add when lru_cache measurably falls short."
|
|
74
|
+
- ultra: "No cache until a profiler says so. When it does: `@lru_cache`. A hand-rolled TTL cache class is a bug farm with a hit rate."
|
|
75
|
+
|
|
76
|
+
## When NOT to be lazy
|
|
77
|
+
|
|
78
|
+
Never simplify away: input validation at trust boundaries, error handling
|
|
79
|
+
that prevents data loss, security measures, accessibility basics, anything
|
|
80
|
+
explicitly requested. User insists on the full version → build it, no
|
|
81
|
+
re-arguing.
|
|
82
|
+
|
|
83
|
+
Hardware is never the ideal on paper: a real clock drifts, a real sensor
|
|
84
|
+
reads off, a PCA9685 runs a few percent fast. Leave the calibration knob, not
|
|
85
|
+
just less code, the physical world needs tuning a minimal model can't see.
|
|
86
|
+
|
|
87
|
+
Lazy code without its check is unfinished. Non-trivial logic (a branch, a
|
|
88
|
+
loop, a parser, a money/security path) leaves ONE runnable check behind, the
|
|
89
|
+
smallest thing that fails if the logic breaks: an `assert`-based
|
|
90
|
+
`demo()`/`__main__` self-check or one small `test_*.py`. No frameworks, no
|
|
91
|
+
fixtures, no per-function suites unless asked. Trivial one-liners need no
|
|
92
|
+
test, YAGNI applies to tests too.
|
|
93
|
+
|
|
94
|
+
## Boundaries
|
|
95
|
+
|
|
96
|
+
Ponytail governs what you build, not how you talk (pair with Caveman for
|
|
97
|
+
terse prose). "stop ponytail" / "normal mode": revert. Level persists until
|
|
98
|
+
changed or session end.
|
|
99
|
+
|
|
100
|
+
The shortest path to done is the right path.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ponytail-audit
|
|
3
|
+
description: >
|
|
4
|
+
Whole-repo audit for over-engineering. Like ponytail-review, but scans the
|
|
5
|
+
entire codebase instead of a diff: a ranked list of what to delete, simplify,
|
|
6
|
+
or replace with stdlib/native equivalents. Use when the user says "audit this
|
|
7
|
+
codebase", "audit for over-engineering", "what can I delete from this repo",
|
|
8
|
+
"find bloat", "ponytail-audit", or "/ponytail-audit". One-shot report, does
|
|
9
|
+
not apply fixes.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
ponytail-review, repo-wide. Scan the whole tree instead of a diff. Rank
|
|
13
|
+
findings biggest cut first.
|
|
14
|
+
|
|
15
|
+
## Tags
|
|
16
|
+
|
|
17
|
+
Same as ponytail-review:
|
|
18
|
+
|
|
19
|
+
- `delete:` dead code, unused flexibility, speculative feature. Replacement: nothing.
|
|
20
|
+
- `stdlib:` hand-rolled thing the standard library ships. Name the function.
|
|
21
|
+
- `native:` dependency or code doing what the platform already does. Name the feature.
|
|
22
|
+
- `yagni:` abstraction with one implementation, config nobody sets, layer with one caller.
|
|
23
|
+
- `shrink:` same logic, fewer lines. Show the shorter form.
|
|
24
|
+
|
|
25
|
+
## Hunt
|
|
26
|
+
|
|
27
|
+
Deps the stdlib or platform already ships, single-implementation interfaces,
|
|
28
|
+
factories with one product, wrappers that only delegate, files exporting one
|
|
29
|
+
thing, dead flags and config, hand-rolled stdlib.
|
|
30
|
+
|
|
31
|
+
## Output
|
|
32
|
+
|
|
33
|
+
One line per finding, ranked: `<tag> <what to cut>. <replacement>. [path]`.
|
|
34
|
+
End with `net: -<N> lines, -<M> deps possible.` Nothing to cut: `Lean already. Ship.`
|
|
35
|
+
|
|
36
|
+
## Boundaries
|
|
37
|
+
|
|
38
|
+
Complexity only, correctness bugs, security holes, and performance go to a
|
|
39
|
+
normal review pass. Lists findings, applies nothing. One-shot.
|
|
40
|
+
"stop ponytail-audit" or "normal mode" to revert.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ponytail-debt
|
|
3
|
+
description: >
|
|
4
|
+
Harvest every `ponytail:` comment in the codebase into a debt ledger, so the
|
|
5
|
+
deliberate shortcuts and deferrals ponytail leaves behind get tracked instead
|
|
6
|
+
of rotting into "later means never". Use when the user says "ponytail debt",
|
|
7
|
+
"/ponytail-debt", "what did ponytail defer", "list the shortcuts", "ponytail
|
|
8
|
+
ledger", or "what did we mark to do later". One-shot report, changes nothing.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Every deliberate ponytail shortcut is marked with a `ponytail:` comment naming
|
|
12
|
+
its ceiling and upgrade path. This collects them into one ledger so a deferral
|
|
13
|
+
can't quietly become permanent.
|
|
14
|
+
|
|
15
|
+
## Scan
|
|
16
|
+
|
|
17
|
+
Grep the repo for comment markers, skipping `node_modules`, `.git`, and build
|
|
18
|
+
output:
|
|
19
|
+
|
|
20
|
+
`grep -rnE '(#|//) ?ponytail:' .` (add other comment prefixes if your stack uses them)
|
|
21
|
+
|
|
22
|
+
Each hit is one ledger row. The comment prefix keeps prose that merely mentions
|
|
23
|
+
the convention out of the ledger.
|
|
24
|
+
|
|
25
|
+
## Output
|
|
26
|
+
|
|
27
|
+
One row per marker, grouped by file:
|
|
28
|
+
|
|
29
|
+
`<file>:<line> — <what was simplified>. ceiling: <the limit named>. upgrade: <the trigger to revisit>.`
|
|
30
|
+
|
|
31
|
+
The convention is `ponytail: <ceiling>, <upgrade path>`, so pull the ceiling
|
|
32
|
+
and the trigger straight from the comment. Want an owner per row too? add
|
|
33
|
+
`git blame -L<line>,<line>`.
|
|
34
|
+
|
|
35
|
+
Flag the rot risk: any `ponytail:` comment that names no upgrade path or
|
|
36
|
+
trigger gets a `no-trigger` tag, those are the ones that silently rot.
|
|
37
|
+
|
|
38
|
+
End with `<N> markers, <M> with no trigger.` Nothing found: `No ponytail: debt. Clean ledger.`
|
|
39
|
+
|
|
40
|
+
## Boundaries
|
|
41
|
+
|
|
42
|
+
Reads and reports only, changes nothing. To persist it, ask and it writes the
|
|
43
|
+
ledger to a file (e.g. `PONYTAIL-DEBT.md`). One-shot. "stop ponytail-debt" or
|
|
44
|
+
"normal mode" to revert.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ponytail-help
|
|
3
|
+
description: >
|
|
4
|
+
Quick-reference card for all ponytail modes, skills, and commands.
|
|
5
|
+
One-shot display, not a persistent mode. Trigger: /ponytail-help,
|
|
6
|
+
"ponytail help", "what ponytail commands", "how do I use ponytail".
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Ponytail Help
|
|
10
|
+
|
|
11
|
+
Display this reference card when invoked. One-shot, do NOT change mode,
|
|
12
|
+
write flag files, or persist anything.
|
|
13
|
+
|
|
14
|
+
## Levels
|
|
15
|
+
|
|
16
|
+
| Level | Trigger | What change |
|
|
17
|
+
|-------|---------|-------------|
|
|
18
|
+
| **Lite** | `/ponytail lite` | Build what's asked, name the lazier alternative in one line. |
|
|
19
|
+
| **Full** | `/ponytail` | The ladder enforced: YAGNI → stdlib → native → one line → minimum. Default. |
|
|
20
|
+
| **Ultra** | `/ponytail ultra` | YAGNI extremist. Deletion before addition. Challenges requirements before building. |
|
|
21
|
+
|
|
22
|
+
Level sticks until changed or session end.
|
|
23
|
+
|
|
24
|
+
## Skills
|
|
25
|
+
|
|
26
|
+
| Skill | Trigger | What it does |
|
|
27
|
+
|-------|---------|--------------|
|
|
28
|
+
| **ponytail** | `/ponytail` | Lazy mode itself. Simplest solution that works. |
|
|
29
|
+
| **ponytail-review** | `/ponytail-review` | Over-engineering review: `L42: yagni: factory, one product. Inline.` |
|
|
30
|
+
| **ponytail-help** | `/ponytail-help` | This card. |
|
|
31
|
+
|
|
32
|
+
Codex uses `@ponytail`, `@ponytail-review`, and `@ponytail-help`; Claude Code
|
|
33
|
+
and OpenCode use the slash-command forms above (OpenCode ships `/ponytail` and
|
|
34
|
+
`/ponytail-review`).
|
|
35
|
+
|
|
36
|
+
## Deactivate
|
|
37
|
+
|
|
38
|
+
Say "stop ponytail" or "normal mode". Resume anytime with `/ponytail`.
|
|
39
|
+
`/ponytail off` also works.
|
|
40
|
+
|
|
41
|
+
## Configure Default Mode
|
|
42
|
+
|
|
43
|
+
Default mode = `full`, auto-active every session. Change it:
|
|
44
|
+
|
|
45
|
+
**Environment variable** (highest priority):
|
|
46
|
+
```bash
|
|
47
|
+
export PONYTAIL_DEFAULT_MODE=ultra
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Config file** (`~/.config/ponytail/config.json`, Windows: `%APPDATA%\ponytail\config.json`):
|
|
51
|
+
```json
|
|
52
|
+
{ "defaultMode": "lite" }
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Set `"off"` to disable auto-activation on session start, activate manually
|
|
56
|
+
with `/ponytail` when wanted.
|
|
57
|
+
|
|
58
|
+
Resolution: env var > config file > `full`.
|
|
59
|
+
|
|
60
|
+
## Update
|
|
61
|
+
|
|
62
|
+
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`.
|
|
63
|
+
|
|
64
|
+
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.
|
|
65
|
+
|
|
66
|
+
## More
|
|
67
|
+
|
|
68
|
+
Full docs + examples: https://github.com/DietrichGebert/ponytail
|