Skip to content

Initial Release of TypeScript SDK #1

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 20 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .eslintrc
Empty file.
76 changes: 76 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Dependencies
node_modules/

# Lock files (for library development)
yarn.lock
package-lock.json
pnpm-lock.yaml
bun.lock
bun.lockb

# Yarn Berry specific
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Bun
.bun

# Volta
.volta/

# Environment variables
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Cache and build directories
.cache/
.next/
.nuxt/
dist/
build/
out/
coverage/
.turbo

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Editor directories and files
.idea/
.vscode/
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
.DS_Store
Thumbs.db

# Testing
.nyc_output
coverage/
*.lcov

# TypeScript
*.tsbuildinfo
next-env.d.ts

# Misc
.tmp/
temp/
.eslintcache
.stylelintcache
Empty file added .prettierrc
Empty file.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Codellm-Devkit TypeScript SDK

## 🚀 Overview
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.

## 📦 Installation

To install the Codellm-Devkit TypeScript SDK, you can use npm or yarn. Run the following command in your terminal:

### Using npm
```bash
npm install --save github:codellm-devkit/typescript-sdk#initial-sdk
```

### Using yarn
```bash
yarn add github:codellm-devkit/typescript-sdk#initial-sdk
```
If you are on yarn v1
```bash
yarn add codellm-devkit/typescript-sdk#initial-sdk
```

### Using bun
```bash
bun add github:codellm-devkit/typescript-sdk#initial-sdk
```

Then run `npm install`, `yarn install`, or `bun install` depending on your package manager.

## ⚙️ Basic Usage

Here’s how to use CLDK to analyze a Java project and access key analysis artifacts:

```typescript
import { CLDK } from "cldk";

// Initialize Java analysis
const analysis = CLDK.for("java").analysis({
projectPath: "/path/to/your/java/project",
analysisLevel: "Symbol Table",
});

// Retrieve structured application model
const jApplication = await analysis.getApplication();
console.log("Parsed JApplication:", jApplication);

// Retrieve the symbol table
const symbolTable = await analysis.getSymbolTable();
console.log("Symbol Table:", symbolTable);
```
5 changes: 5 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[test]
coverage = true
exclude = ["**/node_modules/**"]
patterns = ["**/*Test*.ts", "**/*test*.ts"]
timeout = 600000 # Sets timeout to 10 minutes
40 changes: 40 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "cldk",
"version": "0.1.0",
"description": "",
"main": "dist/index.js",
"scripts": {
"build": "bun build ./src/index.ts --outdir ./dist",
"test": "bun test --preload ./test/conftest.ts --timeout=600000 --verbose",
"clean": "rm -rf dist coverage"
},
"files": [
"dist",
"src/analysis/java/jars/codeanalyzer-2.3.3.jar"
],
"exports": [
"./dist/index.js"
],
"devDependencies": {
"@types/bun": "^1.2.10",
"@types/extract-zip": "2.0.0",
"@types/node": "^22.14.1",
"typescript": "^5.8.3"
},
"private": true,
"dependencies": {
"@types/jsonstream": "^0.8.33",
"JSONStream": "^1.3.5",
"bun": "^1.2.10",
"extract-zip": "^2.0.1",
"fast-glob": "^3.3.3",
"graphology": "^0.26.0",
"loglevel": "^1.9.2",
"zod": "^3.24.3"
},
"testing": {
"java-test-applications-path": "./test-applications/java",
"c-test-applications-path": "./test-applications/c",
"python-test-applications-path": "./test-applications/python"
}
}
57 changes: 57 additions & 0 deletions src/CLDK.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import {JavaAnalysis} from "./analysis/java";
import {spawnSync} from "node:child_process";

export class CLDK {
/**
* The programming language of choice
*/
private language: string;

constructor(language: string) {
this.language = language;
}

/**
* A static for method to create a new instance of the CLDK class
*/
public static for(language: string): CLDK {
return new CLDK(language);
}

/**
* Get the programming language of the CLDK instance
*/
public getLanguage(): string {
return this.language;
}

/**
* Implementation of the analysis method
*/
public analysis({ projectPath, analysisLevel }: { projectPath: string, analysisLevel: string }): JavaAnalysis {
if (this.language === "java") {
this.makeSureJavaIsInstalled();
return new JavaAnalysis({
projectDir: projectPath,
analysisLevel: analysisLevel,
});
} else {
throw new Error(`Analysis support for ${this.language} is not implemented yet.`);
}
}

private makeSureJavaIsInstalled(): Promise<void> {
try {
const result = spawnSync("java", ["-version"], {encoding: "utf-8", stdio: "pipe"});
if (result.error) {
throw result.error;
}
if (result.status !== 0) {
throw new Error(result.stderr || "Java is not installed. Please install Java 11+ to be able to analyze java projects.");
}
} catch (e: any) {
throw new Error(e.message || String(e));
}
return Promise.resolve();
}
}
19 changes: 19 additions & 0 deletions src/analysis/commons/treesitter/TreesitterJava.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright IBM Corporation 2025
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export class TreesitterJava {

}
Loading