Skip to content

Cursor Sdk Cleanup#360

Merged
arul28 merged 3 commits into
mainfrom
ade/cursor-sdk-cleanup-17f7c5d8
May 26, 2026
Merged

Cursor Sdk Cleanup#360
arul28 merged 3 commits into
mainfrom
ade/cursor-sdk-cleanup-17f7c5d8

Conversation

@arul28
Copy link
Copy Markdown
Owner

@arul28 arul28 commented May 25, 2026

Summary

Describe the change.

What Changed

Key files and behaviors.

Validation

How you tested.

Risks

Anything to watch.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for linking lanes to Linear issues via the CLI (link-linear-issue command)
    • Added Cursor slash commands and subagent discovery for improved IDE integration
  • Improvements

    • Refactored slash command discovery system to better support Claude, Codex, and Cursor providers
    • Enhanced Linear issue display with improved project name fallback options
    • Improved chat context attachment handling for Linear issues
    • Optimized agent skill directory discovery
  • Dependencies

    • Updated SDK dependency to latest version

Review Change Stack

Greptile Summary

This PR refactors slash command discovery into a shared markdownSlashCommandDiscovery.ts module, adds Cursor IDE slash command and subagent discovery, relaxes the projectId/projectSlug requirement for Linear issue linking, and introduces a new link-linear-issue CLI subcommand.

  • Slash command refactor: Claude and Codex command discovery logic is extracted into a common markdownSlashCommandDiscovery.ts file; a new cursorSlashCommandDiscovery.ts and slashCommandPromptExpansion.ts consolidate per-provider expansion into a single dispatch function.
  • Linear issue relaxation: projectId and projectSlug are no longer required fields in parseLaneLinearIssueValue, and LinearIssueBadge now falls back to teamKey when both are absent; shared helpers (finalizeLaneLinearIssue, laneLinearIssueMissingFields, isLinkableLaneLinearIssue) are extracted into shared/laneLinearIssue.ts.
  • New CLI command: ade lanes link-linear-issue is added alongside a corresponding linkLinearIssues action registered in the allowlist.

Confidence Score: 5/5

Safe to merge; changes are well-structured refactors with tests and no correctness regressions on core paths.

The slash command discovery refactor is a clean extraction with equivalent behavior for Claude and Codex sessions. The Linear issue parsing relaxation (dropping projectId/projectSlug as required fields) is intentional and tested. The new linkLinearIssues CLI command follows existing patterns and is properly allowlisted. The one observation — Cursor built-in subagents surfacing in non-Cursor TUI autocomplete — is a UX polish item that does not corrupt data or break existing flows.

apps/desktop/src/main/services/chat/projectSlashCommandDiscovery.ts — the unified discovery aggregator includes Cursor built-in subagents that only work inside Cursor sessions.

Important Files Changed

Filename Overview
apps/desktop/src/main/services/chat/markdownSlashCommandDiscovery.ts New shared module extracted from claudeSlashCommandDiscovery; provides reusable markdown file walking, frontmatter parsing, skill discovery, and command resolution. Logic is well-factored and tested.
apps/desktop/src/main/services/chat/projectSlashCommandDiscovery.ts New unified discovery aggregator that includes Cursor slash commands; built-in Cursor subagents (/explore, /bash, /browser) are surfaced to all providers in TUI autocomplete despite being unresolvable outside a Cursor session.
apps/desktop/src/main/services/chat/cursorSlashCommandDiscovery.ts New Cursor slash command discovery module. Correctly handles .cursor/commands markdown files, .cursor/agents subagents, built-in subagents, and ADE skills directory traversal.
apps/desktop/src/main/services/chat/slashCommandPromptExpansion.ts New provider dispatch function for slash command expansion. Cleanly consolidates the previous scattered inline expansions from agentChatService.ts into a single testable unit.
apps/desktop/src/shared/laneLinearIssue.ts New shared module for Linear issue parsing/finalization. Intentionally relaxes projectId/projectSlug requirements; well-tested by accompanying test file.
apps/desktop/src/main/services/lanes/laneService.ts Removes duplicated parseLaneLinearIssue/normalizeLaneLinearIssue in favour of shared helpers; adds linkLinearIssues action. Validation logic is equivalent for all fields except projectId/projectSlug (intentionally relaxed).
apps/ade-cli/src/cli.ts Adds link-linear-issue subcommand with proper validation of --linear-issue-json and optional flags; follows existing CLI patterns.
apps/ade-cli/src/tuiClient/adeApi.ts discoverProjectSlashCommands delegates to the new discoverAllProjectSlashCommands; activateRuntime is now true only for cursor provider. Clean.
apps/desktop/src/main/services/chat/agentChatService.ts Replaces three separate inline slash command expansion blocks with a single resolveProviderSlashCommandPrompt call; adds Cursor-specific slash command discovery branch. Logic is equivalent for Claude and Codex.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User types slash command] --> B{providerSlashCommand?}
    B -- No --> C[Build normal prompt]
    B -- Yes --> D[resolveProviderSlashCommandPrompt]

    D --> E{provider}
    E -- claude --> F{Built-in or runtime command?}
    F -- Yes --> G[return null - use raw text]
    F -- No --> H[resolveClaudeSlashCommandInvocation]

    E -- codex --> I{Built-in or runtime?}
    I -- Yes --> G
    I -- No --> J[resolveClaudeSlashCommandInvocation]
    J -- not found --> K[resolveCodexSlashCommandInvocation]

    E -- cursor --> L[resolveCursorSlashCommandInvocation]
    L -- not found built-in subagent --> G

    E -- other --> G

    H --> M[promptText]
    K --> M
    L --> M
    M -- null --> N[expandedSlashCommandPrompt ?? trimmed raw input]
    M -- text --> N

    subgraph Discovery [TUI autocomplete: discoverAllProjectSlashCommands]
        P[discoverClaudeSlashCommands]
        Q[discoverCodexSlashCommands]
        R[discoverCursorSlashCommands incl. built-in subagents]
    end
