MCPcopy Create free account

hub / github.com/codehamr/codehamr / functions

Functions622 in github.com/codehamr/codehamr

↓ 4 callersMethodstartChat
()
internal/tui/model.go:610
↓ 4 callersFunctionsuggestNames
(m Model)
internal/tui/tui_test.go:239
↓ 3 callersFunctionCloseDebugLog
CloseDebugLog flushes and closes the log. Idempotent.
internal/tui/debuglog.go:47
↓ 3 callersFunctionContextWindowFromHeaders
ContextWindowFromHeaders reads X-Context-Window. Returns 0 when missing, malformed, or out of sane range; the caller reads 0 as "use the fallback". Lo
internal/cloud/cloud.go:118
↓ 3 callersMethodEntry
Entry snapshots state for the history buffer, cloning store and spans so later edits to the live promptInput don't mutate the recorded entry.
internal/tui/prompt.go:503
↓ 3 callersFunctionReachable
Reachable GETs baseURL/v1/models with ctx as deadline; any HTTP response (even 401/404) counts as reachable, only transport errors/timeouts don't. Bac
internal/cloud/cloud.go:30
↓ 3 callersFunctionTruncate
Truncate collapses oversized tool outputs to first 2k + last 2k tokens; inputs at or under 6k pass through unchanged. Head/tail can't overlap: >6k tok
internal/ctx/ctx.go:85
↓ 3 callersFunctionchipLabel
chipLabel is the visible form inserted into the textarea. Plain text, no ANSI, since textarea doesn't render inline styling inside its value.
internal/tui/prompt.go:89
↓ 3 callersFunctionclearPromptHistory
clearPromptHistory removes the on-disk file so /clear also wipes recall. A missing file is not an error: the empty-history intent already holds.
internal/tui/history_store.go:132
↓ 3 callersFunctioncountCmdLeaves
countCmdLeaves runs cmd, recurses into the slice-shaped []tea.Cmd payload of tea.BatchMsg / tea.sequenceMsg (both unexported), and counts leaves where
internal/tui/resize_test.go:218
↓ 3 callersFunctiondrainFinal
drainFinal submits a prompt and pumps the whole turn to completion, returning the settled model. Centralises the submit+drain dance the empty-reply te
internal/tui/tui_test.go:3337
↓ 3 callersFunctionfetchHash
fetchHash downloads codehamr_checksums.txt and returns the hash for asset. The manifest is one line per asset, "<hex-sha256> <filename>"; we match th
internal/update/update.go:257
↓ 3 callersMethodflushStreaming
flushStreaming ends the content phase: render the streaming buffer through glamour, queue it for tea.Println, reset. No-op on an empty buffer. Glamour
internal/tui/render.go:69
↓ 3 callersMethodforwardToTextarea
forwardToTextarea passes msg to the textarea and refreshes the popover to match. The "let the textarea handle it" fallback shared by handleKey, handle
internal/tui/keys.go:93
↓ 3 callersFunctionhamrpassValidate
hamrpassValidate is the single source of truth for whether a key is acceptable and what the UI says about it. Shared by the inline /hamrpass handler a
internal/tui/slash.go:241
↓ 3 callersFunctionhistoryPath
(dir string)
internal/tui/history_store.go:29
↓ 3 callersFunctionhumanRate
humanRate renders throughput: `25 tok/s`, `5.3 tok/s`. Returns "" on degenerate input (no tokens or zero elapsed) so the caller omits the segment. Sub
internal/tui/format.go:48
↓ 3 callersFunctionliveElapsed
liveElapsed renders a running wall-clock duration for the status bar: whole seconds under a minute (no sub-second decimal spinning at the spinner's re
internal/tui/format.go:33
↓ 3 callersFunctionmkfifo
mkfifo creates a FIFO in a temp dir; opening it for read OR write would block forever with no peer, which is exactly what the guards must prevent.
internal/tools/nonregular_unix_test.go:22
↓ 3 callersFunctionnewPromptInput
newPromptInput builds the configured textarea and chip bookkeeping. All styling lives here so model.go never touches textarea internals directly.
internal/tui/prompt.go:58
↓ 3 callersMethodrebuildClient
rebuildClient swaps in a fresh llm.Client for the now-active profile. Replacing the pointer (not mutating fields) drops the prior Client's sticky stat
internal/tui/slash.go:187
↓ 3 callersMethodreconcile
reconcile re-finds each chip's label in the value (searching past the prior span's end) and updates offsets. A span whose label has vanished (e.g. par
internal/tui/prompt.go:312
↓ 3 callersFunctiontimeoutC
timeoutC bounds the hang these tests exist to catch, well under go test's own package timeout so a regression fails fast with a named cause.
internal/tools/nonregular_unix_test.go:15
↓ 3 callersFunctiontoWire
(msgs []chmctx.Message)
internal/llm/llm.go:607
↓ 3 callersFunctiontoolTargetKey
toolTargetKey is the stable identity used to detect a repeated-failure loop: tool name + its target (the path for file tools, the command's first line
internal/tui/model.go:1086
↓ 3 callersMethodupdate
(msg tea.Msg)
internal/tui/model.go:391
↓ 2 callersFunctionAuthHeader
AuthHeader returns the Bearer header a cloud-routed request needs.
internal/cloud/cloud.go:113
↓ 2 callersFunctionEditFileSchema
EditFileSchema is the OpenAI tool definition for edit_file. The description steers the model toward edit_file over write_file for small changes so it
internal/tools/edit.go:76
↓ 2 callersFunctionPrintHelp
PrintHelp writes the canonical human-readable command list. Used by --help.
internal/tui/slash.go:129
↓ 2 callersMethodProbe
Probe sends a minimal hello chat just to harvest response headers in one round trip: status validates the URL/model/key combo, X-Context-Window gives
internal/llm/llm.go:264
↓ 2 callersFunctionReadFileSchema
ReadFileSchema is the OpenAI tool definition for read_file. The description nudges the model toward read_file over `cat` so it stops piping source thr
internal/tools/read.go:35
↓ 2 callersFunctionResponseReserve
ResponseReserve is the slice Budget keeps free for the model's response. Scales as ctxSize/8 so reasoning models get room (262k→32k, 1M→125k), floored
internal/ctx/ctx.go:74
↓ 2 callersMethodabortTurn
abortTurn winds down a turn that did not complete normally: flush in-flight text so the partial block lands in scrollback, post the explanatory banner
internal/tui/model.go:849
↓ 2 callersFunctionassetNameSupported
assetNameSupported returns the set of platforms assetName resolves, with their names. It probes a generous candidate universe UNION the matrix's own v
internal/update/drift_test.go:63
↓ 2 callersMethodbuildTools
buildTools exposes the four local tools every turn: bash, read_file, write_file, edit_file. No loop/control tool; a turn ends when the model stops emi
internal/tui/model.go:686
↓ 2 callersFunctioncmdYieldsScrollbackErase
(cmd tea.Cmd)
internal/tui/resize_test.go:248
↓ 2 callersMethodconfirmActive
confirmActive emits the activation line for the active profile and returns its reachability cmd. Keyed profiles (cloud) probe: the success line is del
internal/tui/slash.go:173
↓ 2 callersFunctioncountLines
countLines returns a paste's visual line count. Terminals disagree on separators (\n unix, \r old-mac, \r\n Windows); max of the \n and \r counts hand
internal/tui/prompt.go:210
↓ 2 callersFunctioncountPrintlnLeaves
(cmd tea.Cmd)
internal/tui/resize_test.go:265
↓ 2 callersFunctiondbgWriteMessage
dbgWriteMessage records a chmctx.Message readably: content and tool calls each get a labeled section. No-op when logging is off, so callers needn't gu
internal/tui/debuglog.go:150
↓ 2 callersMethoddeleteSpan
deleteSpan removes the chip's label from the value and drops it from spans and store. Cursor lands at the vacated start; reconcile re-validates later
internal/tui/prompt.go:288
↓ 2 callersMethoddispatchNextTool
dispatchNextTool pops the next pending tool call and runs it. Every tool flows through runToolCall; none are special-cased. lastToolKey records this c
internal/tui/model.go:1053
↓ 2 callersMethoddoPost
doPost performs one round-trip, mapping status into the typed cloud errors Probe and sendChat share. On 200 it returns the live response with body ope
internal/llm/llm.go:401
↓ 2 callersFunctiondropDanglingToolCalls
dropDanglingToolCalls removes any assistant message whose tool_calls include an id with no answering tool message in the kept slice: the mirror of dro
internal/ctx/ctx.go:360
↓ 2 callersFunctiondropOrphanTools
dropOrphanTools removes tool messages that are not part of the contiguous tool run answering the assistant directly before them: sending one alone 400
internal/ctx/ctx.go:324
↓ 2 callersMethoddroppedBytes
droppedBytes is how many middle bytes the ring discarded; 0 while the whole output still fits head+tail.
internal/tools/bash.go:267
↓ 2 callersFunctionfirstLine
(s string)
internal/tools/bash.go:296
↓ 2 callersFunctiongoreleaserMatrix
goreleaserMatrix is the source of truth: every os/arch goreleaser builds for.
internal/update/drift_test.go:35
↓ 2 callersFunctionhumanInt
humanInt formats a non-negative integer with commas so a context window like 262144 reads as "262,144" rather than a wall of digits.
internal/tui/format.go:71
↓ 2 callersFunctionidleTimeoutFromEnv
idleTimeoutFromEnv resolves CODEHAMR_IDLE_TIMEOUT to a duration, falling back to streamIdleTimeout when unset or unparseable. Accepts a Go duration st
internal/llm/llm.go:192
↓ 2 callersFunctionisHex
isHex reports whether s is non-empty lowercase hex, the shape of a git abbreviated commit hash.
cmd/codehamr/main.go:146
↓ 2 callersFunctionisLocalBuild
isLocalBuild reports whether the binary came from a working tree rather than an official release. `go run` leaves version "dev"; `make install` inject
cmd/codehamr/main.go:132
↓ 2 callersFunctionisUnreachable
(err error)
internal/tui/commands.go:81
↓ 2 callersMethodmaybeFailureNudge
maybeFailureNudge appends one system-role note once the same target has failed maxToolFailStreak times running, then resets the streak so it fires at
internal/tui/model.go:1167
↓ 2 callersFunctionnewestAssistantEmpty
newestAssistantEmpty reports whether the turn's final assistant message carried neither text nor a structured tool call. A clean finish always has a s
internal/tui/model.go:995
↓ 2 callersFunctionpingBackend
pingBackend issues a short GET to baseURL/v1/models via cloud.Reachable. Any HTTP response counts as reachable; transport errors and timeouts mean dis
internal/tui/model.go:1266
↓ 2 callersMethodpopoverHeight
popoverHeight is the rows the popover occupies in View(): 0 when closed, capped at popoverCap to leave the viewport breathing room.
internal/tui/popover.go:112
↓ 2 callersMethodpostChat
postChat dispatches via doPost; on a 400 rejecting reasoning it drops reasoning_effort for this Client's lifetime and retries once. Two wild flavours,
internal/llm/llm.go:379
↓ 2 callersFunctionprobeBackend
probeBackend wraps llm.Client.Probe in a tea.Cmd, bounded by probeTimeout so a hung backend never freezes activation. silent=true (startup probe) skip
internal/tui/probe.go:34
↓ 2 callersMethodrecordToolOutcome
recordToolOutcome updates the failure streak from one finished tool result. A success (or a failure of a different target) resets the streak; a same-
internal/tui/model.go:1146
↓ 2 callersFunctionredactSlash
redactSlash strips the /hamrpass <key> bearer token before it lands in any log. A central hook covers any future secret-bearing command from one place
internal/tui/debuglog.go:67
↓ 2 callersMethodrefreshSuggest
refreshSuggest recomputes the popover from the textarea: command level before the first space, argument level after it.
internal/tui/popover.go:34
↓ 2 callersMethodreloadConfigFromDisk
reloadConfigFromDisk re-runs config.Bootstrap and replaces m.cfg so hand-edits to config.yaml between slash commands take effect immediately. URLOverr
internal/tui/slash.go:107
↓ 2 callersMethodrenderQueued
renderQueued draws the pending-prompt box shown above the divider while a turn runs: a faint title line plus a rounded panel with the collapsed echo,
internal/tui/render.go:124
↓ 2 callersFunctionrunRaw
(parent context.Context, call chmctx.ToolCall)
internal/tools/bash.go:135
↓ 2 callersFunctionrunToolCall
runToolCall executes one tool call off the UI goroutine. parent is the per-turn root: Ctrl+C aborts the tool mid-run, and the toolResultMsg carries th
internal/tui/commands.go:57
↓ 2 callersFunctionrunTurn
runTurn wires a model against handler, submits `text`, drains the command chain, and returns the Model. token, when non-empty, is installed on both th
internal/tui/tui_test.go:1186
↓ 2 callersFunctionruneIndex
runeIndex is a rune-level strings.Index: first occurrence of needle in haystack, or -1. promptInput works in runes throughout because textarea's curso
internal/tui/prompt.go:368
↓ 2 callersMethodsetPopover
setPopover swaps in a new suggestion set. Selection priority: the current row (e.g. active profile), else the first.
internal/tui/popover.go:79
↓ 2 callersMethodsplashLines
splashLines builds the identity block for tea.Println. Below wordmarkWidth the ASCII art soft-wraps into garbage, so collapse to plain text.
internal/tui/render.go:273
↓ 2 callersFunctiontoolResultFailed
toolResultFailed reports whether a tool result is an error the model should react to. File tools wrap errors in parens ("(write error: ...)", "(not fo
internal/tui/model.go:1106
↓ 2 callersFunctiontypeChars
typeChars feeds each rune of s as a separate KeyMsg, rendering View() after each. Non-cosmetic: the viewport only populates its `lines` slice (and thu
internal/tui/prompt_typing_test.go:16
↓ 2 callersFunctionwrapRows
wrapRows mirrors bubbles/textarea.wrap()'s row count so the prompt's auto-grow stays in lock step with what the textarea renders: word-boundary aware
internal/tui/render.go:190
↓ 2 callersFunctionwriteYAML
(path string, v any)
internal/config/config.go:269
↓ 1 callersFunctionBashSchema
BashSchema is the OpenAI tool definition for bash, exposed by every profile.
internal/tools/bash.go:99
↓ 1 callersFunctionDefault
()
internal/config/config.go:98
↓ 1 callersFunctionIsCloudProfile
IsCloudProfile reports whether a profile's context_size is server-managed.
internal/config/config.go:45
↓ 1 callersMethodLineCount
()
internal/tui/prompt.go:543
↓ 1 callersFunctionWriteFileSchema
WriteFileSchema is the OpenAI tool definition for write_file. The description steers the model away from bash heredocs (shell-quoting failure mode) fo
internal/tools/write.go:39
↓ 1 callersMethodactivateHamrpass
activateHamrpass writes the key onto the hamrpass profile (seeding the entry if the user removed it from config.yaml), switches active, rebuilds the c
internal/tui/slash.go:334
↓ 1 callersFunctionanchorUserMessage
anchorUserMessage guarantees the packed window carries a user-role message whenever history has one. The newest-first walk drops oldest-first, so a lo
internal/ctx/ctx.go:201
↓ 1 callersMethodappendUserTurn
appendUserTurn appends a user-role message to history and starts a turn. The only path that does so; used by submit.
internal/tui/model.go:640
↓ 1 callersMethodapplyContent
applyContent writes one streamed text chunk to the live buffer and promotes phase from thinking to streaming on the first chunk so the status bar show
internal/tui/model.go:757
↓ 1 callersFunctionapplyEnvOverrides
applyEnvOverrides folds runtime env vars into cfg. CODEHAMR_URL overrides the active profile's URL (devcontainers / CI), held on a non-serialised fiel
cmd/codehamr/main.go:215
↓ 1 callersMethodapplyError
applyError unwinds the turn on a stream error: preserve content streamed before the error (so the user keeps failure context), emit the one-line hint,
internal/tui/model.go:833
↓ 1 callersMethodapplyToolCall
applyToolCall queues a streamed tool call for later dispatch. flushStreaming up front commits this round's text to scroll before the inline tool-call
internal/tui/model.go:775
↓ 1 callersMethodbeginTurn
beginTurn installs a fresh per-turn context, flips phase to thinking, and returns the chat stream-reader Cmd. Every path starting a new LLM round funn
internal/tui/model.go:630
↓ 1 callersMethodbuildMessages
()
internal/tui/model.go:672
↓ 1 callersFunctionbuildSystem
buildSystem appends the working-directory anchor to the embedded system prompt so "hier" / "here" resolves to a concrete path.
internal/tui/model.go:1258
↓ 1 callersFunctioncmdYieldsPrintln
(cmd tea.Cmd)
internal/tui/resize_test.go:255
↓ 1 callersFunctioncountHistoryLines
countHistoryLines tallies lines without parsing them: fast path for the trim decision in appendPromptHistory.
internal/tui/history_store.go:115
↓ 1 callersMethodcurrentSuggestion
currentSuggestion returns the highlighted popover row, or false when the popover is closed or empty.
internal/tui/popover.go:16
↓ 1 callersMethodcursorOnFirstLine
cursorOnFirstLine: true when ↑ should walk prompt history instead of moving the textarea's own cursor. cursorOnLastLine is the mirror for ↓.
internal/tui/model.go:1253
↓ 1 callersMethodcursorOnLastLine
()
internal/tui/model.go:1254
↓ 1 callersFunctiondbgWriteRequest
dbgWriteRequest records, per LLM round, what newest-first packing actually sent: how much of history survived the budget and how many tool outputs are
internal/tui/debuglog.go:119
↓ 1 callersFunctiondbgWriteSession
dbgWriteSession records the active backend and context budget once at startup. Behaviour differs sharply by model (different model families fail in di
internal/tui/debuglog.go:107
↓ 1 callersFunctiondemoteSystemMessages
demoteSystemMessages rewrites every system-role message in the packed history to a user message. buildMessages always prepends the embedded system pro
internal/ctx/ctx.go:227
↓ 1 callersFunctiondiffersOnlyInWhitespace
differsOnlyInWhitespace reports whether oldString matches content at exactly one spot once every whitespace run is collapsed: i.e. the sole mismatch i
internal/tools/edit.go:68
↓ 1 callersFunctiondispatchDelta
dispatchDelta forwards reasoning and content as events, then accumulates streamed tool-call fragments into index-keyed slots. Reasoning stays out of f
internal/llm/llm.go:544
↓ 1 callersFunctionerrorMessageFromBody
errorMessageFromBody extracts the user-facing string from a non-2xx body. hamrpass wraps errors as `{"error":{"message":...,"provider_hint":...}}`; we
internal/llm/llm.go:445
← previousnext →101–200 of 622, ranked by callers