zam-core 0.5.0 → 0.5.2

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
@@ -1586,6 +1586,10 @@ interface ReviewContext {
1586
1586
  }
1587
1587
  /** Default cap on resolved content length, so bridge JSON / terminal output stays bounded. */
1588
1588
  declare const DEFAULT_REVIEW_CONTEXT_MAX_CHARS = 6000;
1589
+ /** How long resolved review context stays in the in-process cache (5 minutes). */
1590
+ declare const REVIEW_CONTEXT_CACHE_TTL_MS: number;
1591
+ /** Clear the in-process review-context cache (mainly for tests). */
1592
+ declare function clearReviewContextCache(): void;
1589
1593
  /**
1590
1594
  * Resolves a given token's source_link into readable textual content.
1591
1595
  */
@@ -1853,6 +1857,7 @@ declare function saveMachineAiConfig(ai: MachineAiConfig, path?: string): void;
1853
1857
  declare function getConfiguredWorkspaces(path?: string): WorkspaceConfig[];
1854
1858
  declare function saveConfiguredWorkspaces(workspaces: WorkspaceConfig[], path?: string): void;
1855
1859
  declare function upsertConfiguredWorkspace(workspace: WorkspaceConfig, path?: string): WorkspaceConfig[];
1860
+ declare function removeConfiguredWorkspace(id: string, path?: string): WorkspaceConfig[];
1856
1861
  /**
1857
1862
  * Best-effort detection of the file-sync provider a folder lives in, from its
1858
1863
  * path. Used only for friendly messaging ("this folder syncs via OneDrive —
@@ -1947,4 +1952,4 @@ declare function resolveAllBeliefPaths(db: Database): Promise<string[]>;
1947
1952
  */
1948
1953
  declare function resolveAllGoalPaths(db: Database): Promise<string[]>;
1949
1954
 
