snipara-companion 1.3.4 → 1.3.6

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/README.md CHANGED
@@ -41,7 +41,7 @@ For Codex, the primary integration remains Hosted MCP plus `AGENTS.md`.
41
41
 
42
42
  ## Configuring MCP Tool Surfaces
43
43
 
44
- The MCP server advertises different tool surfaces depending on the `SNIPARA_EXPOSED_SURFACES` environment variable. To expose companion tools directly in the advertised manifest, set `SNIPARA_EXPOSED_SURFACES=inline,companion` on the MCP server. This is optional: companion tools are still callable by name on demand via `snipara_help`, even if not advertised.
44
+ The MCP server advertises different tool surfaces depending on the `SNIPARA_EXPOSED_SURFACES` environment variable. Hosted MCP defaults to inline tools plus a small companion maintenance set for index health, reindexing, and read-only memory hygiene. To expose all companion tools directly in the advertised manifest, set `SNIPARA_EXPOSED_SURFACES=inline,companion` on the MCP server. Remaining companion tools are discoverable via `snipara_help` and can be executed by direct JSON-RPC or clients/server configurations that expose those surfaces. Standard MCP agents only receive schemas for tools returned by `tools/list`.
45
45
 
46
46
  ## Installation
47
47
 
@@ -59,6 +59,17 @@ yarn global add snipara-companion
59
59
  snipara-companion
60
60
  ```
61
61
 
62
+ ## New In 1.3.6
63
+
64
+ - Adds `snipara-companion memory audit` for a read-only memory hygiene pass that
65
+ combines hosted memory health, cleanup candidates, and compaction dry-run.
66
+ - Adds `memory health`, `memory clean-candidates`, and `memory compact` as
67
+ direct companion maintenance commands. `memory compact` always sends
68
+ `dry_run=true` and does not mutate memory.
69
+ - Extends `memory-guard check` with `--intent`, `--destructive`, and
70
+ `--require-confirmation` so agents can surface memory/context contradictions
71
+ and ask the user before irreversible actions.
72
+
62
73
  ## New In 1.3.0
63
74
 
64
75
  - Adds top-level Git-style agent work commands: `status`, `brief`, `timeline`,
@@ -462,6 +473,10 @@ snipara-companion sync-documents --file ./snipara-business-context.json --dry-ru
462
473
  snipara-companion reindex --kind doc --mode incremental
463
474
  snipara-companion reindex --job-id index_job_123
464
475
  snipara-companion business-health --json
476
+ snipara-companion memory audit --scope project --include-inactive
477
+ snipara-companion memory health --scope project --json
478
+ snipara-companion memory clean-candidates --scope project --limit-per-bucket 10
479
+ snipara-companion memory compact --scope project --json
465
480
  snipara-companion chunk get --chunk-id chunk_123
466
481
  snipara-companion multi-query --queries "auth flow" "rate limiting"
467
482
  snipara-companion orchestrate --query "understand the auth architecture"
@@ -607,21 +622,27 @@ Semantics:
607
622
  - `snipara-companion sync-documents` = bulk `snipara_sync_documents` for text and supported binary parser documents from a JSON payload or directory
608
623
  - `snipara-companion sync-documents --dry-run` = validate the local payload and business-context freshness metadata without uploading
609
624
  - `snipara-companion business-health` = hosted `snipara_index_health`, with the `business_context` section surfaced for stale/reupload signals
625
+ - `snipara-companion memory audit` = read-only memory hygiene pass that combines `snipara_memory_health`, `snipara_memory_clean_candidates`, and `snipara_memory_compact(dry_run=true)`
626
+ - `snipara-companion memory health` = direct hosted `snipara_memory_health` diagnostics for active counts, stale/noise/anomaly samples, and auto-compaction threshold status
627
+ - `snipara-companion memory clean-candidates` = direct hosted `snipara_memory_clean_candidates` review packet for noise, stale memories, duplicates, category anomalies, and human review queues
628
+ - `snipara-companion memory compact` = hosted compaction preview only; it always calls `snipara_memory_compact` with `dry_run=true` and never mutates memory
610
629
  - `snipara-companion reindex` = trigger or poll hosted `snipara_reindex`; use after uploads when immediate chunk availability matters
611
630
  - `snipara-companion code *` = direct access to the code graph tools without routing through `snipara_context_query`
612
631
  - `snipara-companion recall` = direct durable memory lookup for decisions, learnings, preferences, and carryover
613
632
  - `snipara-companion session-bootstrap` = durable memory first, optional weak session carryover second
614
633
  - `snipara-companion task-commit` = durable task/phase/workflow outcomes only, not a mechanical mirror of every Git commit
615
634
  - `snipara-companion memory-guard check` = forced memory/context recall before retries, commits, or finalization when a command failed or a publishable package surface is touched
635
+ - `snipara-companion memory-guard check --intent "<action>" --destructive --strict` = contradiction check before irreversible actions; blocks until the user explicitly confirms when memory/context disagrees or the action is destructive
616
636
  - `snipara-companion memory-guard remember --guard-tag pre-commit --text "..."` = create a project/team memory in a guard category such as `pre-commit`, `commit`, `failure`, `pre-final`, or `workflow-policy`
617
637
  - `--max-daily-tokens` is still accepted as a compatibility alias for `--max-context-tokens`
618
638
 
619
- ### Memory Guard Before Commit
639
+ ### Memory Guard Before Commit Or Destructive Actions
620
640
 
621
641
  Memory Guard is deterministic, not a user preference. It detects two global signals:
622
642
 
623
643
  - failed or timed-out tool results emitted by Companion hooks
624
644
  - changed files under publishable npm or PyPI package manifests
645
+ - explicit destructive or irreversible intent passed with `--intent` and `--destructive`
625
646
 
626
647
  When triggered, it recalls project guard memories by category and also queries source context before
627
648
  the agent retries, commits, or finalizes. Guard memories are just durable memories with a category tag:
@@ -636,8 +657,17 @@ Run the check manually with:
636
657
 
637
658
  ```bash
