feat(hooks): add config option to disable context window warnings (#1073)
Add hooks.context_warnings config option (default: true) that allows users to disable the context monitor hook's advisory messages. When set to false, the hook exits silently, allowing Claude Code to reach auto-compact naturally without being interrupted. This is useful for long unattended runs where users prefer Claude to auto-compact and continue rather than stopping to warn about context. Changes: - hooks/gsd-context-monitor.js: Check config before emitting warnings - get-shit-done/templates/config.json: Add hooks.context_warnings default - get-shit-done/workflows/settings.md: Add UI for the new setting Fixes #976
This commit is contained in:
@@ -33,5 +33,8 @@
|
||||
"safety": {
|
||||
"always_confirm_destructive": true,
|
||||
"always_confirm_external_services": true
|
||||
},
|
||||
"hooks": {
|
||||
"context_warnings": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +126,15 @@ AskUserQuestion([
|
||||
{ label: "Per Phase", description: "Create branch for each phase (gsd/phase-{N}-{name})" },
|
||||
{ label: "Per Milestone", description: "Create branch for entire milestone (gsd/{version}-{name})" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "Enable context window warnings? (injects advisory messages when context is getting full)",
|
||||
header: "Ctx Warnings",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Yes (Recommended)", description: "Warn when context usage exceeds 65%. Helps avoid losing work." },
|
||||
{ label: "No", description: "Disable warnings. Allows Claude to reach auto-compact naturally. Good for long unattended runs." }
|
||||
]
|
||||
}
|
||||
])
|
||||
```
|
||||
@@ -149,6 +158,9 @@ Merge new settings into existing config.json:
|
||||
},
|
||||
"git": {
|
||||
"branching_strategy": "none" | "phase" | "milestone"
|
||||
},
|
||||
"hooks": {
|
||||
"context_warnings": true/false
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -220,6 +232,7 @@ Display:
|
||||
| UI Phase | {On/Off} |
|
||||
| UI Safety Gate | {On/Off} |
|
||||
| Git Branching | {None/Per Phase/Per Milestone} |
|
||||
| Context Warnings | {On/Off} |
|
||||
| Saved as Defaults | {Yes/No} |
|
||||
|
||||
These settings apply to future /gsd:plan-phase and /gsd:execute-phase runs.
|
||||
|
||||
@@ -43,6 +43,20 @@ process.stdin.on('end', () => {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// Check if context warnings are disabled via config
|
||||
const cwd = data.cwd || process.cwd();
|
||||
const configPath = path.join(cwd, '.planning', 'config.json');
|
||||
if (fs.existsSync(configPath)) {
|
||||
try {
|
||||
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
||||
if (config.hooks?.context_warnings === false) {
|
||||
process.exit(0);
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore config parse errors
|
||||
}
|
||||
}
|
||||
|
||||
const tmpDir = os.tmpdir();
|
||||
const metricsPath = path.join(tmpDir, `claude-ctx-${sessionId}.json`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user