Skip to content

feat(kap-server): add POST /sessions/{id}/skills:reload endpoint - #3597

Closed
liukx0205 wants to merge 2 commits into
mainfrom
feat/skill-reload-route
Closed

feat(kap-server): add POST /sessions/{id}/skills:reload endpoint#3597
liukx0205 wants to merge 2 commits into
mainfrom
feat/skill-reload-route

Conversation

@liukx0205

@liukx0205 liukx0205 commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

Fixes the daemon side of "skills created from the app are not visible to the current session without a restart" (client-side change: https://github.com/MoonshotAI/kimi-code-app/pull/542).

Problem

The daemon's workspace skill catalog only re-scans the user-level skill directories (~/.kimi-code/skills, ~/.agents/skills, explicit/extra dirs) when a session is created. Those directories are not watched, so a skill created while a session is running never shows up in GET /sessions/{id}/skills until the daemon restarts or a new session is created.

What changed

  • Add POST /api/v1/sessions/{session_id}/skills:reload in packages/kap-server/src/routes/skills.ts. It resolves the session like the existing skills routes, calls IWorkspaceSkillCatalog.reloadSources(['user', 'explicit', 'extra']) on the session's program (via programForSession), and returns the refreshed skill list in the same shape as GET /sessions/{id}/skills.
  • The path follows the repo's literal-colon route convention (skills::reload, same as fs::search), so it matches exactly /sessions/{id}/skills:reload.
  • Tests in packages/kap-server/test/skills.test.ts: 40401 for an unknown session, and an end-to-end check that a SKILL.md written into the user skills dir after session creation appears in the reload response and in the subsequent list. API surface snapshot updated.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Reload the user-level skill sources (user / explicit / extra dirs) of the
session's workspace skill catalog and return the refreshed skill list, so
clients can pick up skills created after the session started without a
restart.
@changeset-bot

changeset-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5d5bff3

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 Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Sep 7, 2026

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

commit: 5d5bff3

@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: 377ebefd86

ℹ️ 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 packages/kap-server/src/routes/skills.ts Outdated
Expose reloadSources on ISessionSkillCatalogData (delegating to the
owning workspace skill catalog) and have the skills:reload route reload
through the session scope seed instead of programForSession, so a live
session whose controller belongs to a retained previous runtime
generation reloads its own catalog rather than the current one.
@liukx0205

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 5d5bff36e9

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

@liukx0205

Copy link
Copy Markdown
Collaborator Author

Superseded by a simpler approach: watch user-level skill roots directly so the catalog is always fresh (no endpoint needed). Replaced by #3608

@liukx0205 liukx0205 closed this Sep 7, 2026
wbxl2000 pushed a commit that referenced this pull request Sep 7, 2026
…s fresh (#3608)

* feat(agent-core-v2): watch user-level skill roots so the catalog stays fresh

UserFileSkillSource previously only re-scanned the user skill roots
(KIMI_CODE_HOME/skills and ~/.agents/skills) on catalog load, so a skill
created while the daemon was running never appeared until a restart.

Mirror the workspace-root source: watch both user-level base directories
with a subtree filter limited to the skill-root candidates, debounce
(200ms) change events, and fire onDidChange so the catalog reloads the
'user' source automatically. Watch handles are registered on the
service's DisposableStore and disposed with the App scope.

Supersedes the skills:reload endpoint approach (#3597).

* fix(agent-core-v2): merge same-base watch candidates and drop test comments

Codex review on #3608:

- When KIMI_CODE_HOME equals the OS home dir, deduplicating watch bases
  skipped the .agents/skills candidate entirely. Group candidates by
  base instead so one watch covers both roots.
- Remove // phase labels from the catalog test: agent-core-v2 is a
  comment-free zone enforced by scripts/check-no-comments.mjs (lint was
  red on CI).
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.

1 participant