Skip to content

Commit

Permalink
Add alternative analysis logic (#345)
Browse files Browse the repository at this point in the history
* wip API stuff

* WIP examples

* Add lsp-analysis

* Fix linting issue

* Add extra information

* Follow imports

* Refactor findHono.ts

And split into multiple files

Also: introduce a SearchContext that contains most important references
(like the server, program, etc)

* Add collect more references

* Add back snapshots

* wip

* Add support for RouteTreeReferences

* Simplify logic & dedupe module dependencies

* Move SourceReferenceManager

* Undo changes to api

* Cleanup

* Use relative paths and add in id's

Also do a minor refactor

* Rename server.test to extract-tree test

* remove commented out code

* Add analyze function & hono-factory test case

* Fix linting for goose-quotes

* Add support for createApp/factory pattern

* Sort import for goose-quotes

* Format api

* Format lsp-analysis

* Fix biome ci linting complaints

* Update data structure

And fix app.route() where the route was imported (and aliased) from
another module

* Fix linting and re-anble tests

* quick commit

* Add support for rendering route related content

* Fix unit test

* Move resourceManager to the findHonoRoutes return

* Clean up

* Generate less code

* Use biome ci for linting

* Move test cases into src folder

* Move lsp-analysis to packages

And rename it to @fiberplane/source-analysis

Also: add a postinstall script that builds types and source-analysis
packages

This way people don't have to manually run the build steps of those
packageas

* Initial version working from api

* Add import-as testcase

And also:
* ensure order of the source references in the generated files
* add in imports to local files
* change to id's for module imports

* Streamline source-analysis api

* Fix minor issue and do some cleanup

* Improved handling of built-in modules

Also:
* add support for different methods (in generated hono app)
* change RouteEntry.method from string to limited set of values
* cleanup barrel test-case
* updated multiple test case to include a 'post' and test the generated
  app for support
* add more comments

* Simplify code changes

* Refactory: extract history -> source serializer

* Add comments & add some caching logic

* Add support for using `include` option tsconfig

* Fix build

And prefix private class properties with an underscore

* Feature: enabling ai without restart of studio

* Code cleanupp

* Remove previous implementation of expand-function

* Use consola for logging

with (prototype) custom formatter

* Brett logging

* Add a page for inspecting context shipped to AI calls

* Remove brett logger

* Enable custom logger for source-analysis package

* Use logger in more places

* Disallow console.log in the api

* Add readme and some further tweaks

* Format all the things!

* Start code analysis after logging user in

* Remove aiEnabled from settings

* Fix readme typescript example (syntax issue)

* Move code analysis setup to code-analysis lib

* Modify comment

* Update comment about the RoutesResult and possible race conditions

* Remove dead code

* Remove old vscode links utilities from studio

* Remove unused api route for finding source function from error

* Remove unused trace summarization utilities

* Remove studio api routes for looking up source code of functions

* Remove source function finder

* Remove acorn

* Delete dead file

* tweak readme

---------

Co-authored-by: Brett Beutell <brbeut@gmail.com>
  • Loading branch information
flenter and brettimus authored Nov 18, 2024
1 parent 9f08760 commit bb0c0e2
Show file tree
Hide file tree
Showing 149 changed files with 8,603 additions and 66,126 deletions.
4 changes: 4 additions & 0 deletions api/bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ function runScript(scriptName) {
return;
}

if (scriptName === "studio") {
logger.info(chalk.bold("\nTime Level Message"));
}

// Get the root directory of this script's project
const scriptDir = path.resolve(__dirname, "../");

Expand Down
22 changes: 22 additions & 0 deletions api/biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"extends": ["../biome.jsonc"],
"files": {
"ignore": ["dist", "node_modules"]
},
"overrides": [
{
"include": ["src"],
"linter": {
"enabled": true,
"rules": {
"suspicious": {
"noConsoleLog": {
"level": "warn"
}
}
}
}
}
]
}
5 changes: 5 additions & 0 deletions api/drizzle/0018_exotic_rafael_vega.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE `ai_request_logs` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`log` text NOT NULL,
`created_at` text DEFAULT (CURRENT_TIMESTAMP) NOT NULL
);
Loading

0 comments on commit bb0c0e2

Please sign in to comment.