@iaforged/context-code 1.0.77 → 1.0.79

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 (121) hide show
  1. package/README.md +68 -68
  2. package/cli.js +8515 -8515
  3. package/context-bootstrap.js +27 -27
  4. package/dist/src/bootstrap/state.js +3 -0
  5. package/dist/src/bridge/bridgeMain.js +40 -40
  6. package/dist/src/cli/print.js +12 -12
  7. package/dist/src/commands/agent/agent.js +8 -0
  8. package/dist/src/commands/commit-push-pr.js +55 -55
  9. package/dist/src/commands/createMovedToPluginCommand.js +9 -9
  10. package/dist/src/commands/init-verifiers.js +238 -238
  11. package/dist/src/commands/init.js +216 -216
  12. package/dist/src/commands/install.js +2 -2
  13. package/dist/src/commands/login/login.js +24 -10
  14. package/dist/src/commands/orchestrate/index.js +1 -1
  15. package/dist/src/commands/orchestrate/orchestrate.js +110 -24
  16. package/dist/src/commands/profile/profile.js +15 -1
  17. package/dist/src/commands/provider/index.js +1 -1
  18. package/dist/src/commands/provider/provider.js +34 -1
  19. package/dist/src/commands/review.js +22 -22
  20. package/dist/src/commands/run/index.js +2 -2
  21. package/dist/src/commands/run/run.js +63 -61
  22. package/dist/src/commands/team/index.js +1 -1
  23. package/dist/src/commands/team/team.js +84 -76
  24. package/dist/src/commands/team-auto/teamAuto.js +89 -29
  25. package/dist/src/commands/terminalSetup/terminalSetup.js +24 -24
  26. package/dist/src/commands/usage/index.js +7 -0
  27. package/dist/src/commands/usage/usage.js +5 -0
  28. package/dist/src/commands/workspace/workspace.js +39 -31
  29. package/dist/src/commands.js +0 -2
  30. package/dist/src/components/ConsoleOAuthFlow.js +92 -14
  31. package/dist/src/components/ModelPicker.js +2 -0
  32. package/dist/src/components/agents/generateAgent.js +92 -92
  33. package/dist/src/components/grove/Grove.js +10 -10
  34. package/dist/src/components/permissions/AskUserQuestionPermissionRequest/AskUserQuestionPermissionRequest.js +8 -8
  35. package/dist/src/constants/geminiOAuth.js +13 -0
  36. package/dist/src/constants/github-app.js +134 -134
  37. package/dist/src/constants/prompts.js +123 -123
  38. package/dist/src/coordinator/coordinatorMode.js +252 -252
  39. package/dist/src/hooks/useTypeahead.js +7 -7
  40. package/dist/src/ink/reconciler.js +7 -7
  41. package/dist/src/main.js +5 -5
  42. package/dist/src/memdir/findRelevantMemories.js +6 -6
  43. package/dist/src/services/MagicDocs/prompts.js +56 -56
  44. package/dist/src/services/PromptSuggestion/promptSuggestion.js +29 -29
  45. package/dist/src/services/SessionMemory/prompts.js +66 -66
  46. package/dist/src/services/api/openai.js +584 -21
  47. package/dist/src/services/limits/adapters/ollama.js +3 -3
  48. package/dist/src/services/oauth/geminiCli.js +107 -0
  49. package/dist/src/services/orchestration/execution/AgentTaskExecutor.js +5 -3
  50. package/dist/src/services/orchestration/execution/OrchestrationExecutionRuntime.js +18 -18
  51. package/dist/src/services/orchestration/global/reporting.js +2 -2
  52. package/dist/src/services/toolUseSummary/toolUseSummaryGenerator.js +9 -9
  53. package/dist/src/skills/bundled/batch.js +78 -78
  54. package/dist/src/skills/bundled/claudeApi.js +34 -34
  55. package/dist/src/skills/bundled/claudeInChrome.js +4 -4
  56. package/dist/src/skills/bundled/debug.js +36 -36
  57. package/dist/src/skills/bundled/scheduleRemoteAgents.js +151 -151
  58. package/dist/src/skills/bundled/skillify.js +132 -132
  59. package/dist/src/skills/bundled/stuck.js +53 -53
  60. package/dist/src/skills/bundled/updateConfig.js +418 -418
  61. package/dist/src/tasks/RemoteAgentTask/RemoteAgentTask.js +26 -26
  62. package/dist/src/tools/AgentTool/AgentTool.js +7 -7
  63. package/dist/src/tools/AgentTool/built-in/claudeCodeGuideAgent.js +67 -67
  64. package/dist/src/tools/AgentTool/built-in/exploreAgent.js +32 -32
  65. package/dist/src/tools/AgentTool/built-in/generalPurposeAgent.js +13 -13
  66. package/dist/src/tools/AgentTool/built-in/planAgent.js +49 -49
  67. package/dist/src/tools/AgentTool/built-in/statuslineSetup.js +129 -129
  68. package/dist/src/tools/AgentTool/built-in/verificationAgent.js +119 -119
  69. package/dist/src/tools/AgentTool/prompt.js +131 -131
  70. package/dist/src/tools/AgentTool/runAgent.js +9 -9
  71. package/dist/src/tools/BashTool/BashTool.js +10 -10
  72. package/dist/src/tools/BashTool/prompt.js +94 -94
  73. package/dist/src/tools/ConfigTool/prompt.js +29 -29
  74. package/dist/src/tools/EnterWorktreeTool/prompt.js +27 -27
  75. package/dist/src/tools/FileReadTool/prompt.js +12 -12
  76. package/dist/src/tools/PowerShellTool/prompt.js +82 -82
  77. package/dist/src/tools/RemoteTriggerTool/prompt.js +9 -9
  78. package/dist/src/tools/ScheduleCronTool/prompt.js +37 -37
  79. package/dist/src/tools/TeamCreateTool/prompt.js +110 -110
  80. package/dist/src/tools/TeamDeleteTool/prompt.js +13 -13
  81. package/dist/src/utils/advisor.js +15 -15
  82. package/dist/src/utils/api.js +2 -2
  83. package/dist/src/utils/auth.js +207 -2
  84. package/dist/src/utils/autoUpdater.js +18 -18
  85. package/dist/src/utils/bash/ShellSnapshot.js +86 -86
  86. package/dist/src/utils/bash/commands.js +61 -61
  87. package/dist/src/utils/claudeInChrome/prompt.js +53 -53
  88. package/dist/src/utils/claudeInChrome/setup.js +8 -8
  89. package/dist/src/utils/databaseMcp/server/queries.js +632 -632
  90. package/dist/src/utils/deepLink/registerProtocol.js +35 -35
  91. package/dist/src/utils/deepLink/terminalLauncher.js +12 -12
  92. package/dist/src/utils/hooks/execAgentHook.js +7 -7
  93. package/dist/src/utils/hooks/execPromptHook.js +4 -4
  94. package/dist/src/utils/hooks/skillImprovement.js +36 -36
  95. package/dist/src/utils/logoV2Utils.js +1 -1
  96. package/dist/src/utils/mcp/dateTimeParser.js +9 -9
  97. package/dist/src/utils/messages.js +191 -191
  98. package/dist/src/utils/model/model.js +18 -0
  99. package/dist/src/utils/model/modelOptions.js +51 -1
  100. package/dist/src/utils/model/modelStrings.js +5 -1
  101. package/dist/src/utils/model/modelSupportOverrides.js +3 -0
  102. package/dist/src/utils/model/providerBaseUrls.js +6 -1
  103. package/dist/src/utils/model/providerCatalog.js +64 -28
  104. package/dist/src/utils/model/providerModels.js +88 -17
  105. package/dist/src/utils/model/providerProfiles.js +8 -0
  106. package/dist/src/utils/model/providerProfilesDb.js +578 -393
  107. package/dist/src/utils/model/providerSwitch.js +12 -0
  108. package/dist/src/utils/model/providerWorkspaces.js +2 -0
  109. package/dist/src/utils/model/providers.js +65 -2
  110. package/dist/src/utils/orchestration/store/providerWorkspaceStore.js +3 -1
  111. package/dist/src/utils/orchestration/store/runStore.js +47 -47
  112. package/dist/src/utils/orchestration/store/teamStore.js +61 -61
  113. package/dist/src/utils/powershell/parser.js +253 -253
  114. package/dist/src/utils/sessionTitle.js +12 -12
  115. package/dist/src/utils/sideQuestion.js +17 -17
  116. package/dist/src/utils/status.js +1 -1
  117. package/dist/src/utils/swarm/backends/registry.js +9 -9
  118. package/dist/src/utils/telemetry/instrumentation.js +9 -9
  119. package/dist/src/utils/teleport.js +15 -15
  120. package/dist/src/utils/undercover.js +28 -28
  121. package/package.json +1 -1
