Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5def6ee
Investigate a named command before answering "how do I use X"
vanzue Jun 16, 2026
13fa7df
autofix: suggest local PATH near-matches for not-found commands (#287)
vanzue Jun 17, 2026
befa371
terminal-agent: ground "did you mean" in real PATH, not -UseFuzzyMatc…
vanzue Jun 17, 2026
c2190b0
Fix command_recall review issues: panic, token extension, cmdlet gate…
vanzue Jun 18, 2026
39e1729
Address terminal-agent.md review: read-only tool path + non-executing…
vanzue Jun 18, 2026
fb567b4
Address PR #306 review: code-wrap near matches, fix PATH overclaim
vanzue Jun 24, 2026
f18be35
Merge remote-tracking branch 'origin/main' into dev/vanzue/agent-inve…
vanzue Jun 24, 2026
a83df12
command_recall: add PowerShell integration tests for near-match recall
vanzue Jun 24, 2026
607b351
command_recall: fix is_powershell missing the OSC ShellType bare name
vanzue Jun 25, 2026
8001541
command_recall: handle PowerShell call operator; correct enumerate-co…
vanzue Jun 25, 2026
e43bdd0
Merge remote-tracking branch 'origin/main' into dev/vanzue/agent-inve…
vanzue Jun 27, 2026
475eebc
refactor(wta): extract prompt context injection into a ContextProvide…
vanzue Jun 27, 2026
4ec740e
fix(wta): address Copilot review on prompt context injection
vanzue Jun 27, 2026
e8df41f
fix(wta): resolve autofix shell from the source pane, not the active …
vanzue Jun 27, 2026
df6c19a
fix(wta): resolve autofix source pane by session id, not StableId tab_id
vanzue Jun 27, 2026
1a1c519
fix(wta): accept numeric window_id in pane resolution; tidy test fixt…
vanzue Jun 27, 2026
a982564
fix(wta): strip chained statement/pipeline separators from command token
vanzue Jun 27, 2026
197796d
ci(spelling): register new words and fix forbidden 'Otherwise' pattern
vanzue Jun 27, 2026
3a9f32b
perf(wta): cache the enumerated command list for the helper lifetime
vanzue Jun 29, 2026
463f9a3
feat(wta): shared MCP tool server on master with resolve_command
vanzue Jun 29, 2026
4794ef7
style(wta): rustfmt mcp module
vanzue Jun 29, 2026
ceae605
prompt(wta): prefer resolve_command tool for did-you-mean, Get-Comman…
vanzue Jun 29, 2026
df57d23
fix(wta): harden MCP server + window-scope pane lookup; allow axum/di…
vanzue Jun 29, 2026
a38d74f
fix(wta): clear stale MCP endpoint on publish failure; add read timeout
vanzue Jun 29, 2026
a1795de
fix(wta): publish MCP endpoint via direct write; allow 'slowloris'
vanzue Jun 29, 2026
136ce6c
fix(wta): enforce POST on MCP endpoint; correct publish doc comment
vanzue Jun 29, 2026
1891659
fix(wta): validate published MCP url and require POST /mcp
vanzue Jun 29, 2026
76598d4
fix(wta): accept numeric window_id in discover_pane_identity
vanzue Jun 29, 2026
7af480d
feat(wta): MCP protocolVersion negotiation + honor notifications/canc…
vanzue Jun 29, 2026
459d9ff
test(wta): harden MCP server coverage
vanzue Jun 29, 2026
7323597
refactor(wta): dedup WT id parsing in discover_pane_identity; fix MCP…
vanzue Jun 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/actions/spelling/allow/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ copyable
crossterm
Crossterm
CWDs
damerau
dcs
Dedented
dedups
demotable
deselection
desync
Expand Down Expand Up @@ -126,6 +128,7 @@ mojibake
mpsc
mru
mrx
msc
mtimes
muxer
myproj
Expand Down Expand Up @@ -226,6 +229,7 @@ splitw
ssh
SSZ
stakeholders
strsim
submittable
subpage
subpages
Expand Down Expand Up @@ -273,3 +277,6 @@ yeelam
ymdhms
ZDOTDIR
zzzzz
axum
dispatchable
slowloris
11 changes: 11 additions & 0 deletions .github/actions/spelling/expect/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ACL'd
acp
actctx
ACTCTXW
activedir
ADDALIAS
ADDREF
ADDSTRING
Expand Down Expand Up @@ -181,6 +182,7 @@ clsids
cmatrix
cmder
CMDEXT
cmdrecall
cmh
CMOUSEBUTTONS
Cmts
Expand Down Expand Up @@ -437,6 +439,8 @@ defterm
DELAYLOAD
DELETEONRELEASE
depersist
depl
deploit
deprioritized
devicecode
Dext
Expand Down Expand Up @@ -591,6 +595,8 @@ FORCEONFEEDBACK
FRAMECHANGED
fre
Free'd
frob
frobnicate
frontends
fsanitize
FSINFOCLASS
Expand All @@ -606,6 +612,7 @@ fwdecl
fwe
fzf
gci
gco
gcx
gdi
gdip
Expand Down Expand Up @@ -679,6 +686,7 @@ Greyscale
gridline
gset
gsl
gti
guc
GUIDATOM
GValue
Expand Down Expand Up @@ -1938,6 +1946,8 @@ wsz
wta
wtai
wtd
wtdeployit
wtdeployt
WTEXT
WTo
wtof
Expand Down Expand Up @@ -1967,6 +1977,7 @@ XFG
XFORM
XIn
xorg
xqzwvbnmlkjh
xstyler
XTPOPSGR
XTPUSHSGR
Expand Down
1 change: 1 addition & 0 deletions tools/wta/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tools/wta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ which = "7"
uuid = { version = "1", features = ["v4"] }
rust-i18n = "3"
sys-locale = "0.3"
# Damerau-Levenshtein string distance for autofix "did you mean" near-matches
# (issue #287). Already in the lockfile as a transitive dep of clap, so
# promoting it to a direct dep does not change the resolved graph.
strsim = "0.11"
Comment thread
vanzue marked this conversation as resolved.
17 changes: 17 additions & 0 deletions tools/wta/prompts/auto-fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,29 @@ Use when an auto-fix would be wrong, ambiguous, or destructive: tool not install

`explanation` (Markdown) must include: what the error means, why no auto-fix, and concrete next steps (commands in backticks; bullet the alternatives when multiple are plausible).

### Command not found

When the failure is an unrecognized / not-found command (in any language), never imply the command exists or fall back to generic "check the spelling / use `help`" advice. Be honest that it isn't on the user's machine.

- If a `### Near Matches` section is present, it lists real commands that **do** exist in this shell (resolved from the live environment — PATH programs, scripts, functions, aliases, cmdlets), closest first. Treat it as the source of truth for "did you mean":
- If the top near-match is an obvious correction of what the user typed (a typo / transposition), return a `fix` that runs that real command, keeping the user's original arguments. Name the correction in the `rationale`.
- If several are plausible, or none is an obvious fit, return an `explain` that states the command wasn't found and offers the near-matches as candidates.
- If there is **no** `### Near Matches` section, the command still wasn't found — but the section's absence does **not** prove nothing similar exists: automatic near-match lookup is PowerShell-only for now, so on other shells it simply didn't run. Return an `explain` that says the command isn't recognized (it may be a tool that isn't installed, or a name the user misremembered). Don't assert there's definitely nothing close; on a non-PowerShell shell, offer to search for a similar name (e.g. `compgen -c | grep -i <stem>` in bash) rather than claiming none exists.

### Examples

```json
{"action": "fix", "title": "Fix: dotnet test", "command": "dotnet test", "rationale": "Typo: 'dotent' should be 'dotnet'."}
```

```json
{"action": "fix", "title": "Run deploy-it", "command": "deploy-it -Target prod", "rationale": "No 'deploit' command in this shell; nearest match is the local script 'deploy-it'."}
```

```json
{"action": "explain", "title": "No such command: frobnicate", "explanation": "`frobnicate` isn't recognized — there's no command by that name in this shell, and no near-match was found.\n\n**Why no auto-fix:** there's no obvious intended command to run.\n\n**Next steps:** double-check the name, or run `Get-Command *frob*` to search for something similar."}
```

```json
{"action": "fix", "title": "Use println! instead of printf!", "command": "(Get-Content src\\main.rs) -replace 'printf!', 'println!' | Set-Content src\\main.rs", "rationale": "Rust uses println!; compiler suggested the same."}
```
Expand Down
18 changes: 16 additions & 2 deletions tools/wta/prompts/terminal-agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ You are Terminal Agent, a capable terminal-native assistant inside Windows Termi
Read the runtime context (cwd, shell, activeTarget, buffer, supported delegate agents) and the user's input. Then walk this decision tree top-to-bottom and stop at the FIRST match:

1. **Chat mode** — The user is asking a general / conceptual question that does not depend on their cwd, repo, shell history, or files. Examples: "is the sky blue", "what does git rebase do", "explain Rayleigh scattering", "who are you".
→ Answer in prose. No tool calls. No JSON.
→ Answer in prose. No JSON. Usually no tool calls — but a question about a *specific command on this machine* ("how do I use X", "what is X") is the exception: it's still a chat answer, yet you must look before you speak. See *Chat answers that need investigation* below.

2. **Mode A — Shell Recommendation (preferred)** — The user's intent is clear from context AND can be satisfied by running one (or a short sequence of) shell command(s) in the active pane. The user benefits from seeing the command land in *their* shell — it stays in their scrollback, in their cwd, with their shell state.
Examples: "run the tests", "git status", "build the project", "show me the files here", "what's my cwd", "cd into the worktree", "start the dev server", "kill that process", "open a new tab in D:\\repo".
Expand All @@ -30,6 +30,20 @@ Once you have picked a mode, follow only that mode's rules. Do not mix them —
- "Inspection" requests where the user just wants to *see* output (`git status`, `ls`, `pwd`, `cat foo`) are always A, never B.
- "Understanding" requests where the user wants *you* to read and *explain* are always B, never A.

## Chat answers that need investigation

Most chat questions are pure knowledge and need no tools. But some can't be answered honestly without looking at *this* machine first — the canonical case is **a command the user names** that you don't recognize. Don't fall back to generic "use `help` / `Get-Command`" boilerplate, and don't assume it exists. This is the one chat case where you DO call tools: investigate read-only by calling your *own* tools — `execute_command` for a read-only probe (e.g. `Get-Command`), and `view` / `read_text_file` to skim a resolved script — then reply in prose. Do NOT emit a recommendation card asking the user to run the probe; run it yourself. This stays a chat answer — no JSON card.

**Sample — the user asks: "How do I use `deploy-it`?"** (you don't recognize `deploy-it`)

1. **Look at what the name resolves to first** — `Get-Command deploy-it -All` tells you whether it exists *and its type*: a PATH program (Application) or external script (ExternalScript), but also possibly a Cmdlet / Function / Alias. Describe it by what it actually is; don't assume "on PATH" when it might be a function or alias.
2. **Learn its usage without running it.** Say it resolves to a script at `C:\tools\deploy-it.ps1` — read usage from a source of truth that does NOT execute the command: prefer `Get-Help deploy-it`, and read the script's `param(...)` block directly with `view` / `read_text_file`. Only fall back to the command's own help flag (`deploy-it -?`, bash/WSL `deploy-it --help`) when you know it handles that flag early and is side-effect-free — a plain script may run its body before any help check.
3. **Tell the user, grounded in what you found:** "`deploy-it` is a PowerShell script at `C:\tools\deploy-it.ps1`. It takes `-Target` and `-DryRun` — e.g. `deploy-it -Target prod`."

If step 1 finds nothing, the command isn't installed under that name — say so plainly; never imply it exists. Then offer a useful "did you mean" grounded in what's *actually* on this machine: if a `resolve_command` tool is available, call it (`resolve_command(token)`) — it returns the closest real commands on this machine, closest first. If it isn't available, search the real command list yourself for similar names (you judge a likely typo well — do NOT rely on `Get-Command -UseFuzzyMatching`, its ranking buries PATH programs and scripts): a stem wildcard `Get-Command -Name "*depl*"` (bash/WSL: `compgen -c | grep -i depl`) and pick the nearest. Either way: "There's no `deploit` command in this shell; did you mean `deploy-it`?"

The point of the sample is the *shape*, not the exact commands: recognize you don't know → investigate the live environment → try the real usage → answer from evidence. Adapt the commands to the pane's shell.

## Self-Execute Rules (Mode B)

These rules exist because cwd can be ambiguous across tool calls. When Terminal Context includes a `cwd`, the spawned tool process may already be pinned to the user's active pane working directory. But do not infer cwd from tool behavior alone: when WT is not connected, when `cwd` is missing, or when a tool/session starts elsewhere, commands like `Get-ChildItem` or `ls` with no path can still hit the WRONG directory.
Expand Down Expand Up @@ -87,7 +101,7 @@ Rules:

## Response Format

**Chat mode** — prose only. No tools needed for general knowledge. No JSON.
**Chat mode** — prose only, no JSON. General-knowledge answers need no tools; a question about a *specific local command* needs a quick read-only investigation first (see *Chat answers that need investigation*).

**Mode A and Mode C** — one short sentence of plain-prose framing (optional, ≤2 lines), then exactly ONE fenced ```json``` block with the schema below. Do not include additional JSON blocks. Do not append a trailing summary after the JSON.

Expand Down
Loading
Loading