snipara-companion 1.3.5 → 1.3.7

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
@@ -59,6 +59,30 @@ yarn global add snipara-companion
59
59
  snipara-companion
60
60
  ```
61
61
 
62
+ ## New In 1.3.7
63
+
64
+ - Hardens `memory-guard check` with `--confirmed-by-user "<confirmation>"`
65
+ for explicit, auditable overrides after the user has reviewed destructive or
66
+ contradictory signals.
67
+ - Adds stable guard exit codes in strict mode: `20` for confirmation required,
68
+ `21` for unavailable memory/context guidance, and `22` for invalid guard
69
+ options.
70
+ - Validates destructive checks before hosted calls so vague commands such as
71
+ `--destructive` without `--intent` or `--command` fail fast.
72
+ - Extends `snipara-companion init --with-hooks` so it also installs local code
73
+ overlay Git hooks (`post-commit` sync and `pre-push` promotion/reindex).
74
+
75
+ ## New In 1.3.6
76
+
77
+ - Adds `snipara-companion memory audit` for a read-only memory hygiene pass that
78
+ combines hosted memory health, cleanup candidates, and compaction dry-run.
79
+ - Adds `memory health`, `memory clean-candidates`, and `memory compact` as
80
+ direct companion maintenance commands. `memory compact` always sends
81
+ `dry_run=true` and does not mutate memory.
82
+ - Extends `memory-guard check` with `--intent`, `--destructive`, and
83
+ `--require-confirmation` so agents can surface memory/context contradictions
84
+ and ask the user before irreversible actions.
85
+
62
86
  ## New In 1.3.0
63
87
 
64
88
  - Adds top-level Git-style agent work commands: `status`, `brief`, `timeline`,
@@ -462,6 +486,10 @@ snipara-companion sync-documents --file ./snipara-business-context.json --dry-ru
462
486
  snipara-companion reindex --kind doc --mode incremental
463
487
  snipara-companion reindex --job-id index_job_123
464
488
  snipara-companion business-health --json
489
+ snipara-companion memory audit --scope project --include-inactive
490
+ snipara-companion memory health --scope project --json
491
+ snipara-companion memory clean-candidates --scope project --limit-per-bucket 10
492
+ snipara-companion memory compact --scope project --json
465
493
  snipara-companion chunk get --chunk-id chunk_123
466
494
  snipara-companion multi-query --queries "auth flow" "rate limiting"
467
495
  snipara-companion orchestrate --query "understand the auth architecture"
@@ -607,21 +635,27 @@ Semantics:
607
635
  - `snipara-companion sync-documents` = bulk `snipara_sync_documents` for text and supported binary parser documents from a JSON payload or directory
608
636
  - `snipara-companion sync-documents --dry-run` = validate the local payload and business-context freshness metadata without uploading
609
637
  - `snipara-companion business-health` = hosted `snipara_index_health`, with the `business_context` section surfaced for stale/reupload signals
638
+ - `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)`
639
+ - `snipara-companion memory health` = direct hosted `snipara_memory_health` diagnostics for active counts, stale/noise/anomaly samples, and auto-compaction threshold status
640
+ - `snipara-companion memory clean-candidates` = direct hosted `snipara_memory_clean_candidates` review packet for noise, stale memories, duplicates, category anomalies, and human review queues
641
+ - `snipara-companion memory compact` = hosted compaction preview only; it always calls `snipara_memory_compact` with `dry_run=true` and never mutates memory
610
642
  - `snipara-companion reindex` = trigger or poll hosted `snipara_reindex`; use after uploads when immediate chunk availability matters
611
643
  - `snipara-companion code *` = direct access to the code graph tools without routing through `snipara_context_query`
612
644
  - `snipara-companion recall` = direct durable memory lookup for decisions, learnings, preferences, and carryover
613
645
  - `snipara-companion session-bootstrap` = durable memory first, optional weak session carryover second
614
646
  - `snipara-companion task-commit` = durable task/phase/workflow outcomes only, not a mechanical mirror of every Git commit
615
647
  - `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
648
+ - `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
649
  - `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
650
  - `--max-daily-tokens` is still accepted as a compatibility alias for `--max-context-tokens`
618
651
 
619
- ### Memory Guard Before Commit
652
+ ### Memory Guard Before Commit Or Destructive Actions
620
653
 
621
654
  Memory Guard is deterministic, not a user preference. It detects two global signals:
622
655
 
623
656
  - failed or timed-out tool results emitted by Companion hooks
624
657
  - changed files under publishable npm or PyPI package manifests
658
+ - explicit destructive or irreversible intent passed with `--intent` and `--destructive`
625
659
 
626
660
  When triggered, it recalls project guard memories by category and also queries source context before
627
661
  the agent retries, commits, or finalizes. Guard memories are just durable memories with a category tag:
@@ -636,7 +670,28 @@ Run the check manually with:
636
670
 