@@ -10,430 +10,430 @@ function generateSettingsSchema() {
10
10
  const jsonSchema = toJSONSchema(SettingsSchema(), { io: 'input' });
11
11
  return jsonStringify(jsonSchema, null, 2);
12
12
  }
13
- const SETTINGS_EXAMPLES_DOCS = `## Settings File Locations
14
-
15
- Choose the appropriate file based on scope:
16
-
17
- | File | Scope | Git | Use For |
18
- |------|-------|-----|---------|
19
- | \`~/.context/settings.json\` | Global | N/A | Personal preferences for all projects |
20
- | \`.context/settings.json\` | Project | Commit | Team-wide hooks, permissions, plugins |
21
- | \`.context/settings.local.json\` | Project | Gitignore | Personal overrides for this project |
22
-
23
- Settings load in order: user → project → local (later overrides earlier).
24
-
25
- ## Settings Schema Reference
26
-
27
- ### Permissions
28
- \`\`\`json
29
- {
30
- "permissions": {
31
- "allow": ["Bash(npm:*)", "Edit(.claude)", "Read"],
32
- "deny": ["Bash(rm -rf:*)"],
33
- "ask": ["Write(/etc/*)"],
34
- "defaultMode": "default" | "plan" | "acceptEdits" | "dontAsk",
35
- "additionalDirectories": ["/extra/dir"]
36
- }
37
- }
38
- \`\`\`
39
-
40
- **Permission Rule Syntax:**
41
- - Exact match: \`"Bash(npm run test)"\`
42
- - Prefix wildcard: \`"Bash(git:*)"\` - matches \`git status\`, \`git commit\`, etc.
43
- - Tool only: \`"Read"\` - allows all Read operations
44
-
45
- ### Environment Variables
46
- \`\`\`json
47
- {
48
- "env": {
49
- "DEBUG": "true",
50
- "MY_API_KEY": "value"
51
- }
52
- }
53
- \`\`\`
54
-
55
- ### Model & Agent
56
- \`\`\`json
57
- {
58
- "model": "sonnet", // or "opus", "haiku", full model ID
59
- "agent": "agent-name",
60
- "alwaysThinkingEnabled": true
61
- }
62
- \`\`\`
63
-
64
- ### Attribution (Commits & PRs)
65
- \`\`\`json
66
- {
67
- "attribution": {
68
- "commit": "Custom commit trailer text",
69
- "pr": "Custom PR description text"
70
- }
71
- }
72
- \`\`\`
73
- Set \`commit\` or \`pr\` to empty string \`""\` to hide that attribution.
74
-
75
- ### MCP Server Management
76
- \`\`\`json
77
- {
78
- "enableAllProjectMcpServers": true,
79
- "enabledMcpjsonServers": ["server1", "server2"],
80
- "disabledMcpjsonServers": ["blocked-server"]
81
- }
82
- \`\`\`
83
-
84
- ### Plugins
85
- \`\`\`json
86
- {
87
- "enabledPlugins": {
88
- "formatter@anthropic-tools": true
89
- }
90
- }
91
- \`\`\`
92
- Plugin syntax: \`plugin-name@source\` where source is \`claude-code-marketplace\`, \`claude-plugins-official\`, or \`builtin\`.
93
-
94
- ### Other Settings
95
- - \`language\`: Preferred response language (e.g., "japanese")
96
- - \`cleanupPeriodDays\`: Days to keep transcripts (default: 30; 0 disables persistence entirely)
97
- - \`respectGitignore\`: Whether to respect .gitignore (default: true)
98
- - \`spinnerTipsEnabled\`: Show tips in spinner
99
- - \`spinnerVerbs\`: Customize spinner verbs (\`{ "mode": "append" | "replace", "verbs": [...] }\`)
100
- - \`spinnerTipsOverride\`: Override spinner tips (\`{ "excludeDefault": true, "tips": ["Custom tip"] }\`)
101
- - \`syntaxHighlightingDisabled\`: Disable diff highlighting
13
+ const SETTINGS_EXAMPLES_DOCS = `## Settings File Locations
14
+
15
+ Choose the appropriate file based on scope:
16
+
17
+ | File | Scope | Git | Use For |
18
+ |------|-------|-----|---------|
19
+ | \`~/.context/settings.json\` | Global | N/A | Personal preferences for all projects |
20
+ | \`.context/settings.json\` | Project | Commit | Team-wide hooks, permissions, plugins |
21
+ | \`.context/settings.local.json\` | Project | Gitignore | Personal overrides for this project |
22
+
23
+ Settings load in order: user → project → local (later overrides earlier).
24
+
25
+ ## Settings Schema Reference
26
+
27
+ ### Permissions
28
+ \`\`\`json
29
+ {
30
+ "permissions": {
31
+ "allow": ["Bash(npm:*)", "Edit(.claude)", "Read"],
32
+ "deny": ["Bash(rm -rf:*)"],
33
+ "ask": ["Write(/etc/*)"],
34
+ "defaultMode": "default" | "plan" | "acceptEdits" | "dontAsk",
35
+ "additionalDirectories": ["/extra/dir"]
36
+ }
37
+ }
38
+ \`\`\`
39
+
40
+ **Permission Rule Syntax:**
41
+ - Exact match: \`"Bash(npm run test)"\`
42
+ - Prefix wildcard: \`"Bash(git:*)"\` - matches \`git status\`, \`git commit\`, etc.
43
+ - Tool only: \`"Read"\` - allows all Read operations
44
+
45
+ ### Environment Variables
46
+ \`\`\`json
47
+ {
48
+ "env": {
49
+ "DEBUG": "true",
50
+ "MY_API_KEY": "value"
51
+ }
52
+ }
53
+ \`\`\`
54
+
55
+ ### Model & Agent
56
+ \`\`\`json
57
+ {
58
+ "model": "sonnet", // or "opus", "haiku", full model ID
59
+ "agent": "agent-name",
60
+ "alwaysThinkingEnabled": true
61
+ }
62
+ \`\`\`
63
+
64
+ ### Attribution (Commits & PRs)
65
+ \`\`\`json
66
+ {
67
+ "attribution": {
68
+ "commit": "Custom commit trailer text",
69
+ "pr": "Custom PR description text"
70
+ }
71
+ }
72
+ \`\`\`
73
+ Set \`commit\` or \`pr\` to empty string \`""\` to hide that attribution.
74
+
75
+ ### MCP Server Management
76
+ \`\`\`json
77
+ {
78
+ "enableAllProjectMcpServers": true,
79
+ "enabledMcpjsonServers": ["server1", "server2"],
80
+ "disabledMcpjsonServers": ["blocked-server"]
81
+ }
82
+ \`\`\`
83
+
84
+ ### Plugins
85
+ \`\`\`json
86
+ {
87
+ "enabledPlugins": {
88
+ "formatter@anthropic-tools": true
89
+ }
90
+ }
91
+ \`\`\`
92
+ Plugin syntax: \`plugin-name@source\` where source is \`claude-code-marketplace\`, \`claude-plugins-official\`, or \`builtin\`.
93
+
94
+ ### Other Settings
95
+ - \`language\`: Preferred response language (e.g., "japanese")
96
+ - \`cleanupPeriodDays\`: Days to keep transcripts (default: 30; 0 disables persistence entirely)
97
+ - \`respectGitignore\`: Whether to respect .gitignore (default: true)
98
+ - \`spinnerTipsEnabled\`: Show tips in spinner
99
+ - \`spinnerVerbs\`: Customize spinner verbs (\`{ "mode": "append" | "replace", "verbs": [...] }\`)
100
+ - \`spinnerTipsOverride\`: Override spinner tips (\`{ "excludeDefault": true, "tips": ["Custom tip"] }\`)
101
+ - \`syntaxHighlightingDisabled\`: Disable diff highlighting
102
102
  `;