Loading

Fix All in Claude Code

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/desktop/src/main/services/chat/projectSlashCommandDiscovery.ts:21-23
Cursor's three hard-coded built-in subagents (`/explore`, `/bash`, `/browser`) are unconditionally appended by `discoverCursorSlashCommands` and will therefore appear in the unified TUI autocomplete list for every provider. Because `resolveProviderSlashCommandPrompt` only expands Cursor commands when the session provider is `"cursor"`, a user in a Claude or Codex session who picks one of these from autocomplete will have the raw slash command text (e.g. `/explore`) forwarded to the LLM rather than expanded — silently producing unhelpful output. Filtering them out at the aggregation boundary keeps the shared list to file-backed commands that are actually resolvable across providers.

```suggestion
  for (const command of discoverClaudeSlashCommands(workspaceRoot)) add(command);
  for (const command of discoverCodexSlashCommands(workspaceRoot)) add(command);
  // Only include file-backed Cursor commands (source === "command") in the
  // shared list; built-in Cursor subagents (source === "subagent") are
  // Cursor-SDK-native and cannot be expanded for non-Cursor providers.
  for (const command of discoverCursorSlashCommands(workspaceRoot)) {
    if ((command as { source?: string }).source === "command" || (command as { source?: string }).source === "skill") {
      add(command);
    }
  }
```

Reviews (4): Last reviewed commit: "ship: iteration 2 — fix test-desktop sha..." | Re-trigger Greptile

@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ade Ignored Ignored Preview May 26, 2026 12:14am

@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 25, 2026

@copilot review but do not make fixes

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

📝 Walkthrough

Walkthrough

This PR consolidates Linear issue parsing across lane and chat services and refactors slash command discovery for Claude, Codex, and Cursor into a unified architecture. The changes introduce shared markdown-based discovery utilities, add Cursor slash command support, integrate all providers into the chat service, and expose lane Linear issue linking via the ADE CLI.

Changes

Lane Linear Linking & Chat Slash Command Services

