Skip to content

feat: add GSD tool command adapter#1082

Open
Storm-Chaser wants to merge 1 commit into
Fission-AI:mainfrom
Storm-Chaser:feat/add-gsd2-support
Open

feat: add GSD tool command adapter#1082
Storm-Chaser wants to merge 1 commit into
Fission-AI:mainfrom
Storm-Chaser:feat/add-gsd2-support

Conversation

@Storm-Chaser
Copy link
Copy Markdown

@Storm-Chaser Storm-Chaser commented May 11, 2026

Add support for GSD (Pi's project management system) as a new AI tool integration. GSD uses agent definition files stored in .gsd/agents/ directory with YAML frontmatter containing name and description fields.

Changes:

  • Add gsd.ts adapter with YAML frontmatter formatting and path generation
  • Register gsdAdapter in CommandAdapterRegistry and adapters index
  • Add unit tests covering toolId, file path generation, YAML formatting, and special character escaping in YAML values

GSD agent files follow the pattern: .gsd/agents/opsx-.md

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for generating and formatting commands for GSD, a new command adapter capability.
  • Tests

    • Added comprehensive test coverage for the new adapter functionality.

Review Change Stack

Add support for GSD (Pi's project management system) as a new AI tool
integration. GSD uses agent definition files stored in .gsd/agents/
directory with YAML frontmatter containing name and description fields.

Changes:
- Add gsd.ts adapter with YAML frontmatter formatting and path generation
- Register gsdAdapter in CommandAdapterRegistry and adapters index
- Add unit tests covering toolId, file path generation, YAML formatting,
  and special character escaping in YAML values

GSD agent files follow the pattern: .gsd/agents/opsx-<command-id>.md
@Storm-Chaser Storm-Chaser requested a review from TabishB as a code owner May 11, 2026 08:18
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

📝 Walkthrough

Walkthrough

A new GSD command adapter is implemented with YAML escaping utilities, exported through the adapters module index, and registered in the CommandAdapterRegistry static initializer. Tests validate toolId, file path generation, frontmatter formatting, and YAML special character handling.

Changes

GSD Command Adapter

Layer / File(s) Summary
YAML Escape Utility
src/core/command-generation/adapters/gsd.ts
escapeYamlValue() function safely quotes and escapes strings containing YAML special characters for frontmatter output.
Adapter Implementation
src/core/command-generation/adapters/gsd.ts
gsdAdapter exports a ToolCommandAdapter with toolId: 'gsd', generates .gsd/agents/opsx-<id>.md file paths, and formats Markdown files with YAML frontmatter (name, description) followed by command body.
Module Exports
src/core/command-generation/adapters/index.ts
gsdAdapter is re-exported from the new ./gsd.js module.
Registry Integration
src/core/command-generation/registry.ts
gsdAdapter is imported and registered in CommandAdapterRegistry static initializer alongside existing built-in adapters.
Test Coverage
test/core/command-generation/adapters.test.ts
New test suite validates gsdAdapter toolId, getFilePath() output paths, YAML frontmatter with name and description, quoting of YAML values containing special characters, and inclusion in cross-platform path handling tests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Fission-AI/OpenSpec#735: Both PRs add a new tool command adapter module implementing toolId, getFilePath, and formatFile with YAML escaping, export it from adapters/index.ts, and register it in CommandAdapterRegistry.
  • Fission-AI/OpenSpec#853: Both PRs add a new tool command adapter, update adapters/index.ts and registry.ts to export and register it, and add comprehensive tests for different tool IDs.
  • Fission-AI/OpenSpec#864: Both PRs add a new ToolCommandAdapter module and wire it into adapters index re-export and CommandAdapterRegistry static registration.

Suggested reviewers

  • TabishB

Poem

🐰 A new adapter hops in with YAML grace,
Escaping special chars without a trace,
Registered and tested, all in its place,
GSD commands now have a home—what a race! 🚀

🚥 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: add GSD tool command adapter' directly and clearly describes the main change: introducing a new GSD tool command adapter with all supporting infrastructure.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

@Storm-Chaser
Copy link
Copy Markdown
Author

支持gsd2

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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/gsd.ts`:
- Around line 16-23: The escapeYamlValue function currently quotes strings that
contain carriage returns but the replacement sequence only escapes backslashes,
double quotes, and newlines; update escapeYamlValue to also escape carriage
returns by adding a replacement for '\r' (e.g., replace(/\r/g, '\\r')) alongside
the existing .replace calls so any detected '\r' is properly escaped before
wrapping in quotes.
🪄 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: ec4b8bb6-07cc-40c7-ba0d-6552cb6789b0

📥 Commits

Reviewing files that changed from the base of the PR and between 053d8a5 and 16f73ad.

📒 Files selected for processing (4)
  • src/core/command-generation/adapters/gsd.ts
  • src/core/command-generation/adapters/index.ts
  • src/core/command-generation/registry.ts
  • test/core/command-generation/adapters.test.ts

Comment on lines +16 to +23
function escapeYamlValue(value: string): string {
const needsQuoting = /[:\n\r#{}[\],&*!|>'"%@`]|^\s|\s$/.test(value);
if (needsQuoting) {
const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n');
return `"${escaped}"`;
}
return value;
}
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Carriage return detection vs. escaping mismatch.

The regex on line 17 correctly detects \r as a character requiring quoting, but the escape logic on line 19 only handles \, ", and \n. If a value contains a carriage return, it will be quoted but the \r won't be escaped, potentially producing invalid YAML.

🛡️ Proposed fix to escape carriage returns
 function escapeYamlValue(value: string): string {
   const needsQuoting = /[:\n\r#{}[\],&*!|>'"%@`]|^\s|\s$/.test(value);
   if (needsQuoting) {
-    const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n');
+    const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n').replace(/\r/g, '\\r');
     return `"${escaped}"`;
   }
   return value;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function escapeYamlValue(value: string): string {
const needsQuoting = /[:\n\r#{}[\],&*!|>'"%@`]|^\s|\s$/.test(value);
if (needsQuoting) {
const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n');
return `"${escaped}"`;
}
return value;
}
function escapeYamlValue(value: string): string {
const needsQuoting = /[:\n\r#{}[\],&*!|>'"%@`]|^\s|\s$/.test(value);
if (needsQuoting) {
const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n').replace(/\r/g, '\\r');
return `"${escaped}"`;
}
return value;
}
🤖 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/gsd.ts` around lines 16 - 23, The
escapeYamlValue function currently quotes strings that contain carriage returns
but the replacement sequence only escapes backslashes, double quotes, and
newlines; update escapeYamlValue to also escape carriage returns by adding a
replacement for '\r' (e.g., replace(/\r/g, '\\r')) alongside the existing
.replace calls so any detected '\r' is properly escaped before wrapping in
quotes.

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.

1 participant