Microsoft Intelligent Terminal & Shell Integration Guide
Modern terminal emulators—including Microsoft Windows Terminal, VS Code Integrated Terminal, iTerm2, and WezTerm—have evolved beyond simple character displays into Intelligent Terminals. By emitting standard OSC 133 semantic escape sequences, shells can inform the terminal boundary exactly where prompts start, where user input begins, where program execution starts, and what status code a command returned upon completion.
Starting with v1.8.0, isA_CLI (isa and aix) provides native cross-shell hook instrumentation (isa hook <bash|zsh|pwsh>) and terminal co-pilot capabilities (isa explain and isa fix), enabling frictionless automated error diagnosis, AST codebase symbol resolution, and safe failure remediation.
1. The OSC 133 Semantic Escape Sequence Protocol
The OSC 133 standard defines escape sequences that structure raw terminal text streams into semantic operational zones:
| Escape Sequence | Marker Name | Meaning & Terminal Behavior |
|---|---|---|
\033]133;A\007 | Prompt Start | Marks the beginning of the shell prompt line. |
\033]133;B\007 | Command Start | Marks the completion of the prompt and the beginning of user input. |
\033]133;C\007 | Output Start | Emitted when the user presses Enter and execution starts; marks the start of program output. |
\033]133;D;{code}\007 | Command Finished | Emitted immediately upon process exit, carrying the integer exit code (e.g. 0, 1, 127). |
Modern terminals leverage these escape markers to provide:
- One-Click Output Copying: Instantly select and copy only the command output without prompt clutter.
- Jump to Previous Command: Jump navigation (
Ctrl+Up/Ctrl+Down) between command boundaries. - Failure Highlighting: Red margin markers indicating commands that returned non-zero exit codes.
2. Shell Configuration & Installation
Generating and loading the hook into your interactive shell takes a single line in your shell initialization file:
Bash Configuration (~/.bashrc)
Add to the end of your ~/.bashrc:
# Enable isA shell integration & failure capture
eval "$(isa hook bash)"Zsh Configuration (~/.zshrc)
Add to the end of your ~/.zshrc:
# Enable isA shell integration & failure capture
eval "$(isa hook zsh)"PowerShell Configuration ($PROFILE)
Open your PowerShell profile (notepad $PROFILE) and append:
# Enable isA shell integration & failure capture
Invoke-Expression (& isa hook pwsh)Reload your current shell session (source ~/.bashrc, source ~/.zshrc, or open a new terminal tab) to activate the integration.
3. Terminal Co-Pilot in Action
When a command fails in your terminal, the shell hook asynchronously captures the failure state into ~/.isa/state/last_failure_<tty>.json without blocking your interactive prompt. You can immediately invoke isa explain or isa fix.
Scenario 1: Command Typo Auto-Recovery
Suppose you accidentally mistype a Git command:
$ gti status
gti: command not found (exit code 127)Run isa explain:
$ isa explain
Terminal: pts_2
Failed Command: gti status
Exit Code: 127 (Command Not Found)
Analysis: The executable 'gti' is not installed or not in system PATH.
Diagnosis: Did you mean 'git'?Run isa fix --apply to automatically correct and execute:
$ isa fix --apply
[AUTO-FIX] Detected CLI typo: 'gti' -> 'git'
Executing: git status
On branch main
Your branch is up to date with 'origin/main'.
nothing to commit, working tree cleanScenario 2: Codebase Failure with AST Symbol Resolution
Suppose an automated test fails due to a missing or renamed module attribute:
$ pytest tests/unit/test_billing.py
============================= FAILURES =============================
____________________________ test_invoice __________________________
def test_invoice():
> calc = billing_service.calculate_vat_rate(100.0)
E AttributeError: module 'billing_service' has no attribute 'calculate_vat_rate'
tests/unit/test_billing.py:14: AttributeError
====================== 1 failed in 0.42s ======================Run isa explain:
isa explainparses the traceback and extracts the candidate symbolcalculate_vat_rate.- It queries the SQLite AST symbol index (
.isa/cache/symbols.db) generated byCodebaseASTIndexer. - It finds that
billing_service.pydefinescalculate_vat_amount(amount: float) -> float.
$ isa explain
Terminal: pts_1
Failed Command: pytest tests/unit/test_billing.py
Exit Code: 1 (Verification Failed)
Symbol Resolution:
Target: billing_service.calculate_vat_rate
Closest AST Match: def calculate_vat_amount(amount: float) -> float
Defined at: src/services/billing_service.py:32
Diagnosis: Symbol 'calculate_vat_rate' not found in module 'billing_service'.
Found matching definition 'calculate_vat_amount' at line 32.Run isa fix to inspect the suggested intra-line word diff:
$ isa fix
Recommended Remediation:
--- tests/unit/test_billing.py
+++ tests/unit/test_billing.py
@@ -14,1 +14,1 @@
- calc = billing_service.calculate_vat_rate(100.0)
+ calc = billing_service.calculate_vat_amount(100.0)
Apply this fix? Run 'isa fix --apply'4. Multi-Tab Terminal Isolation
In modern workflows, developers frequently operate multiple terminal tabs or split panes simultaneously. Without rigorous session isolation, a failure in Tab 1 could erroneously trigger a fix in Tab 2.
isA_CLI resolves this via strict TTY sanitization:
- The active terminal device (
os.ttyname(),$TTY,$GPG_TTY, or$SSH_TTY) is captured for each command. - Paths are sanitized using
sanitize_tty:/dev/pts/2$\rightarrow$pts_2/dev/tty1$\rightarrow$tty1- Non-alphanumeric or path-traversal inputs $\rightarrow$ stripped or converted to safe identifiers.
- Each terminal tab writes to its own isolated failure file:
- Tab 1:
~/.isa/state/last_failure_pts_1.json - Tab 2:
~/.isa/state/last_failure_pts_2.json
- Tab 1:
- When running
isa explainorisa fix, the command automatically inspects the caller’s specific TTY, ensuring zero cross-tab contamination.
5. Security & Safety Hardening
Because automated remediation can execute shell commands or patch source code, isa fix implements rigorous security guardrails:
- Strict POSIX Permissions:
- Directory
~/.isa/state/is created with mode0700(rwx------). - Failure records are written atomically with mode
0600(rw-------). - Only the current operating system user can read or write terminal failure state.
- Directory
- Dangerous Command Refusal:
- The remediation engine strictly refuses to suggest or execute dangerous commands:
- Piped shell executions:
| sh,| bash,| sudo sh - Redirection overwriting system roots:
> /,>> /etc/ - Destructive recursive deletions:
rm -rf /,rm -r *
- Piped shell executions:
- When a dangerous pattern is detected,
isa fixdisplays:[WARNING] Refused: Operation is dangerous or ambiguous. Cannot apply fix safely.
- The remediation engine strictly refuses to suggest or execute dangerous commands:
- Preview by Default:
- Running
isa fixwithout--apply(or-y) strictly previews the proposed changes without modifying disk files or executing shell actions.
- Running