Skip to content

Commit 3ce7076

Browse files
fixing codinit files
1 parent d6aef83 commit 3ce7076

File tree

158 files changed

+41081
-203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+41081
-203
lines changed

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Welcome to the CodinIT documentation - your comprehensive guide to using and ext
3333

3434
## Additional Resources
3535

36-
- **CodinIT GitHub Repository:** [https://github.com/Cody/CodinIT](https://github.com/Cody/CodinIT)
36+
- **CodinIT GitHub Repository:** [https://github.com/Gerome-Elassaad/CodinIT](https://github.com/Cody/CodinIT)
3737
- **MCP Documentation:** [https://modelcontextprotocol.org/docs](https://modelcontextprotocol.org/docs)
3838

3939
We're always looking to improve this documentation. If you have suggestions or find areas that could be enhanced, please let us know. Your feedback helps make CodinIT better for everyone.
File renamed without changes.

esbuild.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// esbuild.js
2+
const esbuild = require("esbuild")
3+
const path = require("path")
4+
5+
// Determine if we're in production mode based on CLI arguments
6+
const production = process.argv.includes("--production")
7+
const watchMode = process.argv.includes("--watch")
8+
9+
async function build() {
10+
try {
11+
const context = await esbuild.context({
12+
entryPoints: [path.resolve(__dirname, "src/extension.ts")],
13+
bundle: true,
14+
outfile: path.resolve(__dirname, "dist/extension.js"),
15+
external: ["vscode"], // vscode module is provided by VS Code runtime
16+
format: "cjs", // VS Code extensions use CommonJS
17+
platform: "node", // Target Node.js environment
18+
sourcemap: !production, // Generate sourcemaps if not in production
19+
minify: production, // Minify code if in production
20+
// Define other esbuild options as needed
21+
})
22+
23+
if (watchMode) {
24+
await context.watch()
25+
console.log("Watching for changes...")
26+
} else {
27+
await context.rebuild()
28+
await context.dispose()
29+
console.log("Build succeeded.")
30+
}
31+
} catch (e) {
32+
console.error("Build failed:", e)
33+
process.exit(1)
34+
}
35+
}
36+
37+
build()

evals/cli/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import { evalsEnvHandler } from "./commands/evals-env"
1010
const program = new Command()
1111

1212
// Set up CLI metadata
13-
program.name("CodinIT-eval").description("CLI tool for orchestrating CodinIT evaluations across multiple benchmarks").version("0.1.0")
13+
program
14+
.name("CodinIT-eval")
15+
.description("CLI tool for orchestrating CodinIT evaluations across multiple benchmarks")
16+
.version("0.1.0")
1417

1518
// Setup command
1619
program

evals/cli/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"target": "ES2020",
44
"module": "commonjs",
55
"lib": ["ES2020"],
6+
"types": ["node"],
67
"declaration": true,
78
"outDir": "dist",
89
"rootDir": "src",

memory-bank/raw_reflection_log.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
Date: 2025-05-18
3+
TaskRef: "Fix 'npm run compile' failing due to missing esbuild.js"
4+
5+
Learnings:
6+
- The `compile` script `npm run check-types && npm run lint && node esbuild.js` in `package.json` failed with `Error: Cannot find module 'C:\Users\Gerome\codinit\esbuild.js'`.
7+
- This error directly indicated that the `esbuild.js` file was missing from the project root.
8+
- `esbuild` was listed as a dev dependency, implying a custom build script (`esbuild.js`) was expected.
9+
- A common `esbuild.js` configuration for a VS Code TypeScript extension includes:
10+
- Entry point: `src/extension.ts` (or similar, like `src/main.ts`).
11+
- Output file: `dist/extension.js` (matching the `main` field in `package.json`).
12+
- External dependencies: `['vscode']` (as `vscode` is provided by the VS Code runtime).
13+
- Module format: `cjs` (CommonJS, standard for VS Code extensions).
14+
- Platform: `node`.
15+
- Conditional sourcemap generation and minification based on `--production` flag.
16+
- Support for a `--watch` flag.
17+
- The project's `package.json` specified `typescript: "~5.5.3"`, but the actual version in use (indicated by warnings) was `5.8.3`. The `@typescript-eslint/typescript-estree` package had a compatibility warning for this version (supports `>=4.7.4 <5.6.0`). This was a secondary issue not directly causing the compile failure but noted for future attention.
18+
19+
Difficulties:
20+
- The `esbuild.js` file was entirely missing, and its original content was unknown. The solution involved creating a new, standard configuration. If the original script had project-specific complexities, the generated one might have needed further adjustments.
21+
22+
Successes:
23+
- Correctly diagnosed the `MODULE_NOT_FOUND` error as a missing file.
24+
- Successfully created a new `esbuild.js` file with a standard configuration for a VS Code extension.
25+
- The `npm run compile` command subsequently completed with "Build succeeded."
26+
27+
Improvements_Identified_For_Consolidation:
28+
- General Pattern: When a build script like `node some-bundler-config.js` fails with `MODULE_NOT_FOUND`, and the bundler (e.g., `esbuild`, `webpack`) is a project dependency, it's highly probable the configuration script itself (`some-bundler-config.js`) is missing. A template for this script can often be generated based on project conventions (e.g., `package.json`'s `main` field, common source directories) and the bundler's typical usage for that project type (e.g., VS Code extension, web app).
29+
- Project-Specific: The `claude-dev` project (this project) uses an `esbuild.js` file at the root for its `compile` and `package` npm scripts.
30+
- Troubleshooting: `MODULE_NOT_FOUND` for a script executed via `node <scriptname>.js` is a direct indicator of the absence of `<scriptname>.js` in the path Node.js is looking for it (usually relative to the CWD or an absolute path if specified).
31+
---

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,6 @@
5353
}
5454
]
5555
},
56-
"views": {
57-
"claude-dev-ActivityBar": [
58-
{
59-
"type": "webview",
60-
"id": "claude-dev.SidebarProvider",
61-
"name": ""
62-
}
63-
]
64-
},
6556
"commands": [
6657
{
6758
"command": "CodinIt.plusButtonClicked",
@@ -322,7 +313,7 @@
322313
"@types/diff": "^5.2.1",
323314
"@types/get-folder-size": "^3.0.4",
324315
"@types/mocha": "^10.0.10",
325-
"@types/node": "20.x",
316+
"@types/node": "^20.17.47",
326317
"@types/pdf-parse": "^1.1.4",
327318
"@types/proxyquire": "^1.3.31",
328319
"@types/should": "^11.2.0",
@@ -348,7 +339,7 @@
348339
"ts-node": "^10.9.2",
349340
"ts-proto": "^2.6.1",
350341
"tsconfig-paths": "^4.2.0",
351-
"typescript": "^5.4.5",
342+
"typescript": "~5.5.3",
352343
"vitest": "^3.1.2"
353344
},
354345
"dependencies": {

src/api/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { QwenHandler } from "./providers/qwen"
1717
import { MistralHandler } from "./providers/mistral"
1818
import { DoubaoHandler } from "./providers/doubao"
1919
import { VsCodeLmHandler } from "./providers/vscode-lm"
20-
import { CodinITHandler } from "./providers/CodinIT"
20+
import { ClineHandler } from "./providers/codinit"
2121
import { LiteLlmHandler } from "./providers/litellm"
2222
import { AskSageHandler } from "./providers/asksage"
2323
import { XAIHandler } from "./providers/xai"
@@ -68,8 +68,8 @@ export function buildApiHandler(configuration: ApiConfiguration): ApiHandler {
6868
return new MistralHandler(options)
6969
case "vscode-lm":
7070
return new VsCodeLmHandler(options)
71-
case "CodinIT":
72-
return new CodinITHandler(options)
71+
case "codinit":
72+
return new ClineHandler(options)
7373
case "litellm":
7474
return new LiteLlmHandler(options)
7575
case "asksage":
Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
import { Anthropic } from "@anthropic-ai/sdk"
22
import OpenAI from "openai"
3-
import { ApiHandler } from "../"
3+
import axios from "axios"
4+
import { ApiHandler } from ".."
45
import { ApiHandlerOptions, ModelInfo, openRouterDefaultModelId, openRouterDefaultModelInfo } from "@shared/api"
5-
import { createOpenRouterStream } from "../transform/openrouter-stream"
66
import { ApiStream, ApiStreamUsageChunk } from "../transform/stream"
7-
import axios from "axios"
87
import { OpenRouterErrorResponse } from "./types"
8+
import { createOpenRouterStream } from "../transform/openrouter-stream"
99

10-
export class CodinITHandler implements ApiHandler {
10+
export class ClineHandler implements ApiHandler {
1111
private options: ApiHandlerOptions
12-
private client: OpenAI
12+
private client: OpenAI // Assuming Cline API is compatible with OpenAI client
1313
lastGenerationId?: string
1414

1515
constructor(options: ApiHandlerOptions) {
1616
this.options = options
1717
this.client = new OpenAI({
18-
baseURL: "https://api.CodinIT.bot/v1",
19-
apiKey: this.options.CodinITApiKey || "",
18+
baseURL: "https://api.cline.bot/v1",
2019
defaultHeaders: {
21-
"HTTP-Referer": "https://CodinIT.bot", // Optional, for including your app on CodinIT.bot rankings.
22-
"X-Title": "CodinIT", // Optional. Shows in rankings on CodinIT.bot.
23-
"X-Task-ID": this.options.taskId || "", // Include the task ID in the request headers
20+
"HTTP-Referer": "https://cline.bot", // Optional, for including your app on cline.bot rankings.
21+
"X-Title": "CodinIT", // Optional. Shows in rankings on cline.bot.
22+
"X-Task-ID": this.options.taskId || "", // Include the task ID in the request headers (if applicable)
2423
},
2524
})
2625
}
@@ -29,6 +28,7 @@ export class CodinITHandler implements ApiHandler {
2928
this.lastGenerationId = undefined
3029

3130
const stream = await createOpenRouterStream(
31+
// Reusing OpenRouter stream creation logic
3232
this.client,
3333
systemPrompt,
3434
messages,
@@ -41,22 +41,25 @@ export class CodinITHandler implements ApiHandler {
4141
let didOutputUsage: boolean = false
4242

4343
for await (const chunk of stream) {
44+
// Process chunks from the stream
4445
// openrouter returns an error object instead of the openai sdk throwing an error
4546
if ("error" in chunk) {
4647
const error = chunk.error as OpenRouterErrorResponse["error"]
47-
console.error(`CodinIT API Error: ${error?.code} - ${error?.message}`)
48+
console.error(`Cline API Error: ${error?.code} - ${error?.message}`)
4849
// Include metadata in the error message if available
4950
const metadataStr = error.metadata ? `\nMetadata: ${JSON.stringify(error.metadata, null, 2)}` : ""
50-
throw new Error(`CodinIT API Error ${error.code}: ${error.message}${metadataStr}`)
51+
throw new Error(`Cline API Error ${error.code}: ${error.message}${metadataStr}`)
5152
}
5253

5354
if (!this.lastGenerationId && chunk.id) {
55+
// Capture generation ID if available
5456
this.lastGenerationId = chunk.id
5557
}
5658

5759
const delta = chunk.choices[0]?.delta
5860
if (delta?.content) {
5961
yield {
62+
// Yield text content
6063
type: "text",
6164
text: delta.content,
6265
}
@@ -65,6 +68,7 @@ export class CodinITHandler implements ApiHandler {
6568
// Reasoning tokens are returned separately from the content
6669
if ("reasoning" in delta && delta.reasoning) {
6770
yield {
71+
// Yield reasoning content
6872
type: "reasoning",
6973
// @ts-ignore-next-line
7074
reasoning: delta.reasoning,
@@ -73,6 +77,7 @@ export class CodinITHandler implements ApiHandler {
7377

7478
if (!didOutputUsage && chunk.usage) {
7579
yield {
80+
// Yield usage information
7681
type: "usage",
7782
cacheWriteTokens: 0,
7883
cacheReadTokens: chunk.usage.prompt_tokens_details?.cached_tokens || 0,
@@ -87,7 +92,7 @@ export class CodinITHandler implements ApiHandler {
8792

8893
// Fallback to generation endpoint if usage chunk not returned
8994
if (!didOutputUsage) {
90-
const apiStreamUsage = await this.getApiStreamUsage()
95+
const apiStreamUsage = await this.getApiStreamUsage() // Attempt to retrieve usage from a separate endpoint
9196
if (apiStreamUsage) {
9297
yield apiStreamUsage
9398
}
@@ -97,13 +102,13 @@ export class CodinITHandler implements ApiHandler {
97102
async getApiStreamUsage(): Promise<ApiStreamUsageChunk | undefined> {
98103
if (this.lastGenerationId) {
99104
try {
100-
const response = await axios.get(`https://api.CodinIT.bot/v1/generation?id=${this.lastGenerationId}`, {
101-
headers: {
102-
Authorization: `Bearer ${this.options.CodinITApiKey}`,
103-
},
105+
// Attempt to fetch generation details
106+
const response = await axios.get(`https://api.cline.bot/v1/generation?id=${this.lastGenerationId}`, {
107+
// Assuming Cline API has a similar endpoint
108+
headers: {},
104109
timeout: 15_000, // this request hangs sometimes
105110
})
106-
111+
// Process the response data
107112
const generation = response.data
108113
return {
109114
type: "usage",
@@ -113,20 +118,20 @@ export class CodinITHandler implements ApiHandler {
113118
inputTokens: generation?.native_tokens_prompt || 0,
114119
outputTokens: generation?.native_tokens_completion || 0,
115120
totalCost: generation?.total_cost || 0,
116-
}
121+
} // Return usage data
117122
} catch (error) {
118123
// ignore if fails
119-
console.error("Error fetching CodinIT generation details:", error)
120-
}
124+
console.error("Error fetching Cline generation details:", error)
125+
} // Handle errors gracefully
121126
}
122-
return undefined
127+
return undefined // Return undefined if no generation ID or fetch fails
123128
}
124129

125130
getModel(): { id: string; info: ModelInfo } {
126131
const modelId = this.options.openRouterModelId
127132
const modelInfo = this.options.openRouterModelInfo
128133
if (modelId && modelInfo) {
129-
return { id: modelId, info: modelInfo }
134+
return { id: modelId, info: modelInfo } // Use provided model ID and info if available
130135
}
131136
return { id: openRouterDefaultModelId, info: openRouterDefaultModelInfo }
132137
}

0 commit comments

Comments
 (0)