103
103
  // Note: We keep hand-written examples for common patterns since they're more
104
104
  // actionable than auto-generated schema docs. The generated schema list
105
105
  // provides completeness while examples provide clarity.
106
- const HOOKS_DOCS = `## Hooks Configuration
107
-
108
- Hooks run commands at specific points in Context Code's lifecycle.
109
-
110
- ### Hook Structure
111
- \`\`\`json
112
- {
113
- "hooks": {
114
- "EVENT_NAME": [
115
- {
116
- "matcher": "ToolName|OtherTool",
117
- "hooks": [
118
- {
119
- "type": "command",
120
- "command": "your-command-here",
121
- "timeout": 60,
122
- "statusMessage": "Running..."
123
- }
124
- ]
125
- }
126
- ]
127
- }
128
- }
129
- \`\`\`
130
-
131
- ### Hook Events
132
-
133
- | Event | Matcher | Purpose |
134
- |-------|---------|---------|
135
- | PermissionRequest | Tool name | Run before permission prompt |
136
- | PreToolUse | Tool name | Run before tool, can block |
137
- | PostToolUse | Tool name | Run after successful tool |
138
- | PostToolUseFailure | Tool name | Run after tool fails |
139
- | Notification | Notification type | Run on notifications |
140
- | Stop | - | Run when Claude stops (including clear, resume, compact) |
141
- | PreCompact | "manual"/"auto" | Before compaction |
142
- | PostCompact | "manual"/"auto" | After compaction (receives summary) |
143
- | UserPromptSubmit | - | When user submits |
144
- | SessionStart | - | When session starts |
145
-
146
- **Common tool matchers:** \`Bash\`, \`Write\`, \`Edit\`, \`Read\`, \`Glob\`, \`Grep\`
147
-
148
- ### Hook Types
149
-
150
- **1. Command Hook** - Runs a shell command:
151
- \`\`\`json
152
- { "type": "command", "command": "prettier --write $FILE", "timeout": 30 }
153
- \`\`\`
154
-
155
- **2. Prompt Hook** - Evaluates a condition with LLM:
156
- \`\`\`json
157
- { "type": "prompt", "prompt": "Is this safe? $ARGUMENTS" }
158
- \`\`\`
159
- Only available for tool events: PreToolUse, PostToolUse, PermissionRequest.
160
-
161
- **3. Agent Hook** - Runs an agent with tools:
162
- \`\`\`json
163
- { "type": "agent", "prompt": "Verify tests pass: $ARGUMENTS" }
164
- \`\`\`
165
- Only available for tool events: PreToolUse, PostToolUse, PermissionRequest.
166
-
167
- ### Hook Input (stdin JSON)
168
- \`\`\`json
169
- {
170
- "session_id": "abc123",
171
- "tool_name": "Write",
172
- "tool_input": { "file_path": "/path/to/file.txt", "content": "..." },
173
- "tool_response": { "success": true } // PostToolUse only
174
- }
175
- \`\`\`
176
-
177
- ### Hook JSON Output
178
-
179
- Hooks can return JSON to control behavior:
180
-
181
- \`\`\`json
182
- {
183
- "systemMessage": "Warning shown to user in UI",
184
- "continue": false,
185
- "stopReason": "Message shown when blocking",
186
- "suppressOutput": false,
187
- "decision": "block",
188
- "reason": "Explanation for decision",
189
- "hookSpecificOutput": {
190
- "hookEventName": "PostToolUse",
191
- "additionalContext": "Context injected back to model"
192
- }
193
- }
194
- \`\`\`
195
-
196
- **Fields:**
197
- - \`systemMessage\` - Display a message to the user (all hooks)
198
- - \`continue\` - Set to \`false\` to block/stop (default: true)
199
- - \`stopReason\` - Message shown when \`continue\` is false
200
- - \`suppressOutput\` - Hide stdout from transcript (default: false)
201
- - \`decision\` - "block" for PostToolUse/Stop/UserPromptSubmit hooks (deprecated for PreToolUse, use hookSpecificOutput.permissionDecision instead)
202
- - \`reason\` - Explanation for decision
203
- - \`hookSpecificOutput\` - Event-specific output (must include \`hookEventName\`):
204
- - \`additionalContext\` - Text injected into model context
205
- - \`permissionDecision\` - "allow", "deny", or "ask" (PreToolUse only)
206
- - \`permissionDecisionReason\` - Reason for the permission decision (PreToolUse only)
207
- - \`updatedInput\` - Modified tool input (PreToolUse only)
208
-
209
- ### Common Patterns
210
-
211
- **Auto-format after writes:**
212
- \`\`\`json
213
- {
214
- "hooks": {
215
- "PostToolUse": [{
216
- "matcher": "Write|Edit",
217
- "hooks": [{
218
- "type": "command",
219
- "command": "jq -r '.tool_response.filePath // .tool_input.file_path' | { read -r f; prettier --write \\"$f\\"; } 2>/dev/null || true"
220
- }]
221
- }]
222
- }
223
- }
224
- \`\`\`
225
-
226
- **Log all bash commands:**
227
- \`\`\`json
228
- {
229
- "hooks": {
230
- "PreToolUse": [{
231
- "matcher": "Bash",
232
- "hooks": [{
233
- "type": "command",
234
- "command": "jq -r '.tool_input.command' >> ~/.context/bash-log.txt"
235
- }]
236
- }]
237
- }
238
- }
239
- \`\`\`
240
-
241
- **Stop hook that displays message to user:**
242
-
243
- Command must output JSON with \`systemMessage\` field:
244
- \`\`\`bash
245
- # Example command that outputs: {"systemMessage": "Session complete!"}
246
- echo '{"systemMessage": "Session complete!"}'
247
- \`\`\`
248
-
249
- **Run tests after code changes:**
250
- \`\`\`json
251
- {
252
- "hooks": {
253
- "PostToolUse": [{
254
- "matcher": "Write|Edit",
255
- "hooks": [{
256
- "type": "command",
257
- "command": "jq -r '.tool_input.file_path // .tool_response.filePath' | grep -E '\\\\.(ts|js)$' && npm test || true"
258
- }]
259
- }]
260
- }
261
- }
262
- \`\`\`
106
+ const HOOKS_DOCS = `## Hooks Configuration
107
+
108
+ Hooks run commands at specific points in Context Code's lifecycle.
109
+
110
+ ### Hook Structure
111
+ \`\`\`json
112
+ {
113
+ "hooks": {
114
+ "EVENT_NAME": [
115
+ {
116
+ "matcher": "ToolName|OtherTool",
117
+ "hooks": [
118
+ {
119
+ "type": "command",
120
+ "command": "your-command-here",
121
+ "timeout": 60,
122
+ "statusMessage": "Running..."
123
+ }
124
+ ]
125
+ }
126
+ ]
127
+ }
128
+ }
129
+ \`\`\`
130
+
131
+ ### Hook Events
132
+
133
+ | Event | Matcher | Purpose |
134
+ |-------|---------|---------|
135
+ | PermissionRequest | Tool name | Run before permission prompt |
136
+ | PreToolUse | Tool name | Run before tool, can block |
137
+ | PostToolUse | Tool name | Run after successful tool |
138
+ | PostToolUseFailure | Tool name | Run after tool fails |
139
+ | Notification | Notification type | Run on notifications |
140
+ | Stop | - | Run when Claude stops (including clear, resume, compact) |
141
+ | PreCompact | "manual"/"auto" | Before compaction |
142
+ | PostCompact | "manual"/"auto" | After compaction (receives summary) |
143
+ | UserPromptSubmit | - | When user submits |
144
+ | SessionStart | - | When session starts |
145
+
146
+ **Common tool matchers:** \`Bash\`, \`Write\`, \`Edit\`, \`Read\`, \`Glob\`, \`Grep\`
147
+
148
+ ### Hook Types
149
+
150
+ **1. Command Hook** - Runs a shell command:
151
+ \`\`\`json
152
+ { "type": "command", "command": "prettier --write $FILE", "timeout": 30 }
153
+ \`\`\`
154
+
155
+ **2. Prompt Hook** - Evaluates a condition with LLM:
156
+ \`\`\`json
157
+ { "type": "prompt", "prompt": "Is this safe? $ARGUMENTS" }
158
+ \`\`\`
159
+ Only available for tool events: PreToolUse, PostToolUse, PermissionRequest.
160
+
161
+ **3. Agent Hook** - Runs an agent with tools:
162
+ \`\`\`json
163
+ { "type": "agent", "prompt": "Verify tests pass: $ARGUMENTS" }
164
+ \`\`\`
165
+ Only available for tool events: PreToolUse, PostToolUse, PermissionRequest.
166
+
167
+ ### Hook Input (stdin JSON)
168
+ \`\`\`json
169
+ {
170
+ "session_id": "abc123",
171
+ "tool_name": "Write",
172
+ "tool_input": { "file_path": "/path/to/file.txt", "content": "..." },
173
+ "tool_response": { "success": true } // PostToolUse only
174
+ }
175
+ \`\`\`
176
+
177
+ ### Hook JSON Output
178
+
179
+ Hooks can return JSON to control behavior:
180
+
181
+ \`\`\`json
182
+ {
183
+ "systemMessage": "Warning shown to user in UI",
184
+ "continue": false,
185
+ "stopReason": "Message shown when blocking",
186
+ "suppressOutput": false,
187
+ "decision": "block",
188
+ "reason": "Explanation for decision",
189
+ "hookSpecificOutput": {
190
+ "hookEventName": "PostToolUse",
191
+ "additionalContext": "Context injected back to model"
192
+ }
193
+ }
194
+ \`\`\`
195
+
196
+ **Fields:**
197
+ - \`systemMessage\` - Display a message to the user (all hooks)
198
+ - \`continue\` - Set to \`false\` to block/stop (default: true)
199
+ - \`stopReason\` - Message shown when \`continue\` is false
200
+ - \`suppressOutput\` - Hide stdout from transcript (default: false)
201
+ - \`decision\` - "block" for PostToolUse/Stop/UserPromptSubmit hooks (deprecated for PreToolUse, use hookSpecificOutput.permissionDecision instead)
202
+ - \`reason\` - Explanation for decision
203
+ - \`hookSpecificOutput\` - Event-specific output (must include \`hookEventName\`):
204
+ - \`additionalContext\` - Text injected into model context
205
+ - \`permissionDecision\` - "allow", "deny", or "ask" (PreToolUse only)
206
+ - \`permissionDecisionReason\` - Reason for the permission decision (PreToolUse only)
207
+ - \`updatedInput\` - Modified tool input (PreToolUse only)
208
+
209
+ ### Common Patterns
210
+
211
+ **Auto-format after writes:**
212
+ \`\`\`json
213
+ {
214
+ "hooks": {
215
+ "PostToolUse": [{
216
+ "matcher": "Write|Edit",
217
+ "hooks": [{
218
+ "type": "command",
219
+ "command": "jq -r '.tool_response.filePath // .tool_input.file_path' | { read -r f; prettier --write \\"$f\\"; } 2>/dev/null || true"
220
+ }]
221
+ }]
222
+ }
223
+ }
224
+ \`\`\`
225
+
226
+ **Log all bash commands:**
227
+ \`\`\`json
228
+ {
229
+ "hooks": {
230
+ "PreToolUse": [{
231
+ "matcher": "Bash",
232
+ "hooks": [{
233
+ "type": "command",
234
+ "command": "jq -r '.tool_input.command' >> ~/.context/bash-log.txt"
235
+ }]
236
+ }]
237
+ }
238
+ }
239
+ \`\`\`
240
+
241
+ **Stop hook that displays message to user:**
242
+
243
+ Command must output JSON with \`systemMessage\` field:
244
+ \`\`\`bash
245
+ # Example command that outputs: {"systemMessage": "Session complete!"}
246
+ echo '{"systemMessage": "Session complete!"}'
247
+ \`\`\`
248
+
249
+ **Run tests after code changes:**
250
+ \`\`\`json
251
+ {
252
+ "hooks": {
253
+ "PostToolUse": [{
254
+ "matcher": "Write|Edit",
255
+ "hooks": [{
256
+ "type": "command",
257
+ "command": "jq -r '.tool_input.file_path // .tool_response.filePath' | grep -E '\\\\.(ts|js)$' && npm test || true"
258
+ }]
259
+ }]
260
+ }
261
+ }
262
+ \`\`\`
263
263
  `;
