codmap 0.0.47__tar.gz → 0.0.49__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.
- {codmap-0.0.47/codmap.egg-info → codmap-0.0.49}/PKG-INFO +9 -2
- {codmap-0.0.47 → codmap-0.0.49}/README.md +8 -1
- {codmap-0.0.47 → codmap-0.0.49}/codemap/cli.py +35 -21
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/__init__.py +2 -2
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/templates/agents_block.md +4 -1
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/templates/agents_block.ru.md +4 -1
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/templates/post-commit.sh +5 -5
- codmap-0.0.49/codemap/devkit/usage.py +213 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/extract/behavior.py +126 -12
- {codmap-0.0.47 → codmap-0.0.49}/codemap/extract/union.py +2 -8
- {codmap-0.0.47 → codmap-0.0.49}/codemap/freshness.py +8 -3
- {codmap-0.0.47 → codmap-0.0.49}/codemap/model.py +13 -3
- {codmap-0.0.47 → codmap-0.0.49}/codemap/query.py +9 -2
- {codmap-0.0.47 → codmap-0.0.49}/codemap/scope.py +7 -3
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/audit.py +2 -2
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/check.py +9 -2
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/currency.py +35 -3
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/impact.py +11 -8
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/limits.py +52 -7
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/mcp_server.py +108 -107
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/pack.py +1 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/semantic.py +5 -1
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/server.py +2 -2
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/session.py +160 -88
- {codmap-0.0.47 → codmap-0.0.49}/codemap/store.py +10 -2
- {codmap-0.0.47 → codmap-0.0.49/codmap.egg-info}/PKG-INFO +9 -2
- {codmap-0.0.47 → codmap-0.0.49}/codmap.egg-info/SOURCES.txt +3 -0
- {codmap-0.0.47 → codmap-0.0.49}/pyproject.toml +4 -2
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_epistemic.py +1 -1
- codmap-0.0.49/tests/test_fast_field_and_usage.py +167 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m3_serve.py +6 -3
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m4_behavior.py +4 -4
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m6_repo_scope.py +1 -1
- codmap-0.0.49/tests/test_mcp_surface_contract.py +241 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c110_advise.py +1 -1
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c125_graph_trust.py +4 -1
- codmap-0.0.49/tests/test_r1c132_harness.py +105 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c28_limit_envelope.py +2 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c39_edge_resolution.py +2 -2
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c45_repeat_union.py +20 -3
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c53_narrowing_declared.py +4 -2
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c63_answer_format.py +2 -1
- codmap-0.0.47/codemap/devkit/usage.py +0 -103
- {codmap-0.0.47 → codmap-0.0.49}/LICENSE +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/__init__.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/__main__.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/advise/__init__.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/advise/data/feed.json +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/advise/data/matrix.toml +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/advise/refresh.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/advise/render.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/apidiff.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/arch.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/atomic.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/artifacts.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/hooks.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/install.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/ratchet.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/state.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/templates/brief.txt +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/templates/claude_hooks.json +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/templates/codex_region.toml +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/templates/contract_head.toml +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/templates/cycles_region.toml +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/templates/github-workflow.yml +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/templates/gitlab-ci.yml +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/templates/mcp_claude.args +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/devkit/templates/ratchet_region.toml +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/diagnostics.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/extract/__init__.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/extract/attrflow.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/extract/dataflow.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/extract/dispatch.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/extract/griffe_extractor.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/extract/gsource.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/extract/probe.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/extract/roots.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/incremental.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/integrations/__init__.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/integrations/base.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/integrations/cocoindex.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/integrations/gate.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/integrations/gitnexus.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/integrations/registry.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/integrations/transport.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/provenance.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/__init__.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/_scip_pb2.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/api_surface.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/apidiff.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/architecture.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/ctags.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/livingdocs.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/mermaid.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/rag.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/review.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/scip.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/subsystems.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/serve/vault.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/tomlio.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codemap/watch.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codmap.egg-info/dependency_links.txt +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codmap.egg-info/entry_points.txt +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codmap.egg-info/requires.txt +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/codmap.egg-info/top_level.txt +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/setup.cfg +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_gitnexus_router.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_impact_depth.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_integrations.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_issue3_serve_freshness.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_livingdocs.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m0_api_surface.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m11_argcontract.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m12_dataflow.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m15_review.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m16_architecture.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m17_mcp.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m18_freshness.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m1_5_semantics.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m1_query.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m2_views.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m32_watch.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m5_deep.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m7_dispatch.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_m9_family.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_pack_honesty.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c108_devkit.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c109_namespace_source.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c111_recipe.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c114_devkit_graph.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c115_agents_block.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c116_known_cycles.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c118_dead_code.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c119_first_build.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c120_dispatch_absorbed.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c121_devkit_trust.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c122_serve_robust.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c124_atomic_writes.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c126_scope_roles.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c127_require_current.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c133_pin_links.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c134_refresh_recipe.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c135_advise_generations.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c13_callgraph_accuracy.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c13_grep_vs_graph.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c16_semantic.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c20_attribute_edges.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c21_flat_layout.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c22_source_visible_refs.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c23_hard_python.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c24_test_mapping.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c25_provenance.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c26_deep_union.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c27_config_honesty.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c29_lazy_imports.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c2_ctags.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c30_local_import_calls.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c30f1_reexport_calls.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c30f2_check_scope.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c31_path_origin.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c32_report_json.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c33_query_signature.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c34_signature_kinds.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c35_contract_location.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c36_target_resolution.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c37_rule_mutation.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c38_tool_drift.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c3_arch_contract.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c3_dogfood.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c40_flow_reach.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c41_scope_membership.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c42_deep_tier_stability.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c43_incremental_splice.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c44_absent_answers.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c46_shadowed_definitions.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c47_incremental_resample.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c48_type_checking_imports.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c49_type_only_cycles.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c4_complexity.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c50_flow_entry_points.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c54_deterministic_rendering.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c55_override_grade.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c56_stub_files.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c57_facade_package.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c58_cycle_tangles.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c59_completeness_drop.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c5_apidiff.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c60_nested_definitions.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c62_phantom_rules.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c64_dependency_probe.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c66_pack_direction.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c68_dotted_imports.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c69_contract_validation.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c6_pack.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c70_check_graph_currency.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c71_attribute_chain_calls.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c72_flat_inference_in_packages.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c73_cli_version.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c74_call_site_conservation.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c75_reexported_class_calls.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c76_contract_table_typo.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c77_gate_probe_battery.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c78_forbidden_chains.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c7_edge_vocab.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c80_tests_through_helpers.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c81_protocol_dispatch.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c82_review_changed_lines.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c83_foreign_graph_paths.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c84_missing_roots.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c85_mcp_graph_currency.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c86_incremental_repo_scope.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c87_review_path_base.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c89_review_docs.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c8_deadcode.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c90_currency_without_recipe.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c91_route_vocabulary.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c92_sidecar_pair.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c94_root_builds.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c95_r1c96_foreign_trees.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_r1c9_incremental.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_scip_export.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_scope.py +0 -0
- {codmap-0.0.47 → codmap-0.0.49}/tests/test_subsystems.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codmap
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.49
|
|
4
4
|
Summary: Static analyzer that turns a package's source into a queryable code graph.
|
|
5
5
|
Author-email: kogriv <kogriv@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -54,7 +54,7 @@ without a release.
|
|
|
54
54
|
|
|
55
55
|
[](https://github.com/kogriv/codemap/actions/workflows/ci.yml)
|
|
56
56
|
|
|
57
|
-
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **
|
|
57
|
+
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1526 tests with no failures on
|
|
58
58
|
Python 3.11–3.14** ([in CI](docs/ci.md): the full suite including the dogfood pass, a determinism check, a
|
|
59
59
|
wheel smoke test, and ctags/SCIP interop against the real CLIs), warm serve surface with 32 ops (29 exposed
|
|
60
60
|
as MCP tools), and SCIP export. See **[DESIGN.md](DESIGN.md)** (product design &
|
|
@@ -236,6 +236,13 @@ codemap watch ./pkg -o graph.json &
|
|
|
236
236
|
codemap serve --graph graph.json --watch
|
|
237
237
|
```
|
|
238
238
|
|
|
239
|
+
The local MCP server uses the permissions of the process that starts it. Use it with a
|
|
240
|
+
trusted client and graph. `--source-root` bounds `source` reads. `diff(base)` reads an
|
|
241
|
+
explicit baseline graph, and `check(root)` reads a contract from the selected directory.
|
|
242
|
+
`semantic_search` can invoke an installed adapter only when explicitly enabled in
|
|
243
|
+
`codemap.toml`. `reload` replaces the in-memory snapshot from the configured graph path.
|
|
244
|
+
The MCP server does not sandbox these operations from one another.
|
|
245
|
+
|
|
239
246
|
## What it answers
|
|
240
247
|
|
|
241
248
|
- **Structure & API** — public surface, signatures, docstrings, deprecation.
|
|
@@ -18,7 +18,7 @@ without a release.
|
|
|
18
18
|
|
|
19
19
|
[](https://github.com/kogriv/codemap/actions/workflows/ci.yml)
|
|
20
20
|
|
|
21
|
-
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **
|
|
21
|
+
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.13, **1526 tests with no failures on
|
|
22
22
|
Python 3.11–3.14** ([in CI](docs/ci.md): the full suite including the dogfood pass, a determinism check, a
|
|
23
23
|
wheel smoke test, and ctags/SCIP interop against the real CLIs), warm serve surface with 32 ops (29 exposed
|
|
24
24
|
as MCP tools), and SCIP export. See **[DESIGN.md](DESIGN.md)** (product design &
|
|
@@ -200,6 +200,13 @@ codemap watch ./pkg -o graph.json &
|
|
|
200
200
|
codemap serve --graph graph.json --watch
|
|
201
201
|
```
|
|
202
202
|
|
|
203
|
+
The local MCP server uses the permissions of the process that starts it. Use it with a
|
|
204
|
+
trusted client and graph. `--source-root` bounds `source` reads. `diff(base)` reads an
|
|
205
|
+
explicit baseline graph, and `check(root)` reads a contract from the selected directory.
|
|
206
|
+
`semantic_search` can invoke an installed adapter only when explicitly enabled in
|
|
207
|
+
`codemap.toml`. `reload` replaces the in-memory snapshot from the configured graph path.
|
|
208
|
+
The MCP server does not sandbox these operations from one another.
|
|
209
|
+
|
|
203
210
|
## What it answers
|
|
204
211
|
|
|
205
212
|
- **Structure & API** — public surface, signatures, docstrings, deprecation.
|
|
@@ -92,19 +92,20 @@ def _emit_answer(text: str) -> None:
|
|
|
92
92
|
print(f"_answer format {ANSWER_FORMAT} · schema {SCHEMA_VERSION}_")
|
|
93
93
|
|
|
94
94
|
|
|
95
|
-
def _graph_from(args):
|
|
95
|
+
def _graph_from(args, *, snapshot: bool = False):
|
|
96
96
|
if getattr(args, "build", None):
|
|
97
|
-
|
|
97
|
+
graph = extract(args.build, deep=getattr(args, "deep", False))
|
|
98
|
+
return (graph, None) if snapshot else graph
|
|
98
99
|
if getattr(args, "graph", None):
|
|
99
100
|
if not os.path.exists(args.graph):
|
|
100
101
|
# R1-C119: said before any work, with the command that makes one.
|
|
101
102
|
raise SystemExit(f"error: no graph at {args.graph} — build it first: "
|
|
102
103
|
f"`codemap build <package> -o {args.graph}`")
|
|
103
|
-
graph = store.
|
|
104
|
+
graph, mtime = store.load_snapshot(args.graph)
|
|
104
105
|
if getattr(args, "func", None) not in (_cmd_check, _cmd_serve):
|
|
105
106
|
_warn_if_behind(args.graph, graph, args)
|
|
106
107
|
_warn_if_newer_tool(args.graph, graph)
|
|
107
|
-
return graph
|
|
108
|
+
return (graph, mtime) if snapshot else graph
|
|
108
109
|
raise SystemExit("error: need --graph <file> or --build <path>")
|
|
109
110
|
|
|
110
111
|
|
|
@@ -175,6 +176,7 @@ def _cmd_build(args) -> int:
|
|
|
175
176
|
except OSError as exc:
|
|
176
177
|
print(f"error: cannot create the directory for {args.out}: {exc.strerror}", file=sys.stderr)
|
|
177
178
|
return 2
|
|
179
|
+
input_scope = _resolve_scope_quietly(args) if args.out else None
|
|
178
180
|
if args.consumer or args.docs:
|
|
179
181
|
core_graph = None
|
|
180
182
|
if getattr(args, "incremental", False) and args.out:
|
|
@@ -224,12 +226,17 @@ def _cmd_build(args) -> int:
|
|
|
224
226
|
# rebuild it, and so the graph's age is meaningful to `serve`/stats.
|
|
225
227
|
# M19.A: also record the input scope manifest (scope_id + profile + git).
|
|
226
228
|
from codemap.freshness import write_meta
|
|
227
|
-
base =
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
base = str(roots_base(args.path, tuple(args.consumer or ()), tuple(args.docs or ())))
|
|
230
|
+
recipe_out = getattr(args, "recipe_output", None)
|
|
231
|
+
recipe = (_build_recipe(args, out=recipe_out, incremental=args.incremental)
|
|
232
|
+
if recipe_out else getattr(args, "_argv", []))
|
|
233
|
+
try:
|
|
234
|
+
write_meta(args.out, argv=recipe, cwd=os.getcwd(), target=graph.target, scope=scope,
|
|
235
|
+
roots_base=base, strict=bool(recipe_out), source_verified=bool(
|
|
236
|
+
input_scope and scope and input_scope["scope_id"] == scope["scope_id"]))
|
|
237
|
+
except OSError as exc:
|
|
238
|
+
print(f"error: could not write staged build recipe: {exc}", file=sys.stderr)
|
|
239
|
+
return 2
|
|
233
240
|
if incr_info is not None:
|
|
234
241
|
# R1-C92: a full build that had a reason says it — computed, never shown, before.
|
|
235
242
|
why = f" ({incr_info['reason']})" if incr_info.get("reason") else ""
|
|
@@ -396,14 +403,11 @@ def _incremental_core(args, repeat):
|
|
|
396
403
|
deep=args.deep, repeat=repeat)
|
|
397
404
|
|
|
398
405
|
|
|
399
|
-
def
|
|
400
|
-
"""
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
a loop that never returns. So the sidecar gets the equivalent single build.
|
|
405
|
-
"""
|
|
406
|
-
argv = ["build", args.path, "-o", args.out, "--incremental"]
|
|
406
|
+
def _build_recipe(args, *, out, incremental: bool) -> list[str]:
|
|
407
|
+
"""Single build replay for a watcher or a graph published from a staging file."""
|
|
408
|
+
argv = ["build", args.path, "-o", out]
|
|
409
|
+
if incremental:
|
|
410
|
+
argv.append("--incremental")
|
|
407
411
|
if args.deep:
|
|
408
412
|
argv.append("--deep")
|
|
409
413
|
if (getattr(args, "repeat", None) or 1) > 1:
|
|
@@ -417,6 +421,10 @@ def _watch_build_argv(args) -> list[str]:
|
|
|
417
421
|
return argv
|
|
418
422
|
|
|
419
423
|
|
|
424
|
+
def _watch_build_argv(args) -> list[str]:
|
|
425
|
+
return _build_recipe(args, out=args.out, incremental=True)
|
|
426
|
+
|
|
427
|
+
|
|
420
428
|
def _watch_start_is_stale(out: str, scope_id: str) -> bool:
|
|
421
429
|
"""Does the graph at ``out`` predate the tree we are about to watch? (M3.2)
|
|
422
430
|
|
|
@@ -930,6 +938,8 @@ def _recipe_problem(meta: dict, graph: str) -> str | None:
|
|
|
930
938
|
return f"`build` does not take it ({last[-1] if last else 'unparsable'})"
|
|
931
939
|
if args.command != "build":
|
|
932
940
|
return f"it runs `{args.command}`, not `build`"
|
|
941
|
+
if args.recipe_output:
|
|
942
|
+
return "a published rebuild recipe cannot redirect its own recorded output"
|
|
933
943
|
if not args.out:
|
|
934
944
|
return "it writes no graph file"
|
|
935
945
|
cwd = meta.get("cwd")
|
|
@@ -1263,7 +1273,8 @@ def _cmd_serve(args) -> int:
|
|
|
1263
1273
|
ops over the Model Context Protocol instead (needs the optional `mcp` extra).
|
|
1264
1274
|
"""
|
|
1265
1275
|
from codemap.serve.session import Session
|
|
1266
|
-
|
|
1276
|
+
graph, mtime = _graph_from(args, snapshot=True)
|
|
1277
|
+
session = Session(graph, source_root=args.source_root, served_mtime=mtime,
|
|
1267
1278
|
graph_path=getattr(args, "graph", None),
|
|
1268
1279
|
currency_ttl=getattr(args, "currency_ttl", 10.0))
|
|
1269
1280
|
if getattr(args, "watch", False):
|
|
@@ -1310,7 +1321,9 @@ def _start_reload_watcher(session, args) -> bool:
|
|
|
1310
1321
|
f"{r.get('reason', env.get('error'))}", file=sys.stderr)
|
|
1311
1322
|
return False
|
|
1312
1323
|
|
|
1313
|
-
|
|
1324
|
+
from codemap.freshness import meta_path
|
|
1325
|
+
graph_probe, meta_probe = mtime_probe(args.graph), mtime_probe(meta_path(args.graph))
|
|
1326
|
+
poller = DebouncedPoller(lambda: (graph_probe(), meta_probe()), reload,
|
|
1314
1327
|
interval=args.interval, debounce=args.debounce)
|
|
1315
1328
|
threading.Thread(target=poller.run, kwargs={"cycles": None},
|
|
1316
1329
|
name="codemap-watch", daemon=True).start()
|
|
@@ -1408,6 +1421,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
1408
1421
|
"directory name is the package name every node id starts "
|
|
1409
1422
|
"with — a copy under another name answers to that name.")
|
|
1410
1423
|
b.add_argument("-o", "--out", help="Write graph.json here (default: stdout JSON).")
|
|
1424
|
+
b.add_argument("--recipe-output", help=argparse.SUPPRESS)
|
|
1411
1425
|
b.add_argument("--deep", action="store_true",
|
|
1412
1426
|
help="Deep call resolution via jedi (richer, ~1 min; default fast).")
|
|
1413
1427
|
b.add_argument("--consumer", action="append", metavar="PATH",
|
|
@@ -1683,7 +1697,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
1683
1697
|
dx = dks.add_parser("index", help="Write the per-module digest the hooks read.")
|
|
1684
1698
|
dx.add_argument("--root", default=".")
|
|
1685
1699
|
dx.add_argument("--graph", default=None)
|
|
1686
|
-
dus = dks.add_parser("usage", help="codemap
|
|
1700
|
+
dus = dks.add_parser("usage", help="Count codemap MCP, codemap CLI and grep in local Claude Code transcripts.")
|
|
1687
1701
|
dus.add_argument("--root", default=".")
|
|
1688
1702
|
dus.add_argument("--days", type=int, default=7)
|
|
1689
1703
|
dus.add_argument("--transcripts", default=None, help="Transcripts directory (default: Claude Code's for --root).")
|
|
@@ -16,11 +16,11 @@ import hashlib
|
|
|
16
16
|
from pathlib import Path
|
|
17
17
|
|
|
18
18
|
#: Raised whenever a template changes; adopting projects see "outdated" in `codemap devkit status`.
|
|
19
|
-
DEVKIT_VERSION =
|
|
19
|
+
DEVKIT_VERSION = 8
|
|
20
20
|
|
|
21
21
|
#: sha256 over the templates (name + content, sorted). The suite recomputes it: a template edited without
|
|
22
22
|
#: bumping DEVKIT_VERSION and updating this value fails there, in the same commit (D7).
|
|
23
|
-
TEMPLATES_SHA256 = "
|
|
23
|
+
TEMPLATES_SHA256 = "13012ed7564224f65f411680a07225d4d7ac42aae94467a3ea9daf9386e72499"
|
|
24
24
|
|
|
25
25
|
TEMPLATES_DIR = Path(__file__).parent / "templates"
|
|
26
26
|
|
|
@@ -22,9 +22,12 @@ reaches — ask the graph instead of reading files or grepping.
|
|
|
22
22
|
answer is about the older tree.
|
|
23
23
|
- `resolved.ambiguous` — the short name matched several symbols; ask again by the full name.
|
|
24
24
|
- `limit.truncated: true` — the list is not complete.
|
|
25
|
+
- In `source`, use code with `result.status: verified`. Rebuild and reload when the
|
|
26
|
+
status is `behind` or `unverified` before relying on the recorded line range.
|
|
25
27
|
|
|
26
28
|
**The architecture contract** — `[architecture]` in `codemap.toml`, run as
|
|
27
|
-
`codemap check --graph {{graph}} --root . --require-contract
|
|
29
|
+
`codemap check --graph {{graph}} --root . --require-contract --require-current`.
|
|
30
|
+
In MCP, set `require_contract` and `require_current`, then read `result.ok`. `allowed` there is a
|
|
28
31
|
ratchet: every import between two layers must be a listed pair. A red `allowed` means a new dependency
|
|
29
32
|
between layers: remove the import, or add the pair by hand inside the generated region **with a comment
|
|
30
33
|
giving the reason**, and let the review judge it. `codemap devkit ratchet --tighten` removes the pairs
|
|
@@ -22,9 +22,12 @@ codemap отвечает на вопросы о структуре `{{package}}`
|
|
|
22
22
|
о старом дереве.
|
|
23
23
|
- `resolved.ambiguous` — короткое имя совпало с несколькими символами; спросите по полному имени.
|
|
24
24
|
- `limit.truncated: true` — список неполный.
|
|
25
|
+
- В `source` используйте код при `result.status: verified`. При `behind` или
|
|
26
|
+
`unverified` пересоберите и перечитайте граф, прежде чем опираться на номера строк.
|
|
25
27
|
|
|
26
28
|
**Контракт архитектуры** — `[architecture]` в `codemap.toml`, запуск
|
|
27
|
-
`codemap check --graph {{graph}} --root . --require-contract
|
|
29
|
+
`codemap check --graph {{graph}} --root . --require-contract --require-current`.
|
|
30
|
+
В MCP задайте `require_contract` и `require_current` и проверьте `result.ok`. `allowed` там — храповик:
|
|
28
31
|
каждый импорт между двумя слоями должен быть перечисленной парой. Красный `allowed` — новая зависимость
|
|
29
32
|
между слоями: уберите импорт или допишите пару руками внутри сгенерированного региона **с комментарием о
|
|
30
33
|
причине**, и пусть ревью это оценит. `codemap devkit ratchet --tighten` убирает пары, которыми больше никто
|
|
@@ -21,16 +21,16 @@ LOG="$ROOT/.codemap/rebuild.log"
|
|
|
21
21
|
kind=incremental
|
|
22
22
|
cp {{graph_sh}} {{graph_next_sh}}
|
|
23
23
|
cp {{graph_sh}}.meta.json {{graph_next_sh}}.meta.json
|
|
24
|
-
nice -n 19 $C build {{package_sh}} --deep --repeat 2 {{build_args}} --incremental -o {{graph_next_sh}} >/dev/null 2>"$LOG.err" &
|
|
24
|
+
nice -n 19 $C build {{package_sh}} --deep --repeat 2 {{build_args}} --incremental -o {{graph_next_sh}} --recipe-output {{graph_sh}} >/dev/null 2>"$LOG.err" &
|
|
25
25
|
else
|
|
26
26
|
kind=full
|
|
27
|
-
nice -n 19 $C build {{package_sh}} --deep --repeat 2 {{build_args}} -o {{graph_next_sh}} >/dev/null 2>"$LOG.err" &
|
|
27
|
+
nice -n 19 $C build {{package_sh}} --deep --repeat 2 {{build_args}} -o {{graph_next_sh}} --recipe-output {{graph_sh}} >/dev/null 2>"$LOG.err" &
|
|
28
28
|
fi
|
|
29
29
|
bpid=$!
|
|
30
30
|
wait "$bpid"; brc=$?
|
|
31
|
-
if [ "$brc" -eq 0 ]
|
|
32
|
-
mv {{graph_next_sh}}.meta.json {{graph_sh}}.meta.json
|
|
33
|
-
mv {{graph_next_sh}} {{graph_sh}}
|
|
31
|
+
if [ "$brc" -eq 0 ] &&
|
|
32
|
+
mv {{graph_next_sh}}.meta.json {{graph_sh}}.meta.json 2>>"$LOG.err" &&
|
|
33
|
+
mv {{graph_next_sh}} {{graph_sh}} 2>>"$LOG.err"; then
|
|
34
34
|
[ "$kind" = full ] && touch .codemap/last_full
|
|
35
35
|
$C devkit index --root "$ROOT" >/dev/null 2>>"$LOG.err"
|
|
36
36
|
echo "$(date -Is) $(git log --oneline -1 | cut -c1-60) $kind ok $(( $(date +%s)-start ))s" >> "$LOG"
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"""Codemap MCP, CLI and grep tool use in local Claude Code transcripts.
|
|
2
|
+
|
|
3
|
+
Reads ``~/.claude/projects/<project path with "/" → "-">/**/*.jsonl`` (or ``--transcripts``) — sessions and
|
|
4
|
+
their subagents. Counts ``mcp__codemap__*``, codemap CLI in Bash, and ``Grep`` or grep/rg in Bash.
|
|
5
|
+
Only ``assistant`` records count, once per tool-use id: a transcript also stores request
|
|
6
|
+
blobs that repeat earlier calls without a timestamp, and counting them inflated the numbers (measured on the
|
|
7
|
+
acceptance run, 1 301 repeats in 16 536). Only counts and tool names are reported.
|
|
8
|
+
Codex transcripts are outside this reader's scope.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import json
|
|
14
|
+
import re
|
|
15
|
+
import shlex
|
|
16
|
+
import time
|
|
17
|
+
from collections import Counter
|
|
18
|
+
from datetime import datetime
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
|
|
21
|
+
# A command starts at the line start (a newline separates commands in bash), after `;`, `&`, `|`, `(`, or as
|
|
22
|
+
# the argument of `xargs`.
|
|
23
|
+
GREP_CMD = re.compile(r"(?:^[ \t]*|[;&|(][ \t]*|\bxargs[ \t]+)(?:grep|egrep|rg)\b", re.MULTILINE)
|
|
24
|
+
_SHELL_SEPARATORS = frozenset(";&|()\n")
|
|
25
|
+
_SHELL_KEYWORDS = frozenset({"!", "{", "if", "then", "elif", "else", "while", "until", "do"})
|
|
26
|
+
_SHELL_TRIVIA = re.compile(r"""'[^']*'|"(?:\\[\s\S]|[^"\\])*"|\\[\s\S]|(?<![^\s;&|()<>])\#[^\n]*""")
|
|
27
|
+
_ASSIGNMENT = re.compile(r"[A-Za-z_][A-Za-z_0-9]*=")
|
|
28
|
+
_PYTHON = re.compile(r"python(?:3(?:\.\d+)?)?")
|
|
29
|
+
_UV_VALUE_OPTIONS = frozenset({"--with", "--with-editable", "--with-requirements",
|
|
30
|
+
"--python", "-p", "--project", "--directory", "--env-file",
|
|
31
|
+
"--group", "--no-group", "--extra", "--index", "--default-index"})
|
|
32
|
+
_SHARE_BASIS = "(MCP + CLI) / (MCP + CLI + grep)"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _unquote(word: str) -> str:
|
|
36
|
+
if len(word) >= 2 and word[0] == word[-1] and word[0] in ("'", '"'):
|
|
37
|
+
return word[1:-1]
|
|
38
|
+
return word
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _skip_options(words: list[str], value_options: frozenset[str]) -> list[str]:
|
|
42
|
+
i = 0
|
|
43
|
+
while i < len(words) and words[i].startswith("-"):
|
|
44
|
+
option = words[i]
|
|
45
|
+
if option == "--":
|
|
46
|
+
return words[i + 1:]
|
|
47
|
+
i += 2 if option in value_options else 1
|
|
48
|
+
return words[i:]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _cli_command(words: list[str]) -> bool:
|
|
52
|
+
while words:
|
|
53
|
+
head, *args = words
|
|
54
|
+
program = _unquote(head).rsplit("/", 1)[-1]
|
|
55
|
+
if program == "codemap":
|
|
56
|
+
return True
|
|
57
|
+
if _PYTHON.fullmatch(program):
|
|
58
|
+
return _python_module(args) == "codemap"
|
|
59
|
+
if head in _SHELL_KEYWORDS or _ASSIGNMENT.match(head):
|
|
60
|
+
words = args
|
|
61
|
+
elif program == "uv" and args[:1] == ["run"]:
|
|
62
|
+
words = _skip_options(args[1:], _UV_VALUE_OPTIONS)
|
|
63
|
+
elif program == "env" and not {"-S", "--split-string"}.intersection(args):
|
|
64
|
+
words = _skip_options(args, frozenset({"-u", "--unset", "-C", "--chdir"}))
|
|
65
|
+
elif program == "command" and args[:1] not in (["-v"], ["-V"]):
|
|
66
|
+
words = args[1:] if args[:1] == ["-p"] else args
|
|
67
|
+
else:
|
|
68
|
+
break
|
|
69
|
+
return False
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _python_module(args: list[str]) -> str | None:
|
|
73
|
+
i = 0
|
|
74
|
+
while i < len(args):
|
|
75
|
+
option = args[i]
|
|
76
|
+
if option == "-m" and i + 1 < len(args):
|
|
77
|
+
return _unquote(args[i + 1])
|
|
78
|
+
if option in ("-W", "-X"):
|
|
79
|
+
i += 2
|
|
80
|
+
elif option.startswith(("-W", "-X")) or re.fullmatch(r"-[bBdEIPiOqRsSuvx]+", option):
|
|
81
|
+
i += 1
|
|
82
|
+
else:
|
|
83
|
+
return None
|
|
84
|
+
return None
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _uses_cli(command: str) -> bool:
|
|
88
|
+
def trivia(match):
|
|
89
|
+
token = match[0]
|
|
90
|
+
if token.startswith("#") or token == "\\\n":
|
|
91
|
+
return ""
|
|
92
|
+
if token.startswith("\\") and token[1:] in _SHELL_SEPARATORS:
|
|
93
|
+
return "_"
|
|
94
|
+
return token
|
|
95
|
+
|
|
96
|
+
# Retain quotes so an argument such as `";"` cannot become a command separator.
|
|
97
|
+
lexer = shlex.shlex(_SHELL_TRIVIA.sub(trivia, command), posix=False, punctuation_chars=";&|()<>\n")
|
|
98
|
+
lexer.whitespace = " \t\r"
|
|
99
|
+
lexer.whitespace_split = True
|
|
100
|
+
lexer.commenters = ""
|
|
101
|
+
try:
|
|
102
|
+
tokens = list(lexer)
|
|
103
|
+
except ValueError:
|
|
104
|
+
return False
|
|
105
|
+
if "<<" in tokens: # shell input bodies are data
|
|
106
|
+
return False
|
|
107
|
+
words = []
|
|
108
|
+
arithmetic = False
|
|
109
|
+
for token in tokens:
|
|
110
|
+
if set(token) <= _SHELL_SEPARATORS:
|
|
111
|
+
if not arithmetic and _cli_command(words):
|
|
112
|
+
return True
|
|
113
|
+
words = []
|
|
114
|
+
if "((" in token:
|
|
115
|
+
arithmetic = True
|
|
116
|
+
if "))" in token:
|
|
117
|
+
arithmetic = False
|
|
118
|
+
elif not arithmetic:
|
|
119
|
+
words.append(token)
|
|
120
|
+
return _cli_command(words)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def transcripts_dir(root: Path) -> Path:
|
|
124
|
+
slug = str(Path(root).resolve()).replace("/", "-")
|
|
125
|
+
return Path.home() / ".claude" / "projects" / slug
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def _ts(obj: dict) -> float | None:
|
|
129
|
+
t = obj.get("timestamp")
|
|
130
|
+
if not isinstance(t, str):
|
|
131
|
+
return None
|
|
132
|
+
try:
|
|
133
|
+
return datetime.fromisoformat(t.replace("Z", "+00:00")).timestamp()
|
|
134
|
+
except ValueError:
|
|
135
|
+
return None
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def count(directory: Path, days: int) -> dict:
|
|
139
|
+
since = time.time() - days * 86400
|
|
140
|
+
codemap: Counter = Counter()
|
|
141
|
+
cli = 0
|
|
142
|
+
grep = Counter()
|
|
143
|
+
files = 0
|
|
144
|
+
seen: set[str] = set()
|
|
145
|
+
for f in sorted(directory.glob("**/*.jsonl")) if directory.is_dir() else []:
|
|
146
|
+
if f.stat().st_mtime < since:
|
|
147
|
+
continue
|
|
148
|
+
files += 1
|
|
149
|
+
with f.open(encoding="utf-8", errors="replace") as fh:
|
|
150
|
+
for line in fh:
|
|
151
|
+
if '"tool_use"' not in line:
|
|
152
|
+
continue
|
|
153
|
+
try:
|
|
154
|
+
obj = json.loads(line)
|
|
155
|
+
except ValueError:
|
|
156
|
+
continue
|
|
157
|
+
if obj.get("type") != "assistant":
|
|
158
|
+
continue
|
|
159
|
+
ts = _ts(obj)
|
|
160
|
+
if ts is None or ts < since:
|
|
161
|
+
continue
|
|
162
|
+
content = (obj.get("message") or {}).get("content")
|
|
163
|
+
if not isinstance(content, list):
|
|
164
|
+
continue
|
|
165
|
+
for item in content:
|
|
166
|
+
if not isinstance(item, dict) or item.get("type") != "tool_use":
|
|
167
|
+
continue
|
|
168
|
+
tid = str(item.get("id", ""))
|
|
169
|
+
if tid in seen:
|
|
170
|
+
continue
|
|
171
|
+
seen.add(tid)
|
|
172
|
+
name = str(item.get("name", ""))
|
|
173
|
+
if name.startswith("mcp__codemap__"):
|
|
174
|
+
codemap[name[len("mcp__codemap__"):]] += 1
|
|
175
|
+
elif name == "Grep":
|
|
176
|
+
grep["Grep tool"] += 1
|
|
177
|
+
elif name == "Bash":
|
|
178
|
+
cmd = str((item.get("input") or {}).get("command", ""))
|
|
179
|
+
cli += _uses_cli(cmd)
|
|
180
|
+
if GREP_CMD.search(cmd):
|
|
181
|
+
grep["grep/rg in Bash"] += 1
|
|
182
|
+
mcp = sum(codemap.values())
|
|
183
|
+
grep_total = sum(grep.values())
|
|
184
|
+
numerator = mcp + cli
|
|
185
|
+
denominator = numerator + grep_total
|
|
186
|
+
return {"transcripts": str(directory), "files": files, "days": days,
|
|
187
|
+
"codemap": dict(codemap), "codemap_total": mcp,
|
|
188
|
+
"codemap_cli": {"codemap in Bash": cli} if cli else {}, "codemap_cli_total": cli,
|
|
189
|
+
"grep": dict(grep), "grep_total": grep_total,
|
|
190
|
+
"share": {"basis": _SHARE_BASIS, "numerator": numerator, "denominator": denominator,
|
|
191
|
+
"fraction": numerator / denominator if denominator else None},
|
|
192
|
+
"not_read": "Codex transcripts"}
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def render(r: dict) -> str:
|
|
196
|
+
fraction = r["share"]["fraction"]
|
|
197
|
+
share = f"{100 * fraction:.0f} %" if fraction is not None else "—"
|
|
198
|
+
lines = [f"# codemap usage — last {r['days']} day(s)", "",
|
|
199
|
+
f"Transcripts: `{r['transcripts']}` ({r['files']} file(s) touched in the window).", "",
|
|
200
|
+
"| | calls |", "|---|---|",
|
|
201
|
+
f"| codemap (MCP) | {r['codemap_total']} |",
|
|
202
|
+
f"| codemap (CLI in Bash) | {r['codemap_cli_total']} |",
|
|
203
|
+
f"| grep (Grep tool + grep/rg in Bash) | {r['grep_total']} |",
|
|
204
|
+
f"| codemap share | {share} |", ""]
|
|
205
|
+
lines.append(f"Share: {r['share']['basis']}. A Bash tool-use can count once for CLI and once for grep.")
|
|
206
|
+
lines.append("")
|
|
207
|
+
if r["codemap"]:
|
|
208
|
+
lines.append("By tool: " + ", ".join(f"`{k}` {v}" for k, v in
|
|
209
|
+
sorted(r["codemap"].items(), key=lambda x: (-x[1], x[0]))))
|
|
210
|
+
lines.append("")
|
|
211
|
+
lines.append(f"_Not read: {r['not_read']}. The Bash scan recognises simple command positions; "
|
|
212
|
+
"these counts describe tool use, including searches in text, logs and configs._")
|
|
213
|
+
return "\n".join(lines) + "\n"
|