Skip to content

Refactor command arguments to enable AI prompts with JupyterGIS#969

Open
arjxn-py wants to merge 67 commits intogeojupyter:mainfrom
arjxn-py:add-describedby
Open

Refactor command arguments to enable AI prompts with JupyterGIS#969
arjxn-py wants to merge 67 commits intogeojupyter:mainfrom
arjxn-py:add-describedby

Conversation

@arjxn-py
Copy link
Member

@arjxn-py arjxn-py commented Oct 28, 2025

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

  • PR has a descriptive title and content.
  • PR description contains references to any issues the PR resolves, e.g. Resolves #XXX.
  • PR has one of the labels: documentation, bug, enhancement, feature, maintenance
  • Checks are passing.
    Failing lint checks can be resolved with:
    • pre-commit run --all-files
    • jlpm run lint

📚 Documentation preview: https://jupytergis--969.org.readthedocs.build/en/969/
💡 JupyterLite preview: https://jupytergis--969.org.readthedocs.build/en/969/lite

@github-actions
Copy link
Contributor

Binder 👈 Launch a Binder on branch arjxn-py/jupytergis/add-describedby

@arjxn-py arjxn-py requested a review from martinRenou October 28, 2025 11:41
@arjxn-py arjxn-py added the documentation Improvements or additions to documentation label Oct 28, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 28, 2025

Integration tests report: appsharing.space

@martinRenou martinRenou changed the title Switch to commands with args Refactor command arguments to enable AI prompts with JupyterGIS Dec 3, 2025
arjxn-py and others added 2 commits February 24, 2026 16:09
Co-authored-by: martinRenou <martin.renou@gmail.com>
@arjxn-py arjxn-py closed this Feb 24, 2026
@arjxn-py arjxn-py reopened this Feb 24, 2026
Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log('zooming');


// ----- PARAMETER MODE -----
if (filePath && layerId) {
console.log(`Zooming to layer: ${layerId}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(`Zooming to layer: ${layerId}`);

return;
}

// ---- PARAMETER MODE ----
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment applies to all similar commands

Suggested change
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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can apply similar changes to the other commands that'd be great 🙏🏽

Suggested change
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) => [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants