Add Tcl 'trace' command completions and dynamic rules #65

Merged
Christoph merged 1 commit from 61-trace-has-no-options into main 2026-10-10 16:10:48 +00:00
Owner

This change adds completions and dynamic completion rules for the Tcl trace command in server/src/tools/tcl_command_completion.py so that subcommands, mode values and argument kinds are suggested while composing trace invocations.

Summary of changes

  • Register trace subcommands in SUBCOMMANDS_BY_PATH:

    • ("trace",) -> ("add", "info", "remove")
    • ("trace", "add"), ("trace","info"), ("trace","remove") -> ("command","execution","variable")
  • Provide concrete value suggestions at position 4 (VALUES_BY_POSITION) for the different trace kinds:

    • trace ... command -> ("rename", "delete")
    • trace ... execution -> ("enter", "leave", "enterstep", "leavestep")
    • trace ... variable -> ("array", "read", "write", "unset")
    • The same sets are added for remove as well as add.
  • Add dynamic completion rules (DYNAMIC_COMPLETION_RULES) to suggest argument kinds at position 3 (index frozenset({3})):

    • For trace <add|info|remove> variable use DynamicCompletionKind.VARIABLE.
    • For trace <add|info|remove> command and trace <add|info|remove> execution use DynamicCompletionKind.PROCEDURE.

Concrete before/after behavior

  • Before: trace had no dedicated entries in the completion tables, so the completion system would not offer the subcommands, mode tokens, or context-sensitive argument completions for trace invocations.
  • After: the completion engine will offer add|info|remove as trace subcommands, suggest command|execution|variable for those subcommands, suggest the specific mode tokens at the fourth token, and provide dynamic suggestions of variable names or procedure names at the third argument depending on the chosen kind.

Tests

No test execution results were provided.

Recommended manual checks for the reviewer

  1. Confirm SUBCOMMANDS_BY_PATH contains the three trace subcommand entries and that they appear in the completion UI for trace.
  2. Verify that after typing trace add command <TAB> (or the completion entry point for token index 3) the completion system proposes procedures, and that trace add variable <TAB> proposes variable names.
  3. Check that the mode tokens (rename, delete, enter, leave, enterstep, leavestep, array, read, write, unset) are suggested at the fourth token where VALUES_BY_POSITION entries were added.

Compatibility / notes for reviewers

  • The change is limited to the completion metadata in tcl_command_completion.py and does not alter runtime Tcl behavior.
  • Pay attention to the token index usage: dynamic rules use index 3 (the argument to be completed), while VALUES_BY_POSITION entries target index 4 for mode tokens. Ensure these indices match the completion engine's token indexing.

If you want, I can add a short script or reproducible completion examples that invoke the completion routines on example inputs to make manual verification faster.

Closes #61

This change adds completions and dynamic completion rules for the Tcl `trace` command in `server/src/tools/tcl_command_completion.py` so that subcommands, mode values and argument kinds are suggested while composing `trace` invocations. Summary of changes - Register `trace` subcommands in `SUBCOMMANDS_BY_PATH`: - `("trace",) -> ("add", "info", "remove")` - `("trace", "add")`, `("trace","info")`, `("trace","remove") -> ("command","execution","variable")` - Provide concrete value suggestions at position 4 (`VALUES_BY_POSITION`) for the different `trace` kinds: - `trace ... command` -> `("rename", "delete")` - `trace ... execution` -> `("enter", "leave", "enterstep", "leavestep")` - `trace ... variable` -> `("array", "read", "write", "unset")` - The same sets are added for `remove` as well as `add`. - Add dynamic completion rules (`DYNAMIC_COMPLETION_RULES`) to suggest argument kinds at position 3 (index `frozenset({3})`): - For `trace <add|info|remove> variable` use `DynamicCompletionKind.VARIABLE`. - For `trace <add|info|remove> command` and `trace <add|info|remove> execution` use `DynamicCompletionKind.PROCEDURE`. Concrete before/after behavior - Before: `trace` had no dedicated entries in the completion tables, so the completion system would not offer the subcommands, mode tokens, or context-sensitive argument completions for `trace` invocations. - After: the completion engine will offer `add|info|remove` as `trace` subcommands, suggest `command|execution|variable` for those subcommands, suggest the specific mode tokens at the fourth token, and provide dynamic suggestions of variable names or procedure names at the third argument depending on the chosen kind. Tests No test execution results were provided. Recommended manual checks for the reviewer 1. Confirm `SUBCOMMANDS_BY_PATH` contains the three `trace` subcommand entries and that they appear in the completion UI for `trace`. 2. Verify that after typing `trace add command <TAB>` (or the completion entry point for token index 3) the completion system proposes procedures, and that `trace add variable <TAB>` proposes variable names. 3. Check that the mode tokens (`rename`, `delete`, `enter`, `leave`, `enterstep`, `leavestep`, `array`, `read`, `write`, `unset`) are suggested at the fourth token where `VALUES_BY_POSITION` entries were added. Compatibility / notes for reviewers - The change is limited to the completion metadata in `tcl_command_completion.py` and does not alter runtime Tcl behavior. - Pay attention to the token index usage: dynamic rules use index `3` (the argument to be completed), while `VALUES_BY_POSITION` entries target index `4` for mode tokens. Ensure these indices match the completion engine's token indexing. If you want, I can add a short script or reproducible completion examples that invoke the completion routines on example inputs to make manual verification faster. Closes #61
feat(tcl-completion): add completions and dynamic rules for trace
All checks were successful
Tests / node (pull_request) Successful in 31s
Tests / python (pull_request) Successful in 32s
ac736fff86
Add "trace" subcommands (add, info, remove) and their kinds
(command, execution, variable) to static completion tables. Provide
position-specific value suggestions for each kind (e.g. "rename",
"delete" for command; "enter", "leave", "enterstep", "leavestep" for
execution; "array", "read", "write", "unset" for variable).

Register dynamic completion rules so the appropriate trace argument
positions complete as VARIABLE or PROCEDURE where applicable. This enables
context-aware name suggestions when using trace add/info/remove.

Fixes #61
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Christoph/nx_post_support!65
No description provided.