feat: upgrade to core v0.8.0-alpha.1, replace banned stdlib imports
All checks were successful
Security Scan / security (push) Successful in 8s
Test / test (push) Successful in 1m22s

Replace fmt, strings, path/filepath, core/log with Core primitives.
coreerr.E→core.E. Keep strings.ContainsAny/SplitSeq/Index/Repeat.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude 2026-03-26 14:08:17 +00:00
parent 3a53908d62
commit 8ff7ccaee1
No known key found for this signature in database
GPG key ID: AF404715446AEB41
9 changed files with 94 additions and 100 deletions

View file

@ -46,8 +46,12 @@ Coverage target: maintain ≥90.9%.
- Exported declarations must have Go doc comments beginning with the identifier name
- `go test ./...` and `go vet ./...` must pass before commit
- SPDX header on all source files: `// SPDX-Licence-Identifier: EUPL-1.2`
- Error handling: all errors must use `coreerr.E(op, msg, err)` from `dappco.re/go/core/log`, never `fmt.Errorf` or `errors.New`
- Banned imports in non-test Go files: `errors`, `github.com/pkg/errors`, and legacy `forge.lthn.ai/...` paths
- Error handling: all errors must use `core.E(op, msg, err)` from `dappco.re/go/core`, never `fmt.Errorf` or `errors.New`
- Banned imports in non-test Go files: `fmt`, `errors`, `path/filepath`, `dappco.re/go/core/log`, `github.com/pkg/errors`, and legacy `forge.lthn.ai/...` paths
- Use `core.Sprintf`/`core.Sprint` instead of `fmt.Sprintf`/`fmt.Sprint`
- Use `core.Lower`/`core.Contains`/`core.Trim`/`core.TrimSuffix` etc. instead of `strings.*` where core provides an equivalent
- Use `core.PathBase`/`core.PathGlob`/`core.Concat` instead of `filepath.*`
- Allowed stdlib in non-test files: `encoding/json` (for json.RawMessage, json.Unmarshal), `strings` (for SplitSeq, ContainsAny, Repeat, Index — no core equivalent), `os/exec`
- Conventional commits: `type(scope): description`
- Co-Author trailer: `Co-Authored-By: Virgil <virgil@lethean.io>`

View file

