Basic Structure
This commit is contained in:
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# Dependencies
|
||||
/node_modules
|
||||
|
||||
# Build output
|
||||
/dist
|
||||
|
||||
# Environment variables
|
||||
.env
|
||||
package-lock.json
|
||||
|
||||
# Gemini files
|
||||
GEMINI.md
|
||||
PROGRESS.md
|
||||
@@ -4,9 +4,12 @@ This document outlines the operational constraints and directives for the AI age
|
||||
|
||||
## Core Directives
|
||||
|
||||
* [ ] **Task Completion:** Upon completing a task listed in `SPEC.md` or `PROGRESS.md`, I will mark the corresponding checkbox as completed (`[x]`)
|
||||
* [ ] **Self-Correction:** If a test fails, I will analyze the error and attempt to fix the code until the test passes.
|
||||
* [ ] **Continuous Improvement:** I will update this file (`AGENTS.md`) with any new constraints or core files that are added to the project.
|
||||
* **Task Completion:** Upon completing a task listed in `SPEC.md` or `PROGRESS.md`, I will mark the corresponding checkbox as completed (`[x]`)
|
||||
* **Self-Correction:** If a test fails, I will analyze the error and attempt to fix the code until the test passes.
|
||||
* **Continuous Improvement:** I will update this file (`AGENTS.md`) with any new constraints or core files that are added to the project.
|
||||
* **Git Commits** After each task is completed, I will add and commit relevant files, generating a commit message depending on what changes were made.
|
||||
* **Documentation Generation** I will update the `SPEC.md` file with a detailed record of the changes, and the `README.md` file with any relevant changes or instructions.
|
||||
|
||||
|
||||
## File-Specific Directives
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ Project Plan Requirements:
|
||||
Your plan must include the following sections, detailing the architecture and implementation steps:
|
||||
|
||||
1. Architectural Design & Workflow (LangGraph Graph):
|
||||
Describe the agent's core logic as a directed graph using LangGraph. Define the key nodes and edges, and how they connect to enable the required looping behavior.
|
||||
Describe the agent's core logic as a directed graph using LangGraph. Define the keys and edges, and how they connect to enable the required looping behavior.
|
||||
|
||||
Nodes: Define nodes for each distinct step in the agent's process. At a minimum, include:
|
||||
|
||||
|
||||
20
SPEC.md
20
SPEC.md
@@ -30,14 +30,26 @@ The agent will be equipped with the following tools:
|
||||
* `[ ]` **FileManagementTool**: A set of tools for reading and writing files to the local filesystem. This will be necessary for the agent to create, modify, and save the code scripts it is working on.
|
||||
* `[ ]` **TestRunnerTool**: A tool for running specific test cases against the generated code. This will be used to verify the correctness of the code.
|
||||
|
||||
## 3. Development Phases & Milestones
|
||||
## 3. Technology Stack
|
||||
|
||||
* **Language:** TypeScript
|
||||
* **Framework:** LangChain.js with LangGraph
|
||||
* **CLI Framework:** Commander.js
|
||||
* **Local LLM Runner:** Ollama
|
||||
* **Code Execution Sandbox:** Docker
|
||||
* **Testing:** Jest
|
||||
|
||||
## 4. Development Phases & Milestones
|
||||
|
||||
The project will be developed in the following phases:
|
||||
|
||||
* **Phase 1: Foundation & Tooling**
|
||||
* `[ ]` Set up the local development environment.
|
||||
* `[ ]` Download and set up the Phi4-mini model.
|
||||
* `[ ]` Implement the `CodeExecutionTool`.
|
||||
* `[x]` Set up the local development environment.
|
||||
* `[x]` Download and set up the Phi4-mini model.
|
||||
- Running locally via Ollama on port 11434
|
||||
* `[x]` Implement the `CodeExecutionTool`.
|
||||
- Test pending restart
|
||||
- `[ ]` Test the implmentation of the `CodeExecutionTool`.
|
||||
* `[ ]` Implement the `FileManagementTool`.
|
||||
* `[ ]` Implement the `TestRunnerTool`.
|
||||
|
||||
|
||||
4
jest.config.js
Normal file
4
jest.config.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
};
|
||||
29
package.json
Normal file
29
package.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "blight",
|
||||
"version": "1.0.0",
|
||||
"description": "TODO",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "npx tsc && node dist/index.js",
|
||||
"test": "jest"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://192.168.2.114:3000/artanis/Blight.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"type": "commonjs",
|
||||
"devDependencies": {
|
||||
"@types/dockerode": "^3.3.43",
|
||||
"@types/jest": "^30.0.0",
|
||||
"jest": "^30.0.5",
|
||||
"ts-jest": "^29.4.1",
|
||||
"typescript": "^5.9.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"dockerode": "^4.0.7",
|
||||
"langchain": "^0.3.31"
|
||||
}
|
||||
}
|
||||
1
src/index.ts
Normal file
1
src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
console.log("Hello, world!");
|
||||
10
src/tools/codeExecution.test.ts
Normal file
10
src/tools/codeExecution.test.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { CodeExecutionTool } from "./codeExecution.tool";
|
||||
|
||||
describe("CodeExecutionTool", () => {
|
||||
it("should execute code and return the output", async () => {
|
||||
const tool = new CodeExecutionTool();
|
||||
const code = "console.log('Hello, world!');";
|
||||
const result = await tool._call(code);
|
||||
expect(result).toBe("Hello, world!\n");
|
||||
});
|
||||
});
|
||||
44
src/tools/codeExecution.tool.ts
Normal file
44
src/tools/codeExecution.tool.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { Tool } from "langchain/tools";
|
||||
import Docker from 'dockerode';
|
||||
|
||||
class CodeExecutionTool extends Tool {
|
||||
name = "code-execution";
|
||||
description = "A tool for executing code in a sandboxed environment.";
|
||||
|
||||
private docker = new Docker();
|
||||
|
||||
async _call(code: string): Promise<string> {
|
||||
try {
|
||||
const container = await this.docker.createContainer({
|
||||
Image: 'alpine',
|
||||
Cmd: ['node', '-e', code],
|
||||
Tty: false,
|
||||
HostConfig: {
|
||||
AutoRemove: true,
|
||||
}
|
||||
});
|
||||
|
||||
const stream = await container.attach({ stream: true, stdout: true, stderr: true });
|
||||
await container.start();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let output = '';
|
||||
stream.on('data', (chunk) => {
|
||||
output += chunk.toString('utf8');
|
||||
});
|
||||
|
||||
stream.on('end', () => {
|
||||
resolve(output);
|
||||
});
|
||||
|
||||
stream.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
} catch (err: any) {
|
||||
return `Error executing code: ${err.message}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { CodeExecutionTool };
|
||||
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist",
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"sourceMap": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user