feat: add workspace add-dir support - #812
Conversation
🦋 Changeset detectedLatest commit: 9d3862e The changes in this PR will be included in the next version bump. 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1823aa02ba
ℹ️ 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".
Add multi-directory /add-dir management with session-only or project-remembered persistence, directory completion, confirmation UI, and runtime workspace/permission wiring.
Pass CLI additional directories through shell and prompt resume paths, resolve caller-relative dirs against workDir, and add regression coverage.
Load only user-level and cwd AGENTS.md by default, while preserving additional directory listings in the prompt context.
Add a session appendUserMessage RPC and use it after /add-dir so the command result is recorded as a normal user message and surfaced in the transcript.
Document the add-dir / local-command-stdout research findings and the follow-up tasks for stdout wrapping, slash file completion, and hints.
1823aa0 to
8663f50
Compare
commit: |
Insert the /add-dir result as a user-role <local-command-stdout> record with an injection origin directly inside Session.addAdditionalDir. It enters the model context on the next turn but does not start a turn, and stays out of the live and resumed transcript; the transient status toast is kept for immediate feedback. --add-dir is unaffected since it bypasses addAdditionalDir. Remove the now-unused appendUserMessage RPC and SDK method.
Generalize the slash-argument completion reopen so it fires whenever the text before the cursor ends with '/', not only when the literal '/' key is typed. After Tab-accepting a directory (or auto-applying a single-child dir), the next level's completion list reappears automatically, so repeated Tab keeps drilling down into subdirectories. '@' file mention is unaffected.
Extend the path completion reopen so it also fires for '@' file mentions. After Tab-accepting a directory in an '@' mention, the next level's completion list reappears automatically, matching the '/add-dir' continuous-Tab behavior.
Render a dim ghost-text argument hint inside the input box after a slash command that takes arguments, replacing the popup-only hint that was easy to miss. The hint appears once the command is typed and disappears as soon as an argument is entered, and is truncated to fit the box width. Add argument hints for /compact, /swarm, /goal and /title; /add-dir already had one.
The subagent-host test still asserted that an additional directory's AGENTS.md content appears in the agent system prompt, but additional-dirs AGENTS.md has been intentionally excluded from the default context since an earlier commit (covered by context.test.ts). Drop the stale assertion.
Merge origin/main into feat/add-dir-workspace. Resolved conflicts in 6 files by keeping both sides' independent additions: .gitignore, dispatch.ts imports, agent/index.ts (kept additionalDirs, dropped the field main's logging refactor removed), core-api.ts / types.ts payloads, core-impl.ts imports and the createSession return (kept both the new telemetry and withAdditionalDirs).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47e2bf0c69
ℹ️ 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".
Resolve user-supplied /add-dir paths against the current workdir instead of the project root, so launching from a subdirectory behaves like the CLI --add-dir flag. Also route the local.toml read/write through the kaos abstraction instead of host fs, so the remember path works for non-local sessions.
The /add-dir completer emits ~/... values, but the core treated ~/foo as a relative path because pathe isAbsolute('~/foo') is false, producing <workDir>/~/foo. Expand ~ and ~/ to the home directory (via kaos.gethome()) before resolving.
These were working notes (research and follow-up todos) that don't belong in the PR.
FileSystemAgentRecordPersistence.append buffers records and flushes asynchronously, so readMainWire can read the wire before the local-command-stdout record lands. Flush the main agent's records explicitly in the two add-dir runtime tests to make them deterministic.
|
@liruifengv hello! Can you look an issue: #988?) |
Related Issue
No linked issue.
Problem
Kimi Code did not have a built-in way to add extra workspace directories during a session, persist remembered directories per project, or pass multiple startup additional directories from the CLI.
What changed
/add-dirwith a confirmation dialog for session-only use, remembering the directory in project-local config, or canceling.@filementions./add-dirdirectory argument completion, including/,~/, and../, while filtering dot directories.--add-dirCLI startup support./add-diradditions from immediately refreshing the current system prompt or inserting an add-dir reminder; remembered directories are rendered again for new/resumed sessions.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.Verification
pnpm vitest run packages/agent-core/test/config/workspace-local.test.ts packages/agent-core/test/session/subagent-host.test.ts packages/agent-core/test/harness/runtime.test.ts packages/agent-core/test/tools/path-guard.test.ts packages/agent-core/test/agent/permission.test.ts packages/node-sdk/test/create-session-transport.test.ts apps/kimi-code/test/tui/components/editor/file-mention-provider.test.ts apps/kimi-code/test/tui/commands/add-dir.test.ts apps/kimi-code/test/tui/commands/registry.test.ts apps/kimi-code/test/tui/commands/resolve.test.ts apps/kimi-code/test/cli/options.test.ts apps/kimi-code/test/cli/run-shell.test.ts apps/kimi-code/test/cli/run-prompt.test.tspnpm --filter @moonshot-ai/agent-core run typecheckpnpm --filter @moonshot-ai/kimi-code-sdk run typecheckpnpm --filter @moonshot-ai/kimi-code run typecheckpnpm -C apps/kimi-code run buildpnpm -C apps/kimi-code run smokegit diff --check