Repository navigation
feat(cli): add infer reset and infer insights commands - #1241
Merged
Merged
Conversation
Promote the /reset and /insights chat shortcuts to top-level commands so local runtime state can be wiped and sessions analyzed without a TUI. Both commands are thin wrappers over the existing shortcuts, dispatched through shortcuts.Run - the same non-TUI path headless uses - so neither reimplements any reset or insights logic. - infer reset previews, infer reset confirm wipes, infer reset insights analyzes first. The preview and confirm paths need no gateway or model. - infer insights [since] writes the report, with --model to pick the model. - ResetShortcut.UseCLISurface adapts the shortcut to the command line: the process-scoped confirm gate starts satisfied (two shell invocations are two processes and could never satisfy it) and the preview points at `infer reset confirm` instead of the slash command. - EnsureModel resolves --model then agent.model and validates it against the gateway before generating. A one-shot command inherits no model selection from a chat session, so without it the generator asked the gateway to analyze with an empty model.
edenreich
commented
Sep 18, 2026
Neither shortcut needs bespoke Go code now that `infer reset` and `infer insights` exist. Both become YAML files written to ~/.infer/shortcuts/ by `infer init`, wrapping the commands the way /export and /env already wrap `infer export` and `infer env` - so users can edit, re-point or delete them like any other shortcut. - Delete ResetShortcut and InsightsShortcut, their metadata registrations and their container registrations. The wipe moves into cmd/reset as plain functions; the InsightsGenerator stays and is reached through the new container accessor. - The preview/confirm arm gate goes with it: it guarded against a tab-completed /reset confirm in the TUI, and the TUI no longer executes Go code for /reset. `infer reset confirm` is deliberate on its own. - Vendored reset.yaml and insights.yaml declare subcommands by name only, so resolveCommandConfig appends the name to the parent's args. Spelling the full command out again would have run `infer reset reset confirm`; a test in cmd/init now pins that shape for both files. - A chat session running during a wipe keeps its in-memory conversation, so the command and the YAML comments both say to run /new or restart.
This was referenced Sep 18, 2026
Running `infer reset confirm` on a real machine left state behind and a skeleton of empty directories. - The persistent memory directory is now a wipe target, resolved through cfg.ResolveMemoryDir() so a memory.dir override is honored. A git-backed memory dir gets the same treatment remote stores already get: the local clone is cleared and the output says the remote syncs back on next run. - Per-project runtime dirs are deleted outright instead of being recreated empty. The project dir itself stays, since projects.yaml references it, so targets now splits into prune (deleted) and empty (deleted and recreated because they are fixed userspace locations). - A project whose working directory no longer exists is removed whole. The slug is the cwd with separators replaced by "-", which is ambiguous - /a/my-project and /a/my/project collide - and a wrong guess would delete a live project's state, so a slug counts as stale only when no reading of it resolves on disk. The search is pruned by the filesystem rather than enumerating 2^n splits. - Insights reads the MEMORY.md index as a third source, capped at memory.max_chars on a line boundary. The index is read rather than the fact files because it is already one line per fact, which keeps ingestion cheap; `/reset insights` runs before the wipe so the facts survive in the report. The report frontmatter gains memory_facts. projects.yaml is left alone: it belongs to the desktop app, stores project names rather than paths, and those names collide across repos, so no entry can be matched to a stale runtime dir safely.
Contributor
|
🎉 This PR is included in version 0.204.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Promotes the
/resetand/insightschat shortcuts to top-level commands, so local runtime state can be wiped and sessions analyzed without a TUI.The only non-TUI route today is
infer headless "/reset", which is the wrong entry point: headless boots the gateway container and lists models before it ever dispatches the shortcut, so wiping local state needed a working gateway. Andinfer headless "/reset confirm"silently did nothing, because the confirm gate is process-scoped.Both commands are thin wrappers dispatched through
shortcuts.Run— the same non-TUI path headless uses — so neither reimplements any reset or insights logic.Changes
cmd/reset— parent +confirm+insightssubcommands. Preview and confirm need no gateway and no model; onlyinsightsdoes.cmd/insights—infer insights [since]with--model/-m, and the sharedEnsureModelhelper thatinfer reset insightsreuses (same shape ascmd/init→cmd/migrate).ResetShortcut.UseCLISurface— adapts the shortcut to the command line. The preview gate starts satisfied (two shell invocations are two processes, so the 5-minute window could never be satisfied the way it is in the TUI), and the preview points atinfer reset confirminstead of the slash command. TUI output is unchanged.EnsureModel— resolves--modelthenagent.modeland validates againstListModelsbefore starting a generation. A one-shot command inherits no model selection from a chat session, so without this the generator asked the gateway to analyze with an empty model. Fails fast withno model specified; use --model or set agent.model in config.cmd/root, withcmd/root/root_test.gotopology updated.README.md, cross-references from the/resetand/insightsshortcut entries inREADME.mdanddocs/shortcuts-guide.md.Testing
task precommit:runandtask testpass.cmd/reset/reset_test.go— preview lists the seeded dirs and leaves them on disk;confirmempties them and leavesconfig.yamlalone.cmd/insights/insights_test.go— pins the no-model failure and the shared flag spelling.internal/presentation/shortcuts/reset_test.go.Verified against a throwaway
$HOME: preview leaves everything in place,confirmempties the runtime dirs whileconfig.yamlandskills/survive,infer reset bogusexits 1 with an unknown-command error, and both insights paths exit 1 on an unset model without touching the gateway.Notes
infer headless "/reset confirm"still only previews — same process-scoped gate. Left as is, sinceinfer reset confirmis now the supported entry point and teaching the generic headless dispatcher to special-case one shortcut's gate would be worse than the gap.