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

Function checkStaleCommandResult

hooks_src/init-project.js:216–251  ·  view source on GitHub ↗

* Watchdog: check for stale command results from a previous session. * * If last-command-result.json exists and is older than 10 minutes, * the previous session may have completed a command that wasn't seen. * Surface it so the user knows what happened.

()

Source from the content-addressed store, hash-verified

214 if (shouldSyncScripts()) {
215 const pluginScripts = path.join(PLUGIN_ROOT, 'scripts');
216 const projectScripts = path.join(PROJECT_ROOT, '.citadel', 'scripts');
217 if (fs.existsSync(pluginScripts)) {
218 ensureDir(projectScripts);
219 fs.writeFileSync(
220 path.join(projectScripts, 'package.json'),
221 `${JSON.stringify({ type: 'commonjs' }, null, 2)}\n`,
222 );
223 for (const file of fs.readdirSync(pluginScripts)) {
224 if (file.endsWith('.js') || file.endsWith('.cjs')) {
225 fs.writeFileSync(
226 path.join(projectScripts, file),
227 generateDelegate(file)
228 );
229 }
230 }
231 }
232 writeVersionFile(PLUGIN_ROOT, PROJECT_ROOT);
233 }
234
235 // 5. Copy the runtime-neutral delegated-agent context into the active
236 // runtime's project namespace. Never create another runtime's marker: it
237 // makes later runtime detection ambiguous.
238 const pluginAgentContext = path.join(PLUGIN_ROOT, 'templates', 'agent-context');
239 const runtimeDirectory = authority.runtime === 'codex' ? '.codex' : '.claude';
240 const agentContext = path.join(PROJECT_ROOT, runtimeDirectory, 'agent-context');
241 if (!fs.existsSync(agentContext) && fs.existsSync(pluginAgentContext)) {
242 copyDirRecursive(pluginAgentContext, agentContext);
243 }
244
245 // 6. Write .citadel-root marker (plugin path for reference)
246 const citadelDir = path.join(PROJECT_ROOT, '.citadel');
247 ensureDir(citadelDir);
248 fs.writeFileSync(
249 path.join(citadelDir, 'plugin-root.txt'),
250 `${PLUGIN_ROOT}\n`
251 );
252
253 // 6a. Restore opted-in durable knowledge from the user-level repository
254 // store. Existing files are never overwritten by this automatic path.

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected