Repository navigation
fix: show skill roots of every project folder, including after resume - #5573
Merged
Merged
Conversation
Relative extra_skill_dirs entries were resolved only against the working directory, so in a multi-directory project the extra skill dirs under the additional directories were never scanned and their skill roots were missing from the model listing. Resolve them against the primary directory, the working directory and every shared additional directory, primary first, and reload them when the directory set changes. Explicit --skills-dir entries keep resolving against the working directory. Reload skill sources that change in the same tick together and remerge once, so a directory change no longer produces one partial skill listing per source. The workspace skill preview route follows the same resolution.
A resumed main agent kept the skill listing, AGENTS.md files, subagent list and project directories frozen in its replayed system prompt, and nothing compared them with the current state until a later live change or /reload. A folder added to a multi-directory project while the session was closed therefore never reached the model. Arm a one-time check when the agent is restored and after an undo, and run the same change checks /reload runs at the next step, so the reminders land in that step's request. Restoring itself records nothing, which keeps resumed state identical and leaves forks of an idle resumed session unaffected.
🦋 Changeset detectedLatest commit: 0b52188 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
Codex Review Summary: ✅ CompletedThis 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: |
sailist
approved these changes
Nov 27, 2026
5 of 6 tasks
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Dec 2, 2026
`bun scripts/upstream-ledger.mjs --refresh` at upstream/main 4eb2919 added 126 rows, so every open upstream commit and every PR it references now has a ledger row: 0/596, down from 125 at 8bf8ba3 and 126 at the fetched tip. The refresh only reads `upstream/main ^ main`, so the three release-2.6.2 commits named by the mission (MoonshotAI#4875/MoonshotAI#4905/MoonshotAI#4922) gained rows with the refresh's row shape. Settled with live probes in this tree: - ported: MoonshotAI#5533 (docs 2.8.1 changelog), MoonshotAI#4875 (registry search_url and feedback_url plus the feedback service), MoonshotAI#4905 (Kimi upload status validation in packages/core), MoonshotAI#4922 (swarm task events in sessionTaskFeed), MoonshotAI#5438 (unload only declared dynamic tools), MoonshotAI#5592 (dynamic tool replacement order), MoonshotAI#5595 (append-log known length), MoonshotAI#5573 (skill roots for every work dir), MoonshotAI#5576 (date reminder cwd comparison), MoonshotAI#5618 (session titles for skill openers), MoonshotAI#5638 (frozen loop tool baseline), MoonshotAI#5626 (legacy turn-input origins) - partial: MoonshotAI#5505 (processLiveness source and consumers present; the upstream unit test file was never carried), MoonshotAI#5571 (program-resume and OSC 7577 present; the upstream test helper was never carried), MoonshotAI#5532 (gitService half present; fsService still leaks the environment lease at fsService.ts:1133 and :1267), MoonshotAI#5557 (app-client icon registry kept; the move to app-ui was never carried) - not-applicable: MoonshotAI#4655 (upstream reverted auto review in MoonshotAI#5649), MoonshotAI#5333 (PLAYBOOK:111 deliberate flat experimental flags) M39's "likely present" list was checked, not trusted: MoonshotAI#5438 is present (upstream test passes), MoonshotAI#5487 is not (nativeStartSettleMs/leg.nativeSettled absent), MoonshotAI#5635 is not (ToolsSettled absent), MoonshotAI#5429 needs a visual probe. The remaining 194 pending rows stay open with their reasons; no feature was ported and no upstream-drift allowlist entry was added. Verification: verify -> 332 closed rows, 332 carry every file of their PR; 317 probes pass, 2 foreign-runner skips, 0 fail; a second verify is byte-identical (ledger sha256 cbf53638...). Probe tests 29 pass; bun run lint and node scripts/checks/ratchet.mjs green.
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.
Requirement or Bug
在多文件夹项目里,模型看到的技能清单末尾的
### Skill roots缺了附加文件夹。Skill 工具不可用时,模型要自己去读技能文件,就会找错位置:技能在~/.agents/skills,它却去~/.kimi-code下找。排查下来有两个根因:extra_skill_dirs只按工作目录解析。合入后,不论是新会话还是恢复的会话,模型都能看到每个项目文件夹的技能和它们的 skill roots。
Bug Reproduction Steps
会话恢复(桌面端最常见,平时大部分会话都没有加载):
app文件夹的项目,开一个会话发一条消息,然后关掉会话或重启服务。lib,其中有lib/.agents/skills/<name>/SKILL.md。lib的技能,也没有它的 skill root。相对额外目录:
config.toml里配置extra_skill_dirs = ["team-skills"]。lib,其中有lib/team-skills/<name>/SKILL.md。lib/team-skills也不在### Skill roots里。只有主目录下的team-skills生效。Root Cause
/reload时才发。会话关闭期间发生的变化,恢复时没有任何代码去比对,所以模型一直不知道。这是根本修复:恢复后补做/reload已有的那套比对。extra_skill_dirs:configuredRoots只接收一个工作目录来解析相对路径,额外目录来源也不监听项目目录集合的变化。这也是根本修复:改为按项目的每个目录解析,并在目录变化时重新加载。Code Changes
核心思路:恢复会话时不立刻做检查,只记一个「待检查」标记。到恢复后(以及撤销一轮后)的第一步开始前,再执行一次
/reload同款比对,产生的提醒就进入这一步的请求。相对extra_skill_dirs和项目级技能用同一份目录列表:主目录、工作目录、共享附加目录,主目录优先。同一时刻变化的多个技能来源合并成一次重载,模型只会收到一份完整清单。sequenceDiagram participant Lifecycle as agent 生命周期 participant Notifier as 变更通知服务 participant Reminder as 提醒服务(每步开始前) participant Model as 模型请求 Lifecycle->>Notifier: onDidRestore(回放完成) Notifier->>Notifier: 已绑定 profile 的 main agent:记下待检查 Note over Lifecycle,Notifier: 恢复本身不写任何记录,状态和恢复前一致 Reminder->>Notifier: 第一步开始前调用 restored_changes provider Notifier->>Notifier: notifyAllChanges():技能清单、AGENTS.md、子 agent 列表、项目目录 Notifier-->>Model: 有变化的项各带一条提醒撤销一轮(
ContextUndone)时,提醒和通知快照会一起回退,所以撤销后也重新置上标记,下一步再比对一次。相对额外目录的解析:
技能来源的变更事件:
关键决策
### Skill rootsPath:--skills-dir仍只按工作目录阅读顺序
packages/agent-core-v2/src/agent/changeNotifier/changeNotifierService.ts:恢复和撤销时怎么记待检查、第一步怎么触发比对。packages/agent-core-v2/src/features/skill/catalog/skillRoots.ts:相对路径按目录列表解析的规则。packages/agent-core-v2/src/features/skill/project/extraFileSkillSource.ts:额外目录来源怎么拿目录列表、什么时候重新加载。packages/agent-core-v2/src/features/skill/project/projectSkillCatalogService.ts:同一 tick 的来源变化怎么合并。可以略读:
rootFileSkillSource.ts抽出的共用目录列表、explicitFileSkillSource.ts和configuredSkillRootWatcher.ts的签名透传、programWorkdirs.ts的接线、kap-server 预览接口的一行改动,以及测试和文档。Behavior Changes and Affected Users
extra_skill_dirs,项目有多个目录时~路径,只解析一次~路径的额外目录、--skills-dirextra_skill_dirs时重新加载;没配时不触发merge_all_available_skills)onDidChange的内部消费者:session 目录、变更提醒、插件服务的事件计数。计数保持一一对应/reload发出的相同Path:的清单),第一步收到一次完整的当前清单GET /api/v1/workspaces/{workspace_id}/skills)packages/agent-core-v2/src/**/*.md、工具描述、提醒文案)。新增的只是已有的提醒会在新的时机发出。config-manifest.toml、wire-manifest.d.ts、state-manifest.d.ts、kap.md、contract.txt、node-sdk 导出)。REST 响应的结构没变。findProjectRoot和resolveConfiguredDir,只是对每个目录各调一次;Windows 路径(盘符、UNC)未验证。受影响模块与测试覆盖
configuredRoots的解析规则(相对路径逐个目录解析,绝对路径只解析一次,主目录优先),见skillRoots.test.ts。skillCatalog.test.ts新增的两个用例。changeNotifier.test.ts新增的三个用例。skills.test.ts新增用例。tests/scenarios/conversation.test.ts新增用例。验证过程
pnpm lint以 0 退出;pnpm run check:duplication相对目标分支通过;agent-core-v2、kap-server、tests/scenarios的tsc --noEmit都通过。test/agent、session、integration、features、program、project,共 4,793 个;tests/scenarios、kap-server、node-sdk、acp-server,共 2,146 个。fullCompaction.test.ts和dateChangeInjection.test.ts的「恢复后状态一致」断言失败,并让binding.test.ts里对恢复后会话的 fork 失败。改成第一步再检查后,这三个文件都通过。已知、但不在本 PR 范围内的问题
path参数说明写着「从清单里复制 Path」,但清单已经不列路径,所以多文件夹里的同名技能,模型只能调到默认那份。skill:<name>命令,都只运行默认那份。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.