Skip to content

0.2.17#587

Merged
XingYu-Zhong merged 54 commits into
masterfrom
develop
Jun 25, 2026
Merged

0.2.17#587
XingYu-Zhong merged 54 commits into
masterfrom
develop

Conversation

@XingYu-Zhong

Copy link
Copy Markdown
Collaborator

No description provided.

luoye520ww and others added 30 commits June 23, 2026 18:35
…537)

Split from #525. The restore busy guard read a non-existent thread.state and compared against turn-level states, making it dead code and letting git reset --hard run during active turns. Now reads thread.status === 'running' against the real ThreadStatus contract, fail-closed, before any destructive op.
…538)

Split from #525. Validate untracked-file paths from persisted metadata stay inside the repo root and checkpoint dir (defeating .., absolute, and in-repo-symlink escapes). Enforce https for remote MCP server URLs in customMcpConfigFragment, resisting prototype pollution.

Co-authored-by: XingYu-Zhong <1736101137@qq.com>
Subagent profiles can now carry a providerId so different roles route to
different model providers. The runtime seam was already in place
(MultiProviderModelClient is the child executor's model client, and
ThreadService threads thread.providerId into every ModelRequest); the
only gap was that child threads were created without a providerId.

- SubagentProfileConfig + ChildRunRecord + ChildRunExecutor input + the
  delegate_task child event gain a providerId field.
