From 7e080be4dfaa4a13ed7d3659c7002c72a1dd68bc Mon Sep 17 00:00:00 2001 From: fujufutong Date: Thu, 3 Dec 2026 23:52:11 +0800 Subject: [PATCH] feat(tools): add Xiaomi MiMo (mimocode) tool support --- .gitignore | 1 + README.ja.md | 1 + README.ko.md | 1 + README.md | 1 + README.th.md | 1 + README.zh-CN.md | 1 + docs/guide/tool-support.md | 3 + docs/guide/zh-CN/tool-support.md | 3 + oxlint-plugin-teamai/rules/tool-home-env.js | 2 +- oxlint-plugin-teamai/tool-ids.generated.json | 3 +- package-lock.json | 7 +++ packages/tool-core/src/definition.ts | 1 + packages/tool-definitions/src/facts.ts | 3 +- packages/tool-definitions/src/registry.ts | 3 +- packages/tool-mimocode/package.json | 10 ++++ .../tool-mimocode/src/conformance.test.ts | 9 +++ packages/tool-mimocode/src/definitions.ts | 44 ++++++++++++++ packages/tool-mimocode/src/facts.ts | 5 ++ packages/tool-mimocode/src/index.ts | 5 ++ scripts/doc-checks/readme-matrix.ts | 1 + scripts/tool-support.ts | 1 + src/__tests__/agent-format.test.ts | 46 +++++++++++---- src/__tests__/helpers/locate-matrix.ts | 1 + src/__tests__/locate-agents.test.ts | 28 +++++++++ src/__tests__/locate-matrix.test.ts | 28 +++++++++ src/__tests__/locate-mcp.test.ts | 14 +++++ src/__tests__/locate.test.ts | 7 ++- src/__tests__/self-mode-agents.test.ts | 12 +++- src/__tests__/self-mode-prompt.test.ts | 6 +- src/__tests__/tools-channels.test.ts | 4 +- src/__tests__/tools.test.ts | 2 +- src/__tests__/uninstall.test.ts | 2 +- src/agent-version.ts | 1 + src/known-agents.ts | 13 +++-- src/resources/agent-format.ts | 58 +++++++++---------- src/resources/agents.ts | 10 ++-- src/tool-home.ts | 6 ++ src/tool-registry.ts | 1 + src/tools.ts | 2 + src/types.ts | 5 ++ src/uninstall.ts | 6 +- 41 files changed, 293 insertions(+), 65 deletions(-) create mode 100644 packages/tool-mimocode/package.json create mode 100644 packages/tool-mimocode/src/conformance.test.ts create mode 100644 packages/tool-mimocode/src/definitions.ts create mode 100644 packages/tool-mimocode/src/facts.ts create mode 100644 packages/tool-mimocode/src/index.ts diff --git a/.gitignore b/.gitignore index 460620520e..8996a560b9 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ __pycache__/ .gstack/ .worktrees/ .codebuddy/ +.mimocode/ .teamai/ # TeamAI-managed Copilot sync artifacts .github/hooks/teamai.json diff --git a/README.ja.md b/README.ja.md index cfec478a30..3b3a68c203 100644 --- a/README.ja.md +++ b/README.ja.md @@ -143,6 +143,7 @@ Git を基盤に、3 層の能力を構築します: JoyCode✓✓¹✓✓✓—✓✓—✓✓✓✓— Muse Code✓✓¹✓✓✓✓✓✓✓✓✓✓✓— Antigravity✓✓✓✓✓✓✓✓✓✓✓✓✓✓ + Xiaomi MiMo✓——✓——✓✓²—✓———— diff --git a/README.ko.md b/README.ko.md index 42b2829403..2dff4dc77c 100644 --- a/README.ko.md +++ b/README.ko.md @@ -143,6 +143,7 @@ Git을 기반으로 세 층의 역량을 구축합니다: JoyCode✓✓¹✓✓✓—✓✓—✓✓✓✓— Muse Code✓✓¹✓✓✓✓✓✓✓✓✓✓✓— Antigravity✓✓✓✓✓✓✓✓✓✓✓✓✓✓ + Xiaomi MiMo✓——✓——✓✓²—✓———— diff --git a/README.md b/README.md index 5419c85ec1..64b4c621f2 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,7 @@ Three layers of capability, built on Git: JoyCode✓✓¹✓✓✓—✓✓—✓✓✓✓— Muse Code✓✓¹✓✓✓✓✓✓✓✓✓✓✓— Antigravity✓✓✓✓✓✓✓✓✓✓✓✓✓✓ + Xiaomi MiMo✓——✓——✓✓²—✓———— diff --git a/README.th.md b/README.th.md index 54cc539eae..f9f4874546 100644 --- a/README.th.md +++ b/README.th.md @@ -143,6 +143,7 @@ teamai init https://github.com/your-org/your-repo --scope user JoyCode✓✓¹✓✓✓—✓✓—✓✓✓✓— Muse Code✓✓¹✓✓✓✓✓✓✓✓✓✓✓— Antigravity✓✓✓✓✓✓✓✓✓✓✓✓✓✓ + Xiaomi MiMo✓——✓——✓✓²—✓———— diff --git a/README.zh-CN.md b/README.zh-CN.md index e857ea3ed7..33c3eaae95 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -149,6 +149,7 @@ teamai init https://github.com/your-org/your-repo --scope user JoyCode✓✓¹✓✓✓—✓✓—✓✓✓✓— Muse Code✓✓¹✓✓✓✓✓✓✓✓✓✓✓— Antigravity✓✓✓✓✓✓✓✓✓✓✓✓✓✓ + Xiaomi MiMo✓——✓——✓✓²—✓———— diff --git a/docs/guide/tool-support.md b/docs/guide/tool-support.md index 0e536da915..88eae06be0 100644 --- a/docs/guide/tool-support.md +++ b/docs/guide/tool-support.md @@ -40,6 +40,7 @@ Rule and agent folder files: how the tool reads the files a user-scope rule or a | OpenCode | `~/.config/opencode` `$OPENCODE_CONFIG_DIR` `$XDG_CONFIG_HOME/opencode` | `~/.config/opencode/skills` v
`~/.claude/skills` v | `~/.config/opencode/rules` v | copy | `~/.config/opencode/teamai-context.md` v | `~/.config/opencode/agents` v | opencode-plugin s | `~/.config/opencode/opencode.json` v | opencode | | Muse Code | `~/.config/muse` `$XDG_CONFIG_HOME/muse` | `~/.config/muse/skills` v
`~/.agents/skills` v
`~/.claude/skills` v | in the blocks file (Muse Code AGENTS.md) | copy | `~/.config/muse/AGENTS.md` v | `~/.config/muse/agents` s | `~/.config/muse/settings.json` v | `~/.config/muse/settings.json` s | muse | | Antigravity | `~/.gemini/config` | `~/.gemini/config/skills` v
`~/.agents/skills` v | `~/.gemini/config/rules` v | copy | `~/.gemini/config/rules` v | `~/.gemini/config/agents` v | agy-hooks v | `~/.gemini/config/mcp_config.json` v | agy | +| Xiaomi MiMo | `~/.config/mimocode` `$MIMOCODE_HOME/config` `$XDG_CONFIG_HOME/mimocode` | `~/.config/mimocode/skills` s | — | copy | — | `~/.config/mimocode/agents` s | — | — | — | ## Project scope @@ -73,6 +74,7 @@ Paths are relative to the project root. `cwd only`: the tool reads it only from | OpenCode | `.opencode/skills` v
`.claude/skills` v | `.opencode/rules` v | `.opencode/teamai-context.md` v | `.opencode/agents` v | user hooks | `opencode.json` v
`.opencode/teamai-mcp.json` v | | Muse Code | `.agents/skills` v | session hook v | session hook v | written; reads ? | `.muse/hooks.json` v | `.mcp.json` s | | Antigravity | `.agents/skills` v | `.agents/rules` v | `.agents/rules` v | `.agents/agents` v | user hooks | `.agents/plugins/teamai/mcp_config.json` v | +| Xiaomi MiMo | `.mimocode/skills` s | — | — | `.mimocode/agents` s | — | — | ## Run time and teamai's own AI @@ -106,6 +108,7 @@ User scope, from #1221's matrix; a fix merged since is marked `t`, with a note. | OpenCode | ? | ✓t | ✓d | ✓v | ✓t2 | ✓v | ✓v | ✓t1 | ✓v30 | | Muse Code | ✓t | +v | ? | ✓t | ✓v | ✓t | ✓v | ✓t1 | ✓t31 | | Antigravity | ✓v32 | ✓v | ✓d | ✓v | ✓v | ◐v33 | ✓v | ✓t34 | ✓t35 | +| Xiaomi MiMo | ? | +d | ? | ? | ? | ? | +d | ? | ? | Notes: diff --git a/docs/guide/zh-CN/tool-support.md b/docs/guide/zh-CN/tool-support.md index f070b96619..d32bed31d2 100644 --- a/docs/guide/zh-CN/tool-support.md +++ b/docs/guide/zh-CN/tool-support.md @@ -40,6 +40,7 @@ teamai 为每个工具把每类 Agent 资源写到哪里,以及工具读取哪 | OpenCode | `~/.config/opencode` `$OPENCODE_CONFIG_DIR` `$XDG_CONFIG_HOME/opencode` | `~/.config/opencode/skills` v
`~/.claude/skills` v | `~/.config/opencode/rules` v | copy | `~/.config/opencode/teamai-context.md` v | `~/.config/opencode/agents` v | opencode-plugin s | `~/.config/opencode/opencode.json` v | opencode | | Muse Code | `~/.config/muse` `$XDG_CONFIG_HOME/muse` | `~/.config/muse/skills` v
`~/.agents/skills` v
`~/.claude/skills` v | in the blocks file (Muse Code AGENTS.md) | copy | `~/.config/muse/AGENTS.md` v | `~/.config/muse/agents` s | `~/.config/muse/settings.json` v | `~/.config/muse/settings.json` s | muse | | Antigravity | `~/.gemini/config` | `~/.gemini/config/skills` v
`~/.agents/skills` v | `~/.gemini/config/rules` v | copy | `~/.gemini/config/rules` v | `~/.gemini/config/agents` v | agy-hooks v | `~/.gemini/config/mcp_config.json` v | agy | +| Xiaomi MiMo | `~/.config/mimocode` `$MIMOCODE_HOME/config` `$XDG_CONFIG_HOME/mimocode` | `~/.config/mimocode/skills` s | — | copy | — | `~/.config/mimocode/agents` s | — | — | — | ## 项目范围 @@ -73,6 +74,7 @@ teamai 为每个工具把每类 Agent 资源写到哪里,以及工具读取哪 | OpenCode | `.opencode/skills` v
`.claude/skills` v | `.opencode/rules` v | `.opencode/teamai-context.md` v | `.opencode/agents` v | user hooks | `opencode.json` v
`.opencode/teamai-mcp.json` v | | Muse Code | `.agents/skills` v | session hook v | session hook v | written; reads ? | `.muse/hooks.json` v | `.mcp.json` s | | Antigravity | `.agents/skills` v | `.agents/rules` v | `.agents/rules` v | `.agents/agents` v | user hooks | `.agents/plugins/teamai/mcp_config.json` v | +| Xiaomi MiMo | `.mimocode/skills` s | — | — | `.mimocode/agents` s | — | — | ## 运行时与 teamai 自身的 AI @@ -106,6 +108,7 @@ teamai 为每个工具把每类 Agent 资源写到哪里,以及工具读取哪 | OpenCode | ? | ✓t | ✓d | ✓v | ✓t2 | ✓v | ✓v | ✓t1 | ✓v30 | | Muse Code | ✓t | +v | ? | ✓t | ✓v | ✓t | ✓v | ✓t1 | ✓t31 | | Antigravity | ✓v32 | ✓v | ✓d | ✓v | ✓v | ◐v33 | ✓v | ✓t34 | ✓t35 | +| Xiaomi MiMo | ? | +d | ? | ? | ? | ? | +d | ? | ? | 注: diff --git a/oxlint-plugin-teamai/rules/tool-home-env.js b/oxlint-plugin-teamai/rules/tool-home-env.js index 955d7560fa..46f0729261 100644 --- a/oxlint-plugin-teamai/rules/tool-home-env.js +++ b/oxlint-plugin-teamai/rules/tool-home-env.js @@ -12,7 +12,7 @@ const OWNER = 'src/launch-registry.ts'; */ export const HOME_VARIABLES = new Set([ 'CLAUDE_CONFIG_DIR', 'CODEX_HOME', 'CODEBUDDY_CONFIG_DIR', 'COPILOT_HOME', 'CURSOR_CONFIG_DIR', 'CURSOR_DATA_DIR', 'DSH_HOME', 'HERMES_DATA_DIR_SUFFIX', 'HERMES_HOME', - 'JOYCODE_HOME', 'OMP_PROFILE', 'OPENCLAW_HOME', 'OPENCLAW_PROFILE', 'OPENCLAW_STATE_DIR', 'OPENCODE_CONFIG_DIR', 'PI_CODING_AGENT_DIR', + 'JOYCODE_HOME', 'MIMOCODE_HOME', 'OMP_PROFILE', 'OPENCLAW_HOME', 'OPENCLAW_PROFILE', 'OPENCLAW_STATE_DIR', 'OPENCODE_CONFIG_DIR', 'PI_CODING_AGENT_DIR', 'PI_CONFIG_DIR', 'PI_PROFILE', 'QODERCN_CLI_HOME', 'QODERCN_CONFIG_DIR', 'QODER_CLI_HOME', 'QODER_CONFIG_DIR', 'XDG_CONFIG_HOME', ]); diff --git a/oxlint-plugin-teamai/tool-ids.generated.json b/oxlint-plugin-teamai/tool-ids.generated.json index 53e7900651..37f404681b 100644 --- a/oxlint-plugin-teamai/tool-ids.generated.json +++ b/oxlint-plugin-teamai/tool-ids.generated.json @@ -24,5 +24,6 @@ "workbuddypro", "opencode", "muse", - "agy" + "agy", + "mimocode" ] diff --git a/package-lock.json b/package-lock.json index 9c6e07ddfa..9d4cf64801 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1647,6 +1647,10 @@ "resolved": "packages/tool-launch", "link": true }, + "node_modules/@teamai/tool-mimocode": { + "resolved": "packages/tool-mimocode", + "link": true + }, "node_modules/@teamai/tool-muse": { "resolved": "packages/tool-muse", "link": true @@ -8539,6 +8543,9 @@ "packages/tool-launch": { "name": "@teamai/tool-launch" }, + "packages/tool-mimocode": { + "name": "@teamai/tool-mimocode" + }, "packages/tool-muse": { "name": "@teamai/tool-muse" }, diff --git a/packages/tool-core/src/definition.ts b/packages/tool-core/src/definition.ts index 46aa7fe153..07698c0153 100644 --- a/packages/tool-core/src/definition.ts +++ b/packages/tool-core/src/definition.ts @@ -38,6 +38,7 @@ export type SkillLoad = /** One way a machine moves a tool's home. */ export type HomeMove = | { readonly kind: 'env'; readonly name: string; readonly evidence: Evidence } + | { readonly kind: 'absolute-env-child'; readonly name: string; readonly child: string; readonly evidence: Evidence } /** Qoder: `QODER_CONFIG_DIR`, or `.qoder` inside `QODER_CLI_HOME`. */ | { readonly kind: 'qoder-home'; readonly evidence: Evidence } /** Qoder CN: `QODERCN_CONFIG_DIR`, or `.qoder-cn` inside `QODERCN_CLI_HOME`. */ diff --git a/packages/tool-definitions/src/facts.ts b/packages/tool-definitions/src/facts.ts index 263c5df366..650f73b0d8 100644 --- a/packages/tool-definitions/src/facts.ts +++ b/packages/tool-definitions/src/facts.ts @@ -16,9 +16,10 @@ import { facts as copilot } from '@teamai/tool-copilot/facts'; import { facts as opencode } from '@teamai/tool-opencode/facts'; import { facts as agy } from '@teamai/tool-agy/facts'; import { facts as cursor } from '@teamai/tool-cursor/facts'; +import { facts as mimocode } from '@teamai/tool-mimocode/facts'; /** * Every built-in tool family's facts: its tools and its session platforms, with no adapter, launch profile or schema. * This is what every command loads (teamai/family-facts); the families themselves (`BUILT_IN_TOOLS`) load where first used. */ -export const BUILT_IN_FACTS = { claude, codex, qoder, joycode, pi, codebuddy, kiro, trae, zcode, openclaw, hermes, dsh, muse, copilot, opencode, agy, cursor } as const satisfies Readonly>; +export const BUILT_IN_FACTS = { claude, codex, qoder, joycode, pi, codebuddy, kiro, trae, zcode, openclaw, hermes, dsh, muse, copilot, opencode, agy, cursor, mimocode } as const satisfies Readonly>; diff --git a/packages/tool-definitions/src/registry.ts b/packages/tool-definitions/src/registry.ts index bcd2ecb763..bdf33eed40 100644 --- a/packages/tool-definitions/src/registry.ts +++ b/packages/tool-definitions/src/registry.ts @@ -17,13 +17,14 @@ import { family as copilot } from '@teamai/tool-copilot'; import { family as opencode } from '@teamai/tool-opencode'; import { family as agy } from '@teamai/tool-agy'; import { family as cursor } from '@teamai/tool-cursor'; +import { family as mimocode } from '@teamai/tool-mimocode'; import type { BUILT_IN_FACTS } from './facts.js'; /** * Every built-in tool family, the one with each list of facts (`BUILT_IN_FACTS`). The app reads tools only through these, * never by importing a family. */ -export const BUILT_IN_TOOLS = { claude, codex, qoder, joycode, pi, codebuddy, kiro, trae, zcode, openclaw, hermes, dsh, muse, copilot, opencode, agy, cursor } as const satisfies Readonly>; +export const BUILT_IN_TOOLS = { claude, codex, qoder, joycode, pi, codebuddy, kiro, trae, zcode, openclaw, hermes, dsh, muse, copilot, opencode, agy, cursor, mimocode } as const satisfies Readonly>; /** The sign-in variables of each built-in tool a step runtime launches on the member's own sign-in, by launch adapter id. */ // oxlint-disable-next-line teamai/tool-facts -- read from each launch adapter's own signIn, keyed by launch adapter id as LAUNCH_ADAPTERS is diff --git a/packages/tool-mimocode/package.json b/packages/tool-mimocode/package.json new file mode 100644 index 0000000000..534c00355e --- /dev/null +++ b/packages/tool-mimocode/package.json @@ -0,0 +1,10 @@ +{ + "name": "@teamai/tool-mimocode", + "private": true, + "type": "module", + "description": "MiMoCode tool support; bundled into teamai-cli.", + "exports": { + ".": "./src/index.ts", + "./facts": "./src/facts.ts" + } +} diff --git a/packages/tool-mimocode/src/conformance.test.ts b/packages/tool-mimocode/src/conformance.test.ts new file mode 100644 index 0000000000..b3e0e419e3 --- /dev/null +++ b/packages/tool-mimocode/src/conformance.test.ts @@ -0,0 +1,9 @@ +import { describeFamily } from '@teamai/tool-testing/conformance'; +import { family } from './index.js'; + +describeFamily('tool-mimocode', family, { + calls: {}, + transcripts: {}, + tokens: {}, + versions: {}, +}); diff --git a/packages/tool-mimocode/src/definitions.ts b/packages/tool-mimocode/src/definitions.ts new file mode 100644 index 0000000000..626bfd9f3d --- /dev/null +++ b/packages/tool-mimocode/src/definitions.ts @@ -0,0 +1,44 @@ +import { NONE, type ToolDescriptor } from '@teamai/tool-core/definition'; + +/** Xiaomi MiMo (MiMoCode). */ +export const tools = { + mimocode: { + home: { + dir: '.config/mimocode', + moves: { by: [{ kind: 'absolute-env-child', name: 'MIMOCODE_HOME', child: 'config', evidence: 'source' }, { kind: 'xdg', child: 'mimocode', evidence: 'source' }] }, + }, + installedBy: 'home-edition', + skillLoad: 'unknown', + skills: { + user: [{ base: 'home', path: '.config/mimocode/skills', evidence: 'source' }], + project: [{ base: 'project', path: '.mimocode/skills', when: 'workspaceUnder', evidence: 'source' }], + }, + rules: NONE, + blocks: NONE, + agents: { + user: { reads: [{ base: 'home', path: '.config/mimocode/agents', evidence: 'source' }] }, + project: { reads: [{ base: 'project', path: '.mimocode/agents', when: 'workspaceUnder', evidence: 'source' }] }, + }, + mcp: NONE, + hooks: { user: 'none', self: 'none', subagentStop: false, stopReply: false, shell: 'system', teamHooks: 'home', needsBundle: false }, + sessions: 'none', + launch: 'none', + tokens: 'none', + autoCompact: 'none', + skillAllowedTools: false, + searchEvidence: false, + projectFromHome: false, + legacyAgentMd: false, + features: { + env: '?', + workflows: '+d', + unattended: '?', + recall: '?', + stats: '?', + tokens: '?', + aiBackend: '+d', + sessionJudge: '?', + agentHooks: '?', + }, + }, +} as const satisfies Record; diff --git a/packages/tool-mimocode/src/facts.ts b/packages/tool-mimocode/src/facts.ts new file mode 100644 index 0000000000..17c0559a68 --- /dev/null +++ b/packages/tool-mimocode/src/facts.ts @@ -0,0 +1,5 @@ +import type { ToolFamilyFacts } from '@teamai/tool-core/family'; +import { tools } from './definitions.js'; + +/** What every command may load of this family: its tools; it has no version detector and keeps no sessions teamai reads. */ +export const facts = { tools, platforms: {}, detect: {} } as const satisfies ToolFamilyFacts; diff --git a/packages/tool-mimocode/src/index.ts b/packages/tool-mimocode/src/index.ts new file mode 100644 index 0000000000..dfa30bc5c3 --- /dev/null +++ b/packages/tool-mimocode/src/index.ts @@ -0,0 +1,5 @@ +import type { ToolFamily } from '@teamai/tool-core/family'; +import { tools } from './definitions.js'; + +/** Xiaomi MiMo (MiMoCode). */ +export const family = { tools, launch: {}, platforms: {}, tokens: {}, detect: {} } as const satisfies ToolFamily; diff --git a/scripts/doc-checks/readme-matrix.ts b/scripts/doc-checks/readme-matrix.ts index dc500a9989..db435af36b 100644 --- a/scripts/doc-checks/readme-matrix.ts +++ b/scripts/doc-checks/readme-matrix.ts @@ -62,6 +62,7 @@ const LABELS: ReadonlyMap = new Map(Object.entries({ JoyCode: 'joycode', 'Muse Code': 'muse', Antigravity: 'agy', + 'Xiaomi MiMo': 'mimocode', } satisfies Record)); /** Internal builds the README leaves out. */ diff --git a/scripts/tool-support.ts b/scripts/tool-support.ts index 56330d53d3..31ab1e156f 100644 --- a/scripts/tool-support.ts +++ b/scripts/tool-support.ts @@ -140,6 +140,7 @@ function runTime(value: RunTime): string { function homeMove(move: HomeMove, dir: string): string { switch (move.kind) { case 'env': return `\`$${move.name}\``; + case 'absolute-env-child': return `\`$${move.name}/${move.child}\``; case 'qoder-home': return '`$QODER_CONFIG_DIR` `$QODER_CLI_HOME/.qoder`'; case 'qoder-cn-home': return '`$QODERCN_CONFIG_DIR` `$QODERCN_CLI_HOME/.qoder-cn`'; case 'xdg': return `\`$XDG_CONFIG_HOME/${move.child}\``; diff --git a/src/__tests__/agent-format.test.ts b/src/__tests__/agent-format.test.ts index 2586d064db..fc641c19a4 100644 --- a/src/__tests__/agent-format.test.ts +++ b/src/__tests__/agent-format.test.ts @@ -35,6 +35,7 @@ import { reverseFromJoycode, reverseFromOpencode, renderForTool, + reverseByTool, mergeReverseResults, } from '../resources/agent-format.js'; import type { AgentSpec, ToolName, ParseResult } from '../resources/agent-format.js'; @@ -609,17 +610,42 @@ describe('reverseFromOpencode', () => { const result = reverseFromOpencode('/agents/a.md', content); expect(result.ok).toBe(false); }); +}); - it('round-trips render → reverse preserving common fields', () => { - const spec = makeSpec({ model: 'anthropic/claude-sonnet-4' }); - const { content } = renderForOpencode(spec); - const result = reverseFromOpencode('/agents/test-agent.md', content); - expect(result.ok).toBe(true); - if (!result.ok) return; - expect(result.spec.name).toBe('test-agent'); - expect(result.spec.description).toBe(spec.description); - expect(result.spec.instructions).toBe(spec.instructions); - expect(result.spec.model).toBe('anthropic/claude-sonnet-4'); +describe('path-named Markdown agent formats', () => { + it.each(['opencode', 'mimocode'] as const)('round-trips %s Markdown with its own private fields', (tool) => { + const other = tool === 'opencode' ? 'mimocode' : 'opencode'; + const spec = makeSpec({ + model: 'team-model', + tools: ['read'], + tool_extras: { [tool]: { variant: 'high' }, [other]: { variant: 'low', temperature: 0.1 } }, + }); + const { ext, content } = renderForTool(spec, tool, { model: 'provider/model', effort: 'medium' }); + expect(ext).toBe('.md'); + expect(reverseByTool(tool, path.resolve('agents', `${spec.name}${ext}`), content)).toEqual({ + ok: true, + spec: { + name: spec.name, + description: spec.description, + instructions: spec.instructions, + model: 'provider/model', + tool_extras: { [tool]: { mode: 'subagent', variant: 'high' } }, + }, + }); + }); + + it('keeps a dotted MiMoCode agent ID and renders resolved effort as variant', () => { + const spec = makeSpec({ name: 'backend.agent', tool_extras: { opencode: { variant: 'low' } } }); + const { ext, content } = renderForTool(spec, 'mimocode', { effort: 'high' }); + expect(reverseByTool('mimocode', `${spec.name}${ext}`, content)).toEqual({ + ok: true, + spec: { + name: 'backend.agent', + description: spec.description, + instructions: spec.instructions, + tool_extras: { mimocode: { mode: 'subagent', variant: 'high' } }, + }, + }); }); }); diff --git a/src/__tests__/helpers/locate-matrix.ts b/src/__tests__/helpers/locate-matrix.ts index 47997267f9..3fb79261a1 100644 --- a/src/__tests__/helpers/locate-matrix.ts +++ b/src/__tests__/helpers/locate-matrix.ts @@ -252,6 +252,7 @@ function moveSettingsOf(tool: ToolId, move: HomeMove): MoveSetting[] { const setting = (name: string, value: string): MoveSetting => ({ tool, name, env: { [name]: value }, win32: false }); switch (move.kind) { case 'env': + case 'absolute-env-child': return [setting(move.name, '/moved')]; case 'qoder-home': return [setting('QODER_CONFIG_DIR', '/moved'), setting('QODER_CLI_HOME', '/moved')]; diff --git a/src/__tests__/locate-agents.test.ts b/src/__tests__/locate-agents.test.ts index 051bbb6802..09eaa1b808 100644 --- a/src/__tests__/locate-agents.test.ts +++ b/src/__tests__/locate-agents.test.ts @@ -437,6 +437,34 @@ const ROWS: readonly MatrixRow[] = [ reads: [{ at: '/.opencode/agents', when: 'workspaceUnder' }], source: 'opencode v2.1.1 run: project agents in .opencode/agents; #1221 matrix workspace Agents ✓v', }, + { + tool: 'mimocode', scope: 'user', + writes: ['~/.config/mimocode/agents'], + existingDirs: ['~/.config/mimocode'], installed: { probe: '~/.config/mimocode', met: true }, + reads: [{ at: '~/.config/mimocode/agents', when: 'always' }], + source: 'MiMoCode 0.1.12: the global config directory loads agents/', + }, + { + tool: 'mimocode', scope: 'user', env: { XDG_CONFIG_HOME: '/xdg' }, + writes: ['/xdg/mimocode/agents'], + existingDirs: ['/xdg/mimocode'], installed: { probe: '/xdg/mimocode', met: true }, + reads: [{ at: '/xdg/mimocode/agents', when: 'always' }], + source: 'MiMoCode 0.1.12: XDG_CONFIG_HOME/mimocode is the config directory without MIMOCODE_HOME', + }, + { + tool: 'mimocode', scope: 'user', env: { MIMOCODE_HOME: '/mimo' }, + writes: ['/mimo/config/agents'], + existingDirs: ['/mimo/config'], installed: { probe: '/mimo/config', met: true }, + reads: [{ at: '/mimo/config/agents', when: 'always' }], + source: 'MiMoCode 0.1.12: MIMOCODE_HOME loads agents from its config/agents', + }, + { + tool: 'mimocode', scope: 'project', + writes: ['/.mimocode/agents'], + existingDirs: ['~/.config/mimocode'], installed: { probe: '~/.config/mimocode', met: true }, + reads: [{ at: '/.mimocode/agents', when: 'workspaceUnder' }], + source: 'MiMoCode 0.1.12 reads project .mimocode/agents; the user config root enables delivery in a fresh workspace', + }, { tool: 'muse', scope: 'user', writes: ['~/.config/muse/agents'], diff --git a/src/__tests__/locate-matrix.test.ts b/src/__tests__/locate-matrix.test.ts index 5756964c3a..eb39042c23 100644 --- a/src/__tests__/locate-matrix.test.ts +++ b/src/__tests__/locate-matrix.test.ts @@ -62,6 +62,34 @@ const ROWS: readonly FilesRow[] = [ reads: [{ at: '/.opencode/skills', when: 'workspaceUnder' }, { at: '/.claude/skills', when: 'workspaceUnder' }], source: OPENCODE_SOURCE, }, + { + tool: 'mimocode', scope: 'user', + writes: ['~/.config/mimocode/skills'], + existingDirs: ['~/.config/mimocode'], installed: { probe: '~/.config/mimocode', met: true }, + reads: [{ at: '~/.config/mimocode/skills', when: 'always' }], + source: 'MiMoCode 0.1.12: config home plus skills/', + }, + { + tool: 'mimocode', scope: 'user', env: { XDG_CONFIG_HOME: '/xdg' }, + writes: ['/xdg/mimocode/skills'], + existingDirs: ['/xdg/mimocode'], installed: { probe: '/xdg/mimocode', met: true }, + reads: [{ at: '/xdg/mimocode/skills', when: 'always' }], + source: 'MiMoCode 0.1.12: XDG_CONFIG_HOME/mimocode is the config home without MIMOCODE_HOME', + }, + { + tool: 'mimocode', scope: 'user', env: { MIMOCODE_HOME: '/mimo', XDG_CONFIG_HOME: '/xdg' }, + writes: ['/mimo/config/skills'], + existingDirs: ['/mimo/config'], installed: { probe: '/mimo/config', met: true }, + reads: [{ at: '/mimo/config/skills', when: 'always' }], + source: 'MiMoCode 0.1.12: MIMOCODE_HOME/config takes precedence over XDG_CONFIG_HOME', + }, + { + tool: 'mimocode', scope: 'project', + writes: ['/.mimocode/skills'], + existingDirs: ['~/.config/mimocode'], installed: { probe: '~/.config/mimocode', met: true }, + reads: [{ at: '/.mimocode/skills', when: 'workspaceUnder' }], + source: 'MiMoCode 0.1.12 reads project .mimocode/skills; the user config root enables delivery in a fresh workspace', + }, { tool: 'joycode', scope: 'user', env: { JOYCODE_HOME: '/joycode' }, writes: ['/joycode/skills'], diff --git a/src/__tests__/locate-mcp.test.ts b/src/__tests__/locate-mcp.test.ts index 969dfdecb9..a0073b3fcc 100644 --- a/src/__tests__/locate-mcp.test.ts +++ b/src/__tests__/locate-mcp.test.ts @@ -643,6 +643,20 @@ const COMPLETE_ROWS: readonly MatrixRow[] = [ source: 'teamai reader relationship: tclaude shares Claude project MCP, assumed', writtenBy: 'claude', }, + { + tool: 'mimocode', scope: 'user', + channel: 'none', + existingDirs: ['~/.config/mimocode'], + installed: { probe: '~/.config/mimocode', met: true }, + source: 'TeamAI does not write user MCP configuration for MiMoCode', + }, + { + tool: 'mimocode', scope: 'project', + channel: 'none', + existingDirs: ['~/.config/mimocode'], + installed: { probe: '~/.config/mimocode', met: true }, + source: 'TeamAI does not write project MCP configuration for MiMoCode', + }, { tool: 'trae', scope: 'user', channel: 'none', diff --git a/src/__tests__/locate.test.ts b/src/__tests__/locate.test.ts index fb373eec7b..d16916601f 100644 --- a/src/__tests__/locate.test.ts +++ b/src/__tests__/locate.test.ts @@ -152,7 +152,7 @@ describe('envToolHome', () => { type MoveCase = { tool: ToolId; env: Record; dir: string | null }; const cases: MoveCase[] = Object.keys(TOOLS).filter(isToolId).flatMap((tool) => { const { home } = TOOLS[tool]; - return 'moves' in home ? home.moves.by.flatMap((move) => { + return 'moves' in home ? home.moves.by.flatMap((move): MoveCase[] => { switch (move.kind) { case 'env': return [ @@ -175,6 +175,11 @@ describe('envToolHome', () => { { tool, env: { QODERCN_CONFIG_DIR: ' ', QODERCN_CLI_HOME: '/abs/cli' }, dir: '/abs/cli/.qoder-cn' }, { tool, env: { QODERCN_CONFIG_DIR: ' ', QODERCN_CLI_HOME: ' ' }, dir: null }, ]; + case 'absolute-env-child': + return [ + { tool, env: { [move.name]: 'rel/home' }, dir: null }, + { tool, env: { [move.name]: '/abs/home', XDG_CONFIG_HOME: '/xdg' }, dir: `/abs/home/${move.child}` }, + ]; case 'xdg': return [ { tool, env: { XDG_CONFIG_HOME: 'rel/config' }, dir: null }, diff --git a/src/__tests__/self-mode-agents.test.ts b/src/__tests__/self-mode-agents.test.ts index 2a5b80adf4..2b25c5f329 100644 --- a/src/__tests__/self-mode-agents.test.ts +++ b/src/__tests__/self-mode-agents.test.ts @@ -93,7 +93,16 @@ describe('detectHomeInstalledAgents', () => { expect(await detectHomeInstalledAgents(['cursor'])).toEqual(['cursor']); }); - it('SELF_MODE_AGENT_CHOICES includes Pi, Copilot, JoyCode, Muse Code and Antigravity CLI among the common coding agents', () => { + it.each([ + ['MIMOCODE_HOME', ['mimo-state', 'config']], + ['XDG_CONFIG_HOME', ['mimo-state', 'mimocode']], + ] as const)('auto-detects Xiaomi MiMo via %s', async (variable, segments) => { + vi.stubEnv(variable, path.join(home, segments[0])); + await fse.ensureDir(path.join(home, ...segments)); + expect(await detectHomeInstalledAgents(['mimocode'])).toEqual(['mimocode']); + }); + + it('keeps the common coding tools in picker order', () => { expect([...SELF_MODE_AGENT_CHOICES]).toEqual([ 'claude', 'codex', @@ -105,6 +114,7 @@ describe('detectHomeInstalledAgents', () => { 'workbuddy', 'muse', 'agy', + 'mimocode', ]); }); }); diff --git a/src/__tests__/self-mode-prompt.test.ts b/src/__tests__/self-mode-prompt.test.ts index 9a475c901d..c5026abd00 100644 --- a/src/__tests__/self-mode-prompt.test.ts +++ b/src/__tests__/self-mode-prompt.test.ts @@ -71,11 +71,11 @@ describe('promptForSelfModeAgents — interactive Auto option', () => { expect(result).toEqual(['cursor']); }); - it('offers exactly 11 options (Auto + 10 tools)', async () => { + it('offers Xiaomi MiMo in the common tool picker', async () => { vi.mocked(askSelection).mockResolvedValueOnce([0]); await promptForSelfModeAgents({}); - const [, itemCount] = vi.mocked(askSelection).mock.calls[0]; - expect(itemCount).toBe(11); + const printed = logSpy.mock.calls.map((c) => String(c[0])).join('\n'); + expect(printed).toContain('12. Xiaomi MiMo (.config/mimocode)'); }); it('offers Muse Code with its ~/.config/muse root', async () => { diff --git a/src/__tests__/tools-channels.test.ts b/src/__tests__/tools-channels.test.ts index 9c5af54dc2..f64373afc1 100644 --- a/src/__tests__/tools-channels.test.ts +++ b/src/__tests__/tools-channels.test.ts @@ -68,8 +68,8 @@ describe('the descriptor\'s channels agree with the tables they replaced', () => expect(hookFormatOf(tool)).toBe(BEFORE.hookFormats[tool] ?? 'claude'); }); - it('renders agents for the same tools, and for the Trae editions their subagents directory added since', () => { - expect([...AGENT_TOOLS].sort()).toEqual([...BEFORE.agentTools, 'trae', 'trae-cn'].sort()); + it('renders agents for the previous tools, the Trae editions and MiMoCode', () => { + expect([...AGENT_TOOLS].sort()).toEqual([...BEFORE.agentTools, 'trae', 'trae-cn', 'mimocode'].sort()); }); it('marks the tools earlier releases left hooks and MCP servers for in the default home', () => { diff --git a/src/__tests__/tools.test.ts b/src/__tests__/tools.test.ts index f5405507f7..ba859285cd 100644 --- a/src/__tests__/tools.test.ts +++ b/src/__tests__/tools.test.ts @@ -50,7 +50,7 @@ describe('ToolId', () => { // KNOWN_AGENTS.skillsPath is also the no-config project root (project-agent-root.ts), // so these keep their project path; home detection reads TOOLS[tool].home instead. - const PROJECT_SKILLS_PATH: ToolId[] = ['omp', 'opencode', 'pi']; + const PROJECT_SKILLS_PATH: ToolId[] = ['mimocode', 'omp', 'opencode', 'pi']; it('gives each built-in tool the user skills path KNOWN_AGENTS reports, apart from the project-path ones', () => { const disagreements = TOOL_IDS.flatMap((tool) => { diff --git a/src/__tests__/uninstall.test.ts b/src/__tests__/uninstall.test.ts index 180ef04742..f1a1faaf16 100644 --- a/src/__tests__/uninstall.test.ts +++ b/src/__tests__/uninstall.test.ts @@ -1811,7 +1811,7 @@ console.error('Could not remove podman image teamai-warm:fedcba9876543210: podma // Every tool whose hooks TOOLS puts in a machine-wide adapter, and the user hooks Codex and Copilot run in every project. const machineWide = [ - ...Object.entries(TOOLS).flatMap(([tool, { hooks }]) => hooks.user !== 'unknown' && hooks.user.channel === 'adapter' ? [{ tool, adapter: hooks.user.adapter }] : []), + ...Object.entries(TOOLS).flatMap(([tool, { hooks }]) => hooks.user instanceof Object && hooks.user.channel === 'adapter' ? [{ tool, adapter: hooks.user.adapter }] : []), { tool: 'codex', adapter: 'codex' as const }, { tool: 'copilot', adapter: 'copilot' as const }, ]; diff --git a/src/agent-version.ts b/src/agent-version.ts index 2bf6bcec35..d4a52ea625 100644 --- a/src/agent-version.ts +++ b/src/agent-version.ts @@ -48,6 +48,7 @@ const DETECTORS: Record = { opencode: null, muse: BUILT_IN_FACTS.muse.detect.muse, agy: BUILT_IN_FACTS.agy.detect.agy, + mimocode: null, }; /** The detector for `agentType`: a tool's, or the CodeBuddy IDE's (`codebuddy-ide`). */ diff --git a/src/known-agents.ts b/src/known-agents.ts index 3943b5bdf8..7e4c438674 100644 --- a/src/known-agents.ts +++ b/src/known-agents.ts @@ -10,7 +10,7 @@ import { toolGateRoot, detectToolRoot, } from './types.js'; -import { isToolId, descriptorOf, toolOf } from './tool-registry.js'; +import { isToolId, descriptorOf, installGateOf, toolOf } from './tool-registry.js'; import { installOf, isInstalledFor, locate, ownOf, toolPathUnder } from './locate.js'; import type { LocalConfig, TeamaiConfig, Scope } from './types.js'; import type { ToolId } from './tools.js'; @@ -24,7 +24,7 @@ import { realHost, toolHome, type Host } from './tool-home.js'; * Kept small on purpose — the common coding agents, not the full KNOWN_AGENTS list. */ // oxlint-disable-next-line teamai/tool-facts -- the picker's choices in display order; a tool missing here is still detected -export const SELF_MODE_AGENT_CHOICES = ['claude', 'codex', 'cursor', 'copilot', 'pi', 'joycode', 'codebuddy', 'workbuddy', 'muse', 'agy'] as const satisfies readonly ToolId[]; +export const SELF_MODE_AGENT_CHOICES = ['claude', 'codex', 'cursor', 'copilot', 'pi', 'joycode', 'codebuddy', 'workbuddy', 'muse', 'agy', 'mimocode'] as const satisfies readonly ToolId[]; /** * Normalize the `--agent` option into a deduplicated id list. @@ -120,6 +120,7 @@ export const KNOWN_AGENTS: KnownAgent[] = [ { id: 'zcode', displayName: 'ZCode', category: 'coding', skillsPath: '.zcode/skills' }, { id: 'muse', displayName: 'Muse Code', category: 'coding', skillsPath: '.config/muse/skills' }, { id: 'agy', displayName: 'Antigravity', category: 'coding', skillsPath: '.gemini/config/skills' }, + { id: 'mimocode', displayName: 'Xiaomi MiMo', category: 'coding', skillsPath: '.mimocode/skills' }, // Lobster family { id: 'openclaw', displayName: 'OpenClaw', category: 'lobster', skillsPath: '.openclaw/skills' }, @@ -334,8 +335,10 @@ export async function detectHomeInstalledAgents( const found: string[] = []; for (const id of candidateIds) { - if (id === COPILOT_TOOL_ID) { - if (await pathExists(toolHome(COPILOT_TOOL_ID))) found.push(id); + const shipped = isToolId(id) ? id : undefined; + + if (shipped !== undefined && (shipped === COPILOT_TOOL_ID || installGateOf(shipped) === 'home-edition')) { + if (await pathExists(toolHome(shipped))) found.push(id); continue; } @@ -344,7 +347,7 @@ export async function detectHomeInstalledAgents( if (!skillsPath) continue; // The tool's own dir, e.g. ".claude" or ".config/muse" — never a shared // parent like ".config" that exists on most machines. - const rootSegment = isToolId(id) ? descriptorOf(id).home.dir : path.posix.dirname(skillsPath); + const rootSegment = shipped !== undefined ? descriptorOf(shipped).home.dir : path.posix.dirname(skillsPath); // A Claude Code relocated with CLAUDE_CONFIG_DIR (or a Codex with // CODEX_HOME) may have no default root at all; the developer still uses // it. This runs before any config exists, so the variable is the only signal. diff --git a/src/resources/agent-format.ts b/src/resources/agent-format.ts index 2df87278ab..540a932d8c 100644 --- a/src/resources/agent-format.ts +++ b/src/resources/agent-format.ts @@ -29,7 +29,10 @@ export const AGENT_FILE_EXTENSIONS = ['.agent.md', '.md', '.toml', '.json'] as c * Extract an agent name stem from a filename. * Accepts every native agent extension; returns null for other files. */ -export function agentStemFromFilename(filename: string): string | null { +export function agentStemFromFilename(filename: string, format?: ToolName): string | null { + // MiMoCode strips only .md, so foo.agent.md names foo.agent, not foo. + if (format === 'mimocode') return filename.endsWith('.md') ? path.basename(filename, '.md') : null; + for (const ext of AGENT_FILE_EXTENSIONS) { if (filename.endsWith(ext)) return filename.slice(0, -ext.length); } @@ -603,29 +606,16 @@ export function reverseFromTrae(filePath: string, content: string): ReverseResul * (e.g. `permission: { edit: deny }`), which is flattened into the frontmatter. */ export function renderForOpencode(spec: AgentSpec, resolved?: ParsedFields): RenderResult { - const frontmatterData: ParsedFields = { - description: spec.description, - mode: 'subagent', - }; - - if (spec.model !== undefined) { - frontmatterData['model'] = spec.model; - } + return renderPathNamedMarkdownAgent(spec, 'opencode', resolved); +} - // Resolved fields go before the extras, so an extras value overrides them. - Object.assign(frontmatterData, resolved); - // Flatten tool_extras.opencode into frontmatter (mode/permission/temperature/…). - const extras = spec.tool_extras?.['opencode']; +function renderPathNamedMarkdownAgent(spec: AgentSpec, tool: 'opencode' | 'mimocode', resolved?: ParsedFields): RenderResult { + const frontmatterData: ParsedFields = { description: spec.description, mode: 'subagent' }; - if (extras) { - for (const [key, value] of Object.entries(extras)) { - frontmatterData[key] = value; - } - } - - const content = matter.stringify(spec.instructions, frontmatterData); + if (spec.model !== undefined) frontmatterData['model'] = spec.model; + const fields = { ...frontmatterData, ...resolved, ...spec.tool_extras?.[tool] }; - return { ext: agentFileExtensionForTool('opencode'), content }; + return { ext: agentFileExtensionForTool(tool), content: matter.stringify(spec.instructions, fields) }; } // ─── Internal render helpers ───────────────────────────────────────────────── @@ -760,9 +750,8 @@ const COMMON_COPILOT_FIELDS = new Set(['name', 'description', 'model', 'tools']) const COMMON_CODEX_FIELDS = new Set(['name', 'description', 'developer_instructions', 'model']); const COMMON_KIRO_FIELDS = new Set(['name', 'description', 'prompt', 'model', 'tools']); -// `mode` is not carried to the AgentSpec root — it is an OpenCode-only concept -// (teamai always renders `subagent`), so it round-trips through tool_extras.opencode. -const COMMON_OPENCODE_FIELDS = new Set(['description', 'model']); +// `mode` and `variant` stay in each tool's extras, not in the shared AgentSpec. +const COMMON_PATH_NAMED_MARKDOWN_FIELDS = new Set(['description', 'model']); /** The front matter fields and trimmed body of a Markdown agent file, or why it cannot be read. */ type MarkdownAgentFile = { ok: true; fields: ParsedFields; body: string } | { ok: false; reason: string }; @@ -1103,13 +1092,19 @@ export function reverseFromCursor(filePath: string, content: string): ReverseRes * are collected into tool_extras.opencode. */ export function reverseFromOpencode(filePath: string, content: string): ReverseResult { + return reversePathNamedMarkdownAgent('opencode', path.basename(filePath, '.md'), content); +} + +function reverseFromMimocode(filePath: string, content: string): ReverseResult { + return reversePathNamedMarkdownAgent('mimocode', agentStemFromFilename(filePath, 'mimocode') ?? '', content); +} + +function reversePathNamedMarkdownAgent(tool: 'opencode' | 'mimocode', name: string, content: string): ReverseResult { const read = readMarkdownAgent(content); if (!read.ok) return read; const { fields: fm, body } = read; - const name = path.basename(filePath, '.md'); - if (!name) return { ok: false, reason: 'missing agent name (empty filename)' }; const description = AgentTextFieldSchema.parse(fm['description']); @@ -1121,7 +1116,7 @@ export function reverseFromOpencode(filePath: string, content: string): ReverseR const extras: ParsedFields = {}; for (const [key, value] of Object.entries(fm)) { - if (!COMMON_OPENCODE_FIELDS.has(key)) { + if (!COMMON_PATH_NAMED_MARKDOWN_FIELDS.has(key)) { extras[key] = value; } } @@ -1136,7 +1131,7 @@ export function reverseFromOpencode(filePath: string, content: string): ReverseR if (model !== undefined) spec.model = model; - if (Object.keys(extras).length > 0) spec.tool_extras = { opencode: extras }; + if (Object.keys(extras).length > 0) spec.tool_extras = { [tool]: extras }; return { ok: true, spec }; } @@ -1288,6 +1283,7 @@ export function agentEffortField(tool: ToolName): string | undefined { case 'tcodex': return 'model_reasoning_effort'; case 'opencode': + case 'mimocode': return 'variant'; default: return undefined; @@ -1337,7 +1333,9 @@ export function renderForTool(spec: AgentSpec, tool: ToolName, resolved?: Resolv case 'copilot': return renderForCopilot(target); case 'joycode': return renderForJoycode(target); case 'kiro': return renderForKiro(target); - case 'opencode': return renderForOpencode(target, fields); + case 'opencode': + case 'mimocode': + return renderPathNamedMarkdownAgent(target, tool, fields); case 'workbuddy': case 'workbuddypro': return renderForWorkbuddy(target); @@ -1398,6 +1396,8 @@ function reverseByParser(tool: ToolName, filePath: string, content: string): Rev return reverseFromClaude(filePath, content); case 'opencode': return reverseFromOpencode(filePath, content); + case 'mimocode': + return reverseFromMimocode(filePath, content); case 'workbuddy': case 'workbuddypro': return reverseFromWorkbuddy(filePath, content); diff --git a/src/resources/agents.ts b/src/resources/agents.ts index 61a80d255b..45a6b64063 100644 --- a/src/resources/agents.ts +++ b/src/resources/agents.ts @@ -466,7 +466,7 @@ export class AgentsHandler extends ResourceHandler { const files = await listFiles(agentsDir); for (const file of files) { - const stem = agentStemFromFilename(file); + const stem = agentStemFromFilename(file, agentFormatOf(tool)); if (stem === null) continue; @@ -1037,7 +1037,7 @@ export class AgentsHandler extends ResourceHandler { // `.toml`, `.json` or `.agent.md` beside it is the member's own file // and not ours to delete (#624 review). if (!isLegacyAgent(agentItem)) { - await removeStaleAgentSiblings(destDir, item.name, render.ext, ledger, origin); + await removeStaleAgentSiblings(destDir, item.name, render.ext, ledger, origin, agentFormatOf(tool)); } await writeFile(dest, render.content); @@ -1076,7 +1076,7 @@ export class AgentsHandler extends ResourceHandler { for (const file of await listFiles(dir)) { const copy = path.join(dir, file); - if (agentStemFromFilename(file) === item.name && await recordedUnchanged(ledger.previous, copy)) { + if (agentStemFromFilename(file, format) === item.name && await recordedUnchanged(ledger.previous, copy)) { ledger.recorder?.report('agents', copy); } } @@ -2647,10 +2647,10 @@ function warnLegacyAlias(item: ResourceItem, content: string, aliases: ModelAlia * teamai's (#993). A same-stem file of the member's stays, named. */ async function removeStaleAgentSiblings( - agentsDir: string, stem: string, targetExt: string, ledger: DeliveryLedger | undefined, origin: CopyOrigin | undefined, + agentsDir: string, stem: string, targetExt: string, ledger: DeliveryLedger | undefined, origin: CopyOrigin | undefined, format: AgentTool['format'] | undefined, ): Promise { for (const file of await listFiles(agentsDir)) { - if (agentStemFromFilename(file) !== stem || file === `${stem}${targetExt}`) continue; + if (agentStemFromFilename(file, format) !== stem || file === `${stem}${targetExt}`) continue; const sibling = path.join(agentsDir, file); const removal = await judgeRemoval(ledger?.previous, sibling, origin, ledger?.otherRecords); diff --git a/src/tool-home.ts b/src/tool-home.ts index 8f1b7706fb..7912566a3a 100644 --- a/src/tool-home.ts +++ b/src/tool-home.ts @@ -141,6 +141,12 @@ function moveOf(move: HomeMove, host: Host): EnvToolHome | null { return value ? { dir: absoluteOn(value, host), variable: move.name, kind: 'own' } : null; } + case 'absolute-env-child': { + const dir = absoluteEnv(host, move.name); + + return dir === null ? null : { dir: host.path.join(dir, move.child), variable: move.name, kind: 'own' }; + } + case 'qoder-home': return qoderHome(host); case 'qoder-cn-home': diff --git a/src/tool-registry.ts b/src/tool-registry.ts index fc2e7abf6e..6609cd111d 100644 --- a/src/tool-registry.ts +++ b/src/tool-registry.ts @@ -132,6 +132,7 @@ export function homeVariables(tool: ToolId): readonly string[] { return (home.moves?.by ?? []).flatMap((move): string[] => { switch (move.kind) { case 'env': + case 'absolute-env-child': return [move.name]; case 'qoder-home': return ['QODER_CONFIG_DIR', 'QODER_CLI_HOME']; diff --git a/src/tools.ts b/src/tools.ts index 16f5841638..0b5c63c45a 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -41,6 +41,7 @@ export const TOOL_IDS = [ 'opencode', 'muse', 'agy', + 'mimocode', ] as const; /** A built-in tool (`TOOL_IDS`). */ @@ -92,6 +93,7 @@ export const TOOLS = { opencode: BUILT_IN_FACTS.opencode.tools.opencode, muse: BUILT_IN_FACTS.muse.tools.muse, agy: BUILT_IN_FACTS.agy.tools.agy, + mimocode: BUILT_IN_FACTS.mimocode.tools.mimocode, } as const satisfies Record; type Entry = (typeof TOOLS)[T]; diff --git a/src/types.ts b/src/types.ts index 4227e06031..6ecbf46ac9 100644 --- a/src/types.ts +++ b/src/types.ts @@ -767,6 +767,11 @@ export const DEFAULT_TOOL_PATHS = { mcpProject: '.agents/plugins/teamai/mcp_config.json', userScope: { skills: '.gemini/config/skills', rules: '.gemini/config/rules', agents: '.gemini/config/agents' }, }, + mimocode: { + skills: '.mimocode/skills', + agents: '.mimocode/agents', + userScope: { skills: '.config/mimocode/skills', agents: '.config/mimocode/agents' }, + }, } satisfies Record>; export const TeamaiConfigBaseSchema = z.object({ diff --git a/src/uninstall.ts b/src/uninstall.ts index 5fae6c9ffb..b667fa72a2 100644 --- a/src/uninstall.ts +++ b/src/uninstall.ts @@ -82,7 +82,7 @@ import { BUILTIN_SKILL_NAMES, LEGACY_BUILTIN_SKILL_NAMES, isCliOwnedSkillName } import { ownedSkillFiles, prunedWhole, removeOwnedFiles, skillsGuardBase } from './skill-owned-files.js'; import { cleanupOf, hookAdapterDirIn, hookSettingsFile, installOf, isInstalledFor, locate, openclawWorkspaceDir, ownOf, SHARED_AGENT_SKILLS_PATH, toolPathUnder, workspaceHooksOf, writesOf, type Location } from './locate.js'; import { recordedHomes, realHost, reloadToolHomesHistory, toolHome, toolHomeOf, toolHomesAcrossProfiles } from './tool-home.js'; -import { baseDescriptorOf, channelsOf, folderReachOf, toolInstancesFor, hookSyntaxOf, toolOf } from './tool-registry.js'; +import { agentFormatOf, baseDescriptorOf, channelsOf, folderReachOf, toolInstancesFor, hookSyntaxOf, toolOf } from './tool-registry.js'; import { leftInstanceHookFiles } from './tool-instances.js'; import { isCodexTool } from './utils/tool-names.js'; import { describeOutsideSkillLink, readsCodexSharedSkills, readTeamSkills, skillOrigin } from './resources/skills.js'; @@ -905,7 +905,7 @@ async function discoverToolResources( if (!await pathExists(agentsDir)) continue; for (const file of await listFiles(agentsDir)) { - const name = agentStemFromFilename(path.basename(file)); + const name = agentStemFromFilename(path.basename(file), agentFormatOf(tool)); if (name === null) continue; @@ -1449,7 +1449,7 @@ async function buildRemovalPlan( const ownedAgents: string[] = []; for (const file of res.agentFiles) { - const stem = agentStemFromFilename(path.basename(file)) ?? path.basename(file); + const stem = agentStemFromFilename(path.basename(file), agentFormatOf(tool)) ?? path.basename(file); if (await ownsAgentCopy(teamConfig, localConfig, file, stem, tool, previous)) ownedAgents.push(file); else res.keptFiles.push(describeMembersDirLeft(file, teamAgentNames.get(stem) ?? `agents/${stem}.yaml`, 'uninstall'));