snipara-companion 3.2.7 → 3.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -3328,6 +3328,13 @@ interface SessionBootstrapQualityReport {
3328
3328
  total_tokens?: number;
3329
3329
  oldest_memory_age_days?: number;
3330
3330
  }
3331
+ interface SessionBootstrapBrief {
3332
+ entries: SessionMemoryEntry[];
3333
+ availableCount: number;
3334
+ hiddenCount: number;
3335
+ estimatedTokens: number;
3336
+ budgetTokens: number;
3337
+ }
3331
3338
  interface GeneratedWorkflowPlanDocument {
3332
3339
  mode: "full";
3333
3340
  goal: string;
@@ -3354,6 +3361,12 @@ declare function validatePlanResult(plan: unknown, options?: {
3354
3361
  query?: string;
3355
3362
  cwd?: string;
3356
3363
  }): PlanQualityReport;
3364
+ declare function buildSessionBootstrapBrief(result: SessionMemoriesResult, options: {
3365
+ includeSessionContext: boolean;
3366
+ maxTokens?: number;
3367
+ maxEntries?: number;
3368
+ now?: Date;
3369
+ }): SessionBootstrapBrief;
3357
3370
  declare function buildSessionBootstrapQuality(result: SessionMemoriesResult, options?: {
3358
3371
  expectedMaxTokens?: number;
3359
3372
  now?: Date;
@@ -4258,4 +4271,4 @@ declare function buildOrchestratorHandoff(options: OrchestratorHandoffOptions):
4258
4271
  declare function buildAdaptiveWorkRoutingRecommendation(options: AdaptiveWorkRoutingOptions): AdaptiveWorkRoutingRecommendation;
4259
4272
  declare function writeOrchestratorHandoff(options: OrchestratorHandoffOptions): WrittenOrchestratorHandoff;
4260
4273
 
4261
- export { AUTOMATION_MANIFEST_RELATIVE_PATH, AutomationInstallConflictError, AutomationUnsupportedHookBundleError, CODING_INTELLIGENCE_LEDGER_VERSION, COLLABORATION_STATE_RELATIVE_PATH, ENGINEERING_LEAD_EXECUTION_RECEIPT_STAGES, ENGINEERING_LEAD_EXECUTION_RECEIPT_STATUSES, ENGINEERING_LEAD_POSTURES, ENGINEERING_LEAD_PROOF_VERIFICATION_SOURCES, ENGINEERING_LEAD_PROOF_VERIFICATION_STATUSES, ENGINEERING_LEAD_ROUTING_MODES, ENGINEERING_LEAD_STATUSES, ENGINEERING_LEAD_SUPERVISION_STATUSES, ENGINEERING_LEAD_WORKER_ROLES, ENGINEERING_LEAD_WORK_PACKAGE_STATUSES, ORCHESTRATOR_HANDOFF_RELATIVE_PATH, PRODUCER_LOOP_ARTIFACT_VERSION, PRODUCER_LOOP_RELATIVE_DIR, PRODUCER_LOOP_REPORT_VERSION, TEAM_SYNC_STATE_RELATIVE_PATH, WHY_OUTCOME_CAPTURE_VERSION, WORKFLOW_PLANS_RELATIVE_DIR, WORKFLOW_STATE_RELATIVE_PATH, addLocalWorker, agentReadinessAuditCommand, appendActivityEvent, archiveInactiveTeamSyncWork, attachLocalContextPackReceipts, autoArchiveTeamSyncState, buildAdaptiveWorkRoutingRecommendation, buildAgentReadinessAuditReport, buildAgenticHandoffMarkdown, buildAgenticTimeline, buildAgenticWorkStatus, buildAutomationInstallPlan, buildCanonicalEvent, buildCodeHooksInstallPlan, buildCodePromotionResult, buildCodeStatusResult, buildCodeSyncResult, buildCodingIntelligenceLedger, buildCollaborationActor, buildCollaborationGuardActionCards, buildCollaborationHooksInstallPlan, buildCompanionEngineeringLeadPlanReport, buildContextPackStats, buildEvalCaseArtifact, buildGeneratedWorkflowPlanDocument, buildHostedCodeOverlayUploadPayload, buildHostedGuardPayload, buildJournalCheckpointEntry, buildLocalCallersResult, buildLocalCodeOverlay, buildLocalContextPackReceipt, buildLocalContextPackReceipts, buildLocalImpactResult, buildLocalImportsResult, buildLocalNeighborsResult, buildLocalProjectRealityCheck, buildLocalShortestPathResult, buildLocalSourceSnapshot, buildLocalSourceStatus, buildLocalSourceSyncResult, buildMemoryAudit, buildOnboardFolderManifest, buildOrchestratorHandoff, buildProducerLoopReport, buildProjectIntelligenceBrief, buildProjectIntelligenceRun, buildProjectJudgmentCard, buildSessionBootstrapQuality, buildSessionSnapshot, buildSyncDocumentsDryRun, buildTeamSyncHandoffRecord, buildTeamSyncStartWorkRecord, buildTeamSyncSummary, buildToolCallPayload, buildToolResultPayload, buildVerificationPlan, buildWhyOutcomeCaptureReport, buildWorkflowImpactGate, buildWorkflowPhaseCommitSummary, buildWorkflowPlanScaffold, categoryFromGuardTag, classifyToolResult, cleanContextPacks, codingLedgerExportCommand, collaborationIdeStatusCommand, collectAgentReadinessLocalSignals, collectSyncDocuments, collectSyncDocumentsInput, compactHostedGuardResources, compareLocalSourceSnapshots, completeTeamSyncStateFromEvidence, completeTeamSyncWorkFromEvidence, contextPackCleanCommand, contextPackPackCommand, contextPackRetrieveCommand, contextPackStatsCommand, createClient, createEmptyCollaborationState, createEmptyTeamSyncState, createLocalQueryCache, deriveLocalCollaborationResourcesFromFiles, detectReleaseSurfacesFromFiles, detectRuntimeEnvironment, evalExportCommand, evalRunCommand, evaluateProjectPolicyGates, extractCommandFromToolInput, extractFilesFromToolInput, formatAgentReadinessAuditReport, formatCompanionEngineeringLeadPlanReport, formatOrchestratorRecommendationReason, formatPolicyGateDecision, formatProjectJudgmentCard, formatStuckGuardDecision, getAutomationManifestPath, getAutomationStatus, getCollaborationStatePath, getConfigPath, getContextPackStoragePaths, getLocalCodeOverlayCachePath, getLocalCodePromotionStatePath, getLocalSourceSnapshotPath, getOrchestratorRecommendation, getPlanStepDisplayTitle, getStagedFiles, getStuckGuardInjection, getTeamSyncStatePath, ingestReferences, installAutomationBundle, leadPlanCommand, listProjectsForApiKey, loadAutomationManifest, loadCollaborationState, loadConfig, loadTeamSyncState, memoryAuditCommand, memoryCleanCandidatesCommand, memoryCompactCommand, memoryHealthCommand, memoryLocalCommand, memoryReviewsCommand, normalizeCollaborationFiles, normalizeGuardTag, normalizeWorkflowPlanInput, outcomeCapturePreviewCommand, packContext, parseCollaborationResources, projectIntelligenceBriefCommand, projectIntelligenceRunCommand, readActivityTimeline, readLocalCodeOverlayCache, readLocalCodePromotionState, readLocalSourceSnapshot, readLocalWorkersConfig, readSessionSnapshot, realityCheckCommand, referencesIngestCommand, referencesScanCommand, resolveAutoWorkflowMode, resolveContextPackRecord, resolveFullWorkflowTokenBudget, resolveLocalWorkerRoutingDefaults, resolveQueryFromToolInput, retrieveContextPack, runMemoryGuardCheck, saveCollaborationState, saveConfig, saveTeamSyncState, scanReferences, shouldSuggestOrchestratorForWorkflow, shouldSuggestRuntimeForWorkflow, summarizeLocalCodeOverlay, teamSyncSweepCommand, validatePlanResult, verifyCommand, workersLocalAddCommand, workersLocalListCommand, workersLocalProbePrintCommand, workersLocalRemoveCommand, workersLocalStatusCommand, writeLocalCodeOverlayCache, writeLocalCodePromotionState, writeLocalSourceSnapshot, writeOrchestratorHandoff, writeProducerLoopArtifact, writeSessionSnapshot };
4274
+ export { AUTOMATION_MANIFEST_RELATIVE_PATH, AutomationInstallConflictError, AutomationUnsupportedHookBundleError, CODING_INTELLIGENCE_LEDGER_VERSION, COLLABORATION_STATE_RELATIVE_PATH, ENGINEERING_LEAD_EXECUTION_RECEIPT_STAGES, ENGINEERING_LEAD_EXECUTION_RECEIPT_STATUSES, ENGINEERING_LEAD_POSTURES, ENGINEERING_LEAD_PROOF_VERIFICATION_SOURCES, ENGINEERING_LEAD_PROOF_VERIFICATION_STATUSES, ENGINEERING_LEAD_ROUTING_MODES, ENGINEERING_LEAD_STATUSES, ENGINEERING_LEAD_SUPERVISION_STATUSES, ENGINEERING_LEAD_WORKER_ROLES, ENGINEERING_LEAD_WORK_PACKAGE_STATUSES, ORCHESTRATOR_HANDOFF_RELATIVE_PATH, PRODUCER_LOOP_ARTIFACT_VERSION, PRODUCER_LOOP_RELATIVE_DIR, PRODUCER_LOOP_REPORT_VERSION, TEAM_SYNC_STATE_RELATIVE_PATH, WHY_OUTCOME_CAPTURE_VERSION, WORKFLOW_PLANS_RELATIVE_DIR, WORKFLOW_STATE_RELATIVE_PATH, addLocalWorker, agentReadinessAuditCommand, appendActivityEvent, archiveInactiveTeamSyncWork, attachLocalContextPackReceipts, autoArchiveTeamSyncState, buildAdaptiveWorkRoutingRecommendation, buildAgentReadinessAuditReport, buildAgenticHandoffMarkdown, buildAgenticTimeline, buildAgenticWorkStatus, buildAutomationInstallPlan, buildCanonicalEvent, buildCodeHooksInstallPlan, buildCodePromotionResult, buildCodeStatusResult, buildCodeSyncResult, buildCodingIntelligenceLedger, buildCollaborationActor, buildCollaborationGuardActionCards, buildCollaborationHooksInstallPlan, buildCompanionEngineeringLeadPlanReport, buildContextPackStats, buildEvalCaseArtifact, buildGeneratedWorkflowPlanDocument, buildHostedCodeOverlayUploadPayload, buildHostedGuardPayload, buildJournalCheckpointEntry, buildLocalCallersResult, buildLocalCodeOverlay, buildLocalContextPackReceipt, buildLocalContextPackReceipts, buildLocalImpactResult, buildLocalImportsResult, buildLocalNeighborsResult, buildLocalProjectRealityCheck, buildLocalShortestPathResult, buildLocalSourceSnapshot, buildLocalSourceStatus, buildLocalSourceSyncResult, buildMemoryAudit, buildOnboardFolderManifest, buildOrchestratorHandoff, buildProducerLoopReport, buildProjectIntelligenceBrief, buildProjectIntelligenceRun, buildProjectJudgmentCard, buildSessionBootstrapBrief, buildSessionBootstrapQuality, buildSessionSnapshot, buildSyncDocumentsDryRun, buildTeamSyncHandoffRecord, buildTeamSyncStartWorkRecord, buildTeamSyncSummary, buildToolCallPayload, buildToolResultPayload, buildVerificationPlan, buildWhyOutcomeCaptureReport, buildWorkflowImpactGate, buildWorkflowPhaseCommitSummary, buildWorkflowPlanScaffold, categoryFromGuardTag, classifyToolResult, cleanContextPacks, codingLedgerExportCommand, collaborationIdeStatusCommand, collectAgentReadinessLocalSignals, collectSyncDocuments, collectSyncDocumentsInput, compactHostedGuardResources, compareLocalSourceSnapshots, completeTeamSyncStateFromEvidence, completeTeamSyncWorkFromEvidence, contextPackCleanCommand, contextPackPackCommand, contextPackRetrieveCommand, contextPackStatsCommand, createClient, createEmptyCollaborationState, createEmptyTeamSyncState, createLocalQueryCache, deriveLocalCollaborationResourcesFromFiles, detectReleaseSurfacesFromFiles, detectRuntimeEnvironment, evalExportCommand, evalRunCommand, evaluateProjectPolicyGates, extractCommandFromToolInput, extractFilesFromToolInput, formatAgentReadinessAuditReport, formatCompanionEngineeringLeadPlanReport, formatOrchestratorRecommendationReason, formatPolicyGateDecision, formatProjectJudgmentCard, formatStuckGuardDecision, getAutomationManifestPath, getAutomationStatus, getCollaborationStatePath, getConfigPath, getContextPackStoragePaths, getLocalCodeOverlayCachePath, getLocalCodePromotionStatePath, getLocalSourceSnapshotPath, getOrchestratorRecommendation, getPlanStepDisplayTitle, getStagedFiles, getStuckGuardInjection, getTeamSyncStatePath, ingestReferences, installAutomationBundle, leadPlanCommand, listProjectsForApiKey, loadAutomationManifest, loadCollaborationState, loadConfig, loadTeamSyncState, memoryAuditCommand, memoryCleanCandidatesCommand, memoryCompactCommand, memoryHealthCommand, memoryLocalCommand, memoryReviewsCommand, normalizeCollaborationFiles, normalizeGuardTag, normalizeWorkflowPlanInput, outcomeCapturePreviewCommand, packContext, parseCollaborationResources, projectIntelligenceBriefCommand, projectIntelligenceRunCommand, readActivityTimeline, readLocalCodeOverlayCache, readLocalCodePromotionState, readLocalSourceSnapshot, readLocalWorkersConfig, readSessionSnapshot, realityCheckCommand, referencesIngestCommand, referencesScanCommand, resolveAutoWorkflowMode, resolveContextPackRecord, resolveFullWorkflowTokenBudget, resolveLocalWorkerRoutingDefaults, resolveQueryFromToolInput, retrieveContextPack, runMemoryGuardCheck, saveCollaborationState, saveConfig, saveTeamSyncState, scanReferences, shouldSuggestOrchestratorForWorkflow, shouldSuggestRuntimeForWorkflow, summarizeLocalCodeOverlay, teamSyncSweepCommand, validatePlanResult, verifyCommand, workersLocalAddCommand, workersLocalListCommand, workersLocalProbePrintCommand, workersLocalRemoveCommand, workersLocalStatusCommand, writeLocalCodeOverlayCache, writeLocalCodePromotionState, writeLocalSourceSnapshot, writeOrchestratorHandoff, writeProducerLoopArtifact, writeSessionSnapshot };
package/dist/index.js CHANGED
@@ -101,6 +101,7 @@ __export(index_exports, {
101
101
  buildProjectIntelligenceBrief: () => buildProjectIntelligenceBrief,
102
102
  buildProjectIntelligenceRun: () => buildProjectIntelligenceRun,
103
103
  buildProjectJudgmentCard: () => buildProjectJudgmentCard,
104
+ buildSessionBootstrapBrief: () => buildSessionBootstrapBrief,
104
105
  buildSessionBootstrapQuality: () => buildSessionBootstrapQuality,
105
106
  buildSessionSnapshot: () => buildSessionSnapshot,
106
107
  buildSyncDocumentsDryRun: () => buildSyncDocumentsDryRun,
@@ -17096,6 +17097,239 @@ function isLikelyTestMemory(entry) {
17096
17097
  const text = readBootstrapEntryText(entry).toLowerCase();
17097
17098
  return type === "test" || category === "test" || /^test memory\b/.test(text);
17098
17099
  }
17100
+ function readBootstrapEntryId(entry) {
17101
+ return stringValue7(entry.id) ?? stringValue7(entry.memory_id) ?? `${stringValue7(entry.type) ?? "memory"}:${readBootstrapEntryText(entry).slice(0, 80)}`;
17102
+ }
17103
+ function isSessionCarryoverEntry(entry) {
17104
+ const category = typeof entry.category === "string" ? entry.category.toLowerCase() : "";
17105
+ const text = readBootstrapEntryText(entry).toLowerCase();
17106
+ return category.includes("team_sync_handoff") || category.includes("journal:") || category.includes("workflow-phase") || text.includes("checkpoint: workflow:final-commit") || text.includes("final commit") || text.includes("phase-commit") || text.includes("handoff");
17107
+ }
17108
+ function isLikelyStaleBootstrapEntry(entry, now) {
17109
+ const age = entryAgeDays(entry, now);
17110
+ const text = readBootstrapEntryText(entry).toLowerCase();
17111
+ return typeof age === "number" && age > STALE_BOOTSTRAP_MEMORY_DAYS || typeof entry.confidence === "number" && entry.confidence < 0.5 || text.includes("/users/alopez/devs/snipara/.env") || text.includes("rlm_remember") || text.includes("rlm_recall") || text.includes("railway") || text.includes("vercel") || text.includes("memory injection feature is complete") || text.includes("infotooltip component created") || text.includes("mcp performance optimizations (jan 2026)");
17112
+ }
17113
+ function scoreBootstrapBriefEntry(entry, source2, now) {
17114
+ let score = source2 === "daily" ? 100 : 0;
17115
+ const age = entryAgeDays(entry, now);
17116
+ const type = typeof entry.type === "string" ? entry.type.toLowerCase() : "";
17117
+ const category = typeof entry.category === "string" ? entry.category.toLowerCase() : "";
17118
+ const text = readBootstrapEntryText(entry).toLowerCase();
17119
+ if (isSessionCarryoverEntry(entry)) {
17120
+ score += 90;
17121
+ }
17122
+ if (type === "decision") {
17123
+ score += 25;
17124
+ const authorityStatus = bootstrapAuthorityStatus(entry);
17125
+ if (authorityStatus === "canonical") {
17126
+ score += 55;
17127
+ } else if (authorityStatus === "approved" || authorityStatus === "authoritative") {
17128
+ score += 20;
17129
+ }
17130
+ } else if (type === "context") {
17131
+ score += 20;
17132
+ } else if (type === "learning") {
17133
+ score += 10;
17134
+ }
17135
+ if (category.includes("journal:") || category.includes("workflow-phase")) {
17136
+ score += 40;
17137
+ }
17138
+ if (category.includes("team_sync_handoff")) {
17139
+ score += 55;
17140
+ }
17141
+ if (text.includes("control plane") || text.includes("control-plane") || text.includes("lite")) {
17142
+ score += 35;
17143
+ }
17144
+ if (text.includes("published") || text.includes("deployed") || text.includes("data-dpl-id")) {
17145
+ score += 25;
17146
+ }
17147
+ if (typeof entry.confidence === "number") {
17148
+ score += Math.max(0, Math.min(25, entry.confidence * 25));
17149
+ if (entry.confidence < 0.5) {
17150
+ score -= 90;
17151
+ }
17152
+ }
17153
+ if (typeof age === "number") {
17154
+ if (age <= 1) {
17155
+ score += 65;
17156
+ } else if (age <= 7) {
17157
+ score += 45;
17158
+ } else if (age <= 30) {
17159
+ score += 20;
17160
+ } else if (age > STALE_BOOTSTRAP_MEMORY_DAYS) {
17161
+ score -= 100;
17162
+ }
17163
+ }
17164
+ if (isLikelyTestMemory(entry)) {
17165
+ score -= 120;
17166
+ }
17167
+ if (isLikelyStaleBootstrapEntry(entry, now)) {
17168
+ score -= 80;
17169
+ }
17170
+ return score;
17171
+ }
17172
+ function estimateBootstrapEntryTokens(entry) {
17173
+ return Math.max(8, Math.ceil(compactSessionEntryLine(entry).length / 4));
17174
+ }
17175
+ function bootstrapEntryType(entry) {
17176
+ return typeof entry.type === "string" ? entry.type.toLowerCase() : "";
17177
+ }
17178
+ function isBootstrapDecisionEntry(entry) {
17179
+ return bootstrapEntryType(entry) === "decision";
17180
+ }
17181
+ function bootstrapAuthorityStatus(entry) {
17182
+ const authority = isRecord9(entry.authority) ? entry.authority : void 0;
17183
+ return (stringValue7(entry.authority_status) ?? stringValue7(authority?.authorityStatus) ?? stringValue7(authority?.level) ?? "").toLowerCase();
17184
+ }
17185
+ function bootstrapSimilarityTokens(entry) {
17186
+ const stopWords = /* @__PURE__ */ new Set([
17187
+ "checkpoint",
17188
+ "workflow",
17189
+ "final",
17190
+ "commit",
17191
+ "phase",
17192
+ "summary",
17193
+ "context",
17194
+ "team",
17195
+ "sync",
17196
+ "handoff",
17197
+ "released",
17198
+ "release"
17199
+ ]);
17200
+ const text = readSessionEntryPreview(entry).toLowerCase().replace(/snipara-companion@\d+\.\d+\.\d+/g, "snipara-companion").replace(/[^a-z0-9]+/g, " ");
17201
+ return new Set(text.split(/\s+/).filter((token) => token.length >= 4 && !stopWords.has(token)));
17202
+ }
17203
+ function buildBootstrapTopicTokens(ranked) {
17204
+ const tokens = /* @__PURE__ */ new Set();
17205
+ for (const candidate of ranked) {
17206
+ if (tokens.size >= 48) {
17207
+ break;
17208
+ }
17209
+ if (candidate.score <= 0 || !isSessionCarryoverEntry(candidate.entry)) {
17210
+ continue;
17211
+ }
17212
+ for (const token of bootstrapSimilarityTokens(candidate.entry)) {
17213
+ tokens.add(token);
17214
+ }
17215
+ }
17216
+ return tokens;
17217
+ }
17218
+ function isDecisionRelevantToBootstrap(entry, topicTokens, hasCarryoverCandidate) {
17219
+ if (!isBootstrapDecisionEntry(entry)) {
17220
+ return false;
17221
+ }
17222
+ if (!hasCarryoverCandidate) {
17223
+ return true;
17224
+ }
17225
+ const text = readBootstrapEntryText(entry).toLowerCase();
17226
+ const hasExplicitTopic = text.includes("control plane") || text.includes("control-plane") || text.includes("lite") || text.includes("session-bootstrap") || text.includes("bootstrap brief");
17227
+ if (hasExplicitTopic) {
17228
+ return true;
17229
+ }
17230
+ const category = typeof entry.category === "string" ? entry.category.toLowerCase() : "";
17231
+ if (category.includes("workflow-phase") || category.includes("final-commit") || category.includes("journal:") || category.includes("team_sync")) {
17232
+ return false;
17233
+ }
17234
+ let overlap = 0;
17235
+ for (const token of bootstrapSimilarityTokens(entry)) {
17236
+ if (topicTokens.has(token)) {
17237
+ overlap += 1;
17238
+ }
17239
+ }
17240
+ return overlap >= 3;
17241
+ }
17242
+ function areBootstrapEntriesSimilar(a, b) {
17243
+ const aTokens = bootstrapSimilarityTokens(a);
17244
+ const bTokens = bootstrapSimilarityTokens(b);
17245
+ if (aTokens.size === 0 || bTokens.size === 0) {
17246
+ return false;
17247
+ }
17248
+ let overlap = 0;
17249
+ for (const token of aTokens) {
17250
+ if (bTokens.has(token)) {
17251
+ overlap += 1;
17252
+ }
17253
+ }
17254
+ const smaller = Math.min(aTokens.size, bTokens.size);
17255
+ const larger = Math.max(aTokens.size, bTokens.size);
17256
+ return overlap / smaller >= 0.6 || overlap >= 8 && overlap / larger >= 0.5;
17257
+ }
17258
+ function buildSessionBootstrapBrief(result, options) {
17259
+ const normalized = normalizeSessionMemoriesResult(result);
17260
+ const now = options.now ?? /* @__PURE__ */ new Date();
17261
+ const maxEntries = Math.max(1, Math.min(options.maxEntries ?? 4, 5));
17262
+ const budgetTokens = normalizePositiveTokenBudget(options.maxTokens, 600, true);
17263
+ const candidates = [
17264
+ ...normalized.critical.memories.map((entry) => ({ entry, source: "critical" })),
17265
+ ...options.includeSessionContext ? normalized.daily.memories.map((entry) => ({ entry, source: "daily" })) : []
17266
+ ];
17267
+ const seen = /* @__PURE__ */ new Set();
17268
+ const ranked = candidates.map((candidate, index) => ({
17269
+ ...candidate,
17270
+ index,
17271
+ score: scoreBootstrapBriefEntry(candidate.entry, candidate.source, now)
17272
+ })).sort((a, b) => b.score - a.score || b.index - a.index);
17273
+ const hasFreshCandidate = ranked.some(
17274
+ (candidate) => candidate.score > 0 && !isLikelyStaleBootstrapEntry(candidate.entry, now) && !isLikelyTestMemory(candidate.entry)
17275
+ );
17276
+ const topicTokens = buildBootstrapTopicTokens(ranked);
17277
+ const hasCarryoverCandidate = ranked.some(
17278
+ (candidate) => candidate.score > 0 && isSessionCarryoverEntry(candidate.entry) && !isLikelyStaleBootstrapEntry(candidate.entry, now) && !isLikelyTestMemory(candidate.entry)
17279
+ );
17280
+ const hasFreshDecisionCandidate = maxEntries >= 4 && ranked.some(
17281
+ (candidate) => candidate.score > 0 && isDecisionRelevantToBootstrap(candidate.entry, topicTokens, hasCarryoverCandidate) && !isLikelyStaleBootstrapEntry(candidate.entry, now) && !isLikelyTestMemory(candidate.entry)
17282
+ );
17283
+ const entries = [];
17284
+ let estimatedTokens = 0;
17285
+ let selectedCarryoverCount = 0;
17286
+ let selectedDecisionCount = 0;
17287
+ for (const candidate of ranked) {
17288
+ if (hasFreshCandidate && (isLikelyStaleBootstrapEntry(candidate.entry, now) || isLikelyTestMemory(candidate.entry))) {
17289
+ continue;
17290
+ }
17291
+ const id = readBootstrapEntryId(candidate.entry);
17292
+ const textKey = readBootstrapEntryText(candidate.entry).slice(0, 140).toLowerCase();
17293
+ const key = id || textKey;
17294
+ if (seen.has(key)) {
17295
+ continue;
17296
+ }
17297
+ if (entries.some((entry) => areBootstrapEntriesSimilar(entry, candidate.entry))) {
17298
+ continue;
17299
+ }
17300
+ const isCarryover = isSessionCarryoverEntry(candidate.entry);
17301
+ const isDecision = isBootstrapDecisionEntry(candidate.entry);
17302
+ if (isDecision && !isDecisionRelevantToBootstrap(candidate.entry, topicTokens, hasCarryoverCandidate)) {
17303
+ continue;
17304
+ }
17305
+ if (hasFreshDecisionCandidate && selectedDecisionCount === 0 && isCarryover && selectedCarryoverCount >= maxEntries - 1) {
17306
+ continue;
17307
+ }
17308
+ const entryTokens = estimateBootstrapEntryTokens(candidate.entry);
17309
+ if (entries.length > 0 && estimatedTokens + entryTokens > budgetTokens) {
17310
+ continue;
17311
+ }
17312
+ seen.add(key);
17313
+ entries.push(candidate.entry);
17314
+ estimatedTokens += entryTokens;
17315
+ if (isCarryover) {
17316
+ selectedCarryoverCount += 1;
17317
+ }
17318
+ if (isDecision) {
17319
+ selectedDecisionCount += 1;
17320
+ }
17321
+ if (entries.length >= maxEntries) {
17322
+ break;
17323
+ }
17324
+ }
17325
+ return {
17326
+ entries,
17327
+ availableCount: candidates.length,
17328
+ hiddenCount: Math.max(0, candidates.length - entries.length),
17329
+ estimatedTokens,
17330
+ budgetTokens
17331
+ };
17332
+ }
17099
17333
  function buildSessionBootstrapQuality(result, options = {}) {
17100
17334
  const normalized = normalizeSessionMemoriesResult(result);
17101
17335
  const now = options.now ?? /* @__PURE__ */ new Date();
@@ -20744,6 +20978,30 @@ function printChunkResult(chunkId, result) {
20744
20978
  printJson2(result);
20745
20979
  }
20746
20980
  function readSessionEntryPreview(entry) {
20981
+ for (const value of [entry.summary, entry.text, entry.content, entry.title]) {
20982
+ if (typeof value !== "string") {
20983
+ continue;
20984
+ }
20985
+ const trimmed = value.trim();
20986
+ if (trimmed.startsWith("{") && trimmed.endsWith("}")) {
20987
+ try {
20988
+ const parsed = JSON.parse(trimmed);
20989
+ if (isRecord9(parsed)) {
20990
+ const summary = stringValue7(parsed.summary);
20991
+ const nextStep = stringValue7(parsed.nextStep);
20992
+ const task = stringValue7(parsed.task);
20993
+ const readable = [summary, nextStep ? `Next: ${nextStep}` : void 0, task].filter((item) => Boolean(item)).join(" ");
20994
+ if (readable.length > 0) {
20995
+ return toPreview(readable, 220);
20996
+ }
20997
+ }
20998
+ } catch {
20999
+ }
21000
+ }
21001
+ if (trimmed.length > 0) {
21002
+ return toPreview(trimmed, 220);
21003
+ }
21004
+ }
20747
21005
  return toPreview(entry.text ?? entry.content ?? entry.summary ?? entry.title, 220);
20748
21006
  }
20749
21007
  function compactSessionEntryLine(entry) {
@@ -20751,24 +21009,34 @@ function compactSessionEntryLine(entry) {
20751
21009
  return `- ${label}: ${readSessionEntryPreview(entry)}`;
20752
21010
  }
20753
21011
  function printSessionBootstrap(result, options) {
20754
- const normalized = normalizeSessionMemoriesResult(result);
20755
- const entries = [
20756
- ...normalized.critical.memories,
20757
- ...options.includeSessionContext ? normalized.daily.memories : []
20758
- ].slice(0, 5);
21012
+ const brief = buildSessionBootstrapBrief(result, {
21013
+ includeSessionContext: options.includeSessionContext,
21014
+ maxTokens: options.maxTokens
21015
+ });
21016
+ const entries = brief.entries;
20759
21017
  if (entries.length === 0) {
20760
- return false;
21018
+ return null;
20761
21019
  }
20762
21020
  console.log(import_chalk6.default.bold("Snipara Bootstrap Brief"));
20763
21021
  for (const entry of entries) {
20764
21022
  console.log(compactSessionEntryLine(entry));
20765
21023
  }
20766
- const hiddenCount = normalized.critical.count + (options.includeSessionContext ? normalized.daily.count : 0) - entries.length;
20767
- if (hiddenCount > 0) {
20768
- console.log(`- ${hiddenCount} more available on demand via recall/session-bootstrap --json.`);
20769
- }
20770
21024
  console.log("");
20771
- return true;
21025
+ return brief;
21026
+ }
21027
+ function buildPrintedBootstrapQuality(brief, now) {
21028
+ return buildSessionBootstrapQuality(
21029
+ {
21030
+ critical: {
21031
+ memories: brief.entries,
21032
+ count: brief.entries.length,
21033
+ tokens: brief.estimatedTokens
21034
+ },
21035
+ daily: { memories: [], count: 0, tokens: 0 },
21036
+ total_tokens: brief.estimatedTokens
21037
+ },
21038
+ { expectedMaxTokens: brief.budgetTokens, now }
21039
+ );
20772
21040
  }
20773
21041
  function printSessionBootstrapQuality(report) {
20774
21042
  if (report.warnings.length === 0) {
@@ -22289,13 +22557,12 @@ async function workflowRunCommand(options) {
22289
22557
  const printedBootstrap = printSessionBootstrap(
22290
22558
  payload.session_bootstrap,
22291
22559
  {
22292
- includeSessionContext: Boolean(workflowBudget?.include_session_context)
22560
+ includeSessionContext: Boolean(workflowBudget?.include_session_context),
22561
+ maxTokens: (workflowBudget?.allocations.critical_memory_tokens ?? DEFAULT_FULL_WORKFLOW_CRITICAL_TOKENS) + (workflowBudget?.allocations.session_context_tokens ?? 0)
22293
22562
  }
22294
22563
  );
22295
22564
  if (printedBootstrap && payload.session_bootstrap_quality && typeof payload.session_bootstrap_quality === "object") {
22296
- printSessionBootstrapQuality(
22297
- payload.session_bootstrap_quality
22298
- );
22565
+ printSessionBootstrapQuality(buildPrintedBootstrapQuality(printedBootstrap));
22299
22566
  }
22300
22567
  if (workflowBudget?.warnings.length) {
22301
22568
  console.log(import_chalk6.default.bold("Workflow Budget Warnings"));
@@ -23239,10 +23506,11 @@ async function workflowResumeCommand(options) {
23239
23506
  console.log(import_chalk6.default.bold("Workflow Resume"));
23240
23507
  printManagedWorkflowState(state);
23241
23508
  const printedBootstrap = printSessionBootstrap(bootstrap, {
23242
- includeSessionContext: resolvedContextTokens > 0
23509
+ includeSessionContext: resolvedContextTokens > 0,
23510
+ maxTokens: resolvedCriticalTokens + resolvedContextTokens
23243
23511
  });
23244
23512
  if (printedBootstrap) {
23245
- printSessionBootstrapQuality(bootstrapQuality);
23513
+ printSessionBootstrapQuality(buildPrintedBootstrapQuality(printedBootstrap));
23246
23514
  }
23247
23515
  printWorkflowLocalSessionSnapshot(localSessionSnapshot);
23248
23516
  printWorkflowTeamSyncResume(teamSyncResume);
@@ -23738,7 +24006,25 @@ async function loadDocumentCommand(options) {
23738
24006
  printLoadDocumentResult(options.path, result);
23739
24007
  }
23740
24008
  async function sessionBootstrapCommand(options) {
23741
- ensureConfigured();
24009
+ if (!isConfigured()) {
24010
+ if (options.json) {
24011
+ printJson2({
24012
+ critical: { memories: [], count: 0, tokens: 0 },
24013
+ daily: { memories: [], count: 0, tokens: 0 },
24014
+ total_tokens: 0,
24015
+ session_context: {
24016
+ included: Boolean(options.includeSessionContext),
24017
+ max_tokens: options.includeSessionContext ? DEFAULT_SESSION_CONTEXT_TOKENS : 0
24018
+ },
24019
+ session_bootstrap_quality: buildSessionBootstrapQuality({
24020
+ critical: { memories: [], count: 0, tokens: 0 },
24021
+ daily: { memories: [], count: 0, tokens: 0 },
24022
+ total_tokens: 0
24023
+ })
24024
+ });
24025
+ }
24026
+ return;
24027
+ }
23742
24028
  const resolvedContextTokens = options.maxContextTokens !== void 0 ? options.maxContextTokens : options.includeSessionContext ? DEFAULT_SESSION_CONTEXT_TOKENS : 0;
23743
24029
  const client = createClient(15e3);
23744
24030
  const result = await client.getSessionMemories(options.maxCriticalTokens, resolvedContextTokens);
@@ -23766,17 +24052,11 @@ async function sessionBootstrapCommand(options) {
23766
24052
  return;
23767
24053
  }
23768
24054
  const printedBootstrap = printSessionBootstrap(result, {
23769
- includeSessionContext: resolvedContextTokens > 0
24055
+ includeSessionContext: resolvedContextTokens > 0,
24056
+ maxTokens: (options.maxCriticalTokens ?? DEFAULT_FULL_WORKFLOW_CRITICAL_TOKENS) + resolvedContextTokens
23770
24057
  });
23771
24058
  if (printedBootstrap) {
23772
- printSessionBootstrapQuality(bootstrapQuality);
23773
- }
23774
- if (printedBootstrap && warmSnapshot.storedEntries > 0) {
23775
- printKeyValue2(
23776
- "Warm cache:",
23777
- `${warmSnapshot.storedEntries} bootstrap memory/context entries primed locally`
23778
- );
23779
- console.log("");
24059
+ printSessionBootstrapQuality(buildPrintedBootstrapQuality(printedBootstrap));
23780
24060
  }
23781
24061
  }
23782
24062
  async function recallCommand(options) {
@@ -33781,6 +34061,7 @@ if (require.main === module) {
33781
34061
  buildProjectIntelligenceBrief,
33782
34062
  buildProjectIntelligenceRun,
33783
34063
  buildProjectJudgmentCard,
34064
+ buildSessionBootstrapBrief,
33784
34065
  buildSessionBootstrapQuality,
33785
34066
  buildSessionSnapshot,
33786
34067
  buildSyncDocumentsDryRun,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snipara-companion",
3
- "version": "3.2.7",
3
+ "version": "3.2.9",
4
4
  "description": "Local-first CLI that asks your repo what breaks before an AI coding agent edits it.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {