Release 0.1.1

This commit is contained in:
Patrick Wozniak
2026-05-26 23:05:21 +02:00
parent 5d4277876b
commit cc05faa526
9 changed files with 140 additions and 25 deletions
+42 -9
View File
@@ -38,6 +38,9 @@ export * from "./converters.ts"
export * from "./types.ts"
export const DEFAULT_API_BASE = "https://api.commandcode.ai"
export const COMMAND_CODE_CLI_VERSION = "0.27.2"
const DEFAULT_GENERATE_MAX_TOKENS = 64_000
function defaultUsage(): Usage {
return {
@@ -77,6 +80,23 @@ function successStopReason(reason: TerminalReason): StopReason {
return "stop"
}
function generateMaxTokens(model: ModelLike, options?: StreamOptions): number {
return Math.min(
options?.maxTokens ?? model.maxTokens,
model.maxTokens,
DEFAULT_GENERATE_MAX_TOKENS,
)
}
export function projectSlugFromPath(pathName: string): string {
const slug = pathName
.toLowerCase()
.replace(/^[a-z]:/i, "")
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "")
return slug || "project"
}
export function createStreamCommandCode(deps: CoreDependencies) {
const apiBase = deps.apiBase ?? DEFAULT_API_BASE
const fetchImpl = deps.fetchImpl ?? fetch
@@ -235,7 +255,13 @@ export function createStreamCommandCode(deps: CoreDependencies) {
break
}
case "reasoning-start": {
endTextBlock()
break
}
case "reasoning-delta": {
endTextBlock()
thinkingBlock.push(stringValue(event.text) ?? "")
break
}
@@ -245,6 +271,10 @@ export function createStreamCommandCode(deps: CoreDependencies) {
break
}
case "tool-result": {
break
}
case "tool-call": {
endTextBlock()
const toolCall: ToolCallContent = {
@@ -303,9 +333,12 @@ export function createStreamCommandCode(deps: CoreDependencies) {
try {
stream.push({ type: "start", partial: output })
const workingDir = cwd()
const threadId = uuid()
let body: unknown = {
config: {
workingDir: cwd(),
workingDir,
date: new Date(now()).toISOString().split("T")[0],
environment: getEnvironmentInfo(),
structure: [],
@@ -315,18 +348,19 @@ export function createStreamCommandCode(deps: CoreDependencies) {
gitStatus: "",
recentCommits: [],
},
memory: "",
taste: "",
memory: null,
taste: null,
skills: null,
permissionMode: "standard",
params: {
model: model.id,
messages: messagesToCC(context.messages),
tools: toolsToJson(context.tools),
system: context.systemPrompt ?? "",
max_tokens: Math.min(options?.maxTokens ?? model.maxTokens, 200_000),
max_tokens: generateMaxTokens(model, options),
temperature: 0.3,
stream: true,
},
threadId,
}
const nextBody = await raceAbort(
@@ -341,12 +375,11 @@ export function createStreamCommandCode(deps: CoreDependencies) {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
"x-command-code-version": "0.24.1",
"x-command-code-version": COMMAND_CODE_CLI_VERSION,
"x-cli-environment": "production",
"x-project-slug": "pi-cc",
"x-taste-learning": "false",
"x-project-slug": projectSlugFromPath(workingDir),
"x-taste-learning": "true",
"x-co-flag": "false",
"x-session-id": uuid(),
...options?.headers,
},
body: JSON.stringify(body),