Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
ponytail/hooks/ponytail-config.js at main · DietrichGebert/ponytail · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
DietrichGebert
/
ponytail
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
6.9k
Star
129k
Code
Issues
84
Pull requests
135
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
main
Breadcrumbs
ponytail
/
hooks
/
ponytail-config.js
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
169 lines (151 loc) · 5.74 KB
main
Breadcrumbs
ponytail
/
hooks
/
ponytail-config.js
Copy path
Top
File metadata and controls
Code
Blame
169 lines (151 loc) · 5.74 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env node
// ponytail — shared configuration resolver
//
// Resolution order for default mode:
// 1. PONYTAIL_DEFAULT_MODE environment variable
// 2. Config file defaultMode field:
// - $XDG_CONFIG_HOME/ponytail/config.json (any platform, if set)
// - ~/.config/ponytail/config.json (macOS / Linux fallback)
// - %APPDATA%\ponytail\config.json (Windows fallback)
// 3. 'full'
const
fs
=
require
(
'fs'
)
;
const
path
=
require
(
'path'
)
;
const
os
=
require
(
'os'
)
;
const
DEFAULT_MODE
=
'full'
;
const
VALID_MODES
=
[
'off'
,
'lite'
,
'full'
,
'ultra'
,
'review'
]
;
const
RUNTIME_MODES
=
[
'off'
,
'lite'
,
'full'
,
'ultra'
]
;
function
normalizeMode
(
mode
)
{
if
(
typeof
mode
!==
'string'
)
return
null
;
const
normalized
=
mode
.
trim
(
)
.
toLowerCase
(
)
;
return
RUNTIME_MODES
.
includes
(
normalized
)
?
normalized
:
null
;
}
function
normalizeConfigMode
(
mode
)
{
if
(
typeof
mode
!==
'string'
)
return
null
;
const
normalized
=
mode
.
trim
(
)
.
toLowerCase
(
)
;
return
VALID_MODES
.
includes
(
normalized
)
?
normalized
:
null
;
}
function
normalizePersistedMode
(
mode
)
{
return
normalizeMode
(
mode
)
||
normalizeConfigMode
(
mode
)
;
}
// "stop ponytail" / "normal mode" turn ponytail off, but only as a standalone
// command. Matching the phrase anywhere in the message turned it off mid-task
// for ordinary requests like "add a normal mode toggle" — so require the whole
// message to be the command, ignoring case and trailing punctuation.
function
isDeactivationCommand
(
text
)
{
const
t
=
String
(
text
||
''
)
.
trim
(
)
.
toLowerCase
(
)
.
replace
(
/
[
.
!
?
\s
]
+
$
/
,
''
)
;
return
t
===
'stop ponytail'
||
t
===
'normal mode'
;
}
// ponytail: only embed the plugin install path in a statusline shell command when
// it's made of ordinary path characters. An allowlist beats escaping every shell's
// metacharacters; a hostile clone path (quotes, &, $, backtick, ;, etc.) falls back
// to manual setup instead. Allows : \ / for normal Windows and POSIX paths. Full
// per-shell escaper only if a real need appears.
function
isShellSafe
(
p
)
{
return
typeof
p
===
'string'
&&
/
^
[
A
-
Z
a
-
z
0
-
9
_
.
\-
:
/
\\
~
]
+
$
/
.
test
(
p
)
;
}
function
getConfigDir
(
)
{
if
(
process
.
env
.
XDG_CONFIG_HOME
)
{
return
path
.
join
(
process
.
env
.
XDG_CONFIG_HOME
,
'ponytail'
)
;
}
if
(
process
.
platform
===
'win32'
)
{
return
path
.
join
(
process
.
env
.
APPDATA
||
path
.
join
(
os
.
homedir
(
)
,
'AppData'
,
'Roaming'
)
,
'ponytail'
)
;
}
return
path
.
join
(
os
.
homedir
(
)
,
'.config'
,
'ponytail'
)
;
}
function
getConfigPath
(
)
{
return
path
.
join
(
getConfigDir
(
)
,
'config.json'
)
;
}
function
getClaudeDir
(
)
{
// ponytail: CLAUDE_CONFIG_DIR overrides ~/.claude, matching Claude Code.
return
process
.
env
.
CLAUDE_CONFIG_DIR
||
path
.
join
(
os
.
homedir
(
)
,
'.claude'
)
;
}
function
getDefaultMode
(
)
{
// 1. Environment variable (highest priority)
const
envMode
=
process
.
env
.
PONYTAIL_DEFAULT_MODE
;
// ponytail: a default must be a runtime level (off/lite/full/ultra); review is
// a session-only mode, never a valid default (#377). Validate against
// RUNTIME_MODES so a stray env var or config can't make review the default.
if
(
envMode
&&
RUNTIME_MODES
.
includes
(
envMode
.
toLowerCase
(
)
)
)
{
return
envMode
.
toLowerCase
(
)
;
}
// 2. Config file
try
{
const
configPath
=
getConfigPath
(
)
;
// Strip UTF-8 BOM (common on Windows-saved files) so JSON.parse doesn't choke
const
config
=
JSON
.
parse
(
fs
.
readFileSync
(
configPath
,
'utf8'
)
.
replace
(
/
^
\uFEFF
/
,
''
)
)
;
if
(
config
.
defaultMode
&&
RUNTIME_MODES
.
includes
(
config
.
defaultMode
.
toLowerCase
(
)
)
)
{
return
config
.
defaultMode
.
toLowerCase
(
)
;
}
}
catch
(
e
)
{
// Config file doesn't exist or is invalid — fall through
}
// 3. Default
return
DEFAULT_MODE
;
}
// Silence the pi "Ponytail loaded" startup toast while keeping ponytail active.
// PONYTAIL_QUIET_STARTUP=1 (or any truthy value; 0/false/empty mean "show it")
// takes precedence, else config.quietStartup === true. Mirrors getHideStatus.
function
getQuietStartup
(
)
{
const
env
=
process
.
env
.
PONYTAIL_QUIET_STARTUP
;
if
(
env
!==
undefined
)
{
const
v
=
env
.
trim
(
)
.
toLowerCase
(
)
;
return
v
!==
''
&&
v
!==
'0'
&&
v
!==
'false'
&&
v
!==
'no'
;
}
try
{
const
config
=
JSON
.
parse
(
fs
.
readFileSync
(
getConfigPath
(
)
,
'utf8'
)
.
replace
(
/
^
\uFEFF
/
,
''
)
)
;
return
config
.
quietStartup
===
true
;
}
catch
(
_
)
{
return
false
;
}
}
// Hide the status-bar indicator while keeping ponytail active (#324).
// PONYTAIL_HIDE_STATUS=1 (or any truthy value; 0/false/empty mean "don't hide")
// takes precedence, else config.hideStatus === true.
function
getHideStatus
(
)
{
const
env
=
process
.
env
.
PONYTAIL_HIDE_STATUS
;
if
(
env
!==
undefined
)
{
const
v
=
env
.
trim
(
)
.
toLowerCase
(
)
;
return
v
!==
''
&&
v
!==
'0'
&&
v
!==
'false'
&&
v
!==
'no'
;
}
try
{
const
config
=
JSON
.
parse
(
fs
.
readFileSync
(
getConfigPath
(
)
,
'utf8'
)
.
replace
(
/
^
\uFEFF
/
,
''
)
)
;
return
config
.
hideStatus
===
true
;
}
catch
(
_
)
{
return
false
;
}
}
function
writeDefaultMode
(
mode
)
{
// ponytail: only a runtime level can be a default; review is session-only (#377).
const
normalized
=
normalizeMode
(
mode
)
;
if
(
!
normalized
)
return
null
;
const
configPath
=
getConfigPath
(
)
;
fs
.
mkdirSync
(
path
.
dirname
(
configPath
)
,
{
recursive
:
true
}
)
;
let
config
=
{
}
;
try
{
config
=
JSON
.
parse
(
fs
.
readFileSync
(
configPath
,
'utf8'
)
.
replace
(
/
^
\uFEFF
/
,
''
)
)
;
if
(
!
config
||
typeof
config
!==
'object'
||
Array
.
isArray
(
config
)
)
config
=
{
}
;
}
catch
(
_
)
{
}
config
.
defaultMode
=
normalized
;
fs
.
writeFileSync
(
configPath
,
JSON
.
stringify
(
config
,
null
,
2
)
,
'utf8'
)
;
return
normalized
;
}
module
.
exports
=
{
DEFAULT_MODE
,
VALID_MODES
,
RUNTIME_MODES
,
getDefaultMode
,
getConfigDir
,
getConfigPath
,
getClaudeDir
,
getHideStatus
,
getQuietStartup
,
isShellSafe
,
normalizeMode
,
normalizeConfigMode
,
normalizePersistedMode
,
isDeactivationCommand
,
writeDefaultMode
,
}
;
You can’t perform that action at this time.