feat: Modernize package with ES modules and improve error handling

- Update to ES modules syntax throughout the codebase
- Add fileURLToPath and dirname imports to handle __dirname in ES modules
- Upgrade Anthropic SDK from 0.10.0 to 0.39.0
- Fix JSON parsing to handle responses wrapped in Markdown code blocks
- Improve documentation with clearer installation instructions
- Add important notes about ES modules and SDK requirements
- Update environment examples with API key format and model recommendations
- Include index.js in package files list
- Bump version to 1.0.2
This commit is contained in:
Eyal Toledano
2025-03-04 14:11:57 -05:00
parent 07648a1417
commit c72373d761
10 changed files with 100 additions and 51 deletions

View File

@@ -6,14 +6,22 @@
// This file serves as the main entry point for the package
// The primary functionality is provided through the CLI commands
import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';
import { createRequire } from 'module';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const require = createRequire(import.meta.url);
// Export the path to the dev.js script for programmatic usage
exports.devScriptPath = require.resolve('./scripts/dev.js');
export const devScriptPath = resolve(__dirname, './scripts/dev.js');
// Export a function to initialize a new project programmatically
exports.initProject = async (options = {}) => {
const init = require('./scripts/init');
export const initProject = async (options = {}) => {
const init = await import('./scripts/init.js');
return init.initializeProject(options);
};
// Export version information
exports.version = require('./package.json').version;
export const version = require('./package.json').version;