Skip to content

feat(cli): add Kimi Code CLI as a flat host for skills and agents - #1344

Closed
dkp-consult wants to merge 1 commit into
ai-driven-dev:nextfrom
dkp-consult:feat/733-kimi-code-target
Closed

dkp-consult wants to merge 1 commit into
ai-driven-dev:nextfrom
dkp-consult:feat/733-kimi-code-target

Conversation

@dkp-consult

Copy link
Copy Markdown
Contributor

🎯 What & why

Kimi Code CLI users have no AIDD install. This adds a flat kimi target that writes AIDD skills and agents under .kimi-code/, from setup --ai kimi and from translate --to kimi --as flat. It is the first of the four deliverables settled in #733.

🛠️ How it works

Contract re-checked on 2026-11-17, against Kimi Code CLI 2.6.3 (MoonshotAI/kimi-code@1ccbe41). The 2.0.2 contract still holds:

  • Skills: project roots .kimi-code/skills and .agents/skills (skillRoots.ts:12-13), scanned up to 8 levels deep. A directory-form SKILL.md must have name and description (parser.ts:85).
  • Agents: project roots .kimi-code/agents and .agents/agents (agentRoots.ts:16-17). Every .md file is read, at any depth.
  • The comment of 2026-09-23 did not mention two rules, and both were already in 2.0.2. An agent needs a kebab-case name and a description, and an agent file that breaks either one is skipped with only a log warning (agentFile.ts:25, :67). Kimi ignores fields it does not know, such as model.

Design, modelled on the Antigravity profile:

  • Own root, .kimi-code/. Kimi also reads .agents/, but Antigravity and Codex write there. Using the Kimi-specific root means no file has two owners. When both trees exist, Kimi keeps the first file with a given name, and the brand root is read first, so you get no duplicate skills or agents.
  • Skills one level deep (flatSkillLayout: "single-level"): .kimi-code/skills/aidd-dev-01-plan/SKILL.md. Kimi registers a skill by its frontmatter name, so the name carries the plugin (/skill:aidd-dev-01-plan). It matches the Claude, Cursor, Copilot, Codex and Antigravity flat layouts.
  • One file per agent: .kimi-code/agents/aidd-orchestrator-executor.md. Its frontmatter is rebuilt by the existing portableAgentFrontmatter, and the build stops on a non-kebab-case name (build.ts:40) or an empty description, because Kimi would drop that agent without telling anyone. The profile declares no AgentsCapability, so no route copies Claude frontmatter verbatim.
  • No hooks yet. Every other AI host now runs hooks, and two arch tests apply: hooks facts live only in a hooks.ts descriptor, and only a tool that runs hooks has one. To satisfy both, a small shared helper declares "no hooks": noFlatHooks / NO_HOOKS_ARTIFACT. The CLI reports a plugin's hooks as skipped.

🧪 How to verify

cd cli && pnpm build
mkdir -p /tmp/kimi-out && node dist/cli.js translate .. --to kimi --as flat --out /tmp/kimi-out
find /tmp/kimi-out/.kimi-code -maxdepth 2
pnpm test -- tests/contexts/tools/domain/profiles/kimi

Expected: 4 agents under .kimi-code/agents/, 55 skill folders under .kimi-code/skills/, each SKILL.md with name equal to its folder, and 493 files in total. setup --ai kimi --plugins recommended writes the same files for the plugins it installs, and clean --force removes them all.

