snipara-companion 3.2.7 → 3.2.8
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 +14 -1
- package/dist/index.js +174 -26
- package/package.json +1 -1
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,124 @@ 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
|
+
} else if (type === "context") {
|
|
17125
|
+
score += 20;
|
|
17126
|
+
} else if (type === "learning") {
|
|
17127
|
+
score += 10;
|
|
17128
|
+
}
|
|
17129
|
+
if (category.includes("journal:") || category.includes("workflow-phase")) {
|
|
17130
|
+
score += 40;
|
|
17131
|
+
}
|
|
17132
|
+
if (category.includes("team_sync_handoff")) {
|
|
17133
|
+
score += 55;
|
|
17134
|
+
}
|
|
17135
|
+
if (text.includes("control plane") || text.includes("control-plane") || text.includes("lite")) {
|
|
17136
|
+
score += 35;
|
|
17137
|
+
}
|
|
17138
|
+
if (text.includes("published") || text.includes("deployed") || text.includes("data-dpl-id")) {
|
|
17139
|
+
score += 25;
|
|
17140
|
+
}
|
|
17141
|
+
if (typeof entry.confidence === "number") {
|
|
17142
|
+
score += Math.max(0, Math.min(25, entry.confidence * 25));
|
|
17143
|
+
if (entry.confidence < 0.5) {
|
|
17144
|
+
score -= 90;
|
|
17145
|
+
}
|
|
17146
|
+
}
|
|
17147
|
+
if (typeof age === "number") {
|
|
17148
|
+
if (age <= 1) {
|
|
17149
|
+
score += 65;
|
|
17150
|
+
} else if (age <= 7) {
|
|
17151
|
+
score += 45;
|
|
17152
|
+
} else if (age <= 30) {
|
|
17153
|
+
score += 20;
|
|
17154
|
+
} else if (age > STALE_BOOTSTRAP_MEMORY_DAYS) {
|
|
17155
|
+
score -= 100;
|
|
17156
|
+
}
|
|
17157
|
+
}
|
|
17158
|
+
if (isLikelyTestMemory(entry)) {
|
|
17159
|
+
score -= 120;
|
|
17160
|
+
}
|
|
17161
|
+
if (isLikelyStaleBootstrapEntry(entry, now)) {
|
|
17162
|
+
score -= 80;
|
|
17163
|
+
}
|
|
17164
|
+
return score;
|
|
17165
|
+
}
|
|
17166
|
+
function estimateBootstrapEntryTokens(entry) {
|
|
17167
|
+
return Math.max(8, Math.ceil(compactSessionEntryLine(entry).length / 4));
|
|
17168
|
+
}
|
|
17169
|
+
function buildSessionBootstrapBrief(result, options) {
|
|
17170
|
+
const normalized = normalizeSessionMemoriesResult(result);
|
|
17171
|
+
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
17172
|
+
const maxEntries = Math.max(1, Math.min(options.maxEntries ?? 4, 5));
|
|
17173
|
+
const budgetTokens = normalizePositiveTokenBudget(options.maxTokens, 600, true);
|
|
17174
|
+
const candidates = [
|
|
17175
|
+
...normalized.critical.memories.map((entry) => ({ entry, source: "critical" })),
|
|
17176
|
+
...options.includeSessionContext ? normalized.daily.memories.map((entry) => ({ entry, source: "daily" })) : []
|
|
17177
|
+
];
|
|
17178
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17179
|
+
const ranked = candidates.map((candidate, index) => ({
|
|
17180
|
+
...candidate,
|
|
17181
|
+
index,
|
|
17182
|
+
score: scoreBootstrapBriefEntry(candidate.entry, candidate.source, now)
|
|
17183
|
+
})).sort((a, b) => b.score - a.score || b.index - a.index);
|
|
17184
|
+
const hasFreshCandidate = ranked.some(
|
|
17185
|
+
(candidate) => candidate.score > 0 && !isLikelyStaleBootstrapEntry(candidate.entry, now) && !isLikelyTestMemory(candidate.entry)
|
|
17186
|
+
);
|
|
17187
|
+
const entries = [];
|
|
17188
|
+
let estimatedTokens = 0;
|
|
17189
|
+
for (const candidate of ranked) {
|
|
17190
|
+
if (hasFreshCandidate && (isLikelyStaleBootstrapEntry(candidate.entry, now) || isLikelyTestMemory(candidate.entry))) {
|
|
17191
|
+
continue;
|
|
17192
|
+
}
|
|
17193
|
+
const id = readBootstrapEntryId(candidate.entry);
|
|
17194
|
+
const textKey = readBootstrapEntryText(candidate.entry).slice(0, 140).toLowerCase();
|
|
17195
|
+
const key = id || textKey;
|
|
17196
|
+
if (seen.has(key)) {
|
|
17197
|
+
continue;
|
|
17198
|
+
}
|
|
17199
|
+
seen.add(key);
|
|
17200
|
+
const entryTokens = estimateBootstrapEntryTokens(candidate.entry);
|
|
17201
|
+
if (entries.length > 0 && estimatedTokens + entryTokens > budgetTokens) {
|
|
17202
|
+
continue;
|
|
17203
|
+
}
|
|
17204
|
+
entries.push(candidate.entry);
|
|
17205
|
+
estimatedTokens += entryTokens;
|
|
17206
|
+
if (entries.length >= maxEntries) {
|
|
17207
|
+
break;
|
|
17208
|
+
}
|
|
17209
|
+
}
|
|
17210
|
+
return {
|
|
17211
|
+
entries,
|
|
17212
|
+
availableCount: candidates.length,
|
|
17213
|
+
hiddenCount: Math.max(0, candidates.length - entries.length),
|
|
17214
|
+
estimatedTokens,
|
|
17215
|
+
budgetTokens
|
|
17216
|
+
};
|
|
17217
|
+
}
|
|
17099
17218
|
function buildSessionBootstrapQuality(result, options = {}) {
|
|
17100
17219
|
const normalized = normalizeSessionMemoriesResult(result);
|
|
17101
17220
|
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
@@ -20744,6 +20863,30 @@ function printChunkResult(chunkId, result) {
|
|
|
20744
20863
|
printJson2(result);
|
|
20745
20864
|
}
|
|
20746
20865
|
function readSessionEntryPreview(entry) {
|
|
20866
|
+
for (const value of [entry.summary, entry.text, entry.content, entry.title]) {
|
|
20867
|
+
if (typeof value !== "string") {
|
|
20868
|
+
continue;
|
|
20869
|
+
}
|
|
20870
|
+
const trimmed = value.trim();
|
|
20871
|
+
if (trimmed.startsWith("{") && trimmed.endsWith("}")) {
|
|
20872
|
+
try {
|
|
20873
|
+
const parsed = JSON.parse(trimmed);
|
|
20874
|
+
if (isRecord9(parsed)) {
|
|
20875
|
+
const summary = stringValue7(parsed.summary);
|
|
20876
|
+
const nextStep = stringValue7(parsed.nextStep);
|
|
20877
|
+
const task = stringValue7(parsed.task);
|
|
20878
|
+
const readable = [summary, nextStep ? `Next: ${nextStep}` : void 0, task].filter((item) => Boolean(item)).join(" ");
|
|
20879
|
+
if (readable.length > 0) {
|
|
20880
|
+
return toPreview(readable, 220);
|
|
20881
|
+
}
|
|
20882
|
+
}
|
|
20883
|
+
} catch {
|
|
20884
|
+
}
|
|
20885
|
+
}
|
|
20886
|
+
if (trimmed.length > 0) {
|
|
20887
|
+
return toPreview(trimmed, 220);
|
|
20888
|
+
}
|
|
20889
|
+
}
|
|
20747
20890
|
return toPreview(entry.text ?? entry.content ?? entry.summary ?? entry.title, 220);
|
|
20748
20891
|
}
|
|
20749
20892
|
function compactSessionEntryLine(entry) {
|
|
@@ -20751,24 +20894,34 @@ function compactSessionEntryLine(entry) {
|
|
|
20751
20894
|
return `- ${label}: ${readSessionEntryPreview(entry)}`;
|
|
20752
20895
|
}
|
|
20753
20896
|
function printSessionBootstrap(result, options) {
|
|
20754
|
-
const
|
|
20755
|
-
|
|
20756
|
-
|
|
20757
|
-
|
|
20758
|
-
|
|
20897
|
+
const brief = buildSessionBootstrapBrief(result, {
|
|
20898
|
+
includeSessionContext: options.includeSessionContext,
|
|
20899
|
+
maxTokens: options.maxTokens
|
|
20900
|
+
});
|
|
20901
|
+
const entries = brief.entries;
|
|
20759
20902
|
if (entries.length === 0) {
|
|
20760
|
-
return
|
|
20903
|
+
return null;
|
|
20761
20904
|
}
|
|
20762
20905
|
console.log(import_chalk6.default.bold("Snipara Bootstrap Brief"));
|
|
20763
20906
|
for (const entry of entries) {
|
|
20764
20907
|
console.log(compactSessionEntryLine(entry));
|
|
20765
20908
|
}
|
|
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
20909
|
console.log("");
|
|
20771
|
-
return
|
|
20910
|
+
return brief;
|
|
20911
|
+
}
|
|
20912
|
+
function buildPrintedBootstrapQuality(brief, now) {
|
|
20913
|
+
return buildSessionBootstrapQuality(
|
|
20914
|
+
{
|
|
20915
|
+
critical: {
|
|
20916
|
+
memories: brief.entries,
|
|
20917
|
+
count: brief.entries.length,
|
|
20918
|
+
tokens: brief.estimatedTokens
|
|
20919
|
+
},
|
|
20920
|
+
daily: { memories: [], count: 0, tokens: 0 },
|
|
20921
|
+
total_tokens: brief.estimatedTokens
|
|
20922
|
+
},
|
|
20923
|
+
{ expectedMaxTokens: brief.budgetTokens, now }
|
|
20924
|
+
);
|
|
20772
20925
|
}
|
|
20773
20926
|
function printSessionBootstrapQuality(report) {
|
|
20774
20927
|
if (report.warnings.length === 0) {
|
|
@@ -22289,13 +22442,12 @@ async function workflowRunCommand(options) {
|
|
|
22289
22442
|
const printedBootstrap = printSessionBootstrap(
|
|
22290
22443
|
payload.session_bootstrap,
|
|
22291
22444
|
{
|
|
22292
|
-
includeSessionContext: Boolean(workflowBudget?.include_session_context)
|
|
22445
|
+
includeSessionContext: Boolean(workflowBudget?.include_session_context),
|
|
22446
|
+
maxTokens: (workflowBudget?.allocations.critical_memory_tokens ?? DEFAULT_FULL_WORKFLOW_CRITICAL_TOKENS) + (workflowBudget?.allocations.session_context_tokens ?? 0)
|
|
22293
22447
|
}
|
|
22294
22448
|
);
|
|
22295
22449
|
if (printedBootstrap && payload.session_bootstrap_quality && typeof payload.session_bootstrap_quality === "object") {
|
|
22296
|
-
printSessionBootstrapQuality(
|
|
22297
|
-
payload.session_bootstrap_quality
|
|
22298
|
-
);
|
|
22450
|
+
printSessionBootstrapQuality(buildPrintedBootstrapQuality(printedBootstrap));
|
|
22299
22451
|
}
|
|
22300
22452
|
if (workflowBudget?.warnings.length) {
|
|
22301
22453
|
console.log(import_chalk6.default.bold("Workflow Budget Warnings"));
|
|
@@ -23239,10 +23391,11 @@ async function workflowResumeCommand(options) {
|
|
|
23239
23391
|
console.log(import_chalk6.default.bold("Workflow Resume"));
|
|
23240
23392
|
printManagedWorkflowState(state);
|
|
23241
23393
|
const printedBootstrap = printSessionBootstrap(bootstrap, {
|
|
23242
|
-
includeSessionContext: resolvedContextTokens > 0
|
|
23394
|
+
includeSessionContext: resolvedContextTokens > 0,
|
|
23395
|
+
maxTokens: resolvedCriticalTokens + resolvedContextTokens
|
|
23243
23396
|
});
|
|
23244
23397
|
if (printedBootstrap) {
|
|
23245
|
-
printSessionBootstrapQuality(
|
|
23398
|
+
printSessionBootstrapQuality(buildPrintedBootstrapQuality(printedBootstrap));
|
|
23246
23399
|
}
|
|
23247
23400
|
printWorkflowLocalSessionSnapshot(localSessionSnapshot);
|
|
23248
23401
|
printWorkflowTeamSyncResume(teamSyncResume);
|
|
@@ -23766,17 +23919,11 @@ async function sessionBootstrapCommand(options) {
|
|
|
23766
23919
|
return;
|
|
23767
23920
|
}
|
|
23768
23921
|
const printedBootstrap = printSessionBootstrap(result, {
|
|
23769
|
-
includeSessionContext: resolvedContextTokens > 0
|
|
23922
|
+
includeSessionContext: resolvedContextTokens > 0,
|
|
23923
|
+
maxTokens: (options.maxCriticalTokens ?? DEFAULT_FULL_WORKFLOW_CRITICAL_TOKENS) + resolvedContextTokens
|
|
23770
23924
|
});
|
|
23771
23925
|
if (printedBootstrap) {
|
|
23772
|
-
printSessionBootstrapQuality(
|
|
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("");
|
|
23926
|
+
printSessionBootstrapQuality(buildPrintedBootstrapQuality(printedBootstrap));
|
|
23780
23927
|
}
|
|
23781
23928
|
}
|
|
23782
23929
|
async function recallCommand(options) {
|
|
@@ -33781,6 +33928,7 @@ if (require.main === module) {
|
|
|
33781
33928
|
buildProjectIntelligenceBrief,
|
|
33782
33929
|
buildProjectIntelligenceRun,
|
|
33783
33930
|
buildProjectJudgmentCard,
|
|
33931
|
+
buildSessionBootstrapBrief,
|
|
33784
33932
|
buildSessionBootstrapQuality,
|
|
33785
33933
|
buildSessionSnapshot,
|
|
33786
33934
|
buildSyncDocumentsDryRun,
|