Skip to content

Add function reference to AGENTS.md with auto-generated docs/functions.txt#1624

Merged
nathanjmcdougall merged 7 commits intomainfrom
copilot/configure-agents-dependency-functions
Mar 29, 2026
Merged

Add function reference to AGENTS.md with auto-generated docs/functions.txt#1624
nathanjmcdougall merged 7 commits intomainfrom
copilot/configure-agents-dependency-functions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

Agents were reimplementing logic (especially dependency reads) that already exists as mature, tested functions—e.g. hand-rolling pyproject.toml parsing instead of calling get_dep_groups().

Changes

  • hooks/export-functions.py — New generic hook (modelled after hooks/export-module-tree.py) that accepts --output-file, --source-root, and --strict. It recursively discovers all .py files under the source root, scans module-level public functions (not class methods), and writes a flat bullet list in source order with no hardcoded sections or headers. With --strict, it exits non-zero if any public function lacks a docstring.

  • .pre-commit-config.yaml — Adds the export-functions hook alongside export-module-tree with --source-root=src/usethis --strict, so docs/functions.txt is kept up to date automatically on every prek run.

  • docs/functions.txt — Auto-generated (not hand-written) comprehensive flat reference of all 191 public module-level functions across the usethis package, with full dotted module names (e.g. usethis._deps).

  • AGENTS.md — Embeds docs/functions.txt via the existing <!-- sync:... --> pattern (enforced by the check-doc-sync hook), and adds an explicit "ALWAYS check the Function Reference" instruction to the general guidelines.

  • Docstrings added to all 112 previously undocumented public module-level functions across 50+ source files so the package complies with --strict mode and every public function appears in the generated reference.


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/f28bf4d2-0a29-421e-9322-10081aeec8af

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI changed the title [WIP] Configure agents to be aware of utility functions for dependency management Add function reference to AGENTS.md to prevent agents reinventing existing utilities Mar 28, 2026
Copilot AI requested a review from nathanjmcdougall March 28, 2026 23:41
@nathanjmcdougall
Copy link
Copy Markdown
Collaborator

@copilot wrong way of generating functions.txt. should use a hook similar to how we generate module-tree.txt

…e docstrings

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/2927dcf9-6699-49b6-8758-fd7ac587c972

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 28, 2026

@copilot wrong way of generating functions.txt. should use a hook similar to how we generate module-tree.txt

Done in 22c36f5. Created hooks/export-functions.py (modelled after export-module-tree.py) that scans key source modules for public functions with docstrings and writes docs/functions.txt. Added the export-functions hook to .pre-commit-config.yaml and added missing docstrings to the relevant public functions so they appear in the generated reference.

Copilot AI changed the title Add function reference to AGENTS.md to prevent agents reinventing existing utilities Add function reference to AGENTS.md with auto-generated docs/functions.txt Mar 28, 2026
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review March 29, 2026 21:30
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 29, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing copilot/configure-agents-dependency-functions (0bc5d6f) with main (6846354)

Open in CodSpeed

Copilot AI added a commit that referenced this pull request Mar 29, 2026
…unctions.txt)

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI added a commit that referenced this pull request Mar 29, 2026
…reference

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI and others added 3 commits March 29, 2026 22:32
Add one-line docstrings to all public module-level functions that were
previously missing them, as required by the export-functions strict check.
Also fix export-functions.py to normalize RST double backticks to markdown
single backticks so the output is compatible with prettier's formatting.
This keeps docs/functions.txt and AGENTS.md in sync after prettier runs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
- Move docstrings before comments (not after) in lint.py and hooks.py
- Add blank line after sync marker in AGENTS.md to match prettier's formatting
  so prek passes cleanly without file modifications on each run

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
…rings

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/18fc9b90-3ca4-4cb0-87fd-885ed6de891c

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
@nathanjmcdougall nathanjmcdougall merged commit 9117fac into main Mar 29, 2026
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/configure-agents-dependency-functions branch March 29, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configure agents to be more aware of important utility functions relating to dependency management

2 participants