Observed on Kimi Code CLI 2.1.1 (2026-11-20), in a throwaway git project holding that tree:

  • kimi --agent zz-not-an-agent -p hi fails before any model call and lists the profiles it found: plan, agent, coder, explore, aidd-orchestrator-executor, aidd-orchestrator-explorer, aidd-orchestrator-reviewer, aidd-orchestrator-validator.
  • The provider was pointed at a local server that only records requests, so no model ran. The first request already shows that Kimi discovered everything:
    • the system prompt's skill catalog lists all 55 aidd-* skills, each with its .kimi-code/skills/<name>/SKILL.md path;
    • the Agent tool lists the 4 AIDD agents with their descriptions;
    • with --agent aidd-orchestrator-explorer, the system prompt is that agent's body.
  • Real model turns (kimi -p, default model kimi-code/kimi-for-coding):
    • Skill. The model calls Skill {"skill":"aidd-context-11-explore"}. Kimi injects <skill-loaded name="aidd-context-11-explore" source="project" dir=".../.kimi-code/skills/aidd-context-11-explore"> with the skill body, and the model answers with its heading, # Explore.
    • Delegation. The main agent calls Agent {"subagent_type":"aidd-orchestrator-explorer"}. The subagent runs on that profile (actual_subagent_type: aidd-orchestrator-explorer, status: completed) and answers .kimi-code/agents/aidd-orchestrator-validator.md:2.
    • Agent as main. --agent aidd-orchestrator-explorer runs Glob .kimi-code/agents/* and answers 4 files.

⚠️ Heads-up

  • Verified on Kimi 2.1.1 only. Discovery, a skill loaded through the Skill tool, and delegation to an AIDD agent all work there. Kimi 2.6.3 has not been run, so 2.6.3 support rests on its source alone. The full acceptance run is deliverable 4.
  • In -p mode, 2.1.1 sends /skill:<name> to the model as plain text rather than expanding it, so a skill only runs if the model picks it.
  • Deliberately left out, as later PRs: the native kimi.plugin.json build, hooks and KIMI_PLUGIN_ROOT, Kimi detection in telemetry, MCP, commands, user scope (setup --scope user), and the build-per-tool release matrix entry. Because of the release entry, INSTALL.md says no release zip exists for kimi yet.
  • The bundle budget goes from 772 KB to 775 KB: measured at 772.8 KB, +2.5 KB over next's 770.3 KB.

🔗 Linked issue

Refs #733

✅ I certify

  • I DO CERTIFY I READ EACH LINE OF THE PULL REQUEST BECAUSE I AM A SOFTWARE ENGINEER, NOT A AI PUPPY.

Kimi Code CLI users have no AIDD install. This adds a flat `kimi`
profile that writes AIDD skills and agents under `.kimi-code/`, from
setup and from `translate --to kimi --as flat`.

Checked against the Kimi Code CLI 2.6.3 source on 2026-11-17: project
skills come from `.kimi-code/skills/` and `.agents/skills/`, agents
from `.kimi-code/agents/` and `.agents/agents/`, both scanned
recursively. The profile writes the Kimi-specific root so it never
owns a file Antigravity writes under `.agents/`.

A skill sits one level deep as `<plugin>-<skill>/`, so its `name`, the
handle Kimi registers it by, carries the plugin. An agent is one file,
`<plugin>-<agent>.md`, with its frontmatter rebuilt by the portable
builder. Kimi skips an agent with a non-kebab-case `name` or no
`description` with only a log warning, so both stop the build here.

Hooks, MCP, commands and the native `kimi.plugin.json` build stay out
until their own changes; a plugin's hooks are reported as skipped.

Refs ai-driven-dev#733

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@blafourcade

Copy link
Copy Markdown
Contributor

@dkp-consult heads-up: once Kimi lands in the CLI, the aidd-context generators still won't write for it. Tracked in #1364; it could fit in this PR or a follow-up.

@blafourcade

Copy link
Copy Markdown
Contributor

Thank you @dkp-consult. Kimi Code CLI now ships on next as a full host: a flat project build, plugins installed at user scope through Kimi's local server (#1388), rules through AGENTS.md (#1389), and the generators (#1371). This PR's flat host is covered by that, so I am closing it. Thanks for pushing Kimi in.

@dkp-consult
dkp-consult deleted the feat/733-kimi-code-target branch November 26, 2026 12:24
@blafourcade

Copy link
Copy Markdown
Contributor

Hi @dkp-consult, thanks again for opening the Kimi work here. It landed on next in a different shape: Kimi now gets aidd as a user-scope native plugin through its local server (#1388), with SessionStart and UserPromptSubmit hooks (#1404).

We are stuck on one thing: our account has no Kimi Code subscription. Every model call returns 403 "subscription does not have access to Kimi Code", so we could never reach the tool and turn-end hooks. If you have a subscription, could you run this capture once? It takes about 5 minutes.

1. A probe plugin. Its hook writes each payload it receives to ~/kimi-capture/:

hookprobe/hook.sh

#!/bin/sh
mkdir -p "$HOME/kimi-capture"; IN=$(cat); E=$1
printf '%s' "$IN" > "$HOME/kimi-capture/$E-$(date +%s%N).json"
if [ -e "$HOME/kimi-capture/answer" ]; then
  case "$E" in
    PreToolUse) printf '%s' "$IN" | grep -q blocked.txt && printf '%s' '{"hookSpecificOutput":{"permissionDecision":"deny","permissionDecisionReason":"probe refuses blocked.txt"}}' ;;
    Stop) [ -e "$HOME/kimi-capture/stop-done" ] || { touch "$HOME/kimi-capture/stop-done"; echo "also write continued.txt containing ok" >&2; exit 2; } ;;
  esac
fi
exit 0

hookprobe/.kimi-plugin/plugin.json has one entry per event, every entry shaped {"event": "<E>", "command": "sh ./hook.sh <E>", "timeout": 30}, for SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PostToolUseFailure, Stop, StopFailure, SessionEnd, SubagentStart and SubagentStop. Also set "name": "hookprobe" and "version": "0.0.1".

2. Install it: run kimi web --no-open, take the token from the banner, then POST /api/v1/plugins with {"source": "<absolute path to hookprobe>"}.

3. Run it in a throwaway folder:

kimi -p "Write hello to notes.txt, then run ls."
touch ~/kimi-capture/answer
kimi -p "Write x to blocked.txt, then write y to other.txt."

4. Send it back: zip ~/kimi-capture/ and tell us your kimi --version. Also say whether blocked.txt and continued.txt exist after the second run. Then remove the plugin and delete the two sessions.

That tells us which events fire and whether a refusal and a turn-end follow-up take effect. We will wire only what your capture shows.

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.

2 participants