self-evolve-framework 1.2.0 → 1.4.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.
Files changed (64) hide show
  1. package/README.md +22 -11
  2. package/bin/cli.js +1 -0
  3. package/package.json +1 -1
  4. package/template/skills/ponytail/SKILL.md +133 -0
  5. package/template/skills/ponytail/scripts/hooks/claude-codex-hooks.json +44 -0
  6. package/template/skills/ponytail/scripts/hooks/copilot-hooks.json +21 -0
  7. package/template/skills/ponytail/scripts/hooks/ponytail-activate.js +91 -0
  8. package/template/skills/ponytail/scripts/hooks/ponytail-config.js +122 -0
  9. package/template/skills/ponytail/scripts/hooks/ponytail-instructions.js +94 -0
  10. package/template/skills/ponytail/scripts/hooks/ponytail-mode-tracker.js +55 -0
  11. package/template/skills/ponytail/scripts/hooks/ponytail-runtime.js +68 -0
  12. package/template/skills/ponytail/scripts/hooks/ponytail-statusline.ps1 +21 -0
  13. package/template/skills/ponytail/scripts/hooks/ponytail-statusline.sh +12 -0
  14. package/template/skills/ponytail/scripts/hooks/ponytail-subagent.js +22 -0
  15. package/template/skills/ponytail/scripts/mcp/README.md +46 -0
  16. package/template/skills/ponytail/scripts/mcp/index.js +48 -0
  17. package/template/skills/ponytail/scripts/mcp/instructions.js +26 -0
  18. package/template/skills/ponytail/scripts/mcp/package.json +13 -0
  19. package/template/skills/ponytail/scripts/mcp/test/instructions.test.js +22 -0
  20. package/template/skills/ponytail-audit/SKILL.md +41 -0
  21. package/template/skills/ponytail-debt/SKILL.md +44 -0
  22. package/template/skills/ponytail-gain/SKILL.md +50 -0
  23. package/template/skills/ponytail-help/SKILL.md +69 -0
  24. package/template/skills/ponytail-review/SKILL.md +57 -0
  25. package/template/skills/skillopt-sleep/SKILL.md +48 -34
  26. package/template/skills/skillopt-sleep/scripts/python/__init__.py +20 -0
  27. package/template/skills/skillopt-sleep/scripts/python/__main__.py +343 -0
  28. package/template/skills/skillopt-sleep/scripts/python/backend.py +1371 -0
  29. package/template/skills/skillopt-sleep/scripts/python/budget.py +75 -0
  30. package/template/skills/skillopt-sleep/scripts/python/config.py +162 -0
  31. package/template/skills/skillopt-sleep/scripts/python/consolidate.py +238 -0
  32. package/template/skills/skillopt-sleep/scripts/python/cycle.py +291 -0
  33. package/template/skills/skillopt-sleep/scripts/python/dream.py +138 -0
  34. package/template/skills/skillopt-sleep/scripts/python/experiments/__init__.py +1 -0
  35. package/template/skills/skillopt-sleep/scripts/python/experiments/gbrain_bench.py +119 -0
  36. package/template/skills/skillopt-sleep/scripts/python/experiments/personas.py +86 -0
  37. package/template/skills/skillopt-sleep/scripts/python/experiments/report.py +132 -0
  38. package/template/skills/skillopt-sleep/scripts/python/experiments/run_experiment.py +178 -0
  39. package/template/skills/skillopt-sleep/scripts/python/experiments/run_gbrain.py +209 -0
  40. package/template/skills/skillopt-sleep/scripts/python/experiments/run_transfer.py +155 -0
  41. package/template/skills/skillopt-sleep/scripts/python/experiments/sweep.py +164 -0
  42. package/template/skills/skillopt-sleep/scripts/python/gate.py +50 -0
  43. package/template/skills/skillopt-sleep/scripts/python/harvest.py +304 -0
  44. package/template/skills/skillopt-sleep/scripts/python/harvest_codex.py +253 -0
  45. package/template/skills/skillopt-sleep/scripts/python/harvest_sources.py +41 -0
  46. package/template/skills/skillopt-sleep/scripts/python/judges.py +84 -0
  47. package/template/skills/skillopt-sleep/scripts/python/llm_miner.py +134 -0
  48. package/template/skills/skillopt-sleep/scripts/python/memory.py +129 -0
  49. package/template/skills/skillopt-sleep/scripts/python/mine.py +312 -0
  50. package/template/skills/skillopt-sleep/scripts/python/replay.py +146 -0
  51. package/template/skills/skillopt-sleep/scripts/python/rollout.py +153 -0
  52. package/template/skills/skillopt-sleep/scripts/python/scheduler.py +138 -0
  53. package/template/skills/skillopt-sleep/scripts/python/slow_update.py +142 -0
  54. package/template/skills/skillopt-sleep/scripts/python/staging.py +103 -0
  55. package/template/skills/skillopt-sleep/scripts/python/state.py +96 -0
  56. package/template/skills/skillopt-sleep/scripts/python/tasks_file.py +81 -0
  57. package/template/skills/skillopt-sleep/scripts/python/types.py +146 -0
  58. package/template/skills/skillopt-sleep/scripts/shell/__init__.py +0 -0
  59. package/template/skills/skillopt-sleep/scripts/shell/eval_only.py +466 -0
  60. package/template/skills/skillopt-sleep/scripts/shell/materialize_searchqa.py +148 -0
  61. package/template/skills/skillopt-sleep/scripts/shell/run_alfworld.sh +60 -0
  62. package/template/skills/skillopt-sleep/scripts/shell/run_searchqa.sh +40 -0
  63. package/template/skills/skillopt-sleep/scripts/shell/run_spreadsheetbench.sh +39 -0
  64. package/template/skills/skillopt-sleep/scripts/shell/train.py +556 -0