Layer / File(s) Summary
Shared Linear Issue Parsing & Validation
apps/desktop/src/shared/laneLinearIssue.ts, apps/desktop/src/shared/laneLinearIssue.test.ts
New parsing/finalization utilities (parseLaneLinearIssueValue, parseLaneLinearIssueJson, finalizeLaneLinearIssue, laneLinearIssueMissingFields, isLinkableLaneLinearIssue) validate required fields, normalize priority labels, cap labels to 24 items, and determine linkability; comprehensive test suite covers parsing, validation, JSON handling, and edge cases.
Markdown Slash Command Discovery Library
apps/desktop/src/main/services/chat/markdownSlashCommandDiscovery.ts
Complete utility suite for markdown-based slash command discovery and resolution: frontmatter parsing/stripping, command/agent/skill discovery with depth limits, file resolution with basename fallback, invocation expansion with argument substitution, and ancestor config root computation for precedence ordering.
Cursor & Provider Slash Command Services
apps/desktop/src/main/services/chat/cursorSlashCommandDiscovery.ts, apps/desktop/src/main/services/chat/cursorSlashCommandDiscovery.test.ts, apps/desktop/src/main/services/chat/claudeSlashCommandDiscovery.ts, apps/desktop/src/main/services/chat/claudeSlashCommandDiscovery.test.ts, apps/desktop/src/main/services/chat/codexSlashCommandDiscovery.ts
New Cursor discovery with built-in subagents and file-based commands/agents/skills; refactored Claude discovery to use shared markdown utilities with .claude precedence; refactored Codex discovery with lowercased name handling; all three providers delegate to markdownSlashCommandDiscovery instead of local implementations.
Project Slash Command Aggregation & Provider Prompt Resolution
apps/desktop/src/main/services/chat/projectSlashCommandDiscovery.ts, apps/desktop/src/main/services/chat/slashCommandPromptExpansion.ts
Aggregates slash commands from all three providers with deduplication, /login filtering, and sorting; centralizes provider-specific prompt expansion with suppression logic for built-in commands and provider-specific fallback chains (Codex→Claude→Codex resolver).
Chat Service Integration
apps/desktop/src/main/services/chat/agentChatService.ts, apps/desktop/src/main/services/chat/agentChatService.test.ts, apps/desktop/src/main/services/chat/cursorSdkWorker.ts, apps/desktop/src/shared/agentSkillRoots.ts, apps/desktop/src/shared/agentSkillRoots.test.ts
Centralizes slash command discovery and prompt expansion via resolveProviderSlashCommandPrompt; adds explicit Cursor provider branch; reorders agent skill roots to prioritize .cursor; updates Cursor SDK agent settings to use ["all"] sources instead of ["project", "user"].
Lane Service Refactoring
apps/desktop/src/main/services/lanes/laneService.ts, apps/desktop/src/main/services/lanes/laneService.test.ts
Delegates all Linear issue parsing/finalization/validation to shared helpers; removes 100+ lines of local parsing logic; updates issue reads, writes, and list assembly; adds test for linking issues with blank project identifiers.
Lane CLI & ADE Integration
apps/ade-cli/package.json, apps/ade-cli/src/cli.ts, apps/ade-cli/src/cli.test.ts, apps/ade-cli/src/tuiClient/adeApi.ts, apps/ade-cli/src/tuiClient/__tests__/adeApi.test.ts, apps/desktop/src/main/services/adeActions/registry.ts
Adds lanes link-linear-issue subcommand parsing --linear-issue-json into object-or-array payload with optional flags; integrates Cursor SDK version ^1.0.13; delegates project slash command discovery in ADE client; enables runtime activation for cursor/droid model queries; allowlists linkLinearIssues action for lane domain.
Chat Attachments & Linear Badge UI
apps/desktop/src/shared/chatContextAttachments.ts, apps/desktop/src/shared/chatContextAttachments.test.ts, apps/desktop/src/renderer/components/lanes/LinearIssueBadge.tsx
Refactors chat attachment normalization to use shared Linear issue parsing; comprehensive tests validate normalization, merging, removal, and prompt escaping; extends LinearIssueBadge project display fallback to teamKey when projectSlug unavailable.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • arul28/ADE#274: Both PRs modify the desktop lane Linear-issue handling codepaths—main PR refactors apps/desktop/src/main/services/lanes/laneService.ts to use shared laneLinearIssue parsing/finalization helpers, while retrieved PR #274 extends the same laneService.ts flow to persist/propagate linearIssue during lane creation—so the changes are directly connected at the lane Linear-issue parsing/storage level.

  • arul28/ADE#284: The main PR's only overlapping code with PR #284 is apps/desktop/src/renderer/components/lanes/LinearIssueBadge.tsx, where both change the Linear issue badge rendering (one adjusts the "Project" field fallback logic, the other alters tooltip/JSX structure).

Suggested labels

desktop

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The PR title 'Cursor Sdk Cleanup' is vague and generic, using non-descriptive terms that don't clearly convey the actual scope of changes. Revise the title to be more specific and descriptive of the main refactoring work, such as 'Refactor slash command discovery and Linear issue utilities' or 'Extract shared markdown discovery and prompt expansion logic'.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ade/cursor-sdk-cleanup-17f7c5d8

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.

@capy-ai
Copy link
Copy Markdown

capy-ai Bot commented May 25, 2026

Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

PR Review

