* Health line: one concise line summarizing harness health at session start. * Single bounded read of the tail of hook-timing.jsonl (no spawning, no * directory walks). Silently skips on any error or when no telemetry exists.
()
| 256 | // Scripts are generated as thin delegates rather than copied verbatim. |
| 257 | // Copied scripts import from ../core/ and ../runtimes/ which only exist |
| 258 | // inside the Citadel install, not inside the target project. Delegates |
| 259 | // read plugin-root.txt at runtime and spawn the real script via the |
| 260 | // Citadel install, so imports always resolve correctly. |
| 261 | pruneRetiredDelegates(); |
| 262 | if (shouldSyncScripts()) { |
| 263 | const pluginScripts = path.join(PLUGIN_ROOT, 'scripts'); |
| 264 | const projectScripts = path.join(PROJECT_ROOT, '.citadel', 'scripts'); |
| 265 | if (fs.existsSync(pluginScripts)) { |
| 266 | ensureDir(projectScripts); |
| 267 | fs.writeFileSync( |
| 268 | path.join(projectScripts, 'package.json'), |
| 269 | `${JSON.stringify({ type: 'commonjs' }, null, 2)}\n`, |
| 270 | ); |
| 271 | for (const file of availableDelegates(pluginScripts)) { |
| 272 | if (file.endsWith('.js') || file.endsWith('.cjs')) { |
| 273 | fs.writeFileSync( |
| 274 | path.join(projectScripts, file), |
| 275 | generateDelegate(file) |
| 276 | ); |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | writeVersionFile(PLUGIN_ROOT, PROJECT_ROOT); |
| 281 | } |
| 282 | |
| 283 | // 5. Copy the runtime-neutral delegated-agent context into the active |