klaude-code 1.2.6__py3-none-any.whl → 1.8.0__py3-none-any.whl
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.
- klaude_code/auth/__init__.py +24 -0
- klaude_code/auth/codex/__init__.py +20 -0
- klaude_code/auth/codex/exceptions.py +17 -0
- klaude_code/auth/codex/jwt_utils.py +45 -0
- klaude_code/auth/codex/oauth.py +229 -0
- klaude_code/auth/codex/token_manager.py +84 -0
- klaude_code/cli/auth_cmd.py +73 -0
- klaude_code/cli/config_cmd.py +91 -0
- klaude_code/cli/cost_cmd.py +338 -0
- klaude_code/cli/debug.py +78 -0
- klaude_code/cli/list_model.py +307 -0
- klaude_code/cli/main.py +233 -134
- klaude_code/cli/runtime.py +309 -117
- klaude_code/{version.py → cli/self_update.py} +114 -5
- klaude_code/cli/session_cmd.py +37 -21
- klaude_code/command/__init__.py +88 -27
- klaude_code/command/clear_cmd.py +8 -7
- klaude_code/command/command_abc.py +31 -31
- klaude_code/command/debug_cmd.py +79 -0
- klaude_code/command/export_cmd.py +19 -53
- klaude_code/command/export_online_cmd.py +154 -0
- klaude_code/command/fork_session_cmd.py +267 -0
- klaude_code/command/help_cmd.py +7 -8
- klaude_code/command/model_cmd.py +60 -10
- klaude_code/command/model_select.py +84 -0
- klaude_code/command/prompt-jj-describe.md +32 -0
- klaude_code/command/prompt_command.py +19 -11
- klaude_code/command/refresh_cmd.py +8 -10
- klaude_code/command/registry.py +139 -40
- klaude_code/command/release_notes_cmd.py +84 -0
- klaude_code/command/resume_cmd.py +111 -0
- klaude_code/command/status_cmd.py +104 -60
- klaude_code/command/terminal_setup_cmd.py +7 -9
- klaude_code/command/thinking_cmd.py +98 -0
- klaude_code/config/__init__.py +14 -6
- klaude_code/config/assets/__init__.py +1 -0
- klaude_code/config/assets/builtin_config.yaml +303 -0
- klaude_code/config/builtin_config.py +38 -0
- klaude_code/config/config.py +378 -109
- klaude_code/config/select_model.py +117 -53
- klaude_code/config/thinking.py +269 -0
- klaude_code/{const/__init__.py → const.py} +50 -19
- klaude_code/core/agent.py +20 -28
- klaude_code/core/executor.py +327 -112
- klaude_code/core/manager/__init__.py +2 -4
- klaude_code/core/manager/llm_clients.py +1 -15
- klaude_code/core/manager/llm_clients_builder.py +10 -11
- klaude_code/core/manager/sub_agent_manager.py +37 -6
- klaude_code/core/prompt.py +63 -44
- klaude_code/core/prompts/prompt-claude-code.md +2 -13
- klaude_code/core/prompts/prompt-codex-gpt-5-1-codex-max.md +117 -0
- klaude_code/core/prompts/prompt-codex-gpt-5-2-codex.md +117 -0
- klaude_code/core/prompts/prompt-codex.md +9 -42
- klaude_code/core/prompts/prompt-minimal.md +12 -0
- klaude_code/core/prompts/{prompt-subagent-explore.md → prompt-sub-agent-explore.md} +16 -3
- klaude_code/core/prompts/{prompt-subagent-oracle.md → prompt-sub-agent-oracle.md} +1 -2
- klaude_code/core/prompts/prompt-sub-agent-web.md +51 -0
- klaude_code/core/reminders.py +283 -95
- klaude_code/core/task.py +113 -75
- klaude_code/core/tool/__init__.py +24 -31
- klaude_code/core/tool/file/_utils.py +36 -0
- klaude_code/core/tool/file/apply_patch.py +17 -25
- klaude_code/core/tool/file/apply_patch_tool.py +57 -77
- klaude_code/core/tool/file/diff_builder.py +151 -0
- klaude_code/core/tool/file/edit_tool.py +50 -63
- klaude_code/core/tool/file/move_tool.md +41 -0
- klaude_code/core/tool/file/move_tool.py +435 -0
- klaude_code/core/tool/file/read_tool.md +1 -1
- klaude_code/core/tool/file/read_tool.py +86 -86
- klaude_code/core/tool/file/write_tool.py +59 -69
- klaude_code/core/tool/report_back_tool.py +84 -0
- klaude_code/core/tool/shell/bash_tool.py +265 -22
- klaude_code/core/tool/shell/command_safety.py +3 -6
- klaude_code/core/tool/{memory → skill}/skill_tool.py +16 -26
- klaude_code/core/tool/sub_agent_tool.py +13 -2
- klaude_code/core/tool/todo/todo_write_tool.md +0 -157
- klaude_code/core/tool/todo/todo_write_tool.py +1 -1
- klaude_code/core/tool/todo/todo_write_tool_raw.md +182 -0
- klaude_code/core/tool/todo/update_plan_tool.py +1 -1
- klaude_code/core/tool/tool_abc.py +18 -0
- klaude_code/core/tool/tool_context.py +27 -12
- klaude_code/core/tool/tool_registry.py +7 -7
- klaude_code/core/tool/tool_runner.py +44 -36
- klaude_code/core/tool/truncation.py +29 -14
- klaude_code/core/tool/web/mermaid_tool.md +43 -0
- klaude_code/core/tool/web/mermaid_tool.py +2 -5
- klaude_code/core/tool/web/web_fetch_tool.md +1 -1
- klaude_code/core/tool/web/web_fetch_tool.py +112 -22
- klaude_code/core/tool/web/web_search_tool.md +23 -0
- klaude_code/core/tool/web/web_search_tool.py +130 -0
- klaude_code/core/turn.py +168 -66
- klaude_code/llm/__init__.py +2 -10
- klaude_code/llm/anthropic/client.py +190 -178
- klaude_code/llm/anthropic/input.py +39 -15
- klaude_code/llm/bedrock/__init__.py +3 -0
- klaude_code/llm/bedrock/client.py +60 -0
- klaude_code/llm/client.py +7 -21
- klaude_code/llm/codex/__init__.py +5 -0
- klaude_code/llm/codex/client.py +149 -0
- klaude_code/llm/google/__init__.py +3 -0
- klaude_code/llm/google/client.py +309 -0
- klaude_code/llm/google/input.py +215 -0
- klaude_code/llm/input_common.py +3 -9
- klaude_code/llm/openai_compatible/client.py +72 -164
- klaude_code/llm/openai_compatible/input.py +6 -4
- klaude_code/llm/openai_compatible/stream.py +273 -0
- klaude_code/llm/openai_compatible/tool_call_accumulator.py +17 -1
- klaude_code/llm/openrouter/client.py +89 -160
- klaude_code/llm/openrouter/input.py +18 -30
- klaude_code/llm/openrouter/reasoning.py +118 -0
- klaude_code/llm/registry.py +39 -7
- klaude_code/llm/responses/client.py +184 -171
- klaude_code/llm/responses/input.py +20 -1
- klaude_code/llm/usage.py +17 -12
- klaude_code/protocol/commands.py +17 -1
- klaude_code/protocol/events.py +31 -4
- klaude_code/protocol/llm_param.py +13 -10
- klaude_code/protocol/model.py +232 -29
- klaude_code/protocol/op.py +90 -1
- klaude_code/protocol/op_handler.py +35 -1
- klaude_code/protocol/sub_agent/__init__.py +117 -0
- klaude_code/protocol/sub_agent/explore.py +63 -0
- klaude_code/protocol/sub_agent/oracle.py +91 -0
- klaude_code/protocol/sub_agent/task.py +61 -0
- klaude_code/protocol/sub_agent/web.py +79 -0
- klaude_code/protocol/tools.py +4 -2
- klaude_code/session/__init__.py +2 -2
- klaude_code/session/codec.py +71 -0
- klaude_code/session/export.py +293 -86
- klaude_code/session/selector.py +89 -67
- klaude_code/session/session.py +320 -309
- klaude_code/session/store.py +220 -0
- klaude_code/session/templates/export_session.html +595 -83
- klaude_code/session/templates/mermaid_viewer.html +926 -0
- klaude_code/skill/__init__.py +27 -0
- klaude_code/skill/assets/deslop/SKILL.md +17 -0
- klaude_code/skill/assets/dev-docs/SKILL.md +108 -0
- klaude_code/skill/assets/handoff/SKILL.md +39 -0
- klaude_code/skill/assets/jj-workspace/SKILL.md +20 -0
- klaude_code/skill/assets/skill-creator/SKILL.md +139 -0
- klaude_code/{core/tool/memory/skill_loader.py → skill/loader.py} +55 -15
- klaude_code/skill/manager.py +70 -0
- klaude_code/skill/system_skills.py +192 -0
- klaude_code/trace/__init__.py +20 -2
- klaude_code/trace/log.py +150 -5
- klaude_code/ui/__init__.py +4 -9
- klaude_code/ui/core/input.py +1 -1
- klaude_code/ui/core/stage_manager.py +7 -7
- klaude_code/ui/modes/debug/display.py +2 -1
- klaude_code/ui/modes/repl/__init__.py +3 -48
- klaude_code/ui/modes/repl/clipboard.py +5 -5
- klaude_code/ui/modes/repl/completers.py +487 -123
- klaude_code/ui/modes/repl/display.py +5 -4
- klaude_code/ui/modes/repl/event_handler.py +370 -117
- klaude_code/ui/modes/repl/input_prompt_toolkit.py +552 -105
- klaude_code/ui/modes/repl/key_bindings.py +146 -23
- klaude_code/ui/modes/repl/renderer.py +189 -99
- klaude_code/ui/renderers/assistant.py +9 -2
- klaude_code/ui/renderers/bash_syntax.py +178 -0
- klaude_code/ui/renderers/common.py +78 -0
- klaude_code/ui/renderers/developer.py +104 -48
- klaude_code/ui/renderers/diffs.py +87 -6
- klaude_code/ui/renderers/errors.py +11 -6
- klaude_code/ui/renderers/mermaid_viewer.py +57 -0
- klaude_code/ui/renderers/metadata.py +112 -76
- klaude_code/ui/renderers/sub_agent.py +92 -7
- klaude_code/ui/renderers/thinking.py +40 -18
- klaude_code/ui/renderers/tools.py +405 -227
- klaude_code/ui/renderers/user_input.py +73 -13
- klaude_code/ui/rich/__init__.py +10 -1
- klaude_code/ui/rich/cjk_wrap.py +228 -0
- klaude_code/ui/rich/code_panel.py +131 -0
- klaude_code/ui/rich/live.py +17 -0
- klaude_code/ui/rich/markdown.py +305 -170
- klaude_code/ui/rich/searchable_text.py +10 -13
- klaude_code/ui/rich/status.py +190 -49
- klaude_code/ui/rich/theme.py +135 -39
- klaude_code/ui/terminal/__init__.py +55 -0
- klaude_code/ui/terminal/color.py +1 -1
- klaude_code/ui/terminal/control.py +13 -22
- klaude_code/ui/terminal/notifier.py +44 -4
- klaude_code/ui/terminal/selector.py +658 -0
- klaude_code/ui/utils/common.py +0 -18
- klaude_code-1.8.0.dist-info/METADATA +377 -0
- klaude_code-1.8.0.dist-info/RECORD +219 -0
- {klaude_code-1.2.6.dist-info → klaude_code-1.8.0.dist-info}/entry_points.txt +1 -0
- klaude_code/command/diff_cmd.py +0 -138
- klaude_code/command/prompt-dev-docs-update.md +0 -56
- klaude_code/command/prompt-dev-docs.md +0 -46
- klaude_code/config/list_model.py +0 -162
- klaude_code/core/manager/agent_manager.py +0 -127
- klaude_code/core/prompts/prompt-subagent-webfetch.md +0 -46
- klaude_code/core/tool/file/multi_edit_tool.md +0 -42
- klaude_code/core/tool/file/multi_edit_tool.py +0 -199
- klaude_code/core/tool/memory/memory_tool.md +0 -16
- klaude_code/core/tool/memory/memory_tool.py +0 -462
- klaude_code/llm/openrouter/reasoning_handler.py +0 -209
- klaude_code/protocol/sub_agent.py +0 -348
- klaude_code/ui/utils/debouncer.py +0 -42
- klaude_code-1.2.6.dist-info/METADATA +0 -178
- klaude_code-1.2.6.dist-info/RECORD +0 -167
- /klaude_code/core/prompts/{prompt-subagent.md → prompt-sub-agent.md} +0 -0
- /klaude_code/core/tool/{memory → skill}/__init__.py +0 -0
- /klaude_code/core/tool/{memory → skill}/skill_tool.md +0 -0
- {klaude_code-1.2.6.dist-info → klaude_code-1.8.0.dist-info}/WHEEL +0 -0
|
@@ -6,7 +6,7 @@ from klaude_code.config import Config
|
|
|
6
6
|
from klaude_code.core.manager.llm_clients import LLMClients
|
|
7
7
|
from klaude_code.llm.client import LLMClientABC
|
|
8
8
|
from klaude_code.llm.registry import create_llm_client
|
|
9
|
-
from klaude_code.protocol.sub_agent import
|
|
9
|
+
from klaude_code.protocol.sub_agent import iter_sub_agent_profiles
|
|
10
10
|
from klaude_code.protocol.tools import SubAgentType
|
|
11
11
|
from klaude_code.trace import DebugType, log_debug
|
|
12
12
|
|
|
@@ -15,15 +15,14 @@ def build_llm_clients(
|
|
|
15
15
|
config: Config,
|
|
16
16
|
*,
|
|
17
17
|
model_override: str | None = None,
|
|
18
|
-
enabled_sub_agents: list[SubAgentType] | None = None,
|
|
19
18
|
) -> LLMClients:
|
|
20
19
|
"""Create an ``LLMClients`` bundle driven by application config."""
|
|
21
20
|
|
|
22
21
|
# Resolve main agent LLM config
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
model_name = model_override or config.main_model
|
|
23
|
+
if model_name is None:
|
|
24
|
+
raise ValueError("No model specified. Use --model or --select-model to specify a model.")
|
|
25
|
+
llm_config = config.get_model_config(model_name)
|
|
27
26
|
|
|
28
27
|
log_debug(
|
|
29
28
|
"Main LLM config",
|
|
@@ -35,15 +34,15 @@ def build_llm_clients(
|
|
|
35
34
|
main_client = create_llm_client(llm_config)
|
|
36
35
|
sub_clients: dict[SubAgentType, LLMClientABC] = {}
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
model_name = config.subagent_models.get(sub_agent_type)
|
|
37
|
+
for profile in iter_sub_agent_profiles():
|
|
38
|
+
model_name = config.sub_agent_models.get(profile.name)
|
|
41
39
|
if not model_name:
|
|
42
40
|
continue
|
|
43
|
-
|
|
41
|
+
|
|
44
42
|
if not profile.enabled_for_model(main_client.model_name):
|
|
45
43
|
continue
|
|
44
|
+
|
|
46
45
|
sub_llm_config = config.get_model_config(model_name)
|
|
47
|
-
sub_clients[
|
|
46
|
+
sub_clients[profile.name] = create_llm_client(sub_llm_config)
|
|
48
47
|
|
|
49
48
|
return LLMClients(main=main_client, sub_clients=sub_clients)
|
|
@@ -9,8 +9,9 @@ from __future__ import annotations
|
|
|
9
9
|
|
|
10
10
|
import asyncio
|
|
11
11
|
|
|
12
|
-
from klaude_code.core.agent import Agent, ModelProfileProvider
|
|
12
|
+
from klaude_code.core.agent import Agent, AgentProfile, ModelProfileProvider
|
|
13
13
|
from klaude_code.core.manager.llm_clients import LLMClients
|
|
14
|
+
from klaude_code.core.tool import ReportBackTool
|
|
14
15
|
from klaude_code.protocol import events, model
|
|
15
16
|
from klaude_code.protocol.sub_agent import SubAgentResult
|
|
16
17
|
from klaude_code.session.session import Session
|
|
@@ -35,7 +36,7 @@ class SubAgentManager:
|
|
|
35
36
|
|
|
36
37
|
await self._event_queue.put(event)
|
|
37
38
|
|
|
38
|
-
async def
|
|
39
|
+
async def run_sub_agent(self, parent_agent: Agent, state: model.SubAgentState) -> SubAgentResult:
|
|
39
40
|
"""Run a nested sub-agent task and return its result."""
|
|
40
41
|
|
|
41
42
|
# Create a child session under the same workdir
|
|
@@ -47,6 +48,25 @@ class SubAgentManager:
|
|
|
47
48
|
self._llm_clients.get_client(state.sub_agent_type),
|
|
48
49
|
state.sub_agent_type,
|
|
49
50
|
)
|
|
51
|
+
|
|
52
|
+
# Inject report_back tool if output_schema is provided
|
|
53
|
+
if state.output_schema:
|
|
54
|
+
report_back_tool_class = ReportBackTool.for_schema(state.output_schema)
|
|
55
|
+
report_back_prompt = """\
|
|
56
|
+
|
|
57
|
+
# Structured Output
|
|
58
|
+
You have a `report_back` tool available. When you complete the task,\
|
|
59
|
+
you MUST call `report_back` with the structured result matching the required schema.\
|
|
60
|
+
Only the content passed to `report_back` will be returned to user.\
|
|
61
|
+
"""
|
|
62
|
+
base_prompt = child_profile.system_prompt or ""
|
|
63
|
+
child_profile = AgentProfile(
|
|
64
|
+
llm_client=child_profile.llm_client,
|
|
65
|
+
system_prompt=base_prompt + report_back_prompt,
|
|
66
|
+
tools=[*child_profile.tools, report_back_tool_class.schema()],
|
|
67
|
+
reminders=child_profile.reminders,
|
|
68
|
+
)
|
|
69
|
+
|
|
50
70
|
child_agent = Agent(session=child_session, profile=child_profile)
|
|
51
71
|
|
|
52
72
|
log_debug(
|
|
@@ -58,29 +78,40 @@ class SubAgentManager:
|
|
|
58
78
|
try:
|
|
59
79
|
# Not emit the subtask's user input since task tool call is already rendered
|
|
60
80
|
result: str = ""
|
|
81
|
+
task_metadata: model.TaskMetadata | None = None
|
|
61
82
|
sub_agent_input = model.UserInputPayload(text=state.sub_agent_prompt, images=None)
|
|
83
|
+
child_session.append_history(
|
|
84
|
+
[model.UserMessageItem(content=sub_agent_input.text, images=sub_agent_input.images)]
|
|
85
|
+
)
|
|
62
86
|
async for event in child_agent.run_task(sub_agent_input):
|
|
63
87
|
# Capture TaskFinishEvent content for return
|
|
64
88
|
if isinstance(event, events.TaskFinishEvent):
|
|
65
89
|
result = event.task_result
|
|
90
|
+
# Capture TaskMetadataEvent for metadata propagation
|
|
91
|
+
elif isinstance(event, events.TaskMetadataEvent):
|
|
92
|
+
task_metadata = event.metadata.main_agent
|
|
66
93
|
await self.emit_event(event)
|
|
67
|
-
return SubAgentResult(
|
|
94
|
+
return SubAgentResult(
|
|
95
|
+
task_result=result,
|
|
96
|
+
session_id=child_session.id,
|
|
97
|
+
task_metadata=task_metadata,
|
|
98
|
+
)
|
|
68
99
|
except asyncio.CancelledError:
|
|
69
100
|
# Propagate cancellation so tooling can treat it as user interrupt
|
|
70
101
|
log_debug(
|
|
71
|
-
f"
|
|
102
|
+
f"Sub-agent task for {state.sub_agent_type} was cancelled",
|
|
72
103
|
style="yellow",
|
|
73
104
|
debug_type=DebugType.EXECUTION,
|
|
74
105
|
)
|
|
75
106
|
raise
|
|
76
107
|
except Exception as exc: # pragma: no cover - defensive logging
|
|
77
108
|
log_debug(
|
|
78
|
-
f"
|
|
109
|
+
f"Sub-agent task failed: [{exc.__class__.__name__}] {exc!s}",
|
|
79
110
|
style="red",
|
|
80
111
|
debug_type=DebugType.EXECUTION,
|
|
81
112
|
)
|
|
82
113
|
return SubAgentResult(
|
|
83
|
-
task_result=f"
|
|
114
|
+
task_result=f"Sub-agent task failed: [{exc.__class__.__name__}] {exc!s}",
|
|
84
115
|
session_id="",
|
|
85
116
|
error=True,
|
|
86
117
|
)
|
klaude_code/core/prompt.py
CHANGED
|
@@ -1,77 +1,80 @@
|
|
|
1
1
|
import datetime
|
|
2
2
|
import shutil
|
|
3
|
-
from functools import
|
|
3
|
+
from functools import cache
|
|
4
4
|
from importlib.resources import files
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
|
|
7
|
+
from klaude_code.protocol import llm_param
|
|
8
|
+
from klaude_code.protocol.sub_agent import get_sub_agent_profile
|
|
9
|
+
|
|
7
10
|
COMMAND_DESCRIPTIONS: dict[str, str] = {
|
|
8
11
|
"rg": "ripgrep - fast text search",
|
|
9
|
-
"fd": "
|
|
10
|
-
"tree": "
|
|
12
|
+
"fd": "simple and fast alternative to find",
|
|
13
|
+
"tree": "directory listing as a tree",
|
|
11
14
|
"sg": "ast-grep - AST-aware code search",
|
|
15
|
+
"jj": "jujutsu - Git-compatible version control system",
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
# Mapping from logical prompt keys to resource file paths under the core/prompt directory.
|
|
15
19
|
PROMPT_FILES: dict[str, str] = {
|
|
16
20
|
"main_codex": "prompts/prompt-codex.md",
|
|
17
|
-
"
|
|
21
|
+
"main_gpt_5_1_codex_max": "prompts/prompt-codex-gpt-5-1-codex-max.md",
|
|
22
|
+
"main_gpt_5_2_codex": "prompts/prompt-codex-gpt-5-2-codex.md",
|
|
23
|
+
"main": "prompts/prompt-claude-code.md",
|
|
18
24
|
"main_gemini": "prompts/prompt-gemini.md", # https://ai.google.dev/gemini-api/docs/prompting-strategies?hl=zh-cn#agentic-si-template
|
|
19
|
-
# Sub-agent prompts keyed by their name
|
|
20
|
-
"Task": "prompts/prompt-subagent.md",
|
|
21
|
-
"Oracle": "prompts/prompt-subagent-oracle.md",
|
|
22
|
-
"Explore": "prompts/prompt-subagent-explore.md",
|
|
23
|
-
"WebFetchAgent": "prompts/prompt-subagent-webfetch.md",
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
|
|
27
|
-
@
|
|
28
|
-
def
|
|
29
|
-
"""
|
|
28
|
+
@cache
|
|
29
|
+
def _load_prompt_by_path(prompt_path: str) -> str:
|
|
30
|
+
"""Load and cache prompt content from a file path relative to core package."""
|
|
31
|
+
return files(__package__).joinpath(prompt_path).read_text(encoding="utf-8").strip()
|
|
30
32
|
|
|
33
|
+
|
|
34
|
+
def _load_base_prompt(file_key: str) -> str:
|
|
35
|
+
"""Load and cache the base prompt content from file."""
|
|
36
|
+
try:
|
|
37
|
+
prompt_path = PROMPT_FILES[file_key]
|
|
38
|
+
except KeyError as exc:
|
|
39
|
+
raise ValueError(f"Unknown prompt key: {file_key}") from exc
|
|
40
|
+
|
|
41
|
+
return _load_prompt_by_path(prompt_path)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _get_file_key(model_name: str, protocol: llm_param.LLMClientProtocol) -> str:
|
|
45
|
+
"""Determine which prompt file to use based on model."""
|
|
46
|
+
match model_name:
|
|
47
|
+
case name if "gpt-5.2-codex" in name:
|
|
48
|
+
return "main_gpt_5_2_codex"
|
|
49
|
+
case name if "gpt-5.1-codex-max" in name:
|
|
50
|
+
return "main_gpt_5_1_codex_max"
|
|
51
|
+
case name if "gpt-5" in name:
|
|
52
|
+
return "main_codex"
|
|
53
|
+
case name if "gemini" in name:
|
|
54
|
+
return "main_gemini"
|
|
55
|
+
case _:
|
|
56
|
+
return "main"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _build_env_info(model_name: str) -> str:
|
|
60
|
+
"""Build environment info section with dynamic runtime values."""
|
|
31
61
|
cwd = Path.cwd()
|
|
32
62
|
today = datetime.datetime.now().strftime("%Y-%m-%d")
|
|
33
63
|
is_git_repo = (cwd / ".git").exists()
|
|
64
|
+
is_empty_dir = not any(cwd.iterdir())
|
|
34
65
|
|
|
35
66
|
available_tools: list[str] = []
|
|
36
67
|
for command, desc in COMMAND_DESCRIPTIONS.items():
|
|
37
68
|
if shutil.which(command) is not None:
|
|
38
69
|
available_tools.append(f"{command}: {desc}")
|
|
39
70
|
|
|
40
|
-
if
|
|
41
|
-
match model_name:
|
|
42
|
-
case name if "gpt-5" in name:
|
|
43
|
-
file_key = "main_codex"
|
|
44
|
-
case name if "gemini" in name:
|
|
45
|
-
file_key = "main_gemini"
|
|
46
|
-
case _:
|
|
47
|
-
file_key = "main_claude"
|
|
48
|
-
else:
|
|
49
|
-
file_key = sub_agent_type
|
|
50
|
-
|
|
51
|
-
try:
|
|
52
|
-
prompt_path = PROMPT_FILES[file_key]
|
|
53
|
-
except KeyError as exc:
|
|
54
|
-
raise ValueError(f"Unknown prompt key: {file_key}") from exc
|
|
55
|
-
|
|
56
|
-
base_prompt = (
|
|
57
|
-
files(__package__)
|
|
58
|
-
.joinpath(prompt_path)
|
|
59
|
-
.read_text(encoding="utf-8")
|
|
60
|
-
.format(
|
|
61
|
-
working_directory=str(cwd),
|
|
62
|
-
date=today,
|
|
63
|
-
is_git_repo=is_git_repo,
|
|
64
|
-
model_name=model_name,
|
|
65
|
-
)
|
|
66
|
-
.strip()
|
|
67
|
-
)
|
|
68
|
-
|
|
71
|
+
cwd_display = f"{cwd} (empty)" if is_empty_dir else str(cwd)
|
|
69
72
|
env_lines: list[str] = [
|
|
70
73
|
"",
|
|
71
74
|
"",
|
|
72
75
|
"Here is useful information about the environment you are running in:",
|
|
73
76
|
"<env>",
|
|
74
|
-
f"Working directory: {
|
|
77
|
+
f"Working directory: {cwd_display}",
|
|
75
78
|
f"Today's Date: {today}",
|
|
76
79
|
f"Is directory a git repo: {is_git_repo}",
|
|
77
80
|
f"You are powered by the model: {model_name}",
|
|
@@ -84,6 +87,22 @@ def get_system_prompt(model_name: str, sub_agent_type: str | None = None) -> str
|
|
|
84
87
|
|
|
85
88
|
env_lines.append("</env>")
|
|
86
89
|
|
|
87
|
-
|
|
90
|
+
return "\n".join(env_lines)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def load_system_prompt(
|
|
94
|
+
model_name: str, protocol: llm_param.LLMClientProtocol, sub_agent_type: str | None = None
|
|
95
|
+
) -> str:
|
|
96
|
+
"""Get system prompt content for the given model and sub-agent type."""
|
|
97
|
+
if sub_agent_type is not None:
|
|
98
|
+
profile = get_sub_agent_profile(sub_agent_type)
|
|
99
|
+
base_prompt = _load_prompt_by_path(profile.prompt_file)
|
|
100
|
+
else:
|
|
101
|
+
file_key = _get_file_key(model_name, protocol)
|
|
102
|
+
base_prompt = _load_base_prompt(file_key)
|
|
103
|
+
|
|
104
|
+
if protocol == llm_param.LLMClientProtocol.CODEX:
|
|
105
|
+
# Do not append environment info for Codex protocol
|
|
106
|
+
return base_prompt
|
|
88
107
|
|
|
89
|
-
return base_prompt +
|
|
108
|
+
return base_prompt + _build_env_info(model_name)
|
|
@@ -7,7 +7,7 @@ You are an interactive CLI tool that helps users with software engineering tasks
|
|
|
7
7
|
- NEVER create files unless they're absolutely necessary for achieving your goal. ALWAYS prefer editing an existing file to creating a new one. This includes markdown files.
|
|
8
8
|
|
|
9
9
|
## Professional objectivity
|
|
10
|
-
Prioritize technical accuracy and truthfulness over validating the user's beliefs. Focus on facts and problem-solving, providing direct, objective technical info without any unnecessary superlatives, praise, or emotional validation. It is best for the user if
|
|
10
|
+
Prioritize technical accuracy and truthfulness over validating the user's beliefs. Focus on facts and problem-solving, providing direct, objective technical info without any unnecessary superlatives, praise, or emotional validation. It is best for the user if you honestly applies the same rigorous standards to all ideas and disagrees when necessary, even if it may not be what the user wants to hear. Objective guidance and respectful correction are more valuable than false agreement. Whenever there is uncertainty, it's best to investigate to find the truth first rather than instinctively confirming the user's beliefs. Avoid using over-the-top validation or excessive praise when responding to users such as "You're absolutely right" or similar phrases.
|
|
11
11
|
|
|
12
12
|
## Planning without timelines
|
|
13
13
|
When planning tasks, provide concrete implementation steps without time estimates. Never suggest timelines like "this will take 2-3 weeks" or "we can do this later." Focus on what needs to be done, not when. Break work into actionable steps and let users decide scheduling.
|
|
@@ -84,15 +84,4 @@ assistant: [Uses the Explore tool to find the files that handle client errors in
|
|
|
84
84
|
<example>
|
|
85
85
|
user: What is the codebase structure?
|
|
86
86
|
assistant: [Uses the Explore tool]
|
|
87
|
-
</example>
|
|
88
|
-
|
|
89
|
-
## Memory
|
|
90
|
-
MEMORY PROTOCOL:
|
|
91
|
-
1. Use the `view` command of your `Memory` tool to check for earlier progress.
|
|
92
|
-
2. ... (work on the task) ...
|
|
93
|
-
- As you make progress, record status / progress / thoughts etc in your memory.
|
|
94
|
-
ASSUME INTERRUPTION: Your context window might be reset at any moment, so you risk losing any progress that is not recorded in your memory directory.
|
|
95
|
-
|
|
96
|
-
Note: when editing your memory folder, always try to keep its content up-to-date, coherent and organized. You can rename or delete files that are no longer relevant. Do not create new files unless necessary.
|
|
97
|
-
|
|
98
|
-
Only write down information relevant to current project in your memory system.
|
|
87
|
+
</example>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
You are Codex, based on GPT-5. You are running as a coding agent in the Codex CLI on a user's computer.
|
|
2
|
+
|
|
3
|
+
## General
|
|
4
|
+
|
|
5
|
+
- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep`. (If the `rg` command is not found, then use alternatives.)
|
|
6
|
+
|
|
7
|
+
## Editing constraints
|
|
8
|
+
|
|
9
|
+
- Default to ASCII when editing or creating files. Only introduce non-ASCII or other Unicode characters when there is a clear justification and the file already uses them.
|
|
10
|
+
- Add succinct code comments that explain what is going on if code is not self-explanatory. You should not add comments like "Assigns the value to the variable", but a brief comment might be useful ahead of a complex code block that the user would otherwise have to spend time parsing out. Usage of these comments should be rare.
|
|
11
|
+
- Try to use apply_patch for single file edits, but it is fine to explore other options to make the edit if it does not work well. Do not use apply_patch for changes that are auto-generated (i.e. generating package.json or running a lint or format command like gofmt) or when scripting is more efficient (such as search and replacing a string across a codebase).
|
|
12
|
+
- You may be in a dirty git worktree.
|
|
13
|
+
* NEVER revert existing changes you did not make unless explicitly requested, since these changes were made by the user.
|
|
14
|
+
* If asked to make a commit or code edits and there are unrelated changes to your work or changes that you didn't make in those files, don't revert those changes.
|
|
15
|
+
* If the changes are in files you've touched recently, you should read carefully and understand how you can work with the changes rather than reverting them.
|
|
16
|
+
* If the changes are in unrelated files, just ignore them and don't revert them.
|
|
17
|
+
- Do not amend a commit unless explicitly requested to do so.
|
|
18
|
+
- While you are working, you might notice unexpected changes that you didn't make. If this happens, STOP IMMEDIATELY and ask the user how they would like to proceed.
|
|
19
|
+
- **NEVER** use destructive commands like `git reset --hard` or `git checkout --` unless specifically requested or approved by the user.
|
|
20
|
+
|
|
21
|
+
## Plan tool
|
|
22
|
+
|
|
23
|
+
When using the planning tool:
|
|
24
|
+
- Skip using the planning tool for straightforward tasks (roughly the easiest 25%).
|
|
25
|
+
- Do not make single-step plans.
|
|
26
|
+
- When you made a plan, update it after having performed one of the sub-tasks that you shared on the plan.
|
|
27
|
+
|
|
28
|
+
## Codex CLI harness, sandboxing, and approvals
|
|
29
|
+
|
|
30
|
+
The Codex CLI harness supports several different configurations for sandboxing and escalation approvals that the user can choose from.
|
|
31
|
+
|
|
32
|
+
Filesystem sandboxing defines which files can be read or written. The options for `sandbox_mode` are:
|
|
33
|
+
- **read-only**: The sandbox only permits reading files.
|
|
34
|
+
- **workspace-write**: The sandbox permits reading files, and editing files in `cwd` and `writable_roots`. Editing files in other directories requires approval.
|
|
35
|
+
- **danger-full-access**: No filesystem sandboxing - all commands are permitted.
|
|
36
|
+
|
|
37
|
+
Network sandboxing defines whether network can be accessed without approval. Options for `network_access` are:
|
|
38
|
+
- **restricted**: Requires approval
|
|
39
|
+
- **enabled**: No approval needed
|
|
40
|
+
|
|
41
|
+
Approvals are your mechanism to get user consent to run shell commands without the sandbox. Possible configuration options for `approval_policy` are
|
|
42
|
+
- **untrusted**: The harness will escalate most commands for user approval, apart from a limited allowlist of safe "read" commands.
|
|
43
|
+
- **on-failure**: The harness will allow all commands to run in the sandbox (if enabled), and failures will be escalated to the user for approval to run again without the sandbox.
|
|
44
|
+
- **on-request**: Commands will be run in the sandbox by default, and you can specify in your tool call if you want to escalate a command to run without sandboxing. (Note that this mode is not always available. If it is, you'll see parameters for it in the `shell` command description.)
|
|
45
|
+
- **never**: This is a non-interactive mode where you may NEVER ask the user for approval to run commands. Instead, you must always persist and work around constraints to solve the task for the user. You MUST do your utmost best to finish the task and validate your work before yielding. If this mode is paired with `danger-full-access`, take advantage of it to deliver the best outcome for the user. Further, in this mode, your default testing philosophy is overridden: Even if you don't see local patterns for testing, you may add tests and scripts to validate your work. Just remove them before yielding.
|
|
46
|
+
|
|
47
|
+
When you are running with `approval_policy == on-request`, and sandboxing enabled, here are scenarios where you'll need to request approval:
|
|
48
|
+
- You need to run a command that writes to a directory that requires it (e.g. running tests that write to /var)
|
|
49
|
+
- You need to run a GUI app (e.g., open/xdg-open/osascript) to open browsers or files.
|
|
50
|
+
- You are running sandboxed and need to run a command that requires network access (e.g. installing packages)
|
|
51
|
+
- If you run a command that is important to solving the user's query, but it fails because of sandboxing, rerun the command with approval. ALWAYS proceed to use the `with_escalated_permissions` and `justification` parameters - do not message the user before requesting approval for the command.
|
|
52
|
+
- You are about to take a potentially destructive action such as an `rm` or `git reset` that the user did not explicitly ask for
|
|
53
|
+
- (for all of these, you should weigh alternative paths that do not require approval)
|
|
54
|
+
|
|
55
|
+
When `sandbox_mode` is set to read-only, you'll need to request approval for any command that isn't a read.
|
|
56
|
+
|
|
57
|
+
You will be told what filesystem sandboxing, network sandboxing, and approval mode are active in a developer or user message. If you are not told about this, assume that you are running with workspace-write, network sandboxing enabled, and approval on-failure.
|
|
58
|
+
|
|
59
|
+
Although they introduce friction to the user because your work is paused until the user responds, you should leverage them when necessary to accomplish important work. If the completing the task requires escalated permissions, Do not let these settings or the sandbox deter you from attempting to accomplish the user's task unless it is set to "never", in which case never ask for approvals.
|
|
60
|
+
|
|
61
|
+
When requesting approval to execute a command that will require escalated privileges:
|
|
62
|
+
- Provide the `with_escalated_permissions` parameter with the boolean value true
|
|
63
|
+
- Include a short, 1 sentence explanation for why you need to enable `with_escalated_permissions` in the justification parameter
|
|
64
|
+
|
|
65
|
+
## Special user requests
|
|
66
|
+
|
|
67
|
+
- If the user makes a simple request (such as asking for the time) which you can fulfill by running a terminal command (such as `date`), you should do so.
|
|
68
|
+
- If the user asks for a "review", default to a code review mindset: prioritise identifying bugs, risks, behavioural regressions, and missing tests. Findings must be the primary focus of the response - keep summaries or overviews brief and only after enumerating the issues. Present findings first (ordered by severity with file/line references), follow with open questions or assumptions, and offer a change-summary only as a secondary detail. If no findings are discovered, state that explicitly and mention any residual risks or testing gaps.
|
|
69
|
+
|
|
70
|
+
## Frontend tasks
|
|
71
|
+
When doing frontend design tasks, avoid collapsing into "AI slop" or safe, average-looking layouts.
|
|
72
|
+
Aim for interfaces that feel intentional, bold, and a bit surprising.
|
|
73
|
+
- Typography: Use expressive, purposeful fonts and avoid default stacks (Inter, Roboto, Arial, system).
|
|
74
|
+
- Color & Look: Choose a clear visual direction; define CSS variables; avoid purple-on-white defaults. No purple bias or dark mode bias.
|
|
75
|
+
- Motion: Use a few meaningful animations (page-load, staggered reveals) instead of generic micro-motions.
|
|
76
|
+
- Background: Don't rely on flat, single-color backgrounds; use gradients, shapes, or subtle patterns to build atmosphere.
|
|
77
|
+
- Overall: Avoid boilerplate layouts and interchangeable UI patterns. Vary themes, type families, and visual languages across outputs.
|
|
78
|
+
- Ensure the page loads properly on both desktop and mobile
|
|
79
|
+
|
|
80
|
+
Exception: If working within an existing website or design system, preserve the established patterns, structure, and visual language.
|
|
81
|
+
|
|
82
|
+
## Presenting your work and final message
|
|
83
|
+
|
|
84
|
+
You are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.
|
|
85
|
+
|
|
86
|
+
- Default: be very concise; friendly coding teammate tone.
|
|
87
|
+
- Ask only when needed; suggest ideas; mirror the user's style.
|
|
88
|
+
- For substantial work, summarize clearly; follow final‑answer formatting.
|
|
89
|
+
- Skip heavy formatting for simple confirmations.
|
|
90
|
+
- Don't dump large files you've written; reference paths only.
|
|
91
|
+
- No "save/copy this file" - User is on the same machine.
|
|
92
|
+
- Offer logical next steps (tests, commits, build) briefly; add verify steps if you couldn't do something.
|
|
93
|
+
- For code changes:
|
|
94
|
+
* Lead with a quick explanation of the change, and then give more details on the context covering where and why a change was made. Do not start this explanation with "summary", just jump right in.
|
|
95
|
+
* If there are natural next steps the user may want to take, suggest them at the end of your response. Do not make suggestions if there are no natural next steps.
|
|
96
|
+
* When suggesting multiple options, use numeric lists for the suggestions so the user can quickly respond with a single number.
|
|
97
|
+
- The user does not command execution outputs. When asked to show the output of a command (e.g. `git show`), relay the important details in your answer or summarize the key lines so the user understands the result.
|
|
98
|
+
|
|
99
|
+
### Final answer structure and style guidelines
|
|
100
|
+
|
|
101
|
+
- Plain text; CLI handles styling. Use structure only when it helps scanability.
|
|
102
|
+
- Headers: optional; short Title Case (1-3 words) wrapped in **…**; no blank line before the first bullet; add only if they truly help.
|
|
103
|
+
- Bullets: use - ; merge related points; keep to one line when possible; 4–6 per list ordered by importance; keep phrasing consistent.
|
|
104
|
+
- Monospace: backticks for commands/paths/env vars/code ids and inline examples; use for literal keyword bullets; never combine with **.
|
|
105
|
+
- Code samples or multi-line snippets should be wrapped in fenced code blocks; include an info string as often as possible.
|
|
106
|
+
- Structure: group related bullets; order sections general → specific → supporting; for subsections, start with a bolded keyword bullet, then items; match complexity to the task.
|
|
107
|
+
- Tone: collaborative, concise, factual; present tense, active voice; self‑contained; no "above/below"; parallel wording.
|
|
108
|
+
- Don'ts: no nested bullets/hierarchies; no ANSI codes; don't cram unrelated keywords; keep keyword lists short—wrap/reformat if long; avoid naming formatting styles in answers.
|
|
109
|
+
- Adaptation: code explanations → precise, structured with code refs; simple tasks → lead with outcome; big changes → logical walkthrough + rationale + next actions; casual one-offs → plain sentences, no headers/bullets.
|
|
110
|
+
- File References: When referencing files in your response follow the below rules:
|
|
111
|
+
* Use inline code to make file paths clickable.
|
|
112
|
+
* Each reference should have a stand alone path. Even if it's the same file.
|
|
113
|
+
* Accepted: absolute, workspace‑relative, a/ or b/ diff prefixes, or bare filename/suffix.
|
|
114
|
+
* Optionally include line/column (1‑based): :line[:column] or #Lline[Ccolumn] (column defaults to 1).
|
|
115
|
+
* Do not use URIs like file://, vscode://, or https://.
|
|
116
|
+
* Do not provide range of lines
|
|
117
|
+
* Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\repo\project\main.rs:12:5
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
You are Codex, based on GPT-5. You are running as a coding agent in the Codex CLI on a user's computer.
|
|
2
|
+
|
|
3
|
+
## General
|
|
4
|
+
|
|
5
|
+
- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep`. (If the `rg` command is not found, then use alternatives.)
|
|
6
|
+
|
|
7
|
+
## Editing constraints
|
|
8
|
+
|
|
9
|
+
- Default to ASCII when editing or creating files. Only introduce non-ASCII or other Unicode characters when there is a clear justification and the file already uses them.
|
|
10
|
+
- Add succinct code comments that explain what is going on if code is not self-explanatory. You should not add comments like "Assigns the value to the variable", but a brief comment might be useful ahead of a complex code block that the user would otherwise have to spend time parsing out. Usage of these comments should be rare.
|
|
11
|
+
- Try to use apply_patch for single file edits, but it is fine to explore other options to make the edit if it does not work well. Do not use apply_patch for changes that are auto-generated (i.e. generating package.json or running a lint or format command like gofmt) or when scripting is more efficient (such as search and replacing a string across a codebase).
|
|
12
|
+
- You may be in a dirty git worktree.
|
|
13
|
+
* NEVER revert existing changes you did not make unless explicitly requested, since these changes were made by the user.
|
|
14
|
+
* If asked to make a commit or code edits and there are unrelated changes to your work or changes that you didn't make in those files, don't revert those changes.
|
|
15
|
+
* If the changes are in files you've touched recently, you should read carefully and understand how you can work with the changes rather than reverting them.
|
|
16
|
+
* If the changes are in unrelated files, just ignore them and don't revert them.
|
|
17
|
+
- Do not amend a commit unless explicitly requested to do so.
|
|
18
|
+
- While you are working, you might notice unexpected changes that you didn't make. If this happens, STOP IMMEDIATELY and ask the user how they would like to proceed.
|
|
19
|
+
- **NEVER** use destructive commands like `git reset --hard` or `git checkout --` unless specifically requested or approved by the user.
|
|
20
|
+
|
|
21
|
+
## Plan tool
|
|
22
|
+
|
|
23
|
+
When using the planning tool:
|
|
24
|
+
- Skip using the planning tool for straightforward tasks (roughly the easiest 25%).
|
|
25
|
+
- Do not make single-step plans.
|
|
26
|
+
- When you made a plan, update it after having performed one of the sub-tasks that you shared on the plan.
|
|
27
|
+
|
|
28
|
+
## Codex CLI harness, sandboxing, and approvals
|
|
29
|
+
|
|
30
|
+
The Codex CLI harness supports several different configurations for sandboxing and escalation approvals that the user can choose from.
|
|
31
|
+
|
|
32
|
+
Filesystem sandboxing defines which files can be read or written. The options for `sandbox_mode` are:
|
|
33
|
+
- **read-only**: The sandbox only permits reading files.
|
|
34
|
+
- **workspace-write**: The sandbox permits reading files, and editing files in `cwd` and `writable_roots`. Editing files in other directories requires approval.
|
|
35
|
+
- **danger-full-access**: No filesystem sandboxing - all commands are permitted.
|
|
36
|
+
|
|
37
|
+
Network sandboxing defines whether network can be accessed without approval. Options for `network_access` are:
|
|
38
|
+
- **restricted**: Requires approval
|
|
39
|
+
- **enabled**: No approval needed
|
|
40
|
+
|
|
41
|
+
Approvals are your mechanism to get user consent to run shell commands without the sandbox. Possible configuration options for `approval_policy` are
|
|
42
|
+
- **untrusted**: The harness will escalate most commands for user approval, apart from a limited allowlist of safe "read" commands.
|
|
43
|
+
- **on-failure**: The harness will allow all commands to run in the sandbox (if enabled), and failures will be escalated to the user for approval to run again without the sandbox.
|
|
44
|
+
- **on-request**: Commands will be run in the sandbox by default, and you can specify in your tool call if you want to escalate a command to run without sandboxing. (Note that this mode is not always available. If it is, you'll see parameters for it in the `shell` command description.)
|
|
45
|
+
- **never**: This is a non-interactive mode where you may NEVER ask the user for approval to run commands. Instead, you must always persist and work around constraints to solve the task for the user. You MUST do your utmost best to finish the task and validate your work before yielding. If this mode is paired with `danger-full-access`, take advantage of it to deliver the best outcome for the user. Further, in this mode, your default testing philosophy is overridden: Even if you don't see local patterns for testing, you may add tests and scripts to validate your work. Just remove them before yielding.
|
|
46
|
+
|
|
47
|
+
When you are running with `approval_policy == on-request`, and sandboxing enabled, here are scenarios where you'll need to request approval:
|
|
48
|
+
- You need to run a command that writes to a directory that requires it (e.g. running tests that write to /var)
|
|
49
|
+
- You need to run a GUI app (e.g., open/xdg-open/osascript) to open browsers or files.
|
|
50
|
+
- You are running sandboxed and need to run a command that requires network access (e.g. installing packages)
|
|
51
|
+
- If you run a command that is important to solving the user's query, but it fails because of sandboxing, rerun the command with approval. ALWAYS proceed to use the `sandbox_permissions` and `justification` parameters - do not message the user before requesting approval for the command.
|
|
52
|
+
- You are about to take a potentially destructive action such as an `rm` or `git reset` that the user did not explicitly ask for
|
|
53
|
+
- (for all of these, you should weigh alternative paths that do not require approval)
|
|
54
|
+
|
|
55
|
+
When `sandbox_mode` is set to read-only, you'll need to request approval for any command that isn't a read.
|
|
56
|
+
|
|
57
|
+
You will be told what filesystem sandboxing, network sandboxing, and approval mode are active in a developer or user message. If you are not told about this, assume that you are running with workspace-write, network sandboxing enabled, and approval on-failure.
|
|
58
|
+
|
|
59
|
+
Although they introduce friction to the user because your work is paused until the user responds, you should leverage them when necessary to accomplish important work. If the completing the task requires escalated permissions, Do not let these settings or the sandbox deter you from attempting to accomplish the user's task unless it is set to "never", in which case never ask for approvals.
|
|
60
|
+
|
|
61
|
+
When requesting approval to execute a command that will require escalated privileges:
|
|
62
|
+
- Provide the `sandbox_permissions` parameter with the value `"require_escalated"`
|
|
63
|
+
- Include a short, 1 sentence explanation for why you need escalated permissions in the justification parameter
|
|
64
|
+
|
|
65
|
+
## Special user requests
|
|
66
|
+
|
|
67
|
+
- If the user makes a simple request (such as asking for the time) which you can fulfill by running a terminal command (such as `date`), you should do so.
|
|
68
|
+
- If the user asks for a "review", default to a code review mindset: prioritise identifying bugs, risks, behavioural regressions, and missing tests. Findings must be the primary focus of the response - keep summaries or overviews brief and only after enumerating the issues. Present findings first (ordered by severity with file/line references), follow with open questions or assumptions, and offer a change-summary only as a secondary detail. If no findings are discovered, state that explicitly and mention any residual risks or testing gaps.
|
|
69
|
+
|
|
70
|
+
## Frontend tasks
|
|
71
|
+
When doing frontend design tasks, avoid collapsing into "AI slop" or safe, average-looking layouts.
|
|
72
|
+
Aim for interfaces that feel intentional, bold, and a bit surprising.
|
|
73
|
+
- Typography: Use expressive, purposeful fonts and avoid default stacks (Inter, Roboto, Arial, system).
|
|
74
|
+
- Color & Look: Choose a clear visual direction; define CSS variables; avoid purple-on-white defaults. No purple bias or dark mode bias.
|
|
75
|
+
- Motion: Use a few meaningful animations (page-load, staggered reveals) instead of generic micro-motions.
|
|
76
|
+
- Background: Don't rely on flat, single-color backgrounds; use gradients, shapes, or subtle patterns to build atmosphere.
|
|
77
|
+
- Overall: Avoid boilerplate layouts and interchangeable UI patterns. Vary themes, type families, and visual languages across outputs.
|
|
78
|
+
- Ensure the page loads properly on both desktop and mobile
|
|
79
|
+
|
|
80
|
+
Exception: If working within an existing website or design system, preserve the established patterns, structure, and visual language.
|
|
81
|
+
|
|
82
|
+
## Presenting your work and final message
|
|
83
|
+
|
|
84
|
+
You are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.
|
|
85
|
+
|
|
86
|
+
- Default: be very concise; friendly coding teammate tone.
|
|
87
|
+
- Ask only when needed; suggest ideas; mirror the user's style.
|
|
88
|
+
- For substantial work, summarize clearly; follow final‑answer formatting.
|
|
89
|
+
- Skip heavy formatting for simple confirmations.
|
|
90
|
+
- Don't dump large files you've written; reference paths only.
|
|
91
|
+
- No "save/copy this file" - User is on the same machine.
|
|
92
|
+
- Offer logical next steps (tests, commits, build) briefly; add verify steps if you couldn't do something.
|
|
93
|
+
- For code changes:
|
|
94
|
+
* Lead with a quick explanation of the change, and then give more details on the context covering where and why a change was made. Do not start this explanation with "summary", just jump right in.
|
|
95
|
+
* If there are natural next steps the user may want to take, suggest them at the end of your response. Do not make suggestions if there are no natural next steps.
|
|
96
|
+
* When suggesting multiple options, use numeric lists for the suggestions so the user can quickly respond with a single number.
|
|
97
|
+
- The user does not command execution outputs. When asked to show the output of a command (e.g. `git show`), relay the important details in your answer or summarize the key lines so the user understands the result.
|
|
98
|
+
|
|
99
|
+
### Final answer structure and style guidelines
|
|
100
|
+
|
|
101
|
+
- Plain text; CLI handles styling. Use structure only when it helps scanability.
|
|
102
|
+
- Headers: optional; short Title Case (1-3 words) wrapped in **…**; no blank line before the first bullet; add only if they truly help.
|
|
103
|
+
- Bullets: use - ; merge related points; keep to one line when possible; 4–6 per list ordered by importance; keep phrasing consistent.
|
|
104
|
+
- Monospace: backticks for commands/paths/env vars/code ids and inline examples; use for literal keyword bullets; never combine with **.
|
|
105
|
+
- Code samples or multi-line snippets should be wrapped in fenced code blocks; include an info string as often as possible.
|
|
106
|
+
- Structure: group related bullets; order sections general → specific → supporting; for subsections, start with a bolded keyword bullet, then items; match complexity to the task.
|
|
107
|
+
- Tone: collaborative, concise, factual; present tense, active voice; self‑contained; no "above/below"; parallel wording.
|
|
108
|
+
- Don'ts: no nested bullets/hierarchies; no ANSI codes; don't cram unrelated keywords; keep keyword lists short—wrap/reformat if long; avoid naming formatting styles in answers.
|
|
109
|
+
- Adaptation: code explanations → precise, structured with code refs; simple tasks → lead with outcome; big changes → logical walkthrough + rationale + next actions; casual one-offs → plain sentences, no headers/bullets.
|
|
110
|
+
- File References: When referencing files in your response follow the below rules:
|
|
111
|
+
* Use inline code to make file paths clickable.
|
|
112
|
+
* Each reference should have a stand alone path. Even if it's the same file.
|
|
113
|
+
* Accepted: absolute, workspace‑relative, a/ or b/ diff prefixes, or bare filename/suffix.
|
|
114
|
+
* Optionally include line/column (1‑based): :line[:column] or #Lline[Ccolumn] (column defaults to 1).
|
|
115
|
+
* Do not use URIs like file://, vscode://, or https://.
|
|
116
|
+
* Do not provide range of lines
|
|
117
|
+
* Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\repo\project\main.rs:12:5
|