Skip to content

Conversation

@TabishB
Copy link
Contributor

@TabishB TabishB commented Oct 26, 2025

Summary

  • Added $ARGUMENTS property to the OpenCode apply slash command template
  • This brings the apply command in line with proposal and archive commands
  • Includes guidance text instructing the agent to find and implement the change proposal with clarification when needed

Test plan

  • Verify the updated template is generated correctly when running openspec init or openspec update
  • Test the apply slash command with arguments to ensure it works as expected
  • Confirm the instructions are clear and the agent behaves appropriately

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements
    • Enhanced the apply command with improved prompt structure and formatting for better instruction organization.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 26, 2025

Walkthrough

The opencode.ts configurator's "apply" command frontmatter entry is augmented with an additional structured user prompt block. This includes a separator, instructional text directing users to locate change proposals, and a <UserRequest> section containing ARGUMENTS, extending the content written to openspec-apply.md.

Changes

Cohort / File(s) Summary
Apply command prompt augmentation
src/core/configurators/slash/opencode.ts
Appended structured user prompt block to the "apply" FRONTMATTER entry with separator, instructional text, and <UserRequest> section containing ARGUMENTS

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Static prompt content addition with no logic or control flow changes
  • Localized to a single configuration entry

Poem

🐰 A prompt grows richer, clearer, bright,
With structured blocks and guidance right,
The apply command now guides the way,
To spot proposals every day! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "feat: add support to apply slash command" is clearly related to the main changeset, which adds a $ARGUMENTS property and structured user prompt block to the OpenCode "apply" slash command template. The title accurately describes that functionality is being added to the apply command and is specific enough that a team member reviewing history would understand this change is about augmenting the apply slash command. While the term "support" could be slightly more descriptive (e.g., specifying "$ARGUMENTS support"), the title is not vague or generic and appropriately summarizes the primary change.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-arguments-to-apply-command

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 45266b6 and ba75a35.

📒 Files selected for processing (1)
  • src/core/configurators/slash/opencode.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/core/configurators/slash/opencode.ts

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

Copy link
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: 0

🧹 Nitpick comments (3)
test/core/init.test.ts (1)

1054-1133: Good coverage for fresh vs extend detection.

The new cases correctly assert configured flags across scenarios. Consider adding explicit marker-gating tests in extend mode to lock in the new logic:

  • CLAUDE.md exists without markers + no slash cmd markers ⇒ configured === false
  • Slash cmd file with markers exists but CLAUDE.md without markers ⇒ configured === false (for tools requiring both)

Also, you can DRY repeated choice lookups with a tiny helper:

const getChoice = (callIdx: number, value: string) =>
  mockPrompt.mock.calls[callIdx][0].choices.find((c: any) => c.value === value);
src/core/init.ts (2)

631-651: Extend-mode gating in getExistingToolStates prevents false positives.

Only compute configured states when OpenSpec is initialized; otherwise default to false. This matches the intended UX.

A small trace (debug-level) per tool when extendMode is true would help diagnose why a tool isn’t detected as configured (e.g., “missing markers in CLAUDE.md” vs “no slash commands found”). Keep it behind a quiet flag to avoid noisy output.


657-719: Marker-based configured-state detection is solid; consider a tiny helper to reduce duplication.

You check for start/end markers twice (config and slash files). Extracting a local hasMarkers(content: string) makes this easier to keep consistent and test.

Apply example refactor:

+  private hasMarkers(content: string): boolean {
+    return content.includes(OPENSPEC_MARKERS.start) && content.includes(OPENSPEC_MARKERS.end);
+  }
+
   private async isToolConfigured(
     projectPath: string,
     toolId: string
   ): Promise<boolean> {
@@
-      if (await FileSystemUtils.fileExists(configPath)) {
+      if (await FileSystemUtils.fileExists(configPath)) {
         try {
           const content = await FileSystemUtils.readFile(configPath);
-          hasConfigFile = content.includes(OPENSPEC_MARKERS.start) && content.includes(OPENSPEC_MARKERS.end);
+          hasConfigFile = this.hasMarkers(content);
         } catch {
           // If we can't read the file, treat it as not configured
           hasConfigFile = false;
         }
       }
@@
         if (await FileSystemUtils.fileExists(absolute)) {
           try {
             const content = await FileSystemUtils.readFile(absolute);
-            if (content.includes(OPENSPEC_MARKERS.start) && content.includes(OPENSPEC_MARKERS.end)) {
+            if (this.hasMarkers(content)) {
               hasSlashCommands = true;
               break; // Found at least one valid slash command
             }
           } catch {
             // If we can't read the file, continue checking others

Optional: when both are required, you could surface which prerequisite failed in a debug channel to aid users during extend runs.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a665807 and 45266b6.

📒 Files selected for processing (3)
  • src/core/configurators/slash/opencode.ts (1 hunks)
  • src/core/init.ts (3 hunks)
  • test/core/init.test.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-21T03:05:07.846Z
Learnt from: CR
PR: Fission-AI/OpenSpec#0
File: AGENTS.md:0-0
Timestamp: 2025-10-21T03:05:07.846Z
Learning: Use @/openspec/AGENTS.md to learn how to create and apply change proposals

Applied to files:

  • src/core/configurators/slash/opencode.ts
🧬 Code graph analysis (1)
src/core/init.ts (4)
src/core/config.ts (2)
  • AI_TOOLS (19-34)
  • OPENSPEC_MARKERS (3-6)
src/core/configurators/registry.ts (1)
  • ToolRegistry (7-37)
src/utils/file-system.ts (1)
  • FileSystemUtils (44-187)
src/core/configurators/slash/registry.ts (1)
  • SlashCommandRegistry (16-60)
🔇 Additional comments (3)
src/core/configurators/slash/opencode.ts (1)

25-30: Apply template now accepts arguments; looks good.

Frontmatter closes correctly and the new guidance plus $ARGUMENTS meets the PR goal.

If the apply command expects a change identifier (not free-form), consider using a wrapper for parity with archive and other tools.

Optional diff:

-The user has requested to implement the following change proposal. Find the change proposal and follow the instructions below. If you're not sure or if ambiguous, ask for clarification from the user.
-<UserRequest>
-  $ARGUMENTS
-</UserRequest>
+The user has requested to implement the following change proposal. Locate the change by ID and follow the instructions below. If unsure or ambiguous, ask for clarification.
+<ChangeId>
+  $ARGUMENTS
+</ChangeId>
src/core/init.ts (2)

24-25: Importing OPENSPEC_MARKERS is correct and necessary.


392-392: Passing extendMode into getExistingToolStates is the right call.

Prevents false “already configured” signals during first-time init.

This change adds the $ARGUMENTS property to the OpenCode apply slash command template, allowing users to pass arguments when invoking the apply command. The template now includes instructions for the agent to find and implement the change proposal, with guidance to ask for clarification when ambiguous.
@TabishB TabishB force-pushed the add-arguments-to-apply-command branch from 45266b6 to ba75a35 Compare October 27, 2025 04:55
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