Skip to content

feat: merge skills across workspace directories - #4520

Merged
liruifengv merged 9 commits into
mainfrom
feat/multi-root-workspace-skills-bump
Oct 30, 2026
Merged

liruifengv merged 9 commits into
mainfrom
feat/multi-root-workspace-skills-bump

Conversation

@liruifengv

@liruifengv liruifengv commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

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

 workspaceDirs
+  sharedAdditionalDirs = local config + workspace registry
   additionalDirs = shared + session-only dirs (file access behavior unchanged)

 workspace Skill catalog
+  scan [currentPrimary, originalCwd, ...sharedAdditionalDirs]
+  watch and reload every configured source directory
+  preserve current-primary and workspace-order collision precedence
   session-only dirs
+  exclude them from the shared Skill catalog

 workspace preview and session activation
   use the same merged catalog

 trust disclosure
+  resolve pending dirs with the same helper as session creation
+  disclose session-only directory access without discovering their Skills

 session creation
   await workspace reload after merging additional dirs

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

Behavior Before After Who relies on the old behavior Escape hatch
Multi-directory Skill discovery Only the primary directory contributed project Skills Every configured source directory contributes project Skills Desktop/Web multi-directory projects and TUI/SDK workspaces Not required; this is additive
Duplicate names across source directories Only the primary definition was visible Current primary wins; additional directories use workspace order Projects defining the same Skill in multiple source directories Not required; deterministic precedence
Skill watch and reload Primary-directory changes reloaded the catalog Changes in any configured source directory reload it; shared directory add/remove and primary changes also refresh it Long-lived sessions editing project Skills Not required
Session-only additional directories They did not contribute project Skills They remain excluded from the Skill catalog and cannot leak into other sessions TUI --add-dir and SDK create/resume/add-dir callers Remember the directory in the workspace to include its Skills
Workspace preview and trust disclosure Preview and disclosure covered the primary directory Preview includes configured source directories; trust discloses their Skills and normalized session-only directory paths, but not session-only Skills Desktop/Web new-session and TUI/SDK trust flows No schema or trust-decision change
Session creation Skill reload could finish after the first Skill read Workspace reload is awaited before session scope creation, with the existing failure tolerance retained TUI and SDK create/resume callers Existing reload failure behavior is unchanged
Single-directory and explicit skillDirs discovery Existing behavior Unchanged TUI, CLI, VS Code, ACP, SDK, Desktop, and Web users with one root or explicit Skill directories N/A

Affected 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.
  • Latest targeted runs passed 416 core tests, including 27 workspace catalog, 22 workspace trust, 14 workspace directory, 96 workspace filesystem, 12 session Skills, 85 v2 SDK, 26 server Skills, and 127 TUI startup tests.
  • TypeScript checks for 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.
  • English and Chinese Skills documentation and the changeset were updated for configured source directories.

Checklist

  • I have read the CONTRIBUTING document.
  • Related issue: N/A (direct feature request).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Updated the English and Chinese Skills documentation directly.

Copilot AI balanced review requested due to automatic review settings October 29, 2026 10:39
@changeset-bot

changeset-bot Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3b1935c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Minor

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T05:18:28.765917Z 3b1935c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@3b1935c
npx https://pkg.pr.new/@moonshot-ai/kimi-code@3b1935c

commit: 3b1935c

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread apps/kimi-code/src/tui/kimi-tui.ts Resolved
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +78 to +79
this.workspaceDirs.primaryByWorkspace[this.workspace.workspaceId] ?? this.workspace.cwd;
return [primary, this.workspace.cwd, ...this.workspaceDirs.sharedAdditionalDirs];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment on lines +179 to +181
const skills = (
await listWorkspaceSkillsForRoots(core, ws.root, ws.additionalDirs)
).map(toProtocolSkill);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread apps/kimi-code/src/tui/kimi-tui.ts Resolved
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review


P2 Badge Bound the pre-disclosure workspace reload

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".

@liruifengv

Copy link
Copy Markdown
Collaborator Author

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.

@liruifengv
liruifengv merged commit 3ed0e68 into main Oct 30, 2026
16 checks passed
@liruifengv
liruifengv deleted the feat/multi-root-workspace-skills-bump branch October 30, 2026 05:24
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
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.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
… 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`.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
…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.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
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.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 5, 2026
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.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 11, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants