Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
!./**/*.go
!./**/*.txt
!/pkg/config/builtin-agents/*.yaml
!/pkg/tui/styles/themes/*.yaml
!/pkg/tui/styles/themes/*.yaml
!/vendor
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ evals

# agents
agent.yaml
vendor

# Local environment files
.env.local
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS b
COPY --from=xx / /
RUN apk add --no-cache clang zig
WORKDIR /src
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=bind,source=go.mod,target=go.mod \
--mount=type=bind,source=go.sum,target=go.sum \
go mod download
# RUN --mount=type=cache,target=/go/pkg/mod \
# --mount=type=bind,source=go.mod,target=go.mod \
# --mount=type=bind,source=go.sum,target=go.sum \
# go mod download
ENV CGO_ENABLED=1

FROM builder-base AS builder
Expand Down
21 changes: 21 additions & 0 deletions vendor/charm.land/bubbles/v2/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020-2026 Charmbracelet, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
241 changes: 241 additions & 0 deletions vendor/charm.land/bubbles/v2/cursor/cursor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
// Package cursor provides a virtual cursor to support the textinput and
// textarea elements.
package cursor

import (
"context"
"sync/atomic"
"time"

tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
)

const defaultBlinkSpeed = time.Millisecond * 530

// Internal ID management. Used during animating to ensure that frame messages
// are received only by spinner components that sent them.
var lastID int64

func nextID() int {
return int(atomic.AddInt64(&lastID, 1))
}

// initialBlinkMsg initializes cursor blinking.
type initialBlinkMsg struct{}

// BlinkMsg signals that the cursor should blink. It contains metadata that
// allows us to tell if the blink message is the one we're expecting.
type BlinkMsg struct {
id int
tag int
}

// blinkCanceled is sent when a blink operation is canceled.
type blinkCanceled struct{}

// blinkCtx manages cursor blinking.
type blinkCtx struct {
ctx context.Context
cancel context.CancelFunc
}

// Mode describes the behavior of the cursor.
type Mode int

// Available cursor modes.
const (
CursorBlink Mode = iota
CursorStatic
CursorHide
)

// String returns the cursor mode in a human-readable format. This method is
// provisional and for informational purposes only.
func (c Mode) String() string {
return [...]string{
"blink",
"static",
"hidden",
}[c]
}

// Model is the Bubble Tea model for this cursor element.
type Model struct {
// Style styles the cursor block.
Style lipgloss.Style

// TextStyle is the style used for the cursor when it is blinking
// (hidden), i.e. displaying normal text.
TextStyle lipgloss.Style

// BlinkSpeed is the speed at which the cursor blinks. This has no effect
// unless [CursorMode] is not set to [CursorBlink].
BlinkSpeed time.Duration

// IsBlinked is the state of the cursor blink. When true, the cursor is
// hidden.
IsBlinked bool

// char is the character under the cursor
char string

// The ID of this Model as it relates to other cursors
id int

// focus indicates whether the containing input is focused
focus bool

// Used to manage cursor blink
blinkCtx *blinkCtx

// The ID of the blink message we're expecting to receive.
blinkTag int

// mode determines the behavior of the cursor
mode Mode
}

// New creates a new model with default settings.
func New() Model {
return Model{
id: nextID(),
BlinkSpeed: defaultBlinkSpeed,
IsBlinked: true,
mode: CursorBlink,

blinkCtx: &blinkCtx{
ctx: context.Background(),
},
}
}

// Update updates the cursor.
func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
switch msg := msg.(type) {
case initialBlinkMsg:
// We accept all initialBlinkMsgs generated by the Blink command.

if m.mode != CursorBlink || !m.focus {
return m, nil
}

cmd := m.Blink()
return m, cmd

case tea.FocusMsg:
return m, m.Focus()

case tea.BlurMsg:
m.Blur()
return m, nil

case BlinkMsg:
// We're choosy about whether to accept blinkMsgs so that our cursor
// only exactly when it should.

// Is this model blink-able?
if m.mode != CursorBlink || !m.focus {
return m, nil
}

// Were we expecting this blink message?
if msg.id != m.id || msg.tag != m.blinkTag {
return m, nil
}

var cmd tea.Cmd
if m.mode == CursorBlink {
m.IsBlinked = !m.IsBlinked
cmd = m.Blink()
}
return m, cmd

case blinkCanceled: // no-op
return m, nil
}
return m, nil
}

// Mode returns the model's cursor mode. For available cursor modes, see
// type Mode.
func (m Model) Mode() Mode {
return m.mode
}

// SetMode sets the model's cursor mode. This method returns a command.
//
// For available cursor modes, see type CursorMode.
func (m *Model) SetMode(mode Mode) tea.Cmd {
// Adjust the mode value if it's value is out of range
if mode < CursorBlink || mode > CursorHide {
return nil
}
m.mode = mode
m.IsBlinked = m.mode == CursorHide || !m.focus
if mode == CursorBlink {
return Blink
}
return nil
}

// Blink is a command used to manage cursor blinking.
func (m *Model) Blink() tea.Cmd {
if m.mode != CursorBlink {
return nil
}

if m.blinkCtx != nil && m.blinkCtx.cancel != nil {
m.blinkCtx.cancel()
}

ctx, cancel := context.WithTimeout(m.blinkCtx.ctx, m.BlinkSpeed)
m.blinkCtx.cancel = cancel

m.blinkTag++
blinkMsg := BlinkMsg{id: m.id, tag: m.blinkTag}

return func() tea.Msg {
defer cancel()
<-ctx.Done()
if ctx.Err() == context.DeadlineExceeded {
return blinkMsg
}
return blinkCanceled{}
}
}

// Blink is a command used to initialize cursor blinking.
func Blink() tea.Msg {
return initialBlinkMsg{}
}

// Focus focuses the cursor to allow it to blink if desired.
func (m *Model) Focus() tea.Cmd {
m.focus = true
m.IsBlinked = m.mode == CursorHide // show the cursor unless we've explicitly hidden it

if m.mode == CursorBlink && m.focus {
return m.Blink()
}
return nil
}

// Blur blurs the cursor.
func (m *Model) Blur() {
m.focus = false
m.IsBlinked = true
}

// SetChar sets the character under the cursor.
func (m *Model) SetChar(char string) {
m.char = char
}

// View displays the cursor.
func (m Model) View() string {
if m.IsBlinked {
return m.TextStyle.Inline(true).Render(m.char)
}
return m.Style.Inline(true).Reverse(true).Render(m.char)
}
Loading
Loading