@windyroad/voice-tone 0.9.6 → 0.9.7-preview.1293

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.
@@ -145,5 +145,5 @@
145
145
  }
146
146
  },
147
147
  "name": "wr-voice-tone",
148
- "version": "0.9.6"
148
+ "version": "0.9.7"
149
149
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wr-voice-tone",
3
- "version": "0.9.6",
3
+ "version": "0.9.7",
4
4
  "description": "Voice, tone, and external-communications governance",
5
5
  "author": {
6
6
  "name": "Windy Road Technology",
@@ -1,3 +1,27 @@
1
+ import { readdirSync } from "node:fs";
2
+
3
+ // Resolve only this session's state files, including completed claims so an
4
+ // ambiguous short name cannot consume a different reviewer after delivery.
5
+ export function completionTarget(rawTarget, directory, prefix, rolePrefix = "") {
6
+ if (typeof rawTarget !== "string" || !rawTarget) return "";
7
+ const canonical = rawTarget.startsWith("/root/");
8
+ const target = canonical ? rawTarget.slice(6) : rawTarget;
9
+ let files;
10
+ try { files = readdirSync(directory); } catch { return ""; }
11
+ const targets = new Set();
12
+ for (const file of files) {
13
+ if (!file.startsWith(prefix)) continue;
14
+ const encoded = file.slice(prefix.length).replace(/\.(claim|done)$/, "");
15
+ const decoded = Buffer.from(encoded, "base64url").toString();
16
+ if (Buffer.from(decoded).toString("base64url") !== encoded || !decoded.startsWith(rolePrefix)) continue;
17
+ targets.add(decoded.slice(rolePrefix.length));
18
+ }
19
+ if (targets.has(target)) return target;
20
+ if (canonical) return "";
21
+ const matches = [...targets].filter((registered) => registered.endsWith("/" + target));
22
+ return matches.length === 1 ? matches[0] : "";
23
+ }
24
+
1
25
  export const SPAWN_TOOLS = new Set([
2
26
  "collaboration.spawn_agent",
3
27
  "collaborationspawn_agent",
@@ -5,7 +5,7 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameS
5
5
  import { dirname, join } from "node:path";
6
6
  import { spawnSync } from "node:child_process";
7
7
  import { fileURLToPath } from "node:url";
8
- import { CLOSE_TOOLS, SPAWN_TOOLS, WAIT_TOOLS, response } from "../hooks/lib/codex-completion-input.mjs";
8
+ import { CLOSE_TOOLS, SPAWN_TOOLS, WAIT_TOOLS, completionTarget, response } from "../hooks/lib/codex-completion-input.mjs";
9
9
 
10
10
  const hookDir = dirname(fileURLToPath(import.meta.url));
11
11
  const role = "wr-voice-tone:external-comms";
@@ -246,7 +246,7 @@ function writeMarker(input, registered, target, output, completedAt, claimed) {
246
246
  }
247
247
 
248
248
  function complete(input, target, output) {
249
- target = normalizeTarget(target);
249
+ target = completionTarget(target, stateDir(input.session_id), "codex-review-", role + ":");
250
250
  if (!target || typeof output !== "string" || !output) return;
251
251
  const path = statePath(input, target);
252
252
  if (existsSync(statePath(input, target, ".done"))) return;
@@ -5,7 +5,7 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameS
5
5
  import { dirname, join } from "node:path";
6
6
  import { spawnSync } from "node:child_process";
7
7
  import { fileURLToPath } from "node:url";
8
- import { CLOSE_TOOLS, SPAWN_TOOLS, WAIT_TOOLS, response } from "../hooks/lib/codex-completion-input.mjs";
8
+ import { CLOSE_TOOLS, SPAWN_TOOLS, WAIT_TOOLS, completionTarget, response } from "../hooks/lib/codex-completion-input.mjs";
9
9
 
10
10
  const hookDir = dirname(fileURLToPath(import.meta.url));
11
11
  const role = "wr-voice-tone:agent";
@@ -246,7 +246,7 @@ function writeMarker(input, registered, target, output, completedAt, claimed) {
246
246
  }
247
247
 
248
248
  function complete(input, target, output) {
249
- target = normalizeTarget(target);
249
+ target = completionTarget(target, stateDir(input.session_id), "codex-review-", role + ":");
250
250
  if (!target || typeof output !== "string" || !output) return;
251
251
  const path = statePath(input, target);
252
252
  if (existsSync(statePath(input, target, ".done"))) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windyroad/voice-tone",
3
- "version": "0.9.6",
3
+ "version": "0.9.7-preview.1293",
4
4
  "description": "Voice and tone enforcement for user-facing copy",
5
5
  "bin": {
6
6
  "windyroad-voice-tone": "./bin/install.mjs"