Scope: 32 file(s), +1478 / −716
Verdict: Looks good

This PR bumps @cursor/sdk to 1.0.13, extracts shared markdown slash-command discovery, adds Cursor-specific discovery/expansion, relaxes Linear issue linking for project-less issues, and wires CLI/TUI surfaces (link-linear-issue, dynamic Cursor model discovery). The diff is mostly mechanical extraction with targeted behavior changes that are covered by new tests.


Notes

  • Cursor slash commands: getSlashCommands for the Cursor provider now lists .cursor/commands, agents, skills, and built-in subagents instead of the generic Claude/Codex filesystem merge; send-time expansion for .cursor/commands is new and matches the documented split (agents/skills stay native to the SDK). This aligns autocomplete with what Cursor can actually expand.
  • Linear issues: parseLaneLinearIssueValue / isLinkableLaneLinearIssue intentionally allow empty projectId/projectSlug (see laneService.test.ts and laneLinearIssue.test.ts); primary upsertLaneLinearIssue still enforces core identity fields via laneLinearIssueMissingFields.
  • Cursor worker: settingSources: ["all"] widens which Cursor config layers load versus ["project", "user"]; worth watching in production if team-level rules surprise users, but ADE policy hooks still gate tool execution.
  • Dependency: @cursor/sdk ^1.0.9 → ^1.0.13 (lockfile pins platform binaries at 1.0.13). No issues spotted in the bump itself.
  • Validation: Targeted vitest was not run in this environment (vitest not installed under apps/desktop); findings are from diff review and existing test coverage in the PR.
Open in Web View Automation 

Sent by Cursor Automation: BUGBOT in Versic

Comment thread apps/desktop/src/main/services/chat/markdownSlashCommandDiscovery.ts Outdated
Comment thread apps/ade-cli/src/tuiClient/adeApi.ts Outdated
Copy link
Copy Markdown
Contributor

Copilot AI commented May 25, 2026

@copilot review but do not make fixes

Reviewed only (no fixes applied) against commit 6bd85b0.

One issue found: npm --prefix apps/desktop run typecheck fails at apps/desktop/src/shared/chatContextAttachments.test.ts:88 (Type 'string' is not assignable to type 'null | undefined'). makeAttachment uses Partial<typeof SAMPLE_ISSUE>, and SAMPLE_ISSUE.description is inferred as null, so overriding it with a string in that test now type-errors.

Targeted tests passed:

  • desktop chat/shared tests touched by this refactor
  • ade-cli src/tuiClient/__tests__/adeApi.test.ts and src/cli.test.ts

Copilot finished work on behalf of arul28 May 25, 2026 23:33
Copy link
Copy Markdown

@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: 5

🤖 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 `@apps/ade-cli/src/cli.ts`:
- Around line 2588-2590: The CLI currently allows both --include-in-pr and
--no-include-in-pr to be passed and the later assignment wins; update the
parsing logic around readFlag(args, ["--no-include-in-pr"]), readFlag(args,
["--include-in-pr"]) and input.includeInPr to detect when both flags are present
and fail fast: if both readFlag(...) calls return true, emit a clear error
message and exit with a non-zero status (or throw an Error) instead of silently
overriding; otherwise continue setting input.includeInPr as currently
implemented.

In `@apps/ade-cli/src/tuiClient/__tests__/adeApi.test.ts`:
- Around line 236-257: The test "includes Cursor command files and subagents"
currently only asserts discoverProjectSlashCommands(projectRoot) results; add
two assertion paths that invoke the CLI-layer verification for both headless and
desktop RPC transports: call the ADE CLI verification entry points used in tests
(the headless-mode verifier and the desktop socket-backed ADE RPC verifier —
e.g., the functions or helpers that simulate headless invocation and the desktop
socket-backed RPC client used elsewhere in tests) using the same temporary
projectRoot created by makeTmpRoot, then assert each returns/produces the
expected commands (matching objects with name "/review-code" and "/verifier" and
the same descriptions). Ensure you reference the same
discoverProjectSlashCommands-derived expectations so each transport path
(headless and desktop socket-backed ADE RPC) has its own
expect(...).toEqual/arrayContaining checks to prevent transport-specific
regressions.

In `@apps/desktop/src/main/services/chat/cursorSdkWorker.ts`:
- Line 343: The change broadens configuration layers by setting settingSources
to ["all"]; revert it to only the intended lane-scoped layers by using
settingSources: ["project","user"] in the Cursor SDK agent options (where the
ADE/Cursor agent is initialized) or, if broader sources must remain, add
explicit validation that filters/whitelists allowed layers and rejects
team/enterprise/plugin overrides before applying settings; update the agent
initialization path that sets settingSources to enforce this constraint and add
a short comment documenting the security rationale.

