Add knip library to detect unused dependencies, exports, and files#915
Merged
Add knip library to detect unused dependencies, exports, and files#915
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR integrates the knip library to automatically detect and remove unused dependencies, exports, and files across the monorepo. The changes include adding knip configuration, integrating it into the CI workflow, removing dead code identified by knip analysis, and fixing missing dependency declarations that were being used but not properly declared.
Changes:
- Added knip library with configuration (knip.jsonc) to detect unused dependencies, exports, and files
- Removed unused exports and entire unused files (DoOnce export, TaskModuleInvokeNames export, Messages class, TemplateInterface)
- Added missing dependencies across test-agents and packages that were being used but not declared in package.json
- Fixed incorrect package name reference in test-agents/copilotstudio-console and corrected bundle script path in test-agents/application-style
Reviewed changes
Copilot reviewed 29 out of 31 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| knip.jsonc | Configuration for knip to define workspaces, entry points, and exclusions |
| .vscode/extensions.json | Added knip VS Code extension recommendation |
| .github/workflows/ci.yml | Integrated knip validation into CI pipeline |
| package.json | Added knip dependency, new lint scripts, and @rushstack/terminal peer dependency |
| package-lock.json | Updated lockfile with knip and its dependencies, removed unused global package |
| packages/agents-hosting-storage-cosmos/src/cosmosDbPartitionedStorage.ts | Changed DoOnce class from exported to internal-only |
| packages/agents-hosting-storage-cosmos/package.json | Added missing @microsoft/agents-activity dependency |
| packages/agents-hosting-storage-blob/package.json | Added missing dependencies (@azure/core-auth, @microsoft/agents-activity, zod) |
| packages/agents-hosting-extensions-teams/src/taskModule/taskModule.ts | Changed TaskModuleInvokeNames from exported enum to internal-only |
| packages/agents-hosting-extensions-teams/src/messages/messages.ts | Removed entire unused Messages class file |
| packages/agents-hosting-extensions-teams/src/messageExtension/messagingExtensionAction.ts | Fixed import path to use index barrel export |
| packages/agents-hosting-extensions-teams/package.json | Added missing dependencies (axios, @microsoft/agents-activity, zod) |
| packages/agents-hosting-dialogs/src/template.ts | Removed entire unused TemplateInterface file |
| packages/agents-hosting-dialogs/src/dialogHelper.ts | Changed getActiveDialogContext from exported to internal-only |
| packages/agents-hosting-dialogs/src/choices/findValues.ts | Removed unnecessary @internal comment from exported function |
| packages/agents-hosting-dialogs/package.json | Added missing dependencies (@microsoft/agents-activity, zod) |
| packages/agents-activity/test/activity/activity.treatment.test.ts | Added test to verify ActivityTreatments enum is part of public API |
| packages/agents-activity/src/entity/productInfo.ts | Changed ProductInfo interface from exported to internal-only |
| packages/agents-activity/src/conversation/membershipTypes.ts | Removed unused Zod schema export |
| packages/agents-activity/src/conversation/membershipSourceTypes.ts | Removed unused Zod schema export |
| packages/agents-activity/src/conversation/membershipSource.ts | Removed unused Zod schema exports and imports |
| packages/agents-activity/src/activityTreatments.ts | Removed unused Zod schema export |
| test-agents/web-chat/package.json | Added missing dependencies (@microsoft/agents-activity, axios) |
| test-agents/state-agent/package.json | Added missing @microsoft/agents-hosting dependency |
| test-agents/root-agent/package.json | Added missing dependencies (@microsoft/agents-activity, @microsoft/agents-hosting-storage-blob) |
| test-agents/multi-turn-prompt/package.json | Added missing dependencies (@microsoft/agents-hosting, @microsoft/agents-activity) |
| test-agents/empty-agent/package.json | Added missing @microsoft/agents-hosting dependency |
| test-agents/custom-dialogs/package.json | Added missing dependencies (@microsoft/agents-hosting, @microsoft/agents-activity) |
| test-agents/copilotstudio-console/package.json | Fixed incorrect package name from @microsoft/agents-copilot-studio to @microsoft/agents-copilotstudio-client |
| test-agents/application-style/package.json | Fixed bundle script to point to index.ts instead of index.js, added missing dependencies |
| test-agents/agentic-ai/package.json | Added missing @microsoft/agents-hosting dependency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
benbrown
previously approved these changes
Feb 17, 2026
benbrown
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue #889
Description
This PR adds the knip library to detect unused dependencies, exports, and files. Also detecting when dependencies are being used across the codebase, but not declared in the package.json.
Note
This library was added to run in the CI workflow and to the recommended extension in vscode.
Why Are We Removing These?
After running knip analysis, each flagged item was manually reviewed and confirmed that:
Testing
The following image shows the knip tool detection.
