Skip to content

✨ feat(cli): add modules subcommand for built-in module discovery#1672

Merged
harehare merged 4 commits intomainfrom
feat/add-modules-subcommand-for-built-in-module-discovery
May 1, 2026
Merged

✨ feat(cli): add modules subcommand for built-in module discovery#1672
harehare merged 4 commits intomainfrom
feat/add-modules-subcommand-for-built-in-module-discovery

Conversation

@harehare
Copy link
Copy Markdown
Owner

@harehare harehare commented May 1, 2026

  • Add mq modules subcommand listing all standard modules with their public functions, parameter signatures, and doc comments
  • Add --format / -F option supporting text (default, colored), markdown (GFM table), and table (rounded ASCII table) output
  • Add FunctionInfo and ParamInfo structs to mq-lang for structured module introspection extracted from AST (Expr::Def params) and source-level # doc comments
  • Improve NotDefined error help to suggest mq modules when a function is not found
  • Update CLI --help after_help with modules and -m usage examples

- Add `mq modules` subcommand listing all standard modules with their
  public functions, parameter signatures, and doc comments
- Add `--format` / `-F` option supporting `text` (default, colored),
  `markdown` (GFM table), and `table` (rounded ASCII table) output
- Add `FunctionInfo` and `ParamInfo` structs to `mq-lang` for structured
  module introspection extracted from AST (`Expr::Def` params) and
  source-level `#` doc comments
- Improve `NotDefined` error help to suggest `mq modules` when a
  function is not found
- Update CLI `--help` after_help with `modules` and `-m` usage examples
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 1, 2026

Merging this PR will not alter performance

✅ 29 untouched benchmarks


Comparing feat/add-modules-subcommand-for-built-in-module-discovery (ad85122) with main (728604b)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (856bc2d) during the generation of this report, so 728604b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new mq modules CLI subcommand to discover built-in (standard) modules and list their public functions, signatures, and doc comments by introspecting mq-lang module sources.

Changes:

  • Introduce mq modules subcommand with --format/-F output modes (text, markdown, table).
  • Add module introspection utilities in mq-run that parse standard module AST + extract # doc comments via CST parsing.
  • Expose standard-module loading hooks from mq-lang and enable the cst feature in mq-run to support doc extraction.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
crates/mq-run/src/module_info.rs New module introspection code (AST signatures + CST doc extraction) used by mq modules.
crates/mq-run/src/cli.rs Wires modules subcommand, formatting logic, and adds a basic test.
crates/mq-run/src/lib.rs Registers the new module_info module.
crates/mq-run/Cargo.toml Enables mq-lang’s cst feature and adds rustc-hash dependency.
crates/mq-lang/src/module.rs Adds load_standard_module helper for loading one embedded standard module.
crates/mq-lang/src/lib.rs Re-exports STANDARD_MODULES and load_standard_module from mq-lang.
Cargo.lock Locks the new dependency set (rustc-hash for mq-run).

Comment thread crates/mq-run/src/module_info.rs Outdated
Comment thread crates/mq-run/src/module_info.rs
Comment on lines +108 to +112
.filter_map(|(mod_name, content_fn)| {
let content = content_fn();
let doc_map = extract_doc_comments(content);
let module = mq_lang::load_standard_module(mod_name.as_str())?;

Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

standard_module_functions() currently uses filter_map with load_standard_module(..)?, so any parse/load error will silently drop that module from the listing. That can make mq modules output incomplete without explanation. Consider returning a Result (and surfacing a miette diagnostic in the CLI), or at least including the module name with an error marker/empty function list instead of omitting it.

Copilot uses AI. Check for mistakes.
Comment thread crates/mq-run/src/cli.rs
Comment on lines +491 to +493
let sig = Self::format_function_signature(func);
let desc = func.doc.as_deref().and_then(|d| d.lines().next()).unwrap_or("");
println!("| {} | `{}` | {} |", name, sig, desc);
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print_modules_markdown writes raw module names, signatures, and doc text into a GFM table without escaping. If any value contains |, backticks, or newlines (doc comments often can), the generated table will be malformed. Consider escaping | (e.g. \|), replacing newlines with <br>, and/or wrapping/escaping description text consistently.

Copilot uses AI. Check for mistakes.
Comment thread crates/mq-run/src/cli.rs
Comment thread crates/mq-lang/src/lib.rs
Comment thread crates/mq-lang/src/module.rs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@harehare harehare merged commit 8b6d754 into main May 1, 2026
6 checks passed
@harehare harehare deleted the feat/add-modules-subcommand-for-built-in-module-discovery branch May 1, 2026 23:14
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.

2 participants