@meet-ai/cli 0.0.31 → 0.0.32
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/index.js +127 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16040,10 +16040,56 @@ var init_command10 = __esm(() => {
|
|
|
16040
16040
|
});
|
|
16041
16041
|
|
|
16042
16042
|
// src/lib/hooks/find-room.ts
|
|
16043
|
-
import { readdirSync, readFileSync as readFileSync3 } from "node:fs";
|
|
16043
|
+
import { readdirSync, readFileSync as readFileSync3, writeFileSync as writeFileSync2, createReadStream } from "node:fs";
|
|
16044
16044
|
import { join as join2 } from "node:path";
|
|
16045
|
-
|
|
16045
|
+
import { createInterface } from "node:readline";
|
|
16046
|
+
async function extractTeamName(transcriptPath) {
|
|
16047
|
+
try {
|
|
16048
|
+
const rl = createInterface({
|
|
16049
|
+
input: createReadStream(transcriptPath, "utf-8"),
|
|
16050
|
+
crlfDelay: Infinity
|
|
16051
|
+
});
|
|
16052
|
+
for await (const line of rl) {
|
|
16053
|
+
try {
|
|
16054
|
+
const obj = JSON.parse(line);
|
|
16055
|
+
if (obj.teamName) {
|
|
16056
|
+
rl.close();
|
|
16057
|
+
return obj.teamName;
|
|
16058
|
+
}
|
|
16059
|
+
} catch {
|
|
16060
|
+
continue;
|
|
16061
|
+
}
|
|
16062
|
+
}
|
|
16063
|
+
} catch {}
|
|
16064
|
+
return null;
|
|
16065
|
+
}
|
|
16066
|
+
function registerSession(filePath, data, sessionId) {
|
|
16067
|
+
const ids = data.session_ids ?? [data.session_id];
|
|
16068
|
+
if (!ids.includes(sessionId)) {
|
|
16069
|
+
ids.push(sessionId);
|
|
16070
|
+
}
|
|
16071
|
+
if (!ids.includes(data.session_id)) {
|
|
16072
|
+
ids.unshift(data.session_id);
|
|
16073
|
+
}
|
|
16074
|
+
data.session_ids = ids;
|
|
16075
|
+
try {
|
|
16076
|
+
writeFileSync2(filePath, JSON.stringify(data));
|
|
16077
|
+
} catch {}
|
|
16078
|
+
}
|
|
16079
|
+
async function findRoomId(sessionId, teamsDir, transcriptPath) {
|
|
16046
16080
|
const dir = teamsDir ?? `${process.env.HOME}/.claude/teams`;
|
|
16081
|
+
if (transcriptPath) {
|
|
16082
|
+
const teamName = await extractTeamName(transcriptPath);
|
|
16083
|
+
if (teamName) {
|
|
16084
|
+
const filePath = join2(dir, teamName, "meet-ai.json");
|
|
16085
|
+
try {
|
|
16086
|
+
const raw = readFileSync3(filePath, "utf-8");
|
|
16087
|
+
const data = JSON.parse(raw);
|
|
16088
|
+
registerSession(filePath, data, sessionId);
|
|
16089
|
+
return data.room_id || null;
|
|
16090
|
+
} catch {}
|
|
16091
|
+
}
|
|
16092
|
+
}
|
|
16047
16093
|
let entries;
|
|
16048
16094
|
try {
|
|
16049
16095
|
entries = readdirSync(dir);
|
|
@@ -16055,7 +16101,8 @@ function findRoomId(sessionId, teamsDir) {
|
|
|
16055
16101
|
try {
|
|
16056
16102
|
const raw = readFileSync3(filePath, "utf-8");
|
|
16057
16103
|
const data = JSON.parse(raw);
|
|
16058
|
-
|
|
16104
|
+
const knownIds = data.session_ids ?? [data.session_id];
|
|
16105
|
+
if (knownIds.includes(sessionId) || data.session_id === sessionId) {
|
|
16059
16106
|
return data.room_id || null;
|
|
16060
16107
|
}
|
|
16061
16108
|
} catch {
|
|
@@ -16107,6 +16154,39 @@ function summarize(toolName, toolInput) {
|
|
|
16107
16154
|
var truncate = (s, n) => s.slice(0, n);
|
|
16108
16155
|
var init_summarize = () => {};
|
|
16109
16156
|
|
|
16157
|
+
// src/lib/hooks/format-diff.ts
|
|
16158
|
+
function shortPath(filePath) {
|
|
16159
|
+
const parts = filePath.replace(/\\/g, "/").split("/").filter(Boolean);
|
|
16160
|
+
return parts.slice(-3).join("/");
|
|
16161
|
+
}
|
|
16162
|
+
function formatDiff(filePath, hunks) {
|
|
16163
|
+
const display = shortPath(filePath);
|
|
16164
|
+
const diffLines = hunks.map((hunk) => {
|
|
16165
|
+
const header = `@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`;
|
|
16166
|
+
return `${header}
|
|
16167
|
+
${hunk.lines.join(`
|
|
16168
|
+
`)}`;
|
|
16169
|
+
}).join(`
|
|
16170
|
+
`);
|
|
16171
|
+
return `[diff:${display}]
|
|
16172
|
+
--- a/${display}
|
|
16173
|
+
+++ b/${display}
|
|
16174
|
+
${diffLines}`;
|
|
16175
|
+
}
|
|
16176
|
+
function formatWriteDiff(filePath, content) {
|
|
16177
|
+
const display = shortPath(filePath);
|
|
16178
|
+
const lines = content.split(`
|
|
16179
|
+
`);
|
|
16180
|
+
const header = `@@ -0,0 +1,${lines.length} @@`;
|
|
16181
|
+
const addedLines = lines.map((line) => `+${line}`).join(`
|
|
16182
|
+
`);
|
|
16183
|
+
return `[diff:${display}]
|
|
16184
|
+
--- /dev/null
|
|
16185
|
+
+++ b/${display}
|
|
16186
|
+
${header}
|
|
16187
|
+
${addedLines}`;
|
|
16188
|
+
}
|
|
16189
|
+
|
|
16110
16190
|
// ../../node_modules/.bun/hono@4.11.8/node_modules/hono/dist/utils/url.js
|
|
16111
16191
|
var init_url = () => {};
|
|
16112
16192
|
|
|
@@ -16458,7 +16538,7 @@ var init_hooks = __esm(() => {
|
|
|
16458
16538
|
});
|
|
16459
16539
|
|
|
16460
16540
|
// src/commands/hook/log-tool-use/usecase.ts
|
|
16461
|
-
import { readFileSync as readFileSync4, writeFileSync as
|
|
16541
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, statSync as statSync2, rmSync } from "node:fs";
|
|
16462
16542
|
function getOrCreateParentId(sessionId) {
|
|
16463
16543
|
const path = `/tmp/meet-ai-hook-${sessionId}.msgid`;
|
|
16464
16544
|
try {
|
|
@@ -16474,7 +16554,7 @@ function getOrCreateParentId(sessionId) {
|
|
|
16474
16554
|
}
|
|
16475
16555
|
function saveParentId(sessionId, msgId) {
|
|
16476
16556
|
try {
|
|
16477
|
-
|
|
16557
|
+
writeFileSync3(`/tmp/meet-ai-hook-${sessionId}.msgid`, msgId);
|
|
16478
16558
|
} catch {}
|
|
16479
16559
|
}
|
|
16480
16560
|
async function processHookInput(rawInput, teamsDir) {
|
|
@@ -16484,7 +16564,13 @@ async function processHookInput(rawInput, teamsDir) {
|
|
|
16484
16564
|
} catch {
|
|
16485
16565
|
return "skip";
|
|
16486
16566
|
}
|
|
16487
|
-
const {
|
|
16567
|
+
const {
|
|
16568
|
+
session_id: sessionId,
|
|
16569
|
+
transcript_path: transcriptPath,
|
|
16570
|
+
tool_name: toolName,
|
|
16571
|
+
tool_input: toolInput = {},
|
|
16572
|
+
tool_response: toolResponse
|
|
16573
|
+
} = input;
|
|
16488
16574
|
if (!sessionId || !toolName)
|
|
16489
16575
|
return "skip";
|
|
16490
16576
|
if (toolName === "SendMessage")
|
|
@@ -16494,7 +16580,7 @@ async function processHookInput(rawInput, teamsDir) {
|
|
|
16494
16580
|
if (cmd.startsWith("cd ") || cmd.startsWith("meet-ai "))
|
|
16495
16581
|
return "skip";
|
|
16496
16582
|
}
|
|
16497
|
-
const roomId = findRoomId(sessionId, teamsDir);
|
|
16583
|
+
const roomId = await findRoomId(sessionId, teamsDir, transcriptPath);
|
|
16498
16584
|
if (!roomId)
|
|
16499
16585
|
return "skip";
|
|
16500
16586
|
const url2 = process.env.MEET_AI_URL;
|
|
@@ -16502,6 +16588,31 @@ async function processHookInput(rawInput, teamsDir) {
|
|
|
16502
16588
|
if (!url2 || !key)
|
|
16503
16589
|
return "skip";
|
|
16504
16590
|
const client = createHookClient(url2, key);
|
|
16591
|
+
if (toolName === "Edit" && toolResponse?.structuredPatch) {
|
|
16592
|
+
const hunks = toolResponse.structuredPatch;
|
|
16593
|
+
const filePath = typeof toolInput.file_path === "string" ? toolInput.file_path : "?";
|
|
16594
|
+
const diffContent = formatDiff(filePath, hunks);
|
|
16595
|
+
let parentId2 = getOrCreateParentId(sessionId);
|
|
16596
|
+
if (!parentId2) {
|
|
16597
|
+
parentId2 = await sendParentMessage(client, roomId);
|
|
16598
|
+
if (parentId2)
|
|
16599
|
+
saveParentId(sessionId, parentId2);
|
|
16600
|
+
}
|
|
16601
|
+
await sendLogEntry(client, roomId, diffContent, parentId2 ?? undefined);
|
|
16602
|
+
return "sent";
|
|
16603
|
+
}
|
|
16604
|
+
if (toolName === "Write" && typeof toolInput.content === "string") {
|
|
16605
|
+
const filePath = typeof toolInput.file_path === "string" ? toolInput.file_path : "?";
|
|
16606
|
+
const diffContent = formatWriteDiff(filePath, toolInput.content);
|
|
16607
|
+
let parentId2 = getOrCreateParentId(sessionId);
|
|
16608
|
+
if (!parentId2) {
|
|
16609
|
+
parentId2 = await sendParentMessage(client, roomId);
|
|
16610
|
+
if (parentId2)
|
|
16611
|
+
saveParentId(sessionId, parentId2);
|
|
16612
|
+
}
|
|
16613
|
+
await sendLogEntry(client, roomId, diffContent, parentId2 ?? undefined);
|
|
16614
|
+
return "sent";
|
|
16615
|
+
}
|
|
16505
16616
|
const summary = summarize(toolName, toolInput);
|
|
16506
16617
|
let parentId = getOrCreateParentId(sessionId);
|
|
16507
16618
|
if (!parentId) {
|
|
@@ -16645,14 +16756,14 @@ async function processPlanReview(rawInput, teamsDir) {
|
|
|
16645
16756
|
`);
|
|
16646
16757
|
return;
|
|
16647
16758
|
}
|
|
16648
|
-
const { session_id: sessionId } = input;
|
|
16759
|
+
const { session_id: sessionId, transcript_path: transcriptPath } = input;
|
|
16649
16760
|
if (!sessionId) {
|
|
16650
16761
|
process.stderr.write(`[plan-review] missing session_id
|
|
16651
16762
|
`);
|
|
16652
16763
|
return;
|
|
16653
16764
|
}
|
|
16654
16765
|
const planContent = input.tool_input?.plan || "_Agent requested to exit plan mode without a plan._";
|
|
16655
|
-
const roomId = findRoomId(sessionId, teamsDir);
|
|
16766
|
+
const roomId = await findRoomId(sessionId, teamsDir, transcriptPath);
|
|
16656
16767
|
if (!roomId) {
|
|
16657
16768
|
process.stderr.write(`[plan-review] no room found for session
|
|
16658
16769
|
`);
|
|
@@ -16833,7 +16944,7 @@ async function processQuestionReview(rawInput, teamsDir, opts) {
|
|
|
16833
16944
|
`);
|
|
16834
16945
|
return;
|
|
16835
16946
|
}
|
|
16836
|
-
const { session_id: sessionId, hook_event_name: hookEventName, tool_input: toolInput } = input;
|
|
16947
|
+
const { session_id: sessionId, transcript_path: transcriptPath, hook_event_name: hookEventName, tool_input: toolInput } = input;
|
|
16837
16948
|
if (!sessionId || !toolInput?.questions?.length) {
|
|
16838
16949
|
process.stderr.write(`[question-review] missing session_id or questions
|
|
16839
16950
|
`);
|
|
@@ -16841,7 +16952,7 @@ async function processQuestionReview(rawInput, teamsDir, opts) {
|
|
|
16841
16952
|
}
|
|
16842
16953
|
process.stderr.write(`[question-review] triggered by ${hookEventName} event
|
|
16843
16954
|
`);
|
|
16844
|
-
const roomId = findRoomId(sessionId, teamsDir);
|
|
16955
|
+
const roomId = await findRoomId(sessionId, teamsDir, transcriptPath);
|
|
16845
16956
|
if (!roomId) {
|
|
16846
16957
|
process.stderr.write(`[question-review] no room found for session
|
|
16847
16958
|
`);
|
|
@@ -17030,7 +17141,7 @@ async function processPermissionReview(rawInput, teamsDir, opts) {
|
|
|
17030
17141
|
`);
|
|
17031
17142
|
return;
|
|
17032
17143
|
}
|
|
17033
|
-
const { session_id: sessionId, hook_event_name: hookEventName, tool_name: toolName, tool_input: toolInput } = input;
|
|
17144
|
+
const { session_id: sessionId, transcript_path: transcriptPath, hook_event_name: hookEventName, tool_name: toolName, tool_input: toolInput } = input;
|
|
17034
17145
|
if (!sessionId || !toolName) {
|
|
17035
17146
|
process.stderr.write(`[permission-review] missing session_id or tool_name
|
|
17036
17147
|
`);
|
|
@@ -17044,7 +17155,7 @@ async function processPermissionReview(rawInput, teamsDir, opts) {
|
|
|
17044
17155
|
}
|
|
17045
17156
|
process.stderr.write(`[permission-review] triggered by ${hookEventName} for tool ${toolName}
|
|
17046
17157
|
`);
|
|
17047
|
-
const roomId = findRoomId(sessionId, teamsDir);
|
|
17158
|
+
const roomId = await findRoomId(sessionId, teamsDir, transcriptPath);
|
|
17048
17159
|
if (!roomId) {
|
|
17049
17160
|
process.stderr.write(`[permission-review] no room found for session
|
|
17050
17161
|
`);
|
|
@@ -54959,7 +55070,7 @@ var init_build2 = __esm(async () => {
|
|
|
54959
55070
|
});
|
|
54960
55071
|
|
|
54961
55072
|
// src/lib/process-manager.ts
|
|
54962
|
-
import { mkdirSync as mkdirSync2, readFileSync as readFileSync6, writeFileSync as
|
|
55073
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync6, writeFileSync as writeFileSync4, renameSync, lstatSync } from "node:fs";
|
|
54963
55074
|
import { homedir as homedir4 } from "node:os";
|
|
54964
55075
|
import { join as join4 } from "node:path";
|
|
54965
55076
|
function readRegistry() {
|
|
@@ -54981,7 +55092,7 @@ function writeRegistry(entries) {
|
|
|
54981
55092
|
return;
|
|
54982
55093
|
}
|
|
54983
55094
|
const tmpPath = join4(REGISTRY_DIR, `sessions.${process.pid}.${Date.now()}.tmp`);
|
|
54984
|
-
|
|
55095
|
+
writeFileSync4(tmpPath, JSON.stringify(entries, null, 2), { mode: 384 });
|
|
54985
55096
|
renameSync(tmpPath, REGISTRY_PATH);
|
|
54986
55097
|
}
|
|
54987
55098
|
function addToRegistry(entry) {
|
|
@@ -56448,7 +56559,7 @@ init_output();
|
|
|
56448
56559
|
var main = defineCommand({
|
|
56449
56560
|
meta: {
|
|
56450
56561
|
name: "meet-ai",
|
|
56451
|
-
version: "0.0.
|
|
56562
|
+
version: "0.0.32",
|
|
56452
56563
|
description: "CLI for meet-ai chat rooms — create rooms, send messages, and stream via WebSocket"
|
|
56453
56564
|
},
|
|
56454
56565
|
args: {
|