"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupProject = setupProject;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const defaultContext_1 = require("../templates/defaultContext");
/**
* Initialize the project structure and configuration files
*/
function setupProject() {
const projectDir = process.cwd();
// Create config file if it doesn't exist
const configPath = path_1.default.join(projectDir, 'config.json');
if (!fs_1.default.existsSync(configPath)) {
const defaultConfig = {
port: 3000,
contextPath: path_1.default.join(projectDir, 'context.json'),
autoInject: true,
triggerKeywords: ['new project', 'build', 'create', 'develop'],
knowledgeGraphReference: true,
knowledgeGraphReferenceText: "Please reference my Knowledge Graph for development frameworks, workflows, and patterns."
};
fs_1.default.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
console.log(`Created default configuration at ${configPath}`);
}
else {
console.log(`Configuration file already exists at ${configPath}`);
// Update existing config with Knowledge Graph reference settings if missing
try {
const configContent = fs_1.default.readFileSync(configPath, 'utf8');
const config = JSON.parse(configContent);
let updated = false;
if (config.knowledgeGraphReference === undefined) {
config.knowledgeGraphReference = true;
updated = true;
}
if (config.knowledgeGraphReferenceText === undefined) {
config.knowledgeGraphReferenceText = "Please reference my Knowledge Graph for development frameworks, workflows, and patterns.";
updated = true;
}
if (updated) {
fs_1.default.writeFileSync(configPath, JSON.stringify(config, null, 2));
console.log(`Updated configuration at ${configPath} with Knowledge Graph reference settings`);
}
}
catch (error) {
console.error('Error updating existing configuration:', error instanceof Error ? error.message : String(error));
}
}
// Create context file if it doesn't exist
const contextPath = path_1.default.join(projectDir, 'context.json');
if (!fs_1.default.existsSync(contextPath)) {
(0, defaultContext_1.createDefaultContextFile)(contextPath);
}
else {
console.log(`Context file already exists at ${contextPath}`);
}
console.log('Project setup complete!');
}
//# sourceMappingURL=setup.js.map