Skip to content

Commit e88402f

Browse files
authored
Merge pull request #1 from codellm-devkit/initial-sdk
Initial Release of TypeScript SDK
2 parents fab1273 + 211cc16 commit e88402f

23 files changed

+1192
-0
lines changed

.eslintrc

Whitespace-only changes.

.gitignore

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Lock files (for library development)
5+
yarn.lock
6+
package-lock.json
7+
pnpm-lock.yaml
8+
bun.lock
9+
bun.lockb
10+
11+
# Yarn Berry specific
12+
.pnp.*
13+
.yarn/*
14+
!.yarn/patches
15+
!.yarn/plugins
16+
!.yarn/releases
17+
!.yarn/sdks
18+
!.yarn/versions
19+
20+
# Bun
21+
.bun
22+
23+
# Volta
24+
.volta/
25+
26+
# Environment variables
27+
.env
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# Cache and build directories
34+
.cache/
35+
.next/
36+
.nuxt/
37+
dist/
38+
build/
39+
out/
40+
coverage/
41+
.turbo
42+
43+
# Logs
44+
logs
45+
*.log
46+
npm-debug.log*
47+
yarn-debug.log*
48+
yarn-error.log*
49+
lerna-debug.log*
50+
.pnpm-debug.log*
51+
52+
# Editor directories and files
53+
.idea/
54+
.vscode/
55+
*.suo
56+
*.ntvs*
57+
*.njsproj
58+
*.sln
59+
*.sw?
60+
.DS_Store
61+
Thumbs.db
62+
63+
# Testing
64+
.nyc_output
65+
coverage/
66+
*.lcov
67+
68+
# TypeScript
69+
*.tsbuildinfo
70+
next-env.d.ts
71+
72+
# Misc
73+
.tmp/
74+
temp/
75+
.eslintcache
76+
.stylelintcache

.prettierrc

Whitespace-only changes.

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Codellm-Devkit TypeScript SDK
2+
3+
## 🚀 Overview
4+
Codellm-Devkit (CLDK) is a multilingual program analysis framework that bridges the gap between traditional static analysis tools and Large Language Models (LLMs) specialized for code (CodeLLMs). Codellm-Devkit allows developers to streamline the process of transforming raw code into actionable insights by providing a unified interface for integrating outputs from various analysis tools and preparing them for effective use by CodeLLMs.
5+
6+
## 📦 Installation
7+
8+
To install the Codellm-Devkit TypeScript SDK, you can use npm or yarn. Run the following command in your terminal:
9+
10+
### Using npm
11+
```bash
12+
npm install --save github:codellm-devkit/typescript-sdk#initial-sdk
13+
```
14+
15+
### Using yarn
16+
```bash
17+
yarn add github:codellm-devkit/typescript-sdk#initial-sdk
18+
```
19+
If you are on yarn v1
20+
```bash
21+
yarn add codellm-devkit/typescript-sdk#initial-sdk
22+
```
23+
24+
### Using bun
25+
```bash
26+
bun add github:codellm-devkit/typescript-sdk#initial-sdk
27+
```
28+
29+
Then run `npm install`, `yarn install`, or `bun install` depending on your package manager.
30+
31+
## ⚙️ Basic Usage
32+
33+
Here’s how to use CLDK to analyze a Java project and access key analysis artifacts:
34+
35+
```typescript
36+
import { CLDK } from "cldk";
37+
38+
// Initialize Java analysis
39+
const analysis = CLDK.for("java").analysis({
40+
projectPath: "/path/to/your/java/project",
41+
analysisLevel: "Symbol Table",
42+
});
43+
44+
// Retrieve structured application model
45+
const jApplication = await analysis.getApplication();
46+
console.log("Parsed JApplication:", jApplication);
47+
48+
// Retrieve the symbol table
49+
const symbolTable = await analysis.getSymbolTable();
50+
console.log("Symbol Table:", symbolTable);
51+
```

bunfig.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[test]
2+
coverage = true
3+
exclude = ["**/node_modules/**"]
4+
patterns = ["**/*Test*.ts", "**/*test*.ts"]
5+
timeout = 600000 # Sets timeout to 10 minutes

package.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "cldk",
3+
"version": "0.1.0",
4+
"description": "",
5+
"main": "dist/index.js",
6+
"scripts": {
7+
"build": "bun build ./src/index.ts --outdir ./dist",
8+
"test": "bun test --preload ./test/conftest.ts --timeout=600000 --verbose",
9+
"clean": "rm -rf dist coverage"
10+
},
11+
"files": [
12+
"dist",
13+
"src/analysis/java/jars/codeanalyzer-2.3.3.jar"
14+
],
15+
"exports": [
16+
"./dist/index.js"
17+
],
18+
"devDependencies": {
19+
"@types/bun": "^1.2.10",
20+
"@types/extract-zip": "2.0.0",
21+
"@types/node": "^22.14.1",
22+
"typescript": "^5.8.3"
23+
},
24+
"private": true,
25+
"dependencies": {
26+
"@types/jsonstream": "^0.8.33",
27+
"JSONStream": "^1.3.5",
28+
"bun": "^1.2.10",
29+
"extract-zip": "^2.0.1",
30+
"fast-glob": "^3.3.3",
31+
"graphology": "^0.26.0",
32+
"loglevel": "^1.9.2",
33+
"zod": "^3.24.3"
34+
},
35+
"testing": {
36+
"java-test-applications-path": "./test-applications/java",
37+
"c-test-applications-path": "./test-applications/c",
38+
"python-test-applications-path": "./test-applications/python"
39+
}
40+
}

src/CLDK.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import {JavaAnalysis} from "./analysis/java";
2+
import {spawnSync} from "node:child_process";
3+
4+
export class CLDK {
5+
/**
6+
* The programming language of choice
7+
*/
8+
private language: string;
9+
10+
constructor(language: string) {
11+
this.language = language;
12+
}
13+
14+
/**
15+
* A static for method to create a new instance of the CLDK class
16+
*/
17+
public static for(language: string): CLDK {
18+
return new CLDK(language);
19+
}
20+
21+
/**
22+
* Get the programming language of the CLDK instance
23+
*/
24+
public getLanguage(): string {
25+
return this.language;
26+
}
27+
28+
/**
29+
* Implementation of the analysis method
30+
*/
31+
public analysis({ projectPath, analysisLevel }: { projectPath: string, analysisLevel: string }): JavaAnalysis {
32+
if (this.language === "java") {
33+
this.makeSureJavaIsInstalled();
34+
return new JavaAnalysis({
35+
projectDir: projectPath,
36+
analysisLevel: analysisLevel,
37+
});
38+
} else {
39+
throw new Error(`Analysis support for ${this.language} is not implemented yet.`);
40+
}
41+
}
42+
43+
private makeSureJavaIsInstalled(): Promise<void> {
44+
try {
45+
const result = spawnSync("java", ["-version"], {encoding: "utf-8", stdio: "pipe"});
46+
if (result.error) {
47+
throw result.error;
48+
}
49+
if (result.status !== 0) {
50+
throw new Error(result.stderr || "Java is not installed. Please install Java 11+ to be able to analyze java projects.");
51+
}
52+
} catch (e: any) {
53+
throw new Error(e.message || String(e));
54+
}
55+
return Promise.resolve();
56+
}
57+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Copyright IBM Corporation 2025
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
export class TreesitterJava {
18+
19+
}

0 commit comments

Comments
 (0)