Skip to content

Commit c0fbf06

Browse files
CopilotAdam-it
andauthored
Refactors spo_list_remove LM tool. Closes #592 (#635)
## 🎯 Aim Aligns the `spo_list_remove` Language Model Tool with established naming conventions ({verb}_{noun}) and adds support for recycling lists instead of permanent deletion. ## 📷 Result No visual changes - this is a backend tool enhancement for the Language Model Tools. ## ✅ What was done - [x] **Renamed tool**: `spo_list_remove` → `remove_spo_list` - Updated registration in `ChatTools.ts` - Updated metadata in `package.json` - [x] **Added `recycle` parameter**: Optional boolean (default: `false`) to send lists to recycle bin ```typescript interface ISharePointListRemoveParameters { title: string; webUrl: string; recycle?: boolean; // New parameter with default: false } ``` - Always included in CLI command with nullish coalescing operator for default value - Response message reflects action taken (recycled vs. permanently removed) - [x] **Enhanced model description**: Concise documentation covering: - Core functionality (permanent removal vs. recycling based on parameter) - Use cases (cleanup unused lists, remove test data, manage site content) - [x] **Applied review feedback**: - Simplified modelDescription to be more concise - Updated recycle parameter description for clarity - Set default value for recycle to `false` instead of empty string - Refactored code to always include recycle parameter in command inputs ## 🔗 Related issue Follows patterns from PR #596 / issue #586. Fixes #592 <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>💡 [Feature]: Update spo_list_remove Language Model Tool to Follow standards</issue_title> > <issue_description>### 🎯 Aim of the feature > > Refactor the existing `spo_list_remove` Language Model Tool to align with updated naming conventions, improve model descriptions, and add additional list removal options for enhanced SharePoint list management capabilities. > > **Issues to address:** > > - Rename the tool to **remove_spo_list** following the naming convention {verb}_{noun} as established in the codebase > - Improve `modelDescription`: > - What exactly does the tool do? - describe the specific functionality and capabilities > - What kind of information does it return? - detail the expected response format > - When should and shouldn't it be used? - provide clear use cases and scenarios to avoid > - Describe important limitations or constraints of the tool - identify technical and permission limitations > - Refactor [ListRemove](https://github.com/pnp/vscode-viva/blob/dev/src/chat/tools/spo/ListRemove.ts) > - Missing Properties: lets add support for the following options: `recycle` > > Under the hood use: [spo list remove](https://pnp.github.io/cli-microsoft365/cmd/spo/list/list-remove) > > **The issue #586 has been implemented and can be used as a reference to ensure consistency with the correct standards.** > > ### 🤖 Agent info > > - create your feature branch with the implementation based on dev branch. This is a must > - when opening a PR you MUST target dev branch > - similar change was done in this commit 796856b. you must use it as refrence > > ### 🤔 Additional remarks or comments > > - VS Code LM docs: https://code.visualstudio.com/api/extension-guides/tools > - CLI for Microsoft 365 Reference: https://pnp.github.io/cli-microsoft365/cmd/spo/list/list-remove</issue_description> > > <agent_instructions>don't forget your feature branch MUST be created based on dev branch and NOT main. > </agent_instructions> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> - Fixes #592 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Adam-it <[email protected]> Co-authored-by: Adam Wójcik <[email protected]>
1 parent d670c21 commit c0fbf06

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

npm-shrinkwrap.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,16 @@
298298
}
299299
},
300300
{
301-
"name": "spo_list_remove",
301+
"name": "remove_spo_list",
302302
"tags": [
303303
"sharepoint",
304304
"list",
305305
"spfx-toolkit"
306306
],
307307
"toolReferenceName": "SharePointListRemove",
308308
"displayName": "Remove a SharePoint list",
309-
"modelDescription": "Removes the specified list. This tool may be used to remove a SharePoint list from a site.",
310-
"userDescription": "Removes the specified list.",
309+
"modelDescription": "This tool deletes lists from SharePoint Online sites, either sending them to the site's recycle bin (when recycle is true) or permanently removing them (when recycle is false or omitted). Use this tool to clean up unused lists, remove test data, or manage site content.",
310+
"userDescription": "Removes the specified list from the site.",
311311
"canBeReferencedInPrompt": true,
312312
"icon": "$(trash)",
313313
"inputSchema": {
@@ -322,6 +322,11 @@
322322
"type": "string",
323323
"description": "URL of the site where the list to remove is located. This option is required.",
324324
"default": ""
325+
},
326+
"recycle": {
327+
"type": "boolean",
328+
"description": "When set to true, sends the list to the site's recycle bin instead of permanently removing it. This option is optional.",
329+
"default": false
325330
}
326331
}
327332
}
@@ -1304,7 +1309,7 @@
13041309
},
13051310
"dependencies": {
13061311
"@grconrad/vscode-extension-feedback": "^1.0.0",
1307-
"@pnp/cli-microsoft365-spfx-toolkit": "1.4.0",
1312+
"@pnp/cli-microsoft365-spfx-toolkit": "1.5.0",
13081313
"node-forge": "1.3.1",
13091314
"react-markdown": "10.1.0",
13101315
"remark-gfm": "4.0.1",

src/chat/tools/ChatTools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class ChatTools {
3131
lm.registerTool('spo_list_get', new SharePointListGet())
3232
);
3333
subscriptions.push(
34-
lm.registerTool('spo_list_remove', new SharePointListRemove())
34+
lm.registerTool('remove_spo_list', new SharePointListRemove())
3535
);
3636
subscriptions.push(
3737
lm.registerTool('add_spo_page', new SharePointPageAdd())

src/chat/tools/spo/list/ListRemove.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { validateAuth } from '../utils/ToolAuthValidationUtil';
66
interface ISharePointListRemoveParameters {
77
title: string;
88
webUrl: string;
9+
recycle?: boolean;
910
}
1011

1112
export class SharePointListRemove implements LanguageModelTool<ISharePointListRemoveParameters> {
@@ -22,13 +23,15 @@ export class SharePointListRemove implements LanguageModelTool<ISharePointListRe
2223
const result = await CliExecuter.execute('spo list remove', 'json', {
2324
title: params.title,
2425
webUrl: params.webUrl,
26+
recycle: params.recycle ?? false,
2527
force: true
2628
});
2729
if (result.stderr) {
2830
return new LanguageModelToolResult([new LanguageModelTextPart(`Error: ${result.stderr}`)]);
2931
}
3032

31-
return new LanguageModelToolResult([new LanguageModelTextPart(`List removed successfully ${(result.stdout !== '' ? `\nResult: ${result.stdout}` : '')}`)]);
33+
const recycleAction = params.recycle ? 'recycled' : 'permanently removed';
34+
return new LanguageModelToolResult([new LanguageModelTextPart(`List ${recycleAction} successfully ${(result.stdout !== '' ? `\nResult: ${result.stdout}` : '')}`)]);
3235
}
3336

3437
async prepareInvocation(

0 commit comments

Comments
 (0)