@rajinthan17/dot-cli
Advanced tools
+24
-104
@@ -75,3 +75,3 @@ #!/usr/bin/env node | ||
| function openCursorChat(promptOrParts) { | ||
| function openCursorChat(prompt) { | ||
| if (process.platform === "darwin") { | ||
@@ -83,35 +83,15 @@ try { | ||
| } | ||
| const parts = Array.isArray(promptOrParts) | ||
| ? promptOrParts | ||
| : [{ type: "text", value: promptOrParts }]; | ||
| const lines = [ | ||
| 'tell application "Cursor" to activate', | ||
| "delay 0.5", | ||
| "delay 0.4", | ||
| 'tell application "System Events"', | ||
| 'keystroke "l" using {command down}', | ||
| "delay 0.3", | ||
| "delay 0.2", | ||
| ]; | ||
| 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)}`); | ||
| } | ||
| if (prompt) { | ||
| lines.push(`keystroke ${JSON.stringify(prompt)}`); | ||
| 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. | ||
| lines.push("end tell"); | ||
| const chatProcess = spawn("osascript", lines.flatMap((l) => ["-e", l]), { | ||
@@ -144,3 +124,2 @@ stdio: "inherit", | ||
| } | ||
| // ... fallback for non-darwin remains same or similar ... | ||
| const chatProcess = spawn("cursor", [], { stdio: "inherit" }); | ||
@@ -172,88 +151,29 @@ console.log( | ||
| program | ||
| .command("review") | ||
| .action(async () => { | ||
| const cwd = process.cwd(); | ||
| const codeReviewPath = path.join(cwd, "code-review.md"); | ||
| if (!(await exists(codeReviewPath))) { | ||
| console.error( | ||
| chalk.red( | ||
| `\n✖ code-review.md not found in current folder.\n Expected: ${codeReviewPath}\n Create it and run \`dot review\` again.\n`, | ||
| ), | ||
| ); | ||
| process.exit(1); | ||
| } | ||
| let stagedFiles = []; | ||
| let stagedDiff = ""; | ||
| .description("List the names of staged files in Git") | ||
| .action(() => { | ||
| try { | ||
| stagedFiles = execSync("git diff --cached --name-only", { | ||
| const stagedFiles = execSync("git diff --cached --name-only", { | ||
| encoding: "utf8", | ||
| cwd, | ||
| }) | ||
| .trim() | ||
| .split("\n") | ||
| .filter(Boolean); | ||
| if (stagedFiles.length === 0) { | ||
| console.error( | ||
| chalk.yellow( | ||
| "\n✖ No staged files. Stage changes first, e.g. \`git add .\` then \`dot review\`.\n", | ||
| ), | ||
| ); | ||
| process.exit(1); | ||
| } | ||
| stagedDiff = execSync("git diff --cached", { | ||
| encoding: "utf8", | ||
| cwd, | ||
| }).trim(); | ||
| } catch (e) { | ||
| if (e.status === 128 || e.message?.includes("not a git repository")) { | ||
| console.error( | ||
| chalk.red( | ||
| "\n✖ Not a git repository. Run \`dot review\` from a git repo.\n", | ||
| ), | ||
| ); | ||
| process.exit(1); | ||
| } | ||
| throw e; | ||
| } | ||
| const reviewFileName = path.basename(codeReviewPath); | ||
| const filesToTag = [...stagedFiles, reviewFileName]; | ||
| if (process.platform === "darwin") { | ||
| try { | ||
| spawn("open", ["-a", "Cursor"], { stdio: "ignore", detached: true }); | ||
| } catch { | ||
| // ignore | ||
| if (!stagedFiles) { | ||
| console.log(chalk.yellow("\nℹ No files are currently staged.\n")); | ||
| return; | ||
| } | ||
| const lines = [ | ||
| 'tell application "Cursor" to activate', | ||
| "delay 0.5", | ||
| 'tell application "System Events"', | ||
| 'keystroke "l" using {command down}', | ||
| "delay 0.3", | ||
| ]; | ||
| for (const fileName of filesToTag) { | ||
| lines.push('keystroke "@"'); | ||
| lines.push("delay 0.5"); | ||
| lines.push(`keystroke ${JSON.stringify(fileName)}`); | ||
| lines.push("delay 0.7"); | ||
| lines.push("key code 36"); // Enter to select from picker | ||
| lines.push('keystroke " "'); // Space after chip | ||
| lines.push("delay 0.2"); | ||
| } | ||
| lines.push("key code 36"); // Final Enter to submit chat | ||
| lines.push("end tell"); | ||
| spawn("osascript", lines.flatMap((l) => ["-e", l]), { | ||
| stdio: "inherit", | ||
| console.log(chalk.yellow("\n--- Staged Files for Review ---\n")); | ||
| stagedFiles.split("\n").forEach((file) => { | ||
| console.log(chalk.green(`✔ ${file}`)); | ||
| }); | ||
| } else { | ||
| spawn("cursor", [], { stdio: "inherit" }); | ||
| console.log(""); | ||
| } catch (error) { | ||
| console.error( | ||
| chalk.red("\n✖ Failed to list staged files:"), | ||
| error.message, | ||
| ); | ||
| console.log( | ||
| chalk.yellow("ℹ Make sure you are in a Git repository.\n"), | ||
| ); | ||
| } | ||
@@ -260,0 +180,0 @@ }); |
+1
-1
| { | ||
| "name": "@rajinthan17/dot-cli", | ||
| "version": "1.0.10", | ||
| "version": "1.0.11", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
10673
-18.66%307
-18.13%