-
Notifications
You must be signed in to change notification settings - Fork 91
CodAIze Agent #2574
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
Merged
Merged
CodAIze Agent #2574
Changes from all commits
Commits
Show all changes
162 commits
Select commit
Hold shift + click to select a range
bec0a45
Chat interface for AI assistant
lshala 2d42e1b
Format
lshala 715219c
Update dependency io.ktor.plugin to v3.3.0 (#2412)
renovate[bot] 7722707
Update dependency com.charleskorn.kaml:kaml to v0.96.0 (#2430)
renovate[bot] 308495f
Update dependency @sveltejs/kit to v2.39.1 (#2429)
renovate[bot] b8c202c
Update CODEOWNERS (#2425)
konradweiss d9ac76f
Dokka v2 (#2413)
lshala a5a1799
Update dependency eslint-plugin-svelte to v3.12.4 (#2433)
renovate[bot] c779ba6
Update dependency @sveltejs/kit to v2.42.2 (#2432)
renovate[bot] 69092df
Update dependency com.vanniktech:gradle-maven-publish-plugin to v0.34…
renovate[bot] 13b4c00
Moving `group` back to `allprojects` (#2435)
oxisto bfd3eb3
Update dependency @eslint/compat to v1.4.0 (#2436)
renovate[bot] 90a329b
Update dependency @sveltejs/kit to v2.43.5 (#2437)
renovate[bot] 090520d
Abstract Value Analysis (#1759)
co-de-pot b8ff709
Update dependency @sveltejs/kit to v2.44.0 (#2441)
renovate[bot] 0d39b4c
Update dependency com.charleskorn.kaml:kaml to v0.97.0 (#2442)
renovate[bot] 2417769
Timeout for CDG and CFSensitiveDFG pass (#2417)
KuechA ddda6cd
Only put AST nodes in `fields`/`methods`/... in `RecordDeclaration` t…
oxisto 1630de2
Make MCP configurable (#2444)
maximiliankaul 3e4d65c
Changing function signature of `parse` to accept the file content ins…
oxisto e5fb3ee
Transition to integration tests for MCP (#2445)
fwendland dd0c077
Update dependency com.charleskorn.kaml:kaml to v0.98.0 (#2448)
renovate[bot] 00a0f18
Update dependency @sveltejs/kit to v2.46.4 (#2447)
renovate[bot] 71b7dd6
Fixing comment matching on multiple nested namespaces with no locatio…
konradweiss 4fcf453
Update dependency globals to v16.4.0 (#2451)
renovate[bot] e798ad5
Update dependency @sveltejs/kit to v2.47.2 (#2450)
renovate[bot] bdef6b6
Update dependency vite to v6.4.1 [SECURITY] (#2453)
renovate[bot] 2ba6f1c
Update dependency com.charleskorn.kaml:kaml to v0.102.0 (#2457)
renovate[bot] bee0018
Update dependency @sveltejs/kit to v2.48.1 (#2456)
renovate[bot] a4b6bd9
Expose host and port config in codyze API (#2458)
KuechA 3e0601e
Metric and evidence ids in query trees (#2440)
KuechA cf68b6c
Remove `evidenceID` from `QueryTree` (#2460)
KuechA c2d3bb1
Update dependency eslint-plugin-svelte to v3.13.0 (#2462)
renovate[bot] 8f07ef8
Update dependency black.ninia:jep to v4.3.1 (#2461)
renovate[bot] f2b79a2
Propagate information from underlying node to overlay node (#2466)
fwendland cf5fc5d
Python: remove unsupported versions/add current & future versions (#2…
maximiliankaul c2abe82
Update dependency com.vanniktech:gradle-maven-publish-plugin to v0.35…
renovate[bot] cc84696
Update dependency globals to v16.5.0 (#2464)
renovate[bot] 3532d49
Merge branch 'main' into codyze-goes-ai
lshala 4b608b9
Use koog for LLM stuff; Fix Chat UI bugs
lshala 2653e86
feat(console): rename to CodAIze Agent, update sidebar icon to robot,…
lshala 50b9744
Add a custom MCP Client + UI Widgets
lshala 488536e
Update mcp sdk types in cpg-mcp modules due to version upgrade
lshala 3dde569
Update imports of kotlin mcp sdk in cpg-mcp module
lshala 947863f
Update imports of kotlin mcp sdk in cpg-mcp module
lshala 36fbbaf
Merge branch 'main' into codyze-goes-ai
lshala 0a09fdb
Replace netty with cio
lshala ccca4a3
Add thinking
lshala 0323c7c
spotless
lshala 27748f0
Fix mcp util
lshala cee0280
Add gemini client; Update widgets
lshala 5522b1b
Refactor clients
lshala 741b34b
Add logs for token usage
lshala 9de424b
Merge branch 'main' into codyze-goes-ai
lshala 5302526
Change model
lshala 664ad42
Refactor sending conversation history to LLM; Extend config for mlx llms
lshala 1d58ede
Some refactoring
lshala a43cd1a
Change listing tools returning summaries instead of complete node
lshala 7e0db4a
New tool and refactoring
lshala 46e0259
Minor changes
lshala e6191ce
Minor changes 2
lshala f8221bb
Set noEdges to false for query tree
lshala 302b01f
Remove debug logs
lshala 76c626d
Merge main
lshala 1f05e0f
Add missing payload for concept assignment
lshala 912e91e
Revert CLI run command back to clikt and add wait parameter
lshala d353e6a
Downgrade ktor to 3.2.3 due to kotlin-mcp-sdk
lshala 914e2f8
Merge branch 'main' into codyze-goes-ai
lshala 858eb9a
Merge branch 'main' into codyze-goes-ai
lshala b132d81
Change cpg_llm_analyze tool in prompt
lshala b6d41c1
Merge branch 'main' into codyze-goes-ai
lshala 9f46b96
Remove sampling since llm_analyze mcp tool is changed to a prompt
lshala cd036a0
Merge branch 'main' into codyze-goes-ai
lshala ced2e96
Merge branch 'main' into codyze-goes-ai
lshala 352d98a
Minor changes
lshala a20f9fe
Change urls of mlx and vllm models
lshala 5b5f194
Add prompts and resources support
lshala ef9e9d4
Merge branch 'main' into codyze-goes-ai
lshala 4f35742
Revert ChatClient back using SSE instead of http
lshala 0d8107e
Configure streamable http connection in MCP client
lshala 78d10db
Add application.conf.example file
lshala 625b766
Remove application.conf from tracking
lshala 319949d
Fix svelte deprececated issues in layout.svelte
lshala 6add33f
Fix svelte modal issue
lshala 79faaa1
Fix svelte warnings: add $derived
lshala 0b0b64e
Change integration tests due to latest kotlin-sdk release of 0.9.0
lshala 80fbad8
Fix warnings in ListCommandsTest
lshala 86b5803
Fix failing tests
lshala 5cb28c9
Change JsonSChemaGeneratorTest using a test payload making the test m…
lshala bb25b7b
Fix mcp integration tests
lshala 5342eb2
Uncomment prompt test
lshala e629ecd
Uncomment suggestConceptsPromptTest
lshala eea2a4e
Refactor mcp integration tests
lshala a89702e
Add mcp sdk ServerSession in tests
lshala 9a9a614
Try fixing tests again
lshala ebe0e52
Add example python files back in codyze-core
lshala ad9d43b
Fix svelte issues
lshala 7808409
Cleanup
lshala aa196a4
Revert mcp sdk version back to 0.8.4 due to flaky tests
lshala bc50f93
Make ChatService creation dependend on config file
lshala 2ad3b03
Minor fixes
lshala 3ed268a
Make CodeViewer, Filetree and NodeTable components reusable for ChatI…
lshala 7b9c256
Fix issues when starting codyze webconsole and mcp module disabled
lshala 66bc92e
Merge branch 'main' into codyze-goes-ai
lshala 1af7792
Upgrade mcp sdk to 0.9.0
lshala 3fa23d9
First try with ChannelTransport
lshala 59a5531
Add cancel and close in finally block
lshala aa7395b
Try more tests
lshala 5b60a09
Try ListCommandsTest
lshala 59f8ade
Use new test function in ApplyConceptsTest
lshala feb6340
Fix remaining tests
lshala 6221d37
Add join() to wait until cancel is done
lshala d837069
Fix imports
lshala 0fdf501
Revert changes back
lshala 7366675
Refactor test setup
lshala 54c7d81
Add missing functionality from mcp-sdk-testing example
lshala ecefe86
Get rid of unnecessary functions
lshala b0a005a
Add comment
lshala 2b70f39
Merge branch 'main' into upgrade-mcp-sdk
lshala 728a36d
Replace runTest with runBlocking to use the ChannelTransport's defaul…
lshala 103fe73
Replace runTest in all remaining tests
lshala 8da6ce1
Use CompletableDeferred as in the example
lshala 8dfa410
Remove unnecessary launch/join for client.connect
lshala 84cc3f5
Try tests with timeout
lshala b5e63d8
Refactor test setup again
lshala 1c70ff3
Refactor McpTestSetup
lshala b359f9c
Add unconfined dispatcher for channel transport
lshala 7e44723
Remove runBlocking in tests
lshala 3e2e9c5
Refactor setup
lshala c2a5908
Add comment
lshala cf32485
Merge branch 'main' into codyze-goes-ai
lshala 5baef02
Fix imports
lshala ee77a8a
Merge branch 'upgrade-mcp-sdk' into codyze-goes-ai
lshala 328b72b
Fix listFunctionsTest
lshala c4c64fc
Add ServerSession in testsetup
lshala 748ff6d
Set default dispatcher
lshala 2830827
Create session before client connection
lshala e0e0408
Change frontend-dependency-conventions to runTimeOnly
lshala e5c52ea
Revert setting back
lshala 3926bc8
Merge branch 'main' into codyze-goes-ai
lshala 8d8c3d4
DocStrings
lshala b37101f
Use logger instead of println
lshala 5d57ce5
Merge branch 'main' into codyze-goes-ai
lshala a4683d2
More logs
lshala 03154d6
Exclude shadowJar, shadowDistZip, and shadowDistTar in ci build
lshala 0aeaf97
Add missing mcp integration tests
lshala 80cd8f4
Add tests for ChatClient
lshala 75697fc
Replace println's
lshala 9c0c220
Add MCP application tests
lshala 9c7cba6
Merge ChatService and ChatClient
lshala a57e72d
Rename test
lshala 33cb9a4
Merge branch 'main' into codyze-goes-ai
lshala 161b606
Refactor data flow widget
lshala 167112d
Replace schema of getNode tool
lshala 76b2554
Fix docstrings, host propagation and imports
lshala a1d33fe
Merge branch 'main' into codyze-goes-ai
lshala 95d87f8
Rename mcp models from '*summary' back to '*info'
lshala 4bbe249
Fix JsonSchemaGeneratorTest by adding descriptions
lshala d3ef161
Readme
lshala 8587cd0
Fix test ListCommandsTest in mcp module
lshala 5a3b37f
Revert unintended changes
lshala b3ea3a6
Merge branch 'main' into codyze-goes-ai
lshala 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,143 @@ | ||
| # AGENTS.md | ||
|
|
||
| This file provides guidance to AI coding agents (Claude Code, Cursor, Codex, Gemini CLI, etc.) working in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| **CPG** is a code property graph library and analysis platform. | ||
|
|
||
| Key modules: | ||
| - **cpg-core** – Core library: AST nodes, graph structures, passes, type system | ||
| - **cpg-analysis** – Higher-level analyses built on top of cpg-core (dataflow, control flow, call graphs, etc.) | ||
| - **cpg-language-\*** – Language frontends, one module per language (e.g., `cpg-language-go`, `cpg-language-python`) | ||
| - **cpg-concepts** – Concept and operation definitions | ||
| - **cpg-mcp** – MCP server exposing CPG analysis tools (dataflow, symbol analysis, concept application) to LLMs via streamable HTTP | ||
| - **codyze-console** – Web-based analysis UI with AI agent chat (see [Architecture](#codyze-console-architecture) below) | ||
|
|
||
| ## Technology Stack | ||
|
|
||
| ### Backend | ||
| - **Language**: Kotlin (requires Java 21) | ||
| - **Build**: Gradle with Kotlin DSL | ||
| - **Testing**: JUnit 5, kotlin.test | ||
| - **Formatting**: Google Java Style via spotless plugin | ||
|
|
||
| ### Frontend (`codyze-console/src/main/webapp`) | ||
| - **Framework**: Svelte 5 with SvelteKit | ||
| - **Styling**: Tailwind CSS | ||
| - **Package Manager**: pnpm (not npm) | ||
|
|
||
| ## Development Commands | ||
|
|
||
| ### Build | ||
|
|
||
| ```bash | ||
| # Full build (format + test + publish locally) | ||
| ./gradlew clean spotlessApply build publishToMavenLocal | ||
|
|
||
| # Quick build | ||
| ./gradlew build | ||
|
|
||
| # Build a single module | ||
| ./gradlew :cpg-core:build | ||
| ./gradlew :codyze-console:build | ||
| ``` | ||
|
|
||
| ### Test & Quality | ||
|
|
||
| ```bash | ||
| ./gradlew test # Unit tests | ||
| ./gradlew integrationTest # Integration tests | ||
| ./gradlew performanceTest # Performance tests | ||
| ./gradlew spotlessApply # Auto-format | ||
| ./gradlew spotlessCheck # Check formatting only | ||
| ``` | ||
|
|
||
| ### Frontend (`codyze-console`) | ||
|
|
||
| ```bash | ||
| cd codyze-console/src/main/webapp | ||
| pnpm install # Install dependencies | ||
| pnpm run dev # Dev server | ||
| pnpm run build # Production build | ||
| pnpm run check # Type check | ||
| pnpm run lint # Lint | ||
| pnpm run format # Format | ||
| ``` | ||
|
|
||
| ### Backend (`codyze-console`) | ||
|
|
||
| ```bash | ||
| ./gradlew :codyze-console:compileKotlin --console=plain | ||
| ``` | ||
|
|
||
| ### MCP Server (`cpg-mcp`) | ||
|
|
||
| ```bash | ||
| ./gradlew :cpg-mcp:installDist # Build & install | ||
| ./gradlew :cpg-mcp:run # Run (stdio) | ||
| ./gradlew :cpg-mcp:run --args="--http 8080" # Run with streamable HTTP on port 8080 | ||
| ``` | ||
|
|
||
| ## Code Conventions | ||
|
|
||
| - Follow **Google Java Style** (enforced by spotless – run `./gradlew spotlessApply` before committing) | ||
| - Kotlin idioms preferred over Java-style patterns | ||
| - Use `kotlin.test` assertions in tests, not JUnit assertions directly | ||
| - Frontend: use **Svelte 5 runes** exclusively (no legacy `$:` reactive syntax) | ||
|
|
||
| ## codyze-console Architecture | ||
|
|
||
| codyze-console is a full-stack web application with a Ktor backend and a Svelte 5 SPA frontend. It provides code analysis capabilities and an AI agent chat interface. | ||
|
|
||
| ### Backend (`codyze-console/src/main/kotlin/.../console/`) | ||
|
|
||
| | File / Package | Responsibility | | ||
| |---|---| | ||
| | `Main.kt` | Ktor/Netty entry point (port 8080), optionally starts MCP server on port 8081 | | ||
| | `Router.kt` | REST API routes (`/api/analyze`, `/api/chat`, `/api/querytrees`, etc.) | | ||
| | `ConsoleService.kt` | Core business logic: CPG analysis, QueryTree caching, concept management | | ||
| | `Nodes.kt` | JSON serialization models and CPG node-to-JSON conversion | | ||
| | `ai/ChatClient.kt` | MCP client + agentic tool-calling loop (connects to cpg-mcp via streamable HTTP) | | ||
| | `ai/ChatService.kt` | Loads LLM config from HOCON, creates `ChatClient` with configured provider | | ||
| | `ai/LlmClient.kt` | Provider-agnostic LLM interface (`sendPrompt` -> `List<ToolCall>`) | | ||
| | `ai/OpenAiClient.kt` | OpenAI-compatible client (also works with Ollama, vLLM, MLX) | | ||
| | `ai/GeminiClient.kt` | Google Gemini API client | | ||
| | `ai/McpServerHelper.kt` | Reflection-based bridge to cpg-mcp; loads module dynamically so it remains an optional dependency | | ||
| | `ai/ClientModels.kt` | Data classes for OpenAI/Gemini request/response formats | | ||
|
|
||
| #### AI Agent Data Flow | ||
|
|
||
| 1. Frontend sends chat messages via `POST /api/chat` (SSE stream) | ||
| 2. `ChatClient` forwards to LLM with MCP tool definitions | ||
| 3. If LLM returns tool calls, `ChatClient` executes them against cpg-mcp via `mcp.callTool()` | ||
| 4. Tool results are streamed to the frontend and fed back to the LLM | ||
| 5. Loop repeats (max 8 iterations) until the LLM produces a text response | ||
|
|
||
| #### MCP Integration | ||
|
|
||
| codyze-console acts as both **MCP server host** and **MCP client**: | ||
| - It starts the cpg-mcp server on port 8081 (via reflection, so cpg-mcp is an optional dependency) | ||
| - `ChatClient` connects to it as a client using `StreamableHttpClientTransport` | ||
| - After analysis, the global `TranslationResult` is injected into the MCP server so tools can access the CPG | ||
|
|
||
| ### Frontend (`codyze-console/src/main/webapp/src/`) | ||
|
|
||
| | Directory | Content | | ||
| |---|---| | ||
| | `routes/` | SvelteKit pages: dashboard, components, requirements, chat, new-analysis | | ||
| | `lib/components/ai-agent/` | Chat UI: `ChatInterface`, `WelcomeScreen`, `MessageInput`, `McpCapabilitiesModal` | | ||
| | `lib/components/analysis/` | Code viewer, node tables, findings list, file tree | | ||
| | `lib/components/requirements/` | Requirement cards, charts, QueryTree explorer (lazy-loading) | | ||
| | `lib/services/apiService.ts` | SSE streaming utility (`streamPost` for `/api/chat`) | | ||
| | `lib/services/llmAgent.ts` | Chat API facade wrapping `apiService` | | ||
| | `lib/stores/queryTreeStore.ts` | In-memory cache for QueryTrees with batch fetching and lazy loading | | ||
| | `lib/types.ts` | TypeScript interfaces mirroring backend JSON models | | ||
|
|
||
| ### API Endpoints | ||
|
|
||
| **Analysis:** `POST /api/analyze`, `POST /api/reanalyze`, `GET /api/result`, `GET /api/component/{name}` | ||
|
|
||
| **Chat & MCP:** `POST /api/chat` (SSE), `GET /api/chat/mcp/capabilities`, `POST /api/chat/mcp/prompts/{name}`, `GET /api/features` | ||
|
|
||
| **Requirements:** `GET /api/requirement/{id}`, `GET /api/querytree/{id}`, `POST /api/querytrees` (batch), `GET /api/querytrees/{id}/parents` |
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,65 @@ | ||
| # Codyze Console | ||
|
|
||
| A web application for Codyze with an optional AI chat, which is enhanced by an MCP client that acts as an agent. | ||
| The agent uses the tools of the CPG MCP server to analyze code and answer questions. | ||
|
|
||
| ## Getting Started | ||
|
|
||
| The easiest way to get started is by using the predefined IntelliJ run configurations in the `.run/` directory: | ||
| - *Codyze Console* (standalone) | ||
| - *Codyze Compliance Scan (with Console and Example)* (with an example project). | ||
|
|
||
| Alternatively, starting the application from the command line: | ||
|
|
||
| ```bash | ||
| # Start the console only | ||
| ./gradlew :codyze:run --args="console" | ||
|
|
||
| # With an analysis of a project | ||
| ./gradlew :codyze:run --args="compliance scan --project-dir <path> --console=true" | ||
| ``` | ||
|
|
||
| The web console is available at `http://localhost:8080`. | ||
|
|
||
| ## AI Chat Features | ||
|
|
||
| The AI chat requires the `cpg-mcp` module to be enabled and a configured LLM provider. | ||
|
|
||
| ### 1. Enable the `cpg-mcp` module | ||
|
|
||
| Run the configuration script: | ||
|
|
||
| ```bash | ||
| ./configure_frontends.sh | ||
| ``` | ||
|
|
||
| Or enable it manually by setting `enableMCPModule=true` in `gradle.properties`. | ||
|
|
||
| ### 2. Configure your LLM provider | ||
|
|
||
| Copy the example configuration: | ||
|
|
||
| ```bash | ||
| cp codyze-console/src/main/resources/application.conf.example codyze-console/src/main/resources/application.conf | ||
| ``` | ||
|
|
||
| Then edit `application.conf` and set the `client` field of the provider: | ||
|
|
||
| ```hocon | ||
| llm { | ||
| client = "ollama" | ||
|
|
||
| ollama { | ||
| baseUrl = "http://localhost:11434" | ||
| model = "llama3" | ||
| } | ||
|
|
||
| # ... other providers are preconfigured as placeholders. | ||
| } | ||
| ``` | ||
|
|
||
| Currently, only Gemini and OpenAI-compatible endpoints are supported. The predefined clients (`ollama`, `vLLM`, `mlx`, etc.) use all the same OpenAI-compatible client internally. They are intended for testing and development and allows to switch between different server URLs without reconfiguring every time. | ||
|
|
||
| ### 3. MCP Server | ||
|
|
||
| When `cpg-mcp` is enabled, the MCP server is automatically started on port `8081`. The AI chat connects to it as an MCP client to access the CPG tools (e.g., listing functions, records, and calls). |
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
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.