Metadata-Version: 2.4
Name: prefect-jcodemunch
Version: 0.1.0
Summary: Prefect tasks and flows for keeping jcodemunch-mcp code indexes fresh across many repositories.
Project-URL: Homepage, https://github.com/jgravelle/prefect-jcodemunch
Project-URL: Repository, https://github.com/jgravelle/prefect-jcodemunch
Project-URL: Issues, https://github.com/jgravelle/prefect-jcodemunch/issues
Project-URL: jcodemunch-mcp, https://github.com/jgravelle/jcodemunch-mcp
Author-email: "J. Gravelle" <jjgravelle@gmail.com>
License: MIT
License-File: LICENSE
Keywords: code-indexing,jcodemunch,mcp,prefect,tree-sitter
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development
Requires-Python: >=3.10
Requires-Dist: jcodemunch-mcp>=1.81.0
Requires-Dist: prefect<4,>=3.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == 'dev'
Description-Content-Type: text/markdown

# prefect-jcodemunch

Prefect 3.x tasks and flows for keeping [`jcodemunch-mcp`](https://github.com/jgravelle/jcodemunch-mcp) code indexes fresh across many repositories.

`jcodemunch-mcp` is a token-efficient MCP server that gives AI agents structural access to source code (symbols, call hierarchies, dead-code detection, refactor blast radius). It lives locally per-machine. Once you maintain indexes for more than a handful of repos, keeping them fresh becomes the kind of recurring orchestration problem Prefect is built for.

This package wraps the `jcodemunch-mcp` CLI as Prefect Tasks and Flows so you can:

- **Schedule periodic reindexing** of every repo on a cron
- **Index on push** by triggering a flow from a webhook
- **Chain indexing** into larger pipelines (e.g. doc generation, CI gates, agent provisioning)
- **React to staleness** by querying which repos haven't been touched in N days and refreshing only those

## Install

```bash
pip install prefect-jcodemunch
```

This pulls in `prefect>=3.0` and `jcodemunch-mcp>=1.81.0` automatically. The `jcodemunch-mcp` binary needs to be on `PATH` (the install above puts it there).

## Quick example

Reindex every locally-indexed repo whose index is more than 7 days old:

```python
from prefect_jcodemunch import keep_indexes_fresh

if __name__ == "__main__":
    keep_indexes_fresh(older_than_days=7)
```

Deploy on a daily cron via Prefect Cloud:

```bash
prefect deploy examples/keep_indexes_fresh.py:keep_indexes_fresh \
    --name daily-reindex \
    --cron "0 4 * * *" \
    --pool default-agent-pool
```

## Tasks

| Task | What it wraps |
|---|---|
| `index_local_folder(path)` | `jcodemunch-mcp index <path>` |
| `index_github_repo(owner_repo)` | `jcodemunch-mcp index <owner>/<repo>` |
| `index_file(path)` | `jcodemunch-mcp index-file <path>` (single-file refresh) |
| `list_repos()` | MCP `list_repos` tool — returns `[{source_root, indexed_at, ...}, …]` |
| `reindex_stale_repos(older_than_days=N)` | `list_repos` → filter by age → `index_local_folder` per stale repo |

All Tasks accept `cli_path=` to override the binary location, and pass through to standard Prefect kwargs (retries, timeout, tags) at decoration time.

## Flows

| Flow | Purpose |
|---|---|
| `keep_indexes_fresh(older_than_days=7)` | The standard "schedule me on a cron" flow — walks every locally-indexed repo, refreshes anything older than the threshold |

## Compose with other Prefect blocks

Tasks emit standard Prefect logs and respect retry/timeout config, so the usual blocks plug in:

- **Slack / Discord notifications** on flow failure via `prefect-slack` / `prefect-community`
- **GitHub event triggers** via `prefect-github`
- **Result persistence** to S3 / GCS / local FS via standard result storage blocks

## License

This wrapper package (`prefect-jcodemunch`) is MIT.

The wrapped tool, [`jcodemunch-mcp`](https://github.com/jgravelle/jcodemunch-mcp), is dual-licensed: free for non-commercial use (personal, academic, research) and paid for commercial use. Commercial license tiers and pricing at [j.gravelle.us/jCodeMunch](https://j.gravelle.us/jCodeMunch). Review the terms before deploying in a commercial workflow.

## Issues / contributions

Issues and PRs welcome at https://github.com/jgravelle/prefect-jcodemunch.

For `jcodemunch-mcp` itself (CLI / index format / MCP tools), file at https://github.com/jgravelle/jcodemunch-mcp/issues.
