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

Function createAutomationPlan

core/codex/native-integrations.js:57–118  ·  view source on GitHub ↗
(options = {})

Source from the content-addressed store, hash-verified

55}
56
57function createAutomationPlan(options = {}) {
58 const projectRoot = path.resolve(options.projectRoot || process.cwd());
59 const type = options.type || 'schedule';
60 const command = options.command || '/do status';
61 const cadence = options.cadence || options.interval || 'manual';
62 const id = options.id || `codex-${type}-${slugify(command)}-${nowIso(options).replace(/[:.]/g, '-')}`;
63 const target = options.target || (type === 'daemon' ? 'background-worktree' : 'local-project');
64
65 const prompts = {
66 schedule: `Create a Codex automation for ${projectRoot}. On ${cadence}, run: ${command}. Record the result in .planning/codex-automations/${id}.json and summarize any action taken.`,
67 daemon: `Create a Codex automation that continues Citadel daemon work for ${projectRoot}. Each run should read .planning/daemon.json, continue only when the daemon is running, respect budget gates, and append a run summary to .planning/codex-automations/${id}.json.`,
68 'pr-watch': `Create a Codex automation for PR monitoring in ${projectRoot}. On ${cadence}, inspect the PR checks and review comments, apply safe targeted fixes only when confidence is high, and record each run in .planning/codex-automations/${id}.json.`,
69 };
70
71 const plan = {
72 id,
73 type,
74 projectRoot,
75 target,
76 cadence,
77 command,
78 surface: 'codex-app-automation',
79 prompt: prompts[type] || prompts.schedule,
80 improvesOnLocalOnly: [
81 'Codex owns the schedule instead of relying on a live terminal loop.',
82 'Citadel still keeps the durable run log in .planning.',
83 'The prompt is explicit enough to recreate the automation without re-explaining the harness.',
84 ],
85 status: 'planned',
86 createdAt: nowIso(options),
87 runs: [],
88 };
89
90 const loop = createLoopContract({
91 id: `loop-${id}`,
92 type: `codex-${type}`,
93 title: `Codex automation: ${type}`,
94 goal: command,
95 command,
96 cadence,
97 triggerKind: 'codex-automation',
98 verifierProfile: type,
99 maxAttempts: type === 'pr-watch' ? 3 : 1,
100 statePath: path.join('.planning', 'codex-automations', `${id}.json`).replace(/\\/g, '/'),
101 stopConditions: type === 'daemon'
102 ? ['done', 'budget-exhausted', 'no-active-work', 'needs-human-review']
103 : ['done', 'blocked', 'needs-human-review', 'attempt-limit'],
104 now: options.now,
105 });
106 plan.loopId = loop.id;
107 plan.loopType = loop.type;
108 plan.loopTitle = loop.title;
109 plan.loopStatus = loop.status;
110 plan.loopBudget = loop.budget;
111 plan.loopVerifier = loop.verifier;
112 plan.loopStopConditions = loop.stopConditions;
113
114 if (options.write) {

Callers 3

recordAutomationRunFunction · 0.85
testBridgeUtilitiesFunction · 0.85

Calls 5

createLoopContractFunction · 0.85
slugifyFunction · 0.70
nowIsoFunction · 0.70
writeJsonFunction · 0.70
planningDirFunction · 0.70

Tested by

no test coverage detected