@@ -0,0 +1,68 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { getClaudeDir } = require('./ponytail-config');
4
+
5
+ const STATE_FILE = '.ponytail-active';
6
+ const isCopilot = Boolean(process.env.COPILOT_PLUGIN_DATA);
7
+ const isCodex = !isCopilot && Boolean(process.env.PLUGIN_DATA);
8
+
9
+ let stateDir = getClaudeDir();
10
+ if (isCodex) stateDir = process.env.PLUGIN_DATA;
11
+ if (isCopilot) stateDir = process.env.COPILOT_PLUGIN_DATA;
12
+
13
+ const statePath = path.join(stateDir, STATE_FILE);
14
+
15
+ function setMode(mode) {
16
+ fs.mkdirSync(path.dirname(statePath), { recursive: true });
17
+ fs.writeFileSync(statePath, mode);
18
+ }
19
+
20
+ function clearMode() {
21
+ try { fs.unlinkSync(statePath); } catch (e) {}
22
+ }
23
+
24
+ // Live mode written by activate/mode-tracker. Absent flag = ponytail off.
25
+ function readMode() {
26
+ try {
27
+ return fs.readFileSync(statePath, 'utf8').trim() || null;
28
+ } catch (e) {
29
+ return null;
30
+ }
31
+ }
32
+
33
+ function writeHookOutput(event, mode, context = '') {
34
+ if (isCopilot) {
35
+ // Copilot reads additionalContext on SessionStart; ignores output elsewhere.
36
+ process.stdout.write(JSON.stringify(
37
+ event === 'SessionStart' && context ? { additionalContext: context } : {}));
38
+ return;
39
+ }
40
+ if (isCodex) {
41
+ const output = { systemMessage: `PONYTAIL:${mode.toUpperCase()}` };
42
+ if (context) {
43
+ output.hookSpecificOutput = {
44
+ hookEventName: event,
45
+ additionalContext: context,
46
+ };
47
+ }
48
+ process.stdout.write(JSON.stringify(output));
49
+ return;
50
+ }
51
+ // Native Claude: SessionStart accepts raw stdout, but SubagentStart needs the
52
+ // hookSpecificOutput JSON form or the context is dropped.
53
+ if (event === 'SubagentStart') {
54
+ process.stdout.write(JSON.stringify(
55
+ { hookSpecificOutput: { hookEventName: event, additionalContext: context } }));
56
+ return;
57
+ }
58
+ process.stdout.write(context);
59
+ }
60
+
61
+ module.exports = {
62
+ clearMode,
63
+ isCodex,
64
+ isCopilot,
65
+ readMode,
66
+ setMode,
67
+ writeHookOutput,
68
+ };
@@ -0,0 +1,21 @@
1
+ # CLAUDE_CONFIG_DIR overrides ~/.claude, matching where the hooks write the flag (issue #34)
2
+ $ClaudeDir = if ($env:CLAUDE_CONFIG_DIR) { $env:CLAUDE_CONFIG_DIR } else { Join-Path $HOME ".claude" }
3
+ $Flag = Join-Path $ClaudeDir ".ponytail-active"
4
+ if (-not (Test-Path $Flag)) {
5
+ exit 0
6
+ }
7
+
8
+ $Mode = ""
9
+ try {
10
+ $Mode = (Get-Content $Flag -ErrorAction Stop | Select-Object -First 1).Trim()
11
+ } catch {
12
+ exit 0
13
+ }
14
+
15
+ $Esc = [char]27
16
+ if ([string]::IsNullOrEmpty($Mode) -or $Mode -eq "full") {
17
+ [Console]::Write("${Esc}[38;5;108m[PONYTAIL]${Esc}[0m")
18
+ } else {
19
+ $Suffix = $Mode.ToUpperInvariant()
20
+ [Console]::Write("${Esc}[38;5;108m[PONYTAIL:$Suffix]${Esc}[0m")
21
+ }
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+ # CLAUDE_CONFIG_DIR overrides ~/.claude, matching where the hooks write the flag (issue #34)
3
+ flag="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/.ponytail-active"
4
+ [ -f "$flag" ] || exit 0
5
+
6
+ mode=$(head -n1 "$flag" | tr -d '[:space:]')
7
+
8
+ if [ -z "$mode" ] || [ "$mode" = "full" ]; then
9
+ printf '\033[38;5;108m[PONYTAIL]\033[0m'
10
+ else
11
+ printf '\033[38;5;108m[PONYTAIL:%s]\033[0m' "$(printf '%s' "$mode" | tr '[:lower:]' '[:upper:]')"
12
+ fi
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ // ponytail — Claude Code SubagentStart hook
3
+ //
4
+ // SessionStart context is parent-thread only and never reaches subagents, so
5
+ // without this every Task-spawned agent runs ponytail-unaware (issue #252).
6
+ // When ponytail mode is active, inject the same ruleset into each subagent.
7
+
8
+ const { getPonytailInstructions } = require('./ponytail-instructions');
9
+ const { readMode, writeHookOutput } = require('./ponytail-runtime');
10
+
11
+ const mode = readMode();
12
+
13
+ // Absent flag or off → ponytail isn't active; inject nothing.
14
+ if (!mode || mode === 'off') {
15
+ process.exit(0);
16
+ }
17
+
18
+ try {
19
+ writeHookOutput('SubagentStart', mode, getPonytailInstructions(mode));
20
+ } catch (e) {
21
+ // Silent fail — a stdout error at hook exit must not surface as a hook failure.
22
+ }
@@ -0,0 +1,46 @@
1
+ # ponytail-mcp
2
+
3
+ An MCP server that serves Ponytail's lazy-senior-dev instructions. It exposes
4
+ the same ruleset the Claude hooks and Pi extension use, so every host emits
5
+ identical rules.
6
+
7
+ It is not a replacement for the always-on adapters. Ponytail normally lives in
8
+ the system context every turn. MCP prompts are user-invoked, and there is no
9
+ portable MCP primitive for "inject this into every turn" across hosts. So this
10
+ server is the clean option for MCP hosts whose only injection point is the
11
+ prompt menu, or that pull context through tools. See issue #70.
12
+
13
+ ## What it exposes
14
+
15
+ - Prompt `ponytail`, returns the ruleset as a user message. Optional `mode`
16
+ argument: `lite`, `full`, or `ultra`. Omit it to use the configured default.
17
+ - Tool `ponytail_instructions`, same text, plus `structuredContent`
18
+ (`{ mode, instructions }`), for hosts that pull context via tools or code
19
+ execution. Read-only.
20
+
21
+ Mode resolution reuses `hooks/ponytail-config.js`, so `PONYTAIL_DEFAULT_MODE`
22
+ and `~/.config/ponytail/config.json` work the same as everywhere else.
23
+
24
+ ## Run it
25
+
26
+ ```bash
27
+ cd ponytail-mcp
28
+ npm install
29
+ node index.js # speaks MCP over stdio
30
+ ```
31
+
32
+ Point an MCP host at that command. Example client entry:
33
+
34
+ ```json
35
+ { "mcpServers": { "ponytail": { "command": "node", "args": ["ponytail-mcp/index.js"] } } }
36
+ ```
37
+
38
+ ## Test
39
+
40
+ ```bash
41
+ npm test
42
+ ```
43
+
44
+ Covers mode resolution and the instruction text. The MCP wiring in `index.js`
45
+ is intentionally thin: it just maps the prompt and tool onto
46
+ `buildInstructions`.
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ // Ponytail MCP server: serves the lazy-senior-dev ruleset over stdio as a
3
+ // prompt (user-invoked) and a tool (for hosts that pull context via tools).
4
+ // It does NOT replace the always-on adapters; it's the clean option for hosts
5
+ // whose only injection point is the prompt menu (see #70).
6
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
7
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
8
+ import { z } from "zod";
9
+
10
+ import { MODES, buildInstructions, resolveMode } from "./instructions.js";
11
+
12
+ const server = new McpServer({ name: "ponytail", version: "0.1.0" });
13
+
14
+ const modeArg = z
15
+ .enum(MODES)
16
+ .optional()
17
+ .describe("Ponytail intensity: lite, full, or ultra. Omit for the configured default.");
18
+
19
+ server.registerPrompt(
20
+ "ponytail",
21
+ {
22
+ title: "Ponytail mode",
23
+ description: "Lazy senior dev instructions: YAGNI, stdlib first, the smallest correct change.",
24
+ argsSchema: { mode: modeArg },
25
+ },
26
+ ({ mode }) => ({
27
+ messages: [{ role: "user", content: { type: "text", text: buildInstructions(mode) } }],
28
+ }),
29
+ );
30
+
31
+ server.registerTool(
32
+ "ponytail_instructions",
33
+ {
34
+ title: "Ponytail instructions",
35
+ description: "Return the Ponytail ruleset for the given intensity (lite, full, or ultra).",
36
+ inputSchema: { mode: modeArg },
37
+ outputSchema: { mode: z.string(), instructions: z.string() },
38
+ annotations: { readOnlyHint: true, openWorldHint: false },
39
+ },
40
+ ({ mode }) => {
41
+ const resolvedMode = resolveMode(mode);
42
+ const instructions = buildInstructions(resolvedMode);
43
+ const structuredContent = { mode: resolvedMode, instructions };
44
+ return { content: [{ type: "text", text: instructions }], structuredContent };
45
+ },
46
+ );
47
+
48
+ await server.connect(new StdioServerTransport());
@@ -0,0 +1,26 @@
1
+ // Pure instruction selection for the Ponytail MCP server. No MCP/SDK imports,
2
+ // so this stays unit-testable on its own. Reuses the same builder the Claude
3
+ // hooks and Pi extension use, so every host emits identical rules.
4
+ import { createRequire } from "node:module";
5
+
6
+ const require = createRequire(import.meta.url);
7
+ const { getPonytailInstructions } = require("../hooks/ponytail-instructions.js");
8
+ const { getDefaultMode, normalizeMode } = require("../hooks/ponytail-config.js");
9
+
10
+ // The three intensities the server offers. "off" has no instructions to serve.
11
+ export const MODES = ["lite", "full", "ultra"];
12
+
13
+ // Resolve a requested mode to a runtime intensity. Unknown, empty, or "off"
14
+ // falls back to the configured default, then to "full".
15
+ // ponytail: keep the surface to these three; "off"/"review" aren't served here.
16
+ export function resolveMode(requested) {
17
+ const asked = normalizeMode(requested);
18
+ if (asked && asked !== "off") return asked;
19
+
20
+ const fallback = normalizeMode(getDefaultMode());
21
+ return fallback && fallback !== "off" ? fallback : "full";
22
+ }
23
+
24
+ export function buildInstructions(requested) {
25
+ return getPonytailInstructions(resolveMode(requested));
26
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "ponytail-mcp",
3
+ "version": "4.8.3",
4
+ "description": "MCP server that serves Ponytail's lazy-senior-dev instructions as a prompt and a tool.",
5
+ "private": true,
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "scripts": { "test": "node --test ./test/*.test.js" },
9
+ "dependencies": {
10
+ "@modelcontextprotocol/sdk": "^1.26.0",
11
+ "zod": "^3.23.0"
12
+ }
13
+ }
@@ -0,0 +1,22 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+
4
+ import { MODES, resolveMode, buildInstructions } from "../instructions.js";
5
+
6
+ test("resolveMode keeps valid intensities", () => {
7
+ for (const mode of MODES) assert.equal(resolveMode(mode), mode);
8
+ });
9
+
10
+ test("resolveMode falls back to a runtime intensity for off/unknown/empty", () => {
11
+ // PONYTAIL_DEFAULT_MODE could be anything in CI, so just assert the contract:
12
+ // never returns "off", "review", or junk — always one of the served modes.
13
+ for (const input of ["off", "review", "nonsense", "", undefined, null]) {
14
+ assert.ok(MODES.includes(resolveMode(input)), `resolveMode(${input}) must be a served mode`);
15
+ }
16
+ });
17
+
18
+ test("buildInstructions returns the ruleset tagged with the resolved mode", () => {
19
+ const text = buildInstructions("ultra");
20
+ assert.match(text, /PONYTAIL MODE ACTIVE/);
21
+ assert.match(text, /ultra/);
22
+ });
@@ -0,0 +1,41 @@
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
+ Scope: over-engineering and complexity only. Correctness bugs, security holes,
39
+ and performance are explicitly out of scope. Route them to a normal review
40
+ pass. Lists findings, applies nothing. One-shot.
41
+ "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,50 @@
1
+ ---
2
+ name: ponytail-gain
3
+ description: >
4
+ Show ponytail's measured impact as a compact scoreboard: less code, less
5
+ cost, more speed, from the benchmark medians. One-shot display, not a
6
+ persistent mode, and not a per-repo number. Trigger: /ponytail-gain,
7
+ "ponytail gain", "what does ponytail save", "show ponytail impact",
8
+ "ponytail scoreboard".
9
+ ---
10
+
11
+ # Ponytail Gain
12
+
13
+ Display this scoreboard when invoked. One-shot: do NOT change mode, write flag
14
+ files, or persist anything.
15
+
16
+ The figures are the published benchmark medians (5 everyday tasks: email
17
+ validator, debounce, CSV sum, countdown timer, rate limiter; three models:
18
+ Haiku, Sonnet, Opus). They are measured, not computed from the current repo.
19
+ Source: `benchmarks/` and the README.
20
+
21
+ ## Scoreboard
22
+
23
+ Render plain ASCII bars. The bar length shows the measured range; the label
24
+ carries the exact figure:
25
+
26
+ ```
27
+ ponytail gain benchmark median · 5 tasks · 3 models
28
+
29
+ Lines of code no-skill ████████████████████ 100%
30
+ ponytail ██▌················· 6–20% ▼ 80–94%
31
+ Cost no-skill ████████████████████ 100%
32
+ ponytail █████▌·············· 23–53% ▼ 47–77%
33
+ Speed ponytail ▸ 3–6× faster
34
+
35
+ This repo: /ponytail-debt (shortcuts you deferred)
36
+ /ponytail-audit (what's still cuttable)
37
+ ```
38
+
39
+ ## Honesty boundary
40
+
41
+ These are benchmark medians, not this repo. NEVER print a per-repo savings
42
+ number ("you saved X lines/tokens here"): the unbuilt version was never
43
+ written, so there is no real baseline to subtract from in a live repo. The
44
+ only real per-repo figures come from `/ponytail-debt` (a counted ledger), and
45
+ this card points there instead of inventing one.
46
+
47
+ ## Boundaries
48
+
49
+ One-shot display. Edits nothing, changes no mode.
50
+ "stop ponytail" or "normal mode": revert.
@@ -0,0 +1,69 @@
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-gain** | `/ponytail-gain` | Measured-impact scoreboard: less code, less cost, more speed. |
31
+ | **ponytail-help** | `/ponytail-help` | This card. |
32
+
33
+ Codex uses `@ponytail`, `@ponytail-review`, and `@ponytail-help`; Claude Code
34
+ and OpenCode use the slash-command forms above (OpenCode ships `/ponytail` and
35
+ `/ponytail-review`).
36
+
37
+ ## Deactivate
38
+
39
+ Say "stop ponytail" or "normal mode". Resume anytime with `/ponytail`.
40
+ `/ponytail off` also works.
41
+
42
+ ## Configure Default Mode
43
+
44
+ Default mode = `full`, auto-active every session. Change it:
45
+
46
+ **Environment variable** (highest priority):
47
+ ```bash
48
+ export PONYTAIL_DEFAULT_MODE=ultra
49
+ ```
50
+
51
+ **Config file** (`~/.config/ponytail/config.json`, Windows: `%APPDATA%\ponytail\config.json`):
52
+ ```json
53
+ { "defaultMode": "lite" }
54
+ ```
55
+
56
+ Set `"off"` to disable auto-activation on session start, activate manually
57
+ with `/ponytail` when wanted.
58
+
59
+ Resolution: env var > config file > `full`.
60
+
61
+ ## Update
62
+
63
+ 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`.
64
+
65
+ 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.
66
+
67
+ ## More
68
+
69
+ Full docs + examples: https://github.com/DietrichGebert/ponytail
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: ponytail-review
3
+ description: >
4
+ Code review focused exclusively on over-engineering. Finds what to delete:
5
+ reinvented standard library, unneeded dependencies, speculative abstractions,
6
+ dead flexibility. One line per finding: location, what to cut, what replaces
7
+ it. Use when the user says "review for over-engineering", "what can we
8
+ delete", "is this over-engineered", "simplify review", or invokes
9
+ /ponytail-review. Complements correctness-focused review, this one only
10
+ hunts complexity.
11
+ ---
12
+
13
+ Review diffs for unnecessary complexity. One line per finding: location, what
14
+ to cut, what replaces it. The diff's best outcome is getting shorter.
15
+
16
+ ## Format
17
+
18
+ `L<line>: <tag> <what>. <replacement>.`, or `<file>:L<line>: ...` for
19
+ multi-file diffs.
20
+
21
+ Tags:
22
+
23
+ - `delete:` dead code, unused flexibility, speculative feature. Replacement: nothing.
24
+ - `stdlib:` hand-rolled thing the standard library ships. Name the function.
25
+ - `native:` dependency or code doing what the platform already does. Name the feature.
26
+ - `yagni:` abstraction with one implementation, config nobody sets, layer with one caller.
27
+ - `shrink:` same logic, fewer lines. Show the shorter form.
28
+
29
+ ## Examples
30
+
31
+ ❌ "This EmailValidator class might be more complex than necessary, have you
32
+ considered whether all these validation rules are needed at this stage?"
33
+
34
+ ✅ `L12-38: stdlib: 27-line validator class. "@" in email, 1 line, real validation is the confirmation mail.`
35
+
36
+ ✅ `L4: native: moment.js imported for one format call. Intl.DateTimeFormat, 0 deps.`
37
+
38
+ ✅ `repo.py:L88: yagni: AbstractRepository with one implementation. Inline it until a second one exists.`
39
+
40
+ ✅ `L52-71: delete: retry wrapper around an idempotent local call. Nothing replaces it.`
41
+
42
+ ✅ `L30-44: shrink: manual loop builds dict. dict(zip(keys, values)), 1 line.`
43
+
44
+ ## Scoring
45
+
46
+ End with the only metric that matters: `net: -<N> lines possible.`
47
+
48
+ If there is nothing to cut, say `Lean already. Ship.` and stop.
49
+
50
+ ## Boundaries
51
+
52
+ Scope: over-engineering and complexity only. Correctness bugs, security holes,
53
+ and performance are explicitly out of scope. Route them to a normal review
54
+ pass, not this one. A single smoke test or `assert`-based
55
+ self-check is the ponytail minimum, not bloat, never flag it for deletion.
56
+ Does not apply the fixes, only lists them.
57
+ "stop ponytail-review" or "normal mode": revert to verbose review style.
@@ -1,16 +1,26 @@
1
1
  ---
2
2
  name: skillopt-sleep
3
- description: 离线自我进化引擎。分析历史会话、发现重复模式、优化项目 memory 和规则。用 AI 指令替代外部脚本。
3
+ description: 离线自我进化引擎。分析历史会话、发现重复模式、优化项目 memory 和规则。底层调用 Python 执行引擎(微软 SkillOpt)。
4
4
  ---
5
5
 
6
6
  # SkillOpt-Sleep — 自我进化引擎
7
7
 
8
- > 此技能是 CodeBuddy 适配版(纯指令模式,不依赖外部脚本)。
8
+ > 执行型 skill:AI 提供指令编排,底层 `python -m skillopt_sleep` 驱动 Harvest → Mine → Replay → Consolidate → Stage → Adopt 六阶段工作流。
9
9
 
10
- ## 工作流程(6 阶段)
10
+ ## 工作流程
11
+
12
+ ### 前置条件
13
+
14
+ 每次会话首次运行前,确保引擎可用:
15
+
16
+ ```bash
17
+ cd .codebuddy/skills/skillopt-sleep/scripts/python
18
+ pip install -r requirements.txt 2>/dev/null || echo "依赖已安装"
19
+ ```
11
20
 
12
21
  ### 阶段 1:Harvest — 收集信息
13
- AI 从以下来源收集项目数据:
22
+
23
+ 收集项目数据:
14
24
  - 项目文件结构、代码模式
15
25
  - 构建/编译错误记录(从 `.codebuddy/memory/`)
16
26
  - 已知问题列表
@@ -19,50 +29,54 @@ AI 从以下来源收集项目数据:
19
29
  - 前端文件的设计质量报告(如果安装了 Impeccable skill,调用 `impeccable detect` 检查项目前端设计质量)
20
30
 
21
31
  ### 阶段 2:Mine — 挖掘模式
22
- 分析收集到的数据,识别:
32
+
33
+ 分析数据,识别:
23
34
  - **重复错误**:同一类 build/lint 错误出现次数
24
35
  - **代码异嗅**:循环依赖、过度耦合、重复代码
25
36
  - **缺失约束**:重复发生但无规则防范的问题
26
37
  - **优化机会**:可简化的逻辑、可合并的文件
27
- - **★ 核心边界**:识别模块间的契约接口、关键用户路径和其依赖方,标记"改/删前必须审慎"的承重区域
28
- - **★ 设计异嗅**:分析 Impeccable 检测报告中的 P0/P1 反复出现的问题模式,识别设计约束缺失或 DESIGN.md 与实现不一致的区域
38
+ - **★ 核心边界**:模块间契约接口、关键用户路径和依赖方
39
+ - **★ 设计异嗅**:Impeccable 检测报告中的 P0/P1 反复问题模式
40
+
41
+ ### 阶段 3-6:执行引擎运行
29
42
 
30
- ### 阶段 3:Replay — 回放验证
31
- 对每个发现的问题:
32
- - 如果已有关联规则 → 检查规则是否被遵循
33
- - 如果没有规则 → 评估是否需要新规则
34
- - 如果有修复方案 → 验证方案是否仍适用
43
+ ```bash
44
+ python -m .codebuddy.skills.skillopt-sleep.scripts.python \
45
+ --project "$(pwd)" \
46
+ --mode <dry-run|run|adopt> \
47
+ --backend claude
48
+ ```
49
+
50
+ - `--mode dry-run` → 阶段 1-3,只输出分析报告,不写文件
51
+ - `--mode run` → 阶段 1-5,输出暂存清单到 `.codebuddy/memory/skillopt-staging/`
52
+ - `--mode adopt` → 阶段 6,采纳暂存清单中的建议
53
+
54
+ ### 手动模式(无 Python 引擎时)
55
+
56
+ 如果 Python 环境不可用,AI 按以下指令模拟执行:
35
57
 
36
- ### 阶段 4:Consolidate — 合并优化
58
+ #### Consolidate — 合并优化
37
59
  生成改进建议,只接受通过 Held-out 门控的比例:
38
60
  - **新增规则**:重复 ≥2 次且无规则防范的问题
39
61
  - **更新规则**:现有规则描述模糊或过时
40
62
  - **删除规则**:不再相关或从未被触发的规则
41
63
  - **优化 memory**:合并重复的错误模式记录
42
- - **★ 边界标记**:涉及核心功能路径的删除/修改建议,加 ⚠️ 标签要求人工确认,不可自动采纳
64
+ - **★ 边界标记**:涉及核心功能路径的删除/修改建议,加 ⚠️ 标签
43
65
 
44
- ### 阶段 5:Stage — 暂存
45
- 所有建议先写入 `.codebuddy/memory/skillopt-staging/` 目录,**不修改任何活文件**。
66
+ #### Stage — 暂存
67
+ 所有建议写入 `.codebuddy/memory/skillopt-staging/`,不修改活文件。
46
68
 
47
- ### 阶段 6:Adopt — 采用
48
- 列出所有建议,由你逐条决定是否采纳:
49
- ```
50
- 📋 待采用清单
51
- ✅ 新增 rules/promise-chain-check.mdc → 防止未捕获 async 错误
52
- ✅ 更新 rules/self-evolve.mdc → 增加 cargo check 验证步骤
53
- ❌ 删除 rules/old-node-format.mdc → 节点格式已统一
54
- ```
69
+ #### Adopt — 采用
70
+ 列出建议由用户逐条决定是否采纳。
55
71
 
56
- ## 常用命令(AI 模拟)
72
+ ## 触发
57
73
 
58
- ```text
59
- skillopt-sleep dry-run → 执行阶段 1-3,输出分析报告,不写任何文件
60
- skillopt-sleep run 执行阶段 1-5,输出暂存清单
61
- skillopt-sleep adopt → 采纳暂存清单中的建议
62
- ```
74
+ | 对话输入 | 作用 |
75
+ |----------|------|
76
+ | `skillopt-sleep dry-run` | 执行阶段 1-3(有引擎则调 Python,无则 AI 模拟) |
77
+ | `skillopt-sleep run` | 执行阶段 1-5 |
78
+ | `skillopt-sleep adopt` | 采纳建议 |
63
79
 
64
- ## 触发建议
80
+ ## 内核
65
81
 
66
- - **每日一次**:工作开始时输入 `skillopt-sleep dry-run`,花 30 秒看报告
67
- - **周五总结**:输入 `skillopt-sleep run` 生成周改进提案
68
- - **出现相同错误 2 次后**:不用调,self-evolve rule 会自动触发单条规则创建
82
+ 执行引擎来自 [microsoft/SkillOpt](https://github.com/microsoft/SkillOpt) 由微软研究院开源的 skill 文档训练框架。