-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add LLM-powered static documentation analysis with local testing support #77
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
Open
Copilot
wants to merge
13
commits into
main
Choose a base branch
from
copilot/implement-static-analysis-steps
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
52c6f6d
Initial plan
Copilot 9929aa8
Add core analyzer modules with comprehensive tests
Copilot 714623e
Add documentation, examples, and integration tests
Copilot 62e56ea
Fix analyzer import path in analyzer-api.js
Copilot a3d6cee
Add implementation summary document
Copilot 941ebbe
Add local LLM testing support with llama.cpp and Qwen2.5-0.5B
Copilot 1fe0207
Add quick reference guide for local LLM testing
Copilot 5f7265d
Add comprehensive testing and validation for local LLM integration
Copilot f91ed9a
Fix Windows test compatibility by using double quotes in test glob pa…
Copilot e762126
Update local-llm setup to use CMake build following Unsloth guide
Copilot ed13024
Transitioned to object generation
hawkeyexl 35e145b
Bug tweaks
hawkeyexl 1e95af6
Remove tagging
hawkeyexl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| # LLM Static Analysis Implementation Summary | ||
|
|
||
| ## Overview | ||
| This implementation adds AI-powered static documentation analysis to doc-detective/resolver, enabling automatic extraction of Doc Detective action steps from plain documentation text. | ||
|
|
||
| ## What Was Implemented | ||
|
|
||
| ### Core Modules | ||
|
|
||
| 1. **Document Parser** (`src/analyzer/document-parser.js`) | ||
| - Splits documents into analyzable segments (text and code blocks) | ||
| - Tracks line numbers for source attribution | ||
| - Identifies shell code blocks for command extraction | ||
| - Handles markdown code blocks and paragraph boundaries | ||
|
|
||
| 2. **Prompt Builder** (`src/analyzer/prompt-builder.js`) | ||
| - Constructs LLM prompts optimized for high recall | ||
| - Implements extraction philosophy with 5 key principles | ||
| - Detects relevant action types from content | ||
| - Includes relevant schemas in prompts | ||
| - Provides examples of action decomposition and conditional logic | ||
|
|
||
| 3. **LLM Provider** (`src/llm/provider.js`) | ||
| - Abstracts interactions with multiple LLM providers | ||
| - Supports Anthropic (Claude), Google (Gemini), and OpenAI (GPT-4) | ||
| - Uses Vercel AI SDK for unified interface | ||
| - Handles JSON response parsing and error cases | ||
|
|
||
| 4. **Post-Processor** (`src/analyzer/post-processor.js`) | ||
| - Adds defensive find actions before click/typeKeys | ||
| - Adds wait actions after submit/save operations | ||
| - Tags actions with source attribution | ||
| - Validates actions against doc-detective-common schemas | ||
|
|
||
| 5. **Main Analyzer** (`src/analyzer/index.js`) | ||
| - Orchestrates the complete analysis workflow | ||
| - Processes each segment through the LLM | ||
| - Aggregates results and generates summary statistics | ||
| - Handles errors gracefully per segment | ||
|
|
||
| 6. **Public API** (`src/analyzer-api.js`) | ||
| - Exports the `analyze()` function | ||
| - Loads schemas from doc-detective-common | ||
| - Simple interface for consumers | ||
|
|
||
| ### Testing | ||
|
|
||
| - **80 unit tests** covering all modules | ||
| - **100% pass rate** for all tests | ||
| - Tests for document parsing, prompt building, post-processing | ||
| - Integration test suite for manual validation with real APIs | ||
| - Example usage script demonstrating the feature | ||
|
|
||
| ### Documentation | ||
|
|
||
| - Updated README with: | ||
| - Feature overview | ||
| - Installation instructions | ||
| - Configuration examples for all providers | ||
| - Usage examples | ||
| - Response format documentation | ||
| - Advanced features explanation | ||
| - Limitations and best practices | ||
|
|
||
| - Added example script (`examples/analyzer-example.js`) | ||
| - Added integration test (`src/analyzer/integration.test.js`) | ||
|
|
||
| ### Dependencies Added | ||
|
|
||
| ```json | ||
| { | ||
| "ai": "^3.0.0", | ||
| "@ai-sdk/anthropic": "^0.0.x", | ||
| "@ai-sdk/google": "^0.0.x", | ||
| "@ai-sdk/openai": "^0.0.x" | ||
| } | ||
| ``` | ||
|
|
||
| All dependencies verified free of security vulnerabilities. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```javascript | ||
| const { analyze } = require('doc-detective-resolver'); | ||
|
|
||
| const result = await analyze( | ||
| 'Navigate to https://example.com and click Login', | ||
| { | ||
| provider: 'anthropic', | ||
| apiKey: process.env.ANTHROPIC_API_KEY | ||
| } | ||
| ); | ||
|
|
||
| console.log(`Extracted ${result.summary.totalActions} actions`); | ||
| ``` | ||
|
|
||
| ## Key Features | ||
|
|
||
| 1. **Multi-Provider Support**: Works with Anthropic, Google, and OpenAI | ||
| 2. **High-Recall Extraction**: Captures all possible actions, including implicit ones | ||
| 3. **Defensive Actions**: Automatically adds verification and wait steps | ||
| 4. **Source Attribution**: Tracks where each action came from | ||
| 5. **Schema Validation**: Ensures extracted actions are valid | ||
| 6. **Code Block Support**: Extracts shell commands from code blocks | ||
| 7. **Conditional Logic**: Handles if/then/else patterns | ||
|
|
||
| ## Security | ||
|
|
||
| - ✅ No vulnerabilities in dependencies | ||
| - ✅ CodeQL analysis passed (0 alerts) | ||
| - ✅ API keys handled via environment variables only | ||
| - ✅ No secrets committed to repository | ||
|
|
||
| ## Testing Results | ||
|
|
||
| - Total tests: 80 | ||
| - Passing: 80 | ||
| - Failing: 0 | ||
| - Coverage: All core modules tested | ||
|
|
||
| ## Files Added | ||
|
|
||
| ``` | ||
| src/ | ||
| ├── analyzer-api.js | ||
| ├── analyzer/ | ||
| │ ├── document-parser.js | ||
| │ ├── document-parser.test.js | ||
| │ ├── index.js | ||
| │ ├── integration.test.js | ||
| │ ├── post-processor.js | ||
| │ ├── post-processor.test.js | ||
| │ ├── prompt-builder.js | ||
| │ └── prompt-builder.test.js | ||
| └── llm/ | ||
| └── provider.js | ||
|
|
||
| examples/ | ||
| └── analyzer-example.js | ||
| ``` | ||
|
|
||
| ## Files Modified | ||
|
|
||
| - `package.json` - Added dependencies, updated test script | ||
| - `package-lock.json` - Locked new dependencies | ||
| - `src/index.js` - Exported analyze() function | ||
| - `README.md` - Added documentation | ||
| - `.gitignore` - Added example output files | ||
|
|
||
| ## Next Steps (Future Enhancements) | ||
|
|
||
| Not implemented in this PR (as per requirements): | ||
|
|
||
| - Interactive analysis with browser context | ||
| - Real-time action execution | ||
| - Action validation against live applications | ||
| - UI for reviewing/editing generated actions | ||
| - Integration with Doc Detective's test runner | ||
| - Batch processing API | ||
| - Custom action type definitions | ||
|
|
||
| ## Notes | ||
|
|
||
| - Implementation uses JavaScript (not TypeScript) to match existing codebase | ||
| - Follows existing code patterns and conventions | ||
| - Uses Mocha/Chai for testing (matching current setup) | ||
| - Integrates with doc-detective-common for schema validation | ||
| - All changes are minimal and focused on the feature requirements | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.