Metadata-Version: 2.4
Name: daygent
Version: 0.2.0
Summary: Static lineage and impact analysis for modern data + AI repositories.
Author: Emmanuel Onwubuya
Maintainer: Emmanuel Onwubuya
License-Expression: MIT
Project-URL: Homepage, https://github.com/emyrael/daygent
Project-URL: Repository, https://github.com/emyrael/daygent
Project-URL: Issues, https://github.com/emyrael/daygent/issues
Keywords: lineage,impact-analysis,dbt,sql,fastapi,langgraph,llm,vector-store,static-analysis,cli
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2.7
Requires-Dist: PyYAML>=6.0
Requires-Dist: rich>=13.7
Requires-Dist: sqlglot>=25.0
Requires-Dist: typer>=0.12
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Provides-Extra: release
Requires-Dist: build>=1.2; extra == "release"
Requires-Dist: twine>=5.0; extra == "release"
Dynamic: license-file

# Daygent

Local-first static lineage and blast-radius analysis for modern data + AI repositories.

Daygent reads source files on disk and builds a dependency graph you can inspect, query, and share as JSON, Mermaid, or a fully offline HTML viewer. It answers questions like:

- What depends on this table or dbt model?
- Which API routes could change if this function changes?
- What is downstream of this dataset?
- Which agents, LLMs, or vector collections sit on this path?

It does **not** connect to warehouses, APIs, vector databases, or cloud accounts. It does **not** execute scanned code, resolve environment variables, or phone home.

## Interactive graph viewer

<p align="center">
  <img src="assets/daygent-graph.png" alt="Daygent interactive dependency graph viewer" width="100%">
</p>

Explore dependencies visually, inspect nodes and edges, filter by technology, and trace upstream/downstream impact — fully offline.

```bash
daygent scan .
daygent graph --html --open
```

## Why it exists

Data + AI codebases mix SQL, dbt, Python services, FastAPI, LangGraph, LLM constructors, and HTTP clients. Runtime catalogs and vendor consoles only see what already ran. Daygent maps what the **source** statically declares, so you can review impact before you ship.

## How it works

```text
Repository
   ↓
Scanner (walk files, skip junk)
   ↓
Technology parsers (all matching parsers run)
   ↓
Candidate graph
   ↓
Relevance scope  ←  scan broadly, graph narrowly
   ↓
.daygent/graph.json
   ↓
daygent graph  |  daygent impact  |  HTML viewer
```

Parsers may see every function in a file. The final graph keeps **data/AI lineage**: tables, dbt models, LLMs, vector stores, HTTP hosts, LangGraph nodes, and the connector code that joins them. Unrelated helpers such as `format_date()` stay out unless they sit on that lineage.

## Graph convention

**A → B means B depends on A.** Impact walks with the arrows. Upstream lineage walks against them.

```text
raw.users
   ↓
stg_users
   ↓
user_features
```

Changing `raw.users` can affect everything below it.

## Supported technologies

Static detection only:

| Area | What Daygent reads |
| --- | --- |
| Python | modules, functions, local calls, imports |
| SQL | table lineage via sqlglot, including CTEs |
| dbt | `ref()` / `source()` from Jinja SQL (no dbt CLI, manifest optional) |
| FastAPI | routes, handlers, `include_router` |
| LangGraph | literal `add_node` / `add_edge` |
| LLM constructors | ChatOpenAI, Anthropic, Azure, … when the model is a literal |
| Embeddings | OpenAI / HuggingFace / SentenceTransformer constructors |
| Vector stores | Qdrant, Pinecone, Weaviate, Chroma, FAISS, PGVector |
| External HTTP | literal `https://host/...` URLs |
| PySpark | table reads/writes (`spark.table`, `read.table`, `saveAsTable`, `writeTo`) and literal `spark.sql` |
| Databricks DLT / Lakeflow | pipeline declarations (`@dlt.table`, `@dp.materialized_view`, `dlt.read`, …) |
| Embedded SQL in Python | literal SQL in `execute` / `text(...)` style calls |
| pandas | literal `read_sql` / `read_sql_query` / `read_sql_table` |
| Django | basic ORM model lineage, `objects.raw`, explicit `Meta.db_table` |
| SQLAlchemy | basic model/table lineage, `select`/`query`, literal `text()`, explicit `__tablename__` |

No live vendor, database, Spark session, Django setup, SQLAlchemy engine, or network calls. Dynamic names (`os.getenv("TABLE")`, f-strings, `spark.sql(query)`) are **not** resolved.

## Install

Requires Python 3.11+.

```bash
pip install daygent
```

With uv:

```bash
uv tool install daygent
```

One-off:

```bash
uvx daygent --help
```

## Quick Start

```bash
daygent scan .
daygent graph --html --open
daygent impact <node>
```

From a clone (contributors):

```bash
git clone https://github.com/emyrael/daygent.git
cd daygent
python3.11 -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
```

## Commands

```bash
daygent scan .
daygent graph
daygent graph --json
daygent graph --mermaid
daygent graph --html --open
daygent impact <node>
```

`scan` writes `.daygent/graph.json` (gitignored). `graph` and `impact` read that artifact. If it is missing, the CLI tells you to scan first.

Useful flags:

```bash
daygent scan . --verbose
daygent graph --html --include-source --open
daygent impact stg_users --depth 2 --json
```

`--include-source` is opt-in. Default HTML never embeds repository file contents. With the flag, the viewer includes a short excerpt around known lines and banners: *This HTML contains source-code excerpts.*

## Config is optional

No `daygent.yml` is required. Empty or missing `include` means repository-wide discovery, then lineage scoping.

```yaml
# daygent.yml — optional overrides only
exclude:
  - migrations/**
  - generated/**
output: .daygent/graph.json
```

Built-in skips include `.venv`, `node_modules`, `graphify-out`, `.cursor`, and `*.egg-info`.

## HTML viewer

`daygent graph --html --open` writes a self-contained `.daygent/graph.html`:

- pan, zoom, search, type filters
- click a node for details, connections, evidence, metadata
- click an edge for relationship evidence
- drag nodes; blast-radius / upstream / downstream remain
- no CDN, no `fetch`, no telemetry

## Local-first guarantees

- Fully offline after install
- No telemetry
- No runtime network calls from Daygent itself
- No warehouse / vector-store / API credentials
- No secret or environment resolution
- Scan warnings do not print file bodies

## Known limitations (v0.2)

- Cross-file Python call resolution is incomplete. Same-file calls are detected; calls across modules are not fully linked.
- Dynamic table names, f-string SQL, and runtime-constructed queries are generally omitted.
- No Spark plan analysis, Databricks workspace inspection, Django setup/import, or SQLAlchemy metadata reflection.
- Complex DataFrame variable propagation is not modeled; the containing function is the transform boundary.
- Cross-function/cross-file dynamic dataflow may still be incomplete.
- Isolated Python helpers and unrelated health routes are omitted by design (scoping).
- dbt compile and warehouse introspection are out of scope.
- Default HTML does not ship source code.

The golden fixtures at `tests/fixtures/golden_mixed_stack/` and `tests/fixtures/python_data_stack/` lock this behavior.

## Roadmap

- Real-repository testing beyond fixtures

## License

MIT. See [LICENSE](LICENSE).

## Contribute

See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, parser contracts, and test rules.
