Repository navigation
fix(kap-server): search all workspace source folders - #4511
Conversation
|
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: |
…t land yet Both need multi-root workspace registration (MoonshotAI#4336): the REST create and update schemas carry only `root` and `name`, so there is no `additional_dirs` field to pass through or to de-duplicate. MoonshotAI#4511's fs half is already in place — resolveWorkspaceFs forwards ws.additionalDirs — so it stays in_progress with that note rather than being closed or signed off.
…MoonshotAI#4513 MoonshotAI#4336 is in_progress: d07cc07 adds managed creation with retry-safe ids and 0390f64 puts source folders on the REST and wire surfaces. MoonshotAI#4513 lands on top of that in 718a3ae and is closed against a route probe. MoonshotAI#4511 keeps its fs-side forwarding, but its route-level cross-folder search test is still missing, so it stays in_progress with a manual probe rather than borrowing the workspace-creation case as evidence.
The fuzzy search path now covers every registered source folder, pinned by the fsService case added with 14ba59e. The row stays in_progress because two pieces are still absent: the empty-query listing only sees the work directory (it needs a per-root list anchor, since resolveWithin refuses absolute paths by design), and upstream's route-level test is not ported.
…obes Both halves of the cross-folder search are in place: the fuzzy walk (14ba59e) and the empty-query listing, which now anchors an absolute path at the nearest registered root (a14144d). Upstream's route-level test is not ported, and the evidence says so, but the route forwarding it covers has been in place since MoonshotAI#4527's work. Ledger: closed 36 -> 37, remaining 62.
Port of upstream MoonshotAI/kimi-code bfdfde1's route-level tests and the workspace-scoped `fs::list` they exercise (MoonshotAI#4511). The tests create a workspace with a source folder and drive the three workspace-scoped routes plus a session-scoped search, which is the end-to-end proof that a registered folder reaches the filesystem layer: search and suggest see files in both roots with root-specific paths, a cold session search finds a file that lives only in the source folder, `list` respects the folder boundary and refuses a path outside it, and a `PATCH` that replaces the folder list takes effect on the next call. The `fs::list` route is new here: this fork only had `search` and `suggest` on `/api/v1/workspace/fs:<action>`, so a caller could search a workspace without a session but not list it. The route mirrors the `search` one, reusing its body-schema extension and runtime-scope release, and it is the boundary-refusal case that pins the anchoring introduced in a14144d. Removing `additionalDirs` from the workspace scope makes the cross-folder search case fail, so the forwarding is covered rather than incidental.
Port of upstream MoonshotAI/kimi-code 0772396 (MoonshotAI#4568). IAgentGoalService.editGoalObjective changes only the objective of the current goal: goalId, status, stats and budget are untouched, and goal.updated notifies clients. A running turn is not interrupted, and the tool cannot finish the goal before the agent sees the new objective: an edit bumps an objective revision, each turn records the revision it started under, and UpdateGoal's complete/blocked path refuses a stale revision at execution time, which also covers an edit made while the call waited for approval. CreateGoal replace clears the recorded revisions, so a same-turn replacement goal stays finishable. Surfaces: PATCH /api/v1/sessions/{session_id}/goal, Session#editGoalObjective with the SDKRpcClientBase/V2 pair, and the vis context projector folding the new goal.update objective field. Local-form adaptations, because this fork's goal state differs from upstream: - GoalState carries updatedAt and the transition tracks a changed flag; an objective edit sets it so the snapshot's updatedAt moves. Upstream's transition has neither. - The fork rejects non-strict request bodies at route definition, so editSessionGoalRequestSchema is .strict(). - The route reuses the local ensureMainAgent helper, which returns the agent handle and localizes the not-found message, instead of upstream's ensureMainAgent + handleOf(AGENT_NOT_FOUND) pair. - The complete-status test dispatches GoalUpdate directly because the fork's markComplete clears the goal and cannot leave one in complete status. Also updates the api-surface snapshot, which was still missing POST /api/v1/workspace/fs:list from MoonshotAI#4511; that batch never ran this gate. Verified: agent-core-v2 goal 126 pass, fold 18, goal injection 25; kap-server goal routes 7 and the api-surface snapshot; node-sdk 305; agent-core-v2, kap-server, apps/kimi-code and vis server typechecks clean; agent-core-v2 bun run build and check:no-comments clean. Reverse checks: short-circuiting the execution-time check reddens the two stale-edit cases, and dropping the transition's objective assignment reddens four cases including this route's. No changeset: the CLI does not expose the edit yet, so users of the published package cannot perceive it.
Requirement or Bug
Fix workspace file search and completion so they include every registered source folder in multi-folder projects.
Related review discussion: #4336 (comment)
Bug Reproduction Steps
POST /api/v1/workspace/fs:suggestorPOST /api/v1/workspace/fs:search.Root Cause
resolveWorkspaceFsresolved the workspace metadata but constructed the filesystem scope with onlyws.root. The downstreamWorkspaceFsServicealready supports merging multiple roots, but never receivedws.additionalDirs.This is a fundamental fix: the resolver now passes the current registered
root + additionalDirssnapshot through the existing acquire, runtime mapping, and lease-release path. No request or response schema changes are introduced.Code Changes
WorkspaceFsService.Behavior Changes and Affected Users
fs:suggestandfs:searchfs:searchresolved by workspace referencefs:listPOST /fs:suggestTest coverage:
pnpm --filter @moonshot-ai/kap-server exec vitest run test/fs.test.ts: 65 passed, including the four new regression tests. All four failed before the production fix and passed afterward.pnpm --filter @moonshot-ai/kap-server run typecheck: passed.pnpm --filter @moonshot-ai/kap-server run build: passed.pnpm lint: passed with 0 errors.pnpm test: 17,915 tests passed and 3 unrelated tests failed. Two failures passed when rerun in isolation.agent-core-v2/test/tool/tool.test.ts>returns the spawned agent id when a foreground subagent times outstill timed out independently; this PR does not modify that module.Checklist
gen-changesetsskill; no changeset was added at the author's explicit request.