Concept: Local insights reports with model-backed enrichment#65
Closed
tony wants to merge 0 commit into
Closed
Conversation
7 tasks
Owner
Author
|
Auto-closed during a rebase onto master (a stray force-push briefly made the branch look merged). The same work, rebased onto current master, continues in #87. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
agentgrep insightscommand tree that turns local agent history into a report — deterministic by default, with an opt-in ladder of HTML, classical ML, embeddings, a persistent hybrid index, and a local-LLM summary.agentgreploads none of the optional backends, and every missing rung degrades to a precise install command instead of a traceback.This is a concept branch demonstrating the ADR 0005 architecture end-to-end; it is not intended for direct merge.
Changes by area
Engine —
src/agentgrep/insights/report.py: builds a report from aSearchRecordstream — resolves the effective level, attaches enrichment, and records diagnostics and grounded next actions.activity.py: deterministic level-0 analysis (per-agent/store counters, daily timeline, frequent terms, repeated instructions, an open-thread heuristic, coverage) emittingRecordRefdrilldown handles.loader.py: lazy backend loading behind an injectableimport_moduleseam; availability is probed withimportlib.util.find_specso a builtin report never imports a heavy backend just to list levels.models.py: the curated registry, an atomic urllib downloader, and a manifest sidecar; a torch-freemodel2vecmodel and the LLM artifacts share one cache layout.enrichers/:html(jinja2),ml(scikit-learn TF-IDF + KMeans),embeddings(sentence-transformers preferred, model2vec fallback),index(tantivy+sqlite-vec or LanceDB),llm(Ollama over httpx, grounded in compact facts).cache.py/model.py/progress.py: ADR-0005 cache-directory precedence, the typed report model with JSON payloads, and the progress protocol.CLI —
src/agentgrep/cli/parser.py: theinsightssubcommand tree (report,levels,doctor,setup,models,cache) with typed argument dataclasses.insights_render.py: dispatchers, the text/markdown/html/json/ndjson renderer, and the stderr console progress sink.__init__.py:main()dispatch for the new argument types.Packaging & docs
pyproject.toml:insights-html / -ml / -embeddings / -embeddings-st / -index / -index-lancedb / -llm / -allextras.docs/cli/insights.md: the CLI guide, registered in the CLI index toctree and card grid.Design decisions
best-installednever auto-selects the LLM level, since its runtime depends on an external daemon the import probe cannot see.agentgrep-manifest.jsonpath as a local LLM artifact, so "fetch an embedding model" and "fetch a local LLM" are the same mechanism with one cache layout.Any: an optionally-present third-party module cannot be statically typed, soEnricherContext.modulesisdict[str, Any]— which also lets the tests inject plain fakes through the same seam.Verification
No optional backend is imported at module top of the insights package (all loads are lazy):
The
insightspackage itself is not imported byimport agentgrepexcept function-locally inside the dispatchers:Test plan
tests/test_insights_enrichers.pyurlopen, writes a manifest, and is a no-op when cached —tests/test_insights_models.pytests/test_insights_report.pyimport agentgreploads no optional backend or the insights package —tests/test_import_time.pyruff check,ruff format,ty check,pytest,just build-docsmodel2vecdownload → semantic clustering, and a real tantivy + sqlite-vec index with working sample queries