feat: tb wc with POSIX flags, glob, recursive walk, and MCP support - #5
Open
Citizen4our wants to merge 1 commit into
Open
feat: tb wc with POSIX flags, glob, recursive walk, and MCP support#5Citizen4our wants to merge 1 commit into
Citizen4our wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends
tb wcto GNU/POSIX-like behaviour:-l/-w/-c/-mflags, final-segment glob, recursive directory walk (-r), a single JSON-RPC round-trip per invocation, and an updated MCP tool with catalog examples. Path resolution and metric filtering live in the library crate; CLI, shell, RPC, and MCP share the same semantics and response shapes.Motivation
tb wc -l /docs/*did not behave like users expect from Linuxwc(glob was only partially handled on the CLI read path, not in server-sidewc).is a directory) and a hint to use-rwhen a glob matches directories only.wcwith documented request/response examples.Changes
Library (
tabularium)glob_path.rs(new)path_is_directory, recursive file collection,resolve_wc_file_pathswc.rs(new)WcMetricsFilter, JSON helpers,sum_wc_stats, unit testsrpc/client.rsClient::wc(), typesWcResponse/WcMetrics/WcFileEntry; legacydocument_wckeptCargo.tomlglobsetunder featuredbdb/meta.rsWcStats::from_totalsServer (
tabularium-server)web.rswc: glob,recursive, metric flags;{ files, total }only when two or more files resolvemcp.rsWcArg, expanded catalog and#[tool(description)]with examplesres/mcp/help.txtwcparagraphtests/text_ops.rsCLI (
tabularium-cli)main.rsWcflags and-r; cleaner error output viaprint_cli_messageexecute.rsclient.wc()call; GNU/TTY formatting; sharedprint_cli_messageshell.rsflags_for("wc"), parse tests, errors viaprint_cli_messageCargo.tomlglobsetdependency (via library)Tests & docs
tests/test_cli_wc.py(new) — glob, directory error, recursive glob, single-file-ldocs/json-rpc-methods.md— updatedwcparams and responseRefactors
wc.rs(wc_metrics_object,format_optional_counts,column_labels)print_wc_gnu_linein CLIpaths.len() > 1(one glob match → flat object, same as a literal path)invalid input:/not found:prefixes)Behaviour
tb wc -l /docs/readme.mdtb wc -l '/docs/*'totaltb wc -l /projects/bmsis a directory+ hint to use-rtb wc -l -r 'projects/bms/*'totaltb wc -l -r /projects/bmstotal{ lines: … }(not batch){ files: [...], total: {...} }Defaults: no flags → GNU columns
lines,words,bytes.-c= UTF-8 byte length (POSIX);-m= Unicode scalar count.API notes
document_wc()without metric flags still returns all four fields in a flat object.WcArgwith optional booleans; explicitfalseis not sent on the wire.check_read(parent)first, then per-filecheck_read(fail-fast on first denial).document_wc. Design note in Tabularium KB:/projects/tabularium/design/wc-performance.md.