refactor: simplify managed skill agent metadata#218
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (18)
🚧 Files skipped from review as they are similar to previous changes (5)
Summary by CodeRabbit
WalkthroughThis PR adds a new managed-skill-agents module that centralizes supported bundled-skill agent metadata, home-directory resolution, label/format helpers, CLI option parsing, and "agent not installed" error construction. Consuming modules (embedded-assets, bundled-skill-paths, CLI commands, output formatting, and many tests) were updated to delegate to the new module. I18n catalogs were adjusted to use a {agents} placeholder and a generic errors.skills.agentNotInstalled key; docs updated to prefer capability-based agentic-markdown; package.json bumps agentic-markdown. Sequence DiagramsequenceDiagram
participant User
participant skillCommand
participant parseManagedSkillAgentOption
participant resolveManagedSkillAgentHomeDirectory
participant readBundledSkillFileContent
participant render
User->>skillCommand: invoke skills command with --agent
alt agent option provided and valid
skillCommand->>parseManagedSkillAgentOption: parse --agent value
parseManagedSkillAgentOption-->>skillCommand: BundledSkillAgentName
skillCommand->>resolveManagedSkillAgentHomeDirectory: resolve home directory
resolveManagedSkillAgentHomeDirectory-->>skillCommand: home directory path
skillCommand->>readBundledSkillFileContent: read skill markdown
readBundledSkillFileContent->>readBundledSkillFileContent: call readManagedSkillAgent
readBundledSkillFileContent->>render: render with agent metadata (title, skillSelectionPromptTool)
render-->>skillCommand: rendered markdown
else invalid or missing agent
skillCommand->>parseManagedSkillAgentOption: parse --agent value
parseManagedSkillAgentOption->>parseManagedSkillAgentOption: throw CliUserError
parseManagedSkillAgentOption-->>skillCommand: error with formatted agent list
end
Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/application/commands/skills/bundled-skill-observation.test.ts (1)
155-161: ⚡ Quick winDerive all expected agent home subdirectories from managed metadata.
Line 156/158/160 hardcode managed home directory names. Use
readManagedSkillAgent(...).homeDirectoryNamefor DeepSeek/Trae/Trae-CN consistently so tests track manifest changes automatically.Proposed test update
- expect(resolveDeepSeekTuiHomeDirectory(env)).toBe( - join("/tmp/user-home", ".deepseek"), - ); - expect(resolveTraeHomeDirectory(env)).toBe(join("/tmp/user-home", ".trae")); - expect(resolveTraeCnHomeDirectory(env)).toBe( - join("/tmp/user-home", ".trae-cn"), - ); + expect(resolveDeepSeekTuiHomeDirectory(env)).toBe( + join("/tmp/user-home", readManagedSkillAgent("deepseek-tui").homeDirectoryName), + ); + expect(resolveTraeHomeDirectory(env)).toBe( + join("/tmp/user-home", readManagedSkillAgent("trae").homeDirectoryName), + ); + expect(resolveTraeCnHomeDirectory(env)).toBe( + join("/tmp/user-home", readManagedSkillAgent("trae-cn").homeDirectoryName), + );As per coding guidelines, "
**/*.{ts,tsx}: Never duplicate constant values across files. Define once, import or re-export with aliases elsewhere".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/application/commands/skills/bundled-skill-observation.test.ts` around lines 155 - 161, The test currently hardcodes home directory names for DeepSeek/Trae/Trae-CN; replace those literals by reading the canonical names from the managed skill metadata: call readManagedSkillAgent(env) for each agent (e.g., readManagedSkillAgent(env, "deepseek") / "trae" / "trae-cn" or the correct id used in your test harness) and use the returned .homeDirectoryName when building expected paths for resolveDeepSeekTuiHomeDirectory, resolveTraeHomeDirectory, and resolveTraeCnHomeDirectory so the assertions derive expected subdirectory names from the manifest instead of hardcoded strings.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/application/commands/skills/bundled-skill-paths.ts`:
- Around line 16-81: The file contains many one-line delegation wrappers
(resolveCodexHomeDirectory, resolveClaudeHomeDirectory,
resolveCodeBuddyHomeDirectory, resolveDeepSeekTuiHomeDirectory,
resolveHermesHomeDirectory, resolveOpenClawHomeDirectory,
resolveQoderWorkHomeDirectory, resolveTraeHomeDirectory,
resolveTraeCnHomeDirectory, resolveWorkBuddyHomeDirectory and
resolveBundledSkillHomeDirectory) that only call
resolveManagedSkillAgentHomeDirectory; remove these redundant wrappers and
update callers to import and call resolveManagedSkillAgentHomeDirectory(env,
agentName) directly (or re-export resolveManagedSkillAgentHomeDirectory under
any needed public name) so the API surface is collapsed and no single-line
pass-through functions remain.
In `@src/application/commands/skills/managed-skill-agents.test.ts`:
- Around line 37-42: Replace hardcoded POSIX paths in the
managed-skill-agents.test.ts tests by composing them with path.join;
specifically update the env object (variable name env) and all assertions that
currently use "/tmp/..." strings (including the other occurrences around lines
noted: 45-46, 51-52, and 87-99) to use join(process.cwd() or appropriate base
dirs, 'codex-home') or join(os-specific base, 'openclaw-home') so both fixture
inputs and expected values are built with join(), and import/require path.join
at the top of the test file to keep tests platform-agnostic.
---
Nitpick comments:
In `@src/application/commands/skills/bundled-skill-observation.test.ts`:
- Around line 155-161: The test currently hardcodes home directory names for
DeepSeek/Trae/Trae-CN; replace those literals by reading the canonical names
from the managed skill metadata: call readManagedSkillAgent(env) for each agent
(e.g., readManagedSkillAgent(env, "deepseek") / "trae" / "trae-cn" or the
correct id used in your test harness) and use the returned .homeDirectoryName
when building expected paths for resolveDeepSeekTuiHomeDirectory,
resolveTraeHomeDirectory, and resolveTraeCnHomeDirectory so the assertions
derive expected subdirectory names from the manifest instead of hardcoded
strings.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d409f53f-25a9-45ec-993b-8af079b9a8cd
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (26)
AGENTS.mdCLAUDE.mdcontrib/skills/shared/oo-find-skills/SKILL.mdcontrib/skills/shared/oo-find-skills/references/oo-cli-contract.mdpackage.jsonsrc/application/commands/skills/bundled-skill-observation.test.tssrc/application/commands/skills/bundled-skill-observation.tssrc/application/commands/skills/bundled-skill-paths.tssrc/application/commands/skills/check.test.tssrc/application/commands/skills/check.tssrc/application/commands/skills/embedded-assets.test.tssrc/application/commands/skills/embedded-assets.tssrc/application/commands/skills/init.test.tssrc/application/commands/skills/init.tssrc/application/commands/skills/install-output.tssrc/application/commands/skills/list.tssrc/application/commands/skills/local-skill-source.tssrc/application/commands/skills/locate.test.tssrc/application/commands/skills/locate.tssrc/application/commands/skills/managed-skill-agents.test.tssrc/application/commands/skills/managed-skill-agents.tssrc/application/commands/skills/managed-skill-host-errors.tssrc/application/commands/skills/managed-skill-host-labels.tssrc/application/commands/skills/managed-skill-hosts.tssrc/application/commands/skills/uninstall.tssrc/i18n/catalog.ts
💤 Files with no reviewable changes (2)
- src/application/commands/skills/managed-skill-host-labels.ts
- src/application/commands/skills/managed-skill-host-errors.ts
- Replaced multiple direct calls to resolveCodexHomeDirectory, resolveCodeBuddyHomeDirectory, and other similar functions with a unified approach using resolveManagedSkillAgentHomeDirectory across various test files and implementation files. - Updated tests to ensure they correctly reference the new method for resolving managed skill agent home directories. - Removed unused imports related to bundled skill paths to streamline the codebase.
Summary
Tests