264
- const HOOK_VERIFICATION_FLOW = `## Constructing a Hook (with verification)
265
-
266
- Given an event, matcher, target file, and desired behavior, follow this flow. Each step catches a different failure class — a hook that silently does nothing is worse than no hook.
267
-
268
- 1. **Dedup check.** Read the target file. If a hook already exists on the same event+matcher, show the existing command and ask: keep it, replace it, or add alongside.
269
-
270
- 2. **Construct the command for THIS project — don't assume.** The hook receives JSON on stdin. Build a command that:
271
- - Extracts any needed payload safely — use \`jq -r\` into a quoted variable or \`{ read -r f; ... "$f"; }\`, NOT unquoted \`| xargs\` (splits on spaces)
272
- - Invokes the underlying tool the way this project runs it (npx/bunx/yarn/pnpm? Makefile target? globally-installed?)
273
- - Skips inputs the tool doesn't handle (formatters often have \`--ignore-unknown\`; if not, guard by extension)
274
- - Stays RAW for now — no \`|| true\`, no stderr suppression. You'll wrap it after the pipe-test passes.
275
-
276
- 3. **Pipe-test the raw command.** Synthesize the stdin payload the hook will receive and pipe it directly:
277
- - \`Pre|PostToolUse\` on \`Write|Edit\`: \`echo '{"tool_name":"Edit","tool_input":{"file_path":"<a real file from this repo>"}}' | <cmd>\`
278
- - \`Pre|PostToolUse\` on \`Bash\`: \`echo '{"tool_name":"Bash","tool_input":{"command":"ls"}}' | <cmd>\`
279
- - \`Stop\`/\`UserPromptSubmit\`/\`SessionStart\`: most commands don't read stdin, so \`echo '{}' | <cmd>\` suffices
280
-
281
- Check exit code AND side effect (file actually formatted, test actually ran). If it fails you get a real error — fix (wrong package manager? tool not installed? jq path wrong?) and retest. Once it works, wrap with \`2>/dev/null || true\` (unless the user wants a blocking check).
282
-
283
- 4. **Write the JSON.** Merge into the target file (schema shape in the "Hook Structure" section above). If this creates \`.claude/settings.local.json\` for the first time, add it to .gitignore — the Write tool doesn't auto-gitignore it.
284
-
285
- 5. **Validate syntax + schema in one shot:**
286
-
287
- \`jq -e '.hooks.<event>[] | select(.matcher == "<matcher>") | .hooks[] | select(.type == "command") | .command' <target-file>\`
288
-
289
- Exit 0 + prints your command = correct. Exit 4 = matcher doesn't match. Exit 5 = malformed JSON or wrong nesting. A broken settings.json silently disables ALL settings from that file — fix any pre-existing malformation too.
290
-
291
- 6. **Prove the hook fires** — only for \`Pre|PostToolUse\` on a matcher you can trigger in-turn (\`Write|Edit\` via Edit, \`Bash\` via Bash). \`Stop\`/\`UserPromptSubmit\`/\`SessionStart\` fire outside this turn — skip to step 7.
292
-
293
- For a **formatter** on \`PostToolUse\`/\`Write|Edit\`: introduce a detectable violation via Edit (two consecutive blank lines, bad indentation, missing semicolon — something this formatter corrects; NOT trailing whitespace, Edit strips that before writing), re-read, confirm the hook **fixed** it. For **anything else**: temporarily prefix the command in settings.json with \`echo "$(date) hook fired" >> /tmp/claude-hook-check.txt; \`, trigger the matching tool (Edit for \`Write|Edit\`, a harmless \`true\` for \`Bash\`), read the sentinel file.
294
-
295
- **Always clean up** — revert the violation, strip the sentinel prefix — whether the proof passed or failed.
296
-
297
- **If proof fails but pipe-test passed and \`jq -e\` passed**: the settings watcher isn't watching \`.claude/\` — it only watches directories that had a settings file when this session started. The hook is written correctly. Tell the user to open \`/hooks\` once (reloads config) or restart — you can't do this yourself; \`/hooks\` is a user UI menu and opening it ends this turn.
298
-
299
- 7. **Handoff.** Tell the user the hook is live (or needs \`/hooks\`/restart per the watcher caveat). Point them at \`/hooks\` to review, edit, or disable it later. The UI only shows "Ran N hooks" if a hook errors or is slow — silent success is invisible by design.
264
+ const HOOK_VERIFICATION_FLOW = `## Constructing a Hook (with verification)
265
+
266
+ Given an event, matcher, target file, and desired behavior, follow this flow. Each step catches a different failure class — a hook that silently does nothing is worse than no hook.
267
+
268
+ 1. **Dedup check.** Read the target file. If a hook already exists on the same event+matcher, show the existing command and ask: keep it, replace it, or add alongside.
269
+
270
+ 2. **Construct the command for THIS project — don't assume.** The hook receives JSON on stdin. Build a command that:
271
+ - Extracts any needed payload safely — use \`jq -r\` into a quoted variable or \`{ read -r f; ... "$f"; }\`, NOT unquoted \`| xargs\` (splits on spaces)
272
+ - Invokes the underlying tool the way this project runs it (npx/bunx/yarn/pnpm? Makefile target? globally-installed?)
273
+ - Skips inputs the tool doesn't handle (formatters often have \`--ignore-unknown\`; if not, guard by extension)
274
+ - Stays RAW for now — no \`|| true\`, no stderr suppression. You'll wrap it after the pipe-test passes.
275
+
276
+ 3. **Pipe-test the raw command.** Synthesize the stdin payload the hook will receive and pipe it directly:
277
+ - \`Pre|PostToolUse\` on \`Write|Edit\`: \`echo '{"tool_name":"Edit","tool_input":{"file_path":"<a real file from this repo>"}}' | <cmd>\`
278
+ - \`Pre|PostToolUse\` on \`Bash\`: \`echo '{"tool_name":"Bash","tool_input":{"command":"ls"}}' | <cmd>\`
279
+ - \`Stop\`/\`UserPromptSubmit\`/\`SessionStart\`: most commands don't read stdin, so \`echo '{}' | <cmd>\` suffices
280
+
281
+ Check exit code AND side effect (file actually formatted, test actually ran). If it fails you get a real error — fix (wrong package manager? tool not installed? jq path wrong?) and retest. Once it works, wrap with \`2>/dev/null || true\` (unless the user wants a blocking check).
282
+
283
+ 4. **Write the JSON.** Merge into the target file (schema shape in the "Hook Structure" section above). If this creates \`.claude/settings.local.json\` for the first time, add it to .gitignore — the Write tool doesn't auto-gitignore it.
284
+
285
+ 5. **Validate syntax + schema in one shot:**
286
+
287
+ \`jq -e '.hooks.<event>[] | select(.matcher == "<matcher>") | .hooks[] | select(.type == "command") | .command' <target-file>\`
288
+
289
+ Exit 0 + prints your command = correct. Exit 4 = matcher doesn't match. Exit 5 = malformed JSON or wrong nesting. A broken settings.json silently disables ALL settings from that file — fix any pre-existing malformation too.
290
+
291
+ 6. **Prove the hook fires** — only for \`Pre|PostToolUse\` on a matcher you can trigger in-turn (\`Write|Edit\` via Edit, \`Bash\` via Bash). \`Stop\`/\`UserPromptSubmit\`/\`SessionStart\` fire outside this turn — skip to step 7.
292
+
293
+ For a **formatter** on \`PostToolUse\`/\`Write|Edit\`: introduce a detectable violation via Edit (two consecutive blank lines, bad indentation, missing semicolon — something this formatter corrects; NOT trailing whitespace, Edit strips that before writing), re-read, confirm the hook **fixed** it. For **anything else**: temporarily prefix the command in settings.json with \`echo "$(date) hook fired" >> /tmp/claude-hook-check.txt; \`, trigger the matching tool (Edit for \`Write|Edit\`, a harmless \`true\` for \`Bash\`), read the sentinel file.
294
+
295
+ **Always clean up** — revert the violation, strip the sentinel prefix — whether the proof passed or failed.
296
+
297
+ **If proof fails but pipe-test passed and \`jq -e\` passed**: the settings watcher isn't watching \`.claude/\` — it only watches directories that had a settings file when this session started. The hook is written correctly. Tell the user to open \`/hooks\` once (reloads config) or restart — you can't do this yourself; \`/hooks\` is a user UI menu and opening it ends this turn.
298
+
299
+ 7. **Handoff.** Tell the user the hook is live (or needs \`/hooks\`/restart per the watcher caveat). Point them at \`/hooks\` to review, edit, or disable it later. The UI only shows "Ran N hooks" if a hook errors or is slow — silent success is invisible by design.
300
300
  `;
