@hasna/recordings 0.2.6 → 0.2.7

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.
package/dist/cli/index.js CHANGED
@@ -1515,7 +1515,7 @@ function setAgentFocus(idOrName, projectId, db) {
1515
1515
  }
1516
1516
 
1517
1517
  // src/version.ts
1518
- var VERSION = "0.2.6";
1518
+ var VERSION = "0.2.7";
1519
1519
 
1520
1520
  // src/db/feedback.ts
1521
1521
  function saveFeedback(input) {
@@ -2376,6 +2376,50 @@ function applyEnhancementOptions(config, opts) {
2376
2376
  return config;
2377
2377
  }
2378
2378
 
2379
+ // src/cli/mcp-config.ts
2380
+ function escapeRegExp(value) {
2381
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2382
+ }
2383
+ function isTableHeader(line) {
2384
+ return /^\s*\[/.test(line);
2385
+ }
2386
+ function removeCodexServerBlock(content, name) {
2387
+ const headerRe = new RegExp(`^\\s*\\[mcp_servers\\.${escapeRegExp(name)}(\\..+)?\\]\\s*$`);
2388
+ const lines = content.split(`
2389
+ `);
2390
+ const out = [];
2391
+ let skipping = false;
2392
+ let removed = false;
2393
+ for (const line of lines) {
2394
+ if (isTableHeader(line)) {
2395
+ skipping = headerRe.test(line);
2396
+ if (skipping) {
2397
+ removed = true;
2398
+ continue;
2399
+ }
2400
+ }
2401
+ if (skipping)
2402
+ continue;
2403
+ out.push(line);
2404
+ }
2405
+ const normalized = out.join(`
2406
+ `).replace(/\n{3,}/g, `
2407
+
2408
+ `).replace(/^\n+/, "");
2409
+ return { content: normalized, removed };
2410
+ }
2411
+ function upsertCodexStdioBlock(content, name, mcpCmd) {
2412
+ const { content: cleaned } = removeCodexServerBlock(content, name);
2413
+ const trimmed = cleaned.replace(/\s+$/, "");
2414
+ const block = `[mcp_servers.${name}]
2415
+ command = "${mcpCmd}"
2416
+ args = []
2417
+ `;
2418
+ return trimmed.length > 0 ? `${trimmed}
2419
+
2420
+ ${block}` : block;
2421
+ }
2422
+
2379
2423
  // src/cli/index.ts
2380
2424
  var program = new Command;
2381
2425
  program.name("recordings").description("Speech-to-text recording tool \u2014 record, transcribe, and enhance with AI").version(VERSION).option("--json", "Output as JSON").option("--agent <name>", "Agent name or ID").option("--project <name>", "Project name or ID").option("--session <id>", "Session ID");
@@ -3204,19 +3248,16 @@ program.command("mcp").description("Install recordings MCP server into Claude Co
3204
3248
  if (target === "codex") {
3205
3249
  const configPath = pathJoin2(home, ".codex", "config.toml");
3206
3250
  if (fileExists(configPath)) {
3207
- let content = readFileSync3(configPath, "utf-8");
3251
+ const content = readFileSync3(configPath, "utf-8");
3208
3252
  if (opts.uninstall) {
3209
- content = content.replace(/\n\[mcp_servers\.recordings\]\ncommand = "[^"]*"\nargs = \[\]\n?/g, `
3210
- `);
3211
- } else if (!content.includes("[mcp_servers.recordings]")) {
3212
- content += `
3213
- [mcp_servers.recordings]
3214
- command = "${mcpCmd}"
3215
- args = []
3216
- `;
3253
+ const { content: next, removed } = removeCodexServerBlock(content, "recordings");
3254
+ writeFileSync(configPath, next, "utf-8");
3255
+ console.log(removed ? chalk.green(`Removed from Codex: ${configPath}`) : chalk.yellow(`Codex: no recordings MCP block found in ${configPath}`));
3256
+ } else {
3257
+ const next = upsertCodexStdioBlock(content, "recordings", mcpCmd);
3258
+ writeFileSync(configPath, next, "utf-8");
3259
+ console.log(chalk.green(`Installed into Codex: ${configPath}`));
3217
3260
  }
3218
- writeFileSync(configPath, content, "utf-8");
3219
- console.log(chalk.green(`${action} Codex: ${configPath}`));
3220
3261
  } else {
3221
3262
  console.log(chalk.yellow(`Codex config not found: ${configPath}`));
3222
3263
  }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Pure helpers for editing an agent's MCP server config.
3
+ *
4
+ * Codex stores MCP servers as TOML tables (`[mcp_servers.<name>]`). A server
5
+ * block can be written in several transport forms — stdio (`command`/`args`)
6
+ * or streamable-HTTP (`url`/`http`, optional `headers`/`env` subtables). The
7
+ * uninstall/upsert logic must treat the whole table (and any of its subtables)
8
+ * as one unit regardless of which keys it holds, instead of matching one
9
+ * hand-written key layout. These functions are exported so the round-trip is
10
+ * unit-tested without touching the real `~/.codex/config.toml`.
11
+ */
12
+ /**
13
+ * Remove the `[mcp_servers.<name>]` table AND any of its subtables
14
+ * (`[mcp_servers.<name>.env]`, `.headers`, …) with their bodies — whatever the
15
+ * transport form. A block runs from its header until the next table header or
16
+ * end of file. Returns the rewritten content and whether anything was removed.
17
+ */
18
+ export declare function removeCodexServerBlock(content: string, name: string): {
19
+ content: string;
20
+ removed: boolean;
21
+ };
22
+ /**
23
+ * Ensure exactly one stdio `[mcp_servers.<name>]` block exists, pointing at
24
+ * `mcpCmd`. Any pre-existing block (in any transport form) is replaced, so the
25
+ * install is authoritative and idempotent rather than a silent no-op.
26
+ */
27
+ export declare function upsertCodexStdioBlock(content: string, name: string, mcpCmd: string): string;
28
+ //# sourceMappingURL=mcp-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-config.d.ts","sourceRoot":"","sources":["../../src/cli/mcp-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACX;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CA4BvC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,MAAM,CAKR"}
package/dist/index.js CHANGED
@@ -774,7 +774,7 @@ function setAgentFocus(idOrName, projectId, db) {
774
774
  }
775
775
 
776
776
  // src/version.ts
777
- var VERSION = "0.2.6";
777
+ var VERSION = "0.2.7";
778
778
 
779
779
  // src/db/feedback.ts
780
780
  function saveFeedback(input) {
package/dist/mcp/index.js CHANGED
@@ -4648,7 +4648,7 @@ function setAgentFocus(idOrName, projectId, db) {
4648
4648
  }
4649
4649
 
4650
4650
  // src/version.ts
4651
- var VERSION = "0.2.6";
4651
+ var VERSION = "0.2.7";
4652
4652
 
4653
4653
  // src/db/feedback.ts
4654
4654
  function saveFeedback(input) {
@@ -18,7 +18,7 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
18
18
  var __require = import.meta.require;
19
19
 
20
20
  // src/version.ts
21
- var VERSION = "0.2.6";
21
+ var VERSION = "0.2.7";
22
22
 
23
23
  // src/db/remote-storage.ts
24
24
  import pg from "pg";
package/dist/storage.js CHANGED
@@ -613,7 +613,7 @@ function setAgentFocus(idOrName, projectId, db) {
613
613
  }
614
614
 
615
615
  // src/version.ts
616
- var VERSION = "0.2.6";
616
+ var VERSION = "0.2.7";
617
617
 
618
618
  // src/db/feedback.ts
619
619
  function saveFeedback(input) {
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.2.6";
1
+ export declare const VERSION = "0.2.7";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/recordings",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "type": "module",
5
5
  "description": "Speech-to-text recording tool with MCP and CLI — records, transcribes, and optionally enhances text using AI",
6
6
  "repository": {