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.
Files changed (120) hide show
  1. package/.agents/plugins/marketplace.json +39 -0
  2. package/.agents/rules/ponytail.md +30 -0
  3. package/.claude-plugin/marketplace.json +17 -0
  4. package/.claude-plugin/plugin.json +35 -0
  5. package/.cline-plugin/plugin.json +35 -0
  6. package/.clinerules/chill-agent +274 -0
  7. package/.clinerules/ponytail.md +30 -0
  8. package/.codex-plugin/plugin.json +35 -0
  9. package/.cursor/rules/chill-agent.mdc +278 -0
  10. package/.cursor/rules/ponytail.mdc +36 -0
  11. package/.cursor-plugin/plugin.json +35 -0
  12. package/.devin-plugin/plugin.json +35 -0
  13. package/.grok-plugin/marketplace.json +16 -0
  14. package/.grok-plugin/plugin.json +35 -0
  15. package/.kimi-plugin/plugin.json +35 -0
  16. package/.kiro/steering/ponytail.md +35 -0
  17. package/.omp-plugin/plugin.json +35 -0
  18. package/.openclaw/skills/chill-audit/SKILL.md +103 -0
  19. package/.openclaw/skills/chill-debt/SKILL.md +44 -0
  20. package/.openclaw/skills/chill-gain/SKILL.md +52 -0
  21. package/.openclaw/skills/chill-help/SKILL.md +76 -0
  22. package/.openclaw/skills/chill-review/SKILL.md +101 -0
  23. package/.openclaw/skills/chill-slop/SKILL.md +274 -0
  24. package/.openclaw/skills/chill-slop-code/SKILL.md +93 -0
  25. package/.openclaw/skills/chill-slop-copywriting/SKILL.md +80 -0
  26. package/.openclaw/skills/chill-slop-human/SKILL.md +73 -0
  27. package/.openclaw/skills/chill-slop-mobile/SKILL.md +95 -0
  28. package/.openclaw/skills/chill-slop-ui/SKILL.md +114 -0
  29. package/.openclaw/skills/ponytail/SKILL.md +52 -0
  30. package/.openclaw/skills/ponytail-audit/SKILL.md +103 -0
  31. package/.openclaw/skills/ponytail-debt/SKILL.md +44 -0
  32. package/.openclaw/skills/ponytail-gain/SKILL.md +52 -0
  33. package/.openclaw/skills/ponytail-help/SKILL.md +76 -0
  34. package/.openclaw/skills/ponytail-review/SKILL.md +101 -0
  35. package/.opencode/command/chill-audit.toml +2 -0
  36. package/.opencode/command/chill-debt.toml +2 -0
  37. package/.opencode/command/chill-gain.toml +2 -0
  38. package/.opencode/command/chill-help.toml +2 -0
  39. package/.opencode/command/chill-review.toml +2 -0
  40. package/.opencode/command/chill.toml +2 -0
  41. package/.opencode/command/ponytail-audit.md +5 -0
  42. package/.opencode/command/ponytail-debt.md +5 -0
  43. package/.opencode/command/ponytail-gain.md +5 -0
  44. package/.opencode/command/ponytail-help.md +5 -0
  45. package/.opencode/command/ponytail-review.md +5 -0
  46. package/.opencode/command/ponytail.md +5 -0
  47. package/.opencode/plugins/index.js +4 -0
  48. package/.opencode/plugins/ponytail-frontmatter.cjs +63 -0
  49. package/.opencode/plugins/ponytail.mjs +206 -0
  50. package/.qoder-plugin/plugin.json +35 -0
  51. package/.windsurf/rules/chill-agent.md +274 -0
  52. package/.windsurf/rules/ponytail.md +30 -0
  53. package/AGENTS.md +19 -0
  54. package/__init__.py +228 -0
  55. package/benchmarks/README.md +10 -0
  56. package/benchmarks/loc.js +21 -0
  57. package/benchmarks/results/token-efficiency.md +10 -0
  58. package/commands/ponytail-audit.toml +2 -0
  59. package/commands/ponytail-debt.toml +2 -0
  60. package/commands/ponytail-gain.toml +2 -0
  61. package/commands/ponytail-help.toml +2 -0
  62. package/commands/ponytail-review.toml +2 -0
  63. package/commands/ponytail.toml +2 -0
  64. package/examples/README.md +8 -0
  65. package/examples/anti-slop-copy.md +7 -0
  66. package/examples/anti-slop-ui.md +14 -0
  67. package/examples/csv-sum.md +27 -0
  68. package/examples/debounce.md +22 -0
  69. package/examples/deep-clone.md +14 -0
  70. package/examples/modal-dialog.md +19 -0
  71. package/hooks/chill-activate.js +19 -0
  72. package/hooks/chill-mode-tracker.js +23 -0
  73. package/hooks/chill-statusline.ps1 +10 -0
  74. package/hooks/chill-statusline.sh +9 -0
  75. package/hooks/claude-codex-hooks.json +11 -0
  76. package/hooks/copilot-hooks.json +11 -0
  77. package/hooks/cursor-hooks.json +17 -0
  78. package/hooks/ponytail-activate.js +201 -0
  79. package/hooks/ponytail-instructions.js +98 -0
  80. package/hooks/ponytail-mode-tracker.js +216 -0
  81. package/hooks/ponytail-runtime.js +182 -0
  82. package/hooks/ponytail-statusline.ps1 +24 -0
  83. package/hooks/ponytail-statusline.sh +18 -0
  84. package/hooks/qoder-hooks.json +11 -0
  85. package/i18n/README.es.md +17 -0
  86. package/i18n/README.id.md +25 -0
  87. package/i18n/README.ja.md +17 -0
  88. package/i18n/README.zh-CN.md +17 -0
  89. package/package.json +29 -3
  90. package/pi-extension/index.js +254 -0
  91. package/pi-extension/package.json +8 -0
  92. package/scripts/check-rule-copies.js +74 -0
  93. package/scripts/check-versions.js +77 -0
  94. package/scripts/cursor-hooks.js +145 -0
  95. package/scripts/generate-chillslop.mjs +42 -0
  96. package/scripts/generate-examples.mjs +149 -0
  97. package/scripts/generate-plugin-doors.mjs +108 -0
  98. package/scripts/sync-ponytail.mjs +65 -0
  99. package/scripts/uninstall.js +92 -0
  100. package/skills/ponytail/SKILL.md +52 -0
  101. package/skills/ponytail-audit/SKILL.md +103 -0
  102. package/skills/ponytail-debt/SKILL.md +44 -0
  103. package/skills/ponytail-gain/SKILL.md +52 -0
  104. package/skills/ponytail-help/SKILL.md +76 -0
  105. package/skills/ponytail-review/SKILL.md +101 -0
  106. package/tests/commands.test.js +94 -0
  107. package/tests/copilot-plugin.test.js +35 -0
  108. package/tests/correctness.test.js +245 -0
  109. package/tests/cursor-hooks.test.js +343 -0
  110. package/tests/gemini-extension.test.js +91 -0
  111. package/tests/grok-plugin.test.js +39 -0
  112. package/tests/hermes-plugin.test.js +403 -0
  113. package/tests/hooks.test.js +1005 -0
  114. package/tests/kimi-plugin.test.js +25 -0
  115. package/tests/loc.test.js +18 -0
  116. package/tests/manifests.test.js +29 -0
  117. package/tests/openclaw-skills.test.js +26 -0
  118. package/tests/opencode-plugin.test.js +340 -0
  119. package/tests/qoder-plugin.test.js +84 -0
  120. package/tests/rules.test.js +34 -0
