mirror of
https://github.com/esengine/DeepSeek-Reasonix.git
synced 2026-11-07 10:45:59 -10:00
internal/ was 141 packages side by side, so nothing but a reader's memory
said which were foundations and which assembled the rest. Each now sits in a
layer directory, and the directory is the declaration:
base L0 foundation with no domain in it
contract L1 types and interfaces the layers above agree on
model, tools, safety, ext, state, platform
L2 subsystems, peers of one another
runtime L3 the turn engine
session L4 the controller
assembly L5 the composition root
frontend L6 cli, serve, acp and the host adapters
Only paths change: package names, code and behaviour do not. Imports,
repolint and coverage baselines, sensitive paths, CI package lists and docs
follow the new paths; release notes keep the paths they were written with,
and sample paths inside tests and fixtures keep theirs.
repolint gains layer-order: a package may import its own layer and those
below it, read from where it lives. The 47 imports that point upward today
are recorded as that rule's opening debt (-allow-widen, a new rule's first
baseline) and can only go down. Most of it is config, which still reaches
into eight subsystems and is the next thing to take apart; the rest is
event, history and a few tools reaching into runtime for types that belong
in contract.
42 lines
1.4 KiB
Go
42 lines
1.4 KiB
Go
package agent
|
|
|
|
import (
|
|
"regexp"
|
|
"strings"
|
|
|
|
"github.com/mattn/go-runewidth"
|
|
)
|
|
|
|
// ansiSGR matches ANSI Select-Graphic-Rendition sequences (\e[…m). Width
|
|
// measurement strips these so styled streamed text still gets counted by its
|
|
// visible column footprint.
|
|
var ansiSGR = regexp.MustCompile("\x1b\\[[0-9;]*m")
|
|
|
|
// visibleWidth returns the column count of s after stripping ANSI SGR codes.
|
|
// Delegates to go-runewidth so emoji, fullwidth forms, and ZWJ sequences all
|
|
// measure correctly — a hand-rolled CJK-only table missed every emoji range
|
|
// and made the streamed-text row count drift on emoji-heavy answers.
|
|
func visibleWidth(s string) int {
|
|
return runewidth.StringWidth(ansiSGR.ReplaceAllString(s, ""))
|
|
}
|
|
|
|
// streamedRows counts how many rows the cursor has descended after raw text
|
|
// of length s was printed at the given terminal width. Used by the markdown
|
|
// redraw to know how far up to move before clearing. Each \n descends one
|
|
// row; lines whose visible width exceeds the terminal width descend an extra
|
|
// row per wrap. A line exactly the terminal width does not wrap on its own —
|
|
// terminals "lazy-wrap" only when the next visible character lands.
|
|
func streamedRows(s string, width int) int {
|
|
if width <= 0 {
|
|
width = 80
|
|
}
|
|
rows := 0
|
|
for line := range strings.SplitSeq(s, "\n") {
|
|
if w := visibleWidth(line); w > 0 {
|
|
rows += (w - 1) / width
|
|
}
|
|
}
|
|
rows += strings.Count(s, "\n")
|
|
return rows
|
|
}
|