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

Function resolveNext

scripts/next-action.js:243–320  ·  view source on GitHub ↗
(projectRoot, options = {})

Source from the content-addressed store, hash-verified

241}
242
243function resolveNext(projectRoot, options = {}) {
244 const root = path.resolve(projectRoot || process.cwd());
245 const steps = [];
246 const generatedAt = options.now || new Date().toISOString();
247 let snapshot = collectDashboard({ projectRoot: root });
248
249 if (!options.run) {
250 const repairs = snapshot.repairs || [];
251 const outcome = repairs.length === 0
252 ? 'idle'
253 : (localRepairFor(snapshot.nextAction) ? 'repair-available' : 'needs-human');
254 return {
255 projectRoot: root,
256 generatedAt,
257 mode: 'inspect',
258 outcome,
259 initial: summarizeSnapshot(snapshot),
260 final: summarizeSnapshot(snapshot),
261 steps,
262 approvalCapsule: buildApprovalCapsule(root, snapshot, generatedAt),
263 };
264 }
265
266 const maxSteps = options.maxSteps || 3;
267 for (let index = 0; index < maxSteps; index++) {
268 const action = snapshot.nextAction || {};
269 const repair = localRepairFor(action);
270 if (!repair) {
271 return {
272 projectRoot: root,
273 generatedAt,
274 mode: 'run',
275 outcome: (snapshot.repairs || []).length === 0 ? 'idle' : 'needs-human',
276 initial: steps[0]?.before || summarizeSnapshot(snapshot),
277 final: summarizeSnapshot(snapshot),
278 steps,
279 approvalCapsule: buildApprovalCapsule(root, snapshot, generatedAt),
280 };
281 }
282
283 const before = summarizeSnapshot(snapshot);
284 const result = runNode(root, repair);
285 const after = collectDashboard({ projectRoot: root });
286 const step = {
287 action,
288 repair,
289 before,
290 result,
291 after: summarizeSnapshot(after),
292 };
293 steps.push(step);
294 snapshot = after;
295
296 if (result.status !== 0) {
297 return {
298 projectRoot: root,
299 generatedAt,
300 mode: 'run',

Callers 3

buildConsoleFunction · 0.85
mainFunction · 0.85

Calls 5

collectDashboardFunction · 0.85
localRepairForFunction · 0.85
summarizeSnapshotFunction · 0.85
buildApprovalCapsuleFunction · 0.85
runNodeFunction · 0.85

Tested by

no test coverage detected