301
- const UPDATE_CONFIG_PROMPT = `# Update Config Skill
302
-
303
- Modify Context Code configuration by updating settings.json files.
304
-
305
- ## When Hooks Are Required (Not Memory)
306
-
307
- If the user wants something to happen automatically in response to an EVENT, they need a **hook** configured in settings.json. Memory/preferences cannot trigger automated actions.
308
-
309
- **These require hooks:**
310
- - "Before compacting, ask me what to preserve" → PreCompact hook
311
- - "After writing files, run prettier" → PostToolUse hook with Write|Edit matcher
312
- - "When I run bash commands, log them" → PreToolUse hook with Bash matcher
313
- - "Always run tests after code changes" → PostToolUse hook
314
-
315
- **Hook events:** PreToolUse, PostToolUse, PreCompact, PostCompact, Stop, Notification, SessionStart
316
-
317
- ## CRITICAL: Read Before Write
318
-
319
- **Always read the existing settings file before making changes.** Merge new settings with existing ones - never replace the entire file.
320
-
321
- ## CRITICAL: Use AskUserQuestion for Ambiguity
322
-
323
- When the user's request is ambiguous, use AskUserQuestion to clarify:
324
- - Which settings file to modify (user/project/local)
325
- - Whether to add to existing arrays or replace them
326
- - Specific values when multiple options exist
327
-
328
- ## Decision: Config Tool vs Direct Edit
329
-
330
- **Use the Config tool** for these simple settings:
331
- - \`theme\`, \`editorMode\`, \`verbose\`, \`model\`
332
- - \`language\`, \`alwaysThinkingEnabled\`
333
- - \`permissions.defaultMode\`
334
-
335
- **Edit settings.json directly** for:
336
- - Hooks (PreToolUse, PostToolUse, etc.)
337
- - Complex permission rules (allow/deny arrays)
338
- - Environment variables
339
- - MCP server configuration
340
- - Plugin configuration
341
-
342
- ## Workflow
343
-
344
- 1. **Clarify intent** - Ask if the request is ambiguous
345
- 2. **Read existing file** - Use Read tool on the target settings file
346
- 3. **Merge carefully** - Preserve existing settings, especially arrays
347
- 4. **Edit file** - Use Edit tool (if file doesn't exist, ask user to create it first)
348
- 5. **Confirm** - Tell user what was changed
349
-
350
- ## Merging Arrays (Important!)
351
-
352
- When adding to permission arrays or hook arrays, **merge with existing**, don't replace:
353
-
354
- **WRONG** (replaces existing permissions):
355
- \`\`\`json
356
- { "permissions": { "allow": ["Bash(npm:*)"] } }
357
- \`\`\`
358
-
359
- **RIGHT** (preserves existing + adds new):
360
- \`\`\`json
361
- {
362
- "permissions": {
363
- "allow": [
364
- "Bash(git:*)", // existing
365
- "Edit(.claude)", // existing
366
- "Bash(npm:*)" // new
367
- ]
368
- }
369
- }
370
- \`\`\`
371
-
372
- ${SETTINGS_EXAMPLES_DOCS}
373
-
374
- ${HOOKS_DOCS}
375
-
376
- ${HOOK_VERIFICATION_FLOW}
377
-
378
- ## Example Workflows
379
-
380
- ### Adding a Hook
381
-
382
- User: "Format my code after Claude writes it"
383
-
384
- 1. **Clarify**: Which formatter? (prettier, gofmt, etc.)
385
- 2. **Read**: \`.claude/settings.json\` (or create if missing)
386
- 3. **Merge**: Add to existing hooks, don't replace
387
- 4. **Result**:
388
- \`\`\`json
389
- {
390
- "hooks": {
391
- "PostToolUse": [{
392
- "matcher": "Write|Edit",
393
- "hooks": [{
394
- "type": "command",
395
- "command": "jq -r '.tool_response.filePath // .tool_input.file_path' | { read -r f; prettier --write \\"$f\\"; } 2>/dev/null || true"
396
- }]
397
- }]
398
- }
399
- }
400
- \`\`\`
401
-
402
- ### Adding Permissions
403
-
404
- User: "Allow npm commands without prompting"
405
-
406
- 1. **Read**: Existing permissions
407
- 2. **Merge**: Add \`Bash(npm:*)\` to allow array
408
- 3. **Result**: Combined with existing allows
409
-
410
- ### Environment Variables
411
-
412
- User: "Set DEBUG=true"
413
-
414
- 1. **Decide**: User settings (global) or project settings?
415
- 2. **Read**: Target file
416
- 3. **Merge**: Add to env object
417
- \`\`\`json
418
- { "env": { "DEBUG": "true" } }
419
- \`\`\`
420
-
421
- ## Common Mistakes to Avoid
422
-
423
- 1. **Replacing instead of merging** - Always preserve existing settings
424
- 2. **Wrong file** - Ask user if scope is unclear
425
- 3. **Invalid JSON** - Validate syntax after changes
426
- 4. **Forgetting to read first** - Always read before write
427
-
428
- ## Troubleshooting Hooks
429
-
430
- If a hook isn't running:
431
- 1. **Check the settings file** - Read ~/.context/settings.json or .context/settings.json
432
- 2. **Verify JSON syntax** - Invalid JSON silently fails
433
- 3. **Check the matcher** - Does it match the tool name? (e.g., "Bash", "Write", "Edit")
434
- 4. **Check hook type** - Is it "command", "prompt", or "agent"?
435
- 5. **Test the command** - Run the hook command manually to see if it works
436
- 6. **Use --debug** - Run \`claude --debug\` to see hook execution logs
301
+ const UPDATE_CONFIG_PROMPT = `# Update Config Skill
302
+
303
+ Modify Context Code configuration by updating settings.json files.
304
+
305
+ ## When Hooks Are Required (Not Memory)
306
+
307
+ If the user wants something to happen automatically in response to an EVENT, they need a **hook** configured in settings.json. Memory/preferences cannot trigger automated actions.
308
+
309
+ **These require hooks:**
310
+ - "Before compacting, ask me what to preserve" → PreCompact hook
311
+ - "After writing files, run prettier" → PostToolUse hook with Write|Edit matcher
312
+ - "When I run bash commands, log them" → PreToolUse hook with Bash matcher
313
+ - "Always run tests after code changes" → PostToolUse hook
314
+
315
+ **Hook events:** PreToolUse, PostToolUse, PreCompact, PostCompact, Stop, Notification, SessionStart
316
+
317
+ ## CRITICAL: Read Before Write
318
+
319
+ **Always read the existing settings file before making changes.** Merge new settings with existing ones - never replace the entire file.
320
+
321
+ ## CRITICAL: Use AskUserQuestion for Ambiguity
322
+
323
+ When the user's request is ambiguous, use AskUserQuestion to clarify:
324
+ - Which settings file to modify (user/project/local)
325
+ - Whether to add to existing arrays or replace them
326
+ - Specific values when multiple options exist
327
+
328
+ ## Decision: Config Tool vs Direct Edit
329
+
330
+ **Use the Config tool** for these simple settings:
331
+ - \`theme\`, \`editorMode\`, \`verbose\`, \`model\`
332
+ - \`language\`, \`alwaysThinkingEnabled\`
333
+ - \`permissions.defaultMode\`
334
+
335
+ **Edit settings.json directly** for:
336
+ - Hooks (PreToolUse, PostToolUse, etc.)
337
+ - Complex permission rules (allow/deny arrays)
338
+ - Environment variables
339
+ - MCP server configuration
340
+ - Plugin configuration
341
+
342
+ ## Workflow
343
+
344
+ 1. **Clarify intent** - Ask if the request is ambiguous
345
+ 2. **Read existing file** - Use Read tool on the target settings file
346
+ 3. **Merge carefully** - Preserve existing settings, especially arrays
347
+ 4. **Edit file** - Use Edit tool (if file doesn't exist, ask user to create it first)
348
+ 5. **Confirm** - Tell user what was changed
349
+
350
+ ## Merging Arrays (Important!)
351
+
352
+ When adding to permission arrays or hook arrays, **merge with existing**, don't replace:
353
+
354
+ **WRONG** (replaces existing permissions):
355
+ \`\`\`json
356
+ { "permissions": { "allow": ["Bash(npm:*)"] } }
357
+ \`\`\`
358
+
359
+ **RIGHT** (preserves existing + adds new):
360
+ \`\`\`json
361
+ {
362
+ "permissions": {
363
+ "allow": [
364
+ "Bash(git:*)", // existing
365
+ "Edit(.claude)", // existing
366
+ "Bash(npm:*)" // new
367
+ ]
368
+ }
369
+ }
370
+ \`\`\`
371
+
372
+ ${SETTINGS_EXAMPLES_DOCS}
373
+
374
+ ${HOOKS_DOCS}
375
+
376
+ ${HOOK_VERIFICATION_FLOW}
377
+
378
+ ## Example Workflows
379
+
380
+ ### Adding a Hook
381
+
382
+ User: "Format my code after Claude writes it"
383
+
384
+ 1. **Clarify**: Which formatter? (prettier, gofmt, etc.)
385
+ 2. **Read**: \`.claude/settings.json\` (or create if missing)
386
+ 3. **Merge**: Add to existing hooks, don't replace
387
+ 4. **Result**:
388
+ \`\`\`json
389
+ {
390
+ "hooks": {
391
+ "PostToolUse": [{
392
+ "matcher": "Write|Edit",
393
+ "hooks": [{
394
+ "type": "command",
395
+ "command": "jq -r '.tool_response.filePath // .tool_input.file_path' | { read -r f; prettier --write \\"$f\\"; } 2>/dev/null || true"
396
+ }]
397
+ }]
398
+ }
399
+ }
400
+ \`\`\`
401
+
402
+ ### Adding Permissions
403
+
404
+ User: "Allow npm commands without prompting"
405
+
406
+ 1. **Read**: Existing permissions
407
+ 2. **Merge**: Add \`Bash(npm:*)\` to allow array
408
+ 3. **Result**: Combined with existing allows
409
+
410
+ ### Environment Variables
411
+
412
+ User: "Set DEBUG=true"
413
+
414
+ 1. **Decide**: User settings (global) or project settings?
415
+ 2. **Read**: Target file
416
+ 3. **Merge**: Add to env object
417
+ \`\`\`json
418
+ { "env": { "DEBUG": "true" } }
419
+ \`\`\`
420
+
421
+ ## Common Mistakes to Avoid
422
+
423
+ 1. **Replacing instead of merging** - Always preserve existing settings
424
+ 2. **Wrong file** - Ask user if scope is unclear
425
+ 3. **Invalid JSON** - Validate syntax after changes
426
+ 4. **Forgetting to read first** - Always read before write
427
+
428
+ ## Troubleshooting Hooks
429
+
430
+ If a hook isn't running:
431
+ 1. **Check the settings file** - Read ~/.context/settings.json or .context/settings.json
432
+ 2. **Verify JSON syntax** - Invalid JSON silently fails
433
+ 3. **Check the matcher** - Does it match the tool name? (e.g., "Bash", "Write", "Edit")
434
+ 4. **Check hook type** - Is it "command", "prompt", or "agent"?
435
+ 5. **Test the command** - Run the hook command manually to see if it works
436
+ 6. **Use --debug** - Run \`claude --debug\` to see hook execution logs
437
437
  `;
438
438
  export function registerUpdateConfigSkill() {
439
439
  registerBundledSkill({