Refactor command arguments to enable AI prompts with JupyterGIS#969
Refactor command arguments to enable AI prompts with JupyterGIS#969arjxn-py wants to merge 67 commits intogeojupyter:mainfrom
Conversation
|
Integration tests report: appsharing.space |
e51aa4c to
1716ab8
Compare
Co-authored-by: martinRenou <martin.renou@gmail.com>
martinRenou
left a comment
There was a problem hiding this comment.
Thanks Arjun! I think we can reduce code duplication a bit more.
| const layerId = Object.keys(selectedItems)[0]; | ||
| model.centerOnPosition(layerId); | ||
| const selLayerId = Object.keys(selectedItems)[0]; | ||
| console.log('zooming'); |
There was a problem hiding this comment.
| console.log('zooming'); |
|
|
||
| // ----- PARAMETER MODE ----- | ||
| if (filePath && layerId) { | ||
| console.log(`Zooming to layer: ${layerId}`); |
There was a problem hiding this comment.
| console.log(`Zooming to layer: ${layerId}`); |
| return; | ||
| } | ||
|
|
||
| // ---- PARAMETER MODE ---- |
There was a problem hiding this comment.
This is a very nitpicky comment sorry for this, I don't like these comments, they don't add much explanation of what is going on. It's more noise than anything IMO.
| execute: args => { | ||
| const model = tracker.currentWidget?.model; | ||
| const groupName = args['label'] as string; | ||
| describedBy: { |
There was a problem hiding this comment.
We should have a caption entry in all those commands, to bring more information that the AI can use. This will make the AI more performant, it can figure out which command it needs to run depending on the task it's trying to achieve.
For example here:
| describedBy: { | |
| caption: `Group layers together in a new group with name "groupName" for the JupyterGIS document "filepath"` | |
| describedBy: { |
Also it seems the label is wrong here? Should it be Move To Group instead of root?
| commands.addCommand(CommandIDs.newGeoTiffEntry, { | ||
| label: trans.__('New GeoTiff layer'), | ||
| commands.addCommand(CommandIDs.openNewGeoTiffDialog, { | ||
| label: trans.__('Open New GeoTiff Dialog'), |
There was a problem hiding this comment.
This comment applies to all similar commands
| label: trans.__('Open New GeoTiff Dialog'), | |
| label: trans.__('Open New GeoTiff Layer Creation Dialog'), |
| { | ||
| id: LayerCreationCommandIDs.newGeoJSONWithParams, | ||
| label: 'New GeoJSON Layer From Parameters', | ||
| caption: 'Create a GeoJSON vector layer from a file path or URL', |
There was a problem hiding this comment.
If you can apply similar changes to the other commands that'd be great 🙏🏽
| caption: 'Create a GeoJSON vector layer from a file path or URL', | |
| caption: 'Add a new GeoJSON vector layer (by file path or URL) and add it to the given JupyterGIS file', |
| sqlQueryFn: (layer, p) => | ||
| replaceInSql(proc.operations.sql, p, layer), | ||
| gdalFunction: 'ogr2ogr', | ||
| gdalOptions: (sql: string) => [ |
There was a problem hiding this comment.
I really want this to not be in two places. Since the processing task is the same, only the place from where we pick the model changes, I see no reason to have this code copy pasted.
Description
Port jupytercad/JupyterCAD#782 & jupytercad/JupyterCAD#783
This adds JupyterGIS commands to support argument-based execution (commandWithParams pattern) across document and processing actions.
It enables programmatic invocation of commands (e.g., from MCP agents, chatbots, or automation layers).
Rough demo:
Screen.Recording.2025-11-12.at.15.44.47.mp4
Checklist
Resolves #XXX.Failing lint checks can be resolved with:
pre-commit run --all-filesjlpm run lint📚 Documentation preview: https://jupytergis--969.org.readthedocs.build/en/969/
💡 JupyterLite preview: https://jupytergis--969.org.readthedocs.build/en/969/lite