Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Replace self-update with local history; rename apiclient to transport#16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| package cli | ||
| import ( | ||
| "flag" | ||
| "fmt" | ||
| "os" | ||
| "time" | ||
| "github.com/abstraction-dev/cli/internal/config" | ||
| "github.com/abstraction-dev/cli/internal/history" | ||
| "github.com/abstraction-dev/cli/internal/render" | ||
| ) | ||
| // historyListDefault is how many entries `abstr history` shows without -n. | ||
| const historyListDefault = 20 | ||
| // runHistory inspects or clears the locally stored exchanges. | ||
| func runHistory(args []string) int { | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Data loss — Arguments after the action are silently ignored, so Explain · Fix in Claude Code · Fix in Codex Copy for agent | ||
| fs := flag.NewFlagSet("abstr history", flag.ContinueOnError) | ||
| fs.SetOutput(os.Stderr) | ||
| var configPath string | ||
| var limit int | ||
| fs.StringVar(&configPath, "config", "", "config file path") | ||
| fs.IntVar(&limit, "n", historyListDefault, "how many entries to show") | ||
| if err := fs.Parse(args); err != nil { | ||
| return exitUsage | ||
| } | ||
| cfg, err := config.Load(configPath) | ||
| if err != nil { | ||
| fmt.Fprintln(os.Stderr, "abstr: "+err.Error()) | ||
| return exitRuntime | ||
| } | ||
| store, err := openHistory(cfg) | ||
| if err != nil { | ||
| fmt.Fprintln(os.Stderr, "abstr: "+err.Error()) | ||
| return exitRuntime | ||
| } | ||
| r := newRenderer() | ||
| action := "list" | ||
| if rest := fs.Args(); len(rest) > 0 { | ||
| action = rest[0] | ||
| } | ||
| switch action { | ||
| case "list": | ||
| return listHistory(store, r, limit) | ||
| case "path": | ||
| fmt.Println(store.FilePath()) | ||
| return exitOK | ||
| case "clear": | ||
| if err := store.Clear(); err != nil { | ||
| r.Error("abstr: " + err.Error()) | ||
| return exitRuntime | ||
| } | ||
| r.Success("History cleared.") | ||
| return exitOK | ||
| default: | ||
| fmt.Fprintln(os.Stderr, "unknown history command: "+action) | ||
| return exitUsage | ||
| } | ||
| } | ||
| // listHistory prints the newest entries, one row each: when, workspace, and the | ||
| // question collapsed to the terminal width. | ||
| func listHistory(store *history.Store, r *render.Renderer, limit int) int { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logic error — The fixed 32-column prefix allowance undercounts non-UTC RFC3339 timestamps, causing long history rows to exceed the terminal width. Explain · Fix in Claude Code · Fix in Codex Copy for agent | ||
| entries, err := store.Recent(limit) | ||
| if err != nil { | ||
| r.Error("abstr: " + err.Error()) | ||
| return exitRuntime | ||
| } | ||
| if len(entries) == 0 { | ||
| r.Info("No history yet.") | ||
| return exitOK | ||
| } | ||
| width := render.TermWidth(os.Stdout) - 32 | ||
| for _, e := range entries { | ||
| fmt.Printf("%s %s %s\n", | ||
| e.AskedAt.Local().Format(time.RFC3339), | ||
| shortWorkspace(e.Workspace), | ||
| e.Headline(width)) | ||
| } | ||
| return exitOK | ||
| } | ||
| // openHistory returns the history store sized by configuration. | ||
| func openHistory(cfg *config.Config) (*history.Store, error) { | ||
| return history.Open(cfg.HistoryLimitResolved()) | ||
| } | ||
| // shortWorkspace trims a workspace slug to its leading segment, which is enough | ||
| // to tell rows apart without spending a full UUID per line. | ||
| func shortWorkspace(slug string) string { | ||
| if len(slug) <= 8 { | ||
| return slug | ||
| } | ||
| return slug[:8] | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data loss —
runHistoryTrailing positional arguments are ignored, so a malformed
history clear ...invocation still deletes history instead of returning a usage error.Explain · Fix in Claude Code · Fix in Codex
Copy for agent