import fs from 'fs';
import path from 'path';
import { createDefaultContextFile } from '../templates/defaultContext';
import { ServerConfig } from '../types';
/**
* Initialize the project structure and configuration files
*/
export function setupProject(): void {
const projectDir = process.cwd();
// Create config file if it doesn't exist
const configPath = path.join(projectDir, 'config.json');
if (!fs.existsSync(configPath)) {
const defaultConfig: ServerConfig = {
port: 3000,
contextPath: path.join(projectDir, 'context.json'),
autoInject: true,
triggerKeywords: ['new project', 'build', 'create', 'develop']
};
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
console.log(`Created default configuration at ${configPath}`);
} else {
console.log(`Configuration file already exists at ${configPath}`);
// Removed logic for cleaning up old Knowledge Graph settings
}
// Create context file if it doesn't exist
// Note: ContextService now dynamically generates context.json,
// so creating a default static file might be less relevant.
// Consider removing this or ensuring it aligns with dynamic generation.
const contextPath = path.join(projectDir, 'context.json');
if (!fs.existsSync(contextPath)) {
// If you still want a placeholder file:
const placeholderContext = {
name: "Claude Tool Context",
description: "This context will be dynamically generated on server start.",
version: "auto",
directives: [],
workflows: [],
templates: []
};
fs.writeFileSync(contextPath, JSON.stringify(placeholderContext, null, 2));
console.log(`Created placeholder context file at ${contextPath}`);
// Or remove the call to createDefaultContextFile(contextPath);
} else {
console.log(`Context file already exists at ${contextPath}`);
}
console.log('Project setup complete!');
}