feat: implement filesystem-based hierarchical subcommand routing#623
Open
AboMeezO wants to merge 13 commits intoneplextech:mainfrom
Open
feat: implement filesystem-based hierarchical subcommand routing#623AboMeezO wants to merge 13 commits intoneplextech:mainfrom
AboMeezO wants to merge 13 commits intoneplextech:mainfrom
Conversation
…ding for command parsing and routing
…resolution and middleware support
…with middleware support
…g and demo utilities
…mand management and routing
…I utilities for enhanced command management
|
@AboMeezO is attempting to deploy a commit to the Neplex Team on Vercel. A member of the Team first needs to authorize it. |
…command nesting depth across parsers, handlers, and execution contexts.
…mmand discovery and routing conventions
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Implements filesystem-based hierarchical routing for CommandKit commands, allowing [command]/{group}/<leaf> structures to be discovered, compiled into a command tree, and registered/executed consistently across slash + message commands.
Changes:
- Added a command-tree model + router enhancements to discover/validate hierarchical structures and compile executable route keys with middleware chains.
- Refactored command handling + registration to load hierarchical nodes, index executable leaves by route key, and emit correct Discord registration payloads.
- Updated docs/examples/tests (including a test-bot demo) and CI to cover hierarchical routing, parsing, and registration behavior.
Reviewed changes
Copilot reviewed 83 out of 90 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| skills/commandkit/SKILL.md | Adds hierarchical-commands tag + description update. |
| skills/commandkit/references/08-file-naming-conventions.md | Documents new [command]/{group} + definition file conventions. |
| skills/commandkit/references/05-middlewares.md | Documents middleware variants + hierarchical scoping rules. |
| skills/commandkit/references/02-chat-input-command.md | Adds hierarchical command examples + clarifies handler context. |
| skills/commandkit/references/00-filesystem-structure.md | Adds “advanced” hierarchical filesystem structure section. |
| pnpm-lock.yaml | Lockfile updates (notably path-to-regexp resolution). |
| packages/commandkit/src/utils/utilities.ts | Updates debounce behavior to share promises across a debounce window. |
| packages/commandkit/src/utils/dev-hooks.ts | Awaits reload hooks for commands/events in dev HMR flow. |
| packages/commandkit/src/app/router/index.ts | Re-exports CommandTree. |
| packages/commandkit/src/app/router/CommandTree.ts | Introduces tree node/kind/source + compiled route/diagnostic types. |
| packages/commandkit/src/app/router/CommandsRouter.ts | Implements hierarchical filesystem discovery, diagnostics, and compiled route middleware chains. |
| packages/commandkit/src/app/register/CommandRegistrar.ts | Builds hierarchical slash payloads from cached tree nodes + sanitizes runtime-only fields. |
| packages/commandkit/src/app/handlers/AppCommandHandler.ts | Loads hierarchical nodes, indexes runtime routes, resolves message/interaction route keys, updates banner/type generation. |
| packages/commandkit/src/app/commands/MessageCommandParser.ts | Adds full route parsing for colon-delimited message commands. |
| packages/commandkit/src/app/commands/Context.ts | Returns canonical route identifier via __routeKey / full message route resolution. |
| packages/commandkit/src/app/commands/AppCommandRunner.ts | Uses canonical route key for env markers/logging. |
| packages/commandkit/spec/reload-commands.test.ts | Tests reload behavior across flat + hierarchical command additions/removals. |
| packages/commandkit/spec/message-command-parser.test.ts | Adds tests for hierarchical message route parsing. |
| packages/commandkit/spec/hierarchical-command-registration.test.ts | Tests Discord registration payload generation for hierarchical roots/leaves. |
| packages/commandkit/spec/hierarchical-command-handler.test.ts | Tests runtime loading/indexing and middleware chaining for hierarchical leaves. |
| packages/commandkit/spec/context-command-identifier.test.ts | Tests canonical identifier output across prefixes/aliases and hierarchy. |
| packages/commandkit/spec/commands-router.test.ts | Tests hierarchical discovery/diagnostics + compiled middleware chains. |
| package.json | Adds docgen:check and test:commandkit; adjusts pnpm override for path-to-regexp. |
| apps/website/docs/guide/08-advanced/02-file-naming-conventions.mdx | Updates guide to include hierarchical directories + middleware scoping explanations. |
| apps/website/docs/guide/02-commands/09-subcommand-hierarchy.mdx | New guide page describing filesystem-based subcommand hierarchy. |
| apps/website/docs/guide/02-commands/08-middlewares.mdx | Clarifies directory middleware scope (same-directory) + hierarchical leaf semantics. |
| apps/website/docs/guide/02-commands/07-category-directory.mdx | Adds note contrasting categories vs hierarchy. |
| apps/website/docs/api-reference/ratelimit/interfaces/rate-limit-hooks.mdx | Regenerated API docs formatting updates. |
| apps/website/docs/api-reference/ratelimit/functions/resolve-scope-keys.mdx | Regenerated API docs formatting updates. |
| apps/website/docs/api-reference/ratelimit/functions/ratelimit.mdx | Regenerated API docs formatting updates. |
| apps/website/docs/api-reference/ratelimit/functions/build-scope-prefix.mdx | Regenerated API docs formatting updates. |
| apps/website/docs/api-reference/commandkit/types/run-command.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/types/resolvable-command.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/types/message-command-options-schema.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/types/command-type-data.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/types/command-tree-node-source.mdx | New generated API doc for CommandTreeNodeSource. |
| apps/website/docs/api-reference/commandkit/types/command-tree-node-kind.mdx | New generated API doc for CommandTreeNodeKind. |
| apps/website/docs/api-reference/commandkit/types/command-builder-like.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/types/app-command.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/interfaces/simple-proxy.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/interfaces/prepared-app-command-execution.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/interfaces/pre-register-commands-event.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/interfaces/parsed-message-command.mdx | Adds fullRoute property to generated API docs. |
| apps/website/docs/api-reference/commandkit/interfaces/parsed-command-data.mdx | Adds treeNodes/compiledRoutes/diagnostics to generated API docs. |
| apps/website/docs/api-reference/commandkit/interfaces/middleware.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/interfaces/loaded-command.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/interfaces/custom-app-command-props.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/interfaces/compiled-command-route.mdx | New generated API doc for compiled hierarchical routes. |
| apps/website/docs/api-reference/commandkit/interfaces/commands-router-options.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/interfaces/command.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/interfaces/command-tree-node.mdx | New generated API doc for CommandTreeNode. |
| apps/website/docs/api-reference/commandkit/interfaces/command-route-diagnostic.mdx | New generated API doc for diagnostics. |
| apps/website/docs/api-reference/commandkit/interfaces/app-command-native.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/functions/no-build-only.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/functions/json-serialize.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/functions/dev-only.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/functions/defer.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/functions/create-proxy.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/functions/build-only.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/classes/middleware-context.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/classes/message-command-parser.mdx | Regenerated API docs to include getFullRoute. |
| apps/website/docs/api-reference/commandkit/classes/message-command-options.mdx | Regenerated API docs sourceLine updates. |
| apps/website/docs/api-reference/commandkit/classes/commands-router.mdx | Regenerated API docs to reflect new methods/return types. |
| apps/website/docs/api-reference/commandkit/classes/command-registrar.mdx | Regenerated API docs to reflect hierarchical registration. |
| apps/website/docs/api-reference/commandkit/classes/app-command-handler.mdx | Regenerated API docs to reflect runtime route APIs + async signatures. |
| apps/website/docs/api-reference/cache/interfaces/cache-context.mdx | Regenerated cache API docs. |
| apps/website/docs/api-reference/cache/functions/cache.mdx | Regenerated cache API docs. |
| apps/test-bot/src/utils/hierarchical-demo.ts | Adds demo utilities to visualize routes/middleware trace. |
| apps/test-bot/src/app/commands/(hierarchical)/+middleware.ts | Adds category-scoped middleware for hierarchical demo. |
| apps/test-bot/src/app/commands/(hierarchical)/[workspace]/command.ts | Adds workspace hierarchical root definition. |
| apps/test-bot/src/app/commands/(hierarchical)/[workspace]/+middleware.ts | Adds root middleware for workspace. |
| apps/test-bot/src/app/commands/(hierarchical)/[workspace]/{team}/handoff.subcommand.ts | Adds shorthand leaf under second group branch. |
| apps/test-bot/src/app/commands/(hierarchical)/[workspace]/{team}/group.ts | Adds {team} group definition. |
| apps/test-bot/src/app/commands/(hierarchical)/[workspace]/{team}/+middleware.ts | Adds group middleware for {team}. |
| apps/test-bot/src/app/commands/(hierarchical)/[workspace]/{notes}/group.ts | Adds {notes} group definition. |
| apps/test-bot/src/app/commands/(hierarchical)/[workspace]/{notes}/archive/archive.subcommand.ts | Adds archive leaf demo. |
| apps/test-bot/src/app/commands/(hierarchical)/[workspace]/{notes}/archive/+middleware.ts | Adds leaf-dir middleware for archive. |
| apps/test-bot/src/app/commands/(hierarchical)/[workspace]/{notes}/add.subcommand.ts | Adds add leaf demo. |
| apps/test-bot/src/app/commands/(hierarchical)/[workspace]/{notes}/+middleware.ts | Adds group middleware for {notes}. |
| apps/test-bot/src/app/commands/(hierarchical)/[workspace]/{notes}/+add.middleware.ts | Adds same-dir command-scoped middleware for add. |
| apps/test-bot/src/app/commands/(hierarchical)/[ops]/status.subcommand.ts | Adds direct shorthand subcommand demo. |
| apps/test-bot/src/app/commands/(hierarchical)/[ops]/deploy/deploy.subcommand.ts | Adds direct folder-leaf demo content. |
| apps/test-bot/src/app/commands/(hierarchical)/[ops]/deploy/+middleware.ts | Adds leaf-dir middleware for deploy. |
| apps/test-bot/src/app/commands/(hierarchical)/[ops]/command.ts | Adds ops hierarchical root definition. |
| apps/test-bot/src/app/commands/(hierarchical)/[ops]/+status.middleware.ts | Adds command-scoped middleware for status leaf. |
| apps/test-bot/src/app/commands/(hierarchical)/[ops]/+middleware.ts | Adds root middleware for ops. |
| apps/test-bot/src/app/commands/(general)/help.ts | Extends help output with hierarchical routes. |
| apps/test-bot/src/app/commands/(general)/(animal)/cat.ts | Updates context menu name aliases metadata. |
| AGENTS.md | Documents hierarchical discovery tokens for agents/contributors. |
| .github/workflows/code-quality.yaml | Adds CommandKit test + docgen:check steps to CI. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Normalize docs output line endings before writing - Treat prefix-only message inputs as invalid command prefixes - Update parser tests and generated API docs
Member
|
@AboMeezO could you resolve the merge conflict? |
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
Introduces a filesystem-based routing system for Discord commands, enabling hierarchical subcommands and subcommand groups to be defined through directory structure. The system builds a
CommandTreeand resolves it into valid Discord application commands automatically.This update improves modularity, scalability, and command organization while maintaining full backward compatibility with flat command structures.
Key Changes
Filesystem Router
CommandsRouterto resolve directory structure into a command treeCommandTreeto represent hierarchical command relationshipsCommand Registration
AppCommandHandlerto process hierarchical nodesApplicationCommandDatafrom the resolved treeMiddleware System
+middleware.tsat the directory levelMessage Command Support
MessageCommandParserto support hierarchical command pathsTesting & Examples
test-botapplicationImpact