feat(core): add codeassistant support#1171
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds SourceCraft Code Assistant support: updates config and docs, implements a new command adapter that emits YAML-frontmatter Markdown files under ChangesSourceCraft Tool Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@docs/supported-tools.md`:
- Line 50: Update the documented tool ID `codeassistant` to `sourcecraft`
wherever it appears in the table row containing "SourceCraft Code Assistant
(`codeassistant`)" and in the "Available tool IDs" list (the other occurrence
noted around line 79), since the runtime tool ID comes from AI_TOOLS.value;
change the inline code/label text and any backticked references so they read
`sourcecraft` and ensure the human-readable name still says "SourceCraft Code
Assistant".
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 711fa56e-cffd-4552-a8a5-56c50b2b426d
📒 Files selected for processing (5)
docs/supported-tools.mdsrc/core/command-generation/adapters/index.tssrc/core/command-generation/adapters/sourcecraft.tssrc/core/command-generation/registry.tssrc/core/config.ts
3b559d3 to
3d8c427
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/core/command-generation/adapters/codeassistant.ts`:
- Around line 27-29: The YAML frontmatter is built by directly interpolating
content.description into the template (the return that currently contains
description: ${content.description}), which can produce invalid or injectable
YAML when the description contains newlines or YAML-special characters; fix it
by producing a safe YAML scalar instead of raw interpolation — either
serialize/escape content.description via a YAML library (e.g., js-yaml
safeDump/safeLoad or dump the single key) or convert it to a properly
quoted/escaped string (e.g., JSON.stringify or a block scalar with preserved
indentation) and replace the direct interpolation in the return expression so
the generated frontmatter uses the escaped/serialized value for
content.description.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 091e7e7d-0f23-4de1-a566-7ea4b6619cf8
📒 Files selected for processing (5)
docs/supported-tools.mdsrc/core/command-generation/adapters/codeassistant.tssrc/core/command-generation/adapters/index.tssrc/core/command-generation/registry.tssrc/core/config.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/core/command-generation/adapters/index.ts
- docs/supported-tools.md
Signed-off-by: Александр Мелентьев <aleksandr4842@ya.ru>
f2a35b8 to
a70283a
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/core/command-generation/adapters/codeassistant.ts (1)
1-15:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winFix misleading JSDoc for SourceCraft Code Assistant adapter frontmatter
src/core/command-generation/adapters/codeassistant.tsclaims it follows a “frontmatter specification” and documents “Frontmatter: description”, butformatFile()emits Markdown-only content (# ${content.name}then description/body) with no YAML frontmatter (--- ... ---). Update the JSDoc to describe the actual Markdown header format (or change the implementation if YAML frontmatter is required).🤖 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/core/command-generation/adapters/codeassistant.ts` around lines 1 - 15, The JSDoc for the SourceCraft Code Assistant adapter is misleading: it claims a YAML frontmatter spec and "Frontmatter: description" while the implementation in this module (see formatFile function in codeassistant adapter) actually emits a Markdown header ("# ${content.name}") and description/body without YAML frontmatter; fix this by updating the file-level JSDoc to describe the real output format (Markdown header + description/body, file name pattern .codeassistant/commands/opsx-<id>.md) or, if YAML frontmatter is required, change the formatFile implementation to emit proper YAML frontmatter instead—modify either the JSDoc or formatFile accordingly so they match exactly.
🧹 Nitpick comments (1)
src/core/command-generation/adapters/codeassistant.ts (1)
9-9: ⚡ Quick winRemove unused import.
The
transformToHyphenCommandsimport is not used anywhere in this adapter. This appears to be leftover from a previous implementation.🧹 Proposed fix
import path from 'path'; import type { CommandContent, ToolCommandAdapter } from '../types.js'; -import { transformToHyphenCommands } from '../../../utils/command-references.js';🤖 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/core/command-generation/adapters/codeassistant.ts` at line 9, The import transformToHyphenCommands is unused in the codeassistant adapter; remove the unused import statement (the import of transformToHyphenCommands) from the top of the module to clean up dead code and avoid linter errors, leaving only imports that are actually referenced by functions/classes in this file (e.g., any remaining imports used by exports or functions in codeassistant.ts).
🤖 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.
Outside diff comments:
In `@src/core/command-generation/adapters/codeassistant.ts`:
- Around line 1-15: The JSDoc for the SourceCraft Code Assistant adapter is
misleading: it claims a YAML frontmatter spec and "Frontmatter: description"
while the implementation in this module (see formatFile function in
codeassistant adapter) actually emits a Markdown header ("# ${content.name}")
and description/body without YAML frontmatter; fix this by updating the
file-level JSDoc to describe the real output format (Markdown header +
description/body, file name pattern .codeassistant/commands/opsx-<id>.md) or, if
YAML frontmatter is required, change the formatFile implementation to emit
proper YAML frontmatter instead—modify either the JSDoc or formatFile
accordingly so they match exactly.
---
Nitpick comments:
In `@src/core/command-generation/adapters/codeassistant.ts`:
- Line 9: The import transformToHyphenCommands is unused in the codeassistant
adapter; remove the unused import statement (the import of
transformToHyphenCommands) from the top of the module to clean up dead code and
avoid linter errors, leaving only imports that are actually referenced by
functions/classes in this file (e.g., any remaining imports used by exports or
functions in codeassistant.ts).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5750b572-baf0-43ec-a824-ebd567336487
📒 Files selected for processing (1)
src/core/command-generation/adapters/codeassistant.ts
alfred-openspec
left a comment
There was a problem hiding this comment.
Thanks for adding SourceCraft support. The target is real, but I’m requesting changes before merge because the current adapter is not quite aligned with the SourceCraft command contract and the focused registry test slice fails on this head.
What I verified on head a70283a:
- SourceCraft docs: project commands live in
.codeassistant/commands/, filename becomes the slash command name, and the advanced/recommended format uses YAML frontmatter withdescriptionplus optionalargument-hint. pnpm install --frozen-lockfilepnpm vitest run test/core/command-generation/registry.test.ts test/core/command-generation/adapters.test.ts test/core/available-tools.test.ts
Blockers:
-
The registry test currently fails because the registered adapter emits Markdown-only content with no
---frontmatter, while registered command adapters are expected to include metadata unless they are in the known plain/TOML/markdown exception list. -
SourceCraft command descriptions should be generated as frontmatter metadata so they show in the
/command menu. The adapter currently emits the description as body text, even though the docs showdescription:frontmatter for advanced commands. -
The generated file names are hyphen commands like
.codeassistant/commands/opsx-apply.md, which SourceCraft exposes as/opsx-apply, but the generated bodies still reference colon commands like/opsx:apply. Please run the body throughtransformToHyphenCommands(content.body)unless SourceCraft has a documented colon-alias behavior we can cite and test. -
This needs focused coverage for the new adapter/tool ID: adapter path and format, YAML-safe description escaping,
/opsx:*to/opsx-*body transforms, registry lookup,.codeassistantdetection, and init/update generation.
The config/docs/registry tool ID consistency looks okay on current head: codeassistant is the runtime value everywhere, so the earlier sourcecraft suggestion is obsolete.
Signed-off-by: Александр Мелентьев <aleksandr4842@ya.ru>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/core/command-generation/adapters/codeassistant.ts (1)
26-28:⚠️ Potential issue | 🟠 Major | ⚡ Quick winEscape and quote frontmatter
descriptionbefore interpolation.On Line 27, raw interpolation can generate invalid YAML (or injected keys) when
content.descriptioncontains YAML-significant characters/newlines. Serialize it as a safe scalar before embedding.Proposed fix
formatFile(content: CommandContent): string { const transformedBody = transformToHyphenCommands(content.body); + const safeDescription = JSON.stringify(content.description ?? ''); return `--- -description: ${content.description} +description: ${safeDescription} --- ${transformedBody} `; },🤖 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/core/command-generation/adapters/codeassistant.ts` around lines 26 - 28, The frontmatter interpolation uses raw content.description which can break YAML; escape or quote it before embedding by serializing the scalar (e.g., replace ${content.description} with ${JSON.stringify(content.description)} or use a YAML serializer like js-yaml's dump for a safe scalar). Update the return template in codeassistant.ts to interpolate the serialized description (keep the surrounding frontmatter markers) and ensure any chosen serializer is imported and used where the current return string is built, referencing the existing content.description usage.
🤖 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.
Duplicate comments:
In `@src/core/command-generation/adapters/codeassistant.ts`:
- Around line 26-28: The frontmatter interpolation uses raw content.description
which can break YAML; escape or quote it before embedding by serializing the
scalar (e.g., replace ${content.description} with
${JSON.stringify(content.description)} or use a YAML serializer like js-yaml's
dump for a safe scalar). Update the return template in codeassistant.ts to
interpolate the serialized description (keep the surrounding frontmatter
markers) and ensure any chosen serializer is imported and used where the current
return string is built, referencing the existing content.description usage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 11323003-6104-407b-b02a-286b54641030
📒 Files selected for processing (2)
src/core/command-generation/adapters/codeassistant.tstest/core/available-tools.test.ts
|
@alfred-openspec thanks for review. Please check it again |
alfred-openspec
left a comment
There was a problem hiding this comment.
Thanks for the follow-up. The big command-shape issues are mostly fixed now: SourceCraft's docs confirm .codeassistant/commands/<name>.md, metadata frontmatter, and filename-derived /opsx-* commands, and this head now adds frontmatter plus /opsx:* to /opsx-* body transforms. I also verified pnpm install --frozen-lockfile and the focused registry/adapter/available-tools tests pass locally.
I still need one fix before approval: description is interpolated raw into YAML. OpenSpec descriptions can contain colons, quotes, newlines, or other YAML-significant characters, and SourceCraft displays that field in the command menu, so this should use the same safe scalar escaping pattern as the other hyphen-command adapters. Please also add a focused codeassistantAdapter test covering the path, frontmatter escaping, and body command-reference transform so this does not regress.
Signed-off-by: Александр Мелентьев <aleksandr4842@ya.ru>
|
@alfred-openspec thanks for review. I added needed tests |
Summary by CodeRabbit
New Features
Documentation
Tests