Skip to content

Commit 2a6b97c

Browse files
feat: update dependencies and enhance planning functionality with sonnet reasoning
1 parent 0ce2b76 commit 2a6b97c

5 files changed

Lines changed: 150 additions & 30 deletions

File tree

deno.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
},
77
"imports": {
88
"@cliffy/prompt": "jsr:@cliffy/prompt@^1.0.0-rc.7",
9-
"@std/assert": "jsr:@std/assert@1",
9+
"@std/assert": "jsr:@std/assert@^1.0.11",
1010
"@db/sqlite": "jsr:@db/sqlite",
1111
"table": "jsr:@sauber/table",
12-
"anthropic": "npm:@anthropic-ai/sdk",
12+
"anthropic": "npm:@anthropic-ai/sdk@0.37.0",
1313
}
1414
}

deno.lock

Lines changed: 117 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,11 @@ Note: When chaining operations, use separate BASH_TOOL commands and store result
145145

146146
export const API_CONFIG = {
147147
MODEL: "claude-3-5-sonnet-20241022",
148+
REASONING_MODEL: "claude-3-7-sonnet-20250219",
148149
INTENT_MODEL: "claude-3-5-haiku-20241022",
149150
MAX_TOKENS: 8192,
151+
MIN_THINKING_TOKENS: 1024,
152+
MAX_TOKENS_WHEN_THINKING: 20000,
150153
MAX_INTENT_TOKENS: 20,
151154
}
152155

src/modules/planner/planner.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {Anthropic} from "anthropic"
33
import {API_CONFIG, PLANNER_SYSTEM_PROMPT} from "../../config/constants.ts"
44
import {Select, Input, Confirm} from "@cliffy/prompt"
55
import {PromptDatabase} from "../db/database.ts"
6+
import {blue, green, yellow, bold, dim} from "jsr:@std/fmt/colors"
67

78
export default async function generatePlan(
89
systemInfo: string,
@@ -19,9 +20,15 @@ export default async function generatePlan(
1920
<Tools>${JSON.stringify(tools.map(tool => tool.name))}</Tools>
2021
<UserRequest>${userPrompt}</UserRequest>`
2122

23+
console.log(blue("\n🧠 Generating plan..."))
24+
2225
const response = await claude.messages.create({
23-
model: API_CONFIG.MODEL,
24-
max_tokens: API_CONFIG.MAX_TOKENS,
26+
model: API_CONFIG.REASONING_MODEL,
27+
max_tokens: API_CONFIG.MAX_TOKENS_WHEN_THINKING,
28+
thinking: {
29+
type: "enabled",
30+
budget_tokens: API_CONFIG.MIN_THINKING_TOKENS
31+
},
2532
messages: [{
2633
role: "user",
2734
content: promptContent,
@@ -30,10 +37,28 @@ export default async function generatePlan(
3037
})
3138

3239
try {
40+
// Display the thinking process if available
41+
const thinkingBlock = response.content.find(block => block.type === "thinking")
42+
if (thinkingBlock && 'thinking' in thinkingBlock) {
43+
console.log(bold("\n🔍 Planning Thought Process:"))
44+
console.log("═".repeat(80))
45+
46+
// Format thinking text with proper indentation and line breaks
47+
const formattedThinking = thinkingBlock.thinking
48+
.split('\n')
49+
.map(line => dim(green(` ${line}`)))
50+
.join('\n')
51+
52+
console.log(formattedThinking)
53+
console.log("═".repeat(80))
54+
}
55+
3356
const textBlock = response.content.find(block => block.type === "text")
3457
const planJson = textBlock ? JSON.parse(textBlock.text) : {}
3558
const initialPlan = {planSteps: planJson}
3659

60+
console.log(yellow("\n✅ Plan generated successfully!"))
61+
3762
// Log the planner interaction with sessionId
3863
await db.savePrompt({
3964
mode: "planner",

src/utils/jina.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ async function jinaFetch(endpoint: string, url: string): Promise<string> {
2020
}
2121

2222
let response = await fetch(jinaApiEndpoint, {headers})
23-
log.info({headers, success: response.ok, code: response.status})
24-
23+
2524
// If we get a 403, retry once with X-No-Cache header
2625
if (response.status === 403) {
2726
log.info('Got 403, retrying with X-No-Cache header')
@@ -31,14 +30,12 @@ async function jinaFetch(endpoint: string, url: string): Promise<string> {
3130
'X-No-Cache': 'true'
3231
}
3332
})
34-
console.log({headers})
3533
}
3634

3735
if (!response.ok) {
3836
throw new Error(`Jina API error: ${response.statusText}`)
3937
}
4038
log.info(`fetched ${jinaApiEndpoint}`)
41-
log.info({headers, success: response.ok, code: response.status})
4239

4340
return await response.text()
4441
}

0 commit comments

Comments
 (0)