637
671
  ```bash
638
672
  snipara-companion memory-guard check --trigger pre-commit --staged --strict
639
- ```
673
+ snipara-companion memory-guard check \
674
+ --intent "npm publish snipara-companion" \
675
+ --destructive \
676
+ --strict
677
+ snipara-companion memory-guard check \
678
+ --intent "npm publish snipara-companion" \
679
+ --destructive \
680
+ --strict \
681
+ --confirmed-by-user "User confirmed npm publish after reviewing guard output"
682
+ ```
683
+
684
+ When memory or source context contradicts the requested action, the JSON output
685
+ sets `requiresConfirmation=true`, includes `contradictions`, and provides a
686
+ `confirmationPrompt`. In `--strict` mode the command exits non-zero until the
687
+ operator has explicitly confirmed the override.
688
+
689
+ Strict mode exit codes:
690
+
691
+ - `20`: confirmation is required before continuing.
692
+ - `21`: memory/context guidance was unavailable for a triggered guard.
693
+ - `22`: guard options were invalid, for example `--destructive` without a
694
+ specific `--intent` or `--command`.
640
695
 
641
696
  ### Commit Memory Policy
642
697
 
package/dist/index.d.ts CHANGED
@@ -997,17 +997,31 @@ 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
+ type MemoryGuardBlockReason = "confirmation_required" | "guidance_unavailable";
1004
+ interface MemoryGuardContradiction {
1005
+ source: "memory" | "context";
1006
+ reason: string;
1007
+ excerpt: string;
1008
+ memoryId?: string;
1009
+ category?: string;
1010
+ title?: string;
1011
+ file?: string;
1012
+ }
1003
1013
  interface MemoryGuardCheckOptions {
1004
1014
  trigger?: MemoryGuardTrigger;
1005
1015
  files?: string[];
1006
1016
  staged?: boolean;
1007
1017
  command?: string;
1018
+ intent?: string;
1008
1019
  result?: string;
1009
1020
  exitCode?: number;
1010
1021
  status?: string;
1022
+ destructive?: boolean;
1023
+ requireConfirmation?: boolean;
1024
+ confirmedByUser?: string;
1011
1025
  strict?: boolean;
1012
1026
  json?: boolean;
1013
1027
  limit?: number;
@@ -1015,9 +1029,18 @@ interface MemoryGuardCheckOptions {
1015
1029
  includeContext?: boolean;
1016
1030
  recentFailures?: boolean;
1017
1031
  }
1032
+ interface MemoryGuardConfirmation {
1033
+ required: boolean;
1034
+ confirmed: boolean;
1035
+ note?: string;
1036
+ overridesDestructive: boolean;
1037
+ overridesContradictions: boolean;
1038
+ }
1018
1039
  interface MemoryGuardCheckResult {
1019
1040
  triggered: boolean;
1020
1041
  shouldBlock: boolean;
1042
+ blockReason?: MemoryGuardBlockReason;
1043
+ exitCode: number;
1021
1044
  trigger: MemoryGuardTrigger;
1022
1045
  findings: MemoryGuardFinding[];
1023
1046
  files: string[];
@@ -1031,6 +1054,12 @@ interface MemoryGuardCheckResult {
1031
1054
  }>;
1032
1055
  query: string;
1033
1056
  categories: string[];
1057
+ intent?: string;
1058
+ destructive: boolean;
1059
+ contradictions: MemoryGuardContradiction[];
1060
+ requiresConfirmation: boolean;
1061
+ confirmation: MemoryGuardConfirmation;
1062
+ confirmationPrompt?: string;
1034
1063
  memoryAvailable: boolean;
1035
1064
  contextAvailable: boolean;
1036
1065
  memories: RecalledMemory[];
@@ -1078,6 +1107,45 @@ interface ProjectIntelligenceBrief {
1078
1107
  declare function buildProjectIntelligenceBrief(options: ProjectIntelligenceBriefOptions): Promise<ProjectIntelligenceBrief>;
1079
1108
  declare function projectIntelligenceBriefCommand(options: ProjectIntelligenceBriefOptions): Promise<void>;
1080
1109
 
1110
+ interface MemoryHealthCommandOptions {
1111
+ scope?: MemoryScope;
1112
+ includeInactive?: boolean;
1113
+ sampleLimit?: number;
1114
+ json?: boolean;
1115
+ }
1116
+ interface MemoryCleanCandidatesCommandOptions {
1117
+ scope?: MemoryScope;
1118
+ includeInactive?: boolean;
1119
+ limitPerBucket?: number;
1120
+ json?: boolean;
1121
+ }
1122
+ interface MemoryCompactCommandOptions {
1123
+ scope?: MemoryScope;
1124
+ deduplicate?: boolean;
1125
+ promoteThreshold?: number;
1126
+ archiveOlderThanDays?: number;
1127
+ json?: boolean;
1128
+ }
1129
+ interface MemoryAuditCommandOptions extends MemoryHealthCommandOptions, MemoryCleanCandidatesCommandOptions, MemoryCompactCommandOptions {
1130
+ }
1131
+ interface MemoryAuditResult {
1132
+ version: "snipara.memory_audit.v1";
1133
+ generatedAt: string;
1134
+ scope?: MemoryScope;
1135
+ health?: Record<string, unknown>;
1136
+ cleanCandidates?: Record<string, unknown>;
1137
+ compactDryRun?: Record<string, unknown>;
1138
+ errors: Array<{
1139
+ surface: string;
1140
+ message: string;
1141
+ }>;
1142
+ }
1143
+ declare function memoryHealthCommand(options: MemoryHealthCommandOptions): Promise<void>;
1144
+ declare function memoryCleanCandidatesCommand(options: MemoryCleanCandidatesCommandOptions): Promise<void>;
1145
+ declare function memoryCompactCommand(options: MemoryCompactCommandOptions): Promise<void>;
1146
+ declare function buildMemoryAudit(options: MemoryAuditCommandOptions): Promise<MemoryAuditResult>;
1147
+ declare function memoryAuditCommand(options: MemoryAuditCommandOptions): Promise<void>;
1148
+
1081
1149
  interface VerifyCommandOptions {
1082
1150
  task?: string;
1083
1151
  qualifiedName?: string;
@@ -1994,4 +2062,4 @@ interface WrittenOrchestratorHandoff {
1994
2062
  declare function buildOrchestratorHandoff(options: OrchestratorHandoffOptions): OrchestratorHandoffArtifact;
1995
2063
  declare function writeOrchestratorHandoff(options: OrchestratorHandoffOptions): WrittenOrchestratorHandoff;
1996
2064
 
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 };
2065
+ 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 };