@ -2,11 +2,12 @@
package session
import (
"fmt"
"maps"
"slices"
"strings"
"time"
"dappco.re/go/core"
)
// SessionAnalytics holds computed metrics for a parsed session.
@ -98,22 +99,22 @@ func Analyse(sess *Session) *SessionAnalytics {
// FormatAnalytics returns a tabular text summary suitable for CLI display.
func FormatAnalytics(a *SessionAnalytics) string {
var b strings.Builder
b := core.NewBuilder()
b.WriteString("Session Analytics\n")
b.WriteString(strings.Repeat("=", 50) + "\n\n")
b.WriteString(fmt.Sprintf(" Duration: %s\n", formatDuration(a.Duration)))
b.WriteString(fmt.Sprintf(" Active Time: %s\n", formatDuration(a.ActiveTime)))
b.WriteString(fmt.Sprintf(" Events: %d\n", a.EventCount))
b.WriteString(fmt.Sprintf(" Success Rate: %.1f%%\n", a.SuccessRate*100))
b.WriteString(fmt.Sprintf(" Est. Input Tk: %d\n", a.EstimatedInputTokens))
b.WriteString(fmt.Sprintf(" Est. Output Tk: %d\n", a.EstimatedOutputTokens))
b.WriteString(core.Sprintf(" Duration: %s\n", formatDuration(a.Duration)))
b.WriteString(core.Sprintf(" Active Time: %s\n", formatDuration(a.ActiveTime)))
b.WriteString(core.Sprintf(" Events: %d\n", a.EventCount))
b.WriteString(core.Sprintf(" Success Rate: %.1f%%\n", a.SuccessRate*100))
b.WriteString(core.Sprintf(" Est. Input Tk: %d\n", a.EstimatedInputTokens))
b.WriteString(core.Sprintf(" Est. Output Tk: %d\n", a.EstimatedOutputTokens))
if len(a.ToolCounts) > 0 {
b.WriteString("\n Tool Breakdown\n")
b.WriteString(" " + strings.Repeat("-", 48) + "\n")
b.WriteString(fmt.Sprintf(" %-14s %6s %6s %10s %10s\n",
b.WriteString(core.Sprintf(" %-14s %6s %6s %10s %10s\n",
"Tool", "Calls", "Errors", "Avg", "Max"))
b.WriteString(" " + strings.Repeat("-", 48) + "\n")
@ -122,7 +123,7 @@ func FormatAnalytics(a *SessionAnalytics) string {
errors := a.ErrorCounts[tool]
avg := a.AvgLatency[tool]
max := a.MaxLatency[tool]
b.WriteString(fmt.Sprintf(" %-14s %6d %6d %10s %10s\n",
b.WriteString(core.Sprintf(" %-14s %6d %6d %10s %10s\n",
tool, a.ToolCounts[tool], errors,
formatDuration(avg), formatDuration(max)))
}

View file

@ -19,8 +19,11 @@ func TestConventions_BannedImports_Good(t *testing.T) {
files := parseGoFiles(t, ".")
banned := map[string]string{
"errors": "use coreerr.E(op, msg, err) for package errors",
"github.com/pkg/errors": "use coreerr.E(op, msg, err) for package errors",
"errors": "use core.E(op, msg, err) from dappco.re/go/core",
"fmt": "use core.Sprintf/core.Sprint from dappco.re/go/core",
"path/filepath": "use core.Path*/PathGlob from dappco.re/go/core",
"github.com/pkg/errors": "use core.E(op, msg, err) from dappco.re/go/core",
"dappco.re/go/core/log": "use dappco.re/go/core directly (core.E, core.Wrap)",
}
for _, file := range files {

2
go.mod
View file

@ -3,7 +3,7 @@ module dappco.re/go/core/session
go 1.26.0
require (
dappco.re/go/core/log v0.1.0
dappco.re/go/core v0.8.0-alpha.1
github.com/stretchr/testify v1.11.1
)

4
go.sum
View file

@ -1,5 +1,5 @@
dappco.re/go/core/log v0.1.0 h1:pa71Vq2TD2aoEUQWFKwNcaJ3GBY8HbaNGqtE688Unyc=
dappco.re/go/core/log v0.1.0/go.mod h1:Nkqb8gsXhZAO8VLpx7B8i1iAmohhzqA20b9Zr8VUcJs=
dappco.re/go/core v0.8.0-alpha.1 h1:gj7+Scv+L63Z7wMxbJYHhaRFkHJo2u4MMPuUSv/Dhtk=
dappco.re/go/core v0.8.0-alpha.1/go.mod h1:f2/tBZ3+3IqDrg2F5F598llv0nmb/4gJVCFzM5geE4A=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

44
html.go
View file

@ -2,20 +2,18 @@
package session
import (
"fmt"
"html"
"os"
"strings"
"time"
coreerr "dappco.re/go/core/log"
"dappco.re/go/core"
)
// RenderHTML generates a self-contained HTML timeline from a session.
func RenderHTML(sess *Session, outputPath string) error {
f, err := os.Create(outputPath)
if err != nil {
return coreerr.E("RenderHTML", "create html", err)
return core.E("RenderHTML", "create html", err)
}
defer f.Close()
@ -31,7 +29,7 @@ func RenderHTML(sess *Session, outputPath string) error {
}
}
fmt.Fprintf(f, `<!DOCTYPE html>
f.WriteString(core.Sprintf(`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
@ -93,14 +91,14 @@ body { background: var(--bg); color: var(--fg); font-family: var(--font); font-s
shortID(sess.ID), shortID(sess.ID),
sess.StartTime.Format("2006-01-02 15:04:05"),
formatDuration(duration),
toolCount)
toolCount))
if errorCount > 0 {
fmt.Fprintf(f, `
<span class="err">%d errors</span>`, errorCount)
f.WriteString(core.Sprintf(`
<span class="err">%d errors</span>`, errorCount))
}
fmt.Fprintf(f, `
f.WriteString(`
</div>
</div>
<div class="search">
@ -119,7 +117,7 @@ body { background: var(--bg); color: var(--fg); font-family: var(--font); font-s
var i int
for evt := range sess.EventsSeq() {
toolClass := strings.ToLower(evt.Tool)
toolClass := core.Lower(evt.Tool)
if evt.Type == "user" {
toolClass = "user"
} else if evt.Type == "assistant" {
@ -152,7 +150,7 @@ body { background: var(--bg); color: var(--fg); font-family: var(--font); font-s
durStr = formatDuration(evt.Duration)
}
fmt.Fprintf(f, `<div class="event%s" data-type="%s" data-tool="%s" data-text="%s" id="evt-%d">
f.WriteString(core.Sprintf(`<div class="event%s" data-type="%s" data-tool="%s" data-text="%s" id="evt-%d">
<div class="event-header" onclick="toggle(%d)">
<span class="arrow">&#9654;</span>
<span class="time">%s</span>
@ -166,7 +164,7 @@ body { background: var(--bg); color: var(--fg); font-family: var(--font); font-s
errorClass,
evt.Type,
evt.Tool,
html.EscapeString(strings.ToLower(evt.Input+" "+evt.Output)),
html.EscapeString(core.Lower(evt.Input+" "+evt.Output)),
i,
i,
evt.Timestamp.Format("15:04:05"),
@ -174,7 +172,7 @@ body { background: var(--bg); color: var(--fg); font-family: var(--font); font-s
html.EscapeString(toolLabel),
html.EscapeString(truncate(evt.Input, 120)),
durStr,
statusIcon)
statusIcon))
if evt.Input != "" {
label := "Command"
@ -187,8 +185,8 @@ body { background: var(--bg); color: var(--fg); font-family: var(--font); font-s
} else if evt.Tool == "Edit" || evt.Tool == "Write" {
label = "File"
}
fmt.Fprintf(f, ` <div class="section"><div class="label">%s</div><pre>%s</pre></div>
`, label, html.EscapeString(evt.Input))
f.WriteString(core.Sprintf(` <div class="section"><div class="label">%s</div><pre>%s</pre></div>
`, label, html.EscapeString(evt.Input)))
}
if evt.Output != "" {
@ -196,17 +194,17 @@ body { background: var(--bg); color: var(--fg); font-family: var(--font); font-s
if !evt.Success {
outClass = "output err"
}
fmt.Fprintf(f, ` <div class="section"><div class="label">Output</div><pre class="%s">%s</pre></div>
`, outClass, html.EscapeString(evt.Output))
f.WriteString(core.Sprintf(` <div class="section"><div class="label">Output</div><pre class="%s">%s</pre></div>
`, outClass, html.EscapeString(evt.Output)))
}
fmt.Fprint(f, ` </div>
f.WriteString(` </div>
</div>
`)
i++
}
fmt.Fprint(f, `</div>
f.WriteString(`</div>
<script>
function toggle(i) {
document.getElementById('evt-'+i).classList.toggle('open');
@ -250,13 +248,13 @@ func shortID(id string) string {
func formatDuration(d time.Duration) string {
if d < time.Second {
return fmt.Sprintf("%dms", d.Milliseconds())
return core.Sprintf("%dms", d.Milliseconds())
}
if d < time.Minute {
return fmt.Sprintf("%.1fs", d.Seconds())
return core.Sprintf("%.1fs", d.Seconds())
}
if d < time.Hour {
return fmt.Sprintf("%dm%ds", int(d.Minutes()), int(d.Seconds())%60)
return core.Sprintf("%dm%ds", int(d.Minutes()), int(d.Seconds())%60)
}
return fmt.Sprintf("%dh%dm", int(d.Hours()), int(d.Minutes())%60)
return core.Sprintf("%dh%dm", int(d.Hours()), int(d.Minutes())%60)
}

View file

@ -4,17 +4,15 @@ package session
import (
"bufio"
"encoding/json"
"fmt"
"io"
"iter"
"maps"
"os"
"path/filepath"
"slices"
"strings"
"time"
coreerr "dappco.re/go/core/log"
"dappco.re/go/core"
)
// maxScannerBuffer is the maximum line length the scanner will accept.
@ -128,15 +126,12 @@ func ListSessions(projectsDir string) ([]Session, error) {
// ListSessionsSeq returns an iterator over all sessions found in the Claude projects directory.
func ListSessionsSeq(projectsDir string) iter.Seq[Session] {
return func(yield func(Session) bool) {
matches, err := filepath.Glob(filepath.Join(projectsDir, "*.jsonl"))
if err != nil {
return
}
matches := core.PathGlob(core.Concat(projectsDir, "/", "*.jsonl"))
var sessions []Session
for _, path := range matches {
base := filepath.Base(path)
id := strings.TrimSuffix(base, ".jsonl")
base := core.PathBase(path)
id := core.TrimSuffix(base, ".jsonl")
info, err := os.Stat(path)
if err != nil {
@ -204,10 +199,7 @@ func ListSessionsSeq(projectsDir string) iter.Seq[Session] {
// PruneSessions deletes session files in the projects directory that were last
// modified more than maxAge ago. Returns the number of files deleted.
func PruneSessions(projectsDir string, maxAge time.Duration) (int, error) {
matches, err := filepath.Glob(filepath.Join(projectsDir, "*.jsonl"))
if err != nil {
return 0, coreerr.E("PruneSessions", "list sessions", err)
}
matches := core.PathGlob(core.Concat(projectsDir, "/", "*.jsonl"))
var deleted int
now := time.Now()
@ -238,11 +230,11 @@ func (s *Session) IsExpired(maxAge time.Duration) bool {
// FetchSession retrieves a session by ID from the projects directory.
// It ensures the ID does not contain path traversal characters.
func FetchSession(projectsDir, id string) (*Session, *ParseStats, error) {
if strings.Contains(id, "..") || strings.ContainsAny(id, `/\`) {
return nil, nil, coreerr.E("FetchSession", "invalid session id", nil)
if core.Contains(id, "..") || strings.ContainsAny(id, `/\`) {
return nil, nil, core.E("FetchSession", "invalid session id", nil)
}
path := filepath.Join(projectsDir, id+".jsonl")
path := core.Concat(projectsDir, "/", id, ".jsonl")
return ParseTranscript(path)
}
@ -251,12 +243,12 @@ func FetchSession(projectsDir, id string) (*Session, *ParseStats, error) {
func ParseTranscript(path string) (*Session, *ParseStats, error) {
f, err := os.Open(path)
if err != nil {
return nil, nil, coreerr.E("ParseTranscript", "open transcript", err)
return nil, nil, core.E("ParseTranscript", "open transcript", err)
}
defer f.Close()
base := filepath.Base(path)
id := strings.TrimSuffix(base, ".jsonl")
base := core.PathBase(path)
id := core.TrimSuffix(base, ".jsonl")
sess, stats, err := parseFromReader(f, id)
if sess != nil {
@ -302,7 +294,7 @@ func parseFromReader(r io.Reader, id string) (*Session, *ParseStats, error) {
stats.TotalLines++
raw := scanner.Text()
if strings.TrimSpace(raw) == "" {
if core.Trim(raw) == "" {
continue
}
@ -317,14 +309,14 @@ func parseFromReader(r io.Reader, id string) (*Session, *ParseStats, error) {
preview = preview[:100]
}
stats.Warnings = append(stats.Warnings,
fmt.Sprintf("line %d: skipped (bad JSON): %s", lineNum, preview))
core.Sprintf("line %d: skipped (bad JSON): %s", lineNum, preview))
lastLineFailed = true
continue
}
ts, err := time.Parse(time.RFC3339Nano, entry.Timestamp)
if err != nil {
stats.Warnings = append(stats.Warnings, fmt.Sprintf("line %d: bad timestamp %q: %v", lineNum, entry.Timestamp, err))
stats.Warnings = append(stats.Warnings, core.Sprintf("line %d: bad timestamp %q: %v", lineNum, entry.Timestamp, err))
continue
}
@ -339,19 +331,19 @@ func parseFromReader(r io.Reader, id string) (*Session, *ParseStats, error) {
case "assistant":
var msg rawMessage
if err := json.Unmarshal(entry.Message, &msg); err != nil {
stats.Warnings = append(stats.Warnings, fmt.Sprintf("line %d: failed to unmarshal assistant message: %v", lineNum, err))
stats.Warnings = append(stats.Warnings, core.Sprintf("line %d: failed to unmarshal assistant message: %v", lineNum, err))
continue
}
for i, raw := range msg.Content {
var block contentBlock
if err := json.Unmarshal(raw, &block); err != nil {
stats.Warnings = append(stats.Warnings, fmt.Sprintf("line %d block %d: failed to unmarshal content: %v", lineNum, i, err))
stats.Warnings = append(stats.Warnings, core.Sprintf("line %d block %d: failed to unmarshal content: %v", lineNum, i, err))
continue
}
switch block.Type {
case "text":
if text := strings.TrimSpace(block.Text); text != "" {
if text := core.Trim(block.Text); text != "" {
sess.Events = append(sess.Events, Event{
Timestamp: ts,
Type: "assistant",
@ -372,13 +364,13 @@ func parseFromReader(r io.Reader, id string) (*Session, *ParseStats, error) {
case "user":
var msg rawMessage
if err := json.Unmarshal(entry.Message, &msg); err != nil {
stats.Warnings = append(stats.Warnings, fmt.Sprintf("line %d: failed to unmarshal user message: %v", lineNum, err))
stats.Warnings = append(stats.Warnings, core.Sprintf("line %d: failed to unmarshal user message: %v", lineNum, err))
continue
}
for i, raw := range msg.Content {
var block contentBlock
if err := json.Unmarshal(raw, &block); err != nil {
stats.Warnings = append(stats.Warnings, fmt.Sprintf("line %d block %d: failed to unmarshal content: %v", lineNum, i, err))
stats.Warnings = append(stats.Warnings, core.Sprintf("line %d block %d: failed to unmarshal content: %v", lineNum, i, err))
continue
}
@ -405,7 +397,7 @@ func parseFromReader(r io.Reader, id string) (*Session, *ParseStats, error) {
}
case "text":
if text := strings.TrimSpace(block.Text); text != "" {
if text := core.Trim(block.Text); text != "" {
sess.Events = append(sess.Events, Event{
Timestamp: ts,
Type: "user",
@ -432,7 +424,7 @@ func parseFromReader(r io.Reader, id string) (*Session, *ParseStats, error) {
if stats.OrphanedToolCalls > 0 {
for id := range pendingTools {
stats.Warnings = append(stats.Warnings,
fmt.Sprintf("orphaned tool call: %s", id))
core.Sprintf("orphaned tool call: %s", id))
}
}
@ -462,12 +454,12 @@ func extractToolInput(toolName string, raw json.RawMessage) string {
case "Edit":
var inp editInput
if json.Unmarshal(raw, &inp) == nil {
return fmt.Sprintf("%s (edit)", inp.FilePath)
return core.Sprintf("%s (edit)", inp.FilePath)
}
case "Write":
var inp writeInput
if json.Unmarshal(raw, &inp) == nil {
return fmt.Sprintf("%s (%d bytes)", inp.FilePath, len(inp.Content))
return core.Sprintf("%s (%d bytes)", inp.FilePath, len(inp.Content))
}
case "Grep":
var inp grepInput
@ -476,7 +468,7 @@ func extractToolInput(toolName string, raw json.RawMessage) string {
if path == "" {
path = "."
}
return fmt.Sprintf("/%s/ in %s", inp.Pattern, path)
return core.Sprintf("/%s/ in %s", inp.Pattern, path)
}
case "Glob":
var inp globInput
@ -490,7 +482,7 @@ func extractToolInput(toolName string, raw json.RawMessage) string {
if desc == "" {
desc = truncate(inp.Prompt, 80)
}
return fmt.Sprintf("[%s] %s", inp.SubagentType, desc)
return core.Sprintf("[%s] %s", inp.SubagentType, desc)
}
}
@ -498,7 +490,7 @@ func extractToolInput(toolName string, raw json.RawMessage) string {
var m map[string]any
if json.Unmarshal(raw, &m) == nil {
parts := slices.Sorted(maps.Keys(m))
return strings.Join(parts, ", ")
return core.Join(", ", parts...)
}
return ""
@ -517,13 +509,13 @@ func extractResultContent(content any) string {
}
}
}
return strings.Join(parts, "\n")
return core.Join("\n", parts...)
case map[string]any:
if text, ok := v["text"].(string); ok {
return text
}
}
return fmt.Sprintf("%v", content)
return core.Sprintf("%v", content)
}
func truncate(s string, max int) string {

View file

@ -3,10 +3,10 @@ package session
import (
"iter"
"path/filepath"
"slices"
"strings"
"time"
"dappco.re/go/core"
)
// SearchResult represents a match found in a session transcript.
@ -25,12 +25,9 @@ func Search(projectsDir, query string) ([]SearchResult, error) {
// SearchSeq returns an iterator over search results matching the query across all sessions.
func SearchSeq(projectsDir, query string) iter.Seq[SearchResult] {
return func(yield func(SearchResult) bool) {
matches, err := filepath.Glob(filepath.Join(projectsDir, "*.jsonl"))
if err != nil {
return
}
matches := core.PathGlob(core.Concat(projectsDir, "/", "*.jsonl"))
query = strings.ToLower(query)
query = core.Lower(query)
for _, path := range matches {
sess, _, err := ParseTranscript(path)
@ -42,8 +39,8 @@ func SearchSeq(projectsDir, query string) iter.Seq[SearchResult] {
if evt.Type != "tool_use" {
continue
}
text := strings.ToLower(evt.Input + " " + evt.Output)
if strings.Contains(text, query) {
text := core.Lower(evt.Input + " " + evt.Output)
if core.Contains(text, query) {
matchCtx := evt.Input
if matchCtx == "" {
matchCtx = truncate(evt.Output, 120)

View file

@ -2,31 +2,30 @@
package session
import (
"fmt"
"os"
"os/exec"
"strings"
coreerr "dappco.re/go/core/log"
"dappco.re/go/core"
)
// RenderMP4 generates an MP4 video from session events using VHS (charmbracelet).
func RenderMP4(sess *Session, outputPath string) error {
if _, err := exec.LookPath("vhs"); err != nil {
return coreerr.E("RenderMP4", "vhs not installed (go install github.com/charmbracelet/vhs@latest)", nil)
return core.E("RenderMP4", "vhs not installed (go install github.com/charmbracelet/vhs@latest)", nil)
}
tape := generateTape(sess, outputPath)
tmpFile, err := os.CreateTemp("", "session-*.tape")
if err != nil {
return coreerr.E("RenderMP4", "create tape", err)
return core.E("RenderMP4", "create tape", err)
}
defer os.Remove(tmpFile.Name())
if _, err := tmpFile.WriteString(tape); err != nil {
tmpFile.Close()
return coreerr.E("RenderMP4", "write tape", err)
return core.E("RenderMP4", "write tape", err)
}
tmpFile.Close()
@ -34,16 +33,16 @@ func RenderMP4(sess *Session, outputPath string) error {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return coreerr.E("RenderMP4", "vhs render", err)
return core.E("RenderMP4", "vhs render", err)
}
return nil
}
func generateTape(sess *Session, outputPath string) string {
var b strings.Builder
b := core.NewBuilder()
b.WriteString(fmt.Sprintf("Output %s\n", outputPath))
b.WriteString(core.Sprintf("Output %s\n", outputPath))
b.WriteString("Set FontSize 16\n")
b.WriteString("Set Width 1400\n")
b.WriteString("Set Height 800\n")
@ -57,7 +56,7 @@ func generateTape(sess *Session, outputPath string) string {
if len(id) > 8 {
id = id[:8]
}
b.WriteString(fmt.Sprintf("Type \"# Session %s | %s\"\n",
b.WriteString(core.Sprintf("Type \"# Session %s | %s\"\n",
id, sess.StartTime.Format("2006-01-02 15:04")))
b.WriteString("Enter\n")
b.WriteString("Sleep 2s\n")
@ -75,7 +74,7 @@ func generateTape(sess *Session, outputPath string) string {
continue
}
// Show the command
b.WriteString(fmt.Sprintf("Type %q\n", "$ "+cmd))
b.WriteString(core.Sprintf("Type %q\n", "$ "+cmd))
b.WriteString("Enter\n")
// Show abbreviated output
@ -88,7 +87,7 @@ func generateTape(sess *Session, outputPath string) string {
if line == "" {
continue
}
b.WriteString(fmt.Sprintf("Type %q\n", line))
b.WriteString(core.Sprintf("Type %q\n", line))
b.WriteString("Enter\n")
}
}
@ -104,14 +103,14 @@ func generateTape(sess *Session, outputPath string) string {
b.WriteString("\n")
case "Read", "Edit", "Write":
b.WriteString(fmt.Sprintf("Type %q\n",
fmt.Sprintf("# %s: %s", evt.Tool, truncate(evt.Input, 80))))
b.WriteString(core.Sprintf("Type %q\n",
core.Sprintf("# %s: %s", evt.Tool, truncate(evt.Input, 80))))
b.WriteString("Enter\n")
b.WriteString("Sleep 500ms\n")
case "Task":
b.WriteString(fmt.Sprintf("Type %q\n",
fmt.Sprintf("# Agent: %s", truncate(evt.Input, 80))))
b.WriteString(core.Sprintf("Type %q\n",
core.Sprintf("# Agent: %s", truncate(evt.Input, 80))))
b.WriteString("Enter\n")
b.WriteString("Sleep 1s\n")
}