- DelegationRuntime resolves providerId (explicit call arg wins over the
  profile's) and passes it through; child-agent-executor threads it onto
  threads.create so the child's ModelRequest routes correctly.
- delegate_task description surfaces each profile's provider.

Tests cover profile-resolved + explicit-override routing and that the
providerId reaches the child ModelRequest.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…edTools, name/description/color

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nfig bridge, sidebar Bot row

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…realtime child runs

- Thread/CreateThreadRequest: add agentId + systemPrompt fields; agent-loop
  threads thread.systemPrompt into ModelRequest so primary-agent persona
  snapshots replace the runtime base for that conversation.
- chat-store createThread accepts agentId and snapshots model/providerId/
  systemPrompt from the picked KunSubagentProfileV1 when mode is primary/all.
- FloatingComposerAgentPicker: self-contained picker next to the model
  picker; loads agents from settings and writes to composerAgentId state.
- ServerRuntime exposes delegationRuntime + modelClient + defaultModel.
- New routes:
  - GET /v1/delegation/diagnostics
  - GET /v1/delegation/profiles
- SubagentsView polls /v1/delegation/diagnostics every 2s and renders an
  'Active runs' panel plus per-card last-run / N-active badges.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- workspace-agents.ts: loadWorkspaceAgentProfiles(workspace) reads
  <workspace>/.kun/agents/*.md with YAML frontmatter (lean handwritten
  parser, no new deps) and returns SubagentProfileConfig records. Body
  becomes the systemPrompt verbatim.
- delegation-runtime: runChild overlays workspace profiles on top of the
  static GUI/builtin config map per-call (workspace wins). New `detach` flag
  returns the queued record immediately and continues execution in a fresh
  AbortController held by the runtime. New `abortChild(id)` cancels a
  detached background run.
- delegate_task tool schema: new `detach: boolean` option for the model.
- routes:
  - POST /v1/agents/generate — one-shot LLM call (json_object mode) drafts
    a SubagentProfileConfig from a user intent string.
  - POST /v1/delegation/abort/:childId — cancel a background child run.
- SubagentsView: 'AI draft' button → GenerateDialog → prefilled profile
  editor. Active-run rows get a Square abort button.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- agent-loop: thread.systemPrompt (primary-agent persona) now augments the
  base prompt (base + persona) instead of replacing it, so the agent keeps
  kun's tool/safety conventions + skill catalog. Matches child-agent-executor.
- FloatingComposerAgentPicker: force a settings refresh when the menu opens
  so a just-created agent shows immediately.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Reverts PR #550 to restore electron-builder default artifact naming for prerelease packages.
revert(release): remove explicit artifact names
…ep file search | Tool Runtime:全局Skill加载+来源标记+深路径文件搜索

English:
Problem: Three Tool Runtime issues from GitHub:
- #149: Global skill directory (~/.kun/skills) not scanned, only project-level
- #340: @-mention file search limited to 6 levels, deep paths not found
- #238: No step-level watchdog (deferred — requires agent-loop integration)

Solution:
1. Global skill loading (#149): Added globalRoots field to SkillsCapabilityConfig.
   discoverSkills() now scans project roots first (priority), then global roots.
   Each LoadedSkill carries a source marker ('project' | 'global').
   SkillRuntimeDiagnostics now exposes globalRoots for UI display.

2. Deep file search (#340): Increased FILE_MENTION_MAX_DEPTH from 6 to 10,
   FILE_MENTION_MAX_DIRECTORIES from 140 to 200, FILE_MENTION_MAX_FILES from
   1200 to 1600 in workspace-file-index.ts.

3. Step watchdog (#238): Deferred — requires integration into agent-loop.ts
   which is already modified by context-compiler. Will be addressed in Router
   module integration step.

Testing:
- Full kun suite: 799/801 passing (2 pre-existing failures)
- Typecheck: zero errors
- skill-runtime.test.ts: all 18 tests pass with globalRoots default
- skill-tool-provider.test.ts: all 3 tests pass
- http-server.test.ts: all diagnostics tests pass with updated SkillRuntimeDiagnostics

Tech debt: Step-level watchdog (#238) needs Promise.race-based timeout in
agent-loop.ts modelStep(). This requires coordinating with the context-compiler
changes already in the codebase.

简体中文:
问题:三个Tool Runtime GitHub Issue:
- #149:全局skill目录(~/.kun/skills)未被扫描,只有项目级
- #340:@-mention文件搜索限6层深度,深路径文件找不到
- #238:无环节级看门狗(延后——需要agent-loop集成)

解决方案:
1. 全局skill加载(#149):SkillsCapabilityConfig新增globalRoots字段。
   discoverSkills()先扫描项目根(优先),再扫描全局根。每个LoadedSkill
   携带source标记('project'|'global')。SkillRuntimeDiagnostics暴露
   globalRoots供UI展示。

2. 深文件搜索(#340):workspace-file-index.ts中FILE_MENTION_MAX_DEPTH
   从6提升到10,目录上限从140提升到200,文件上限从1200提升到1600。

3. 环节看门狗(#238):延后——需要集成到agent-loop.ts,该文件已被上下文
   编译器修改。将在Router模块集成阶段一并处理。

测试:全量799/801通过,类型检查零错误。

技术债务:环节看门狗需要在agent-loop.ts的modelStep()中用Promise.race实现
超时机制,需与已有的上下文编译器修改协调。
…onfig | 接入#149:全局Skill配置对接

English:
Problem: GitHub Issue #149 — global skill directory (~/.kun/skills) not
scanned. Code for globalRoots existed in SkillsCapabilityConfig and
skill-runtime.ts but kun-process.ts (which builds the runtime config
from GUI settings) never passed globalRoots through.

Root cause: skillCapabilityConfigForRuntime() only passed  and
 — the  field was silently dropped.

Fix: Pass  alongside roots. The skill-runtime
already handles the scanning correctly (project roots first, then global).

Changes: kun-process.ts +1 line.

Testing: Full kun suite 815/817 passing. Typecheck zero errors.

简体中文:
问题:#149——全局skill目录未被扫描。globalRoots代码已存在但kun-process.ts
从未将其传递到运行时配置。

根因:skillCapabilityConfigForRuntime()只传递了roots和legacySkillMd,
globalRoots字段被静默丢弃。

修复:在roots旁传递existing.globalRoots ?? []。skill-runtime已正确处理
扫描逻辑(先项目根,后全局根)。

变更:kun-process.ts +1行。
fix(tool-runtime): add global skill root support and deep @-file search | Tool Runtime:全局Skill加载+深路径搜索
XingYu-Zhong and others added 24 commits June 24, 2026 22:47
…56-557-558

# Conflicts:
#	kun/src/contracts/capabilities.ts
#	kun/src/skills/skill-runtime.ts
#	kun/tests/skill-runtime.test.ts
#	kun/tests/skill-tool-provider.test.ts
#	src/main/kun-process.ts
feat(chat): support PDF uploads and scoped skills
…n caches | 修复 Skill 禁用与 Codex 插件目录开关 (#392)

#394 only persisted the GUI disable choices; the runtime still loaded
disabled skills and always scanned ~/.codex/plugins/cache. This completes
the fix:

- B: add `disabledIds` to SkillsCapabilityConfig and filter at the single
  discoverSkills chokepoint, so disabled skills disappear from the catalog,
  auto-match, load_skill, diagnostics, and counts. Wire settings.disabledSkillIds
  into the runtime config.
- A: tie Codex plugin caches to the `global-codex` toggle — disabling the
  Codex global root also stops scanning ~/.codex/plugins/cache/**.
- C: treat ~/.codex/plugins/cache roots as GUI-managed (isCodexPluginCacheRoot)
  so stale version dirs from plugin upgrades are dropped instead of lingering.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…re + i18n

- Compaction summary can pin its own model/provider (contextCompaction.summaryModel
  / summaryProviderId), falling back to the turn's main model; routed via
  MultiProviderModelClient.
- Preset built-in General/Explore subagent profiles (builtin flag: cannot delete,
  can disable); normalize guarantees built-ins always exist; fix promptPreamble map.
- SubagentsView i18n keys for en/zh (subagents/newAgent/activeRuns/projectAgents/etc).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Brings the subagent system into develop: per-agent provider/model routing,
SubagentMode + systemPrompt/allowedTools, GUI management (SubagentsView),
.kun/agents/*.md overlay, primary-persona + delegation parity, AI-draft,
detach/abort, and a configurable Compaction summary model + preset
General/Explore. UI is reworked next on develop.
…t + animated kun + i18n

- New AgentsView replaces the orphaned SubagentsView: each agent has a model
  dropdown (sourced from composerModelGroups). Delegatable group (General/
  Explore/custom) + System group (Compaction configurable; Title/Summary
  marked rule-based).
- Built-in agents (General/Explore) cannot be deleted, only disabled; custom
  agents support create/edit/delete + AI-draft.
- AgentKun: self-contained animated mascot, distinct pose per agent (wave /
  spyglass / hug-box / sign / scroll), body tinted by agent color.
- Compaction row configures contextCompaction.summaryModel/providerId.
- Full EN/ZH i18n (agentsView.* keys, incl. localized built-in descriptions).
- Workbench route 'subagents' renders AgentsView; removed duplicate merge
  branch; deleted orphaned SubagentsView.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two real bugs caused frequent tool-call failures:

1. Anthropic Messages output was hard-capped at 4096 tokens while the
   agent loop never set maxTokens. Reasoning models (e.g. MiniMax-M3)
   spend that budget on thinking, truncating tool-call arguments into
   invalid JSON. Add a reasoning-aware default (8192 base / 32768 for
   thinking models), an optional per-model `maxOutputTokens` capability
   override, and route both through a shared resolveMaxTokens for all
   three wire formats.

2. The chat_completions streaming path only finalized tool calls on
   finish_reason === 'tool_calls', with no post-stream flush, so a
   provider ending with 'stop'/'length'/bare [DONE] while a call was
   pending dropped it silently. Add a post-loop flush in streamSse that
   recovers any unfinalized named call (truncated args surface as __raw
   instead of vanishing); report 'tool_calls' when a recovery happens.

Also surface a warning on stopReason 'length' instead of reporting a
silently truncated turn as a clean completion.

Adds the first real SSE streaming coverage for tool-call finalization.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
把 user_input/ask-user 交互从时间线内联气泡改为悬浮在输入框正上方的面板,气泡退化为只读记录(hybrid)。打字即答当前问、单问题裸 chips / 多问题步进、Esc 取消。无需改 kun 契约,复用 resolveUserInput。

- new: user-input-panel-logic (pure helpers + 13 tests), use-composer-user-input controller hook (one-shot resolvedRef guard against double-submit), FloatingComposerUserInputPanel (single=bare chips, multi=stepper)
- FloatingComposer: derive pending block, type-to-answer intercept (slash stays an escape hatch, trailing fallback for /-leading answers), Esc-to-cancel, placeholder, panel render, goal-floater/panel mutex
- message-timeline-bubbles: UserInputBubble -> read-only record + cancel, reuse shared logic
- store: persist answers on submit-error so the read-only record stays faithful
- i18n: en/zh panel strings

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
When using endpointFormat 'messages' against a third-party Anthropic-
compatible API, parallel tool calls (multiple tool_use in one assistant
turn) produced N consecutive user messages, each holding a single
tool_result. This violates Anthropic's rule that every tool_use from a
single turn must be answered by tool_result blocks inside ONE user
message, triggering HTTP 400 'tool_use ids were found without
tool_result blocks immediately after'.

The agent loop already waits for all parallel results before the next
turn; the bug was only in the Anthropic conversion layer, which split
the correctly-collected consecutive role:'tool' messages back into
separate user messages. Merge consecutive tool_result blocks (plus
their sibling image blocks) into the same user message. The chat
completions and responses paths are unaffected.

Fixes #574
The workflow/Loop editor renders as a `fixed inset-0` full-window
overlay. On Windows/Linux, AppShell draws a real 40px DOM titlebar in
normal flow, but the overlay sat at top:0 and covered it — clipping the
header and the right-side 配置/运行日志 tabs (and the back button)
under the window's top edge. macOS uses a native traffic-light overlay
with no DOM titlebar, so inset-0 is correct there — hence Windows-only.

Add `.ds-titlebar-fixed-overlay` keyed off the existing
`--ds-windows-titlebar-height` var (only set on win32/linux, falls back
to 0px elsewhere) and apply it to the editor overlay so the whole
editor shifts below the real titlebar on Windows while staying
unchanged on macOS.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ompaction mode

Replace the side-channel summary generation (serialized transcript stuffed
into a single user message + rigid ## Goal/## Completed sections) with a
dedicated compaction-mode turn modeled on opencode's compaction agent:

- Add COMPACTION_SYSTEM_PROMPT (ported from opencode compaction.txt) as the
  summarizer system prompt; drop the main agent prefix/few-shots.
- Feed the real conversation items as model messages (trailing tool calls
  trimmed) followed by a free-form continuation prompt instead of a
  byte-capped serialized transcript.
- Remove rigid section headers; raise default summary max tokens to 2048.

kun already models compaction non-destructively (the compaction TurnItem is
the summary message; effectiveHistoryAfterLatestCompaction mirrors opencode's
filterCompacted), so only the generation path changed. Tests now detect the
summary request via systemPrompt === COMPACTION_SYSTEM_PROMPT.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The vision-downgrade guard engaged on any user message, so selecting a
vision-capable model disabled every text-only model in the picker once a
single message was sent. Narrow the guard to conversations that actually
carry image (or unknown-kind, e.g. restored-session) attachments;
document-only and text-only chats can downgrade freely.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ime failure

Fixes #573

The renderer's format-runtime-error.ts mapped any 'fetch failed' substring
to fetch_failed ('Could not reach Kun, make sure kun serve is running'),
but 'model request failed: fetch failed' means the local runtime is
healthy and only the upstream model provider connection failed.

Add a model_request_failed error code (matched before fetch_failed via
the 'model request failed:' pattern with colon) that shows a distinct
message pointing at network, proxy, and provider configuration.

The colon-based pattern precisely isolates connection errors from HTTP
status errors like 'model request failed with status 400:'.
- Updated terminal tab renaming styles for improved focus.
- Expanded right panel mode options to include 'subagents'.
- Refactored UI font scaling to allow numeric values instead of fixed enums, with legacy support.
- Adjusted tests to accommodate new font scaling logic.
- Added new localization strings for subagent features in English and Chinese.
- Implemented animations for subagent UI elements to enhance user experience.
- Enhanced chat store actions to manage thread titles more effectively, including auto-upgrade logic.
- Introduced optional model and reasoning effort slots for Kun runtime settings.
fix(runtime): distinguish upstream model fetch_failed from local runtime failure
…l-result

fix(model): merge parallel tool_results into one Anthropic user message
…endor

feat(settings): annotate built-in endpoint formats with vendor (openai/anthropic)
fix(chat): show chrome for plain text code blocks
@XingYu-Zhong XingYu-Zhong merged commit cc61824 into master Jun 25, 2026
5 checks passed
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.

5 participants