@k-leumas/queque-cli 0.9.2 → 0.10.1
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/README.md +18 -21
- package/dist/cli/app.js +681 -167
- package/dist/cli/app.js.map +1 -1
- package/package.json +1 -1
- package/shell/README.md +124 -0
- package/shell/bash/queque.bash +594 -0
- package/shell/zsh/queque.zsh +20 -8
package/dist/cli/app.js
CHANGED
|
@@ -48812,6 +48812,7 @@ function ensureSelectableCandidates(candidates) {
|
|
|
48812
48812
|
}
|
|
48813
48813
|
];
|
|
48814
48814
|
}
|
|
48815
|
+
var SHELL_SYNTAX_INSTRUCTION = "Write every command in the syntax of the shell named in shellName.";
|
|
48815
48816
|
function buildPrompt(envelope) {
|
|
48816
48817
|
const filtered = filterContextEnvelope(envelope);
|
|
48817
48818
|
const gitChunk = filtered.extras.find((chunk) => chunk.kind === "git");
|
|
@@ -48822,6 +48823,7 @@ function buildPrompt(envelope) {
|
|
|
48822
48823
|
"No markdown, no prose, no code fences. Raw JSON array only.",
|
|
48823
48824
|
"",
|
|
48824
48825
|
"The command should be safe to place back into a shell buffer.",
|
|
48826
|
+
SHELL_SYNTAX_INSTRUCTION,
|
|
48825
48827
|
"",
|
|
48826
48828
|
"Shell context:",
|
|
48827
48829
|
JSON.stringify(
|
|
@@ -49564,6 +49566,7 @@ var PROVIDER_KINDS = ["claude-sdk", "claude-cli", "openai", "ollama", "unknown"]
|
|
|
49564
49566
|
var QUERY_OUTCOMES = ["accepted", "escaped", "error"];
|
|
49565
49567
|
var OS_KINDS = ["darwin", "linux", "other"];
|
|
49566
49568
|
var ARCH_KINDS = ["x64", "arm64", "other"];
|
|
49569
|
+
var SHELL_KINDS = ["zsh", "bash", "fish"];
|
|
49567
49570
|
var DISTRO_IDS = [
|
|
49568
49571
|
"macos",
|
|
49569
49572
|
"ubuntu",
|
|
@@ -49588,12 +49591,17 @@ var errorFields = {
|
|
|
49588
49591
|
error_kind: errorKind,
|
|
49589
49592
|
provider: providerKind
|
|
49590
49593
|
};
|
|
49594
|
+
var majorMinor = external_exports.union([external_exports.string().regex(/^\d{1,2}\.\d{1,2}$/), external_exports.literal("unknown")]);
|
|
49591
49595
|
var environmentFields = {
|
|
49592
49596
|
os: external_exports.enum(OS_KINDS),
|
|
49593
49597
|
arch: external_exports.enum(ARCH_KINDS),
|
|
49594
49598
|
distro: external_exports.enum(DISTRO_IDS),
|
|
49595
|
-
/**
|
|
49596
|
-
|
|
49599
|
+
/** The shell the `??` came from (Phase 11 D-11). */
|
|
49600
|
+
shell: external_exports.enum(SHELL_KINDS),
|
|
49601
|
+
/** That shell's major.minor: `5.2`, never `5.2.21(1)-release`; or `unknown`. */
|
|
49602
|
+
shell_version: majorMinor,
|
|
49603
|
+
/** zsh major.minor when shell is zsh, else `unknown`. Kept from phase 10: add, do not rename. */
|
|
49604
|
+
zsh: majorMinor,
|
|
49597
49605
|
node_major: external_exports.number().int().min(18).max(99),
|
|
49598
49606
|
zellij: external_exports.boolean()
|
|
49599
49607
|
};
|
|
@@ -50505,6 +50513,11 @@ function bootstrapBuiltins() {
|
|
|
50505
50513
|
shell: "zsh",
|
|
50506
50514
|
description: "zsh ZLE widget adapter (Phase 2 built-in)"
|
|
50507
50515
|
});
|
|
50516
|
+
registerShellAdapter({
|
|
50517
|
+
id: "bash",
|
|
50518
|
+
shell: "bash",
|
|
50519
|
+
description: "bash readline bind -x adapter (Phase 11)"
|
|
50520
|
+
});
|
|
50508
50521
|
registerStorageHook({
|
|
50509
50522
|
id: "noop",
|
|
50510
50523
|
description: "No-op storage hook (default \u2014 no persistence)"
|
|
@@ -59727,13 +59740,19 @@ var import_react33 = __toESM(require_react(), 1);
|
|
|
59727
59740
|
var import_react36 = __toESM(require_react(), 1);
|
|
59728
59741
|
|
|
59729
59742
|
// src/contracts/shell.ts
|
|
59743
|
+
var SHELL_NAMES = ["zsh", "bash", "fish"];
|
|
59744
|
+
function isShellName(value) {
|
|
59745
|
+
return typeof value === "string" && SHELL_NAMES.includes(value);
|
|
59746
|
+
}
|
|
59730
59747
|
var shellRequestSchema = external_exports.object({
|
|
59731
59748
|
version: external_exports.literal(1),
|
|
59732
59749
|
ttyPath: external_exports.string(),
|
|
59733
59750
|
cwd: external_exports.string().regex(/^\/[^\0]*$/, "cwd must be an absolute POSIX path"),
|
|
59734
59751
|
shellPid: external_exports.number().int().positive(),
|
|
59735
59752
|
lbuffer: external_exports.string(),
|
|
59736
|
-
rbuffer: external_exports.string()
|
|
59753
|
+
rbuffer: external_exports.string(),
|
|
59754
|
+
shell: external_exports.enum(SHELL_NAMES).default("zsh"),
|
|
59755
|
+
shellVersion: external_exports.string().max(40).optional()
|
|
59737
59756
|
});
|
|
59738
59757
|
var shellResultSchema = external_exports.discriminatedUnion("kind", [
|
|
59739
59758
|
external_exports.object({
|
|
@@ -59779,8 +59798,11 @@ var baseContextSchema = external_exports.object({
|
|
|
59779
59798
|
cwd: external_exports.string(),
|
|
59780
59799
|
ttyPath: external_exports.string(),
|
|
59781
59800
|
shellPid: external_exports.number().int().positive(),
|
|
59782
|
-
/**
|
|
59783
|
-
|
|
59801
|
+
/**
|
|
59802
|
+
* The shell the adapter reported (`request.shell`, Phase 11 D-02). An enum, so a
|
|
59803
|
+
* free-form value never reaches a provider prompt.
|
|
59804
|
+
*/
|
|
59805
|
+
shellName: external_exports.enum(SHELL_NAMES),
|
|
59784
59806
|
platform: external_exports.string(),
|
|
59785
59807
|
timestamp: external_exports.string()
|
|
59786
59808
|
});
|
|
@@ -59893,7 +59915,7 @@ function buildBaseContext(request) {
|
|
|
59893
59915
|
cwd: request.cwd,
|
|
59894
59916
|
ttyPath: request.ttyPath,
|
|
59895
59917
|
shellPid: request.shellPid,
|
|
59896
|
-
shellName:
|
|
59918
|
+
shellName: request.shell,
|
|
59897
59919
|
platform: process.platform,
|
|
59898
59920
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
59899
59921
|
};
|
|
@@ -60142,13 +60164,13 @@ function pingDaemonFetchCap(socketPath2) {
|
|
|
60142
60164
|
return;
|
|
60143
60165
|
}
|
|
60144
60166
|
const build = response.data.build;
|
|
60145
|
-
if (build === "0.
|
|
60167
|
+
if (build === "0.10.1+ae3c19f.mwi98zwx") {
|
|
60146
60168
|
done("yes");
|
|
60147
60169
|
return;
|
|
60148
60170
|
}
|
|
60149
60171
|
void appendDebugLog("daemon", "daemon build differs", {
|
|
60150
60172
|
daemonBuild: build ?? null,
|
|
60151
|
-
clientBuild: "0.
|
|
60173
|
+
clientBuild: "0.10.1+ae3c19f.mwi98zwx"
|
|
60152
60174
|
});
|
|
60153
60175
|
done("no");
|
|
60154
60176
|
});
|
|
@@ -60872,7 +60894,7 @@ function lexHand(s) {
|
|
|
60872
60894
|
}
|
|
60873
60895
|
return tokens;
|
|
60874
60896
|
}
|
|
60875
|
-
var
|
|
60897
|
+
var ZSH_RES_EXPECT = /* @__PURE__ */ new Set([
|
|
60876
60898
|
"if",
|
|
60877
60899
|
"then",
|
|
60878
60900
|
"else",
|
|
@@ -60893,7 +60915,24 @@ var RES_EXPECT = /* @__PURE__ */ new Set([
|
|
|
60893
60915
|
"repeat",
|
|
60894
60916
|
"end"
|
|
60895
60917
|
]);
|
|
60896
|
-
var
|
|
60918
|
+
var ZSH_ONLY_RES_EXPECT = /* @__PURE__ */ new Set(["nocorrect", "noglob", "repeat", "end"]);
|
|
60919
|
+
var BASH_RES_EXPECT = new Set(
|
|
60920
|
+
[...ZSH_RES_EXPECT].filter((word) => !ZSH_ONLY_RES_EXPECT.has(word))
|
|
60921
|
+
);
|
|
60922
|
+
var ZSH_RES_LOOP = /* @__PURE__ */ new Set(["for", "foreach", "select"]);
|
|
60923
|
+
var BASH_RES_LOOP = /* @__PURE__ */ new Set(["for", "select"]);
|
|
60924
|
+
var RES_EXPECT_BY_SHELL = {
|
|
60925
|
+
zsh: ZSH_RES_EXPECT,
|
|
60926
|
+
bash: BASH_RES_EXPECT,
|
|
60927
|
+
// Phase 12 gives fish its own table (begin, end, and, or, not); until then it reads as bash.
|
|
60928
|
+
fish: BASH_RES_EXPECT
|
|
60929
|
+
};
|
|
60930
|
+
var RES_LOOP_BY_SHELL = {
|
|
60931
|
+
zsh: ZSH_RES_LOOP,
|
|
60932
|
+
bash: BASH_RES_LOOP,
|
|
60933
|
+
// Phase 12: fish loops (`for x in …; …; end`) have no `do`; until then it reads as bash.
|
|
60934
|
+
fish: BASH_RES_LOOP
|
|
60935
|
+
};
|
|
60897
60936
|
var SHELLS = /* @__PURE__ */ new Set(["bash", "sh", "zsh", "dash", "ksh", "fish"]);
|
|
60898
60937
|
var FIND_EXEC = /* @__PURE__ */ new Set(["-exec", "-execdir", "-ok", "-okdir"]);
|
|
60899
60938
|
var WRAPPERS = /* @__PURE__ */ new Map([
|
|
@@ -60965,11 +61004,13 @@ var NEEDS_POSITIONAL = /* @__PURE__ */ new Map([
|
|
|
60965
61004
|
]);
|
|
60966
61005
|
var LOOKUP_BUILTINS = /* @__PURE__ */ new Set(["type", "which", "whence", "where"]);
|
|
60967
61006
|
var ASSIGN_RE = /^[A-Za-z_][A-Za-z0-9_]*(\[[^\]]*\])?\+?=/;
|
|
60968
|
-
function commandWords(tokens, builtins, depth = 0) {
|
|
61007
|
+
function commandWords(tokens, builtins, depth = 0, shell = "zsh") {
|
|
60969
61008
|
const out = [];
|
|
61009
|
+
const resExpect = RES_EXPECT_BY_SHELL[shell] ?? ZSH_RES_EXPECT;
|
|
61010
|
+
const resLoop = RES_LOOP_BY_SHELL[shell] ?? ZSH_RES_LOOP;
|
|
60970
61011
|
const recurse = (text) => {
|
|
60971
61012
|
if (depth + 1 > MAX_RECURSION_DEPTH) return;
|
|
60972
|
-
out.push(...commandWords(lexHand(text), builtins, depth + 1));
|
|
61013
|
+
out.push(...commandWords(lexHand(text), builtins, depth + 1, shell));
|
|
60973
61014
|
};
|
|
60974
61015
|
let expect = true;
|
|
60975
61016
|
let skipNextWord = false;
|
|
@@ -61043,8 +61084,11 @@ function commandWords(tokens, builtins, depth = 0) {
|
|
|
61043
61084
|
}
|
|
61044
61085
|
}
|
|
61045
61086
|
if (ASSIGN_RE.test(tok.lead ?? w) && (current2 === null || WRAPPERS.has(current2))) continue;
|
|
61046
|
-
if (!tok.quoted &&
|
|
61047
|
-
|
|
61087
|
+
if (!tok.quoted && resExpect.has(w)) {
|
|
61088
|
+
if (w === "repeat" && tokens[k + 1]?.t === "word") skipNextWord = true;
|
|
61089
|
+
continue;
|
|
61090
|
+
}
|
|
61091
|
+
if (!tok.quoted && resLoop.has(w)) {
|
|
61048
61092
|
skipUntil = "do";
|
|
61049
61093
|
continue;
|
|
61050
61094
|
}
|
|
@@ -61105,10 +61149,10 @@ function commandWords(tokens, builtins, depth = 0) {
|
|
|
61105
61149
|
}
|
|
61106
61150
|
return out;
|
|
61107
61151
|
}
|
|
61108
|
-
function extractCommandWords(command, builtins) {
|
|
61152
|
+
function extractCommandWords(command, builtins, shell = "zsh") {
|
|
61109
61153
|
if (command.length > MAX_COMMAND_LENGTH) return [];
|
|
61110
61154
|
try {
|
|
61111
|
-
return commandWords(lexHand(command), builtins);
|
|
61155
|
+
return commandWords(lexHand(command), builtins, 0, shell);
|
|
61112
61156
|
} catch {
|
|
61113
61157
|
return [];
|
|
61114
61158
|
}
|
|
@@ -61287,7 +61331,7 @@ function isInstalled(inventory, name) {
|
|
|
61287
61331
|
function missingTools(command, inventory) {
|
|
61288
61332
|
const missing = [];
|
|
61289
61333
|
const seen = /* @__PURE__ */ new Set();
|
|
61290
|
-
for (const { word, kind } of extractCommandWords(command, inventory.builtins)) {
|
|
61334
|
+
for (const { word, kind } of extractCommandWords(command, inventory.builtins, inventory.shell)) {
|
|
61291
61335
|
if (kind !== "external" || seen.has(word)) continue;
|
|
61292
61336
|
seen.add(word);
|
|
61293
61337
|
if (!isInstalled(inventory, word)) missing.push(word);
|
|
@@ -61317,6 +61361,19 @@ function annotateCandidates(candidates, inventory, platform2 = process.platform)
|
|
|
61317
61361
|
// src/ui/CandidateSelect.tsx
|
|
61318
61362
|
var import_react35 = __toESM(require_react(), 1);
|
|
61319
61363
|
|
|
61364
|
+
// src/shared/instant-frame-spec.ts
|
|
61365
|
+
var SAVE_CURSOR = "\x1B7";
|
|
61366
|
+
var RESTORE_CURSOR = "\x1B8";
|
|
61367
|
+
var ERASE_BELOW = "\x1B[J";
|
|
61368
|
+
var CURSOR_HOME = "\x1B[H";
|
|
61369
|
+
var INSTANT_FRAME_VIEWPORT_LINES = 18;
|
|
61370
|
+
var INSTANT_FRAME_LOADING_TEXT = "thinking\u2026";
|
|
61371
|
+
var MODAL_MAX_COLUMNS = 80;
|
|
61372
|
+
var CONTROL_CHARACTERS = new RegExp("\\p{Cc}", "gu");
|
|
61373
|
+
function inlineScrollReserve(lines) {
|
|
61374
|
+
return `${"\n".repeat(lines)}\x1B[${lines}A\r${SAVE_CURSOR}`;
|
|
61375
|
+
}
|
|
61376
|
+
|
|
61320
61377
|
// src/ui/ControlsLine.tsx
|
|
61321
61378
|
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
61322
61379
|
function ControlsLine() {
|
|
@@ -61335,7 +61392,7 @@ function ControlsLine() {
|
|
|
61335
61392
|
// src/ui/LoadingSpinner.tsx
|
|
61336
61393
|
var import_react34 = __toESM(require_react(), 1);
|
|
61337
61394
|
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
|
|
61338
|
-
var FRAMES = [
|
|
61395
|
+
var FRAMES = [INSTANT_FRAME_LOADING_TEXT, "thinking.", "thinking..", "thinking\u2026"];
|
|
61339
61396
|
function LoadingSpinner() {
|
|
61340
61397
|
const [frame, setFrame] = (0, import_react34.useState)(0);
|
|
61341
61398
|
(0, import_react34.useEffect)(() => {
|
|
@@ -61420,7 +61477,7 @@ function filterCandidates(candidates, query) {
|
|
|
61420
61477
|
(c) => c.command.toLowerCase().includes(lower) || (c.install?.form?.toLowerCase().includes(lower) ?? false)
|
|
61421
61478
|
);
|
|
61422
61479
|
}
|
|
61423
|
-
var MODAL_VIEWPORT_LINES =
|
|
61480
|
+
var MODAL_VIEWPORT_LINES = INSTANT_FRAME_VIEWPORT_LINES;
|
|
61424
61481
|
var INCOMPLETE_LIST_NOTE = "list may be incomplete";
|
|
61425
61482
|
var LIST_STATUS_ROW_LINES = 1;
|
|
61426
61483
|
var MARK_COLUMNS = 2;
|
|
@@ -61498,7 +61555,7 @@ var ACTIVE_HEAD = "\u250C> ";
|
|
|
61498
61555
|
var ACTIVE_TAIL = "\u2502 ";
|
|
61499
61556
|
var DESTRUCTIVE_WARNING_MARK = "\u26A0";
|
|
61500
61557
|
var DESTRUCTIVE_WARNING_TEXT = `${DESTRUCTIVE_WARNING_MARK} review carefully \u2014 this command may be destructive`;
|
|
61501
|
-
var MODAL_MAX_WIDTH =
|
|
61558
|
+
var MODAL_MAX_WIDTH = MODAL_MAX_COLUMNS;
|
|
61502
61559
|
var MODAL_PADDING_X = 2;
|
|
61503
61560
|
function linePrefix(active, lineIndex) {
|
|
61504
61561
|
if (!active) {
|
|
@@ -61728,22 +61785,15 @@ function CandidateSelect({
|
|
|
61728
61785
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { dimColor: true, children: legend.slice(MISSING_TOOL_MARK.length) })
|
|
61729
61786
|
] }),
|
|
61730
61787
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ControlsLine, {}),
|
|
61731
|
-
process.env.QQ_DEV_ROOT != null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { justifyContent: "flex-end", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: "yellow", children: `dev v${"0.
|
|
61788
|
+
process.env.QQ_DEV_ROOT != null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { justifyContent: "flex-end", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: "yellow", children: `dev v${"0.10.1"} ${"ae3c19f"}` }) })
|
|
61732
61789
|
] });
|
|
61733
61790
|
}
|
|
61734
61791
|
|
|
61735
61792
|
// src/client/instant-frame.ts
|
|
61736
61793
|
import { stripVTControlCharacters } from "util";
|
|
61737
|
-
var SAVE_CURSOR = "\x1B7";
|
|
61738
|
-
var RESTORE_CURSOR = "\x1B8";
|
|
61739
|
-
var ERASE_BELOW = "\x1B[J";
|
|
61740
|
-
var CURSOR_HOME = "\x1B[H";
|
|
61741
61794
|
var SYNC_UPDATE_BEGIN = "\x1B[?2026h";
|
|
61742
61795
|
var INLINE_SURFACE_CLEAR = RESTORE_CURSOR + ERASE_BELOW;
|
|
61743
61796
|
var PANE_SURFACE_CLEAR = CURSOR_HOME + ERASE_BELOW;
|
|
61744
|
-
function inlineScrollReserve(lines) {
|
|
61745
|
-
return `${"\n".repeat(lines)}\x1B[${lines}A\r${SAVE_CURSOR}`;
|
|
61746
|
-
}
|
|
61747
61797
|
function hasVisibleText(chunk) {
|
|
61748
61798
|
const text = typeof chunk === "string" ? chunk : Buffer.isBuffer(chunk) ? chunk.toString() : "";
|
|
61749
61799
|
return stripVTControlCharacters(text).trim() !== "";
|
|
@@ -61902,7 +61952,7 @@ function linuxDistro(osRelease) {
|
|
|
61902
61952
|
const id = match?.[1]?.trim().replace(/^(["'])(.*)\1$/, "$2").toLowerCase();
|
|
61903
61953
|
return id !== void 0 && LINUX_DISTRO_IDS.has(id) ? id : "other";
|
|
61904
61954
|
}
|
|
61905
|
-
function
|
|
61955
|
+
function shellMajorMinor(version3) {
|
|
61906
61956
|
const match = /^(\d{1,2})\.(\d{1,2})(?![0-9])/.exec(version3?.trim() ?? "");
|
|
61907
61957
|
return match ? `${match[1]}.${match[2]}` : "unknown";
|
|
61908
61958
|
}
|
|
@@ -61918,12 +61968,17 @@ function collectEnvironmentShape(input = {}) {
|
|
|
61918
61968
|
if (major === null) {
|
|
61919
61969
|
return null;
|
|
61920
61970
|
}
|
|
61971
|
+
const shell = input.shell ?? "zsh";
|
|
61972
|
+
const shellVersion = shellMajorMinor(
|
|
61973
|
+
input.shellVersion ?? (shell === "zsh" ? env3.QQ_ZSH_VERSION : void 0)
|
|
61974
|
+
);
|
|
61921
61975
|
const result = environmentPayloadSchema.safeParse({
|
|
61922
61976
|
os: os4,
|
|
61923
61977
|
arch: archKind(input.arch ?? process.arch),
|
|
61924
61978
|
distro,
|
|
61925
|
-
|
|
61926
|
-
|
|
61979
|
+
shell,
|
|
61980
|
+
shell_version: shellVersion,
|
|
61981
|
+
zsh: shell === "zsh" ? shellVersion : "unknown",
|
|
61927
61982
|
node_major: major,
|
|
61928
61983
|
zellij: env3.ZELLIJ !== void 0
|
|
61929
61984
|
});
|
|
@@ -61996,7 +62051,8 @@ async function reportClientTelemetry(input) {
|
|
|
61996
62051
|
return;
|
|
61997
62052
|
}
|
|
61998
62053
|
const provider = input.provider ? input.provider() : resolveProviderKind();
|
|
61999
|
-
const
|
|
62054
|
+
const { shell, shellVersion } = input;
|
|
62055
|
+
const shape = input.environment ? input.environment() : collectEnvironmentShape({ env: input.env, shell, shellVersion });
|
|
62000
62056
|
const errors = input.errors ?? [];
|
|
62001
62057
|
const events = [];
|
|
62002
62058
|
if (shape) {
|
|
@@ -62022,13 +62078,16 @@ async function reportClientTelemetry(input) {
|
|
|
62022
62078
|
}
|
|
62023
62079
|
|
|
62024
62080
|
// src/client/tool-handoff.ts
|
|
62025
|
-
import { readFile } from "fs/promises";
|
|
62081
|
+
import { access, readFile } from "fs/promises";
|
|
62026
62082
|
import * as path3 from "path";
|
|
62027
62083
|
var TOOL_HANDOFF_FILES = {
|
|
62028
62084
|
commands: "commands.txt",
|
|
62029
62085
|
builtins: "builtins.txt",
|
|
62030
62086
|
functions: "functions.txt"
|
|
62031
62087
|
};
|
|
62088
|
+
var TOOL_HANDOFF_PENDING = "tools.pending";
|
|
62089
|
+
var TOOL_HANDOFF_PENDING_BUDGET_MS = 500;
|
|
62090
|
+
var TOOL_HANDOFF_PENDING_POLL_MS = 10;
|
|
62032
62091
|
function toNameSet(content) {
|
|
62033
62092
|
return new Set(content.split(/\r?\n/).filter((name) => name.length > 0));
|
|
62034
62093
|
}
|
|
@@ -62039,11 +62098,35 @@ function errorReason(error43) {
|
|
|
62039
62098
|
}
|
|
62040
62099
|
return "unreadable";
|
|
62041
62100
|
}
|
|
62042
|
-
|
|
62101
|
+
function sleep3(ms) {
|
|
62102
|
+
return new Promise((resolve6) => setTimeout(resolve6, ms));
|
|
62103
|
+
}
|
|
62104
|
+
async function waitWhilePending(sessionDir, budgetMs) {
|
|
62105
|
+
const marker = path3.join(sessionDir, TOOL_HANDOFF_PENDING);
|
|
62106
|
+
const deadline = Date.now() + budgetMs;
|
|
62107
|
+
for (; ; ) {
|
|
62108
|
+
try {
|
|
62109
|
+
await access(marker);
|
|
62110
|
+
} catch {
|
|
62111
|
+
return true;
|
|
62112
|
+
}
|
|
62113
|
+
if (Date.now() >= deadline) return false;
|
|
62114
|
+
await sleep3(TOOL_HANDOFF_PENDING_POLL_MS);
|
|
62115
|
+
}
|
|
62116
|
+
}
|
|
62117
|
+
async function readToolHandoff(sessionDir, options = {}) {
|
|
62043
62118
|
if (process.env.QQ_TOOL_AWARENESS === "0") {
|
|
62044
62119
|
void appendDebugLog("client", "tool handoff unavailable", { reason: "disabled" });
|
|
62045
62120
|
return null;
|
|
62046
62121
|
}
|
|
62122
|
+
const ready = await waitWhilePending(
|
|
62123
|
+
sessionDir,
|
|
62124
|
+
options.pendingBudgetMs ?? TOOL_HANDOFF_PENDING_BUDGET_MS
|
|
62125
|
+
);
|
|
62126
|
+
if (!ready) {
|
|
62127
|
+
void appendDebugLog("client", "tool handoff unavailable", { reason: "pending-timeout" });
|
|
62128
|
+
return null;
|
|
62129
|
+
}
|
|
62047
62130
|
let contents;
|
|
62048
62131
|
try {
|
|
62049
62132
|
contents = await Promise.all([
|
|
@@ -62065,7 +62148,7 @@ async function readToolHandoff(sessionDir) {
|
|
|
62065
62148
|
builtins: builtins.size,
|
|
62066
62149
|
functions: functions.size
|
|
62067
62150
|
});
|
|
62068
|
-
return { commands, builtins, functions };
|
|
62151
|
+
return { commands, builtins, functions, shell: options.shell ?? "zsh" };
|
|
62069
62152
|
}
|
|
62070
62153
|
|
|
62071
62154
|
// src/client/zellij-pane-resize.ts
|
|
@@ -62231,7 +62314,7 @@ async function runForegroundClient(args) {
|
|
|
62231
62314
|
cwd: request.cwd,
|
|
62232
62315
|
shellPid: request.shellPid
|
|
62233
62316
|
});
|
|
62234
|
-
const
|
|
62317
|
+
const toolInventoryRead = resultMode === "llm" ? readToolHandoff(path4.dirname(requestFile), { shell: request.shell }) : Promise.resolve(null);
|
|
62235
62318
|
const telemetryErrors = [];
|
|
62236
62319
|
try {
|
|
62237
62320
|
await ensureDaemon(socketPath2);
|
|
@@ -62249,7 +62332,7 @@ async function runForegroundClient(args) {
|
|
|
62249
62332
|
lbuffer: fixtureLbuffer,
|
|
62250
62333
|
rbuffer: request.rbuffer
|
|
62251
62334
|
});
|
|
62252
|
-
|
|
62335
|
+
await appendDebugLog("client", "wrote replace-buffer result", {
|
|
62253
62336
|
resultFile,
|
|
62254
62337
|
lbufferLength: fixtureLbuffer.length,
|
|
62255
62338
|
rbufferLength: request.rbuffer.length
|
|
@@ -62291,7 +62374,7 @@ async function runForegroundClient(args) {
|
|
|
62291
62374
|
ttyReadStream.setRawMode(true);
|
|
62292
62375
|
ttyReadStream.setRawMode(false);
|
|
62293
62376
|
} catch {
|
|
62294
|
-
const msg = "\r\nqueque: terminal does not support interactive mode\r\nRun ?? from an interactive
|
|
62377
|
+
const msg = "\r\nqueque: terminal does not support interactive mode\r\nRun ?? from an interactive shell.\r\n";
|
|
62295
62378
|
ttyWriteStream.write(msg);
|
|
62296
62379
|
await writeShellResult(resultFile, {
|
|
62297
62380
|
kind: "error",
|
|
@@ -62314,7 +62397,9 @@ async function runForegroundClient(args) {
|
|
|
62314
62397
|
intent: decision.intent,
|
|
62315
62398
|
confidence: decision.confidence
|
|
62316
62399
|
};
|
|
62317
|
-
const
|
|
62400
|
+
const gathered = await gatherContext(normalized2);
|
|
62401
|
+
const toolInventory = await toolInventoryRead;
|
|
62402
|
+
const envelope = withInstalledToolsChunk(gathered, toolInventory);
|
|
62318
62403
|
void appendDebugLog("client", "context gathered", {
|
|
62319
62404
|
extraCount: envelope.extras.length
|
|
62320
62405
|
});
|
|
@@ -62464,11 +62549,17 @@ async function runForegroundClient(args) {
|
|
|
62464
62549
|
}
|
|
62465
62550
|
}
|
|
62466
62551
|
}
|
|
62467
|
-
await reportClientTelemetry({
|
|
62552
|
+
await reportClientTelemetry({
|
|
62553
|
+
socketPath: socketPath2,
|
|
62554
|
+
record: outcome,
|
|
62555
|
+
errors: telemetryErrors,
|
|
62556
|
+
shell: request.shell,
|
|
62557
|
+
shellVersion: request.shellVersion
|
|
62558
|
+
});
|
|
62468
62559
|
}
|
|
62469
62560
|
} else {
|
|
62470
62561
|
await writeShellResult(resultFile, { kind: "cancel" });
|
|
62471
|
-
|
|
62562
|
+
await appendDebugLog("client", "wrote cancel result", { resultFile });
|
|
62472
62563
|
}
|
|
62473
62564
|
} finally {
|
|
62474
62565
|
await ttyHandle?.close();
|
|
@@ -62483,8 +62574,15 @@ function parseResultMode(mode) {
|
|
|
62483
62574
|
void appendDebugLog("client", `unknown --result-mode "${mode}", defaulting to cancel`);
|
|
62484
62575
|
return "cancel";
|
|
62485
62576
|
}
|
|
62577
|
+
var TEST_ENV_MODES = /* @__PURE__ */ new Set(["cancel", "replace-buffer-fixture"]);
|
|
62578
|
+
function resolveResultMode(flag, envMode) {
|
|
62579
|
+
if (flag !== void 0) return parseResultMode(flag);
|
|
62580
|
+
if (envMode === void 0 || TEST_ENV_MODES.has(envMode)) return parseResultMode(envMode);
|
|
62581
|
+
void appendDebugLog("client", `ignored QQ_TEST_RESULT_MODE "${envMode}" (not a fixture mode)`);
|
|
62582
|
+
return "llm";
|
|
62583
|
+
}
|
|
62486
62584
|
async function clientCommand(options) {
|
|
62487
|
-
const resultMode =
|
|
62585
|
+
const resultMode = resolveResultMode(options.resultMode, process.env.QQ_TEST_RESULT_MODE);
|
|
62488
62586
|
void appendDebugLog("client", "command start", {
|
|
62489
62587
|
requestFile: options.requestFile,
|
|
62490
62588
|
resultFile: options.resultFile,
|
|
@@ -62548,7 +62646,7 @@ function startDaemonServer(socketPath2, options = {}) {
|
|
|
62548
62646
|
streamCandidates: true,
|
|
62549
62647
|
providerPin: true,
|
|
62550
62648
|
telemetry: true,
|
|
62551
|
-
build: "0.
|
|
62649
|
+
build: "0.10.1+ae3c19f.mwi98zwx"
|
|
62552
62650
|
});
|
|
62553
62651
|
void appendDebugLog("daemon", "replied pong");
|
|
62554
62652
|
break;
|
|
@@ -62716,7 +62814,7 @@ function createTelemetryBuffer(deps = {}) {
|
|
|
62716
62814
|
const readState = deps.readState ?? (() => readTelemetryState());
|
|
62717
62815
|
const env3 = deps.env ?? (() => process.env);
|
|
62718
62816
|
const endpointFor = deps.endpoint ?? resolveTelemetryEndpoint;
|
|
62719
|
-
const version3 = deps.version ?? "0.
|
|
62817
|
+
const version3 = deps.version ?? "0.10.1";
|
|
62720
62818
|
let events = [];
|
|
62721
62819
|
let lastSent = null;
|
|
62722
62820
|
let lastEnvironment = null;
|
|
@@ -62970,16 +63068,16 @@ async function daemonCommand(options) {
|
|
|
62970
63068
|
// src/cli/commands/doctor.ts
|
|
62971
63069
|
import { spawn as spawn4 } from "child_process";
|
|
62972
63070
|
import {
|
|
62973
|
-
accessSync as
|
|
62974
|
-
constants as
|
|
63071
|
+
accessSync as accessSync3,
|
|
63072
|
+
constants as constants4,
|
|
62975
63073
|
lstatSync as lstatSync2,
|
|
62976
63074
|
mkdtempSync,
|
|
62977
63075
|
readFileSync as readFileSync8,
|
|
62978
63076
|
rmSync,
|
|
62979
|
-
statSync as
|
|
63077
|
+
statSync as statSync4
|
|
62980
63078
|
} from "fs";
|
|
62981
|
-
import { homedir as homedir7 } from "os";
|
|
62982
|
-
import { join as join6 } from "path";
|
|
63079
|
+
import { homedir as homedir7, userInfo as userInfo2 } from "os";
|
|
63080
|
+
import { basename as basename4, join as join6 } from "path";
|
|
62983
63081
|
|
|
62984
63082
|
// src/contracts/doctor.ts
|
|
62985
63083
|
var DOCTOR_CHECK_IDS = [
|
|
@@ -62994,7 +63092,10 @@ var DOCTOR_CHECK_IDS = [
|
|
|
62994
63092
|
"locale",
|
|
62995
63093
|
"provider",
|
|
62996
63094
|
"node",
|
|
62997
|
-
"telemetry"
|
|
63095
|
+
"telemetry",
|
|
63096
|
+
"bash",
|
|
63097
|
+
"fish",
|
|
63098
|
+
"bash_profile"
|
|
62998
63099
|
];
|
|
62999
63100
|
var DOCTOR_STATUSES = ["ok", "warn", "fail"];
|
|
63000
63101
|
var DOCTOR_PLATFORMS = ["darwin", "linux", "other"];
|
|
@@ -63078,69 +63179,336 @@ async function detectProvider() {
|
|
|
63078
63179
|
};
|
|
63079
63180
|
}
|
|
63080
63181
|
|
|
63081
|
-
// src/
|
|
63082
|
-
import {
|
|
63083
|
-
import {
|
|
63084
|
-
import { dirname as dirname6, join as join5, resolve as resolve5 } from "path";
|
|
63182
|
+
// src/shared/shell-registry.ts
|
|
63183
|
+
import { existsSync as existsSync4 } from "fs";
|
|
63184
|
+
import { basename as basename2, dirname as dirname6, resolve as resolve5 } from "path";
|
|
63085
63185
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
63086
|
-
var
|
|
63087
|
-
var
|
|
63088
|
-
|
|
63089
|
-
|
|
63090
|
-
|
|
63091
|
-
|
|
63186
|
+
var ZSH_FAIL_BELOW = "5.0";
|
|
63187
|
+
var ZSH_WARN_BELOW = "5.8";
|
|
63188
|
+
var BASH_FAIL_BELOW = "5.0";
|
|
63189
|
+
var BASH_WARN_BELOW = "5.1";
|
|
63190
|
+
var SHELL_SPECS = {
|
|
63191
|
+
zsh: {
|
|
63192
|
+
shell: "zsh",
|
|
63193
|
+
shipped: true,
|
|
63194
|
+
rcFile: ".zshrc",
|
|
63195
|
+
rcDisplay: "~/.zshrc",
|
|
63196
|
+
adapterFile: "queque.zsh",
|
|
63197
|
+
binary: "zsh",
|
|
63198
|
+
versionArgs: ["-fc", "print -r -- $ZSH_VERSION"],
|
|
63199
|
+
failBelow: ZSH_FAIL_BELOW,
|
|
63200
|
+
warnBelow: ZSH_WARN_BELOW,
|
|
63201
|
+
bindingWidget: "qq-question-widget",
|
|
63202
|
+
bindingKeymaps: ["emacs", "viins"]
|
|
63203
|
+
},
|
|
63204
|
+
bash: {
|
|
63205
|
+
shell: "bash",
|
|
63206
|
+
shipped: true,
|
|
63207
|
+
rcFile: ".bashrc",
|
|
63208
|
+
rcDisplay: "~/.bashrc",
|
|
63209
|
+
adapterFile: "queque.bash",
|
|
63210
|
+
binary: "bash",
|
|
63211
|
+
versionArgs: ["--noprofile", "--norc", "-c", 'printf %s "$BASH_VERSION"'],
|
|
63212
|
+
failBelow: BASH_FAIL_BELOW,
|
|
63213
|
+
warnBelow: BASH_WARN_BELOW,
|
|
63214
|
+
bindingWidget: "_qq_question",
|
|
63215
|
+
bindingKeymaps: ["emacs", "vi-insert"]
|
|
63216
|
+
},
|
|
63217
|
+
// Phase 12 confirms these values when the fish adapter ships.
|
|
63218
|
+
fish: {
|
|
63219
|
+
shell: "fish",
|
|
63220
|
+
shipped: false,
|
|
63221
|
+
rcFile: ".config/fish/conf.d/queque.fish",
|
|
63222
|
+
rcDisplay: "~/.config/fish/conf.d/queque.fish",
|
|
63223
|
+
adapterFile: "queque.fish",
|
|
63224
|
+
binary: "fish",
|
|
63225
|
+
versionArgs: ["--no-config", "-c", "echo $version"],
|
|
63226
|
+
failBelow: "4.0",
|
|
63227
|
+
warnBelow: "4.0",
|
|
63228
|
+
bindingWidget: "_qq_question",
|
|
63229
|
+
bindingKeymaps: ["default", "insert"]
|
|
63230
|
+
}
|
|
63231
|
+
};
|
|
63232
|
+
function getShellSpec(shell) {
|
|
63233
|
+
return SHELL_SPECS[shell];
|
|
63234
|
+
}
|
|
63235
|
+
function shippedShellNames() {
|
|
63236
|
+
return SHELL_NAMES.filter((name) => SHELL_SPECS[name].shipped);
|
|
63237
|
+
}
|
|
63238
|
+
function shellFromPath(path5) {
|
|
63239
|
+
if (!path5) {
|
|
63240
|
+
return null;
|
|
63241
|
+
}
|
|
63242
|
+
const name = basename2(path5.trim());
|
|
63243
|
+
return isShellName(name) ? name : null;
|
|
63244
|
+
}
|
|
63245
|
+
function detectShell(input) {
|
|
63246
|
+
if (input.arg !== void 0) {
|
|
63247
|
+
return isShellName(input.arg) ? input.arg : null;
|
|
63248
|
+
}
|
|
63249
|
+
return shellFromPath(input.env?.SHELL) ?? shellFromPath(input.userShell);
|
|
63250
|
+
}
|
|
63251
|
+
var HOMEBREW_PREFIXES = [
|
|
63252
|
+
"/opt/homebrew",
|
|
63253
|
+
"/usr/local",
|
|
63254
|
+
"/home/linuxbrew/.linuxbrew"
|
|
63255
|
+
];
|
|
63256
|
+
var PACKAGE_SHELL_DIR = resolve5(dirname6(fileURLToPath2(import.meta.url)), "../../shell");
|
|
63257
|
+
function resolveAdapterPath(spec, opts = {}) {
|
|
63258
|
+
const prefixes = opts.prefixes ?? HOMEBREW_PREFIXES;
|
|
63259
|
+
const exists = opts.exists ?? existsSync4;
|
|
63260
|
+
for (const prefix of prefixes) {
|
|
63261
|
+
const candidate = resolve5(prefix, "share", "queque", spec.adapterFile);
|
|
63262
|
+
if (exists(candidate)) {
|
|
63263
|
+
return candidate;
|
|
63264
|
+
}
|
|
63092
63265
|
}
|
|
63093
|
-
return resolve5(
|
|
63266
|
+
return resolve5(opts.packageShellDir ?? PACKAGE_SHELL_DIR, spec.shell, spec.adapterFile);
|
|
63094
63267
|
}
|
|
63268
|
+
var VERSION_PREFIX = /^\d+(?:\.\d+)*/;
|
|
63269
|
+
function parseShellVersion(raw) {
|
|
63270
|
+
const match = VERSION_PREFIX.exec(raw.trim());
|
|
63271
|
+
return match ? match[0].split(".").map(Number) : null;
|
|
63272
|
+
}
|
|
63273
|
+
function versionBelow(version3, threshold) {
|
|
63274
|
+
const floor = threshold.split(".").map(Number);
|
|
63275
|
+
for (let i = 0; i < Math.max(version3.length, floor.length); i++) {
|
|
63276
|
+
const a = version3[i] ?? 0;
|
|
63277
|
+
const b = floor[i] ?? 0;
|
|
63278
|
+
if (a !== b) {
|
|
63279
|
+
return a < b;
|
|
63280
|
+
}
|
|
63281
|
+
}
|
|
63282
|
+
return false;
|
|
63283
|
+
}
|
|
63284
|
+
function stripLineComment(line) {
|
|
63285
|
+
let quote = null;
|
|
63286
|
+
for (let i = 0; i < line.length; i++) {
|
|
63287
|
+
const c = line[i];
|
|
63288
|
+
if (quote === "'") {
|
|
63289
|
+
if (c === "'") quote = null;
|
|
63290
|
+
continue;
|
|
63291
|
+
}
|
|
63292
|
+
if (c === "\\") {
|
|
63293
|
+
i++;
|
|
63294
|
+
continue;
|
|
63295
|
+
}
|
|
63296
|
+
if (quote === '"') {
|
|
63297
|
+
if (c === '"') quote = null;
|
|
63298
|
+
continue;
|
|
63299
|
+
}
|
|
63300
|
+
if (c === '"' || c === "'") {
|
|
63301
|
+
quote = c;
|
|
63302
|
+
} else if (c === "#" && (i === 0 || /[\s;&|()]/.test(line[i - 1] ?? ""))) {
|
|
63303
|
+
return line.slice(0, i);
|
|
63304
|
+
}
|
|
63305
|
+
}
|
|
63306
|
+
return line;
|
|
63307
|
+
}
|
|
63308
|
+
function stripShellComments(text) {
|
|
63309
|
+
return text.split("\n").map(stripLineComment).join("\n");
|
|
63310
|
+
}
|
|
63311
|
+
var BASH_LOGIN_FILES = [".bash_profile", ".bash_login", ".profile"];
|
|
63312
|
+
var BASHRC_SOURCE_RE = /(?:^|[\s;&|])(?:\.|source)\s+["']?(?:~|\$HOME|\$\{HOME\})\/\.bashrc(?=["'\s;&|)]|$)/m;
|
|
63313
|
+
function loginFileSourcesBashrc(readRc) {
|
|
63314
|
+
for (const relPath of BASH_LOGIN_FILES) {
|
|
63315
|
+
const text = readRc(relPath);
|
|
63316
|
+
if (text !== null) {
|
|
63317
|
+
return {
|
|
63318
|
+
file: `~/${relPath}`,
|
|
63319
|
+
sourcesBashrc: BASHRC_SOURCE_RE.test(stripShellComments(text))
|
|
63320
|
+
};
|
|
63321
|
+
}
|
|
63322
|
+
}
|
|
63323
|
+
return { file: null, sourcesBashrc: false };
|
|
63324
|
+
}
|
|
63325
|
+
|
|
63326
|
+
// src/cli/commands/init.ts
|
|
63327
|
+
import { spawnSync } from "child_process";
|
|
63328
|
+
import { accessSync as accessSync2, appendFileSync, constants as constants3, readFileSync as readFileSync7, statSync as statSync3 } from "fs";
|
|
63329
|
+
import { homedir as homedir6, userInfo } from "os";
|
|
63330
|
+
import { basename as basename3, join as join5 } from "path";
|
|
63331
|
+
var MARKER = "# queque shell integration";
|
|
63332
|
+
var VERSION_PROBE_TIMEOUT_MS = 3e3;
|
|
63095
63333
|
function hasShellIntegration(existing, shell) {
|
|
63096
|
-
|
|
63334
|
+
const file2 = `queque\\.${shell}`;
|
|
63335
|
+
const scriptPattern = new RegExp(
|
|
63336
|
+
`(?:^|[\\s;&|])(?:source|\\.)\\s+(?:"[^"\\n]*${file2}"|'[^'\\n]*${file2}'|[^\\s"';&|]*${file2}(?=[\\s;&|)]|$))`,
|
|
63337
|
+
"m"
|
|
63338
|
+
);
|
|
63339
|
+
return scriptPattern.test(stripShellComments(existing));
|
|
63340
|
+
}
|
|
63341
|
+
function whichOnPath(name, pathEnv) {
|
|
63342
|
+
for (const dir of (pathEnv ?? "").split(":")) {
|
|
63343
|
+
if (!dir) {
|
|
63344
|
+
continue;
|
|
63345
|
+
}
|
|
63346
|
+
const candidate = join5(dir, name);
|
|
63347
|
+
try {
|
|
63348
|
+
if (statSync3(candidate).isFile()) {
|
|
63349
|
+
accessSync2(candidate, constants3.X_OK);
|
|
63350
|
+
return candidate;
|
|
63351
|
+
}
|
|
63352
|
+
} catch {
|
|
63353
|
+
}
|
|
63354
|
+
}
|
|
63355
|
+
return null;
|
|
63356
|
+
}
|
|
63357
|
+
function passwdShell() {
|
|
63358
|
+
try {
|
|
63359
|
+
return userInfo().shell ?? void 0;
|
|
63360
|
+
} catch {
|
|
63361
|
+
return void 0;
|
|
63362
|
+
}
|
|
63363
|
+
}
|
|
63364
|
+
function defaultInitDeps() {
|
|
63365
|
+
const env3 = process.env;
|
|
63366
|
+
return {
|
|
63367
|
+
home: homedir6(),
|
|
63368
|
+
env: env3,
|
|
63369
|
+
platform: process.platform,
|
|
63370
|
+
userShell: passwdShell(),
|
|
63371
|
+
which: (name) => whichOnPath(name, env3.PATH),
|
|
63372
|
+
probeVersion: (binary, args) => {
|
|
63373
|
+
const probeEnv2 = { ...env3 };
|
|
63374
|
+
delete probeEnv2.BASH_ENV;
|
|
63375
|
+
delete probeEnv2.ENV;
|
|
63376
|
+
const result = spawnSync(binary, [...args], {
|
|
63377
|
+
encoding: "utf8",
|
|
63378
|
+
env: probeEnv2,
|
|
63379
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
63380
|
+
timeout: VERSION_PROBE_TIMEOUT_MS
|
|
63381
|
+
});
|
|
63382
|
+
return result.status === 0 && typeof result.stdout === "string" ? result.stdout : null;
|
|
63383
|
+
},
|
|
63384
|
+
readFile: (path5) => {
|
|
63385
|
+
try {
|
|
63386
|
+
return readFileSync7(path5, "utf8");
|
|
63387
|
+
} catch {
|
|
63388
|
+
return null;
|
|
63389
|
+
}
|
|
63390
|
+
},
|
|
63391
|
+
appendFile: (path5, text) => appendFileSync(path5, text),
|
|
63392
|
+
out: (line) => console.log(line),
|
|
63393
|
+
err: (line) => console.error(line)
|
|
63394
|
+
};
|
|
63395
|
+
}
|
|
63396
|
+
var refused = { exitCode: 1, wrote: false };
|
|
63397
|
+
var BASH_NOT_FOUND = "queque: bash not found; bash 5.0 or newer is needed for the ?? trigger";
|
|
63398
|
+
var BASH_TOO_OLD_DARWIN = "bash 5+ needed: brew install bash";
|
|
63399
|
+
var BASH_TOO_OLD = "bash 5.0 or newer is needed for the ?? trigger";
|
|
63400
|
+
var BASH_NEWER_NOT_LOGIN = "queque: a newer bash is installed but is not your login shell; add it to /etc/shells, run chsh -s with its path, then run qq init bash again";
|
|
63401
|
+
var FISH_NOT_SHIPPED = "queque: fish support is coming in a later release; supported now: zsh, bash";
|
|
63402
|
+
var CANNOT_DETECT = "queque: could not detect your shell; run qq init zsh or qq init bash";
|
|
63403
|
+
var BASHRC_SNIPPET = " [ -f ~/.bashrc ] && . ~/.bashrc";
|
|
63404
|
+
function bashVersion(deps, spec, binary) {
|
|
63405
|
+
if (!binary) {
|
|
63406
|
+
return null;
|
|
63407
|
+
}
|
|
63408
|
+
const raw = deps.probeVersion(binary, spec.versionArgs);
|
|
63409
|
+
return raw === null ? null : parseShellVersion(raw);
|
|
63410
|
+
}
|
|
63411
|
+
function bashGate(deps, spec) {
|
|
63412
|
+
const shellEnv = deps.env.SHELL;
|
|
63413
|
+
const loginBash = shellEnv && basename3(shellEnv) === spec.binary ? shellEnv : null;
|
|
63414
|
+
const pathBash = deps.which(spec.binary);
|
|
63415
|
+
const binary = loginBash ?? pathBash;
|
|
63416
|
+
const version3 = bashVersion(deps, spec, binary);
|
|
63417
|
+
if (!version3) {
|
|
63418
|
+
deps.err(BASH_NOT_FOUND);
|
|
63419
|
+
return false;
|
|
63420
|
+
}
|
|
63421
|
+
if (!versionBelow(version3, spec.failBelow)) {
|
|
63097
63422
|
return true;
|
|
63098
63423
|
}
|
|
63099
|
-
|
|
63100
|
-
|
|
63424
|
+
deps.err(deps.platform === "darwin" ? BASH_TOO_OLD_DARWIN : BASH_TOO_OLD);
|
|
63425
|
+
if (loginBash && pathBash && pathBash !== loginBash) {
|
|
63426
|
+
const other = bashVersion(deps, spec, pathBash);
|
|
63427
|
+
if (other && !versionBelow(other, spec.failBelow)) {
|
|
63428
|
+
deps.err(BASH_NEWER_NOT_LOGIN);
|
|
63429
|
+
}
|
|
63430
|
+
}
|
|
63431
|
+
return false;
|
|
63101
63432
|
}
|
|
63102
|
-
function
|
|
63433
|
+
function loginShellHint(deps) {
|
|
63434
|
+
const login = loginFileSourcesBashrc((relPath) => deps.readFile(join5(deps.home, relPath)));
|
|
63435
|
+
if (login.sourcesBashrc) {
|
|
63436
|
+
return;
|
|
63437
|
+
}
|
|
63438
|
+
const file2 = login.file ?? "~/.bash_profile";
|
|
63439
|
+
deps.err(`queque: macOS terminals start login shells; make ${file2} source ~/.bashrc`);
|
|
63440
|
+
deps.err(BASHRC_SNIPPET);
|
|
63441
|
+
}
|
|
63442
|
+
function runInit(shellArg, deps) {
|
|
63103
63443
|
bootstrapBuiltins();
|
|
63104
|
-
const
|
|
63105
|
-
|
|
63106
|
-
|
|
63107
|
-
|
|
63108
|
-
|
|
63109
|
-
|
|
63110
|
-
|
|
63111
|
-
|
|
63112
|
-
|
|
63444
|
+
const registered = new Set(listShellAdapters().map((adapter) => adapter.shell));
|
|
63445
|
+
const supported = shippedShellNames().filter((name) => registered.has(name));
|
|
63446
|
+
const shell = detectShell({ arg: shellArg, env: deps.env, userShell: deps.userShell });
|
|
63447
|
+
if (shellArg !== void 0 && shell === null) {
|
|
63448
|
+
deps.err(`Unsupported shell: '${shellArg}'. Supported: ${supported.join(", ")}`);
|
|
63449
|
+
return refused;
|
|
63450
|
+
}
|
|
63451
|
+
if (shell === null) {
|
|
63452
|
+
deps.err(CANNOT_DETECT);
|
|
63453
|
+
return refused;
|
|
63454
|
+
}
|
|
63455
|
+
const spec = getShellSpec(shell);
|
|
63456
|
+
if (!spec.shipped) {
|
|
63457
|
+
deps.err(FISH_NOT_SHIPPED);
|
|
63458
|
+
return refused;
|
|
63459
|
+
}
|
|
63460
|
+
if (!supported.includes(shell)) {
|
|
63461
|
+
deps.err(`Unsupported shell: '${shell}'. Supported: ${supported.join(", ")}`);
|
|
63462
|
+
return refused;
|
|
63463
|
+
}
|
|
63464
|
+
if (shell === "bash" && !bashGate(deps, spec)) {
|
|
63465
|
+
return refused;
|
|
63466
|
+
}
|
|
63467
|
+
const rcPath = join5(deps.home, spec.rcFile);
|
|
63468
|
+
const existing = deps.readFile(rcPath) ?? "";
|
|
63469
|
+
let wrote = false;
|
|
63113
63470
|
if (hasShellIntegration(existing, shell)) {
|
|
63114
|
-
|
|
63115
|
-
|
|
63116
|
-
|
|
63117
|
-
|
|
63118
|
-
|
|
63119
|
-
${
|
|
63471
|
+
deps.err(`queque: shell integration already present in ${spec.rcDisplay}`);
|
|
63472
|
+
} else {
|
|
63473
|
+
const scriptPath = (deps.adapterPath ?? resolveAdapterPath)(spec);
|
|
63474
|
+
deps.appendFile(rcPath, `
|
|
63475
|
+
${MARKER}
|
|
63476
|
+
source "${scriptPath}"
|
|
63120
63477
|
`);
|
|
63121
|
-
|
|
63478
|
+
deps.out(
|
|
63479
|
+
`queque: added shell integration to ${spec.rcDisplay} \u2014 run: source ${spec.rcDisplay}`
|
|
63480
|
+
);
|
|
63481
|
+
wrote = true;
|
|
63482
|
+
}
|
|
63483
|
+
if (shell === "bash" && deps.platform === "darwin") {
|
|
63484
|
+
loginShellHint(deps);
|
|
63485
|
+
}
|
|
63486
|
+
return { exitCode: 0, wrote };
|
|
63487
|
+
}
|
|
63488
|
+
function initCommand(shell, deps = defaultInitDeps()) {
|
|
63489
|
+
const result = runInit(shell, deps);
|
|
63490
|
+
if (result.exitCode !== 0) {
|
|
63491
|
+
process.exitCode = result.exitCode;
|
|
63492
|
+
}
|
|
63122
63493
|
}
|
|
63123
63494
|
|
|
63124
63495
|
// src/cli/commands/doctor.ts
|
|
63125
|
-
var ZSH_FAIL_BELOW = "5.0";
|
|
63126
|
-
var ZSH_WARN_BELOW = "5.8";
|
|
63127
63496
|
var SOCKET_PATH_MAX_BYTES = { linux: 107, darwin: 103 };
|
|
63128
63497
|
var SOCKET_PATH_MAX_DEFAULT = 107;
|
|
63129
63498
|
var NODE_WARN_BELOW_MAJOR = 24;
|
|
63130
|
-
var
|
|
63131
|
-
var
|
|
63132
|
-
var ZSH_BINDINGS_TIMEOUT_MS = 5e3;
|
|
63499
|
+
var SHELL_VERSION_TIMEOUT_MS = 3e3;
|
|
63500
|
+
var SHELL_BINDINGS_TIMEOUT_MS = 5e3;
|
|
63133
63501
|
var EXIT_GRACE_MS = 100;
|
|
63134
63502
|
var MAX_CAPTURE_CHARS = 64 * 1024;
|
|
63135
|
-
function
|
|
63503
|
+
function whichOnPath2(name, pathEnv) {
|
|
63136
63504
|
for (const dir of (pathEnv ?? "").split(":")) {
|
|
63137
63505
|
if (!dir) {
|
|
63138
63506
|
continue;
|
|
63139
63507
|
}
|
|
63140
63508
|
const candidate = join6(dir, name);
|
|
63141
63509
|
try {
|
|
63142
|
-
if (
|
|
63143
|
-
|
|
63510
|
+
if (statSync4(candidate).isFile()) {
|
|
63511
|
+
accessSync3(candidate, constants4.X_OK);
|
|
63144
63512
|
return candidate;
|
|
63145
63513
|
}
|
|
63146
63514
|
} catch {
|
|
@@ -63194,23 +63562,47 @@ function captureStdout(command, args, timeoutMs, env3) {
|
|
|
63194
63562
|
var BINDING_LINE = /^__qq_(emacs|viins)__ (.*)$/gm;
|
|
63195
63563
|
var BOUND_WIDGET = /^"\?" ([A-Za-z0-9_.:+-]{1,64})$/;
|
|
63196
63564
|
function parseZshBindings(output) {
|
|
63197
|
-
const
|
|
63565
|
+
const keymaps = { emacs: null, viins: null };
|
|
63198
63566
|
let seen = false;
|
|
63199
63567
|
for (const match of output.matchAll(BINDING_LINE)) {
|
|
63200
63568
|
seen = true;
|
|
63201
63569
|
const keymap = match[1];
|
|
63202
63570
|
const widget = BOUND_WIDGET.exec(match[2]?.trim() ?? "");
|
|
63203
|
-
|
|
63571
|
+
keymaps[keymap] = widget?.[1] ?? null;
|
|
63572
|
+
}
|
|
63573
|
+
return seen ? { keymaps, bracketedPaste: null, bleLoaded: false } : null;
|
|
63574
|
+
}
|
|
63575
|
+
var BASH_BINDINGS_SCRIPT = `for __qq_m in emacs vi-insert; do builtin printf '__qq_%s__ %s\\n' "$__qq_m" "$({ builtin bind -m "$__qq_m" -X; builtin bind -m "$__qq_m" -p; } 2>/dev/null | command grep -m 1 -F '"?"')"; done; builtin printf '__qq_paste__ %s\\n' "$(builtin bind -v 2>/dev/null | command grep -F enable-bracketed-paste)"; builtin printf '__qq_ble__ %s\\n' "\${BLE_VERSION:-}"`;
|
|
63576
|
+
var BASH_MARKER = /__qq_(emacs|vi-insert|paste|ble)__ ?([^\n]*)/g;
|
|
63577
|
+
var BASH_BOUND = /^"\?":?\s+"?([A-Za-z0-9_.:+-]{1,64})"?$/;
|
|
63578
|
+
var BASH_PASTE = /^set enable-bracketed-paste (on|off)$/;
|
|
63579
|
+
function parseBashBindings(output) {
|
|
63580
|
+
const keymaps = { emacs: null, "vi-insert": null };
|
|
63581
|
+
let bracketedPaste = null;
|
|
63582
|
+
let bleLoaded = false;
|
|
63583
|
+
let seen = false;
|
|
63584
|
+
for (const match of output.matchAll(BASH_MARKER)) {
|
|
63585
|
+
seen = true;
|
|
63586
|
+
const marker = match[1];
|
|
63587
|
+
const value = (match[2] ?? "").trim();
|
|
63588
|
+
if (marker === "paste") {
|
|
63589
|
+
const paste = BASH_PASTE.exec(value);
|
|
63590
|
+
bracketedPaste = paste ? paste[1] === "on" : null;
|
|
63591
|
+
} else if (marker === "ble") {
|
|
63592
|
+
bleLoaded = value !== "";
|
|
63593
|
+
} else if (marker !== void 0) {
|
|
63594
|
+
keymaps[marker] = BASH_BOUND.exec(value)?.[1] ?? null;
|
|
63595
|
+
}
|
|
63204
63596
|
}
|
|
63205
|
-
return seen ?
|
|
63597
|
+
return seen ? { keymaps, bracketedPaste, bleLoaded } : null;
|
|
63206
63598
|
}
|
|
63207
63599
|
var BINDINGS_SCRIPT = `print -r -- "__qq_emacs__ $(bindkey -M emacs '?')"; print -r -- "__qq_viins__ $(bindkey -M viins '?')"`;
|
|
63208
63600
|
function probeTmpDir() {
|
|
63209
63601
|
try {
|
|
63210
|
-
if (!
|
|
63602
|
+
if (!statSync4("/tmp").isDirectory()) {
|
|
63211
63603
|
return false;
|
|
63212
63604
|
}
|
|
63213
|
-
|
|
63605
|
+
accessSync3("/tmp", constants4.W_OK);
|
|
63214
63606
|
const dir = mkdtempSync("/tmp/qq-doctor-");
|
|
63215
63607
|
rmSync(dir, { recursive: true, force: true });
|
|
63216
63608
|
return true;
|
|
@@ -63225,9 +63617,31 @@ function lstatOwner(path5) {
|
|
|
63225
63617
|
return null;
|
|
63226
63618
|
}
|
|
63227
63619
|
}
|
|
63620
|
+
function passwdShell2() {
|
|
63621
|
+
try {
|
|
63622
|
+
return userInfo2().shell ?? void 0;
|
|
63623
|
+
} catch {
|
|
63624
|
+
return void 0;
|
|
63625
|
+
}
|
|
63626
|
+
}
|
|
63627
|
+
function probeEnv(env3) {
|
|
63628
|
+
const { BASH_ENV: _bashEnv, ENV: _env, ...rest } = env3;
|
|
63629
|
+
return rest;
|
|
63630
|
+
}
|
|
63228
63631
|
function defaultDoctorDeps() {
|
|
63229
63632
|
const env3 = process.env;
|
|
63230
63633
|
const homeDir = homedir7();
|
|
63634
|
+
const which = (name) => whichOnPath2(name, env3.PATH);
|
|
63635
|
+
const shellBinary = (shell) => {
|
|
63636
|
+
const spec = getShellSpec(shell);
|
|
63637
|
+
if (!spec.shipped) {
|
|
63638
|
+
return null;
|
|
63639
|
+
}
|
|
63640
|
+
if (shell === "bash" && env3.SHELL && basename4(env3.SHELL) === "bash") {
|
|
63641
|
+
return env3.SHELL;
|
|
63642
|
+
}
|
|
63643
|
+
return shell === "zsh" ? "zsh" : which(spec.binary);
|
|
63644
|
+
};
|
|
63231
63645
|
return {
|
|
63232
63646
|
env: env3,
|
|
63233
63647
|
platform: process.platform,
|
|
@@ -63235,31 +63649,40 @@ function defaultDoctorDeps() {
|
|
|
63235
63649
|
uid: process.getuid?.() ?? 0,
|
|
63236
63650
|
socketPath: socketPath(),
|
|
63237
63651
|
nodeVersion: process.versions.node,
|
|
63238
|
-
qqVersion: "0.
|
|
63239
|
-
which
|
|
63240
|
-
|
|
63241
|
-
const
|
|
63242
|
-
|
|
63243
|
-
|
|
63244
|
-
|
|
63245
|
-
|
|
63246
|
-
);
|
|
63652
|
+
qqVersion: "0.10.1",
|
|
63653
|
+
which,
|
|
63654
|
+
shellVersion: async (shell) => {
|
|
63655
|
+
const binary = shellBinary(shell);
|
|
63656
|
+
if (binary === null) {
|
|
63657
|
+
return null;
|
|
63658
|
+
}
|
|
63659
|
+
const args = [...getShellSpec(shell).versionArgs];
|
|
63660
|
+
const out = await captureStdout(binary, args, SHELL_VERSION_TIMEOUT_MS, probeEnv(env3));
|
|
63247
63661
|
return out?.trim() || null;
|
|
63248
63662
|
},
|
|
63249
|
-
|
|
63250
|
-
const
|
|
63251
|
-
|
|
63663
|
+
shellBindings: async (shell) => {
|
|
63664
|
+
const binary = shellBinary(shell);
|
|
63665
|
+
if (binary === null) {
|
|
63666
|
+
return null;
|
|
63667
|
+
}
|
|
63668
|
+
const script = shell === "bash" ? BASH_BINDINGS_SCRIPT : BINDINGS_SCRIPT;
|
|
63669
|
+
const out = await captureStdout(binary, ["-ic", script], SHELL_BINDINGS_TIMEOUT_MS, {
|
|
63670
|
+
...probeEnv(env3),
|
|
63252
63671
|
QQ_DAEMON_PREWARMED: "1"
|
|
63253
63672
|
});
|
|
63254
|
-
|
|
63673
|
+
if (out === null) {
|
|
63674
|
+
return null;
|
|
63675
|
+
}
|
|
63676
|
+
return shell === "bash" ? parseBashBindings(out) : parseZshBindings(out);
|
|
63255
63677
|
},
|
|
63256
|
-
|
|
63678
|
+
readRc: (relPath) => {
|
|
63257
63679
|
try {
|
|
63258
|
-
return readFileSync8(join6(homeDir,
|
|
63680
|
+
return readFileSync8(join6(homeDir, relPath), "utf8");
|
|
63259
63681
|
} catch {
|
|
63260
63682
|
return null;
|
|
63261
63683
|
}
|
|
63262
63684
|
},
|
|
63685
|
+
userShell: passwdShell2(),
|
|
63263
63686
|
probeTmp: probeTmpDir,
|
|
63264
63687
|
socketOwner: lstatOwner,
|
|
63265
63688
|
pingDaemon: pingDaemonFetchCap,
|
|
@@ -63273,22 +63696,6 @@ function defaultDoctorDeps() {
|
|
|
63273
63696
|
})
|
|
63274
63697
|
};
|
|
63275
63698
|
}
|
|
63276
|
-
var VERSION_PREFIX = /^\d+(?:\.\d+)*/;
|
|
63277
|
-
function versionParts(text) {
|
|
63278
|
-
const match = VERSION_PREFIX.exec(text.trim());
|
|
63279
|
-
return match ? match[0].split(".").map(Number) : null;
|
|
63280
|
-
}
|
|
63281
|
-
function versionBelow(version3, threshold) {
|
|
63282
|
-
const floor = threshold.split(".").map(Number);
|
|
63283
|
-
for (let i = 0; i < Math.max(version3.length, floor.length); i++) {
|
|
63284
|
-
const a = version3[i] ?? 0;
|
|
63285
|
-
const b = floor[i] ?? 0;
|
|
63286
|
-
if (a !== b) {
|
|
63287
|
-
return a < b;
|
|
63288
|
-
}
|
|
63289
|
-
}
|
|
63290
|
-
return false;
|
|
63291
|
-
}
|
|
63292
63699
|
var ok = (id, summary) => ({ id, status: "ok", summary });
|
|
63293
63700
|
var warn = (id, summary, hint) => ({
|
|
63294
63701
|
id,
|
|
@@ -63302,28 +63709,39 @@ var fail = (id, summary, hint) => ({
|
|
|
63302
63709
|
summary,
|
|
63303
63710
|
hint
|
|
63304
63711
|
});
|
|
63305
|
-
|
|
63306
|
-
|
|
63307
|
-
|
|
63308
|
-
|
|
63712
|
+
function installHint(spec, platform2) {
|
|
63713
|
+
if (spec.shell === "bash") {
|
|
63714
|
+
return platform2 === "darwin" ? `brew install bash (${BASH_WARN_BELOW} or newer), then make it your login shell` : `install bash ${BASH_WARN_BELOW} or newer with your package manager`;
|
|
63715
|
+
}
|
|
63716
|
+
return `install ${spec.shell} ${spec.warnBelow} or newer`;
|
|
63717
|
+
}
|
|
63718
|
+
var BASH_PASTE_DEFAULT_SINCE = "5.1";
|
|
63719
|
+
async function checkShellVersion(deps, spec) {
|
|
63720
|
+
const id = spec.shell;
|
|
63721
|
+
const hint = installHint(spec, deps.platform);
|
|
63722
|
+
if (deps.which(spec.binary) === null) {
|
|
63723
|
+
return { check: fail(id, `${id} not found on PATH`, hint), parts: null };
|
|
63724
|
+
}
|
|
63725
|
+
let raw;
|
|
63726
|
+
try {
|
|
63727
|
+
raw = await deps.shellVersion(spec.shell);
|
|
63728
|
+
} catch {
|
|
63729
|
+
raw = null;
|
|
63309
63730
|
}
|
|
63310
|
-
const
|
|
63311
|
-
const parts = raw === null ? null : versionParts(raw);
|
|
63731
|
+
const parts = raw === null ? null : parseShellVersion(raw);
|
|
63312
63732
|
if (parts === null) {
|
|
63313
|
-
return warn(
|
|
63733
|
+
return { check: warn(id, `${id} is on PATH but its version could not be read`, hint), parts };
|
|
63314
63734
|
}
|
|
63315
|
-
const version3 = parts.join(".");
|
|
63316
|
-
if (versionBelow(parts,
|
|
63317
|
-
return fail(
|
|
63735
|
+
const version3 = parts.slice(0, 3).join(".");
|
|
63736
|
+
if (versionBelow(parts, spec.failBelow)) {
|
|
63737
|
+
return { check: fail(id, `${id} ${version3} is older than ${spec.failBelow}`, hint), parts };
|
|
63318
63738
|
}
|
|
63319
|
-
if (versionBelow(parts,
|
|
63320
|
-
|
|
63321
|
-
|
|
63322
|
-
|
|
63323
|
-
ZSH_INSTALL_HINT
|
|
63324
|
-
);
|
|
63739
|
+
if (versionBelow(parts, spec.warnBelow)) {
|
|
63740
|
+
const paste = spec.shell === "bash" && versionBelow(parts, BASH_PASTE_DEFAULT_SINCE) ? `; bracketed paste is off by default before ${BASH_PASTE_DEFAULT_SINCE}` : "";
|
|
63741
|
+
const summary = `${id} ${version3} is untested (oldest tested is ${spec.warnBelow}${paste})`;
|
|
63742
|
+
return { check: warn(id, summary, hint), parts };
|
|
63325
63743
|
}
|
|
63326
|
-
return ok(
|
|
63744
|
+
return { check: ok(id, `${id} ${version3}`), parts };
|
|
63327
63745
|
}
|
|
63328
63746
|
function checkJq(deps) {
|
|
63329
63747
|
if (deps.which("jq") === null) {
|
|
@@ -63397,33 +63815,94 @@ async function checkDaemon(deps) {
|
|
|
63397
63815
|
}
|
|
63398
63816
|
return ok("daemon", "daemon not running; starts on the next ??");
|
|
63399
63817
|
}
|
|
63400
|
-
function
|
|
63401
|
-
|
|
63402
|
-
return
|
|
63818
|
+
function readRcSafe(deps, relPath) {
|
|
63819
|
+
try {
|
|
63820
|
+
return deps.readRc(relPath);
|
|
63821
|
+
} catch {
|
|
63822
|
+
return null;
|
|
63823
|
+
}
|
|
63824
|
+
}
|
|
63825
|
+
function checkIntegration(deps, spec) {
|
|
63826
|
+
if (!hasShellIntegration(readRcSafe(deps, spec.rcFile) ?? "", spec.shell)) {
|
|
63827
|
+
return warn(
|
|
63828
|
+
"integration",
|
|
63829
|
+
`${spec.rcDisplay} does not load QueQue`,
|
|
63830
|
+
`qq init ${spec.shell} && source ${spec.rcDisplay}`
|
|
63831
|
+
);
|
|
63832
|
+
}
|
|
63833
|
+
return ok("integration", `${spec.rcDisplay} loads QueQue`);
|
|
63834
|
+
}
|
|
63835
|
+
var BASHRC_SOURCE_LINE = "[ -f ~/.bashrc ] && . ~/.bashrc";
|
|
63836
|
+
function checkBashProfile(deps) {
|
|
63837
|
+
const login = loginFileSourcesBashrc((relPath) => readRcSafe(deps, relPath));
|
|
63838
|
+
if (login.file === null) {
|
|
63839
|
+
return warn(
|
|
63840
|
+
"bash_profile",
|
|
63841
|
+
"no ~/.bash_profile, ~/.bash_login or ~/.profile; macOS login shells skip ~/.bashrc",
|
|
63842
|
+
`add ${BASHRC_SOURCE_LINE} to ~/.bash_profile`
|
|
63843
|
+
);
|
|
63403
63844
|
}
|
|
63404
|
-
|
|
63845
|
+
if (!login.sourcesBashrc) {
|
|
63846
|
+
return warn(
|
|
63847
|
+
"bash_profile",
|
|
63848
|
+
`${login.file} does not source ~/.bashrc; macOS login shells skip it`,
|
|
63849
|
+
`add ${BASHRC_SOURCE_LINE} to ${login.file}`
|
|
63850
|
+
);
|
|
63851
|
+
}
|
|
63852
|
+
return ok("bash_profile", `${login.file} sources ~/.bashrc`);
|
|
63853
|
+
}
|
|
63854
|
+
function bindingHint(spec) {
|
|
63855
|
+
return spec.shell === "bash" ? "qq init bash && source ~/.bashrc, then check what rebinds ? later in ~/.bashrc" : "qq init zsh && source ~/.zshrc, then check plugins that rebind ?";
|
|
63405
63856
|
}
|
|
63406
|
-
async function checkBinding(deps) {
|
|
63857
|
+
async function checkBinding(deps, spec, version3) {
|
|
63858
|
+
const hint = bindingHint(spec);
|
|
63859
|
+
if (version3.check.status === "fail" || spec.shell === "bash" && version3.parts === null) {
|
|
63860
|
+
return warn(
|
|
63861
|
+
"binding",
|
|
63862
|
+
`? key bindings not checked: ${spec.shell} ${spec.failBelow} or newer is needed first`,
|
|
63863
|
+
installHint(spec, deps.platform)
|
|
63864
|
+
);
|
|
63865
|
+
}
|
|
63407
63866
|
let bindings;
|
|
63408
63867
|
try {
|
|
63409
|
-
bindings = await deps.
|
|
63868
|
+
bindings = await deps.shellBindings(spec.shell);
|
|
63410
63869
|
} catch {
|
|
63411
63870
|
bindings = null;
|
|
63412
63871
|
}
|
|
63413
|
-
const hint = "qq init zsh && source ~/.zshrc, then check plugins that rebind ?";
|
|
63414
63872
|
if (bindings === null) {
|
|
63415
|
-
return warn(
|
|
63873
|
+
return warn(
|
|
63874
|
+
"binding",
|
|
63875
|
+
`could not read the ? key bindings from an interactive ${spec.shell}`,
|
|
63876
|
+
hint
|
|
63877
|
+
);
|
|
63416
63878
|
}
|
|
63417
|
-
|
|
63418
|
-
|
|
63879
|
+
if (bindings.bleLoaded) {
|
|
63880
|
+
return warn(
|
|
63881
|
+
"binding",
|
|
63882
|
+
"ble.sh is loaded and replaces readline; the ?? trigger needs plain readline",
|
|
63883
|
+
"start bash without ble.sh (remove it from ~/.bashrc) to use ??"
|
|
63884
|
+
);
|
|
63885
|
+
}
|
|
63886
|
+
for (const keymap of spec.bindingKeymaps) {
|
|
63887
|
+
const widget = bindings.keymaps[keymap] ?? null;
|
|
63419
63888
|
if (widget === null) {
|
|
63420
63889
|
return warn("binding", `? has no readable binding in the ${keymap} keymap`, hint);
|
|
63421
63890
|
}
|
|
63422
|
-
if (widget !==
|
|
63891
|
+
if (widget !== spec.bindingWidget) {
|
|
63423
63892
|
return warn("binding", `? is bound to ${widget} in the ${keymap} keymap`, hint);
|
|
63424
63893
|
}
|
|
63425
63894
|
}
|
|
63426
|
-
|
|
63895
|
+
if (bindings.bracketedPaste === false) {
|
|
63896
|
+
return warn(
|
|
63897
|
+
"binding",
|
|
63898
|
+
"bracketed paste is off, so pasting text that contains ?? opens QueQue",
|
|
63899
|
+
"add set enable-bracketed-paste on to ~/.inputrc"
|
|
63900
|
+
);
|
|
63901
|
+
}
|
|
63902
|
+
return ok(
|
|
63903
|
+
"binding",
|
|
63904
|
+
`? is bound to ${spec.bindingWidget} in ${spec.bindingKeymaps.join(" and ")}`
|
|
63905
|
+
);
|
|
63427
63906
|
}
|
|
63428
63907
|
function checkTerm(deps) {
|
|
63429
63908
|
const term = deps.env.TERM;
|
|
@@ -63481,7 +63960,7 @@ async function checkProvider(deps) {
|
|
|
63481
63960
|
return ok("provider", `provider detected: ${DETECTED_NAMES[detected.kind]}`);
|
|
63482
63961
|
}
|
|
63483
63962
|
function checkNode(deps) {
|
|
63484
|
-
const parts =
|
|
63963
|
+
const parts = parseShellVersion(deps.nodeVersion);
|
|
63485
63964
|
if (parts === null) {
|
|
63486
63965
|
return warn(
|
|
63487
63966
|
"node",
|
|
@@ -63520,20 +63999,33 @@ function checkTelemetry(deps) {
|
|
|
63520
63999
|
function reportPlatform(platform2) {
|
|
63521
64000
|
return platform2 === "darwin" || platform2 === "linux" ? platform2 : "other";
|
|
63522
64001
|
}
|
|
63523
|
-
|
|
63524
|
-
|
|
63525
|
-
|
|
64002
|
+
function resolveDoctorShell(deps, requested) {
|
|
64003
|
+
if (requested !== void 0 && getShellSpec(requested).shipped) {
|
|
64004
|
+
return requested;
|
|
64005
|
+
}
|
|
64006
|
+
const detected = detectShell({ env: deps.env, userShell: deps.userShell });
|
|
64007
|
+
return detected !== null && getShellSpec(detected).shipped ? detected : "zsh";
|
|
64008
|
+
}
|
|
64009
|
+
async function runDoctorChecks(deps = defaultDoctorDeps(), options = {}) {
|
|
64010
|
+
const spec = getShellSpec(resolveDoctorShell(deps, options.shell));
|
|
64011
|
+
const versionThenBinding = (async () => {
|
|
64012
|
+
const version4 = await checkShellVersion(deps, spec);
|
|
64013
|
+
return { version: version4, binding: await checkBinding(deps, spec, version4) };
|
|
64014
|
+
})();
|
|
64015
|
+
const [{ version: version3, binding }, daemon, provider] = await Promise.all([
|
|
64016
|
+
versionThenBinding,
|
|
63526
64017
|
checkDaemon(deps),
|
|
63527
|
-
checkBinding(deps),
|
|
63528
64018
|
checkProvider(deps)
|
|
63529
64019
|
]);
|
|
64020
|
+
const loginRow = spec.shell === "bash" && deps.platform === "darwin" ? [checkBashProfile(deps)] : [];
|
|
63530
64021
|
const checks = [
|
|
63531
|
-
|
|
64022
|
+
version3.check,
|
|
63532
64023
|
checkJq(deps),
|
|
63533
64024
|
checkTmp(deps),
|
|
63534
64025
|
checkSocket(deps),
|
|
63535
64026
|
daemon,
|
|
63536
|
-
checkIntegration(deps),
|
|
64027
|
+
checkIntegration(deps, spec),
|
|
64028
|
+
...loginRow,
|
|
63537
64029
|
binding,
|
|
63538
64030
|
checkTerm(deps),
|
|
63539
64031
|
checkLocale(deps),
|
|
@@ -63563,7 +64055,26 @@ function formatDoctorReport(report) {
|
|
|
63563
64055
|
`;
|
|
63564
64056
|
}
|
|
63565
64057
|
async function doctorCommand(options, deps) {
|
|
63566
|
-
const
|
|
64058
|
+
const supported = shippedShellNames().join(", ");
|
|
64059
|
+
let shell;
|
|
64060
|
+
if (options.shell !== void 0) {
|
|
64061
|
+
if (!isShellName(options.shell)) {
|
|
64062
|
+
process.stderr.write(`qq doctor: unsupported shell; supported: ${supported}
|
|
64063
|
+
`);
|
|
64064
|
+
process.exitCode = 2;
|
|
64065
|
+
return;
|
|
64066
|
+
}
|
|
64067
|
+
if (!getShellSpec(options.shell).shipped) {
|
|
64068
|
+
process.stderr.write(
|
|
64069
|
+
`qq doctor: ${options.shell} support is coming in a later release; supported now: ${supported}
|
|
64070
|
+
`
|
|
64071
|
+
);
|
|
64072
|
+
process.exitCode = 2;
|
|
64073
|
+
return;
|
|
64074
|
+
}
|
|
64075
|
+
shell = options.shell;
|
|
64076
|
+
}
|
|
64077
|
+
const report = await runDoctorChecks(deps ?? defaultDoctorDeps(), { shell });
|
|
63567
64078
|
process.stdout.write(
|
|
63568
64079
|
options.json ? `${JSON.stringify(report, null, 2)}
|
|
63569
64080
|
` : formatDoctorReport(report)
|
|
@@ -63592,7 +64103,7 @@ var MAX_ATTEMPTS = 3;
|
|
|
63592
64103
|
var MAX_REASON = 120;
|
|
63593
64104
|
var NO_CHANGES = "No changes made.";
|
|
63594
64105
|
var CLAUDE_AUTH_HINT = "If ?? says Claude is not authenticated, run `claude /login` or set ANTHROPIC_API_KEY (docs: https://code.claude.com/docs/en/authentication).";
|
|
63595
|
-
var OPENAI_KEY_MISSING = "OPENAI_API_KEY is not set. Add `export OPENAI_API_KEY=...` to ~/.zshrc
|
|
64106
|
+
var OPENAI_KEY_MISSING = "OPENAI_API_KEY is not set. Add `export OPENAI_API_KEY=...` to your shell rc file (~/.zshrc or ~/.bashrc), before the queque source line, or put it in ~/.env.local, open a new terminal, and run `qq init provider` again.";
|
|
63596
64107
|
function openDownloadUrl(url2) {
|
|
63597
64108
|
if (url2 !== OLLAMA_DOWNLOAD_URL) {
|
|
63598
64109
|
return;
|
|
@@ -64113,13 +64624,16 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
64113
64624
|
process.exit(process.exitCode ?? 0);
|
|
64114
64625
|
});
|
|
64115
64626
|
cli.command(
|
|
64116
|
-
"init
|
|
64117
|
-
"Add
|
|
64627
|
+
"init [shell]",
|
|
64628
|
+
"Add the ?? trigger to your shell rc file (detects zsh or bash; `qq init bash` picks one), or run `qq init provider` to pick OpenAI or Ollama"
|
|
64118
64629
|
).action(async (shell) => {
|
|
64119
64630
|
await dispatchInit(shell);
|
|
64120
64631
|
});
|
|
64121
|
-
cli.command("doctor", "Check this machine for problems that stop ??").option("--json", "Print the report as JSON").
|
|
64122
|
-
|
|
64632
|
+
cli.command("doctor", "Check this machine for problems that stop ??").option("--json", "Print the report as JSON").option(
|
|
64633
|
+
"--shell <name>",
|
|
64634
|
+
"Check the ?? setup for this shell (zsh or bash; default: your login shell)"
|
|
64635
|
+
).action(async (options) => {
|
|
64636
|
+
await doctorCommand({ json: options.json, shell: options.shell });
|
|
64123
64637
|
});
|
|
64124
64638
|
cli.command("telemetry [action]", "Anonymous usage and error counts: status, on, off or show").action(async (action) => {
|
|
64125
64639
|
await telemetryCommand(action);
|