@puls-atlas/cli
Version:
The Puls Atlas CLI tool for managing Atlas projects
32 lines • 1.35 kB
JavaScript
import { logger } from '../../utils/logger.js';
import { createAtlasAiArtifacts, createGeneratedFileDriftIssues, logAiWriteOutcome, writeAtlasAiArtifacts } from './artifactsRuntime.js';
export const runAiSync = async (options = {}, dependencies = {}, cwd = process.cwd()) => {
const loggerImpl = dependencies.logger ?? logger;
let spinner;
try {
spinner = loggerImpl.spinner('Syncing Atlas AI context...');
const artifacts = createAtlasAiArtifacts(options, dependencies, cwd, 'atlas ai sync');
const driftIssues = createGeneratedFileDriftIssues(artifacts, dependencies);
if (!options.dryRun && driftIssues.length === 0) {
spinner.succeed('Atlas AI context is already current.');
logAiWriteOutcome(loggerImpl, artifacts, 'sync (no-op)');
return {
artifacts,
status: 'current'
};
}
if (!options.dryRun) {
writeAtlasAiArtifacts(artifacts, dependencies);
}
spinner.succeed(options.dryRun ? 'Atlas AI sync preview is ready.' : 'Atlas AI context is synced.');
logAiWriteOutcome(loggerImpl, artifacts, options.dryRun ? 'sync (dry-run)' : 'sync');
return {
artifacts,
status: options.dryRun ? 'preview' : 'synced'
};
} catch (error) {
spinner?.fail('Failed to sync Atlas AI context.');
loggerImpl.error(error.message);
return null;
}
};