@lazehq/cli 0.1.25 → 0.1.26
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/laze.mjs +76 -49
- package/package.json +1 -1
package/dist/laze.mjs
CHANGED
|
@@ -35437,7 +35437,7 @@ function cliEnvironment({
|
|
|
35437
35437
|
|
|
35438
35438
|
// src/services/config-store.service.ts
|
|
35439
35439
|
import { chmod, mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
35440
|
-
import { dirname, resolve } from "node:path";
|
|
35440
|
+
import { basename, dirname, resolve } from "node:path";
|
|
35441
35441
|
var EMPTY = { profiles: {}, bindings: {} };
|
|
35442
35442
|
var ConfigStore = class _ConfigStore {
|
|
35443
35443
|
constructor(path) {
|
|
@@ -35540,6 +35540,11 @@ function chooseProfile({
|
|
|
35540
35540
|
const profile = name2 ? config2.profiles[name2] : void 0;
|
|
35541
35541
|
return name2 && profile ? { name: name2, profile } : { name: void 0, profile: void 0 };
|
|
35542
35542
|
}
|
|
35543
|
+
function isWorktreeRoot({ directory }) {
|
|
35544
|
+
const parent = dirname(directory);
|
|
35545
|
+
if (basename(parent) === ".worktrees") return true;
|
|
35546
|
+
return basename(parent) === "worktrees" && basename(dirname(parent)) === ".claude";
|
|
35547
|
+
}
|
|
35543
35548
|
function boundProfileOf({
|
|
35544
35549
|
bindings,
|
|
35545
35550
|
cwd
|
|
@@ -35549,7 +35554,7 @@ function boundProfileOf({
|
|
|
35549
35554
|
const bound = bindings[directory];
|
|
35550
35555
|
if (bound) return bound;
|
|
35551
35556
|
const parent = dirname(directory);
|
|
35552
|
-
if (parent === directory) return void 0;
|
|
35557
|
+
if (parent === directory || isWorktreeRoot({ directory })) return void 0;
|
|
35553
35558
|
directory = parent;
|
|
35554
35559
|
}
|
|
35555
35560
|
return void 0;
|
|
@@ -35620,7 +35625,7 @@ function flagText({
|
|
|
35620
35625
|
}
|
|
35621
35626
|
|
|
35622
35627
|
// src/rules/cli-version.rules.ts
|
|
35623
|
-
var STAMPED = "0.1.
|
|
35628
|
+
var STAMPED = "0.1.26";
|
|
35624
35629
|
function cliVersionOf({ stamped = STAMPED } = {}) {
|
|
35625
35630
|
return stamped.startsWith("__") ? "dev" : stamped;
|
|
35626
35631
|
}
|
|
@@ -65627,6 +65632,29 @@ function selfClauseOf({ self: self2 }) {
|
|
|
65627
65632
|
return self2 ? `, where you are ${self2}` : "";
|
|
65628
65633
|
}
|
|
65629
65634
|
|
|
65635
|
+
// src/rules/session-headers.rules.ts
|
|
65636
|
+
import { relative, sep } from "node:path";
|
|
65637
|
+
function sessionKeyOf({ session }) {
|
|
65638
|
+
return `${session.harness}:${session.sessionId}`;
|
|
65639
|
+
}
|
|
65640
|
+
function sessionHeadersOf({
|
|
65641
|
+
session
|
|
65642
|
+
}) {
|
|
65643
|
+
if (!session) return {};
|
|
65644
|
+
return {
|
|
65645
|
+
[AGENT_SESSION_HEADER]: sessionKeyOf({ session }),
|
|
65646
|
+
[AGENT_SESSION_FOLDER_HEADER]: encodeURIComponent(session.folder),
|
|
65647
|
+
[AGENT_SESSION_HOST_HEADER]: encodeURIComponent(session.host)
|
|
65648
|
+
};
|
|
65649
|
+
}
|
|
65650
|
+
function displayFolderOf({ folder, home }) {
|
|
65651
|
+
if (!home) return folder;
|
|
65652
|
+
const below = relative(home, folder);
|
|
65653
|
+
if (below === "") return "~";
|
|
65654
|
+
if (below.startsWith("..") || below.startsWith(sep)) return folder;
|
|
65655
|
+
return `~/${below.split(sep).join("/")}`;
|
|
65656
|
+
}
|
|
65657
|
+
|
|
65630
65658
|
// src/rules/transcript.rules.ts
|
|
65631
65659
|
function record2(value) {
|
|
65632
65660
|
return typeof value === "object" && value !== null ? value : {};
|
|
@@ -66545,33 +66573,32 @@ import { mkdir as mkdir3, readdir, readFile as readFile3, writeFile as writeFile
|
|
|
66545
66573
|
import { hostname as hostname3 } from "node:os";
|
|
66546
66574
|
import { dirname as dirname3, join as join3 } from "node:path";
|
|
66547
66575
|
|
|
66548
|
-
// src/rules/
|
|
66549
|
-
|
|
66550
|
-
|
|
66551
|
-
return `${session.harness}:${session.sessionId}`;
|
|
66552
|
-
}
|
|
66553
|
-
function sessionHeadersOf({
|
|
66554
|
-
session
|
|
66576
|
+
// src/rules/rush-host.rules.ts
|
|
66577
|
+
function rushSessionOf({
|
|
66578
|
+
parentArgs
|
|
66555
66579
|
}) {
|
|
66556
|
-
if (!
|
|
66557
|
-
|
|
66558
|
-
|
|
66559
|
-
|
|
66560
|
-
|
|
66561
|
-
};
|
|
66580
|
+
if (!parentArgs) return void 0;
|
|
66581
|
+
const [program = "", verb, action, id] = parentArgs;
|
|
66582
|
+
const isRush = program === "rush" || program.endsWith("/rush");
|
|
66583
|
+
if (!isRush || verb !== "host" || action !== "run" || !id) return void 0;
|
|
66584
|
+
return { id, program };
|
|
66562
66585
|
}
|
|
66563
|
-
function
|
|
66564
|
-
|
|
66565
|
-
|
|
66566
|
-
|
|
66567
|
-
|
|
66568
|
-
|
|
66586
|
+
function rushSendCommand({ program, id }) {
|
|
66587
|
+
return ["sh", "-c", 'printf "%s\\n" "$LAZE_WAKE_TEXT" | "$0" session send "$1"', program, id];
|
|
66588
|
+
}
|
|
66589
|
+
function rushListsLive({ listed, sessionId }) {
|
|
66590
|
+
try {
|
|
66591
|
+
const sessions = JSON.parse(listed);
|
|
66592
|
+
return sessions.some((one) => one.sessionId === sessionId && one.state !== "stopped");
|
|
66593
|
+
} catch {
|
|
66594
|
+
return false;
|
|
66595
|
+
}
|
|
66569
66596
|
}
|
|
66570
66597
|
|
|
66571
66598
|
// src/services/claude-project.service.ts
|
|
66572
|
-
import { basename, isAbsolute, relative as relative2, resolve as resolve2 } from "node:path";
|
|
66599
|
+
import { basename as basename2, isAbsolute, relative as relative2, resolve as resolve2 } from "node:path";
|
|
66573
66600
|
function harnessIn({ words }) {
|
|
66574
|
-
const names = words.slice(0, 2).map((word3) =>
|
|
66601
|
+
const names = words.slice(0, 2).map((word3) => basename2(word3).replace(/\.(js|mjs|cjs)$/, ""));
|
|
66575
66602
|
if (names.includes("codex")) return "codex";
|
|
66576
66603
|
if (words.some((word3) => word3.includes("@openai/codex"))) return "codex";
|
|
66577
66604
|
const claude = words.some((word3) => word3.includes("@anthropic-ai/claude-code"));
|
|
@@ -66744,7 +66771,8 @@ async function currentSessionOf({
|
|
|
66744
66771
|
async function sessionProfileArgs({
|
|
66745
66772
|
context,
|
|
66746
66773
|
args,
|
|
66747
|
-
session
|
|
66774
|
+
session,
|
|
66775
|
+
binds = true
|
|
66748
66776
|
}) {
|
|
66749
66777
|
if (!session) return args;
|
|
66750
66778
|
const key = sessionKeyOf({ session });
|
|
@@ -66754,16 +66782,29 @@ async function sessionProfileArgs({
|
|
|
66754
66782
|
return { ...args, flags: { ...args.flags, profile: bound } };
|
|
66755
66783
|
}
|
|
66756
66784
|
const own2 = flagText({ args, name: "profile" });
|
|
66757
|
-
if (own2 && config2.profiles[own2]?.kind === "agent") {
|
|
66785
|
+
if (binds && !args.flags.plugin && own2 && config2.profiles[own2]?.kind === "agent") {
|
|
66758
66786
|
await context.store.bindSession({ session: key, profile: own2 });
|
|
66759
66787
|
}
|
|
66760
66788
|
return args;
|
|
66761
66789
|
}
|
|
66790
|
+
async function rushKeeps({ context, key }) {
|
|
66791
|
+
const sessionId = key.slice(key.indexOf(":") + 1);
|
|
66792
|
+
let listed = "";
|
|
66793
|
+
const code = await context.runCommand({
|
|
66794
|
+
command: ["sh", "-c", "command -v rush >/dev/null && rush session list --json"],
|
|
66795
|
+
env: {},
|
|
66796
|
+
stdout: { write: (chunk) => listed += chunk },
|
|
66797
|
+
stderr: { write: () => true }
|
|
66798
|
+
}).catch(() => 1);
|
|
66799
|
+
if (code !== 0) return false;
|
|
66800
|
+
return rushListsLive({ listed, sessionId });
|
|
66801
|
+
}
|
|
66762
66802
|
async function liveElsewhere({
|
|
66763
66803
|
context,
|
|
66764
66804
|
key,
|
|
66765
66805
|
claudePid
|
|
66766
66806
|
}) {
|
|
66807
|
+
if (await rushKeeps({ context, key })) return true;
|
|
66767
66808
|
const folder = dirname3(statePathOf({ context, kind: "sessions", profile: "x" }));
|
|
66768
66809
|
for (const file3 of await readdir(folder).catch(() => [])) {
|
|
66769
66810
|
const pid = Number(file3.replace(/\.json$/, ""));
|
|
@@ -66821,7 +66862,7 @@ async function agentProfileHere({
|
|
|
66821
66862
|
if (!folder && !session) return void 0;
|
|
66822
66863
|
const asked = { ...args, flags: { ...args.flags, ...folder ? { profile: folder } : {} } };
|
|
66823
66864
|
const name2 = flagText({
|
|
66824
|
-
args: await sessionProfileArgs({ context, args: asked, session }),
|
|
66865
|
+
args: await sessionProfileArgs({ context, args: asked, session, binds: false }),
|
|
66825
66866
|
name: "profile"
|
|
66826
66867
|
});
|
|
66827
66868
|
return name2 && config2.profiles[name2]?.kind === "agent" ? name2 : void 0;
|
|
@@ -67482,20 +67523,6 @@ function channelLabelIn(channel) {
|
|
|
67482
67523
|
import { readFile as readFile7, rm as rm2, writeFile as writeFile6, mkdir as mkdir6 } from "node:fs/promises";
|
|
67483
67524
|
import { dirname as dirname6 } from "node:path";
|
|
67484
67525
|
|
|
67485
|
-
// src/rules/rush-host.rules.ts
|
|
67486
|
-
function rushSessionOf({
|
|
67487
|
-
parentArgs
|
|
67488
|
-
}) {
|
|
67489
|
-
if (!parentArgs) return void 0;
|
|
67490
|
-
const [program = "", verb, action, id] = parentArgs;
|
|
67491
|
-
const isRush = program === "rush" || program.endsWith("/rush");
|
|
67492
|
-
if (!isRush || verb !== "host" || action !== "run" || !id) return void 0;
|
|
67493
|
-
return { id, program };
|
|
67494
|
-
}
|
|
67495
|
-
function rushSendCommand({ program, id }) {
|
|
67496
|
-
return ["sh", "-c", 'printf "%s\\n" "$LAZE_WAKE_TEXT" | "$0" session send "$1"', program, id];
|
|
67497
|
-
}
|
|
67498
|
-
|
|
67499
67526
|
// src/services/rush-host.service.ts
|
|
67500
67527
|
import { mkdir as mkdir5, readFile as readFile6, writeFile as writeFile5 } from "node:fs/promises";
|
|
67501
67528
|
import { dirname as dirname5, join as join6 } from "node:path";
|
|
@@ -69907,10 +69934,10 @@ async function nextStepsFor({
|
|
|
69907
69934
|
}) {
|
|
69908
69935
|
if (harness === "codex") return linkCodexSession({ context, args, profile, laze, directory });
|
|
69909
69936
|
if (!hooked) return waiterStepsOf({ profile, laze });
|
|
69937
|
+
const session = await currentSessionOf({ context, args });
|
|
69938
|
+
if (session) await context.store.bindSession({ session: sessionKeyOf({ session }), profile });
|
|
69910
69939
|
const plugin2 = args.flags["no-plugin"] ? void 0 : await installLazePlugin({ context });
|
|
69911
|
-
if (plugin2?.registered) {
|
|
69912
|
-
await markReloadTipTold({ context, session: await currentSessionOf({ context, args }) });
|
|
69913
|
-
}
|
|
69940
|
+
if (plugin2?.registered) await markReloadTipTold({ context, session });
|
|
69914
69941
|
const mcp2 = args.flags.mcp ? await registerMcp({ context, directory, profile }) : void 0;
|
|
69915
69942
|
const mcpAdd2 = mcpAddCommandOf({ context, profile });
|
|
69916
69943
|
const lines = pluginLinesOf({ context, registered: plugin2?.registered });
|
|
@@ -75813,7 +75840,7 @@ async function channelSettings({ context, args }) {
|
|
|
75813
75840
|
|
|
75814
75841
|
// src/services/chat-actions-commands.service.ts
|
|
75815
75842
|
import { readFile as readFile17 } from "node:fs/promises";
|
|
75816
|
-
import { basename as
|
|
75843
|
+
import { basename as basename3, isAbsolute as isAbsolute2, relative as relative4, resolve as resolve7 } from "node:path";
|
|
75817
75844
|
|
|
75818
75845
|
// src/services/file-upload.service.ts
|
|
75819
75846
|
async function sendParts({
|
|
@@ -76113,7 +76140,7 @@ var files = async ({ context, args, client }) => {
|
|
|
76113
76140
|
};
|
|
76114
76141
|
function uploadNameOf({ cwd, path }) {
|
|
76115
76142
|
const inside = relative4(cwd, path);
|
|
76116
|
-
return inside && !inside.startsWith("..") && !isAbsolute2(inside) ? inside :
|
|
76143
|
+
return inside && !inside.startsWith("..") && !isAbsolute2(inside) ? inside : basename3(path);
|
|
76117
76144
|
}
|
|
76118
76145
|
var fileUpload = async ({ context, args, client }) => {
|
|
76119
76146
|
const path = resolve7(context.cwd, wordAt(args, 3));
|
|
@@ -79110,7 +79137,7 @@ function feedFlagsOf({ args }) {
|
|
|
79110
79137
|
|
|
79111
79138
|
// src/services/feed-files.service.ts
|
|
79112
79139
|
import { readFile as readFile23 } from "node:fs/promises";
|
|
79113
|
-
import { basename as
|
|
79140
|
+
import { basename as basename4, resolve as resolve9 } from "node:path";
|
|
79114
79141
|
|
|
79115
79142
|
// ../../modules/feed/contract/src/feed.ts
|
|
79116
79143
|
var feedAuthorSchemaDefinition = external_exports.object({
|
|
@@ -79689,7 +79716,7 @@ async function bytesOf2({
|
|
|
79689
79716
|
async function downloaded({ context, url: url2 }) {
|
|
79690
79717
|
const response = await context.fetcher(url2);
|
|
79691
79718
|
if (!response.ok) throw new CliUsageError(`${url2} answered ${response.status}`);
|
|
79692
|
-
const fileName =
|
|
79719
|
+
const fileName = basename4(new URL(url2).pathname) || "file";
|
|
79693
79720
|
const header = (response.headers.get("content-type") ?? "").split(";")[0]?.trim();
|
|
79694
79721
|
return {
|
|
79695
79722
|
fileName,
|
|
@@ -79699,7 +79726,7 @@ async function downloaded({ context, url: url2 }) {
|
|
|
79699
79726
|
}
|
|
79700
79727
|
async function local({ context, path }) {
|
|
79701
79728
|
const full = resolve9(context.cwd, path);
|
|
79702
|
-
const fileName =
|
|
79729
|
+
const fileName = basename4(full);
|
|
79703
79730
|
return {
|
|
79704
79731
|
fileName,
|
|
79705
79732
|
contentType: contentTypeOf(fileName),
|
package/package.json
CHANGED