feat(ai): add ubiquitous prompt routing and richer AI context#18
Merged
feat(ai): add ubiquitous prompt routing and richer AI context#18
Conversation
- Add pre-parse AI shortcut support for 'dub PROMPT' and '--ai' - Add typo-guard handling with interactive/non-interactive behavior - Extend AI context with bounded redacted shell history - Add model-native browsing option with graceful fallback metadata - Persist invocation and browsing metadata in command history
There was a problem hiding this comment.
Pull request overview
Adds “AI shortcut” CLI routing so unknown top-level input can be treated as an AI prompt, and enriches AI runs with additional context/metadata (including shell history and browsing telemetry).
Changes:
- Introduces CLI arg preprocessing with typo-guard +
--aiforced AI prompt mode, and persists invocation metadata into history. - Extends AI context collection to include bounded, redacted recent shell history.
- Adds model-native web browsing provider options with graceful fallback, and expands config defaults/tests accordingly.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/shell-history.ts | New utility to read/parse recent zsh/bash history and redact sensitive fragments. |
| src/lib/shell-history.test.ts | Tests for zsh/bash parsing, bounding, and redaction. |
| src/lib/history.ts | Adds new optional metadata fields to history entries. |
| src/lib/history.test.ts | Validates new history metadata fields round-trip. |
| src/lib/config.ts | Adds new ai.* configuration defaults and normalizes nested config. |
| src/lib/config.test.ts | Updates default-config expectations. |
| src/lib/ai-shortcut.ts | New CLI preprocessing (AI shortcut fallback, typo guard, --ai forced mode). |
| src/lib/ai-shortcut.test.ts | Tests for shortcut routing and typo guard behavior. |
| src/lib/ai-context.ts | Adds recent shell history into AI context (configurable via options/config). |
| src/lib/ai-context.test.ts | Updates context expectations and injects shell history in tests. |
| src/index.ts | Hooks preprocessing into CLI startup; records invocation + browsing metadata in history. |
| src/commands/ai.ts | Adds web-browsing provider options + graceful fallback and returns browsing telemetry. |
| src/commands/ai.test.ts | Tests browsing provider options and graceful fallback behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Respect ai.shortcutFallback.enabled before applying fallback routing - Truncate and budget shell history before adding to AI context - Use bounded tail reads for shell history files to avoid full-file loads
1161e07 to
8bb09b4
Compare
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
dub PROMPT) and add forced--aimodeTest Plan