editprompt 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/dist/index.js +29 -26
  3. package/package.json +6 -6
package/README.md CHANGED
@@ -120,7 +120,7 @@ While editprompt is running, you can send content to the target pane or clipboar
120
120
 
121
121
  ```bash
122
122
  # Run this command from within your editor session
123
- editprompt "your content here"
123
+ editprompt -- "your content here"
124
124
  ```
125
125
 
126
126
  This sends the content to the target pane (or clipboard) while keeping your editor open, so you can continue editing and send multiple times.
@@ -140,7 +140,7 @@ if vim.env.EDITPROMPT then
140
140
 
141
141
  -- Execute editprompt command
142
142
  vim.system(
143
- { "editprompt", content },
143
+ { "editprompt", "--", content },
144
144
  { text = true },
145
145
  function(obj)
146
146
  vim.schedule(function()
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import { promisify } from "node:util";
8
8
  import clipboardy from "clipboardy";
9
9
 
10
10
  //#region package.json
11
- var version = "0.5.1";
11
+ var version = "0.5.2";
12
12
 
13
13
  //#endregion
14
14
  //#region src/config/constants.ts
@@ -37,8 +37,7 @@ function parseEnvVars(envStrings) {
37
37
  for (const envString of envStrings) {
38
38
  const [key, ...valueParts] = envString.split("=");
39
39
  if (!key || valueParts.length === 0) throw new Error(`Invalid environment variable format: ${envString}`);
40
- const value = valueParts.join("=");
41
- result[key] = value;
40
+ result[key] = valueParts.join("=");
42
41
  }
43
42
  return result;
44
43
  }
@@ -47,19 +46,12 @@ function parseEnvVars(envStrings) {
47
46
  //#region src/utils/tempFile.ts
48
47
  function getFormattedDateTime() {
49
48
  const now = /* @__PURE__ */ new Date();
50
- const year = now.getFullYear();
51
- const month = String(now.getMonth() + 1).padStart(2, "0");
52
- const day = String(now.getDate()).padStart(2, "0");
53
- const hours = String(now.getHours()).padStart(2, "0");
54
- const minutes = String(now.getMinutes()).padStart(2, "0");
55
- const seconds = String(now.getSeconds()).padStart(2, "0");
56
- return `${year}${month}${day}${hours}${minutes}${seconds}`;
49
+ return `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, "0")}${String(now.getDate()).padStart(2, "0")}${String(now.getHours()).padStart(2, "0")}${String(now.getMinutes()).padStart(2, "0")}${String(now.getSeconds()).padStart(2, "0")}`;
57
50
  }
58
51
  async function createTempFile() {
59
52
  const tempDir = join(tmpdir(), "editprompt-prompts");
60
53
  await mkdir(tempDir, { recursive: true });
61
- const fileName = `${TEMP_FILE_PREFIX}${getFormattedDateTime()}${TEMP_FILE_EXTENSION}`;
62
- const filePath = join(tempDir, fileName);
54
+ const filePath = join(tempDir, `${TEMP_FILE_PREFIX}${getFormattedDateTime()}${TEMP_FILE_EXTENSION}`);
63
55
  await writeFile(filePath, "", "utf-8");
64
56
  return filePath;
65
57
  }
@@ -89,18 +81,17 @@ async function launchEditor(editor, filePath, envVars, sendConfig) {
89
81
  env: processEnv
90
82
  });
91
83
  editorProcess.on("error", (error) => {
92
- reject(new Error(`Failed to launch editor: ${error.message}`));
84
+ reject(/* @__PURE__ */ new Error(`Failed to launch editor: ${error.message}`));
93
85
  });
94
86
  editorProcess.on("exit", (code) => {
95
87
  if (code === 0) resolve();
96
- else reject(new Error(`Editor exited with code: ${code}`));
88
+ else reject(/* @__PURE__ */ new Error(`Editor exited with code: ${code}`));
97
89
  });
98
90
  });
99
91
  }
