Repository navigation
feat: merge skills across workspace directories - #4520
Conversation
🦋 Changeset detectedLatest commit: 3b1935c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 618c4f4fa9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d850028357
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 628f3fd494
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| this.workspaceDirs.primaryByWorkspace[this.workspace.workspaceId] ?? this.workspace.cwd; | ||
| return [primary, this.workspace.cwd, ...this.workspaceDirs.sharedAdditionalDirs]; |
There was a problem hiding this comment.
Retain the promoted primary after removing the old root
When a live managed workspace promotes B from additional directory to primary and then removes the old primary A from its directory set, the directory service still filters registry entries by the immutable workspace.cwd A and consequently drops the workspace's primaryByWorkspace mapping. This fallback then makes the Skill source scan only A, losing B and all remaining configured sources for existing sessions. Fresh evidence beyond the prior primary-promotion finding is the subsequent supported removal of A; derive the current managed workspace by ID even when its updated directory set no longer contains the program's original cwd.
Useful? React with 👍 / 👎.
| const skills = ( | ||
| await listWorkspaceSkillsForRoots(core, ws.root, ws.additionalDirs) | ||
| ).map(toProtocolSkill); |
There was a problem hiding this comment.
Include local-config dirs in implicit workspace previews
When an implicit or legacy workspace has additional directories declared in .kimi-code/local.toml, WorkspaceDirsService loads them into fileDirs, but the persisted workspace record's additionalDirs remains empty. This route now scans only ws.root and that registry field, so GET /workspaces/{id}/skills omits the local-config Skills even though sessions for the same workspace load and can invoke them. Build the preview from the live workspace catalog or merge readProjectConfigDirs() into the roots passed here.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1d697f866
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
There was a problem hiding this comment.
💡 Codex Review
When a configured workspace directory is large or on a stalled network mount, this full workspace rediscovery can block getWorkspaceTrustInfo() and the TUI trust prompt indefinitely because it is awaited before describeInstructionSources() reaches the existing one-second waitForReady fallback. Fresh evidence beyond the earlier pending-directory timeout comment is that the final code removed that scan but now awaits reloadSources(['workspace']) outside the timeout; include this reload in the bounded wait and return the loading warning when it expires.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
For the pre-disclosure workspace reload timeout: acknowledged, but we are deferring this hardening follow-up for now and leaving the current behavior unchanged in this PR. |
Workspace skill discovery read `[cwd, ...additionalDirs]`, and `additionalDirs` folds in the ephemeral, reference-counted directories a session adds for the duration of a call. A one-off `--add-dir` therefore reached workspace skill discovery, and the registry's primary directory was never consulted, so a workspace whose primary root differs from the session cwd only saw the cwd's skills. `IWorkspaceDirs` now separates `sharedAdditionalDirs` (file + registry directories, the ones that belong to the workspace itself) from `additionalDirs` (that set plus the ephemeral ones), and exposes `primaryByWorkspace`. Discovery walks `primaryByWorkspace[workspaceId] → cwd → sharedAdditionalDirs` and dedupes by root path, and the file watcher follows every project root it discovered instead of the cwd's alone — its signature now covers the watch set, so a newly added directory replaces the watchers rather than being ignored. The change-detection baselines in `setFileDirs` and `reloadFromRegistry` move to `sharedAdditionalDirs` as well: an ephemeral add or release still fires through `additionalDirs`, but must not mask a real workspace-directory change. Verified: agent-core-v2 typecheck clean, check-no-comments clean; skill + workspace suites 466 pass. Reverting `workDirs` to `additionalDirs` reddens `merges skills across shared workspace directories and skips session-only ones`; restoring it is green. Still open for MoonshotAI#4520: the kap-server skills route, the CLI/TUI call sites, the trust disclosure and the bilingual docs.
… directory The pre-trust disclosure resolved project skill roots from the session cwd alone, so a workspace registered with additional directories showed fewer outside-the-project skill roots than trusting it would actually activate, and the extra directories themselves were missing from the directory list unless the local config also named them. `WorkspaceTrustDisclosureService` now takes `IWorkspaceDirs`, waits for it, reloads the workspace skill source before describing anything, and resolves both the skill roots and the disclosed directories across `sharedAdditionalDirs` — deduplicated by real path, so a directory that a `settings.local.json` entry and the workspace registry both name appears once. Local-form note: upstream threads *pending* directories from `getWorkspaceTrustInfo(workDir, options)` through `Program.acquireWorkdir`/`ProgramWorkdirs` and resolves them inside the service. The fork has neither `ProgramWorkdirs` nor a `WorkspaceTrustInfoOptions` type, so this change discloses the directories the workspace already has instead of adding an option nobody can supply yet. Directories that are still unregistered remain outside the disclosure — recorded as the remaining gap for MoonshotAI#4520. Verified: agent-core-v2 typecheck clean, workspaceTrust + skill suites 167 pass, node-sdk suite 78 pass / 3 skip, apps/kimi-code typecheck clean. This path has no direct unit test in the tree (the disclosure unit suite was dropped in favour of SDK e2e coverage, and the local trust e2e cases are skipped); the behaviour it relies on — `projectRootsForDirs` over `sharedAdditionalDirs` — is the one pinned by `merges skills across shared workspace directories and skips session-only ones`.
…te gap Multi-directory skill discovery, the route that lists a workspace's skills, the trust disclosure and the bilingual docs are in. The pending (unregistered) directory branch of the disclosure stays unported: it needs `getWorkspaceTrustInfo(workDir, options)` and `ProgramWorkdirs`, neither of which exists here, and no caller could supply the option. The row stays in_progress until the changeset wording is confirmed and the verdict is signed off.
Multi-directory skill discovery, the workspace skills route, the trust disclosure including pending directories, and the bilingual docs are in. The one local-form divergence — resolving pending directories inside the disclosure service instead of through ProgramWorkdirs — is recorded on the row.
Ports the docs half of upstream MoonshotAI/kimi-code 8b6a003 (MoonshotAI#4673): the 2.5.0 section from the upstream release notes lands in both changelogs, en and zh, word for word. Every feature the section names is in this tree - busy /model and /effort (MoonshotAI#4621), merged project-level skills (MoonshotAI#4520), remote sessions in SSH, Docker and custom-command environments (MoonshotAI#4062), [workspace] require_trust (MoonshotAI#4517), web search off by default (MoonshotAI#4516), and the subagent model pool (MoonshotAI#4418) - so the notes describe what the fork actually does. Deliberately not touched: apps/kimi-code/CHANGELOG.md still tops out at 2.4.1 and package.json still says 2.4.1. That file is generated by `changeset version`, this tree has 377 pending changesets, and AGENTS.md forbids running version or publish from this repository, so the entry is written on the docs side only. Whoever next cuts a release here should reconcile this section with what changeset version generates rather than re-deriving it by hand.
Both failures are stale expectations, not runtime regressions. The Memory tool description was recorded with CRLF escapes from a checkout made before the repository enforced '* text=auto eol=lf', so any canonical LF checkout saw a different byte sequence. The Skill tool's optional path parameter landed in 9db956b (MoonshotAI#4520 port) without refreshing the inline snapshots that embed the tool schema. The snapshots now carry the canonical LF text and the path parameter; tool.test.ts and loop.test.ts pass on a clean HEAD worktree.
Requirement or Bug
Support Skills from every configured source directory in multi-directory workspaces.
Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
The existing catalog remains the single source for listing, slash activation, and model invocation. No REST response schema or Skill source type was added. Session-only directories continue to grant file access but do not contribute Skills; remembering a directory in the workspace makes it a shared source directory. Live primary changes update collision precedence without rebuilding the program. English and Chinese documentation describes the configured-directory boundary.
Behavior Changes and Affected Users
--add-dirand SDK create/resume/add-dir callersskillDirsdiscoveryAffected modules and coverage:
agent-core-v2: shared directory separation, ordered discovery, watch/reload, primary changes, trust disclosure, and session lifecycle.node-sdk: session A/B isolation, workspace preview, and trust disclosure for absolute, relative, and home-relative session-only paths.kap-server: workspace/session Skills and activation through the existing APIs.agent-core-v2,node-sdk,kap-server, and the CLI passed. Targeted lint had no errors. Full suites were not run locally; PR CI remains the full-suite gate.Checklist
gen-changesetsskill, or this PR needs no changeset.