mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-01 06:42:06 +01:00
Land the approved Cloud configuration and release-image package stack.
Includes the separately reviewed adapter settings (#18335), external adapters (#18333), bundled plugins (#18336), startup configuration (#18339), and migration/package checks (#18341).
Includes the final image-owned loader and linked-dependency inventory corrections.
Verified stack head: 462716170d.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { resolveDefaultConfigPath } from "./home-paths.js";
|
|
import { isCloudManagedInstance } from "./services/cloud-instance.js";
|
|
|
|
const PAPERCLIP_CONFIG_BASENAME = "config.json";
|
|
const PAPERCLIP_ENV_FILENAME = ".env";
|
|
|
|
function findConfigFileFromAncestors(startDir: string): string | null {
|
|
const absoluteStartDir = path.resolve(startDir);
|
|
let currentDir = absoluteStartDir;
|
|
|
|
while (true) {
|
|
const candidate = path.resolve(currentDir, ".paperclip", PAPERCLIP_CONFIG_BASENAME);
|
|
if (fs.existsSync(candidate)) {
|
|
return candidate;
|
|
}
|
|
|
|
const nextDir = path.resolve(currentDir, "..");
|
|
if (nextDir === currentDir) break;
|
|
currentDir = nextDir;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
export function resolvePaperclipConfigPath(overridePath?: string): string {
|
|
if (overridePath) return path.resolve(overridePath);
|
|
if (process.env.PAPERCLIP_CONFIG) return path.resolve(process.env.PAPERCLIP_CONFIG);
|
|
if (isCloudManagedInstance()) return resolveDefaultConfigPath();
|
|
return findConfigFileFromAncestors(process.cwd()) ?? resolveDefaultConfigPath();
|
|
}
|
|
|
|
export function resolvePaperclipEnvPath(overrideConfigPath?: string): string {
|
|
return path.resolve(path.dirname(resolvePaperclipConfigPath(overrideConfigPath)), PAPERCLIP_ENV_FILENAME);
|
|
}
|