638
659
  snipara-companion memory-guard check --trigger pre-commit --staged --strict
660
+ snipara-companion memory-guard check \
661
+ --intent "npm publish snipara-companion" \
662
+ --destructive \
663
+ --strict
639
664
  ```
640
665
 
666
+ When memory or source context contradicts the requested action, the JSON output
667
+ sets `requiresConfirmation=true`, includes `contradictions`, and provides a
668
+ `confirmationPrompt`. In `--strict` mode the command exits non-zero until the
669
+ operator has explicitly confirmed the override.
670
+
641
671
  ### Commit Memory Policy
642
672
 
643
673
  Companion separates two concepts:
package/dist/index.d.ts CHANGED
@@ -997,17 +997,29 @@ interface ReleaseSurface {
997
997
  manifestPath: string;
998
998
  }
999
999
  interface MemoryGuardFinding {
1000
- code: "recent_failure" | "release_surface" | "manual";
1000
+ code: "recent_failure" | "release_surface" | "manual" | "destructive_intent" | "contradiction";
1001
1001
  message: string;
1002
1002
  }
1003
+ interface MemoryGuardContradiction {
1004
+ source: "memory" | "context";
1005
+ reason: string;
1006
+ excerpt: string;
1007
+ memoryId?: string;
1008
+ category?: string;
1009
+ title?: string;
1010
+ file?: string;
1011
+ }
1003
1012
  interface MemoryGuardCheckOptions {
1004
1013
  trigger?: MemoryGuardTrigger;
1005
1014
  files?: string[];
1006
1015
  staged?: boolean;
1007
1016
  command?: string;
1017
+ intent?: string;
1008
1018
  result?: string;
1009
1019
  exitCode?: number;
1010
1020
  status?: string;
1021
+ destructive?: boolean;
1022
+ requireConfirmation?: boolean;
1011
1023
  strict?: boolean;
1012
1024
  json?: boolean;
1013
1025
  limit?: number;
@@ -1031,6 +1043,11 @@ interface MemoryGuardCheckResult {
1031
1043
  }>;
1032
1044
  query: string;
1033
1045
  categories: string[];
1046
+ intent?: string;
1047
+ destructive: boolean;
1048
+ contradictions: MemoryGuardContradiction[];
1049
+ requiresConfirmation: boolean;
1050
+ confirmationPrompt?: string;
1034
1051
  memoryAvailable: boolean;
1035
1052
  contextAvailable: boolean;
1036
1053
  memories: RecalledMemory[];
@@ -1078,6 +1095,45 @@ interface ProjectIntelligenceBrief {
1078
1095
  declare function buildProjectIntelligenceBrief(options: ProjectIntelligenceBriefOptions): Promise<ProjectIntelligenceBrief>;
1079
1096
  declare function projectIntelligenceBriefCommand(options: ProjectIntelligenceBriefOptions): Promise<void>;
1080
1097
 
1098
+ interface MemoryHealthCommandOptions {
1099
+ scope?: MemoryScope;
1100
+ includeInactive?: boolean;
1101
+ sampleLimit?: number;
1102
+ json?: boolean;
1103
+ }
1104
+ interface MemoryCleanCandidatesCommandOptions {
1105
+ scope?: MemoryScope;
1106
+ includeInactive?: boolean;
1107
+ limitPerBucket?: number;
1108
+ json?: boolean;
1109
+ }
1110
+ interface MemoryCompactCommandOptions {
1111
+ scope?: MemoryScope;
1112
+ deduplicate?: boolean;
1113
+ promoteThreshold?: number;
1114
+ archiveOlderThanDays?: number;
1115
+ json?: boolean;
1116
+ }
1117
+ interface MemoryAuditCommandOptions extends MemoryHealthCommandOptions, MemoryCleanCandidatesCommandOptions, MemoryCompactCommandOptions {
1118
+ }
1119
+ interface MemoryAuditResult {
1120
+ version: "snipara.memory_audit.v1";
1121
+ generatedAt: string;
1122
+ scope?: MemoryScope;
1123
+ health?: Record<string, unknown>;
1124
+ cleanCandidates?: Record<string, unknown>;
1125
+ compactDryRun?: Record<string, unknown>;
1126
+ errors: Array<{
1127
+ surface: string;
1128
+ message: string;
1129
+ }>;
1130
+ }
1131
+ declare function memoryHealthCommand(options: MemoryHealthCommandOptions): Promise<void>;
1132
+ declare function memoryCleanCandidatesCommand(options: MemoryCleanCandidatesCommandOptions): Promise<void>;
1133
+ declare function memoryCompactCommand(options: MemoryCompactCommandOptions): Promise<void>;
1134
+ declare function buildMemoryAudit(options: MemoryAuditCommandOptions): Promise<MemoryAuditResult>;
1135
+ declare function memoryAuditCommand(options: MemoryAuditCommandOptions): Promise<void>;
1136
+
1081
1137
  interface VerifyCommandOptions {
1082
1138
  task?: string;
1083
1139
  qualifiedName?: string;
@@ -1994,4 +2050,4 @@ interface WrittenOrchestratorHandoff {
1994
2050
  declare function buildOrchestratorHandoff(options: OrchestratorHandoffOptions): OrchestratorHandoffArtifact;
1995
2051
  declare function writeOrchestratorHandoff(options: OrchestratorHandoffOptions): WrittenOrchestratorHandoff;
1996
2052
 
1997
- export { AUTOMATION_MANIFEST_RELATIVE_PATH, AutomationInstallConflictError, AutomationUnsupportedHookBundleError, ORCHESTRATOR_HANDOFF_RELATIVE_PATH, TEAM_SYNC_STATE_RELATIVE_PATH, WORKFLOW_PLANS_RELATIVE_DIR, WORKFLOW_STATE_RELATIVE_PATH, archiveInactiveTeamSyncWork, autoArchiveTeamSyncState, buildAgenticHandoffMarkdown, buildAgenticTimeline, buildAgenticWorkStatus, buildAutomationInstallPlan, buildCanonicalEvent, buildCodeHooksInstallPlan, buildCodePromotionResult, buildCodeStatusResult, buildCodeSyncResult, buildHostedCodeOverlayUploadPayload, buildJournalCheckpointEntry, buildLocalCallersResult, buildLocalCodeOverlay, buildLocalImpactResult, buildLocalImportsResult, buildLocalNeighborsResult, buildLocalShortestPathResult, buildOnboardFolderManifest, buildOrchestratorHandoff, buildProjectIntelligenceBrief, buildSyncDocumentsDryRun, buildTeamSyncHandoffRecord, buildTeamSyncStartWorkRecord, buildTeamSyncSummary, buildToolCallPayload, buildToolResultPayload, buildVerificationPlan, buildWorkflowPhaseCommitSummary, buildWorkflowPlanScaffold, categoryFromGuardTag, classifyToolResult, collectSyncDocuments, collectSyncDocumentsInput, createClient, createEmptyTeamSyncState, createLocalQueryCache, detectReleaseSurfacesFromFiles, detectRuntimeEnvironment, extractCommandFromToolInput, extractFilesFromToolInput, formatOrchestratorRecommendationReason, formatStuckGuardDecision, getAutomationManifestPath, getAutomationStatus, getConfigPath, getLocalCodeOverlayCachePath, getLocalCodePromotionStatePath, getOrchestratorRecommendation, getPlanStepDisplayTitle, getStagedFiles, getStuckGuardInjection, getTeamSyncStatePath, installAutomationBundle, listProjectsForApiKey, loadAutomationManifest, loadConfig, loadTeamSyncState, normalizeGuardTag, normalizeWorkflowPlanInput, projectIntelligenceBriefCommand, readLocalCodeOverlayCache, readLocalCodePromotionState, resolveQueryFromToolInput, runMemoryGuardCheck, saveConfig, saveTeamSyncState, shouldSuggestOrchestratorForWorkflow, shouldSuggestRuntimeForWorkflow, summarizeLocalCodeOverlay, teamSyncSweepCommand, verifyCommand, writeLocalCodeOverlayCache, writeLocalCodePromotionState, writeOrchestratorHandoff };
2053
+ export { AUTOMATION_MANIFEST_RELATIVE_PATH, AutomationInstallConflictError, AutomationUnsupportedHookBundleError, ORCHESTRATOR_HANDOFF_RELATIVE_PATH, TEAM_SYNC_STATE_RELATIVE_PATH, WORKFLOW_PLANS_RELATIVE_DIR, WORKFLOW_STATE_RELATIVE_PATH, archiveInactiveTeamSyncWork, autoArchiveTeamSyncState, buildAgenticHandoffMarkdown, buildAgenticTimeline, buildAgenticWorkStatus, buildAutomationInstallPlan, buildCanonicalEvent, buildCodeHooksInstallPlan, buildCodePromotionResult, buildCodeStatusResult, buildCodeSyncResult, buildHostedCodeOverlayUploadPayload, buildJournalCheckpointEntry, buildLocalCallersResult, buildLocalCodeOverlay, buildLocalImpactResult, buildLocalImportsResult, buildLocalNeighborsResult, buildLocalShortestPathResult, buildMemoryAudit, buildOnboardFolderManifest, buildOrchestratorHandoff, buildProjectIntelligenceBrief, buildSyncDocumentsDryRun, buildTeamSyncHandoffRecord, buildTeamSyncStartWorkRecord, buildTeamSyncSummary, buildToolCallPayload, buildToolResultPayload, buildVerificationPlan, buildWorkflowPhaseCommitSummary, buildWorkflowPlanScaffold, categoryFromGuardTag, classifyToolResult, collectSyncDocuments, collectSyncDocumentsInput, createClient, createEmptyTeamSyncState, createLocalQueryCache, detectReleaseSurfacesFromFiles, detectRuntimeEnvironment, extractCommandFromToolInput, extractFilesFromToolInput, formatOrchestratorRecommendationReason, formatStuckGuardDecision, getAutomationManifestPath, getAutomationStatus, getConfigPath, getLocalCodeOverlayCachePath, getLocalCodePromotionStatePath, getOrchestratorRecommendation, getPlanStepDisplayTitle, getStagedFiles, getStuckGuardInjection, getTeamSyncStatePath, installAutomationBundle, listProjectsForApiKey, loadAutomationManifest, loadConfig, loadTeamSyncState, memoryAuditCommand, memoryCleanCandidatesCommand, memoryCompactCommand, memoryHealthCommand, normalizeGuardTag, normalizeWorkflowPlanInput, projectIntelligenceBriefCommand, readLocalCodeOverlayCache, readLocalCodePromotionState, resolveQueryFromToolInput, runMemoryGuardCheck, saveConfig, saveTeamSyncState, shouldSuggestOrchestratorForWorkflow, shouldSuggestRuntimeForWorkflow, summarizeLocalCodeOverlay, teamSyncSweepCommand, verifyCommand, writeLocalCodeOverlayCache, writeLocalCodePromotionState, writeOrchestratorHandoff };