Skip to content

feat: add lfmf and ontology tooling#72

Merged
elasticdotventures merged 7 commits into
mainfrom
feat/lfmf-ontology-tools
May 3, 2026
Merged

feat: add lfmf and ontology tooling#72
elasticdotventures merged 7 commits into
mainfrom
feat/lfmf-ontology-tools

Conversation

@elasticdotventures

Copy link
Copy Markdown
Member

Summary

  • add the new lfmf-counter workspace crate and CLI
  • add the new ontology-extractor workspace crate and CLI
  • wire the workspace and lockfile updates needed for both crates

Notes

  • validated cargo check -p lfmf-counter, cargo test -p lfmf-counter, and cargo check -p ontology-extractor
  • left local scratch files temp_lib.rs and temp_ont.rs out of the PR

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 3, 2026 13:37
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds two new workspace CLI tools: lfmf-counter for tracking/printing lesson counters, and ontology-extractor for extracting Rust AST terms and emitting a simple ontology graph/summary, plus the workspace/lockfile wiring to build them.

Changes:

  • Introduce crates/lfmf-counter library + lfmf-stats CLI for persisting and reporting tool-level counters.
  • Introduce crates/ontology-extractor library + ontology-extractor CLI for walking .rs files, collecting terms, and outputting a summary/JSON graph.
  • Register both crates in the workspace and update Cargo.lock (notably clap).

Reviewed changes

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

Show a summary per file
File Description
crates/ontology-extractor/src/main.rs New CLI entrypoint for running extraction and printing summary/JSON output.
crates/ontology-extractor/src/lib.rs New extraction + graph-building library using walkdir + syn::visit.
crates/ontology-extractor/Cargo.toml New crate manifest and deps for ontology extractor.
crates/lfmf-counter/src/main.rs New lfmf-stats CLI with subcommands for summary/list/problematic/top.
crates/lfmf-counter/src/lib.rs New persistent counter library (serde + json file) and basic tests.
crates/lfmf-counter/Cargo.toml New crate manifest and deps for LFMF counter.
crates/lfmf-counter/.lfmf-counters.json Added sample/state JSON counter file.
Cargo.toml Add the two new crates to workspace members; small comment edit under lints.
Cargo.lock Lockfile updates to include the new crates and bump clap.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +7
[package]
name = "ontology-extractor"
version = "1.8.1"
edition = "2021"
description = "Rust AST extraction for ontological knowledge graph construction"
license = "MIT"

Comment on lines +1 to +7
[package]
name = "lfmf-counter"
version = "1.8.1"
edition = "2021"
description = "LFMF lesson counter with $🦨++ and $🐛++ support"
license = "MIT"

Comment on lines +243 to +249
impl Default for LfmfCounter {
fn default() -> Self {
Self {
counters: HashMap::new(),
storage_path: Self::default_storage_path(),
}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Comment on lines +78 to +89
let tools = counter.get_stats().await?;

if args.sort_by_activity {
let active_tools = counter
.get_tools_by_activity()
.into_iter()
.cloned()
.collect::<Vec<_>>();
print_tools_list(&active_tools, args.show_suggestions, args.limit);
} else {
print_tools_list(&tools, args.show_suggestions, args.limit);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Comment thread Cargo.toml Outdated
Comment thread crates/ontology-extractor/src/lib.rs Outdated
Comment on lines +49 to +67
pub async fn extract_rust_idioms(&self, crate_path: &Path) -> Result<Vec<RustTerm>> {
let mut terms = Vec::new();

for entry in WalkDir::new(crate_path)
.into_iter()
.filter_entry(|entry| entry.file_name() != "target")
{
let entry = entry.context("failed to walk crate path")?;
if !entry.file_type().is_file()
|| entry.path().extension().and_then(|ext| ext.to_str()) != Some("rs")
{
continue;
}

let source = fs::read_to_string(entry.path())
.with_context(|| format!("failed to read {}", entry.path().display()))?;
let syntax = syn::parse_file(&source)
.with_context(|| format!("failed to parse {}", entry.path().display()))?;

Comment thread crates/ontology-extractor/Cargo.toml Outdated
Comment on lines +132 to +134
fn default_storage_path() -> PathBuf {
std::env::current_dir().unwrap().join(COUNTER_FILE)
}
Comment thread crates/lfmf-counter/src/lib.rs Outdated
Comment thread crates/lfmf-counter/src/main.rs Outdated
Comment on lines +40 to +48
// Sort by activity (default) or tool name
#[arg(short, long)]
sort_by_activity: bool,

// Show suggestions for tools
#[arg(short, long)]
show_suggestions: bool,

// Limit number of tools to show
elasticdotventures and others added 3 commits May 3, 2026 23:48
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Brian Horakh <35611074+elasticdotventures@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Brian Horakh <35611074+elasticdotventures@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Brian Horakh <35611074+elasticdotventures@users.noreply.github.com>
@elasticdotventures

Copy link
Copy Markdown
Member Author

@copilot apply changes based on the comments in this thread

Copilot AI and others added 2 commits May 3, 2026 13:52
- Use workspace inheritance (version/edition/license) in both Cargo.toml files
- Add [lints] workspace = true to both crates
- Replace unwrap() with expect() in default_storage_path()
- Use doc comments (///) in ListArgs for clap --help output
- Fix extract_rust_idioms dedup key to include classification (preserves
  distinct items with same name in different namespaces)
- Wrap blocking I/O in spawn_blocking so async runtime is not blocked
- Use eprintln! for verbose status so --format json output stays valid JSON

Agent-Logs-Url: https://github.com/PromptExecution/l3dg3rr/sessions/b4d10f5c-691b-42f3-90f6-c321580465b8

Co-authored-by: elasticdotventures <35611074+elasticdotventures@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PromptExecution/l3dg3rr/sessions/b4d10f5c-691b-42f3-90f6-c321580465b8

Co-authored-by: elasticdotventures <35611074+elasticdotventures@users.noreply.github.com>

Copilot AI commented May 3, 2026

Copy link
Copy Markdown
Contributor

@copilot apply changes based on the comments in this thread

Applied all changes from the review thread (commits 275a567 and 63e3200):

  • Both Cargo.toml files: switched to workspace inheritance (version.workspace, edition.workspace, license.workspace) and added [lints] workspace = true
  • default_storage_path(): replaced unwrap() with expect("cannot determine current directory for counter storage")
  • ListArgs fields: changed // comments to /// doc comments so clap picks them up for --help output
  • extract_rust_idioms dedup: now includes classification in both the sort key and the dedup predicate, so items with the same name in different namespaces (e.g. struct Foo and fn Foo()) are preserved
  • extract_rust_idioms blocking I/O: wrapped the entire walk/read/parse loop in tokio::task::spawn_blocking so the async runtime thread isn't blocked
  • Verbose output: changed initial status println! to eprintln! so --format json output stays valid JSON for downstream consumers; also changed sort to sort_unstable_by per the follow-up review suggestion

@elasticdotventures elasticdotventures merged commit 4ba02a7 into main May 3, 2026
1 check failed
Copilot stopped work on behalf of elasticdotventures due to an error May 3, 2026 15:09
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.

3 participants