100
92
  async function readFileContent(filePath) {
101
93
  try {
102
- const content = await readFile(filePath, "utf-8");
103
- return processContent(content);
94
+ return processContent(await readFile(filePath, "utf-8"));
104
95
  } catch (error) {
105
96
  throw new Error(`Failed to read file: ${error instanceof Error ? error.message : "Unknown error"}`);
106
97
  }
@@ -111,8 +102,7 @@ async function openEditorAndGetContent(editorOption, envVars, sendConfig) {
111
102
  const parsedEnvVars = parseEnvVars(envVars);
112
103
  try {
113
104
  await launchEditor(editor, tempFilePath, parsedEnvVars, sendConfig);
114
- const content = await readFileContent(tempFilePath);
115
- return content;
105
+ return await readFileContent(tempFilePath);
116
106
  } catch (error) {
117
107
  if (error instanceof Error) throw error;
118
108
  throw new Error("An unknown error occurred");
@@ -208,12 +198,10 @@ function readSendConfig() {
208
198
  const targetPane = process.env.EDITPROMPT_TARGET_PANE;
209
199
  const muxValue = process.env.EDITPROMPT_MUX || "tmux";
210
200
  if (!VALID_MUX_TYPES.includes(muxValue)) throw new Error(`Invalid EDITPROMPT_MUX value: ${muxValue}. Must be one of: ${VALID_MUX_TYPES.join(", ")}`);
211
- const mux = muxValue;
212
- const alwaysCopy = process.env.EDITPROMPT_ALWAYS_COPY === "1";
213
201
  return {
214
202
  targetPane,
215
- mux,
216
- alwaysCopy
203
+ mux: muxValue,
204
+ alwaysCopy: process.env.EDITPROMPT_ALWAYS_COPY === "1"
217
205
  };
218
206
  }
219
207
 
@@ -238,10 +226,24 @@ async function runSendOnlyMode(rawContent) {
238
226
  }
239
227
  }
240
228
 
229
+ //#endregion
230
+ //#region src/utils/argumentParser.ts
231
+ /**
232
+ * Extract raw content from CLI arguments
233
+ * Prioritizes ctx.rest (for -- separator) over ctx.positionals
234
+ *
235
+ * @param rest - Arguments passed after -- separator
236
+ * @param positionals - Positional arguments
237
+ * @returns Raw content string or undefined if no content provided
238
+ */
239
+ function extractRawContent(rest, positionals) {
240
+ if (rest.length > 0) return rest.join(" ");
241
+ return positionals[0];
242
+ }
243
+
241
244
  //#endregion
242
245
  //#region src/index.ts
243
- const argv = process.argv.slice(2);
244
- await cli(argv, {
246
+ await cli(process.argv.slice(2), {
245
247
  name: "editprompt",
246
248
  description: "A CLI tool that lets you write prompts for Claude Code using your favorite text editor",
247
249
  args: {
@@ -278,7 +280,7 @@ await cli(argv, {
278
280
  },
279
281
  async run(ctx) {
280
282
  try {
281
- const rawContent = ctx.positionals[0];
283
+ const rawContent = extractRawContent(ctx.rest, ctx.positionals);
282
284
  if (rawContent !== void 0) {
283
285
  await runSendOnlyMode(rawContent);
284
286
  return;
@@ -311,4 +313,5 @@ await cli(argv, {
311
313
  }
312
314
  }, { version });
313
315
 
314
- //#endregion
316
+ //#endregion
317
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "editprompt",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "author": "eetann",
5
5
  "description": "A CLI tool that lets you write prompts for CLI tools using your favorite text editor",
6
6
  "license": "MIT",
@@ -48,10 +48,10 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@biomejs/biome": "1.9.4",
51
- "@types/bun": "^1.2.16",
52
- "@types/node": "^24.0.1",
53
- "@typescript/native-preview": "^7.0.0-dev.20250712.1",
54
- "bumpp": "^10.2.0",
51
+ "@types/bun": "^1.3.0",
52
+ "@types/node": "^24.9.1",
53
+ "@typescript/native-preview": "^7.0.0-dev.20251021.1",
54
+ "bumpp": "^10.3.1",
55
55
  "tsdown": "latest"
56
56
  },
57
57
  "dependencies": {
@@ -59,6 +59,6 @@
59
59
  "gunshi": "^0.26.3"
60
60
  },
61
61
  "peerDependencies": {
62
- "typescript": "^5"
62
+ "typescript": "^5.8.3"
63
63
  }
64
64
  }