Files
codetyper.cli/test/tools.test.ts
Carlos Gutierrez 187cc68304 Improve agent autonomy and diff view readability
Agent behavior improvements:
  - Add project context detection (tsconfig.json, pom.xml, etc.)
  - Enforce validation after changes (tsc --noEmit, mvn compile, etc.)
  - Run tests automatically - never ask "do you want me to run tests"
  - Complete full loop: create → type-check → test → confirm
  - Add command detection for direct execution (run tree, run ls)

  Diff view improvements:
  - Use darker backgrounds for added/removed lines
  - Add diffLineBgAdded, diffLineBgRemoved, diffLineText theme colors
  - Improve text visibility with white text on dark backgrounds
  - Update both React/Ink and SolidJS diff components

  Streaming fixes:
  - Fix tool call argument accumulation using OpenAI index field
  - Fix streaming content display after tool calls
  - Add consecutive error tracking to prevent token waste

  Other changes:
  - ESC to abort operations, Ctrl+C to exit
  - Fix model selection when provider changes in cascade mode
  - Add debug logging for troubleshooting
  - Move tests to root tests/ folder
  - Fix banner test GRADIENT_COLORS reference
2026-01-29 07:33:30 -05:00

50 lines
1.8 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { viewTool } from '../src/tools/view.js';
import { editTool } from '../src/tools/edit.js';
import { writeTool } from '../src/tools/write.js';
import { grepTool } from '../src/tools/grep.js';
import { globTool } from '../src/tools/glob.js';
import { bashTool } from '../src/tools/bash.js';
describe('Tools', () => {
describe('ViewTool', () => {
it('should read file contents', async () => {
const result = await viewTool.execute('package.json');
expect(result.success).toBe(true);
expect(result.output).toContain('codetyper-cli');
});
it('should check if file exists', async () => {
const exists = await viewTool.exists('package.json');
expect(exists).toBe(true);
});
});
describe('GlobTool', () => {
it('should find TypeScript files', async () => {
const result = await globTool.execute('src/**/*.ts');
expect(result.success).toBe(true);
expect(result.files).toBeDefined();
expect(result.files!.length).toBeGreaterThan(0);
});
it('should find files by extension', async () => {
const files = await globTool.findByExtension('ts', 'src');
expect(files.length).toBeGreaterThan(0);
});
});
describe('BashTool', () => {
it('should execute simple command', async () => {
const result = await bashTool.execute({ command: 'echo "Hello World"', description: 'Test command' }, { autoApprove: true, abort: new AbortController() });
expect(result.success).toBe(true);
expect(result.output).toContain('Hello World');
});
it('should check if command exists', async () => {
const exists = await bashTool.execute({ command: 'command -v node', description: 'Check if node exists' }, { autoApprove: true, abort: new AbortController() });
expect(exists.success).toBe(true);
});
});
});