@rajinthan17/dot-cli
Advanced tools
+53
-20
@@ -75,3 +75,3 @@ #!/usr/bin/env node | ||
| function openCursorChat(prompt) { | ||
| function openCursorChat(promptOrParts) { | ||
| if (process.platform === "darwin") { | ||
@@ -83,15 +83,37 @@ try { | ||
| } | ||
| const parts = Array.isArray(promptOrParts) | ||
| ? promptOrParts | ||
| : [{ type: "text", value: promptOrParts }]; | ||
| const lines = [ | ||
| 'tell application "Cursor" to activate', | ||
| "delay 0.4", | ||
| "delay 0.5", | ||
| 'tell application "System Events"', | ||
| 'keystroke "l" using {command down}', | ||
| "delay 0.2", | ||
| "delay 0.3", | ||
| ]; | ||
| if (prompt) { | ||
| lines.push(`keystroke ${JSON.stringify(prompt)}`); | ||
| for (const part of parts) { | ||
| if (!part.value) continue; | ||
| if (part.type === "tag") { | ||
| // Perform tagging sequence: @ -> wait -> filename -> wait -> enter | ||
| lines.push('keystroke "@"'); | ||
| lines.push("delay 0.4"); | ||
| lines.push(`keystroke ${JSON.stringify(part.value)}`); | ||
| lines.push("delay 0.6"); | ||
| lines.push("key code 36"); // Enter to select from picker | ||
| lines.push('keystroke " "'); // Space after chip | ||
| } else { | ||
| lines.push(`keystroke ${JSON.stringify(part.value)}`); | ||
| } | ||
| lines.push("delay 0.1"); | ||
| lines.push("key code 36"); | ||
| } | ||
| // Final enter to send the chat if it's the review command (we can detect by array vs string if we want, | ||
| // but usually user wants to review before hitting enter. | ||
| // However, the original code had 'key code 36' at the end. I'll keep it for now or make it optional.) | ||
| lines.push("key code 36"); | ||
| lines.push("end tell"); | ||
| const chatProcess = spawn("osascript", lines.flatMap((l) => ["-e", l]), { | ||
@@ -124,2 +146,3 @@ stdio: "inherit", | ||
| } | ||
| // ... fallback for non-darwin remains same or similar ... | ||
| const chatProcess = spawn("cursor", [], { stdio: "inherit" }); | ||
@@ -204,17 +227,27 @@ console.log( | ||
| const reviewFileTag = `@${path.basename(codeReviewPath)}`; | ||
| const stagedFileTags = stagedFiles.map((f) => `@${f}`).join(" "); | ||
| const reviewFileName = path.basename(codeReviewPath); | ||
| const parts = [ | ||
| { | ||
| type: "text", | ||
| value: `Review the staged changes in these files: `, | ||
| }, | ||
| ]; | ||
| const prompt = `Review the staged changes against the guidelines in ${reviewFileTag}. | ||
| stagedFiles.forEach((f, i) => { | ||
| parts.push({ type: "tag", value: f }); | ||
| if (i < stagedFiles.length - 1) { | ||
| parts.push({ type: "text", value: ", " }); | ||
| } | ||
| }); | ||
| ## Files to review | ||
| ${stagedFileTags} | ||
| parts.push({ | ||
| type: "text", | ||
| value: `\nagainst the guidelines in `, | ||
| }); | ||
| parts.push({ type: "tag", value: reviewFileName }); | ||
| parts.push({ | ||
| type: "text", | ||
| value: `.\nPlease provide feedback on any issues or suggestions.`, | ||
| }); | ||
| ## Staged diff | ||
| \`\`\`diff | ||
| ${stagedDiff} | ||
| \`\`\` | ||
| Please review the diff against the guidelines in ${reviewFileTag} and list any issues or suggestions.`; | ||
| console.log( | ||
@@ -228,5 +261,5 @@ chalk.yellow("\n--- Code review (staged vs code-review.md) ---\n"), | ||
| console.log( | ||
| chalk.blue("ℹ Opening Cursor Chat with the review prompt.\n"), | ||
| chalk.blue("ℹ Opening Cursor Chat and tagging files...\n"), | ||
| ); | ||
| openCursorChat(prompt); | ||
| openCursorChat(parts); | ||
| }); | ||
@@ -233,0 +266,0 @@ |
+1
-1
| { | ||
| "name": "@rajinthan17/dot-cli", | ||
| "version": "1.0.5", | ||
| "version": "1.0.6", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
13269
9.62%381
8.55%