In `@apps/desktop/src/main/services/lanes/laneService.ts`:
- Around line 2380-2382: linkLinearIssues currently accepts items that pass
isLinkableLaneLinearIssue but later parseLaneLinearIssueLink uses
parseLaneLinearIssueJson which requires additional fields, causing stored links
to be dropped on read; update linkLinearIssues to validate entries against the
same requirements as parseLaneLinearIssueJson by calling
parseLaneLinearIssueJson (or reuse its validation logic) on the finalized item
(finalizeLaneLinearIssue result) before inserting, and skip/log items that fail
parseLaneLinearIssueJson so only round-trippable link rows are stored; ensure
you reference finalizeLaneLinearIssue, isLinkableLaneLinearIssue,
parseLaneLinearIssueJson, and parseLaneLinearIssueLink in the change so the
validation is aligned.

In `@apps/desktop/src/renderer/components/lanes/LinearIssueBadge.tsx`:
- Line 58: The project selection currently uses issue.projectName?.trim() ||
issue.projectSlug || issue.teamKey, which lets a whitespace-only projectSlug
win; update the fallback to trim projectSlug as well by using
issue.projectName?.trim() || issue.projectSlug?.trim() || issue.teamKey so
blank/whitespace projectSlug falls through to teamKey (change the variable
assignment for project in LinearIssueBadge component).
🪄 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: 2506e367-9441-4015-88a1-dffa686e6e22

📥 Commits

Reviewing files that changed from the base of the PR and between 7b8d9ae and 6bd85b0.

