MCPcopy Create free account

hub / github.com/codehamr/codehamr / functions

Functions622 in github.com/codehamr/codehamr

↓ 139 callersMethodUpdate
Update is the bubbletea entry point: it dispatches to update()'s typed handlers then drains the outbox into a single tea.Println, so lines land in scr
internal/tui/model.go:380
↓ 130 callersFunctionnewTestModel
newTestModel wires a model against a mock OpenAI SSE server so we can exercise submit → stream → done without the real stack. The server is torn down
internal/tui/tui_test.go:30
↓ 72 callersMethodValue
Value returns the prompt text with every chip label expanded to its original content, what goes to the LLM on submit.
internal/tui/prompt.go:471
↓ 66 callersMethodString
String reassembles head + tail. The in-band seam marker keeps the two halves from reading as contiguous; the accurate size report lives in the caller'
internal/tools/bash.go:283
↓ 41 callersFunctionBootstrap
Bootstrap returns the config for the current project, creating .codehamr/ and config.yaml on first use. config.yaml is never overwritten; the prompt i
internal/config/config.go:118
↓ 41 callersFunctionNew
New builds a Client governed by the caller's context, not http.Client.Timeout. That timeout is end-to-end (it covers body reads) and would kill a slow
internal/llm/llm.go:238
↓ 39 callersMethodError
()
internal/cloud/cloud.go:109
↓ 38 callersMethodActiveProfile
ActiveProfile returns the selected profile. Bootstrap guarantees c.Active names a real one, so this is a straight map lookup.
internal/config/config.go:331
↓ 35 callersFunctionstripANSI
stripANSI removes CSI escape sequences (`\x1b[…m`) so tests can match the visible text through glamour's per-word styling, which splits "foo bar" into
internal/tui/tui_test.go:2435
↓ 33 callersMethodappendLine
appendLine queues a styled line for tea.Println on the next Update cycle, so the terminal, not us, owns the scrollback. scroll is a passive write-only
internal/tui/render.go:35
↓ 28 callersMethodChat
Chat streams an assistant response on the returned channel, closing it when the stream ends. Reasoning runs at `high` effort by default; if the server
internal/llm/llm.go:286
↓ 26 callersMethodSetValue
SetValue installs a plain-text value, dropping any chip state. Used by the slash popover's Tab-completion path, where no chip can be injected.
internal/tui/prompt.go:533
↓ 26 callersFunctioncollect
(ch <-chan Event)
internal/llm/llm_test.go:21
↓ 24 callersFunctionnewChippablePrompt
newChippablePrompt returns a realistically-sized promptInput. Width matters: cursor navigation walks the wrapped grid; height is irrelevant here.
internal/tui/prompt_test.go:13
↓ 24 callersFunctionpasteKey
pasteKey builds the bracketed-paste KeyMsg bubbletea emits on paste. Paste=true is the flag Update keys off of.
internal/tui/prompt_test.go:22
↓ 23 callersMethodDisplayValue
DisplayValue returns the text as shown, chip labels stay collapsed. Used for echo-to-scroll on submit and the ↑/↓ history snapshot.
internal/tui/prompt.go:499
↓ 22 callersMethodpopoverOpen
popoverOpen reports whether the slash-autocomplete popover should render and consume ↑/↓/Tab/Esc.
internal/tui/popover.go:12
↓ 20 callersMethodrunSlash
runSlash dispatches a slash-prefixed submission; unknown commands produce a quiet hint, not an error. config.yaml is re-read before every slash so han
internal/tui/slash.go:85
↓ 19 callersFunctionPack
Pack keeps whole messages newest-first until the budget is full, then returns them chronologically. The newest message is always kept, even if it alon
internal/ctx/ctx.go:140
↓ 19 callersFunctiondbgWritef
dbgWritef appends one timestamped record. No-op when logging is off. The timestamp carries the date too (not just the clock) so a shared log is unambi
internal/tui/debuglog.go:90
↓ 19 callersFunctionmakePaste
makePaste returns a string with exactly n lines (n-1 newlines).
internal/tui/prompt_test.go:27
↓ 18 callersFunctiontypeInto
typeInto feeds text one rune at a time, as a keyboard would, exercising the refreshSuggest hook on the KeyRunes fall-through.
internal/tui/tui_test.go:230
↓ 17 callersMethodHeight
()
internal/tui/prompt.go:541
↓ 17 callersMethodView
View renders only the live bottom region: in-flight streaming tokens, the popover, a divider, the prompt, and the status bar. Everything else has alre
internal/tui/render.go:240
↓ 15 callersMethodactive
()
internal/tui/model.go:43
↓ 15 callersMethodrenderStatusBar
()
internal/tui/render.go:302
↓ 15 callersMethodsetCursorRuneOffset
setCursorRuneOffset moves the cursor to an absolute rune position. textarea has no (row, col) setter, so we step CursorUp/Down to the target row then
internal/tui/prompt.go:418
↓ 14 callersFunctionNew
(cfg *config.Config, cli *llm.Client, projectDir, version string)
internal/tui/model.go:266
↓ 13 callersFunctionBash
Bash runs one shell command through /bin/sh -c and returns combined stdout+stderr. Non-zero exit is not an error; the model sees the failure and react
internal/tools/bash.go:38
↓ 13 callersFunctionEditFile
EditFile replaces old_string with new_string in path. old_string must match EXACTLY ONCE; otherwise the file is untouched and an error string is retur
internal/tools/edit.go:15
↓ 13 callersFunctionExecute
Execute runs a tool call and returns the (possibly truncated) result ready to be appended to the conversation as a `tool` message.
internal/tools/bash.go:125
↓ 13 callersFunctionhashOf
hashOf returns the sha256 hex digest, matching goreleaser's manifest format.
internal/update/update_test.go:60
↓ 13 callersMethodinstallTurnContext
installTurnContext cancels any in-flight turn context and installs a fresh per-turn root on m.turnCtx / m.cancel. Cancel-old-then-install-new keeps Ct
internal/tui/model.go:620
↓ 13 callersFunctionsseOK
sseOK writes an OpenAI-style streamed response plus a [DONE] terminator. The budget header travels on the 200 like in production.
internal/llm/llm_test.go:31
↓ 13 callersMethodsubmit
submit commits a user prompt. sendText is the expanded form sent to the LLM (chip labels replaced by their original paste content); echoText is the co
internal/tui/model.go:575
↓ 12 callersFunctionloadPromptHistory
loadPromptHistory returns every saved prompt oldest-first, matching the in-memory append order so historyUp/Down walk the same direction for typed and
internal/tui/history_store.go:34
↓ 11 callersMethodLine
()
internal/tui/prompt.go:542
↓ 11 callersMethodResolvedKey
ResolvedKey returns the profile's key, expanding it against the process environment when the WHOLE key is a `${VAR}` reference (the advertised form; s
internal/config/config.go:234
↓ 11 callersMethodSave
Save rewrites config.yaml.
internal/config/config.go:262
↓ 11 callersFunctionappendPromptHistory
appendPromptHistory writes value as one more entry, trimming to historyMaxEntries to bound growth. Empty prompts are skipped so stray ↵ presses don't
internal/tui/history_store.go:64
↓ 11 callersFunctioncountSystem
countSystem counts RoleSystem messages, the shape every nudge appends.
internal/tui/tui_test.go:1948
↓ 10 callersMethodReset
Reset clears the typed text and all chip state. nextID is preserved so ids stay monotonic within a session.
internal/tui/prompt.go:525
↓ 10 callersFunctionTokens
Tokens approximates token count as char/4, good enough for budgeting.
internal/ctx/ctx.go:35
↓ 10 callersMethodhandleProbe
handleProbe consumes an activation-time Probe result. Success stores the live context window and prints the activation line; failure surfaces the erro
internal/tui/probe.go:58
↓ 10 callersMethodhandleStream
handleStream dispatches one llm.Event to the matching apply* helper and re-arms the stream reader; EventError unwinds the turn instead of looping. Eve
internal/tui/model.go:714
↓ 10 callersMethodhandleStreamClosed
handleStreamClosed drives what happens after one round's stream finishes: dispatch the next pending tool call, or, if none, finalize the turn and hand
internal/tui/model.go:911
↓ 10 callersFunctionplatformAsset
platformAsset is the asset name Apply expects for the current runtime, via the same assetName helper production uses.
internal/update/update_test.go:68
↓ 10 callersFunctionwithReleaseURLs
withReleaseURLs swaps checksumsURL and releaseBase for one test; safe only because these tests don't run in parallel.
internal/update/update_test.go:47
↓ 9 callersFunctionApply
Apply downloads the current platform's binary, verifies its sha256 against the published codehamr_checksums.txt, and atomically replaces execPath. The
internal/update/update.go:133
↓ 9 callersMethodWrite
(p []byte)
internal/tools/bash.go:238
↓ 9 callersFunctiondrain
drain advances the model until no async commands remain, a synchronous bubbletea mini-runtime. tea.BatchMsg arrives when Update wraps multiple Cmds (e
internal/tui/tui_test.go:2737
↓ 9 callersFunctionnewFakeRelease
(t *testing.T, asset string, body []byte, declared string)
internal/update/update_test.go:27
↓ 9 callersFunctionwrapForScrollback
wrapForScrollback hard-wraps every line of s to the terminal width before it goes to tea.Println. bubbletea's standard renderer dumps queued Println l
internal/tui/render.go:48
↓ 8 callersMethodclosePopover
()
internal/tui/popover.go:102
↓ 8 callersFunctionsendEvent
sendEvent puts e on out, bailing if parent cancels first, so a slow or vanished consumer after Ctrl+C can't wedge the stream goroutine on a full buffe
internal/llm/llm.go:343
↓ 7 callersMethodActiveURL
ActiveURL is the endpoint every dial-out uses: the runtime override if set, else the active profile's URL. Use this over ActiveProfile().URL so CODEHA
internal/config/config.go:338
↓ 7 callersFunctionInlineStatus
InlineStatus is the one-liner the TUI prints per tool call.
internal/tools/bash.go:194
↓ 7 callersFunctionWriteFile
WriteFile writes content to path, creating parent dirs. Errors return as part of the output string (bash convention), never as a Go error, so the mode
internal/tools/write.go:12
↓ 7 callersMethodrecomputeLayout
recomputeLayout caps the textarea height so a long paste can't push the status bar off-screen: leave minViewport rows of breathing room above it. Chea
internal/tui/render.go:91
↓ 6 callersFunctionReadFile
ReadFile returns path's contents, truncated to the shared tool-output budget (Truncate). The model gets exact bytes, not a shell-mangled approximation
internal/tools/read.go:14
↓ 6 callersMethodTokens
()
internal/ctx/ctx.go:37
↓ 6 callersFunctionappendStatus
appendStatus wraps one segment in styleStatus and appends it, keeping renderStatusBar readable instead of repeating the wrap at each call site.
internal/tui/render.go:332
↓ 6 callersFunctionassetName
assetName mirrors the name_template in .goreleaser.yaml. Every goos goreleaser builds for must have a case here; a missing one silently locks that pla
internal/update/update.go:82
↓ 6 callersMethodmaybeRunawayNudge
maybeRunawayNudge appends one soft system note when a turn crosses maxToolRounds tool calls without finishing. The runawayNudged latch fires it exactl
internal/tui/model.go:1196
↓ 6 callersMethodsetPromptText
setPromptText overwrites the textarea, parks the cursor at the end, and refreshes the popover. Centralises the SetValue + CursorEnd + refreshSuggest d
internal/tui/keys.go:103
↓ 5 callersFunctionBudget
Budget subtracts the fixed reservations from the total context size, then leaves a headroom margin (see budgetHeadroomDivisor) so a char/4 undercount
internal/ctx/ctx.go:395
↓ 5 callersFunctionFromHeaders
FromHeaders reads the budget header. Missing (e.g. local Ollama) yields the zero value and the UI skips the segment. Out-of-range values are clamped,
internal/cloud/cloud.go:68
↓ 5 callersMethodSetActive
SetActive switches the active profile and persists. Fails on an unknown name, no silent coercion. On Save failure it reverts in-memory Active so the l
internal/config/config.go:355
↓ 5 callersMethodSetHeight
(h int)
internal/tui/prompt.go:540
↓ 5 callersMethodactiveContextSize
activeContextSize returns the context window the packer should aim at: the live server-reported value for the active profile if known, else the on-dis
internal/tui/model.go:317
↓ 5 callersFunctionbackendLabel
backendLabel renders the connection signal. Connected: profile name, bold, no colour. Disconnected: bold yellow plus a `!` marker, so the state stays
internal/tui/format.go:62
↓ 5 callersFunctioncmdYieldsClearScreen
(cmd tea.Cmd)
internal/tui/resize_test.go:241
↓ 5 callersMethodcursorRuneOffset
cursorRuneOffset returns the cursor as an absolute rune index into Value(). textarea only exposes (row, col) plus LineInfo, so we reconstruct it by wa
internal/tui/prompt.go:394
↓ 5 callersMethodendTurn
endTurn zeroes per-turn state after a turn finishes or aborts. Pair to beginTurn. Cancels the per-turn context unconditionally to release the CancelFu
internal/tui/model.go:653
↓ 5 callersMethodmaxTextareaHeight
maxTextareaHeight caps the textarea: terminal minus chrome, breathing room, the active popover, and the queued-prompt box. Shared by recomputeLayout a
internal/tui/render.go:98
↓ 5 callersMethodrecordAndNudge
recordAndNudge replays Update's toolResultMsg "queue drained" branch: record the outcome, then consider the failure nudge. Lets the streak tests exerc
internal/tui/tui_test.go:1853
↓ 5 callersFunctiontoolCallLeakWarning
toolCallLeakWarning returns a user-facing diagnostic when the newest assistant message carries a tool-call opener (`<tool_call>`) in its text instead
internal/tui/model.go:1033
↓ 5 callersMethodvisualPromptLines
visualPromptLines counts the *visual* rows the textarea needs (a line that wraps to three screen rows wants a three-row textarea), via wrapRows which
internal/tui/render.go:165
↓ 4 callersFunctionCheck
Check reports whether the local binary's sha256 differs from the remote asset's recorded hash. ctx propagates a startup Ctrl+C into the HTTP request.
internal/update/update.go:56
↓ 4 callersFunctionCleanupOld
CleanupOld removes the execPath+".old" left by a previous Apply. Run at the start of the next launch: on Windows the .old is locked for the prior proc
internal/update/update.go:232
↓ 4 callersMethodCursorEnd
()
internal/tui/prompt.go:544
↓ 4 callersMethodEnsureHamrpass
EnsureHamrpass returns the hamrpass profile, re-creating it from the seed if the user deleted it. Lets /hamrpass activate by pasting a key without a r
internal/config/config.go:212
↓ 4 callersMethodModelNames
ModelNames returns the profile names sorted, so the popover cycles deterministically regardless of map iteration order.
internal/config/config.go:347
↓ 4 callersFunctionOpenDebugLog
OpenDebugLog truncates <dir>/log.txt and opens it for writing. On failure it reports once on stderr and disables logging: the log must never block the
internal/tui/debuglog.go:30
↓ 4 callersMethodRestore
Restore replays a history entry: sets the display text, installs the snapshot's chip state, drops the cursor at the end.
internal/tui/prompt.go:513
↓ 4 callersMethodSetWidth
(w int)
internal/tui/prompt.go:539
↓ 4 callersMethodStatusSuffix
StatusSuffix builds the " · 73% pass" status-bar tail; "" before the first snapshot. Rounded to nearest percent so it doesn't jitter on every token.
internal/cloud/cloud.go:91
↓ 4 callersMethodapplyDone
applyDone closes one LLM round: harvest the live context window, accumulate turn/session tokens, append the assistant message, flush streaming. A turn
internal/tui/model.go:785
↓ 4 callersMethodchipAtBoundary
chipAtBoundary returns the chip whose start (atStart=true) or end (atStart=false) coincides with cur, the check Backspace/Delete/Left/Right share.
internal/tui/prompt.go:165
↓ 4 callersFunctioncommandByName
commandByName returns the registered command for a slash name, or nil. Centralises the linear scan shared by completion, dispatch, and runSlash.
internal/tui/slash.go:73
↓ 4 callersFunctiondbgEnabled
dbgEnabled reports whether logging is on. Callers use it to skip building expensive log payloads (e.g. accumulating a round's reasoning) when the log
internal/tui/debuglog.go:81
↓ 4 callersMethoderrorMessage
errorMessage maps a stream error into a one-line TUI hint, same format across all profiles.
internal/tui/commands.go:65
↓ 4 callersMethodfinalizeTurn
finalizeTurn freezes the finished turn's wall-clock summary into the status bar (shown at idle until the next submit) and logs the totals. outcome is
internal/tui/model.go:879
↓ 4 callersFunctionhumanTokens
humanTokens renders a token count compactly: `900 tok`, `1.2k tok`, `1.5M tok`. The k/M ranges always keep one decimal (`2.0k`, not `2k`) so the live
internal/tui/format.go:16
↓ 4 callersMethodmaybeVerifyNudge
maybeVerifyNudge appends one re-grounding system note when a substantial turn (>= verifyNudgeMinRounds tool calls) is about to finish with a clean, no
internal/tui/model.go:1227
↓ 4 callersMethodpopoverMoveSelection
popoverMoveSelection wraps the selection index modulo the filtered list.
internal/tui/popover.go:24
↓ 4 callersFunctionreadEvent
readEvent drains one event from the LLM stream as a tea.Msg, re-scheduled until the channel closes. Tags ch so Update can spot stale prior-turn events
internal/tui/commands.go:40
↓ 4 callersMethodrenderPopover
renderPopover draws the suggestion list: value flush left, description right aligned, one row each. Selection is a colour change (stylePopoverSelected
internal/tui/popover.go:123
↓ 4 callersFunctionschemaToTool
schemaToTool unwraps a tool schema (the map[string]any shape shared by bash and the file tools) into the typed llm.Tool the chat payload expects.
internal/tui/model.go:697
↓ 4 callersMethodsnapCursorOutOfChip
snapCursorOutOfChip snaps a cursor sitting strictly inside a chip to the nearer boundary. Returns the (possibly adjusted) offset so callers skip a sec
internal/tui/prompt.go:148
next →1–100 of 622, ranked by callers