refactor: Migrate all lib packages to ESM

Convert all shared library packages from CommonJS to ESM for consistency
with apps/server and modern JavaScript standards.

Changes:
- Add "type": "module" to package.json for all libs
- Update tsconfig.json to use "NodeNext" module/moduleResolution
- Add .js extensions to all relative imports

Packages migrated:
- @automaker/dependency-resolver (already ESM, added .js extension)
- @automaker/git-utils (CommonJS → ESM)
- @automaker/model-resolver (CommonJS → ESM)
- @automaker/platform (CommonJS → ESM)
- @automaker/utils (CommonJS → ESM)

Benefits:
 Consistent module system across all packages
 Better tree-shaking and modern bundling support
 Native browser support (future-proof)
 Fixes E2E CI server startup issues

All tests passing: 632/632 server tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Kacper
2025-12-21 00:23:13 +01:00
parent 49a5a7448c
commit c1386caeb2
16 changed files with 34 additions and 22 deletions

View File

@@ -8,4 +8,4 @@ export {
areDependenciesSatisfied, areDependenciesSatisfied,
getBlockingDependencies, getBlockingDependencies,
type DependencyResolutionResult, type DependencyResolutionResult,
} from './resolver'; } from './resolver.js';

View File

@@ -1,6 +1,7 @@
{ {
"name": "@automaker/git-utils", "name": "@automaker/git-utils",
"version": "1.0.0", "version": "1.0.0",
"type": "module",
"description": "Git operations utilities for AutoMaker", "description": "Git operations utilities for AutoMaker",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@@ -7,8 +7,8 @@ import fs from "fs/promises";
import path from "path"; import path from "path";
import { exec } from "child_process"; import { exec } from "child_process";
import { promisify } from "util"; import { promisify } from "util";
import { BINARY_EXTENSIONS, type FileStatus } from './types'; import { BINARY_EXTENSIONS, type FileStatus } from './types.js';
import { isGitRepo, parseGitStatus } from './status'; import { isGitRepo, parseGitStatus } from './status.js';
const execAsync = promisify(exec); const execAsync = promisify(exec);
const logger = createLogger("GitUtils"); const logger = createLogger("GitUtils");

View File

@@ -8,13 +8,13 @@ export {
BINARY_EXTENSIONS, BINARY_EXTENSIONS,
GIT_STATUS_MAP, GIT_STATUS_MAP,
type FileStatus, type FileStatus,
} from './types'; } from './types.js';
// Export status utilities // Export status utilities
export { export {
isGitRepo, isGitRepo,
parseGitStatus, parseGitStatus,
} from './status'; } from './status.js';
// Export diff utilities // Export diff utilities
export { export {
@@ -23,4 +23,4 @@ export {
listAllFilesInDirectory, listAllFilesInDirectory,
generateDiffsForNonGitDirectory, generateDiffsForNonGitDirectory,
getGitRepositoryDiffs, getGitRepositoryDiffs,
} from './diff'; } from './diff.js';

View File

@@ -4,7 +4,7 @@
import { exec } from "child_process"; import { exec } from "child_process";
import { promisify } from "util"; import { promisify } from "util";
import { GIT_STATUS_MAP, type FileStatus } from './types'; import { GIT_STATUS_MAP, type FileStatus } from './types.js';
const execAsync = promisify(exec); const execAsync = promisify(exec);

View File

@@ -2,7 +2,9 @@
"extends": "../tsconfig.base.json", "extends": "../tsconfig.base.json",
"compilerOptions": { "compilerOptions": {
"outDir": "./dist", "outDir": "./dist",
"rootDir": "./src" "rootDir": "./src",
"module": "NodeNext",
"moduleResolution": "NodeNext"
}, },
"include": ["src/**/*"], "include": ["src/**/*"],
"exclude": ["node_modules", "dist"] "exclude": ["node_modules", "dist"]

View File

@@ -1,6 +1,7 @@
{ {
"name": "@automaker/model-resolver", "name": "@automaker/model-resolver",
"version": "1.0.0", "version": "1.0.0",
"type": "module",
"description": "Model resolution utilities for AutoMaker", "description": "Model resolution utilities for AutoMaker",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@@ -10,4 +10,4 @@ export { CLAUDE_MODEL_MAP, DEFAULT_MODELS, type ModelAlias } from '@automaker/ty
export { export {
resolveModelString, resolveModelString,
getEffectiveModel, getEffectiveModel,
} from './resolver'; } from './resolver.js';

View File

@@ -2,7 +2,9 @@
"extends": "../tsconfig.base.json", "extends": "../tsconfig.base.json",
"compilerOptions": { "compilerOptions": {
"outDir": "./dist", "outDir": "./dist",
"rootDir": "./src" "rootDir": "./src",
"module": "NodeNext",
"moduleResolution": "NodeNext"
}, },
"include": ["src/**/*"], "include": ["src/**/*"],
"exclude": ["node_modules", "dist"] "exclude": ["node_modules", "dist"]

View File

@@ -1,6 +1,7 @@
{ {
"name": "@automaker/platform", "name": "@automaker/platform",
"version": "1.0.0", "version": "1.0.0",
"type": "module",
"description": "Platform-specific utilities for AutoMaker", "description": "Platform-specific utilities for AutoMaker",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@@ -20,7 +20,7 @@ export {
getCredentialsPath, getCredentialsPath,
getProjectSettingsPath, getProjectSettingsPath,
ensureDataDir, ensureDataDir,
} from './paths'; } from './paths.js';
// Subprocess management // Subprocess management
export { export {
@@ -28,7 +28,7 @@ export {
spawnProcess, spawnProcess,
type SubprocessOptions, type SubprocessOptions,
type SubprocessResult, type SubprocessResult,
} from './subprocess'; } from './subprocess.js';
// Security // Security
export { export {
@@ -37,4 +37,4 @@ export {
isPathAllowed, isPathAllowed,
validatePath, validatePath,
getAllowedPaths, getAllowedPaths,
} from './security'; } from './security.js';

View File

@@ -2,7 +2,9 @@
"extends": "../tsconfig.base.json", "extends": "../tsconfig.base.json",
"compilerOptions": { "compilerOptions": {
"outDir": "./dist", "outDir": "./dist",
"rootDir": "./src" "rootDir": "./src",
"module": "NodeNext",
"moduleResolution": "NodeNext"
}, },
"include": ["src/**/*"], "include": ["src/**/*"],
"exclude": ["node_modules", "dist"] "exclude": ["node_modules", "dist"]

View File

@@ -1,6 +1,7 @@
{ {
"name": "@automaker/utils", "name": "@automaker/utils",
"version": "1.0.0", "version": "1.0.0",
"type": "module",
"description": "Shared utility functions for AutoMaker", "description": "Shared utility functions for AutoMaker",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@@ -10,7 +10,7 @@ export {
isAuthenticationError, isAuthenticationError,
classifyError, classifyError,
getUserFriendlyErrorMessage, getUserFriendlyErrorMessage,
} from './error-handler'; } from './error-handler.js';
// Conversation utilities // Conversation utilities
export { export {
@@ -18,7 +18,7 @@ export {
normalizeContentBlocks, normalizeContentBlocks,
formatHistoryAsText, formatHistoryAsText,
convertHistoryToMessages, convertHistoryToMessages,
} from './conversation-utils'; } from './conversation-utils.js';
// Image handling // Image handling
export { export {
@@ -26,14 +26,14 @@ export {
readImageAsBase64, readImageAsBase64,
convertImagesToContentBlocks, convertImagesToContentBlocks,
formatImagePathsForPrompt, formatImagePathsForPrompt,
} from './image-handler'; } from './image-handler.js';
// Prompt building // Prompt building
export { export {
buildPromptWithImages, buildPromptWithImages,
type PromptContent, type PromptContent,
type PromptWithImages, type PromptWithImages,
} from './prompt-builder'; } from './prompt-builder.js';
// Logger // Logger
export { export {
@@ -41,10 +41,10 @@ export {
getLogLevel, getLogLevel,
setLogLevel, setLogLevel,
LogLevel, LogLevel,
} from './logger'; } from './logger.js';
// File system utilities // File system utilities
export { export {
mkdirSafe, mkdirSafe,
existsSafe, existsSafe,
} from './fs-utils'; } from './fs-utils.js';

View File

@@ -8,7 +8,7 @@
* - Supports both vision and non-vision models * - Supports both vision and non-vision models
*/ */
import { convertImagesToContentBlocks, formatImagePathsForPrompt } from "./image-handler"; import { convertImagesToContentBlocks, formatImagePathsForPrompt } from "./image-handler.js";
/** /**
* Content that can be either simple text or structured blocks * Content that can be either simple text or structured blocks

View File

@@ -2,7 +2,9 @@
"extends": "../tsconfig.base.json", "extends": "../tsconfig.base.json",
"compilerOptions": { "compilerOptions": {
"outDir": "./dist", "outDir": "./dist",
"rootDir": "./src" "rootDir": "./src",
"module": "NodeNext",
"moduleResolution": "NodeNext"
}, },
"include": ["src/**/*"], "include": ["src/**/*"],
"exclude": ["node_modules", "dist"] "exclude": ["node_modules", "dist"]