⛔ Files ignored due to path filters (6)
  • apps/ade-cli/package-lock.json is excluded by !**/package-lock.json, !**/package-lock.json
  • docs/ARCHITECTURE.md is excluded by !docs/**
  • docs/features/agents/README.md is excluded by !docs/**
  • docs/features/chat/README.md is excluded by !docs/**
  • docs/features/chat/agent-routing.md is excluded by !docs/**
  • docs/features/lanes/README.md is excluded by !docs/**
📒 Files selected for processing (26)
  • apps/ade-cli/package.json
  • apps/ade-cli/src/cli.test.ts
  • apps/ade-cli/src/cli.ts
  • apps/ade-cli/src/tuiClient/__tests__/adeApi.test.ts
  • apps/ade-cli/src/tuiClient/adeApi.ts
  • apps/desktop/src/main/services/adeActions/registry.ts
  • apps/desktop/src/main/services/chat/agentChatService.test.ts
  • apps/desktop/src/main/services/chat/agentChatService.ts
  • apps/desktop/src/main/services/chat/claudeSlashCommandDiscovery.test.ts
  • apps/desktop/src/main/services/chat/claudeSlashCommandDiscovery.ts
  • apps/desktop/src/main/services/chat/codexSlashCommandDiscovery.ts
  • apps/desktop/src/main/services/chat/cursorSdkWorker.ts
  • apps/desktop/src/main/services/chat/cursorSlashCommandDiscovery.test.ts
  • apps/desktop/src/main/services/chat/cursorSlashCommandDiscovery.ts
  • apps/desktop/src/main/services/chat/markdownSlashCommandDiscovery.ts
  • apps/desktop/src/main/services/chat/projectSlashCommandDiscovery.ts
  • apps/desktop/src/main/services/chat/slashCommandPromptExpansion.ts
  • apps/desktop/src/main/services/lanes/laneService.test.ts
  • apps/desktop/src/main/services/lanes/laneService.ts
  • apps/desktop/src/renderer/components/lanes/LinearIssueBadge.tsx
  • apps/desktop/src/shared/agentSkillRoots.test.ts
  • apps/desktop/src/shared/agentSkillRoots.ts
  • apps/desktop/src/shared/chatContextAttachments.test.ts
  • apps/desktop/src/shared/chatContextAttachments.ts
  • apps/desktop/src/shared/laneLinearIssue.test.ts
  • apps/desktop/src/shared/laneLinearIssue.ts

Comment thread apps/ade-cli/src/cli.ts
Comment on lines +2588 to +2590
if (readFlag(args, ["--no-include-in-pr"])) input.includeInPr = false;
if (readFlag(args, ["--include-in-pr"])) input.includeInPr = true;
if (readFlag(args, ["--close-on-merge"])) input.closeOnMerge = true;
Copy link
Copy Markdown

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

Reject contradictory include-in-pr flags

Passing both --include-in-pr and --no-include-in-pr currently succeeds and silently picks the later assignment. Please fail fast on conflicting flags to avoid ambiguous CLI behavior.

Suggested fix
-    if (readFlag(args, ["--no-include-in-pr"])) input.includeInPr = false;
-    if (readFlag(args, ["--include-in-pr"])) input.includeInPr = true;
+    const noIncludeInPr = readFlag(args, ["--no-include-in-pr"]);
+    const includeInPr = readFlag(args, ["--include-in-pr"]);
+    if (noIncludeInPr && includeInPr) {
+      throw new CliUsageError(
+        "Use either --include-in-pr or --no-include-in-pr, not both.",
+      );
+    }
+    if (noIncludeInPr) input.includeInPr = false;
+    if (includeInPr) input.includeInPr = true;
📝 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
if (readFlag(args, ["--no-include-in-pr"])) input.includeInPr = false;
if (readFlag(args, ["--include-in-pr"])) input.includeInPr = true;
if (readFlag(args, ["--close-on-merge"])) input.closeOnMerge = true;
const noIncludeInPr = readFlag(args, ["--no-include-in-pr"]);
const includeInPr = readFlag(args, ["--include-in-pr"]);
if (noIncludeInPr && includeInPr) {
throw new CliUsageError(
"Use either --include-in-pr or --no-include-in-pr, not both.",
);
}
if (noIncludeInPr) input.includeInPr = false;
if (includeInPr) input.includeInPr = true;
if (readFlag(args, ["--close-on-merge"])) input.closeOnMerge = true;
🤖 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 `@apps/ade-cli/src/cli.ts` around lines 2588 - 2590, The CLI currently allows
both --include-in-pr and --no-include-in-pr to be passed and the later
assignment wins; update the parsing logic around readFlag(args,
["--no-include-in-pr"]), readFlag(args, ["--include-in-pr"]) and
input.includeInPr to detect when both flags are present and fail fast: if both
readFlag(...) calls return true, emit a clear error message and exit with a
non-zero status (or throw an Error) instead of silently overriding; otherwise
continue setting input.includeInPr as currently implemented.

Comment on lines +236 to +257
it("includes Cursor command files and subagents", () => {
const projectRoot = makeTmpRoot("ade-code-cursor-command-");
const commandsDir = path.join(projectRoot, ".cursor", "commands");
const agentsDir = path.join(projectRoot, ".cursor", "agents");
fs.mkdirSync(commandsDir, { recursive: true });
fs.mkdirSync(agentsDir, { recursive: true });
fs.writeFileSync(path.join(commandsDir, "review-code.md"), "Review code.\n");
fs.writeFileSync(path.join(agentsDir, "verifier.md"), [
"---",
"description: Verify the change",
"---",
"",
"Verify.",
"",
].join("\n"));

const commands = discoverProjectSlashCommands(projectRoot);
expect(commands).toEqual(expect.arrayContaining([
expect.objectContaining({ name: "/review-code", description: "Review code." }),
expect.objectContaining({ name: "/verifier", description: "Verify the change" }),
]));
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add dual-path ADE CLI verification for these new API behaviors.

These tests validate payload wiring, but they don’t verify the required headless mode and desktop socket-backed ADE RPC paths. Please add one assertion path per mode for these added behaviors to prevent transport-specific regressions.

As per coding guidelines, "For ADE CLI changes, verify both headless mode and the desktop socket-backed ADE RPC path".

Also applies to: 260-279

🤖 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 `@apps/ade-cli/src/tuiClient/__tests__/adeApi.test.ts` around lines 236 - 257,
The test "includes Cursor command files and subagents" currently only asserts
discoverProjectSlashCommands(projectRoot) results; add two assertion paths that
invoke the CLI-layer verification for both headless and desktop RPC transports:
call the ADE CLI verification entry points used in tests (the headless-mode
verifier and the desktop socket-backed ADE RPC verifier — e.g., the functions or
helpers that simulate headless invocation and the desktop socket-backed RPC
client used elsewhere in tests) using the same temporary projectRoot created by
makeTmpRoot, then assert each returns/produces the expected commands (matching
objects with name "/review-code" and "/verifier" and the same descriptions).
Ensure you reference the same discoverProjectSlashCommands-derived expectations
so each transport path (headless and desktop socket-backed ADE RPC) has its own
expect(...).toEqual/arrayContaining checks to prevent transport-specific
regressions.

local: {
cwd: init.laneRoot,
settingSources: ["project", "user"],
settingSources: ["all"],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Cursor SDK TypeScript settingSources parameter documentation what does "all" include

💡 Result:

In Cursor SDK TypeScript, local.settingSources: ["all"] is a shorthand that includes all ambient on-disk settings layers for a local agent: project, user, team, mdm, and plugins. [1] Specifically: - "project" →.cursor/ in the workspace [1] - "user" → ~/.cursor/ [1] - "team" → team settings synced from the dashboard [1] - "mdm" → MDM-managed enterprise settings [1] - "plugins" → plugin-provided settings [1] - "all" → shorthand for all of the above [1] Note: local.settingSources only applies to local agents; cloud agents ignore this field and always load project/team/plugins instead. [1]

Citations:


Restrict settingSources to prevent cross-scope config leakage

In apps/desktop/src/main/services/chat/cursorSdkWorker.ts (line 343), changing settingSources from ["project","user"] to ["all"] expands local agent configuration layers to include not only workspace/project and user settings, but also team, MDM-managed enterprise settings, and plugin-provided settings (per Cursor SDK docs). This broadens the effective configuration beyond the lane-scoped project/user boundary and can undermine isolation and policy/hook enforcement. Revert to ["project","user"] or explicitly constrain/validate which layers are allowed for the ADE/Cursor agent and document the security rationale.

🤖 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 `@apps/desktop/src/main/services/chat/cursorSdkWorker.ts` at line 343, The
change broadens configuration layers by setting settingSources to ["all"];
revert it to only the intended lane-scoped layers by using settingSources:
["project","user"] in the Cursor SDK agent options (where the ADE/Cursor agent
is initialized) or, if broader sources must remain, add explicit validation that
filters/whitelists allowed layers and rejects team/enterprise/plugin overrides
before applying settings; update the agent initialization path that sets
settingSources to enforce this constraint and add a short comment documenting
the security rationale.

Comment thread apps/desktop/src/main/services/lanes/laneService.ts
}) {
const [copyState, setCopyState] = React.useState<CopyState>("idle");
const project = issue.projectName?.trim() || issue.projectSlug;
const project = issue.projectName?.trim() || issue.projectSlug || issue.teamKey;
Copy link
Copy Markdown

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

Trim projectSlug before fallback to avoid blank project display.

A whitespace-only projectSlug will currently win the fallback chain and render as empty text instead of teamKey.

Proposed fix
-  const project = issue.projectName?.trim() || issue.projectSlug || issue.teamKey;
+  const project = issue.projectName?.trim() || issue.projectSlug?.trim() || issue.teamKey;
📝 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
const project = issue.projectName?.trim() || issue.projectSlug || issue.teamKey;
const project = issue.projectName?.trim() || issue.projectSlug?.trim() || issue.teamKey;
🤖 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 `@apps/desktop/src/renderer/components/lanes/LinearIssueBadge.tsx` at line 58,
The project selection currently uses issue.projectName?.trim() ||
issue.projectSlug || issue.teamKey, which lets a whitespace-only projectSlug
win; update the fallback to trim projectSlug as well by using
issue.projectName?.trim() || issue.projectSlug?.trim() || issue.teamKey so
blank/whitespace projectSlug falls through to teamKey (change the variable
assignment for project in LinearIssueBadge component).

@arul28 arul28 force-pushed the ade/cursor-sdk-cleanup-17f7c5d8 branch from 6bd85b0 to 27124a5 Compare May 25, 2026 23:37
@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 25, 2026

@copilot review but do not make fixes

Copy link
Copy Markdown
Contributor

Copilot AI commented May 25, 2026

@copilot review but do not make fixes

Reviewed only (no fixes applied) at commit 27124a5.

Current status looks clean:

  • The two review concerns called out in the PR summary are addressed (candidateNames.has(/${target}) and activateRuntime: provider === "cursor").
  • Focused validation passes locally:
    • npm --prefix apps/desktop run test -- src/main/services/chat/cursorSlashCommandDiscovery.test.ts src/main/services/chat/claudeSlashCommandDiscovery.test.ts src/shared/chatContextAttachments.test.ts src/shared/laneLinearIssue.test.ts
    • npm --prefix apps/ade-cli run test -- src/tuiClient/__tests__/adeApi.test.ts src/cli.test.ts
    • npm --prefix apps/desktop run typecheck
    • npm --prefix apps/ade-cli run typecheck
  • GitHub Actions check for this branch: latest completed run succeeded, and the currently in-progress run has no failed jobs so far.

No UI changes in this review-only pass, so no screenshot applies.

Copilot finished work on behalf of arul28 May 25, 2026 23:42
@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 25, 2026

@copilot review but do not make fixes

Copy link
Copy Markdown
Contributor

Copilot AI commented May 26, 2026

@copilot review but do not make fixes

Reviewed only (no fixes applied) at commit b9b8b5b.

Findings:

  • CI: the last failed CI run on this branch (26424099878) failed in test-desktop (4) on src/renderer/components/terminals/cliLaunch.test.ts (uses the selected lane worktree to seed skill roots). The latest branch commit appears to address that shard failure; current review workflow run is still in progress and has no failed jobs yet.
  • I can reproduce that discoverProjectSlashCommands(...) includes Cursor built-in subagents globally (e.g. /explore, /bash, /browser) even from an empty temp project root, so they can appear in the TUI fallback command list independent of provider.
  • cursorSdkWorker still uses settingSources: ["all"]; I don’t see a direct failing test from this, but it is a scope expansion relative to the prior explicit ["project", "user"] setup and should be intentionally documented/confirmed.

Focused validation I ran locally is green:

  • npm --prefix apps/desktop run test -- src/renderer/components/terminals/cliLaunch.test.ts src/main/services/chat/agentChatService.test.ts src/main/services/chat/cursorSlashCommandDiscovery.test.ts
  • npm --prefix apps/desktop run typecheck
  • npm --prefix apps/ade-cli run test -- src/tuiClient/__tests__/adeApi.test.ts src/cli.test.ts
  • npm --prefix apps/ade-cli run typecheck

No UI changes in this review-only pass, so no screenshot applies.

Copilot finished work on behalf of arul28 May 26, 2026 00:02
arul28 and others added 3 commits May 25, 2026 20:13
Extract Cursor-specific slash command discovery from Claude/Codex
implementations into dedicated modules. Pull markdown parsing,
project discovery, and prompt expansion into shared services.
Extract Linear issue helpers from laneService and chat context
attachment logic into standalone shared modules with tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Type SAMPLE_ISSUE as LaneLinearIssue to fix description type mismatch
- Remove dead candidateNames.has(target) branch (target never has / prefix)
- Restrict activateRuntime to cursor provider only (was unintentionally
  including droid)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Update cliLaunch.test.ts assertion: .cursor/skills is now first
  in ancestorSkillDirs ordering (matches agentSkillRoots.ts change)
- Use Partial<LaneLinearIssue> instead of Partial<typeof SAMPLE_ISSUE>
  to allow string description overrides in test helper

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@arul28 arul28 force-pushed the ade/cursor-sdk-cleanup-17f7c5d8 branch from b9b8b5b to 110ce10 Compare May 26, 2026 00:14
@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented May 26, 2026

@copilot review but do not make fixes

Copy link
Copy Markdown
Contributor

Copilot AI commented May 26, 2026

@copilot review but do not make fixes

Reviewed only (no fixes applied) at commit 110ce10.

Current findings:

  • The concrete Greptile concern is still reproducible: discoverProjectSlashCommands(...) includes Cursor built-ins (/explore, /bash, /browser) even for an empty temp project root, so they remain in the cross-provider fallback list.
  • CI context: latest in-progress runs for this branch (26425090311 and 26425094314) currently show no failed jobs; the last completed failure on this branch remains the older shard-4 failure (cliLaunch.test.ts) from run 26424099878.

Focused local validation is green:

  • npm --prefix apps/desktop run test -- src/main/services/chat/cursorSlashCommandDiscovery.test.ts src/main/services/chat/agentChatService.test.ts src/renderer/components/terminals/cliLaunch.test.ts
  • npm --prefix apps/desktop run typecheck
  • npm --prefix apps/ade-cli run test -- src/tuiClient/__tests__/adeApi.test.ts src/cli.test.ts
  • npm --prefix apps/ade-cli run typecheck

No UI changes in this review-only pass, so no screenshot applies.

Copilot finished work on behalf of arul28 May 26, 2026 00:19
@arul28 arul28 merged commit 6d8189b into main May 26, 2026
28 checks passed
@arul28 arul28 deleted the ade/cursor-sdk-cleanup-17f7c5d8 branch May 26, 2026 00:29
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