fix(retrieval): suppress dry-run details in summary mode
This commit is contained in:
1 parent
561e010c41
commit
5ca0dcfb53
2 files changed
+19
-4
No files matched your search
@@ -67,7 +67,7 @@ def save_state(path, state, dry_run):
|
|||||||
path.write_text(json.dumps(state, indent=2) + '\n', encoding='utf-8')
|
path.write_text(json.dumps(state, indent=2) + '\n', encoding='utf-8')
|
||||||
|
|
||||||
|
|
||||||
def sync(root, home, clients, enabled, dry_run, update):
|
def sync(root, home, clients, enabled, dry_run, update, summary=False):
|
||||||
base = home / '.my-ai-configuration'
|
base = home / '.my-ai-configuration'
|
||||||
target = base / 'semantic-retrieval'
|
target = base / 'semantic-retrieval'
|
||||||
state_path = base / 'semantic-retrieval.json'
|
state_path = base / 'semantic-retrieval.json'
|
||||||
@@ -78,7 +78,8 @@ def sync(root, home, clients, enabled, dry_run, update):
|
|||||||
if not enabled:
|
if not enabled:
|
||||||
owned = [client for client in state['clients'] if client in clients]
|
owned = [client for client in state['clients'] if client in clients]
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print('DRYRUN disable semantic retrieval: ' + (', '.join(owned) if owned else 'nothing owned'))
|
if not summary:
|
||||||
|
print('DRYRUN disable semantic retrieval: ' + (', '.join(owned) if owned else 'nothing owned'))
|
||||||
return
|
return
|
||||||
for client in owned:
|
for client in owned:
|
||||||
command(client, [client, 'mcp', 'remove', NAME] + (['--scope', 'user'] if client == 'claude' else []), home, False)
|
command(client, [client, 'mcp', 'remove', NAME] + (['--scope', 'user'] if client == 'claude' else []), home, False)
|
||||||
@@ -96,7 +97,8 @@ def sync(root, home, clients, enabled, dry_run, update):
|
|||||||
if target.exists() and not state['files']:
|
if target.exists() and not state['files']:
|
||||||
raise ValueError('Semantic retrieval directory exists without setup ownership; refusing to overwrite it.')
|
raise ValueError('Semantic retrieval directory exists without setup ownership; refusing to overwrite it.')
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print('DRYRUN enable semantic retrieval: Qwen3-Embedding-0.6B + Qwen3-Reranker-0.6B')
|
if not summary:
|
||||||
|
print('DRYRUN enable semantic retrieval: Qwen3-Embedding-0.6B + Qwen3-Reranker-0.6B')
|
||||||
return
|
return
|
||||||
target.mkdir(parents=True, exist_ok=True)
|
target.mkdir(parents=True, exist_ok=True)
|
||||||
source = root / 'shared' / 'retrieval'
|
source = root / 'shared' / 'retrieval'
|
||||||
@@ -134,9 +136,10 @@ def main():
|
|||||||
parser.add_argument('--enabled', choices=('true', 'false'), required=True)
|
parser.add_argument('--enabled', choices=('true', 'false'), required=True)
|
||||||
parser.add_argument('--dry-run', action='store_true')
|
parser.add_argument('--dry-run', action='store_true')
|
||||||
parser.add_argument('--update', action='store_true')
|
parser.add_argument('--update', action='store_true')
|
||||||
|
parser.add_argument('--summary', action='store_true')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
clients = ('codex', 'claude') if args.client == 'both' else (args.client,)
|
clients = ('codex', 'claude') if args.client == 'both' else (args.client,)
|
||||||
sync(args.root.resolve(), args.home.resolve(), clients, args.enabled == 'true', args.dry_run, args.update)
|
sync(args.root.resolve(), args.home.resolve(), clients, args.enabled == 'true', args.dry_run, args.update, args.summary)
|
||||||
print('SEMANTIC RETRIEVAL: reconciliation complete' + (' (dry run)' if args.dry_run else ''))
|
print('SEMANTIC RETRIEVAL: reconciliation complete' + (' (dry run)' if args.dry_run else ''))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import importlib.util
|
import importlib.util
|
||||||
|
import io
|
||||||
import json
|
import json
|
||||||
|
from contextlib import redirect_stdout
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
@@ -13,6 +15,16 @@ SPEC.loader.exec_module(MODULE)
|
|||||||
|
|
||||||
|
|
||||||
class SemanticRetrievalTests(unittest.TestCase):
|
class SemanticRetrievalTests(unittest.TestCase):
|
||||||
|
def test_summary_dry_run_omits_details_without_writes(self):
|
||||||
|
with tempfile.TemporaryDirectory() as directory:
|
||||||
|
home = Path(directory) / 'home'
|
||||||
|
for enabled in (True, False):
|
||||||
|
output = io.StringIO()
|
||||||
|
with redirect_stdout(output):
|
||||||
|
MODULE.sync(ROOT, home, ['codex'], enabled, True, False, summary=True)
|
||||||
|
self.assertEqual(output.getvalue(), '')
|
||||||
|
self.assertFalse(home.exists())
|
||||||
|
|
||||||
def test_claude_registration_places_name_before_environment(self):
|
def test_claude_registration_places_name_before_environment(self):
|
||||||
with tempfile.TemporaryDirectory() as directory:
|
with tempfile.TemporaryDirectory() as directory:
|
||||||
home = Path(directory) / 'home'
|
home = Path(directory) / 'home'
|
||||||
|
|||||||
Reference in new issue
Block a user