memory-cli 0.1.0__tar.gz
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.
- memory_cli-0.1.0/.gitignore +8 -0
- memory_cli-0.1.0/CHANGELOG.md +13 -0
- memory_cli-0.1.0/LICENSE +21 -0
- memory_cli-0.1.0/PKG-INFO +102 -0
- memory_cli-0.1.0/README.md +78 -0
- memory_cli-0.1.0/memory_cli/__init__.py +1 -0
- memory_cli-0.1.0/memory_cli/__main__.py +49 -0
- memory_cli-0.1.0/memory_cli/capture/__init__.py +7 -0
- memory_cli-0.1.0/memory_cli/capture/codex_rollout.py +164 -0
- memory_cli-0.1.0/memory_cli/capture/event_lines.py +66 -0
- memory_cli-0.1.0/memory_cli/capture/extract.py +458 -0
- memory_cli-0.1.0/memory_cli/capture/state.py +183 -0
- memory_cli-0.1.0/memory_cli/commands/__init__.py +21 -0
- memory_cli-0.1.0/memory_cli/commands/admin.py +363 -0
- memory_cli-0.1.0/memory_cli/commands/common.py +609 -0
- memory_cli-0.1.0/memory_cli/commands/curate.py +1189 -0
- memory_cli-0.1.0/memory_cli/commands/diagnostics.py +126 -0
- memory_cli-0.1.0/memory_cli/commands/edit.py +1282 -0
- memory_cli-0.1.0/memory_cli/commands/hooks.py +730 -0
- memory_cli-0.1.0/memory_cli/commands/import_recovery.py +45 -0
- memory_cli-0.1.0/memory_cli/commands/install.py +152 -0
- memory_cli-0.1.0/memory_cli/commands/integrate.py +480 -0
- memory_cli-0.1.0/memory_cli/commands/memory.py +2152 -0
- memory_cli-0.1.0/memory_cli/commands/read.py +1290 -0
- memory_cli-0.1.0/memory_cli/commands/sources.py +766 -0
- memory_cli-0.1.0/memory_cli/commands/split.py +97 -0
- memory_cli-0.1.0/memory_cli/commands/split_plan.py +196 -0
- memory_cli-0.1.0/memory_cli/commands/split_transaction.py +230 -0
- memory_cli-0.1.0/memory_cli/commands/synthesis.py +1122 -0
- memory_cli-0.1.0/memory_cli/core/__init__.py +16 -0
- memory_cli-0.1.0/memory_cli/core/auto_state.py +30 -0
- memory_cli-0.1.0/memory_cli/core/codex_pass.py +109 -0
- memory_cli-0.1.0/memory_cli/core/config.py +87 -0
- memory_cli-0.1.0/memory_cli/core/file_journal.py +163 -0
- memory_cli-0.1.0/memory_cli/core/headless.py +130 -0
- memory_cli-0.1.0/memory_cli/core/jobs.py +130 -0
- memory_cli-0.1.0/memory_cli/core/resources.py +57 -0
- memory_cli-0.1.0/memory_cli/core/runner.py +398 -0
- memory_cli-0.1.0/memory_cli/core/safe_io.py +155 -0
- memory_cli-0.1.0/memory_cli/core/store_git.py +407 -0
- memory_cli-0.1.0/memory_cli/core/yaml_load.py +14 -0
- memory_cli-0.1.0/memory_cli/corroborate/__init__.py +11 -0
- memory_cli-0.1.0/memory_cli/corroborate/cli.py +267 -0
- memory_cli-0.1.0/memory_cli/corroborate/decide.py +893 -0
- memory_cli-0.1.0/memory_cli/corroborate/digest.py +425 -0
- memory_cli-0.1.0/memory_cli/corroborate/fill.py +744 -0
- memory_cli-0.1.0/memory_cli/corroborate/job.py +15 -0
- memory_cli-0.1.0/memory_cli/corroborate/reword.py +446 -0
- memory_cli-0.1.0/memory_cli/corroborate/run.py +1142 -0
- memory_cli-0.1.0/memory_cli/corroborate/state.py +300 -0
- memory_cli-0.1.0/memory_cli/digest/__init__.py +4 -0
- memory_cli-0.1.0/memory_cli/digest/lessons.py +483 -0
- memory_cli-0.1.0/memory_cli/entry/__init__.py +12 -0
- memory_cli-0.1.0/memory_cli/entry/auto.py +660 -0
- memory_cli-0.1.0/memory_cli/entry/capture.py +1403 -0
- memory_cli-0.1.0/memory_cli/entry/corroborate.py +214 -0
- memory_cli-0.1.0/memory_cli/entry/integrate.py +684 -0
- memory_cli-0.1.0/memory_cli/entry/integrate_self_check.py +203 -0
- memory_cli-0.1.0/memory_cli/entry/research.py +9 -0
- memory_cli-0.1.0/memory_cli/entry/settle.py +614 -0
- memory_cli-0.1.0/memory_cli/entry/split_auto.py +460 -0
- memory_cli-0.1.0/memory_cli/entry/synthesize.py +22 -0
- memory_cli-0.1.0/memory_cli/integrate/__init__.py +9 -0
- memory_cli-0.1.0/memory_cli/integrate/answers.py +42 -0
- memory_cli-0.1.0/memory_cli/integrate/briefs/check-brief.md +16 -0
- memory_cli-0.1.0/memory_cli/integrate/briefs/place-brief.md +26 -0
- memory_cli-0.1.0/memory_cli/integrate/log.py +43 -0
- memory_cli-0.1.0/memory_cli/integrate/plan.py +125 -0
- memory_cli-0.1.0/memory_cli/integrate/rows.py +99 -0
- memory_cli-0.1.0/memory_cli/integrate/state.py +158 -0
- memory_cli-0.1.0/memory_cli/integrate/undo.py +143 -0
- memory_cli-0.1.0/memory_cli/mem.py +1180 -0
- memory_cli-0.1.0/memory_cli/memories/__init__.py +16 -0
- memory_cli-0.1.0/memory_cli/memories/fingerprints.py +51 -0
- memory_cli-0.1.0/memory_cli/memories/journal.py +93 -0
- memory_cli-0.1.0/memory_cli/memories/locations.py +282 -0
- memory_cli-0.1.0/memory_cli/memories/matching.py +451 -0
- memory_cli-0.1.0/memory_cli/memories/model.py +205 -0
- memory_cli-0.1.0/memory_cli/memories/parse.py +237 -0
- memory_cli-0.1.0/memory_cli/memories/records.py +266 -0
- memory_cli-0.1.0/memory_cli/memories/rules.py +291 -0
- memory_cli-0.1.0/memory_cli/memories/sightings.py +314 -0
- memory_cli-0.1.0/memory_cli/memories/terms.py +148 -0
- memory_cli-0.1.0/memory_cli/memories/write.py +358 -0
- memory_cli-0.1.0/memory_cli/notes/__init__.py +13 -0
- memory_cli-0.1.0/memory_cli/notes/check.py +806 -0
- memory_cli-0.1.0/memory_cli/notes/due.py +260 -0
- memory_cli-0.1.0/memory_cli/notes/fields.py +217 -0
- memory_cli-0.1.0/memory_cli/notes/index.py +230 -0
- memory_cli-0.1.0/memory_cli/notes/links.py +170 -0
- memory_cli-0.1.0/memory_cli/notes/note.py +222 -0
- memory_cli-0.1.0/memory_cli/notes/search.py +391 -0
- memory_cli-0.1.0/memory_cli/notes/split_candidates.py +72 -0
- memory_cli-0.1.0/memory_cli/research/__init__.py +5 -0
- memory_cli-0.1.0/memory_cli/research/checks.py +1065 -0
- memory_cli-0.1.0/memory_cli/research/pipeline.py +952 -0
- memory_cli-0.1.0/memory_cli/session/__init__.py +5 -0
- memory_cli-0.1.0/memory_cli/session/handoff.py +139 -0
- memory_cli-0.1.0/memory_cli/session/notices.py +111 -0
- memory_cli-0.1.0/memory_cli/settle/__init__.py +5 -0
- memory_cli-0.1.0/memory_cli/settle/state.py +111 -0
- memory_cli-0.1.0/memory_cli/settle/verdicts.py +693 -0
- memory_cli-0.1.0/memory_cli/split/briefs/checker-brief.md +5 -0
- memory_cli-0.1.0/memory_cli/split/briefs/editor-brief.md +20 -0
- memory_cli-0.1.0/memory_cli/syntheses/__init__.py +8 -0
- memory_cli-0.1.0/memory_cli/syntheses/document.py +400 -0
- memory_cli-0.1.0/memory_cli/syntheses/edit.py +581 -0
- memory_cli-0.1.0/memory_cli/syntheses/project.py +384 -0
- memory_cli-0.1.0/memory_cli/syntheses/split_conservation.py +50 -0
- memory_cli-0.1.0/memory_cli/syntheses/units.py +427 -0
- memory_cli-0.1.0/memory_cli/synthesize/__init__.py +9 -0
- memory_cli-0.1.0/memory_cli/synthesize/backfill.py +431 -0
- memory_cli-0.1.0/memory_cli/synthesize/briefs/backfill-brief.md +26 -0
- memory_cli-0.1.0/memory_cli/synthesize/briefs/checker-brief.md +13 -0
- memory_cli-0.1.0/memory_cli/synthesize/briefs/fixer-brief.md +19 -0
- memory_cli-0.1.0/memory_cli/synthesize/briefs/memory-brief.md +30 -0
- memory_cli-0.1.0/memory_cli/synthesize/briefs/settle-brief.md +32 -0
- memory_cli-0.1.0/memory_cli/synthesize/briefs/verdict-brief.md +50 -0
- memory_cli-0.1.0/memory_cli/synthesize/briefs/web-brief.md +33 -0
- memory_cli-0.1.0/memory_cli/synthesize/cli.py +311 -0
- memory_cli-0.1.0/memory_cli/synthesize/pipeline.py +764 -0
- memory_cli-0.1.0/memory_cli/synthesize/references.py +164 -0
- memory_cli-0.1.0/memory_cli/synthesize/run.py +150 -0
- memory_cli-0.1.0/memory_cli/synthesize/topics.py +528 -0
- memory_cli-0.1.0/memory_cli/templates/knowledge.md +23 -0
- memory_cli-0.1.0/memory_cli/templates/literature.md +25 -0
- memory_cli-0.1.0/memory_cli/templates/research.md +23 -0
- memory_cli-0.1.0/memory_cli/templates/synthesis.md +6 -0
- memory_cli-0.1.0/pyproject.toml +52 -0
- memory_cli-0.1.0/tests/architecture/test_claude_fake.py +41 -0
- memory_cli-0.1.0/tests/architecture/test_env_isolation.py +60 -0
- memory_cli-0.1.0/tests/architecture/test_import_graph.py +366 -0
- memory_cli-0.1.0/tests/architecture/test_mem_line_ceiling.py +13 -0
- memory_cli-0.1.0/tests/architecture/test_mem_patch_guard.py +116 -0
- memory_cli-0.1.0/tests/architecture/test_module_loaders.py +49 -0
- memory_cli-0.1.0/tests/architecture/test_tree_imports.py +62 -0
- memory_cli-0.1.0/tests/auto/test_auto_curation.py +820 -0
- memory_cli-0.1.0/tests/auto/test_auto_split_default.py +9 -0
- memory_cli-0.1.0/tests/capture/capture_world.py +163 -0
- memory_cli-0.1.0/tests/capture/conftest.py +18 -0
- memory_cli-0.1.0/tests/capture/fixtures/codex-rollout.jsonl +20 -0
- memory_cli-0.1.0/tests/capture/test_capture.py +848 -0
- memory_cli-0.1.0/tests/capture/test_capture_auto.py +538 -0
- memory_cli-0.1.0/tests/capture/test_capture_exclusion.py +135 -0
- memory_cli-0.1.0/tests/capture/test_capture_state.py +243 -0
- memory_cli-0.1.0/tests/capture/test_capture_sweep.py +399 -0
- memory_cli-0.1.0/tests/capture/test_capture_sweep_codex.py +131 -0
- memory_cli-0.1.0/tests/capture/test_codex_rollout.py +386 -0
- memory_cli-0.1.0/tests/capture/test_mem_capture.py +1156 -0
- memory_cli-0.1.0/tests/commands/commands_world.py +7 -0
- memory_cli-0.1.0/tests/commands/split_world.py +28 -0
- memory_cli-0.1.0/tests/commands/test_compact_log.py +137 -0
- memory_cli-0.1.0/tests/commands/test_confirm_owner.py +154 -0
- memory_cli-0.1.0/tests/commands/test_consolidation.py +529 -0
- memory_cli-0.1.0/tests/commands/test_curate_apply.py +192 -0
- memory_cli-0.1.0/tests/commands/test_curation.py +1393 -0
- memory_cli-0.1.0/tests/commands/test_diagnostics.py +48 -0
- memory_cli-0.1.0/tests/commands/test_fetch_sources.py +412 -0
- memory_cli-0.1.0/tests/commands/test_find_new.py +630 -0
- memory_cli-0.1.0/tests/commands/test_import.py +377 -0
- memory_cli-0.1.0/tests/commands/test_import_recovery.py +53 -0
- memory_cli-0.1.0/tests/commands/test_init_store.py +86 -0
- memory_cli-0.1.0/tests/commands/test_install_command.py +273 -0
- memory_cli-0.1.0/tests/commands/test_memory_edit.py +263 -0
- memory_cli-0.1.0/tests/commands/test_memory_search.py +270 -0
- memory_cli-0.1.0/tests/commands/test_new_body.py +105 -0
- memory_cli-0.1.0/tests/commands/test_note_edit.py +327 -0
- memory_cli-0.1.0/tests/commands/test_note_marks.py +197 -0
- memory_cli-0.1.0/tests/commands/test_origin.py +63 -0
- memory_cli-0.1.0/tests/commands/test_paging.py +126 -0
- memory_cli-0.1.0/tests/commands/test_passages.py +133 -0
- memory_cli-0.1.0/tests/commands/test_project_synthesis_commands.py +321 -0
- memory_cli-0.1.0/tests/commands/test_projects.py +252 -0
- memory_cli-0.1.0/tests/commands/test_remember.py +555 -0
- memory_cli-0.1.0/tests/commands/test_rename.py +281 -0
- memory_cli-0.1.0/tests/commands/test_resolve.py +178 -0
- memory_cli-0.1.0/tests/commands/test_search_scope.py +112 -0
- memory_cli-0.1.0/tests/commands/test_search_stats.py +433 -0
- memory_cli-0.1.0/tests/commands/test_short_by.py +256 -0
- memory_cli-0.1.0/tests/commands/test_short_topic.py +274 -0
- memory_cli-0.1.0/tests/commands/test_show.py +147 -0
- memory_cli-0.1.0/tests/commands/test_split_auto.py +451 -0
- memory_cli-0.1.0/tests/commands/test_split_command.py +151 -0
- memory_cli-0.1.0/tests/commands/test_split_plan.py +162 -0
- memory_cli-0.1.0/tests/commands/test_split_transaction.py +174 -0
- memory_cli-0.1.0/tests/commands/test_store.py +204 -0
- memory_cli-0.1.0/tests/commands/test_store_precedence.py +358 -0
- memory_cli-0.1.0/tests/commands/test_synthesis_structure.py +445 -0
- memory_cli-0.1.0/tests/commands/test_terms.py +406 -0
- memory_cli-0.1.0/tests/commands/test_transcript_records.py +640 -0
- memory_cli-0.1.0/tests/commands/test_usage_log.py +108 -0
- memory_cli-0.1.0/tests/conftest.py +66 -0
- memory_cli-0.1.0/tests/core/test_codex_refusals.py +125 -0
- memory_cli-0.1.0/tests/core/test_config.py +81 -0
- memory_cli-0.1.0/tests/core/test_file_journal.py +204 -0
- memory_cli-0.1.0/tests/core/test_headless.py +208 -0
- memory_cli-0.1.0/tests/core/test_headless_golden.py +671 -0
- memory_cli-0.1.0/tests/core/test_jobs.py +20 -0
- memory_cli-0.1.0/tests/core/test_jobs_golden.py +249 -0
- memory_cli-0.1.0/tests/core/test_lock_contention.py +201 -0
- memory_cli-0.1.0/tests/core/test_lock_contract.py +112 -0
- memory_cli-0.1.0/tests/core/test_runner.py +499 -0
- memory_cli-0.1.0/tests/core/test_safe_io.py +520 -0
- memory_cli-0.1.0/tests/core/test_store_git.py +731 -0
- memory_cli-0.1.0/tests/corroborate/conftest.py +14 -0
- memory_cli-0.1.0/tests/corroborate/corroborate_world.py +478 -0
- memory_cli-0.1.0/tests/corroborate/test_corroborate.py +890 -0
- memory_cli-0.1.0/tests/corroborate/test_corroborate_cli.py +269 -0
- memory_cli-0.1.0/tests/corroborate/test_corroborate_codex.py +270 -0
- memory_cli-0.1.0/tests/corroborate/test_corroborate_digest.py +446 -0
- memory_cli-0.1.0/tests/corroborate/test_corroborate_fill.py +1348 -0
- memory_cli-0.1.0/tests/corroborate/test_corroborate_reword.py +523 -0
- memory_cli-0.1.0/tests/corroborate/test_corroborate_run.py +794 -0
- memory_cli-0.1.0/tests/corroborate/test_fill_auto.py +194 -0
- memory_cli-0.1.0/tests/corroborate/test_repo_memories.py +164 -0
- memory_cli-0.1.0/tests/corroborate/test_reword.py +510 -0
- memory_cli-0.1.0/tests/digest/test_digest.py +891 -0
- memory_cli-0.1.0/tests/fixtures/valid/knowledge/README.md +9 -0
- memory_cli-0.1.0/tests/fixtures/valid/knowledge/computing/README.md +11 -0
- memory_cli-0.1.0/tests/fixtures/valid/knowledge/computing/attention-replaces-recurrence.md +24 -0
- memory_cli-0.1.0/tests/fixtures/valid/literature/README.md +9 -0
- memory_cli-0.1.0/tests/fixtures/valid/literature/computing/2017-vaswani-attention.md +26 -0
- memory_cli-0.1.0/tests/fixtures/valid/literature/computing/README.md +11 -0
- memory_cli-0.1.0/tests/fixtures/valid/research/2026-11-llm-eval-methods/README.md +23 -0
- memory_cli-0.1.0/tests/fixtures/valid/research/2026-11-llm-eval-methods/notes/reading-list.md +3 -0
- memory_cli-0.1.0/tests/fixtures/valid/research/README.md +9 -0
- memory_cli-0.1.0/tests/fixtures/valid/topics.yaml +6 -0
- memory_cli-0.1.0/tests/golden/mem_cli.json +497 -0
- memory_cli-0.1.0/tests/integrate/integrate_store.py +163 -0
- memory_cli-0.1.0/tests/integrate/integrate_world.py +164 -0
- memory_cli-0.1.0/tests/integrate/test_auto_process.py +75 -0
- memory_cli-0.1.0/tests/integrate/test_integrate_command.py +564 -0
- memory_cli-0.1.0/tests/integrate/test_plan.py +222 -0
- memory_cli-0.1.0/tests/integrate/test_reconcile.py +286 -0
- memory_cli-0.1.0/tests/integrate/test_rows.py +65 -0
- memory_cli-0.1.0/tests/integrate/test_run.py +430 -0
- memory_cli-0.1.0/tests/integrate/test_self_check.py +108 -0
- memory_cli-0.1.0/tests/integrate/test_state.py +191 -0
- memory_cli-0.1.0/tests/integrate/test_undo.py +336 -0
- memory_cli-0.1.0/tests/mem/test_main_module.py +63 -0
- memory_cli-0.1.0/tests/mem/test_mem_cli_golden.py +120 -0
- memory_cli-0.1.0/tests/mem/test_session_index_golden.py +57 -0
- memory_cli-0.1.0/tests/memories/memories_world.py +5 -0
- memory_cli-0.1.0/tests/memories/test_case_log.py +1236 -0
- memory_cli-0.1.0/tests/memories/test_pairs.py +378 -0
- memory_cli-0.1.0/tests/memories/test_records.py +625 -0
- memory_cli-0.1.0/tests/memories/test_records_facade.py +55 -0
- memory_cli-0.1.0/tests/memories/test_rules.py +761 -0
- memory_cli-0.1.0/tests/memories/test_rules_session.py +261 -0
- memory_cli-0.1.0/tests/memories/test_short_check.py +73 -0
- memory_cli-0.1.0/tests/memories/test_sightings.py +233 -0
- memory_cli-0.1.0/tests/notes/notes_world.py +16 -0
- memory_cli-0.1.0/tests/notes/test_check.py +387 -0
- memory_cli-0.1.0/tests/notes/test_core.py +97 -0
- memory_cli-0.1.0/tests/notes/test_index_links.py +375 -0
- memory_cli-0.1.0/tests/notes/test_related_mentions.py +93 -0
- memory_cli-0.1.0/tests/notes/test_requirements.py +100 -0
- memory_cli-0.1.0/tests/notes/test_search_links.py +99 -0
- memory_cli-0.1.0/tests/notes/test_size_topic_and_retest_rules.py +124 -0
- memory_cli-0.1.0/tests/notes/test_split_candidates.py +80 -0
- memory_cli-0.1.0/tests/packaging/test_wheel.py +298 -0
- memory_cli-0.1.0/tests/pytest.ini +7 -0
- memory_cli-0.1.0/tests/research/test_research_checks.py +908 -0
- memory_cli-0.1.0/tests/research/test_research_run.py +581 -0
- memory_cli-0.1.0/tests/session/session_world.py +39 -0
- memory_cli-0.1.0/tests/session/test_codex_host.py +54 -0
- memory_cli-0.1.0/tests/session/test_handoff.py +167 -0
- memory_cli-0.1.0/tests/session/test_session_index.py +291 -0
- memory_cli-0.1.0/tests/session/test_session_index_due.py +131 -0
- memory_cli-0.1.0/tests/session/test_signal.py +231 -0
- memory_cli-0.1.0/tests/session/test_triage.py +559 -0
- memory_cli-0.1.0/tests/settle/settle_world.py +146 -0
- memory_cli-0.1.0/tests/settle/test_inprocess_mem.py +81 -0
- memory_cli-0.1.0/tests/settle/test_quarantine.py +220 -0
- memory_cli-0.1.0/tests/settle/test_settle.py +847 -0
- memory_cli-0.1.0/tests/settle/test_settle_codex.py +170 -0
- memory_cli-0.1.0/tests/settle/test_settle_run.py +282 -0
- memory_cli-0.1.0/tests/settle/test_settle_start.py +21 -0
- memory_cli-0.1.0/tests/support/capture.py +149 -0
- memory_cli-0.1.0/tests/support/fakes/claude.py +104 -0
- memory_cli-0.1.0/tests/support/fakes/codex.py +82 -0
- memory_cli-0.1.0/tests/support/installed_jobs.py +121 -0
- memory_cli-0.1.0/tests/support/isolation.py +17 -0
- memory_cli-0.1.0/tests/support/launch.py +119 -0
- memory_cli-0.1.0/tests/support/lessons.py +128 -0
- memory_cli-0.1.0/tests/support/markers.py +7 -0
- memory_cli-0.1.0/tests/support/paths.py +8 -0
- memory_cli-0.1.0/tests/support/store.py +87 -0
- memory_cli-0.1.0/tests/syntheses/test_append_text.py +32 -0
- memory_cli-0.1.0/tests/syntheses/test_note_fingerprint.py +271 -0
- memory_cli-0.1.0/tests/syntheses/test_project_syntheses.py +345 -0
- memory_cli-0.1.0/tests/syntheses/test_project_synthesis_curation.py +178 -0
- memory_cli-0.1.0/tests/syntheses/test_split_conservation.py +51 -0
- memory_cli-0.1.0/tests/syntheses/test_syntheses.py +488 -0
- memory_cli-0.1.0/tests/syntheses/test_synthesis_inline_references.py +538 -0
- memory_cli-0.1.0/tests/syntheses/test_synthesis_notes.py +504 -0
- memory_cli-0.1.0/tests/syntheses/test_synthesis_refs.py +466 -0
- memory_cli-0.1.0/tests/synthesize/synthesize_world.py +110 -0
- memory_cli-0.1.0/tests/synthesize/test_backfill.py +342 -0
- memory_cli-0.1.0/tests/synthesize/test_mem_synthesize_self_check.py +20 -0
- memory_cli-0.1.0/tests/synthesize/test_parse_spend.py +31 -0
- memory_cli-0.1.0/tests/synthesize/test_synth_pipeline_refs.py +268 -0
- memory_cli-0.1.0/tests/synthesize/test_synth_session.py +42 -0
- memory_cli-0.1.0/tests/synthesize/test_synthesize_cli_golden.py +243 -0
- memory_cli-0.1.0/tests/synthesize/test_synthesize_references.py +319 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
4
|
+
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-11-29
|
|
8
|
+
|
|
9
|
+
First release on PyPI: `uv tool install memory-cli`.
|
|
10
|
+
|
|
11
|
+
- Python 3.12 to 3.15 on Linux and macOS (CI tests 3.12, 3.14 and 3.15).
|
|
12
|
+
- Release workflow: build once, test that wheel on Linux and macOS, install rehearsal, PyPI Trusted Publishing on a `v*` tag.
|
|
13
|
+
- Initial import from Agent-Skills@675ce579 (`plugins/memory/engine`).
|
memory_cli-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mili-ssm
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: memory-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The memory engine: the `mem` command and its background entries
|
|
5
|
+
Project-URL: Repository, https://github.com/Mili-ssm/memory-cli
|
|
6
|
+
Author: Mili-ssm
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: MacOS
|
|
14
|
+
Classifier: Operating System :: POSIX
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
21
|
+
Requires-Python: <3.16,>=3.12
|
|
22
|
+
Requires-Dist: pyyaml
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# memory-cli
|
|
26
|
+
|
|
27
|
+
[](https://github.com/Mili-ssm/memory-cli/actions/workflows/ci.yml)
|
|
28
|
+
|
|
29
|
+
The `mem` memory engine: a store of notes and lessons you search, curate and keep in git, plus the background commands that
|
|
30
|
+
settle, capture, corroborate, integrate, research and synthesize it. It is the engine of the
|
|
31
|
+
[Agent-Skills](https://github.com/Mili-ssm/Agent-Skills) `memory` plugin for Claude Code and Codex, and works from a terminal on its own.
|
|
32
|
+
|
|
33
|
+
## Status
|
|
34
|
+
|
|
35
|
+
Alpha (`0.1.0`), on [PyPI](https://pypi.org/project/memory-cli/). The Agent-Skills memory plugin still bundles its own frozen copy of
|
|
36
|
+
this engine until it switches to this package.
|
|
37
|
+
|
|
38
|
+
## Requirements
|
|
39
|
+
|
|
40
|
+
| Need | Detail |
|
|
41
|
+
|---|---|
|
|
42
|
+
| [uv](https://docs.astral.sh/uv/) | installs the commands in an isolated environment |
|
|
43
|
+
| Python | 3.12 to 3.15 |
|
|
44
|
+
| OS | Linux or macOS (Windows is not supported yet) |
|
|
45
|
+
| git | the store keeps its history in git |
|
|
46
|
+
|
|
47
|
+
## Install
|
|
48
|
+
|
|
49
|
+
| From | Command |
|
|
50
|
+
|---|---|
|
|
51
|
+
| PyPI | `uv tool install memory-cli` |
|
|
52
|
+
| A checkout | `uv tool install .` |
|
|
53
|
+
|
|
54
|
+
If `uv tool install` refuses because `~/.local/bin/mem*` already exists, those files are launchers an older plugin wrote.
|
|
55
|
+
Remove them with `mem install-command --remove` (from the plugin's `mem`), or delete the `~/.local/bin/mem*` files whose
|
|
56
|
+
second line is `# agent-memory launcher (mem install-command)`, then install again.
|
|
57
|
+
|
|
58
|
+
## Commands
|
|
59
|
+
|
|
60
|
+
| Command | Does |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `mem` | memory engine: search and read a store of notes, and write, curate and check it |
|
|
63
|
+
| `mem-auto` | one bounded curation run in the background |
|
|
64
|
+
| `mem-capture` | memory capture from session transcripts: `run`, `auto`, `sweep`, `exclude`, `ack` |
|
|
65
|
+
| `mem-corroborate` | a background pass that matches lessons by meaning and keeps one general record of each |
|
|
66
|
+
| `mem-integrate` | joins loose knowledge notes to the parts of syntheses with two cheap read-only sessions each |
|
|
67
|
+
| `mem-research` | answer a question from memory, then (by depth) check notes and the question against the web |
|
|
68
|
+
| `mem-settle` | one bounded settling run in the background |
|
|
69
|
+
| `mem-synthesize` | write syntheses for topics that have none, quietly, one headless session per step |
|
|
70
|
+
|
|
71
|
+
`<command> --help` lists the options. The background commands run a headless `claude` or `codex` session (`--runner`).
|
|
72
|
+
|
|
73
|
+
## Development
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
uv sync --group dev # pinned Ruff and basedpyright, pytest
|
|
77
|
+
uv tool install pre-commit && pre-commit install # once per clone: commit checks lint and types, push runs the suite
|
|
78
|
+
uv run pytest tests -q -n auto # full suite; `-m "not slow"` skips the tests that spawn processes
|
|
79
|
+
uv run ruff check . && uv run ruff format --check .
|
|
80
|
+
uv run basedpyright
|
|
81
|
+
uv build # sdist, then the wheel from it
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The repository carries its own tool configuration (`ruff.toml`, `pyrightconfig.json`, `tests/pytest.ini`, `.pre-commit-config.yaml`), so it works the same nested in an Agent-Skills checkout or on its own. The package is flat (`memory_cli/` at the root) so a fix ports one to one between this repository and the plugin's copy.
|
|
85
|
+
|
|
86
|
+
## Release
|
|
87
|
+
|
|
88
|
+
Maintainers. The workflow `.github/workflows/release.yml` builds once, tests that wheel on Linux and macOS, rehearses an
|
|
89
|
+
install, and publishes through PyPI Trusted Publishing (environments `pypi` and `testpypi`; no tokens).
|
|
90
|
+
|
|
91
|
+
1. Rehearse: set `version` in `pyproject.toml` to a pre-release (`X.Y.ZrcN` or `X.Y.Z.devN`; an index accepts a version
|
|
92
|
+
only once), merge to `main`, then run the workflow from `main` with `workflow_dispatch` (`target: testpypi`).
|
|
93
|
+
2. Release: set `version` to `X.Y.Z` and the `CHANGELOG.md` heading to `## [X.Y.Z] - YYYY-MM-DD`; merge to `main`.
|
|
94
|
+
3. Tag `vX.Y.Z` on that `main` commit (it must equal the `pyproject.toml` version) and push the tag. After the tests the
|
|
95
|
+
`publish-pypi` job waits for the owner's approval of the `pypi` environment, then publishes. PyPI is reachable only
|
|
96
|
+
from a `v*` tag.
|
|
97
|
+
|
|
98
|
+
A pull request that touches the workflow, `pyproject.toml` or `tests/packaging/` runs everything except publishing.
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
MIT, see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# memory-cli
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Mili-ssm/memory-cli/actions/workflows/ci.yml)
|
|
4
|
+
|
|
5
|
+
The `mem` memory engine: a store of notes and lessons you search, curate and keep in git, plus the background commands that
|
|
6
|
+
settle, capture, corroborate, integrate, research and synthesize it. It is the engine of the
|
|
7
|
+
[Agent-Skills](https://github.com/Mili-ssm/Agent-Skills) `memory` plugin for Claude Code and Codex, and works from a terminal on its own.
|
|
8
|
+
|
|
9
|
+
## Status
|
|
10
|
+
|
|
11
|
+
Alpha (`0.1.0`), on [PyPI](https://pypi.org/project/memory-cli/). The Agent-Skills memory plugin still bundles its own frozen copy of
|
|
12
|
+
this engine until it switches to this package.
|
|
13
|
+
|
|
14
|
+
## Requirements
|
|
15
|
+
|
|
16
|
+
| Need | Detail |
|
|
17
|
+
|---|---|
|
|
18
|
+
| [uv](https://docs.astral.sh/uv/) | installs the commands in an isolated environment |
|
|
19
|
+
| Python | 3.12 to 3.15 |
|
|
20
|
+
| OS | Linux or macOS (Windows is not supported yet) |
|
|
21
|
+
| git | the store keeps its history in git |
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
| From | Command |
|
|
26
|
+
|---|---|
|
|
27
|
+
| PyPI | `uv tool install memory-cli` |
|
|
28
|
+
| A checkout | `uv tool install .` |
|
|
29
|
+
|
|
30
|
+
If `uv tool install` refuses because `~/.local/bin/mem*` already exists, those files are launchers an older plugin wrote.
|
|
31
|
+
Remove them with `mem install-command --remove` (from the plugin's `mem`), or delete the `~/.local/bin/mem*` files whose
|
|
32
|
+
second line is `# agent-memory launcher (mem install-command)`, then install again.
|
|
33
|
+
|
|
34
|
+
## Commands
|
|
35
|
+
|
|
36
|
+
| Command | Does |
|
|
37
|
+
|---|---|
|
|
38
|
+
| `mem` | memory engine: search and read a store of notes, and write, curate and check it |
|
|
39
|
+
| `mem-auto` | one bounded curation run in the background |
|
|
40
|
+
| `mem-capture` | memory capture from session transcripts: `run`, `auto`, `sweep`, `exclude`, `ack` |
|
|
41
|
+
| `mem-corroborate` | a background pass that matches lessons by meaning and keeps one general record of each |
|
|
42
|
+
| `mem-integrate` | joins loose knowledge notes to the parts of syntheses with two cheap read-only sessions each |
|
|
43
|
+
| `mem-research` | answer a question from memory, then (by depth) check notes and the question against the web |
|
|
44
|
+
| `mem-settle` | one bounded settling run in the background |
|
|
45
|
+
| `mem-synthesize` | write syntheses for topics that have none, quietly, one headless session per step |
|
|
46
|
+
|
|
47
|
+
`<command> --help` lists the options. The background commands run a headless `claude` or `codex` session (`--runner`).
|
|
48
|
+
|
|
49
|
+
## Development
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
uv sync --group dev # pinned Ruff and basedpyright, pytest
|
|
53
|
+
uv tool install pre-commit && pre-commit install # once per clone: commit checks lint and types, push runs the suite
|
|
54
|
+
uv run pytest tests -q -n auto # full suite; `-m "not slow"` skips the tests that spawn processes
|
|
55
|
+
uv run ruff check . && uv run ruff format --check .
|
|
56
|
+
uv run basedpyright
|
|
57
|
+
uv build # sdist, then the wheel from it
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The repository carries its own tool configuration (`ruff.toml`, `pyrightconfig.json`, `tests/pytest.ini`, `.pre-commit-config.yaml`), so it works the same nested in an Agent-Skills checkout or on its own. The package is flat (`memory_cli/` at the root) so a fix ports one to one between this repository and the plugin's copy.
|
|
61
|
+
|
|
62
|
+
## Release
|
|
63
|
+
|
|
64
|
+
Maintainers. The workflow `.github/workflows/release.yml` builds once, tests that wheel on Linux and macOS, rehearses an
|
|
65
|
+
install, and publishes through PyPI Trusted Publishing (environments `pypi` and `testpypi`; no tokens).
|
|
66
|
+
|
|
67
|
+
1. Rehearse: set `version` in `pyproject.toml` to a pre-release (`X.Y.ZrcN` or `X.Y.Z.devN`; an index accepts a version
|
|
68
|
+
only once), merge to `main`, then run the workflow from `main` with `workflow_dispatch` (`target: testpypi`).
|
|
69
|
+
2. Release: set `version` to `X.Y.Z` and the `CHANGELOG.md` heading to `## [X.Y.Z] - YYYY-MM-DD`; merge to `main`.
|
|
70
|
+
3. Tag `vX.Y.Z` on that `main` commit (it must equal the `pyproject.toml` version) and push the tag. After the tests the
|
|
71
|
+
`publish-pypi` job waits for the owner's approval of the `pypi` environment, then publishes. PyPI is reachable only
|
|
72
|
+
from a `v*` tag.
|
|
73
|
+
|
|
74
|
+
A pull request that touches the workflow, `pyproject.toml` or `tests/packaging/` runs everything except publishing.
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT, see [LICENSE](LICENSE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""The memory engine: the `mem` command and the background entries (`mem-auto`, `mem-settle`, ...)."""
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""`python -m memory_cli [--bin NAME] ARGS`: runs the entry of one console script, or `mem` without `--bin`.
|
|
2
|
+
|
|
3
|
+
`engine/run.py` (the PEP 723 launcher behind `plugin/bin/`) and the children the engine starts for itself
|
|
4
|
+
(`core.resources.mem_command`) both come here. `mem` is imported only for the default path, so Python caches mem.pyc.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
if __name__ == "__main__":
|
|
10
|
+
# One static import per name, so the import graph sees each edge; the other entries stay unloaded.
|
|
11
|
+
name = sys.argv[2] if sys.argv[1:2] == ["--bin"] and sys.argv[2:3] else ""
|
|
12
|
+
if name == "mem-auto":
|
|
13
|
+
from memory_cli.entry import auto
|
|
14
|
+
|
|
15
|
+
main = auto.main
|
|
16
|
+
elif name == "mem-capture":
|
|
17
|
+
from memory_cli.entry import capture
|
|
18
|
+
|
|
19
|
+
main = capture.main
|
|
20
|
+
elif name == "mem-corroborate":
|
|
21
|
+
from memory_cli.entry import corroborate
|
|
22
|
+
|
|
23
|
+
main = corroborate.main
|
|
24
|
+
elif name == "mem-integrate":
|
|
25
|
+
from memory_cli.entry import integrate
|
|
26
|
+
|
|
27
|
+
main = integrate.main
|
|
28
|
+
elif name == "mem-research":
|
|
29
|
+
from memory_cli.entry import research
|
|
30
|
+
|
|
31
|
+
main = research.main
|
|
32
|
+
elif name == "mem-settle":
|
|
33
|
+
from memory_cli.entry import settle
|
|
34
|
+
|
|
35
|
+
main = settle.main
|
|
36
|
+
elif name == "mem-synthesize":
|
|
37
|
+
from memory_cli.entry import synthesize
|
|
38
|
+
|
|
39
|
+
main = synthesize.main
|
|
40
|
+
elif sys.argv[1:2] == ["--bin"]:
|
|
41
|
+
print(f"memory_cli: unknown --bin name: {name!r}", file=sys.stderr)
|
|
42
|
+
sys.exit(2)
|
|
43
|
+
else:
|
|
44
|
+
from memory_cli import mem
|
|
45
|
+
|
|
46
|
+
main = mem.main
|
|
47
|
+
if name:
|
|
48
|
+
sys.argv = [name, *sys.argv[3:]]
|
|
49
|
+
sys.exit(main())
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""Transcript capture: reducing a session transcript to candidate memories and the state of the background run.
|
|
2
|
+
|
|
3
|
+
`extract`: transcript to compact extract, candidate validation
|
|
4
|
+
`codex_rollout`: a Codex rollout to the same extract lines
|
|
5
|
+
`event_lines`: the line pieces both decoders share
|
|
6
|
+
`state`: state of the background capture run
|
|
7
|
+
"""
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"""Decode a Codex rollout (`~/.codex/sessions/.../rollout-*.jsonl`) into extract event lines.
|
|
2
|
+
|
|
3
|
+
Same line format as the Claude decoder in `extract`. The owner's words come only from
|
|
4
|
+
`response_item` messages of role `user` (the `event_msg` copies are duplicates); injected
|
|
5
|
+
context and developer messages are not the owner's. Shares the line limits and the tool
|
|
6
|
+
bookkeeping with the Claude decoder through `event_lines`.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
import re
|
|
11
|
+
|
|
12
|
+
from memory_cli.capture import event_lines as ev
|
|
13
|
+
|
|
14
|
+
# Only known injected envelopes are filtered: arbitrary snake_case XML can be owner text.
|
|
15
|
+
_INJECTED = re.compile(
|
|
16
|
+
r"# AGENTS\.md instructions(?: for /[^\n]+)?[ \t]*\n\s*<INSTRUCTIONS>.*</INSTRUCTIONS>|"
|
|
17
|
+
r"<(environment_context|codex_internal_context|external_codex_apps_[a-z0-9_]+|"
|
|
18
|
+
r"send_user_message_question_reply)(?:\s[^>]*)?>.*</\1>",
|
|
19
|
+
re.DOTALL,
|
|
20
|
+
)
|
|
21
|
+
_SUBAGENT_ARGS = ("message", "cmd", "target") # JSON keys of the Codex subagent tools
|
|
22
|
+
_SUBAGENT = "\0subagent" # state key: this rollout is a Codex subagent thread, which yields nothing
|
|
23
|
+
_FAILED_PREFIX = "Script failed"
|
|
24
|
+
_PROCESS_EXIT = re.compile(r"^Process exited with code (-?\d+)(?:\r?\n|$)")
|
|
25
|
+
_OUTPUT_MARK = "Output:\n"
|
|
26
|
+
_EXEC_MIN_PARTS = 2 # header and structured result
|
|
27
|
+
# Outer types that carry no content for the extract; any other outer type is counted as skipped.
|
|
28
|
+
_KNOWN_OUTER = (
|
|
29
|
+
"session_meta",
|
|
30
|
+
"turn_context",
|
|
31
|
+
"event_msg",
|
|
32
|
+
"response_item",
|
|
33
|
+
"compacted",
|
|
34
|
+
"token_usage_record",
|
|
35
|
+
"world_state",
|
|
36
|
+
"inter_agent_communication_metadata",
|
|
37
|
+
)
|
|
38
|
+
_CALLS = ("custom_tool_call", "function_call")
|
|
39
|
+
_OUTPUTS = ("custom_tool_call_output", "function_call_output")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def is_rollout(first_line: str) -> bool:
|
|
43
|
+
"""True when the first line of a file is a Codex `session_meta` item."""
|
|
44
|
+
try:
|
|
45
|
+
entry = json.loads(first_line)
|
|
46
|
+
except (ValueError, RecursionError): # a first line nested deeper than the parser allows
|
|
47
|
+
return False
|
|
48
|
+
return isinstance(entry, dict) and entry.get("type") == "session_meta"
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# not `event_lines.text_of`: Codex parts are typed `input_text`/`output_text`, which it skips
|
|
52
|
+
def _texts(content: object) -> list[str]:
|
|
53
|
+
if not isinstance(content, list):
|
|
54
|
+
return []
|
|
55
|
+
return [b["text"] for b in content if isinstance(b, dict) and isinstance(b.get("text"), str)]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _message_events(payload: dict) -> list[str]:
|
|
59
|
+
role = payload.get("role")
|
|
60
|
+
if role == "user":
|
|
61
|
+
texts = [t for t in _texts(payload.get("content")) if not _INJECTED.fullmatch(t.strip())]
|
|
62
|
+
body = ev.flat(" ".join(texts), ev.HUMAN_LIMIT)
|
|
63
|
+
return [f"OWNER: {body}"] if body else []
|
|
64
|
+
if role == "assistant":
|
|
65
|
+
body = ev.flat(" ".join(_texts(payload.get("content"))), ev.AGENT_LIMIT)
|
|
66
|
+
return [f"AGENT: {body}"] if body else []
|
|
67
|
+
return []
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _argument(payload: dict) -> str:
|
|
71
|
+
raw = payload.get("input") if payload.get("type") == "custom_tool_call" else None
|
|
72
|
+
if isinstance(raw, str):
|
|
73
|
+
return raw
|
|
74
|
+
try:
|
|
75
|
+
args = json.loads(payload.get("arguments") or "")
|
|
76
|
+
except (TypeError, ValueError):
|
|
77
|
+
return ""
|
|
78
|
+
return ev.tool_arg(args) or _subagent_arg(args)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _subagent_arg(args: object) -> str:
|
|
82
|
+
if not isinstance(args, dict):
|
|
83
|
+
return ""
|
|
84
|
+
values = (args.get(key) for key in _SUBAGENT_ARGS)
|
|
85
|
+
return next((v for v in values if isinstance(v, str) and v), "")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _call_events(payload: dict, names: dict) -> list[str]:
|
|
89
|
+
block = {
|
|
90
|
+
"name": payload.get("name"),
|
|
91
|
+
"id": payload.get("call_id"),
|
|
92
|
+
"input": {"command": _argument(payload)},
|
|
93
|
+
}
|
|
94
|
+
return [ev.tool_use_line(block, names)]
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _output_text(output: object) -> str:
|
|
98
|
+
if isinstance(output, dict):
|
|
99
|
+
return _output_text(output.get("output", output.get("content")))
|
|
100
|
+
return output if isinstance(output, str) else " ".join(_texts(output))
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _exec_result(output: object) -> dict | None:
|
|
104
|
+
"""Decode the shell runner's metadata part, separate from the command's own output."""
|
|
105
|
+
parts = _texts(output)
|
|
106
|
+
if len(parts) < _EXEC_MIN_PARTS or not parts[0].startswith("Script completed\nWall time "):
|
|
107
|
+
return None
|
|
108
|
+
try:
|
|
109
|
+
meta = json.loads(parts[1])
|
|
110
|
+
except (ValueError, RecursionError):
|
|
111
|
+
return None
|
|
112
|
+
if (
|
|
113
|
+
isinstance(meta, dict)
|
|
114
|
+
and {"chunk_id", "wall_time_seconds", "exit_code", "output"} <= meta.keys()
|
|
115
|
+
):
|
|
116
|
+
return meta
|
|
117
|
+
return None
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _output_events(payload: dict, names: dict, state: dict) -> list[str]:
|
|
121
|
+
output = payload.get("output")
|
|
122
|
+
name = names.get(payload.get("call_id"), "?")
|
|
123
|
+
if name == "exec":
|
|
124
|
+
output = _exec_result(output) or output
|
|
125
|
+
text = _output_text(output)
|
|
126
|
+
exit_code = output.get("exit_code") if isinstance(output, dict) else payload.get("exit_code")
|
|
127
|
+
process_exit = _PROCESS_EXIT.match(text)
|
|
128
|
+
failed = (
|
|
129
|
+
(isinstance(exit_code, int) and not isinstance(exit_code, bool) and exit_code != 0)
|
|
130
|
+
or payload.get("is_error") is True
|
|
131
|
+
or (isinstance(output, dict) and output.get("is_error") is True)
|
|
132
|
+
or text.startswith(_FAILED_PREFIX)
|
|
133
|
+
or (process_exit is not None and process_exit.group(1).lstrip("-").strip("0"))
|
|
134
|
+
)
|
|
135
|
+
if failed:
|
|
136
|
+
text = text.partition(_OUTPUT_MARK)[2] or text
|
|
137
|
+
event = ev.result_event({"is_error": failed, "content": text}, name, state)
|
|
138
|
+
return [event] if event is not None else []
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _item_events(payload: dict, names: dict, state: dict) -> list[str]:
|
|
142
|
+
kind = payload.get("type")
|
|
143
|
+
if kind == "message":
|
|
144
|
+
return _message_events(payload)
|
|
145
|
+
if kind in _CALLS:
|
|
146
|
+
return _call_events(payload, names)
|
|
147
|
+
if kind in _OUTPUTS:
|
|
148
|
+
return _output_events(payload, names, state)
|
|
149
|
+
return []
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def events(entry: dict, names: dict, state: dict) -> list[str]:
|
|
153
|
+
"""Extract lines (without the line number prefix) of one rollout item."""
|
|
154
|
+
kind = entry.get("type")
|
|
155
|
+
payload = entry.get("payload")
|
|
156
|
+
if kind not in _KNOWN_OUTER:
|
|
157
|
+
raise ValueError(f"unknown rollout item type: {kind!r}")
|
|
158
|
+
if not isinstance(payload, dict):
|
|
159
|
+
return []
|
|
160
|
+
if kind == "session_meta":
|
|
161
|
+
state[_SUBAGENT] = payload.get("thread_source", "user") != "user"
|
|
162
|
+
if kind != "response_item" or state.get(_SUBAGENT):
|
|
163
|
+
return []
|
|
164
|
+
return _item_events(payload, names, state)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""Pieces of an extract line that every transcript decoder shares: the length limits and how a text,
|
|
2
|
+
a tool call and a tool result become a line. Pure; standard library only."""
|
|
3
|
+
|
|
4
|
+
HUMAN_LIMIT = 2000 # an owner's words are kept longer than a subagent report
|
|
5
|
+
REPORT_LIMIT = 800
|
|
6
|
+
AGENT_LIMIT = 1500
|
|
7
|
+
ARG_LIMIT = 200
|
|
8
|
+
ERROR_LIMIT = 400
|
|
9
|
+
_TOOL_ARGS = ("command", "file_path", "description")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def flat(text: str, limit: int) -> str:
|
|
13
|
+
# cut before normalizing so memory does not follow the size of the line; a text that is mostly
|
|
14
|
+
# whitespace can come out shorter than `limit` with its tail lost, which is accepted
|
|
15
|
+
return " ".join(text[: limit * 8].split())[:limit].strip()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def text_of(content: object) -> str:
|
|
19
|
+
"""Text of a string or of the text blocks of a list; "" otherwise."""
|
|
20
|
+
if isinstance(content, str):
|
|
21
|
+
return content
|
|
22
|
+
if isinstance(content, list):
|
|
23
|
+
parts = []
|
|
24
|
+
for b in content:
|
|
25
|
+
if isinstance(b, str):
|
|
26
|
+
parts.append(b)
|
|
27
|
+
elif (
|
|
28
|
+
isinstance(b, dict)
|
|
29
|
+
and b.get("type", "text") == "text"
|
|
30
|
+
and isinstance(b.get("text"), str)
|
|
31
|
+
):
|
|
32
|
+
parts.append(b["text"])
|
|
33
|
+
return " ".join(parts)
|
|
34
|
+
return ""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def name_of(value: object) -> str:
|
|
38
|
+
return value if isinstance(value, str) and value else "?"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def tool_arg(inp: object) -> str:
|
|
42
|
+
if not isinstance(inp, dict):
|
|
43
|
+
return ""
|
|
44
|
+
for key in _TOOL_ARGS:
|
|
45
|
+
value = inp.get(key)
|
|
46
|
+
if isinstance(value, str):
|
|
47
|
+
return value
|
|
48
|
+
return ""
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def tool_use_line(b: dict, names: dict) -> str:
|
|
52
|
+
name = name_of(b.get("name"))
|
|
53
|
+
if isinstance(b.get("id"), str):
|
|
54
|
+
names[b["id"]] = name
|
|
55
|
+
return f"TOOL {name}: {flat(tool_arg(b.get('input')), ARG_LIMIT)}"
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def result_event(b: dict, name: str, state: dict) -> str | None:
|
|
59
|
+
if b.get("is_error"):
|
|
60
|
+
state[name] = True
|
|
61
|
+
return f"TOOL ERROR {name}: {flat(text_of(b.get('content')), ERROR_LIMIT)}"
|
|
62
|
+
was_failing = state.get(name)
|
|
63
|
+
state[name] = False
|
|
64
|
+
if name == "AskUserQuestion":
|
|
65
|
+
return f"OWNER ANSWER: {flat(text_of(b.get('content')), REPORT_LIMIT)}"
|
|
66
|
+
return f"TOOL OK {name}" if was_failing else None
|