@herbertgao/pi-extensions 2026.8.1 → 2026.8.2

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 (162) hide show
  1. package/README.md +5 -2
  2. package/node_modules/@czottmann/pi-automode/README.md +16 -2
  3. package/node_modules/@czottmann/pi-automode/docs/GLOSSARY.md +35 -0
  4. package/node_modules/@czottmann/pi-automode/docs/automode-classifier-flow.md +18 -9
  5. package/node_modules/@czottmann/pi-automode/docs/defaults.md +6 -2
  6. package/node_modules/@czottmann/pi-automode/examples/automode.local.json +6 -0
  7. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/classifier.ts +11 -7
  8. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/config.ts +100 -0
  9. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/constants.ts +32 -0
  10. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/extension.ts +78 -3
  11. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/hard-deny.ts +16 -4
  12. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/paths.ts +23 -1
  13. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/permissions.ts +22 -1
  14. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/types.ts +18 -2
  15. package/node_modules/@czottmann/pi-automode/package.json +4 -4
  16. package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-audit.md +5 -0
  17. package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-debt.md +5 -0
  18. package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-gain.md +5 -0
  19. package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-help.md +5 -0
  20. package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-review.md +5 -0
  21. package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail.md +5 -0
  22. package/node_modules/@dietrichgebert/ponytail/.opencode/plugins/ponytail-frontmatter.cjs +23 -0
  23. package/node_modules/@dietrichgebert/ponytail/.opencode/plugins/ponytail.mjs +99 -0
  24. package/node_modules/@dietrichgebert/ponytail/.qoder/rules/ponytail.md +30 -0
  25. package/node_modules/@dietrichgebert/ponytail/.qoder-plugin/plugin.json +16 -0
  26. package/node_modules/@dietrichgebert/ponytail/AGENTS.md +32 -0
  27. package/node_modules/@dietrichgebert/ponytail/LICENSE +21 -0
  28. package/node_modules/@dietrichgebert/ponytail/README.es.md +298 -0
  29. package/node_modules/@dietrichgebert/ponytail/README.ko.md +315 -0
  30. package/node_modules/@dietrichgebert/ponytail/README.md +351 -0
  31. package/node_modules/@dietrichgebert/ponytail/assets/benchmark-3model.svg +21 -0
  32. package/node_modules/@dietrichgebert/ponytail/assets/benchmark-agentic.svg +62 -0
  33. package/node_modules/@dietrichgebert/ponytail/assets/logo-dark.png +0 -0
  34. package/node_modules/@dietrichgebert/ponytail/assets/logo-dark.svg +115 -0
  35. package/node_modules/@dietrichgebert/ponytail/assets/logo-greenpt-dark.svg +27 -0
  36. package/node_modules/@dietrichgebert/ponytail/assets/logo-greenpt.svg +27 -0
  37. package/node_modules/@dietrichgebert/ponytail/assets/logo.png +0 -0
  38. package/node_modules/@dietrichgebert/ponytail/assets/social-preview.png +0 -0
  39. package/node_modules/@dietrichgebert/ponytail/assets/waitlist-banner-es.png +0 -0
  40. package/node_modules/@dietrichgebert/ponytail/assets/waitlist-banner-ko.png +0 -0
  41. package/node_modules/@dietrichgebert/ponytail/assets/waitlist-banner.png +0 -0
  42. package/node_modules/@dietrichgebert/ponytail/hooks/claude-codex-hooks.json +44 -0
  43. package/node_modules/@dietrichgebert/ponytail/hooks/copilot-hooks.json +21 -0
  44. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-activate.js +96 -0
  45. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-config.js +169 -0
  46. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-instructions.js +98 -0
  47. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-mode-tracker.js +130 -0
  48. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-runtime.js +85 -0
  49. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-statusline.ps1 +24 -0
  50. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-statusline.sh +18 -0
  51. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-subagent.js +77 -0
  52. package/node_modules/@dietrichgebert/ponytail/hooks/qoder-hooks.json +26 -0
  53. package/node_modules/@dietrichgebert/ponytail/package.json +47 -0
  54. package/node_modules/@dietrichgebert/ponytail/pi-extension/index.js +211 -0
  55. package/node_modules/@dietrichgebert/ponytail/pi-extension/package.json +8 -0
  56. package/node_modules/@dietrichgebert/ponytail/scripts/uninstall.js +60 -0
  57. package/node_modules/@dietrichgebert/ponytail/skills/ponytail/SKILL.md +120 -0
  58. package/node_modules/@dietrichgebert/ponytail/skills/ponytail-audit/SKILL.md +41 -0
  59. package/node_modules/@dietrichgebert/ponytail/skills/ponytail-debt/SKILL.md +44 -0
  60. package/node_modules/@dietrichgebert/ponytail/skills/ponytail-gain/SKILL.md +50 -0
  61. package/node_modules/@dietrichgebert/ponytail/skills/ponytail-help/SKILL.md +71 -0
  62. package/node_modules/@dietrichgebert/ponytail/skills/ponytail-review/SKILL.md +57 -0
  63. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +1 -3
  64. package/node_modules/@herbertgao/pi-cc-extensions/README.md +1 -3
  65. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +10 -6
  66. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/agent-summary.ts +6 -2
  67. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +24 -83
  68. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +1 -1
  69. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/markdown-enhance.ts +119 -0
  70. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +73 -9
  71. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/index.ts +2 -2
  72. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse-hover.ts +130 -0
  73. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse-interaction.ts +65 -542
  74. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse-layout.ts +160 -0
  75. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse-packets.ts +143 -0
  76. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse-scroll.ts +184 -0
  77. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool-diff/diff-renderer.ts +2 -2
  78. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool-grouping.ts +9 -2
  79. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/transcript-refresh.ts +91 -0
  80. package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/agent-summary.ts +1 -1
  81. package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -3
  82. package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-dark.json +1 -0
  83. package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-light.json +2 -2
  84. package/node_modules/@herbertgao/pi-stash/README.md +9 -9
  85. package/node_modules/@herbertgao/pi-stash/package.json +1 -1
  86. package/node_modules/@herbertgao/pi-stash/src/index.ts +2 -1
  87. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +14 -0
  88. package/node_modules/@herbertgao/pi-subagents/README.md +6 -2
  89. package/node_modules/@herbertgao/pi-subagents/package.json +3 -3
  90. package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +85 -11
  91. package/node_modules/@herbertgao/pi-subagents/src/index.ts +28 -4
  92. package/node_modules/@herbertgao/pi-subagents/src/settings.ts +12 -0
  93. package/node_modules/@herbertgao/pi-subagents/src/types.ts +2 -0
  94. package/node_modules/@narumitw/pi-btw/LICENSE +21 -0
  95. package/node_modules/@narumitw/pi-btw/README.md +210 -0
  96. package/node_modules/@narumitw/pi-btw/package.json +53 -0
  97. package/node_modules/@narumitw/pi-btw/src/bring-to-main.ts +632 -0
  98. package/node_modules/@narumitw/pi-btw/src/btw.ts +996 -0
  99. package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +339 -0
  100. package/node_modules/@narumitw/pi-btw/src/index.ts +1 -0
  101. package/node_modules/@narumitw/pi-btw/src/menu.ts +296 -0
  102. package/node_modules/@narumitw/pi-btw/src/settings.ts +237 -0
  103. package/node_modules/@narumitw/pi-btw/src/side-thread.ts +238 -0
  104. package/node_modules/@narumitw/pi-btw/src/text.ts +10 -0
  105. package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +620 -0
  106. package/node_modules/@pi-plugins/fast-mode/LICENSE +21 -0
  107. package/node_modules/@pi-plugins/fast-mode/README.md +92 -0
  108. package/node_modules/@pi-plugins/fast-mode/dist/index.d.mts +6 -0
  109. package/node_modules/@pi-plugins/fast-mode/dist/index.d.mts.map +1 -0
  110. package/node_modules/@pi-plugins/fast-mode/dist/index.mjs +2026 -0
  111. package/node_modules/@pi-plugins/fast-mode/dist/index.mjs.map +1 -0
  112. package/node_modules/@pi-plugins/fast-mode/package.json +73 -0
  113. package/node_modules/pi-mcp-adapter/CHANGELOG.md +59 -0
  114. package/node_modules/pi-mcp-adapter/README.md +62 -13
  115. package/node_modules/pi-mcp-adapter/agent-plugin-loader.ts +377 -0
  116. package/node_modules/pi-mcp-adapter/commands.ts +9 -7
  117. package/node_modules/pi-mcp-adapter/config.ts +110 -49
  118. package/node_modules/pi-mcp-adapter/direct-tools.ts +34 -19
  119. package/node_modules/pi-mcp-adapter/elicitation-handler.ts +37 -36
  120. package/node_modules/pi-mcp-adapter/errors.ts +21 -17
  121. package/node_modules/pi-mcp-adapter/host-html-template.ts +13 -7
  122. package/node_modules/pi-mcp-adapter/index.ts +37 -14
  123. package/node_modules/pi-mcp-adapter/init.ts +9 -7
  124. package/node_modules/pi-mcp-adapter/json-schema-validator.ts +2 -2
  125. package/node_modules/pi-mcp-adapter/lifecycle.ts +8 -8
  126. package/node_modules/pi-mcp-adapter/logger.ts +1 -1
  127. package/node_modules/pi-mcp-adapter/mcp-auth-flow.ts +36 -22
  128. package/node_modules/pi-mcp-adapter/mcp-auth.ts +120 -2
  129. package/node_modules/pi-mcp-adapter/mcp-code.ts +13 -11
  130. package/node_modules/pi-mcp-adapter/mcp-oauth-provider.ts +19 -13
  131. package/node_modules/pi-mcp-adapter/mcp-output-guard.ts +15 -11
  132. package/node_modules/pi-mcp-adapter/mcp-panel.ts +34 -15
  133. package/node_modules/pi-mcp-adapter/mcp-probe.ts +131 -34
  134. package/node_modules/pi-mcp-adapter/mcp-script-worker.mjs +2 -2
  135. package/node_modules/pi-mcp-adapter/mcp-setup-panel.ts +7 -4
  136. package/node_modules/pi-mcp-adapter/mcp-trace.ts +59 -64
  137. package/node_modules/pi-mcp-adapter/metadata-cache.ts +34 -26
  138. package/node_modules/pi-mcp-adapter/npx-resolver.ts +6 -4
  139. package/node_modules/pi-mcp-adapter/oauth-handler.ts +1 -1
  140. package/node_modules/pi-mcp-adapter/onboarding-state.ts +19 -11
  141. package/node_modules/pi-mcp-adapter/package.json +13 -8
  142. package/node_modules/pi-mcp-adapter/panel-keys.ts +20 -4
  143. package/node_modules/pi-mcp-adapter/prompts.ts +2 -2
  144. package/node_modules/pi-mcp-adapter/proxy-modes.ts +48 -11
  145. package/node_modules/pi-mcp-adapter/sampling-handler.ts +22 -15
  146. package/node_modules/pi-mcp-adapter/search-ranking.ts +2 -1
  147. package/node_modules/pi-mcp-adapter/server-manager.ts +165 -113
  148. package/node_modules/pi-mcp-adapter/session-recovery.ts +11 -12
  149. package/node_modules/pi-mcp-adapter/skills/mcp-scripting/SKILL.md +3 -3
  150. package/node_modules/pi-mcp-adapter/state.ts +3 -1
  151. package/node_modules/pi-mcp-adapter/tool-approval.ts +67 -4
  152. package/node_modules/pi-mcp-adapter/tool-metadata.ts +6 -5
  153. package/node_modules/pi-mcp-adapter/tool-result-renderer.ts +14 -2
  154. package/node_modules/pi-mcp-adapter/ts-shape.ts +9 -2
  155. package/node_modules/pi-mcp-adapter/types.ts +109 -22
  156. package/node_modules/pi-mcp-adapter/ui-app-bridge-helpers.ts +40 -0
  157. package/node_modules/pi-mcp-adapter/ui-resource-handler.ts +28 -19
  158. package/node_modules/pi-mcp-adapter/ui-server.ts +90 -58
  159. package/node_modules/pi-mcp-adapter/ui-session.ts +16 -14
  160. package/node_modules/pi-mcp-adapter/unix-socket-transport.ts +4 -4
  161. package/node_modules/pi-mcp-adapter/utils.ts +23 -9
  162. package/package.json +22 -7
