MCPcopy Create free account
hub / github.com/SethGammon/Citadel / syncProjectGuidance

Function syncProjectGuidance

scripts/codex-compat.js:646–723  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

644 console.log(` ${synced} script delegates synced.`);
645}
646
647function generateOpenAIYaml(skillDir, fm) {
648 const yaml = `# Generated by Citadel. Do not edit manually.
649interface:
650 display_name: "${(fm.name || 'unknown').replace(/"/g, '\\"')}"
651 short_description: "${(fm.description || '').replace(/"/g, '\\"')}"
652policy:
653 allow_implicit_invocation: true
654`;
655
656 writeFile(path.join(skillDir, 'agents', 'openai.yaml'), yaml);
657}
658
659// ---- 5. Generate AGENTS.md if missing ---------------------------------------
660
661function syncProjectGuidance() {
662 console.log('Checking AGENTS.md...');
663
664 const agentsMdPath = path.join(PROJECT_ROOT, 'AGENTS.md');
665 if (fs.existsSync(agentsMdPath)) {
666 console.log(' AGENTS.md already exists, skipping.');
667 return;
668 }
669
670 const projectSpecPath = path.join(PROJECT_ROOT, '.citadel', 'project.md');
671 if (fs.existsSync(projectSpecPath)) {
672 const content = fs.readFileSync(projectSpecPath, 'utf8');
673 const spec = parseProjectSpec(content);
674 const errors = validateProjectSpec(spec);
675 if (errors.length === 0) {
676 writeFile(agentsMdPath, renderCodexGuidance(spec));
677 console.log(' Generated AGENTS.md from .citadel/project.md with Codex-specific guidance.');
678 return;
679 }
680 console.warn(` warning: .citadel/project.md invalid (${errors.join('; ')}); using fallback guidance.`);
681 }
682
683 // CLAUDE.md is a fallback only. Keep the generated file Codex-specific so
684 // Codex instruction discovery, nested overrides, and review guidance have a
685 // clear owner even when the project has no Citadel spec yet.
686 const claudeMdPath = path.join(PROJECT_ROOT, 'CLAUDE.md');
687 if (fs.existsSync(claudeMdPath)) {
688 const content = fs.readFileSync(claudeMdPath, 'utf8');
689 const fallback = [
690 '# Codex Project Guidance',
691 '',
692 'This AGENTS.md was generated by Citadel for Codex instruction discovery.',
693 '',
694 '## Repository expectations',
695 '',
696 '- Read this file before changing code.',
697 '- Prefer project-specific build, test, lint, and verification commands from this file or nested AGENTS.override.md files.',
698 '- Preserve user-authored changes and avoid broad rewrites unless the task calls for them.',
699 '',
700 '## Review guidelines',
701 '',
702 '- Prioritize correctness, security, regressions, and missing verification.',
703 '- Keep review findings focused and actionable.',

Callers 1

mainFunction · 0.85

Calls 4

parseProjectSpecFunction · 0.85
validateProjectSpecFunction · 0.85
renderCodexGuidanceFunction · 0.85
writeFileFunction · 0.70

Tested by

no test coverage detected