@@ -0,0 +1,254 @@
1
+ import { createRequire } from "node:module";
2
+
3
+ const require = createRequire(import.meta.url);
4
+ const {
5
+ DEFAULT_MODE,
6
+ RUNTIME_MODES,
7
+ getDefaultMode,
8
+ getQuietStartup,
9
+ getHideStatus,
10
+ normalizeMode,
11
+ normalizePersistedMode,
12
+ isDeactivationCommand,
13
+ writeDefaultMode,
14
+ } = require("../hooks/ponytail-config.js");
15
+ const { getPonytailInstructions, filterSkillBodyForMode } = require("../hooks/ponytail-instructions.js");
16
+
17
+ export { filterSkillBodyForMode };
18
+ export const readDefaultMode = getDefaultMode;
19
+ export const readQuietStartup = getQuietStartup;
20
+
21
+ const RUNTIME_MODE_LIST = RUNTIME_MODES.join("|");
22
+ const PONYTAIL_COMMAND_DESCRIPTION = `Set mode: ${RUNTIME_MODE_LIST}. Commands: status, default <mode>`;
23
+
24
+ // Every item is a complete command: pi submits on Enter, so a bare "default" would run without a mode.
25
+ // Values only: per-level descriptions would be a second copy of the Levels table in SKILL.md.
26
+ export function completePonytailArgs(prefix) {
27
+ const typed = String(prefix || "").trimStart();
28
+ const values = [...RUNTIME_MODES, "status", ...RUNTIME_MODES.map((m) => `default ${m}`)].filter((v) => v.startsWith(typed));
29
+ return values.length ? values.map((value) => ({ value, label: value })) : null;
30
+ }
31
+
32
+ export function resolveSessionMode(entries, fallbackMode = DEFAULT_MODE) {
33
+ const fallback = normalizePersistedMode(fallbackMode) || DEFAULT_MODE;
34
+ if (!Array.isArray(entries)) return fallback;
35
+
36
+ for (let i = entries.length - 1; i >= 0; i -= 1) {
37
+ const entry = entries[i];
38
+ if (entry?.type !== "custom" || entry?.customType !== "ponytail-mode") continue;
39
+
40
+ const mode = normalizePersistedMode(entry?.data?.mode);
41
+ if (mode) return mode;
42
+ }
43
+
44
+ return fallback;
45
+ }
46
+
47
+ export function parsePonytailCommand(text, defaultMode = DEFAULT_MODE, currentMode = null) {
48
+ const fallback = normalizePersistedMode(defaultMode) || DEFAULT_MODE;
49
+ const normalizedText = String(text || "").trim().toLowerCase();
50
+
51
+ if (!normalizedText) {
52
+ // Bare /ponytail switches ponytail on, or reports the level when it already is (#639).
53
+ if (currentMode && currentMode !== "off") return { type: "status" };
54
+ return { type: "set-mode", mode: fallback === "off" ? "full" : fallback };
55
+ }
56
+
57
+ const [primary, secondary] = normalizedText.split(/\s+/);
58
+
59
+ if (primary === "status") return { type: "status" };
60
+
61
+ if (primary === "default") {
62
+ // ponytail: a default must be a runtime level; review is session-only (#377).
63
+ const mode = normalizeMode(secondary);
64
+ return mode ? { type: "set-default", mode } : { type: "invalid", reason: "invalid-default-mode" };
65
+ }
66
+
67
+ const mode = normalizeMode(primary);
68
+ return mode ? { type: "set-mode", mode } : { type: "invalid", reason: "invalid-mode", mode: primary };
69
+ }
70
+
71
+ export { writeDefaultMode };
72
+
73
+ export default function ponytailExtension(pi) {
74
+ let currentMode = DEFAULT_MODE;
75
+ let configuredDefaultMode = getDefaultMode();
76
+ let hideStatus = getHideStatus();
77
+ let isActive = false;
78
+ let lastCtx = null;
79
+
80
+ // -- Status bar --
81
+ function syncStatus(ctx) {
82
+ if (ctx) lastCtx = ctx;
83
+ const c = ctx || lastCtx;
84
+ // ponytail: hide the indicator but keep the ruleset active (#324).
85
+ if (hideStatus) return;
86
+ if (!c?.ui?.setStatus) return;
87
+ // ponytail: try/catch guards against pi-web theme proxy throwing before initTheme
88
+ let theme;
89
+ try { theme = c.ui.theme; if (!theme?.fg) return; } catch { return; }
90
+ if (currentMode === "off") {
91
+ c.ui.setStatus("ponytail", undefined);
92
+ return;
93
+ }
94
+ const levelIcons = { lite: "🌿", full: "⚡", ultra: "🔥" };
95
+ const icon = levelIcons[currentMode] || "";
96
+ const label = currentMode.toUpperCase();
97
+ const indicator = isActive ? theme.fg("accent", "●") : theme.fg("dim", "○");
98
+ c.ui.setStatus("ponytail", indicator + " 🐴 " + theme.fg("muted", "ponytail: ") + theme.fg("text", icon + " " + label));
99
+ }
100
+
101
+ const setMode = (mode, ctx) => {
102
+ const normalized = normalizePersistedMode(mode);
103
+ if (!normalized) return;
104
+
105
+ currentMode = normalized;
106
+ pi.appendEntry("ponytail-mode", { mode: normalized });
107
+ syncStatus(ctx);
108
+ ctx?.ui?.notify?.(`Ponytail mode set to ${normalized}.`, "info");
109
+ };
110
+
111
+ const sendAlias = (skillName, args, ctx) => {
112
+ const normalized = String(args || "").trim();
113
+ const message = normalized ? `${skillName} ${normalized}` : skillName;
114
+
115
+ // pi.sendUserMessage does not expand skill commands on its own, so without
116
+ // expandPromptTemplates the alias lands as the literal text
117
+ // "/skill:ponytail-review" and the skill body never reaches the agent.
118
+ if (ctx?.isIdle?.() === false) {
119
+ pi.sendUserMessage(message, { expandPromptTemplates: true, deliverAs: "followUp" });
120
+ ctx?.ui?.notify?.(`${skillName} queued as follow-up.`, "info");
121
+ return;
122
+ }
123
+
124
+ pi.sendUserMessage(message, { expandPromptTemplates: true });
125
+ };
126
+
127
+ pi.registerCommand("ponytail", {
128
+ description: PONYTAIL_COMMAND_DESCRIPTION,
129
+ getArgumentCompletions: (prefix) => completePonytailArgs(prefix),
130
+ handler: async (args, ctx) => {
131
+ const parsed = parsePonytailCommand(args, configuredDefaultMode, currentMode);
132
+
133
+ if (parsed.type === "status") {
134
+ ctx?.ui?.notify?.(`Ponytail: current ${currentMode} • default ${configuredDefaultMode}`, "info");
135
+ return;
136
+ }
137
+
138
+ if (parsed.type === "set-default") {
139
+ try {
140
+ const written = writeDefaultMode(parsed.mode);
141
+ if (written) {
142
+ configuredDefaultMode = getDefaultMode();
143
+ const message = configuredDefaultMode === written
144
+ ? `Default Ponytail mode set to ${written}.`
145
+ : `Saved default ${written}, but env override keeps default at ${configuredDefaultMode}.`;
146
+ ctx?.ui?.notify?.(message, "info");
147
+ }
148
+ } catch (e) {
149
+ ctx?.ui?.notify?.(`Failed to save default mode: ${e.message}`, "error");
150
+ }
151
+ return;
152
+ }
153
+
154
+ if (parsed.type === "set-mode") {
155
+ setMode(parsed.mode, ctx);
156
+ return;
157
+ }
158
+
159
+ ctx?.ui?.notify?.("Unknown or unsupported /ponytail mode.", "warning");
160
+ },
161
+ });
162
+
163
+ pi.registerCommand("ponytail-review", {
164
+ description: "Run /skill:ponytail-review",
165
+ handler: (args, ctx) => sendAlias("/skill:ponytail-review", args, ctx),
166
+ });
167
+
168
+ pi.registerCommand("ponytail-audit", {
169
+ description: "Run /skill:ponytail-audit",
170
+ handler: (args, ctx) => sendAlias("/skill:ponytail-audit", args, ctx),
171
+ });
172
+
173
+ pi.registerCommand("ponytail-gain", {
174
+ description: "Run /skill:ponytail-gain",
175
+ handler: (args, ctx) => sendAlias("/skill:ponytail-gain", args, ctx),
176
+ });
177
+
178
+ pi.registerCommand("ponytail-debt", {
179
+ description: "Run /skill:ponytail-debt",
180
+ handler: (args, ctx) => sendAlias("/skill:ponytail-debt", args, ctx),
181
+ });
182
+
183
+ pi.registerCommand("ponytail-help", {
184
+ description: "Run /skill:ponytail-help",
185
+ handler: (args, ctx) => sendAlias("/skill:ponytail-help", args, ctx),
186
+ });
187
+
188
+ pi.on("input", async (event, ctx) => {
189
+ if (event?.source === "extension") return;
190
+
191
+ const text = String(event?.text || "");
192
+ if (currentMode !== "off" && isDeactivationCommand(text)) {
193
+ setMode("off", ctx);
194
+ }
195
+ });
196
+
197
+ const restoreSessionMode = (ctx) => {
198
+ const entries = ctx?.sessionManager?.getBranch?.() || ctx?.sessionManager?.getEntries?.() || [];
199
+ currentMode = resolveSessionMode(entries, configuredDefaultMode);
200
+ syncStatus(ctx);
201
+ };
202
+
203
+ pi.on("session_start", async (_event, ctx) => {
204
+ configuredDefaultMode = getDefaultMode();
205
+ hideStatus = getHideStatus();
206
+ restoreSessionMode(ctx);
207
+ if (!getQuietStartup()) {
208
+ ctx?.ui?.notify?.(`Ponytail loaded: ${currentMode}`, "info");
209
+ }
210
+ });
211
+
212
+ // Both hosts emit session_tree. Pi re-emits session_start on /new, /resume and
213
+ // /fork; OMP emits session_switch and session_branch instead.
214
+ for (const eventName of ["session_tree", "session_switch", "session_branch"]) {
215
+ pi.on(eventName, async (_event, ctx) => {
216
+ restoreSessionMode(ctx);
217
+ });
218
+ }
219
+
220
+ pi.on("agent_start", async (_event, ctx) => {
221
+ isActive = true;
222
+ syncStatus(ctx);
223
+ });
224
+
225
+ pi.on("agent_end", async (_event, ctx) => {
226
+ isActive = false;
227
+ syncStatus(ctx);
228
+ });
229
+
230
+ pi.on("before_agent_start", async (event) => {
231
+ if (!currentMode || currentMode === "off") {
232
+ // Clear a stale section when the mode is off so a previous turn does not linger (#953).
233
+ if (event?.systemPromptOptions?.sections) delete event.systemPromptOptions.sections.ponytail;
234
+ return;
235
+ }
236
+ const instructions = getPonytailInstructions(currentMode);
237
+ // Prefer structured sections so Pi can keep the cached prefix when other
238
+ // extensions change their own section (#953). Fall back to replacement
239
+ // for older Pi versions without systemPromptOptions.sections.
240
+ const sections = event?.systemPromptOptions?.sections;
241
+ if (sections && typeof sections === "object") {
242
+ sections.ponytail = instructions;
243
+ return;
244
+ }
245
+ // OMP passes the system prompt as an array of parts; keep it one (#776).
246
+ if (Array.isArray(event?.systemPrompt)) {
247
+ return { systemPrompt: [...event.systemPrompt, instructions] };
248
+ }
249
+ // Guard a null/undefined event or a missing systemPrompt: don't crash, and
250
+ // don't prepend the literal string "undefined" to the prompt (#439, #440).
251
+ const base = event?.systemPrompt ? `${event.systemPrompt}\n\n` : "";
252
+ return { systemPrompt: `${base}${instructions}` };
253
+ });
254
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "ponytail-pi-extension-dev",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "test": "node --test ./test/*.test.js"
7
+ }
8
+ }
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ const root = path.join(__dirname, '..');
6
+
7
+ function read(relPath) {
8
+ return fs.readFileSync(path.join(root, relPath), 'utf8').replace(/\r\n/g, '\n').trim();
9
+ }
10
+
11
+ function stripFrontmatter(text) {
12
+ return text.replace(/^---\n[\s\S]*?\n---\n*/, '').trim();
13
+ }
14
+
15
+ const agents = read('AGENTS.md');
16
+ const canonical = agents.replace(/\n\n\(Yes, this file also applies[\s\S]*?\)$/, '').trim();
17
+
18
+ // Compact copies: same body as AGENTS.md, host-specific frontmatter stripped.
19
+ const copies = [
20
+ ['.cursor/rules/ponytail.mdc', stripFrontmatter],
21
+ ['.windsurf/rules/ponytail.md', text => text.trim()],
22
+ ['.clinerules/ponytail.md', text => text.trim()],
23
+ ['.agents/rules/ponytail.md', text => text.trim()],
24
+ ['.qoder/rules/ponytail.md', text => text.trim()],
25
+ ['.github/copilot-instructions.md', text => text.trim()],
26
+ ['.kiro/steering/ponytail.md', stripFrontmatter],
27
+ ];
28
+
29
+ let failed = false;
30
+
31
+ for (const [relPath, normalize] of copies) {
32
+ const actual = normalize(read(relPath));
33
+ if (actual !== canonical) {
34
+ console.error(`${relPath} drifted from AGENTS.md`);
35
+ failed = true;
36
+ }
37
+ }
38
+
39
+ // SKILL.md is the runtime source of truth and is longer than the compact body,
40
+ // so it cannot be byte-compared. ponytail: canary, not full equality. Assert the
41
+ // load-bearing rules survive verbatim in both the source and AGENTS.md. Changing
42
+ // a rule's wording trips this, which is the reminder to propagate it everywhere.
43
+ // Upgrade path: generate the copies from SKILL.md if this ever misses a real drift.
44
+ const INVARIANTS = [
45
+ 'in this codebase', // ladder rung: reuse what already exists (#217)
46
+ 'grep every caller', // root-cause bug fix (#245)
47
+ 'never about the change itself', // scope: callers, tests and fixtures the change breaks
48
+ 'shortcut: <the limit>, <when to upgrade>', // shortcut marker comment
49
+ 'correct on edge cases', // robust-variant rule
50
+ 'Lazy code without its check is unfinished', // test reflex
51
+ // the "never cut" carve-outs: pin each so a reword in either file can't silently drop one.
52
+ 'validation at trust boundaries',
53
+ 'prevents data loss',
54
+ 'security',
55
+ 'accessibility',
56
+ ];
57
+
58
+ const skill = read('skills/ponytail/SKILL.md');
59
+ const sources = [['skills/ponytail/SKILL.md', skill], ['AGENTS.md', agents]];
60
+ for (const phrase of INVARIANTS) {
61
+ for (const [label, text] of sources) {
62
+ if (!text.includes(phrase)) {
63
+ console.error(`${label} is missing rule invariant: "${phrase}"`);
64
+ failed = true;
65
+ }
66
+ }
67
+ }
68
+
69
+ if (failed) {
70
+ console.error('Update the copied rule text, AGENTS.md, or SKILL.md so the shared rules match.');
71
+ process.exit(1);
72
+ }
73
+
74
+ console.log(`Rule copies match AGENTS.md; ${INVARIANTS.length} rule invariants present in SKILL.md and AGENTS.md.`);
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env node
2
+ // Version-consistency guard. Ponytail declares its version in seven files across
3
+ // five host ecosystems, and every release bumps all of them by hand.
4
+ //
5
+ // tests/gemini-extension.test.js already checks the four plugin manifests agree
6
+ // with each other, but that can't catch the failure mode that shipped in v4.8.0:
7
+ // every manifest stayed stale at 4.7.0 *together* while the release moved on, so
8
+ // they "agreed" and the test passed (#260, #262). It also ignores the two
9
+ // package.json files. This check closes both gaps:
10
+ // 1. every version-bearing file must share one pinned X.Y.Z version, and
11
+ // 2. on a release-tag CI run, that shared version must equal the tag.
12
+
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+
16
+ const root = path.join(__dirname, '..');
17
+ const PINNED_SEMVER = /^\d+\.\d+\.\d+$/;
18
+
19
+ // Every file that declares the project version, and who reads it. Add new host
20
+ // manifests here so a future ecosystem can't drift unnoticed.
21
+ const VERSION_FILES = [
22
+ '.claude-plugin/plugin.json', // Claude Code plugin — what users install
23
+ '.codex-plugin/plugin.json', // Codex plugin
24
+ '.devin-plugin/plugin.json', // Devin CLI plugin
25
+ '.github/plugin/plugin.json', // Copilot plugin
26
+ '.qoder-plugin/plugin.json', // Qoder plugin
27
+ 'gemini-extension.json', // Gemini CLI extension
28
+ 'package.json', // pi-package / repo root
29
+ ];
30
+
31
+ function readVersion(relPath) {
32
+ try {
33
+ // Strip a UTF-8 BOM some Windows editors prepend (breaks JSON.parse).
34
+ const raw = fs.readFileSync(path.join(root, relPath), 'utf8').replace(/^\uFEFF/, '');
35
+ return JSON.parse(raw).version;
36
+ } catch (e) {
37
+ throw new Error(`${relPath}: ${e.message}`);
38
+ }
39
+ }
40
+
41
+ let failed = false;
42
+ const versions = VERSION_FILES.map((relPath) => {
43
+ const version = readVersion(relPath);
44
+ if (typeof version !== 'string' || !PINNED_SEMVER.test(version)) {
45
+ console.error(`${relPath}: version must be a pinned X.Y.Z semver, got ${JSON.stringify(version)}`);
46
+ failed = true;
47
+ }
48
+ return [relPath, version];
49
+ });
50
+
51
+ // Every file must declare the same version.
52
+ const distinct = [...new Set(versions.map(([, v]) => v))];
53
+ if (distinct.length > 1) {
54
+ console.error('Version mismatch — every manifest must share one version:');
55
+ for (const [relPath, version] of versions) console.error(` ${version}\t${relPath}`);
56
+ failed = true;
57
+ }
58
+ const shared = distinct.length === 1 ? distinct[0] : null;
59
+
60
+ // On a release-tag push CI sets GITHUB_REF_TYPE=tag and GITHUB_REF_NAME=vX.Y.Z.
61
+ // The shared version must equal the tag — this catches tagging a release whose
62
+ // version files were never bumped, which mutual agreement alone cannot.
63
+ if (shared && process.env.GITHUB_REF_TYPE === 'tag') {
64
+ const tag = process.env.GITHUB_REF_NAME || '';
65
+ const tagVersion = tag.replace(/^v/, '');
66
+ if (PINNED_SEMVER.test(tagVersion) && tagVersion !== shared) {
67
+ console.error(`release tag ${tag} does not match version ${shared}; bump the version files before tagging`);
68
+ failed = true;
69
+ }
70
+ }
71
+
72
+ if (failed) {
73
+ console.error('Align the version fields (see issue #260) so every manifest shares one version.');
74
+ process.exit(1);
75
+ }
76
+
77
+ console.log(`All ${VERSION_FILES.length} version files pinned at ${shared}.`);
@@ -0,0 +1,145 @@
1
+ #!/usr/bin/env node
2
+ // ponytail — install or remove the Cursor hooks (hooks/cursor-hooks.json) in
3
+ // ~/.cursor/hooks.json (default) or <cwd>/.cursor/hooks.json (--project),
4
+ // merging with whatever hooks are already there. Only entries that run one of
5
+ // ponytail's own hooks/ponytail-*.js scripts are added or removed; every other
6
+ // hook stays as it was.
7
+ //
8
+ // node scripts/cursor-hooks.js install [--project]
9
+ // node scripts/cursor-hooks.js uninstall [--project]
10
+
11
+ const fs = require('fs');
12
+ const os = require('os');
13
+ const path = require('path');
14
+ const { isShellSafe } = require('../hooks/ponytail-config');
15
+
16
+ const ROOT = path.join(__dirname, '..');
17
+ const TEMPLATE = path.join(ROOT, 'hooks', 'cursor-hooks.json');
18
+ const PONYTAIL_HOOK = /[\\/]hooks[\\/]ponytail-[\w-]+\.js(?=["'\s]|$)/;
19
+
20
+ function isPonytailHook(entry) {
21
+ return Boolean(entry && typeof entry.command === 'string' && PONYTAIL_HOOK.test(entry.command));
22
+ }
23
+
24
+ function hooksPath(scope) {
25
+ return scope === 'project'
26
+ ? path.join(process.cwd(), '.cursor', 'hooks.json')
27
+ : path.join(os.homedir(), '.cursor', 'hooks.json');
28
+ }
29
+
30
+ // Missing file → empty config. Malformed JSON throws a SyntaxError so the
31
+ // caller can refuse to touch the file rather than overwrite it.
32
+ function readConfig(file) {
33
+ let config = {};
34
+ try {
35
+ config = JSON.parse(fs.readFileSync(file, 'utf8').replace(/^\uFEFF/, ''));
36
+ } catch (e) {
37
+ if (e.code !== 'ENOENT') throw e;
38
+ }
39
+ if (!config || typeof config !== 'object' || Array.isArray(config)) {
40
+ throw new Error(file + ' must contain a JSON object; nothing was changed');
41
+ }
42
+ if (config.hooks === undefined) config.hooks = {};
43
+ if (!config.hooks || typeof config.hooks !== 'object' || Array.isArray(config.hooks)) {
44
+ throw new Error(file + ': hooks must be an object; nothing was changed');
45
+ }
46
+ for (const [event, entries] of Object.entries(config.hooks)) {
47
+ if (!Array.isArray(entries)) {
48
+ throw new Error(file + ': hooks.' + event + ' must be an array; nothing was changed');
49
+ }
50
+ }
51
+ return config;
52
+ }
53
+
54
+ function writeConfig(file, config) {
55
+ fs.mkdirSync(path.dirname(file), { recursive: true });
56
+ fs.writeFileSync(file, JSON.stringify(config, null, 2) + '\n', 'utf8');
57
+ }
58
+
59
+ // The template's PONYTAIL_DIR placeholder becomes this checkout's absolute
60
+ // path. Forward slashes run unchanged under cmd, PowerShell and bash, and the
61
+ // same allowlist that guards the statusline snippet keeps shell metacharacters
62
+ // out of the command string.
63
+ function ponytailEntries() {
64
+ const root = ROOT.replace(/\\/g, '/');
65
+ if (!isShellSafe(root)) {
66
+ throw new Error('ponytail is checked out at a path with shell metacharacters (' + ROOT +
67
+ '); move it, or copy hooks/cursor-hooks.json by hand and quote the path for your shell');
68
+ }
69
+ const template = JSON.parse(fs.readFileSync(TEMPLATE, 'utf8'));
70
+ const hooks = {};
71
+ for (const [event, entries] of Object.entries(template.hooks)) {
72
+ hooks[event] = entries.map((entry) => ({ ...entry, command: entry.command.replace(/PONYTAIL_DIR/g, root) }));
73
+ }
74
+ return hooks;
75
+ }
76
+
77
+ function stripPonytail(config) {
78
+ for (const [event, entries] of Object.entries(config.hooks)) {
79
+ if (!Array.isArray(entries)) continue;
80
+ const kept = entries.filter((entry) => !isPonytailHook(entry));
81
+ if (kept.length) config.hooks[event] = kept;
82
+ else delete config.hooks[event];
83
+ }
84
+ }
85
+
86
+ function install(scope) {
87
+ const file = hooksPath(scope);
88
+ const config = readConfig(file);
89
+ if (config.version === undefined) config.version = 1;
90
+ // Re-running replaces stale ponytail entries instead of duplicating them.
91
+ stripPonytail(config);
92
+ for (const [event, entries] of Object.entries(ponytailEntries())) {
93
+ config.hooks[event] = [...(config.hooks[event] || []), ...entries];
94
+ }
95
+ writeConfig(file, config);
96
+ return file;
97
+ }
98
+
99
+ // Returns the file it changed, or null when there was nothing of ponytail's in it.
100
+ function uninstall(scope) {
101
+ const file = hooksPath(scope);
102
+ if (!fs.existsSync(file)) return null;
103
+ const config = readConfig(file);
104
+ const before = JSON.stringify(config);
105
+ stripPonytail(config);
106
+ if (JSON.stringify(config) === before) return null;
107
+ const otherKeys = Object.keys(config).filter((k) => k !== 'version' && k !== 'hooks');
108
+ if (Object.keys(config.hooks).length === 0 && otherKeys.length === 0) {
109
+ // Only ponytail lived here: drop the file rather than leave an empty husk.
110
+ fs.unlinkSync(file);
111
+ } else {
112
+ writeConfig(file, config);
113
+ }
114
+ return file;
115
+ }
116
+
117
+ if (require.main === module) {
118
+ const args = process.argv.slice(2);
119
+ const action = args[0];
120
+ const scope = args.includes('--project') ? 'project' : 'user';
121
+ try {
122
+ if (action === 'install') {
123
+ const file = install(scope);
124
+ console.log('Installed ponytail hooks in ' + file);
125
+ console.log('Cursor reloads hooks.json on save; start a new chat to activate.');
126
+ } else if (action === 'uninstall') {
127
+ const file = uninstall(scope);
128
+ console.log(file
129
+ ? 'Removed ponytail hooks from ' + file
130
+ : 'No ponytail hooks in ' + hooksPath(scope));
131
+ } else {
132
+ console.error('usage: node scripts/cursor-hooks.js install|uninstall [--project]');
133
+ process.exit(1);
134
+ }
135
+ } catch (e) {
136
+ if (e instanceof SyntaxError) {
137
+ console.error(hooksPath(scope) + ' is not valid JSON; nothing was changed, fix it by hand (' + e.message + ')');
138
+ } else {
139
+ console.error(e.message);
140
+ }
141
+ process.exit(1);
142
+ }
143
+ }
144
+
145
+ module.exports = { hooksPath, install, isPonytailHook, uninstall };
@@ -0,0 +1,42 @@
1
+ // scripts/generate-chillslop.mjs
2
+ import fs from 'node:fs';
3
+
4
+ let text = fs.readFileSync('antislop.raw.md', 'utf8');
5
+
6
+ text = text.replace(
7
+ /# antislop\n\n> Anti Slop: Rules for AI Coding Agents/g,
8
+ '# ChillSlop 2.0: Anti-Slop & Pragmatic Senior Dev Standard\n\n> Dual Core: Anti-Slop (miqdadbadjuber) + Ponytail (dietrichgebert) + ChillRewind Time-Travel'
9
+ );
10
+
11
+ text = text.replace(/antislop/g, 'chill-agent');
12
+ text = text.replace(/Anti Slop/g, 'ChillAgent Anti-Slop & Ponytail Core');
13
+
14
+ const ponytailHeader = `
15
+ ## The Pragmatic Senior Dev Creed (Ponytail Synthesis)
16
+
17
+ > **"The best code is the code you never wrote. The best design is the interface that gets out of the user's way."**
18
+
19
+ Active for the whole session until the user says "stop chill" or "normal mode".
20
+ Switch intensity mode: \`/chill [lite|full|ultra]\`.
21
+
22
+ ### The 6-Step Minimalist Execution Ladder
23
+ Take the first option that completely solves the problem:
24
+ 1. **Does it need to exist?** Skip features, options, and flexibility nobody asked for.
25
+ 2. **Already in this codebase?** Use existing helpers, components, and services.
26
+ 3. **Standard library or native platform?** Reach for \`node:*\`, native \`fetch\`, CSS Grid, native \`<dialog>\`.
27
+ 4. **Already-installed dependency?** Use what exists in \`package.json\`. Never add an npm package for 10 lines.
28
+ 5. **Can it be a single readable line?** Write the single line.
29
+ 6. **Otherwise:** The minimum code that works reliably.
30
+
31
+ Be lazy about the solution, never about the change itself: finish every caller, test, fixture, and edge case your change touches. Deletion beats addition.
32
+ `;
33
+
34
+ text = text.replace('## Core Principle', ponytailHeader + '\n## Core Principle');
35
+
36
+ fs.writeFileSync('chillslop.md', text, 'utf8');
37
+ fs.writeFileSync('antislop.md', text, 'utf8');
38
+ fs.writeFileSync('rules/chillslop.md', text, 'utf8');
39
+ fs.writeFileSync('rules/antislop.md', text, 'utf8');
40
+ fs.writeFileSync('rules/chillslop.mdc', text, 'utf8');
41
+
42
+ console.log('Successfully generated full-length master rules (chars: ' + text.length + ')');