|
1 | 1 | <picture>
|
2 |
| - <source media="(prefers-color-scheme: dark)" srcset="docs/assets/cldk-dark.png"> |
3 |
| - <source media="(prefers-color-scheme: light)" srcset="docs/assets/cldk-light.png"> |
| 2 | + <source media="(prefers-color-scheme: dark)" srcset="./docs/assets/cldk-dark.png"> |
| 3 | + <source media="(prefers-color-scheme: light)" srcset="./docs/assets/cldk-light.png"> |
4 | 4 | <img alt="Logo">
|
5 | 5 | </picture>
|
6 | 6 |
|
|
25 | 25 |
|
26 | 26 | **A framework that bridges the gap between traditional program analysis tools and Large Language Models (LLMs) specialized for code (CodeLLMs).**
|
27 | 27 |
|
28 |
| -### 🚀 Overview |
| 28 | +### Overview |
29 | 29 | This is the TypeScript SDK for the Codellm-Devkit (CLDK). The SDK provides a unified interface for integrating outputs from various analysis tools and preparing them for effective use by CodeLLMs. It allows developers to streamline the process of transforming raw code into actionable insights.
|
30 | 30 |
|
31 | 31 | ### 📦 Installation
|
32 | 32 |
|
33 |
| -To install the Codellm-Devkit TypeScript SDK, you can use npm or yarn. Run the following command in your terminal: |
| 33 | +To install the SDK, you can use bun, npm, or yarn. Run the following command in your terminal: |
34 | 34 |
|
35 | 35 | #### Using npm
|
36 | 36 | ```bash
|
37 |
| -npm install --save github:codellm-devkit/typescript-sdk#initial-sdk |
| 37 | +npm i @cldk/cldk |
38 | 38 | ```
|
39 | 39 |
|
40 | 40 | #### Using yarn
|
41 | 41 | ```bash
|
42 |
| -yarn add github:codellm-devkit/typescript-sdk#initial-sdk |
43 |
| -``` |
44 |
| -If you are on yarn v1 |
45 |
| -```bash |
46 |
| -yarn add codellm-devkit/typescript-sdk#initial-sdk |
| 42 | +yarn add @cldk/cldk |
47 | 43 | ```
|
48 | 44 |
|
49 | 45 | #### Using bun
|
50 | 46 | ```bash
|
51 |
| -bun add github:codellm-devkit/typescript-sdk#initial-sdk |
| 47 | +bun add @cldk/cldk |
52 | 48 | ```
|
53 | 49 |
|
54 |
| -Then run `npm install`, `yarn install`, or `bun install` depending on your package manager. |
| 50 | +### 🚀 Quickstart |
55 | 51 |
|
56 |
| -### ⚙️ Basic Usage |
| 52 | +1. Create a Temporary Directory |
57 | 53 |
|
58 |
| -Here’s how to use CLDK to analyze a Java project and access key analysis artifacts: |
| 54 | + ```bash |
| 55 | + mkdir cldk-quickstart |
| 56 | + cd cldk-quickstart |
| 57 | + ``` |
59 | 58 |
|
60 |
| -```typescript |
61 |
| -import { CLDK } from "cldk"; |
| 59 | +2. Initialize a Bare Project |
62 | 60 |
|
63 |
| -// Initialize Java analysis |
64 |
| -const analysis = CLDK.for("java").analysis({ |
65 |
| - projectPath: "/path/to/your/java/project", |
66 |
| - analysisLevel: "Symbol Table", |
67 |
| -}); |
| 61 | + ```bash |
| 62 | + bun init -y |
| 63 | + ``` |
68 | 64 |
|
69 |
| -// Retrieve structured application model |
70 |
| -const jApplication = await analysis.getApplication(); |
71 |
| -console.log("Parsed JApplication:", jApplication); |
| 65 | + This creates a minimal `package.json` instantly. |
72 | 66 |
|
73 |
| -// Retrieve the symbol table |
74 |
| -const symbolTable = await analysis.getSymbolTable(); |
75 |
| -console.log("Symbol Table:", symbolTable); |
76 |
| -``` |
| 67 | +3. Install `@cldk/cldk` |
| 68 | + |
| 69 | + ```bash |
| 70 | + bun add @cldk/cldk |
| 71 | + ``` |
| 72 | + |
| 73 | +4. Create a file `test-analysis.ts` with the following content: |
| 74 | + |
| 75 | + ```typescript |
| 76 | + import { CLDK } from "cldk"; |
| 77 | + |
| 78 | + // Initialize Java analysis |
| 79 | + const analysis = CLDK.for("java").analysis({ |
| 80 | + projectPath: "/path/to/your/java/project", |
| 81 | + analysisLevel: "Symbol Table", |
| 82 | + }); |
| 83 | + |
| 84 | + // Retrieve structured application model |
| 85 | + const jApplication = await analysis.getApplication(); |
| 86 | + console.log("Parsed JApplication:", jApplication); |
| 87 | + |
| 88 | + // Retrieve the symbol table |
| 89 | + const symbolTable = await analysis.getSymbolTable(); |
| 90 | + console.log("Symbol Table:", symbolTable); |
| 91 | + ``` |
| 92 | + |
| 93 | +5. Run the Script |
| 94 | + |
| 95 | + ```bash |
| 96 | + bun test-analysis.ts |
| 97 | + ``` |
| 98 | + |
| 99 | +### 🛠️ Development Instructions |
| 100 | + |
| 101 | +#### Developing Locally (with Bun) |
| 102 | + |
| 103 | +1. Clone the repository: |
| 104 | + ```bash |
| 105 | + git clone https://github.com/codellm-devkit/typescript-sdk.git |
| 106 | + cd typescript-sdk |
| 107 | + ``` |
| 108 | + |
| 109 | +2. If you don't have it already, pleaes install `Bun`: |
| 110 | + ```bash |
| 111 | + curl -fsSL https://bun.sh/install | bash |
| 112 | + ``` |
| 113 | + _Note: follow any post-installation instructions to complete the installation_ |
| 114 | +3. Install the dependencies |
| 115 | + ```bash |
| 116 | + bun install |
| 117 | + ``` |
| 118 | + |
| 119 | +4. Run tests: |
| 120 | + ```bash |
| 121 | + bun run test |
| 122 | + ``` |
| 123 | + |
| 124 | +#### Developing inside a Container (Using Dev Containers) |
| 125 | + |
| 126 | +1. If you don't, ensure you have Docker/Podman and a compatible editor (e.g., VS Code) with the Dev Containers extension installed. |
| 127 | + |
| 128 | +2. Open the repository in your editor. When prompted, reopen the project in the dev container. The devcontainer is configured to come pre-installed with bun and all the necessary dependencies. |
| 129 | + |
| 130 | +3. You can start by run tests: |
| 131 | + ```bash |
| 132 | + bun run test |
| 133 | + ``` |
0 commit comments