Skip to content

feat(core): add codeassistant support#1171

Open
aleksandr4842 wants to merge 3 commits into
Fission-AI:mainfrom
aleksandr4842:codeassistant
Open

feat(core): add codeassistant support#1171
aleksandr4842 wants to merge 3 commits into
Fission-AI:mainfrom
aleksandr4842:codeassistant

Conversation

@aleksandr4842

@aleksandr4842 aleksandr4842 commented Jun 4, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features

    • Added support for SourceCraft Code Assistant as a selectable AI tool and enabled generation of compatible command files for it.
    • Registered the new tool so it appears alongside existing built-in tools.
  • Documentation

    • Updated supported-tools docs to list SourceCraft Code Assistant, its skills entry, and command file patterns.
  • Tests

    • Expanded tests to verify detection when the tool's skills directory is present.

@aleksandr4842 aleksandr4842 requested a review from TabishB as a code owner June 4, 2026 12:57
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds SourceCraft Code Assistant support: updates config and docs, implements a new command adapter that emits YAML-frontmatter Markdown files under .codeassistant/commands/, re-exports and registers the adapter, and adds tests for tool detection.

Changes

SourceCraft Tool Support

Layer / File(s) Summary
Configuration and documentation
src/core/config.ts, docs/supported-tools.md
Adds codeassistant to AI_TOOLS (value: "codeassistant", skillsDir: ".codeassistant"), inserts a Tool Directory row, and lists codeassistant in the --tools available IDs.
Code Assistant adapter implementation
src/core/command-generation/adapters/codeassistant.ts
New codeassistantAdapter formats command files at .codeassistant/commands/opsx-<commandId>.md with YAML frontmatter (description) and a transformed body via transformToHyphenCommands.
Adapter export and registry wiring
src/core/command-generation/adapters/index.ts, src/core/command-generation/registry.ts
Re-exports codeassistantAdapter and registers it in CommandAdapterRegistry's static initializer for discovery via registry APIs.
Availability tests
test/core/available-tools.test.ts
Adds a test asserting detection of the SourceCraft Code Assistant when .codeassistant exists and ensures existing Mistral Vibe assertions remain valid.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • TabishB
  • Israel-Laguan

Poem

🐇 I hop through code with nimble paws,
A new helper joins the cause,
YAML whispers, files appear,
Commands in rows, so neat and clear,
Hooray — this rabbit gives a cheer!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(core): add codeassistant support' clearly and concisely summarizes the main change: adding support for a new codeassistant tool to the core system.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1b06fdd and 3b559d3.

📒 Files selected for processing (5)
  • docs/supported-tools.md
  • src/core/command-generation/adapters/index.ts
  • src/core/command-generation/adapters/sourcecraft.ts
  • src/core/command-generation/registry.ts
  • src/core/config.ts

Comment thread docs/supported-tools.md

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3b559d3 and 3d8c427.

📒 Files selected for processing (5)
  • docs/supported-tools.md
  • src/core/command-generation/adapters/codeassistant.ts
  • src/core/command-generation/adapters/index.ts
  • src/core/command-generation/registry.ts
  • src/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

Comment thread src/core/command-generation/adapters/codeassistant.ts
Signed-off-by: Александр Мелентьев <aleksandr4842@ya.ru>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Fix misleading JSDoc for SourceCraft Code Assistant adapter frontmatter

src/core/command-generation/adapters/codeassistant.ts claims it follows a “frontmatter specification” and documents “Frontmatter: description”, but formatFile() 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 win

Remove unused import.

The transformToHyphenCommands import 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3d8c427 and 688bda1.

📒 Files selected for processing (1)
  • src/core/command-generation/adapters/codeassistant.ts

@alfred-openspec alfred-openspec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with description plus optional argument-hint.
  • pnpm install --frozen-lockfile
  • pnpm vitest run test/core/command-generation/registry.test.ts test/core/command-generation/adapters.test.ts test/core/available-tools.test.ts

Blockers:

  1. 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.

  2. 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 show description: frontmatter for advanced commands.

  3. 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 through transformToHyphenCommands(content.body) unless SourceCraft has a documented colon-alias behavior we can cite and test.

  4. 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, .codeassistant detection, 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>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
src/core/command-generation/adapters/codeassistant.ts (1)

26-28: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Escape and quote frontmatter description before interpolation.

On Line 27, raw interpolation can generate invalid YAML (or injected keys) when content.description contains 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

📥 Commits

Reviewing files that changed from the base of the PR and between a70283a and fbe9b7e.

📒 Files selected for processing (2)
  • src/core/command-generation/adapters/codeassistant.ts
  • test/core/available-tools.test.ts

@aleksandr4842

Copy link
Copy Markdown
Author

@alfred-openspec thanks for review. Please check it again

@alfred-openspec alfred-openspec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@aleksandr4842

Copy link
Copy Markdown
Author

@alfred-openspec thanks for review. I added needed tests

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