@axplusb/kepler 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -0
- package/package.json +36 -4
- package/pulse/app/activity/page.tsx +190 -0
- package/pulse/app/api/activity/route.ts +138 -0
- package/pulse/app/api/costs/route.ts +88 -0
- package/pulse/app/api/export/route.ts +77 -0
- package/pulse/app/api/history/route.ts +11 -0
- package/pulse/app/api/import/route.ts +31 -0
- package/pulse/app/api/memory/route.ts +52 -0
- package/pulse/app/api/plans/route.ts +9 -0
- package/pulse/app/api/projects/[slug]/route.ts +96 -0
- package/pulse/app/api/projects/route.ts +121 -0
- package/pulse/app/api/sessions/[id]/replay/route.ts +20 -0
- package/pulse/app/api/sessions/[id]/route.ts +31 -0
- package/pulse/app/api/sessions/route.ts +112 -0
- package/pulse/app/api/settings/route.ts +14 -0
- package/pulse/app/api/stats/route.ts +143 -0
- package/pulse/app/api/todos/route.ts +9 -0
- package/pulse/app/api/tools/route.ts +160 -0
- package/pulse/app/costs/page.tsx +179 -0
- package/pulse/app/export/page.tsx +465 -0
- package/pulse/app/favicon.ico +0 -0
- package/pulse/app/globals.css +263 -0
- package/pulse/app/help/page.tsx +142 -0
- package/pulse/app/history/page.tsx +157 -0
- package/pulse/app/layout.tsx +46 -0
- package/pulse/app/memory/page.tsx +365 -0
- package/pulse/app/overview-client.tsx +393 -0
- package/pulse/app/page.tsx +14 -0
- package/pulse/app/plans/page.tsx +308 -0
- package/pulse/app/projects/[slug]/page.tsx +390 -0
- package/pulse/app/projects/page.tsx +110 -0
- package/pulse/app/sessions/[id]/page.tsx +243 -0
- package/pulse/app/sessions/page.tsx +39 -0
- package/pulse/app/settings/page.tsx +188 -0
- package/pulse/app/todos/page.tsx +211 -0
- package/pulse/app/tools/page.tsx +249 -0
- package/pulse/cli.js +159 -0
- package/pulse/components/activity/day-of-week-chart.tsx +35 -0
- package/pulse/components/activity/streak-card.tsx +36 -0
- package/pulse/components/costs/cache-efficiency-panel.tsx +76 -0
- package/pulse/components/costs/cost-by-project-chart.tsx +48 -0
- package/pulse/components/costs/cost-over-time-chart.tsx +95 -0
- package/pulse/components/costs/model-token-table.tsx +60 -0
- package/pulse/components/global-search.tsx +193 -0
- package/pulse/components/keyboard-nav-provider.tsx +23 -0
- package/pulse/components/layout/bottom-nav.tsx +52 -0
- package/pulse/components/layout/client-layout.tsx +31 -0
- package/pulse/components/layout/sidebar-context.tsx +50 -0
- package/pulse/components/layout/sidebar.tsx +182 -0
- package/pulse/components/layout/top-bar.tsx +121 -0
- package/pulse/components/overview/activity-heatmap.tsx +107 -0
- package/pulse/components/overview/conversation-table.tsx +148 -0
- package/pulse/components/overview/model-breakdown-donut.tsx +95 -0
- package/pulse/components/overview/peak-hours-chart.tsx +87 -0
- package/pulse/components/overview/project-activity-donut.tsx +96 -0
- package/pulse/components/overview/stat-card.tsx +102 -0
- package/pulse/components/overview/usage-over-time-chart.tsx +166 -0
- package/pulse/components/projects/project-card.tsx +175 -0
- package/pulse/components/sessions/replay/assistant-markdown.tsx +94 -0
- package/pulse/components/sessions/replay/compaction-card.tsx +25 -0
- package/pulse/components/sessions/replay/session-sidebar.tsx +231 -0
- package/pulse/components/sessions/replay/token-accumulation-chart.tsx +98 -0
- package/pulse/components/sessions/replay/tool-call-badge.tsx +127 -0
- package/pulse/components/sessions/replay/turn-cards.tsx +220 -0
- package/pulse/components/sessions/replay/user-tool-result.tsx +158 -0
- package/pulse/components/sessions/session-badges.tsx +49 -0
- package/pulse/components/sessions/session-table.tsx +299 -0
- package/pulse/components/theme-provider.tsx +44 -0
- package/pulse/components/tools/feature-adoption-table.tsx +58 -0
- package/pulse/components/tools/mcp-server-panel.tsx +45 -0
- package/pulse/components/tools/tool-ranking-chart.tsx +57 -0
- package/pulse/components/tools/version-history-table.tsx +32 -0
- package/pulse/components/ui/alert.tsx +66 -0
- package/pulse/components/ui/badge.tsx +48 -0
- package/pulse/components/ui/breadcrumb.tsx +109 -0
- package/pulse/components/ui/button.tsx +64 -0
- package/pulse/components/ui/calendar.tsx +220 -0
- package/pulse/components/ui/card.tsx +92 -0
- package/pulse/components/ui/command.tsx +158 -0
- package/pulse/components/ui/dialog.tsx +158 -0
- package/pulse/components/ui/input.tsx +21 -0
- package/pulse/components/ui/popover.tsx +89 -0
- package/pulse/components/ui/progress.tsx +31 -0
- package/pulse/components/ui/select.tsx +190 -0
- package/pulse/components/ui/separator.tsx +28 -0
- package/pulse/components/ui/sheet.tsx +143 -0
- package/pulse/components/ui/skeleton.tsx +13 -0
- package/pulse/components/ui/table.tsx +116 -0
- package/pulse/components/ui/tabs.tsx +91 -0
- package/pulse/components/ui/tooltip.tsx +57 -0
- package/pulse/components/use-global-keyboard-nav.ts +79 -0
- package/pulse/components.json +23 -0
- package/pulse/eslint.config.mjs +18 -0
- package/pulse/lib/claude-reader.ts +594 -0
- package/pulse/lib/decode.ts +129 -0
- package/pulse/lib/pricing.ts +102 -0
- package/pulse/lib/replay-parser.ts +165 -0
- package/pulse/lib/tool-categories.ts +127 -0
- package/pulse/lib/utils.ts +6 -0
- package/pulse/next-env.d.ts +6 -0
- package/pulse/next.config.ts +16 -0
- package/pulse/package.json +45 -0
- package/pulse/postcss.config.mjs +7 -0
- package/pulse/public/activity.png +0 -0
- package/pulse/public/cc-lens.png +0 -0
- package/pulse/public/command-k.png +0 -0
- package/pulse/public/costs.png +0 -0
- package/pulse/public/dashboard-dark.png +0 -0
- package/pulse/public/dashboard-white.png +0 -0
- package/pulse/public/export.png +0 -0
- package/pulse/public/file.svg +1 -0
- package/pulse/public/globe.svg +1 -0
- package/pulse/public/next.svg +1 -0
- package/pulse/public/projects.png +0 -0
- package/pulse/public/session-chat.png +0 -0
- package/pulse/public/todos.png +0 -0
- package/pulse/public/tools.png +0 -0
- package/pulse/public/vercel.svg +1 -0
- package/pulse/public/window.svg +1 -0
- package/pulse/tsconfig.json +34 -0
- package/pulse/types/claude.ts +294 -0
- package/src/agents/loader.mjs +89 -0
- package/src/agents/parser.mjs +98 -0
- package/src/agents/teams.mjs +123 -0
- package/src/auth/oauth.mjs +220 -0
- package/src/auth/tarang-auth.mjs +277 -0
- package/src/config/cli-args.mjs +173 -0
- package/src/config/env.mjs +263 -0
- package/src/config/settings.mjs +132 -0
- package/src/context/ast-parser.mjs +298 -0
- package/src/context/bm25.mjs +85 -0
- package/src/context/retriever.mjs +270 -0
- package/src/context/skeleton.mjs +134 -0
- package/src/core/agent-loop.mjs +480 -0
- package/src/core/approval.mjs +273 -0
- package/src/core/backend-url.mjs +57 -0
- package/src/core/cache.mjs +105 -0
- package/src/core/callback-client.mjs +149 -0
- package/src/core/checkpoints.mjs +142 -0
- package/src/core/context-manager.mjs +198 -0
- package/src/core/headless.mjs +168 -0
- package/src/core/hooks-manager.mjs +87 -0
- package/src/core/jsonl-writer.mjs +351 -0
- package/src/core/local-agent.mjs +429 -0
- package/src/core/local-store.mjs +325 -0
- package/src/core/mode-selector.mjs +51 -0
- package/src/core/output-filter.mjs +177 -0
- package/src/core/paths.mjs +98 -0
- package/src/core/pricing.mjs +314 -0
- package/src/core/providers.mjs +219 -0
- package/src/core/rate-limiter.mjs +119 -0
- package/src/core/safety.mjs +200 -0
- package/src/core/scheduler.mjs +173 -0
- package/src/core/session-manager.mjs +317 -0
- package/src/core/session.mjs +143 -0
- package/src/core/settings-sync.mjs +85 -0
- package/src/core/stagnation.mjs +57 -0
- package/src/core/stream-client.mjs +367 -0
- package/src/core/streaming.mjs +182 -0
- package/src/core/system-prompt.mjs +135 -0
- package/src/core/tool-executor.mjs +725 -0
- package/src/hooks/engine.mjs +162 -0
- package/src/index.mjs +370 -0
- package/src/mcp/client.mjs +253 -0
- package/src/mcp/transport-shttp.mjs +130 -0
- package/src/mcp/transport-sse.mjs +131 -0
- package/src/mcp/transport-ws.mjs +134 -0
- package/src/permissions/checker.mjs +57 -0
- package/src/permissions/command-classifier.mjs +573 -0
- package/src/permissions/injection-check.mjs +60 -0
- package/src/permissions/path-check.mjs +102 -0
- package/src/permissions/prompt.mjs +73 -0
- package/src/permissions/sandbox.mjs +112 -0
- package/src/plugins/loader.mjs +138 -0
- package/src/skills/loader.mjs +147 -0
- package/src/skills/runner.mjs +55 -0
- package/src/telemetry/index.mjs +96 -0
- package/src/terminal/agents.mjs +177 -0
- package/src/terminal/analytics.mjs +292 -0
- package/src/terminal/ansi.mjs +421 -0
- package/src/terminal/main.mjs +150 -0
- package/src/terminal/repl.mjs +1484 -0
- package/src/terminal/tool-display.mjs +58 -0
- package/src/tools/agent.mjs +137 -0
- package/src/tools/ask-user.mjs +61 -0
- package/src/tools/bash.mjs +148 -0
- package/src/tools/cron-create.mjs +120 -0
- package/src/tools/cron-delete.mjs +49 -0
- package/src/tools/cron-list.mjs +37 -0
- package/src/tools/edit.mjs +82 -0
- package/src/tools/enter-worktree.mjs +69 -0
- package/src/tools/exit-worktree.mjs +57 -0
- package/src/tools/glob.mjs +117 -0
- package/src/tools/grep.mjs +129 -0
- package/src/tools/lint.mjs +71 -0
- package/src/tools/ls.mjs +58 -0
- package/src/tools/lsp.mjs +115 -0
- package/src/tools/multi-edit.mjs +94 -0
- package/src/tools/notebook-edit.mjs +96 -0
- package/src/tools/read-mcp-resource.mjs +57 -0
- package/src/tools/read.mjs +138 -0
- package/src/tools/registry.mjs +132 -0
- package/src/tools/remote-trigger.mjs +84 -0
- package/src/tools/send-message.mjs +64 -0
- package/src/tools/skill.mjs +52 -0
- package/src/tools/test-runner.mjs +49 -0
- package/src/tools/todo-write.mjs +68 -0
- package/src/tools/tool-search.mjs +77 -0
- package/src/tools/web-fetch.mjs +65 -0
- package/src/tools/web-search.mjs +89 -0
- package/src/tools/write.mjs +55 -0
- package/src/ui/banner.mjs +237 -0
- package/src/ui/commands.mjs +499 -0
- package/src/ui/formatter.mjs +379 -0
- package/src/ui/markdown.mjs +278 -0
- package/src/ui/slash-commands.mjs +258 -0
- package/index.js +0 -1
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Variables — support for Claude Code env vars.
|
|
3
|
+
*
|
|
4
|
+
* Reads and normalizes the ~50 most important environment variables
|
|
5
|
+
* that control Claude Code behavior.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* All supported environment variables with defaults and descriptions.
|
|
10
|
+
*/
|
|
11
|
+
export const ENV_SCHEMA = {
|
|
12
|
+
// API Configuration
|
|
13
|
+
ANTHROPIC_API_KEY: { type: 'string', description: 'Anthropic API key' },
|
|
14
|
+
ANTHROPIC_BASE_URL: { type: 'string', default: 'https://api.anthropic.com', description: 'Anthropic API base URL' },
|
|
15
|
+
ANTHROPIC_MODEL: { type: 'string', description: 'Override default model' },
|
|
16
|
+
OPENAI_API_KEY: { type: 'string', description: 'OpenAI API key for compatible models' },
|
|
17
|
+
OPENAI_BASE_URL: { type: 'string', default: 'https://api.openai.com/v1', description: 'OpenAI-compatible base URL' },
|
|
18
|
+
GOOGLE_API_KEY: { type: 'string', description: 'Google AI API key' },
|
|
19
|
+
GEMINI_API_KEY: { type: 'string', description: 'Alias for GOOGLE_API_KEY' },
|
|
20
|
+
|
|
21
|
+
// Model Configuration
|
|
22
|
+
CLAUDE_CODE_MAX_OUTPUT_TOKENS: { type: 'number', default: 16384, description: 'Max output tokens' },
|
|
23
|
+
CLAUDE_CODE_SUBAGENT_MODEL: { type: 'string', description: 'Model for subagents' },
|
|
24
|
+
CLAUDE_CODE_EFFORT_LEVEL: { type: 'string', default: 'normal', description: 'Effort level (low/normal/high)' },
|
|
25
|
+
|
|
26
|
+
// Behavior Flags
|
|
27
|
+
CLAUDE_CODE_BRIEF: { type: 'boolean', default: false, description: 'Brief output mode' },
|
|
28
|
+
CLAUDE_CODE_DISABLE_CRON: { type: 'boolean', default: false, description: 'Disable cron tasks' },
|
|
29
|
+
CLAUDE_CODE_ENABLE_TASKS: { type: 'boolean', default: false, description: 'Enable task system' },
|
|
30
|
+
ORCA_STAGNATION_DETECTION: { type: 'boolean', default: false, description: 'Detect consecutive identical tool-call loops' },
|
|
31
|
+
ORCA_STAGNATION_THRESHOLD: { type: 'number', default: 3, description: 'Consecutive identical calls before warning' },
|
|
32
|
+
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: { type: 'boolean', default: false, description: 'Enable agent teams' },
|
|
33
|
+
CLAUDE_CODE_DEBUG: { type: 'boolean', default: false, description: 'Debug mode' },
|
|
34
|
+
CLAUDE_CODE_DISABLE_TELEMETRY: { type: 'boolean', default: false, description: 'Disable telemetry' },
|
|
35
|
+
|
|
36
|
+
// Permission and Security
|
|
37
|
+
CLAUDE_CODE_PERMISSION_MODE: { type: 'string', default: 'default', description: 'Permission mode' },
|
|
38
|
+
CLAUDE_CODE_SANDBOX: { type: 'boolean', default: true, description: 'Enable sandbox' },
|
|
39
|
+
|
|
40
|
+
// Context and Memory
|
|
41
|
+
CLAUDE_CODE_MAX_CONTEXT_TOKENS: { type: 'number', default: 180000, description: 'Max context window tokens' },
|
|
42
|
+
CLAUDE_CODE_AUTO_COMPACT: { type: 'boolean', default: true, description: 'Auto-compact context' },
|
|
43
|
+
|
|
44
|
+
// UI and Display
|
|
45
|
+
SHOW_THINKING: { type: 'boolean', default: false, description: 'Show thinking blocks' },
|
|
46
|
+
SHOW_TOOL_RESULTS: { type: 'boolean', default: false, description: 'Show tool results in REPL' },
|
|
47
|
+
NO_COLOR: { type: 'boolean', default: false, description: 'Disable colored output' },
|
|
48
|
+
TERM: { type: 'string', description: 'Terminal type' },
|
|
49
|
+
|
|
50
|
+
// MCP
|
|
51
|
+
MCP_DEBUG: { type: 'boolean', default: false, description: 'MCP debug logging' },
|
|
52
|
+
|
|
53
|
+
// Remote
|
|
54
|
+
REMOTE_AGENT_URL: { type: 'string', description: 'Remote agent endpoint' },
|
|
55
|
+
REMOTE_AGENT_TOKEN: { type: 'string', description: 'Remote agent auth token' },
|
|
56
|
+
|
|
57
|
+
// Search
|
|
58
|
+
BRAVE_API_KEY: { type: 'string', description: 'Brave Search API key' },
|
|
59
|
+
SEARXNG_URL: { type: 'string', description: 'SearXNG instance URL' },
|
|
60
|
+
|
|
61
|
+
// Networking
|
|
62
|
+
HTTP_PROXY: { type: 'string', description: 'HTTP proxy URL' },
|
|
63
|
+
HTTPS_PROXY: { type: 'string', description: 'HTTPS proxy URL' },
|
|
64
|
+
NO_PROXY: { type: 'string', description: 'No-proxy list' },
|
|
65
|
+
|
|
66
|
+
// Agent Identity
|
|
67
|
+
AGENT_ID: { type: 'string', default: 'main', description: 'Agent identifier for teams' },
|
|
68
|
+
|
|
69
|
+
// Feature Flags
|
|
70
|
+
CLAUDE_CODE_THINKING: { type: 'boolean', default: false, description: 'Enable extended thinking' },
|
|
71
|
+
CLAUDE_CODE_THINKING_BUDGET: { type: 'number', default: 10000, description: 'Thinking token budget' },
|
|
72
|
+
CLAUDE_CODE_STREAMING: { type: 'boolean', default: true, description: 'Enable streaming' },
|
|
73
|
+
|
|
74
|
+
// Paths
|
|
75
|
+
CLAUDE_CONFIG_DIR: { type: 'string', description: 'Custom config directory' },
|
|
76
|
+
CLAUDE_CACHE_DIR: { type: 'string', description: 'Custom cache directory' },
|
|
77
|
+
|
|
78
|
+
// Extended: OAuth & Auth
|
|
79
|
+
CLAUDE_OAUTH_CLIENT_ID: { type: 'string', description: 'OAuth client ID' },
|
|
80
|
+
CLAUDE_OAUTH_REDIRECT_URI: { type: 'string', default: 'http://localhost:9876/callback', description: 'OAuth redirect URI' },
|
|
81
|
+
ANTHROPIC_AUTH_TOKEN: { type: 'string', description: 'Anthropic auth token (OAuth)' },
|
|
82
|
+
|
|
83
|
+
// Extended: Sandbox & Security
|
|
84
|
+
CLAUDE_CODE_SANDBOX_PLATFORM: { type: 'string', description: 'Override sandbox platform (linux/darwin)' },
|
|
85
|
+
CLAUDE_CODE_INJECTION_CHECK: { type: 'boolean', default: true, description: 'Enable command injection checks' },
|
|
86
|
+
CLAUDE_CODE_PATH_CHECK: { type: 'boolean', default: true, description: 'Enable file path validation' },
|
|
87
|
+
|
|
88
|
+
// Extended: Rate Limiting
|
|
89
|
+
CLAUDE_CODE_MAX_RETRIES: { type: 'number', default: 5, description: 'Max API retries on 429/529' },
|
|
90
|
+
CLAUDE_CODE_RETRY_BASE_DELAY: { type: 'number', default: 1000, description: 'Base retry delay in ms' },
|
|
91
|
+
CLAUDE_CODE_RETRY_MAX_DELAY: { type: 'number', default: 60000, description: 'Max retry delay in ms' },
|
|
92
|
+
|
|
93
|
+
// Extended: Agent Teams
|
|
94
|
+
CLAUDE_CODE_TEAM_SIZE: { type: 'number', default: 5, description: 'Max team size for multi-agent' },
|
|
95
|
+
CLAUDE_CODE_TEAM_BROADCAST: { type: 'boolean', default: false, description: 'Broadcast messages to all teammates' },
|
|
96
|
+
|
|
97
|
+
// Extended: Providers
|
|
98
|
+
AWS_ACCESS_KEY_ID: { type: 'string', description: 'AWS access key for Bedrock' },
|
|
99
|
+
AWS_SECRET_ACCESS_KEY: { type: 'string', description: 'AWS secret key for Bedrock' },
|
|
100
|
+
AWS_REGION: { type: 'string', default: 'us-east-1', description: 'AWS region for Bedrock' },
|
|
101
|
+
GOOGLE_APPLICATION_CREDENTIALS: { type: 'string', description: 'GCP service account credentials path' },
|
|
102
|
+
VERTEX_PROJECT: { type: 'string', description: 'GCP project for Vertex AI' },
|
|
103
|
+
VERTEX_REGION: { type: 'string', default: 'us-central1', description: 'GCP region for Vertex AI' },
|
|
104
|
+
|
|
105
|
+
// Extended: Cron & Scheduling
|
|
106
|
+
CLAUDE_CODE_CRON_INTERVAL: { type: 'number', default: 60000, description: 'Cron check interval in ms' },
|
|
107
|
+
CLAUDE_CODE_SCHEDULED_TASKS_FILE: { type: 'string', description: 'Path to scheduled tasks JSON' },
|
|
108
|
+
|
|
109
|
+
// Extended: Plugins
|
|
110
|
+
CLAUDE_CODE_PLUGIN_DIR: { type: 'string', description: 'Custom plugin directory' },
|
|
111
|
+
CLAUDE_CODE_DISABLE_PLUGINS: { type: 'boolean', default: false, description: 'Disable all plugins' },
|
|
112
|
+
|
|
113
|
+
// Extended: Session
|
|
114
|
+
CLAUDE_CODE_SESSION_TTL: { type: 'number', default: 86400000, description: 'Session TTL in ms (default 24h)' },
|
|
115
|
+
CLAUDE_CODE_AUTO_SAVE: { type: 'boolean', default: true, description: 'Auto-save sessions' },
|
|
116
|
+
|
|
117
|
+
// Extended: Logging
|
|
118
|
+
CLAUDE_CODE_LOG_LEVEL: { type: 'string', default: 'info', description: 'Log level (debug/info/warn/error)' },
|
|
119
|
+
CLAUDE_CODE_LOG_FILE: { type: 'string', description: 'Log file path' },
|
|
120
|
+
|
|
121
|
+
// Extended: Hooks
|
|
122
|
+
CLAUDE_CODE_HOOK_TIMEOUT: { type: 'number', default: 10000, description: 'Hook execution timeout in ms' },
|
|
123
|
+
CLAUDE_CODE_HOOK_FAIL_OPEN: { type: 'boolean', default: true, description: 'Allow on hook failure' },
|
|
124
|
+
|
|
125
|
+
// Extended: Context
|
|
126
|
+
CLAUDE_CODE_COMPACT_THRESHOLD: { type: 'number', default: 0.8, description: 'Context compaction threshold (0-1)' },
|
|
127
|
+
CLAUDE_CODE_MAX_MESSAGES: { type: 'number', default: 200, description: 'Max messages in context' },
|
|
128
|
+
|
|
129
|
+
// Extended: Cache
|
|
130
|
+
CLAUDE_CODE_PROMPT_CACHE: { type: 'boolean', default: true, description: 'Enable prompt caching' },
|
|
131
|
+
CLAUDE_CODE_CACHE_TTL: { type: 'number', default: 300000, description: 'Cache TTL in ms (default 5min)' },
|
|
132
|
+
|
|
133
|
+
// Extended: Output
|
|
134
|
+
CLAUDE_CODE_MAX_LINES: { type: 'number', default: 200, description: 'Max output lines for tools' },
|
|
135
|
+
CLAUDE_CODE_TRUNCATE: { type: 'boolean', default: true, description: 'Truncate long outputs' },
|
|
136
|
+
CLAUDE_CODE_JSON_OUTPUT: { type: 'boolean', default: false, description: 'Output JSON instead of text' },
|
|
137
|
+
|
|
138
|
+
// Extended: Git
|
|
139
|
+
CLAUDE_CODE_GIT_ENABLED: { type: 'boolean', default: true, description: 'Enable git operations' },
|
|
140
|
+
CLAUDE_CODE_GIT_AUTO_COMMIT: { type: 'boolean', default: false, description: 'Auto-commit changes' },
|
|
141
|
+
|
|
142
|
+
// Extended: Editor
|
|
143
|
+
EDITOR: { type: 'string', description: 'Default text editor' },
|
|
144
|
+
VISUAL: { type: 'string', description: 'Default visual editor' },
|
|
145
|
+
|
|
146
|
+
// Extended: Language
|
|
147
|
+
LANG: { type: 'string', description: 'System locale' },
|
|
148
|
+
LC_ALL: { type: 'string', description: 'Locale override' },
|
|
149
|
+
|
|
150
|
+
// Extended: CI/CD
|
|
151
|
+
CI: { type: 'boolean', default: false, description: 'Running in CI environment' },
|
|
152
|
+
GITHUB_ACTIONS: { type: 'boolean', default: false, description: 'Running in GitHub Actions' },
|
|
153
|
+
GITLAB_CI: { type: 'boolean', default: false, description: 'Running in GitLab CI' },
|
|
154
|
+
|
|
155
|
+
// Extended: Container
|
|
156
|
+
CONTAINER: { type: 'boolean', default: false, description: 'Running in container' },
|
|
157
|
+
DOCKER: { type: 'boolean', default: false, description: 'Running in Docker' },
|
|
158
|
+
CODESPACE_NAME: { type: 'string', description: 'GitHub Codespace name' },
|
|
159
|
+
|
|
160
|
+
// Extended: Notification
|
|
161
|
+
CLAUDE_CODE_NOTIFY: { type: 'boolean', default: false, description: 'Enable desktop notifications' },
|
|
162
|
+
CLAUDE_CODE_WEBHOOK_URL: { type: 'string', description: 'Webhook URL for notifications' },
|
|
163
|
+
|
|
164
|
+
// Extended: Experimental
|
|
165
|
+
CLAUDE_CODE_EXPERIMENTAL_MCP: { type: 'boolean', default: false, description: 'Enable experimental MCP features' },
|
|
166
|
+
CLAUDE_CODE_EXPERIMENTAL_TOOLS: { type: 'boolean', default: false, description: 'Enable experimental tools' },
|
|
167
|
+
CLAUDE_CODE_EXPERIMENTAL_VISION: { type: 'boolean', default: false, description: 'Enable vision/image support' },
|
|
168
|
+
CLAUDE_CODE_EXPERIMENTAL_MEMORY: { type: 'boolean', default: false, description: 'Enable persistent memory' },
|
|
169
|
+
|
|
170
|
+
// Extended: Worktree
|
|
171
|
+
CLAUDE_CODE_WORKTREE_DIR: { type: 'string', description: 'Default worktree base directory' },
|
|
172
|
+
CLAUDE_CODE_AUTO_WORKTREE: { type: 'boolean', default: false, description: 'Auto-create worktrees for branches' },
|
|
173
|
+
|
|
174
|
+
// Extended: Notebook
|
|
175
|
+
CLAUDE_CODE_NOTEBOOK_KERNEL: { type: 'string', default: 'python3', description: 'Default Jupyter kernel' },
|
|
176
|
+
|
|
177
|
+
// Extended: LSP
|
|
178
|
+
CLAUDE_CODE_LSP_ENABLED: { type: 'boolean', default: false, description: 'Enable LSP integration' },
|
|
179
|
+
CLAUDE_CODE_LSP_PORT: { type: 'number', default: 0, description: 'LSP server port (0 = auto)' },
|
|
180
|
+
|
|
181
|
+
// Extended: Timeouts
|
|
182
|
+
CLAUDE_CODE_TOOL_TIMEOUT: { type: 'number', default: 120000, description: 'Tool execution timeout in ms' },
|
|
183
|
+
CLAUDE_CODE_API_TIMEOUT: { type: 'number', default: 300000, description: 'API call timeout in ms' },
|
|
184
|
+
CLAUDE_CODE_MCP_TIMEOUT: { type: 'number', default: 30000, description: 'MCP operation timeout in ms' },
|
|
185
|
+
|
|
186
|
+
// Extended: Permissions (additional)
|
|
187
|
+
CLAUDE_CODE_ALLOWED_TOOLS: { type: 'string', description: 'Comma-separated list of allowed tools' },
|
|
188
|
+
CLAUDE_CODE_DISALLOWED_TOOLS: { type: 'string', description: 'Comma-separated list of disallowed tools' },
|
|
189
|
+
|
|
190
|
+
// Extended: Telemetry (additional)
|
|
191
|
+
CLAUDE_CODE_TELEMETRY_ENDPOINT: { type: 'string', description: 'Custom telemetry endpoint URL' },
|
|
192
|
+
CLAUDE_CODE_SENTRY_DSN: { type: 'string', description: 'Sentry DSN for error reporting' },
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Read and normalize all environment variables.
|
|
197
|
+
* @returns {object} normalized env config
|
|
198
|
+
*/
|
|
199
|
+
export function readEnv() {
|
|
200
|
+
const env = {};
|
|
201
|
+
|
|
202
|
+
for (const [key, schema] of Object.entries(ENV_SCHEMA)) {
|
|
203
|
+
const raw = process.env[key];
|
|
204
|
+
if (raw === undefined) {
|
|
205
|
+
if (schema.default !== undefined) {
|
|
206
|
+
env[key] = schema.default;
|
|
207
|
+
}
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
switch (schema.type) {
|
|
212
|
+
case 'boolean':
|
|
213
|
+
env[key] = raw === '1' || raw === 'true' || raw === 'yes';
|
|
214
|
+
break;
|
|
215
|
+
case 'number':
|
|
216
|
+
env[key] = parseInt(raw, 10);
|
|
217
|
+
if (isNaN(env[key])) env[key] = schema.default;
|
|
218
|
+
break;
|
|
219
|
+
default:
|
|
220
|
+
env[key] = raw;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return env;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Get a specific env var with type coercion.
|
|
229
|
+
* @param {string} key
|
|
230
|
+
* @param {*} [defaultValue]
|
|
231
|
+
*/
|
|
232
|
+
export function getEnv(key, defaultValue) {
|
|
233
|
+
const schema = ENV_SCHEMA[key];
|
|
234
|
+
const raw = process.env[key];
|
|
235
|
+
|
|
236
|
+
if (raw === undefined) return defaultValue ?? schema?.default;
|
|
237
|
+
|
|
238
|
+
if (schema?.type === 'boolean') return raw === '1' || raw === 'true';
|
|
239
|
+
if (schema?.type === 'number') {
|
|
240
|
+
const n = parseInt(raw, 10);
|
|
241
|
+
return isNaN(n) ? defaultValue : n;
|
|
242
|
+
}
|
|
243
|
+
return raw;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* List all supported env vars with their current values.
|
|
248
|
+
*/
|
|
249
|
+
export function listEnvVars() {
|
|
250
|
+
const result = [];
|
|
251
|
+
for (const [key, schema] of Object.entries(ENV_SCHEMA)) {
|
|
252
|
+
const value = process.env[key];
|
|
253
|
+
result.push({
|
|
254
|
+
key,
|
|
255
|
+
type: schema.type,
|
|
256
|
+
value: value || undefined,
|
|
257
|
+
default: schema.default,
|
|
258
|
+
description: schema.description,
|
|
259
|
+
isSet: value !== undefined,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings chain — user/project/local/managed (from decompiled source).
|
|
3
|
+
*
|
|
4
|
+
* Supports all 76 properties from Claude Code's settings schema.
|
|
5
|
+
* Five-layer hierarchy: user > project > local > managed > feature flags.
|
|
6
|
+
*/
|
|
7
|
+
import fs from 'fs';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import os from 'os';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Full settings schema with defaults.
|
|
13
|
+
*/
|
|
14
|
+
export const SETTINGS_SCHEMA = {
|
|
15
|
+
permissions: {
|
|
16
|
+
defaultMode: 'default',
|
|
17
|
+
allowRules: [],
|
|
18
|
+
denyRules: [],
|
|
19
|
+
allowedTools: [],
|
|
20
|
+
deniedTools: [],
|
|
21
|
+
sandbox: true,
|
|
22
|
+
sandboxAllowPaths: [],
|
|
23
|
+
},
|
|
24
|
+
hooks: {
|
|
25
|
+
PreToolUse: [],
|
|
26
|
+
PostToolUse: [],
|
|
27
|
+
PreToolUseFailure: [],
|
|
28
|
+
PostToolUseFailure: [],
|
|
29
|
+
Notification: [],
|
|
30
|
+
Stop: [],
|
|
31
|
+
SessionStart: [],
|
|
32
|
+
},
|
|
33
|
+
model: 'claude-sonnet-4-6',
|
|
34
|
+
subagentModel: null,
|
|
35
|
+
fastModel: 'claude-haiku-4-5',
|
|
36
|
+
fastMode: false,
|
|
37
|
+
alwaysThinkingEnabled: false,
|
|
38
|
+
autoCompactEnabled: true,
|
|
39
|
+
fileCheckpointingEnabled: true,
|
|
40
|
+
promptSuggestionEnabled: true,
|
|
41
|
+
briefMode: false,
|
|
42
|
+
maxContextTokens: 180000,
|
|
43
|
+
maxOutputTokens: 16384,
|
|
44
|
+
maxTokens: 16384,
|
|
45
|
+
thinkingBudget: 10000,
|
|
46
|
+
compactThreshold: 0.8,
|
|
47
|
+
stream: true,
|
|
48
|
+
stagnationDetection: false,
|
|
49
|
+
stagnationThreshold: 3,
|
|
50
|
+
mcpServers: {},
|
|
51
|
+
theme: 'auto',
|
|
52
|
+
showThinking: false,
|
|
53
|
+
showToolResults: false,
|
|
54
|
+
showTokenUsage: true,
|
|
55
|
+
vimMode: false,
|
|
56
|
+
terminalBell: false,
|
|
57
|
+
telemetryEnabled: false,
|
|
58
|
+
debugMode: false,
|
|
59
|
+
enableTeams: false,
|
|
60
|
+
agentId: null,
|
|
61
|
+
cronEnabled: true,
|
|
62
|
+
featureFlags: {},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export async function loadSettings() {
|
|
66
|
+
const chain = [
|
|
67
|
+
path.join(os.homedir(), '.claude', 'settings.json'),
|
|
68
|
+
path.join(process.cwd(), '.claude', 'settings.json'),
|
|
69
|
+
path.join(process.cwd(), '.claude', 'settings.local.json'),
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
let merged = deepClone(SETTINGS_SCHEMA);
|
|
73
|
+
|
|
74
|
+
for (const file of chain) {
|
|
75
|
+
try {
|
|
76
|
+
const data = JSON.parse(fs.readFileSync(file, 'utf-8'));
|
|
77
|
+
merged = deepMerge(merged, data);
|
|
78
|
+
} catch {
|
|
79
|
+
// File not found or invalid
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
applyEnvOverrides(merged);
|
|
84
|
+
return merged;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function deepClone(obj) {
|
|
88
|
+
return JSON.parse(JSON.stringify(obj));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function deepMerge(target, source) {
|
|
92
|
+
const result = { ...target };
|
|
93
|
+
for (const [key, value] of Object.entries(source)) {
|
|
94
|
+
if (value && typeof value === 'object' && !Array.isArray(value) && typeof result[key] === 'object' && !Array.isArray(result[key])) {
|
|
95
|
+
result[key] = deepMerge(result[key] || {}, value);
|
|
96
|
+
} else {
|
|
97
|
+
result[key] = value;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function applyEnvOverrides(settings) {
|
|
104
|
+
if (process.env.ANTHROPIC_MODEL) settings.model = process.env.ANTHROPIC_MODEL;
|
|
105
|
+
if (process.env.CLAUDE_CODE_SUBAGENT_MODEL) settings.subagentModel = process.env.CLAUDE_CODE_SUBAGENT_MODEL;
|
|
106
|
+
if (process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS) {
|
|
107
|
+
const n = parseInt(process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS, 10);
|
|
108
|
+
if (!isNaN(n)) { settings.maxOutputTokens = n; settings.maxTokens = n; }
|
|
109
|
+
}
|
|
110
|
+
if (process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS) {
|
|
111
|
+
const n = parseInt(process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS, 10);
|
|
112
|
+
if (!isNaN(n)) settings.maxContextTokens = n;
|
|
113
|
+
}
|
|
114
|
+
if (process.env.CLAUDE_CODE_BRIEF === '1') settings.briefMode = true;
|
|
115
|
+
if (process.env.CLAUDE_CODE_DEBUG === '1') settings.debugMode = true;
|
|
116
|
+
if (process.env.CLAUDE_CODE_PERMISSION_MODE) settings.permissions.defaultMode = process.env.CLAUDE_CODE_PERMISSION_MODE;
|
|
117
|
+
if (process.env.CLAUDE_CODE_STREAMING === '0') settings.stream = false;
|
|
118
|
+
if (process.env.CLAUDE_CODE_THINKING === '1') settings.alwaysThinkingEnabled = true;
|
|
119
|
+
if (process.env.CLAUDE_CODE_DISABLE_CRON === '1') settings.cronEnabled = false;
|
|
120
|
+
if (process.env.CLAUDE_CODE_ENABLE_TASKS === '1') settings.enableTeams = true;
|
|
121
|
+
const stagnationEnabled = process.env.ORCA_STAGNATION_DETECTION;
|
|
122
|
+
if (stagnationEnabled !== undefined) {
|
|
123
|
+
settings.stagnationDetection = ['1', 'true', 'yes', 'on'].includes(
|
|
124
|
+
stagnationEnabled.toLowerCase(),
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
const stagnationThreshold = process.env.ORCA_STAGNATION_THRESHOLD;
|
|
128
|
+
if (stagnationThreshold) {
|
|
129
|
+
const n = parseInt(stagnationThreshold, 10);
|
|
130
|
+
if (Number.isInteger(n) && n >= 2) settings.stagnationThreshold = n;
|
|
131
|
+
}
|
|
132
|
+
}
|