autosnippet
Version:
Extract code patterns into a knowledge base for AI coding assistants
59 lines (58 loc) • 2.14 kB
JavaScript
/**
* Shared helpers for async AI-fill pipeline dispatch.
*
* Previously duplicated in:
* - bootstrap-internal.ts (Phase 5)
* - rescan-internal.ts (Step 6-7)
*
* @module bootstrap/shared/async-fill-helpers
*/
/**
* Build task definitions from dimensions for BootstrapTaskManager.
*/
export function buildTaskDefs(dimensions) {
return dimensions.map((dim) => ({
id: dim.id,
meta: {
type: dim.skillWorthy ? 'skill' : 'candidate',
dimId: dim.id,
label: dim.label,
skillWorthy: !!dim.skillWorthy,
skillMeta: dim.skillMeta || null,
},
}));
}
/**
* Start a BootstrapTaskManager session (graceful degradation if unavailable).
*/
export function startTaskManagerSession(container, taskDefs, logger, logPrefix) {
try {
const taskManager = container.get('bootstrapTaskManager');
return taskManager.startSession(taskDefs);
}
catch (e) {
logger.warn(`[${logPrefix}] BootstrapTaskManager init failed (graceful degradation): ${e instanceof Error ? e.message : String(e)}`);
return null;
}
}
// ── Pipeline Fill View dispatch (Phase D-2) ──────────────
/**
* Dispatch fillDimensionsV3 from a PipelineFillView.
*
* Passes the view directly to orchestrator (no more flat-context expansion).
* Fires via setImmediate (fire-and-forget).
*
* @param view - Typed PipelineFillView from handler
* @param dimensions - Active dimensions for this run (may differ from snapshot.activeDimensions for rescan gap-only)
* @param fillDimensionsV3 - The pipeline function to invoke
* @param logPrefix - Log prefix (e.g. 'Bootstrap', 'Rescan-Internal')
*/
export function dispatchPipelineFill(view, dimensions, fillDimensionsV3, logPrefix) {
const ctxLogger = view.ctx.logger;
setImmediate(() => {
ctxLogger?.info(`[${logPrefix}] Dispatching v3 AI-First pipeline`);
fillDimensionsV3(view, dimensions).catch((e) => {
ctxLogger?.error(`[${logPrefix}] Async fill failed: ${e instanceof Error ? e.message : String(e)}`);
});
});
}