@@ -0,0 +1,169 @@
1
+ #!/usr/bin/env node
2
+ // ponytail — shared configuration resolver
3
+ //
4
+ // Resolution order for default mode:
5
+ // 1. PONYTAIL_DEFAULT_MODE environment variable
6
+ // 2. Config file defaultMode field:
7
+ // - $XDG_CONFIG_HOME/ponytail/config.json (any platform, if set)
8
+ // - ~/.config/ponytail/config.json (macOS / Linux fallback)
9
+ // - %APPDATA%\ponytail\config.json (Windows fallback)
10
+ // 3. 'full'
11
+
12
+ const fs = require('fs');
13
+ const path = require('path');
14
+ const os = require('os');
15
+
16
+ const DEFAULT_MODE = 'full';
17
+ const VALID_MODES = ['off', 'lite', 'full', 'ultra', 'review'];
18
+ const RUNTIME_MODES = ['off', 'lite', 'full', 'ultra'];
19
+
20
+ function normalizeMode(mode) {
21
+ if (typeof mode !== 'string') return null;
22
+ const normalized = mode.trim().toLowerCase();
23
+ return RUNTIME_MODES.includes(normalized) ? normalized : null;
24
+ }
25
+
26
+ function normalizeConfigMode(mode) {
27
+ if (typeof mode !== 'string') return null;
28
+ const normalized = mode.trim().toLowerCase();
29
+ return VALID_MODES.includes(normalized) ? normalized : null;
30
+ }
31
+
32
+ function normalizePersistedMode(mode) {
33
+ return normalizeMode(mode) || normalizeConfigMode(mode);
34
+ }
35
+
36
+ // "stop ponytail" / "normal mode" turn ponytail off, but only as a standalone
37
+ // command. Matching the phrase anywhere in the message turned it off mid-task
38
+ // for ordinary requests like "add a normal mode toggle" — so require the whole
39
+ // message to be the command, ignoring case and trailing punctuation.
40
+ function isDeactivationCommand(text) {
41
+ const t = String(text || '').trim().toLowerCase().replace(/[.!?\s]+$/, '');
42
+ return t === 'stop ponytail' || t === 'normal mode';
43
+ }
44
+
45
+ // ponytail: only embed the plugin install path in a statusline shell command when
46
+ // it's made of ordinary path characters. An allowlist beats escaping every shell's
47
+ // metacharacters; a hostile clone path (quotes, &, $, backtick, ;, etc.) falls back
48
+ // to manual setup instead. Allows : \ / for normal Windows and POSIX paths. Full
49
+ // per-shell escaper only if a real need appears.
50
+ function isShellSafe(p) {
51
+ return typeof p === 'string' && /^[A-Za-z0-9 _.\-:/\\~]+$/.test(p);
52
+ }
53
+
54
+ function getConfigDir() {
55
+ if (process.env.XDG_CONFIG_HOME) {
56
+ return path.join(process.env.XDG_CONFIG_HOME, 'ponytail');
57
+ }
58
+ if (process.platform === 'win32') {
59
+ return path.join(
60
+ process.env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming'),
61
+ 'ponytail'
62
+ );
63
+ }
64
+ return path.join(os.homedir(), '.config', 'ponytail');
65
+ }
66
+
67
+ function getConfigPath() {
68
+ return path.join(getConfigDir(), 'config.json');
69
+ }
70
+
71
+ function getClaudeDir() {
72
+ // ponytail: CLAUDE_CONFIG_DIR overrides ~/.claude, matching Claude Code.
73
+ return process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude');
74
+ }
75
+
76
+ function getDefaultMode() {
77
+ // 1. Environment variable (highest priority)
78
+ const envMode = process.env.PONYTAIL_DEFAULT_MODE;
79
+ // ponytail: a default must be a runtime level (off/lite/full/ultra); review is
80
+ // a session-only mode, never a valid default (#377). Validate against
81
+ // RUNTIME_MODES so a stray env var or config can't make review the default.
82
+ if (envMode && RUNTIME_MODES.includes(envMode.toLowerCase())) {
83
+ return envMode.toLowerCase();
84
+ }
85
+
86
+ // 2. Config file
87
+ try {
88
+ const configPath = getConfigPath();
89
+ // Strip UTF-8 BOM (common on Windows-saved files) so JSON.parse doesn't choke
90
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8').replace(/^\uFEFF/, ''));
91
+ if (config.defaultMode && RUNTIME_MODES.includes(config.defaultMode.toLowerCase())) {
92
+ return config.defaultMode.toLowerCase();
93
+ }
94
+ } catch (e) {
95
+ // Config file doesn't exist or is invalid — fall through
96
+ }
97
+
98
+ // 3. Default
99
+ return DEFAULT_MODE;
100
+ }
101
+
102
+ // Silence the pi "Ponytail loaded" startup toast while keeping ponytail active.
103
+ // PONYTAIL_QUIET_STARTUP=1 (or any truthy value; 0/false/empty mean "show it")
104
+ // takes precedence, else config.quietStartup === true. Mirrors getHideStatus.
105
+ function getQuietStartup() {
106
+ const env = process.env.PONYTAIL_QUIET_STARTUP;
107
+ if (env !== undefined) {
108
+ const v = env.trim().toLowerCase();
109
+ return v !== '' && v !== '0' && v !== 'false' && v !== 'no';
110
+ }
111
+ try {
112
+ const config = JSON.parse(fs.readFileSync(getConfigPath(), 'utf8').replace(/^\uFEFF/, ''));
113
+ return config.quietStartup === true;
114
+ } catch (_) {
115
+ return false;
116
+ }
117
+ }
118
+
119
+ // Hide the status-bar indicator while keeping ponytail active (#324).
120
+ // PONYTAIL_HIDE_STATUS=1 (or any truthy value; 0/false/empty mean "don't hide")
121
+ // takes precedence, else config.hideStatus === true.
122
+ function getHideStatus() {
123
+ const env = process.env.PONYTAIL_HIDE_STATUS;
124
+ if (env !== undefined) {
125
+ const v = env.trim().toLowerCase();
126
+ return v !== '' && v !== '0' && v !== 'false' && v !== 'no';
127
+ }
128
+ try {
129
+ const config = JSON.parse(fs.readFileSync(getConfigPath(), 'utf8').replace(/^\uFEFF/, ''));
130
+ return config.hideStatus === true;
131
+ } catch (_) {
132
+ return false;
133
+ }
134
+ }
135
+
136
+ function writeDefaultMode(mode) {
137
+ // ponytail: only a runtime level can be a default; review is session-only (#377).
138
+ const normalized = normalizeMode(mode);
139
+ if (!normalized) return null;
140
+
141
+ const configPath = getConfigPath();
142
+ fs.mkdirSync(path.dirname(configPath), { recursive: true });
143
+ let config = {};
144
+ try {
145
+ config = JSON.parse(fs.readFileSync(configPath, 'utf8').replace(/^\uFEFF/, ''));
146
+ if (!config || typeof config !== 'object' || Array.isArray(config)) config = {};
147
+ } catch (_) {}
148
+ config.defaultMode = normalized;
149
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf8');
150
+ return normalized;
151
+ }
152
+
153
+ module.exports = {
154
+ DEFAULT_MODE,
155
+ VALID_MODES,
156
+ RUNTIME_MODES,
157
+ getDefaultMode,
158
+ getConfigDir,
159
+ getConfigPath,
160
+ getClaudeDir,
161
+ getHideStatus,
162
+ getQuietStartup,
163
+ isShellSafe,
164
+ normalizeMode,
165
+ normalizeConfigMode,
166
+ normalizePersistedMode,
167
+ isDeactivationCommand,
168
+ writeDefaultMode,
169
+ };
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+ // Shared Ponytail instruction builder for Claude hooks and Pi extension.
3
+
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const { DEFAULT_MODE, normalizeMode, normalizePersistedMode } = require('./ponytail-config');
7
+
8
+ const INDEPENDENT_MODES = new Set(['review']);
9
+ const SKILL_PATH = path.join(__dirname, '..', 'skills', 'ponytail', 'SKILL.md');
10
+
11
+ function filterSkillBodyForMode(body, mode) {
12
+ const effectiveMode = normalizeMode(mode) || DEFAULT_MODE;
13
+ const withoutFrontmatter = String(body || '').replace(/^---[\s\S]*?---\s*/, '');
14
+
15
+ // Only the intensity table rows and worked examples are mode-specific, and
16
+ // both are keyed by a mode name (lite/full/ultra). A bullet whose label is
17
+ // not a mode — e.g. "No unrequested abstractions: ..." — is a normal rule
18
+ // and must be kept verbatim.
19
+ return withoutFrontmatter
20
+ .split(/\r?\n/)
21
+ .filter((line) => {
22
+ const tableLabel = line.match(/^\|\s*\*\*(.+?)\*\*\s*\|/);
23
+ if (tableLabel) {
24
+ const labelMode = normalizeMode(tableLabel[1].trim());
25
+ if (labelMode) return labelMode === effectiveMode;
26
+ }
27
+
28
+ // Require a quoted value: every worked example is `- lite: "..."`. Without
29
+ // this, an ordinary rule bullet that happens to start with a mode word
30
+ // (e.g. "- Full: ...") is silently dropped in every other mode — it looks
31
+ // like a worked example but is really prose meant to survive verbatim.
32
+ const exampleLabel = line.match(/^-\s*([^:]+):\s*"/);
33
+ if (exampleLabel) {
34
+ const labelMode = normalizeMode(exampleLabel[1].trim());
35
+ if (labelMode) return labelMode === effectiveMode;
36
+ }
37
+
38
+ return true;
39
+ })
40
+ .join('\n');
41
+ }
42
+
43
+ function getFallbackInstructions(mode) {
44
+ return 'PONYTAIL MODE ACTIVE — level: ' + mode + '\n\n' +
45
+ 'You are a lazy senior developer. Lazy means efficient, not careless. The best code is the code never written.\n\n' +
46
+ '## Persistence\n\n' +
47
+ 'ACTIVE EVERY RESPONSE. No drift back to over-building. Still active if unsure. Off only: "stop ponytail" / "normal mode".\n\n' +
48
+ 'Current level: **' + mode + '**. Switch: `/ponytail lite|full|ultra`.\n\n' +
49
+ '## The ladder\n\n' +
50
+ 'Before any code, stop at the first rung that holds (the ladder runs after you understand the problem, not instead of it — read the code it touches and trace the real flow first):\n' +
51
+ '1. Does this need to be built at all? (YAGNI)\n' +
52
+ '2. Does it already exist in this codebase? Reuse what is already here, do not re-write it.\n' +
53
+ '3. Does the standard library do this? Use it.\n' +
54
+ '4. Does a native platform feature cover it? Use it.\n' +
55
+ '5. Does an already-installed dependency solve it? Use it.\n' +
56
+ '6. Can this be one line? Make it one line.\n' +
57
+ '7. Only then: write the minimum code that works.\n\n' +
58
+ 'Bug fix = root cause, not symptom: grep every caller of the function you touch and fix the shared function once (a smaller diff than one guard per caller); patching only the path the ticket names leaves a sibling caller broken.\n\n' +
59
+ '## Rules\n\n' +
60
+ 'No abstractions that were not requested. No avoidable dependencies. No boilerplate nobody asked for. ' +
61
+ 'Deletion over addition. Boring over clever. Fewest files possible. ' +
62
+ 'Ship the lazy version and question the complex request in the same response — never stall. ' +
63
+ 'Between two same-size stdlib options, pick the one correct on edge cases. ' +
64
+ 'Mark deliberate simplifications that cut a real corner with a known ceiling, using a `ponytail:` comment that names the ceiling and upgrade path.\n\n' +
65
+ '## Output\n\n' +
66
+ 'Code first. Then at most three short lines: what was skipped, when to add it. ' +
67
+ 'If the explanation is longer than the code, delete the explanation. ' +
68
+ 'Explanation the user explicitly asked for is not debt, give it in full.\n\n' +
69
+ '## When NOT to be lazy\n\n' +
70
+ 'Never simplify away: understanding the problem (read it fully and trace the real flow before picking a rung — a small diff you do not understand is just laziness dressed up as efficiency), input validation at trust boundaries, error handling that prevents data loss, ' +
71
+ 'security measures, accessibility basics, the calibration real hardware needs (the platform is never the spec ideal), anything the user explicitly asked to keep. ' +
72
+ '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.\n\n' +
73
+ '## Boundaries\n\n' +
74
+ 'Ponytail governs what you build, not how you talk. "stop ponytail" or "normal mode": revert. Level persists until changed or session end.';
75
+ }
76
+
77
+ function getPonytailInstructions(mode) {
78
+ const configuredMode = normalizePersistedMode(mode) || DEFAULT_MODE;
79
+
80
+ if (INDEPENDENT_MODES.has(configuredMode)) {
81
+ return 'PONYTAIL MODE ACTIVE — level: ' + configuredMode + '. Behavior defined by /ponytail-' + configuredMode + ' skill.';
82
+ }
83
+
84
+ const effectiveMode = normalizeMode(configuredMode) || DEFAULT_MODE;
85
+
86
+ try {
87
+ return 'PONYTAIL MODE ACTIVE — level: ' + effectiveMode + '\n\n' +
88
+ filterSkillBodyForMode(fs.readFileSync(SKILL_PATH, 'utf8'), effectiveMode);
89
+ } catch (e) {
90
+ return getFallbackInstructions(effectiveMode);
91
+ }
92
+ }
93
+
94
+ module.exports = {
95
+ filterSkillBodyForMode,
96
+ getFallbackInstructions,
97
+ getPonytailInstructions,
98
+ };
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env node
2
+ // ponytail — UserPromptSubmit hook to track which ponytail mode is active
3
+ // Inspects user input for /ponytail commands and writes mode to flag file
4
+
5
+ const { getDefaultMode, isDeactivationCommand, writeDefaultMode } = require('./ponytail-config');
6
+ const { clearMode, isQoder, readMode, setMode, writeHookOutput } = require('./ponytail-runtime');
7
+ const { getPonytailInstructions } = require('./ponytail-instructions');
8
+
9
+ let input = '';
10
+ let done = false;
11
+
12
+ function finish() {
13
+ if (done) return;
14
+ done = true;
15
+ try {
16
+ // Strip UTF-8 BOM some shells prepend when piping (breaks JSON.parse)
17
+ const data = JSON.parse(input.replace(/^\uFEFF/, ''));
18
+ const prompt = (data.prompt || '').trim().toLowerCase();
19
+
20
+ // Match /ponytail commands
21
+ let modeSwitched = false;
22
+ let deactivated = false;
23
+ if (/^[/@$]ponytail/.test(prompt)) {
24
+ const parts = prompt.split(/\s+/);
25
+ const cmd = parts[0].replace(/^[@$]/, '/');
26
+ const arg = parts[1] || '';
27
+
28
+ let mode = null;
29
+ let isReportOnly = false;
30
+
31
+ if (cmd === '/ponytail-review' || cmd === '/ponytail:ponytail-review') {
32
+ mode = 'review';
33
+ } else if (cmd === '/ponytail' || cmd === '/ponytail:ponytail') {
34
+ // `/ponytail default <mode>` persists the default to config (survives
35
+ // restarts). Plain switches stay session-scoped ("sticks until session
36
+ // end"), so this is the only path that writes config. review is not a
37
+ // valid default (#377), so only off/lite/full/ultra are accepted.
38
+ if (arg === 'default') {
39
+ const dmode = parts[2];
40
+ if (dmode === 'off' || dmode === 'lite' || dmode === 'full' || dmode === 'ultra') {
41
+ writeDefaultMode(dmode);
42
+ writeHookOutput('UserPromptSubmit', dmode, 'PONYTAIL DEFAULT SET — new sessions start in ' + dmode + '.');
43
+ }
44
+ return; // don't fall through to the session-mode switch
45
+ }
46
+ if (arg === 'lite') mode = 'lite';
47
+ else if (arg === 'full') mode = 'full';
48
+ else if (arg === 'ultra') mode = 'ultra';
49
+ else if (arg === 'off') mode = 'off';
50
+ else if (arg === '') {
51
+ isReportOnly = true;
52
+ mode = readMode() || getDefaultMode();
53
+ } else {
54
+ mode = getDefaultMode();
55
+ }
56
+ }
57
+
58
+ if (isReportOnly) {
59
+ writeHookOutput(
60
+ 'UserPromptSubmit',
61
+ mode,
62
+ 'PONYTAIL MODE ACTIVE — level: ' + mode,
63
+ );
64
+ } else if (mode && mode !== 'off') {
65
+ setMode(mode);
66
+ modeSwitched = true;
67
+ // ponytail: Qoder needs the full ruleset every turn, so when a mode
68
+ // switch happens we fold the confirmation into the ruleset output
69
+ // below (one JSON on stdout) instead of emitting two separate writes.
70
+ if (!isQoder) {
71
+ writeHookOutput(
72
+ 'UserPromptSubmit',
73
+ mode,
74
+ 'PONYTAIL MODE CHANGED — level: ' + mode,
75
+ );
76
+ }
77
+ } else if (mode === 'off') {
78
+ clearMode();
79
+ deactivated = true;
80
+ writeHookOutput('UserPromptSubmit', 'off', 'PONYTAIL MODE OFF');
81
+ }
82
+ }
83
+
84
+ // Detect deactivation
85
+ if (!modeSwitched && !deactivated && isDeactivationCommand(prompt)) {
86
+ clearMode();
87
+ deactivated = true;
88
+ writeHookOutput('UserPromptSubmit', 'off', 'PONYTAIL MODE OFF');
89
+ }
90
+
91
+ // Qoder has no SessionStart event, so UserPromptSubmit does double duty:
92
+ // activate the default mode on first prompt (if no flag exists yet), then
93
+ // inject the ruleset on every prompt. Claude Code/Codex do this in
94
+ // SessionStart via ponytail-activate.js; Qoder can't, so we do it here.
95
+ // Skip when deactivated — user just turned ponytail off.
96
+ if (isQoder && !deactivated) {
97
+ let currentMode = readMode();
98
+ if (!currentMode) {
99
+ // First prompt in session — initialize from config/env default
100
+ currentMode = getDefaultMode();
101
+ if (currentMode !== 'off') {
102
+ try { setMode(currentMode); } catch (e) {}
103
+ }
104
+ }
105
+ if (currentMode && currentMode !== 'off') {
106
+ // ponytail: one JSON per invocation — mode-switch confirmation is
107
+ // folded into the ruleset header so Qoder gets both in one write.
108
+ const header = modeSwitched
109
+ ? 'PONYTAIL MODE CHANGED — level: ' + currentMode + '\n\n'
110
+ : '';
111
+ writeHookOutput('UserPromptSubmit', currentMode, header + getPonytailInstructions(currentMode));
112
+ }
113
+ }
114
+ } catch (e) {
115
+ // Silent fail
116
+ }
117
+ }
118
+
119
+ process.stdin.on('data', chunk => { input += chunk; });
120
+ process.stdin.on('end', finish);
121
+
122
+ // Never hang the session. On Windows, Claude Code runs this hook through a
123
+ // PowerShell `if {}` wrapper that can swallow the piped prompt JSON, so stdin
124
+ // 'end' never fires and the hook blocks forever — freezing the session (#443).
125
+ // On error, or after a short fallback, process whatever arrived (recovering the
126
+ // mode if data came without EOF) and exit. unref() keeps the timer from adding
127
+ // latency to the normal path, where 'end' fires first. Mirrors the best-effort,
128
+ // never-block contract the other lifecycle hooks already follow.
129
+ process.stdin.on('error', () => { finish(); process.exit(0); });
130
+ setTimeout(() => { finish(); process.exit(0); }, 1000).unref();
@@ -0,0 +1,85 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const os = require('os');
4
+ const { getClaudeDir, getConfigDir } = require('./ponytail-config');
5
+
6
+ const STATE_FILE = '.ponytail-active';
7
+ const isCopilot = Boolean(process.env.COPILOT_PLUGIN_DATA);
8
+ const isCodex = !isCopilot && Boolean(process.env.PLUGIN_DATA);
9
+ const isQoder = !isCopilot && !isCodex && Boolean(process.env.QODER_SESSION_ID);
10
+
11
+ let stateDir = getClaudeDir();
12
+ if (isCodex) stateDir = process.env.PLUGIN_DATA;
13
+ if (isCopilot) stateDir = process.env.COPILOT_PLUGIN_DATA;
14
+ if (isQoder) stateDir = path.join(os.homedir(), '.qoder');
15
+
16
+ const statePath = path.join(stateDir, STATE_FILE);
17
+
18
+ function setMode(mode) {
19
+ fs.mkdirSync(path.dirname(statePath), { recursive: true });
20
+ fs.writeFileSync(statePath, mode);
21
+ }
22
+
23
+ function clearMode() {
24
+ try { fs.unlinkSync(statePath); } catch (e) {}
25
+ }
26
+
27
+ // Live mode written by activate/mode-tracker. Absent flag = ponytail off.
28
+ function readMode() {
29
+ try {
30
+ return fs.readFileSync(statePath, 'utf8').trim() || null;
31
+ } catch (e) {
32
+ return null;
33
+ }
34
+ }
35
+
36
+ function writeHookOutput(event, mode, context = '') {
37
+ if (isCopilot) {
38
+ // Copilot reads additionalContext on SessionStart; ignores output elsewhere.
39
+ process.stdout.write(JSON.stringify(
40
+ event === 'SessionStart' && context ? { additionalContext: context } : {}));
41
+ return;
42
+ }
43
+ if (isCodex) {
44
+ const output = { systemMessage: `PONYTAIL:${mode.toUpperCase()}` };
45
+ if (context) {
46
+ output.hookSpecificOutput = {
47
+ hookEventName: event,
48
+ additionalContext: context,
49
+ };
50
+ }
51
+ process.stdout.write(JSON.stringify(output));
52
+ return;
53
+ }
54
+ if (isQoder) {
55
+ // Qoder: hookSpecificOutput JSON, same shape as Codex minus systemMessage.
56
+ // UserPromptSubmit additionalContext is injected into the Agent's conversation.
57
+ const output = {};
58
+ if (context) {
59
+ output.hookSpecificOutput = {
60
+ hookEventName: event,
61
+ additionalContext: context,
62
+ };
63
+ }
64
+ process.stdout.write(JSON.stringify(output));
65
+ return;
66
+ }
67
+ // Native Claude: SessionStart accepts raw stdout, but SubagentStart needs the
68
+ // hookSpecificOutput JSON form or the context is dropped.
69
+ if (event === 'SubagentStart') {
70
+ process.stdout.write(JSON.stringify(
71
+ { hookSpecificOutput: { hookEventName: event, additionalContext: context } }));
72
+ return;
73
+ }
74
+ process.stdout.write(context);
75
+ }
76
+
77
+ module.exports = {
78
+ clearMode,
79
+ isCodex,
80
+ isCopilot,
81
+ isQoder,
82
+ readMode,
83
+ setMode,
84
+ writeHookOutput,
85
+ };
@@ -0,0 +1,24 @@
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
+ # ultra is the high-intensity mode; flag it amber so it stands out from the
17
+ # default green. The level is still in the text, so color is a redundant cue.
18
+ $Color = if ($Mode -eq "ultra") { "173" } else { "108" }
19
+ if ([string]::IsNullOrEmpty($Mode) -or $Mode -eq "full") {
20
+ [Console]::Write("${Esc}[38;5;${Color}m[PONYTAIL]${Esc}[0m")
21
+ } else {
22
+ $Suffix = $Mode.ToUpperInvariant()
23
+ [Console]::Write("${Esc}[38;5;${Color}m[PONYTAIL:$Suffix]${Esc}[0m")
24
+ }
@@ -0,0 +1,18 @@
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
+ # ultra is the high-intensity mode; flag it amber so it stands out from the
9
+ # default green at a glance. The level is still in the text, so color is a
10
+ # redundant cue, not the only one.
11
+ color=108
12
+ [ "$mode" = "ultra" ] && color=173
13
+
14
+ if [ -z "$mode" ] || [ "$mode" = "full" ]; then
15
+ printf '\033[38;5;%sm[PONYTAIL]\033[0m' "$color"
16
+ else
17
+ printf '\033[38;5;%sm[PONYTAIL:%s]\033[0m' "$color" "$(printf '%s' "$mode" | tr '[:lower:]' '[:upper:]')"
18
+ fi
@@ -0,0 +1,77 @@
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
+ // Scoping (opt-in, issue #506): set PONYTAIL_SUBAGENT_MATCHER to a regex and
9
+ // the ruleset is injected only into subagents whose agent_type matches. The
10
+ // regex is unanchored and case-insensitive — "explore|general" matches either,
11
+ // "^general$" is exact. Unset means inject into every subagent, as before.
12
+
13
+ const { getPonytailInstructions } = require('./ponytail-instructions');
14
+ const { readMode, writeHookOutput } = require('./ponytail-runtime');
15
+
16
+ const mode = readMode();
17
+
18
+ // Absent flag or off → ponytail isn't active; inject nothing.
19
+ if (!mode || mode === 'off') {
20
+ process.exit(0);
21
+ }
22
+
23
+ function inject() {
24
+ try {
25
+ writeHookOutput('SubagentStart', mode, getPonytailInstructions(mode));
26
+ } catch (e) {
27
+ // Silent fail — a stdout error at hook exit must not surface as a hook failure.
28
+ }
29
+ }
30
+
31
+ // A bad regex must never crash the hook; treat it as "no matcher" and inject.
32
+ let matcherRe = null;
33
+ try {
34
+ if (process.env.PONYTAIL_SUBAGENT_MATCHER) {
35
+ matcherRe = new RegExp(process.env.PONYTAIL_SUBAGENT_MATCHER, 'i');
36
+ }
37
+ } catch (e) {
38
+ matcherRe = null;
39
+ }
40
+
41
+ // No matcher → keep the original synchronous, stdin-independent path. On Windows
42
+ // the PowerShell `if {}` wrapper can swallow the piped JSON so stdin 'end' never
43
+ // fires (#443); the default path must not wait on stdin or it would stall every
44
+ // subagent spawn.
45
+ if (!matcherRe) {
46
+ inject();
47
+ process.exit(0);
48
+ }
49
+
50
+ // Matcher set → read agent_type from stdin and skip only on a definite
51
+ // mismatch. Missing/unparseable agent_type, a stdin error, or the timeout all
52
+ // fail open (inject), so scoping never silently drops the persona.
53
+ let input = '';
54
+ let done = false;
55
+
56
+ function finish() {
57
+ if (done) return;
58
+ done = true;
59
+
60
+ let agentType = '';
61
+ try {
62
+ // Strip UTF-8 BOM some shells prepend when piping (breaks JSON.parse)
63
+ agentType = String(JSON.parse(input.replace(/^\uFEFF/, '')).agent_type || '').trim();
64
+ } catch (e) {
65
+ // Unparseable payload — fall through and inject to be safe.
66
+ }
67
+ if (agentType && !matcherRe.test(agentType)) {
68
+ process.exit(0);
69
+ }
70
+ inject();
71
+ }
72
+
73
+ process.stdin.on('data', chunk => { input += chunk; });
74
+ process.stdin.on('end', finish);
75
+ // Never block the session (#443): recover on stdin error or a short fallback.
76
+ process.stdin.on('error', () => { finish(); process.exit(0); });
77
+ setTimeout(() => { finish(); process.exit(0); }, 1000).unref();
@@ -0,0 +1,26 @@
1
+ {
2
+ "_comment": "Reference template — copy the 'hooks' object into your .qoder/settings.json or ~/.qoder/settings.json. Replace PONYTAIL_DIR with the path to your ponytail checkout (e.g. ~/.qoder/plugins/ponytail or the npm global install path).",
3
+ "hooks": {
4
+ "UserPromptSubmit": [
5
+ {
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "node PONYTAIL_DIR/hooks/ponytail-mode-tracker.js"
10
+ }
11
+ ]
12
+ }
13
+ ],
14
+ "PreToolUse": [
15
+ {
16
+ "matcher": "task|Task",
17
+ "hooks": [
18
+ {
19
+ "type": "command",
20
+ "command": "node PONYTAIL_DIR/hooks/ponytail-subagent.js"
21
+ }
22
+ ]
23
+ }
24
+ ]
25
+ }
26
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@dietrichgebert/ponytail",
3
+ "version": "4.9.0",
4
+ "description": "Lazy senior dev mode for AI agents. The best code is the code you never wrote.",
5
+ "keywords": ["opencode-plugin", "opencode", "ponytail", "pi-package", "pi", "skills", "qoder"],
6
+ "license": "MIT",
7
+ "author": {
8
+ "name": "Dietrich Gebert",
9
+ "url": "https://github.com/DietrichGebert"
10
+ },
11
+ "homepage": "https://github.com/DietrichGebert/ponytail",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/DietrichGebert/ponytail.git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/DietrichGebert/ponytail/issues"
18
+ },
19
+ "main": "./.opencode/plugins/ponytail.mjs",
20
+ "exports": {
21
+ ".": "./.opencode/plugins/ponytail.mjs",
22
+ "./plugin": "./.opencode/plugins/ponytail.mjs"
23
+ },
24
+ "files": [
25
+ "AGENTS.md",
26
+ "hooks/",
27
+ "skills/",
28
+ ".opencode/",
29
+ ".qoder/",
30
+ ".qoder-plugin/",
31
+ "pi-extension/",
32
+ "scripts/uninstall.js",
33
+ "assets/",
34
+ "LICENSE"
35
+ ],
36
+ "scripts": {
37
+ "test": "node --test tests/*.test.js && npm test --prefix pi-extension && npm test --prefix ponytail-mcp"
38
+ },
39
+ "pi": {
40
+ "extensions": ["./pi-extension/index.js"],
41
+ "skills": ["./skills"]
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ }
46
+ }
47
+