threecode

Search:
Group by:

Entry point and outer REPL loop.

main parses CLI args, sets up the session, and runs the interactive loop. turns.runTurns is the inner driver: it calls the model, dispatches tool calls, updates the session, and handles compaction - repeating until the model emits no tool calls.

Module graph overview::

threecode (entry) ├── turns turn lifecycle + API/tool orchestration ├── api HTTP + SSE streaming + spinner ├── actions tool_call JSON → Action → execute ├── compact supersede elision + LLM summarization ├── session .3log persistence (save + load) ├── display terminal rendering (markdown, token bar, replays) ├── ui REPL :commands + provider wizard ├── config config file parse + profile resolution ├── prompts KnownGoodCombos + per-family (prompt, tools) ├── shell shell command parsing for the read cache ├── web native web search + URL fetch ├── update background auto-update ├── fatprompt volatile prompt/token/ticker state and frame bytes ├── util string utils, ANSI palette, markdown helpers ├── types shared types + globals └── minline readline-style input

Exports

ApiError, ToolRecord, Action, ExitConfig, ReadCache, debugEnabled, Usage, Profile, MaxBashTimeout, ExitUsage, experimentalEnabled, ActionKind, die, PlanItem, DefaultBashTimeout, InputState, Session, bashTimeoutSecs, streamingEnabled, ExitApi, ParseIssue, looksLikePath, BrightWhiteFg, userConfigRoot, sanitizeUtf8, bundledCaFile, isMdFenceLine, debugOut, levenshteinCapped, CyanFg, debugOut, resolvePath, BlueFg, applyInlineMd, isMdSepRow, GreyFg, utf8ByteCut, charWrapAnsi, humanTokens, OffWhiteFg, isBinaryContent, wrapAnsi, userDataRoot, replaceFirst, safeCwd, clipMiddle, renderMdTable, tokenSlot, BoldOn, collapseHome, isMdTableRow, Reset, levenshtein, bundledSslContext, utf8ByteCutEnd, detectMdHeader, humanBytes, stripPreamble, visibleWidth, HelpText, discoverSkills, xmlToolCallsFallback, Version, KnownGoodCombo, knownGoodReasoning, knownGoodReasonings, refreshSystemPrompt, skillsDirs, findSystemPromptOverride, knownGoodContextWindow, setup, defaultReasoningsFor, buildCredit, GenerationDefaults, knownGoodFamily, knownGoodTags, DefaultSystemPrompt, materializeBuiltinSkills, reasoningSupported, KnownGoodCombos, buildSystemPrompt, knownGoodGeneration, ConfigExample, builtinSkillsDir, BuiltinSkills, ReasoningLevels, isKnownGood, knownGoodContextWindow, versionSuffix, knownGoodGeneration, knownGoodFamily, bashMutationPath, splitStatements, bashReadPath, shellTokens, releaseSessionLock, SessionExt, listSessionPaths, appendIndexAt, pendingDraftPathFor, releaseActiveSessionLock, loadSessionFile, firstUserMessage, clearDraft, indexIdsAt, appendSessionIndex, draftPathFor, usageFromJson, listSessionPathsForCwd, SessionPreview, currentDraftPath, sessionDir, newSessionPath, sessionLockDir, sessionIdFromPath, loadDraft, indexPathAt, historyFile, saveSession, mangleCwd, previewSession, sessionPathIndexDir, loadPendingDraft, draftDir, SessionLocked, acquireSessionLock, sessionLockPathFor, clearPendingDraft, pendingDraftDir, resolveSessionPath, activeLockPath, saveDraft, renderSession, summarizeHistory, SummarizeThresholdFrac, SummarizeKeepRecent, SummarizerSystemPrompt, decideContextAction, contextWindowFor, applySummary, ContextAction, SummaryPrefix, contextWindowFor, SummarizeMaxTokens, activeSearchUrl, resolveReasoning, explainExperimentalGate, activeProviders, notifyEnabled, inferProvider, splitModels, hasKnownGoodModel, activeCurrent, resolveFamily, bashPathOverride, firstModel, loadStateOrEmpty, shortToFull, KeyPrefixCatalog, parseConfigFile, catalogUrl, buildProfile, shortModel, writeConfigFile, firstKnownGoodCombo, ProviderCatalog, configPath, providerForProfile, orderedModels, gateExperimental, formatModels, curatedFor, findModel, ProviderRec, defaultNameFromUrl, loadProfile, currentProvider, availableReasonings, runActionStreaming, stripActions, previewCmd, bannerFor, computeDiff, runAction, toolCallToAction, parseActions, parseActionsChecked, fileSig, newReadCache, isNetworkQuiet, setApiStreamHooks, QuietRecvWakeMs, markNetworkQuiet, installInterruptHook, parseUsage, clearInterrupted, verifyProfileHook, fetchModels, applyReasoning, FetchModelsHook, fetchModelsHook, apiStreamHooks, QuietTooLongMs, verifyBody, applyGenerationDefaults, parseXmlToolCalls, setInterrupted, buildBatchAssistantMsg, callModel, clearNetworkQuiet, stripInternalFields, isInterrupted, VerifyProfileHook, requestTurnInterrupt, verifyProfile, classifyRetry, ApiStreamHooks, retryCategory, applyStreamingOptions, buildStreamAssistantMsg, closeCachedStreamConn, toolTranscriptBytes, hintLn, subtleWriteLn, printSessionList, cmdResponse, assistantTextBytes, toolIcon, finishMd, tokenLineBytes, printKnownGood, tokenLineLabel, listTools, printDiff, hint, toolBannerBytes, renderToolBanner, skillNameFromAct, welcome, renderAssistantContent, warn, writeAssistantBullet, toolTranscriptBytes, SessionListCap, printCompactHeadTail, renderHelp, toolResultBytes, renderTokenLine, err, handleMdLine, warnLn, errLn, cmdError, printSkillLoaded, replaySessionTail, installEditorTweaks, AssistantTextStyle, MarkdownState, printActionResult, initMarkdownState, renderToolPending, showTool, showProfile, contextLabel, isSkillRead, subtleWrite, note, navigatedUp, noteLn, printToolResult, readOptional, isFirstUserMessage, CommandResult, promptNewProvider, CommandDisposition, handleCommand, WizardReadLineHook, promptEditProvider, CommandKind, sessionPreamble, CommandNames, inlineAtFiles, readRequired, classifyCommand, completionFor, handleCommandResult, readInput, wizardReadLineHook, bootstrapProvider, buildUserMessage, spinnerFooterFrame, apiFinalUsage, startBarTick, barFooterBytes, FatPromptGeometry, footerGeometry, liveEditorSpinnerFooterBytes, DefaultBashMaxLines, DeferredSubmitMarker, inputMessages, followupStartsAfterReceipt, clearPendingHintEvent, inputEditor, clampToWidth, receiptTouchesNextResponse, setCommandStatusActive, apiAfterCall, ensureInputThreadStarted, setTicker, tokenBarFrame, liveEditorBarTickFrame, PromptMode, rowsAboveEditor, spinnerFooterBytes, editorHeight, DefaultHeight, BashViewport, paintBarBytes, clearBarBelowAtColBytes, setPendingHintEvent, tokenBarText, endTurn, commitTranscriptBytes, finishBash, addScrollLine, writeTranscriptWithFatPromptRestore, markProviderActivity, clearSpinnerFooterBytes, FooterFrame, liveEditorFooterAnchored, paintBarPrompt, noFooterFrame, setTickerEvent, FatPrompt, currentBarHasGap, inputStateLock, EditorPromptBytes, inputSession, apiProgress, clearBarPrompt, clearBarEvent, initFatPromptState, setTokenBar, apply, apiAfterLiveContent, restoreInputTermios, flushDraftNow, promptOnlyBytes, FatPromptEvent, stopTurnInputForFinalRender, clearFooterFrame, apiTrimTrailingContent, currentBarLabel, beginForegroundEditorRedraw, apiSetStatusLabel, footerRowsAboveEditor, barFooterBelowBytes, clearPromptAfterPendingReceiptBytes, footerFrame, barWrapRows, emitFatPromptEvent, inputState, restoreCancelTermios, activeCommandHook, feedContent, clearTickerEvent, footerFrameBytes, PromptMarker, inputThreadRunning, contentStreamedLive, addTranscriptItem, installApiStreamHooks, apiProviderActivity, PendingHint, frameRows, hideRealCaretBytes, bashVisibleRows, editorRows, consumeQueuedCommand, beginBash, stopBarTick, consumeQueuedInput, formatUserPromptItem, stopSpinner, paintPromptOnly, releaseIdleSubmittedInput, inputProfile, stopDraftFlusher, barFooterBelowAtColBytes, finishForegroundEditorRedraw, setEditor, hasQueuedAutosend, apiBeforeCall, fatPromptState, labelCells, spinnerBarBytes, moveToBarBelowBytes, liveLabel, writeTranscriptWithFatPrompt, ClearBarPromptBytes, enterPromptInput, ClearBarBelowBytes, DefaultWidth, frameText, liveBarBytes, promptOnlyResetBytes, paintBarBelow, FatPromptState, finishContent, initFatPrompt, beginTurn, nextCommandSymbol, endTurnBytes, emitUserSubmit, spinnerCleanupBytes, apiContentFinished, startSpinner, setBarEvent, footerFrameBytes, setActiveCommandHook, receiptBarBytes, hasNonNewlineBytes, initLiveMarkdownStream, apiReasoningDelta, resetPromptInputAfterEmpty, TokenBarState, FatPromptEventKind, setBarPromptState, paintInitialPrompt, paintInitialBar, pendingHint, endTurnAfterTranscriptAppend, clearBarRowBytes, apiNoUsage, hasElapsedSuffix, FooterFrameKind, repaintBarPrompt, tokenBarRows, FooterState, ensureDraftFlusherStarted, apiContentDelta, setPromptModeEvent, pushBashOutput, absoluteBarTickFrame, liveEditorSpinnerBarBytes, LiveMarkdownStream, captureStdoutWrites, setExitCode, StreamMaxLines, printBashScroll, subtleWriteLn, printLine, viewportRows, initStreamingView, finalTranscriptRows, addLine, setSymbol, StreamingView, onTurnInterrupted, runTurns, runTurnsInteractive, assistantItem, toolItem, TranscriptKind, userPromptItem, formatItem, plainCommandBodyBytes, appendItem, TranscriptItem, commandItem