@@ -10,15 +10,12 @@ for the frontend extension.
1010
1111## Features
1212
13- - ** Document Management** : Open documents in JupyterLab with various layout modes
14- - ** Markdown Preview** : Open markdown files in rendered preview mode
15- - ** Notebook Operations** : Clear outputs and show diffs for notebooks
16- - ** Jupyter AI Integration** : Tools available for use with Jupyter AI
13+ - ** Command Discovery** : List all available JupyterLab commands with their metadata
14+ - ** Command Execution** : Execute any JupyterLab command programmatically from Python
1715
1816## Requirements
1917
20- - JupyterLab >= 4.0.0
21- - jupyter-ai (for AI toolkit functionality)
18+ - JupyterLab >= 4.5.0a3
2219
2320## Install
2421
@@ -30,47 +27,29 @@ pip install jupyterlab_commands_toolkit
3027
3128## Usage
3229
33- ### With Jupyter AI
34-
35- The extension provides a toolkit for Jupyter AI with the following tools:
36-
37- 1 . ** open_document_tool** : Open documents in JupyterLab with various layout modes
38- 2 . ** open_markdown_preview_tool** : Open markdown files in rendered preview mode
39- 3 . ** clear_notebook_outputs_tool** : Clear all outputs in the active notebook
40- 4 . ** show_notebook_diff_tool** : Show git diff for the current notebook using nbdime
30+ Use the toolkit to execute any JupyterLab command from Python:
4131
4232``` python
43- # Access the AI toolkit
44- from jupyterlab_commands_toolkit import ai_toolkit
33+ import asyncio
34+ from jupyterlab_commands_toolkit.tools import execute_command, list_all_commands
4535
46- # The toolkit is automatically available to Jupyter AI when installed
47- ```
36+ # Execute a command (requires running in an async context)
37+ async def main ():
38+ # List all available commands
39+ commands = await list_all_commands()
4840
49- ### Direct Usage
41+ # Toggle the file browser
42+ result = await execute_command(" filebrowser:toggle-main" )
5043
51- You can also use the commands directly:
52-
53- ``` python
54- from jupyterlab_commands_toolkit.tools import (
55- open_document,
56- open_markdown_file_in_preview_mode,
57- clear_all_outputs_in_notebook,
58- show_diff_of_current_notebook
59- )
44+ # Run notebook cells
45+ result = await execute_command(" notebook:run-all-cells" )
6046
61- # Open a document
62- open_document(" notebook.ipynb" , mode = " split-right" )
63-
64- # Open markdown in preview
65- open_markdown_file_in_preview_mode(" README.md" )
66-
67- # Clear notebook outputs
68- clear_all_outputs_in_notebook(True )
69-
70- # Show notebook diff
71- show_diff_of_current_notebook(True )
47+ # Run in JupyterLab environment
48+ asyncio.run(main())
7249```
7350
51+ For a full list of available commands in JupyterLab, refer to the [ JupyterLab Command Registry documentation] ( https://jupyterlab.readthedocs.io/en/latest/user/commands.html#commands-list ) .
52+
7453## Uninstall
7554
7655To remove the extension, execute:
0 commit comments