mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-16 21:53:07 +00:00
fix: Update @github/copilot-sdk version and enhance version utility to locate package.json (#840)
- Changed @github/copilot-sdk dependency from "^0.1.16" to "0.1.16" in package.json and package-lock.json. - Improved version utility in version.ts to check multiple candidate paths for package.json, ensuring better reliability in locating the file.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -113,3 +113,4 @@ data/
|
|||||||
.planning/
|
.planning/
|
||||||
.mcp.json
|
.mcp.json
|
||||||
.planning
|
.planning
|
||||||
|
.bg-shell/
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
"@automaker/prompts": "1.0.0",
|
"@automaker/prompts": "1.0.0",
|
||||||
"@automaker/types": "1.0.0",
|
"@automaker/types": "1.0.0",
|
||||||
"@automaker/utils": "1.0.0",
|
"@automaker/utils": "1.0.0",
|
||||||
"@github/copilot-sdk": "^0.1.16",
|
"@github/copilot-sdk": "0.1.16",
|
||||||
"@modelcontextprotocol/sdk": "1.25.2",
|
"@modelcontextprotocol/sdk": "1.25.2",
|
||||||
"@openai/codex-sdk": "^0.98.0",
|
"@openai/codex-sdk": "^0.98.0",
|
||||||
"cookie-parser": "1.4.7",
|
"cookie-parser": "1.4.7",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Version utility - Reads version from package.json
|
* Version utility - Reads version from package.json
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync, existsSync } from 'fs';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import { dirname, join } from 'path';
|
import { dirname, join } from 'path';
|
||||||
import { createLogger } from '@automaker/utils';
|
import { createLogger } from '@automaker/utils';
|
||||||
@@ -24,7 +24,20 @@ export function getVersion(): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const packageJsonPath = join(__dirname, '..', '..', 'package.json');
|
const candidatePaths = [
|
||||||
|
// Development via tsx: src/lib -> project root
|
||||||
|
join(__dirname, '..', '..', 'package.json'),
|
||||||
|
// Packaged/build output: lib -> server bundle root
|
||||||
|
join(__dirname, '..', 'package.json'),
|
||||||
|
];
|
||||||
|
|
||||||
|
const packageJsonPath = candidatePaths.find((candidate) => existsSync(candidate));
|
||||||
|
if (!packageJsonPath) {
|
||||||
|
throw new Error(
|
||||||
|
`package.json not found in any expected location: ${candidatePaths.join(', ')}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
||||||
const version = packageJson.version || '0.0.0';
|
const version = packageJson.version || '0.0.0';
|
||||||
cachedVersion = version;
|
cachedVersion = version;
|
||||||
|
|||||||
@@ -28,12 +28,19 @@ const serverLogger = createLogger('Server');
|
|||||||
export async function startServer(): Promise<void> {
|
export async function startServer(): Promise<void> {
|
||||||
const isDev = !app.isPackaged;
|
const isDev = !app.isPackaged;
|
||||||
|
|
||||||
// Find Node.js executable (handles desktop launcher scenarios)
|
let command: string;
|
||||||
|
let commandSource: string;
|
||||||
|
let args: string[];
|
||||||
|
let serverPath: string;
|
||||||
|
|
||||||
|
if (isDev) {
|
||||||
|
// In development, run the TypeScript server via the user's Node.js.
|
||||||
const nodeResult = findNodeExecutable({
|
const nodeResult = findNodeExecutable({
|
||||||
skipSearch: isDev,
|
skipSearch: true,
|
||||||
logger: (msg: string) => logger.info(msg),
|
logger: (msg: string) => logger.info(msg),
|
||||||
});
|
});
|
||||||
const command = nodeResult.nodePath;
|
command = nodeResult.nodePath;
|
||||||
|
commandSource = nodeResult.source;
|
||||||
|
|
||||||
// Validate that the found Node executable actually exists
|
// Validate that the found Node executable actually exists
|
||||||
// systemPathExists is used because node-finder returns system paths
|
// systemPathExists is used because node-finder returns system paths
|
||||||
@@ -48,12 +55,18 @@ export async function startServer(): Promise<void> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
throw new Error(`Node.js executable not found at: ${command} (source: ${nodeResult.source})`);
|
throw new Error(
|
||||||
|
`Node.js executable not found at: ${command} (source: ${nodeResult.source})`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
let args: string[];
|
// In packaged builds, use Electron's bundled Node runtime instead of a system Node.
|
||||||
let serverPath: string;
|
// This makes the desktop app self-contained and avoids incompatibilities with whatever
|
||||||
|
// Node version the user happens to have installed globally.
|
||||||
|
command = process.execPath;
|
||||||
|
commandSource = 'electron';
|
||||||
|
}
|
||||||
|
|
||||||
// __dirname is apps/ui/dist-electron (Vite bundles all into single file)
|
// __dirname is apps/ui/dist-electron (Vite bundles all into single file)
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
@@ -133,6 +146,8 @@ export async function startServer(): Promise<void> {
|
|||||||
PORT: state.serverPort.toString(),
|
PORT: state.serverPort.toString(),
|
||||||
DATA_DIR: dataDir,
|
DATA_DIR: dataDir,
|
||||||
NODE_PATH: serverNodeModules,
|
NODE_PATH: serverNodeModules,
|
||||||
|
// Run packaged backend with Electron's embedded Node runtime.
|
||||||
|
...(app.isPackaged && { ELECTRON_RUN_AS_NODE: '1' }),
|
||||||
// Pass API key to server for CSRF protection
|
// Pass API key to server for CSRF protection
|
||||||
AUTOMAKER_API_KEY: state.apiKey!,
|
AUTOMAKER_API_KEY: state.apiKey!,
|
||||||
// Only set ALLOWED_ROOT_DIRECTORY if explicitly provided in environment
|
// Only set ALLOWED_ROOT_DIRECTORY if explicitly provided in environment
|
||||||
@@ -146,6 +161,7 @@ export async function startServer(): Promise<void> {
|
|||||||
logger.info('[DATA_DIR_SPAWN] env.DATA_DIR=', env.DATA_DIR);
|
logger.info('[DATA_DIR_SPAWN] env.DATA_DIR=', env.DATA_DIR);
|
||||||
|
|
||||||
logger.info('Starting backend server...');
|
logger.info('Starting backend server...');
|
||||||
|
logger.info('Runtime command:', command, `(source: ${commandSource})`);
|
||||||
logger.info('Server path:', serverPath);
|
logger.info('Server path:', serverPath);
|
||||||
logger.info('Server root (cwd):', serverRoot);
|
logger.info('Server root (cwd):', serverRoot);
|
||||||
logger.info('NODE_PATH:', serverNodeModules);
|
logger.info('NODE_PATH:', serverNodeModules);
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -44,7 +44,7 @@
|
|||||||
"@automaker/prompts": "1.0.0",
|
"@automaker/prompts": "1.0.0",
|
||||||
"@automaker/types": "1.0.0",
|
"@automaker/types": "1.0.0",
|
||||||
"@automaker/utils": "1.0.0",
|
"@automaker/utils": "1.0.0",
|
||||||
"@github/copilot-sdk": "^0.1.16",
|
"@github/copilot-sdk": "0.1.16",
|
||||||
"@modelcontextprotocol/sdk": "1.25.2",
|
"@modelcontextprotocol/sdk": "1.25.2",
|
||||||
"@openai/codex-sdk": "^0.98.0",
|
"@openai/codex-sdk": "^0.98.0",
|
||||||
"cookie-parser": "1.4.7",
|
"cookie-parser": "1.4.7",
|
||||||
|
|||||||
Reference in New Issue
Block a user