aiterm-steer-delivery 0.1.5 → 0.1.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/CHANGELOG.md +6 -0
- package/dist/cursor-receiver.js +5 -3
- package/dist/files.d.ts +2 -0
- package/dist/files.js +4 -0
- package/dist/hook-main.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.7
|
|
4
|
+
|
|
5
|
+
- WindowsのCursor(cursor-agent 2026.09.28)はhookのstdinのJSONの先頭にBOM(U+FEFF)を付ける。`handleCursorHook`がそのまま読んで失敗し、会話への結び付けも作業中の差し込みも起きず、配送は`sending`のまま止まっていた(紅蓮氏の報告、foxで確認)。hook入口の読み取り(Codex・Claude Code・Cursor共通)と`handleCursorHook`で先頭のBOMを落とす。`withoutBom`も公開する。
|
|
6
|
+
## 0.1.6
|
|
7
|
+
|
|
8
|
+
- Cursor CLI(cursor-agent)の親もCursor親として見分ける。CLIはMCPのinitializeで`clientInfo.name`を`"Cursor"`と名乗り、`"cursor-vscode"`(Desktop)しか見ていなかったため、CLIから呼ぶとhookと背景受信の配送に乗らなかった(紅蓮氏の報告、macbookのcursor-agent 2026.09.28で確認)。
|
|
3
9
|
## 0.1.5
|
|
4
10
|
|
|
5
11
|
- Steerの導入で「再起動が要るCodex」を数える時、別のCODEX_HOMEで動くCodex(同じ端末の他の利用者やBot)まで数えていた(紅蓮氏の報告)。Linuxではprocessの環境からCODEX_HOME(無ければHOME/.codex)を読み、hookを入れた場所のものだけを数える。macOS・Windowsは他processの環境を読めないので、今までどおり数える。
|
package/dist/cursor-receiver.js
CHANGED
|
@@ -4,17 +4,19 @@ import * as fs from "node:fs";
|
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import * as path from "node:path";
|
|
6
6
|
import { z } from "zod";
|
|
7
|
-
import { waitForFileState, writeJson0600 } from "./files.js";
|
|
7
|
+
import { waitForFileState, withoutBom, writeJson0600 } from "./files.js";
|
|
8
8
|
import { CursorDeliveryError } from "./errors.js";
|
|
9
9
|
export const cursorParentSchema = z.object({
|
|
10
10
|
kind: z.literal("cursor"),
|
|
11
11
|
hook_root: z.string(),
|
|
12
12
|
}).strict();
|
|
13
13
|
const deliveryIdSchema = z.string().uuid();
|
|
14
|
+
// Cursor DesktopはMCPのinitializeで "cursor-vscode"、Cursor CLI(cursor-agent)は "Cursor" と名乗る。
|
|
15
|
+
// どちらも同じ ~/.cursor/hooks.json のhookで届く。
|
|
14
16
|
export function isCursorMcpClient(clientName) {
|
|
15
17
|
if (clientName === undefined)
|
|
16
18
|
return false;
|
|
17
|
-
return clientName === "cursor-vscode" || clientName.startsWith("cursor-vscode ");
|
|
19
|
+
return clientName === "cursor-vscode" || clientName.startsWith("cursor-vscode ") || clientName === "Cursor";
|
|
18
20
|
}
|
|
19
21
|
export function cursorHooksFile(home = process.env.HOME ?? homedir()) {
|
|
20
22
|
return path.join(process.env.CURSOR_HOME ?? path.join(home, ".cursor"), "hooks.json");
|
|
@@ -191,7 +193,7 @@ function inject(hookRoot, conv) {
|
|
|
191
193
|
export async function handleCursorHook(profile, raw, hookRoot) {
|
|
192
194
|
let parsed;
|
|
193
195
|
try {
|
|
194
|
-
parsed = JSON.parse(raw);
|
|
196
|
+
parsed = JSON.parse(withoutBom(raw));
|
|
195
197
|
}
|
|
196
198
|
catch {
|
|
197
199
|
return {};
|
package/dist/files.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** WindowsのCursorはhookのstdinのJSONの先頭にBOM(U+FEFF)を付ける。JSONとして読む前に落とす。 */
|
|
2
|
+
export declare function withoutBom(text: string): string;
|
|
1
3
|
export declare function writeJson0600(p: string, v: unknown): void;
|
|
2
4
|
export declare function writeHookJson(file: string, value: unknown): void;
|
|
3
5
|
/** directory内の状態変化を待つ。inspectが値を返した時点でresolveする。timeoutMsを省くと期限なし。 */
|
package/dist/files.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
5
|
+
/** WindowsのCursorはhookのstdinのJSONの先頭にBOM(U+FEFF)を付ける。JSONとして読む前に落とす。 */
|
|
6
|
+
export function withoutBom(text) {
|
|
7
|
+
return text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
|
|
8
|
+
}
|
|
5
9
|
export function writeJson0600(p, v) {
|
|
6
10
|
// truncate-in-place はクラッシュ/ENOSPC の窓で空・途中 JSON を残すので、temp→rename の原子的置換にする
|
|
7
11
|
const tmp = `${p}.${randomBytes(6).toString("hex")}.tmp`;
|
package/dist/hook-main.js
CHANGED
|
@@ -5,6 +5,7 @@ import { claudeHookRoot, cursorHookRoot } from "./profile.js";
|
|
|
5
5
|
import { runCodexResultHook } from "./codex-hooks.js";
|
|
6
6
|
import { prepareClaudeHookRequest, runClaudeResultHook, closeClaudeParentSession } from "./claude-receiver.js";
|
|
7
7
|
import { handleCursorHook } from "./cursor-receiver.js";
|
|
8
|
+
import { withoutBom } from "./files.js";
|
|
8
9
|
import { runCursorReceive } from "./cursor-receive.js";
|
|
9
10
|
import { channelReceiveProcess, closeClaudeSessionChannels, handleCursorChannelHook, receiveFromChannel, runClaudeChannelWaiter } from "./channel.js";
|
|
10
11
|
async function readStdin() {
|
|
@@ -12,7 +13,7 @@ async function readStdin() {
|
|
|
12
13
|
process.stdin.setEncoding("utf8");
|
|
13
14
|
for await (const chunk of process.stdin)
|
|
14
15
|
input += chunk;
|
|
15
|
-
return input;
|
|
16
|
+
return withoutBom(input);
|
|
16
17
|
}
|
|
17
18
|
/** Codexの同期hook(PostToolUse/Stop)。stdoutはCodexの公式hook出力だけに使う。失敗をStop継続のexit 2に変換しない。 */
|
|
18
19
|
export async function runCodexHookMain(profile, directory = process.argv[2]) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./profile.js";
|
|
2
2
|
export * from "./errors.js";
|
|
3
|
-
export { writeJson0600, writeHookJson, waitForFileState } from "./files.js";
|
|
3
|
+
export { writeJson0600, writeHookJson, waitForFileState, withoutBom } from "./files.js";
|
|
4
4
|
export { readRuntimeProcesses, parsePosixProcessTable, type RuntimeProcess, type NativeProcessIdentity } from "./process.js";
|
|
5
5
|
export { resolveWindowsPowerShell7, quotePowerShell, windowsPowerShellSync, windowsStartProcessArgumentList } from "./windows.js";
|
|
6
6
|
export { setupNodeExecutable } from "./setup-node.js";
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// 親AIが作業中ならそのturnへ差し込み、idleなら同じ会話へ普通に届ける。受信方式は親ごとに公式の仕組みを使う。
|
|
3
3
|
export * from "./profile.js";
|
|
4
4
|
export * from "./errors.js";
|
|
5
|
-
export { writeJson0600, writeHookJson, waitForFileState } from "./files.js";
|
|
5
|
+
export { writeJson0600, writeHookJson, waitForFileState, withoutBom } from "./files.js";
|
|
6
6
|
export { readRuntimeProcesses, parsePosixProcessTable } from "./process.js";
|
|
7
7
|
export { resolveWindowsPowerShell7, quotePowerShell, windowsPowerShellSync, windowsStartProcessArgumentList } from "./windows.js";
|
|
8
8
|
export { setupNodeExecutable } from "./setup-node.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiterm-steer-delivery",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Aiterm's steer delivery as a library: deliver text to the parent AI session that called your MCP tool — steered into the running turn when it is busy, delivered normally when it is idle. Codex (official queue + sync hooks), Claude Code (asyncRewake hooks), Cursor (hooks + background receiver).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|