Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=5d7e3ba2610083ec18c99874eb75984d
sha512=48a48712c428ac89ae44a8d6794803b357797662a830f96d3549c9819172f46608df6bfd7cfb16b95a3cd56f95f0d223acf6958caf422e5b159fdbf46438110a
Description
dune-ai-context parses external library dependencies using dune describe external-lib-deps, finds their .cmi files, and writes interface signatures for AI-assisted coding tools.
README
dune‑ai‑context
dune‑ai‑context is a small OCaml command‑line tool that:
- Parses the external library dependencies of an OCaml project by invoking
dune describe external‑lib‑deps. - Filters out
ppx_‑prefixed packages (they are usually build‑time helpers). - Looks for the compiled interface files (
.cmi) of the remaining vendor libraries in the current OPAM switch ($OPAM_SWITCH_PREFIX/lib). - Collects the public API of all third‑party libraries and writes each interface to
vendor_interfaces/<library>.mli. The generatedvendor_interfacesdirectory can be added to a project's source tree and used as a context for AI‑assisted coding tools such as Claude Code, OpenCode, Aider, and similar assistants that can read local files to provide more accurate suggestions.
The tool is useful when you need to inspect or export the public API of the third‑party libraries used in a project, and when you want to give AI coding assistants full visibility of those APIs without requiring them to resolve external dependencies themselves.
Installation
The project depends on the following OPAM packages:
dune(≥ 3.1)ocaml(≥ 4.14)sexplib
You can install the tool directly from the repository:
git clone https://github.com/zenfey/dune-ai-context
cd dune-ai-context
opam pin add dune-ai-context .
opam install dune-ai-contextBuilding from source
If you prefer to build manually with dune:
dune buildThe executable will be built as _build/default/bin/dune_ai_context.exe (and installed as dune-ai-context when you run dune install).
Usage
Assuming your OCaml project that uses Dune is located at <proj-root>:
- Run the tool from the project root:
cd <proj-root>
dune-ai-context- Or invoke it with the project directory as an argument:
dune-ai-context <proj-root>The command will create a vendor_interfaces directory inside the current working directory (or inside <proj-root> if you passed it as an argument) and populate it with <library>.mli files containing the exported signatures.
Environment variable
dune‑ai‑context relies on the OPAM_SWITCH_PREFIX environment variable to locate the compiled libraries. Ensure it is set (it is automatically set when you are inside an OPAM switch). If the variable is not present the tool will skip the .cmi lookup.
Testing
There are currently no inline tests. Run the tests with:
dune runtestLicense
MIT – see the LICENSE file for details.
Contributing
Feel free to open issues or submit pull requests on the GitHub repository:
Dev Dependencies (1)
-
odoc
with-doc
Optional Dependencies
None
Used by
None
Conflicts
None
Build status
Results of building dune-ai-context with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 0.1.2 (this version) | n/a | good | good | good | good |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure