refactor: deduplicate OpenClaw adapter, fix clawdbot config#98
refactor: deduplicate OpenClaw adapter, fix clawdbot config#98
Conversation
Follow-up to #86 — cleanup without changing contributor attribution. - OpenClawAdapter extends ClawdbotAdapter (removes 80 lines of copy-paste) - Revert clawdbot config to legacy paths (.clawdbot/skills, AGENTS.md) - OpenClaw detection: ~/.openclaw or openclaw.json - Widen ClawdbotAdapter property types for extensibility - Fix tests: adapter count 44→45, remove stale detection assertions
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughClawdbot and OpenClaw adapters were restructured: OpenClawAdapter now extends ClawdbotAdapter. Clawdbot adapter properties gained explicit string type annotations. OpenClaw detection logic was simplified. Clawdbot agent config entries were updated. Test expectations were adjusted (adapter count and Clawdbot detection assertions). Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The TUI had a manually-maintained 44-agent AgentType union in translator.service.ts that fell out of sync when openclaw was added to core. Replace with re-export from @skillkit/core so it stays in sync automatically. Fixes CI typecheck failure from #86.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/agents/src/openclaw.ts`:
- Around line 16-21: The detection logic in isDetected was loosened by removing
the skills/ directory check; restore the original semantics so we only return
true when either (there is a local skills directory AND the global ~/.openclaw
exists) OR a local openclaw.json exists. Update isDetected to compute the
skillsDir (e.g., join(process.cwd(), 'skills')), check existsSync(skillsDir)
together with globalOpenClaw, and only OR that combined result with
existsSync(openclawConfig); keep using the same identifiers (isDetected,
globalOpenClaw, openclawConfig) and existsSync checks.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7b499885-4769-438d-a366-1a1ed2109c5e
📒 Files selected for processing (5)
packages/agents/src/__tests__/adapters.test.tspackages/agents/src/__tests__/clawdbot.test.tspackages/agents/src/clawdbot.tspackages/agents/src/openclaw.tspackages/core/src/agent-config.ts
💤 Files with no reviewable changes (1)
- packages/agents/src/tests/clawdbot.test.ts
| override async isDetected(): Promise<boolean> { | ||
| const globalOpenClaw = join(homedir(), '.openclaw'); | ||
| // OpenClaw config file | ||
| const openclawConfig = join(process.cwd(), 'openclaw.json'); | ||
|
|
||
| return ( | ||
| (existsSync(projectSkills) && existsSync(globalOpenClaw)) || | ||
| existsSync(openclawConfig) | ||
| ); | ||
| return existsSync(globalOpenClaw) || existsSync(openclawConfig); | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if there are any other detection patterns in the codebase that might conflict
echo "Checking other adapter detection patterns..."
rg -n "isDetected|existsSync.*skills" packages/agents/src/*.ts
echo ""
echo "Checking if any tests verify the old detection behavior with skills/ directory..."
rg -n "isDetected|skills.*openclaw|openclaw.*skills" packages/agents/src/__tests__/Repository: rohitg00/skillkit
Length of output: 2415
🏁 Script executed:
# Find and examine openclaw test file
find packages/agents/src/__tests__/ -name "*openclaw*" -type fRepository: rohitg00/skillkit
Length of output: 43
🏁 Script executed:
# Read the full openclaw.ts file to see context
cat -n packages/agents/src/openclaw.tsRepository: rohitg00/skillkit
Length of output: 1001
🏁 Script executed:
# Check git history for changes to skills/ directory check in openclaw.ts
git log --oneline packages/agents/src/openclaw.ts | head -20Repository: rohitg00/skillkit
Length of output: 128
🏁 Script executed:
# Search for any references to skills/ directory in openclaw-related context
rg "skills" packages/agents/src/ -i --type ts -B 2 -A 2Repository: rohitg00/skillkit
Length of output: 50373
🏁 Script executed:
# Get the actual diff from the commit that refactored openclaw
git show 808ae83 packages/agents/src/openclaw.tsRepository: rohitg00/skillkit
Length of output: 1705
🏁 Script executed:
# Check the ClawdbotAdapter parent class to understand inheritance
cat -n packages/agents/src/clawdbot.ts | head -100Repository: rohitg00/skillkit
Length of output: 2874
🏁 Script executed:
# Search for any mention of skills/ directory in openclaw context across the codebase
rg "openclaw|OpenClaw" packages/agents/src/ -B 3 -A 3 | grep -i "skills\|skill" | head -30Repository: rohitg00/skillkit
Length of output: 302
🏁 Script executed:
# Check if there's a backup or old version of openclaw file
find . -name "*openclaw*" -type f | head -20Repository: rohitg00/skillkit
Length of output: 94
🏁 Script executed:
# Look for any PR or commit message reference to `#86`
git log --all --oneline | grep -i "#86\|openclaw" | head -10Repository: rohitg00/skillkit
Length of output: 315
🏁 Script executed:
# Show the original OpenClaw adapter implementation from PR `#86`
git show 5324e45:packages/agents/src/openclaw.tsRepository: rohitg00/skillkit
Length of output: 3179
Detection logic was significantly relaxed — verify intentional scope change.
The isDetected() method previously required (skills/ directory AND ~/.openclaw exist) OR openclaw.json exists. It now returns true if either ~/.openclaw OR openclaw.json exists, removing the skills/ directory check entirely.
This means projects will now be detected as OpenClaw if the developer simply has ~/.openclaw installed globally—even without a local skills/ directory or openclaw.json file. Confirm this intentional relaxation won't cause false positives, particularly in environments where multiple developers share the same machine with a shared ~/.openclaw directory.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/agents/src/openclaw.ts` around lines 16 - 21, The detection logic in
isDetected was loosened by removing the skills/ directory check; restore the
original semantics so we only return true when either (there is a local skills
directory AND the global ~/.openclaw exists) OR a local openclaw.json exists.
Update isDetected to compute the skillsDir (e.g., join(process.cwd(),
'skills')), check existsSync(skillsDir) together with globalOpenClaw, and only
OR that combined result with existsSync(openclawConfig); keep using the same
identifiers (isDetected, globalOpenClaw, openclawConfig) and existsSync checks.
Summary
Follow-up cleanup to #86 (merged with @austinmao's full attribution).
.clawdbot/skills,AGENTS.md) — preserves existing clawdbot usersskills/,CLAUDE.md,~/.openclaw/, extended frontmatter~/.openclaworopenclaw.json. Clawdbot:~/.clawdbotorclawdbot.jsonskills/detection assertions removedTest Plan
Summary by CodeRabbit
Refactor
Chores
Tests