UNPKG

newo

Version:

NEWO CLI: Professional command-line tool with modular architecture for NEWO AI Agent development. Features account migration, integration management, webhook automation, AKB knowledge base, project attributes, sandbox testing, IDN-based file management, r

83 lines 4.09 kB
import fs from 'fs-extra'; import path from 'path'; export const NEWO_CUSTOMERS_DIR = path.posix.join(process.cwd(), 'newo_customers'); export const STATE_DIR = path.join(process.cwd(), '.newo'); export function customerDir(customerIdn) { return path.posix.join(NEWO_CUSTOMERS_DIR, customerIdn); } export function customerProjectsDir(customerIdn) { return path.posix.join(customerDir(customerIdn), 'projects'); } export function customerStateDir(customerIdn) { return path.join(STATE_DIR, customerIdn); } export function mapPath(customerIdn) { return path.join(customerStateDir(customerIdn), 'map.json'); } export function hashesPath(customerIdn) { return path.join(customerStateDir(customerIdn), 'hashes.json'); } export async function ensureState(customerIdn) { await fs.ensureDir(STATE_DIR); await fs.ensureDir(customerStateDir(customerIdn)); await fs.ensureDir(customerProjectsDir(customerIdn)); } export function projectDir(customerIdn, projectIdn) { return path.posix.join(customerProjectsDir(customerIdn), projectIdn); } export function flowsYamlPath(customerIdn) { return path.posix.join(customerProjectsDir(customerIdn), 'flows.yaml'); } export function customerAttributesPath(customerIdn) { return path.posix.join(customerDir(customerIdn), 'attributes.yaml'); } export function customerAttributesMapPath(customerIdn) { return path.join(customerStateDir(customerIdn), 'attributes-map.json'); } export function customerAttributesBackupPath(customerIdn) { return path.join(customerStateDir(customerIdn), 'attributes-backup.yaml'); } // Legacy skill path - direct file export function skillPath(customerIdn, projectIdn, agentIdn, flowIdn, skillIdn, runnerType = 'guidance') { const extension = runnerType === 'nsl' ? '.jinja' : '.guidance'; return path.posix.join(customerProjectsDir(customerIdn), projectIdn, agentIdn, flowIdn, `${skillIdn}${extension}`); } // New hierarchical structure paths export function skillFolderPath(customerIdn, projectIdn, agentIdn, flowIdn, skillIdn) { return path.posix.join(customerProjectsDir(customerIdn), projectIdn, agentIdn, flowIdn, skillIdn); } export function skillScriptPath(customerIdn, projectIdn, agentIdn, flowIdn, skillIdn, runnerType = 'guidance') { const extension = runnerType === 'nsl' ? '.jinja' : '.guidance'; return path.posix.join(skillFolderPath(customerIdn, projectIdn, agentIdn, flowIdn, skillIdn), `${skillIdn}${extension}`); } // Metadata paths for hierarchical structure export function projectMetadataPath(customerIdn, projectIdn) { return path.posix.join(customerProjectsDir(customerIdn), projectIdn, 'metadata.yaml'); } export function agentMetadataPath(customerIdn, projectIdn, agentIdn) { return path.posix.join(customerProjectsDir(customerIdn), projectIdn, agentIdn, 'metadata.yaml'); } export function flowMetadataPath(customerIdn, projectIdn, agentIdn, flowIdn) { return path.posix.join(customerProjectsDir(customerIdn), projectIdn, agentIdn, flowIdn, 'metadata.yaml'); } export function skillMetadataPath(customerIdn, projectIdn, agentIdn, flowIdn, skillIdn) { return path.posix.join(skillFolderPath(customerIdn, projectIdn, agentIdn, flowIdn, skillIdn), 'metadata.yaml'); } // Legacy metadata path - keep for backwards compatibility export function metadataPath(customerIdn, projectIdn) { return path.posix.join(customerProjectsDir(customerIdn), projectIdn, 'metadata.json'); } // Legacy support - will be deprecated export const ROOT_DIR = path.posix.join(process.cwd(), 'projects'); export const MAP_PATH = path.join(STATE_DIR, 'map.json'); export const HASHES_PATH = path.join(STATE_DIR, 'hashes.json'); export async function writeFileSafe(filepath, content) { await fs.ensureDir(path.dirname(filepath)); await fs.writeFile(filepath, content, 'utf8'); } // Deprecated: use writeFileSafe instead export const writeFileAtomic = writeFileSafe; export async function readIfExists(filepath) { return (await fs.pathExists(filepath)) ? fs.readFile(filepath, 'utf8') : null; } //# sourceMappingURL=fsutil.js.map