Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Static analysis utilties to improve ai request generation (#291)
* Proof of concept of static analysis to expand function context for ai req gen * Wire up tests for static analysis with an example repo * Move expand-function tests to their own test file * Use logger in the expand-function module and also fix directory traversal * Return undefined if no value was found for expanded defn * Factor out helper for getting out-of-scope identifiers and add utiltiies for creating workspace/executeCommand rpc calls * Also analzy function expressions jic * Update followImport with a docstring explaining why it was used (and hopefully should not be anymore) * Add failing test for filtering out web standard globals from identifiers returned by static analysis * Filter out web standard globals from the identifiers returned by static analysis * Add a type guard for definition responses from tsserver * Remove dead code and shuffle some files * Fix type error * Refactor forEach * Comment out some debug logs * Refactor getDefinitionText to provide info on whether it returned a function * Add TODO for tomorrow * Terminate language server when process exits * Add janky test for recursively expanding out of scope vars ((needs work)) * Add tests for identifier analyzer and update its behavior for property accesses on out of scope vars * Update workers-types in static analysis test repo * Implement a singleton pattern for the typescript server instance (child process) and fix up some tests * Add some tests for a drizzlified codebase and handle pnpm packages properly when extracing package names * Update comment * Move search-function into a folder * Write some tests for search-file and search-function * Update comments and logs * Move out of scope identifier analysis out of searchFunction * Tidy up search-function tests * Add README * Fix typecheck on studio * Add docstring to expandFunction * Start ts language server process if ai is enabled * Resolve path that is passed to getTSServer * Ignore directories more aggresively when searching for function * Remove srcPath argument as it is unneeded * Recursively expand context * Improve some logging and make test-static-analysis runnable * Add a nontrivial column to db schema * Expand logger with trace level and account for reponening changed files in lang server * Add trace logging * Format * Implement absolutely unhinged method for mapping back to source function but it works * Add option to skip source map searches * Remove type from prompt * Document search-compiled-function * Make search-source-function async * Fix tests for async search file, and remove .trace logging * Format * Add link to Ades work in the README * Also expand middleware context * Do not serialize 3rd party functions into context * Update identifier analyzer to have a scope stack (broke property access logic however) * Fix issues with property access. Now start tackling inner scope issues * Fix inner scope issues * Break out unit tests to be more granular * Split out identifier analyzer into smaller unit tests (again) * Continue with identifier-analyzer tests * Add hacky solution for middleware source function detection issue * Fix expand-function tests except for the one on Drizzle schema expansion (schema.stuff) * Improve type-narrowing for functions passed to analyzeOutOfScopeIdentifiers * Add a test for the source map reader to cover case where certain middleware could not be mapped back * Add some comments * Implement source hints from hits from the source map * Update blurb about eslint * Set up tests for full file context * Expand entirety of imported file if we are dealing with namespace imports * Add middleware context to the qa tester propmt * Turn off noisy logs bit by bit and try to speed up context builder * Start optimizing source map lookups * More comments * Start refactoring findSourceFunction to handle batch lookups * Modify tests to handle batch lookups * Update some comments * Add performance boost * Cleanup * Move inference router to its own folder * Factor out handler and middleware expansion utilties from the inference route * Fix expand-handler test route * Add docstrings and clean up some code for getting source map and compiled index.js * Log when we terminate tsserver * Start renaming things to make more sense * Add back prefiltering of bearerAuth middleware * Clean up some debug logs and implement an explicict debug logging switch on expandFunction * Factor out extractPackage * Do not throw errors in inference handler if context expansion fails * Add better docstrings to expand-function * Get definition text of type assignments * Extract out FunctionContextTypes * Remove unnecessary any * Update docstring in identifierAnalyzer * Update context-for-import to use module resolution helper * No need for xml escaping * Remove comment * Update expand function README * Update find-source-function * Clean up expand-handler use of buildAiContext * Remove TODO comments by unknown types * Add changelog entry * Add helper is-dependency * Update find-source-function tests after more fiddling with the test-static-analysis codebase * Comment out debug logs * Remove debug logs * Comment out one more debug log
- Loading branch information