glitool 2.0.4 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,24 +2,20 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import React, { useState, useEffect } from 'react';
3
3
  import { Box, Text } from 'ink';
4
4
  const STAGE_COLOR = {
5
- planner: '#c4732e',
6
- coder: '#3e8a9a',
7
- validator: '#6c5ab8',
8
- judge: '#5a8c5a',
9
- debugger: '#b54226',
10
- reviewer: '#6c5ab8',
11
- refactorer: '#3e8a9a',
12
- git_agent: '#5a8c5a',
5
+ coding: '#3e8a9a',
6
+ debugging: '#b54226',
7
+ refactoring: '#3e8a9a',
8
+ git: '#5a8c5a',
9
+ planning: '#c4732e',
10
+ review: '#6c5ab8',
13
11
  };
14
12
  const STAGE_LABEL = {
15
- planner: 'PLANNER',
16
- coder: 'CODER',
17
- validator: 'VALIDATOR',
18
- judge: 'JUDGE',
19
- debugger: 'DEBUGGER',
20
- reviewer: 'REVIEWER',
21
- refactorer: 'REFACTORER',
22
- git_agent: 'GIT',
13
+ coding: 'CODING',
14
+ debugging: 'DEBUGGING',
15
+ refactoring: 'REFACTORING',
16
+ git: 'GIT',
17
+ planning: 'PLANNING',
18
+ review: 'REVIEW',
23
19
  };
24
20
  const TOOL_VERB = {
25
21
  readFile: 'read',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitool",
3
- "version": "2.0.4",
3
+ "version": "2.1.0",
4
4
  "description": "AI coding assistant for your terminal",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,22 +0,0 @@
1
- // REPLACE the whole file with:
2
- import { makeLlm } from '../llm/factory.js';
3
- import { SystemMessage, HumanMessage } from "@langchain/core/messages";
4
- export async function runReviewer(plan, coderOutput, userMessage, model) {
5
- const llm = makeLlm(model);
6
- const response = await llm.invoke([
7
- new SystemMessage(`You are a code reviewer. check if the coder's work correctly fulfills the user's request. Return valid JSON only:
8
- {
9
- "approved": true or false,
10
- "feedback": "what needs fixing if not approved, otherwise empty string",
11
- "finalResponse": "the final message to show the user summarizing what was done"
12
- }`),
13
- new HumanMessage(`User request: ${userMessage}\n\nPlan:\n${plan}\n\nWhat was done:\n${coderOutput}`)
14
- ]);
15
- try {
16
- const cleaned = response.content.replace(/```json|```/g, '').trim();
17
- return JSON.parse(cleaned);
18
- }
19
- catch {
20
- return { approved: true, feedback: '', finalResponse: coderOutput };
21
- }
22
- }
@@ -1,51 +0,0 @@
1
- import fs from 'fs';
2
- import { get } from 'http';
3
- import path from 'path';
4
- const SKIP_DIRS = ['node_modules', '.git', 'dist', 'build', '.next'];
5
- const TEXT_EXTENSIONS = ['.ts', '.js', '.json', '.md', '.txt', '.tsx', '.jsx', '.css', '.html', '.env'];
6
- const MAX_FILE_SIZE = 50 * 1024; // 50kb
7
- function getFiles(dir, prefix = '') {
8
- const entries = fs.readdirSync(dir, { withFileTypes: true });
9
- const lines = [];
10
- for (const entry of entries) {
11
- if (SKIP_DIRS.includes(entry.name))
12
- continue;
13
- const fullPath = path.join(dir, entry.name);
14
- if (entry.isDirectory()) {
15
- lines.push(`${prefix}${entry.name}/`);
16
- lines.push(...getFiles(fullPath, prefix + ' '));
17
- }
18
- else {
19
- lines.push(`${prefix}${entry.name}`);
20
- }
21
- }
22
- return lines;
23
- }
24
- function getFileContents(dir) {
25
- const entries = fs.readdirSync(dir, { withFileTypes: true });
26
- let result = '';
27
- for (const entry of entries) {
28
- if (SKIP_DIRS.includes(entry.name))
29
- continue;
30
- const fullPath = path.join(dir, entry.name);
31
- if (entry.isDirectory()) {
32
- result += getFileContents(fullPath);
33
- }
34
- else {
35
- const ext = path.extname(entry.name);
36
- if (!TEXT_EXTENSIONS.includes(ext))
37
- continue;
38
- const stats = fs.statSync(fullPath);
39
- if (stats.size > MAX_FILE_SIZE)
40
- continue;
41
- const content = fs.readFileSync(fullPath, 'utf-8');
42
- result += `\n--- File: ${fullPath} ---\n${content}\n`;
43
- }
44
- }
45
- return result;
46
- }
47
- export function getProjectContext(dir) {
48
- const structure = getFiles(dir).join('\n');
49
- const contents = getFileContents(dir);
50
- return `Folder structure:\n${structure}\n\nFile contents:${contents}`;
51
- }
@@ -1,61 +0,0 @@
1
- import { tool } from "@langchain/core/tools";
2
- import fs from 'fs';
3
- import path from 'path';
4
- import { execSync } from "child_process";
5
- import { z } from 'zod';
6
- const SKIP_DIRS = ['node_modules', '.git', 'dist', 'build', '.next'];
7
- function getDependencyList() {
8
- const packageJsonPath = path.join(process.cwd(), 'package.json');
9
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
10
- return packageJson.dependencies || {};
11
- }
12
- function checkForOutdatedDependencies() {
13
- try {
14
- const result = execSync('npm outdated --json', { timeout: 10000, stdio: 'pipe' }).toString();
15
- return JSON.parse(result);
16
- }
17
- catch (error) {
18
- return {};
19
- }
20
- }
21
- function analyzeCodeQuality() {
22
- try {
23
- const result = execSync(`eslint . --format json`, { timeout: 10000, stdio: 'pipe' }).toString();
24
- return JSON.parse(result);
25
- }
26
- catch (error) {
27
- return { error: [], warnings: [] };
28
- }
29
- }
30
- function getFiles(dir) {
31
- const entries = fs.readdirSync(dir, { withFileTypes: true });
32
- const files = [];
33
- for (const entry of entries) {
34
- if (SKIP_DIRS.includes(entry.name))
35
- continue;
36
- const fullPath = path.join(dir, entry.name);
37
- if (entry.isDirectory()) {
38
- files.push(...getFiles(fullPath));
39
- }
40
- else {
41
- files.push(fullPath);
42
- }
43
- }
44
- return files;
45
- }
46
- export const analyzeProjectTool = tool(async () => {
47
- const dependencies = getDependencyList();
48
- const outdatedDependencies = checkForOutdatedDependencies();
49
- const codeQualityResults = analyzeCodeQuality();
50
- const projectFiles = getFiles(process.cwd());
51
- return {
52
- dependencies,
53
- outdatedDependencies,
54
- codeQualityResults,
55
- projectFiles
56
- };
57
- }, {
58
- name: 'analyzeProject',
59
- description: 'analyze the current project for dependencies, code quality , and project structure . useful for getting an overview of the project and identifying potential issues.',
60
- schema: z.object({})
61
- });