@corbat-tech/coco 2.13.0 → 2.14.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/dist/cli/index.js +173 -179
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +31 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cli/index.js
CHANGED
|
@@ -1397,6 +1397,15 @@ var init_anthropic = __esm({
|
|
|
1397
1397
|
function needsResponsesApi(model) {
|
|
1398
1398
|
return model.includes("codex") || model.startsWith("gpt-5") || model.startsWith("o4-") || model.startsWith("o3-");
|
|
1399
1399
|
}
|
|
1400
|
+
function needsMaxCompletionTokens(model) {
|
|
1401
|
+
return model.startsWith("o1") || model.startsWith("o3") || model.startsWith("o4") || model.startsWith("gpt-4o") || model.startsWith("gpt-4.1") || model.startsWith("gpt-5") || model.startsWith("chatgpt-4o");
|
|
1402
|
+
}
|
|
1403
|
+
function buildMaxTokensParam(model, maxTokens) {
|
|
1404
|
+
if (needsMaxCompletionTokens(model)) {
|
|
1405
|
+
return { max_completion_tokens: maxTokens };
|
|
1406
|
+
}
|
|
1407
|
+
return { max_tokens: maxTokens };
|
|
1408
|
+
}
|
|
1400
1409
|
function createOpenAIProvider(config) {
|
|
1401
1410
|
const provider = new OpenAIProvider();
|
|
1402
1411
|
if (config) {
|
|
@@ -1605,9 +1614,10 @@ var init_openai = __esm({
|
|
|
1605
1614
|
return withRetry(async () => {
|
|
1606
1615
|
try {
|
|
1607
1616
|
const supportsTemp = this.supportsTemperature(model);
|
|
1617
|
+
const maxTokens = options?.maxTokens ?? this.config.maxTokens ?? 8192;
|
|
1608
1618
|
const response = await this.client.chat.completions.create({
|
|
1609
1619
|
model,
|
|
1610
|
-
|
|
1620
|
+
...buildMaxTokensParam(model, maxTokens),
|
|
1611
1621
|
messages: this.convertMessages(messages, options?.system),
|
|
1612
1622
|
stop: options?.stopSequences,
|
|
1613
1623
|
...supportsTemp && {
|
|
@@ -1643,9 +1653,10 @@ var init_openai = __esm({
|
|
|
1643
1653
|
try {
|
|
1644
1654
|
const supportsTemp = this.supportsTemperature(model);
|
|
1645
1655
|
const extraBody = this.getExtraBody(model);
|
|
1656
|
+
const maxTokens = options?.maxTokens ?? this.config.maxTokens ?? 8192;
|
|
1646
1657
|
const requestParams = {
|
|
1647
1658
|
model,
|
|
1648
|
-
|
|
1659
|
+
...buildMaxTokensParam(model, maxTokens),
|
|
1649
1660
|
messages: this.convertMessages(messages, options?.system),
|
|
1650
1661
|
tools: this.convertTools(options.tools),
|
|
1651
1662
|
tool_choice: this.convertToolChoice(options.toolChoice)
|
|
@@ -1689,9 +1700,10 @@ var init_openai = __esm({
|
|
|
1689
1700
|
}
|
|
1690
1701
|
try {
|
|
1691
1702
|
const supportsTemp = this.supportsTemperature(model);
|
|
1703
|
+
const maxTokens = options?.maxTokens ?? this.config.maxTokens ?? 8192;
|
|
1692
1704
|
const stream = await this.client.chat.completions.create({
|
|
1693
1705
|
model,
|
|
1694
|
-
|
|
1706
|
+
...buildMaxTokensParam(model, maxTokens),
|
|
1695
1707
|
messages: this.convertMessages(messages, options?.system),
|
|
1696
1708
|
stream: true,
|
|
1697
1709
|
...supportsTemp && { temperature: options?.temperature ?? this.config.temperature ?? 0 }
|
|
@@ -1725,9 +1737,10 @@ var init_openai = __esm({
|
|
|
1725
1737
|
try {
|
|
1726
1738
|
const supportsTemp = this.supportsTemperature(model);
|
|
1727
1739
|
const extraBody = this.getExtraBody(model);
|
|
1740
|
+
const maxTokens = options?.maxTokens ?? this.config.maxTokens ?? 8192;
|
|
1728
1741
|
const requestParams = {
|
|
1729
1742
|
model,
|
|
1730
|
-
|
|
1743
|
+
...buildMaxTokensParam(model, maxTokens),
|
|
1731
1744
|
messages: this.convertMessages(messages, options?.system),
|
|
1732
1745
|
tools: this.convertTools(options.tools),
|
|
1733
1746
|
tool_choice: this.convertToolChoice(options.toolChoice),
|
|
@@ -1989,11 +2002,20 @@ var init_openai = __esm({
|
|
|
1989
2002
|
} catch {
|
|
1990
2003
|
try {
|
|
1991
2004
|
const model = this.config.model || DEFAULT_MODEL2;
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
2005
|
+
if (needsResponsesApi(model)) {
|
|
2006
|
+
await this.client.responses.create({
|
|
2007
|
+
model,
|
|
2008
|
+
input: [{ role: "user", content: [{ type: "input_text", text: "Hi" }] }],
|
|
2009
|
+
max_output_tokens: 1,
|
|
2010
|
+
store: false
|
|
2011
|
+
});
|
|
2012
|
+
} else {
|
|
2013
|
+
await this.client.chat.completions.create({
|
|
2014
|
+
model,
|
|
2015
|
+
messages: [{ role: "user", content: "Hi" }],
|
|
2016
|
+
...buildMaxTokensParam(model, 1)
|
|
2017
|
+
});
|
|
2018
|
+
}
|
|
1997
2019
|
return true;
|
|
1998
2020
|
} catch {
|
|
1999
2021
|
return false;
|
|
@@ -8477,17 +8499,19 @@ function initializeContextManager(session, provider) {
|
|
|
8477
8499
|
reservedTokens: 4096
|
|
8478
8500
|
});
|
|
8479
8501
|
}
|
|
8480
|
-
function updateContextTokens(session, provider) {
|
|
8502
|
+
function updateContextTokens(session, provider, toolRegistry) {
|
|
8481
8503
|
if (!session.contextManager) return;
|
|
8482
8504
|
let totalTokens = 0;
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
const
|
|
8486
|
-
|
|
8505
|
+
{
|
|
8506
|
+
totalTokens += provider.countTokens(session.config.agent.systemPrompt);
|
|
8507
|
+
for (const message of session.messages) {
|
|
8508
|
+
const content = typeof message.content === "string" ? message.content : JSON.stringify(message.content);
|
|
8509
|
+
totalTokens += provider.countTokens(content);
|
|
8510
|
+
}
|
|
8487
8511
|
}
|
|
8488
8512
|
session.contextManager.setUsedTokens(totalTokens);
|
|
8489
8513
|
}
|
|
8490
|
-
async function checkAndCompactContext(session, provider, signal) {
|
|
8514
|
+
async function checkAndCompactContext(session, provider, signal, toolRegistry) {
|
|
8491
8515
|
if (!session.contextManager) {
|
|
8492
8516
|
initializeContextManager(session, provider);
|
|
8493
8517
|
}
|
|
@@ -8542,189 +8566,159 @@ var init_session = __esm({
|
|
|
8542
8566
|
memory: "Memory, Checkpoints & Persistence",
|
|
8543
8567
|
document: "Documents (PDF, Images, Diagrams)"
|
|
8544
8568
|
};
|
|
8545
|
-
COCO_SYSTEM_PROMPT = `You are Corbat-Coco, an autonomous coding assistant
|
|
8546
|
-
|
|
8547
|
-
##
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
\
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
**Core Principle: USE TOOLS, DON'T DESCRIBE**
|
|
8564
|
-
\u26A0\uFE0F CRITICAL: You MUST use your tools to perform actions. NEVER just describe what you would do or claim you did something without actually calling a tool.
|
|
8565
|
-
|
|
8566
|
-
**Tool Calling is MANDATORY:**
|
|
8567
|
-
- User says "create a file" \u2192 CALL write_file tool FIRST (don't show code, don't explain, just CALL THE TOOL)
|
|
8568
|
-
- User says "search the web" \u2192 CALL web_search tool FIRST (don't describe what you would search for)
|
|
8569
|
-
- User says "run tests" \u2192 CALL bash_exec tool FIRST (don't say you ran them, actually run them)
|
|
8570
|
-
- EVERY action requires a TOOL CALL. Text responses are ONLY for brief confirmations AFTER tools execute.
|
|
8571
|
-
|
|
8572
|
-
**Execution Process:**
|
|
8573
|
-
1. **Orient**: Output ONE line stating the *goal* of the next step \u2014 not the tool, the intent.
|
|
8574
|
-
- Good: "Confirming the typo is gone\u2026" / "Checking tests still pass\u2026" / "Reading the config to understand current structure\u2026"
|
|
8575
|
-
- Bad: "I'll use grep to search." (restates the tool, not the goal)
|
|
8576
|
-
- Skip this for obvious single-step tasks ("create hello.js" \u2192 just create it).
|
|
8577
|
-
2. **Execute**: IMMEDIATELY CALL THE APPROPRIATE TOOLS (this is mandatory, not optional)
|
|
8578
|
-
3. **Respond**: Brief confirmation of what was done (AFTER all tools executed)
|
|
8579
|
-
|
|
8580
|
-
**Critical Rules:**
|
|
8581
|
-
- User says "create X with Y" \u2192 Immediately call write_file/edit_file tool, no discussion
|
|
8582
|
-
- If a task needs data you don't have, fetch it with web_search/web_fetch FIRST, THEN complete the task with other tools
|
|
8583
|
-
- Never ask "should I do this?" or "do you want me to...?" - JUST DO IT (with tools)
|
|
8584
|
-
- If you don't call tools, you didn't do the task - showing code is NOT the same as creating files
|
|
8585
|
-
- NEVER show code blocks as examples - ALWAYS write them to files with tools
|
|
8586
|
-
|
|
8587
|
-
**PROACTIVE INFORMATION RETRIEVAL (Critical Rule):**
|
|
8588
|
-
NEVER say "I don't have access to real-time data" or "I can't search the internet". You HAVE web_search and web_fetch tools. Use them:
|
|
8589
|
-
- User asks about weather, stocks, news, current events \u2192 CALL web_search IMMEDIATELY
|
|
8590
|
-
- User asks something that requires up-to-date info \u2192 CALL web_search FIRST, then respond
|
|
8591
|
-
- You're not sure if your knowledge is current \u2192 CALL web_search to verify
|
|
8592
|
-
- Unknown library, recent release, API change \u2192 CALL web_search before answering
|
|
8593
|
-
- ANY question about the real world that isn't purely about this codebase \u2192 web_search it
|
|
8594
|
-
|
|
8595
|
-
If web_search returns no useful results: say "I searched but couldn't find current information about X" (NOT "I don't have access").
|
|
8596
|
-
|
|
8597
|
-
**IMPORTANT**: You have many tools beyond basic file/bash/git. Before answering "I can't do that", check if any of your tools can help. For example:
|
|
8598
|
-
- Need information from the internet? Use **web_search** and **web_fetch**
|
|
8599
|
-
- Need to understand a codebase structure? Use **codebase_map** or **semantic_search**
|
|
8600
|
-
- Need to remember something across sessions? Use **create_memory** / **recall_memory**
|
|
8601
|
-
- Need to generate a diagram? Use **generate_diagram**
|
|
8602
|
-
- Need to read a PDF or image? Use **read_pdf** or **read_image**
|
|
8603
|
-
- Need to query a database? Use **sql_query**
|
|
8604
|
-
- Need to save/restore project state? Use **create_checkpoint** / **restore_checkpoint**
|
|
8605
|
-
- Need to do a code review? Use **code_review**
|
|
8606
|
-
- Need to search code semantically? Use **semantic_search**
|
|
8607
|
-
- Need to show a diff visually? Use **show_diff**
|
|
8569
|
+
COCO_SYSTEM_PROMPT = `You are Corbat-Coco, an autonomous coding assistant. You execute tasks using tools \u2014 you do not describe what you would do.
|
|
8570
|
+
|
|
8571
|
+
## Execution Model
|
|
8572
|
+
|
|
8573
|
+
YOU ARE AN EXECUTION AGENT. Every action requires a TOOL CALL. Text is ONLY for brief confirmations AFTER tools execute.
|
|
8574
|
+
|
|
8575
|
+
Process:
|
|
8576
|
+
1. Orient \u2014 ONE line stating the goal (not the tool). Skip for obvious tasks.
|
|
8577
|
+
2. Execute \u2014 CALL tools immediately.
|
|
8578
|
+
3. Confirm \u2014 Brief summary of what was done.
|
|
8579
|
+
|
|
8580
|
+
Rules:
|
|
8581
|
+
- "Create X" \u2192 call write_file. "Fix Y" \u2192 call edit_file. "Run tests" \u2192 call bash_exec. Always tools first.
|
|
8582
|
+
- NEVER show code blocks instead of writing files. NEVER describe actions instead of performing them.
|
|
8583
|
+
- NEVER ask "should I?" or "do you want me to?" \u2014 the user already told you. JUST DO IT.
|
|
8584
|
+
- If you need real-time data, CALL web_search. NEVER say "I don't have access to real-time data."
|
|
8585
|
+
- Before answering "I can't do that", check your full tool catalog below \u2014 you likely have a tool for it.
|
|
8608
8586
|
|
|
8609
8587
|
## Available Tools
|
|
8610
8588
|
{TOOL_CATALOG}
|
|
8611
8589
|
|
|
8612
|
-
##
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
-
|
|
8617
|
-
-
|
|
8618
|
-
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
-
|
|
8635
|
-
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
-
|
|
8656
|
-
-
|
|
8657
|
-
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
-
|
|
8661
|
-
-
|
|
8662
|
-
-
|
|
8663
|
-
-
|
|
8664
|
-
-
|
|
8665
|
-
-
|
|
8590
|
+
## Tool Strategy
|
|
8591
|
+
|
|
8592
|
+
### Parallel Execution
|
|
8593
|
+
ALWAYS execute independent operations concurrently. This is 3-5x faster.
|
|
8594
|
+
- Reading multiple files \u2192 batch all read_file calls together
|
|
8595
|
+
- Multiple searches \u2192 batch all grep/glob calls together
|
|
8596
|
+
- git_status + read_file \u2192 parallel (no dependency)
|
|
8597
|
+
DEFAULT IS PARALLEL. Only serialize when output of step A is needed as input for step B.
|
|
8598
|
+
|
|
8599
|
+
### Codebase Research Before Changes
|
|
8600
|
+
YOU MUST understand the impact zone before writing or editing ANY code:
|
|
8601
|
+
1. SEARCH for all usages of the symbol you are modifying (grep across the codebase)
|
|
8602
|
+
2. SEARCH for similar implementations \u2014 avoid duplicating existing code
|
|
8603
|
+
3. READ related files \u2014 not just the target, also its importers and dependents
|
|
8604
|
+
4. FOLLOW existing patterns \u2014 if the codebase does X a certain way, do it that way
|
|
8605
|
+
|
|
8606
|
+
NEVER edit a file you have not read in the current conversation.
|
|
8607
|
+
NEVER modify a function without checking its callers first.
|
|
8608
|
+
|
|
8609
|
+
### Error Recovery
|
|
8610
|
+
When a tool fails, classify the failure and respond accordingly:
|
|
8611
|
+
- **Invalid input** (file not found, text not matched): re-read or re-search to get correct input. NEVER retry with the same arguments.
|
|
8612
|
+
- **Transient** (timeout, rate limit): retry once with simplified parameters.
|
|
8613
|
+
- **Structural** (wrong approach, missing dependency): STOP. Explain to user and suggest an alternative.
|
|
8614
|
+
|
|
8615
|
+
Specifics:
|
|
8616
|
+
- edit_file "text not found" \u2192 read_file to see actual content; use closest matching lines.
|
|
8617
|
+
- web_fetch 404/403 \u2192 web_search for alternative URL. Do NOT retry same URL.
|
|
8618
|
+
- Build/test failure \u2192 read stderr, inspect failing file, fix code BEFORE retrying build.
|
|
8619
|
+
- After 2 failures on same tool: stop, rethink approach or explain the issue.
|
|
8620
|
+
- After 3+ fix attempts on same bug: this is likely architectural. Explain to user.
|
|
8621
|
+
|
|
8622
|
+
## Code Quality
|
|
8623
|
+
|
|
8624
|
+
### Verification Protocol
|
|
8625
|
+
YOU MUST verify before ANY completion claim. No exceptions.
|
|
8626
|
+
1. IDENTIFY the proving command (test, build, typecheck, lint)
|
|
8627
|
+
2. RUN it freshly \u2014 cached or remembered results are NOT evidence
|
|
8628
|
+
3. READ the full output including exit codes
|
|
8629
|
+
4. VERIFY output matches your claim
|
|
8630
|
+
5. STATE the result with evidence
|
|
8631
|
+
|
|
8632
|
+
STOP if you catch yourself using "should work", "probably fixed", or "Done!" before running checks.
|
|
8633
|
+
- "Should work now" \u2192 RUN verification. Belief is not evidence.
|
|
8634
|
+
- "It's a tiny change" \u2192 Tiny changes break systems. Verify.
|
|
8635
|
+
- "Tests passed before my change" \u2192 Re-run. Your change may have broken them.
|
|
8636
|
+
|
|
8637
|
+
### Code Style
|
|
8638
|
+
- Use full, descriptive names. Functions are verbs; variables are nouns. No 1-2 char names.
|
|
8639
|
+
- Explicitly type function signatures and public APIs. Avoid \`any\`.
|
|
8640
|
+
- Use guard clauses and early returns. Handle errors first. Avoid nesting beyond 2-3 levels.
|
|
8641
|
+
- Only add comments for complex logic explaining WHY, not WHAT. Never add TODO comments \u2014 implement instead.
|
|
8642
|
+
- Match the existing code style. Do not reformat unrelated code.
|
|
8643
|
+
- NEVER add "Co-Authored-By", "Generated by", or AI attribution to commits, code, docs, or PRs.
|
|
8644
|
+
|
|
8645
|
+
### Testing Discipline
|
|
8646
|
+
- NEVER modify existing tests to make them pass unless the user explicitly asks.
|
|
8647
|
+
- If tests fail after your change, the bug is in YOUR code, not the test.
|
|
8648
|
+
- Every bugfix MUST include a regression test proving the bug is fixed.
|
|
8649
|
+
- Test BEHAVIOR, not implementation details \u2014 tests should survive refactors.
|
|
8650
|
+
- One clear assertion per test. Descriptive names: "should [expected] when [condition]".
|
|
8651
|
+
|
|
8652
|
+
## Debugging Protocol
|
|
8653
|
+
|
|
8654
|
+
When fixing bugs, investigate BEFORE fixing. Guessing wastes time.
|
|
8655
|
+
|
|
8656
|
+
Phase 1 \u2014 Investigate (complete BEFORE any fix attempt):
|
|
8657
|
+
1. Read the FULL error message and stack trace
|
|
8658
|
+
2. Reproduce the issue consistently
|
|
8659
|
+
3. Check recent changes (git diff, new deps, config)
|
|
8660
|
+
4. Trace backward \u2014 follow the bad value upstream to its origin
|
|
8661
|
+
|
|
8662
|
+
Phase 2 \u2014 Analyze:
|
|
8663
|
+
1. Find similar WORKING code in the codebase
|
|
8664
|
+
2. Identify the specific difference causing the failure
|
|
8665
|
+
|
|
8666
|
+
Phase 3 \u2014 Fix:
|
|
8667
|
+
1. State your hypothesis: "The bug is caused by X because Y"
|
|
8668
|
+
2. Make the SMALLEST possible change to test it
|
|
8669
|
+
3. Write a failing test reproducing the bug FIRST, then fix, then verify
|
|
8670
|
+
|
|
8671
|
+
After 3+ failed attempts: STOP. This is likely architectural. Explain to the user.
|
|
8672
|
+
|
|
8673
|
+
## Task Planning
|
|
8674
|
+
|
|
8675
|
+
For tasks with 3+ steps:
|
|
8676
|
+
1. List the concrete changes needed (files to create/modify)
|
|
8677
|
+
2. Identify dependencies (what must come first)
|
|
8678
|
+
3. Break into atomic steps with verification after each
|
|
8679
|
+
4. Implement vertically (one complete slice end-to-end) rather than horizontally
|
|
8680
|
+
|
|
8681
|
+
## After Completing Tasks
|
|
8682
|
+
|
|
8683
|
+
Suggest 1-2 brief, actionable next steps:
|
|
8684
|
+
- New function \u2192 "Consider adding tests"
|
|
8685
|
+
- Bug fix \u2192 "Run full test suite"
|
|
8686
|
+
- New endpoint \u2192 "Update API docs and add integration tests"
|
|
8687
|
+
- Added dependency \u2192 "Run audit to check for vulnerabilities"
|
|
8666
8688
|
|
|
8667
8689
|
## File Access
|
|
8668
8690
|
File operations are restricted to the project directory by default.
|
|
8669
|
-
|
|
8670
|
-
If a file tool fails with "outside project directory", the system will automatically prompt the user to authorize the path and retry. You do NOT need to tell the user to run any command manually.
|
|
8671
|
-
|
|
8672
|
-
## Output Formatting Rules
|
|
8691
|
+
Use **authorize_path** to access paths outside the project \u2014 it prompts the user interactively.
|
|
8673
8692
|
|
|
8674
|
-
|
|
8693
|
+
## Tone and Brevity
|
|
8675
8694
|
|
|
8676
|
-
|
|
8695
|
+
Responses are short and direct by default. Lead with the answer or action, not reasoning.
|
|
8696
|
+
- Do NOT open with "Great question!" or "Sure, I can help with that."
|
|
8697
|
+
- Do NOT repeat what the user said back to them.
|
|
8698
|
+
- If you can say it in one sentence, do not use three.
|
|
8699
|
+
- Only expand when the user asks for explanation or detail.
|
|
8700
|
+
- Be professionally honest \u2014 disagree when warranted, do not validate incorrect approaches.
|
|
8677
8701
|
|
|
8678
|
-
|
|
8679
|
-
~~~markdown
|
|
8680
|
-
Your content here...
|
|
8681
|
-
~~~
|
|
8702
|
+
## Output Formatting
|
|
8682
8703
|
|
|
8683
|
-
|
|
8704
|
+
**Normal conversation**: plain text. Short, direct.
|
|
8684
8705
|
|
|
8685
|
-
|
|
8686
|
-
- Code: \`\`\`javascript / \`\`\`typescript / \`\`\`python / \`\`\`bash / etc.
|
|
8687
|
-
- Shell commands: \`\`\`bash
|
|
8688
|
-
- ASCII diagrams: \`\`\`ascii
|
|
8689
|
-
- Tree structures / file paths: \`\`\`text
|
|
8690
|
-
- Any other fenced content: \`\`\`<lang>
|
|
8706
|
+
**Structured content** (docs, tutorials, multi-section responses, or when user asks for "markdown"):
|
|
8691
8707
|
|
|
8692
|
-
|
|
8708
|
+
1. Wrap entire response in a tilde markdown block:
|
|
8693
8709
|
~~~markdown
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
Some text here.
|
|
8697
|
-
|
|
8698
|
-
\`\`\`bash
|
|
8699
|
-
echo "hello"
|
|
8700
|
-
ls -la
|
|
8701
|
-
\`\`\`
|
|
8702
|
-
|
|
8703
|
-
\`\`\`ascii
|
|
8704
|
-
\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510
|
|
8705
|
-
\u2502 Service \u2502
|
|
8706
|
-
\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
|
|
8707
|
-
\`\`\`
|
|
8708
|
-
|
|
8709
|
-
More text after blocks.
|
|
8710
|
+
Your content here...
|
|
8710
8711
|
~~~
|
|
8711
8712
|
|
|
8712
|
-
|
|
8713
|
+
2. CRITICAL: Bare ~~~ closes the outer block. Only use it as the VERY LAST line.
|
|
8713
8714
|
|
|
8714
|
-
|
|
8715
|
+
3. ALL inner fenced blocks use backtick syntax:
|
|
8716
|
+
\`\`\`typescript / \`\`\`bash / \`\`\`text / etc.
|
|
8715
8717
|
|
|
8716
|
-
|
|
8717
|
-
- User asks for documentation, summary, tutorial, guide
|
|
8718
|
-
- Response has multiple sections with headers
|
|
8719
|
-
- Response includes tables or complex formatting
|
|
8720
|
-
- User explicitly requests markdown
|
|
8718
|
+
4. Include all content in ONE block.
|
|
8721
8719
|
|
|
8722
|
-
**
|
|
8723
|
-
|
|
8724
|
-
- Short explanations (1-2 sentences)
|
|
8725
|
-
- Questions back to the user
|
|
8726
|
-
- Confirmation messages
|
|
8727
|
-
- Error messages`;
|
|
8720
|
+
**Use markdown block when**: multiple sections, tables, complex formatting.
|
|
8721
|
+
**Do NOT use when**: simple answers, short explanations, confirmations.`;
|
|
8728
8722
|
SHELL_METACHARACTERS = /[;|&`$(){}<>!\n\\'"]/;
|
|
8729
8723
|
SAFE_COMMAND_VALIDATORS = {
|
|
8730
8724
|
git: (args) => {
|