1950
- export { type ADOConfig, type ADOCredentials, type AgentSkill, type AnalysisResult, type ApplySessionSynthesisInput, type ApplySessionSynthesisResult, BUILT_IN_SENSITIVE_MATCHERS, type BloomLevel$1 as BloomLevel, type CaptureDecision, type CaptureDenialReason, type CaptureRequest, type Card, type CardDeletionImpact, type CardState$1 as CardState, type CascadeBlockResult, type CommandRecord, type CommandSequence, type ConnectionOptions, type CreateAgentSkillInput, type CreateGoalInput, type CreateReviewInput, type CreateSessionInput, type CreateTokenInput, type Credentials, DEFAULT_OBSERVER_POLICY, DEFAULT_REVIEW_CONTEXT_MAX_CHARS, type Database, type DatabaseProvider, type DatabaseTargetInfo, type DatabaseValue, type DeleteCardResult, type DeleteTokenResult, type DiscoveryOptions, type DomainCompetence, type EvaluateInput, type EvaluateResult, type ExecuteReviewActionInput, type ExecutionContext, type FSRSParameters, type Goal, type GoalFrontmatter, type GoalStatus, type GoalSummary, HOMEBREW_CASK, type ImportResult, type InstallChannel, type InstallConfig, type InstallMode, type InstallPlan, type InstallResult, type LocalLLMRunner, type LogStepInput, type MachineAiConfig, type MachineProviderRecord, type MachineRoleBinding, type MonitorEvent, type Neighborhood, type NeighborhoodToken, OBSERVER_POLICY_UNSET_HINT, OBSERVER_POLICY_VERSION, type ObservationRating, type ObserverConsent, type ObserverPolicy, type ObserverRetention, type ObserverScope, type ObserverSettingKey, type PrepareSessionSynthesisInput, type Prerequisite, type PrerequisiteWithToken, type PromptInput, type Rating, type RecallPrompt, type RemoteDatabaseOptions, type RepoPaths, type ResolvedCaptureTarget, type ResolvedReference, type ReviewActionResult, type ReviewActionType, type ReviewContext, type ReviewLog, type ReviewQueue, type ReviewQueueItem, type ReviewQueueOptions, type RunResult, SIDECAR_POLICY_FILE, SNAPSHOT_VERSION, type SchedulingCard, type Session, type SessionStep, type SessionSummary, type SessionSynthesisCandidate, type SessionSynthesisEvidence, type SessionSynthesisPreview, type SessionSynthesisRecord, type SidecarPrivacyPolicy, type SkillProposal, type SkillSource, type SnapshotManifest, type Statement, type SupportedLocale, type SymbiosisMode, type SynthesisConfidence, type SystemProfile, type Token, type TokenDeleteImpact, type TokenPattern, type TranslationKey, type TursoCredentials, UI_OBSERVATION_PROTOCOL_VERSION, type UiActionType, type UiApplicationContext, type UiCandidateToken, type UiEvidenceRef, type UiEvidenceType, type UiObservationKind, type UiObservationReport, type UiObservedAction, type UnblockResult, type UpdateActionKind, type UpdateCardInput, type UpdateDecision, type UpdateStep, type UpdateStepKind, type UpdateTokenInput, type UserSetting, type UserStats, WINGET_PACKAGE_ID, type WorkItem, type WorkspaceConfig, type WorkspaceKind, type WorkspaceSourceControl, addPrerequisite, analyzeObservation, appendUiObservationReport, applySessionSynthesis, buildReviewQueue, buildUiSynthesisCandidates, cascadeBlock, clearADOCredentials, clearProviderApiKey, clearTursoCredentials, compareVersions, createAgentSkill, createFSRS, createGoal, createToken, decidePostCapture, decidePreCapture, decideUpdate, deleteCardForUser, deleteSetting, deleteToken, deprecateToken, detectSyncProvider, detectSystemLocale, discoverSkills, distributeGlobalSkills, endSession, ensureCard, ensureMonitorDir, ensureUiObserverDir, evaluateRating, executeReviewAction, exportSnapshot, extractTasks, extractTokenRefs, fetchActiveWorkItems, findTokens, generateBashHooks, generateBashUnhooks, generateConceptFreeCue, generatePowerShellHooks, generatePowerShellUnhooks, generatePrompt, generateZshHooks, generateZshUnhooks, getADOCredentials, getAgentSkill, getAllSettings, getAllSettingsDetailed, getBlockedCards, getCard, getCardById, getCardDeletionImpact, getConfiguredWorkspaces, getDatabaseTargetInfo, getDefaultDbPath, getDependents, getDomainCompetence, getDueCards, getGoal, getGoalTree, getInstallChannel, getInstallMode, getMachineAiConfig, getMonitorDir, getMonitorLogStats, getMonitorPath, getPackageSkillPath, getPrerequisites, getProviderApiKey, getRepoPaths, getReviewsForCard, getReviewsForUser, getSessionSummary, getSessionSynthesisRecords, getSetting, getSystemProfile, getTokenById, getTokenBySlug, getTokenDeleteImpact, getTokenNeighborhood, getTursoCredentials, getUiObservationPath, getUiObserverDir, getUserStats, hasCommand, importSnapshot, injectShellHooks, installFastFlowLM, installOllama, installOpenCode, interleave, isObserverPolicyConfigured, isUiObservationReport, listAgentSkills, listGoals, listProviderApiKeyRefs, listTokens, loadADOConfig, loadCredentials, loadInstallConfig, logReview, logStep, matchBuiltInSensitive, matchDenylist, matchesFilePath, monitorLogExists, normalizeLocale, normalizePath, openDatabase, openDatabaseWithSync, openRemoteDatabase, pairCommands, parseGoalFile, parseMonitorLog, parseObserverList, parseObserverPolicy, parseSnapshot, parseUiObservationLog, planOpenCodeInstall, planUpdate, prepareLocalModel, prepareSessionSynthesis, readMonitorLog, readUiObservationLog, resolveAllBeliefPaths, resolveAllGoalPaths, resolveObserverPolicy, resolveReference, resolveRepoPath, resolveReviewContext, saveConfiguredWorkspaces, saveCredentials, saveInstallConfig, saveMachineAiConfig, serializeGoal, setADOCredentials, setInstallChannel, setInstallMode, setProviderApiKey, setSetting, setTursoCredentials, startSession, syncObserverSidecarPolicy, t, toSidecarPrivacyPolicy, uiObservationLogExists, uiObservationTimeSpan, unblockReady, updateCard, updateGoalStatus, updateToken, upsertConfiguredWorkspace, verifySnapshot, wouldCreateCycle, writeMonitorEvent };
1955
+ export { type ADOConfig, type ADOCredentials, type AgentSkill, type AnalysisResult, type ApplySessionSynthesisInput, type ApplySessionSynthesisResult, BUILT_IN_SENSITIVE_MATCHERS, type BloomLevel$1 as BloomLevel, type CaptureDecision, type CaptureDenialReason, type CaptureRequest, type Card, type CardDeletionImpact, type CardState$1 as CardState, type CascadeBlockResult, type CommandRecord, type CommandSequence, type ConnectionOptions, type CreateAgentSkillInput, type CreateGoalInput, type CreateReviewInput, type CreateSessionInput, type CreateTokenInput, type Credentials, DEFAULT_OBSERVER_POLICY, DEFAULT_REVIEW_CONTEXT_MAX_CHARS, type Database, type DatabaseProvider, type DatabaseTargetInfo, type DatabaseValue, type DeleteCardResult, type DeleteTokenResult, type DiscoveryOptions, type DomainCompetence, type EvaluateInput, type EvaluateResult, type ExecuteReviewActionInput, type ExecutionContext, type FSRSParameters, type Goal, type GoalFrontmatter, type GoalStatus, type GoalSummary, HOMEBREW_CASK, type ImportResult, type InstallChannel, type InstallConfig, type InstallMode, type InstallPlan, type InstallResult, type LocalLLMRunner, type LogStepInput, type MachineAiConfig, type MachineProviderRecord, type MachineRoleBinding, type MonitorEvent, type Neighborhood, type NeighborhoodToken, OBSERVER_POLICY_UNSET_HINT, OBSERVER_POLICY_VERSION, type ObservationRating, type ObserverConsent, type ObserverPolicy, type ObserverRetention, type ObserverScope, type ObserverSettingKey, type PrepareSessionSynthesisInput, type Prerequisite, type PrerequisiteWithToken, type PromptInput, REVIEW_CONTEXT_CACHE_TTL_MS, type Rating, type RecallPrompt, type RemoteDatabaseOptions, type RepoPaths, type ResolvedCaptureTarget, type ResolvedReference, type ReviewActionResult, type ReviewActionType, type ReviewContext, type ReviewLog, type ReviewQueue, type ReviewQueueItem, type ReviewQueueOptions, type RunResult, SIDECAR_POLICY_FILE, SNAPSHOT_VERSION, type SchedulingCard, type Session, type SessionStep, type SessionSummary, type SessionSynthesisCandidate, type SessionSynthesisEvidence, type SessionSynthesisPreview, type SessionSynthesisRecord, type SidecarPrivacyPolicy, type SkillProposal, type SkillSource, type SnapshotManifest, type Statement, type SupportedLocale, type SymbiosisMode, type SynthesisConfidence, type SystemProfile, type Token, type TokenDeleteImpact, type TokenPattern, type TranslationKey, type TursoCredentials, UI_OBSERVATION_PROTOCOL_VERSION, type UiActionType, type UiApplicationContext, type UiCandidateToken, type UiEvidenceRef, type UiEvidenceType, type UiObservationKind, type UiObservationReport, type UiObservedAction, type UnblockResult, type UpdateActionKind, type UpdateCardInput, type UpdateDecision, type UpdateStep, type UpdateStepKind, type UpdateTokenInput, type UserSetting, type UserStats, WINGET_PACKAGE_ID, type WorkItem, type WorkspaceConfig, type WorkspaceKind, type WorkspaceSourceControl, addPrerequisite, analyzeObservation, appendUiObservationReport, applySessionSynthesis, buildReviewQueue, buildUiSynthesisCandidates, cascadeBlock, clearADOCredentials, clearProviderApiKey, clearReviewContextCache, clearTursoCredentials, compareVersions, createAgentSkill, createFSRS, createGoal, createToken, decidePostCapture, decidePreCapture, decideUpdate, deleteCardForUser, deleteSetting, deleteToken, deprecateToken, detectSyncProvider, detectSystemLocale, discoverSkills, distributeGlobalSkills, endSession, ensureCard, ensureMonitorDir, ensureUiObserverDir, evaluateRating, executeReviewAction, exportSnapshot, extractTasks, extractTokenRefs, fetchActiveWorkItems, findTokens, generateBashHooks, generateBashUnhooks, generateConceptFreeCue, generatePowerShellHooks, generatePowerShellUnhooks, generatePrompt, generateZshHooks, generateZshUnhooks, getADOCredentials, getAgentSkill, getAllSettings, getAllSettingsDetailed, getBlockedCards, getCard, getCardById, getCardDeletionImpact, getConfiguredWorkspaces, getDatabaseTargetInfo, getDefaultDbPath, getDependents, getDomainCompetence, getDueCards, getGoal, getGoalTree, getInstallChannel, getInstallMode, getMachineAiConfig, getMonitorDir, getMonitorLogStats, getMonitorPath, getPackageSkillPath, getPrerequisites, getProviderApiKey, getRepoPaths, getReviewsForCard, getReviewsForUser, getSessionSummary, getSessionSynthesisRecords, getSetting, getSystemProfile, getTokenById, getTokenBySlug, getTokenDeleteImpact, getTokenNeighborhood, getTursoCredentials, getUiObservationPath, getUiObserverDir, getUserStats, hasCommand, importSnapshot, injectShellHooks, installFastFlowLM, installOllama, installOpenCode, interleave, isObserverPolicyConfigured, isUiObservationReport, listAgentSkills, listGoals, listProviderApiKeyRefs, listTokens, loadADOConfig, loadCredentials, loadInstallConfig, logReview, logStep, matchBuiltInSensitive, matchDenylist, matchesFilePath, monitorLogExists, normalizeLocale, normalizePath, openDatabase, openDatabaseWithSync, openRemoteDatabase, pairCommands, parseGoalFile, parseMonitorLog, parseObserverList, parseObserverPolicy, parseSnapshot, parseUiObservationLog, planOpenCodeInstall, planUpdate, prepareLocalModel, prepareSessionSynthesis, readMonitorLog, readUiObservationLog, removeConfiguredWorkspace, resolveAllBeliefPaths, resolveAllGoalPaths, resolveObserverPolicy, resolveReference, resolveRepoPath, resolveReviewContext, saveConfiguredWorkspaces, saveCredentials, saveInstallConfig, saveMachineAiConfig, serializeGoal, setADOCredentials, setInstallChannel, setInstallMode, setProviderApiKey, setSetting, setTursoCredentials, startSession, syncObserverSidecarPolicy, t, toSidecarPrivacyPolicy, uiObservationLogExists, uiObservationTimeSpan, unblockReady, updateCard, updateGoalStatus, updateToken, upsertConfiguredWorkspace, verifySnapshot, wouldCreateCycle, writeMonitorEvent };
package/dist/index.js CHANGED
@@ -3674,6 +3674,14 @@ function generatePrompt(input) {
3674
3674
  import { existsSync as existsSync6, readFileSync as readFileSync6 } from "fs";
3675
3675
  import { dirname as dirname3, join as join7, resolve } from "path";
3676
3676
  var DEFAULT_REVIEW_CONTEXT_MAX_CHARS = 6e3;
3677
+ var REVIEW_CONTEXT_CACHE_TTL_MS = 5 * 60 * 1e3;
3678
+ var reviewContextCache = /* @__PURE__ */ new Map();
3679
+ function reviewContextCacheKey(sourceLink, maxChars) {
3680
+ return `${sourceLink}\0${maxChars}`;
3681
+ }
3682
+ function clearReviewContextCache() {
3683
+ reviewContextCache.clear();
3684
+ }
3677
3685
  function htmlToText(html) {
3678
3686
  let content = html;
3679
3687
  const bodyMatch = /<body[^>]*>([\s\S]*?)<\/body>/i.exec(html);
@@ -3816,6 +3824,11 @@ async function resolveReviewContext(sourceLink, opts = {}) {
3816
3824
  const cleaned = sourceLink?.trim();
3817
3825
  if (!cleaned) return null;
3818
3826
  const maxChars = opts.maxChars ?? DEFAULT_REVIEW_CONTEXT_MAX_CHARS;
3827
+ const cacheKey = reviewContextCacheKey(cleaned, maxChars);
3828
+ const cached = reviewContextCache.get(cacheKey);
3829
+ if (cached && cached.expiresAt > Date.now()) {
3830
+ return cached.context;
3831
+ }
3819
3832
  const resolved = await resolveReference(cleaned);
3820
3833
  let content = resolved.content;
3821
3834
  let truncated = false;
@@ -3823,7 +3836,7 @@ async function resolveReviewContext(sourceLink, opts = {}) {
3823
3836
  content = content.slice(0, maxChars);
3824
3837
  truncated = true;
3825
3838
  }
3826
- return {
3839
+ const context = {
3827
3840
  sourceLink: cleaned,
3828
3841
  sourceType: resolved.sourceType,
3829
3842
  content,
@@ -3831,6 +3844,11 @@ async function resolveReviewContext(sourceLink, opts = {}) {
3831
3844
  url: resolved.url,
3832
3845
  truncated
3833
3846
  };
3847
+ reviewContextCache.set(cacheKey, {
3848
+ context,
3849
+ expiresAt: Date.now() + REVIEW_CONTEXT_CACHE_TTL_MS
3850
+ });
3851
+ return context;
3834
3852
  }
3835
3853
  function normalizePath(p) {
3836
3854
  const base = p.split("#")[0].trim();
@@ -4526,6 +4544,13 @@ function upsertConfiguredWorkspace(workspace, path = defaultConfigPath()) {
4526
4544
  saveConfiguredWorkspaces(next, path);
4527
4545
  return next;
4528
4546
  }
4547
+ function removeConfiguredWorkspace(id, path = defaultConfigPath()) {
4548
+ const next = getConfiguredWorkspaces(path).filter(
4549
+ (workspace) => workspace.id !== id
4550
+ );
4551
+ saveConfiguredWorkspaces(next, path);
4552
+ return next;
4553
+ }
4529
4554
  function detectSyncProvider(dir) {
4530
4555
  const p = dir.toLowerCase();
4531
4556
  if (p.includes("onedrive")) return "OneDrive";
@@ -5025,6 +5050,7 @@ export {
5025
5050
  HOMEBREW_CASK,
5026
5051
  OBSERVER_POLICY_UNSET_HINT,
5027
5052
  OBSERVER_POLICY_VERSION,
5053
+ REVIEW_CONTEXT_CACHE_TTL_MS,
5028
5054
  SIDECAR_POLICY_FILE,
5029
5055
  SNAPSHOT_VERSION,
5030
5056
  UI_OBSERVATION_PROTOCOL_VERSION,
@@ -5038,6 +5064,7 @@ export {
5038
5064
  cascadeBlock,
5039
5065
  clearADOCredentials,
5040
5066
  clearProviderApiKey,
5067
+ clearReviewContextCache,
5041
5068
  clearTursoCredentials,
5042
5069
  compareVersions,
5043
5070
  createAgentSkill,
@@ -5154,6 +5181,7 @@ export {
5154
5181
  prepareSessionSynthesis,
5155
5182
  readMonitorLog,
5156
5183
  readUiObservationLog,
5184
+ removeConfiguredWorkspace,
5157
5185
  resolveAllBeliefPaths,
5158
5186
  resolveAllGoalPaths,
5159
5187
  resolveObserverPolicy,